@ebfe/vantkit-doc 0.0.1 → 0.0.2

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.
@@ -0,0 +1,110 @@
1
+ # ColoringAvatar
2
+
3
+ ### 介绍
4
+
5
+ 着色头像
6
+
7
+ **主要功能描述**
8
+
9
+ - 内置中英文名称取值逻辑
10
+ - 内置渐变随机色
11
+ - 支持自定义
12
+ - 头像着色
13
+ - 文字大小
14
+ - 头像尺寸
15
+
16
+ ## 代码演示
17
+
18
+ ### 基础用法
19
+
20
+ ```html
21
+ <template>
22
+ <demo-block title="中文名">
23
+ <section>
24
+ <span class="desc">展示后两个字符 (李钟硕)</span>
25
+ <ColoringAvatar name="李钟硕" />
26
+ </section>
27
+ </demo-block>
28
+ <demo-block title="英文名">
29
+ <section>
30
+ <span class="desc">展示第一个字符 (IU)</span>
31
+ <ColoringAvatar name="IU" />
32
+ </section>
33
+ </demo-block>
34
+ <demo-block title="自定义颜色">
35
+ <section>
36
+ <ColoringAvatar name="Ashun" :bg-attr="bgAttr" />
37
+ <van-space>
38
+ <van-button
39
+ size="small"
40
+ type="primary"
41
+ v-for="item in changeBgAttrList"
42
+ :key="item.value"
43
+ :color="item.value"
44
+ @click="setBgAttr(item.value)"
45
+ >
46
+ {{ item.desc }}
47
+ </van-button>
48
+ </van-space>
49
+ </section>
50
+ </demo-block>
51
+ <demo-block title="自定义文字大小">
52
+ <section>
53
+ <ColoringAvatar name="Ashun" :font-size="24" />
54
+ </section>
55
+ </demo-block>
56
+ </template>
57
+
58
+ <script setup lang="ts">
59
+ import { ColoringAvatar } from '@ebfe/vant-kit';
60
+ import { useWrapperRef } from '@ebfe/vhooks';
61
+ import { Space as VanSpace, Button as VanButton } from 'vant';
62
+
63
+ const changeBgAttrList = [
64
+ {
65
+ desc: '黑色',
66
+ value: 'black',
67
+ },
68
+ {
69
+ desc: '紫色',
70
+ value: '#8e44ad',
71
+ },
72
+ {
73
+ desc: '粉色',
74
+ value: 'pink',
75
+ },
76
+ {
77
+ desc: '土豪金',
78
+ value: 'linear-gradient(90deg, #b35b1d, #d97b2e, #d97b2e, #ffb86b, #d97b2e, #d97b2e, #b35b1d)',
79
+ },
80
+ ];
81
+ const [bgAttr, setBgAttr] = useWrapperRef(changeBgAttrList[3].value);
82
+ </script>
83
+
84
+ <style scoped lang="less">
85
+ section {
86
+ padding: 0px 16px;
87
+ display: flex;
88
+ flex-direction: column;
89
+ justify-content: center;
90
+ align-items: center;
91
+ gap: 12px;
92
+
93
+ .desc {
94
+ font-size: 12px;
95
+ align-self: flex-start;
96
+ color: #aaa;
97
+ }
98
+ }
99
+ </style>
100
+ ```
101
+
102
+ ## API
103
+
104
+ ### Props
105
+
106
+ | 参数 | 说明 | 类型 | 默认值 |
107
+ | -------- | ------------ | ------ | ------ |
108
+ | size | 头像尺寸(px) | number | 36 |
109
+ | fontSize | 文字大小(px) | number | 14 |
110
+ | bgAttr | 背景色属性 | string | - |
@@ -0,0 +1,248 @@
1
+ # DatePicker
2
+
3
+ ### 介绍
4
+
5
+ 主要基于 vant 的 popup、date-picker 组件进行二次封装,方便处理时间选择的需求场景。
6
+
7
+ - 支持传入所有 [date-picker props](https://vant-ui.github.io/vant/#/zh-CN/date-picker#props)
8
+ - 支持暴露所有 [date-picker slots](https://vant-ui.github.io/vant/#/zh-CN/date-picker#slots)
9
+
10
+ **主要功能描述**
11
+
12
+ - 支持自定义触发器
13
+ - 支持自定义展示值
14
+ - 支持更改 picker 打开时默认选中的值(modelValue 有值,则以modelValue 为准)
15
+
16
+ **对开发者的解脱**
17
+
18
+ - 符合 ui 设计
19
+ - 默认处理选项的 formatter
20
+ - 打开收起逻辑的编写
21
+ - 对所选项 `真实值`、`展示值` 的隔离和处理
22
+
23
+ ## 代码演示
24
+
25
+ ### 基础用法
26
+
27
+ ```html
28
+ <template>
29
+ <DatePicker v-model="modelValue" :picker-props="{ title: '基础用法' }">
30
+ <template #trigger="{ triggerPopupShow, showValue }">
31
+ <div class="trigger-box">
32
+ <p>value:{{ modelValue }}</p>
33
+ <p>showValue:{{ showValue }}</p>
34
+ <van-button @click="triggerPopupShow"> trigger </van-button>
35
+ </div>
36
+ </template>
37
+ </DatePicker>
38
+ </template>
39
+
40
+ <script setup lang="ts">
41
+ import { useWrapperRef } from '@ebfe/vhooks';
42
+ import { DatePicker } from '@ebfe/vant-kit';
43
+ import { Button as VanButton } from 'vant';
44
+
45
+ const [modelValue] = useWrapperRef('');
46
+ </script>
47
+
48
+ <style scoped lang="less">
49
+ .trigger-box {
50
+ display: flex;
51
+ flex-direction: column;
52
+ justify-content: center;
53
+ align-items: center;
54
+ }
55
+ </style>
56
+ ```
57
+
58
+ ### 格式化展示值
59
+
60
+ ```html
61
+ <template>
62
+ <DatePicker
63
+ v-model="modelValue"
64
+ :show-value-formatter="(date) => dayjs(date).format('YY年MM月DD日')"
65
+ :picker-props="{ title: '格式化展示值' }"
66
+ @confirm="
67
+ (p) => {
68
+ showToast(`dayjs(date).format('YY年MM月DD日'))`);
69
+ console.log(p);
70
+ }
71
+ "
72
+ >
73
+ <template #trigger="{ triggerPopupShow, showValue }">
74
+ <div class="trigger-box">
75
+ <p>value:{{ modelValue }}</p>
76
+ <p>showValue:{{ showValue }}</p>
77
+ <van-button type="primary" @click="triggerPopupShow"> trigger </van-button>
78
+ </div>
79
+ </template>
80
+ </DatePicker>
81
+ </template>
82
+
83
+ <script setup lang="ts">
84
+ import { useWrapperRef } from '@ebfe/vhooks';
85
+ import { DatePicker } from '@ebfe/vant-kit';
86
+ import { Button as VanButton, showToast } from 'vant';
87
+ import dayjs from 'dayjs';
88
+
89
+ const [modelValue] = useWrapperRef('2030-03-04');
90
+ </script>
91
+
92
+ <style scoped lang="less">
93
+ .trigger-box {
94
+ display: flex;
95
+ flex-direction: column;
96
+ justify-content: center;
97
+ align-items: center;
98
+ }
99
+ </style>
100
+ ```
101
+
102
+ ### 自定义 picker 打开时默认选中的值
103
+
104
+ modelValue 有值,则以 modelValue 为准
105
+
106
+ ```html
107
+ <template>
108
+ <DatePicker ref="DatePickerRef" v-model="modelValue" :picker-props="{ title: '设置 picker 默认选中项' }">
109
+ <template #trigger="{ triggerPopupShow, pickerRealtimeOptions, showValue }">
110
+ <div class="trigger-box">
111
+ <p>value:{{ modelValue }}</p>
112
+ <p>showValue:{{ showValue }}</p>
113
+ <p>picker 实时选中值:{{ pickerRealtimeOptions }}</p>
114
+ <p>(modelValue 有值,则以 modelValue 为准)</p>
115
+ <van-space>
116
+ <van-button type="primary" @click="triggerPopupShow"> trigger </van-button>
117
+ <van-button type="warning" @click="() => DatePickerRef?.setPickerRealtimeDate('2035-05-06')">
118
+ 2035-05-06
119
+ </van-button>
120
+ </van-space>
121
+ </div>
122
+ </template>
123
+ </DatePicker>
124
+ </template>
125
+
126
+ <script setup lang="ts">
127
+ import { useWrapperRef } from '@ebfe/vhooks';
128
+ import { DatePicker } from '@ebfe/vant-kit';
129
+ import { ref } from 'vue';
130
+ import { Button as VanButton, Space as VanSpace } from 'vant';
131
+
132
+ const [modelValue] = useWrapperRef('2030-03-04');
133
+ const DatePickerRef = ref<InstanceType<typeof DatePicker>>();
134
+ </script>
135
+
136
+ <style scoped lang="less">
137
+ .trigger-box {
138
+ display: flex;
139
+ flex-direction: column;
140
+ justify-content: center;
141
+ align-items: center;
142
+ }
143
+ </style>
144
+ ```
145
+
146
+ ### 支持所有 date-picker props
147
+
148
+ 例如设置 columnsType 为: 月日
149
+
150
+ ```html
151
+ <template>
152
+ <DatePicker v-model="modelValue" :picker-props="{ title: '基础用法', columnsType: ['month', 'day'] }">
153
+ <template #trigger="{ triggerPopupShow, showValue }">
154
+ <div class="trigger-box">
155
+ <p>value:{{ modelValue }}</p>
156
+ <p>showValue:{{ showValue }}</p>
157
+ <van-button @click="triggerPopupShow"> trigger </van-button>
158
+ </div>
159
+ </template>
160
+ </DatePicker>
161
+ </template>
162
+
163
+ <script setup lang="ts">
164
+ import { useWrapperRef } from '@ebfe/vhooks';
165
+ import { DatePicker } from '@ebfe/vant-kit';
166
+ import { Button as VanButton } from 'vant';
167
+
168
+ const [modelValue] = useWrapperRef('');
169
+ </script>
170
+
171
+ <style scoped lang="less">
172
+ .trigger-box {
173
+ display: flex;
174
+ flex-direction: column;
175
+ justify-content: center;
176
+ align-items: center;
177
+ }
178
+ </style>
179
+ ```
180
+
181
+ ### 支持所有 date-picker slots
182
+
183
+ 例如设置 columns-top
184
+
185
+ ```html
186
+ <template>
187
+ <DatePicker v-model="modelValue" :picker-props="{ title: '基础用法' }">
188
+ <template #trigger="{ triggerPopupShow }">
189
+ <div class="trigger-box">
190
+ <van-button @click="triggerPopupShow"> trigger </van-button>
191
+ </div>
192
+ </template>
193
+ <template #columns-top>
194
+ <div class="columns-top-bar">
195
+ <span>这里是 columns-top 插槽内容</span>
196
+ </div>
197
+ </template>
198
+ </DatePicker>
199
+ </template>
200
+
201
+ <script setup lang="ts">
202
+ import { useWrapperRef } from '@ebfe/vhooks';
203
+ import { DatePicker } from '@ebfe/vant-kit';
204
+ import { Button as VanButton } from 'vant';
205
+
206
+ const [modelValue] = useWrapperRef('');
207
+ </script>
208
+
209
+ <style scoped lang="less">
210
+ .trigger-box {
211
+ display: flex;
212
+ flex-direction: column;
213
+ justify-content: center;
214
+ align-items: center;
215
+ }
216
+ .columns-top-bar {
217
+ display: flex;
218
+ justify-content: center;
219
+ align-items: center;
220
+ }
221
+ </style>
222
+ ```
223
+
224
+ ## API
225
+
226
+ ### Props
227
+
228
+ TDatePickerProps
229
+
230
+ | 参数 | 说明 | 类型 | 默认值 |
231
+ | ------------------ | ----------------------------------------------------------------------------- | ---------------------------------------------- | ------ |
232
+ | modelValue | 值 | string | - |
233
+ | pickerProps | [date-picker props](https://vant-ui.github.io/vant/#/zh-CN/date-picker#props) | `Partial<DatePickerProps>` | - |
234
+ | showValueFormatter | 自定义展示值 | `showValueFormatter?: (date?: Date) => string` | - |
235
+
236
+ ### Slots
237
+
238
+ 支持暴露所有 [date-picker slots](https://vant-ui.github.io/vant/#/zh-CN/date-picker#slots)
239
+
240
+ | 插槽名 | 说明 | 参数 |
241
+ | ------- | ------ | ------------------------------------------------------- |
242
+ | trigger | 触发器 | `{ triggerPopupShow, showValue, pickerRealtimeOptions}` |
243
+
244
+ ### 方法
245
+
246
+ | 方法名 | 说明 | 类型 |
247
+ | :-------------------- | :--------------------------------------------------------------------- | :--------------------------- |
248
+ | setPickerRealtimeDate | 设置 picker 打开时默认选中的值(modelValue 有值,则以modelValue 为准) | `(newValue: string) => void` |