@didaoktv/didaoui-uniapp 2.14.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.
- package/components/dd-goods-sku/dd-goods-sku.vue +6 -1
- package/components/dd-package-sku/dd-package-sku.vue +24 -1
- package/components/dd-segmented-tab/dd-segmented-tab.vue +40 -3
- package/components/dd-waterfall/dd-waterfall.vue +66 -8
- package/components/dd-waterfall/waterfall.ts +17 -0
- package/package.json +1 -1
- package/libs/config/color.js +0 -16
- package/libs/config/props.js +0 -184
- package/libs/mixin/button.js +0 -18
- package/libs/mixin/mixin.js +0 -44
- package/libs/mixin/mpMixin.js +0 -13
- package/libs/mixin/openType.js +0 -27
- package/libs/vue.js +0 -3
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
<text v-if="originPrice" class="dd-goods-sku__header__info__price__origin">¥{{ originPrice }}</text>
|
|
26
26
|
</view>
|
|
27
27
|
<view class="dd-goods-sku__header__info__stock">库存 {{ stock }} 件</view>
|
|
28
|
-
<view class="dd-goods-sku__header__info__selected">已选: {{ selectedSkuText }}</view>
|
|
28
|
+
<view v-if="selectedSkuText" class="dd-goods-sku__header__info__selected">已选: {{ selectedSkuText }}</view>
|
|
29
|
+
<view v-else class="dd-goods-sku__header__info__selected dd-goods-sku__header__info__selected--hint">请选择规格</view>
|
|
29
30
|
</view>
|
|
30
31
|
</slot>
|
|
31
32
|
</view>
|
|
@@ -404,6 +405,10 @@ defineExpose({ open, close, reset })
|
|
|
404
405
|
&__selected {
|
|
405
406
|
font-size: 26rpx;
|
|
406
407
|
color: var(--dd-text-primary, #{$dd-text-primary});
|
|
408
|
+
|
|
409
|
+
&--hint {
|
|
410
|
+
color: var(--dd-text-tertiary, #{$dd-text-tertiary});
|
|
411
|
+
}
|
|
407
412
|
}
|
|
408
413
|
}
|
|
409
414
|
}
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
<view v-if="stock !== undefined && stock !== null" class="dd-package-sku__header__info__stock">
|
|
28
28
|
库存 {{ stock }} 件
|
|
29
29
|
</view>
|
|
30
|
-
<view class="dd-package-sku__header__info__selected">已选: {{ selectedText
|
|
30
|
+
<view v-if="selectedText" class="dd-package-sku__header__info__selected">已选: {{ selectedText }}</view>
|
|
31
|
+
<view v-else-if="!hasSelectable" class="dd-package-sku__header__info__selected dd-package-sku__header__info__selected--hint">无需选择</view>
|
|
32
|
+
<view v-else class="dd-package-sku__header__info__selected dd-package-sku__header__info__selected--hint">请选择套餐内容</view>
|
|
31
33
|
</view>
|
|
32
34
|
</view>
|
|
33
35
|
|
|
@@ -50,6 +52,7 @@
|
|
|
50
52
|
@click="onItemClick(group, item)"
|
|
51
53
|
>
|
|
52
54
|
<text>{{ item.name }}</text>
|
|
55
|
+
<text v-if="qtyText(item)" class="dd-package-sku__chip__qty">{{ qtyText(item) }}</text>
|
|
53
56
|
<text v-if="surchargeText(item)" class="dd-package-sku__chip__surcharge">{{ surchargeText(item) }}</text>
|
|
54
57
|
<text v-if="itemDisabled(item)" class="dd-package-sku__chip__soldout">已售罄</text>
|
|
55
58
|
</view>
|
|
@@ -156,6 +159,10 @@ const originPrice = computed(() => props.goodsInfo.originPrice || props.goodsInf
|
|
|
156
159
|
const stock = computed(() => props.goodsInfo.stock ?? props.goodsInfo.quantity)
|
|
157
160
|
/** 已选项实时摘要(确认前即联动展示) */
|
|
158
161
|
const selectedText = computed(() => buildSelectedText(props.groups, selections))
|
|
162
|
+
/** 是否存在可选的 OPTIONAL 项:全部 FIXED 或可选项全售罄/停用时无需选择 */
|
|
163
|
+
const hasSelectable = computed(() =>
|
|
164
|
+
props.groups.some((g) => !isFixed(g) && g.items.some((it) => !isItemDisabled(it))),
|
|
165
|
+
)
|
|
159
166
|
|
|
160
167
|
// 模板内避免复杂表达式(小程序约束),逐一下沉为方法
|
|
161
168
|
function isFixedGroup(group: PackageSkuGroup): boolean {
|
|
@@ -174,6 +181,12 @@ function surchargeText(item: PackageSkuItem): string {
|
|
|
174
181
|
return surchargeLabel(item)
|
|
175
182
|
}
|
|
176
183
|
|
|
184
|
+
/** 件数标签:「×N」(单次选中/每份固定含份数,>1 才标,与 buildSelectedText 摘要口径一致),返回空串不显示 */
|
|
185
|
+
function qtyText(item: PackageSkuItem): string {
|
|
186
|
+
const n = item.perQty ?? 1
|
|
187
|
+
return n > 1 ? `×${n}` : ''
|
|
188
|
+
}
|
|
189
|
+
|
|
177
190
|
function isSelected(group: PackageSkuGroup, item: PackageSkuItem): boolean {
|
|
178
191
|
return (selections[String(group.id)] ?? []).includes(item.id)
|
|
179
192
|
}
|
|
@@ -304,6 +317,10 @@ defineExpose({ open, close, reset })
|
|
|
304
317
|
&__selected {
|
|
305
318
|
font-size: 26rpx;
|
|
306
319
|
color: var(--dd-text-primary, #{$dd-text-primary});
|
|
320
|
+
|
|
321
|
+
&--hint {
|
|
322
|
+
color: var(--dd-text-tertiary, #{$dd-text-tertiary});
|
|
323
|
+
}
|
|
307
324
|
}
|
|
308
325
|
}
|
|
309
326
|
}
|
|
@@ -368,6 +385,12 @@ defineExpose({ open, close, reset })
|
|
|
368
385
|
color: var(--dd-text-secondary, #{$dd-text-secondary});
|
|
369
386
|
}
|
|
370
387
|
|
|
388
|
+
&__qty {
|
|
389
|
+
margin-left: 8rpx;
|
|
390
|
+
font-size: 24rpx;
|
|
391
|
+
color: var(--dd-text-secondary, #{$dd-text-secondary});
|
|
392
|
+
}
|
|
393
|
+
|
|
371
394
|
&__surcharge {
|
|
372
395
|
margin-left: 8rpx;
|
|
373
396
|
font-size: 24rpx;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<view
|
|
3
3
|
v-if="variant === 'pill'"
|
|
4
4
|
class="dd-seg dd-seg--pill"
|
|
5
|
-
:class="{ 'dd-seg--sm': size === 'sm' }"
|
|
5
|
+
:class="{ 'dd-seg--sm': size === 'sm', 'dd-seg--no-ellipsis': !ellipsis }"
|
|
6
6
|
>
|
|
7
7
|
<view class="dd-seg__track">
|
|
8
8
|
<view
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
<view
|
|
25
25
|
v-else
|
|
26
26
|
class="dd-seg dd-seg--text"
|
|
27
|
-
:class="{ 'dd-seg--sm': size === 'sm' }"
|
|
27
|
+
:class="{ 'dd-seg--sm': size === 'sm', 'dd-seg--no-ellipsis': !ellipsis }"
|
|
28
|
+
:style="gapStyle"
|
|
28
29
|
>
|
|
29
30
|
<view
|
|
30
31
|
v-for="(opt, index) in options"
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
</template>
|
|
41
42
|
|
|
42
43
|
<script setup lang="ts">
|
|
43
|
-
import { getCurrentInstance, nextTick, onMounted, ref, watch } from 'vue'
|
|
44
|
+
import { computed, getCurrentInstance, nextTick, onMounted, ref, watch } from 'vue'
|
|
44
45
|
// z-index 统一取 libs/config/zIndex.js(分段项盖住滑块指示器取 base 档)
|
|
45
46
|
import zIndexConfig from '../../libs/config/zIndex.js'
|
|
46
47
|
|
|
@@ -50,6 +51,17 @@ interface Props {
|
|
|
50
51
|
variant?: 'pill' | 'text'
|
|
51
52
|
/** 尺寸:md 标准;sm 小号(与页面 24rpx 字号胶囊控件同高,用于工具行等紧凑场景) */
|
|
52
53
|
size?: 'sm' | 'md'
|
|
54
|
+
/**
|
|
55
|
+
* text 变体水平间距(rpx)。不传则沿用 SCSS 默认 $dd-space-6;
|
|
56
|
+
* 项数多(如 7 项横滑)需要收窄时由消费方显式传值,避免把整体节奏写死在组件里
|
|
57
|
+
*/
|
|
58
|
+
gap?: number
|
|
59
|
+
/**
|
|
60
|
+
* 标签超长是否打点省略。默认 true(单行省略号);
|
|
61
|
+
* false 时不打点也不换行:项改为按内容自适应宽度(放弃等分)、标签强制单行,
|
|
62
|
+
* 总宽超出容器会溢出——标签过长时请精简文案或保留省略
|
|
63
|
+
*/
|
|
64
|
+
ellipsis?: boolean
|
|
53
65
|
}
|
|
54
66
|
|
|
55
67
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -57,6 +69,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
57
69
|
options: () => [],
|
|
58
70
|
variant: 'pill',
|
|
59
71
|
size: 'md',
|
|
72
|
+
ellipsis: true,
|
|
60
73
|
})
|
|
61
74
|
|
|
62
75
|
const emit = defineEmits<{
|
|
@@ -66,6 +79,10 @@ const emit = defineEmits<{
|
|
|
66
79
|
|
|
67
80
|
const instance = getCurrentInstance()
|
|
68
81
|
const indicatorStyle = ref({ width: '0px', transform: 'translateX(0px)' })
|
|
82
|
+
// 未传 gap 时不产出内联样式,交回 SCSS 里的 $dd-space-6 兜底
|
|
83
|
+
const gapStyle = computed(() =>
|
|
84
|
+
props.gap === undefined ? undefined : { columnGap: `${props.gap}rpx` },
|
|
85
|
+
)
|
|
69
86
|
|
|
70
87
|
function labelOf(opt: string | { label: string }): string {
|
|
71
88
|
return typeof opt === 'string' ? opt : opt.label
|
|
@@ -217,4 +234,24 @@ defineExpose({ refresh: measure })
|
|
|
217
234
|
line-height: 1.2;
|
|
218
235
|
@include dd-ellipsis(1);
|
|
219
236
|
}
|
|
237
|
+
|
|
238
|
+
// ellipsis=false:不打点不换行,项按内容自适应宽度(放弃等分),标签强制单行;
|
|
239
|
+
// ponytail: 总宽超出容器会溢出(未做横滑),标签过长请精简文案或保留省略
|
|
240
|
+
.dd-seg--no-ellipsis {
|
|
241
|
+
.dd-seg__item,
|
|
242
|
+
.dd-seg-text__item {
|
|
243
|
+
flex: 0 0 auto;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.dd-seg__label {
|
|
247
|
+
overflow: visible;
|
|
248
|
+
white-space: nowrap;
|
|
249
|
+
text-overflow: clip;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// text 变体容器本可换行,no-ellipsis 时整体强制单行
|
|
254
|
+
.dd-seg--text.dd-seg--no-ellipsis {
|
|
255
|
+
flex-wrap: nowrap;
|
|
256
|
+
}
|
|
220
257
|
</style>
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
v-for="cell in column"
|
|
11
11
|
:key="cell.index"
|
|
12
12
|
class="dd-waterfall__item"
|
|
13
|
+
:id="itemId(cell.index)"
|
|
13
14
|
:style="`margin-bottom: ${gap}rpx;`"
|
|
14
15
|
>
|
|
15
16
|
<slot :item="cell.item" :index="cell.index" />
|
|
@@ -19,7 +20,8 @@
|
|
|
19
20
|
</template>
|
|
20
21
|
|
|
21
22
|
<script setup lang="ts">
|
|
22
|
-
import { computed } from 'vue'
|
|
23
|
+
import { computed, getCurrentInstance, nextTick, onMounted, ref, watch } from 'vue'
|
|
24
|
+
import { assignColumns } from './waterfall'
|
|
23
25
|
|
|
24
26
|
type WaterfallItem = Record<string, any>
|
|
25
27
|
|
|
@@ -48,21 +50,77 @@ interface Cell {
|
|
|
48
50
|
index: number
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
const instance = getCurrentInstance()
|
|
54
|
+
/** 实例前缀:同一页面挂多个瀑布流时按 id 前缀串起「数据下标 → 视高」,
|
|
55
|
+
* 列内 DOM 顺序是列主序,不能靠 query 返回顺序对应数据顺序 */
|
|
56
|
+
const uid = `dd-wf-${Math.random().toString(36).slice(2, 8)}`
|
|
57
|
+
|
|
51
58
|
const columnCount = computed(() => Math.max(1, Math.floor(props.columns) || 1))
|
|
52
59
|
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
*/
|
|
60
|
+
/** 每项所在列号(下标 = 数据下标):首屏按奇偶预排,量到视高后改为「谁矮进谁」 */
|
|
61
|
+
const columnOf = ref<number[]>([])
|
|
62
|
+
|
|
63
|
+
const itemId = (index: number): string => `${uid}-${index}`
|
|
64
|
+
|
|
59
65
|
const columnList = computed<Cell[][]>(() => {
|
|
60
66
|
const cols = Array.from({ length: columnCount.value }, () => [] as Cell[])
|
|
61
67
|
;(props.modelValue || []).forEach((item, index) => {
|
|
62
|
-
|
|
68
|
+
const col = columnOf.value[index] ?? index % cols.length
|
|
69
|
+
cols[col].push({ item, index })
|
|
63
70
|
})
|
|
64
71
|
return cols
|
|
65
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)
|
|
66
124
|
</script>
|
|
67
125
|
|
|
68
126
|
<style lang="scss" scoped>
|
|
@@ -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/package.json
CHANGED
package/libs/config/color.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// 为了给某些特殊场景使用和向后兼容,无需删除此文件(2020-06-20)
|
|
2
|
-
const color = {
|
|
3
|
-
primary: '#3c9cff',
|
|
4
|
-
info: '#909399',
|
|
5
|
-
default: '#909399',
|
|
6
|
-
warning: '#f9ae3d',
|
|
7
|
-
error: '#f56c6c',
|
|
8
|
-
success: '#5ac725',
|
|
9
|
-
mainColor: '#303133',
|
|
10
|
-
contentColor: '#606266',
|
|
11
|
-
tipsColor: '#909399',
|
|
12
|
-
lightColor: '#c0c4cc',
|
|
13
|
-
borderColor: '#e4e7ed'
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default color
|
package/libs/config/props.js
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared props configuration store.
|
|
3
|
-
*
|
|
4
|
-
* Component defaults are registered lazily by each component props.js file so
|
|
5
|
-
* importing one component no longer pulls defaults for every component.
|
|
6
|
-
*/
|
|
7
|
-
import config from './config'
|
|
8
|
-
import zIndex from './zIndex.js'
|
|
9
|
-
import color from './color.js'
|
|
10
|
-
import { shallowMerge } from '../function/index.js'
|
|
11
|
-
|
|
12
|
-
const componentKeys = [
|
|
13
|
-
'actionSheet',
|
|
14
|
-
'album',
|
|
15
|
-
'alert',
|
|
16
|
-
'avatar',
|
|
17
|
-
'avatarGroup',
|
|
18
|
-
'backtop',
|
|
19
|
-
'badge',
|
|
20
|
-
'box',
|
|
21
|
-
'button',
|
|
22
|
-
'calendar',
|
|
23
|
-
'calendarStrip',
|
|
24
|
-
'card',
|
|
25
|
-
'cell',
|
|
26
|
-
'cellGroup',
|
|
27
|
-
'checkbox',
|
|
28
|
-
'checkboxGroup',
|
|
29
|
-
'circleProgress',
|
|
30
|
-
'code',
|
|
31
|
-
'codeInput',
|
|
32
|
-
'col',
|
|
33
|
-
'collapse',
|
|
34
|
-
'collapseItem',
|
|
35
|
-
'columnNotice',
|
|
36
|
-
'countDown',
|
|
37
|
-
'countTo',
|
|
38
|
-
'datetimePicker',
|
|
39
|
-
'divider',
|
|
40
|
-
'dropdown',
|
|
41
|
-
'dropdownItem',
|
|
42
|
-
'empty',
|
|
43
|
-
'form',
|
|
44
|
-
'formItem',
|
|
45
|
-
'gap',
|
|
46
|
-
'grid',
|
|
47
|
-
'gridItem',
|
|
48
|
-
'guide',
|
|
49
|
-
'icon',
|
|
50
|
-
'image',
|
|
51
|
-
'indexAnchor',
|
|
52
|
-
'indexItem',
|
|
53
|
-
'indexList',
|
|
54
|
-
'input',
|
|
55
|
-
'keyboard',
|
|
56
|
-
'line',
|
|
57
|
-
'lineProgress',
|
|
58
|
-
'link',
|
|
59
|
-
'list',
|
|
60
|
-
'listItem',
|
|
61
|
-
'loadingIcon',
|
|
62
|
-
'loadingPage',
|
|
63
|
-
'loadmore',
|
|
64
|
-
'modal',
|
|
65
|
-
'navbar',
|
|
66
|
-
'navbarMini',
|
|
67
|
-
'noNetwork',
|
|
68
|
-
'noticeBar',
|
|
69
|
-
'notify',
|
|
70
|
-
'novelReader',
|
|
71
|
-
'numberBox',
|
|
72
|
-
'numberKeyboard',
|
|
73
|
-
'overlay',
|
|
74
|
-
'parse',
|
|
75
|
-
'pdfReader',
|
|
76
|
-
'picker',
|
|
77
|
-
'pickerColumn',
|
|
78
|
-
'popover',
|
|
79
|
-
'popup',
|
|
80
|
-
'radio',
|
|
81
|
-
'radioGroup',
|
|
82
|
-
'rate',
|
|
83
|
-
'readMore',
|
|
84
|
-
'row',
|
|
85
|
-
'rowNotice',
|
|
86
|
-
'safeBottom',
|
|
87
|
-
'scrollList',
|
|
88
|
-
'search',
|
|
89
|
-
'section',
|
|
90
|
-
'skeleton',
|
|
91
|
-
'slider',
|
|
92
|
-
'statusBar',
|
|
93
|
-
'steps',
|
|
94
|
-
'stepsItem',
|
|
95
|
-
'sticky',
|
|
96
|
-
'subsection',
|
|
97
|
-
'swipeAction',
|
|
98
|
-
'swipeActionItem',
|
|
99
|
-
'swiper',
|
|
100
|
-
'swiperIndicator',
|
|
101
|
-
'switch',
|
|
102
|
-
'tabbar',
|
|
103
|
-
'tabbarItem',
|
|
104
|
-
'table',
|
|
105
|
-
'tabs',
|
|
106
|
-
'tabsItem',
|
|
107
|
-
'tag',
|
|
108
|
-
'td',
|
|
109
|
-
'text',
|
|
110
|
-
'textarea',
|
|
111
|
-
'th',
|
|
112
|
-
'toast',
|
|
113
|
-
'toolbar',
|
|
114
|
-
'tooltip',
|
|
115
|
-
'tr',
|
|
116
|
-
'transition',
|
|
117
|
-
'upload'
|
|
118
|
-
]
|
|
119
|
-
|
|
120
|
-
const props = {}
|
|
121
|
-
|
|
122
|
-
function ensureComponentProps(key) {
|
|
123
|
-
if (!props[key] || typeof props[key] !== 'object') {
|
|
124
|
-
props[key] = {}
|
|
125
|
-
}
|
|
126
|
-
return props[key]
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function isPlainObject(value) {
|
|
130
|
-
return Object.prototype.toString.call(value) === '[object Object]'
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function cloneDefaultValue(value) {
|
|
134
|
-
if (Array.isArray(value)) {
|
|
135
|
-
return value.slice()
|
|
136
|
-
}
|
|
137
|
-
if (isPlainObject(value)) {
|
|
138
|
-
return mergeDefaults({}, value)
|
|
139
|
-
}
|
|
140
|
-
return value
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function mergeDefaults(target, defaults = {}) {
|
|
144
|
-
if (!target || typeof target !== 'object' || !defaults || typeof defaults !== 'object') {
|
|
145
|
-
return target
|
|
146
|
-
}
|
|
147
|
-
Object.keys(defaults).forEach((key) => {
|
|
148
|
-
const defaultValue = defaults[key]
|
|
149
|
-
const targetValue = target[key]
|
|
150
|
-
if (targetValue === undefined) {
|
|
151
|
-
target[key] = cloneDefaultValue(defaultValue)
|
|
152
|
-
} else if (isPlainObject(targetValue) && isPlainObject(defaultValue)) {
|
|
153
|
-
mergeDefaults(targetValue, defaultValue)
|
|
154
|
-
}
|
|
155
|
-
})
|
|
156
|
-
return target
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
componentKeys.forEach(ensureComponentProps)
|
|
160
|
-
|
|
161
|
-
export function registerComponentProps(defaultProps = {}) {
|
|
162
|
-
Object.keys(defaultProps || {}).forEach((key) => {
|
|
163
|
-
const componentProps = ensureComponentProps(key)
|
|
164
|
-
mergeDefaults(componentProps, defaultProps[key])
|
|
165
|
-
})
|
|
166
|
-
return props
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export function setPropsConfig(configProps = {}) {
|
|
170
|
-
Object.keys(configProps || {}).forEach((key) => {
|
|
171
|
-
shallowMerge(ensureComponentProps(key), configProps[key])
|
|
172
|
-
})
|
|
173
|
-
return props
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function setConfig(configs = {}) {
|
|
177
|
-
shallowMerge(config, configs.config || {})
|
|
178
|
-
setPropsConfig(configs.props || {})
|
|
179
|
-
shallowMerge(color, configs.color || {})
|
|
180
|
-
shallowMerge(zIndex, configs.zIndex || {})
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// ponytail: 不提供全局配置注入入口(含 http 实例注册),DidaoUI 组件默认值由各组件 props.js 就地注册
|
|
184
|
-
export default props
|
package/libs/mixin/button.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { defineMixin } from '../vue'
|
|
2
|
-
|
|
3
|
-
export const buttonMixin = defineMixin({
|
|
4
|
-
props: {
|
|
5
|
-
lang: String,
|
|
6
|
-
sessionFrom: String,
|
|
7
|
-
sendMessageTitle: String,
|
|
8
|
-
sendMessagePath: String,
|
|
9
|
-
sendMessageImg: String,
|
|
10
|
-
showMessageCard: Boolean,
|
|
11
|
-
appParameter: String,
|
|
12
|
-
formType: String,
|
|
13
|
-
openType: String
|
|
14
|
-
}
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
export default buttonMixin
|
|
18
|
-
|
package/libs/mixin/mixin.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// ponytail: 组件库基础 mixin 的轻量版——只保留组件实际消费的能力
|
|
2
|
-
// (props customStyle/customClass/url/linkType、getRect)。
|
|
3
|
-
// 不携带运行时主题注入,DidaoUI 用 scss 变量体系,不需要。
|
|
4
|
-
import { defineMixin } from '../vue'
|
|
5
|
-
|
|
6
|
-
export const mixin = defineMixin({
|
|
7
|
-
props: {
|
|
8
|
-
customStyle: {
|
|
9
|
-
type: [Object, String],
|
|
10
|
-
default: () => ({})
|
|
11
|
-
},
|
|
12
|
-
customClass: {
|
|
13
|
-
type: String,
|
|
14
|
-
default: ''
|
|
15
|
-
},
|
|
16
|
-
url: {
|
|
17
|
-
type: String,
|
|
18
|
-
default: ''
|
|
19
|
-
},
|
|
20
|
-
linkType: {
|
|
21
|
-
type: String,
|
|
22
|
-
default: 'navigateTo'
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
methods: {
|
|
26
|
-
// 查询组件内节点信息
|
|
27
|
-
async getRect(selector, all = false) {
|
|
28
|
-
const inst = uni.createSelectorQuery().in(this)
|
|
29
|
-
const q = all ? inst.selectAll(selector) : inst.select(selector)
|
|
30
|
-
return new Promise((resolve) => {
|
|
31
|
-
q.boundingClientRect((rect) => {
|
|
32
|
-
resolve(all && Array.isArray(rect) && rect.length ? rect : rect)
|
|
33
|
-
}).exec()
|
|
34
|
-
})
|
|
35
|
-
},
|
|
36
|
-
// 空操作:键盘等组件模板 @touchmove.stop.prevent="noop" 依赖此方法,
|
|
37
|
-
// 缺失时 handler 为 undefined 会在渲染期抛 _withMods 错误
|
|
38
|
-
noop(e) {
|
|
39
|
-
e && typeof e.stopPropagation === 'function' && e.stopPropagation()
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
export default mixin
|
package/libs/mixin/mpMixin.js
DELETED
package/libs/mixin/openType.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { defineMixin } from '../vue'
|
|
2
|
-
|
|
3
|
-
export const openType = defineMixin({
|
|
4
|
-
props: {
|
|
5
|
-
openType: String
|
|
6
|
-
},
|
|
7
|
-
methods: {
|
|
8
|
-
onGetUserInfo(event) {
|
|
9
|
-
this.$emit('getuserinfo', event.detail)
|
|
10
|
-
},
|
|
11
|
-
onContact(event) {
|
|
12
|
-
this.$emit('contact', event.detail)
|
|
13
|
-
},
|
|
14
|
-
onGetPhoneNumber(event) {
|
|
15
|
-
this.$emit('getphonenumber', event.detail)
|
|
16
|
-
},
|
|
17
|
-
onError(event) {
|
|
18
|
-
this.$emit('error', event.detail)
|
|
19
|
-
},
|
|
20
|
-
onLaunchApp(event) {
|
|
21
|
-
this.$emit('launchapp', event.detail)
|
|
22
|
-
},
|
|
23
|
-
onOpenSetting(event) {
|
|
24
|
-
this.$emit('opensetting', event.detail)
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
})
|
package/libs/vue.js
DELETED