@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,115 +1,111 @@
1
1
  <script lang="ts" setup>
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
- import { computed, onMounted, ref, watch } from 'vue'
4
- import { patchTextareaMaxRowsSupport } from '../tools'
5
-
6
- export interface Ui3nTextProps {
7
- text: string;
8
- rows?: number;
9
- maxRows?: number;
10
- label?: string;
11
- placeholder?: string;
12
- rules?: Array<(v: string) => any>;
13
- disabled?: boolean;
14
- }
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import { computed, onMounted, ref, watch } from 'vue';
4
+ import { patchTextareaMaxRowsSupport } from '../tools';
15
5
 
16
- export interface Ui3nTextEmits {
17
- (ev: 'init', value: HTMLTextAreaElement): void;
18
- (ev: 'input', value: string): void;
19
- (ev: 'focus', value: Event): void;
20
- (ev: 'blur', value: Event): void;
21
- (ev: 'update:text', value: string): void;
22
- (ev: 'update:valid', value: boolean): void;
23
- }
6
+ export interface Ui3nTextProps {
7
+ text: string;
8
+ rows?: number;
9
+ maxRows?: number;
10
+ label?: string;
11
+ placeholder?: string;
12
+ rules?: Array<(v: string) => any>;
13
+ disabled?: boolean;
14
+ }
24
15
 
25
- const props = defineProps<Ui3nTextProps>()
26
- const emit = defineEmits<Ui3nTextEmits>()
16
+ export interface Ui3nTextEmits {
17
+ (ev: 'init', value: HTMLTextAreaElement): void;
18
+ (ev: 'input', value: string): void;
19
+ (ev: 'focus', value: Event): void;
20
+ (ev: 'blur', value: Event): void;
21
+ (ev: 'update:text', value: string): void;
22
+ (ev: 'update:valid', value: boolean): void;
23
+ }
27
24
 
28
- const textareaElement = ref<HTMLTextAreaElement | null>(null)
29
- const isFocused = ref(false)
30
- const errorMessage = ref('')
25
+ const props = withDefaults(
26
+ defineProps<Ui3nTextProps>(),
27
+ {
28
+ rows: 6,
29
+ maxRows: 6,
30
+ label: '',
31
+ placeholder: '',
32
+ disabled: false,
33
+ },
34
+ );
35
+ const emit = defineEmits<Ui3nTextEmits>();
31
36
 
32
- const componentProps = computed(() => {
33
- const { rows = 6, maxRows = 6, label = '', placeholder = '', disabled = false } = props
34
- return { rows, maxRows, label, placeholder, disabled }
35
- })
37
+ const textareaElement = ref<HTMLTextAreaElement | null>(null);
38
+ const isFocused = ref(false);
39
+ const errorMessage = ref('');
36
40
 
37
- const isValid = computed(() => {
38
- if (!props.text) {
39
- return true
40
- }
41
+ const isValid = computed(() => {
42
+ if (!props.text) {
43
+ return true;
44
+ }
41
45
 
42
- return !errorMessage.value
43
- })
46
+ return !errorMessage.value;
47
+ });
44
48
 
