plugin-ui-for-kzt 0.0.18 → 0.0.19

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/example/App.vue CHANGED
@@ -3,29 +3,14 @@
3
3
  <h1>Plugin UI KZT - Компоненты</h1>
4
4
  <p>Ниже представлены все компоненты библиотеки с примерами их использования.</p>
5
5
  <section>
6
- <h2>BaseTag.vue</h2>
7
- <div style="display: flex;
8
- gap: 8px;
9
- align-items: center;">
10
- <base-tag size="extra-small" text="base tag" />
11
- <base-tag size="small" color="secondary" text="base tag secondary" />
12
- <base-tag
13
- text="base tag"
14
- size="medium"
15
- closable
16
- @close="console.log('Tag closed')"
17
- />
18
- <base-tag
19
- text="base tag"
6
+ <base-site-input
7
+ id="phone-input"
8
+ v-model="phoneNumber"
20
9
  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>
10
+ placeholder="Введите номер телефона"
11
+ :error="phoneError"
12
+ hint="Номер телефона должен быть не менее 5 символов"
13
+ />
29
14
  </section>
30
15
  <section>
31
16
  <h2>BaseBadgeGroup.vue</h2>
@@ -141,11 +126,23 @@
141
126
  </div>
142
127
  </template>
143
128
  <script setup lang="ts">
144
- import { ref } from 'vue';
129
+ import { ref, watch } from 'vue';
145
130
  import { useModal } from '../src/composables/useModal';
146
131
  import MyCustomModal from './MyCustomModal.vue';
147
132
 
148
- const accept = ['image/*']
133
+ const accept = ['.jpg', '.pdf']
134
+ const phoneNumber = ref('');
135
+ const phoneError = ref('');
136
+ watch(phoneNumber, (newValue) => {
137
+ console.log('Новый номер телефона:', newValue.length);
138
+ if (newValue.length > 17) {
139
+ console.log('Номер телефона должен быть не менее 5 символов');
140
+ phoneError.value = 'Некорректный номер телефона';
141
+ } else {
142
+ console.log('Номер телефона корректен');
143
+ phoneError.value = '';
144
+ }
145
+ });
149
146
 
150
147
  const modal = useModal();
151
148
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plugin-ui-for-kzt",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "description": "plugin-ui for kazaktelekom",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,9 +24,11 @@
24
24
  </div>
25
25
  </div>
26
26
 
27
- <div v-if="(error && typeof error === 'string') || hint" class="base-input__hint">
28
- {{ error || hint }}
29
- </div>
27
+ <transition name="error">
28
+ <div v-if="(error && typeof error === 'string') || hint" class="base-input__hint">
29
+ {{ error || hint }}
30
+ </div>
31
+ </transition>
30
32
  </label>
31
33
  </div>
32
34
  </template>
@@ -132,6 +134,10 @@ function handleInput(event: Event) {
132
134
  color: var(--primary-black-500);
133
135
  }
134
136
 
137
+ &__hint {
138
+ transition: opacity 0.3s ease, transform 0.3s ease;
139
+ }
140
+
135
141
  @include is-disabled-state {
136
142
  #{$input}__icon--right {
137
143
  color: var(--primary-black-400);
@@ -299,4 +305,15 @@ function handleInput(event: Event) {
299
305
  }
300
306
  }
301
307
  }
308
+ .error-enter-active,
309
+ .error-leave-active {
310
+ transition: opacity 0.3s ease, transform 0.3s ease;
311
+ }
312
+
313
+ .error-enter-from,
314
+ .error-leave-to {
315
+ opacity: 0;
316
+ transform: translateY(10px);
317
+ max-height: 0;
318
+ }
302
319
  </style>
@@ -1,32 +1,31 @@
1
1
  <template>
2
- <div :class="classList">
3
- <div class="base-input-currency__wrapper">
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>
2
+ <div :class="classList">
3
+ <div class="base-input-currency__wrapper">
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"
23
+ :size="size"
24
+ :error="error"
25
+ class="base-input-currency__select"
26
+ />
27
+ </div>
18
28
  </div>
19
- <base-select
20
- id="select-currency"
21
- v-model="selectedOptionId"
22
- :options="optionsCurrency"
23
- :size="size"
24
- :error="error"
25
- class="base-input-currency__select"
26
- >
27
- </base-select>
28
- </div>
29
- </div>
30
29
  </template>
