@didaoktv/didaoui-uniapp 2.13.0 → 2.15.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.
Files changed (69) hide show
  1. package/README.md +6 -6
  2. package/components/dd-album/dd-album.vue +280 -228
  3. package/components/dd-avatar/dd-avatar.vue +132 -75
  4. package/components/dd-avatar-group/dd-avatar-group.vue +52 -30
  5. package/components/dd-barcode/dd-barcode.vue +884 -947
  6. package/components/dd-button/dd-button.vue +47 -21
  7. package/components/dd-canvas/dd-canvas.vue +1156 -985
  8. package/components/dd-car-keyboard/dd-car-keyboard.vue +12 -12
  9. package/components/dd-champion-card/dd-champion-card.vue +49 -21
  10. package/components/dd-checkbox-group/dd-checkbox-group.vue +2 -0
  11. package/components/dd-copy/dd-copy.vue +51 -56
  12. package/components/dd-cropper/dd-cropper.vue +1224 -1135
  13. package/components/dd-divider/dd-divider.vue +9 -2
  14. package/components/dd-form/dd-form.vue +2 -0
  15. package/components/dd-goods-sku/dd-goods-sku.vue +6 -1
  16. package/components/dd-icon/dd-icon.vue +1 -1
  17. package/components/dd-keyboard/dd-keyboard.vue +95 -46
  18. package/components/dd-link/dd-link.vue +72 -49
  19. package/components/dd-markdown/dd-markdown.vue +154 -154
  20. package/components/dd-number-keyboard/dd-number-keyboard.vue +109 -94
  21. package/components/dd-package-sku/dd-package-sku.vue +24 -1
  22. package/components/dd-parse/dd-parse.vue +473 -442
  23. package/components/dd-poster/dd-poster.vue +579 -567
  24. package/components/dd-pull-refresh/dd-pull-refresh.vue +1 -9
  25. package/components/dd-qrcode/dd-qrcode.vue +431 -405
  26. package/components/dd-radio-group/dd-radio-group.vue +1 -1
  27. package/components/dd-segmented-tab/dd-segmented-tab.vue +61 -16
  28. package/components/dd-signature/dd-signature.vue +377 -357
  29. package/components/dd-step/dd-step.vue +1 -1
  30. package/components/dd-sticky/dd-sticky.vue +5 -10
  31. package/components/dd-swipe-action/dd-swipe-action.vue +1 -9
  32. package/components/dd-swipe-item/dd-swipe-item.vue +2 -0
  33. package/components/dd-swipeable-tab/dd-swipeable-tab.vue +1 -5
  34. package/components/dd-switch/dd-switch.vue +1 -1
  35. package/components/dd-text/dd-text.vue +304 -82
  36. package/components/dd-waterfall/dd-waterfall.vue +147 -0
  37. package/components/dd-waterfall/waterfall.ts +17 -0
  38. package/index.ts +4 -3
  39. package/libs/function/index.d.ts +88 -0
  40. package/libs/function/index.js +14 -0
  41. package/libs/function/test.d.ts +65 -0
  42. package/package.json +1 -1
  43. package/scss/_mixins.scss +8 -0
  44. package/scss/_theme-tokens.scss +7 -0
  45. package/scss/_variables.scss +283 -156
  46. package/components/dd-album/album.js +0 -19
  47. package/components/dd-album/props.js +0 -89
  48. package/components/dd-avatar/avatar.js +0 -19
  49. package/components/dd-avatar/props.js +0 -84
  50. package/components/dd-avatar-group/avatarGroup.js +0 -14
  51. package/components/dd-avatar-group/props.js +0 -57
  52. package/components/dd-keyboard/keyboard.js +0 -19
  53. package/components/dd-keyboard/props.js +0 -79
  54. package/components/dd-link/link.js +0 -17
  55. package/components/dd-link/props.js +0 -44
  56. package/components/dd-number-keyboard/numberKeyboard.js +0 -8
  57. package/components/dd-number-keyboard/props.js +0 -24
  58. package/components/dd-parse/props.js +0 -57
  59. package/components/dd-text/props.js +0 -120
  60. package/components/dd-text/text.js +0 -30
  61. package/components/dd-text/value.js +0 -87
  62. package/libs/config/color.js +0 -16
  63. package/libs/config/props.js +0 -184
  64. package/libs/mixin/button.js +0 -18
  65. package/libs/mixin/mixin.js +0 -44
  66. package/libs/mixin/mpMixin.js +0 -13
  67. package/libs/mixin/openType.js +0 -27
  68. package/libs/vue.js +0 -3
  69. package/scss/_dd-shared.scss +0 -40
