@94ai/nf-popup-lazy-select 3.2.72 → 3.2.75
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/lib/index.d.ts +308 -132
- package/lib/nf-popup-lazy-select.cjs.js +204 -72
- package/lib/nf-popup-lazy-select.esm-bundler.js +205 -73
- package/lib/nf-popup-lazy-select.vue.d.ts +131 -50
- package/package/nf-popup-lazy-select.vue +276 -129
- package/package.json +4 -4
|
@@ -1,111 +1,125 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
2
|
+
<el-popover
|
|
3
|
+
class="nf-popup-lazy-select"
|
|
4
|
+
:width="popupWidth"
|
|
5
|
+
:disabled="popupDisabled"
|
|
6
|
+
:popper-class="(popupClass || '') + ' nf-popup-lazy-select-popover'"
|
|
7
|
+
:offset="popupOffset"
|
|
8
|
+
:title="popupTitle"
|
|
9
|
+
:trigger="popupTrigger"
|
|
10
|
+
:placement="popupPlacement"
|
|
11
|
+
:transition="popupTransition"
|
|
12
|
+
:visible-arrow="popupVisibleArrow"
|
|
13
|
+
:popper-options="popupOptions"
|
|
14
|
+
:open-delay="popupOpenDelay"
|
|
15
|
+
:close-delay="popupCloseDelay"
|
|
16
|
+
:tabindex="popupTabindex"
|
|
17
|
+
v-model="popup"
|
|
18
|
+
@after-enter="(e) => $emit('popup-after-enter', e)"
|
|
19
|
+
@after-leave="(e) => $emit('popup-after-leave', e)"
|
|
20
|
+
@hide="(e) => $emit('popup-hide', e)"
|
|
21
|
+
@show="changeShow"
|
|
22
|
+
>
|
|
23
|
+
<slot slot="reference" name="default"></slot>
|
|
24
|
+
<nf-lazy-select
|
|
25
|
+
v-model="currentVal"
|
|
26
|
+
ref="popLazySelectRef"
|
|
27
|
+
|
|
28
|
+
:request="request"
|
|
29
|
+
:page-size="pageSize"
|
|
30
|
+
:page-no-alias="pageNoAlias"
|
|
31
|
+
:page-size-alias="pageSizeAlias"
|
|
32
|
+
:value-alias="valueAlias"
|
|
33
|
+
:keyword-alias="keywordAlias"
|
|
34
|
+
|
|
35
|
+
:loading-desc="loadingDesc"
|
|
36
|
+
:no-data-text="noDataText"
|
|
37
|
+
:placeholder="placeholder"
|
|
38
|
+
|
|
39
|
+
:multiple-limit="multipleLimit"
|
|
40
|
+
:collapse-tags="collapseTags"
|
|
41
|
+
|
|
42
|
+
:disabled="disabled"
|
|
43
|
+
:popper-class="popperClass"
|
|
44
|
+
:multiple="multiple"
|
|
45
|
+
:reserve-keyword="reserveKeyword"
|
|
46
|
+
:default-first-option="defaultFirstOption"
|
|
47
|
+
:popper-append-to-body="false"
|
|
48
|
+
|
|
49
|
+
:key-value="keyValue"
|
|
50
|
+
:data-key="dataKey"
|
|
51
|
+
:virtual-list="virtualList"
|
|
52
|
+
:keeps="keeps"
|
|
53
|
+
:estimate-size="estimateSize"
|
|
54
|
+
|
|
55
|
+
v-bind="$attrs"
|
|
56
|
+
|
|
57
|
+
:offset="offset"
|
|
58
|
+
:start="start"
|
|
59
|
+
:page-mode="pageMode"
|
|
60
|
+
:direction="direction"
|
|
61
|
+
:top-threshold="topThreshold"
|
|
62
|
+
:bottom-threshold="bottomThreshold"
|
|
63
|
+
:root-tag="rootTag"
|
|
64
|
+
:wrap-tag="wrapTag"
|
|
65
|
+
:wrap-style="wrapStyle"
|
|
66
|
+
:item-tag="itemTag"
|
|
67
|
+
:item-class="itemClass"
|
|
68
|
+
:item-class-add="itemClassAdd"
|
|
69
|
+
:item-style="itemStyle"
|
|
70
|
+
:item-scoped-slots="itemScopedSlots"
|
|
71
|
+
:header-tag="headerTag"
|
|
72
|
+
:header-class="headeClass"
|
|
73
|
+
:header-style="headerStyle"
|
|
74
|
+
:footer-tag="footerTag"
|
|
75
|
+
:footer-class="footerClass"
|
|
76
|
+
:footer-style="footerStyle"
|
|
77
|
+
:extra-props="extraProps"
|
|
78
|
+
|
|
79
|
+
:size="size"
|
|
80
|
+
:showTip="showTip"
|
|
81
|
+
:width="width"
|
|
82
|
+
:max-width="maxWidth"
|
|
83
|
+
:height="dataList.length ? height : '0'"
|
|
84
|
+
|
|
85
|
+
@scroll="e => $emit('scroll', e)"
|
|
86
|
+
@totop="e => $emit('totop', e)"
|
|
87
|
+
@tobottom="e => $emit('tobottom', e)"
|
|
88
|
+
@resized="e => $emit('resized', e)"
|
|
89
|
+
@remove-tag="e => $emit('remove-tag', e)"
|
|
90
|
+
@blur="e => $emit('blur', e)"
|
|
91
|
+
@focus="e => $emit('focus', e)"
|
|
92
|
+
@clear="e => $emit('clear', e)"
|
|
93
|
+
@visible-change="visibleChange"
|
|
94
|
+
@fetch-data="fetchDataHandler"
|
|
95
|
+
>
|
|
96
|
+
<slot name="prefix" slot="prefix" v-if="!multiple">
|
|
97
|
+
<span class="nf-input__prefix el-input__prefix"><i class="el-icon-search"></i></span>
|
|
98
|
+
</slot>
|
|
99
|
+
<slot name="header" slot="header"></slot>
|
|
100
|
+
<slot name="empty" slot="empty" />
|
|
101
|
+
<slot name="loading" slot="loading" />
|
|
102
|
+
</nf-lazy-select>
|
|
103
|
+
</el-popover>
|
|
95
104
|
</template>
|
|
96
105
|
|
|
97
106
|
<script lang="ts">
|
|
98
107
|
import { defineComponent } from 'vue-demi'
|
|
99
108
|
|
|
100
109
|
export default defineComponent({
|
|
101
|
-
name:
|
|
110
|
+
name: 'nf-popup-lazy-select'
|
|
102
111
|
})
|
|
103
112
|
</script>
|
|
104
113
|
|
|
105
114
|
<script lang="ts" setup>
|
|
106
|
-
import {
|
|
115
|
+
import {
|
|
116
|
+
computed,
|
|
117
|
+
ref
|
|
118
|
+
} from 'vue-demi'
|
|
107
119
|
|
|
108
120
|
const props = withDefaults(defineProps<{
|
|
121
|
+
popdownOnSelect?: boolean,
|
|
122
|
+
assignmentOnSelect?: boolean,
|
|
109
123
|
/**
|
|
110
124
|
* 输入时传递给后端key别名定制
|
|
111
125
|
*/
|
|
@@ -140,7 +154,6 @@ const props = withDefaults(defineProps<{
|
|
|
140
154
|
reserveKeyword?: boolean
|
|
141
155
|
popperClass?: string
|
|
142
156
|
defaultFirstOption?: boolean
|
|
143
|
-
popperAppendToBody?: boolean
|
|
144
157
|
/**
|
|
145
158
|
* 输入框文本提示
|
|
146
159
|
*/
|
|
@@ -161,7 +174,7 @@ const props = withDefaults(defineProps<{
|
|
|
161
174
|
bottomThreshold?: number,
|
|
162
175
|
rootTag?: string,
|
|
163
176
|
wrapTag?: string,
|
|
164
|
-
wrapStyle?:
|
|
177
|
+
wrapStyle?: Record<string, any>,
|
|
165
178
|
itemTag?: string,
|
|
166
179
|
itemClass?: string,
|
|
167
180
|
itemClassAdd?: Function,
|
|
@@ -190,27 +203,32 @@ const props = withDefaults(defineProps<{
|
|
|
190
203
|
*/
|
|
191
204
|
width?: string,
|
|
192
205
|
height?: string,
|
|
206
|
+
maxWidth?: string,
|
|
193
207
|
|
|
194
208
|
/**
|
|
195
209
|
* 开启select item tooltip
|
|
196
210
|
*/
|
|
197
211
|
showTip?: boolean,
|
|
198
212
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
+
popupWidth?: string | number
|
|
214
|
+
popupClass?: string
|
|
215
|
+
popupTitle?: string
|
|
216
|
+
popupDisabled?: boolean
|
|
217
|
+
popupOffset?: number
|
|
218
|
+
popupPlacement?: string
|
|
219
|
+
popupTrigger?: 'click' | 'focus' | 'hover' | 'manual'
|
|
220
|
+
popupTransition?: string
|
|
221
|
+
popupVisibleArrow?: boolean
|
|
222
|
+
popupOptions?: Record<string, any>
|
|
223
|
+
popupOpenDelay?: number
|
|
224
|
+
popupCloseDelay?: number
|
|
225
|
+
popupTabindex?: number
|
|
226
|
+
|
|
227
|
+
size?: 'mini' | 'medium' | 'small'
|
|
228
|
+
value?: string | number | string[] | number[]
|
|
213
229
|
}>(), {
|
|
230
|
+
popdownOnSelect: false,
|
|
231
|
+
assignmentOnSelect: true,
|
|
214
232
|
keywordAlias: 'keyword',
|
|
215
233
|
pageNoAlias: 'pageNo',
|
|
216
234
|
pageSizeAlias: 'pageSize',
|
|
@@ -229,7 +247,6 @@ const props = withDefaults(defineProps<{
|
|
|
229
247
|
reserveKeyword: false,
|
|
230
248
|
popperClass: '',
|
|
231
249
|
defaultFirstOption: false,
|
|
232
|
-
popperAppendToBody: true,
|
|
233
250
|
placeholder: '请输入',
|
|
234
251
|
|
|
235
252
|
offset: 0,
|
|
@@ -263,29 +280,159 @@ const props = withDefaults(defineProps<{
|
|
|
263
280
|
virtualList: false,
|
|
264
281
|
keyValue: () => ['label', 'value'],
|
|
265
282
|
|
|
266
|
-
width: '100%',
|
|
283
|
+
width: 'calc(100% - 6px)',
|
|
267
284
|
height: '245px',
|
|
285
|
+
maxWidth: 'calc(100% - 6px)',
|
|
268
286
|
|
|
269
287
|
showTip: false,
|
|
270
288
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
289
|
+
popupWidth: '200',
|
|
290
|
+
popupClass: '',
|
|
291
|
+
popupDisabled: false,
|
|
292
|
+
popupOffset: 0,
|
|
293
|
+
popupPlacement: 'bottom',
|
|
294
|
+
popupTrigger: 'click',
|
|
295
|
+
popupTransition: 'fade-in-linear',
|
|
296
|
+
popupVisibleArrow: true,
|
|
297
|
+
popupOptions: () => ({ boundariesElement: 'body', gpuAcceleration: false }),
|
|
298
|
+
popupCloseDelay: 200,
|
|
299
|
+
popupTabindex: 0,
|
|
300
|
+
|
|
301
|
+
size: 'mini',
|
|
302
|
+
|
|
303
|
+
value: undefined
|
|
286
304
|
})
|
|
287
305
|
|
|
288
|
-
const
|
|
306
|
+
const emit = defineEmits<{
|
|
307
|
+
(e: 'input', event?: string | number | string[] | number[]): void
|
|
308
|
+
(e: 'change', event?: string | number | string[] | number[]): void
|
|
309
|
+
(e: 'update:value', event?: string | number | string[] | number[]): void
|
|
310
|
+
|
|
311
|
+
(e: 'fetch-data', event: {
|
|
312
|
+
allCachedList: any[],
|
|
313
|
+
currentList: any[],
|
|
314
|
+
event: {
|
|
315
|
+
total: number,
|
|
316
|
+
current: number,
|
|
317
|
+
hasMore: boolean,
|
|
318
|
+
keyword: string,
|
|
319
|
+
/**
|
|
320
|
+
* 当前记录原始值
|
|
321
|
+
*/
|
|
322
|
+
records: any[],
|
|
323
|
+
/**
|
|
324
|
+
* 原始渲染数据
|
|
325
|
+
*/
|
|
326
|
+
originData: any[],
|
|
327
|
+
/**
|
|
328
|
+
* 组件渲染数据
|
|
329
|
+
*/
|
|
330
|
+
data: any[]
|
|
331
|
+
}
|
|
332
|
+
}): void
|
|
333
|
+
(e: 'select-item', event: any): void
|
|
334
|
+
|
|
335
|
+
(e: 'visible-change', event: boolean): void
|
|
336
|
+
(e: 'remove-tag', event: string | number): void
|
|
337
|
+
(e: 'clear'): void
|
|
338
|
+
(e: 'blur', event: Event): void
|
|
339
|
+
(e: 'focus', event: Event): void
|
|
340
|
+
|
|
341
|
+
(e: 'scroll', event: Event): void
|
|
342
|
+
(e: 'totop', event: Event): void
|
|
343
|
+
(e: 'tobottom', event: Event): void
|
|
344
|
+
(e: 'resized', event: Event): void
|
|
345
|
+
|
|
346
|
+
(e: 'popup-after-enter', event: Event): void
|
|
347
|
+
(e: 'popup-after-leave', event: Event): void
|
|
348
|
+
(e: 'popup-hide', event: boolean): void
|
|
349
|
+
(e: 'popup-show', event: boolean): void
|
|
350
|
+
}>()
|
|
351
|
+
|
|
352
|
+
const changeShow = () => {
|
|
353
|
+
const visible = popLazySelectRef.value?.$refs?.nfLazySelect?.$refs?.nfVirtualSelect?.visible
|
|
354
|
+
if (popup.value && typeof visible === 'boolean' && !visible) { // 手动触发 显示具有副作用,需要定制visible-change
|
|
355
|
+
popLazySelectRef.value.$refs.nfLazySelect.$refs.nfVirtualSelect.toggleMenu()
|
|
356
|
+
}
|
|
357
|
+
emit('popup-show', popup.value)
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const popLazySelectRef = ref()
|
|
361
|
+
const popup = ref(false) // 定制关闭浮层
|
|
362
|
+
const dataList = ref<any[]>([]) // 收起缓存数据
|
|
363
|
+
const dataMap = ref({})
|
|
364
|
+
const lockVisibleChange = ref(false)
|
|
365
|
+
|
|
366
|
+
const visibleChange = async (e) => {
|
|
367
|
+
// console.log(lockVisibleChange.value, 'lockVisibleChange')
|
|
368
|
+
// debugger
|
|
369
|
+
if (lockVisibleChange.value) {
|
|
370
|
+
lockVisibleChange.value = false
|
|
371
|
+
return 'break'
|
|
372
|
+
}
|
|
373
|
+
// console.log(e, 'visibleChange')
|
|
374
|
+
emit('visible-change', e)
|
|
375
|
+
}
|
|
376
|
+
const fetchDataHandler = (e) => {
|
|
377
|
+
e.originData?.forEach(data => {
|
|
378
|
+
if (!dataMap.value[data[props.valueAlias]]) {
|
|
379
|
+
dataMap.value[data[props.valueAlias]] = true
|
|
380
|
+
dataList.value.push(data)
|
|
381
|
+
}
|
|
382
|
+
})
|
|
383
|
+
emit('fetch-data', {
|
|
384
|
+
allCachedList: dataList.value,
|
|
385
|
+
currentList: e.originData,
|
|
386
|
+
event: e
|
|
387
|
+
})
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const currentVal = computed({
|
|
391
|
+
get() {
|
|
392
|
+
return props.value
|
|
393
|
+
},
|
|
394
|
+
set(val) {
|
|
395
|
+
const changeVal = (value) => { // 更改v-model
|
|
396
|
+
emit('input', value)
|
|
397
|
+
emit('update:value', value)
|
|
398
|
+
emit('change', value)
|
|
399
|
+
}
|
|
400
|
+
const getValItem = () => { // 发射值
|
|
401
|
+
if (props.multiple) {
|
|
402
|
+
return (val as (number | string)[])?.map(it => dataList.value.find(item => item[props.valueAlias] === it))
|
|
403
|
+
} else {
|
|
404
|
+
return val ? dataList.value.find(item => item[props.valueAlias] === val) : val
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (!props.multiple) { // 单选
|
|
408
|
+
if (props.popdownOnSelect) { // 选中关闭浮层
|
|
409
|
+
changeVal(undefined)
|
|
410
|
+
if (val) {
|
|
411
|
+
popup.value = false
|
|
412
|
+
}
|
|
413
|
+
} else {
|
|
414
|
+
if (!props.assignmentOnSelect) { // 选中要不要赋值回显
|
|
415
|
+
changeVal(undefined)
|
|
416
|
+
} else {
|
|
417
|
+
changeVal(val)
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
if (val) { // 定制visibleChange
|
|
421
|
+
lockVisibleChange.value = true
|
|
422
|
+
}
|
|
423
|
+
} else {
|
|
424
|
+
changeVal(val)
|
|
425
|
+
}
|
|
426
|
+
emit('select-item', getValItem())
|
|
427
|
+
}
|
|
428
|
+
})
|
|
289
429
|
|
|
430
|
+
defineExpose({
|
|
431
|
+
currentVal,
|
|
432
|
+
dataMap,
|
|
433
|
+
dataList,
|
|
434
|
+
popup,
|
|
435
|
+
popLazySelectRef,
|
|
436
|
+
})
|
|
290
437
|
</script>
|
|
291
438
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@94ai/nf-popup-lazy-select",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.75",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "zoujiahe <zoujiahe@94ai.com>",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"url": "http://94ai.gitlab.com/ui/common-ui.git"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@94ai/nf-
|
|
18
|
-
"@94ai/nf-
|
|
17
|
+
"@94ai/nf-lazy-select": "^3.2.75",
|
|
18
|
+
"@94ai/nf-theme-chalk": "^3.2.75",
|
|
19
19
|
"vue-demi": "^0.14.5"
|
|
20
20
|
},
|
|
21
21
|
"peerDependenciesMeta": {
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"types": "lib/index.d.ts",
|
|
32
32
|
"main": "lib/nf-popup-lazy-select.cjs.js",
|
|
33
33
|
"module": "lib/nf-popup-lazy-select.esm-bundler.js",
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "3e303fef4a30e065979f80c4df5000243b57d652"
|
|
35
35
|
}
|