papayaui 0.2.16 → 0.2.18
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/cascader/cascader.vue +1 -0
- package/components/cascader/props.ts +1 -0
- package/components/cascader/search-view.vue +4 -4
- package/components/cell/cell.vue +4 -2
- package/components/popover/demo.vue +10 -0
- package/components/popover/popover.scss +80 -20
- package/components/popover/popover.vue +76 -39
- package/components/popover/props.ts +66 -12
- package/components/uploader/demo.vue +5 -0
- package/components/uploader/uploader.vue +6 -6
- package/demos/popover/demo-1.vue +15 -7
- package/demos/popover/demo-2.vue +25 -0
- package/demos/popover/demo-3.vue +11 -0
- package/demos/uploader/demo-9.vue +53 -0
- package/package.json +1 -1
- package/styles/color.scss +2 -0
- package/styles/layout_border.scss +2 -3
- package/components/.DS_Store +0 -0
- package/fonts/.DS_Store +0 -0
- package/images/.DS_Store +0 -0
|
@@ -31,7 +31,7 @@ const ns = useNamespace('cascader-search-view')
|
|
|
31
31
|
const props = defineProps(cascaderSearchViewProps)
|
|
32
32
|
const emit = defineEmits(cascaderSearchViewEmits)
|
|
33
33
|
|
|
34
|
-
const { options, fieldNames, searchText, lazySearch } = toRefs(props)
|
|
34
|
+
const { options, fieldNames, searchText, lazySearch, maxLevel } = toRefs(props)
|
|
35
35
|
|
|
36
36
|
const searchData = ref<SearchNode[]>([])
|
|
37
37
|
const loading = ref<boolean>(false)
|
|
@@ -42,7 +42,7 @@ watch(searchText, (newVal) => {
|
|
|
42
42
|
|
|
43
43
|
const getFlattenTreeData = (data: CascaderOption[], remote?: boolean, filterStr?: string) => {
|
|
44
44
|
const result: SearchNode[] = []
|
|
45
|
-
const loop = (list: CascaderOption[], prefixLabel = '', parentPath = '') => {
|
|
45
|
+
const loop = (list: CascaderOption[], prefixLabel = '', parentPath = '', level = 0) => {
|
|
46
46
|
list.forEach((item, index) => {
|
|
47
47
|
const newItem = item as any
|
|
48
48
|
const node: SearchNode = {
|
|
@@ -51,8 +51,8 @@ const getFlattenTreeData = (data: CascaderOption[], remote?: boolean, filterStr?
|
|
|
51
51
|
__label: `${prefixLabel}${prefixLabel ? '/' : ''}${newItem[fieldNames.value.label]}`,
|
|
52
52
|
__remoteSearch: !!remote,
|
|
53
53
|
}
|
|
54
|
-
if (newItem[fieldNames.value.children]?.length) {
|
|
55
|
-
loop(newItem[fieldNames.value.children], node.__label, node.__path)
|
|
54
|
+
if (newItem[fieldNames.value.children]?.length && level < maxLevel.value - 1) {
|
|
55
|
+
loop(newItem[fieldNames.value.children], node.__label, node.__path, level + 1)
|
|
56
56
|
} else {
|
|
57
57
|
;(filterStr ? node.__label.includes(filterStr) : true) && result.push(node)
|
|
58
58
|
}
|
package/components/cell/cell.vue
CHANGED
|
@@ -31,8 +31,10 @@
|
|
|
31
31
|
})
|
|
32
32
|
"
|
|
33
33
|
>
|
|
34
|
-
<
|
|
35
|
-
|
|
34
|
+
<text v-if="!$slots.default" :selectable="selectable" :user-select="selectable">
|
|
35
|
+
{{ value }}
|
|
36
|
+
</text>
|
|
37
|
+
<slot v-else />
|
|
36
38
|
|
|
37
39
|
<view v-if="errorMessage" :class="ns.e('error-message')">
|
|
38
40
|
{{ errorMessage }}
|
|
@@ -2,11 +2,21 @@
|
|
|
2
2
|
<DocDemoBlock title="基础用法" card>
|
|
3
3
|
<Demo1 />
|
|
4
4
|
</DocDemoBlock>
|
|
5
|
+
|
|
6
|
+
<DocDemoBlock title="选项配置" card>
|
|
7
|
+
<Demo2 />
|
|
8
|
+
</DocDemoBlock>
|
|
9
|
+
|
|
10
|
+
<DocDemoBlock title="自定义内容" card>
|
|
11
|
+
<Demo3 />
|
|
12
|
+
</DocDemoBlock>
|
|
5
13
|
</template>
|
|
6
14
|
|
|
7
15
|
<script lang="ts" setup>
|
|
8
16
|
import DocDemoBlock from '../../doc/doc-demo-block.vue'
|
|
9
17
|
import Demo1 from '../../demos/popover/demo-1.vue'
|
|
18
|
+
import Demo2 from '../../demos/popover/demo-2.vue'
|
|
19
|
+
import Demo3 from '../../demos/popover/demo-3.vue'
|
|
10
20
|
</script>
|
|
11
21
|
|
|
12
22
|
<style lang="scss" scoped></style>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
@import '../../styles/vars.scss';
|
|
2
2
|
.#{$prefix}-popover {
|
|
3
|
-
$arrowSize:
|
|
4
|
-
$darkColor: #
|
|
3
|
+
$arrowSize: _var(popover-arrow-size, 6px);
|
|
4
|
+
$darkColor: #4c4c4c;
|
|
5
|
+
$lightColor: #fff;
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
&-overlay {
|
|
7
|
+
&__overlay {
|
|
8
8
|
position: fixed;
|
|
9
9
|
top: 0;
|
|
10
10
|
left: 0;
|
|
@@ -12,18 +12,23 @@
|
|
|
12
12
|
height: 100vh;
|
|
13
13
|
background-color: transparent;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
&__wrapper {
|
|
17
|
+
display: inline-block;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&__content {
|
|
16
21
|
position: fixed;
|
|
17
22
|
left: 0;
|
|
18
23
|
top: 0;
|
|
19
24
|
margin: 0;
|
|
20
25
|
padding: 0;
|
|
21
|
-
border-radius:
|
|
26
|
+
border-radius: _var(popover-radius, 8px);
|
|
22
27
|
opacity: 0.2;
|
|
23
28
|
box-shadow: 0px 0px 5px #dcdee0;
|
|
24
29
|
}
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
&__arrow {
|
|
27
32
|
position: absolute;
|
|
28
33
|
width: $arrowSize;
|
|
29
34
|
height: $arrowSize;
|
|
@@ -34,29 +39,84 @@
|
|
|
34
39
|
height: $arrowSize;
|
|
35
40
|
z-index: -1;
|
|
36
41
|
content: ' ';
|
|
42
|
+
border-width: 1px;
|
|
43
|
+
border-style: solid;
|
|
44
|
+
border-bottom-color: transparent !important;
|
|
45
|
+
border-right-color: transparent !important;
|
|
37
46
|
transform: rotate(45deg);
|
|
38
47
|
box-sizing: border-box;
|
|
39
48
|
}
|
|
40
49
|
}
|
|
41
50
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
&__action {
|
|
52
|
+
position: relative;
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
box-sizing: border-box;
|
|
56
|
+
width: _var(popover-action-width, 128px);
|
|
57
|
+
height: _var(popover-action-height, 44px);
|
|
58
|
+
padding: 0 _var(popover-action-padding, 16px);
|
|
59
|
+
font-size: _var(popover-action-font-size, 14px);
|
|
60
|
+
line-height: _var(popover-action-line-height, 20px);
|
|
61
|
+
cursor: pointer;
|
|
62
|
+
@include _setVar(color-border, #ebedf0);
|
|
63
|
+
|
|
64
|
+
&-icon {
|
|
65
|
+
margin-right: 8px;
|
|
66
|
+
font-size: _var(popover-action-icon-size, 20px);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&-text {
|
|
70
|
+
display: flex;
|
|
71
|
+
flex: 1;
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
height: 100%;
|
|
75
|
+
}
|
|
45
76
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
77
|
+
|
|
78
|
+
@each $theme in light, dark {
|
|
79
|
+
$color: $darkColor;
|
|
80
|
+
$backgroundColor: $lightColor;
|
|
81
|
+
@if $theme == dark {
|
|
82
|
+
$color: $lightColor;
|
|
83
|
+
$backgroundColor: $darkColor;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&--#{$theme} {
|
|
87
|
+
color: _var(popover-#{$theme}-text-color, $color);
|
|
88
|
+
background: _var(popover-#{$theme}-background, $backgroundColor);
|
|
89
|
+
}
|
|
90
|
+
&--#{$theme} &__arrow {
|
|
91
|
+
&::before {
|
|
92
|
+
border-color: _var(popover-#{$theme}-background, $backgroundColor);
|
|
93
|
+
background: _var(popover-#{$theme}-background, $backgroundColor);
|
|
94
|
+
}
|
|
52
95
|
}
|
|
53
96
|
}
|
|
54
97
|
|
|
55
|
-
|
|
56
|
-
$top: calc($arrowSize / 2);
|
|
98
|
+
&--bottom &__arrow {
|
|
99
|
+
$top: calc($arrowSize / -2);
|
|
57
100
|
left: 50%;
|
|
58
|
-
top:
|
|
59
|
-
margin-left:
|
|
101
|
+
top: $top;
|
|
102
|
+
margin-left: $top;
|
|
60
103
|
border-top-left-radius: 2px;
|
|
61
104
|
}
|
|
105
|
+
|
|
106
|
+
&--with-icon &__action-text {
|
|
107
|
+
justify-content: flex-start;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&--light &--action-active {
|
|
111
|
+
background-color: #f2f3f5;
|
|
112
|
+
}
|
|
113
|
+
&--dark &--action-active {
|
|
114
|
+
background-color: #444;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&--disabled {
|
|
118
|
+
color: _var(color-disabled);
|
|
119
|
+
background-color: transparent !important;
|
|
120
|
+
cursor: not-allowed;
|
|
121
|
+
}
|
|
62
122
|
}
|
|
@@ -1,46 +1,58 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view :class="
|
|
3
|
-
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
2
|
+
<view v-show="show" :class="ns.e('overlay')" @tap="onClickOverlay"></view>
|
|
3
|
+
<view :class="ns.e('wrapper')" @tap.stop="onVisibleChange()">
|
|
4
|
+
<slot name="reference" />
|
|
5
|
+
</view>
|
|
6
|
+
<view v-show="show" :class="[ns.e('content'), ns.m(theme), ns.m('bottom')]" :style="contentStyle">
|
|
7
|
+
<template v-if="!$slots.default">
|
|
8
|
+
<view
|
|
9
|
+
v-for="(action, index) in actions"
|
|
10
|
+
:key="index"
|
|
11
|
+
:class="[
|
|
12
|
+
ns.e('action'),
|
|
13
|
+
ns.is('with-icon', !!action.icon),
|
|
14
|
+
ns.is('disabled', action.disabled),
|
|
15
|
+
]"
|
|
16
|
+
:style="ns.style({ color: action.color })"
|
|
17
|
+
:hover-class="ns.m('action-active')"
|
|
18
|
+
@tap.stop="onSelect(action, index)"
|
|
19
|
+
>
|
|
20
|
+
<IconComponent
|
|
21
|
+
v-if="action.icon"
|
|
22
|
+
:class="ns.e('action-icon')"
|
|
23
|
+
:class-prefix="iconPrefix"
|
|
24
|
+
:name="action.icon"
|
|
25
|
+
/>
|
|
26
|
+
<view :class="[ns.e('action-text'), { 'border-bottom': index < actions.length - 1 }]">
|
|
27
|
+
{{ action.text }}
|
|
28
|
+
</view>
|
|
21
29
|
</view>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
</template>
|
|
31
|
+
<slot v-else />
|
|
32
|
+
|
|
33
|
+
<view :class="ns.e('arrow')" :style="{ transform: `translateX(${arrowLeft}px)` }"></view>
|
|
25
34
|
</view>
|
|
26
35
|
</template>
|
|
27
36
|
|
|
28
37
|
<script lang="ts" setup>
|
|
29
|
-
import { getUnitValue } from '../../utils'
|
|
30
38
|
import { computed, getCurrentInstance, nextTick, ref, watch } from 'vue'
|
|
31
|
-
import useRect from '../../hooks/useRect'
|
|
32
39
|
import useNamespace from '../../core/useNamespace'
|
|
33
|
-
import
|
|
40
|
+
import useRect from '../../hooks/useRect'
|
|
41
|
+
import { getUnitValue } from '../../utils'
|
|
42
|
+
import IconComponent from '../icon/icon.vue'
|
|
43
|
+
import type { PopoverAction } from './props'
|
|
44
|
+
import { popoverEmits, popoverProps } from './props'
|
|
34
45
|
|
|
35
46
|
const ns = useNamespace('popover')
|
|
36
47
|
|
|
37
|
-
defineProps(popoverProps)
|
|
48
|
+
const props = defineProps(popoverProps)
|
|
49
|
+
const emit = defineEmits(popoverEmits)
|
|
38
50
|
|
|
39
51
|
const show = ref<boolean>(false)
|
|
40
52
|
|
|
41
53
|
const instance = getCurrentInstance()
|
|
42
54
|
|
|
43
|
-
const
|
|
55
|
+
const wrapperRect = ref<Required<UniApp.NodeInfo>>({
|
|
44
56
|
left: 0,
|
|
45
57
|
right: 0,
|
|
46
58
|
top: 0,
|
|
@@ -48,31 +60,41 @@ const tooltipRect = ref<Required<UniApp.NodeInfo>>({
|
|
|
48
60
|
width: 0,
|
|
49
61
|
height: 0,
|
|
50
62
|
} as Required<UniApp.NodeInfo>)
|
|
51
|
-
const
|
|
63
|
+
const contentWidth = ref<number>(0)
|
|
52
64
|
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
(tooltipRect.value.width || 0) / 2
|
|
58
|
-
)
|
|
65
|
+
const contentOffsetLeft = computed<number>(() => {
|
|
66
|
+
const { left = 0, width = 0 } = wrapperRect.value
|
|
67
|
+
const offsetLeft = left + width / 2 - contentWidth.value / 2
|
|
68
|
+
return offsetLeft
|
|
59
69
|
})
|
|
60
70
|
|
|
61
71
|
const arrowLeft = computed(() => {
|
|
62
|
-
return
|
|
72
|
+
return contentOffsetLeft.value < 0 ? contentOffsetLeft.value : 0
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const contentStyle = computed(() => {
|
|
76
|
+
return {
|
|
77
|
+
opacity: wrapperRect.value.height && contentWidth ? '1' : '0',
|
|
78
|
+
top: getUnitValue(wrapperRect.value.top + wrapperRect.value.height + props.offset[1], 'px'),
|
|
79
|
+
left: getUnitValue(
|
|
80
|
+
(contentOffsetLeft.value < 0 ? 0 : contentOffsetLeft.value) + props.offset[0],
|
|
81
|
+
'px',
|
|
82
|
+
),
|
|
83
|
+
zIndex: props.zIndex,
|
|
84
|
+
}
|
|
63
85
|
})
|
|
64
86
|
|
|
65
87
|
watch(show, (newVal) => {
|
|
66
88
|
if (instance && newVal) {
|
|
67
89
|
nextTick(() => {
|
|
68
|
-
useRect(instance, `.${ns.
|
|
90
|
+
useRect(instance, `.${ns.e('wrapper')}`).then((res) => {
|
|
69
91
|
if (res) {
|
|
70
|
-
|
|
92
|
+
wrapperRect.value = res
|
|
71
93
|
}
|
|
72
94
|
})
|
|
73
|
-
useRect(instance, `.${ns.
|
|
95
|
+
useRect(instance, `.${ns.e('content')}`).then((res) => {
|
|
74
96
|
if (res) {
|
|
75
|
-
|
|
97
|
+
contentWidth.value = res.width || 0
|
|
76
98
|
}
|
|
77
99
|
})
|
|
78
100
|
})
|
|
@@ -82,6 +104,21 @@ watch(show, (newVal) => {
|
|
|
82
104
|
const onVisibleChange = (visible = !show.value) => {
|
|
83
105
|
show.value = visible
|
|
84
106
|
}
|
|
107
|
+
|
|
108
|
+
const onClickOverlay = () => {
|
|
109
|
+
emit('click-overlay')
|
|
110
|
+
if (props.closeOnClickOverlay) {
|
|
111
|
+
onVisibleChange(false)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const onSelect = (action: PopoverAction, index: number) => {
|
|
116
|
+
if (action.disabled) return
|
|
117
|
+
emit('select', action, index)
|
|
118
|
+
if (props.closeOnClickAction) {
|
|
119
|
+
onVisibleChange(false)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
85
122
|
</script>
|
|
86
123
|
|
|
87
124
|
<style lang="scss">
|
|
@@ -1,19 +1,28 @@
|
|
|
1
|
-
import type { ExtractPropTypes } from 'vue'
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue'
|
|
2
|
+
import { isUndefined } from '../../utils'
|
|
3
|
+
import { iconProps } from '../icon'
|
|
4
|
+
|
|
5
|
+
export type PopoverTheme = 'light' | 'dark'
|
|
6
|
+
export type PopoverPlacement = 'bottom'
|
|
7
|
+
|
|
8
|
+
export interface PopoverAction {
|
|
9
|
+
/** 选项文字 */
|
|
10
|
+
text: string
|
|
11
|
+
/** 文字左侧的图标,支持传入图标名称或图片链接,等同于 Icon 组件的 name 属性 */
|
|
12
|
+
icon?: string
|
|
13
|
+
/** 选项文字颜色 */
|
|
14
|
+
color?: string
|
|
15
|
+
/** 是否为禁用状态 */
|
|
16
|
+
disabled?: boolean
|
|
17
|
+
}
|
|
2
18
|
|
|
3
19
|
export const popoverProps = {
|
|
4
20
|
/**
|
|
5
|
-
*
|
|
21
|
+
* 选项列表
|
|
6
22
|
*/
|
|
7
|
-
|
|
8
|
-
type:
|
|
9
|
-
default:
|
|
10
|
-
},
|
|
11
|
-
/**
|
|
12
|
-
* 浮窗宽度
|
|
13
|
-
*/
|
|
14
|
-
width: {
|
|
15
|
-
type: [String, Number],
|
|
16
|
-
default: '300',
|
|
23
|
+
actions: {
|
|
24
|
+
type: Array as PropType<PopoverAction[]>,
|
|
25
|
+
default: () => [],
|
|
17
26
|
},
|
|
18
27
|
/**
|
|
19
28
|
* 浮窗层级
|
|
@@ -22,6 +31,51 @@ export const popoverProps = {
|
|
|
22
31
|
type: Number,
|
|
23
32
|
default: 9,
|
|
24
33
|
},
|
|
34
|
+
/**
|
|
35
|
+
* 主题
|
|
36
|
+
*/
|
|
37
|
+
theme: {
|
|
38
|
+
type: String as PropType<PopoverTheme>,
|
|
39
|
+
default: 'light',
|
|
40
|
+
},
|
|
41
|
+
/**
|
|
42
|
+
* 弹出位置
|
|
43
|
+
*/
|
|
44
|
+
placement: {
|
|
45
|
+
type: String as PropType<PopoverPlacement>,
|
|
46
|
+
default: 'bottom',
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* 出现位置的偏移量
|
|
50
|
+
*/
|
|
51
|
+
offset: {
|
|
52
|
+
type: Object as PropType<[number, number]>,
|
|
53
|
+
default: () => [0, 8],
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* 是否在点击选项后关闭
|
|
57
|
+
*/
|
|
58
|
+
closeOnClickAction: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: true,
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* 是否在点击遮罩层后关闭菜单
|
|
64
|
+
*/
|
|
65
|
+
closeOnClickOverlay: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: true,
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* 图标类名前缀,等同于 Icon 组件的 class-prefix 属性
|
|
71
|
+
*/
|
|
72
|
+
iconPrefix: iconProps.classPrefix,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const popoverEmits = {
|
|
76
|
+
select: (action: PopoverAction, _index: number) => !isUndefined(action),
|
|
77
|
+
'click-overlay': () => true,
|
|
25
78
|
}
|
|
26
79
|
|
|
27
80
|
export type PopoverProps = ExtractPropTypes<typeof popoverProps>
|
|
81
|
+
export type PopoverEmits = typeof popoverEmits
|
|
@@ -31,6 +31,10 @@
|
|
|
31
31
|
<Demo8 />
|
|
32
32
|
</DocDemoBlock>
|
|
33
33
|
|
|
34
|
+
<DocDemoBlock title="自定义预览" card>
|
|
35
|
+
<Demo9 />
|
|
36
|
+
</DocDemoBlock>
|
|
37
|
+
|
|
34
38
|
<pa-safe-bottom />
|
|
35
39
|
</template>
|
|
36
40
|
|
|
@@ -43,6 +47,7 @@ import Demo5 from '../../demos/uploader/demo-5.vue'
|
|
|
43
47
|
import Demo6 from '../../demos/uploader/demo-6.vue'
|
|
44
48
|
import Demo7 from '../../demos/uploader/demo-7.vue'
|
|
45
49
|
import Demo8 from '../../demos/uploader/demo-8.vue'
|
|
50
|
+
import Demo9 from '../../demos/uploader/demo-9.vue'
|
|
46
51
|
import DocDemoBlock from '../../doc/doc-demo-block.vue'
|
|
47
52
|
</script>
|
|
48
53
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
<view :class="[ns.e('wrapper'), ns.is('disabled', disabled)]">
|
|
4
4
|
<view v-for="(file, index) in fileList" :key="index" :class="ns.e('preview')">
|
|
5
5
|
<view
|
|
6
|
+
v-if="!$slots.file"
|
|
6
7
|
:class="[ns.e('preview-image'), ns.e(`preview-type-${file.type ?? 'image'}`)]"
|
|
7
8
|
:style="sizeStyle"
|
|
8
9
|
@click="onPreview(file, index)"
|
|
@@ -19,6 +20,8 @@
|
|
|
19
20
|
<text>{{ file.type }}</text>
|
|
20
21
|
</template>
|
|
21
22
|
</view>
|
|
23
|
+
<slot v-else name="file" :file="file" :index="index" :style="sizeStyle" />
|
|
24
|
+
|
|
22
25
|
<view
|
|
23
26
|
v-if="deletable && file.deletable !== false"
|
|
24
27
|
:class="ns.e('preview-delete')"
|
|
@@ -87,13 +90,10 @@ const onChooseFile = () => {
|
|
|
87
90
|
})
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
const beforeValid = <T extends object>(
|
|
91
|
-
files: T,
|
|
92
|
-
fun?: (files: T) => boolean | Promise<unknown>,
|
|
93
|
-
) => {
|
|
93
|
+
const beforeValid = <T extends object>(files: T, fn?: (files: T) => boolean | Promise<unknown>) => {
|
|
94
94
|
return new Promise<void>((resolve, reject) => {
|
|
95
|
-
if (typeof
|
|
96
|
-
const res =
|
|
95
|
+
if (typeof fn === 'function') {
|
|
96
|
+
const res = fn(files)
|
|
97
97
|
if (res === false) {
|
|
98
98
|
return reject()
|
|
99
99
|
}
|
package/demos/popover/demo-1.vue
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<pa-popover
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
<pa-popover :actions="actions">
|
|
3
|
+
<template #reference>
|
|
4
|
+
<pa-button>浅色风格</pa-button>
|
|
5
|
+
</template>
|
|
6
|
+
</pa-popover>
|
|
7
|
+
|
|
8
|
+
<pa-popover theme="dark" :actions="actions">
|
|
9
|
+
<template #reference>
|
|
10
|
+
<pa-button class="ml-30">深色风格</pa-button>
|
|
9
11
|
</template>
|
|
10
12
|
</pa-popover>
|
|
11
13
|
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import { ref } from 'vue'
|
|
17
|
+
|
|
18
|
+
const actions = ref([{ text: '选项一' }, { text: '选项二' }, { text: '选项三' }])
|
|
19
|
+
</script>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<pa-popover :actions="actions1">
|
|
3
|
+
<template #reference>
|
|
4
|
+
<pa-button>展示图标</pa-button>
|
|
5
|
+
</template>
|
|
6
|
+
</pa-popover>
|
|
7
|
+
|
|
8
|
+
<pa-popover theme="dark" :actions="actions2">
|
|
9
|
+
<template #reference>
|
|
10
|
+
<pa-button class="ml-30">禁用选项</pa-button>
|
|
11
|
+
</template>
|
|
12
|
+
</pa-popover>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import { ref } from 'vue'
|
|
17
|
+
|
|
18
|
+
const actions1 = ref([
|
|
19
|
+
{ text: '选项一', icon: 'plus' },
|
|
20
|
+
{ text: '选项二', icon: 'scan' },
|
|
21
|
+
{ text: '选项三', icon: 'refresh' },
|
|
22
|
+
])
|
|
23
|
+
|
|
24
|
+
const actions2 = ref([{ text: '选项一', disabled: true }, { text: '选项二' }, { text: '选项三' }])
|
|
25
|
+
</script>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<pa-popover>
|
|
3
|
+
<template #reference>
|
|
4
|
+
<pa-button>基础用法</pa-button>
|
|
5
|
+
</template>
|
|
6
|
+
<view class="p-20" style="width: 150px">
|
|
7
|
+
<text class="text-32">标题</text>
|
|
8
|
+
<text class="text-28 block">这是一段内容,这是一段内容,这是一段内容,这是一段内容。</text>
|
|
9
|
+
</view>
|
|
10
|
+
</pa-popover>
|
|
11
|
+
</template>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<pa-uploader v-model:file-list="fileList" preview-size="100px">
|
|
3
|
+
<template #file="{ file, index, style }">
|
|
4
|
+
<view class="file-item" :style="style">
|
|
5
|
+
<image :src="file.url" :style="style" />
|
|
6
|
+
<view class="mark">图片{{ index + 1 }}</view>
|
|
7
|
+
</view>
|
|
8
|
+
</template>
|
|
9
|
+
</pa-uploader>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
import { ref } from 'vue'
|
|
14
|
+
// 仅做本地示例,使用时请用网络图片
|
|
15
|
+
import img1 from '../../images/demo2.jpeg'
|
|
16
|
+
import img2 from '../../images/demo3.jpg'
|
|
17
|
+
|
|
18
|
+
let src1 = ''
|
|
19
|
+
let src2 = ''
|
|
20
|
+
// #ifdef MP
|
|
21
|
+
const fileManager = uni.getFileSystemManager()
|
|
22
|
+
src1 = 'data:image/jpeg;base64,' + fileManager.readFileSync(img1, 'base64')
|
|
23
|
+
src2 = 'data:image/jpeg;base64,' + fileManager.readFileSync(img2, 'base64')
|
|
24
|
+
// #endif
|
|
25
|
+
// #ifdef H5
|
|
26
|
+
src1 = img1
|
|
27
|
+
src2 = img2
|
|
28
|
+
// #endif
|
|
29
|
+
|
|
30
|
+
const fileList = ref([
|
|
31
|
+
{
|
|
32
|
+
url: src1,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
url: src2,
|
|
36
|
+
},
|
|
37
|
+
])
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<style lang="scss" scoped>
|
|
41
|
+
.file-item {
|
|
42
|
+
position: relative;
|
|
43
|
+
}
|
|
44
|
+
.mark {
|
|
45
|
+
position: absolute;
|
|
46
|
+
left: 0;
|
|
47
|
+
bottom: 0;
|
|
48
|
+
width: 100px;
|
|
49
|
+
color: #fff;
|
|
50
|
+
text-align: center;
|
|
51
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
52
|
+
}
|
|
53
|
+
</style>
|
package/package.json
CHANGED
package/styles/color.scss
CHANGED
|
@@ -20,6 +20,7 @@ $color-text-black-3: #969799;
|
|
|
20
20
|
|
|
21
21
|
$color-active: $color-gray;
|
|
22
22
|
$color-disabled: #c8c9cc;
|
|
23
|
+
$color-border: #e4e7ed;
|
|
23
24
|
|
|
24
25
|
$colors: (
|
|
25
26
|
primary: $color-primary,
|
|
@@ -35,4 +36,5 @@ $colors: (
|
|
|
35
36
|
red: $color-danger,
|
|
36
37
|
active: $color-active,
|
|
37
38
|
disabled: $color-disabled,
|
|
39
|
+
border: $color-border,
|
|
38
40
|
);
|
|
@@ -22,13 +22,12 @@
|
|
|
22
22
|
top: 0;
|
|
23
23
|
pointer-events: none;
|
|
24
24
|
box-sizing: border-box;
|
|
25
|
-
-webkit-transform-origin: 0 0;
|
|
26
25
|
transform-origin: 0 0;
|
|
27
26
|
// 多加0.1%,能解决有时候边框缺失的问题
|
|
28
27
|
width: 199.8%;
|
|
29
28
|
height: 199.7%;
|
|
30
|
-
transform: scale(0.5
|
|
31
|
-
border: 0 solid
|
|
29
|
+
transform: scale(0.5);
|
|
30
|
+
border: 0 solid _var(color-border);
|
|
32
31
|
z-index: 2;
|
|
33
32
|
}
|
|
34
33
|
|
package/components/.DS_Store
DELETED
|
Binary file
|
package/fonts/.DS_Store
DELETED
|
Binary file
|
package/images/.DS_Store
DELETED
|
Binary file
|