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.
Files changed (35) hide show
  1. package/dist/components/BaseCalendar/BaseCalendar.vue.d.ts +9 -1
  2. package/dist/components/BaseField/BaseField.vue.d.ts +98 -0
  3. package/dist/components/BaseInput/BaseInput.vue.d.ts +16 -14
  4. package/dist/components/BaseInputCalendar/BaseInputCalendar.vue.d.ts +13 -15
  5. package/dist/components/BaseInputCurrency/BaseInputCurrency.vue.d.ts +7 -9
  6. package/dist/components/BaseInputEmail/BaseInputEmail.vue.d.ts +7 -12
  7. package/dist/components/BaseInputPhone/BaseInputPhone.vue.d.ts +7 -12
  8. package/dist/components/BaseSiteInput/BaseSiteInput.vue.d.ts +11 -7
  9. package/dist/components/BaseTextarea/BaseTextarea.vue.d.ts +7 -12
  10. package/dist/components/BaseTooltip/BaseTooltip.vue.d.ts +1 -1
  11. package/dist/composables/kit/state.d.ts +1 -1
  12. package/dist/index.d.ts +2 -1
  13. package/dist/index.js +1 -1
  14. package/example/App.vue +172 -133
  15. package/package.json +1 -1
  16. package/src/components/BaseField/BaseField.vue +184 -0
  17. package/src/components/BaseField/README.md +85 -0
  18. package/src/components/BaseInput/BaseInput.vue +161 -210
  19. package/src/components/BaseInputCalendar/BaseInputCalendar.vue +10 -7
  20. package/src/components/BaseInputCurrency/BaseInputCurrency.vue +56 -54
  21. package/src/components/BaseInputEmail/BaseInputEmail.vue +2 -4
  22. package/src/components/BaseInputPhone/BaseInputPhone.vue +29 -48
  23. package/src/components/BaseSelect/BaseSelect.vue +9 -52
  24. package/src/components/BaseSiteInput/BaseSiteInput.vue +10 -20
  25. package/src/components/BaseTextarea/BaseTextarea.vue +3 -30
  26. package/src/components/BaseUpload/BaseUpload.vue +1 -1
  27. package/src/composables/kit/state.ts +1 -1
  28. package/src/index.ts +5 -2
  29. package/src/styles/index.scss +87 -2
  30. package/src/styles/root.scss +1 -0
  31. package/src/styles/variables.scss +2 -1
  32. package/src/types/calendar.d.ts +2 -0
  33. package/src/types/field.d.ts +12 -0
  34. package/src/types/input.d.ts +26 -8
  35. package/webpack.config.js +1 -1
@@ -1,51 +1,42 @@
1
1
  <template>
2
- <div class="base-input" :class="classList">
3
- <label class="base-input__label" :for="id">
4
- <span v-if="label" class="base-input__label-text">{{ label }}</span>
5
-
6
- <div class="base-input__wrapper">
7
- <div v-if="$slots['left-icon']" class="base-input__icon base-input__icon--left">
8
- <slot name="left-icon"></slot>
9
- </div>
10
-
11
- <input
12
- :id="id"
13
- :type="type"
14
- :value="modelValue"
15
- v-maska="mask"
16
- v-bind="componentAttrs"
17
- :placeholder="placeholder || ''"
18
- class="base-input__field"
19
- @input="handleInput"
20
- />
21
-
22
- <div v-if="$slots['right-icon']" class="base-input__icon base-input__icon--right">
23
- <slot name="right-icon"></slot>
24
- </div>
2
+ <div class="base-input" :class="classList">
3
+ <div class="base-input__wrapper">
4
+ <div v-if="$slots['left-icon']" class="base-input__icon base-input__icon--left">
5
+ <slot name="left-icon"></slot>
25
6
  </div>
26
-
27
- <div v-if="(error && typeof error === 'string') || hint" class="base-input__hint">
28
- {{ error || hint }}
7
+ <input
8
+ :id="id"
9
+ :type="type"
10
+ :value="modelValue"
11
+ v-maska="mask"
12
+ v-bind="componentAttrs"
13
+ :placeholder="placeholder || ''"
14
+ class="base-input__field"
15
+ :class="{ 'base-input__field--focusable': focusable }"
16
+ @input="handleInput"
17
+ />
18
+ <div v-if="$slots['right-icon']" class="base-input__icon base-input__icon--right">
19
+ <slot name="right-icon"></slot>
29
20
  </div>
30
- </label>
31
21
  </div>
22
+ </div>
32
23
  </template>
33
24
 
34
25
  <script setup lang="ts">
35
26
  import { computed, useAttrs, useSlots } from 'vue';
