@94ai/nf-popup-lazy-select 3.1.13

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,10 @@
1
+ import NfPopupLazySelect from './nf-popup-lazy-select.vue'
2
+ import { Vue2, PluginObject } from 'vue-demi'
3
+ import CustomSelectDropdown from './custom-select-dropdown.vue'
4
+
5
+ NfPopupLazySelect.install = (app: typeof Vue2) => {
6
+ app!.component('nf-popup-lazy-select', NfPopupLazySelect)
7
+ app!.component('custom-select-dropdown', CustomSelectDropdown)
8
+ }
9
+
10
+ export default NfPopupLazySelect as typeof NfPopupLazySelect & PluginObject<undefined>
@@ -0,0 +1,440 @@
1
+ <template>
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="changeHide"
21
+ @show="changeShow"
22
+ >
23
+ <slot slot="reference" name="default"></slot>
24
+ <nf-lazy-select
25
+ v-model="currentVal"
26
+ ref="popLazySelectRef"
27
+ :visible-change-keyword-cached="visibleChangeKeywordCached"
28
+ :visible-change-select-list-cached="visibleChangeSelectListCached"
29
+ :emit-selected-item-on-click="emitSelectedItemOnClick"
30
+ :tag="tag"
31
+
32
+ :request="request"
33
+ :page-size="pageSize"
34
+ :page-no-alias="pageNoAlias"
35
+ :page-size-alias="pageSizeAlias"
36
+ :value-alias="valueAlias"
37
+ :keyword-alias="keywordAlias"
38
+
39
+ :loading-desc="loadingDesc"
40
+ :no-data-text="noDataText"
41
+ :placeholder="placeholder"
42
+
43
+ :multiple-limit="multipleLimit"
44
+ :collapse-tags="collapseTags"
45
+
46
+ :disabled="disabled"
47
+ :popper-class="popperClass"
48
+ :multiple="multiple"
49
+ :reserve-keyword="reserveKeyword"
50
+ :default-first-option="defaultFirstOption"
51
+ :popper-append-to-body="false"
52
+
53
+ :key-value="keyValue"
54
+ :data-key="dataKey"
55
+ :virtual-list="virtualList"
56
+ :keeps="keeps"
57
+ :estimate-size="estimateSize"
58
+
59
+ v-bind="$attrs"
60
+
61
+ :offset="offset"
62
+ :start="start"
63
+ :page-mode="pageMode"
64
+ :direction="direction"
65
+ :top-threshold="topThreshold"
66
+ :bottom-threshold="bottomThreshold"
67
+ :root-tag="rootTag"
68
+ :wrap-tag="wrapTag"
69
+ :wrap-style="wrapStyle"
70
+ :item-tag="itemTag"
71
+ :item-class="itemClass"
72
+ :item-class-add="itemClassAdd"
73
+ :item-style="itemStyle"
74
+ :item-scoped-slots="itemScopedSlots"
75
+ :header-tag="headerTag"
76
+ :header-class="headeClass"
77
+ :header-style="headerStyle"
78
+ :footer-tag="footerTag"
79
+ :footer-class="footerClass"
80
+ :footer-style="footerStyle"
81
+ :extra-props="extraProps"
82
+
83
+ :size="size"
84
+ :showTip="showTip"
85
+ :width="width"
86
+ :max-width="maxWidth"
87
+ :height="dataList.length ? height : '0'"
88
+
89
+ @get-selected-data="getSelectedData"
90
+ @select-item="selectItem"
91
+ @scroll="e => $emit('scroll', e)"
92
+ @totop="e => $emit('totop', e)"
93
+ @tobottom="e => $emit('tobottom', e)"
94
+ @resized="e => $emit('resized', e)"
95
+ @remove-tag="e => $emit('remove-tag', e)"
96
+ @blur="e => $emit('blur', e)"
97
+ @focus="e => $emit('focus', e)"
98
+ @clear="e => $emit('clear', e)"
99
+ @visible-change="visibleChange"
100
+ @fetch-data="fetchDataHandler"
101
+ >
102
+ <slot name="prefix" slot="prefix" v-if="!multiple">
103
+ <span class="nf-input__prefix el-input__prefix"><i class="el-icon-search"></i></span>
104
+ </slot>
105
+ <slot name="header" slot="header"></slot>
106
+ <slot name="empty" slot="empty" />
107
+ <slot name="loading" slot="loading" />
108
+ </nf-lazy-select>
109
+ </el-popover>
110
+ </template>
111
+
112
+ <script lang="ts">
113
+ import { defineComponent } from 'vue-demi'
114
+
115
+ export default defineComponent({
116
+ name: 'nf-popup-lazy-select'
117
+ })
118
+ </script>
119
+
120
+ <script lang="ts" setup>
121
+ import {
122
+ computed,
123
+ ref
124
+ } from 'vue-demi'
125
+
126
+ const props = withDefaults(defineProps<{
127
+ tag?: string, // 定制下拉渲染标签
128
+ popdownOnSelect?: boolean, // 选中关闭浮层
129
+ assignmentOnSelect?: boolean, // 选中赋值
130
+ emitSelectedItemOnClick?: boolean, // 选中触发get
131
+ visibleChangeKeywordCached?: boolean, // focus时要不要缓存上一次搜索的keyword
132
+ visibleChangeSelectListCached?: boolean, // focus时要不要缓存上一次搜索的下拉列表
133
+
134
+ /**
135
+ * 输入时传递给后端key别名定制
136
+ */
137
+ keywordAlias?: string,
138
+ pageNoAlias?: string,
139
+ pageSizeAlias?: string,
140
+ valueAlias?: string,
141
+ /**
142
+ * 调用页数的接口,要求返回{records: any[], total:number}的格式
143
+ */
144
+ request?: Function,
145
+ /**
146
+ * 加载中文本提示
147
+ */
148
+ loadingDesc?: string,
149
+ /**
150
+ * 分页大小
151
+ */
152
+ pageSize?: number
153
+ /**
154
+ * 初始化是否加载数据,不加载则延迟到focus
155
+ */
156
+ initList?: boolean
157
+
158
+ /**
159
+ * el-select参数
160
+ */
161
+ multipleLimit?: number
162
+ collapseTags?: boolean
163
+ disabled?: boolean
164
+ multiple?: boolean
165
+ reserveKeyword?: boolean
166
+ popperClass?: string
167
+ defaultFirstOption?: boolean
168
+ /**
169
+ * 输入框文本提示
170
+ */
171
+ placeholder?: string
172
+ /**
173
+ * 没数据文本提示
174
+ */
175
+ noDataText?: string
176
+
177
+ /**
178
+ * 虚拟滚动其他参数
179
+ */
180
+ offset?: number,
181
+ start?: number,
182
+ pageMode?: boolean,
183
+ direction?: string,
184
+ topThreshold?: number,
185
+ bottomThreshold?: number,
186
+ rootTag?: string,
187
+ wrapTag?: string,
188
+ wrapStyle?: Record<string, any>,
189
+ itemTag?: string,
190
+ itemClass?: string,
191
+ itemClassAdd?: Function,
192
+ itemStyle?: Record<string, any>,
193
+ itemScopedSlots?: Record<string, any>,
194
+ headerTag?: string,
195
+ headeClass?: string,
196
+ headerStyle?: Record<string, any>,
197
+ footerTag?: string,
198
+ footerClass?: string,
199
+ footerStyle?: Record<string, any>,
200
+ extraProps?: Record<string, any>
201
+
202
+ /**
203
+ * 开启虚拟滚动
204
+ */
205
+ virtualList?: boolean,
206
+ dataKey?: string | (() => string),
207
+ keyValue?: [string, string],
208
+ dataComponent?: Record<string, any>,
209
+ keeps?: number,
210
+ estimateSize?: number,
211
+
212
+ /**
213
+ * 样式控制
214
+ */
215
+ width?: string,
216
+ height?: string,
217
+ maxWidth?: string,
218
+
219
+ /**
220
+ * 开启select item tooltip
221
+ */
222
+ showTip?: boolean,
223
+
224
+ popupWidth?: string | number
225
+ popupClass?: string
226
+ popupTitle?: string
227
+ popupDisabled?: boolean
228
+ popupOffset?: number
229
+ popupPlacement?: string
230
+ popupTrigger?: 'click' | 'focus' | 'hover' | 'manual'
231
+ popupTransition?: string
232
+ popupVisibleArrow?: boolean
233
+ popupOptions?: Record<string, any>
234
+ popupOpenDelay?: number
235
+ popupCloseDelay?: number
236
+ popupTabindex?: number
237
+
238
+ size?: 'mini' | 'medium' | 'small'
239
+ value?: string | number | string[] | number[]
240
+ }>(), {
241
+ tag: 'custom-select-dropdown', // 定制下拉渲染标签
242
+ popdownOnSelect: false, // 选中关闭浮层
243
+ assignmentOnSelect: true, // 选中赋值
244
+ emitSelectedItemOnClick: false, // 选中触发get-selected-data
245
+ visibleChangeKeywordCached: true, // focus时要不要缓存上一次搜索的keyword
246
+ visibleChangeSelectListCached: true, // focus时要不要缓存上一次搜索的下拉列表
247
+
248
+ keywordAlias: 'keyword',
249
+ pageNoAlias: 'pageNo',
250
+ pageSizeAlias: 'pageSize',
251
+ valueAlias: 'value',
252
+ // 调用页数的接口
253
+ request: () => ({}),
254
+ loadingDesc: '加载中...',
255
+ pageSize: 10,
256
+ initList: true,
257
+
258
+ noDataText: '无数据',
259
+ multipleLimit: 0,
260
+ collapseTags: false,
261
+ disabled: false,
262
+ multiple: false,
263
+ reserveKeyword: true,
264
+ popperClass: '',
265
+ defaultFirstOption: false,
266
+ placeholder: '请输入',
267
+
268
+ offset: 0,
269
+ start: 0,
270
+ pageMode: false,
271
+ direction: 'vertical',
272
+ topThreshold: 0,
273
+ bottomThreshold: 0,
274
+ rootTag: 'div',
275
+ wrapTag: 'div',
276
+ wrapStyle: () => ({}),
277
+ itemTag: 'div',
278
+ itemClass: '',
279
+ itemClassAdd: undefined,
280
+ itemStyle: () => ({}),
281
+ itemScopedSlots: () => ({}),
282
+ headerTag: 'div',
283
+ headeClass: '',
284
+ headerStyle: () => ({}),
285
+ footerTag: 'div',
286
+ footerClass: '',
287
+ footerStyle: () => ({}),
288
+ extraProps: () => ({
289
+ label: 'label',
290
+ value: 'value'
291
+ }),
292
+
293
+ keeps: 30,
294
+ estimateSize: 50,
295
+ dataKey: 'templateId',
296
+ virtualList: false,
297
+ keyValue: () => ['label', 'value'],
298
+
299
+ width: 'calc(100% - 6px)',
300
+ height: '245px',
301
+ maxWidth: 'calc(100% - 6px)',
302
+
303
+ showTip: false,
304
+
305
+ popupWidth: '200',
306
+ popupClass: '',
307
+ popupDisabled: false,
308
+ popupOffset: 0,
309
+ popupPlacement: 'bottom',
310
+ popupTrigger: 'click',
311
+ popupTransition: 'fade-in-linear',
312
+ popupVisibleArrow: true,
313
+ popupOptions: () => ({ boundariesElement: 'body', gpuAcceleration: false }),
314
+ popupCloseDelay: 200,
315
+ popupTabindex: 0,
316
+
317
+ size: 'mini',
318
+
319
+ value: undefined
320
+ })
321
+
322
+ const emit = defineEmits<{
323
+ (e: 'input', event?: string | number | string[] | number[]): void
324
+ (e: 'change', event?: string | number | string[] | number[]): void
325
+ (e: 'update:value', event?: string | number | string[] | number[]): void
326
+
327
+ (e: 'fetch-data', event: {
328
+ total: number,
329
+ current: number,
330
+ hasMore: boolean,
331
+ keyword: string,
332
+ /**
333
+ * 当前接口分页数据
334
+ */
335
+ records: any[],
336
+ /**
337
+ * 当前下拉所有分页数据
338
+ */
339
+ data: any[],
340
+ /**
341
+ * 当前下拉所有分页接口原始数据
342
+ */
343
+ originData: any[],
344
+ /**
345
+ * 所有经过组件的下拉原始数据
346
+ */
347
+ allCachedDataList: any[],
348
+ }): void
349
+ (e: 'get-selected-data', event: any): void
350
+
351
+ (e: 'visible-change', event: boolean): void
352
+ (e: 'remove-tag', event: string | number): void
353
+ (e: 'clear'): void
354
+ (e: 'blur', event: Event): void
355
+ (e: 'focus', event: Event): void
356
+
357
+ (e: 'scroll', event: Event): void
358
+ (e: 'totop', event: Event): void
359
+ (e: 'tobottom', event: Event): void
360
+ (e: 'resized', event: Event): void
361
+
362
+ (e: 'popup-after-enter', event: Event): void
363
+ (e: 'popup-after-leave', event: Event): void
364
+ (e: 'popup-hide', event: boolean): void
365
+ (e: 'popup-show', event: boolean): void
366
+ }>()
367
+
368
+ const getSelectedData = (e) => {
369
+ emit('get-selected-data', e)
370
+ }
371
+
372
+ const visibleChange = async (e) => {
373
+ emit('visible-change', e)
374
+ }
375
+ const changeHide = () => {
376
+ const visible = popLazySelectRef.value?.$refs?.nfLazySelect?.nfVirtualSelect?.visible
377
+ if (!popup.value && typeof visible === 'boolean' && visible) {
378
+ popLazySelectRef.value.$refs.nfLazySelect.nfVirtualSelect.toggleMenu()
379
+ }
380
+ emit('popup-hide', popup.value)
381
+ }
382
+
383
+ const changeShow = () => {
384
+ const visible = popLazySelectRef.value?.$refs?.nfLazySelect?.nfVirtualSelect?.visible
385
+ if (popup.value && typeof visible === 'boolean' && !visible) {
386
+ popLazySelectRef.value.$refs.nfLazySelect.nfVirtualSelect.toggleMenu()
387
+ }
388
+ emit('popup-show', popup.value)
389
+ }
390
+
391
+
392
+ const popLazySelectRef = ref()
393
+ const popup = ref(false) // 定制关闭浮层
394
+ const dataList = ref<any[]>([]) // 收起缓存数据
395
+ const allCachedDataList = ref<any[]>([])
396
+
397
+ const fetchDataHandler = (e) => {
398
+ dataList.value = e.data
399
+ allCachedDataList.value = e.allCachedDataList
400
+ emit('fetch-data', e)
401
+ }
402
+
403
+ const selectItem = (val) => {
404
+ if (!props.assignmentOnSelect) {
405
+ if (props.emitSelectedItemOnClick) {
406
+ const getValItem = () => { // 发射值
407
+ if (props.multiple) {
408
+ return (val as (number | string)[])?.map(it => allCachedDataList.value.find(item => item[props.valueAlias] === it))
409
+ } else {
410
+ return val ? allCachedDataList.value.find(item => item[props.valueAlias] === val) : val
411
+ }
412
+ }
413
+ emit('get-selected-data', getValItem())
414
+ } else {
415
+ emit('get-selected-data', val)
416
+ }
417
+ }
418
+ }
419
+
420
+ const currentVal = computed({
421
+ get() {
422
+ return props.value
423
+ },
424
+ set(val) {
425
+ if (!props.multiple && props.popdownOnSelect && val) { // 单选&选中关闭浮层&有可能是清空
426
+ popup.value = false
427
+ }
428
+ emit('input', val)
429
+ emit('update:value', val)
430
+ emit('change', val)
431
+ }
432
+ })
433
+
434
+ defineExpose({
435
+ currentVal, // 当前选中值
436
+ popup, // 手动关闭浮层
437
+ popLazySelectRef, // nf-lazy-select
438
+ })
439
+ </script>
440
+
@@ -0,0 +1 @@
1
+ import '@94ai/nf-theme-chalk/lib/css/nf-popup-lazy-select.css'
@@ -0,0 +1 @@
1
+ import '@94ai/nf-theme-chalk/lib/nf-popup-lazy-select.scss'
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@94ai/nf-popup-lazy-select",
3
+ "version": "3.1.13",
4
+ "description": "> TODO: description",
5
+ "keywords": [],
6
+ "author": "zoujiahe <zoujiahe@94ai.com>",
7
+ "homepage": "https://oss.xccjh.top/common-ui/#/ai-index",
8
+ "license": "ISC",
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "http://94ai.gitlab.com/ui/common-ui.git"
15
+ },
16
+ "dependencies": {
17
+ "@94ai/nf-lazy-select": "^3.1.13",
18
+ "@94ai/nf-theme-chalk": "^3.1.13",
19
+ "vue-demi": "^0.14.5"
20
+ },
21
+ "peerDependenciesMeta": {
22
+ "@vue/composition-api": {
23
+ "optional": true
24
+ }
25
+ },
26
+ "peerDependencies": {
27
+ "@vue/composition-api": "^1.0.0-rc.1",
28
+ "element-ui": ">=2.13.2",
29
+ "vue": "^2.0.0 || >=3.0.0"
30
+ },
31
+ "types": "lib/index.d.ts",
32
+ "main": "lib/nf-popup-lazy-select.cjs.js",
33
+ "module": "lib/nf-popup-lazy-select.esm-bundler.js",
34
+ "gitHead": "a8c56183ccc8e979008e2d38bfde2d7d1448654c"
35
+ }
@@ -0,0 +1,8 @@
1
+ export default {
2
+ plugins: {
3
+ // 这个工具可以实现自动添加CSS3前缀
4
+ autoprefixer: {
5
+ overrideBrowserslist: ['last 5 version', '>1%', 'ie >=8']
6
+ },
7
+ },
8
+ }