@@ -0,0 +1,147 @@
1
+ <template>
2
+ <view class="dd-waterfall" :class="customClass" :style="customStyle">
3
+ <view
4
+ v-for="(column, colIndex) in columnList"
5
+ :key="colIndex"
6
+ class="dd-waterfall__column"
7
+ :style="colIndex > 0 ? `margin-left: ${gap}rpx;` : ''"
8
+ >
9
+ <view
10
+ v-for="cell in column"
11
+ :key="cell.index"
12
+ class="dd-waterfall__item"
13
+ :id="itemId(cell.index)"
14
+ :style="`margin-bottom: ${gap}rpx;`"
15
+ >
16
+ <slot :item="cell.item" :index="cell.index" />
17
+ </view>
18
+ </view>
19
+ </view>
20
+ </template>
21
+
22
+ <script setup lang="ts">
23
+ import { computed, getCurrentInstance, nextTick, onMounted, ref, watch } from 'vue'
24
+ import { assignColumns } from './waterfall'
25
+
26
+ type WaterfallItem = Record<string, any>
27
+
28
+ interface Props {
29
+ /** 数据数组(v-model,只读消费;组件不修改它) */
30
+ modelValue?: WaterfallItem[]
31
+ /** 列数 */
32
+ columns?: number
33
+ /** 列间距与项间距(rpx) */
34
+ gap?: number
35
+ customStyle?: string
36
+ customClass?: string
37
+ }
38
+
39
+ const props = withDefaults(defineProps<Props>(), {
40
+ modelValue: () => [],
41
+ columns: 2,
42
+ gap: 16,
43
+ customStyle: '',
44
+ customClass: '',
45
+ })
46
+
47
+ interface Cell {
48
+ item: WaterfallItem
49
+ /** 在原数组中的下标(同时用作渲染 key 与插槽参数) */
50
+ index: number
51
+ }
52
+
53
+ const instance = getCurrentInstance()
54
+ /** 实例前缀:同一页面挂多个瀑布流时按 id 前缀串起「数据下标 → 视高」,
55
+ * 列内 DOM 顺序是列主序,不能靠 query 返回顺序对应数据顺序 */
56
+ const uid = `dd-wf-${Math.random().toString(36).slice(2, 8)}`
57
+
58
+ const columnCount = computed(() => Math.max(1, Math.floor(props.columns) || 1))
59
+
60
+ /** 每项所在列号(下标 = 数据下标):首屏按奇偶预排,量到视高后改为「谁矮进谁」 */
61
+ const columnOf = ref<number[]>([])
62
+
63
+ const itemId = (index: number): string => `${uid}-${index}`
64
+
65
+ const columnList = computed<Cell[][]>(() => {
66
+ const cols = Array.from({ length: columnCount.value }, () => [] as Cell[])
67
+ ;(props.modelValue || []).forEach((item, index) => {
68
+ const col = columnOf.value[index] ?? index % cols.length
69
+ cols[col].push({ item, index })
70
+ })
71
+ return cols
72
+ })
73
+
74
+ let measuring = false
75
+
76
+ /** 小程序 setData 后布局是异步的(H5 也得等一帧),量高前留出渲染窗口;uview 同款口径(默认 300ms) */
77
+ const MEASURE_DELAY = 200
78
+
79
+ /**
80
+ * 按「当前最矮列」落位:按数据顺序逐项找累计高度最小的列塞入。
81
+ * 这是瀑布流对不等高卡片的常规口径——列内独立堆叠不留整行空白,末项也会跟在较矮的那列下面。
82
+ * 量不到高度(0 高/容器不可见/布局未就绪)时整轮放弃,保留奇偶预排,避免把全部卡片挤进第一列。
83
+ * ponytail: 只在数据/列数变化时重量;卡片自己变高(如倒计时文案换行)不触发重排,需要时再说
84
+ */
85
+ function layout(): void {
86
+ const list = props.modelValue || []
87
+ if (!list.length || measuring) return
88
+ measuring = true
89
+ nextTick(() => {
90
+ setTimeout(() => {
91
+ const query = uni.createSelectorQuery().in(instance)
92
+ query.selectAll('.dd-waterfall__item').boundingClientRect()
93
+ query.exec((res) => {
94
+ measuring = false
95
+ const rects = ((res && res[0]) || []) as UniApp.NodeInfo[]
96
+ const heightById = new Map<string, number>()
97
+ for (const r of rects) {
98
+ if (r.id && r.id.startsWith(uid)) heightById.set(r.id, r.height || 0)
99
+ }
100
+ if (!heightById.size) return
101
+ // 全部量不到高(容器不可见/布局未就绪)才放弃整轮;个别 0 高按 0 参与计算,不影响其余项落位
102
+ let ready = 0
103
+ heightById.forEach((h) => {
104
+ if (h > 0) ready += 1
105
+ })
106
+ if (!ready) return
107
+ const gapPx = uni.upx2px(props.gap)
108
+ // 逐项进当前最矮列(纯逻辑在 waterfall.ts,附 scripts/waterfall-selfcheck.ts)
109
+ const next = assignColumns(
110
+ list.map((_, i) => heightById.get(itemId(i)) ?? 0),
111
+ columnCount.value,
112
+ gapPx,
113
+ )
114
+ // 结果没变就不触发重渲染,避免量高 → 重排 → 再量高的循环
115
+ const same = next.length === columnOf.value.length && next.every((c, i) => c === columnOf.value[i])
116
+ if (!same) columnOf.value = next
117
+ })
118
+ }, MEASURE_DELAY)
119
+ })
120
+ }
121
+
122
+ onMounted(layout)
123
+ watch([() => props.modelValue, columnCount], layout)
124
+ </script>
125
+
126
+ <style lang="scss" scoped>
127
+ @import '../../scss/variables';
128
+ @import '../../scss/mixins';
129
+
130
+ .dd-waterfall {
131
+ display: flex;
132
+ flex-direction: row;
133
+ align-items: flex-start;
134
+ }
135
+
136
+ .dd-waterfall__column {
137
+ display: flex;
138
+ flex: 1;
139
+ flex-direction: column;
140
+ /* 列宽必须可压缩,否则长内容(长词、大图)会撑破均分 */
141
+ min-width: 0;
142
+ }
143
+
144
+ .dd-waterfall__item {
145
+ width: 100%;
146
+ }
147
+ </style>
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 瀑布流列分配(纯逻辑,便于自检):按数据顺序逐项塞进当前累计高度最小的列。
3
+ * 返回每个数据项所在列号(下标 = 数据下标)。
4
+ * 读数顺序保持数据顺序;列内参差由各自堆叠吸收。
5
+ */
6
+ export function assignColumns(heights: number[], columnCount: number, gap = 0): number[] {
7
+ const cols = Math.max(1, Math.floor(columnCount) || 1)
8
+ const totals = Array.from({ length: cols }, () => 0)
9
+ return heights.map((h) => {
10
+ let target = 0
11
+ for (let c = 1; c < cols; c++) {
12
+ if (totals[c] < totals[target]) target = c
13
+ }
14
+ totals[target] += h + gap
15
+ return target
16
+ })
17
+ }
package/index.ts CHANGED
@@ -43,11 +43,12 @@ import DdDropdownItem from './components/dd-dropdown-item/dd-dropdown-item.vue'
43
43
  import DdSidebar from './components/dd-sidebar/dd-sidebar.vue'