45
- onMounted(() => {
46
- if (textareaElement.value) {
47
- patchTextareaMaxRowsSupport(textareaElement.value!)
48
- emit('init', textareaElement.value!)
49
- }
50
- })
51
-
52
- watch(
53
- () => isValid.value,
54
- val => emit('update:valid', val),
55
- { immediate: true },
56
- )
57
-
58
- const validate = (text: string) => {
59
- errorMessage.value = ''
60
- if (props.rules && props.rules.length) {
61
- for (const validateFunction of props.rules) {
62
- if (typeof validateFunction === 'function') {
63
- const res = validateFunction(text)
64
- if (typeof res === 'string') {
65
- errorMessage.value += res
66
- }
49
+ onMounted(() => {
50
+ if (textareaElement.value) {
51
+ patchTextareaMaxRowsSupport(textareaElement.value!);
52
+ emit('init', textareaElement.value!);
53
+ }
54
+ });
55
+
56
+ watch(
57
+ () => isValid.value,
58
+ val => emit('update:valid', val),
59
+ { immediate: true },
60
+ );
61
+
62
+ const validate = (text: string) => {
63
+ errorMessage.value = '';
64
+ if (props.rules && props.rules.length) {
65
+ for (const validateFunction of props.rules) {
66
+ if (typeof validateFunction === 'function') {
67
+ const res = validateFunction(text);
68
+ if (typeof res === 'string') {
69
+ errorMessage.value += res;
67
70
  }
68
71
  }
69
72
  }
70
73
  }
74
+ };
71
75
 
72
- const onFocus = (event: Event) => {
73
- isFocused.value = true
74
- emit('focus', event)
75
- }
76
+ const onFocus = (event: Event) => {
77
+ isFocused.value = true;
78
+ emit('focus', event);
79
+ };
76
80
 
77
- const onBlur = (event: Event) => {
78
- isFocused.value = false
79
- emit('blur', event)
80
- }
81
+ const onBlur = (event: Event) => {
82
+ isFocused.value = false;
83
+ emit('blur', event);
84
+ };
81
85
 
82
- const onInput = (ev: Event) => {
83
- const value = (ev.target as HTMLInputElement).value
84
- validate(value)
85
- emit('update:text', value)
86
- emit('input', value)
87
- }
86
+ const onInput = (ev: Event) => {
87
+ const value = (ev.target as HTMLInputElement).value;
88
+ validate(value);
89
+ emit('update:text', value);
90
+ emit('input', value);
91
+ };
88
92
  </script>
89
93
 
90
94
  <template>
91
- <div
92
- :class="[
93
- 'ui3n-text',
94
- { 'ui3n-text--disabled': props.disabled, 'ui3n-text--focused': isFocused },
95
- ]"
96
- >
97
- <label
98
- v-if="componentProps.label"
99
- class="ui3n-text__label"
100
- >
101
- {{ componentProps.label }}
95
+ <div :class="[$style.text, disabled && $style.disabled, isFocused && $style.focused]">
96
+ <label v-if="label" :class="$style.label">
97
+ {{ label }}
102
98
  </label>
103
- <div class="ui3n-text__body">
99
+ <div :class="$style.body">
104
100
  <textarea
105
101
  ref="textareaElement"
106
- :value="props.text"
107
- :placeholder="componentProps.placeholder"
108
- :readonly="componentProps.disabled"
109
- :rows="componentProps.rows"
110
- :max-rows="componentProps.maxRows"
111
- :disabled="componentProps.disabled"
112
- class="ui3n-text__content"
102
+ :class="$style.content"
103
+ :value="text"
104
+ :placeholder="placeholder"
105
+ :readonly="disabled"
106
+ :rows="rows"
107
+ :max-rows="maxRows"
108
+ :disabled="disabled"
113
109
  v-bind="$attrs"
114
110
  @input="onInput"
115
111
  @focusin="onFocus"
@@ -119,67 +115,160 @@
119
115
  </div>
120
116
  </template>
121
117
 
122
- <style lang="scss" scoped>
123
- .ui3n-text {
124
- position: relative;
125
- width: 100%;
126
-
127
- &__label {
128
- display: block;
129
- width: 100%;
130
- font-size: var(--font-12, 12px);
131
- font-weight: 600;
132
- color: var(--black-90, #212121);
133
- margin-bottom: calc(var(--base-size, 8px) / 2);
134
- }
118
+ <style lang="scss" module>
119
+ .text {
120
+ position: relative;
121
+ width: 100%;
122
+ border-radius: var(--spacing-xs);
123
+ }
135
124
 
136
- &__body {
137
- position: relative;
138
- width: 100%;
139
- padding: var(--base-size, 8px) 0;
140
- background-color: var(--gray-50, #f2f2f2);
141
- border-radius: 4px;
142
- }
125
+ .label {
126
+ display: block;
127
+ width: 100%;
128
+ font-size: var(--font-12);
129
+ line-height: var(--font-16);
130
+ font-weight: 600;
131
+ color: var(--color-text-control-primary-default);
132
+ margin-bottom: var(--spacing-xs);
133
+ }
143
134
 
144
- &__content {
145
- resize: none;
146
- display: block;
147
- box-sizing: border-box;
148
- position: relative;
149
- width: 100%;
150
- border-radius: 4px;
151
- background-color: var(--gray-50, #f2f2f2);
152
- padding: 0 var(--base-size, 8px);
153
- font-family: OpenSans, sans-serif;
154
- font-size: var(--font-13, 13px);
155
- font-weight: 400;
156
- line-height: var(--font-16, 16px);
157
- color: var(--black-90, #212121);
158
- border: none;
159
-
160
- &::placeholder {
161
- font-size: var(--font-13, 13px);
162
- font-weight: 300;
163
- font-style: italic;
164
- color: var(--gray-90, #212121);
165
- }
166
- }
135
+ .body {
136
+ position: relative;
137
+ width: 100%;
138
+ padding: var(--spacing-s) 0;
139
+ background-color: var(--color-bg-control-secondary-default);
140
+ border-radius: var(--spacing-xs);
141
+ transition: all 0.2s ease-in-out;
167
142
 
168
- &--disabled {
169
- pointer-events: none;
170
- user-select: none;
171
- opacity: 0.5;
172
- }
143
+ &:hover {
144
+ &:not(:focus-within) {
145
+ background-color: var(--color-bg-control-secondary-hover);
173
146
 
174
- &--focused {
175
- .ui3n-text {
176
- &__body, &__content {
177
- background-color: var(--blue-main-20, #d8edfd);
178
- outline: none;
179
- border: none;
147
+ .content {
148
+ background-color: var(--color-bg-control-secondary-hover);
149
+
150
+ &::placeholder {
151
+ color: var(--color-text-control-secondary-hover);
180
152
  }
181
153
  }
182
154
  }
183
155
  }
156
+ }
157
+
158
+ .content {
159
+ resize: none;
160
+ display: block;
161
+ border: none;
162
+ box-sizing: border-box;
163
+ position: relative;
164
+ width: 100%;
165
+ border-radius: var(--spacing-xs);
166
+ background-color: var(--color-bg-control-secondary-default);
167
+ padding: 0 var(--spacing-s);
168
+ font-family: Manrope, sans-serif;
169
+ font-size: var(--font-13);
170
+ line-height: var(--font-16);
171
+ font-weight: 400;
172
+ color: var(--color-text-control-primary-default);
173
+ transition: all 0.2s ease-in-out;
174
+
175
+ &::placeholder {
176
+ color: var(--color-text-control-secondary-default);
177
+ font-style: italic;
178
+ font-size: var(--font-13);
179
+ line-height: var(--font-16);
180
+ font-weight: 400;
181
+ }
182
+
183
+ &:focus-within {
184
+ outline: none;
185
+ }
186
+ }
187
+
188
+ .disabled {
189
+ pointer-events: none;
190
+ user-select: none;
191
+
192
+ .body {
193
+ background-color: var(--color-bg-control-secondary-disabled);
194
+ }
195
+
196
+ .content {
197
+ background-color: var(--color-bg-control-secondary-disabled);
198
+ color: var(--color-text-control-secondary-disabled);
199
+ }
200
+ }
201
+
202
+ .focused {
203
+ .body {
204
+ background-color: var(--color-bg-control-secondary-focused);
205
+ outline: 1px solid var(--color-border-control-accent-focused);
206
+ }
207
+
208
+ .content {
209
+ background-color: var(--color-bg-control-secondary-focused);
210
+ }
211
+ }
212
+
213
+ //.ui3n-text {
214
+ // position: relative;
215
+ // width: 100%;
216
+ //
217
+ // &__label {
218
+ // display: block;
219
+ // width: 100%;
220
+ // font-size: var(--font-12, 12px);
221
+ // font-weight: 600;
222
+ // color: var(--black-90, #212121);
223
+ // margin-bottom: calc(var(--base-size, 8px) / 2);
224
+ // }
225
+ //
226
+ // &__body {
227
+ // position: relative;
228
+ // width: 100%;
229
+ // padding: var(--base-size, 8px) 0;
230
+ // background-color: var(--gray-50, #f2f2f2);
231
+ // border-radius: 4px;
232
+ // }
233
+ //
234
+ // &__content {
235
+ // resize: none;
236
+ // display: block;
237
+ // box-sizing: border-box;
238
+ // position: relative;
239
+ // width: 100%;
240
+ // border-radius: 4px;
241
+ // background-color: var(--gray-50, #f2f2f2);
242
+ // padding: 0 var(--base-size, 8px);
243
+ // font-family: OpenSans, sans-serif;
244
+ // font-size: var(--font-13, 13px);
245
+ // font-weight: 400;
246
+ // line-height: var(--font-16, 16px);
247
+ // color: var(--black-90, #212121);
248
+ // border: none;
249
+ //
250
+ // &::placeholder {
251
+ // font-size: var(--font-13, 13px);
252
+ // font-weight: 300;
253
+ // font-style: italic;
254
+ // color: var(--gray-90, #212121);
255
+ // }
256
+ // }
257
+ //
258
+ // &--disabled {
259
+ // pointer-events: none;
260
+ // user-select: none;
261
+ // opacity: 0.5;
262
+ // }
263
+ //
264
+ // &--focused {
265
+ // .ui3n-text {
266
+ // &__body, &__content {
267
+ // background-color: var(--blue-main-20, #d8edfd);
268
+ // outline: none;
269
+ // border: none;
270
+ // }
271
+ // }
272
+ // }
273
+ //}
184
274
  </style>
185
- ../tools/textarea-max-rows
@@ -1,80 +1,80 @@
1
1
  <script lang="ts" setup generic="T extends { id?: string }">
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
- import { computed, onMounted, ref } from 'vue'
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import { computed, onMounted, ref } from 'vue';
4
4
 
5
- export interface Ui3nVirtualScrollProps<T> {
6
- items: T[];
7
- minChildHeight: number;
8
- renderAhread?: number;
9
- }
5
+ export interface Ui3nVirtualScrollProps<T> {
6
+ items: T[];
7
+ minChildHeight: number;
8
+ renderAhead?: number;
9
+ }
10
10
 
11
- export interface Ui3nVirtualScrollSlots<T> {
12
- item: (item: T, index: number) => any;
13
- }
11
+ export interface Ui3nVirtualScrollSlots<T> {
12
+ item: ({ value, index }: { value: T, index: number}) => any;
13
+ }
14
14
 
15
- const props = withDefaults(defineProps<Ui3nVirtualScrollProps<T>>(), {
16
- renderAhread: 20,
17
- })
18
- defineSlots<Ui3nVirtualScrollSlots<T>>()
15
+ const props = withDefaults(defineProps<Ui3nVirtualScrollProps<T>>(), {
16
+ renderAhead: 20,
17
+ });
18
+ defineSlots<Ui3nVirtualScrollSlots<T>>();
19
19
 
20
- const scrollTop = ref(0)
21
- const animationFrame = ref<number | undefined>()
22
- const wrapElement = ref<HTMLDivElement | null>(null)
23
- const wrapElementHeight = computed(() => wrapElement.value
24
- ? wrapElement.value.clientHeight
25
- : 0
26
- )
27
- const itemCount = computed(() => props.items.length)
28
- const totalHeight = computed(() => itemCount.value * props.minChildHeight)
29
- const startNode = computed(() => {
30
- const val = Math.floor(scrollTop.value / props.minChildHeight) - props.renderAhread
31
- return Math.max(0, val)
32
- })
33
- const visibleNodeCount = computed(() => {
34
- const val = Math.ceil(wrapElementHeight.value / props.minChildHeight) +2 * props.renderAhread
35
- return Math.min(itemCount.value - startNode.value, val)
36
- })
37
- const offsetY = computed(() => startNode.value * props.minChildHeight)
38
- const visibleChildren = computed(() => props.items.slice(startNode.value, startNode.value + visibleNodeCount.value))
20
+ const scrollTop = ref(0);
21
+ const animationFrame = ref<number | undefined>();
22
+ const wrapElement = ref<HTMLDivElement | null>(null);
23
+ const wrapElementHeight = computed(() => wrapElement.value
24
+ ? wrapElement.value.clientHeight
25
+ : 0,
26
+ );
27
+ const itemCount = computed(() => props.items.length);
28
+ const totalHeight = computed(() => itemCount.value * props.minChildHeight);
29
+ const startNode = computed(() => {
30
+ const val = Math.floor(scrollTop.value / props.minChildHeight) - props.renderAhead;
31
+ return Math.max(0, val);
32
+ });
33
+ const visibleNodeCount = computed(() => {
34
+ const val = Math.ceil(wrapElementHeight.value / props.minChildHeight) + 2 * props.renderAhead;
35
+ return Math.min(itemCount.value - startNode.value, val);
36
+ });
37
+ const offsetY = computed(() => startNode.value * props.minChildHeight);
38
+ const visibleChildren = computed(() => props.items.slice(startNode.value, startNode.value + visibleNodeCount.value));
39
39
 
40
- const onScroll = (event: Event) => {
41
- if (animationFrame.value) {
42
- cancelAnimationFrame(animationFrame.value)
43
- }
44
-
45
- animationFrame.value = requestAnimationFrame(() => scrollTop.value = (event.target as HTMLDivElement).scrollTop)
40
+ const onScroll = (event: Event) => {
41
+ if (animationFrame.value) {
42
+ cancelAnimationFrame(animationFrame.value);
46
43
  }
47
44
 
48
- onMounted(() => {
49
- if (wrapElement.value) {
50
- scrollTop.value = wrapElement.value.scrollTop
51
- }
52
- })
45
+ animationFrame.value = requestAnimationFrame(() => scrollTop.value = (event.target as HTMLDivElement).scrollTop);
46
+ };
47
+
48
+ onMounted(() => {
49
+ if (wrapElement.value) {
50
+ scrollTop.value = wrapElement.value.scrollTop;
51
+ }
52
+ });
53
53
  </script>
54
54
 
55
55
  <template>
56
56
  <div
57
57
  ref="wrapElement"
58
- class="ui3n-virtual-scroll"
58
+ :class="$style.virtualScroll"
59
59
  @scroll="onScroll"
60
60
  >
61
61
  <div
62
- class="ui3n-virtual-scroll__viewport"
62
+ :class="$style.viewport"
63
63
  :style="{ height: `${totalHeight}px` }"
64
64
  >
65
65
  <div
66
- class="ui3n-virtual-scroll__content"
66
+ :class="$style.content"
67
67
  :style="{ transform: `translateY(${offsetY}px)` }"
68
68
  >
69
69
  <div
70
70
  v-for="(item, index) in visibleChildren"
71
71
  :key="item.id"
72
72
  :data-sid="item.id ?? index"
73
- class="ui3n-virtual-scroll__item"
73
+ :class="$style.item"
74
74
  >
75
75
  <slot
76
76
  name="item"
77
- :item="item"
77
+ :value="item"
78
78
  :index="startNode + index"
79
79
  />
80
80
  </div>
@@ -83,26 +83,26 @@
83
83
  </div>
84
84
  </template>
85
85
 
86
- <style lang="scss" scoped>
87
- .ui3n-virtual-scroll {
88
- position: relative;
89
- width: 100%;
90
- height: 100%;
91
- overflow-y: auto;
86
+ <style lang="scss" module>
87
+ .virtualScroll {
88
+ position: relative;
89
+ width: 100%;
90
+ height: 100%;
91
+ overflow-y: auto;
92
+ }
92
93
 
93
- &__viewport {
94
- position: relative;
95
- overflow: hidden;
96
- will-change: transform;
97
- }
94
+ .viewport {
95
+ position: relative;
96
+ overflow: hidden;
97
+ will-change: transform;
98
+ }
98
99
 
99
- &__content {
100
- will-change: transform;
101
- }
100
+ .content {
101
+ will-change: transform;
102
+ }
102
103
 
103
- &__item {
104
- position: relative;
105
- min-height: 16px;
106
- }
107
- }
104
+ .item {
105
+ position: relative;
106
+ min-height: 16px;
107
+ }
108
108
  </style>