@94ai/nf-variable-select 3.2.49
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/.eslintrc.cjs +49 -0
- package/README.md +11 -0
- package/components.d.ts +8 -0
- package/lib/index.d.ts +509 -0
- package/lib/nf-variable-select.cjs.js +249 -0
- package/lib/nf-variable-select.esm-bundler.js +249 -0
- package/lib/nf-variable-select.vue.d.ts +184 -0
- package/lib/style/css.d.ts +1 -0
- package/lib/style/css.js +1 -0
- package/lib/style/index.d.ts +1 -0
- package/lib/style/index.js +1 -0
- package/lib/types.d.ts +5 -0
- package/package/index.ts +8 -0
- package/package/nf-variable-select.vue +145 -0
- package/package/style/css.ts +1 -0
- package/package/style/index.ts +1 -0
- package/package/types.ts +5 -0
- package/package.json +34 -0
- package/postcss.config.js +8 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="nf-variable-select">
|
|
3
|
+
<el-popover
|
|
4
|
+
:placement="placement"
|
|
5
|
+
:width="width"
|
|
6
|
+
:trigger="trigger"
|
|
7
|
+
:disabled="disabled"
|
|
8
|
+
:popper-class="(popperClass || '') + ' nf-variate-select-popover'"
|
|
9
|
+
:offset="offset"
|
|
10
|
+
:transition="transition"
|
|
11
|
+
:visible-arrow="visibleArrow"
|
|
12
|
+
:popper-options="popperOptions"
|
|
13
|
+
:open-delay="openDelay"
|
|
14
|
+
:close-delay="closeDelay"
|
|
15
|
+
:tabindex="tabindex"
|
|
16
|
+
@after-enter="$emit('after-enter')"
|
|
17
|
+
@after-leave="$emit('after-leave')"
|
|
18
|
+
@hide="popHideHandle"
|
|
19
|
+
@show="$emit('show')"
|
|
20
|
+
>
|
|
21
|
+
<div slot="reference">
|
|
22
|
+
<slot />
|
|
23
|
+
</div>
|
|
24
|
+
<div class="nf-variable-select-box">
|
|
25
|
+
<div class="nf-variable-select-search">
|
|
26
|
+
<el-input v-model="keyword" prefix-icon="el-icon-search" :placeholder="placeholder" :size="size"/>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="nf-variable-select-variate">
|
|
29
|
+
<div v-for="item in list" :key="item[keyAlias]" class="nf-variable-select-variate-item" @click="handleItem(item)">{{ item[valueAlias] }}</div>
|
|
30
|
+
<div v-if="!list || !list.length" class="nf-variable-select-nothing">{{ noMatchDesc }}</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</el-popover>
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script lang="ts">
|
|
38
|
+
import { defineComponent } from 'vue-demi'
|
|
39
|
+
|
|
40
|
+
export default defineComponent({
|
|
41
|
+
name: "nf-variable-select",
|
|
42
|
+
})
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<script lang="ts" setup>
|
|
46
|
+
import {
|
|
47
|
+
computed,
|
|
48
|
+
ref,
|
|
49
|
+
watch
|
|
50
|
+
} from 'vue-demi'
|
|
51
|
+
import { VariableItem } from './types'
|
|
52
|
+
import {
|
|
53
|
+
generateUUID
|
|
54
|
+
} from '@94ai/common-utils'
|
|
55
|
+
|
|
56
|
+
const props = withDefaults(defineProps<{
|
|
57
|
+
noMatchDesc?: string
|
|
58
|
+
placeholder?: string
|
|
59
|
+
keyAlias?: string
|
|
60
|
+
valueAlias?: string
|
|
61
|
+
data?: VariableItem[]
|
|
62
|
+
placement?: string
|
|
63
|
+
width?: string | number
|
|
64
|
+
trigger?: 'click'|'focus'|'hover'|'manual'
|
|
65
|
+
popperClass?: string
|
|
66
|
+
disabled?: boolean
|
|
67
|
+
offset?: number
|
|
68
|
+
transition?: string
|
|
69
|
+
visibleArrow?: boolean
|
|
70
|
+
popperOptions?: Record<string, any>
|
|
71
|
+
openDelay?: number
|
|
72
|
+
closeDelay?: number
|
|
73
|
+
tabindex?: number
|
|
74
|
+
size?: "mini" | "medium" | "small"
|
|
75
|
+
}>(), {
|
|
76
|
+
noMatchDesc: '无匹配数据',
|
|
77
|
+
placeholder: '输入变量名搜索',
|
|
78
|
+
keyAlias: 'paramId',
|
|
79
|
+
placement: 'bottom',
|
|
80
|
+
valueAlias: 'name',
|
|
81
|
+
width: '160',
|
|
82
|
+
trigger: 'click',
|
|
83
|
+
popperClass: '',
|
|
84
|
+
disabled: false,
|
|
85
|
+
offset: 0,
|
|
86
|
+
transition: 'fade-in-linear',
|
|
87
|
+
visibleArrow: true,
|
|
88
|
+
popperOptions: () => ({ boundariesElement: 'body', gpuAcceleration: false }),
|
|
89
|
+
data: () => [],
|
|
90
|
+
openDelay: undefined,
|
|
91
|
+
closeDelay: 200,
|
|
92
|
+
tabindex: 0,
|
|
93
|
+
size: 'mini'
|
|
94
|
+
})
|
|
95
|
+
const emit = defineEmits<{
|
|
96
|
+
(e: 'variateClick', event: VariableItem): void
|
|
97
|
+
(e: 'hidden'): void
|
|
98
|
+
}>()
|
|
99
|
+
|
|
100
|
+
const keyword = ref()
|
|
101
|
+
const allList = ref<VariableItem[]>([])
|
|
102
|
+
|
|
103
|
+
const list = computed(() => {
|
|
104
|
+
if (!keyword.value) {
|
|
105
|
+
return allList.value.map(item => {
|
|
106
|
+
if (item[props.keyAlias]) {
|
|
107
|
+
return item
|
|
108
|
+
}
|
|
109
|
+
item[props.keyAlias] = generateUUID()
|
|
110
|
+
return item
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
return allList.value.filter(item => {
|
|
114
|
+
return item[props.valueAlias].includes(keyword.value)
|
|
115
|
+
}).map(item => {
|
|
116
|
+
if (item[props.keyAlias]) {
|
|
117
|
+
return item
|
|
118
|
+
}
|
|
119
|
+
item[props.keyAlias] = generateUUID()
|
|
120
|
+
return item
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
watch(() => {
|
|
125
|
+
return props.data
|
|
126
|
+
}, () => {
|
|
127
|
+
allList.value = props.data || []
|
|
128
|
+
}, {
|
|
129
|
+
deep: true,
|
|
130
|
+
immediate: true
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
const handleItem = (item: VariableItem) => {
|
|
134
|
+
emit('variateClick', item)
|
|
135
|
+
}
|
|
136
|
+
const popHideHandle = () => {
|
|
137
|
+
let timer: ReturnType<typeof setTimeout> | undefined = setTimeout(() => {
|
|
138
|
+
clearTimeout(timer)
|
|
139
|
+
timer = undefined
|
|
140
|
+
keyword.value = ''
|
|
141
|
+
}, 300)
|
|
142
|
+
emit('hidden')
|
|
143
|
+
}
|
|
144
|
+
</script>
|
|
145
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@94ai/nf-theme-chalk/lib/css/nf-variable-select.css'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@94ai/nf-theme-chalk/lib/nf-variable-select.scss'
|
package/package/types.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@94ai/nf-variable-select",
|
|
3
|
+
"version": "3.2.49",
|
|
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-theme-chalk": "^3.2.49",
|
|
18
|
+
"vue-demi": "^0.14.5"
|
|
19
|
+
},
|
|
20
|
+
"peerDependenciesMeta": {
|
|
21
|
+
"@vue/composition-api": {
|
|
22
|
+
"optional": true
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@vue/composition-api": "^1.0.0-rc.1",
|
|
27
|
+
"element-ui": ">=2.13.2",
|
|
28
|
+
"vue": "^2.0.0 || >=3.0.0"
|
|
29
|
+
},
|
|
30
|
+
"types": "lib/index.d.ts",
|
|
31
|
+
"main": "lib/nf-variable-select.cjs.js",
|
|
32
|
+
"module": "lib/nf-variable-select.esm-bundler.js",
|
|
33
|
+
"gitHead": "8cbd9254da4ec43f46b29198c0839bf2ba19132d"
|
|
34
|
+
}
|