adata-ui 0.1.40 → 0.1.41
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/adata-ui.common.js +76 -40
- package/dist/adata-ui.common.js.map +1 -1
- package/dist/adata-ui.umd.js +76 -40
- package/dist/adata-ui.umd.js.map +1 -1
- package/dist/adata-ui.umd.min.js +2 -2
- package/dist/adata-ui.umd.min.js.map +1 -1
- package/package-lock.json +1 -1
- package/package.json +1 -1
- package/src/App.vue +27 -14
- package/src/components/Header/Header.vue +1 -1
- package/src/components/SearchTextField/SearchTextField.vue +106 -66
package/package-lock.json
CHANGED
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -1,37 +1,50 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div id="app">
|
|
3
|
-
<!-- <text-field label="Пример" v-model="value" @input="inputHandle" @enterPressed="inputHandle" />-->
|
|
4
|
-
<search-text-field
|
|
3
|
+
<!-- <text-field label="Пример" v-model="value" @input="inputHandle" @enterPressed="inputHandle" />-->
|
|
4
|
+
<search-text-field
|
|
5
|
+
label="Пример2"
|
|
6
|
+
v-model="value"
|
|
7
|
+
@input="inputHandle"
|
|
8
|
+
@enterPressed="inputHandle"
|
|
9
|
+
:options="options"
|
|
10
|
+
:optionFields="['id', 'name']"
|
|
11
|
+
v-mask="'####-##'"
|
|
12
|
+
clearable
|
|
13
|
+
/>
|
|
5
14
|
</div>
|
|
6
15
|
</template>
|
|
7
16
|
|
|
8
17
|
<script>
|
|
9
|
-
|
|
18
|
+
import { VueMaskDirective } from "v-mask";
|
|
10
19
|
// import TextField from "./components/TextField/TextField";
|
|
11
20
|
import SearchTextField from "./components/SearchTextField/SearchTextField";
|
|
12
21
|
|
|
13
22
|
export default {
|
|
14
|
-
name:
|
|
23
|
+
name: "App",
|
|
24
|
+
directives: {
|
|
25
|
+
mask: VueMaskDirective,
|
|
26
|
+
},
|
|
15
27
|
components: {
|
|
16
28
|
// TextField,
|
|
17
|
-
SearchTextField
|
|
29
|
+
SearchTextField,
|
|
18
30
|
},
|
|
19
31
|
data() {
|
|
20
32
|
return {
|
|
21
33
|
value: "",
|
|
22
|
-
options: [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
options: [
|
|
35
|
+
{
|
|
36
|
+
id: 1,
|
|
37
|
+
name: "reg",
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
28
41
|
},
|
|
29
42
|
methods: {
|
|
30
43
|
inputHandle(val) {
|
|
31
44
|
console.log(val);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
35
48
|
</script>
|
|
36
49
|
|
|
37
50
|
<style>
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
|
|
76
76
|
<script>
|
|
77
77
|
import Profile from "./Profile";
|
|
78
|
-
import { profileDropDown } from "
|
|
78
|
+
import { profileDropDown } from "../../configs/profileDropDown"
|
|
79
79
|
import MobileToggle from "../transitions/VerticalMobileToggle";
|
|
80
80
|
|
|
81
81
|
export default {
|
|
@@ -1,52 +1,86 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
<div
|
|
3
|
+
class="adt-text-block"
|
|
4
|
+
v-click-outside="onOutsideClick"
|
|
5
|
+
@keydown.down.up.prevent="onUpOrDownClicked"
|
|
5
6
|
>
|
|
6
7
|
<div :class="['adt-text-block__field', { error: !!errorText }]">
|
|
7
8
|
<input
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
:class="{ error: !!errorText }"
|
|
9
|
+
ref="input"
|
|
10
|
+
:type="type"
|
|
11
|
+
:value="value"
|
|
12
|
+
:placeholder="placeholder"
|
|
13
|
+
required
|
|
14
|
+
@keyup.enter="enterPressed"
|
|
15
|
+
@input="$emit('input', $event.target.value)"
|
|
16
|
+
@focus="showAutocomplete = true"
|
|
17
|
+
@click="$emit('showVTour')"
|
|
18
|
+
class="adt-text-block__input"
|
|
19
|
+
:class="{ error: !!errorText }"
|
|
20
20
|
/>
|
|
21
21
|
<label class="adt-text-block__label">
|
|
22
22
|
{{ label }}
|
|
23
23
|
</label>
|
|
24
|
-
<div
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
<div
|
|
25
|
+
class="adt-text-block__icon"
|
|
26
|
+
v-if="clearable && value"
|
|
27
|
+
@click="$emit('input', '')"
|
|
28
|
+
>
|
|
29
|
+
<svg
|
|
30
|
+
width="12"
|
|
31
|
+
height="12"
|
|
32
|
+
fill="none"
|
|
33
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
34
|
+
viewBox="0 0 16 16"
|
|
35
|
+
id="clearIcon"
|
|
36
|
+
>
|
|
37
|
+
<path
|
|
38
|
+
d="M2 2l12 12m0-12L2 14"
|
|
39
|
+
stroke="#2C3E50"
|
|
40
|
+
stroke-linecap="round"
|
|
41
|
+
stroke-linejoin="round"
|
|
42
|
+
></path>
|
|
27
43
|
</svg>
|
|
28
44
|
</div>
|
|
29
45
|
</div>
|
|
30
46
|
<div class="adt-text-block__error" v-if="!!errorText">
|
|
31
|
-
<svg
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
47
|
+
<svg
|
|
48
|
+
width="14"
|
|
49
|
+
height="14"
|
|
50
|
+
viewBox="0 0 16 16"
|
|
51
|
+
fill="none"
|
|
52
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
53
|
+
id="icon__attention"
|
|
54
|
+
>
|
|
55
|
+
<path
|
|
56
|
+
d="M8.5 4C8.5 3.72386 8.27614 3.5 8 3.5C7.72386 3.5 7.5 3.72386 7.5 4H8.5ZM7.5 9C7.5 9.27614 7.72386 9.5 8 9.5C8.27614 9.5 8.5 9.27614 8.5 9H7.5ZM7.5 4V9H8.5V4H7.5Z"
|
|
57
|
+
fill="#FF2E43"
|
|
58
|
+
/>
|
|
59
|
+
<path
|
|
60
|
+
d="M8.5 11C8.5 10.7239 8.27614 10.5 8 10.5C7.72386 10.5 7.5 10.7239 7.5 11H8.5ZM7.5 11.5C7.5 11.7761 7.72386 12 8 12C8.27614 12 8.5 11.7761 8.5 11.5H7.5ZM7.5 11V11.5H8.5V11H7.5Z"
|
|
61
|
+
fill="#FF2E43"
|
|
62
|
+
/>
|
|
63
|
+
<circle cx="8" cy="8" r="7" stroke="#FF2E43" />
|
|
35
64
|
</svg>
|
|
36
65
|
{{ errorText }}
|
|
37
66
|
</div>
|
|
38
|
-
<div
|
|
67
|
+
<div
|
|
68
|
+
class="adt-text-block__options search-options"
|
|
69
|
+
v-show="options && options.length > 0 && showAutocomplete"
|
|
70
|
+
>
|
|
39
71
|
<PerfectScrollbar>
|
|
40
72
|
<div class="search-options__wrapper">
|
|
41
73
|
<div
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
74
|
+
class="search-options__item"
|
|
75
|
+
v-for="(option, index) in options"
|
|
76
|
+
:key="index"
|
|
77
|
+
@click="onAutocompleteOptionClick(option)"
|
|
78
|
+
ref="searchOptions"
|
|
47
79
|
>
|
|
48
80
|
{{ !!optionFields.length ? textByOption(option) : option }}
|
|
49
|
-
<div class="hiddenOne" v-if="option.type && isTypeRequired">
|
|
81
|
+
<div class="hiddenOne" v-if="option.type && isTypeRequired">
|
|
82
|
+
${{ option.type }}$
|
|
83
|
+
</div>
|
|
50
84
|
</div>
|
|
51
85
|
</div>
|
|
52
86
|
</PerfectScrollbar>
|
|
@@ -55,8 +89,8 @@
|
|
|
55
89
|
</template>
|
|
56
90
|
|
|
57
91
|
<script>
|
|
58
|
-
import
|
|
59
|
-
|
|
92
|
+
import "../../assets/style.scss";
|
|
93
|
+
|
|
60
94
|
import { PerfectScrollbar } from "vue2-perfect-scrollbar";
|
|
61
95
|
import vClickOutside from "v-click-outside";
|
|
62
96
|
|
|
@@ -64,20 +98,24 @@ export default {
|
|
|
64
98
|
name: "SearchTextField",
|
|
65
99
|
directives: {
|
|
66
100
|
clickOutside: vClickOutside.directive,
|
|
67
|
-
mask: VueMaskDirective
|
|
68
101
|
},
|
|
69
102
|
props: {
|
|
70
103
|
errorText: {
|
|
71
104
|
type: String,
|
|
72
|
-
default: ""
|
|
105
|
+
default: "",
|
|
73
106
|
},
|
|
74
107
|
placeholder: {
|
|
75
108
|
type: String,
|
|
76
|
-
default: ""
|
|
109
|
+
default: "",
|
|
77
110
|
},
|
|
78
111
|
mask: {
|
|
79
112
|
type: String,
|
|
80
|
-
default: ""
|
|
113
|
+
default: "",
|
|
114
|
+
},
|
|
115
|
+
value: {
|
|
116
|
+
type: String,
|
|
117
|
+
required: true,
|
|
118
|
+
default: "",
|
|
81
119
|
},
|
|
82
120
|
label: {
|
|
83
121
|
type: String,
|
|
@@ -89,15 +127,15 @@ export default {
|
|
|
89
127
|
},
|
|
90
128
|
clearable: {
|
|
91
129
|
type: Boolean,
|
|
92
|
-
default: false
|
|
130
|
+
default: false,
|
|
93
131
|
},
|
|
94
132
|
isWithIcon: {
|
|
95
133
|
type: Boolean,
|
|
96
|
-
default: false
|
|
134
|
+
default: false,
|
|
97
135
|
},
|
|
98
136
|
isTypeRequired: {
|
|
99
137
|
type: Boolean,
|
|
100
|
-
default: false
|
|
138
|
+
default: false,
|
|
101
139
|
},
|
|
102
140
|
options: {
|
|
103
141
|
type: Array,
|
|
@@ -105,34 +143,33 @@ export default {
|
|
|
105
143
|
},
|
|
106
144
|
optionFields: {
|
|
107
145
|
type: Array,
|
|
108
|
-
default: null
|
|
146
|
+
default: null,
|
|
109
147
|
},
|
|
110
148
|
isMobile: {
|
|
111
149
|
type: Boolean,
|
|
112
|
-
default: false
|
|
150
|
+
default: false,
|
|
113
151
|
},
|
|
114
152
|
},
|
|
115
153
|
components: {
|
|
116
|
-
PerfectScrollbar
|
|
154
|
+
PerfectScrollbar,
|
|
117
155
|
},
|
|
118
156
|
data() {
|
|
119
157
|
return {
|
|
120
158
|
showAutocomplete: false,
|
|
121
159
|
showPlaceholder: false,
|
|
122
|
-
|
|
123
|
-
}
|
|
160
|
+
};
|
|
124
161
|
},
|
|
125
162
|
computed: {
|
|
126
163
|
inputPlaceholder() {
|
|
127
|
-
return this.showPlaceholder ? this.placeholder : ""
|
|
128
|
-
}
|
|
164
|
+
return this.showPlaceholder ? this.placeholder : "";
|
|
165
|
+
},
|
|
129
166
|
},
|
|
130
167
|
methods: {
|
|
131
|
-
|
|
132
|
-
this.$emit(
|
|
168
|
+
enterPressed() {
|
|
169
|
+
this.$emit("enterPressed", this.showAutocomplete);
|
|
133
170
|
},
|
|
134
171
|
onOutsideClick() {
|
|
135
|
-
if (!this.isMobile) this.showAutocomplete = false
|
|
172
|
+
if (!this.isMobile) this.showAutocomplete = false;
|
|
136
173
|
},
|
|
137
174
|
onUpOrDownClicked(e) {
|
|
138
175
|
const autoCompleteOptions = this.$refs.searchOptions;
|
|
@@ -140,44 +177,48 @@ export default {
|
|
|
140
177
|
if (length > 0) {
|
|
141
178
|
switch (e.which) {
|
|
142
179
|
case 40:
|
|
143
|
-
this.moveOption(autoCompleteOptions,
|
|
180
|
+
this.moveOption(autoCompleteOptions, "nextElementSibling");
|
|
144
181
|
break;
|
|
145
182
|
case 38:
|
|
146
|
-
this.moveOption(autoCompleteOptions,
|
|
183
|
+
this.moveOption(autoCompleteOptions, "previousElementSibling");
|
|
147
184
|
break;
|
|
148
185
|
}
|
|
149
186
|
}
|
|
150
187
|
},
|
|
151
188
|
moveOption(autoCompleteOptions, elementType) {
|
|
152
|
-
const selectedOption = autoCompleteOptions.find((option) =>
|
|
189
|
+
const selectedOption = autoCompleteOptions.find((option) =>
|
|
190
|
+
option.hasAttribute("id")
|
|
191
|
+
);
|
|
153
192
|
if (selectedOption) {
|
|
154
193
|
const siblingElement = selectedOption[elementType];
|
|
155
|
-
this.$emit(
|
|
156
|
-
if (siblingElement?.classList.contains(
|
|
194
|
+
this.$emit("castOption", siblingElement?.innerText || "");
|
|
195
|
+
if (siblingElement?.classList.contains("search-options__item")) {
|
|
157
196
|
selectedOption.removeAttribute("id");
|
|
158
|
-
siblingElement.setAttribute("id",
|
|
197
|
+
siblingElement.setAttribute("id", "searchVariant");
|
|
159
198
|
return;
|
|
160
199
|
}
|
|
161
200
|
selectedOption.removeAttribute("id");
|
|
162
201
|
return;
|
|
163
202
|
}
|
|
164
203
|
let innerText = "";
|
|
165
|
-
if (elementType ===
|
|
204
|
+
if (elementType === "nextElementSibling")
|
|
166
205
|
innerText = this.getAutocompleteOptionText(autoCompleteOptions?.[0]);
|
|
167
|
-
if (elementType ===
|
|
168
|
-
innerText = this.getAutocompleteOptionText(
|
|
169
|
-
|
|
206
|
+
if (elementType === "previousElementSibling")
|
|
207
|
+
innerText = this.getAutocompleteOptionText(
|
|
208
|
+
autoCompleteOptions?.[autoCompleteOptions.length - 1]
|
|
209
|
+
);
|
|
210
|
+
this.$emit("castOption", innerText);
|
|
170
211
|
},
|
|
171
212
|
getAutocompleteOptionText(autocompleteOption) {
|
|
172
|
-
autocompleteOption.setAttribute("id",
|
|
213
|
+
autocompleteOption.setAttribute("id", "searchVariant");
|
|
173
214
|
return autocompleteOption.innerText;
|
|
174
215
|
},
|
|
175
|
-
inputHandler() {
|
|
176
|
-
this.$emit(
|
|
216
|
+
inputHandler(e) {
|
|
217
|
+
this.$emit("input", e.target.value);
|
|
177
218
|
this.showAutocomplete = true;
|
|
178
219
|
},
|
|
179
220
|
onAutocompleteOptionClick(option) {
|
|
180
|
-
this.$emit(
|
|
221
|
+
this.$emit("click", option);
|
|
181
222
|
this.showAutocomplete = false;
|
|
182
223
|
},
|
|
183
224
|
textByOption(obj) {
|
|
@@ -186,8 +227,7 @@ export default {
|
|
|
186
227
|
acc += obj[curr];
|
|
187
228
|
return acc;
|
|
188
229
|
}, "");
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
};
|
|
192
233
|
</script>
|
|
193
|
-
|