plugin-ui-for-kzt 0.0.18 → 0.0.20
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/BaseCalendar/BaseCalendar.vue.d.ts +9 -1
- package/dist/components/BaseField/BaseField.vue.d.ts +98 -0
- package/dist/components/BaseInput/BaseInput.vue.d.ts +16 -14
- package/dist/components/BaseInputCalendar/BaseInputCalendar.vue.d.ts +13 -15
- package/dist/components/BaseInputCurrency/BaseInputCurrency.vue.d.ts +7 -9
- package/dist/components/BaseInputEmail/BaseInputEmail.vue.d.ts +7 -12
- package/dist/components/BaseInputPhone/BaseInputPhone.vue.d.ts +7 -12
- package/dist/components/BaseSiteInput/BaseSiteInput.vue.d.ts +11 -7
- package/dist/components/BaseTextarea/BaseTextarea.vue.d.ts +7 -12
- package/dist/components/BaseTooltip/BaseTooltip.vue.d.ts +1 -1
- package/dist/composables/kit/state.d.ts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/example/App.vue +172 -133
- 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 +161 -210
- package/src/components/BaseInputCalendar/BaseInputCalendar.vue +10 -7
- package/src/components/BaseInputCurrency/BaseInputCurrency.vue +56 -54
- package/src/components/BaseInputEmail/BaseInputEmail.vue +2 -4
- package/src/components/BaseInputPhone/BaseInputPhone.vue +29 -48
- package/src/components/BaseSelect/BaseSelect.vue +9 -52
- package/src/components/BaseSiteInput/BaseSiteInput.vue +10 -20
- package/src/components/BaseTextarea/BaseTextarea.vue +3 -30
- package/src/components/BaseUpload/BaseUpload.vue +1 -1
- package/src/composables/kit/state.ts +1 -1
- 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/webpack.config.js +1 -1
package/example/App.vue
CHANGED
|
@@ -3,157 +3,196 @@
|
|
|
3
3
|
<h1>Plugin UI KZT - Компоненты</h1>
|
|
4
4
|
<p>Ниже представлены все компоненты библиотеки с примерами их использования.</p>
|
|
5
5
|
<section>
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
text="base tag"
|
|
14
|
-
size="medium"
|
|
15
|
-
closable
|
|
16
|
-
@close="console.log('Tag closed')"
|
|
17
|
-
/>
|
|
18
|
-
<base-tag
|
|
19
|
-
text="base tag"
|
|
20
|
-
size="large"
|
|
21
|
-
addingTag
|
|
22
|
-
@addTag="console.log('New tag added:')"
|
|
23
|
-
/>
|
|
24
|
-
<base-tag
|
|
25
|
-
isHasAddTag
|
|
26
|
-
@updateInput="console.log(' tag added:', $event)"
|
|
27
|
-
/>
|
|
28
|
-
</div>
|
|
29
|
-
</section>
|
|
30
|
-
<section>
|
|
31
|
-
<h2>BaseBadgeGroup.vue</h2>
|
|
32
|
-
|
|
33
|
-
<base-badge-group
|
|
34
|
-
size="medium"
|
|
35
|
-
color="primary"
|
|
36
|
-
badge-position="right"
|
|
6
|
+
<BaseField
|
|
7
|
+
size="large"
|
|
8
|
+
id="BaseInputEmail"
|
|
9
|
+
label="BaseInputEmail"
|
|
10
|
+
:focusable="false"
|
|
11
|
+
:tabIndex="8"
|
|
12
|
+
:error="errorValue"
|
|
37
13
|
>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
14
|
+
<template #default="data">
|
|
15
|
+
<BaseInputEmail
|
|
16
|
+
id="BaseInputEmail"
|
|
17
|
+
v-model="calendarModel"
|
|
18
|
+
label="Select date hereBaseInputEmail"
|
|
19
|
+
placeholder="Select date"
|
|
20
|
+
:error="data.error"
|
|
21
|
+
:size="data.size"
|
|
22
|
+
/>
|
|
43
23
|
</template>
|
|
44
|
-
|
|
45
|
-
<
|
|
46
|
-
size="
|
|
47
|
-
|
|
48
|
-
|
|
24
|
+
</BaseField>
|
|
25
|
+
<BaseField
|
|
26
|
+
size="small"
|
|
27
|
+
id="calendar-input"
|
|
28
|
+
label="calendar Input"
|
|
29
|
+
:tabIndex="7"
|
|
30
|
+
:error="errorValue"
|
|
49
31
|
>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
32
|
+
<template #default="data">
|
|
33
|
+
<base-input-calendar
|
|
34
|
+
id="calendar"
|
|
35
|
+
v-model="calendarModel"
|
|
36
|
+
label="Select date here"
|
|
37
|
+
:size="data.size"
|
|
38
|
+
placeholder="Select date"
|
|
39
|
+
:error="data.error"
|
|
40
|
+
:min-date="new Date()"
|
|
41
|
+
@validationError="handleError"
|
|
42
|
+
/>
|
|
55
43
|
</template>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
class="badge-example"
|
|
64
|
-
closable
|
|
65
|
-
>
|
|
66
|
-
<template #text>Пример бейджа</template>
|
|
67
|
-
</base-badge>
|
|
68
|
-
<base-badge
|
|
69
|
-
size="small"
|
|
70
|
-
color="gray"
|
|
71
|
-
class="badge-example"
|
|
72
|
-
has-dot
|
|
44
|
+
</BaseField>
|
|
45
|
+
<BaseField
|
|
46
|
+
size="medium"
|
|
47
|
+
id="textarea-input"
|
|
48
|
+
label="text Input"
|
|
49
|
+
:tabIndex="6"
|
|
50
|
+
:error="errorValue"
|
|
73
51
|
>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
52
|
+
<template #default="data">
|
|
53
|
+
<BaseTextarea
|
|
54
|
+
:size="data.size"
|
|
55
|
+
v-model="inputValue"
|
|
56
|
+
id="textarea-input"
|
|
57
|
+
:error="data.error"
|
|
58
|
+
>
|
|
59
|
+
</BaseTextarea>
|
|
60
|
+
</template>
|
|
61
|
+
</BaseField>
|
|
62
|
+
<BaseField
|
|
63
|
+
size="medium"
|
|
64
|
+
id="select-input"
|
|
65
|
+
label="select input"
|
|
66
|
+
:tabIndex="5"
|
|
67
|
+
:error="errorValue"
|
|
81
68
|
>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
69
|
+
<template #default="data">
|
|
70
|
+
<BaseSelect
|
|
71
|
+
:size="data.size"
|
|
72
|
+
v-model="selectValue"
|
|
73
|
+
:options="options"
|
|
74
|
+
id="select-input"
|
|
75
|
+
:error="data.error"
|
|
76
|
+
>
|
|
77
|
+
<template #left-icon>
|
|
78
|
+
<BaseIcon name="star" />
|
|
79
|
+
</template>
|
|
80
|
+
<template #right-icon>
|
|
81
|
+
<BaseIcon name="close" />
|
|
82
|
+
</template>
|
|
83
|
+
</BaseSelect>
|
|
84
|
+
</template>
|
|
85
|
+
</BaseField>
|
|
86
|
+
<BaseField
|
|
87
|
+
size="medium"
|
|
88
|
+
id="BaseInput "
|
|
89
|
+
label="BaseInput "
|
|
90
|
+
:tabIndex="0"
|
|
91
|
+
:error="errorValue"
|
|
89
92
|
>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
<template #default="data">
|
|
94
|
+
<BaseInput
|
|
95
|
+
:size="data.size"
|
|
96
|
+
v-model="inputValue"
|
|
97
|
+
type="text"
|
|
98
|
+
placeholder="Type here"
|
|
99
|
+
id="BaseInput "
|
|
100
|
+
:error="data.error"
|
|
101
|
+
>
|
|
102
|
+
<template #left-icon>
|
|
103
|
+
<BaseIcon name="star" />
|
|
104
|
+
</template>
|
|
105
|
+
<template #right-icon>
|
|
106
|
+
<BaseIcon name="close" />
|
|
107
|
+
</template>
|
|
108
|
+
</BaseInput>
|
|
109
|
+
</template>
|
|
110
|
+
</BaseField>
|
|
111
|
+
<BaseField
|
|
112
|
+
size="medium"
|
|
113
|
+
id="input-phone"
|
|
114
|
+
label="input-phone"
|
|
115
|
+
:tabIndex="1"
|
|
116
|
+
:error="errorValue"
|
|
96
117
|
>
|
|
97
|
-
|
|
98
|
-
<
|
|
118
|
+
<template #default="data">
|
|
119
|
+
<BaseInputPhone
|
|
120
|
+
:size="data.size"
|
|
121
|
+
v-model="inputValue4"
|
|
122
|
+
type="text"
|
|
123
|
+
placeholder="Type here"
|
|
124
|
+
id="phone-input"
|
|
125
|
+
:error="`${data.error}`"
|
|
126
|
+
:focusable="false"
|
|
127
|
+
/>
|
|
99
128
|
</template>
|
|
100
|
-
|
|
101
|
-
</section>
|
|
129
|
+
</BaseField>
|
|
102
130
|
|
|
103
|
-
<
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
v-model:current-slide="currentSlide"
|
|
122
|
-
/>
|
|
123
|
-
<!-- :autoplay="true"
|
|
124
|
-
:autoplay-interval="2000" -->
|
|
125
|
-
</div>
|
|
126
|
-
<section>
|
|
127
|
-
medium size
|
|
128
|
-
<base-textarea class="text-area" size="medium" placeholder="test"></base-textarea>
|
|
129
|
-
</section>
|
|
130
|
-
</section>
|
|
131
|
-
<section style="height: 300px;">
|
|
132
|
-
<p></p>
|
|
133
|
-
<base-textarea class="text-area" size="custom" placeholder="test"></base-textarea>
|
|
134
|
-
</section>
|
|
131
|
+
<BaseField
|
|
132
|
+
size="medium"
|
|
133
|
+
id="BaseInputCurrency"
|
|
134
|
+
label="BaseInputCurrency"
|
|
135
|
+
:tabIndex="2"
|
|
136
|
+
:error="errorValue"
|
|
137
|
+
>
|
|
138
|
+
<template #default="data">
|
|
139
|
+
<BaseInputCurrency
|
|
140
|
+
:size="data.size"
|
|
141
|
+
v-model="inputValue3"
|
|
142
|
+
type="text"
|
|
143
|
+
placeholder="Type here"
|
|
144
|
+
id="BaseInputCurrency"
|
|
145
|
+
:error="`${data.error}`"
|
|
146
|
+
/>
|
|
147
|
+
</template>
|
|
148
|
+
</BaseField>
|
|
135
149
|
|
|
136
|
-
<
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
150
|
+
<BaseField
|
|
151
|
+
size="medium"
|
|
152
|
+
id="BaseSiteInput"
|
|
153
|
+
label="BaseSiteInput"
|
|
154
|
+
:tabIndex="3"
|
|
155
|
+
:focusable="false"
|
|
156
|
+
:error="errorValue"
|
|
157
|
+
>
|
|
158
|
+
<template #default="data">
|
|
159
|
+
<BaseSiteInput
|
|
160
|
+
:size="data.size"
|
|
161
|
+
v-model="inputValue3"
|
|
162
|
+
placeholder="write site url"
|
|
163
|
+
id="BaseSiteInput"
|
|
164
|
+
:error="`${data.error}`"
|
|
165
|
+
/>
|
|
166
|
+
</template>
|
|
167
|
+
</BaseField>
|
|
168
|
+
|
|
140
169
|
</section>
|
|
141
170
|
</div>
|
|
142
171
|
</template>
|
|
143
172
|
<script setup lang="ts">
|
|
144
|
-
import { ref } from 'vue';
|
|
145
|
-
import { useModal } from '../src/composables/useModal';
|
|
146
|
-
import MyCustomModal from './MyCustomModal.vue';
|
|
173
|
+
import { ref, watch } from 'vue';
|
|
147
174
|
|
|
148
|
-
const
|
|
175
|
+
const inputValue = ref('as');
|
|
176
|
+
const selectValue = ref('');
|
|
177
|
+
const options = ref([
|
|
178
|
+
{ id: '1', name: 'Option 1', value: 'option1' },
|
|
179
|
+
{ id: '2', name: 'Option 2', value: 'option2' },
|
|
180
|
+
{ id: '3', name: 'Option 3', value: 'option3' },
|
|
181
|
+
]);
|
|
182
|
+
const inputValue3 = ref('');
|
|
183
|
+
const calendarModel = ref('');
|
|
184
|
+
const inputValue4 = ref('');
|
|
185
|
+
const errorValue = ref('');
|
|
186
|
+
errorValue.value = errorValue.value.length < 3 ? 'Input must be at least 3 characters long' : '';
|
|
187
|
+
watch(inputValue, (newValue) => {
|
|
188
|
+
console.log('Input 1 value changed:', newValue);
|
|
189
|
+
errorValue.value = newValue.length < 3 ? 'Input must be at least 3 characters long' : '';
|
|
190
|
+
});
|
|
149
191
|
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
modal.open('myModal', { closable: true }, MyCustomModal);
|
|
192
|
+
const handleError = (value: string) => {
|
|
193
|
+
console.error('Validation error:', value);
|
|
194
|
+
errorValue.value = value;
|
|
154
195
|
};
|
|
155
|
-
|
|
156
|
-
const currentSlide = ref(0);
|
|
157
196
|
</script>
|
|
158
197
|
|
|
159
198
|
<style lang="scss" scoped>
|
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-функций, которые должны быть настроены в проекте.
|