36
- import type { ICoreInputProps } from '../../types/input'
37
- import { useKitSize } from '../../composables/kit/size'
38
- import { useKitState } from '../../composables/kit/state'
39
- import { vMaska } from "maska/vue"
27
+ import type { ICoreInputProps } from '../../types/input';
28
+ import { useKitSize } from '../../composables/kit/size';
29
+ import { useKitState } from '../../composables/kit/state';
30
+ import { vMaska } from 'maska/vue';
40
31
 
41
32
  const props = withDefaults(defineProps<ICoreInputProps>(), {
33
+ id: '',
42
34
  size: 'medium',
43
35
  type: 'text',
44
36
  modelValue: '',
45
- placeholder: '' as string,
46
- error: '',
47
- hint: '',
37
+ placeholder: '',
48
38
  mask: '',
39
+ focusable: true,
49
40
  });
50
41
 
51
42
  const emit: (event: 'update:modelValue', value: string) => void = defineEmits();
@@ -53,22 +44,21 @@ const emit: (event: 'update:modelValue', value: string) => void = defineEmits();
53
44
  const { sizeClassList } = useKitSize(props);
54
45
  const { stateClassList, stateAttrs } = useKitState(props);
55
46
  const attrs = useAttrs();
47
+ const slots = useSlots();
56
48
 
57
49
  const componentAttrs = computed(() => ({
58
50
  ...attrs,
59
51
  ...stateAttrs.value,
60
52
  }));
61
53
 
62
- const slots = useSlots();
63
-
64
54
  const classList = computed(() => [
65
55
  sizeClassList.value,
66
56
  stateClassList.value,
67
-
68
57
  {
69
- '--is-readonly': props.readonly,
70
58
  '--icon-left': !!slots['left-icon'],
71
59
  '--icon-right': !!slots['right-icon'],
60
+ '--is-error': props.error,
61
+ '--is-readonly': props.readonly,
72
62
  },
73
63
  ]);
74
64
 
@@ -82,90 +72,81 @@ function handleInput(event: Event) {
82
72
  @import '../../styles/variables';
83
73
  @import '../../styles/root';
84
74
 
85
- .base-input {
86
- width: 100%;
87
- $input: &;
88
-
89
- &__wrapper {
90
- position: relative;
91
- display: flex;
92
- flex-direction: column;
93
- align-items: flex-start;
94
- width: 100%;
95
- }
96
-
97
- &__field {
98
- flex: 1;
99
- width: 100%;
100
- height: 100%;
101
- color: var(--primary-text-primary);
102
- background: var(--bg-light);
103
- border: 1px solid var(--primary-black-300);
104
- outline: none;
105
- transition: all var(--transition);
106
-
107
- &::placeholder {
108
- color: var(--primary-text-tertiary);
109
- }
75
+ .base-input {
76
+ width: 100%;
77
+ $input: &;
110
78
 
111
- @include pressed {
112
- color: var(--primary-blue);
113
- }
114
-
115
- @include focused {
116
- border: 1px solid var(--primary-blue-500);
117
- outline: 4px solid var(--effects-primary-focus);
118
- }
79
+ &__wrapper {
80
+ position: relative;
81
+ display: flex;
82
+ align-items: center;
83
+ width: 100%;
84
+ }
119
85
 
120
- @include is-disabled-state {
121
- & {
122
- color: var(--primary-text-tertiary);
123
- background: var(--primary-black-100);
124
- }
125
- }
86
+ &__field {
87
+ flex: 1;
88
+ width: 100%;
89
+ height: 100%;
90
+ color: var(--primary-text-primary);
91
+ background: var(--bg-light);
92
+ border: 1px solid var(--primary-black-300);
93
+ outline: none;
94
+ transition: all var(--transition);
95
+
96
+ &::placeholder {
97
+ color: var(--primary-text-tertiary);
126
98
  }
127
99
 
128
- &__icon {
129
- display: flex;
130
- align-items: center;
131
- justify-content: center;
132
- color: var(--primary-black-500);
100
+ @include pressed {
101
+ color: var(--primary-blue);
133
102
  }
134
103
 
135
104
  @include is-disabled-state {
136
- #{$input}__icon--right {
137
- color: var(--primary-black-400);
138
- }
139
-
140
- #{$input}__hint {
141
- color: var(--primary-text-secondary);
105
+ & {
106
+ color: var(--primary-text-tertiary);
107
+ background: var(--primary-black-100);
142
108
  }
143
109
  }
144
110
 
145
- &__icon--left, &__icon--right {
146
- position: absolute;
147
- top: 50%;
148
- transform: translateY(-50%);
111
+ &--focusable {
112
+ @include focused {
113
+ border: 1px solid var(--primary-blue-500);
114
+ outline: 4px solid var(--effects-primary-focus);
115
+ }
149
116
  }
117
+ }
150
118
 
151
- &__label {
152
- display: flex;
153
- flex-direction: column;
154
- gap: 6px;
155
- width: 100%;
156
- }
119
+ &__icon {
120
+ display: flex;
121
+ align-items: center;
122
+ justify-content: center;
123
+ color: var(--primary-black-500);
124
+ }
157
125
 
158
- &__label-text {
159
- color: var(--primary-text-primary);
126
+ @include is-disabled-state {
127
+ #{$input}__icon--right {
128
+ color: var(--primary-black-400);
160
129
  }
130
+ }
161
131
 
162
- &.--is-error {
163
- #{$input}__hint {
164
- color: var(--error-red);
165
- }
132
+ &__icon--left,
133
+ &__icon--right {
134
+ position: absolute;
135
+ top: 50%;
136
+ transform: translateY(-50%);
137
+ }
138
+
139
+ &.--is-error {
166
140
 
167
141
  #{$input}__field {
168
142
  border-color: var(--error-red-light-01);
143
+
144
+ &--focusable {
145
+ @include focused {
146
+ border: 1px solid var(--error-red-light-02);
147
+ outline: 4px solid var(--effects-error-focus);
148
+ }
149
+ }
169
150
  }
170
151
 
171
152
  #{$input}__icon--right > * {
@@ -173,130 +154,100 @@ function handleInput(event: Event) {
173
154
  }
174
155
  }
175
156
 
176
- &.--small-size {
177
- #{$input} {
178
- &__label {
179
- font: var(--typography-text-s-medium);
180
- }
181
-
182
- &__hint {
183
- font: var(--typography-text-s-regular);
184
- }
185
- }
186
-
187
- #{$input}__wrapper {
188
- height: 40px;
189
- }
190
-
191
- #{$input}__field {
192
- padding: 8px 14px;
193
- font: var(--typography-text-m-regular);
194
- border-radius: 10px;
195
- }
196
-
197
- &.--icon-left #{$input}__field {
198
- padding-left: 42px;
199
- }
200
-
201
- &.--icon-right #{$input}__field {
202
- padding-right: 38px;
203
- }
204
-
205
- #{$input}__icon--left {
206
- left: 14px;
207
- width: 20px;
208
- height: 20px;
209
- }
157
+ &.--small-size {
158
+ #{$input}__wrapper {
159
+ height: 40px;
160
+ }
210
161
 
