@solar-taro/ui-vant 1.0.0 → 1.0.1

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 (56) hide show
  1. package/cascader-picker/index.vue.d.ts +73 -0
  2. package/date-range-picker/index.vue.d.ts +75 -0
  3. package/directives/bind-function.d.ts +5 -0
  4. package/directives/datetime-picker.d.ts +5 -0
  5. package/directives/readonly.d.ts +3 -0
  6. package/index.js +1764 -0
  7. package/item/index.vue.d.ts +44 -0
  8. package/list/index.vue.d.ts +105 -0
  9. package/modal/index.vue.d.ts +56 -0
  10. package/opper-controller/index.vue.d.ts +45 -0
  11. package/overlay/overlay.d.ts +37 -0
  12. package/package.json +1 -1
  13. package/plugin.d.ts +9 -0
  14. package/select-picker/index.vue.d.ts +66 -0
  15. package/selector/index.vue.d.ts +126 -0
  16. package/tabbar/index.vue.d.ts +58 -0
  17. package/vant.interface.d.ts +91 -0
  18. package/eslint.config.cjs +0 -22
  19. package/project.json +0 -29
  20. package/src/cascader-picker/index.vue +0 -210
  21. package/src/date-range-picker/index.vue +0 -201
  22. package/src/directives/bind-function.ts +0 -22
  23. package/src/directives/datetime-picker.ts +0 -33
  24. package/src/directives/readonly.ts +0 -5
  25. package/src/item/index.vue +0 -34
  26. package/src/list/index.vue +0 -86
  27. package/src/modal/index.vue +0 -55
  28. package/src/opper-controller/index.vue +0 -365
  29. package/src/overlay/overlay.ts +0 -76
  30. package/src/plugin.ts +0 -14
  31. package/src/select-picker/index.vue +0 -80
  32. package/src/selector/index.vue +0 -252
  33. package/src/tabbar/index.vue +0 -56
  34. package/src/vant.interface.ts +0 -96
  35. package/tsconfig.json +0 -21
  36. package/tsconfig.lib.json +0 -24
  37. package/tsconfig.spec.json +0 -28
  38. package/vite.config.ts +0 -130
  39. /package/{src/cascader-picker/index.ts → cascader-picker/index.d.ts} +0 -0
  40. /package/{src/date-range-picker/index.ts → date-range-picker/index.d.ts} +0 -0
  41. /package/{src/date-range-picker → date-range-picker}/index.scss +0 -0
  42. /package/{src/directives/index.ts → directives/index.d.ts} +0 -0
  43. /package/{src/index.ts → index.d.ts} +0 -0
  44. /package/{src/index.scss → index.scss} +0 -0
  45. /package/{src/item/index.ts → item/index.d.ts} +0 -0
  46. /package/{src/item → item}/index.scss +0 -0
  47. /package/{src/list/index.ts → list/index.d.ts} +0 -0
  48. /package/{src/modal/index.ts → modal/index.d.ts} +0 -0
  49. /package/{src/opper-controller/index.ts → opper-controller/index.d.ts} +0 -0
  50. /package/{src/opper-controller → opper-controller}/index.scss +0 -0
  51. /package/{src/overlay/index.ts → overlay/index.d.ts} +0 -0
  52. /package/{src/select-picker/index.ts → select-picker/index.d.ts} +0 -0
  53. /package/{src/selector/index.ts → selector/index.d.ts} +0 -0
  54. /package/{src/selector → selector}/index.scss +0 -0
  55. /package/{src/tabbar/index.ts → tabbar/index.d.ts} +0 -0
  56. /package/{src/tabbar → tabbar}/index.scss +0 -0
@@ -1,252 +0,0 @@
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>
@@ -1,56 +0,0 @@
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>
@@ -1,96 +0,0 @@
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 DELETED
@@ -1,21 +0,0 @@
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
- }
package/tsconfig.lib.json DELETED
@@ -1,24 +0,0 @@
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
- }
@@ -1,28 +0,0 @@
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 DELETED
@@ -1,130 +0,0 @@
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
- });
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes