@community-release/nx-ui 0.0.4 → 0.0.7
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/dist/module.d.mts +7 -0
- package/dist/module.d.ts +7 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +230 -9
- package/dist/runtime/components/accordion.vue +221 -0
- package/dist/runtime/components/animated-number/animateValue.d.ts +13 -0
- package/dist/runtime/components/animated-number/animateValue.mjs +56 -0
- package/dist/runtime/components/animated-number/index.vue +43 -0
- package/dist/runtime/components/button/index.vue +360 -0
- package/dist/runtime/components/button/index.vue.d.ts +81 -0
- package/dist/runtime/components/button/props.json +6 -0
- package/dist/runtime/components/card.vue +138 -0
- package/dist/runtime/components/checkbox.vue +227 -0
- package/dist/runtime/components/countdown/index.vue +64 -0
- package/dist/runtime/components/countdown/props.json +6 -0
- package/dist/runtime/components/filter/index.vue +140 -0
- package/dist/runtime/components/filter/props.json +4 -0
- package/dist/runtime/components/grid.vue +169 -0
- package/dist/runtime/components/grid.vue.d.ts +56 -0
- package/dist/runtime/components/helpers/Countdown.d.ts +0 -0
- package/dist/runtime/components/helpers/Countdown.mjs +143 -0
- package/dist/runtime/components/helpers/getEventCoord.d.ts +7 -0
- package/dist/runtime/components/helpers/getEventCoord.mjs +16 -0
- package/dist/runtime/components/helpers/isImageExist.d.ts +6 -0
- package/dist/runtime/components/helpers/isImageExist.mjs +20 -0
- package/dist/runtime/components/helpers/isMobileDevice.d.ts +5 -0
- package/dist/runtime/components/helpers/isMobileDevice.mjs +12 -0
- package/dist/runtime/components/helpers/isWebKit.d.ts +5 -0
- package/dist/runtime/components/helpers/isWebKit.mjs +12 -0
- package/dist/runtime/components/helpers/uniq.d.ts +2 -0
- package/dist/runtime/components/helpers/uniq.mjs +1 -0
- package/dist/runtime/components/icons/check.svg +1 -0
- package/dist/runtime/components/icons/check.white.svg +1 -0
- package/dist/runtime/components/impulse-indicator.vue +139 -0
- package/dist/runtime/components/impulse-indicator.vue.d.ts +21 -0
- package/dist/runtime/components/input/index.vue +241 -0
- package/dist/runtime/components/input/props.json +5 -0
- package/dist/runtime/components/label.vue +33 -0
- package/dist/runtime/components/loading.vue +91 -0
- package/dist/runtime/components/map/device-zoom-switch.vue +160 -0
- package/dist/runtime/components/map/index.vue +135 -0
- package/dist/runtime/components/map/location/index.vue +109 -0
- package/dist/runtime/components/map/location/list.vue +54 -0
- package/dist/runtime/components/map/location/nearest.vue +88 -0
- package/dist/runtime/components/map/openlayers/index.vue +355 -0
- package/dist/runtime/components/map/props.json +5 -0
- package/dist/runtime/components/map/store.d.ts +114 -0
- package/dist/runtime/components/map/store.mjs +166 -0
- package/dist/runtime/components/map/zoom.vue +61 -0
- package/dist/runtime/components/notice/index.vue +63 -0
- package/dist/runtime/components/notice/item.vue +118 -0
- package/dist/runtime/components/notice/store.d.ts +27 -0
- package/dist/runtime/components/notice/store.mjs +46 -0
- package/dist/runtime/components/radio.vue +215 -0
- package/dist/runtime/components/select.vue +303 -0
- package/dist/runtime/components/static-map.vue +345 -0
- package/dist/runtime/components/styles/components.less +3 -0
- package/dist/runtime/components/styles/mixins.less +6 -0
- package/dist/runtime/components/textarea/index.vue +166 -0
- package/dist/runtime/components/textarea/props.json +4 -0
- package/dist/runtime/components/tooltip.vue +137 -0
- package/dist/runtime/plugins/methods.d.ts +2 -0
- package/dist/runtime/plugins/methods.mjs +20 -0
- package/dist/runtime/plugins/variables.d.ts +2 -0
- package/dist/runtime/plugins/variables.mjs +17 -0
- package/dist/types.d.mts +2 -11
- package/dist/types.d.ts +2 -11
- package/package.json +2 -2
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/*
|
|
2
|
+
var c = new Countdown( secondsLeft );
|
|
3
|
+
|
|
4
|
+
c.onTick = function( time ) {
|
|
5
|
+
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
c.onFinish = function() {
|
|
9
|
+
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
c.start();
|
|
13
|
+
*/
|
|
14
|
+
var Countdown = function( secondsLeft, totalSeconds ){
|
|
15
|
+
|
|
16
|
+
this.timer = null;
|
|
17
|
+
this.time = null;
|
|
18
|
+
this.progress = 100;
|
|
19
|
+
this.secondsLeft = secondsLeft;
|
|
20
|
+
|
|
21
|
+
this.secToTime = function( sec ){
|
|
22
|
+
var secondsInAMinute = 60;
|
|
23
|
+
var secondsInAnHour = 60 * secondsInAMinute;
|
|
24
|
+
var secondsInADay = 24 * secondsInAnHour;
|
|
25
|
+
|
|
26
|
+
// get days
|
|
27
|
+
var days = Math.floor(sec / secondsInADay);
|
|
28
|
+
|
|
29
|
+
// get hours
|
|
30
|
+
var hourSeconds = sec % secondsInADay;
|
|
31
|
+
var hours = Math.floor(hourSeconds / secondsInAnHour);
|
|
32
|
+
|
|
33
|
+
// get minutes
|
|
34
|
+
var minuteSeconds = hourSeconds % secondsInAnHour;
|
|
35
|
+
var minutes = Math.floor(minuteSeconds / secondsInAMinute);
|
|
36
|
+
|
|
37
|
+
// get remaining seconds
|
|
38
|
+
var remainingSeconds = minuteSeconds % secondsInAMinute;
|
|
39
|
+
var seconds = Math.floor(remainingSeconds);
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
if (hours < 10) hours = '0' + hours;
|
|
43
|
+
if (minutes < 10) minutes = '0' + minutes;
|
|
44
|
+
if (seconds < 10) seconds = '0' + seconds;
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
d: days, h: hours, m: minutes, s: seconds,
|
|
48
|
+
full: days +' days, '+ hours +' hours, '+ minutes +' minutes, '+ seconds +' seconds.',
|
|
49
|
+
progress: this.progress
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
this.setTime = function( secondsLeft, totalSeconds ){
|
|
54
|
+
this.secondsLeft = secondsLeft;
|
|
55
|
+
|
|
56
|
+
if ((totalSeconds === undefined) || (totalSeconds === null)) {
|
|
57
|
+
this.totalSeconds = secondsLeft;
|
|
58
|
+
this.totalDays = 365;
|
|
59
|
+
this.totalHours = 24;
|
|
60
|
+
} else {
|
|
61
|
+
this.totalSeconds = totalSeconds;
|
|
62
|
+
this.totalDays = this.secToTime( this.totalSeconds ).d;
|
|
63
|
+
this.totalHours = this.secToTime( this.totalSeconds ).h;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
this.setTime( secondsLeft, totalSeconds );
|
|
67
|
+
|
|
68
|
+
this._update = function(){
|
|
69
|
+
if ((this.secondsLeft-1) >= 0) {
|
|
70
|
+
this.secondsLeft--;
|
|
71
|
+
|
|
72
|
+
this.time = this.secToTime( this.secondsLeft );
|
|
73
|
+
this.progress = 100 - (this.secondsLeft * 100 / this.totalSeconds);
|
|
74
|
+
|
|
75
|
+
if (this.hasOwnProperty( 'onTick' )) {
|
|
76
|
+
this.onTick( this.time );
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
} else {
|
|
80
|
+
this.stop();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
this.start = function(){
|
|
85
|
+
if (this.timer == null) {
|
|
86
|
+
this.timer = setInterval(this._update.bind(this), 1000);
|
|
87
|
+
this._update();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
this.pause = function(){
|
|
92
|
+
clearInterval( this.timer );
|
|
93
|
+
this.timer = null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this.stop = function(){
|
|
97
|
+
clearInterval( this.timer );
|
|
98
|
+
this.timer = null;
|
|
99
|
+
this.secondsLeft = 0;
|
|
100
|
+
this.time = this.secToTime( this.secondsLeft );
|
|
101
|
+
if (this.hasOwnProperty( 'onTick' )) {
|
|
102
|
+
this.onTick( this.time );
|
|
103
|
+
}
|
|
104
|
+
if (this.hasOwnProperty( 'onFinish' )) {
|
|
105
|
+
this.onFinish();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
this.getSeconds = function(){
|
|
110
|
+
return this.secondsLeft;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
this.destroy = function() {
|
|
114
|
+
this.stop();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
function calcSecondsLeft( date ) {
|
|
119
|
+
var left = 0, total = 0;
|
|
120
|
+
|
|
121
|
+
// Seconds left
|
|
122
|
+
var endDate = new Date(Date.UTC(
|
|
123
|
+
date.end.year, date.end.month-1, date.end.day, date.end.hour, date.end.minute, date.end.second
|
|
124
|
+
)),
|
|
125
|
+
now = new Date(),
|
|
126
|
+
offset = date.timezone * 60 * 60;
|
|
127
|
+
|
|
128
|
+
left = (endDate.getTime()/1000 - now.getTime()/1000) - offset;
|
|
129
|
+
|
|
130
|
+
// Total seconds
|
|
131
|
+
if (date.start != null) {
|
|
132
|
+
var startDate = new Date(Date.UTC(
|
|
133
|
+
date.start.year, date.start.month-1, date.start.day, date.start.hour, date.start.minute, date.start.second
|
|
134
|
+
));
|
|
135
|
+
total = endDate.getTime()/1000 - startDate.getTime()/1000;
|
|
136
|
+
} else {
|
|
137
|
+
total = null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return { total: total, left: left };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export default Countdown;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return event coordinates relative to element
|
|
3
|
+
* @param {Event} e - event
|
|
4
|
+
* @param {null|HTMLElement} target - you can use specific target element instead of e.target
|
|
5
|
+
* @returns {boolean}
|
|
6
|
+
*/
|
|
7
|
+
export default function _default(e: Event, target?: null | HTMLElement): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return event coordinates relative to element
|
|
3
|
+
* @param {Event} e - event
|
|
4
|
+
* @param {null|HTMLElement} target - you can use specific target element instead of e.target
|
|
5
|
+
* @returns {boolean}
|
|
6
|
+
*/
|
|
7
|
+
export default function(e, target = null) {
|
|
8
|
+
if (target === null) target = e.target;
|
|
9
|
+
|
|
10
|
+
const box = target.getBoundingClientRect();
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
x: e.clientX - box.left,
|
|
14
|
+
y: e.clientY - box.top
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if image exist
|
|
3
|
+
* @param {string} url - image url (local or remote)
|
|
4
|
+
* @returns {boolean}
|
|
5
|
+
*/
|
|
6
|
+
export default function(url) {
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
const image = new Image;
|
|
9
|
+
|
|
10
|
+
image.onload = function() {
|
|
11
|
+
resolve(this.width > 1 && this.height > 1);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
image.onerror = () => {
|
|
15
|
+
resolve(false);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
image.src = url;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default () => 'i' + Math.random().toString(36).slice(2, 9);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024"><path d="M1002.57 167.77c28.573 28.572 28.573 74.746 0 103.32L417.395 856.264c-28.573 28.573-74.747 28.573-103.32 0L21.423 563.677c-28.564-28.573-28.564-74.747 0-103.32 28.568-28.573 74.88-28.573 103.453 0l238.801 240.7L899.25 167.768c28.573-28.618 74.747-28.618 103.32 0z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024"><path fill="#fff" d="M1002.57 167.77c28.573 28.572 28.573 74.746 0 103.32L417.395 856.264c-28.573 28.573-74.747 28.573-103.32 0L21.423 563.677c-28.564-28.573-28.564-74.747 0-103.32 28.568-28.573 74.88-28.573 103.453 0l238.801 240.7L899.25 167.768c28.573-28.618 74.747-28.618 103.32 0z"/></svg>
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="component-ui component-ui-impulse-indicator">
|
|
3
|
+
<transition-group name="impulse" tag="span">
|
|
4
|
+
<span
|
|
5
|
+
v-for="item in impulseArray"
|
|
6
|
+
:key="item.id"
|
|
7
|
+
class="impulse"
|
|
8
|
+
:style="{top: item.top, left: item.left, background: item.background}"
|
|
9
|
+
></span>
|
|
10
|
+
</transition-group>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
export default {
|
|
16
|
+
name: 'impulse-indicator',
|
|
17
|
+
|
|
18
|
+
// Data
|
|
19
|
+
props: {
|
|
20
|
+
impulse: {
|
|
21
|
+
type: [Object, Boolean],
|
|
22
|
+
default: false
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
data() {
|
|
26
|
+
return {
|
|
27
|
+
impulseArray: []
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
watch: {
|
|
31
|
+
impulse(options) {
|
|
32
|
+
if (options) {
|
|
33
|
+
this.$emit('update:impulse', false);
|
|
34
|
+
this.addImpulse(options);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
// Methods
|
|
40
|
+
methods: {
|
|
41
|
+
addImpulse(options) {
|
|
42
|
+
let id = Math.random().toString(36).substr(2, 9);
|
|
43
|
+
|
|
44
|
+
options = Object.assign({
|
|
45
|
+
background: '#000'
|
|
46
|
+
}, options);
|
|
47
|
+
|
|
48
|
+
options.id = id;
|
|
49
|
+
|
|
50
|
+
if ('event' in options) {
|
|
51
|
+
let target = ('target' in options) ? options.target : event.target;
|
|
52
|
+
|
|
53
|
+
let rect = target.getBoundingClientRect();
|
|
54
|
+
|
|
55
|
+
options.left = options.event.clientX - rect.left;
|
|
56
|
+
options.top = options.event.clientY - rect.top;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const sLeft = options.left.toString();
|
|
60
|
+
const sTop = options.top.toString();
|
|
61
|
+
|
|
62
|
+
if (sLeft.indexOf('px') == -1 && sLeft.indexOf('%') == -1) {
|
|
63
|
+
options.left = options.left + 'px';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (sTop.indexOf('px') == -1 && sTop.indexOf('%') == -1) {
|
|
67
|
+
options.top = options.top + 'px';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this.impulseArray.push(options);
|
|
71
|
+
|
|
72
|
+
setTimeout(() => {
|
|
73
|
+
for (let i=0, item; i < this.impulseArray.length; i++) {
|
|
74
|
+
item = this.impulseArray[i];
|
|
75
|
+
|
|
76
|
+
if (item.id === id) this.impulseArray.splice(i--, 1);
|
|
77
|
+
}
|
|
78
|
+
}, 2000);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
// Hooks
|
|
83
|
+
mounted() {
|
|
84
|
+
|
|
85
|
+
},
|
|
86
|
+
}
|
|
87
|
+
</script>
|
|
88
|
+
|
|
89
|
+
<style lang="less">
|
|
90
|
+
.component-ui-impulse-indicator {
|
|
91
|
+
@keyframes impulse {
|
|
92
|
+
0% {
|
|
93
|
+
opacity: 0;
|
|
94
|
+
transform: translate3d(-50%, -50%, 0) scale(0.01);
|
|
95
|
+
}
|
|
96
|
+
10% {
|
|
97
|
+
opacity: 0.06;
|
|
98
|
+
}
|
|
99
|
+
30% {
|
|
100
|
+
opacity: 0.12;
|
|
101
|
+
}
|
|
102
|
+
90% {
|
|
103
|
+
opacity: 0.05;
|
|
104
|
+
transform: translate3d(-50%, -50%, 0) scale(1);
|
|
105
|
+
}
|
|
106
|
+
100% {
|
|
107
|
+
opacity: 0;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
overflow: hidden;
|
|
112
|
+
position: absolute;
|
|
113
|
+
top: 0;
|
|
114
|
+
bottom: 0;
|
|
115
|
+
left: 0;
|
|
116
|
+
right: 0;
|
|
117
|
+
pointer-events: none;
|
|
118
|
+
|
|
119
|
+
.impulse {
|
|
120
|
+
transform-origin: 50% 50%;
|
|
121
|
+
transform: translate3d(-50%, -50%, 0);
|
|
122
|
+
opacity: 1;
|
|
123
|
+
|
|
124
|
+
position: absolute;
|
|
125
|
+
top: 50%;
|
|
126
|
+
left: 50%;
|
|
127
|
+
|
|
128
|
+
padding-bottom: 200%;
|
|
129
|
+
width: 200%;
|
|
130
|
+
|
|
131
|
+
border-radius: 50%;
|
|
132
|
+
background: #000811;
|
|
133
|
+
|
|
134
|
+
pointer-events: none;
|
|
135
|
+
|
|
136
|
+
animation: 0.8s ease-in-out 1 both impulse;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
let name: string;
|
|
3
|
+
namespace props {
|
|
4
|
+
namespace impulse {
|
|
5
|
+
export let type: (ObjectConstructor | BooleanConstructor)[];
|
|
6
|
+
let _default: boolean;
|
|
7
|
+
export { _default as default };
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function data(): {
|
|
11
|
+
impulseArray: never[];
|
|
12
|
+
};
|
|
13
|
+
namespace watch {
|
|
14
|
+
function impulse(options: any): void;
|
|
15
|
+
}
|
|
16
|
+
namespace methods {
|
|
17
|
+
function addImpulse(options: any): void;
|
|
18
|
+
}
|
|
19
|
+
function mounted(): void;
|
|
20
|
+
}
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<section class="component-ui-input" :class="classes" @click="refInput.focus()">
|
|
3
|
+
<ui-impulse-indicator :impulse="impulse" @update:impulse="$emit('update:impulse', false)" />
|
|
4
|
+
|
|
5
|
+
<div class="com-content">
|
|
6
|
+
<div class="slot-prepend" v-if="hasSlot('prepend')"><slot name="prepend"></slot></div>
|
|
7
|
+
<div class="slot-default">
|
|
8
|
+
<input
|
|
9
|
+
ref="refInput"
|
|
10
|
+
:value="modelValue"
|
|
11
|
+
:type="type"
|
|
12
|
+
:placeholder="placeholder"
|
|
13
|
+
:disabled="disabled"
|
|
14
|
+
|
|
15
|
+
@change="updateValue($event.target.value)"
|
|
16
|
+
@input="updateValue($event.target.value)"
|
|
17
|
+
@blur="handleBlur($event.target.value)"
|
|
18
|
+
@keyup.enter="updateValue($event.target.value, true, true)"
|
|
19
|
+
|
|
20
|
+
@focus="haveFocus = true"
|
|
21
|
+
|
|
22
|
+
formnovalidate
|
|
23
|
+
spellcheck="false"
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="slot-append" v-if="hasSlot('append')"><slot name="append"></slot></div>
|
|
27
|
+
</div>
|
|
28
|
+
</section>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script setup>
|
|
32
|
+
// Import
|
|
33
|
+
import { ref, computed, useSlots } from 'vue';
|
|
34
|
+
import UiImpulseIndicator from '../impulse-indicator.vue';
|
|
35
|
+
import comProps from '#build/ui.input.mjs';
|
|
36
|
+
|
|
37
|
+
// Misc
|
|
38
|
+
const emit = defineEmits(['input', 'enter', 'blur', 'update:modelValue']);
|
|
39
|
+
const slots = useSlots();
|
|
40
|
+
|
|
41
|
+
// Data
|
|
42
|
+
const props = defineProps({
|
|
43
|
+
modelValue: {
|
|
44
|
+
required: true
|
|
45
|
+
},
|
|
46
|
+
placeholder: {
|
|
47
|
+
default: comProps.placeholder,
|
|
48
|
+
},
|
|
49
|
+
disabled: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false,
|
|
52
|
+
},
|
|
53
|
+
type: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: 'text'
|
|
56
|
+
},
|
|
57
|
+
impulse: {
|
|
58
|
+
default: false
|
|
59
|
+
},
|
|
60
|
+
shape: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: comProps.shape,
|
|
63
|
+
},
|
|
64
|
+
size: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: comProps.size,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const refInput = ref(null);
|
|
71
|
+
const haveFocus = ref(false);
|
|
72
|
+
|
|
73
|
+
const classes = computed(() => {
|
|
74
|
+
const ar = [];
|
|
75
|
+
|
|
76
|
+
if (props.modelValue !== '') ar.push('tag-not-empty');
|
|
77
|
+
if (haveFocus.value) ar.push('tag-focus');
|
|
78
|
+
if (props.disabled) ar.push('tag-disabled');
|
|
79
|
+
if (props.size) ar.push(`tag-size-${props.size}`);
|
|
80
|
+
if (props.shape) ar.push(`tag-shape-${props.shape}`);
|
|
81
|
+
|
|
82
|
+
return ar;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Methods
|
|
86
|
+
function updateValue(value, doTrim = false, submit = false) {
|
|
87
|
+
const validValue = doTrim ? value.trim() : value;
|
|
88
|
+
|
|
89
|
+
if (value !== validValue)
|
|
90
|
+
refInput.value.value = validValue;
|
|
91
|
+
|
|
92
|
+
emit('update:modelValue', validValue);
|
|
93
|
+
|
|
94
|
+
if (submit) emit('enter', validValue);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function handleBlur(v) {
|
|
98
|
+
haveFocus.value = false;
|
|
99
|
+
|
|
100
|
+
emit('blur', v);
|
|
101
|
+
updateValue(v);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const hasSlot = (name) => {
|
|
105
|
+
return !!slots[name];
|
|
106
|
+
};
|
|
107
|
+
// Hooks
|
|
108
|
+
|
|
109
|
+
</script>
|
|
110
|
+
|
|
111
|
+
<style lang="less">
|
|
112
|
+
// Misc
|
|
113
|
+
@com-ani-ease: var(--ui-ani-ease);
|
|
114
|
+
|
|
115
|
+
// Input height
|
|
116
|
+
@com-input-height-large: var(--ui-input-height-large);
|
|
117
|
+
@com-input-height-big: var(--ui-input-height-big);
|
|
118
|
+
@com-input-height-medium: var(--ui-input-height-medium);
|
|
119
|
+
@com-input-height-default: var(--ui-input-height-default);
|
|
120
|
+
@com-input-height-small: var(--ui-input-height-small);
|
|
121
|
+
@com-input-height-mini: var(--ui-input-height-mini);
|
|
122
|
+
|
|
123
|
+
// Border radius
|
|
124
|
+
@com-border-radius-default: var(--ui-border-radius-default);
|
|
125
|
+
@com-border-radius-small: var(--ui-border-radius-small);
|
|
126
|
+
@com-border-radius-round: var(--ui-input-height-large);
|
|
127
|
+
|
|
128
|
+
// Color
|
|
129
|
+
@com-color-border-bolder: var(--ui-color-border-bolder);
|
|
130
|
+
@com-color-bg: var(--ui-color-bg);
|
|
131
|
+
@com-color-header-text: var(--ui-color-header-text);
|
|
132
|
+
@com-color-gray-text: var(--ui-color-gray-text);
|
|
133
|
+
@com-color-primary: var(--color-primary);
|
|
134
|
+
|
|
135
|
+
// Space
|
|
136
|
+
@com-space-small: var(--ui-space-small);
|
|
137
|
+
@com-space-mini: var(--ui-space-mini;);
|
|
138
|
+
|
|
139
|
+
// Font
|
|
140
|
+
@com-font-text: var(--ui-font-text);
|
|
141
|
+
|
|
142
|
+
// Text size
|
|
143
|
+
@com-text-default: var(--ui-text-default);
|
|
144
|
+
@com-text-small: var(--ui-text-small);
|
|
145
|
+
@com-text-mini: var(--ui-text-mini);
|
|
146
|
+
|
|
147
|
+
.component-ui-input {
|
|
148
|
+
overflow: hidden;
|
|
149
|
+
position: relative;
|
|
150
|
+
height: @com-input-height-default;
|
|
151
|
+
border: 1px solid @com-color-border-bolder;
|
|
152
|
+
border-radius: @com-border-radius-default;
|
|
153
|
+
background: @com-color-bg;
|
|
154
|
+
cursor: text;
|
|
155
|
+
|
|
156
|
+
.com-content {
|
|
157
|
+
display: flex;
|
|
158
|
+
height: 100%;
|
|
159
|
+
|
|
160
|
+
> div {
|
|
161
|
+
position: relative;
|
|
162
|
+
height: 100%;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.slot-prepend,
|
|
166
|
+
.slot-append {
|
|
167
|
+
flex: 0 0 40px;
|
|
168
|
+
display: grid;
|
|
169
|
+
place-items: center;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.slot-default {
|
|
174
|
+
width: 100%;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
input {
|
|
178
|
+
box-sizing: border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box;
|
|
179
|
+
|
|
180
|
+
display: block;
|
|
181
|
+
padding: 0 @com-space-mini;
|
|
182
|
+
width: 100%;
|
|
183
|
+
height: 100%;
|
|
184
|
+
|
|
185
|
+
font-family: @com-font-text;
|
|
186
|
+
font-size: @com-text-default;
|
|
187
|
+
color: @com-color-header-text;
|
|
188
|
+
|
|
189
|
+
background: transparent;
|
|
190
|
+
border: none;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Shape
|
|
194
|
+
&.tag-shape-round {
|
|
195
|
+
border-radius: @com-border-radius-round;
|
|
196
|
+
}
|
|
197
|
+
&.tag-shape-round-square {
|
|
198
|
+
border-radius: @com-border-radius-small;
|
|
199
|
+
}
|
|
200
|
+
&.tag-shape-square {
|
|
201
|
+
border-radius: 0;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Size
|
|
205
|
+
&.tag-size-large { height: @com-input-height-large; }
|
|
206
|
+
&.tag-size-big { height: @com-input-height-big; }
|
|
207
|
+
&.tag-size-medium { height: @com-input-height-medium; }
|
|
208
|
+
&.tag-size-small {
|
|
209
|
+
//padding: 0 @com-space-small;
|
|
210
|
+
height: @com-input-height-small;
|
|
211
|
+
font-size: @com-text-small;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
&.tag-size-mini {
|
|
215
|
+
//padding: 0 10px;
|
|
216
|
+
height: @com-input-height-mini;
|
|
217
|
+
|
|
218
|
+
font-size: @com-text-mini;
|
|
219
|
+
|
|
220
|
+
.loading-indicator {
|
|
221
|
+
transform: translate3d(-50%, -50%, 0) scale(0.6);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Focus
|
|
226
|
+
&.tag-focus {
|
|
227
|
+
border-color: @com-color-primary;
|
|
228
|
+
outline: 1px solid @com-color-primary;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Disabled
|
|
232
|
+
&.tag-disabled {
|
|
233
|
+
cursor: not-allowed;
|
|
234
|
+
opacity: 0.6;
|
|
235
|
+
|
|
236
|
+
input {
|
|
237
|
+
cursor: not-allowed;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
</style>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<label class="component-ui-label">
|
|
3
|
+
<span class="component-ui-label--text">{{ text }}</span>
|
|
4
|
+
<slot></slot>
|
|
5
|
+
</label>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script setup>
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
text: {
|
|
11
|
+
default: ''
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<style lang="less">
|
|
17
|
+
@com-space-micro: var(--ui-space-micro);
|
|
18
|
+
@com-font-weight-medium: var(--ui-font-weight-medium);
|
|
19
|
+
@com-text-medium: var(--ui-text-medium);
|
|
20
|
+
@com-color-header-text: var(--ui-color-header-text);
|
|
21
|
+
|
|
22
|
+
.component-ui-label {
|
|
23
|
+
display: block;
|
|
24
|
+
|
|
25
|
+
.component-ui-label--text {
|
|
26
|
+
display: block;
|
|
27
|
+
padding-bottom: @com-space-micro;
|
|
28
|
+
font-weight: @com-font-weight-medium;
|
|
29
|
+
font-size: @com-text-medium;
|
|
30
|
+
color: @com-color-header-text;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
</style>
|