@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,110 +1,110 @@
1
1
  <script lang="ts" setup>
2
- import { computed, ref } from 'vue'
3
- import { Icon } from '@iconify/vue'
4
- import Ui3nTableSortIcon from './ui3n-table-sort-icon.vue'
5
- import type { ListingEntryTypeExtended, EntityAction, SortField } from '../constants'
6
-
7
- export interface Ui3nTableProps {
8
- items: ListingEntryTypeExtended[];
9
- textIfEmpty?: string;
2
+ import { computed, ref } from 'vue';
3
+ import { Icon } from '@iconify/vue';
4
+ import Ui3nTableSortIcon from './ui3n-table-sort-icon.vue';
5
+ import type { ListingEntryTypeExtended, EntityAction, SortField } from '../constants';
6
+
7
+ export interface Ui3nTableProps {
8
+ items: ListingEntryTypeExtended[];
9
+ textIfEmpty?: string;
10
+ }
11
+
12
+ export interface Ui3nTableEmits {
13
+ (ev: 'go', name: string): void;
14
+ (ev: 'action', value: { action: EntityAction, entity: ListingEntryTypeExtended }): void;
15
+ }
16
+
17
+ const props = defineProps<Ui3nTableProps>();
18
+ const emits = defineEmits<Ui3nTableEmits>();
19
+
20
+ const sortField = ref<SortField>('name');
21
+ const sortDirection = ref<'asc' | 'desc'>('asc');
22
+
23
+ const sortByName = (itemA: ListingEntryTypeExtended, itemB: ListingEntryTypeExtended) => {
24
+ if (sortDirection.value === 'desc') {
25
+ return itemA.name < itemB.name ? 1 : -1;
10
26
  }
11
-
12
- export interface Ui3nTableEmits {
13
- (ev: 'go', name: string): void;
14
- (ev: 'action', value: { action: EntityAction, entity: ListingEntryTypeExtended }): void;
27
+ return itemA.name > itemB.name ? 1 : -1;
28
+ };
29
+ const sortByType = (itemA: ListingEntryTypeExtended, itemB: ListingEntryTypeExtended) => {
30
+ if (sortDirection.value === 'desc') {
31
+ return itemA.type! < itemB.type! ? 1 : -1;
15
32
  }
16
-
17
- const props = defineProps<Ui3nTableProps>()
18
- const emit = defineEmits<Ui3nTableEmits>()
19
-
20
- const sortField = ref<SortField>('name')
21
- const sortDirection = ref<'asc'|'desc'>('asc')
22
-
23
- const sortByName = (itemA: ListingEntryTypeExtended, itemB: ListingEntryTypeExtended) => {
24
- if (sortDirection.value === 'desc') {
25
- return itemA.name < itemB.name ? 1 : -1
26
- }
27
- return itemA.name > itemB.name ? 1 : -1
33
+ return itemA.type! > itemB.type! ? 1 : -1;
34
+ };
35
+ const sortByCreatedAt = (itemA: ListingEntryTypeExtended, itemB: ListingEntryTypeExtended) => {
36
+ const tsA = itemA.ctime!.getTime();
37
+ const tsB = itemB.ctime!.getTime();
38
+ return sortDirection.value === 'asc' ? tsA - tsB : tsB - tsA;
39
+ };
40
+ const sortByChangedAt = (itemA: ListingEntryTypeExtended, itemB: ListingEntryTypeExtended) => {
41
+ const tsA = itemA.mtime!.getTime();
42
+ const tsB = itemB.mtime!.getTime();
43
+ return sortDirection.value === 'asc' ? tsA - tsB : tsB - tsA;
44
+ };
45
+
46
+ const placeholder = computed(() => props.textIfEmpty || 'Empty');
47
+ const sortMap = {
48
+ name: sortByName,
49
+ type: sortByType,
50
+ createdAt: sortByCreatedAt,
51
+ changedAt: sortByChangedAt,
52
+ };
53
+ const sortedItems = computed(() => [...props.items].sort(sortMap[sortField.value]));
54
+ const changeSort = (field: SortField) => {
55
+ if (field !== sortField.value) {
56
+ sortField.value = field;
57
+ sortDirection.value = 'asc';
58
+ } else {
59
+ sortDirection.value = sortDirection.value === 'asc' ? 'desc' : 'asc';
28
60
  }
29
- const sortByType = (itemA: ListingEntryTypeExtended, itemB: ListingEntryTypeExtended) => {
30
- if (sortDirection.value === 'desc') {
31
- return itemA.type! < itemB.type! ? 1 : -1
32
- }
33
- return itemA.type! > itemB.type! ? 1 : -1
61
+ };
62
+
63
+ const getTimeAsString = (date: Date) => {
64
+ return date
65
+ ? `${`${date.getDate()}`.padStart(2, '0')}/${`${date.getMonth() + 1}`.padStart(2, '0')}/${date.getFullYear()} ${`${date.getHours()}`.padStart(2, '0')}:${`${date.getMinutes()}`.padStart(2, '0')}`
66
+ : '';
67
+ };
68
+
69
+ const handleClick = (ev: MouseEvent) => {
70
+ ev.preventDefault();
71
+ const { target } = ev;
72
+ const { id, classList } = target as Element;
73
+ if (classList.contains('ui3n-table__item') && id) {
74
+ return props.items.find(i => i.id === id);
34
75
  }
35
- const sortByCreatedAt = (itemA: ListingEntryTypeExtended, itemB: ListingEntryTypeExtended) => {
36
- const tsA = itemA.ctime!.getTime()
37
- const tsB = itemB.ctime!.getTime()
38
- return sortDirection.value === 'asc' ? tsA - tsB : tsB - tsA
76
+ return undefined;
77
+ };
78
+ const onClick = (ev: MouseEvent) => {
79
+ handleClick(ev);
80
+ const entity = handleClick(ev);
81
+ if (entity && entity.isFolder && entity.fullPath) {
82
+ emits('go', entity.fullPath);
39
83
  }
40
- const sortByChangedAt = (itemA: ListingEntryTypeExtended, itemB: ListingEntryTypeExtended) => {
41
- const tsA = itemA.mtime!.getTime()
42
- const tsB = itemB.mtime!.getTime()
43
- return sortDirection.value === 'asc' ? tsA - tsB : tsB - tsA
84
+ };
85
+ const onRightClick = (ev: MouseEvent) => {
86
+ handleClick(ev);
87
+ const entity = handleClick(ev);
88
+ if (entity) {
89
+ emits('action', { action: 'open:menu', entity });
44
90
  }
91
+ };
45
92
 
46
- const placeholder = computed(() => props.textIfEmpty || 'Empty')
47
- const sortMap = {
48
- name: sortByName,
49
- type: sortByType,
50
- createdAt: sortByCreatedAt,
51
- changedAt: sortByChangedAt,
52
- }
53
- const sortedItems =computed(() => [...props.items].sort(sortMap[sortField.value]))
54
- const changeSort = (field: SortField) => {
55
- if (field !== sortField.value) {
56
- sortField.value = field
57
- sortDirection.value = 'asc'
58
- } else {
59
- sortDirection.value = sortDirection.value === 'asc' ? 'desc' : 'asc'
60
- }
61
- }
62
-
63
- const getTimeAsString = (date: Date) => {
64
- return date
65
- ? `${`${date.getDate()}`.padStart(2, '0')}/${`${date.getMonth() + 1}`.padStart(2, '0')}/${date.getFullYear()} ${`${date.getHours()}`.padStart(2, '0')}:${`${date.getMinutes()}`.padStart(2, '0')}`
66
- : ''
67
- }
68
-
69
- const handleClick = (ev: MouseEvent) => {
70
- ev.preventDefault()
71
- const { target } = ev
72
- const { id, classList } = target as Element
73
- if (classList.contains('ui3n-table__item') && id) {
74
- return props.items.find(i => i.id === id)
75
- }
76
- return undefined
77
- }
78
- const onClick = (ev: MouseEvent) => {
79
- handleClick(ev)
80
- const entity = handleClick(ev)
81
- if (entity && entity.isFolder && entity.fullPath) {
82
- emit('go', entity.fullPath)
83
- }
84
- }
85
- const onRightClick = (ev: MouseEvent) => {
86
- handleClick(ev)
87
- const entity = handleClick(ev)
88
- if (entity) {
89
- emit( 'action', { action: 'open-menu', entity })
90
- }
91
- }
92
-
93
- const handleActions = (ev: MouseEvent, action: EntityAction, entity: ListingEntryTypeExtended) => {
94
- ev.preventDefault()
95
- ev.stopImmediatePropagation()
96
- emit('action', { action, entity })
97
- }
93
+ const handleActions = (ev: MouseEvent, action: EntityAction, entity: ListingEntryTypeExtended) => {
94
+ ev.preventDefault();
95
+ ev.stopImmediatePropagation();
96
+ emits('action', { action, entity });
97
+ };
98
98
  </script>
99
99
 
100
100
  <template>
101
- <div class="ui3n-table">
102
- <div class="ui3n-table__header">
101
+ <div :class="$style.table">
102
+ <div :class="$style.header">
103
103
  <div
104
- class="ui3n-table__header-cell ui3n-table__header-cell--sortable ui3n-table__name"
104
+ :class="[$style.cellHeader, $style.cellHeaderSortable, $style.columnName]"
105
105
  @click="changeSort('name')"
106
106
  >
107
- <span class="ui3n-table__header-text">Name</span>
107
+ <span :class="$style.cellHeaderText">Name</span>
108
108
  <ui3n-table-sort-icon
109
109
  v-if="sortField === 'name'"
110
110
  :value="sortDirection"
@@ -112,10 +112,10 @@
112
112
  />
113
113
  </div>
114
114
  <div
115
- class="ui3n-table__header-cell ui3n-table__header-cell--sortable ui3n-table__type"
115
+ :class="[$style.cellHeader, $style.cellHeaderSortable, $style.columnType]"
116
116
  @click="changeSort('type')"
117
117
  >
118
- <span class="ui3n-table__header-text">Type</span>
118
+ <span :class="$style.cellHeaderText">Type</span>
119
119
  <ui3n-table-sort-icon
120
120
  v-if="sortField === 'type'"
121
121
  :value="sortDirection"
@@ -124,10 +124,10 @@
124
124
  </div>
125
125
 
126
126
  <div
127
- class="ui3n-table__header-cell ui3n-table__header-cell--sortable ui3n-table__changedAt"
127
+ :class="[$style.cellHeader, $style.cellHeaderSortable, $style.columnChangeAt]"
128
128
  @click="changeSort('changedAt')"
129
129
  >
130
- <span class="ui3n-table__header-text">Changed At</span>
130
+ <span :class="$style.cellHeaderText">Changed At</span>
131
131
  <ui3n-table-sort-icon
132
132
  v-if="sortField === 'changedAt'"
133
133
  :value="sortDirection"
@@ -136,12 +136,12 @@
136
136
  </div>
137
137
  </div>
138
138
 
139
- <div class="ui3n-table__content">
139
+ <div :class="$style.content">
140
140
  <div
141
141
  v-for="item in sortedItems"
142
142
  :id="item.id"
143
143
  :key="item.id"
144
- class="ui3n-table__item"
144
+ :class="$style.row"
145
145
  @click="onClick"
146
146
  @click.right="onRightClick"
147
147
  >
@@ -149,15 +149,15 @@
149
149
  :icon="item.isFolder ? 'folder' : 'subject'"
150
150
  :width="16"
151
151
  :height="16"
152
- class="ui3n-table__item-icon"
152
+ :class="$style.rowIcon"
153
153
  />
154
- <div class="ui3n-table__item-cell ui3n-table__name">
154
+ <div :class="[$style.cellRow, $style.columnName]">
155
155
  {{ item.name }}
156
156
  </div>
157
- <div class="ui3n-table__item-cell ui3n-table__type">
157
+ <div :class="[$style.cellRow, $style.columnType]">
158
158
  {{ item.ext || '' }}
159
159
  </div>
160
- <div class="ui3n-table__item-cell ui3n-table__changedAt">
160
+ <div :class="[$style.cellRow, $style.columnChangeAt]">
161
161
  {{ getTimeAsString(item.mtime!) }}
162
162
  </div>
163
163
 
@@ -166,7 +166,7 @@
166
166
  icon="bookmark"
167
167
  :width="12"
168
168
  :height="12"
169
- class="ui3n-table__item-bookmark"
169
+ :class="$style.rowBookmark"
170
170
  @click="handleActions($event, 'add:favorites', item)"
171
171
  />
172
172
 
@@ -174,14 +174,14 @@
174
174
  icon="baseline-edit"
175
175
  :width="12"
176
176
  :height="12"
177
- class="ui3n-table__item-rename"
177
+ :class="$style.rowRename"
178
178
  @click="handleActions($event, 'rename', item)"
179
179
  />
180
180
  </div>
181
181
 
182
182
  <div
183
183
  v-if="!sortedItems.length"
184
- class="ui3n-table__empty"
184
+ :class="$style.emptyText"
185
185
  >
186
186
  {{ placeholder }}
187
187
  </div>
@@ -189,135 +189,140 @@
189
189
  </div>
190
190
  </template>
191
191
 
192
- <style lang="scss" scoped>
193
- @import "../assets/styles/mixins";
194
-
195
- .ui3n-table {
196
- --table-header-height: 36px;
197
- --table-row-height: 28px;
198
-
199
- position: relative;
200
- width: 100%;
201
- height: 100%;
202
- overflow-x: hidden;
203
- overflow-y: auto;
204
-
205
- &__header {
206
- position: sticky;
207
- top: 0;
208
- display: flex;
209
- width: 100%;
210
- height: var(--table-header-height);
211
- justify-content: flex-start;
212
- align-items: center;
213
- padding: 0 calc(var(--base-size) * 2);
214
- background-color: var(--gray-50);
215
-
216
- &-cell {
217
- display: flex;
218
- justify-content: flex-start;
219
- align-items: center;
220
- font-size: var(--font-13);
221
- line-height: var(--font-18);
222
- font-weight: 500;
223
- color: var(--black-90);
224
-
225
- &--sortable {
226
- cursor: pointer;
227
- }
228
- }
229
-
230
- &-text {
231
- display: block;
232
- position: relative;
233
- @include text-overflow-ellipsis(100%)
234
- }
235
- }
236
-
237
- &__item {
238
- display: flex;
239
- width: 100%;
240
- height: var(--table-row-height);
241
- justify-content: flex-start;
242
- align-items: center;
243
- padding: 0 calc(var(--base-size) * 2) 0 calc(var(--base-size) * 5);
244
- cursor: pointer;
245
- border-bottom: 1px solid var(--gray-50);
246
-
247
- &-bookmark,
248
- &-rename {
249
- display: none;
250
- position: absolute;
251
- z-index: 1;
252
- color: var(--black-30);
253
- }
254
-
255
- &-bookmark {
256
- left: 2px;
257
- }
258
-
259
- &-rename {
260
- right: calc(var(--base-size) * 13 + 24px);
261
- }
262
-
263
- &-icon {
264
- position: absolute;
265
- left: calc(var(--base-size) * 2);
266
- color: var(--black-30);
267
- pointer-events: none;
268
- }
269
-
270
- &-cell {
271
- position: relative;
272
- font-weight: 400;
273
- pointer-events: none;
274
- }
275
-
276
- &:hover {
277
- background-color: var(--blue-main-30);
278
-
279
- .ui3n-table__item-bookmark,
280
- .ui3n-table__item-rename {
281
- display: block;
282
- }
283
-
284
- .ui3n-table__item-icon {
285
- color: var(--blue-main);
286
- }
287
- }
192
+ <style lang="scss" module>
193
+ @import "../assets/styles/mixins";
194
+
195
+ .table {
196
+ --table-header-height: 36px;
197
+ --table-row-height: 28px;
198
+
199
+ position: relative;
200
+ width: 100%;
201
+ height: 100%;
202
+ overflow-x: hidden;
203
+ overflow-y: auto;
204
+ }
205
+
206
+ .header {
207
+ position: sticky;
208
+ top: 0;
209
+ display: flex;
210
+ width: 100%;
211
+ height: var(--table-header-height);
212
+ justify-content: flex-start;
213
+ align-items: center;
214
+ padding: var(--spacing-m);
215
+ background-color: var(--color-bg-table-header-default);
216
+ }
217
+
218
+ .cellHeader {
219
+ display: flex;
220
+ justify-content: flex-start;
221
+ align-items: center;
222
+ font-size: var(--font-14);
223
+ line-height: var(--font-20);
224
+ font-weight: 500;
225
+ color: var(--color-text-table-primary-default);
226
+ }
227
+
228
+ .cellHeaderSortable {
229
+ cursor: pointer;
230
+ }
231
+
232
+ .cellHeaderText {
233
+ display: block;
234
+ position: relative;
235
+ @include text-overflow-ellipsis(100%);
236
+ }
237
+
238
+ .row {
239
+ display: flex;
240
+ width: 100%;
241
+ height: var(--table-row-height);
242
+ justify-content: flex-start;
243
+ align-items: center;
244
+ padding: 0 var(--spacing-m) 0 calc(var(--spacing-l) + var(--spacing-s));
245
+ cursor: pointer;
246
+ border-bottom: 1px solid var(--color-border-table-primary-default);
247
+
248
+ &:hover {
249
+ background-color: var(--color-bg-control-primary-hover);
250
+
251
+ .rowBookmark,
252
+ .rowRename {
253
+ display: block;
288
254
  }
289
255
 
290
- &__name {
291
- flex: 1 0;
292
-
293
- &.ui3n-table__item-cell {
294
- font-size: var(--font-12);
295
- }
256
+ .rowIcon {
257
+ color: var(--color-icon-table-accent-hover);
296
258
  }
259
+ }
260
+ }
261
+
262
+ .rowBookmark,
263
+ .rowRename {
264
+ display: none;
265
+ position: absolute;
266
+ z-index: 1;
267
+ color: var(--color-icon-control-accent-unselected);
268
+ }
269
+
270
+ .rowBookmark {
271
+ left: 2px;
272
+ }
273
+
274
+ .rowRename {
275
+ right: calc(var(--spacing-l) * 4);
276
+ }
277
+
278
+ .rowIcon {
279
+ position: absolute;
280
+ left: var(--spacing-m);
281
+ color: var(--color-icon-table-secondary-default);
282
+ pointer-events: none;
283
+ }
284
+
285
+ .cellRow {
286
+ position: relative;
287
+ font-weight: 400;
288
+ pointer-events: none;
289
+ }
290
+
291
+ .columnName {
292
+ flex: 1 0;
293
+
294
+ .rowCell {
295
+ font-size: var(--font-12);
296
+ }
297
+ }
297
298
 
298
- &__type {
299
- width: calc(var(--base-size) * 7);
300
- text-align: center;
299
+ .columnType {
300
+ position: relative;
301
+ width: 56px;
302
+ display: flex;
303
+ justify-content: center;
304
+ align-items: center;
301
305
 
302
- &.ui3n-table__item-cell {
303
- font-size: var(--font-10);
304
- }
305
- }
306
306
 
307
- &__changedAt {
308
- width: calc(var(--base-size) * 13);
307
+ .rowCell {
308
+ font-size: var(--font-10);
309
+ }
310
+ }
309
311
 
310
- &.ui3n-table__item-cell {
311
- font-size: var(--font-11);
312
- }
313
- }
312
+ .columnChangeAt {
313
+ position: relative;
314
+ width: 104px;
314
315
 
315
- &__empty {
316
- font-size: var(--font-20);
317
- font-style: italic;
318
- color: var(--black-30);
319
- text-align: center;
320
- padding-top: calc(var(--base-size) * 10);
321
- }
316
+ .rowCell {
317
+ font-size: var(--font-12);
322
318
  }
319
+ }
320
+
321
+ .emptyText {
322
+ font-size: var(--font-14);
323
+ line-height: var(--font-20);
324
+ color: var(--color-text-control-secondary-default);
325
+ text-align: center;
326
+ padding: 56px 0;
327
+ }
323
328
  </style>