cbvirtua 1.0.26 → 1.0.28
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/after/after.d.ts +3 -0
- package/after/after.index.d.ts +3 -0
- package/after/after.index.js +3 -0
- package/after/after.index.js.map +1 -0
- package/after/after.js +11 -0
- package/after/after.js.map +1 -0
- package/after/after.model.d.ts +9 -0
- package/after/after.model.js +2 -0
- package/after/after.model.js.map +1 -0
- package/after/after.spec.d.ts +1 -0
- package/after/after.spec.js +226 -0
- package/after/after.spec.js.map +1 -0
- package/after/afterify.d.ts +3 -0
- package/after/afterify.js +26 -0
- package/after/afterify.js.map +1 -0
- package/before/before.d.ts +3 -0
- package/before/before.index.d.ts +3 -0
- package/before/before.index.js +3 -0
- package/before/before.index.js.map +1 -0
- package/before/before.js +11 -0
- package/before/before.js.map +1 -0
- package/before/before.model.d.ts +4 -0
- package/before/before.model.js +2 -0
- package/before/before.model.js.map +1 -0
- package/before/before.spec.d.ts +1 -0
- package/before/before.spec.js +174 -0
- package/before/before.spec.js.map +1 -0
- package/before/beforify.d.ts +3 -0
- package/before/beforify.js +18 -0
- package/before/beforify.js.map +1 -0
- package/package.json +1 -1
- package/Autocomplete.vue.txt +0 -603
- package/md.txt +0 -24
- package/py/cn.js +0 -28
- package/py/decode.js +0 -33
- package/py/dict-cn.json +0 -1
- package/py/dict-tw.json +0 -1
- package/py/engine.js +0 -117
- package/py/tw.js +0 -28
- package/style/basic.less +0 -69
- package/style/index.less +0 -125
- package/style/index.tsx +0 -2
- package/style/mixin.less +0 -53
- package/style/rtl.less +0 -68
- package/vant/style/README.md +0 -79
- package/vant/style/README.zh-CN.md +0 -79
- package/vant/style/animation.less +0 -139
- package/vant/style/base.less +0 -10
- package/vant/style/clearfix.less +0 -5
- package/vant/style/demo/index.vue +0 -110
- package/vant/style/ellipsis.less +0 -13
- package/vant/style/hairline.less +0 -47
- package/vant/style/mixins/clearfix.less +0 -7
- package/vant/style/mixins/ellipsis.less +0 -15
- package/vant/style/mixins/hairline.less +0 -39
- package/vant/style/normalize.less +0 -38
- package/vant/style/reset.less +0 -171
- package/vant/style/var.less +0 -901
- package/vant/tab/README.md +0 -307
- package/vant/tab/README.zh-CN.md +0 -342
- package/vant/tab/demo/index.vue +0 -193
- package/vant/tab/index.js +0 -95
- package/vant/tab/index.less +0 -17
- package/vant/tab/test/__snapshots__/demo.spec.js.snap +0 -349
- package/vant/tab/test/__snapshots__/index.spec.js.snap +0 -352
- package/vant/tab/test/__snapshots__/insert.spec.js.snap +0 -63
- package/vant/tab/test/demo.spec.js +0 -4
- package/vant/tab/test/index.spec.js +0 -435
- package/vant/tab/test/insert.spec.js +0 -75
- package/vant/tabs/Content.js +0 -79
- package/vant/tabs/Title.js +0 -91
- package/vant/tabs/index.js +0 -453
- package/vant/tabs/index.less +0 -153
- package/vant/tabs/utils.ts +0 -53
- package/vant/utils/constant.ts +0 -11
- package/vant/utils/create/bem.ts +0 -45
- package/vant/utils/create/component.ts +0 -86
- package/vant/utils/create/i18n.ts +0 -16
- package/vant/utils/create/index.ts +0 -14
- package/vant/utils/deep-assign.ts +0 -27
- package/vant/utils/deep-clone.ts +0 -23
- package/vant/utils/dom/event.ts +0 -56
- package/vant/utils/dom/node.ts +0 -7
- package/vant/utils/dom/raf.ts +0 -40
- package/vant/utils/dom/reset-scroll.ts +0 -16
- package/vant/utils/dom/scroll.ts +0 -81
- package/vant/utils/dom/style.ts +0 -11
- package/vant/utils/format/number.ts +0 -52
- package/vant/utils/format/string.ts +0 -15
- package/vant/utils/format/unit.ts +0 -61
- package/vant/utils/functional.ts +0 -73
- package/vant/utils/index.ts +0 -79
- package/vant/utils/interceptor.ts +0 -27
- package/vant/utils/router.ts +0 -54
- package/vant/utils/test/bem.spec.js +0 -39
- package/vant/utils/test/index.spec.js +0 -152
- package/vant/utils/test/interceptor.spec.js +0 -50
- package/vant/utils/types.ts +0 -40
- package/vant/utils/validate/date.ts +0 -8
- package/vant/utils/validate/email.ts +0 -5
- package/vant/utils/validate/mobile.ts +0 -6
- package/vant/utils/validate/number.ts +0 -12
- package/vant/utils/validate/system.ts +0 -13
- package/vant/utils/vnodes.ts +0 -33
- package//346/226/260/345/273/272 /346/226/207/346/234/254/346/226/207/346/241/243.txt" +0 -85
package/Autocomplete.vue.txt
DELETED
|
@@ -1,603 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="autocomplete">
|
|
3
|
-
<div class="autocomplete__box" :class="{'autocomplete__searching' : showResults}">
|
|
4
|
-
|
|
5
|
-
<img v-if="!isLoading" class="autocomplete__icon" src="../assets/search.svg">
|
|
6
|
-
<img v-else class="autocomplete__icon animate-spin" src="../assets/loading.svg">
|
|
7
|
-
|
|
8
|
-
<div class="autocomplete__inputs">
|
|
9
|
-
<input
|
|
10
|
-
v-model="display"
|
|
11
|
-
:placeholder="placeholder"
|
|
12
|
-
:disabled="disableInput"
|
|
13
|
-
:maxlength="maxlength"
|
|
14
|
-
:class="inputClass"
|
|
15
|
-
@click="search"
|
|
16
|
-
@input="search"
|
|
17
|
-
@keydown.enter="enter"
|
|
18
|
-
@keydown.tab="close"
|
|
19
|
-
@keydown.up="up"
|
|
20
|
-
@keydown.down="down"
|
|
21
|
-
@keydown.esc="close"
|
|
22
|
-
@focus="focus"
|
|
23
|
-
@blur="blur"
|
|
24
|
-
type="text"
|
|
25
|
-
autocomplete="off">
|
|
26
|
-
<input :name="name" type="hidden" :value="value">
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
<!-- clearButtonIcon -->
|
|
30
|
-
<span v-show="!disableInput && !isEmpty && !isLoading && !hasError" class="autocomplete__icon autocomplete--clear" @click="clear">
|
|
31
|
-
<span v-if="clearButtonIcon" :class="clearButtonIcon"></span>
|
|
32
|
-
<img v-else src="../assets/close.svg">
|
|
33
|
-
</span>
|
|
34
|
-
</div>
|
|
35
|
-
|
|
36
|
-
<ul v-show="showResults" class="autocomplete__results" :style="listStyle">
|
|
37
|
-
<slot name="results">
|
|
38
|
-
<!-- error -->
|
|
39
|
-
<li v-if="hasError" class="autocomplete__results__item autocomplete__results__item--error">{{ error }}</li>
|
|
40
|
-
|
|
41
|
-
<!-- results -->
|
|
42
|
-
<template v-if="!hasError">
|
|
43
|
-
<slot name="firstResult"></slot>
|
|
44
|
-
<li
|
|
45
|
-
v-for="(result, key) in results"
|
|
46
|
-
:key="key"
|
|
47
|
-
@click.prevent="select(result)"
|
|
48
|
-
class="autocomplete__results__item"
|
|
49
|
-
:class="{'autocomplete__selected' : isSelected(key) }"
|
|
50
|
-
v-html="formatDisplay(result)">
|
|
51
|
-
</li>
|
|
52
|
-
<slot name="lastResult"></slot>
|
|
53
|
-
</template>
|
|
54
|
-
|
|
55
|
-
<!-- no results -->
|
|
56
|
-
<li v-if="noResultMessage" class="autocomplete__results__item autocomplete__no-results">
|
|
57
|
-
<slot name="noResults">No Results.</slot>
|
|
58
|
-
</li>
|
|
59
|
-
</slot>
|
|
60
|
-
</ul>
|
|
61
|
-
</div>
|
|
62
|
-
</template>
|
|
63
|
-
|
|
64
|
-
<script type="text/babel">
|
|
65
|
-
import debounce from 'lodash/debounce'
|
|
66
|
-
export default {
|
|
67
|
-
props: {
|
|
68
|
-
/**
|
|
69
|
-
* Data source for the results
|
|
70
|
-
* `String` is a url, typed input will be appended
|
|
71
|
-
* `Function` received typed input, and must return a string; to be used as a url
|
|
72
|
-
* `Array` and `Object` (see `results-property`) are used directly
|
|
73
|
-
*/
|
|
74
|
-
source: {
|
|
75
|
-
type: [String, Function, Array, Object],
|
|
76
|
-
required: true
|
|
77
|
-
},
|
|
78
|
-
/**
|
|
79
|
-
* http method
|
|
80
|
-
*/
|
|
81
|
-
method: {
|
|
82
|
-
type: String,
|
|
83
|
-
default: 'get'
|
|
84
|
-
},
|
|
85
|
-
/**
|
|
86
|
-
* Input placeholder
|
|
87
|
-
*/
|
|
88
|
-
placeholder: {
|
|
89
|
-
default: 'Search'
|
|
90
|
-
},
|
|
91
|
-
/**
|
|
92
|
-
* Preset starting value
|
|
93
|
-
*/
|
|
94
|
-
initialValue: {
|
|
95
|
-
type: [String, Number]
|
|
96
|
-
},
|
|
97
|
-
/**
|
|
98
|
-
* Preset starting display value
|
|
99
|
-
*/
|
|
100
|
-
initialDisplay: {
|
|
101
|
-
type: String
|
|
102
|
-
},
|
|
103
|
-
/**
|
|
104
|
-
* CSS class for the surrounding input div
|
|
105
|
-
*/
|
|
106
|
-
inputClass: {
|
|
107
|
-
type: [String, Object]
|
|
108
|
-
},
|
|
109
|
-
/**
|
|
110
|
-
* To disable the input
|
|
111
|
-
*/
|
|
112
|
-
disableInput: {
|
|
113
|
-
type: Boolean
|
|
114
|
-
},
|
|
115
|
-
/**
|
|
116
|
-
* name property of the input holding the selected value
|
|
117
|
-
*/
|
|
118
|
-
name: {
|
|
119
|
-
type: String
|
|
120
|
-
},
|
|
121
|
-
/**
|
|
122
|
-
* api - property of results array
|
|
123
|
-
*/
|
|
124
|
-
resultsProperty: {
|
|
125
|
-
type: String
|
|
126
|
-
},
|
|
127
|
-
/**
|
|
128
|
-
* Results property used as the value
|
|
129
|
-
*/
|
|
130
|
-
resultsValue: {
|
|
131
|
-
type: String,
|
|
132
|
-
default: 'id'
|
|
133
|
-
},
|
|
134
|
-
/**
|
|
135
|
-
* Results property used as the display
|
|
136
|
-
*/
|
|
137
|
-
resultsDisplay: {
|
|
138
|
-
type: [String, Function],
|
|
139
|
-
default: 'name'
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Callback to format the server data
|
|
144
|
-
*/
|
|
145
|
-
resultsFormatter: {
|
|
146
|
-
type: Function
|
|
147
|
-
},
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Whether to show the no results message
|
|
151
|
-
*/
|
|
152
|
-
showNoResults: {
|
|
153
|
-
type: Boolean,
|
|
154
|
-
default: true
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Additional request headers
|
|
159
|
-
*/
|
|
160
|
-
requestHeaders: {
|
|
161
|
-
type: Object
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Credentials: same-origin, include, *omit
|
|
166
|
-
*/
|
|
167
|
-
credentials: {
|
|
168
|
-
type: String
|
|
169
|
-
},
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Optional clear button icon class
|
|
173
|
-
*/
|
|
174
|
-
clearButtonIcon: {
|
|
175
|
-
type: String
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Optional max input length
|
|
180
|
-
*/
|
|
181
|
-
maxlength: {
|
|
182
|
-
type: Number
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
data () {
|
|
186
|
-
return {
|
|
187
|
-
value: null,
|
|
188
|
-
display: null,
|
|
189
|
-
results: null,
|
|
190
|
-
selectedIndex: null,
|
|
191
|
-
loading: false,
|
|
192
|
-
isFocussed: false,
|
|
193
|
-
error: null,
|
|
194
|
-
selectedId: null,
|
|
195
|
-
selectedDisplay: null,
|
|
196
|
-
eventListener: false
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
computed: {
|
|
200
|
-
showResults () {
|
|
201
|
-
return Array.isArray(this.results) || this.hasError
|
|
202
|
-
},
|
|
203
|
-
noResults () {
|
|
204
|
-
return Array.isArray(this.results) && this.results.length === 0
|
|
205
|
-
},
|
|
206
|
-
noResultMessage () {
|
|
207
|
-
return this.noResults &&
|
|
208
|
-
!this.isLoading &&
|
|
209
|
-
this.isFocussed &&
|
|
210
|
-
!this.hasError &&
|
|
211
|
-
this.showNoResults
|
|
212
|
-
},
|
|
213
|
-
isEmpty () {
|
|
214
|
-
return !this.display
|
|
215
|
-
},
|
|
216
|
-
isLoading () {
|
|
217
|
-
return this.loading === true
|
|
218
|
-
},
|
|
219
|
-
hasError () {
|
|
220
|
-
return this.error !== null
|
|
221
|
-
},
|
|
222
|
-
listStyle () {
|
|
223
|
-
if (this.isLoading) {
|
|
224
|
-
return {
|
|
225
|
-
color: '#ccc'
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
methods: {
|
|
231
|
-
/**
|
|
232
|
-
* Search wrapper method
|
|
233
|
-
*/
|
|
234
|
-
search () {
|
|
235
|
-
this.selectedIndex = null
|
|
236
|
-
switch (true) {
|
|
237
|
-
case typeof this.source === 'string':
|
|
238
|
-
// No resource search with no input
|
|
239
|
-
if (!this.display || this.display.length < 1) {
|
|
240
|
-
return
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return this.resourceSearch(this.source + this.display)
|
|
244
|
-
case typeof this.source === 'function':
|
|
245
|
-
// No resource search with no input
|
|
246
|
-
if (!this.display || this.display.length < 1) {
|
|
247
|
-
return
|
|
248
|
-
}
|
|
249
|
-
return this.resourceSearch(this.source(this.display))
|
|
250
|
-
case Array.isArray(this.source):
|
|
251
|
-
return this.arrayLikeSearch()
|
|
252
|
-
default:
|
|
253
|
-
throw new TypeError()
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Debounce the typed search query before making http requests
|
|
259
|
-
* @param {String} url
|
|
260
|
-
*/
|
|
261
|
-
resourceSearch: debounce(function (url) {
|
|
262
|
-
if (!this.display) {
|
|
263
|
-
this.results = []
|
|
264
|
-
return
|
|
265
|
-
}
|
|
266
|
-
this.loading = true
|
|
267
|
-
this.setEventListener()
|
|
268
|
-
this.request(url)
|
|
269
|
-
}, 200),
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Make an http request for results
|
|
273
|
-
* @param {String} url
|
|
274
|
-
*/
|
|
275
|
-
request (url) {
|
|
276
|
-
let promise = fetch(url, {
|
|
277
|
-
method: this.method,
|
|
278
|
-
credentials: this.getCredentials(),
|
|
279
|
-
headers: this.getHeaders()
|
|
280
|
-
})
|
|
281
|
-
|
|
282
|
-
return promise
|
|
283
|
-
.then(response => {
|
|
284
|
-
if (response.ok) {
|
|
285
|
-
this.error = null
|
|
286
|
-
return response.json()
|
|
287
|
-
}
|
|
288
|
-
throw new Error('Network response was not ok.')
|
|
289
|
-
})
|
|
290
|
-
.then(response => {
|
|
291
|
-
this.results = this.setResults(response)
|
|
292
|
-
this.emitRequestResultEvent()
|
|
293
|
-
this.loading = false
|
|
294
|
-
})
|
|
295
|
-
.catch(error => {
|
|
296
|
-
this.error = error.message
|
|
297
|
-
this.loading = false
|
|
298
|
-
})
|
|
299
|
-
},
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Set some default headers and apply user supplied headers
|
|
303
|
-
*/
|
|
304
|
-
getHeaders () {
|
|
305
|
-
const headers = {
|
|
306
|
-
'Accept': 'application/json, text/plain, */*'
|
|
307
|
-
}
|
|
308
|
-
if (this.requestHeaders) {
|
|
309
|
-
for (var prop in this.requestHeaders) {
|
|
310
|
-
headers[prop] = this.requestHeaders[prop]
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
return new Headers(headers)
|
|
314
|
-
},
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Set default credentials and apply user supplied value
|
|
318
|
-
*/
|
|
319
|
-
getCredentials () {
|
|
320
|
-
let credentials = 'same-origin'
|
|
321
|
-
if (this.credentials) {
|
|
322
|
-
credentials = this.credentials
|
|
323
|
-
}
|
|
324
|
-
return credentials
|
|
325
|
-
},
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Set results property from api response
|
|
329
|
-
* @param {Object|Array} response
|
|
330
|
-
* @return {Array}
|
|
331
|
-
*/
|
|
332
|
-
setResults (response) {
|
|
333
|
-
if (this.resultsFormatter) {
|
|
334
|
-
return this.resultsFormatter(response)
|
|
335
|
-
}
|
|
336
|
-
if (this.resultsProperty && response[this.resultsProperty]) {
|
|
337
|
-
return response[this.resultsProperty]
|
|
338
|
-
}
|
|
339
|
-
if (Array.isArray(response)) {
|
|
340
|
-
return response
|
|
341
|
-
}
|
|
342
|
-
return []
|
|
343
|
-
},
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Emit an event based on the request results
|
|
347
|
-
*/
|
|
348
|
-
emitRequestResultEvent () {
|
|
349
|
-
if (this.results.length === 0) {
|
|
350
|
-
this.$emit('noResults', {query: this.display})
|
|
351
|
-
} else {
|
|
352
|
-
this.$emit('results', {results: this.results})
|
|
353
|
-
}
|
|
354
|
-
},
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* Search in results passed via an array
|
|
358
|
-
*/
|
|
359
|
-
arrayLikeSearch () {
|
|
360
|
-
this.setEventListener()
|
|
361
|
-
if (!this.display) {
|
|
362
|
-
this.results = this.source
|
|
363
|
-
this.$emit('results', {results: this.results})
|
|
364
|
-
this.loading = false
|
|
365
|
-
return true
|
|
366
|
-
}
|
|
367
|
-
this.results = this.source.filter((item) => {
|
|
368
|
-
return this.formatDisplay(item).toLowerCase().includes(this.display.toLowerCase())
|
|
369
|
-
})
|
|
370
|
-
this.$emit('results', {results: this.results})
|
|
371
|
-
this.loading = false
|
|
372
|
-
},
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Select a result
|
|
376
|
-
* @param {Object}
|
|
377
|
-
*/
|
|
378
|
-
select (obj) {
|
|
379
|
-
if (!obj) {
|
|
380
|
-
return
|
|
381
|
-
}
|
|
382
|
-
this.value = (this.resultsValue && obj[this.resultsValue]) ? obj[this.resultsValue] : obj.id
|
|
383
|
-
this.display = this.formatDisplay(obj)
|
|
384
|
-
this.selectedDisplay = this.display
|
|
385
|
-
this.$emit('selected', {
|
|
386
|
-
value: this.value,
|
|
387
|
-
display: this.display,
|
|
388
|
-
selectedObject: obj
|
|
389
|
-
})
|
|
390
|
-
this.$emit('input', this.value)
|
|
391
|
-
this.close()
|
|
392
|
-
},
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* @param {Object} obj
|
|
396
|
-
* @return {String}
|
|
397
|
-
*/
|
|
398
|
-
formatDisplay (obj) {
|
|
399
|
-
switch (typeof this.resultsDisplay) {
|
|
400
|
-
case 'function':
|
|
401
|
-
return this.resultsDisplay(obj)
|
|
402
|
-
case 'string':
|
|
403
|
-
if (!obj[this.resultsDisplay]) {
|
|
404
|
-
throw new Error(`"${this.resultsDisplay}" property expected on result but is not defined.`)
|
|
405
|
-
}
|
|
406
|
-
return obj[this.resultsDisplay]
|
|
407
|
-
default:
|
|
408
|
-
throw new TypeError()
|
|
409
|
-
}
|
|
410
|
-
},
|
|
411
|
-
|
|
412
|
-
/**
|
|
413
|
-
* Register the component as focussed
|
|
414
|
-
*/
|
|
415
|
-
focus () {
|
|
416
|
-
this.isFocussed = true
|
|
417
|
-
},
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* Remove the focussed value
|
|
421
|
-
*/
|
|
422
|
-
blur () {
|
|
423
|
-
this.isFocussed = false
|
|
424
|
-
},
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* Is this item selected?
|
|
428
|
-
* @param {Object}
|
|
429
|
-
* @return {Boolean}
|
|
430
|
-
*/
|
|
431
|
-
isSelected (key) {
|
|
432
|
-
return key === this.selectedIndex
|
|
433
|
-
},
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* Focus on the previous results item
|
|
437
|
-
*/
|
|
438
|
-
up () {
|
|
439
|
-
if (this.selectedIndex === null) {
|
|
440
|
-
this.selectedIndex = this.results.length - 1
|
|
441
|
-
return
|
|
442
|
-
}
|
|
443
|
-
this.selectedIndex = (this.selectedIndex === 0) ? this.results.length - 1 : this.selectedIndex - 1
|
|
444
|
-
},
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* Focus on the next results item
|
|
448
|
-
*/
|
|
449
|
-
down () {
|
|
450
|
-
if (this.selectedIndex === null) {
|
|
451
|
-
this.selectedIndex = 0
|
|
452
|
-
return
|
|
453
|
-
}
|
|
454
|
-
this.selectedIndex = (this.selectedIndex === this.results.length - 1) ? 0 : this.selectedIndex + 1
|
|
455
|
-
},
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* Select an item via the keyboard
|
|
459
|
-
*/
|
|
460
|
-
enter () {
|
|
461
|
-
if (this.selectedIndex === null) {
|
|
462
|
-
this.$emit('nothingSelected', this.display)
|
|
463
|
-
return
|
|
464
|
-
}
|
|
465
|
-
this.select(this.results[this.selectedIndex])
|
|
466
|
-
this.$emit('enter', this.display)
|
|
467
|
-
},
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
* Clear all values, results and errors
|
|
471
|
-
*/
|
|
472
|
-
clear () {
|
|
473
|
-
this.display = null
|
|
474
|
-
this.value = null
|
|
475
|
-
this.results = null
|
|
476
|
-
this.error = null
|
|
477
|
-
this.$emit('clear')
|
|
478
|
-
},
|
|
479
|
-
|
|
480
|
-
/**
|
|
481
|
-
* Close the results list. If nothing was selected clear the search
|
|
482
|
-
*/
|
|
483
|
-
close () {
|
|
484
|
-
if (!this.value || !this.selectedDisplay) {
|
|
485
|
-
this.clear()
|
|
486
|
-
}
|
|
487
|
-
if (this.selectedDisplay !== this.display && this.value) {
|
|
488
|
-
this.display = this.selectedDisplay
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
this.results = null
|
|
492
|
-
this.error = null
|
|
493
|
-
this.removeEventListener()
|
|
494
|
-
this.$emit('close')
|
|
495
|
-
},
|
|
496
|
-
|
|
497
|
-
/**
|
|
498
|
-
* Add event listener for clicks outside the results
|
|
499
|
-
*/
|
|
500
|
-
setEventListener () {
|
|
501
|
-
if (this.eventListener) {
|
|
502
|
-
return false
|
|
503
|
-
}
|
|
504
|
-
this.eventListener = true
|
|
505
|
-
document.addEventListener('click', this.clickOutsideListener, true)
|
|
506
|
-
return true
|
|
507
|
-
},
|
|
508
|
-
|
|
509
|
-
/**
|
|
510
|
-
* Remove the click event listener
|
|
511
|
-
*/
|
|
512
|
-
removeEventListener () {
|
|
513
|
-
this.eventListener = false
|
|
514
|
-
document.removeEventListener('click', this.clickOutsideListener, true)
|
|
515
|
-
},
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* Method invoked by the event listener
|
|
519
|
-
*/
|
|
520
|
-
clickOutsideListener (event) {
|
|
521
|
-
if (this.$el && !this.$el.contains(event.target)) {
|
|
522
|
-
this.close()
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
},
|
|
526
|
-
mounted () {
|
|
527
|
-
this.value = this.initialValue
|
|
528
|
-
this.display = this.initialDisplay
|
|
529
|
-
this.selectedDisplay = this.initialDisplay
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
</script>
|
|
533
|
-
|
|
534
|
-
<style lang="stylus">
|
|
535
|
-
.autocomplete
|
|
536
|
-
position relative
|
|
537
|
-
width 100%
|
|
538
|
-
*
|
|
539
|
-
box-sizing border-box
|
|
540
|
-
|
|
541
|
-
.autocomplete__box
|
|
542
|
-
display flex
|
|
543
|
-
align-items center
|
|
544
|
-
background #fff
|
|
545
|
-
border: 1px solid #ccc
|
|
546
|
-
border-radius 3px
|
|
547
|
-
padding 0 5px
|
|
548
|
-
|
|
549
|
-
.autocomplete__searching
|
|
550
|
-
border-radius 3px 3px 0 0
|
|
551
|
-
|
|
552
|
-
.autocomplete__inputs
|
|
553
|
-
flex-grow 1
|
|
554
|
-
padding 0 5px
|
|
555
|
-
input
|
|
556
|
-
width 100%
|
|
557
|
-
border 0
|
|
558
|
-
&:focus
|
|
559
|
-
outline none
|
|
560
|
-
|
|
561
|
-
.autocomplete--clear
|
|
562
|
-
cursor pointer
|
|
563
|
-
|
|
564
|
-
.autocomplete__results
|
|
565
|
-
margin 0
|
|
566
|
-
padding 0
|
|
567
|
-
list-style-type none
|
|
568
|
-
z-index 1000
|
|
569
|
-
position absolute
|
|
570
|
-
max-height 400px
|
|
571
|
-
overflow-y auto
|
|
572
|
-
background white
|
|
573
|
-
width 100%
|
|
574
|
-
border 1px solid #ccc
|
|
575
|
-
border-top 0
|
|
576
|
-
color black
|
|
577
|
-
|
|
578
|
-
.autocomplete__results__item--error
|
|
579
|
-
color red
|
|
580
|
-
|
|
581
|
-
.autocomplete__results__item
|
|
582
|
-
padding 7px 10px
|
|
583
|
-
cursor pointer
|
|
584
|
-
&:hover
|
|
585
|
-
background rgba(0, 180, 255, 0.075)
|
|
586
|
-
&.autocomplete__selected
|
|
587
|
-
background rgba(0, 180, 255, 0.15)
|
|
588
|
-
|
|
589
|
-
.autocomplete__icon
|
|
590
|
-
height 14px
|
|
591
|
-
width 14px
|
|
592
|
-
|
|
593
|
-
.animate-spin
|
|
594
|
-
animation spin 2s infinite linear
|
|
595
|
-
|
|
596
|
-
@keyframes spin
|
|
597
|
-
from
|
|
598
|
-
transform rotate(0deg)
|
|
599
|
-
to
|
|
600
|
-
transform rotate(360deg)
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
</style>
|
package/md.txt
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export default class CustomFormatter {
|
|
2
|
-
constructor (options = {}) {
|
|
3
|
-
this._locale = options.locale || 'en-US'
|
|
4
|
-
this._formatter = new MessageFormat(this._locale)
|
|
5
|
-
this._caches = Object.create(null)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interpolate (message, values) {
|
|
9
|
-
let fn = this._caches[message]
|
|
10
|
-
if (!fn) {
|
|
11
|
-
fn = this._formatter.compile(message, this._locale)
|
|
12
|
-
this._caches[message] = fn
|
|
13
|
-
}
|
|
14
|
-
return [fn(values)]
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// 在 Vue 的原型中挂载 $t 方法,这是我们为什么能够直接在模板中使用的原因
|
|
19
|
-
// 把 VueI18n 对象实例的方法都注入到 Vue 实例上
|
|
20
|
-
Vue.prototype.$t = function (key: Path, ...values: any): TranslateResult {
|
|
21
|
-
const i18n = this.$i18n
|
|
22
|
-
// 代理模式的使用
|
|
23
|
-
return i18n._t(key, i18n.locale, i18n._getMessages(), this, ...values)
|
|
24
|
-
}
|
package/py/cn.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const dict = require('./dict-cn.json');
|
|
2
|
-
const decode = require('./decode');
|
|
3
|
-
const Engine = require('./engine');
|
|
4
|
-
|
|
5
|
-
const DICT = decode(dict);
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 拼音查询引擎
|
|
9
|
-
* @param {[string]|[Object]} data 数据
|
|
10
|
-
* @param {?string|[string]} indexs 如果 data 为 [Object],这里需要建立拼音索引 key
|
|
11
|
-
* @param {?boolean|[boolean]} begin 如果 begin 为 true,从开始字符匹配
|
|
12
|
-
*/
|
|
13
|
-
class PinyinEngine extends Engine {
|
|
14
|
-
constructor(data, indexs, begin) {
|
|
15
|
-
super(data, indexs, DICT, (begin && '$'));
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 将内容进行分词
|
|
20
|
-
* @param {string} words 目标字符串
|
|
21
|
-
* @return {string}
|
|
22
|
-
*/
|
|
23
|
-
static participle(keyword) {
|
|
24
|
-
return Engine.participle(keyword, DICT);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = PinyinEngine;
|
package/py/decode.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
module.exports = dict => {
|
|
2
|
-
const [word] = dict;
|
|
3
|
-
const keys = dict[1].split(',');
|
|
4
|
-
const map = {};
|
|
5
|
-
|
|
6
|
-
if (!dict.length) {
|
|
7
|
-
return map;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
for (let i = 0, charCode = 0, len = word.length; i < len; i ++, charCode ++) {
|
|
11
|
-
const val = word[i];
|
|
12
|
-
|
|
13
|
-
// 处理偏移
|
|
14
|
-
if (val < 0) {
|
|
15
|
-
charCode -= val + 1;
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const char = String.fromCharCode(charCode);
|
|
20
|
-
|
|
21
|
-
if (typeof val === 'number') {
|
|
22
|
-
map[char] = [keys[val]];
|
|
23
|
-
} else {
|
|
24
|
-
map[char] = [];
|
|
25
|
-
for (let w = 0, l = val.length; w < l; w ++) {
|
|
26
|
-
map[char].push(keys[val[w]]);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return map;
|
|
33
|
-
};
|