plugin-ui-for-kzt 0.0.21 → 0.0.23
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/BaseBadge/BaseBadge.vue.d.ts +1 -1
- package/dist/components/BaseButton/BaseButton.vue.d.ts +1 -3
- package/dist/components/BaseCalendar/BaseCalendar.vue.d.ts +9 -1
- package/dist/components/BaseCheckbox/BaseCheckbox.vue.d.ts +1 -3
- package/dist/components/BaseDropdown/BaseDropdown.vue.d.ts +1 -3
- package/dist/components/BaseField/BaseField.vue.d.ts +98 -0
- package/dist/components/BaseInput/BaseInput.vue.d.ts +19 -17
- package/dist/components/BaseInputCalendar/BaseInputCalendar.vue.d.ts +15 -17
- package/dist/components/BaseInputCurrency/BaseInputCurrency.vue.d.ts +10 -12
- package/dist/components/BaseInputEmail/BaseInputEmail.vue.d.ts +9 -14
- package/dist/components/BaseInputPhone/BaseInputPhone.vue.d.ts +9 -14
- package/dist/components/BaseOpenedListItem/BaseOpenedListItem.vue.d.ts +1 -3
- package/dist/components/BasePagination/BasePagination.vue.d.ts +1 -1
- package/dist/components/BaseRadio/BaseRadio.vue.d.ts +1 -3
- package/dist/components/BaseSegmentedButtons/BaseSegmentedButtons.vue.d.ts +1 -3
- package/dist/components/BaseSelect/BaseSelect.vue.d.ts +1 -1
- package/dist/components/BaseSiteInput/BaseSiteInput.vue.d.ts +11 -7
- package/dist/components/BaseTabs/BaseTabs.vue.d.ts +25 -0
- package/dist/components/BaseTag/BaseTag.vue.d.ts +1 -1
- package/dist/components/BaseTextarea/BaseTextarea.vue.d.ts +9 -14
- package/dist/components/BaseToggle/BaseToggle.vue.d.ts +1 -3
- package/dist/components/BaseTooltip/BaseTooltip.vue.d.ts +1 -1
- package/dist/components/BaseUpload/BaseUpload.vue.d.ts +11 -0
- package/dist/components/BaseUpload/CropModal.vue.d.ts +9 -0
- package/dist/composables/kit/state.d.ts +1 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/dist/index.js.LICENSE.txt +15 -0
- package/example/App.vue +37 -31
- package/example/TestImage.vue +6 -0
- package/package.json +2 -1
- package/src/components/BaseCheckbox/BaseCheckbox.vue +76 -46
- 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/BaseRadio/BaseRadio.vue +266 -233
- package/src/components/BaseSelect/BaseSelect.vue +9 -52
- package/src/components/BaseSiteInput/BaseSiteInput.vue +11 -63
- package/src/components/BaseTabs/BaseTabs.vue +193 -0
- package/src/components/BaseTextarea/BaseTextarea.vue +3 -30
- package/src/components/BaseUpload/BaseUpload.vue +35 -1
- package/src/components/BaseUpload/CropModal.vue +210 -0
- package/src/composables/kit/state.ts +1 -2
- package/src/index.ts +8 -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/tab.d.ts +17 -0
- package/src/types/uploadedFile.d.ts +7 -0
- package/src/types/utils.d.ts +0 -1
|
@@ -1 +1,16 @@
|
|
|
1
1
|
/*! #__NO_SIDE_EFFECTS__ */
|
|
2
|
+
|
|
3
|
+
/*! *****************************************************************************
|
|
4
|
+
Copyright (c) Microsoft Corporation.
|
|
5
|
+
|
|
6
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
7
|
+
purpose with or without fee is hereby granted.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
***************************************************************************** */
|
package/example/App.vue
CHANGED
|
@@ -1,43 +1,49 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="demo-page">
|
|
3
3
|
<h1>Plugin UI KZT - Компоненты</h1>
|
|
4
|
-
<section>
|
|
5
|
-
|
|
6
|
-
v-model="currentSlide"
|
|
7
|
-
:options="options"
|
|
8
|
-
size="extra-small"
|
|
9
|
-
/>
|
|
10
|
-
<br/>
|
|
11
|
-
<base-segmented-buttons
|
|
12
|
-
v-model="currentSlide"
|
|
13
|
-
:options="options"
|
|
14
|
-
size="small"
|
|
15
|
-
/>
|
|
16
|
-
<br/>
|
|
17
|
-
<base-segmented-buttons
|
|
18
|
-
v-model="currentSlide"
|
|
19
|
-
:options="options"
|
|
20
|
-
size="medium"
|
|
21
|
-
/>
|
|
22
|
-
<br/>
|
|
23
|
-
<base-segmented-buttons
|
|
24
|
-
v-model="currentSlide"
|
|
25
|
-
:options="options"
|
|
26
|
-
size="large"
|
|
27
|
-
/>
|
|
4
|
+
<section style="display: flex; flex-direction: column; gap: 10px;">
|
|
5
|
+
<base-upload :enableCrop="true" :crop-texts="{ cancel: 'Cancel', confirm: 'Apply' }" :accepted-formats="accept" :on-update:files="onFilesUpdate" />
|
|
28
6
|
</section>
|
|
29
7
|
</div>
|
|
30
8
|
</template>
|
|
31
9
|
<script setup lang="ts">
|
|
32
|
-
import { ref } from 'vue';
|
|
10
|
+
import { ref, markRaw } from 'vue';
|
|
11
|
+
import TestImage from './TestImage.vue';
|
|
33
12
|
|
|
34
|
-
const
|
|
35
|
-
{ value: '0', label: 'Компоненты', disabled: true },
|
|
36
|
-
{ value: '1', label: 'Композиции' },
|
|
37
|
-
{ value: '2', label: 'Стили' },
|
|
38
|
-
];
|
|
13
|
+
const accept = ['.png', '.jpg', '.jpeg', '.pdf', '.doc', '.docx'];
|
|
39
14
|
|
|
40
|
-
const
|
|
15
|
+
const uploadedFiles = ref<{ name: string; size: number; file: File }[]>([]);
|
|
16
|
+
|
|
17
|
+
const onFilesUpdate = (files: typeof uploadedFiles.value) => {
|
|
18
|
+
uploadedFiles.value = files;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const activeTab = ref(2);
|
|
22
|
+
const options = ref([
|
|
23
|
+
{
|
|
24
|
+
title: 'title 1',
|
|
25
|
+
id: 1,
|
|
26
|
+
icon: markRaw(TestImage),
|
|
27
|
+
disabled: true,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
title: 'title 2',
|
|
31
|
+
id: 2,
|
|
32
|
+
icon: markRaw(TestImage),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: 'title 4',
|
|
36
|
+
id: 4,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
title: 'title 5',
|
|
40
|
+
id: 5,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
title: 'title 6',
|
|
44
|
+
id: 6,
|
|
45
|
+
},
|
|
46
|
+
])
|
|
41
47
|
</script>
|
|
42
48
|
|
|
43
49
|
<style lang="scss" scoped>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path d="M15.7999 2.20999C15.3899 1.79999 14.6799 2.07999 14.6799 2.64999V6.13999C14.6799 7.59999 15.9199 8.80999 17.4299 8.80999C18.3799 8.81999 19.6999 8.81999 20.8299 8.81999C21.3999 8.81999 21.6999 8.14999 21.2999 7.74999C19.8599 6.29999 17.2799 3.68999 15.7999 2.20999Z" fill="currentColor"/>
|
|
4
|
+
<path d="M20.5 10.19H17.61C15.24 10.19 13.31 8.26 13.31 5.89V3C13.31 2.45 12.86 2 12.31 2H8.07C4.99 2 2.5 4 2.5 7.57V16.43C2.5 20 4.99 22 8.07 22H15.93C19.01 22 21.5 20 21.5 16.43V11.19C21.5 10.64 21.05 10.19 20.5 10.19ZM11.5 17.75H7.5C7.09 17.75 6.75 17.41 6.75 17C6.75 16.59 7.09 16.25 7.5 16.25H11.5C11.91 16.25 12.25 16.59 12.25 17C12.25 17.41 11.91 17.75 11.5 17.75ZM13.5 13.75H7.5C7.09 13.75 6.75 13.41 6.75 13C6.75 12.59 7.09 12.25 7.5 12.25H13.5C13.91 12.25 14.25 12.59 14.25 13C14.25 13.41 13.91 13.75 13.5 13.75Z" fill="currentColor"/>
|
|
5
|
+
</svg>
|
|
6
|
+
</template>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plugin-ui-for-kzt",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"description": "plugin-ui for kazaktelekom",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"maska": "^3.1.1",
|
|
52
52
|
"pinia": "^2.3.1",
|
|
53
53
|
"vue": "^3.0.0",
|
|
54
|
+
"vue-advanced-cropper": "^2.8.9",
|
|
54
55
|
"vue-virtual-scroller": "^2.0.0-beta.8"
|
|
55
56
|
}
|
|
56
57
|
}
|
|
@@ -4,29 +4,25 @@
|
|
|
4
4
|
:class="classList"
|
|
5
5
|
>
|
|
6
6
|
<div class="base-checkbox__wrapper" @click="handleToggle">
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class="base-checkbox__input"
|
|
14
|
-
/>
|
|
15
|
-
</div>
|
|
16
|
-
|
|
17
|
-
<div class="base-checkbox__icon-wrapper">
|
|
18
|
-
<base-icon
|
|
19
|
-
class="base-checkbox__icon"
|
|
20
|
-
name="checkbox"
|
|
21
|
-
:size="size"
|
|
7
|
+
<div class="base-checkbox__input-wrapper">
|
|
8
|
+
<input
|
|
9
|
+
v-model="model"
|
|
10
|
+
v-bind="inputAttrs"
|
|
11
|
+
type="checkbox"
|
|
12
|
+
class="base-checkbox__input"
|
|
22
13
|
/>
|
|
14
|
+
<div class="base-checkbox__icon-wrapper">
|
|
15
|
+
<base-icon
|
|
16
|
+
class="base-checkbox__icon"
|
|
17
|
+
name="checkbox"
|
|
18
|
+
size="custom"
|
|
19
|
+
/>
|
|
20
|
+
</div>
|
|
23
21
|
</div>
|
|
24
|
-
|
|
25
22
|
<div class="base-checkbox__label-wrapper">
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
</div>
|
|
23
|
+
<span v-if="label" class="base-checkbox__label">{{ label }}</span>
|
|
24
|
+
<span v-if="subLabel" class="base-checkbox__sublabel">{{ subLabel }}</span>
|
|
25
|
+
</div>
|
|
30
26
|
</div>
|
|
31
27
|
</div>
|
|
32
28
|
</template>
|
|
@@ -39,42 +35,42 @@ import { useAttrs, computed } from 'vue';
|
|
|
39
35
|
import BaseIcon from '../BaseIcon/BaseIcon.vue';
|
|
40
36
|
|
|
41
37
|
const props = withDefaults(defineProps<IBaseRadioProps>(), {
|
|
42
|
-
|
|
38
|
+
size: 'medium',
|
|
43
39
|
});
|
|
44
40
|
|
|
45
41
|
const emit = defineEmits<{
|
|
46
|
-
|
|
42
|
+
(e: 'update:modelValue', value: boolean): void;
|
|
47
43
|
}>();
|
|
48
44
|
|
|
49
45
|
const { sizeClassList } = useKitSize(props);
|
|
50
46
|
const { stateClassList, stateAttrs } = useKitState(props);
|
|
51
47
|
|
|
52
48
|
const model = computed({
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
get: () => props.modelValue,
|
|
50
|
+
set: (val) => emit('update:modelValue', val),
|
|
55
51
|
});
|
|
56
52
|
|
|
57
53
|
const attrs = useAttrs();
|
|
58
54
|
|
|
59
55
|
const inputAttrs = computed(() => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
return {
|
|
57
|
+
...attrs,
|
|
58
|
+
...stateAttrs.value,
|
|
59
|
+
id: props.id,
|
|
60
|
+
};
|
|
65
61
|
});
|
|
66
62
|
|
|
67
63
|
function handleToggle() {
|
|
68
|
-
|
|
64
|
+
model.value = !model.value;
|
|
69
65
|
}
|
|
70
66
|
|
|
71
67
|
const classList = computed(() => [
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
sizeClassList.value,
|
|
69
|
+
stateClassList.value,
|
|
70
|
+
{
|
|
71
|
+
'--is-active': model.value,
|
|
72
|
+
'--is-readonly': props.readonly,
|
|
73
|
+
},
|
|
78
74
|
]);
|
|
79
75
|
</script>
|
|
80
76
|
|
|
@@ -85,8 +81,6 @@ const classList = computed(() => [
|
|
|
85
81
|
.base-checkbox {
|
|
86
82
|
$item: &;
|
|
87
83
|
|
|
88
|
-
--icon-size: 18px;
|
|
89
|
-
|
|
90
84
|
&__wrapper {
|
|
91
85
|
display: flex;
|
|
92
86
|
column-gap: 10px;
|
|
@@ -99,31 +93,36 @@ const classList = computed(() => [
|
|
|
99
93
|
pointer-events: none;
|
|
100
94
|
}
|
|
101
95
|
|
|
102
|
-
&.--
|
|
96
|
+
&.--small-size {
|
|
103
97
|
#{$item} {
|
|
104
98
|
&__wrapper {
|
|
105
|
-
column-gap: var(--spacing-
|
|
99
|
+
column-gap: var(--spacing-s);
|
|
106
100
|
}
|
|
107
101
|
|
|
108
102
|
&__label {
|
|
109
|
-
font: var(--typography-text-
|
|
103
|
+
font: var(--typography-text-s-medium);
|
|
110
104
|
}
|
|
111
105
|
|
|
112
106
|
&__sublabel {
|
|
113
|
-
font: var(--typography-text-
|
|
107
|
+
font: var(--typography-text-xs-regular);
|
|
114
108
|
}
|
|
115
109
|
|
|
116
110
|
&__icon-wrapper {
|
|
117
|
-
width:
|
|
118
|
-
height:
|
|
111
|
+
width: 20px;
|
|
112
|
+
height: 20px;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&__icon {
|
|
116
|
+
width: 15px;
|
|
117
|
+
height: 15px;
|
|
119
118
|
}
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
|
|
123
|
-
&.--
|
|
122
|
+
&.--medium-size {
|
|
124
123
|
#{$item} {
|
|
125
124
|
&__wrapper {
|
|
126
|
-
column-gap: var(--spacing-
|
|
125
|
+
column-gap: var(--spacing-m);
|
|
127
126
|
}
|
|
128
127
|
|
|
129
128
|
&__label {
|
|
@@ -138,6 +137,37 @@ const classList = computed(() => [
|
|
|
138
137
|
width: 24px;
|
|
139
138
|
height: 24px;
|
|
140
139
|
}
|
|
140
|
+
|
|
141
|
+
&__icon {
|
|
142
|
+
width: 18px;
|
|
143
|
+
height: 18px;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
&.--large-size {
|
|
149
|
+
#{$item} {
|
|
150
|
+
&__wrapper {
|
|
151
|
+
column-gap: var(--spacing-l);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
&__label {
|
|
155
|
+
font: var(--typography-text-m-medium);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
&__sublabel {
|
|
159
|
+
font: var(--typography-text-s-regular);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
&__icon-wrapper {
|
|
163
|
+
width: 32px;
|
|
164
|
+
height: 32px;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
&__icon {
|
|
168
|
+
width: 22.4px;
|
|
169
|
+
height: 22.4px;
|
|
170
|
+
}
|
|
141
171
|
}
|
|
142
172
|
}
|
|
143
173
|
|
|
@@ -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-функций, которые должны быть настроены в проекте.
|