plugin-ui-for-kzt 0.0.20 → 0.0.21
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/components/BaseButton/BaseButton.vue.d.ts +2 -0
- package/dist/components/BaseCalendar/BaseCalendar.vue.d.ts +0 -8
- package/dist/components/BaseCheckbox/BaseCheckbox.vue.d.ts +2 -0
- package/dist/components/BaseDropdown/BaseDropdown.vue.d.ts +2 -0
- package/dist/components/BaseInput/BaseInput.vue.d.ts +15 -17
- package/dist/components/BaseInputCalendar/BaseInputCalendar.vue.d.ts +14 -12
- package/dist/components/BaseInputCurrency/BaseInputCurrency.vue.d.ts +9 -7
- package/dist/components/BaseInputEmail/BaseInputEmail.vue.d.ts +12 -7
- package/dist/components/BaseInputPhone/BaseInputPhone.vue.d.ts +12 -7
- package/dist/components/BaseOpenedListItem/BaseOpenedListItem.vue.d.ts +2 -0
- package/dist/components/BaseRadio/BaseRadio.vue.d.ts +2 -0
- package/dist/components/BaseSegmentedButtons/BaseSegmentedButtons.vue.d.ts +2 -0
- package/dist/components/BaseSiteInput/BaseSiteInput.vue.d.ts +7 -11
- package/dist/components/BaseTextarea/BaseTextarea.vue.d.ts +12 -7
- package/dist/components/BaseToggle/BaseToggle.vue.d.ts +2 -0
- package/dist/composables/kit/state.d.ts +2 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -1
- package/example/App.vue +30 -185
- package/package.json +1 -1
- package/src/components/BaseInput/BaseInput.vue +228 -162
- package/src/components/BaseInputCalendar/BaseInputCalendar.vue +7 -10
- package/src/components/BaseInputCurrency/BaseInputCurrency.vue +78 -39
- package/src/components/BaseInputEmail/BaseInputEmail.vue +4 -2
- package/src/components/BaseInputPhone/BaseInputPhone.vue +89 -29
- package/src/components/BaseSegmentedButtons/BaseSegmentedButtons.vue +1 -0
- package/src/components/BaseSelect/BaseSelect.vue +52 -9
- package/src/components/BaseSiteInput/BaseSiteInput.vue +63 -11
- package/src/components/BaseTextarea/BaseTextarea.vue +30 -3
- package/src/composables/kit/state.ts +2 -1
- package/src/index.ts +2 -5
- package/src/styles/index.scss +2 -87
- package/src/styles/root.scss +0 -1
- package/src/styles/variables.scss +1 -2
- package/src/types/button.d.ts +1 -0
- package/src/types/calendar.d.ts +0 -2
- package/src/types/input.d.ts +8 -26
- package/src/types/utils.d.ts +1 -0
- package/dist/components/BaseField/BaseField.vue.d.ts +0 -98
- package/src/components/BaseField/BaseField.vue +0 -184
- package/src/components/BaseField/README.md +0 -85
- package/src/types/field.d.ts +0 -12
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :class="classList">
|
|
3
3
|
<div class="base-input-currency__wrapper">
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
<div class="base-input-currency__input-container">
|
|
5
|
+
<span class="base-input-currency__symbol">{{ selectedOption.symbol }}</span>
|
|
6
|
+
<base-input
|
|
7
|
+
id="input-currency"
|
|
8
|
+
type="text"
|
|
9
|
+
:modelValue="modelValue"
|
|
10
|
+
v-bind="componentAttrs"
|
|
11
|
+
v-maska
|
|
12
|
+
:data-maska="selectedOption.mask"
|
|
13
|
+
:size="size"
|
|
14
|
+
:placeholder="placeholder || '0.00'"
|
|
15
|
+
class="base-input-currency__input"
|
|
16
|
+
@update:modelValue="handleInput"
|
|
17
|
+
></base-input>
|
|
18
|
+
</div>
|
|
19
|
+
<base-select
|
|
20
|
+
id="select-currency"
|
|
21
|
+
v-model="selectedOptionId"
|
|
22
|
+
:options="optionsCurrency"
|
|
13
23
|
:size="size"
|
|
14
|
-
:
|
|
15
|
-
|
|
16
|
-
class="base-input-currency__input"
|
|
17
|
-
@update:modelValue="handleInput"
|
|
24
|
+
:error="error"
|
|
25
|
+
class="base-input-currency__select"
|
|
18
26
|
/>
|
|
19
27
|
</div>
|
|
20
|
-
<base-select
|
|
21
|
-
id="select-currency"
|
|
22
|
-
v-model="selectedOptionId"
|
|
23
|
-
:options="optionsCurrency"
|
|
24
|
-
:size="size"
|
|
25
|
-
:error="error"
|
|
26
|
-
class="base-input-currency__select"
|
|
27
|
-
>
|
|
28
|
-
</base-select>
|
|
29
|
-
</div>
|
|
30
28
|
</div>
|
|
31
29
|
</template>
|
|
32
30
|
|
|
@@ -37,7 +35,7 @@ import BaseInput from '../BaseInput/BaseInput.vue';
|
|
|
37
35
|
import BaseSelect from '../BaseSelect/BaseSelect.vue';
|
|
38
36
|
import { useKitState } from '../../composables/kit/state';
|
|
39
37
|
import { useKitSize } from '../../composables/kit/size';
|
|
40
|
-
import type { ICoreInputProps
|
|
38
|
+
import type { ICoreInputProps } from '../../types/input';
|
|
41
39
|
|
|
42
40
|
const props = withDefaults(defineProps<ICoreInputProps>(), {
|
|
43
41
|
size: 'medium',
|
|
@@ -45,23 +43,24 @@ const props = withDefaults(defineProps<ICoreInputProps>(), {
|
|
|
45
43
|
modelValue: '',
|
|
46
44
|
placeholder: '0.00',
|
|
47
45
|
error: '',
|
|
46
|
+
hint: '',
|
|
48
47
|
});
|
|
49
48
|
|
|
50
49
|
const emit: (event: 'update:modelValue', value: string) => void = defineEmits();
|
|
51
50
|
|
|
52
|
-
const optionsCurrency = ref
|
|
53
|
-
{ id: '1', name: 'KZT', value: '
|
|
54
|
-
{ id: '2', name: 'RUB', value: '
|
|
55
|
-
{ id: '3', name: 'KGS', value: '
|
|
56
|
-
{ id: '4', name: 'UZS', value: '
|
|
51
|
+
const optionsCurrency = ref([
|
|
52
|
+
{ id: '1', name: 'KZT', value: 'kzt', mask: '# ##0.##', symbol: '₸' },
|
|
53
|
+
{ id: '2', name: 'RUB', value: 'rub', mask: '# ##0.##', symbol: '₽' },
|
|
54
|
+
{ id: '3', name: 'KGS', value: 'kgs', mask: '# ##0.##', symbol: '⃀' },
|
|
55
|
+
{ id: '4', name: 'UZS', value: 'uzs', mask: '# ##0.##', symbol: 'сў' },
|
|
57
56
|
]);
|
|
58
57
|
|
|
59
|
-
const selectedOption = ref
|
|
58
|
+
const selectedOption = ref(optionsCurrency.value[0]);
|
|
60
59
|
|
|
61
|
-
const selectedOptionId = ref
|
|
60
|
+
const selectedOptionId = ref(selectedOption.value.id);
|
|
62
61
|
|
|
63
|
-
watch(selectedOptionId, (newId
|
|
64
|
-
const newOption = optionsCurrency.value.find((option
|
|
62
|
+
watch(selectedOptionId, (newId) => {
|
|
63
|
+
const newOption = optionsCurrency.value.find((option) => option.id === newId);
|
|
65
64
|
if (newOption) {
|
|
66
65
|
selectedOption.value = newOption;
|
|
67
66
|
}
|
|
@@ -72,16 +71,21 @@ const { sizeClassList } = useKitSize(props);
|
|
|
72
71
|
const attrs = useAttrs();
|
|
73
72
|
|
|
74
73
|
const componentAttrs = computed(() => ({
|
|
75
|
-
...attrs,
|
|
76
|
-
...stateAttrs.value,
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
...attrs,
|
|
75
|
+
...stateAttrs.value,
|
|
76
|
+
label: props.label,
|
|
77
|
+
error: props.error,
|
|
78
|
+
hint: props.hint,
|
|
79
|
+
placeholder: props.placeholder,
|
|
79
80
|
}));
|
|
80
81
|
|
|
81
82
|
const classList = computed(() => [
|
|
82
83
|
stateClassList.value,
|
|
83
84
|
sizeClassList.value,
|
|
84
|
-
'base-input-currency'
|
|
85
|
+
'base-input-currency',
|
|
86
|
+
{
|
|
87
|
+
'--is-has-hint': !!props.hint,
|
|
88
|
+
}
|
|
85
89
|
]);
|
|
86
90
|
|
|
87
91
|
const modelValue = computed({
|
|
@@ -112,7 +116,6 @@ width: 100%;
|
|
|
112
116
|
&__input-container {
|
|
113
117
|
display: flex;
|
|
114
118
|
align-items: center;
|
|
115
|
-
flex-grow: 1;
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
&__symbol {
|
|
@@ -150,6 +153,14 @@ width: 100%;
|
|
|
150
153
|
}
|
|
151
154
|
|
|
152
155
|
&.--small-size {
|
|
156
|
+
&.--is-has-hint {
|
|
157
|
+
#{$input} {
|
|
158
|
+
&__select {
|
|
159
|
+
margin-bottom: 26px;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
153
164
|
#{$input} {
|
|
154
165
|
:deep(.base-select) {
|
|
155
166
|
width: 71px;
|
|
@@ -158,6 +169,10 @@ width: 100%;
|
|
|
158
169
|
&__symbol {
|
|
159
170
|
font-size: var(--typography-text-s-regular);
|
|
160
171
|
}
|
|
172
|
+
|
|
173
|
+
&.--is-error {
|
|
174
|
+
margin-bottom: 26px;
|
|
175
|
+
}
|
|
161
176
|
}
|
|
162
177
|
|
|
163
178
|
:deep(.base-input__field) {
|
|
@@ -166,6 +181,14 @@ width: 100%;
|
|
|
166
181
|
}
|
|
167
182
|
|
|
168
183
|
&.--medium-size {
|
|
184
|
+
&.--is-has-hint {
|
|
185
|
+
#{$input} {
|
|
186
|
+
&__select {
|
|
187
|
+
margin-bottom: 26px;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
169
192
|
#{$input} {
|
|
170
193
|
:deep(.base-select) {
|
|
171
194
|
width: 75px;
|
|
@@ -174,6 +197,10 @@ width: 100%;
|
|
|
174
197
|
&__symbol {
|
|
175
198
|
font-size: var(--typography-text-m-regular);
|
|
176
199
|
}
|
|
200
|
+
|
|
201
|
+
&.--is-error {
|
|
202
|
+
margin-bottom: 26px;
|
|
203
|
+
}
|
|
177
204
|
}
|
|
178
205
|
|
|
179
206
|
:deep(.base-input__field) {
|
|
@@ -182,6 +209,14 @@ width: 100%;
|
|
|
182
209
|
}
|
|
183
210
|
|
|
184
211
|
&.--large-size {
|
|
212
|
+
&.--is-has-hint {
|
|
213
|
+
#{$input} {
|
|
214
|
+
&__select {
|
|
215
|
+
margin-bottom: 30px;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
185
220
|
#{$input} {
|
|
186
221
|
:deep(.base-select) {
|
|
187
222
|
width: 87px;
|
|
@@ -190,6 +225,10 @@ width: 100%;
|
|
|
190
225
|
&__symbol {
|
|
191
226
|
font-size: var(--typography-text-l-regular);
|
|
192
227
|
}
|
|
228
|
+
|
|
229
|
+
&.--is-error {
|
|
230
|
+
margin-bottom: 30px;
|
|
231
|
+
}
|
|
193
232
|
}
|
|
194
233
|
|
|
195
234
|
:deep(.base-input__field) {
|
|
@@ -47,6 +47,8 @@ const props = withDefaults(defineProps<ICoreInputProps>(), {
|
|
|
47
47
|
type: 'email',
|
|
48
48
|
modelValue: '',
|
|
49
49
|
placeholder: '' as string,
|
|
50
|
+
error: '',
|
|
51
|
+
hint: '',
|
|
50
52
|
});
|
|
51
53
|
|
|
52
54
|
const emit = defineEmits<{
|
|
@@ -62,7 +64,7 @@ function onUpdateModelValue(value: string) {
|
|
|
62
64
|
emit('update:modelValue', value);
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
const emailError = ref
|
|
67
|
+
const emailError = ref('');
|
|
66
68
|
|
|
67
69
|
watch(modelValue, (value) => {
|
|
68
70
|
if (!/^[\w\-.]+@(?:[\w\-]+\.)+[\w\-]{2,4}$/.test(String(value))) {
|
|
@@ -75,7 +77,7 @@ watch(modelValue, (value) => {
|
|
|
75
77
|
|
|
76
78
|
<style scoped lang="scss">
|
|
77
79
|
.base-input-email {
|
|
78
|
-
width:
|
|
80
|
+
width: max-content;
|
|
79
81
|
|
|
80
82
|
&__tooltip-container {
|
|
81
83
|
position: relative;
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
:error="error"
|
|
10
10
|
class="base-input-phone__select"
|
|
11
11
|
>
|
|
12
|
-
<template #iconItem="{ item }:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
<template #iconItem="{ item }: ICoreButtonProps">
|
|
13
|
+
<base-icon
|
|
14
|
+
:name="item.icon"
|
|
15
|
+
:size="size"
|
|
16
|
+
/>
|
|
17
17
|
</template>
|
|
18
18
|
</base-select>
|
|
19
19
|
<base-input
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
:mask="selectedOption.mask"
|
|
25
25
|
:size="size"
|
|
26
26
|
:placeholder="placeholder || ''"
|
|
27
|
-
:focusable="false"
|
|
28
27
|
class="base-input-phone__input"
|
|
29
28
|
@update:modelValue="handleInput"
|
|
30
29
|
></base-input>
|
|
@@ -38,39 +37,40 @@ import BaseInput from '../BaseInput/BaseInput.vue';
|
|
|
38
37
|
import BaseSelect from '../BaseSelect/BaseSelect.vue';
|
|
39
38
|
import { useKitState } from '../../composables/kit/state';
|
|
40
39
|
import { useKitSize } from '../../composables/kit/size';
|
|
41
|
-
import type { ICoreInputProps
|
|
40
|
+
import type { ICoreInputProps } from '../../types/input';
|
|
42
41
|
|
|
43
|
-
interface
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
interface ICoreButtonProps {
|
|
43
|
+
item:{
|
|
44
|
+
icon:string
|
|
45
|
+
}
|
|
47
46
|
}
|
|
48
|
-
|
|
49
47
|
const props = withDefaults(defineProps<ICoreInputProps>(), {
|
|
50
48
|
size: 'medium',
|
|
51
49
|
type: 'text',
|
|
52
50
|
modelValue: '',
|
|
53
|
-
placeholder: '',
|
|
51
|
+
placeholder: '' as string,
|
|
52
|
+
error: '',
|
|
53
|
+
hint: '',
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
const emit: (event: 'update:modelValue', value: string) => void = defineEmits();
|
|
57
57
|
|
|
58
|
-
const optionsPhone = ref
|
|
59
|
-
{ id: '1', name: 'KZ', value: '
|
|
60
|
-
{ id: '2', name: 'RU', value: '
|
|
61
|
-
{ id: '3', name: 'KG', value: '
|
|
62
|
-
{ id: '4', name: 'UZ', value: '
|
|
58
|
+
const optionsPhone = ref([
|
|
59
|
+
{ id: '1', name: 'KZ', value: 'kz', mask: '+7 (###) ###-##-##', icon: 'kz' },
|
|
60
|
+
{ id: '2', name: 'RU', value: 'ru', mask: '+7 (###) ###-##-##', icon: 'ru' },
|
|
61
|
+
{ id: '3', name: 'KG', value: 'kg', mask:'+996 (###) ###-###', icon: 'kg' },
|
|
62
|
+
{ id: '4', name: 'UZ', value: 'uz', mask: '+998 (##) ###-##-##', icon: 'uz' },
|
|
63
63
|
]);
|
|
64
64
|
|
|
65
|
-
const selectedOption = ref
|
|
65
|
+
const selectedOption = ref(optionsPhone.value[0]);
|
|
66
66
|
|
|
67
|
-
const selectedOptionId = ref
|
|
67
|
+
const selectedOptionId = ref(selectedOption.value.id);
|
|
68
68
|
|
|
69
69
|
watch(selectedOptionId, (newId) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
const newOption = optionsPhone.value.find((option) => option.id === newId);
|
|
71
|
+
if (newOption) {
|
|
72
|
+
selectedOption.value = newOption;
|
|
73
|
+
}
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
const { stateClassList, stateAttrs } = useKitState(props);
|
|
@@ -80,20 +80,24 @@ const attrs = useAttrs();
|
|
|
80
80
|
const componentAttrs = computed(() => ({
|
|
81
81
|
...attrs,
|
|
82
82
|
...stateAttrs.value,
|
|
83
|
+
label: props.label,
|
|
83
84
|
error: props.error,
|
|
84
|
-
|
|
85
|
+
hint: props.hint,
|
|
85
86
|
placeholder: props.placeholder,
|
|
86
87
|
}));
|
|
87
88
|
|
|
88
89
|
const classList = computed(() => [
|
|
89
90
|
stateClassList.value,
|
|
90
91
|
sizeClassList.value,
|
|
91
|
-
'base-input-phone'
|
|
92
|
+
'base-input-phone',
|
|
93
|
+
{
|
|
94
|
+
'--is-has-hint': !!props.hint,
|
|
95
|
+
}
|
|
92
96
|
]);
|
|
93
97
|
|
|
94
98
|
const modelValue = computed({
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
get: () => props.modelValue,
|
|
100
|
+
set: value => emit('update:modelValue', value),
|
|
97
101
|
});
|
|
98
102
|
const handleInput = (value: string) => {
|
|
99
103
|
emit('update:modelValue', value);
|
|
@@ -122,7 +126,11 @@ const handleInput = (value: string) => {
|
|
|
122
126
|
:deep(.base-input__field) {
|
|
123
127
|
border-top-left-radius: 0 !important;
|
|
124
128
|
border-bottom-left-radius: 0 !important;
|
|
125
|
-
border-left: none
|
|
129
|
+
border-left: none;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
:deep(.base-select__hint) {
|
|
133
|
+
display: none;
|
|
126
134
|
}
|
|
127
135
|
}
|
|
128
136
|
|
|
@@ -135,27 +143,79 @@ const handleInput = (value: string) => {
|
|
|
135
143
|
}
|
|
136
144
|
|
|
137
145
|
&.--small-size {
|
|
146
|
+
&.--is-has-hint {
|
|
147
|
+
#{$input} {
|
|
148
|
+
&__select {
|
|
149
|
+
margin-bottom: 26px;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
138
154
|
#{$input} {
|
|
139
155
|
:deep(.base-select) {
|
|
140
156
|
width: 71px;
|
|
141
157
|
}
|
|
158
|
+
|
|
159
|
+
&__select {
|
|
160
|
+
&.--is-error {
|
|
161
|
+
margin-bottom: 26px;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
:deep(.base-input__label-text),
|
|
166
|
+
:deep(.base-input__hint) {
|
|
167
|
+
transform: translateX(-54px);
|
|
142
168
|
}
|
|
143
169
|
}
|
|
144
170
|
|
|
145
171
|
&.--medium-size {
|
|
172
|
+
&.--is-has-hint {
|
|
173
|
+
#{$input} {
|
|
174
|
+
&__select {
|
|
175
|
+
margin-bottom: 26px;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
146
180
|
#{$input} {
|
|
147
181
|
&__select {
|
|
148
182
|
width: 75px;
|
|
183
|
+
|
|
184
|
+
&.--is-error {
|
|
185
|
+
margin-bottom: 26px;
|
|
186
|
+
}
|
|
149
187
|
}
|
|
150
188
|
}
|
|
189
|
+
|
|
190
|
+
:deep(.base-input__label-text),
|
|
191
|
+
:deep(.base-input__hint) {
|
|
192
|
+
transform: translateX(-75px);
|
|
193
|
+
}
|
|
151
194
|
}
|
|
152
195
|
|
|
153
196
|
&.--large-size {
|
|
197
|
+
&.--is-has-hint {
|
|
198
|
+
#{$input} {
|
|
199
|
+
&__select {
|
|
200
|
+
margin-bottom: 30px;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
154
205
|
#{$input} {
|
|
155
206
|
&__select {
|
|
156
207
|
width: 87px;
|
|
208
|
+
|
|
209
|
+
&.--is-error {
|
|
210
|
+
margin-bottom: 30px;
|
|
211
|
+
}
|
|
157
212
|
}
|
|
158
213
|
}
|
|
214
|
+
|
|
215
|
+
:deep(.base-input__label-text),
|
|
216
|
+
:deep(.base-input__hint) {
|
|
217
|
+
transform: translateX(-86px);
|
|
218
|
+
}
|
|
159
219
|
}
|
|
160
220
|
}
|
|
161
221
|
</style>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="base-select" :class="[classList]">
|
|
3
3
|
<div class="base-select__wrapper">
|
|
4
|
+
<label v-if="label" :for="id" class="base-select__label">{{ label }}</label>
|
|
5
|
+
|
|
4
6
|
<base-dropdown
|
|
5
7
|
v-model="dropdownVisible"
|
|
6
8
|
transition-name="top"
|
|
@@ -15,7 +17,7 @@
|
|
|
15
17
|
>
|
|
16
18
|
<slot
|
|
17
19
|
name="header"
|
|
18
|
-
:value="actualOption
|
|
20
|
+
:value="actualOption"
|
|
19
21
|
>
|
|
20
22
|
<div v-if="$slots.headerIcon" class="base-select__header_prefix_icon">
|
|
21
23
|
<slot name="headerIcon" />
|
|
@@ -61,7 +63,7 @@
|
|
|
61
63
|
key-field="id"
|
|
62
64
|
class="base-select__list"
|
|
63
65
|
>
|
|
64
|
-
<template #default="{ item, index, active } :
|
|
66
|
+
<template #default="{ item, index, active } : SlotProps">
|
|
65
67
|
<dynamic-scroller-item
|
|
66
68
|
:item="item"
|
|
67
69
|
:active="active"
|
|
@@ -88,6 +90,10 @@
|
|
|
88
90
|
</div>
|
|
89
91
|
</template>
|
|
90
92
|
</base-dropdown>
|
|
93
|
+
|
|
94
|
+
<div v-if="(error && typeof error === 'string') || hint" class="base-select__hint">
|
|
95
|
+
{{ error || hint }}
|
|
96
|
+
</div>
|
|
91
97
|
</div>
|
|
92
98
|
</div>
|
|
93
99
|
</template>
|
|
@@ -96,13 +102,20 @@
|
|
|
96
102
|
import { computed, ref, watch } from 'vue';
|
|
97
103
|
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css';
|
|
98
104
|
import { DynamicScroller, DynamicScrollerItem } from 'vue-virtual-scroller';
|
|
99
|
-
import type { ICoreSelectProps, TSelectValue, ICoreSelectBaseProps
|
|
105
|
+
import type { ICoreSelectProps, TSelectValue, ICoreSelectBaseProps } from '../../types/input';
|
|
100
106
|
import BaseDropdown from '../BaseDropdown/BaseDropdown.vue';
|
|
101
107
|
import BaseOpenedListItem from '../BaseOpenedListItem/BaseOpenedListItem.vue';
|
|
102
108
|
import { useKitSize } from '../../composables/kit/size';
|
|
103
109
|
import { useKitState } from '../../composables/kit/state';
|
|
104
110
|
import { useKitStyle } from '../../composables/kit/style';
|
|
105
111
|
|
|
112
|
+
// Определяем тип для slotProps
|
|
113
|
+
interface SlotProps {
|
|
114
|
+
item: ICoreSelectBaseProps;
|
|
115
|
+
index: number;
|
|
116
|
+
active: boolean;
|
|
117
|
+
}
|
|
118
|
+
|
|
106
119
|
const props = withDefaults(defineProps<ICoreSelectProps & {
|
|
107
120
|
modelValue?: TSelectValue
|
|
108
121
|
}>(), {
|
|
@@ -117,11 +130,11 @@ const emit = defineEmits<{
|
|
|
117
130
|
|
|
118
131
|
const actualValue = ref<TSelectValue>(props.modelValue ?? '');
|
|
119
132
|
const actualOption = computed(() =>
|
|
120
|
-
props.options?.find((item:
|
|
133
|
+
props.options?.find((item: ICoreSelectBaseProps) => item.id === actualValue.value) || null
|
|
121
134
|
);
|
|
122
135
|
|
|
123
136
|
watch(() => props.modelValue, (val) => {
|
|
124
|
-
actualValue.value = val
|
|
137
|
+
actualValue.value = val;
|
|
125
138
|
}, { immediate: true });
|
|
126
139
|
|
|
127
140
|
function handleInput(value: TSelectValue) {
|
|
@@ -139,7 +152,7 @@ const { styleClassList } = useKitStyle(props);
|
|
|
139
152
|
const listItemAttrs = computed(() => (item: ICoreSelectBaseProps) => ({
|
|
140
153
|
icon: item.icon,
|
|
141
154
|
active: actualValue.value === item.id,
|
|
142
|
-
title: item.name || '',
|
|
155
|
+
title: item.name || item.label || '',
|
|
143
156
|
style: item.style,
|
|
144
157
|
disabled: item.disabled,
|
|
145
158
|
class: 'base-select__item',
|
|
@@ -157,10 +170,8 @@ const classList = computed(() => [
|
|
|
157
170
|
]);
|
|
158
171
|
|
|
159
172
|
defineSlots<{
|
|
160
|
-
default(props:
|
|
173
|
+
default(props: SlotProps): any;
|
|
161
174
|
iconItem(props: { item: ICoreSelectBaseProps }): any;
|
|
162
|
-
header(props: { value: ICoreSelectProps['options'] }): any;
|
|
163
|
-
headerIcon(): any;
|
|
164
175
|
}>();
|
|
165
176
|
</script>
|
|
166
177
|
|
|
@@ -194,6 +205,14 @@ defineSlots<{
|
|
|
194
205
|
}
|
|
195
206
|
|
|
196
207
|
&.--is-error {
|
|
208
|
+
#{$select}__hint {
|
|
209
|
+
color: var(--error-red);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
#{$select}__label {
|
|
213
|
+
border-color: var(--error-red-light-01);
|
|
214
|
+
}
|
|
215
|
+
|
|
197
216
|
#{$select}__arrow > * {
|
|
198
217
|
color: var(--error-red);
|
|
199
218
|
}
|
|
@@ -257,6 +276,14 @@ defineSlots<{
|
|
|
257
276
|
|
|
258
277
|
&.--small-size {
|
|
259
278
|
#{$select} {
|
|
279
|
+
&__label {
|
|
280
|
+
font: var(--typography-text-s-medium);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
&__hint {
|
|
284
|
+
font: var(--typography-text-s-regular);
|
|
285
|
+
}
|
|
286
|
+
|
|
260
287
|
&__header_value {
|
|
261
288
|
font: var(--typography-text-m-regular);
|
|
262
289
|
}
|
|
@@ -280,6 +307,14 @@ defineSlots<{
|
|
|
280
307
|
|
|
281
308
|
&.--medium-size {
|
|
282
309
|
#{$select} {
|
|
310
|
+
&__label {
|
|
311
|
+
font: var(--typography-text-s-medium);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
&__hint {
|
|
315
|
+
font: var(--typography-text-s-regular);
|
|
316
|
+
}
|
|
317
|
+
|
|
283
318
|
&__header_value {
|
|
284
319
|
font: var(--typography-text-m-regular);
|
|
285
320
|
}
|
|
@@ -298,6 +333,14 @@ defineSlots<{
|
|
|
298
333
|
|
|
299
334
|
&.--large-size {
|
|
300
335
|
#{$select} {
|
|
336
|
+
&__label {
|
|
337
|
+
font: var(--typography-text-m-medium);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
&__hint {
|
|
341
|
+
font: var(--typography-text-m-regular);
|
|
342
|
+
}
|
|
343
|
+
|
|
301
344
|
&__header_value {
|
|
302
345
|
font: var(--typography-text-l-regular);
|
|
303
346
|
}
|