@v1nt1248/3nclient-lib 0.0.42 → 0.1.1

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