@didaoktv/didaoui-uniapp 2.13.0 → 2.14.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 (59) 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-icon/dd-icon.vue +1 -1
  16. package/components/dd-keyboard/dd-keyboard.vue +95 -46
  17. package/components/dd-link/dd-link.vue +72 -49
  18. package/components/dd-markdown/dd-markdown.vue +154 -154
  19. package/components/dd-number-keyboard/dd-number-keyboard.vue +109 -94
  20. package/components/dd-parse/dd-parse.vue +473 -442
  21. package/components/dd-poster/dd-poster.vue +579 -567
  22. package/components/dd-pull-refresh/dd-pull-refresh.vue +1 -9
  23. package/components/dd-qrcode/dd-qrcode.vue +431 -405
  24. package/components/dd-radio-group/dd-radio-group.vue +1 -1
  25. package/components/dd-segmented-tab/dd-segmented-tab.vue +22 -14
  26. package/components/dd-signature/dd-signature.vue +377 -357
  27. package/components/dd-step/dd-step.vue +1 -1
  28. package/components/dd-sticky/dd-sticky.vue +5 -10
  29. package/components/dd-swipe-action/dd-swipe-action.vue +1 -9
  30. package/components/dd-swipe-item/dd-swipe-item.vue +2 -0
  31. package/components/dd-swipeable-tab/dd-swipeable-tab.vue +1 -5
  32. package/components/dd-switch/dd-switch.vue +1 -1
  33. package/components/dd-text/dd-text.vue +304 -82
  34. package/components/dd-waterfall/dd-waterfall.vue +89 -0
  35. package/index.ts +4 -3
  36. package/libs/function/index.d.ts +88 -0
  37. package/libs/function/index.js +14 -0
  38. package/libs/function/test.d.ts +65 -0
  39. package/package.json +1 -1
  40. package/scss/_mixins.scss +8 -0
  41. package/scss/_theme-tokens.scss +7 -0
  42. package/scss/_variables.scss +283 -156
  43. package/components/dd-album/album.js +0 -19
  44. package/components/dd-album/props.js +0 -89
  45. package/components/dd-avatar/avatar.js +0 -19
  46. package/components/dd-avatar/props.js +0 -84
  47. package/components/dd-avatar-group/avatarGroup.js +0 -14
  48. package/components/dd-avatar-group/props.js +0 -57
  49. package/components/dd-keyboard/keyboard.js +0 -19
  50. package/components/dd-keyboard/props.js +0 -79
  51. package/components/dd-link/link.js +0 -17
  52. package/components/dd-link/props.js +0 -44
  53. package/components/dd-number-keyboard/numberKeyboard.js +0 -8
  54. package/components/dd-number-keyboard/props.js +0 -24
  55. package/components/dd-parse/props.js +0 -57
  56. package/components/dd-text/props.js +0 -120
  57. package/components/dd-text/text.js +0 -30
  58. package/components/dd-text/value.js +0 -87
  59. package/scss/_dd-shared.scss +0 -40
