@didaoktv/didaoui-uniapp 2.12.0 → 2.13.0
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/README.md +2 -2
- package/components/dd-fold/dd-fold.vue +133 -0
- package/index.ts +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
- **帝王级配色** — 帝王金 `#F5A623` + 皇家蓝 `#2D4BA0` 双主色,暗色主题默认
|
|
8
8
|
- **玻璃拟态设计** — 多层级玻璃拟态效果,打造高端夜店沉浸感
|
|
9
|
-
- **
|
|
9
|
+
- **99 个精心打磨的组件** — 覆盖表单、导航、布局卡片、数据展示、浮层反馈、交互、画布七大类,含 KTV 业务组件(房态卡、账单明细、工单卡、日历、二维码)
|
|
10
10
|
- **Vue3 + TypeScript** — 完整类型定义,Composition API
|
|
11
11
|
- **多端兼容** — H5 / 微信小程序 / 抖音小程序 / Android / iOS
|
|
12
12
|
|
|
@@ -53,7 +53,7 @@ import { DdButton, DdInput } from '@didaoktv/didaoui-uniapp'
|
|
|
53
53
|
| 表单输入 | 25 | Button, CodeButton, Input, Form, Field, Switch, Checkbox, CheckboxGroup, Radio, RadioGroup, Stepper, SearchBar, Slider, DatePicker, Picker, Rate, Upload, Icon, Keyboard, NumberKeyboard, CarKeyboard, Cascader, GoodsSku, PackageSku, TreeSelect |
|
|
54
54
|
| 导航 | 14 | Navigation, TopNavbar, SegmentedTab, SwipeableTab, Drawer, Tabbar, TabbarItem, Backtop, Collapse, CollapseItem, DropdownMenu, DropdownItem, Sidebar, SidebarItem | |
|
|
55
55
|
| 布局/卡片 | 11 | Card, RoomCard, GoodsCard, FeatureGrid, Sticky, BillDetail, WorkorderCard, Calendar, Qrcode, SubmitBar, CartBar |
|
|
56
|
-
| 数据展示 |
|
|
56
|
+
| 数据展示 | 26 | Tag, StatCard, ChampionCard, Avatar, AvatarGroup, Badge, ListCell, Cell, CellGroup, Fold, CountDown, Divider, Image, Progress, Skeleton, EmptyState, Step, Steps, Text, Link, Copy, Album, Coupon, Parse, Markdown, Price |
|
|
57
57
|
| 浮层反馈 | 11 | Modal, ActionSheet, Toast, Alert, Loading, Dialog, Overlay, Popup, Popover, PopoverItem, Portal |
|
|
58
58
|
| 交互 | 5 | SwipeAction, Swipe, SwipeItem, PullRefresh, Loadmore |
|
|
59
59
|
| 小程序专属 | 2 | CapsuleButton, MiniProgramNavbar |
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="dd-fold">
|
|
3
|
+
<view class="dd-fold__clip" :style="clipStyle">
|
|
4
|
+
<view class="dd-fold__body">
|
|
5
|
+
<slot />
|
|
6
|
+
</view>
|
|
7
|
+
<view v-if="clamped" class="dd-fold__fade" :style="fadeStyle" />
|
|
8
|
+
</view>
|
|
9
|
+
<view v-if="overflow" class="dd-fold__toggle" @tap.stop="onToggle">
|
|
10
|
+
<text class="dd-fold__toggle-text">{{ expanded ? collapseText : expandText }}</text>
|
|
11
|
+
<dd-icon :name="expanded ? 'arrow-up' : 'arrow-down'" class="dd-fold__icon" />
|
|
12
|
+
</view>
|
|
13
|
+
</view>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
import { computed, getCurrentInstance, nextTick, onMounted, ref, watch } from 'vue'
|
|
18
|
+
import DdIcon from '../dd-icon/dd-icon.vue'
|
|
19
|
+
|
|
20
|
+
interface Props {
|
|
21
|
+
/** 展开态,配合 v-model:expanded 受控(组件本身不做内部状态) */
|
|
22
|
+
expanded?: boolean
|
|
23
|
+
/** 折叠高度(rpx),内容自然高度超过它才折叠 */
|
|
24
|
+
maxHeight?: number
|
|
25
|
+
/** 底部渐变高度(rpx) */
|
|
26
|
+
fadeHeight?: number
|
|
27
|
+
/** 渐变终色,默认取页面底色 token;与所在区域底色不一致时传入 */
|
|
28
|
+
fadeColor?: string
|
|
29
|
+
expandText?: string
|
|
30
|
+
collapseText?: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
34
|
+
expanded: false,
|
|
35
|
+
maxHeight: 320,
|
|
36
|
+
fadeHeight: 96,
|
|
37
|
+
fadeColor: '',
|
|
38
|
+
expandText: '展开详情',
|
|
39
|
+
collapseText: '收起',
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
const emit = defineEmits<{
|
|
43
|
+
(e: 'update:expanded', val: boolean): void
|
|
44
|
+
(e: 'toggle', val: boolean): void
|
|
45
|
+
}>()
|
|
46
|
+
|
|
47
|
+
const instance = getCurrentInstance()
|
|
48
|
+
/** 内容自然高度是否超过 maxHeight(低于则完全不折叠,不出现渐变与入口) */
|
|
49
|
+
const overflow = ref(false)
|
|
50
|
+
|
|
51
|
+
const clamped = computed(() => overflow.value && !props.expanded)
|
|
52
|
+
|
|
53
|
+
const clipStyle = computed(() =>
|
|
54
|
+
clamped.value ? `max-height: ${props.maxHeight}rpx;` : '',
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
const fadeStyle = computed(() => {
|
|
58
|
+
const to = props.fadeColor || 'var(--dd-bg-section, #6b7280)'
|
|
59
|
+
return `height: ${props.fadeHeight}rpx; background: linear-gradient(to bottom, transparent, ${to} 78%);`
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
/** 量内容自然高度(父级 max-height/overflow 不改变子元素自身高度);rpx→px 用平台换算,各端阈值一致 */
|
|
63
|
+
function measure(): void {
|
|
64
|
+
const ctx = instance?.proxy
|
|
65
|
+
if (!ctx) return
|
|
66
|
+
uni
|
|
67
|
+
.createSelectorQuery()
|
|
68
|
+
.in(ctx)
|
|
69
|
+
.select('.dd-fold__body')
|
|
70
|
+
.boundingClientRect((rect) => {
|
|
71
|
+
const height = (rect as { height?: number } | null)?.height ?? 0
|
|
72
|
+
overflow.value = height > uni.upx2px(props.maxHeight) + 0.5
|
|
73
|
+
})
|
|
74
|
+
.exec()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** 手动重量:插槽内容异步变化(加载更多、图片就绪等)后调用 */
|
|
78
|
+
defineExpose({ measure })
|
|
79
|
+
|
|
80
|
+
function onToggle(): void {
|
|
81
|
+
const next = !props.expanded
|
|
82
|
+
emit('update:expanded', next)
|
|
83
|
+
emit('toggle', next)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// 首屏等一帧布局落定再量(小程序端 nextTick 早于布局)
|
|
87
|
+
onMounted(() => {
|
|
88
|
+
nextTick(() => setTimeout(measure, 60))
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
watch(
|
|
92
|
+
() => props.maxHeight,
|
|
93
|
+
() => nextTick(measure),
|
|
94
|
+
)
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
<style lang="scss" scoped>
|
|
98
|
+
@import '../../scss/variables';
|
|
99
|
+
@import '../../scss/mixins';
|
|
100
|
+
|
|
101
|
+
.dd-fold {
|
|
102
|
+
width: 100%;
|
|
103
|
+
|
|
104
|
+
&__clip {
|
|
105
|
+
position: relative;
|
|
106
|
+
width: 100%;
|
|
107
|
+
overflow: hidden;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&__fade {
|
|
111
|
+
position: absolute;
|
|
112
|
+
right: 0;
|
|
113
|
+
bottom: 0;
|
|
114
|
+
left: 0;
|
|
115
|
+
pointer-events: none;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
&__toggle {
|
|
119
|
+
display: flex;
|
|
120
|
+
align-items: center;
|
|
121
|
+
justify-content: center;
|
|
122
|
+
gap: $dd-space-1;
|
|
123
|
+
padding-top: $dd-space-1;
|
|
124
|
+
font-size: $dd-font-size-caption;
|
|
125
|
+
line-height: $dd-line-height-caption;
|
|
126
|
+
color: var(--dd-primary-400, #{$dd-primary-400});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
&__icon {
|
|
130
|
+
font-size: 1em;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
</style>
|
package/index.ts
CHANGED
|
@@ -57,7 +57,7 @@ import DdQrcode from './components/dd-qrcode/dd-qrcode.vue'
|
|
|
57
57
|
import DdSubmitBar from './components/dd-submit-bar/dd-submit-bar.vue'
|
|
58
58
|
import DdCartBar from './components/dd-cart-bar/dd-cart-bar.vue'
|
|
59
59
|
|
|
60
|
-
// === Display (
|
|
60
|
+
// === Display (26) ===
|
|
61
61
|
import DdTag from './components/dd-tag/dd-tag.vue'
|
|
62
62
|
import DdStatCard from './components/dd-stat-card/dd-stat-card.vue'
|
|
63
63
|
import DdChampionCard from './components/dd-champion-card/dd-champion-card.vue'
|
|
@@ -67,6 +67,7 @@ import DdBadge from './components/dd-badge/dd-badge.vue'
|
|
|
67
67
|
import DdListCell from './components/dd-list-cell/dd-list-cell.vue'
|
|
68
68
|
import DdCell from './components/dd-cell/dd-cell.vue'
|
|
69
69
|
import DdCellGroup from './components/dd-cell-group/dd-cell-group.vue'
|
|
70
|
+
import DdFold from './components/dd-fold/dd-fold.vue'
|
|
70
71
|
import DdCountDown from './components/dd-count-down/dd-count-down.vue'
|
|
71
72
|
import DdDivider from './components/dd-divider/dd-divider.vue'
|
|
72
73
|
import DdImage from './components/dd-image/dd-image.vue'
|
|
@@ -128,7 +129,7 @@ const components = {
|
|
|
128
129
|
DdSubmitBar,
|
|
129
130
|
DdCartBar,
|
|
130
131
|
DdTag, DdStatCard, DdChampionCard, DdAvatar, DdAvatarGroup, DdBadge,
|
|
131
|
-
DdListCell, DdCell, DdCellGroup, DdCountDown, DdDivider,
|
|
132
|
+
DdListCell, DdCell, DdCellGroup, DdFold, DdCountDown, DdDivider,
|
|
132
133
|
DdImage, DdProgress, DdSkeleton, DdEmptyState, DdStep, DdSteps,
|
|
133
134
|
DdText, DdLink, DdCopy, DdAlbum, DdCoupon, DdParse, DdMarkdown, DdPrice,
|
|
134
135
|
DdModal, DdActionSheet, DdToast, DdAlert, DdLoading,
|
|
@@ -161,7 +162,7 @@ export {
|
|
|
161
162
|
DdSubmitBar,
|
|
162
163
|
DdCartBar,
|
|
163
164
|
DdTag, DdStatCard, DdChampionCard, DdAvatar, DdAvatarGroup, DdBadge,
|
|
164
|
-
DdListCell, DdCell, DdCellGroup, DdCountDown, DdDivider,
|
|
165
|
+
DdListCell, DdCell, DdCellGroup, DdFold, DdCountDown, DdDivider,
|
|
165
166
|
DdImage, DdProgress, DdSkeleton, DdEmptyState, DdStep, DdSteps,
|
|
166
167
|
DdText, DdLink, DdCopy, DdAlbum, DdCoupon, DdParse, DdMarkdown, DdPrice,
|
|
167
168
|
DdModal, DdActionSheet, DdToast, DdAlert, DdLoading,
|