211
- #{$input}__icon--right {
212
- right: 14px;
213
- width: 16px;
214
- height: 16px;
215
- }
162
+ #{$input}__field {
163
+ padding: 8px 14px;
164
+ font: var(--typography-text-m-regular);
165
+ border-radius: 10px;
216
166
  }
217
167
 
218
- &.--medium-size {
219
- #{$input} {
220
- &__label {
221
- font: var(--typography-text-s-medium);
222
- }
168
+ &.--icon-left #{$input}__field {
169
+ padding-left: 42px;
170
+ }
223
171
 
224
- &__hint {
225
- font: var(--typography-text-s-regular);
226
- }
172
+ &.--icon-right #{$input}__field {
173
+ padding-right: 38px;
174
+ }
227
175
 
228
- &__wrapper {
229
- height: 48px;
230
- }
176
+ #{$input}__icon--left {
177
+ left: 14px;
178
+ width: 20px;
179
+ height: 20px;
180
+ }
231
181
 
232
- &__field {
233
- padding: 12px 14px;
234
- font: var(--typography-text-m-regular);
235
- border-radius: 12px;
236
- }
237
- }
182
+ #{$input}__icon--right {
183
+ right: 14px;
184
+ width: 16px;
185
+ height: 16px;
186
+ }
187
+ }
238
188
 
239
- &.--icon-left #{$input}__field {
240
- padding-left: 46px;
241
- }
189
+ &.--medium-size {
190
+ #{$input}__wrapper {
191
+ height: 48px;
192
+ }
242
193
 
243
- &.--icon-right #{$input}__field {
244
- padding-right: 42px;
245
- }
194
+ #{$input}__field {
195
+ padding: 12px 14px;
196
+ font: var(--typography-text-m-regular);
197
+ border-radius: 12px;
198
+ }
246
199
 
247
- #{$input}__icon--left {
248
- left: 14px;
249
- width: 24px;
250
- height: 24px;
251
- }
200
+ &.--icon-left #{$input}__field {
201
+ padding-left: 46px;
202
+ }
252
203
 
