nubomed-ui 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/.env.bi +13 -0
- package/.env.terminal +13 -0
- package/.vscode/extensions.json +3 -0
- package/README.md +17 -0
- package/index.html +13 -0
- package/nubomed-ui/nubomed-ui.es.js +2005 -0
- package/nubomed-ui/nubomed-ui.umd.js +1 -0
- package/nubomed-ui/style.css +1 -0
- package/package.json +19 -7
- package/src/App.vue +31 -0
- package/src/bi-demos/Header.vue +29 -0
- package/src/bi-demos/Table.vue +69 -0
- package/src/bi-demos/index.vue +132 -0
- package/src/bi-packages/components/Box/images/corner-error.png +0 -0
- package/src/bi-packages/components/Box/images/corner-warning.png +0 -0
- package/src/bi-packages/components/Box/images/corner.png +0 -0
- package/src/bi-packages/components/Box/index.scss +86 -0
- package/src/bi-packages/components/Box/index.vue +53 -0
- package/src/bi-packages/components/Carousel/CarouselItem.vue +0 -0
- package/src/bi-packages/components/Carousel/index.vue +0 -0
- package/src/bi-packages/components/Header/images/left-bg.png +0 -0
- package/src/bi-packages/components/Header/images/logo.png +0 -0
- package/src/bi-packages/components/Header/images/right-bg.png +0 -0
- package/src/bi-packages/components/Header/index.scss +50 -0
- package/src/bi-packages/components/Header/index.vue +54 -0
- package/src/bi-packages/components/Table/TableColgroup.vue +43 -0
- package/src/bi-packages/components/Table/index copy.vue +107 -0
- package/src/bi-packages/components/Table/index.scss +118 -0
- package/src/bi-packages/components/Table/index.vue +108 -0
- package/src/bi-packages/components/TableColumn/index.scss +7 -0
- package/src/bi-packages/components/TableColumn/index.vue +60 -0
- package/src/bi-packages/fonts/OPPOSans-B.ttf +0 -0
- package/src/bi-packages/fonts/OPPOSans-M.ttf +0 -0
- package/src/bi-packages/fonts/font.scss +11 -0
- package/src/bi-packages/iconfont-svg/demo.css +539 -0
- package/src/bi-packages/iconfont-svg/demo_index.html +4811 -0
- package/src/bi-packages/iconfont-svg/iconfont.css +819 -0
- package/src/bi-packages/iconfont-svg/iconfont.js +1 -0
- package/src/bi-packages/iconfont-svg/iconfont.json +1416 -0
- package/src/bi-packages/iconfont-svg/iconfont.ttf +0 -0
- package/src/bi-packages/iconfont-svg/iconfont.woff +0 -0
- package/src/bi-packages/iconfont-svg/iconfont.woff2 +0 -0
- package/src/bi-packages/index.js +34 -0
- package/src/bi-packages/styles/mixin.scss +12 -0
- package/src/bi-packages/styles/var.scss +11 -0
- package/src/demos/ActionBar.vue +59 -0
- package/src/demos/Badge.vue +28 -0
- package/src/demos/Button copy.vue +302 -0
- package/src/demos/Button.vue +116 -0
- package/src/demos/ButtonGroup.vue +40 -0
- package/src/demos/Check.vue +29 -0
- package/src/demos/Dialog.vue +255 -0
- package/src/demos/Empty.vue +38 -0
- package/src/demos/FooterMenu.vue +49 -0
- package/src/demos/Header.vue +71 -0
- package/src/demos/Icons.vue +314 -0
- package/src/demos/Input.vue +87 -0
- package/src/demos/InputKeyboard.vue +30 -0
- package/src/demos/InputNumber.vue +34 -0
- package/src/demos/LeftMenu.vue +128 -0
- package/src/demos/Menus.vue +106 -0
- package/src/demos/OpenCabinetBall.vue +37 -0
- package/src/demos/Statusbar.vue +146 -0
- package/src/demos/Steps.vue +45 -0
- package/src/demos/Tost.vue +35 -0
- package/src/demos/button/button.md +19 -0
- package/src/demos/data/terList.json +145 -0
- package/src/demos/images/cabinets/H3000-D.png +0 -0
- package/src/demos/images/cabinets/H3000-R.png +0 -0
- package/src/demos/images/cabinets/H3000-Rh.png +0 -0
- package/src/demos/images/cabinets/H3000-Rh2.png +0 -0
- package/src/demos/images/cabinets/H3010-R.png +0 -0
- package/src/demos/index.vue +348 -0
- package/src/docs/icons/Icon.vue +72 -0
- package/src/docs/icons/icon.md +21 -0
- package/src/docs/index.html +15 -0
- package/src/docs/index.vue +301 -0
- package/src/main.js +23 -0
- package/src/packages/components/ActionBar/images/error.png +0 -0
- package/src/packages/components/ActionBar/images/loading.gif +0 -0
- package/src/packages/components/ActionBar/images/success.png +0 -0
- package/src/packages/components/ActionBar/images/warning.png +0 -0
- package/src/packages/components/ActionBar/images/warning_yellow.png +0 -0
- package/src/packages/components/ActionBar/index.scss +81 -0
- package/src/packages/components/ActionBar/index.vue +100 -0
- package/src/packages/components/Badge/index.scss +50 -0
- package/src/packages/components/Badge/index.vue +75 -0
- package/src/packages/components/Button/index.scss +241 -0
- package/src/packages/components/Button/index.vue +111 -0
- package/src/packages/components/ButtonGroup/index.scss +54 -0
- package/src/packages/components/ButtonGroup/index.vue +75 -0
- package/src/packages/components/Check/Cate.vue +138 -0
- package/src/packages/components/Check/index.scss +47 -0
- package/src/packages/components/Check/index.vue +105 -0
- package/src/packages/components/Dialog/images/error.png +0 -0
- package/src/packages/components/Dialog/images/success.png +0 -0
- package/src/packages/components/Dialog/images/warning-red.png +0 -0
- package/src/packages/components/Dialog/images/warning-yellow.png +0 -0
- package/src/packages/components/Dialog/index.scss +154 -0
- package/src/packages/components/Dialog/index.vue +305 -0
- package/src/packages/components/Empty/images/empty-abnormal.png +0 -0
- package/src/packages/components/Empty/images/empty-data.png +0 -0
- package/src/packages/components/Empty/images/empty-search.png +0 -0
- package/src/packages/components/Empty/index.vue +68 -0
- package/src/packages/components/Form/FormItem.vue +73 -0
- package/src/packages/components/Form/index.vue +76 -0
- package/src/packages/components/Icon/index.vue +30 -0
- package/src/packages/components/Input/index.scss +184 -0
- package/src/packages/components/Input/index.vue +189 -0
- package/src/packages/components/InputKeyboard/index.scss +63 -0
- package/src/packages/components/InputKeyboard/index.vue +117 -0
- package/src/packages/components/InputNumber/index.scss +103 -0
- package/src/packages/components/InputNumber/index.vue +160 -0
- package/src/packages/components/Menu/index.scss +559 -0
- package/src/packages/components/Menu/index.vue +211 -0
- package/src/packages/components/OpenCabinetBall/CabinetStatus.vue +94 -0
- package/src/packages/components/OpenCabinetBall/index.scss +204 -0
- package/src/packages/components/OpenCabinetBall/index.vue +113 -0
- package/src/packages/components/Statusbar/CabinetList.vue +125 -0
- package/src/packages/components/Statusbar/CabinetListStatus.vue +75 -0
- package/src/packages/components/Statusbar/CabinetListTempHum.vue +108 -0
- package/src/packages/components/Statusbar/index.scss +205 -0
- package/src/packages/components/Statusbar/index.vue +83 -0
- package/src/packages/components/Steps/index.scss +104 -0
- package/src/packages/components/Steps/index.vue +66 -0
- package/src/packages/components/SvgIcon/index.vue +41 -0
- package/src/packages/components/Toast/index.vue +72 -0
- package/src/packages/fonts/OPPOSans-B.ttf +0 -0
- package/src/packages/fonts/OPPOSans-M.ttf +0 -0
- package/src/packages/fonts/font.scss +11 -0
- package/src/packages/iconfont-svg/demo.css +539 -0
- package/src/packages/iconfont-svg/demo_index.html +4811 -0
- package/src/packages/iconfont-svg/iconfont.css +819 -0
- package/src/packages/iconfont-svg/iconfont.js +1 -0
- package/src/packages/iconfont-svg/iconfont.json +1416 -0
- package/src/packages/iconfont-svg/iconfont.ttf +0 -0
- package/src/packages/iconfont-svg/iconfont.woff +0 -0
- package/src/packages/iconfont-svg/iconfont.woff2 +0 -0
- package/src/packages/index.js +64 -0
- package/src/packages/styles/var.scss +24 -0
- package/src/utils/create.js +48 -0
- package/src/utils/index.js +13 -0
- package/src/utils/validate.js +3 -0
- package/vite.config.js +47 -0
- package/nubomed-ui.es.js +0 -152
- package/nubomed-ui.umd.js +0 -1
- package/style.css +0 -1
@@ -0,0 +1,73 @@
|
|
1
|
+
<!--
|
2
|
+
* @Author: chenghuan.dong
|
3
|
+
* @Date: 2022-12-24 19:25:39
|
4
|
+
* @LastEditors: chenghuan.dong
|
5
|
+
* @LastEditTime: 2023-07-04 20:11:13
|
6
|
+
* @Description: 空页面
|
7
|
+
-->
|
8
|
+
<template>
|
9
|
+
<div :class="bem(['', prop])" :prop="prop" :ref="prop">
|
10
|
+
<label v-if="label" :class="labelClasses">{{ label }}</label>
|
11
|
+
<div :class="bem('content')"><slot></slot>
|
12
|
+
<p v-if="errorMessage">{{ errorMessage }}</p>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
</template>
|
16
|
+
<script setup>
|
17
|
+
import { computed } from 'vue';
|
18
|
+
import { createNamespace } from '../../../utils/create.js'
|
19
|
+
// 定义名称
|
20
|
+
defineOptions({
|
21
|
+
name: 'NbFormItem'
|
22
|
+
})
|
23
|
+
|
24
|
+
// 定义props
|
25
|
+
const props = defineProps({
|
26
|
+
// 定义Props
|
27
|
+
// 提示语
|
28
|
+
label: {
|
29
|
+
type: String,
|
30
|
+
default: ''
|
31
|
+
},
|
32
|
+
// 字段
|
33
|
+
prop: {
|
34
|
+
type: String,
|
35
|
+
default: ''
|
36
|
+
},
|
37
|
+
// body的内容是表单
|
38
|
+
rules: {
|
39
|
+
type: Array,
|
40
|
+
default: []
|
41
|
+
}
|
42
|
+
})
|
43
|
+
|
44
|
+
const [name, bem] = createNamespace('form-item')
|
45
|
+
const labelClasses = bem('label',{
|
46
|
+
required: props.rules.find(x => x.required === true)
|
47
|
+
})
|
48
|
+
defineExpose({
|
49
|
+
error: () => {
|
50
|
+
console.error('error')
|
51
|
+
}
|
52
|
+
})
|
53
|
+
</script>
|
54
|
+
|
55
|
+
<style lang="scss">
|
56
|
+
.nb-form-item {
|
57
|
+
display: flex;
|
58
|
+
align-items: center;
|
59
|
+
margin-bottom: 40px;
|
60
|
+
&__label {
|
61
|
+
color: var(--nb-font-color-7);
|
62
|
+
font-size: 28px;
|
63
|
+
line-height: 42px;
|
64
|
+
margin-right: 20px;
|
65
|
+
text-align: right;
|
66
|
+
&--required::before{
|
67
|
+
content: '*';
|
68
|
+
color: var(--nb-abnormal-color);
|
69
|
+
margin-right: 4px;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
</style>
|
@@ -0,0 +1,76 @@
|
|
1
|
+
<!--
|
2
|
+
* @Author: chenghuan.dong
|
3
|
+
* @Date: 2022-12-24 19:25:39
|
4
|
+
* @LastEditors: chenghuan.dong
|
5
|
+
* @LastEditTime: 2023-07-04 20:13:38
|
6
|
+
* @Description: 空页面
|
7
|
+
-->
|
8
|
+
<template>
|
9
|
+
<form :class="classes" ref="form">
|
10
|
+
<slot />
|
11
|
+
</form>
|
12
|
+
</template>
|
13
|
+
<script setup>
|
14
|
+
import { ref } from 'vue'
|
15
|
+
import { createNamespace } from '../../../utils/create.js'
|
16
|
+
// 定义名称
|
17
|
+
defineOptions({
|
18
|
+
name: 'NbForm'
|
19
|
+
})
|
20
|
+
|
21
|
+
// 定义props
|
22
|
+
const props = defineProps({
|
23
|
+
// 定义Props
|
24
|
+
// 提示语
|
25
|
+
label: {
|
26
|
+
type: String,
|
27
|
+
default: ''
|
28
|
+
},
|
29
|
+
model: {
|
30
|
+
type: Object,
|
31
|
+
default: () => {
|
32
|
+
return {}
|
33
|
+
}
|
34
|
+
},
|
35
|
+
// body的内容是表单
|
36
|
+
rules: {
|
37
|
+
type: Object,
|
38
|
+
default: () => {
|
39
|
+
return {}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
})
|
43
|
+
|
44
|
+
const [name, bem] = createNamespace('form')
|
45
|
+
const classes = bem('')
|
46
|
+
const form = ref()
|
47
|
+
|
48
|
+
function validate(cb) {
|
49
|
+
console.log('校验表单')
|
50
|
+
cb && cb()
|
51
|
+
}
|
52
|
+
|
53
|
+
defineExpose({
|
54
|
+
validate
|
55
|
+
})
|
56
|
+
</script>
|
57
|
+
|
58
|
+
<style lang="scss">
|
59
|
+
.nb-form-item {
|
60
|
+
display: flex;
|
61
|
+
align-items: center;
|
62
|
+
margin-bottom: 40px;
|
63
|
+
&__label {
|
64
|
+
color: var(--nb-font-color-7);
|
65
|
+
font-size: 28px;
|
66
|
+
line-height: 42px;
|
67
|
+
margin-right: 20px;
|
68
|
+
text-align: right;
|
69
|
+
&--required::before {
|
70
|
+
content: '*';
|
71
|
+
color: var(--nb-abnormal-color);
|
72
|
+
margin-right: 4px;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
</style>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<!--
|
2
|
+
* @Author: chenghuan.dong
|
3
|
+
* @Date: 2023-06-27 16:57:58
|
4
|
+
* @LastEditors: chenghuan.dong
|
5
|
+
* @LastEditTime: 2023-06-27 20:25:45
|
6
|
+
* @Description:
|
7
|
+
-->
|
8
|
+
<template>
|
9
|
+
<svg-icon :icon="icon" class="nb-icon" />
|
10
|
+
</template>
|
11
|
+
<script setup>
|
12
|
+
// 定义名称
|
13
|
+
defineOptions({
|
14
|
+
name: 'NbIcon'
|
15
|
+
})
|
16
|
+
|
17
|
+
// 定义props
|
18
|
+
const props = defineProps({
|
19
|
+
// 定义Props
|
20
|
+
// 类型,可选值为 primary warning default info
|
21
|
+
icon: {
|
22
|
+
type: String,
|
23
|
+
required: true,
|
24
|
+
default: ''
|
25
|
+
}
|
26
|
+
})
|
27
|
+
</script>
|
28
|
+
|
29
|
+
<style lang="scss">
|
30
|
+
</style>
|
@@ -0,0 +1,184 @@
|
|
1
|
+
:root {
|
2
|
+
// 按size
|
3
|
+
// size=large
|
4
|
+
--nb-input-large-width: 480px;
|
5
|
+
--nb-input-large-height: 80px;
|
6
|
+
--nb-input-large-font-size: 28px;
|
7
|
+
--nb-input-large-icon-size: 40px;
|
8
|
+
// size=medium
|
9
|
+
--nb-input-medium-width: 400px;
|
10
|
+
--nb-input-medium-height: 64px;
|
11
|
+
--nb-input-medium-font-size: 24px;
|
12
|
+
--nb-input-medium-icon-size: 40px;
|
13
|
+
// size=small
|
14
|
+
--nb-input-small-width: 240px;
|
15
|
+
--nb-input-small-height: 64px;
|
16
|
+
--nb-input-small-font-size: 24px;
|
17
|
+
--nb-input-small-icon-size: 32px;
|
18
|
+
}
|
19
|
+
|
20
|
+
.nb-input {
|
21
|
+
display: inline-flex;
|
22
|
+
align-items: center;
|
23
|
+
line-height: 1;
|
24
|
+
box-sizing: border-box;
|
25
|
+
outline: none;
|
26
|
+
transition: 0.1s;
|
27
|
+
border-radius: var(--nb-input-border-radius);
|
28
|
+
border: 1px solid var(--nb-input-border-color);
|
29
|
+
font-family: inherit;
|
30
|
+
font-weight: normal;
|
31
|
+
vertical-align: middle;
|
32
|
+
caret-color: var(--nb-theme-color);
|
33
|
+
&:focus {
|
34
|
+
outline: none;
|
35
|
+
}
|
36
|
+
.nb-input__inner {
|
37
|
+
width: 100%;
|
38
|
+
flex-grow: 1;
|
39
|
+
-webkit-appearance: none;
|
40
|
+
color: var(--nb-input-color);
|
41
|
+
font-size: inherit;
|
42
|
+
padding: 0;
|
43
|
+
outline: none;
|
44
|
+
border: none;
|
45
|
+
background: none;
|
46
|
+
box-sizing: border-box;
|
47
|
+
&::placeholder {
|
48
|
+
color: var(--nb-input-placeholder-text-color);
|
49
|
+
font-weight: 400;
|
50
|
+
font-family: inherit;
|
51
|
+
font-size: inherit;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
.nb-input__prefix {
|
55
|
+
height: 100%;
|
56
|
+
.svg-icon {
|
57
|
+
color: #cad0e0;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
.nb-input__clear,
|
61
|
+
.nb-input__password {
|
62
|
+
display: flex;
|
63
|
+
align-items: center;
|
64
|
+
height: 100%;
|
65
|
+
cursor: pointer;
|
66
|
+
.svg-icon {
|
67
|
+
color: #8b8ea0;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
&--focus {
|
72
|
+
border: 2px solid var(--nb-theme-color);
|
73
|
+
}
|
74
|
+
|
75
|
+
&--dark {
|
76
|
+
border: 1px solid #fff;
|
77
|
+
background-color: transparent;
|
78
|
+
color: #ffffff;
|
79
|
+
.nb-input__inner {
|
80
|
+
background-color: transparent;
|
81
|
+
color: #ffffff;
|
82
|
+
&::placeholder {
|
83
|
+
color: rgba(#ffffff, 0.5);
|
84
|
+
}
|
85
|
+
}
|
86
|
+
.nb-input__prefix .svg-icon,
|
87
|
+
.nb-input__clear .svg-icon,
|
88
|
+
.nb-input__password .svg-icon {
|
89
|
+
color: #cad0e0;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
&--large {
|
93
|
+
width: var(--nb-input-large-width);
|
94
|
+
height: var(--nb-input-large-height);
|
95
|
+
line-height: var(--nb-input-large-height);
|
96
|
+
padding: 0 16px 0 11px;
|
97
|
+
.nb-input__inner {
|
98
|
+
height: var(--nb-input-large-height);
|
99
|
+
line-height: var(--nb-input-large-height);
|
100
|
+
font-size: var(--nb-input-large-font-size);
|
101
|
+
}
|
102
|
+
.nb-input__prefix {
|
103
|
+
margin-right: 16px;
|
104
|
+
.svg-icon {
|
105
|
+
width: var(--nb-input-large-icon-size);
|
106
|
+
height: var(--nb-input-large-icon-size);
|
107
|
+
}
|
108
|
+
}
|
109
|
+
.nb-input__clear,
|
110
|
+
.nb-input__password {
|
111
|
+
width: 48px;
|
112
|
+
margin-left: 9px;
|
113
|
+
.svg-icon {
|
114
|
+
width: var(--nb-input-large-icon-size);
|
115
|
+
height: var(--nb-input-large-icon-size);
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
|
120
|
+
&--medium {
|
121
|
+
width: var(--nb-input-medium-width);
|
122
|
+
height: var(--nb-input-medium-height);
|
123
|
+
line-height: var(--nb-input-medium-height);
|
124
|
+
padding: 0 16px 0 11px;
|
125
|
+
.nb-input__inner {
|
126
|
+
height: var(--nb-input-medium-height);
|
127
|
+
line-height: var(--nb-input-medium-height);
|
128
|
+
font-size: var(--nb-input-medium-font-size);
|
129
|
+
}
|
130
|
+
.nb-input__prefix {
|
131
|
+
margin-right: 16px;
|
132
|
+
.svg-icon {
|
133
|
+
width: var(--nb-input-medium-icon-size);
|
134
|
+
height: var(--nb-input-medium-icon-size);
|
135
|
+
}
|
136
|
+
}
|
137
|
+
.nb-input__clear,
|
138
|
+
.nb-input__password {
|
139
|
+
width: 48px;
|
140
|
+
margin-left: 9px;
|
141
|
+
.svg-icon {
|
142
|
+
width: var(--nb-input-medium-icon-size);
|
143
|
+
height: var(--nb-input-medium-icon-size);
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
&--small {
|
149
|
+
width: var(--nb-input-small-width);
|
150
|
+
height: var(--nb-input-small-height);
|
151
|
+
line-height: var(--nb-input-small-height);
|
152
|
+
padding: 0 16px 0 11px;
|
153
|
+
.nb-input__inner {
|
154
|
+
height: var(--nb-input-small-height);
|
155
|
+
line-height: var(--nb-input-small-height);
|
156
|
+
font-size: var(--nb-input-small-font-size);
|
157
|
+
}
|
158
|
+
.nb-input__prefix {
|
159
|
+
margin-right: 16px;
|
160
|
+
.svg-icon {
|
161
|
+
width: var(--nb-input-small-icon-size);
|
162
|
+
height: var(--nb-input-small-icon-size);
|
163
|
+
}
|
164
|
+
}
|
165
|
+
.nb-input__clear,
|
166
|
+
.nb-input__password {
|
167
|
+
width: 48px;
|
168
|
+
margin-left: 9px;
|
169
|
+
.svg-icon {
|
170
|
+
width: var(--nb-input-small-icon-size);
|
171
|
+
height: var(--nb-input-small-icon-size);
|
172
|
+
}
|
173
|
+
}
|
174
|
+
}
|
175
|
+
&--disabled {
|
176
|
+
cursor: not-allowed;
|
177
|
+
background: var(--nb-input-disabled-background);
|
178
|
+
box-shadow: var(--nb-input-disabled-box-shadow);
|
179
|
+
border: 1px solid var(--nb-input-disabled-border-color);
|
180
|
+
&.nb-input.nb-input--disabled {
|
181
|
+
color: var(--nb-input-disabled-color);
|
182
|
+
}
|
183
|
+
}
|
184
|
+
}
|
@@ -0,0 +1,189 @@
|
|
1
|
+
<!--
|
2
|
+
* @Author: chenghuan.dong
|
3
|
+
* @Date: 2023-06-27 16:57:58
|
4
|
+
* @LastEditors: chenghuan.dong
|
5
|
+
* @LastEditTime: 2023-06-29 19:18:26
|
6
|
+
* @Description: 文本输入框
|
7
|
+
-->
|
8
|
+
<template>
|
9
|
+
<div :class="wrapClass" @mouseenter="handleMouseEnter" @mouseleave="handleMouseLeave">
|
10
|
+
<div v-if="props.prefixIcon || $slots.prefix" class="nb-input__prefix">
|
11
|
+
<slot name="prefix" />
|
12
|
+
<svg-icon v-if="props.prefixIcon" :icon="props.prefixIcon" />
|
13
|
+
</div>
|
14
|
+
<input
|
15
|
+
v-model="inputValue"
|
16
|
+
:type="showPassword ? (hidePassword ? 'text' : 'password') : type"
|
17
|
+
:placeholder="placeholder"
|
18
|
+
:readonly="readonly"
|
19
|
+
:disabled="disabled"
|
20
|
+
class="nb-input__inner"
|
21
|
+
@focus="handleFocus"
|
22
|
+
@blur="handleBlur"
|
23
|
+
/>
|
24
|
+
<!-- 清除 -->
|
25
|
+
<div v-if="showClear" class="nb-input__clear" @click.stop="handleClear">
|
26
|
+
<svg-icon icon="circle-close-filled" />
|
27
|
+
</div>
|
28
|
+
<!-- 密码框显示小眼睛 -->
|
29
|
+
<div v-if="showPwdVisible" class="nb-input__password" @click.stop="handleShowPassword">
|
30
|
+
<svg-icon :icon="hidePassword ? 'eye-open' : 'eye-close'" />
|
31
|
+
</div>
|
32
|
+
<div v-if="props.suffixIcon || $slots.suffix" class="nb-input__suffix">
|
33
|
+
<slot name="suffix" />
|
34
|
+
<svg-icon v-if="props.suffixIcon" :icon="props.suffixIcon" />
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
</template>
|
38
|
+
<script setup>
|
39
|
+
import { ref, computed } from 'vue'
|
40
|
+
import { createNamespace } from '../../../utils/create.js'
|
41
|
+
|
42
|
+
const [name, bem] = createNamespace('input')
|
43
|
+
|
44
|
+
// 定义名称
|
45
|
+
defineOptions({
|
46
|
+
name: 'NbInput'
|
47
|
+
})
|
48
|
+
|
49
|
+
// 定义props
|
50
|
+
const props = defineProps({
|
51
|
+
// 值
|
52
|
+
modelValue: {
|
53
|
+
type: [String, Number, Object],
|
54
|
+
default: ''
|
55
|
+
},
|
56
|
+
// 尺寸,可选值为 large medium small
|
57
|
+
size: {
|
58
|
+
type: String,
|
59
|
+
default: 'medium',
|
60
|
+
validator(value) {
|
61
|
+
return ['large', 'medium', 'small'].includes(value)
|
62
|
+
}
|
63
|
+
},
|
64
|
+
// 类型,可选值为 text
|
65
|
+
type: {
|
66
|
+
type: String,
|
67
|
+
default: 'text'
|
68
|
+
},
|
69
|
+
// 输入框占位文本
|
70
|
+
placeholder: {
|
71
|
+
type: String
|
72
|
+
},
|
73
|
+
// 原生 readonly 属性,是否只读
|
74
|
+
readonly: {
|
75
|
+
type: Boolean,
|
76
|
+
default: false
|
77
|
+
},
|
78
|
+
// 是否显示清除按钮,只有当 type 不是 textarea时生效
|
79
|
+
clearable: {
|
80
|
+
type: Boolean,
|
81
|
+
default: true
|
82
|
+
},
|
83
|
+
// 是否显示切换密码图标
|
84
|
+
showPassword: {
|
85
|
+
type: Boolean,
|
86
|
+
default: false
|
87
|
+
},
|
88
|
+
// 是否为禁用状态
|
89
|
+
disabled: {
|
90
|
+
type: Boolean,
|
91
|
+
default: false
|
92
|
+
},
|
93
|
+
// 自定义后缀图标
|
94
|
+
suffixIcon: {
|
95
|
+
type: String
|
96
|
+
},
|
97
|
+
// 自定义前缀图标
|
98
|
+
prefixIcon: {
|
99
|
+
type: String
|
100
|
+
},
|
101
|
+
// 主题( 内置了 dark / light 两种主题)
|
102
|
+
effect: {
|
103
|
+
type: String,
|
104
|
+
default: 'light',
|
105
|
+
validator(value) {
|
106
|
+
return ['dark', 'light'].includes(value)
|
107
|
+
}
|
108
|
+
}
|
109
|
+
})
|
110
|
+
|
111
|
+
// 定义emits
|
112
|
+
const emits = defineEmits(['input', 'change', 'focus', 'blur', 'clear'])
|
113
|
+
|
114
|
+
const hovering = ref(false)
|
115
|
+
const focused = ref(false)
|
116
|
+
const hidePassword = ref(false)
|
117
|
+
|
118
|
+
// 输入框值
|
119
|
+
const inputValue = computed({
|
120
|
+
get: () => props.modelValue,
|
121
|
+
set: (value) => {
|
122
|
+
emits('update:modelValue', value)
|
123
|
+
}
|
124
|
+
})
|
125
|
+
|
126
|
+
const showClear = computed(
|
127
|
+
() => props.clearable && !props.disabled && !props.readonly && !!inputValue.value && (focused.value || hovering.value)
|
128
|
+
)
|
129
|
+
|
130
|
+
const showPwdVisible = computed(
|
131
|
+
() =>
|
132
|
+
props.showPassword &&
|
133
|
+
!props.disabled &&
|
134
|
+
!props.readonly &&
|
135
|
+
!!inputValue.value &&
|
136
|
+
(!!inputValue.value || focused.value)
|
137
|
+
)
|
138
|
+
|
139
|
+
// 样式
|
140
|
+
const wrapClass = computed(() => {
|
141
|
+
return bem([
|
142
|
+
props.size,
|
143
|
+
props.type,
|
144
|
+
props.effect,
|
145
|
+
{
|
146
|
+
disabled: props.disabled,
|
147
|
+
prefix: props.prefixIcon ? true : false,
|
148
|
+
focus: focused.value
|
149
|
+
}
|
150
|
+
])
|
151
|
+
})
|
152
|
+
const prefixClasses = bem(['prefix'])
|
153
|
+
|
154
|
+
const handleMouseEnter = (evt) => {
|
155
|
+
hovering.value = true
|
156
|
+
emits('mouseenter', evt)
|
157
|
+
}
|
158
|
+
|
159
|
+
const handleMouseLeave = (evt) => {
|
160
|
+
hovering.value = false
|
161
|
+
emits('mouseleave', evt)
|
162
|
+
}
|
163
|
+
|
164
|
+
const handleClear = () => {
|
165
|
+
emits('update:modelValue', '')
|
166
|
+
emits('clear')
|
167
|
+
}
|
168
|
+
|
169
|
+
const handleShowPassword = () => {
|
170
|
+
hidePassword.value = !hidePassword.value
|
171
|
+
if (hidePassword.value) {
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
175
|
+
const handleFocus = () => {
|
176
|
+
focused.value = true
|
177
|
+
emits('focus')
|
178
|
+
}
|
179
|
+
|
180
|
+
const handleBlur = () => {
|
181
|
+
focused.value = false
|
182
|
+
emits('blur')
|
183
|
+
}
|
184
|
+
|
185
|
+
</script>
|
186
|
+
|
187
|
+
<style lang="scss">
|
188
|
+
@import './index.scss';
|
189
|
+
</style>
|
@@ -0,0 +1,63 @@
|
|
1
|
+
.nb-input-keyboard {
|
2
|
+
display: inline-block;
|
3
|
+
width: 310px;
|
4
|
+
overflow-x: hidden;
|
5
|
+
padding: 30px 15px;
|
6
|
+
box-sizing: border-box;
|
7
|
+
&__input {
|
8
|
+
width: 100%;
|
9
|
+
display: flex;
|
10
|
+
align-items: center;
|
11
|
+
justify-content: space-between;
|
12
|
+
.nb-input {
|
13
|
+
width: 200px;
|
14
|
+
height: 50px;
|
15
|
+
margin-right: 6px;
|
16
|
+
}
|
17
|
+
.nb-button {
|
18
|
+
min-width: 74px;
|
19
|
+
width: 74px;
|
20
|
+
height: 50px;
|
21
|
+
font-size: 18px;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
&__keyboard {
|
25
|
+
width: 280px;
|
26
|
+
height: 353px;
|
27
|
+
margin-top: 30.5px;
|
28
|
+
background: #ffffff;
|
29
|
+
border-radius: 4px;
|
30
|
+
border: 1px solid #cad0e0;
|
31
|
+
box-sizing: border-box;
|
32
|
+
padding: 5px 0 0 5px;
|
33
|
+
display: flex;
|
34
|
+
flex-direction: column;
|
35
|
+
div {
|
36
|
+
flex: 1;
|
37
|
+
display: flex;
|
38
|
+
align-items: center;
|
39
|
+
justify-content: space-between;
|
40
|
+
margin-bottom: 5px;
|
41
|
+
span {
|
42
|
+
flex: 1;
|
43
|
+
height: 100%;
|
44
|
+
background: #f4f6f9;
|
45
|
+
border-radius: 3px;
|
46
|
+
border: 1px solid #cad0e0;
|
47
|
+
font-size: 25px;
|
48
|
+
font-family: var(--nb-font-bold-family);
|
49
|
+
line-height: 38px;
|
50
|
+
display: flex;
|
51
|
+
align-items: center;
|
52
|
+
justify-content: center;
|
53
|
+
box-sizing: border-box;
|
54
|
+
margin-right: 5px;
|
55
|
+
cursor: pointer;
|
56
|
+
&:active {
|
57
|
+
background-color: var(--nb-theme-color);
|
58
|
+
color: #ffffff;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|