Skip to content

Commit 62628ef

Browse files
committed
docs: update docs
1 parent 8ad2073 commit 62628ef

11 files changed

Lines changed: 357 additions & 86 deletions

File tree

packages/varlet-ui/src/auto-complete/AutoComplete.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
placement="bottom"
1616
:disabled="disabled || formDisabled || readonly || formReadonly"
1717
:class="n('menu-select')"
18-
:popover-class="variant === 'standard' ? n('--standard-menu-margin') : undefined"
18+
:popover-class="
19+
variant === 'standard' ? n('--standard-menu-margin') : variant === 'filled' ? n('--filled-menu-margin') : ''
20+
"
1921
@update:model-value="handleAutoComplete"
2022
@key-escape="handleKeyEscape"
2123
>

packages/varlet-ui/src/auto-complete/autoComplete.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@
1616
&--standard-menu-margin {
1717
margin-top: var(--field-decorator-line-focus-size) !important;
1818
}
19+
20+
&--filled-menu-margin {
21+
margin-top: var(--field-decorator-line-focus-size) !important;
22+
}
1923
}

packages/varlet-ui/src/auto-complete/docs/en-US.md

Lines changed: 121 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Autocomplete function of input field.
99
```html
1010
<script setup>
1111
import { ref, computed } from 'vue'
12+
import { z } from 'zod'
1213
1314
const { value, options } = useAutoComplete()
1415
const { value: value2, options: options2 } = useAutoComplete()
@@ -21,7 +22,6 @@ const { value: value8, options: options8 } = useAutoComplete()
2122
const { value: value9, options: options9 } = useAutoComplete()
2223
const { value: value10, options: options10 } = useAutoComplete()
2324
const { value: value11, options: options11 } = useAutoComplete()
24-
const { value: value12, options: options12 } = useAutoComplete()
2525
2626
function useAutoComplete() {
2727
const value = ref('')
@@ -60,27 +60,19 @@ function useAutoComplete() {
6060
v-model="value6"
6161
/>
6262
<var-auto-complete
63-
placeholder="validate With Zod"
64-
:options="options12"
63+
placeholder="Validate With Zod"
64+
:options="options7"
6565
:rules="z.string().min(7, 'Text length must be greater than 6')"
66-
v-model="value12"
66+
v-model="value7"
6767
/>
68-
<var-auto-complete placeholder="Display Icon" :options="options7" v-model="value7">
68+
<var-auto-complete placeholder="Display Icon" :options="options8" v-model="value8">
6969
<template #prepend-icon>
7070
<var-icon class="prepend-icon" name="github" />
7171
</template>
7272
<template #append-icon>
7373
<var-icon class="append-icon" name="github" />
7474
</template>
7575
</var-auto-complete>
76-
<var-auto-complete placeholder="Custom Icon Size" :options="options8" v-model="value8">
77-
<template #prepend-icon>
78-
<var-icon class="prepend-icon" name="github" :size="28" />
79-
</template>
80-
<template #append-icon>
81-
<var-icon class="append-icon" name="github" :size="42" />
82-
</template>
83-
</var-auto-complete>
8476
<var-auto-complete
8577
placeholder="Maxlength"
8678
:maxlength="10"
@@ -118,6 +110,7 @@ function useAutoComplete() {
118110
```html
119111
<script setup>
120112
import { ref, computed } from 'vue'
113+
import { z } from 'zod'
121114
122115
const { value, options } = useAutoComplete()
123116
const { value: value2, options: options2 } = useAutoComplete()
@@ -130,7 +123,6 @@ const { value: value8, options: options8 } = useAutoComplete()
130123
const { value: value9, options: options9 } = useAutoComplete()
131124
const { value: value10, options: options10 } = useAutoComplete()
132125
const { value: value11, options: options11 } = useAutoComplete()
133-
const { value: value12, options: options12 } = useAutoComplete()
134126
135127
function useAutoComplete() {
136128
const value = ref('')
@@ -171,43 +163,141 @@ function useAutoComplete() {
171163
/>
172164
<var-auto-complete
173165
variant="outlined"
174-
placeholder="validate With Zod"
175-
:options="options12"
166+
placeholder="Validate With Zod"
167+
:options="options7"
176168
:rules="z.string().min(7, 'Text length must be greater than 6')"
177-
v-model="value12"
169+
v-model="value7"
178170
/>
179-
<var-auto-complete variant="outlined" placeholder="Display Icon" :options="options7" v-model="value7">
171+
<var-auto-complete variant="outlined" placeholder="Display Icon" :options="options8" v-model="value8">
180172
<template #prepend-icon>
181173
<var-icon class="prepend-icon" name="github" />
182174
</template>
183175
<template #append-icon>
184176
<var-icon class="append-icon" name="github" />
185177
</template>
186178
</var-auto-complete>
187-
<var-auto-complete variant="outlined" placeholder="Custom Icon Size" :options="options8" v-model="value8">
179+
<var-auto-complete
180+
variant="outlined"
181+
placeholder="Maxlength"
182+
:maxlength="10"
183+
:options="options9"
184+
v-model="value9"
185+
/>
186+
<var-auto-complete
187+
variant="outlined"
188+
placeholder="Custom Menu Show Timing"
189+
:get-show="(value) => value.length > 3"
190+
:options="options10"
191+
v-model="value10"
192+
/>
193+
<var-auto-complete
194+
variant="outlined"
195+
size="small"
196+
placeholder="Small Size"
197+
:options="options11"
198+
v-model="value11"
199+
/>
200+
</var-space>
201+
</template>
202+
203+
<style>
204+
.prepend-icon {
205+
margin-right: 6px;
206+
}
207+
208+
.append-icon {
209+
margin-left: 6px;
210+
}
211+
</style>
212+
```
213+
214+
### Filled Variant
215+
216+
```html
217+
<script setup>
218+
import { ref, computed } from 'vue'
219+
import { z } from 'zod'
220+
221+
const { value, options } = useAutoComplete()
222+
const { value: value2, options: options2 } = useAutoComplete()
223+
const { value: value3, options: options3 } = useAutoComplete()
224+
const { value: value4, options: options4 } = useAutoComplete()
225+
const { value: value5, options: options5 } = useAutoComplete()
226+
const { value: value6, options: options6 } = useAutoComplete()
227+
const { value: value7, options: options7 } = useAutoComplete()
228+
const { value: value8, options: options8 } = useAutoComplete()
229+
const { value: value9, options: options9 } = useAutoComplete()
230+
const { value: value10, options: options10 } = useAutoComplete()
231+
const { value: value11, options: options11 } = useAutoComplete()
232+
233+
function useAutoComplete() {
234+
const value = ref('')
235+
const options = computed(() =>
236+
['@qq.com', '@163.com', '@gmail.com'].map((suffix) => {
237+
const [prefix] = value.value.split('@')
238+
return {
239+
label: `${prefix}${suffix}`,
240+
value: `${prefix}${suffix}`,
241+
}
242+
})
243+
)
244+
245+
retu drn {
246+
value,
247+
options,
248+
}
249+
}
250+
</script>
251+
252+
<template>
253+
<var-space direction="column" size="large">
254+
<var-auto-complete variant="filled" placeholder="Please enter text" :options="options" v-model="value" />
255+
<var-auto-complete variant="filled" readonly placeholder="Readonly" :options="options2" v-model="value2" />
256+
<var-auto-complete variant="filled" disabled placeholder="Disabled" :options="options3" v-model="value3" />
257+
<var-auto-complete variant="filled" clearable placeholder="Clearable" :options="options4" v-model="value4" />
258+
<var-auto-complete variant="filled" clearable placeholder="Use the clear icon slot" :options="options5" v-model="value5">
259+
<template #clear-icon="{ clear }">
260+
<var-icon name="error" @click="clear" />
261+
</template>
262+
</var-auto-complete>
263+
<var-auto-complete
264+
variant="filled"
265+
placeholder="Validate"
266+
:options="options6"
267+
:rules="v => v.length > 6 || 'Text length must be greater than 6'"
268+
v-model="value6"
269+
/>
270+
<var-auto-complete
271+
variant="filled"
272+
placeholder="Validate With Zod"
273+
:options="options7"
274+
:rules="z.string().min(7, 'Text length must be greater than 6')"
275+
v-model="value7"
276+
/>
277+
<var-auto-complete variant="filled" placeholder="Display Icon" :options="options8" v-model="value8">
188278
<template #prepend-icon>
189-
<var-icon class="prepend-icon" name="github" :size="28" />
279+
<var-icon class="prepend-icon" name="github" />
190280
</template>
191281
<template #append-icon>
192-
<var-icon class="append-icon" name="github" :size="42" />
282+
<var-icon class="append-icon" name="github" />
193283
</template>
194284
</var-auto-complete>
195285
<var-auto-complete
196-
variant="outlined"
286+
variant="filled"
197287
placeholder="Maxlength"
198288
:maxlength="10"
199289
:options="options9"
200290
v-model="value9"
201291
/>
202292
<var-auto-complete
203-
variant="outlined"
293+
variant="filled"
204294
placeholder="Custom Menu Show Timing"
205295
:get-show="(value) => value.length > 3"
206296
:options="options10"
207297
v-model="value10"
208298
/>
209299
<var-auto-complete
210-
variant="outlined"
300+
variant="filled"
211301
size="small"
212302
placeholder="Small Size"
213303
:options="options11"
@@ -236,7 +326,7 @@ function useAutoComplete() {
236326
| Prop | Description | Type | Default |
237327
| ------- | --- |----------------|-----------|
238328
| `v-model` | The value of the binding | _string_ | `-` |
239-
| `variant` | Input variants, The optional value is `standard` `outlined` | _string_ | `standard` |
329+
| `variant` | Input variants, The optional value is `standard` `outlined` `filled` | _string_ | `standard` |
240330
| `size` | Input size, The optional value is `normal` `small` | _string_ | `normal` |
241331
| `placeholder` | placeholder | _string_ | `-` |
242332
| `options` | Specifies options | _AutoCompleteOption[]_ | `[]` |
@@ -299,6 +389,12 @@ function useAutoComplete() {
299389

300390
Here are the CSS variables used by the component. Styles can be customized using [StyleProvider](#/en-US/style-provider).
301391

392+
#### AutoComplete Variables
393+
302394
| Variable | Default |
303395
| --- | --- |
304396
| `--auto-complete-options-padding` | `6px 0` |
397+
398+
#### Variant Variables
399+
400+
For style variables related to variant, please refer to the style variables of the [Input component](#/en-US/input#yang4shi4bian4liang4).

0 commit comments

Comments
 (0)