@v1nt1248/3nclient-lib 0.0.42 → 0.1.0

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 (56) hide show
  1. package/README.md +4 -4
  2. package/dist/components/index.d.ts +20 -19
  3. package/dist/components/ui3n-badge-simple.vue.d.ts +2 -2
  4. package/dist/components/ui3n-badge.vue.d.ts +1 -1
  5. package/dist/components/ui3n-breadcrumb.vue.d.ts +7 -7
  6. package/dist/components/ui3n-breadcrumbs.vue.d.ts +3 -3
  7. package/dist/components/ui3n-button.vue.d.ts +29 -4
  8. package/dist/components/ui3n-checkbox.vue.d.ts +2 -2
  9. package/dist/components/ui3n-chip.vue.d.ts +2 -2
  10. package/dist/components/ui3n-dialog.vue.d.ts +4 -4
  11. package/dist/components/ui3n-drop-files.vue.d.ts +23 -3
  12. package/dist/components/ui3n-emoji.vue.d.ts +2 -2
  13. package/dist/components/ui3n-icon.vue.d.ts +29 -3
  14. package/dist/components/ui3n-input.vue.d.ts +9 -9
  15. package/dist/components/ui3n-list.vue.d.ts +1 -1
  16. package/dist/components/ui3n-menu.vue.d.ts +2 -2
  17. package/dist/components/ui3n-notification.vue.d.ts +30 -1
  18. package/dist/components/ui3n-switch.vue.d.ts +55 -0
  19. package/dist/components/ui3n-table-sort-icon.vue.d.ts +1 -1
  20. package/dist/components/ui3n-table.vue.d.ts +2 -2
  21. package/dist/components/ui3n-tabs.vue.d.ts +2 -2
  22. package/dist/components/ui3n-text.vue.d.ts +29 -3
  23. package/dist/components/ui3n-virtual-scroll.vue.d.ts +9 -6
  24. package/dist/constants/types.d.ts +2 -4
  25. package/dist/directives/index.d.ts +1 -1
  26. package/dist/index.d.ts +25 -27
  27. package/dist/plugins/dialogs.d.ts +1 -1
  28. package/dist/plugins/index.d.ts +8 -8
  29. package/dist/plugins/notifications.d.ts +1 -1
  30. package/dist/plugins/vue-bus.d.ts +1 -1
  31. package/dist/style.css +1 -1
  32. package/dist/tools/sqlite-on-3nstorage/index.d.ts +3 -3
  33. package/dist/ui-3n-lib.js +6794 -6469
  34. package/package.json +57 -59
  35. package/src/components/index.ts +47 -41
  36. package/src/components/ui3n-badge-simple.vue +35 -38
  37. package/src/components/ui3n-badge.vue +25 -25
  38. package/src/components/ui3n-breadcrumb.vue +44 -44
  39. package/src/components/ui3n-breadcrumbs.vue +19 -19
  40. package/src/components/ui3n-button.vue +240 -150
  41. package/src/components/ui3n-checkbox.vue +199 -158
  42. package/src/components/ui3n-chip.vue +96 -98
  43. package/src/components/ui3n-dialog.vue +225 -235
  44. package/src/components/ui3n-drop-files.vue +146 -154
  45. package/src/components/ui3n-emoji.vue +62 -64
  46. package/src/components/ui3n-icon.vue +32 -13
  47. package/src/components/ui3n-input.vue +239 -221
  48. package/src/components/ui3n-list.vue +92 -111
  49. package/src/components/ui3n-menu.vue +101 -100
  50. package/src/components/ui3n-notification.vue +182 -113
  51. package/src/components/ui3n-switch.vue +146 -0
  52. package/src/components/ui3n-table-sort-icon.vue +1 -2
  53. package/src/components/ui3n-table.vue +229 -223
  54. package/src/components/ui3n-tabs.vue +141 -148
  55. package/src/components/ui3n-text.vue +235 -146
  56. package/src/components/ui3n-virtual-scroll.vue +68 -68
