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,55 @@
|
|
|
1
|
+
@import "../common/abstracts/variable";
|
|
2
|
+
@import "../common/abstracts/mixin";
|
|
3
|
+
|
|
4
|
+
.oxy-theme-dark {
|
|
5
|
+
@include b(collapse) {
|
|
6
|
+
background: $-dark-background2;
|
|
7
|
+
|
|
8
|
+
@include e(content) {
|
|
9
|
+
color: $-dark-color3;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@include b(collapse) {
|
|
15
|
+
background: $-color-white;
|
|
16
|
+
|
|
17
|
+
@include when(viewmore) {
|
|
18
|
+
padding: $-collapse-side-padding;
|
|
19
|
+
}
|
|
20
|
+
@include e(content) {
|
|
21
|
+
font-size: $-collapse-body-fs;
|
|
22
|
+
color: $-collapse-body-color;
|
|
23
|
+
|
|
24
|
+
@include when(retract) {
|
|
25
|
+
display: -webkit-box;
|
|
26
|
+
-webkit-box-orient: vertical;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
font-size: $-collapse-retract-fs;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
@include e(more) {
|
|
32
|
+
display: inline-block;
|
|
33
|
+
font-size: $-collapse-retract-fs;
|
|
34
|
+
margin-top: 8px;
|
|
35
|
+
color: $-collapse-more-color;
|
|
36
|
+
user-select: none;
|
|
37
|
+
}
|
|
38
|
+
@include e(more-txt) {
|
|
39
|
+
display: inline-block;
|
|
40
|
+
vertical-align: middle;
|
|
41
|
+
margin-right: 4px;
|
|
42
|
+
}
|
|
43
|
+
@include e(arrow) {
|
|
44
|
+
display: inline-block;
|
|
45
|
+
vertical-align: middle;
|
|
46
|
+
transition: transform 0.1s;
|
|
47
|
+
font-size: $-collapse-arrow-size;
|
|
48
|
+
height: $-collapse-arrow-size;
|
|
49
|
+
line-height: $-collapse-arrow-size;
|
|
50
|
+
|
|
51
|
+
@include when(retract) {
|
|
52
|
+
transform: rotate(-180deg);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="`oxy-collapse ${viewmore ? 'is-viewmore' : ''} ${customClass}`" :style="customStyle">
|
|
3
|
+
<!-- 普通或手风琴 -->
|
|
4
|
+
<block v-if="!viewmore">
|
|
5
|
+
<slot></slot>
|
|
6
|
+
</block>
|
|
7
|
+
<!-- 查看更多模式 -->
|
|
8
|
+
<view v-else>
|
|
9
|
+
<view
|
|
10
|
+
:class="`oxy-collapse__content ${!modelValue ? 'is-retract' : ''} `"
|
|
11
|
+
:style="`-webkit-line-clamp: ${contentLineNum}; -webkit-box-orient: vertical`"
|
|
12
|
+
>
|
|
13
|
+
<slot></slot>
|
|
14
|
+
</view>
|
|
15
|
+
<view class="oxy-collapse__more" @click="handleMore">
|
|
16
|
+
<!-- 自定义展开按钮 -->
|
|
17
|
+
<view v-if="useMoreSlot" :class="customMoreSlotClass">
|
|
18
|
+
<slot name="more"></slot>
|
|
19
|
+
</view>
|
|
20
|
+
<!-- 显示展开或折叠按钮 -->
|
|
21
|
+
<block v-else>
|
|
22
|
+
<span class="oxy-collapse__more-txt">{{ !modelValue ? translate('expand') : translate('retract') }}</span>
|
|
23
|
+
<view :class="`oxy-collapse__arrow ${modelValue ? 'is-retract' : ''}`">
|
|
24
|
+
<oxy-icon name="arrow-down"></oxy-icon>
|
|
25
|
+
</view>
|
|
26
|
+
</block>
|
|
27
|
+
</view>
|
|
28
|
+
</view>
|
|
29
|
+
</view>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<script lang="ts">
|
|
33
|
+
export default {
|
|
34
|
+
name: 'oxy-collapse',
|
|
35
|
+
options: {
|
|
36
|
+
addGlobalClass: true,
|
|
37
|
+
virtualHost: true,
|
|
38
|
+
styleIsolation: 'shared'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<script lang="ts" setup>
|
|
44
|
+
import OxyIcon from '../oxy-icon/oxy-icon.vue'
|
|
45
|
+
import { onBeforeMount, ref, watch } from 'vue'
|
|
46
|
+
import { COLLAPSE_KEY, collapseProps, type CollapseExpose, type CollapseToggleAllOptions } from './types'
|
|
47
|
+
import { useChildren } from '../composables/useChildren'
|
|
48
|
+
import { isArray, isBoolean, isDef } from '../common/util'
|
|
49
|
+
import { useTranslate } from '../composables/useTranslate'
|
|
50
|
+
|
|
51
|
+
const props = defineProps(collapseProps)
|
|
52
|
+
const emit = defineEmits(['change', 'update:modelValue'])
|
|
53
|
+
|
|
54
|
+
const { translate } = useTranslate('collapse')
|
|
55
|
+
const contentLineNum = ref<number>(0) // 查看更多的折叠面板,收起时的显示行数
|
|
56
|
+
|
|
57
|
+
const { linkChildren, children } = useChildren(COLLAPSE_KEY)
|
|
58
|
+
|
|
59
|
+
linkChildren({ props, toggle })
|
|
60
|
+
|
|
61
|
+
watch(
|
|
62
|
+
() => props.modelValue,
|
|
63
|
+
(newVal) => {
|
|
64
|
+
const { viewmore, accordion } = props
|
|
65
|
+
// 手风琴状态下 value 类型只能为 string
|
|
66
|
+
if (accordion && typeof newVal !== 'string') {
|
|
67
|
+
console.error('accordion value must be string')
|
|
68
|
+
} else if (!accordion && !viewmore && !isArray(newVal)) {
|
|
69
|
+
console.error('value must be Array')
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{ deep: true }
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
watch(
|
|
76
|
+
() => props.lineNum,
|
|
77
|
+
(newVal) => {
|
|
78
|
+
if (newVal <= 0) {
|
|
79
|
+
console.error('lineNum must greater than 0')
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{ deep: true, immediate: true }
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
onBeforeMount(() => {
|
|
86
|
+
const { lineNum, viewmore, modelValue } = props
|
|
87
|
+
contentLineNum.value = viewmore && !modelValue ? lineNum : 0
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
function updateChange(activeNames: string | string[] | boolean) {
|
|
91
|
+
emit('update:modelValue', activeNames)
|
|
92
|
+
emit('change', {
|
|
93
|
+
value: activeNames
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function toggle(name: string, expanded: boolean) {
|
|
98
|
+
const { accordion, modelValue } = props
|
|
99
|
+
if (accordion) {
|
|
100
|
+
updateChange(name === modelValue ? '' : name)
|
|
101
|
+
} else if (expanded) {
|
|
102
|
+
updateChange((modelValue as string[]).concat(name))
|
|
103
|
+
} else {
|
|
104
|
+
updateChange((modelValue as string[]).filter((activeName) => activeName !== name))
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 切换所有面板展开状态,传 true 为全部展开,false 为全部收起,不传参为全部切换
|
|
110
|
+
* @param options 面板状态
|
|
111
|
+
*/
|
|
112
|
+
const toggleAll = (options: CollapseToggleAllOptions = {}) => {
|
|
113
|
+
if (props.accordion) {
|
|
114
|
+
return
|
|
115
|
+
}
|
|
116
|
+
if (isBoolean(options)) {
|
|
117
|
+
options = { expanded: options }
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const { expanded, skipDisabled } = options
|
|
121
|
+
const names: string[] = []
|
|
122
|
+
children.forEach((item, index) => {
|
|
123
|
+
if (item.disabled && skipDisabled) {
|
|
124
|
+
if (item.$.exposed!.getExpanded()) {
|
|
125
|
+
names.push(item.name || index)
|
|
126
|
+
}
|
|
127
|
+
} else if (isDef(expanded) ? expanded : !item.$.exposed!.getExpanded()) {
|
|
128
|
+
names.push(item.name || index)
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
updateChange(names)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* 查看更多点击
|
|
136
|
+
*/
|
|
137
|
+
function handleMore() {
|
|
138
|
+
emit('update:modelValue', !props.modelValue)
|
|
139
|
+
emit('change', {
|
|
140
|
+
value: !props.modelValue
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
defineExpose<CollapseExpose>({
|
|
145
|
+
toggleAll
|
|
146
|
+
})
|
|
147
|
+
</script>
|
|
148
|
+
|
|
149
|
+
<style lang="scss" scoped>
|
|
150
|
+
@import './index.scss';
|
|
151
|
+
</style>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type ComponentPublicInstance, type ExtractPropTypes, type InjectionKey, type PropType } from 'vue'
|
|
2
|
+
import { baseProps, makeBooleanProp, makeNumberProp, makeStringProp } from '../common/props'
|
|
3
|
+
|
|
4
|
+
export type CollapseToggleAllOptions =
|
|
5
|
+
| boolean
|
|
6
|
+
| {
|
|
7
|
+
expanded?: boolean
|
|
8
|
+
skipDisabled?: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type CollapseProvide = {
|
|
12
|
+
props: Partial<CollapseProps>
|
|
13
|
+
toggle: (name: string, expanded: boolean) => void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const COLLAPSE_KEY: InjectionKey<CollapseProvide> = Symbol('oxy-collapse')
|
|
17
|
+
|
|
18
|
+
export const collapseProps = {
|
|
19
|
+
...baseProps,
|
|
20
|
+
/**
|
|
21
|
+
* 查看更多模式下的插槽外部自定义样式
|
|
22
|
+
*/
|
|
23
|
+
customMoreSlotClass: makeStringProp(''),
|
|
24
|
+
/**
|
|
25
|
+
* 绑定值
|
|
26
|
+
*/
|
|
27
|
+
modelValue: {
|
|
28
|
+
type: [String, Array, Boolean] as PropType<string | Array<string> | boolean>
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* 手风琴模式
|
|
32
|
+
*/
|
|
33
|
+
accordion: makeBooleanProp(false),
|
|
34
|
+
/**
|
|
35
|
+
* 查看更多的折叠面板
|
|
36
|
+
*/
|
|
37
|
+
viewmore: makeBooleanProp(false),
|
|
38
|
+
/**
|
|
39
|
+
* 查看更多的自定义插槽使用标志
|
|
40
|
+
*/
|
|
41
|
+
useMoreSlot: makeBooleanProp(false),
|
|
42
|
+
/**
|
|
43
|
+
* 查看更多的折叠面板,收起时的显示行数
|
|
44
|
+
*/
|
|
45
|
+
lineNum: makeNumberProp(2)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type CollapseProps = ExtractPropTypes<typeof collapseProps>
|
|
49
|
+
|
|
50
|
+
export type CollapseExpose = {
|
|
51
|
+
/**
|
|
52
|
+
* 切换所有面板展开状态,传 true 为全部展开,false 为全部收起,不传参为全部切换
|
|
53
|
+
* @param options 面板状态
|
|
54
|
+
*/
|
|
55
|
+
toggleAll: (options?: CollapseToggleAllOptions) => void
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type CollapseInstance = ComponentPublicInstance<CollapseProps, CollapseExpose>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
@import '../common/abstracts/variable';
|
|
2
|
+
@import '../common/abstracts/mixin';
|
|
3
|
+
|
|
4
|
+
.oxy-theme-dark {
|
|
5
|
+
@include b(collapse-item) {
|
|
6
|
+
@include halfPixelBorder('top', 0, $-dark-border-color);
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@include e(title) {
|
|
10
|
+
color: $-dark-color;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@include e(body) {
|
|
14
|
+
color: $-dark-color3;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@include when(disabled) {
|
|
18
|
+
.oxy-collapse-item__title {
|
|
19
|
+
color: $-dark-color-gray;
|
|
20
|
+
}
|
|
21
|
+
.oxy-collapse-item__arrow {
|
|
22
|
+
color: $-dark-color-gray;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@include b(collapse-item) {
|
|
30
|
+
position: relative;
|
|
31
|
+
@include halfPixelBorder('top');
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@include e(header) {
|
|
35
|
+
position: relative;
|
|
36
|
+
display: flex;
|
|
37
|
+
justify-content: space-between;
|
|
38
|
+
align-items: center;
|
|
39
|
+
padding: $-collapse-header-padding;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
user-select: none;
|
|
42
|
+
|
|
43
|
+
@include when(expanded) {
|
|
44
|
+
@include halfPixelBorder('bottom');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@include when(custom) {
|
|
48
|
+
display: block;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@include e(title) {
|
|
53
|
+
color: $-collapse-title-color;
|
|
54
|
+
font-weight: $-fw-medium;
|
|
55
|
+
font-size: $-collapse-title-fs;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@include edeep(arrow) {
|
|
59
|
+
display: block;
|
|
60
|
+
font-size: $-collapse-arrow-size;
|
|
61
|
+
color: $-collapse-arrow-color;
|
|
62
|
+
transition: transform 0.3s;
|
|
63
|
+
|
|
64
|
+
@include when(retract) {
|
|
65
|
+
transform: rotate(-180deg);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@include e(wrapper) {
|
|
70
|
+
position: relative;
|
|
71
|
+
overflow: hidden;
|
|
72
|
+
will-change: height;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@include e(body) {
|
|
76
|
+
color: $-collapse-body-color;
|
|
77
|
+
font-size: $-collapse-body-fs;
|
|
78
|
+
padding: $-collapse-body-padding;
|
|
79
|
+
line-height: 1.43;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@include when(disabled) {
|
|
83
|
+
.oxy-collapse-item__title {
|
|
84
|
+
color: $-collapse-disabled-color;
|
|
85
|
+
}
|
|
86
|
+
.oxy-collapse-item__arrow {
|
|
87
|
+
color: $-collapse-disabled-color;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="`oxy-collapse-item ${disabled ? 'is-disabled' : ''} is-border ${customClass}`" :style="customStyle">
|
|
3
|
+
<view
|
|
4
|
+
:class="`oxy-collapse-item__header ${expanded ? 'is-expanded' : ''} ${isFirst ? 'oxy-collapse-item__header-first' : ''} ${
|
|
5
|
+
$slots.title ? 'is-custom' : ''
|
|
6
|
+
}`"
|
|
7
|
+
@click="handleClick"
|
|
8
|
+
>
|
|
9
|
+
<slot name="title" :expanded="expanded" :disabled="disabled" :isFirst="isFirst">
|
|
10
|
+
<text class="oxy-collapse-item__title">{{ title }}</text>
|
|
11
|
+
<oxy-icon name="arrow-down" :custom-class="`oxy-collapse-item__arrow ${expanded ? 'is-retract' : ''}`" />
|
|
12
|
+
</slot>
|
|
13
|
+
</view>
|
|
14
|
+
<view class="oxy-collapse-item__wrapper" :style="contentStyle" @transitionend="handleTransitionEnd">
|
|
15
|
+
<view class="oxy-collapse-item__body" :class="customBodyClass" :style="customBodyStyle" :id="collapseId">
|
|
16
|
+
<slot />
|
|
17
|
+
</view>
|
|
18
|
+
</view>
|
|
19
|
+
</view>
|
|
20
|
+
</template>
|
|
21
|
+
<script lang="ts">
|
|
22
|
+
export default {
|
|
23
|
+
name: 'oxy-collapse-item',
|
|
24
|
+
options: {
|
|
25
|
+
addGlobalClass: true,
|
|
26
|
+
virtualHost: true,
|
|
27
|
+
styleIsolation: 'shared'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<script lang="ts" setup>
|
|
33
|
+
import OxyIcon from '../oxy-icon/oxy-icon.vue'
|
|
34
|
+
import { computed, getCurrentInstance, onMounted, ref, watch, type CSSProperties } from 'vue'
|
|
35
|
+
import { addUnit, getRect, isArray, isDef, isPromise, isString, objToStyle, pause, uuid } from '../common/util'
|
|
36
|
+
import { useParent } from '../composables/useParent'
|
|
37
|
+
import { COLLAPSE_KEY } from '../oxy-collapse/types'
|
|
38
|
+
import { collapseItemProps, type CollapseItemExpose } from './types'
|
|
39
|
+
|
|
40
|
+
const collapseId = ref<string>(`collapseId${uuid()}`)
|
|
41
|
+
|
|
42
|
+
const props = defineProps(collapseItemProps)
|
|
43
|
+
|
|
44
|
+
const { parent: collapse, index } = useParent(COLLAPSE_KEY)
|
|
45
|
+
|
|
46
|
+
const height = ref<string | number>('')
|
|
47
|
+
const inited = ref<boolean>(false)
|
|
48
|
+
const expanded = ref<boolean>(false)
|
|
49
|
+
const { proxy } = getCurrentInstance() as any
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 容器样式,(动画)
|
|
53
|
+
*/
|
|
54
|
+
const isFirst = computed(() => {
|
|
55
|
+
return index.value === 0
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 容器样式,(动画)
|
|
60
|
+
*/
|
|
61
|
+
const contentStyle = computed(() => {
|
|
62
|
+
const style: CSSProperties = {}
|
|
63
|
+
if (inited.value) {
|
|
64
|
+
style.transition = 'height 0.3s ease-in-out'
|
|
65
|
+
}
|
|
66
|
+
if (!expanded.value) {
|
|
67
|
+
style.height = '0px'
|
|
68
|
+
} else if (height.value) {
|
|
69
|
+
style.height = addUnit(height.value)
|
|
70
|
+
}
|
|
71
|
+
return objToStyle(style)
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 是否选中
|
|
76
|
+
*/
|
|
77
|
+
const isSelected = computed(() => {
|
|
78
|
+
const modelValue = collapse ? collapse?.props.modelValue || [] : []
|
|
79
|
+
const { name } = props
|
|
80
|
+
return (isString(modelValue) && modelValue === name) || (isArray(modelValue) && modelValue.indexOf(name as string) >= 0)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
watch(
|
|
84
|
+
() => isSelected.value,
|
|
85
|
+
(newVal) => {
|
|
86
|
+
updateExpand(newVal)
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
onMounted(() => {
|
|
91
|
+
updateExpand(isSelected.value)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
async function updateExpand(useBeforeExpand: boolean = true) {
|
|
95
|
+
try {
|
|
96
|
+
if (useBeforeExpand) {
|
|
97
|
+
await handleBeforeExpand()
|
|
98
|
+
}
|
|
99
|
+
initRect()
|
|
100
|
+
} catch (error) {
|
|
101
|
+
/* empty */
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function initRect() {
|
|
106
|
+
getRect(`#${collapseId.value}`, false, proxy).then(async (rect) => {
|
|
107
|
+
const { height: rectHeight } = rect
|
|
108
|
+
height.value = isDef(rectHeight) ? Number(rectHeight) : ''
|
|
109
|
+
await pause()
|
|
110
|
+
if (isSelected.value) {
|
|
111
|
+
expanded.value = true
|
|
112
|
+
} else {
|
|
113
|
+
expanded.value = false
|
|
114
|
+
}
|
|
115
|
+
if (!inited.value) {
|
|
116
|
+
inited.value = true
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function handleTransitionEnd() {
|
|
122
|
+
if (expanded.value) {
|
|
123
|
+
height.value = ''
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// 点击子项
|
|
128
|
+
async function handleClick() {
|
|
129
|
+
if (props.disabled) return
|
|
130
|
+
try {
|
|
131
|
+
await updateExpand()
|
|
132
|
+
const { name } = props
|
|
133
|
+
collapse && collapse.toggle(name, !expanded.value)
|
|
134
|
+
} catch (error) {
|
|
135
|
+
/* empty */
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 展开前钩子
|
|
141
|
+
*/
|
|
142
|
+
function handleBeforeExpand() {
|
|
143
|
+
return new Promise<void>((resolve, reject) => {
|
|
144
|
+
const { name } = props
|
|
145
|
+
const nextexpanded = !expanded.value
|
|
146
|
+
if (nextexpanded && props.beforeExpend) {
|
|
147
|
+
const response = props.beforeExpend(name)
|
|
148
|
+
if (!response) {
|
|
149
|
+
reject()
|
|
150
|
+
}
|
|
151
|
+
if (isPromise(response)) {
|
|
152
|
+
response.then(() => resolve()).catch(reject)
|
|
153
|
+
} else {
|
|
154
|
+
resolve()
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
resolve()
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function getExpanded() {
|
|
163
|
+
return expanded.value
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
defineExpose<CollapseItemExpose>({ getExpanded, updateExpand })
|
|
167
|
+
</script>
|
|
168
|
+
|
|
169
|
+
<style lang="scss" scoped>
|
|
170
|
+
@import './index.scss';
|
|
171
|
+
</style>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ComponentPublicInstance, ExtractPropTypes, PropType } from 'vue'
|
|
2
|
+
import { baseProps, makeBooleanProp, makeRequiredProp, makeStringProp } from '../common/props'
|
|
3
|
+
|
|
4
|
+
export type CollapseItemBeforeExpand = (name: string) => boolean | Promise<unknown>
|
|
5
|
+
|
|
6
|
+
export const collapseItemProps = {
|
|
7
|
+
...baseProps,
|
|
8
|
+
/**
|
|
9
|
+
* 自定义折叠栏内容容器样式类名
|
|
10
|
+
*/
|
|
11
|
+
customBodyClass: makeStringProp(''),
|
|
12
|
+
/**
|
|
13
|
+
* 自定义折叠栏内容容器样式
|
|
14
|
+
*/
|
|
15
|
+
customBodyStyle: makeStringProp(''),
|
|
16
|
+
/**
|
|
17
|
+
* 折叠栏的标题, 可通过 slot 传递自定义内容
|
|
18
|
+
*/
|
|
19
|
+
title: makeStringProp(''),
|
|
20
|
+
/**
|
|
21
|
+
* 禁用折叠栏
|
|
22
|
+
*/
|
|
23
|
+
disabled: makeBooleanProp(false),
|
|
24
|
+
/**
|
|
25
|
+
* 折叠栏的标识符
|
|
26
|
+
*/
|
|
27
|
+
name: makeRequiredProp(String),
|
|
28
|
+
/**
|
|
29
|
+
* 打开前的回调函数,返回 false 可以阻止打开,支持返回 Promise
|
|
30
|
+
*/
|
|
31
|
+
beforeExpend: Function as PropType<CollapseItemBeforeExpand>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type CollapseItemProps = ExtractPropTypes<typeof collapseItemProps>
|
|
35
|
+
|
|
36
|
+
export type CollapseItemExpose = {
|
|
37
|
+
/**
|
|
38
|
+
* 获取展开状态
|
|
39
|
+
* @returns boolean
|
|
40
|
+
*/
|
|
41
|
+
getExpanded: () => boolean
|
|
42
|
+
/**
|
|
43
|
+
* 更新展开状态
|
|
44
|
+
*/
|
|
45
|
+
updateExpand: () => Promise<void>
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type CollapseItemInstance = ComponentPublicInstance<CollapseItemProps, CollapseItemExpose>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="themeClass" :style="themeStyle">
|
|
3
|
+
<slot />
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
export default {
|
|
9
|
+
name: 'oxy-config-provider',
|
|
10
|
+
options: {
|
|
11
|
+
virtualHost: true,
|
|
12
|
+
addGlobalClass: true,
|
|
13
|
+
styleIsolation: 'shared'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<script lang="ts" setup>
|
|
19
|
+
import { computed } from 'vue'
|
|
20
|
+
import { configProviderProps } from './types'
|
|
21
|
+
import { objToStyle } from '../common/util'
|
|
22
|
+
|
|
23
|
+
const props = defineProps(configProviderProps)
|
|
24
|
+
|
|
25
|
+
const themeClass = computed(() => {
|
|
26
|
+
return `oxy-theme-${props.theme} ${props.customClass}`
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const themeStyle = computed(() => {
|
|
30
|
+
const styleObj = mapThemeVarsToCSSVars(props.themeVars)
|
|
31
|
+
return styleObj ? `${objToStyle(styleObj)}${props.customStyle}` : props.customStyle
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const kebabCase = (str: string): string => {
|
|
35
|
+
str = str.replace(str.charAt(0), str.charAt(0).toLocaleLowerCase())
|
|
36
|
+
return str.replace(/([a-z])([A-Z])/g, (_, p1, p2) => p1 + '-' + p2.toLowerCase())
|
|
37
|
+
}
|
|
38
|
+
const colorRgb = (str: string) => {
|
|
39
|
+
if (!str) return
|
|
40
|
+
var sColor = str.toLowerCase()
|
|
41
|
+
//十六进制颜色值的正则表达式
|
|
42
|
+
var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/
|
|
43
|
+
// 如果是16进制颜色
|
|
44
|
+
if (sColor && reg.test(sColor)) {
|
|
45
|
+
if (sColor.length === 4) {
|
|
46
|
+
var sColorNew = '#'
|
|
47
|
+
for (let i = 1; i < 4; i += 1) {
|
|
48
|
+
sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1))
|
|
49
|
+
}
|
|
50
|
+
sColor = sColorNew
|
|
51
|
+
}
|
|
52
|
+
//处理六位的颜色值
|
|
53
|
+
var sColorChange: number[] = []
|
|
54
|
+
for (let i = 1; i < 7; i += 2) {
|
|
55
|
+
sColorChange.push(parseInt('0x' + sColor.slice(i, i + 2)))
|
|
56
|
+
}
|
|
57
|
+
return sColorChange.join(',')
|
|
58
|
+
}
|
|
59
|
+
return null
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const mapThemeVarsToCSSVars = (themeVars: Record<string, string>) => {
|
|
63
|
+
if (!themeVars) return
|
|
64
|
+
const cssVars: Record<string, string> = {}
|
|
65
|
+
Object.keys(themeVars).forEach((key) => {
|
|
66
|
+
cssVars[`--oxy-${kebabCase(key)}`] = themeVars[key]
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
return cssVars
|
|
70
|
+
}
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
<style lang="scss" scoped></style>
|