plugin-ui-for-kzt 0.0.21 → 0.0.22
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 +4 -6
- package/dist/components/BaseCalendar/BaseCalendar.vue.d.ts +9 -1
- package/dist/components/BaseCheckbox/BaseCheckbox.vue.d.ts +4 -6
- package/dist/components/BaseDropdown/BaseDropdown.vue.d.ts +3 -5
- package/dist/components/BaseField/BaseField.vue.d.ts +98 -0
- package/dist/components/BaseInput/BaseInput.vue.d.ts +20 -18
- package/dist/components/BaseInputCalendar/BaseInputCalendar.vue.d.ts +17 -19
- package/dist/components/BaseInputCurrency/BaseInputCurrency.vue.d.ts +11 -13
- package/dist/components/BaseInputEmail/BaseInputEmail.vue.d.ts +11 -16
- package/dist/components/BaseInputPhone/BaseInputPhone.vue.d.ts +11 -16
- package/dist/components/BaseOpenedListItem/BaseOpenedListItem.vue.d.ts +3 -5
- package/dist/components/BaseRadio/BaseRadio.vue.d.ts +4 -6
- package/dist/components/BaseSegmentedButtons/BaseSegmentedButtons.vue.d.ts +3 -5
- package/dist/components/BaseSelect/BaseSelect.vue.d.ts +4 -4
- package/dist/components/BaseSiteInput/BaseSiteInput.vue.d.ts +11 -7
- package/dist/components/BaseTag/BaseTag.vue.d.ts +1 -1
- package/dist/components/BaseTextarea/BaseTextarea.vue.d.ts +11 -16
- package/dist/components/BaseToggle/BaseToggle.vue.d.ts +4 -6
- package/dist/components/BaseTooltip/BaseTooltip.vue.d.ts +1 -1
- package/dist/composables/kit/state.d.ts +1 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/components/BaseField/BaseField.vue +184 -0
- package/src/components/BaseField/README.md +85 -0
- package/src/components/BaseInput/BaseInput.vue +162 -228
- package/src/components/BaseInputCalendar/BaseInputCalendar.vue +10 -7
- package/src/components/BaseInputCurrency/BaseInputCurrency.vue +39 -78
- package/src/components/BaseInputEmail/BaseInputEmail.vue +2 -4
- package/src/components/BaseInputPhone/BaseInputPhone.vue +29 -89
- package/src/components/BaseSelect/BaseSelect.vue +9 -52
- package/src/components/BaseSiteInput/BaseSiteInput.vue +11 -63
- package/src/components/BaseTextarea/BaseTextarea.vue +3 -30
- package/src/composables/kit/state.ts +1 -2
- package/src/index.ts +5 -2
- package/src/styles/index.scss +87 -2
- package/src/styles/root.scss +1 -0
- package/src/styles/variables.scss +2 -1
- package/src/types/calendar.d.ts +2 -0
- package/src/types/field.d.ts +12 -0
- package/src/types/input.d.ts +26 -8
- package/src/types/utils.d.ts +0 -1
package/package.json
CHANGED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="base-field" :class="classList">
|
|
3
|
+
<label class="base-field__label" :for="id">
|
|
4
|
+
<span v-if="label" class="base-field__label-text">{{ label }}</span>
|
|
5
|
+
<div class="base-field__wrapper" :class="{ 'base-field__wrapper--focusable': focusable}" :tabindex="tabIndex">
|
|
6
|
+
<slot :data="componentAttrs" />
|
|
7
|
+
</div>
|
|
8
|
+
<transition name="error">
|
|
9
|
+
<div
|
|
10
|
+
v-if="(error && typeof error === 'string') || hint"
|
|
11
|
+
class="base-field__hint"
|
|
12
|
+
aria-live="polite"
|
|
13
|
+
>
|
|
14
|
+
{{ error || hint }}
|
|
15
|
+
</div>
|
|
16
|
+
</transition>
|
|
17
|
+
</label>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup lang="ts">
|
|
22
|
+
import { computed, useAttrs } from 'vue';
|
|
23
|
+
import { useKitSize } from '../../composables/kit/size';
|
|
24
|
+
import { useKitState } from '../../composables/kit/state';
|
|
25
|
+
|
|
26
|
+
import type { TFieldProps } from '../../types/field';
|
|
27
|
+
|
|
28
|
+
interface IDefaultSlotProps {
|
|
29
|
+
id: string;
|
|
30
|
+
error?: string;
|
|
31
|
+
size?: string;
|
|
32
|
+
focusable?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const props = withDefaults(defineProps<TFieldProps>(), {
|
|
36
|
+
size: 'medium',
|
|
37
|
+
id: '',
|
|
38
|
+
label: '',
|
|
39
|
+
hint: '',
|
|
40
|
+
error: '',
|
|
41
|
+
focusable: true,
|
|
42
|
+
tabIndex: 0,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
defineEmits<{
|
|
46
|
+
(event: 'update:modelValue', value: string): void;
|
|
47
|
+
(event: 'error', value: string): void;
|
|
48
|
+
}>();
|
|
49
|
+
|
|
50
|
+
const attrs = useAttrs();
|
|
51
|
+
const { stateAttrs } = useKitState(props);
|
|
52
|
+
const { sizeClassList } = useKitSize(props);
|
|
53
|
+
|
|
54
|
+
const componentAttrs = computed<IDefaultSlotProps>(() => ({
|
|
55
|
+
...(attrs || {}),
|
|
56
|
+
...(stateAttrs.value || {}),
|
|
57
|
+
id: props.id,
|
|
58
|
+
error: props.error,
|
|
59
|
+
size: props.size,
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
const classList = computed(() => [
|
|
63
|
+
...sizeClassList.value,
|
|
64
|
+
{ '--is-error': props.error && typeof props.error === 'string' },
|
|
65
|
+
]);
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<style scoped lang="scss">
|
|
69
|
+
@import '../../styles/variables';
|
|
70
|
+
@import '../../styles/root';
|
|
71
|
+
|
|
72
|
+
.base-field {
|
|
73
|
+
width: 100%;
|
|
74
|
+
|
|
75
|
+
&__wrapper {
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-direction: column;
|
|
78
|
+
width: 100%;
|
|
79
|
+
position: relative;
|
|
80
|
+
transition: all var(--transition);
|
|
81
|
+
|
|
82
|
+
&--focusable {
|
|
83
|
+
@include focused {
|
|
84
|
+
border: 1px solid var(--primary-blue-500);
|
|
85
|
+
outline: 4px solid var(--effects-primary-focus);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&__label {
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-direction: column;
|
|
93
|
+
gap: 6px;
|
|
94
|
+
width: 100%;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
&__label-text {
|
|
98
|
+
color: var(--primary-text-primary);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&__hint {
|
|
102
|
+
color: var(--primary-text-secondary);
|
|
103
|
+
overflow: hidden;
|
|
104
|
+
max-height: 100px;
|
|
105
|
+
transition: all 0.3s ease;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&.--is-error {
|
|
109
|
+
.base-field__wrapper {
|
|
110
|
+
&--focusable {
|
|
111
|
+
@include focused {
|
|
112
|
+
border: none;
|
|
113
|
+
outline: 4px solid var(--effects-error-focus);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.base-field__hint {
|
|
119
|
+
color: var(--error-red);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
&.--small-size {
|
|
124
|
+
.base-field__wrapper {
|
|
125
|
+
border-radius: 10px;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.base-field__label-text {
|
|
129
|
+
font: var(--typography-text-s-medium);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.base-field__hint {
|
|
133
|
+
font: var(--typography-text-s-regular);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
&.--medium-size {
|
|
138
|
+
.base-field__wrapper {
|
|
139
|
+
border-radius: 12px;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.base-field__label-text {
|
|
143
|
+
font: var(--typography-text-s-medium);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.base-field__hint {
|
|
147
|
+
font: var(--typography-text-s-regular);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&.--large-size {
|
|
152
|
+
.base-field__wrapper {
|
|
153
|
+
border-radius: 12px;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.base-field__label-text {
|
|
157
|
+
font: var(--typography-text-m-medium);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.base-field__hint {
|
|
161
|
+
font: var(--typography-text-m-regular);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.error-enter-active,
|
|
167
|
+
.error-leave-active {
|
|
168
|
+
transition: opacity 0.3s ease, max-height 0.3s ease, transform 0.3s ease;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.error-enter-from,
|
|
172
|
+
.error-leave-to {
|
|
173
|
+
opacity: 0;
|
|
174
|
+
transform: translateY(10px);
|
|
175
|
+
max-height: 0;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.error-enter-to,
|
|
179
|
+
.error-leave-from {
|
|
180
|
+
opacity: 1;
|
|
181
|
+
transform: translateY(0);
|
|
182
|
+
max-height: 100px;
|
|
183
|
+
}
|
|
184
|
+
</style>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
BaseField Component
|
|
2
|
+
BaseField — это универсальный компонент-обертка для полей ввода, который предоставляет стилизованную обертку, метку (label), подсказку (hint) и обработку ошибок. Компонент предназначен для использования в связке с другими компонентами ввода, такими как BaseInput, через механизм слотов Vue.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
Использование
|
|
6
|
+
Компонент BaseField используется как обертка для других компонентов ввода, таких как BaseInput. Он предоставляет метку, подсказку и стили для обработки ошибок.
|
|
7
|
+
Пример использования
|
|
8
|
+
<template>
|
|
9
|
+
<BaseField
|
|
10
|
+
id="test-input"
|
|
11
|
+
label="Test Input"
|
|
12
|
+
hint="Enter your text"
|
|
13
|
+
:error="errorValue"
|
|
14
|
+
size="medium"
|
|
15
|
+
>
|
|
16
|
+
<BaseInput
|
|
17
|
+
v-model="inputValue"
|
|
18
|
+
type="text"
|
|
19
|
+
placeholder="Type here"
|
|
20
|
+
id="test-input"
|
|
21
|
+
/>
|
|
22
|
+
</BaseField>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script setup lang="ts">
|
|
26
|
+
import { ref } from 'vue';
|
|
27
|
+
import BaseField from './BaseField.vue';
|
|
28
|
+
import BaseInput from './BaseInput.vue';
|
|
29
|
+
|
|
30
|
+
const inputValue = ref('');
|
|
31
|
+
const errorValue = ref('Input must be at least 3 characters long');
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
События
|
|
36
|
+
|
|
37
|
+
update:modelValue
|
|
38
|
+
value: string
|
|
39
|
+
Эмитируется при обновлении значения поля ввода.
|
|
40
|
+
|
|
41
|
+
error
|
|
42
|
+
value: string
|
|
43
|
+
Эмитируется при возникновении ошибки в поле ввода.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
Слоты
|
|
47
|
+
|
|
48
|
+
default
|
|
49
|
+
Основной слот для размещения компонента ввода (например, BaseInput).
|
|
50
|
+
|
|
51
|
+
Слот передает объект с пропсами, включая componentAttrs, который содержит объединенные атрибуты из useAttrs и stateAttrs.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
Стили
|
|
55
|
+
Компонент использует SCSS для стилизации. Основные классы:
|
|
56
|
+
|
|
57
|
+
.base-field: Основной контейнер компонента.
|
|
58
|
+
.base-field__label: Контейнер для метки и поля ввода.
|
|
59
|
+
.base-field__label-text: Текст метки.
|
|
60
|
+
.base-field__wrapper: Обертка для содержимого слота.
|
|
61
|
+
.base-field__hint: Текст подсказки или ошибки.
|
|
62
|
+
.--is-error: Модификатор для отображения состояния ошибки.
|
|
63
|
+
.--small-size, .--medium-size, .--large-size: Модификаторы для разных размеров.
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
Типизация
|
|
67
|
+
Компонент использует TypeScript и ожидает тип TFieldProps из файла types/field. Пример структуры:
|
|
68
|
+
export interface TFieldProps {
|
|
69
|
+
id?: string;
|
|
70
|
+
label?: string;
|
|
71
|
+
hint?: string;
|
|
72
|
+
error?: string | boolean;
|
|
73
|
+
size?: string;
|
|
74
|
+
focusable?: boolean;
|
|
75
|
+
tabIndex?: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
Примечания
|
|
79
|
+
|
|
80
|
+
Если focusable равно false, атрибут tabindex не применяется, и обертка не будет фокусируемой.
|
|
81
|
+
|
|
82
|
+
Ограничения
|
|
83
|
+
|
|
84
|
+
Компонент предполагает наличие вложенного компонента ввода в слоте (например, BaseInput). Без содержимого слота функциональность ограничена.
|
|
85
|
+
Стили и размеры зависят от внешних переменных и composable-функций, которые должны быть настроены в проекте.
|