@94ai/nf-variable-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,148 @@
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
+ @show="$emit('show')"
19
+ @hide="popHideHandle"
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: 'variate-click', event: VariableItem): void
97
+ (e: 'hidden'): void
98
+ (e: 'show'): void
99
+ (e: 'after-enter'): void
100
+ (e: 'after-leave'): void
101
+ }>()
102
+
103
+ const keyword = ref()
104
+ const allList = ref<VariableItem[]>([])
105
+
106
+ const list = computed(() => {
107
+ if (!keyword.value) {
108
+ return allList.value.map(item => {
109
+ if (item[props.keyAlias]) {
110
+ return item
111
+ }
112
+ item[props.keyAlias] = generateUUID()
113
+ return item
114
+ })
115
+ }
116
+ return allList.value.filter(item => {
117
+ return item[props.valueAlias].includes(keyword.value)
118
+ }).map(item => {
119
+ if (item[props.keyAlias]) {
120
+ return item
121
+ }
122
+ item[props.keyAlias] = generateUUID()
123
+ return item
124
+ })
125
+ })
126
+
127
+ watch(() => {
128
+ return props.data
129
+ }, () => {
130
+ allList.value = props.data || []
131
+ }, {
132
+ deep: true,
133
+ immediate: true
134
+ })
135
+
136
+ const handleItem = (item: VariableItem) => {
137
+ emit('variate-click', item)
138
+ }
139
+ const popHideHandle = () => {
140
+ let timer: ReturnType<typeof setTimeout> | undefined = setTimeout(() => {
141
+ clearTimeout(timer)
142
+ timer = undefined
143
+ keyword.value = ''
144
+ }, 300)
145
+ emit('hidden')
146
+ }
147
+ </script>
148
+
@@ -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'
@@ -0,0 +1,5 @@
1
+ export type VariableItem = {
2
+ name?: string
3
+ paramId?: string
4
+ [index:string]: any
5
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@94ai/nf-variable-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/common-utils": "^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-variable-select.cjs.js",
33
+ "module": "lib/nf-variable-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
+ }