@@ -231,7 +231,7 @@ const lineStyle = computed(() => ({
231
231
  text-align: left;
232
232
  flex: 1;
233
233
  padding-bottom: $dd-space-4;
234
- padding-left: $dd-space-1;
234
+ padding-left: $dd-space-3;
235
235
  margin-top: 0;
236
236
  }
237
237
  }
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <view
3
+ ref="rootRef"
3
4
  class="dd-sticky"
4
5
  :class="{ 'dd-sticky--disabled': disabled }"
5
6
  :style="stickyStyle"
@@ -12,6 +13,7 @@
12
13
  import { computed, getCurrentInstance, onMounted, onUnmounted, ref } from 'vue'
13
14
  // z-index 统一取 libs/config/zIndex.js:默认吸顶层级取 sticky 档(zIndex prop 保留可覆盖)
14
15
  import zIndexConfig from '../../libs/config/zIndex.js'
16
+ import { rpxToPx } from '../../libs/function/index.js'
15
17
 
16
18
  interface Props {
17
19
  offsetTop?: number // rpx
@@ -28,6 +30,8 @@ const props = withDefaults(defineProps<Props>(), {
28
30
  const emit = defineEmits<{ (e: 'change', val: { isFixed: boolean; scrollTop: number }): void }>()
29
31
 
30
32
  const isFixed = ref(false)
33
+ // H5 侧观察自身根节点(避免全局选择器在多实例下取到第一个)
34
+ const rootRef = ref<HTMLElement | null>(null)
31
35
 
32
36
  const stickyStyle = computed(() => {
33
37
  if (props.disabled) {
@@ -44,15 +48,6 @@ const stickyStyle = computed(() => {
44
48
  let observer: any = null
45
49
  const instance = getCurrentInstance()
46
50
 
47
- function rpxToPx(rpx: number): number {
48
- try {
49
- const info = uni.getWindowInfo()
50
- return (rpx / 750) * info.windowWidth
51
- } catch {
52
- return rpx / 2
53
- }
54
- }
55
-
56
51
  onMounted(() => {
57
52
  if (props.disabled) return
58
53
  // #ifdef H5
@@ -66,7 +61,7 @@ onMounted(() => {
66
61
  // H5: 使用原生 IntersectionObserver API
67
62
  function setupH5Observer() {
68
63
  // #ifdef H5
69
- const el = document.querySelector('.dd-sticky')
64
+ const el = rootRef.value
70
65
  if (!el) return
71
66
  const px = rpxToPx(props.offsetTop)
72
67
  const io = new IntersectionObserver(
@@ -43,6 +43,7 @@
43
43
 
44
44
  <script setup lang="ts">
45
45
  import { computed, ref } from 'vue'
46
+ import { rpxToPx } from '../../libs/function/index.js'
46
47
  import DdIcon from '../dd-icon/dd-icon.vue'
47
48
  // z-index 统一取 libs/config/zIndex.js(操作层 base 档,内容层档内 +1 盖住操作层)
48
49
  import zIndexConfig from '../../libs/config/zIndex.js'
@@ -92,15 +93,6 @@ const actionWidthPx = computed(() => rpxToPx(props.actionWidth))
92
93
  const leftWidthPx = computed(() => actionWidthPx.value * props.leftActions.length)
93
94
  const rightWidthPx = computed(() => actionWidthPx.value * props.rightActions.length)
94
95
 
95
- function rpxToPx(rpx: number): number {
96
- try {
97
- const info = uni.getWindowInfo()
98
- return (rpx / 750) * info.windowWidth
99
- } catch {
100
- return rpx / 2
101
- }
102
- }
103
-
104
96
  function onTouchStart(e: any) {
105
97
  if (props.disabled) return
106
98
  dragging = true
@@ -20,6 +20,8 @@ onUnmounted(() => {
20
20
  </script>
21
21
 
22
22
  <style lang="scss" scoped>
23
+ @import '../../scss/variables';
24
+ @import '../../scss/mixins';
23
25
  .dd-swipe-item {
24
26
  width: 100%;
25
27
  height: 100%;
@@ -44,6 +44,7 @@
44
44
  <script setup lang="ts">
45
45
  import { nextTick, onMounted, ref, watch } from 'vue'
46
46
  import { getCurrentInstance } from 'vue'
47
+ import { rpxToPx } from '../../libs/function/index.js'
47
48
 
48
49
  interface Props {
49
50
  modelValue?: number
@@ -79,11 +80,6 @@ function onSelect(index: number) {
79
80
  measure()
80
81
  }
81
82
 
82
- function rpxToPx(rpx: number): number {
83
- const w = uni.getWindowInfo?.().windowWidth || 375
84
- return (rpx * w) / 750
85
- }
86
-
87
83
  function measure() {
88
84
  nextTick(() => {
89
85
  const query = uni.createSelectorQuery().in(instance)
@@ -56,7 +56,7 @@ function onToggle() {
56
56
  top: 50%;
57
57
  left: 6rpx;
58
58
  transform: translateY(-50%);
59
- background: #ffffff;
59
+ background: $dd-color-white;
60
60
  border-radius: 50%;
61
61
  box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.3);
62
62
  @include dd-transition(left 0.3s cubic-bezier(0.34, 1.56, 0.64, 1));
@@ -67,16 +67,14 @@
67
67
  </view>
68
68
  </template>
69
69
 
70
- <script>
71
- import { props } from './props'
72
- import value from './value.js'
73
- import { mpMixin } from '../../libs/mixin/mpMixin';
74
- import { mixin } from '../../libs/mixin/mixin';
75
- import { buttonMixin } from '../../libs/mixin/button';
76
- import { openType } from '../../libs/mixin/openType';
77
- import { addStyle, addUnit, deepMerge } from '../../libs/function/index';
78
-
79
- function normalizeLineHeight(value) {
70
+ <script setup lang="ts">
71
+ import { computed } from 'vue'
72
+ import DdIcon from '../dd-icon/dd-icon.vue'
73
+ import DdLink from '../dd-link/dd-link.vue'
74
+ import { addStyle, addUnit, deepMerge, error, priceFormat, timeFormat } from '../../libs/function/index.js';
75
+ import test from '../../libs/function/test';
76
+
77
+ function normalizeLineHeight(value: any) {
80
78
  const valueString = String(value).trim()
81
79
  const numericValue = Number(valueString)
82
80
  const isUnitless =
@@ -105,7 +103,7 @@ function normalizeLineHeight(value) {
105
103
  * @property {String | Number} lines 文本显示的行数,如果设置,超出此行数,将会显示省略号
106
104
  * @property {String} color 文本颜色(默认 '#303133' )
107
105
  * @property {String | Number} size 字体大小(默认 15 )
108
- * @property {Object | String} iconStyle 图标的样式 (默认 {fontSize: '15px'} )
106
+ * @property {Object | String} iconStyle 图标的样式 (默认 {fontSize: '30rpx'} )
109
107
  * @property {String} decoration 文字装饰,下划线,中划线等,可选值 none|underline|line-through(默认 'none' )
110
108
  * @property {Object | String | Number} margin 外边距,对象、字符串,数值形式均可(默认 0 )
111
109
  * @property {String | Number} lineHeight 文本行高,支持带单位值或无单位倍数(如 1.2)
@@ -114,96 +112,320 @@ function normalizeLineHeight(value) {
114
112
  * @event {Function} click 点击触发事件
115
113
  * @example <dd-text text="我用十年青春,赴你最后之约"></dd-text>
116
114
  */
117
- export default {
118
- name: 'dd-text',
119
- // #ifdef MP
120
- mixins: [mpMixin, mixin, value, buttonMixin, openType, props],
115
+ interface Props {
116
+ // 主题颜色
117
+ type?: string
118
+ // 是否显示
119
+ show?: boolean
120
+ // 显示的值
121
+ text?: string | number
122
+ // 前置图标
123
+ prefixIcon?: string
124
+ // 后置图标
125
+ suffixIcon?: string
126
+ // 文本处理的匹配模式
127
+ // text-普通文本,price-价格,phone-手机号,name-姓名,date-日期,link-超链接
128
+ mode?: string
129
+ // mode=link下,配置的链接
130
+ href?: string
131
+ // 格式化规则
132
+ format?: string | ((text: any) => any)
133
+ // mode=phone时,点击文本是否拨打电话
134
+ call?: boolean
135
+ // 小程序的打开方式
136
+ openType?: string
137
+ // 是否粗体,默认normal
138
+ bold?: boolean
139
+ // 是否块状
140
+ block?: boolean
141
+ // 文本显示的行数,如果设置,超出此行数,将会显示省略号
142
+ lines?: string | number
143
+ // 文本颜色
144
+ color?: string
145
+ // 字体大小
146
+ size?: string | number
147
+ // 图标的样式
148
+ iconStyle?: Record<string, any> | string
149
+ // 文字装饰,下划线,中划线等,可选值 none|underline|line-through
150
+ decoration?: string
151
+ // 外边距,对象、字符串,数值形式均可
152
+ margin?: Record<string, any> | string | number
153
+ // 文本行高
154
+ lineHeight?: string | number
155
+ // 文本对齐方式,可选值left|center|right
156
+ align?: string
157
+ // 文字换行,可选值break-word|normal|anywhere
158
+ wordWrap?: string
159
+ // 占满剩余空间
160
+ flex1?: boolean
161
+ // 通用兜底 prop:自定义类名
162
+ customClass?: string
163
+ // 通用兜底 prop:定义需要用到的外部样式
164
+ customStyle?: Record<string, any> | string
165
+ // 小程序 button 透传属性
166
+ lang?: string
167
+ sessionFrom?: string
168
+ sendMessageTitle?: string
169
+ sendMessagePath?: string
170
+ sendMessageImg?: string
171
+ showMessageCard?: boolean
172
+ appParameter?: string
173
+ }
174
+
175
+ const props = withDefaults(defineProps<Props>(), {
176
+ type: '',
177
+ show: true,
178
+ text: '',
179
+ prefixIcon: '',
180
+ suffixIcon: '',
181
+ mode: '',
182
+ href: '',
183
+ format: '',
184
+ call: false,
185
+ openType: '',
186
+ bold: false,
187
+ block: false,
188
+ lines: '',
189
+ color: '',
190
+ size: 15,
191
+ iconStyle: () => ({ fontSize: '30rpx' }),
192
+ decoration: 'none',
193
+ margin: 0,
194
+ lineHeight: '',
195
+ align: 'left',
196
+ wordWrap: 'normal',
197
+ flex1: false,
198
+ customClass: '',
199
+ customStyle: () => ({}),
200
+ })
201
+
202
+ const emit = defineEmits<{
203
+ (e: 'click', ev: any): void;
204
+ (e: 'getuserinfo', detail: any): void;
205
+ (e: 'contact', detail: any): void;
206
+ (e: 'getphonenumber', detail: any): void;
207
+ (e: 'error', detail: any): void;
208
+ (e: 'launchapp', detail: any): void;
209
+ (e: 'opensetting', detail: any): void;
210
+ }>()
211
+
212
+ // ponytail: 模板里的 :data-index="index" 沿袭 Options API 行为,取值为 undefined
213
+ const index = undefined
214
+
215
+ const isNvue = computed(() => {
216
+ let nvue = false
217
+ // #ifdef APP-NVUE
218
+ nvue = true
121
219
  // #endif
122
- // #ifndef MP
123
- mixins: [mpMixin, mixin, value, props],
220
+ return nvue
221
+ })
222
+
223
+ const isMp = computed(() => {
224
+ let mp = false
225
+ // #ifdef MP
226
+ mp = true
124
227
  // #endif
125
- emits: ['click'],
126
- computed: {
127
- wrapStyle() {
128
- let style = {
129
- margin: this.margin,
130
- justifyContent: this.align === 'left' ? 'flex-start' : this.align === 'center' ? 'center' : 'flex-end'
131
- }
132
- // 占满剩余空间
133
- if (this.flex1) {
134
- style.flex = 1;
135
- // #ifndef APP-NVUE
136
- style.width = '100%';
137
- // #endif
138
- }
139
- return style;
140
- },
141
- valueStyle() {
142
- const style = {
143
- textDecoration: this.decoration,
144
- fontWeight: this.bold ? 'bold' : 'normal',
145
- wordWrap: this.wordWrap,
146
- fontSize: addUnit(this.size)
147
- }
148
- if (!this.type) {
149
- // ponytail: 剥离运行时主题;未传 color 时继承上下文,跟随设计系统文本色
150
- style.color = this.color || 'inherit'
151
- }
152
- this.isNvue && this.lines && (style.lines = this.lines)
153
- this.lineHeight &&
154
- (style.lineHeight = normalizeLineHeight(this.lineHeight))
155
- !this.isNvue && this.block && (style.display = 'block')
156
- return deepMerge(style, addStyle(this.customStyle))
157
- },
158
- isNvue() {
159
- let nvue = false
160
- // #ifdef APP-NVUE
161
- nvue = true
162
- // #endif
163
- return nvue
164
- },
165
- isMp() {
166
- let mp = false
167
- // #ifdef MP
168
- mp = true
169
- // #endif
170
- return mp
228
+ return mp
229
+ })
230
+
231
+ // 默认的姓名脱敏规则
232
+ function formatName(name: string) {
233
+ let value = ''
234
+ if (name.length === 2) {
235
+ value = name.substr(0, 1) + '*'
236
+ } else if (name.length > 2) {
237
+ let char = ''
238
+ for (let i = 0, len = name.length - 2; i < len; i++) {
239
+ char += '*'
171
240
  }
172
- },
173
- data() {
174
- return {}
175
- },
176
- methods: {
177
- addStyle,
178
- clickHandler(e) {
179
- // 如果为手机号模式,拨打电话
180
- if (this.call && this.mode === 'phone') {
181
- uni.makePhoneCall({
182
- phoneNumber: this.text
183
- })
184
- }
185
- this.$emit('click', e)
241
+ value = name.substr(0, 1) + char + name.substr(-1, 1)
242
+ } else {
243
+ value = name
244
+ }
245
+ return value
246
+ }
247
+
248
+ // 经处理后需要显示的值
249
+ const value = computed(() => {
250
+ const {
251
+ text,
252
+ mode,
253
+ format,
254
+ href
255
+ } = props
256
+ // 价格类型
257
+ if (mode === 'price') {
258
+ // 如果text不为金额进行提示
259
+ if (!/^\d+(\.\d+)?$/.test(String(text))) {
260
+ error('金额模式下,text参数需要为金额格式');
261
+ }
262
+ // 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的金额格式化处理
263
+ if (typeof format === 'function') {
264
+ // 如果用户传入的是函数,使用函数格式化
265
+ return format(text)
266
+ }
267
+ // 如果format非正则,非函数,则使用默认的金额格式化方法进行操作
268
+ return priceFormat(text, 2)
269
+ } if (mode === 'date') {
270
+ // 判断是否合法的日期或者时间戳
271
+ !test.date(text) && error('日期模式下,text参数需要为日期或时间戳格式')
272
+ // 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的格式化处理
273
+ if (typeof format === 'function') {
274
+ // 如果用户传入的是函数,使用函数格式化
275
+ return format(text)
276
+ } if (format) {
277
+ // 如果format非正则,非函数,则使用默认的时间格式化方法进行操作
278
+ return timeFormat(text, format)
279
+ }
280
+ // 如果没有设置format,则设置为默认的时间格式化形式
281
+ return timeFormat(text, 'yyyy-mm-dd')
282
+ } if (mode === 'phone') {
283
+ // 判断是否合法的手机号
284
+ // !test.mobile(text) && error('手机号模式下,text参数需要为手机号码格式')
285
+ if (typeof format === 'function') {
286
+ // 如果用户传入的是函数,使用函数格式化
287
+ return format(text)
288
+ } if (format === 'encrypt') {
289
+ // 如果format为encrypt,则将手机号进行星号加密处理
290
+ const str = String(text)
291
+ return `${str.substr(0, 3)}****${str.substr(7)}`
186
292
  }
293
+ return text
294
+ } if (mode === 'name') {
295
+ // 判断是否合法的字符粗
296
+ !(typeof (text) === 'string') && error('姓名模式下,text参数需要为字符串格式')
297
+ if (typeof format === 'function') {
298
+ // 如果用户传入的是函数,使用函数格式化
299
+ return format(text)
300
+ } if (format === 'encrypt') {
301
+ // 如果format为encrypt,则将姓名进行星号加密处理
302
+ return formatName(String(text))
303
+ }
304
+ return text
305
+ } if (mode === 'link') {
306
+ // 判断是否合法的字符粗
307
+ !test.url(href) && error('超链接模式下,href参数需要为URL格式')
308
+ return text
309
+ }
310
+ return text
311
+ })
312
+
313
+ const wrapStyle = computed(() => {
314
+ let style: Record<string, any> = {
315
+ margin: props.margin,
316
+ justifyContent: props.align === 'left' ? 'flex-start' : props.align === 'center' ? 'center' : 'flex-end'
317
+ }
318
+ // 占满剩余空间
319
+ if (props.flex1) {
320
+ style.flex = 1;
321
+ // #ifndef APP-NVUE
322
+ style.width = '100%';
323
+ // #endif
324
+ }
325
+ return style;
326
+ })
327
+
328
+ const valueStyle = computed(() => {
329
+ const style: Record<string, any> = {
330
+ textDecoration: props.decoration,
331
+ fontWeight: props.bold ? 'bold' : 'normal',
332
+ wordWrap: props.wordWrap,
333
+ fontSize: addUnit(props.size)
334
+ }
335
+ if (!props.type) {
336
+ // ponytail: 剥离运行时主题;未传 color 时继承上下文,跟随设计系统文本色
337
+ style.color = props.color || 'inherit'
338
+ }
339
+ isNvue.value && props.lines && (style.lines = props.lines)
340
+ props.lineHeight &&
341
+ (style.lineHeight = normalizeLineHeight(props.lineHeight))
342
+ !isNvue.value && props.block && (style.display = 'block')
343
+ return deepMerge(style, addStyle(props.customStyle))
344
+ })
345
+
346
+ function clickHandler(e: any) {
347
+ // 如果为手机号模式,拨打电话
348
+ if (props.call && props.mode === 'phone') {
349
+ uni.makePhoneCall({
350
+ phoneNumber: props.text as string
351
+ })
187
352
  }
353
+ emit('click', e)
354
+ }
355
+
356
+ function onGetUserInfo(event: any) {
357
+ emit('getuserinfo', event.detail)
188
358
  }
359
+
360
+ function onContact(event: any) {
361
+ emit('contact', event.detail)
362
+ }
363
+
364
+ function onGetPhoneNumber(event: any) {
365
+ emit('getphonenumber', event.detail)
366
+ }
367
+
368
+ function onError(event: any) {
369
+ emit('error', event.detail)
370
+ }
371
+
372
+ function onLaunchApp(event: any) {
373
+ emit('launchapp', event.detail)
374
+ }
375
+
376
+ function onOpenSetting(event: any) {
377
+ emit('opensetting', event.detail)
378
+ }
379
+
380
+ defineExpose({ value, wrapStyle, valueStyle, clickHandler, formatName })
189
381
  </script>
190
382
 
191
383
  <style lang="scss" scoped>
192
384
  @import '../../scss/variables';
193
- @import '../../scss/dd-shared';
385
+ @import '../../scss/mixins';
386
+
387
+ // 按钮重置(原 dd-shared 全局工具类,收敛到本组件 scoped 内)
388
+ .dd-reset-button {
389
+ padding: 0;
390
+ background-color: transparent;
391
+ font-size: inherit;
392
+ line-height: inherit;
393
+ color: inherit;
394
+ &::after {
395
+ border: none;
396
+ }
397
+ }
398
+
399
+ // 多行省略(模板按 lines 动态拼 dd-line-N)
400
+ @for $i from 1 through 10 {
401
+ .dd-line-#{$i} {
402
+ /* #ifdef APP-NVUE */
403
+ lines: $i;
404
+ text-overflow: ellipsis;
405
+ overflow: hidden;
406
+ flex: 1;
407
+ /* #endif */
408
+ /* #ifndef APP-NVUE */
409
+ display: -webkit-box;
410
+ -webkit-box-orient: vertical;
411
+ -webkit-line-clamp: $i;
412
+ overflow: hidden;
413
+ /* #endif */
414
+ }
415
+ }
194
416
  .dd-text {
195
- @include flex(row);
417
+ @include dd-flex(row);
196
418
  align-items: center;
197
419
  flex-wrap: nowrap;
198
420
 
199
421
  &__price {
200
- font-size: 14px;
422
+ font-size: $dd-font-size-body;
201
423
  color: var(--dd-text-secondary, #{$dd-text-secondary});
202
424
  }
203
425
 
204
426
  &__value {
205
- font-size: 14px;
206
- @include flex;
427
+ font-size: $dd-font-size-body;
428
+ @include dd-flex;
207
429
  color: var(--dd-text-secondary, #{$dd-text-secondary});
208
430
  flex-wrap: wrap;
209
431
  // flex: 1;
@@ -0,0 +1,89 @@
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
+ :style="`margin-bottom: ${gap}rpx;`"
14
+ >
15
+ <slot :item="cell.item" :index="cell.index" />
16
+ </view>
17
+ </view>
18
+ </view>
19
+ </template>
20
+
21
+ <script setup lang="ts">
22
+ import { computed } from 'vue'
23
+
24
+ type WaterfallItem = Record<string, any>
25
+
26
+ interface Props {
27
+ /** 数据数组(v-model,只读消费;组件不修改它) */
28
+ modelValue?: WaterfallItem[]
29
+ /** 列数 */
30
+ columns?: number
31
+ /** 列间距与项间距(rpx) */
32
+ gap?: number
33
+ customStyle?: string
34
+ customClass?: string
35
+ }
36
+
37
+ const props = withDefaults(defineProps<Props>(), {
38
+ modelValue: () => [],
39
+ columns: 2,
40
+ gap: 16,
41
+ customStyle: '',
42
+ customClass: '',
43
+ })
44
+
45
+ interface Cell {
46
+ item: WaterfallItem
47
+ /** 在原数组中的下标(同时用作渲染 key 与插槽参数) */
48
+ index: number
49
+ }
50
+
51
+ const columnCount = computed(() => Math.max(1, Math.floor(props.columns) || 1))
52
+
53
+ /**
54
+ * 按数据顺序轮流填列:第 i 项进第 i % 列。
55
+ * 这是瀑布流对「顺序敏感」列表的正确填充口径——按最矮列塞下一个会把顺序彻底打散
56
+ * (房态看板要按包厢号找房,A101、A104、AB202 交错是不可接受的);
57
+ * 列各自独立堆叠,因此仍没有普通 grid 的整行等高空白。
58
+ */
59
+ const columnList = computed<Cell[][]>(() => {
60
+ const cols = Array.from({ length: columnCount.value }, () => [] as Cell[])
61
+ ;(props.modelValue || []).forEach((item, index) => {
62
+ cols[index % cols.length].push({ item, index })
63
+ })
64
+ return cols
65
+ })
66
+ </script>
67
+
68
+ <style lang="scss" scoped>
69
+ @import '../../scss/variables';
70
+ @import '../../scss/mixins';
71
+
72
+ .dd-waterfall {
73
+ display: flex;
74
+ flex-direction: row;
75
+ align-items: flex-start;
76
+ }
77
+
78
+ .dd-waterfall__column {
79
+ display: flex;
80
+ flex: 1;
81
+ flex-direction: column;
82
+ /* 列宽必须可压缩,否则长内容(长词、大图)会撑破均分 */
83
+ min-width: 0;
84
+ }
85
+
86
+ .dd-waterfall__item {
87
+ width: 100%;
88
+ }
89
+ </style>
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,