44
44
  import DdSidebarItem from './components/dd-sidebar-item/dd-sidebar-item.vue'
45
45
 
46
- // === Layout (11) ===
46
+ // === Layout (13) ===
47
47
  import DdCard from './components/dd-card/dd-card.vue'
48
48
  import DdRoomCard from './components/dd-room-card/dd-room-card.vue'
49
49
  import DdGoodsCard from './components/dd-goods-card/dd-goods-card.vue'
50
50
  import DdFeatureGrid from './components/dd-feature-grid/dd-feature-grid.vue'
51
+ import DdWaterfall from './components/dd-waterfall/dd-waterfall.vue'
51
52
  import DdSticky from './components/dd-sticky/dd-sticky.vue'
52
53
  import DdBillDetail from './components/dd-bill-detail/dd-bill-detail.vue'
53
54
  import DdWorkorderCard from './components/dd-workorder-card/dd-workorder-card.vue'
@@ -125,7 +126,7 @@ const components = {
125
126
  DdDrawer, DdTabbar, DdTabbarItem, DdBacktop,
126
127
  DdCollapse, DdCollapseItem, DdDropdownMenu, DdDropdownItem,
127
128
  DdSidebar, DdSidebarItem,
128
- DdCard, DdRoomCard, DdGoodsCard, DdFeatureGrid, DdSticky, DdBillDetail, DdWorkorderCard, DdOrderList, DdCalendar, DdQrcode,
129
+ DdCard, DdRoomCard, DdGoodsCard, DdFeatureGrid, DdWaterfall, DdSticky, DdBillDetail, DdWorkorderCard, DdOrderList, DdCalendar, DdQrcode,
129
130
  DdSubmitBar,
130
131
  DdCartBar,
131
132
  DdTag, DdStatCard, DdChampionCard, DdAvatar, DdAvatarGroup, DdBadge,
@@ -158,7 +159,7 @@ export {
158
159
  DdDrawer, DdTabbar, DdTabbarItem, DdBacktop,
159
160
  DdCollapse, DdCollapseItem, DdDropdownMenu, DdDropdownItem,
160
161
  DdSidebar, DdSidebarItem,
161
- DdCard, DdRoomCard, DdGoodsCard, DdFeatureGrid, DdSticky, DdBillDetail, DdWorkorderCard, DdOrderList, DdCalendar, DdQrcode,
162
+ DdCard, DdRoomCard, DdGoodsCard, DdFeatureGrid, DdWaterfall, DdSticky, DdBillDetail, DdWorkorderCard, DdOrderList, DdCalendar, DdQrcode,
162
163
  DdSubmitBar,
163
164
  DdCartBar,
164
165
  DdTag, DdStatCard, DdChampionCard, DdAvatar, DdAvatarGroup, DdBadge,
@@ -0,0 +1,88 @@
1
+ // libs/function/index.js 的类型声明(allowJs 未开启,TS 侧导入 .js 需要此声明)
2
+ // ponytail: 只声明导出签名,实现仍以 JS 为准;返回值宽泛标注以免与运行时用法冲突。
3
+
4
+ export interface NodeInfo {
5
+ width: number
6
+ height: number
7
+ top: number
8
+ left: number
9
+ right: number
10
+ bottom: number
11
+ [key: string]: any
12
+ }
13
+
14
+ export function getRect(selector: string, all?: false, comp?: any): Promise<NodeInfo>
15
+ export function getRect(selector: string, all: true, comp?: any): Promise<NodeInfo[]>
16
+ export function range(min?: number, max?: number, value?: number): number
17
+ export function getPx(value: number | string, unit?: boolean): any
18
+ export function rpx2px(value: number): number
19
+ export function rpxToPx(rpx: number): number
20
+ export function sleep(value?: number): Promise<void>
21
+ export function os(): string
22
+ export function sys(): any
23
+ export function getWindowInfo(): any
24
+ export function getDeviceInfo(): any
25
+ export function random(min: number, max: number): number
26
+ export function guid(len?: number, firstU?: boolean, radix?: number | null): string
27
+ export function $parent(name?: string): any
28
+ export function addStyle(customStyle: any, target?: 'object' | 'string'): any
29
+ export function addUnit(value?: number | string, unit?: string): any
30
+ export function deepClone<T>(obj: T): T
31
+ export function deepMerge<T = any>(targetOrigin?: any, source?: any): T
32
+ export function shallowMerge<T = any>(target: any, source?: any): T
33
+ export function error(err: any): void
34
+ export function randomArray<T>(array?: T[]): T[]
35
+ export function timeFormat(dateTime?: any, formatStr?: string): string
36
+ export function timeFrom(timestamp?: any, format?: string): string
37
+ export function trim(str: string, pos?: 'both' | 'left' | 'right' | 'all'): string
38
+ export function queryParams(data?: Record<string, any>, isPrefix?: boolean, arrayFormat?: string): string
39
+ export function toast(title: string, duration?: number): void
40
+ export function type2icon(type?: string, fill?: boolean): string
41
+ export function priceFormat(number: number | string, decimals?: number, decimalPoint?: string, thousandsSeparator?: string): string
42
+ export function getDuration(value: any, unit?: boolean): any
43
+ export function padZero(value: number): string
44
+ export function formValidate(instance: any, event: any): any
45
+ export function getProperty(obj: any, key: string): any
46
+ export function setProperty(obj: any, key: string, value: any): void
47
+ export function page(): any
48
+ export function pages(): any
49
+ export function getValueByPath(obj: any, path: string): any
50
+ export function genLightColor(textColor: string, lightness?: number): string
51
+
52
+ declare const _default: {
53
+ getRect: typeof getRect
54
+ range: typeof range
55
+ getPx: typeof getPx
56
+ sleep: typeof sleep
57
+ os: typeof os
58
+ sys: typeof sys
59
+ getWindowInfo: typeof getWindowInfo
60
+ random: typeof random
61
+ guid: typeof guid
62
+ $parent: typeof $parent
63
+ addStyle: typeof addStyle
64
+ addUnit: typeof addUnit
65
+ deepClone: typeof deepClone
66
+ deepMerge: typeof deepMerge
67
+ shallowMerge: typeof shallowMerge
68
+ error: typeof error
69
+ randomArray: typeof randomArray
70
+ timeFormat: typeof timeFormat
71
+ timeFrom: typeof timeFrom
72
+ trim: typeof trim
73
+ queryParams: typeof queryParams
74
+ toast: typeof toast
75
+ type2icon: typeof type2icon
76
+ priceFormat: typeof priceFormat
77
+ getDuration: typeof getDuration
78
+ padZero: typeof padZero
79
+ formValidate: typeof formValidate
80
+ getProperty: typeof getProperty
81
+ setProperty: typeof setProperty
82
+ page: typeof page
83
+ pages: typeof pages
84
+ getValueByPath: typeof getValueByPath
85
+ genLightColor: typeof genLightColor
86
+ rpx2px: typeof rpx2px
87
+ }
88
+ export default _default
@@ -111,6 +111,20 @@ export function rpx2px(value) {
111
111
  // #endif
112
112
  }
113
113
 
114
+ /**
115
+ * @description rpx 转 px(按 750 设计稿宽度等比缩放),取不到窗口宽度时按 2 倍换算兜底
116
+ * @param {number} rpx 设计稿 rpx 值
117
+ * @returns {number}
118
+ */
119
+ export function rpxToPx(rpx) {
120
+ try {
121
+ const info = uni.getWindowInfo()
122
+ return (Number(rpx) / 750) * info.windowWidth
123
+ } catch {
124
+ return Number(rpx) / 2
125
+ }
126
+ }
127
+
114
128
  /**
115
129
  * @description 进行延时,以达到可以简写代码的目的 比如: await sleep(20)将会阻塞20ms
116
130
  * @param {number} value 堵塞时间 单位ms 毫秒
@@ -0,0 +1,65 @@
1
+ // libs/function/test.js 的类型声明(allowJs 未开启,TS 侧导入 .js 需要此声明)
2
+ // ponytail: 校验函数统一 `(value: any, ...) => boolean`,实现细节以 JS 为准。
3
+
4
+ export function email(value: any): boolean
5
+ export function mobile(value: any): boolean
6
+ export function url(value: any): boolean
7
+ export function date(value: any): boolean
8
+ export function dateISO(value: any): boolean
9
+ export function number(value: any): boolean
10
+ export function string(value: any): boolean
11
+ export function digits(value: any): boolean
12
+ export function idCard(value: any): boolean
13
+ export function carNo(value: any): boolean
14
+ export function amount(value: any): boolean
15
+ export function chinese(value: any): boolean
16
+ export function letter(value: any): boolean
17
+ export function enOrNum(value: any): boolean
18
+ export function contains(value: any, param: any): boolean
19
+ export function range(value: any, param: [number, number]): boolean
20
+ export function rangeLength(value: any, param: [number, number]): boolean
21
+ export function landline(value: any): boolean
22
+ export function empty(value: any): boolean
23
+ export function jsonString(value: any): boolean
24
+ export function array(value: any): boolean
25
+ export function object(value: any): boolean
26
+ export function objectPromise(value: any): boolean
27
+ export function code(value: any, len?: number): boolean
28
+ export function func(value: any): boolean
29
+ export function promise(value: any): boolean
30
+ export function image(value: any): boolean
31
+ export function video(value: any): boolean
32
+ export function regExp(o: any): boolean
33
+
34
+ declare const _default: {
35
+ email: typeof email
36
+ mobile: typeof mobile
37
+ url: typeof url
38
+ date: typeof date
39
+ dateISO: typeof dateISO
40
+ number: typeof number
41
+ digits: typeof digits
42
+ idCard: typeof idCard
43
+ carNo: typeof carNo
44
+ amount: typeof amount
45
+ chinese: typeof chinese
46
+ letter: typeof letter
47
+ enOrNum: typeof enOrNum
48
+ contains: typeof contains
49
+ range: typeof range
50
+ rangeLength: typeof rangeLength
51
+ empty: typeof empty
52
+ isEmpty: typeof empty
53
+ jsonString: typeof jsonString
54
+ landline: typeof landline
55
+ object: typeof object
56
+ array: typeof array
57
+ code: typeof code
58
+ func: typeof func
59
+ promise: typeof promise
60
+ video: typeof video
61
+ image: typeof image
62
+ regExp: typeof regExp
63
+ string: typeof string
64
+ }
65
+ export default _default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@didaoktv/didaoui-uniapp",
3
- "version": "2.13.0",
3
+ "version": "2.15.0",
4
4
  "description": "帝到KTV UniApp 组件库",
5
5
  "main": "index.ts",
6
6
  "types": "index.ts",
package/scss/_mixins.scss CHANGED
@@ -122,6 +122,14 @@
122
122
  }
123
123
  }
124
124
 
125
+ // flex 布局(nvue 下由默认 flex 兜底,显式声明方向)
126
+ @mixin dd-flex($direction: row) {
127
+ /* #ifndef APP-NVUE */
128
+ display: flex;
129
+ /* #endif */
130
+ flex-direction: $direction;
131
+ }
132
+
125
133
  // flex 居中
126
134
  @mixin dd-flex-center {
127
135
  display: flex;
@@ -28,6 +28,13 @@ $dd-vars-base: (
28
28
  'error': $dd-error,
29
29
  'info': $dd-info,
30
30
  'vip': $dd-vip-500,
31
+ // 排行榜奖牌色(明暗不翻转)
32
+ 'medal-gold': $dd-medal-gold,
33
+ 'medal-gold-deep': $dd-medal-gold-deep,
34
+ 'medal-silver': $dd-medal-silver,
35
+ 'medal-silver-deep': $dd-medal-silver-deep,
36
+ 'medal-bronze': $dd-medal-bronze,
37
+ 'medal-bronze-deep': $dd-medal-bronze-deep,
31
38
  // 对比色(明暗不翻转;品牌主题可覆盖,如红金主题配白字)
32
39
  'primary-contrast': $dd-primary-contrast,
33
40
  'accent-contrast': $dd-accent-contrast,