31
30
 
32
31
  <script setup lang="ts">
@@ -39,21 +38,21 @@ import { useKitSize } from '../../composables/kit/size';
39
38
  import type { ICoreInputProps } from '../../types/input';
40
39
 
41
40
  const props = withDefaults(defineProps<ICoreInputProps>(), {
42
- size: 'medium',
43
- type: 'text',
44
- modelValue: '',
45
- placeholder: '0.00',
46
- error: '',
47
- hint: '',
41
+ size: 'medium',
42
+ type: 'text',
43
+ modelValue: '',
44
+ placeholder: '0.00',
45
+ error: '',
46
+ hint: '',
48
47
  });
49
48
 
50
49
  const emit: (event: 'update:modelValue', value: string) => void = defineEmits();
51
50
 
52
51
  const optionsCurrency = ref([
53
- { id: '1', name: 'KZT', value: 'kzt', mask: '# ##0.##', symbol: '₸' },
54
- { id: '2', name: 'RUB', value: 'rub', mask: '# ##0.##', symbol: '₽' },
55
- { id: '3', name: 'KGS', value: 'kgs', mask: '# ##0.##', symbol: '⃀' },
56
- { id: '4', name: 'UZS', value: 'uzs', mask: '# ##0.##', symbol: 'сў' },
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
58
  const selectedOption = ref(optionsCurrency.value[0]);
@@ -61,10 +60,10 @@ const selectedOption = ref(optionsCurrency.value[0]);
61
60
  const selectedOptionId = ref(selectedOption.value.id);
62
61
 
63
62
  watch(selectedOptionId, (newId) => {
64
- const newOption = optionsCurrency.value.find((option) => option.id === newId);
65
- if (newOption) {
66
- selectedOption.value = newOption;
67
- }
63
+ const newOption = optionsCurrency.value.find((option) => option.id === newId);
64
+ if (newOption) {
65
+ selectedOption.value = newOption;
66
+ }
68
67
  });
69
68
 
70
69
  const { stateClassList, stateAttrs } = useKitState(props);
@@ -72,27 +71,30 @@ const { sizeClassList } = useKitSize(props);
72
71
  const attrs = useAttrs();
73
72
 
74
73
  const componentAttrs = computed(() => ({
75
- ...attrs,
76
- ...stateAttrs.value,
77
- label: props.label,
78
- error: props.error,
79
- hint: props.hint,
80
- placeholder: props.placeholder,
74
+ ...attrs,
75
+ ...stateAttrs.value,
76
+ label: props.label,
77
+ error: props.error,
78
+ hint: props.hint,
79
+ placeholder: props.placeholder,
81
80
  }));
82
81
 
83
82
  const classList = computed(() => [
84
- stateClassList.value,
85
- sizeClassList.value,
86
- 'base-input-currency',
83
+ stateClassList.value,
84
+ sizeClassList.value,
85
+ 'base-input-currency',
86
+ {
87
+ '--is-has-hint': !!props.hint,
88
+ }
87
89
  ]);
88
90
 
89
91
  const modelValue = computed({
90
- get: () => props.modelValue,
91
- set: (value) => emit('update:modelValue', value),
92
+ get: () => props.modelValue,
93
+ set: (value) => emit('update:modelValue', value),
92
94
  });
93
95
 
94
96
  const handleInput = (value: string) => {
95
- emit('update:modelValue', value);
97
+ emit('update:modelValue', value);
96
98
  };
97
99
  </script>
98
100
 
@@ -151,13 +153,26 @@ width: 100%;
151
153
  }
152
154
 
153
155
  &.--small-size {
156
+ &.--is-has-hint {
157
+ #{$input} {
158
+ &__select {
159
+ margin-bottom: 26px;
160
+ }
161
+ }
162
+ }
163
+
154
164
  #{$input} {
155
165
  :deep(.base-select) {
156
166
  width: 71px;
157
167
  }
168
+
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,13 +181,26 @@ 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;
172
195
  }
196
+
173
197
  &__symbol {
174
198
  font-size: var(--typography-text-m-regular);
175
199
  }