@@ -1,140 +1,142 @@
1
1
  <script lang="ts" setup>
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
- import { computed, onMounted, ref, watch } from 'vue'
4
- import Ui3nIcon from './ui3n-icon.vue'
5
- import Ui3nButton from './ui3n-button.vue'
6
-
7
- export interface Ui3nInputProps {
8
- value: string;
9
- label?: string;
10
- placeholder?: string;
11
- clearable?: boolean;
12
- autofocus?: boolean;
13
- rules?: Array<(v: string) => any>;
14
- disabled?: boolean;
15
- icon?: string;
16
- iconColor?: string;
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import { computed, onMounted, ref, watch } from 'vue';
4
+ import Ui3nIcon from './ui3n-icon.vue';
5
+ import Ui3nButton from './ui3n-button.vue';
6
+
7
+ export interface Ui3nInputProps {
8
+ modelValue: string;
9
+ label?: string;
10
+ placeholder?: string;
11
+ clearable?: boolean;
12
+ autofocus?: boolean;
13
+ rules?: Array<(v: string) => any>;
14
+ disabled?: boolean;
15
+ icon?: string;
16
+ iconColor?: string;
17
+ }
18
+
19
+ export interface Ui3nInputEmits {
20
+ (ev: 'input', value: string): void;
21
+ (ev: 'focus', value: Event): void;
22
+ (ev: 'blur', value: Event): void;
23
+ (ev: 'clear'): void;
24
+ (ev: 'change', value: string): void;
25
+ (ev: 'update:modelValue', value: string): void;
26
+ (ev: 'update:valid', value: boolean): void;
27
+ }
28
+
29
+ const props = defineProps<Ui3nInputProps>();
30
+ const emits = defineEmits<Ui3nInputEmits>();
31
+
32
+ const inputElement = ref<HTMLInputElement | null>(null);
33
+ const text = ref<string>('');
34
+ const isFocused = ref(false);
35
+ const errorMessage = ref('');
36
+
37
+ const cssIconColor = computed(() => {
38
+ if (props.disabled) {
39
+ return 'var(--color-icon-control-primary-disabled)';
17
40
  }
18
41
 
19
- export interface Ui3nInputEmits {
20
- (ev: 'input', value: string): void;
21
- (ev: 'focus', value: Event): void;
22
- (ev: 'blur', value: Event): void;
23
- (ev: 'clear', value: string): void;
24
- (ev: 'change', value: string): void;
25
- (ev: 'update:value', value: string): void;
26
- (ev: 'update:valid', value: boolean): void;
42
+ return props.iconColor || 'var(--color-icon-control-primary-default)'
43
+ });
44
+ const isValid = computed(() => {
45
+ if (!text.value) {
46
+ return true;
27
47
  }
28
48
 
29
- const props = defineProps<Ui3nInputProps>()
30
- const emit = defineEmits<Ui3nInputEmits>()
49
+ return !errorMessage.value;
50
+ });
31
51
 
32
- const inputElement = ref<HTMLInputElement|null>(null)
33
- const text = ref<string>('')
34
- const isFocused = ref(false)
35
- const errorMessage = ref('')
36
-
37
- const isValid = computed(() => {
38
- if (!text.value) {
39
- return true
40
- }
41
-
42
- return !errorMessage.value
43
- })
44
-
45
- onMounted(() => {
46
- if (props.autofocus && inputElement.value) {
47
- inputElement.value.focus()
48
- }
49
- })
50
-
51
- watch(
52
- () => props.value,
53
- val => text.value = val,
54
- { immediate: true },
55
- )
56
-
57
- watch(
58
- () => isValid.value,
59
- val => emit('update:valid', val),
60
- { immediate: true },
61
- )
62
-
63
- const onFocus = (event: Event) => {
64
- isFocused.value = true
65
- emit('focus', event)
66
- }
67
-
68
- const onBlur = (event: Event) => {
69
- isFocused.value = false
70
- emit('blur', event)
71
- }
72
-
73
- const onChange = (event: Event) => {
74
- const value = (event.target as HTMLInputElement).value
75
- validate(value)
76
- emit('update:value', value)
77
- emit('change', value)
78
- }
79
-
80
- const onInput = (ev: Event) => {
81
- const value = (ev.target as HTMLInputElement).value
82
- text.value = value
83
- validate(value)
84
- emit('update:value', value)
85
- emit('input', value)
52
+ onMounted(() => {
53
+ if (props.autofocus && inputElement.value) {
54
+ inputElement.value.focus();
86
55
  }
87
-
88
- const clearValue = () => {
89
- text.value = ''
90
- validate('')
91
- emit('update:value', '')
92
- emit('input', '')
93
- emit('change', '')
94
- }
95
-
96
- const validate = (text: string) => {
97
- errorMessage.value = ''
98
- if (props.rules && props.rules.length) {
99
- for (const validateFunction of props.rules) {
100
- if (typeof validateFunction === 'function') {
101
- const res = validateFunction(text)
102
- if (typeof res === 'string') {
103
- errorMessage.value += res
104
- }
56
+ });
57
+
58
+ watch(
59
+ () => props.modelValue,
60
+ val => text.value = val,
61
+ { immediate: true },
62
+ );
63
+
64
+ watch(
65
+ () => isValid.value,
66
+ val => emits('update:valid', val),
67
+ { immediate: true },
68
+ );
69
+
70
+ const onFocus = (event: Event) => {
71
+ isFocused.value = true;
72
+ emits('focus', event);
73
+ };
74
+
75
+ const onBlur = (event: Event) => {
76
+ isFocused.value = false;
77
+ emits('blur', event);
78
+ };
79
+
80
+ const onChange = (event: Event) => {
81
+ const value = (event.target as HTMLInputElement).value;
82
+ validate(value);
83
+ emits('change', value);
84
+ };
85
+
86
+ const onInput = (ev: Event) => {
87
+ const value = (ev.target as HTMLInputElement).value;
88
+ text.value = value;
89
+ validate(value);
90
+ emits('update:modelValue', value);
91
+ emits('input', value);
92
+ };
93
+
94
+ const clearValue = () => {
95
+ text.value = '';
96
+ validate('');
97
+ emits('update:modelValue', '');
98
+ emits('input', '');
99
+ emits('change', '');
100
+ emits('clear');
101
+ };
102
+
103
+ const validate = (text: string) => {
104
+ errorMessage.value = '';
105
+ if (props.rules && props.rules.length) {
106
+ for (const validateFunction of props.rules) {
107
+ if (typeof validateFunction === 'function') {
108
+ const res = validateFunction(text);
109
+ if (typeof res === 'string') {
110
+ errorMessage.value += res;
105
111
  }
106
112
  }
107
113
  }
108
114
  }
115
+ };
109
116
  </script>
110
117
 
111
118
  <template>
112
119
  <div
113
120
  ref="wrapperElement"
114
121
  :class="[
115
- 'ui3n-input',
116
- {
117
- 'ui3n-input--with-label': props.label,
118
- 'ui3n-input--with-icon': props.icon,
119
- 'ui3n-input--clearable': props.clearable && !!text,
120
- 'ui3n-input--disabled': props.disabled,
121
- 'ui3n-input--error': !!errorMessage,
122
- },
122
+ $style.input,
123
+ label && $style.withLabel,
124
+ icon && $style.withIcon,
125
+ clearable && text && $style.clearable,
126
+ disabled && $style.disabled,
127
+ !!errorMessage && $style.error,
123
128
  ]"
124
129
  >
125
- <label
126
- v-if="props.label"
127
- class="ui3n-input__label"
128
- >
129
- {{ props.label }}
130
+ <label v-if="label" :class="$style.label">
131
+ {{ label }}
130
132
  </label>
131
133
 
132
134
  <input
133
135
  ref="inputElement"
134
136
  :value="text"
135
- :placeholder="props.placeholder"
136
- :disabled="props.disabled"
137
- class="ui3n-input__input"
137
+ :placeholder="placeholder"
138
+ :disabled="disabled"
139
+ :class="$style.field"
138
140
  @input="onInput"
139
141
  @focusin="onFocus"
140
142
  @focusout="onBlur"
@@ -142,142 +144,158 @@
142
144
  >
143
145
 
144
146
  <ui3n-icon
145
- v-if="props.icon"
146
- :icon="props.icon"
147
+ v-if="icon"
148
+ :icon="icon"
147
149
  :width="16"
148
150
  :height="16"
149
- :color="props.iconColor || 'var(--black-30, #b3b3b3)'"
150
- class="ui3n-input__icon"
151
+ :class="[$style.icon, disabled && $style.iconDisabled]"
151
152
  />
152
153
 
153
154
  <ui3n-button
154
- v-if="props.clearable && !!text"
155
- round
155
+ v-if="clearable && !!text"
156
+ type="icon"
157
+ size="small"
156
158
  color="transparent"
157
159
  icon="close"
158
160
  icon-size="16"
159
- icon-color="var(----black-30, #b3b3b3)"
160
- class="ui3n-input__clear-btn"
161
+ icon-color="var(--color-icon-control-accent-default)"
162
+ :class="$style.clearBtn"
161
163
  @click="clearValue"
162
164
  />
163
165
 
164
- <div
165
- v-if="errorMessage"
166
- class="ui3n-input__error-text"
167
- >
166
+ <div v-if="errorMessage" :class="$style.errorText">
168
167
  {{ errorMessage }}
169
168
  </div>
170
169
  </div>
171
170
  </template>
172
171
 
173
- <style lang="scss" scoped>
174
- @import "../assets/styles/mixins";
175
-
176
- .ui3n-input {
177
- --ui3n-input-height: calc(var(--base-size, 8px) * 4);
178
- --ui3n-input-padding-left: var(--base-size, 8px);
179
- --ui3n-input-padding-right: var(--base-size, 8px);
180
-
181
- position: relative;
182
- width: 100%;
183
-
184
- &__label {
185
- display: block;
186
- width: 100%;
187
- font-size: var(--font-12, 12px);
188
- line-height: var(--font-16, 16px);
189
- font-weight: 600;
190
- color: var(--black-90, #212121);
191
- margin-bottom: var(--half-size, 4px);
192
- }
172
+ <style lang="scss" module>
173
+ @import "../assets/styles/mixins";
193
174
 
194
- &__input {
195
- display: block;
196
- box-sizing: border-box;
197
- width: 100%;
198
- position: relative;
199
- border: none;
200
- outline: none;
201
- height: var(--ui3n-input-height);
202
- padding: 0 var(--ui3n-input-padding-right) 0 var(--ui3n-input-padding-left);
203
- border-radius: var(--half-size, 4px);
204
- background-color: var(--gray-50, #f2f2f2);
205
- font-size: var(--font-13, 13px);
206
- font-weight: 400;
207
- line-height: 1;
208
- color: var(--black-90, #212121);
209
-
210
- &::placeholder {
211
- color: var(--black-30, #b3b3b3);
212
- font-style: italic;
213
- font-size: var(--font-13, 13px);
214
- font-weight: 400;
215
- }
216
-
217
- &:focus-within {
218
- background-color: var(--blue-main-20, #d8edfd);
219
- }
220
- }
175
+ .input {
176
+ --ui3n-input-height: var(--spacing-l);
177
+ --ui3n-input-padding-left: var(--spacing-s);
178
+ --ui3n-input-padding-right: var(--spacing-s);
221
179
 
222
- &__icon {
223
- position: absolute;
224
- left: var(--half-size, 4px);
225
- top: calc((var(--ui3n-input-height) - 16px) / 2);
226
- }
180
+ position: relative;
181
+ width: 100%;
182
+ border-radius: var(--spacing-xs);
227
183
 
228
- &__clear-btn {
229
- position: absolute;
230
- right: 0;
231
- top: calc((var(--ui3n-input-height) - 28px) / 2);
232
- }
184
+ &:hover {
185
+ .field:not(:focus-within) {
186
+ background-color: var(--color-bg-control-secondary-hover);
233
187
 
234
- &__error-text {
235
- font-style: italic;
236
- font-size: var(--font-10, 10px);
237
- font-weight: 400;
238
- line-height: 1.5;
239
- color: var(--pear-100, #f75d53);
188
+ &::placeholder {
189
+ color: var(--color-text-control-secondary-hover);
190
+ }
240
191
  }
192
+ }
241
193
 
242
- &--clearable {
243
- --ui3n-input-padding-right: calc(var(--base-size, 8px) * 3);
194
+ &:focus-within {
195
+ .field {
196
+ background-color: var(--color-bg-control-secondary-focused);
197
+ outline: 1px solid var(--color-border-control-accent-focused);
244
198
  }
245
199
 
246
- &--with-icon {
247
- --ui3n-input-padding-left: calc(var(--base-size, 8px) * 3);
200
+ .icon {
201
+ color: v-bind(cssIconColor) !important;
248
202
  }
203
+ }
204
+ }
205
+
206
+ .label {
207
+ display: block;
208
+ width: 100%;
209
+ font-size: var(--font-12);
210
+ line-height: var(--font-16);
211
+ font-weight: 600;
212
+ color: var(--color-text-control-primary-default);
213
+ margin-bottom: var(--spacing-xs);
214
+ }
215
+
216
+ .field {
217
+ display: block;
218
+ box-sizing: border-box;
219
+ width: 100%;
220
+ position: relative;
221
+ border: none;
222
+ outline: none;
223
+ height: var(--ui3n-input-height);
224
+ padding: 0 var(--ui3n-input-padding-right) 0 var(--ui3n-input-padding-left);
225
+ border-radius: var(--spacing-xs);
226
+ background-color: var(--color-bg-control-secondary-default);
227
+ font-size: var(--font-13);
228
+ line-height: var(--font-16);
229
+ font-weight: 400;
230
+ color: var(--color-text-control-primary-default);
231
+ transition: all 0.2s ease-in-out;
232
+
233
+ &::placeholder {
234
+ color: var(--color-text-control-secondary-default);
235
+ font-style: italic;
236
+ font-size: var(--font-13);
237
+ line-height: var(--font-16);
238
+ font-weight: 400;
239
+ }
249
240
 
250
- &--error {
251
- --ui3n-input-padding-left: calc(var(--base-size, 8px) - 1px);
252
- --ui3n-input-padding-right: calc(var(--base-size, 8px) - 1px);
253
-
254
- .ui3n-input__input {
255
- border: 1px solid var(--pear-100, #f75d53)
256
- }
257
-
258
- &.ui3n-input--clearable {
259
- --ui3n-input-padding-right: calc(var(--base-size, 8px) * 2 - 1px);
260
- }
261
-
262
- &.ui3n-input--with-icon {
263
- --ui3n-input-padding-left: calc(var(--base-size, 8px) * 2 - 1px);
264
- }
265
- }
241
+ &[disabled] {
242
+ background-color: var(--color-bg-control-secondary-disabled);
243
+ color: var(--color-text-control-secondary-disabled);
244
+ }
245
+ }
246
+
247
+ .icon {
248
+ position: absolute;
249
+ left: var(--half-size, 4px);
250
+ top: calc((var(--ui3n-input-height) - 16px) / 2);
251
+ color: var(--color-icon-control-secondary-default) !important;
252
+ }
253
+
254
+ .iconDisabled {
255
+ color: v-bind(cssIconColor) !important;
256
+ }
257
+
258
+ .clearBtn {
259
+ position: absolute;
260
+ right: 0;
261
+ top: calc((var(--ui3n-input-height) - 24px) / 2);
262
+ z-index: 1;
263
+ }
264
+
265
+ .errorText {
266
+ font-style: italic;
267
+ font-size: var(--font-10);
268
+ font-weight: 400;
269
+ line-height: 1.4;
270
+ color: var(--content-error-default);
271
+ }
272
+
273
+ .clearable {
274
+ --ui3n-input-padding-right: var(--spacing-ml);
275
+ }
276
+
277
+ .withIcon {
278
+ --ui3n-input-padding-left: var(--spacing-ml);
279
+ }
280
+
281
+ .error {
282
+ .field {
283
+ outline: 1px solid var(--content-error-default);
284
+ }
285
+ }
266
286
 
267
- &--disabled {
268
- pointer-events: none;
269
- user-select: none;
270
- opacity: 0.5;
271
- }
287
+ .disabled {
288
+ pointer-events: none;
289
+ user-select: none;
290
+ }
272
291
 
273
- &--with-label {
274
- .ui3n-input__icon {
275
- top: calc((var(--ui3n-input-height) - 16px) / 2 + 20px);
276
- }
292
+ .withLabel {
293
+ .icon {
294
+ top: calc((var(--ui3n-input-height) - 16px) / 2 + 20px);
295
+ }
277
296
 
278
- .ui3n-input__clear-btn {
279
- top: calc((var(--ui3n-input-height) - 28px) / 2 + 20px);
280
- }
281
- }
297
+ .clearBtn {
298
+ top: calc((var(--ui3n-input-height) - 24px) / 2 + 20px);
282
299
  }
300
+ }
283
301
  </style>