253
- #{$input}__icon--right {
254
- right: 14px;
255
- width: 20px;
256
- height: 20px;
257
- }
204
+ &.--icon-right #{$input}__field {
205
+ padding-right: 42px;
258
206
  }
259
207
 
260
- &.--large-size {
261
- #{$input} {
262
- &__label {
263
- font: var(--typography-text-m-medium);
264
- }
208
+ #{$input}__icon--left {
209
+ left: 14px;
210
+ width: 24px;
211
+ height: 24px;
212
+ }
265
213
 
266
- &__hint {
267
- font: var(--typography-text-m-regular);
268
- }
214
+ #{$input}__icon--right {
215
+ right: 14px;
216
+ width: 20px;
217
+ height: 20px;
218
+ }
219
+ }
269
220
 
270
- &__wrapper {
271
- height: 56px;
272
- }
221
+ &.--large-size {
222
+ #{$input}__wrapper {
223
+ height: 56px;
224
+ }
273
225
 
274
- &__field {
275
- padding: 14px 16px;
276
- font: var(--typography-text-l-regular);
277
- border-radius: 12px;
278
- }
279
- }
226
+ #{$input}__field {
227
+ padding: 14px 16px;
228
+ font: var(--typography-text-l-regular);
229
+ border-radius: 12px;
230
+ }
280
231
 
281
- &.--icon-left #{$input}__field {
282
- padding-left: 56px;
283
- }
232
+ &.--icon-left #{$input}__field {
233
+ padding-left: 56px;
234
+ }
284
235
 
285
- &.--icon-right #{$input}__field {
286
- padding-right: 48px;
287
- }
236
+ &.--icon-right #{$input}__field {
237
+ padding-right: 48px;
238
+ }
288
239
 
289
- #{$input}__icon--left {
290
- left: 16px;
291
- width: 32px;
292
- height: 32px;
293
- }
240
+ #{$input}__icon--left {
241
+ left: 16px;
242
+ width: 32px;
243
+ height: 32px;
244
+ }
294
245
 
295
- #{$input}__icon--right {
296
- right: 16px;
297
- width: 24px;
298
- height: 24px;
299
- }
246
+ #{$input}__icon--right {
247
+ right: 16px;
248
+ width: 24px;
249
+ height: 24px;
300
250
  }
301
251
  }
302
- </style>
252
+ }
253
+ </style>
@@ -6,11 +6,11 @@
6
6
  :range="range"
7
7
  :size="size"
8
8
  :min-date="minDate"
9
+ :id="id"
9
10
  >
10
11
  <base-input
11
- v-bind="{ ...$props, ...$attrs }"
12
+ v-bind="{ ...$props }"
12
13
  :model-value="formattedValue"
13
- :error="errorMessage || props.error"
14
14
  @update:model-value="handleInputUpdate"
15
15
  >
16
16
  <template #['left-icon']>
@@ -37,13 +37,14 @@ const props = withDefaults(defineProps<TCoreInputCalendarProps>(), {
37
37
  type: 'text',
38
38
  modelValue: '',
39
39
  placeholder: '',
40
- error: '',
41
- hint: '',
42
40
  range: false,
43
41
  minDate: null,
44
42
  });
45
43
 
46
- const emit: (event: 'update:modelValue', value: string) => void = defineEmits();
44
+ const emit = defineEmits<{
45
+ 'update:modelValue': [value: string],
46
+ 'validationError': [value: string],
47
+ }>();
47
48
 
48
49
  const inputValue = ref<string>('');
49
50
 
@@ -201,16 +202,18 @@ function handleInputUpdate(value: string) {
201
202
 
202
203
  inputValue.value = filteredValue;
203
204
  emit('update:modelValue', filteredValue);
205
+ emit('validationError', validation.value);
204
206
 
205
207
  const parsed = parseDateString(filteredValue);
206
208
  if (parsed) {
207
209
  const formatted = formatDateRange(parsed);
208
210
  inputValue.value = formatted;
209
211
  emit('update:modelValue', formatted);
212
+ emit('validationError', validation.value);
210
213
  }
211
214
  }
212
215
 
213
- const errorMessage = computed<string>(() => {
216
+ const validation = computed<string>(() => {
214
217
  if (!inputValue.value) {
215
218
  return '';
216
219
  }
@@ -233,7 +236,7 @@ const errorMessage = computed<string>(() => {
233
236
 
234
237
  <style scoped lang="scss">
235
238
  .base-input-calendar {
236
- width: max-content;
239
+ width: 100%;
237
240
 
238
241
  &__wrapper {
239
242
  position: relative;