@solar-taro/ui-vant 0.0.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/CHANGELOG.md +3 -0
- package/README.md +11 -0
- package/eslint.config.cjs +22 -0
- package/package.json +22 -0
- package/project.json +29 -0
- package/src/cascader-picker/index.ts +1 -0
- package/src/cascader-picker/index.vue +210 -0
- package/src/date-range-picker/index.scss +47 -0
- package/src/date-range-picker/index.ts +1 -0
- package/src/date-range-picker/index.vue +201 -0
- package/src/directives/bind-function.ts +22 -0
- package/src/directives/datetime-picker.ts +33 -0
- package/src/directives/index.ts +3 -0
- package/src/directives/readonly.ts +5 -0
- package/src/index.scss +149 -0
- package/src/index.ts +12 -0
- package/src/item/index.scss +37 -0
- package/src/item/index.ts +1 -0
- package/src/item/index.vue +34 -0
- package/src/list/index.ts +1 -0
- package/src/list/index.vue +86 -0
- package/src/modal/index.ts +1 -0
- package/src/modal/index.vue +55 -0
- package/src/opper-controller/index.scss +37 -0
- package/src/opper-controller/index.ts +1 -0
- package/src/opper-controller/index.vue +365 -0
- package/src/overlay/index.ts +1 -0
- package/src/overlay/overlay.ts +76 -0
- package/src/plugin.ts +14 -0
- package/src/select-picker/index.ts +1 -0
- package/src/select-picker/index.vue +80 -0
- package/src/selector/index.scss +16 -0
- package/src/selector/index.ts +1 -0
- package/src/selector/index.vue +252 -0
- package/src/tabbar/index.scss +78 -0
- package/src/tabbar/index.ts +1 -0
- package/src/tabbar/index.vue +56 -0
- package/src/vant.interface.ts +96 -0
- package/tsconfig.json +21 -0
- package/tsconfig.lib.json +24 -0
- package/tsconfig.spec.json +28 -0
- package/vite.config.ts +130 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<slot :present="present" :label="inputValue">
|
|
3
|
+
<van-field
|
|
4
|
+
v-if="type === 'field'"
|
|
5
|
+
v-readonly
|
|
6
|
+
v-bind="$attrs"
|
|
7
|
+
class="sun-selector"
|
|
8
|
+
:label="label"
|
|
9
|
+
:value="inputValue"
|
|
10
|
+
:placeholder="placeholder"
|
|
11
|
+
:required="required"
|
|
12
|
+
:disabled="disabled"
|
|
13
|
+
@click-input="present()">
|
|
14
|
+
<van-icon v-if="canClear" slot="right-icon" name="clear" @tap="clear()" />
|
|
15
|
+
</van-field>
|
|
16
|
+
|
|
17
|
+
<van-search
|
|
18
|
+
v-else-if="type === 'search'"
|
|
19
|
+
v-readonly
|
|
20
|
+
v-bind="$attrs"
|
|
21
|
+
class="sun-selector"
|
|
22
|
+
:label="label"
|
|
23
|
+
:value="inputValue"
|
|
24
|
+
:placeholder="placeholder"
|
|
25
|
+
:use-right-icon-slot="canClear"
|
|
26
|
+
shape="round"
|
|
27
|
+
:clearable="false"
|
|
28
|
+
:disabled="disabled"
|
|
29
|
+
@click-input="present()">
|
|
30
|
+
<van-icon v-if="canClear" slot="right-icon" name="clear" @tap="clear()" />
|
|
31
|
+
</van-search>
|
|
32
|
+
</slot>
|
|
33
|
+
|
|
34
|
+
<van-action-sheet :show="show" :title="placeholder" :close-on-click-overlay="true" @close="close()" @cancel="close()">
|
|
35
|
+
<van-search
|
|
36
|
+
v-if="searchable"
|
|
37
|
+
shape="round"
|
|
38
|
+
input-align="center"
|
|
39
|
+
:value="keyword"
|
|
40
|
+
placeholder="输入关键字搜索"
|
|
41
|
+
@change="keyword = $event.detail.trim()" />
|
|
42
|
+
|
|
43
|
+
<block v-if="virtual">
|
|
44
|
+
<sun-virtual-scroll
|
|
45
|
+
v-if="firstRendered"
|
|
46
|
+
class="sun-selector-options"
|
|
47
|
+
:refresher="refresher"
|
|
48
|
+
:refreshing="refreshing"
|
|
49
|
+
:items="filteredOptions"
|
|
50
|
+
:item-size="virtualProps.itemSize"
|
|
51
|
+
:item-key="valueKey"
|
|
52
|
+
:style="{ height }"
|
|
53
|
+
@refresh="emit('refresh')">
|
|
54
|
+
<template #default="{ item, index }">
|
|
55
|
+
<slot name="option" :option="item" :index="index" :active="isOptionActive(item)" :select="() => select(item)">
|
|
56
|
+
<van-cell
|
|
57
|
+
class="sun-selector-option"
|
|
58
|
+
:class="{ 'sun-selector-option-active': isOptionActive(item) }"
|
|
59
|
+
:clickable="true"
|
|
60
|
+
size="large"
|
|
61
|
+
@tap="select(item)">
|
|
62
|
+
<slot-view class="sun-selector-option-label" name="title">{{ item[labelKey] }}</slot-view>
|
|
63
|
+
<van-icon v-if="isOptionActive(item)" class="sun-selector-option-icon" slot="right-icon" name="success" />
|
|
64
|
+
</van-cell>
|
|
65
|
+
</slot>
|
|
66
|
+
</template>
|
|
67
|
+
</sun-virtual-scroll>
|
|
68
|
+
<view v-else :style="{ height }"></view>
|
|
69
|
+
</block>
|
|
70
|
+
|
|
71
|
+
<sun-list v-else class="sun-selector-options" :refresher="refresher" :refreshing="refreshing" :data="filteredOptions"
|
|
72
|
+
:loading="loading" empty-type="search" :style="{ height }" @refresh="emit('refresh')">
|
|
73
|
+
<template v-for="(item, index) of filteredOptions" :key="item[valueKey]">
|
|
74
|
+
<slot name="option" :option="item" :index="index" :active="isOptionActive(item)" :select="() => select(item)">
|
|
75
|
+
<van-cell
|
|
76
|
+
class="sun-selector-option"
|
|
77
|
+
:class="{ 'sun-selector-option-active': isOptionActive(item) }"
|
|
78
|
+
:clickable="true"
|
|
79
|
+
size="large"
|
|
80
|
+
@tap="select(item)">
|
|
81
|
+
<slot-view class="sun-selector-option-label" name="title">{{ item[labelKey] }}</slot-view>
|
|
82
|
+
<van-icon v-if="isOptionActive(item)" class="sun-selector-option-icon" slot="right-icon" name="success" />
|
|
83
|
+
</van-cell>
|
|
84
|
+
</slot>
|
|
85
|
+
</template>
|
|
86
|
+
</sun-list>
|
|
87
|
+
|
|
88
|
+
<view v-if="!isSingleMode" class="van-button-container">
|
|
89
|
+
<van-button type="primary" round="true" block="true" @tap="confirm()">确定</van-button>
|
|
90
|
+
</view>
|
|
91
|
+
</van-action-sheet>
|
|
92
|
+
</template>
|
|
93
|
+
|
|
94
|
+
<script lang="ts" setup>
|
|
95
|
+
import { useFilterList } from '@solar-taro/core';
|
|
96
|
+
import { SunVirtualScroll } from '@solar-taro/ui-sun';
|
|
97
|
+
import { computed, ref } from 'vue';
|
|
98
|
+
import { SunList } from '../list';
|
|
99
|
+
|
|
100
|
+
interface SelectorOption {
|
|
101
|
+
[key: string]: any;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const props = withDefaults(
|
|
105
|
+
defineProps<{
|
|
106
|
+
type?: 'field' | 'search';
|
|
107
|
+
mode?: 'single' | 'multiple';
|
|
108
|
+
label?: string;
|
|
109
|
+
placeholder?: string;
|
|
110
|
+
modelValue: unknown;
|
|
111
|
+
options: SelectorOption[];
|
|
112
|
+
labelKey?: string;
|
|
113
|
+
valueKey?: string;
|
|
114
|
+
loading?: boolean;
|
|
115
|
+
height?: string;
|
|
116
|
+
required?: boolean;
|
|
117
|
+
disabled?: boolean;
|
|
118
|
+
/** 多选模式下,分割符 */
|
|
119
|
+
delimiter?: string;
|
|
120
|
+
searchable?: boolean;
|
|
121
|
+
virtual?: boolean | { itemSize?: number };
|
|
122
|
+
// sun-list
|
|
123
|
+
refresher?: boolean;
|
|
124
|
+
refreshing?: boolean
|
|
125
|
+
}>(),
|
|
126
|
+
{
|
|
127
|
+
type: 'field',
|
|
128
|
+
mode: 'single',
|
|
129
|
+
placeholder: '请选择',
|
|
130
|
+
labelKey: 'fullName',
|
|
131
|
+
valueKey: 'id',
|
|
132
|
+
height: '70vh',
|
|
133
|
+
delimiter: ',',
|
|
134
|
+
searchable: true
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
const emit = defineEmits<{
|
|
139
|
+
'update:modelValue': [unknown]
|
|
140
|
+
select: [SelectorOption]
|
|
141
|
+
/** 多选模式下,取消选择某项时 */
|
|
142
|
+
unselect: [SelectorOption]
|
|
143
|
+
clear: [unknown]
|
|
144
|
+
close: []
|
|
145
|
+
/** 多选模式下,点击确认按钮 */
|
|
146
|
+
confirm: [SelectorOption[]]
|
|
147
|
+
// sun-list
|
|
148
|
+
refresh: []
|
|
149
|
+
}>();
|
|
150
|
+
|
|
151
|
+
const show = ref(false);
|
|
152
|
+
/** 首次渲染完成,指的是 van-action-sheet 完全弹出来,弹出动画结束后 */
|
|
153
|
+
const firstRendered = ref(false);
|
|
154
|
+
const { keyword, filteredList: filteredOptions } = useFilterList(() => props.options, (option, keyword) =>
|
|
155
|
+
(option[props.labelKey] as string).includes(keyword.value)
|
|
156
|
+
);
|
|
157
|
+
const inputValue = computed(() => {
|
|
158
|
+
if (isSingleMode.value) {
|
|
159
|
+
const option = props.options.find(opt => opt[props.valueKey] === props.modelValue);
|
|
160
|
+
return option?.[props.labelKey] || '';
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// 多选,此时是数组
|
|
164
|
+
return (props.modelValue as unknown[])?.map(val =>
|
|
165
|
+
props.options.find(opt =>
|
|
166
|
+
opt[props.valueKey] === val)?.[props.labelKey] || ''
|
|
167
|
+
).join(props.delimiter);
|
|
168
|
+
});
|
|
169
|
+
const canClear = computed(() => props.modelValue && !props.required);
|
|
170
|
+
const isSingleMode = computed(() => props.mode === 'single');
|
|
171
|
+
|
|
172
|
+
const virtualProps = computed(() => {
|
|
173
|
+
let id: string | undefined;
|
|
174
|
+
let itemSize = 44; // van-cell 的高度
|
|
175
|
+
|
|
176
|
+
if (typeof props.virtual !== 'boolean') {
|
|
177
|
+
if (props.virtual?.itemSize) {
|
|
178
|
+
itemSize = props.virtual?.itemSize;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return { id, itemSize };
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
function isOptionActive(option: SelectorOption) {
|
|
186
|
+
const optionValue = option[props.valueKey];
|
|
187
|
+
|
|
188
|
+
if (isSingleMode.value) {
|
|
189
|
+
return props.modelValue === optionValue;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return (props.modelValue as unknown[])?.includes(optionValue) || false;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function present() {
|
|
196
|
+
if (!props.disabled) {
|
|
197
|
+
show.value = true;
|
|
198
|
+
// 因为 van-action-sheet 打开需要动画 300ms,所以这里延迟一下,
|
|
199
|
+
firstRendered.value || setTimeout(() => {
|
|
200
|
+
firstRendered.value = true;
|
|
201
|
+
}, 300);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function close() {
|
|
206
|
+
show.value = false;
|
|
207
|
+
emit('close');
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function confirm() {
|
|
211
|
+
const activeOptions = (props.modelValue as unknown[]).map(
|
|
212
|
+
value => props.options.find(option => option[props.valueKey] === value)!
|
|
213
|
+
);
|
|
214
|
+
emit('confirm', activeOptions);
|
|
215
|
+
close();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function select(option: SelectorOption) {
|
|
219
|
+
const optionValue = option[props.valueKey];
|
|
220
|
+
let updateModelValue = props.modelValue;
|
|
221
|
+
|
|
222
|
+
if (isSingleMode.value) {
|
|
223
|
+
// 单选,切非必填时,已选的就取消选择
|
|
224
|
+
if (isOptionActive(option)) {
|
|
225
|
+
if (!props.required) {
|
|
226
|
+
emit('unselect', option);
|
|
227
|
+
updateModelValue = null;
|
|
228
|
+
}
|
|
229
|
+
} else {
|
|
230
|
+
emit('select', option);
|
|
231
|
+
updateModelValue = optionValue;
|
|
232
|
+
}
|
|
233
|
+
close();
|
|
234
|
+
} else {
|
|
235
|
+
// 多选,已选的就取消选择
|
|
236
|
+
if (isOptionActive(option)) {
|
|
237
|
+
emit('unselect', option);
|
|
238
|
+
updateModelValue = (props.modelValue as unknown[]).filter(opt => opt !== optionValue);
|
|
239
|
+
} else {
|
|
240
|
+
emit('select', option);
|
|
241
|
+
updateModelValue = ((props.modelValue as unknown[]) || []).concat(option[props.valueKey]);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
emit('update:modelValue', updateModelValue);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function clear() {
|
|
249
|
+
emit('clear', props.modelValue);
|
|
250
|
+
emit('update:modelValue', null);
|
|
251
|
+
}
|
|
252
|
+
</script>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
.sun-tabbar {
|
|
2
|
+
--height: 60px;
|
|
3
|
+
--background: #f8fafc;
|
|
4
|
+
--color: #64748b;
|
|
5
|
+
--border-color: #e2e8f0;
|
|
6
|
+
position: fixed;
|
|
7
|
+
left: 0;
|
|
8
|
+
bottom: 0;
|
|
9
|
+
display: flex;
|
|
10
|
+
height: var(--height);
|
|
11
|
+
width: 100vw;
|
|
12
|
+
overflow-x: auto;
|
|
13
|
+
overflow-y: hidden;
|
|
14
|
+
padding-bottom: var(--safe-bottom);
|
|
15
|
+
box-sizing: content-box;
|
|
16
|
+
background: var(--background);
|
|
17
|
+
|
|
18
|
+
&-item {
|
|
19
|
+
position: relative;
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
align-items: center;
|
|
24
|
+
height: var(--height);
|
|
25
|
+
color: var(--color);
|
|
26
|
+
flex: auto;
|
|
27
|
+
flex-shrink: 0;
|
|
28
|
+
min-width: 150rpx;
|
|
29
|
+
font-size: 12px;
|
|
30
|
+
gap: 2px;
|
|
31
|
+
border-top: 0.5px solid var(--border-color);
|
|
32
|
+
transition: color ease-out 0.25s;
|
|
33
|
+
|
|
34
|
+
> van-icon {
|
|
35
|
+
position: relative;
|
|
36
|
+
font-size: 24px;
|
|
37
|
+
width: 100rpx;
|
|
38
|
+
height: 54rpx;
|
|
39
|
+
|
|
40
|
+
&::before {
|
|
41
|
+
content: "";
|
|
42
|
+
position: absolute;
|
|
43
|
+
top: 0;
|
|
44
|
+
left: 0;
|
|
45
|
+
width: 100%;
|
|
46
|
+
height: 100%;
|
|
47
|
+
border-radius: 99px;
|
|
48
|
+
z-index: -1;
|
|
49
|
+
transform: scaleX(0.75);
|
|
50
|
+
transition:
|
|
51
|
+
background-color ease-out 0.25s,
|
|
52
|
+
transform ease-out 0.25s;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&-icon-only {
|
|
57
|
+
> van-icon {
|
|
58
|
+
font-size: 26px;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&-text-only {
|
|
63
|
+
font-size: 16px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&-active {
|
|
67
|
+
font-weight: bold;
|
|
68
|
+
color: var(--color-primary);
|
|
69
|
+
|
|
70
|
+
> van-icon {
|
|
71
|
+
&::before {
|
|
72
|
+
transform: scaleX(1);
|
|
73
|
+
background-color: rgba(var(--color-primary-rgb), 0.1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SunTabbar } from './index.vue';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<scroll-view
|
|
3
|
+
v-bind="$attrs"
|
|
4
|
+
class="sun-tabbar"
|
|
5
|
+
:scroll-x="true"
|
|
6
|
+
:enable-flex="true"
|
|
7
|
+
:enhanced="true"
|
|
8
|
+
:show-scrollbar="false"
|
|
9
|
+
:scroll-with-animation="true"
|
|
10
|
+
:scroll-left="scrollLeft">
|
|
11
|
+
<view
|
|
12
|
+
v-for="(tab, index) of tabs"
|
|
13
|
+
:key="index"
|
|
14
|
+
class="sun-tabbar-item"
|
|
15
|
+
:class="{
|
|
16
|
+
'sun-tabbar-item-active': active === index,
|
|
17
|
+
'sun-tabbar-item-icon-only': !tab.text,
|
|
18
|
+
'sun-tabbar-item-text-only': !tab.icon,
|
|
19
|
+
}"
|
|
20
|
+
@tap="toggle(index)">
|
|
21
|
+
<slot :tab="tab" :index="index">
|
|
22
|
+
<van-icon v-if="tab.icon" :name="active === index ? tab.icon[1] || tab.icon[0] : tab.icon[0]" />
|
|
23
|
+
{{ tab.text }}
|
|
24
|
+
</slot>
|
|
25
|
+
</view>
|
|
26
|
+
</scroll-view>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script lang="ts" setup>
|
|
30
|
+
import { computed } from 'vue';
|
|
31
|
+
|
|
32
|
+
const emit = defineEmits<{
|
|
33
|
+
(e: 'update:active', v: number): void;
|
|
34
|
+
(e: 'toggle', v: number): void;
|
|
35
|
+
}>();
|
|
36
|
+
|
|
37
|
+
const props = withDefaults(
|
|
38
|
+
defineProps<{
|
|
39
|
+
tabs: {
|
|
40
|
+
icon?: [string, string?];
|
|
41
|
+
text?: string;
|
|
42
|
+
}[];
|
|
43
|
+
active?: number;
|
|
44
|
+
}>(),
|
|
45
|
+
{
|
|
46
|
+
active: 0
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const scrollLeft = computed(() => props.active > 2 ? (props.active - 2) * 150 + 'rpx' : 0);
|
|
51
|
+
|
|
52
|
+
function toggle(index: number) {
|
|
53
|
+
emit('toggle', index);
|
|
54
|
+
emit('update:active', index);
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export interface VanNotifyOptions {
|
|
2
|
+
type?: 'primary' | 'success' | 'danger' | 'warning';
|
|
3
|
+
color?: string;
|
|
4
|
+
zIndex?: number;
|
|
5
|
+
top?: number;
|
|
6
|
+
message: string;
|
|
7
|
+
context?: any;
|
|
8
|
+
duration?: number;
|
|
9
|
+
selector?: string;
|
|
10
|
+
background?: string;
|
|
11
|
+
safeAreaInsetTop?: boolean;
|
|
12
|
+
onClick?: () => void;
|
|
13
|
+
onOpened?: () => void;
|
|
14
|
+
onClose?: () => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type Action = 'confirm' | 'cancel' | 'overlay';
|
|
18
|
+
type DialogContext = WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
|
|
19
|
+
|
|
20
|
+
export interface VanDialogOptions {
|
|
21
|
+
lang?: string;
|
|
22
|
+
show?: boolean;
|
|
23
|
+
title?: string;
|
|
24
|
+
width?: string | number | null;
|
|
25
|
+
zIndex?: number;
|
|
26
|
+
theme?: string;
|
|
27
|
+
context?: (() => DialogContext) | DialogContext;
|
|
28
|
+
message?: string;
|
|
29
|
+
overlay?: boolean;
|
|
30
|
+
selector?: string;
|
|
31
|
+
ariaLabel?: string;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated use custom-class instead
|
|
34
|
+
*/
|
|
35
|
+
className?: string;
|
|
36
|
+
customStyle?: string;
|
|
37
|
+
transition?: string;
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated use beforeClose instead
|
|
40
|
+
*/
|
|
41
|
+
asyncClose?: boolean;
|
|
42
|
+
beforeClose?: null | ((action: Action) => Promise<void | boolean> | void);
|
|
43
|
+
businessId?: number;
|
|
44
|
+
sessionFrom?: string;
|
|
45
|
+
overlayStyle?: string;
|
|
46
|
+
appParameter?: string;
|
|
47
|
+
messageAlign?: string;
|
|
48
|
+
sendMessageImg?: string;
|
|
49
|
+
showMessageCard?: boolean;
|
|
50
|
+
sendMessagePath?: string;
|
|
51
|
+
sendMessageTitle?: string;
|
|
52
|
+
confirmButtonText?: string;
|
|
53
|
+
cancelButtonText?: string;
|
|
54
|
+
showConfirmButton?: boolean;
|
|
55
|
+
showCancelButton?: boolean;
|
|
56
|
+
closeOnClickOverlay?: boolean;
|
|
57
|
+
confirmButtonOpenType?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface VanDialog {
|
|
61
|
+
(options: VanDialogOptions): Promise<WechatMiniprogram.Component.TrivialInstance>;
|
|
62
|
+
alert(options: VanDialogOptions): Promise<WechatMiniprogram.Component.TrivialInstance>;
|
|
63
|
+
confirm(options: VanDialogOptions): Promise<WechatMiniprogram.Component.TrivialInstance>;
|
|
64
|
+
close(): void;
|
|
65
|
+
stopLoading(): void;
|
|
66
|
+
currentOptions: VanDialogOptions;
|
|
67
|
+
defaultOptions: VanDialogOptions;
|
|
68
|
+
setDefaultOptions(options: VanDialogOptions): void;
|
|
69
|
+
resetDefaultOptions(): void;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export interface VanNotify {
|
|
73
|
+
(options: VanNotifyOptions | string): any;
|
|
74
|
+
clear: (options?: VanNotifyOptions | undefined) => void;
|
|
75
|
+
setDefaultOptions: (options: VanNotifyOptions) => void;
|
|
76
|
+
resetDefaultOptions: () => void;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** van-uploader 组件的文件类型 */
|
|
80
|
+
export interface VanUploaderFile {
|
|
81
|
+
url: string;
|
|
82
|
+
thumb: string;
|
|
83
|
+
name?: string;
|
|
84
|
+
type?: 'image' | 'video' | 'file';
|
|
85
|
+
isImage?: boolean;
|
|
86
|
+
isVideo?: boolean;
|
|
87
|
+
status?: 'uploading' | 'failed' | 'done';
|
|
88
|
+
message?: string;
|
|
89
|
+
deletable?: boolean;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** van-picker column */
|
|
93
|
+
export interface VanPickerColumn<T> {
|
|
94
|
+
values: T[];
|
|
95
|
+
defaultIndex?: number;
|
|
96
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"forceConsistentCasingInFileNames": true,
|
|
5
|
+
"strict": true,
|
|
6
|
+
"noImplicitOverride": true,
|
|
7
|
+
"noImplicitReturns": true,
|
|
8
|
+
"noFallthroughCasesInSwitch": true,
|
|
9
|
+
"noPropertyAccessFromIndexSignature": true
|
|
10
|
+
},
|
|
11
|
+
"files": [],
|
|
12
|
+
"include": [],
|
|
13
|
+
"references": [
|
|
14
|
+
{
|
|
15
|
+
"path": "./tsconfig.lib.json"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "./tsconfig.spec.json"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../dist/out-tsc",
|
|
5
|
+
"declaration": true
|
|
6
|
+
},
|
|
7
|
+
"include": [
|
|
8
|
+
"src/**/*.ts"
|
|
9
|
+
],
|
|
10
|
+
"exclude": [
|
|
11
|
+
"vite.config.ts",
|
|
12
|
+
"vite.config.mts",
|
|
13
|
+
"vitest.config.ts",
|
|
14
|
+
"vitest.config.mts",
|
|
15
|
+
"src/**/*.test.ts",
|
|
16
|
+
"src/**/*.spec.ts",
|
|
17
|
+
"src/**/*.test.tsx",
|
|
18
|
+
"src/**/*.spec.tsx",
|
|
19
|
+
"src/**/*.test.js",
|
|
20
|
+
"src/**/*.spec.js",
|
|
21
|
+
"src/**/*.test.jsx",
|
|
22
|
+
"src/**/*.spec.jsx"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../dist/out-tsc",
|
|
5
|
+
"types": [
|
|
6
|
+
"vitest/globals",
|
|
7
|
+
"vitest/importMeta",
|
|
8
|
+
"vite/client",
|
|
9
|
+
"node",
|
|
10
|
+
"vitest"
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
"include": [
|
|
14
|
+
"vite.config.ts",
|
|
15
|
+
"vite.config.mts",
|
|
16
|
+
"vitest.config.ts",
|
|
17
|
+
"vitest.config.mts",
|
|
18
|
+
"src/**/*.test.ts",
|
|
19
|
+
"src/**/*.spec.ts",
|
|
20
|
+
"src/**/*.test.tsx",
|
|
21
|
+
"src/**/*.spec.tsx",
|
|
22
|
+
"src/**/*.test.js",
|
|
23
|
+
"src/**/*.spec.js",
|
|
24
|
+
"src/**/*.test.jsx",
|
|
25
|
+
"src/**/*.spec.jsx",
|
|
26
|
+
"src/**/*.d.ts"
|
|
27
|
+
]
|
|
28
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/// <reference types='vitest' />
|
|
2
|
+
import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
|
|
3
|
+
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
4
|
+
import vue from '@vitejs/plugin-vue';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import { defineConfig } from 'vite';
|
|
7
|
+
import dts from 'vite-plugin-dts';
|
|
8
|
+
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
root: __dirname,
|
|
11
|
+
cacheDir: '../../node_modules/.vite/ui-vant',
|
|
12
|
+
plugins: [
|
|
13
|
+
nxViteTsPaths(),
|
|
14
|
+
nxCopyAssetsPlugin(['*.md']),
|
|
15
|
+
dts({
|
|
16
|
+
entryRoot: 'src',
|
|
17
|
+
include: ['src'],
|
|
18
|
+
tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
|
|
19
|
+
copyDtsFiles: true,
|
|
20
|
+
}),
|
|
21
|
+
vue({
|
|
22
|
+
template: {
|
|
23
|
+
transformAssetUrls: {
|
|
24
|
+
video: ['src', 'poster'],
|
|
25
|
+
'live-player': ['src'],
|
|
26
|
+
audio: ['src'],
|
|
27
|
+
source: ['src'],
|
|
28
|
+
image: ['src'],
|
|
29
|
+
'cover-image': ['src']
|
|
30
|
+
},
|
|
31
|
+
compilerOptions: {
|
|
32
|
+
mode: 'module',
|
|
33
|
+
optimizeImports: true,
|
|
34
|
+
isNativeTag: tag => {
|
|
35
|
+
return [
|
|
36
|
+
'slot-view',
|
|
37
|
+
'view',
|
|
38
|
+
'scroll-view',
|
|
39
|
+
'swiper',
|
|
40
|
+
'cover-view',
|
|
41
|
+
'cover-image',
|
|
42
|
+
'icon',
|
|
43
|
+
'text',
|
|
44
|
+
'rich-text',
|
|
45
|
+
'progress',
|
|
46
|
+
'button',
|
|
47
|
+
'checkbox',
|
|
48
|
+
'form',
|
|
49
|
+
'input',
|
|
50
|
+
'label',
|
|
51
|
+
'picker',
|
|
52
|
+
'picker-view',
|
|
53
|
+
'picker-view-column',
|
|
54
|
+
'radio',
|
|
55
|
+
'radio-group',
|
|
56
|
+
'checkbox-group',
|
|
57
|
+
'slider',
|
|
58
|
+
'switch',
|
|
59
|
+
'textarea',
|
|
60
|
+
'navigator',
|
|
61
|
+
'audio',
|
|
62
|
+
'image',
|
|
63
|
+
'video',
|
|
64
|
+
'camera',
|
|
65
|
+
'live-player',
|
|
66
|
+
'live-pusher',
|
|
67
|
+
'map',
|
|
68
|
+
'canvas',
|
|
69
|
+
'open-data',
|
|
70
|
+
'web-view',
|
|
71
|
+
'swiper-item',
|
|
72
|
+
'movable-area',
|
|
73
|
+
'movable-view',
|
|
74
|
+
'functional-page-navigator',
|
|
75
|
+
'ad',
|
|
76
|
+
'block',
|
|
77
|
+
'import',
|
|
78
|
+
'official-account',
|
|
79
|
+
'editor'
|
|
80
|
+
].some(o => o === tag) || tag.startsWith('van-')
|
|
81
|
+
},
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
],
|
|
86
|
+
// Uncomment this if you are using workers.
|
|
87
|
+
// worker: {
|
|
88
|
+
// plugins: [ nxViteTsPaths() ],
|
|
89
|
+
// },
|
|
90
|
+
// Configuration for building your library.
|
|
91
|
+
// See: https://vitejs.dev/guide/build.html#library-mode
|
|
92
|
+
build: {
|
|
93
|
+
target: 'es2019',
|
|
94
|
+
outDir: '../../dist/ui-vant',
|
|
95
|
+
emptyOutDir: true,
|
|
96
|
+
reportCompressedSize: true,
|
|
97
|
+
lib: {
|
|
98
|
+
// Could also be a dictionary or array of multiple entry points.
|
|
99
|
+
entry: 'src/index.ts',
|
|
100
|
+
name: 'ui-vant',
|
|
101
|
+
fileName: 'index',
|
|
102
|
+
// Change this to the formats you want to support.
|
|
103
|
+
// Don't forget to update your package.json as well.
|
|
104
|
+
formats: ['es'],
|
|
105
|
+
},
|
|
106
|
+
rollupOptions: {
|
|
107
|
+
// External packages that should not be bundled into your library.
|
|
108
|
+
external: [
|
|
109
|
+
'vue',
|
|
110
|
+
'rxjs',
|
|
111
|
+
/@tarojs.+/,
|
|
112
|
+
/@ngify.+/,
|
|
113
|
+
/@opper.+/,
|
|
114
|
+
/@solar-kit.+/,
|
|
115
|
+
/@solar-taro.+/,
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
test: {
|
|
120
|
+
watch: false,
|
|
121
|
+
globals: true,
|
|
122
|
+
environment: 'node',
|
|
123
|
+
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
124
|
+
reporters: ['default'],
|
|
125
|
+
coverage: {
|
|
126
|
+
reportsDirectory: '../../coverage/ui-vant',
|
|
127
|
+
provider: 'v8',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
});
|