200
+
201
+ &.--is-error {
202
+ margin-bottom: 26px;
203
+ }
176
204
  }
177
205
 
178
206
  :deep(.base-input__field) {
@@ -181,13 +209,26 @@ width: 100%;
181
209
  }
182
210
 
183
211
  &.--large-size {
212
+ &.--is-has-hint {
213
+ #{$input} {
214
+ &__select {
215
+ margin-bottom: 30px;
216
+ }
217
+ }
218
+ }
219
+
184
220
  #{$input} {
185
221
  :deep(.base-select) {
186
222
  width: 87px;
187
223
  }
224
+
188
225
  &__symbol {
189
226
  font-size: var(--typography-text-l-regular);
190
227
  }
228
+
229
+ &.--is-error {
230
+ margin-bottom: 30px;
231
+ }
191
232
  }
192
233
 
193
234
  :deep(.base-input__field) {
@@ -90,6 +90,9 @@ const classList = computed(() => [
90
90
  stateClassList.value,
91
91
  sizeClassList.value,
92
92
  'base-input-phone',
93
+ {
94
+ '--is-has-hint': !!props.hint,
95
+ }
93
96
  ]);
94
97
 
95
98
  const modelValue = computed({
@@ -140,10 +143,24 @@ const handleInput = (value: string) => {
140
143
  }
141
144
 
142
145
  &.--small-size {
146
+ &.--is-has-hint {
147
+ #{$input} {
148
+ &__select {
149
+ margin-bottom: 26px;
150
+ }
151
+ }
152
+ }
153
+
143
154
  #{$input} {
144
155
  :deep(.base-select) {
145
156
  width: 71px;
146
157
  }
158
+
159
+ &__select {
160
+ &.--is-error {
161
+ margin-bottom: 26px;
162
+ }
163
+ }
147
164
  }
148
165
  :deep(.base-input__label-text),
149
166
  :deep(.base-input__hint) {
@@ -152,9 +169,21 @@ const handleInput = (value: string) => {
152
169
  }
153
170
 
154
171
  &.--medium-size {
172
+ &.--is-has-hint {
173
+ #{$input} {
174
+ &__select {
175
+ margin-bottom: 26px;
176
+ }
177
+ }
178
+ }
179
+
155
180
  #{$input} {
156
181
  &__select {
157
182
  width: 75px;
183
+
184
+ &.--is-error {
185
+ margin-bottom: 26px;
186
+ }
158
187
  }
159
188
  }
160
189
 
@@ -165,9 +194,21 @@ const handleInput = (value: string) => {
165
194
  }
166
195
 
167
196
  &.--large-size {
197
+ &.--is-has-hint {
198
+ #{$input} {
199
+ &__select {
200
+ margin-bottom: 30px;
201
+ }
202
+ }
203
+ }
204
+
168
205
  #{$input} {
169
206
  &__select {
170
207
  width: 87px;
208
+
209
+ &.--is-error {
210
+ margin-bottom: 30px;
211
+ }
171
212
  }
172
213
  }
173
214
 
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div :class="classList">
3
3
  <div class="base-site-input__wrapper">
4
- <div class="base-site-input__url-wrapper">
4
+ <div :class="{ '--is-error' : urlError }" class="base-site-input__url-wrapper">
5
5
  <span class="base-site-input__url">
6
6
  https://
7
7
  </span>
@@ -22,6 +22,7 @@
22
22
  import { computed, ref, watch } from 'vue';
23
23
  import BaseInput from '../BaseInput/BaseInput.vue';
24
24
  import { useKitSize } from '../../composables/kit/size'
25
+ import { useKitState } from '../../composables/kit/state';
25
26
  import type { ICorePropsBaseSiteInput } from '../../types/input'
26
27
 
27
28
  const props = withDefaults(defineProps<ICorePropsBaseSiteInput>(),{
@@ -36,10 +37,15 @@ const emit = defineEmits<{
36
37
 
37
38
  const urlError = ref('');
38
39
  const { sizeClassList } = useKitSize(props);
40
+ const { stateClassList } = useKitState(props);
39
41
 
40
42
  const classList = computed(() => [
41
43
  sizeClassList.value,
44
+ stateClassList.value,
42
45
  'base-site-input',
46
+ {
47
+ '--is-has-hint': !!props.hint,
48
+ }
43
49
  ]);
44
50
 
45
51
  const normalizedValue = computed(() => {
@@ -108,12 +114,24 @@ watch(modelValue, (value) => {
108
114
  }
109
115
 
110
116
  &.--small-size {
117
+ &.--is-has-hint, &.--is-error {
118
+ #{$input} {
119
+ &__url-wrapper {
120
+ margin-bottom: 26px;
121
+ }
122
+ }
123
+ }
124
+
111
125
  #{$input} {
112
126
  &__url-wrapper{
113
127
  height: 40px;
114
128
  font: var(--typography-text-m-regular);
115
129
  border-top-left-radius: var(--corner-radius-s);
116
130
  border-bottom-left-radius: var(--corner-radius-s);
131
+
132
+ &.--is-error {
133
+ margin-bottom: 26px;
134
+ }
117
135
  }
118
136
 
119
137
  &__url {
@@ -128,12 +146,24 @@ watch(modelValue, (value) => {
128
146
  }
129
147
 
130
148
  &.--medium-size {
149
+ &.--is-has-hint, &.--is-error {
150
+ #{$input} {
151
+ &__url-wrapper {
152
+ margin-bottom: 26px;
153
+ }
154
+ }
155
+ }
156
+
131
157
  #{$input} {
132
158
  &__url-wrapper{
133
159
  height: 48px;
134
160
  font: var(--typography-text-m-regular);
135
161
  border-top-left-radius: var(--corner-radius-m);
136
162
  border-bottom-left-radius: var(--corner-radius-m);
163
+
164
+ &.--is-error {
165
+ margin-bottom: 26px;
166
+ }
137
167
  }
138
168
 
139
169
  &__url {
@@ -148,12 +178,24 @@ watch(modelValue, (value) => {
148
178
  }
149
179
 
150
180
  &.--large-size {
181
+ &.--is-has-hint, &.--is-error {
182
+ #{$input} {
183
+ &__url-wrapper {
184
+ margin-bottom: 30px;
185
+ }
186
+ }
187
+ }
188
+
151
189
  #{$input} {
152
190
  &__url-wrapper{
153
191
  height: 56px;
154
192
  font: var(--typography-text-l-regular);
155
193
  border-top-left-radius: var(--corner-radius-m);
156
194
  border-bottom-left-radius: var(--corner-radius-m);
195
+
196
+ &.--is-error {
197
+ margin-bottom: 30px;
198
+ }
157
199
  }
158
200
 
159
201
  &__url {
@@ -152,7 +152,7 @@ const handleFileUpload = (event: Event) => {
152
152
  Array.from(files).forEach((file) => {
153
153
  const fileExtension = `.${file.name.split('.').pop()?.toLowerCase() || ''}`;
154
154
  if (!props.acceptedFormats.includes(fileExtension)) {
155
- errorMessage.value = `Недопустимый формат файла: ${file.name}. Допустимы: ${props.acceptedFormats.join(', ')}.`;
155
+ errorMessage.value = `Недопустимый формат файла: ${file.name}. Допустимый: ${props.acceptedFormats.join(', ')}.`;
156
156
  return;
157
157
  }
158
158
 
@@ -11,6 +11,7 @@ export function useKitState(props: ICoreState) {
11
11
  '--is-error': props.error,
12
12
  '--is-loading': props.loading,
13
13
  '--is-disabled': props.disabled,
14
+ '--is-has-hint': props.hint,
14
15
  },
15
16
  ]);
16
17
 
@@ -28,6 +28,7 @@ export interface ICoreState {
28
28
  required?: boolean
29
29
  error?: Nullable<string | number | boolean> | undefined
30
30
  loading?: boolean
31
+ hint?: Nullable<string | number | boolean> | undefined
31
32
  }
32
33
 
33
34
  export interface ICoreStyle {
package/webpack.config.js CHANGED
@@ -97,7 +97,7 @@ module.exports = (env, argv) => {
97
97
  devServer: {
98
98
  static: path.join(__dirname, "example"),
99
99
  compress: true,
100
- port: 9000,
100
+ port: 9001,
101
101
  hot: false,
102
102
  liveReload: true,
103
103
  open: true,