@v1nt1248/3nclient-lib 0.1.5 → 0.1.7

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 (126) hide show
  1. package/dist/components/index.d.ts +42 -23
  2. package/dist/components/ui3n-badge/types.d.ts +13 -0
  3. package/dist/components/{ui3n-badge-simple.vue.d.ts → ui3n-badge/ui3n-badge-simple.vue.d.ts} +2 -7
  4. package/dist/components/{ui3n-badge.vue.d.ts → ui3n-badge/ui3n-badge.vue.d.ts} +2 -8
  5. package/dist/components/ui3n-breadcrumbs/types.d.ts +17 -0
  6. package/dist/components/{ui3n-breadcrumb.vue.d.ts → ui3n-breadcrumbs/ui3n-breadcrumb.vue.d.ts} +1 -12
  7. package/dist/components/{ui3n-breadcrumbs.vue.d.ts → ui3n-breadcrumbs/ui3n-breadcrumbs.vue.d.ts} +1 -4
  8. package/dist/components/ui3n-button/types.d.ts +19 -0
  9. package/dist/components/{ui3n-button.vue.d.ts → ui3n-button/ui3n-button.vue.d.ts} +3 -21
  10. package/dist/components/ui3n-checkbox/types.d.ts +18 -0
  11. package/dist/components/{ui3n-checkbox.vue.d.ts → ui3n-checkbox/ui3n-checkbox.vue.d.ts} +3 -19
  12. package/dist/components/ui3n-chip/types.d.ts +21 -0
  13. package/dist/components/{ui3n-chip.vue.d.ts → ui3n-chip/ui3n-chip.vue.d.ts} +1 -20
  14. package/dist/components/ui3n-dialog/types.d.ts +36 -0
  15. package/dist/components/{ui3n-dialog.vue.d.ts → ui3n-dialog/ui3n-dialog.vue.d.ts} +1 -36
  16. package/dist/components/ui3n-drop-files/types.d.ts +12 -0
  17. package/dist/components/{ui3n-drop-files.vue.d.ts → ui3n-drop-files/ui3n-drop-files.vue.d.ts} +2 -11
  18. package/dist/components/ui3n-emoji/types.d.ts +8 -0
  19. package/dist/components/{ui3n-emoji.vue.d.ts → ui3n-emoji/ui3n-emoji.vue.d.ts} +1 -8
  20. package/dist/components/ui3n-icon/types.d.ts +16 -0
  21. package/dist/components/{ui3n-icon.vue.d.ts → ui3n-icon/ui3n-icon.vue.d.ts} +1 -16
  22. package/dist/components/ui3n-input/types.d.ts +25 -0
  23. package/dist/components/{ui3n-input.vue.d.ts → ui3n-input/ui3n-input.vue.d.ts} +3 -27
  24. package/dist/components/ui3n-list/types.d.ts +20 -0
  25. package/dist/components/{ui3n-list.vue.d.ts → ui3n-list/ui3n-list.vue.d.ts} +1 -19
  26. package/dist/components/ui3n-notification/types.d.ts +11 -0
  27. package/dist/components/{ui3n-notification.vue.d.ts → ui3n-notification/ui3n-notification.vue.d.ts} +2 -2
  28. package/dist/components/ui3n-progress/types.d.ts +17 -0
  29. package/dist/components/{ui3n-progress-circular.vue.d.ts → ui3n-progress/ui3n-progress-circular.vue.d.ts} +3 -11
  30. package/dist/components/{ui3n-progress-linear.vue.d.ts → ui3n-progress/ui3n-progress-linear.vue.d.ts} +2 -9
  31. package/dist/components/ui3n-step-line-bar/types.d.ts +5 -0
  32. package/dist/components/{ui3n-step-line-bar.vue.d.ts → ui3n-step-line-bar/ui3n-step-line-bar.vue.d.ts} +1 -5
  33. package/dist/components/ui3n-switch/types.d.ts +14 -0
  34. package/dist/components/{ui3n-switch.vue.d.ts → ui3n-switch/ui3n-switch.vue.d.ts} +2 -14
  35. package/dist/components/ui3n-table/composables/useTable.d.ts +1 -1
  36. package/dist/components/ui3n-table/types.d.ts +5 -0
  37. package/dist/components/{ui3n-table-sort-icon.vue.d.ts → ui3n-table/ui3n-table-sort-icon.vue.d.ts} +1 -5
  38. package/dist/components/ui3n-tabs/types.d.ts +16 -0
  39. package/dist/components/{ui3n-tabs.vue.d.ts → ui3n-tabs/ui3n-tabs.vue.d.ts} +2 -18
  40. package/dist/components/ui3n-text/types.d.ts +17 -0
  41. package/dist/components/{ui3n-text.vue.d.ts → ui3n-text/ui3n-text.vue.d.ts} +5 -21
  42. package/dist/components/ui3n-tooltip/ui3n-tooltip.vue.d.ts +63 -0
  43. package/dist/components/ui3n-virtual-scroll/types.d.ts +12 -0
  44. package/dist/components/{ui3n-virtual-scroll.vue.d.ts → ui3n-virtual-scroll/ui3n-virtual-scroll.vue.d.ts} +1 -11
  45. package/dist/constants/index.d.ts +0 -1
  46. package/dist/index.d.ts +26 -24
  47. package/dist/plugins/dialogs/dialogs.d.ts +9 -0
  48. package/dist/plugins/{store-dialogs.d.ts → dialogs/store-dialogs.d.ts} +1 -1
  49. package/dist/plugins/dialogs/types.d.ts +12 -0
  50. package/dist/plugins/i18n/i18n.d.ts +9 -0
  51. package/dist/plugins/{i18n.d.ts → i18n/types.d.ts} +1 -9
  52. package/dist/plugins/index.d.ts +13 -9
  53. package/dist/plugins/notifications/notifications.d.ts +8 -0
  54. package/dist/plugins/{store-notifications.d.ts → notifications/store-notifications.d.ts} +1 -1
  55. package/dist/plugins/notifications/types.d.ts +6 -0
  56. package/dist/plugins/{store-vue-bus.d.ts → vue-bus/store-vue-bus.d.ts} +1 -1
  57. package/dist/plugins/vue-bus/types.d.ts +13 -0
  58. package/dist/plugins/{vue-bus.d.ts → vue-bus/vue-bus.d.ts} +2 -6
  59. package/dist/style.css +1 -1
  60. package/dist/ui3n-components.d.ts +60 -0
  61. package/dist/ui3n-components.js +5252 -0
  62. package/dist/ui3n-plugins.d.ts +44 -0
  63. package/dist/ui3n-plugins.js +5678 -0
  64. package/dist/ui3n-utils.d.ts +2 -0
  65. package/dist/{ui-3n-lib.js → ui3n-utils.js} +4477 -14513
  66. package/dist/{tools → utils}/index.d.ts +2 -2
  67. package/package.json +18 -6
  68. package/src/components/index.ts +53 -41
  69. package/src/components/ui3n-badge/types.ts +14 -0
  70. package/src/components/{ui3n-badge-simple.vue → ui3n-badge/ui3n-badge-simple.vue} +29 -35
  71. package/src/components/ui3n-badge/ui3n-badge.vue +82 -0
  72. package/src/components/ui3n-breadcrumbs/types.ts +21 -0
  73. package/src/components/{ui3n-breadcrumb.vue → ui3n-breadcrumbs/ui3n-breadcrumb.vue} +1 -14
  74. package/src/components/{ui3n-breadcrumbs.vue → ui3n-breadcrumbs/ui3n-breadcrumbs.vue} +1 -4
  75. package/src/components/ui3n-button/types.ts +20 -0
  76. package/src/components/{ui3n-button.vue → ui3n-button/ui3n-button.vue} +3 -23
  77. package/src/components/ui3n-checkbox/types.ts +22 -0
  78. package/src/components/{ui3n-checkbox.vue → ui3n-checkbox/ui3n-checkbox.vue} +2 -23
  79. package/src/components/ui3n-chip/types.ts +19 -0
  80. package/src/components/{ui3n-chip.vue → ui3n-chip/ui3n-chip.vue} +32 -50
  81. package/src/components/ui3n-dialog/types.ts +40 -0
  82. package/src/components/{ui3n-dialog.vue → ui3n-dialog/ui3n-dialog.vue} +3 -49
  83. package/src/components/ui3n-drop-files/types.ts +15 -0
  84. package/src/components/{ui3n-drop-files.vue → ui3n-drop-files/ui3n-drop-files.vue} +2 -10
  85. package/src/components/ui3n-emoji/types.ts +9 -0
  86. package/src/components/{ui3n-emoji.vue → ui3n-emoji/ui3n-emoji.vue} +2 -11
  87. package/src/components/ui3n-icon/types.ts +17 -0
  88. package/src/components/ui3n-icon/ui3n-icon.vue +53 -0
  89. package/src/components/ui3n-input/types.ts +26 -0
  90. package/src/components/{ui3n-input.vue → ui3n-input/ui3n-input.vue} +4 -30
  91. package/src/components/ui3n-list/types.ts +17 -0
  92. package/src/components/{ui3n-list.vue → ui3n-list/ui3n-list.vue} +1 -16
  93. package/src/components/ui3n-notification/types.ts +11 -0
  94. package/src/components/{ui3n-notification.vue → ui3n-notification/ui3n-notification.vue} +3 -3
  95. package/src/components/ui3n-progress/types.ts +18 -0
  96. package/src/components/{ui3n-progress-circular.vue → ui3n-progress/ui3n-progress-circular.vue} +1 -10
  97. package/src/components/{ui3n-progress-linear.vue → ui3n-progress/ui3n-progress-linear.vue} +1 -9
  98. package/src/components/ui3n-step-line-bar/types.ts +5 -0
  99. package/src/components/{ui3n-step-line-bar.vue → ui3n-step-line-bar/ui3n-step-line-bar.vue} +1 -5
  100. package/src/components/ui3n-switch/types.ts +17 -0
  101. package/src/components/{ui3n-switch.vue → ui3n-switch/ui3n-switch.vue} +1 -16
  102. package/src/components/ui3n-table/composables/useTable.ts +1 -1
  103. package/src/components/ui3n-table/types.ts +6 -0
  104. package/src/components/{ui3n-table-sort-icon.vue → ui3n-table/ui3n-table-sort-icon.vue} +2 -7
  105. package/src/components/ui3n-table/ui3n-table.vue +3 -3
  106. package/src/components/ui3n-tabs/types.ts +19 -0
  107. package/src/components/{ui3n-tabs.vue → ui3n-tabs/ui3n-tabs.vue} +3 -20
  108. package/src/components/ui3n-text/types.ts +18 -0
  109. package/src/components/{ui3n-text.vue → ui3n-text/ui3n-text.vue} +2 -21
  110. package/src/components/ui3n-virtual-scroll/types.ts +11 -0
  111. package/src/components/{ui3n-virtual-scroll.vue → ui3n-virtual-scroll/ui3n-virtual-scroll.vue} +1 -11
  112. package/dist/constants/types.d.ts +0 -29
  113. package/dist/plugins/dialogs.d.ts +0 -18
  114. package/dist/plugins/notifications.d.ts +0 -12
  115. package/src/components/ui3n-badge.vue +0 -89
  116. package/src/components/ui3n-icon.vue +0 -70
  117. package/src/components/ui3n-table-simple.vue +0 -328
  118. /package/dist/plugins/{store-i18n.d.ts → i18n/store-i18n.d.ts} +0 -0
  119. /package/dist/plugins/{icons.d.ts → icons/icons.d.ts} +0 -0
  120. /package/dist/{tools/common.helpers.d.ts → utils/common.utils.d.ts} +0 -0
  121. /package/dist/{tools → utils}/sqlite-on-3nstorage/deferred.d.ts +0 -0
  122. /package/dist/{tools → utils}/sqlite-on-3nstorage/index.d.ts +0 -0
  123. /package/dist/{tools → utils}/sqlite-on-3nstorage/synced.d.ts +0 -0
  124. /package/dist/{tools → utils}/sqlite-on-3nstorage/types.d.ts +0 -0
  125. /package/dist/{tools → utils}/textarea-max-rows.d.ts +0 -0
  126. /package/dist/{tools/ui.helpers.d.ts → utils/ui.utils.d.ts} +0 -0
@@ -1,26 +1,7 @@
1
1
  <script lang="ts" setup>
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
2
  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
- }
15
-
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
- }
3
+ import { patchTextareaMaxRowsSupport } from '@/utils';
4
+ import type { Ui3nTextEmits, Ui3nTextProps } from './types';
24
5
 
25
6
  const props = withDefaults(
26
7
  defineProps<Ui3nTextProps>(),
@@ -0,0 +1,11 @@
1
+ import { VNode } from 'vue';
2
+
3
+ export interface Ui3nVirtualScrollProps<T> {
4
+ items: T[];
5
+ minChildHeight: number;
6
+ renderAhead?: number;
7
+ }
8
+
9
+ export interface Ui3nVirtualScrollSlots<T> {
10
+ item: ({ value, index }: { value: T; index: number }) => VNode;
11
+ }
@@ -1,16 +1,6 @@
1
1
  <script lang="ts" setup generic="T extends { id?: string }">
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
2
  import { computed, onMounted, ref } from 'vue';
4
-
5
- export interface Ui3nVirtualScrollProps<T> {
6
- items: T[];
7
- minChildHeight: number;
8
- renderAhead?: number;
9
- }
10
-
11
- export interface Ui3nVirtualScrollSlots<T> {
12
- item: ({ value, index }: { value: T, index: number}) => any;
13
- }
3
+ import type { Ui3nVirtualScrollProps, Ui3nVirtualScrollSlots } from './types';
14
4
 
15
5
  const props = withDefaults(defineProps<Ui3nVirtualScrollProps<T>>(), {
16
6
  renderAhead: 20,
@@ -1,29 +0,0 @@
1
- export type CbFunction = (...args: any[]) => void;
2
- export interface VueEventBus {
3
- on: (type: string | symbol, handler: CbFunction) => void;
4
- off: (type: string | symbol, handler?: CbFunction) => void;
5
- emit: (type: string | symbol, arg?: any) => void;
6
- once: (type: string | symbol, handler: CbFunction) => void;
7
- clear: () => void;
8
- }
9
- export interface Ui3nNotificationProps {
10
- id?: string;
11
- type?: 'success' | 'warning' | 'info' | 'error';
12
- content: string;
13
- position?: 'left' | 'center' | 'right';
14
- duration?: number;
15
- withIcon?: boolean;
16
- teleport?: string;
17
- onOpen?: () => void;
18
- onClose?: () => void;
19
- }
20
- export interface ListingEntryTypeExtended extends web3n.files.Stats {
21
- id: string | undefined;
22
- name: string;
23
- fullPath?: string;
24
- tags?: string[];
25
- type: string;
26
- ext?: string;
27
- }
28
- export type EntityAction = 'rename' | 'add:favorites' | 'open:menu';
29
- export type SortField = 'name' | 'type' | 'createdAt' | 'changedAt';
@@ -1,18 +0,0 @@
1
- import { Plugin, VNode, InjectionKey } from 'vue';
2
- import { Ui3nDialogComponentProps } from '../components/ui3n-dialog.vue';
3
- export type DialogInstance = {
4
- id: string;
5
- el: HTMLDivElement;
6
- vNode: VNode;
7
- destroy: () => void;
8
- };
9
- export interface DialogsPlugin {
10
- $openDialog: (params: Ui3nDialogComponentProps) => DialogInstance | undefined;
11
- }
12
- export declare const DIALOGS_KEY: InjectionKey<DialogsPlugin>;
13
- export declare const dialogs: Plugin;
14
- declare module '@vue/runtime-core' {
15
- interface ComponentCustomProperties {
16
- $openDialog: (params: Ui3nDialogComponentProps) => DialogInstance | undefined;
17
- }
18
- }
@@ -1,12 +0,0 @@
1
- import { Plugin, InjectionKey } from 'vue';
2
- import { Ui3nNotificationProps } from '../constants';
3
- export interface NotificationsPlugin {
4
- $createNotice: (params: Ui3nNotificationProps) => void;
5
- }
6
- export declare const NOTIFICATIONS_KEY: InjectionKey<NotificationsPlugin>;
7
- export declare const notifications: Plugin;
8
- declare module '@vue/runtime-core' {
9
- interface ComponentCustomProperties {
10
- $createNotice: (params: Ui3nNotificationProps) => void;
11
- }
12
- }
@@ -1,89 +0,0 @@
1
- <script lang="ts" setup>
2
- import { computed, ref, useSlots } from 'vue';
3
- import get from 'lodash/get';
4
- import Ui3nBadgeSimple from './ui3n-badge-simple.vue';
5
-
6
- export interface Ui3nBadgeProps {
7
- dot?: boolean;
8
- value?: string | number;
9
- color?: string;
10
- textColor?: string;
11
- position?: 'right-top' | 'right-bottom' | 'left-top' | 'left-bottom';
12
- }
13
-
14
- const props = withDefaults(
15
- defineProps<Ui3nBadgeProps>(),
16
- {
17
- dot: false,
18
- value: '',
19
- color: 'var(--color-bg-button-primary-default)',
20
- textColor: 'var(--color-text-button-primary-default)',
21
- position: 'right-top',
22
- },
23
- );
24
-
25
- const slots = useSlots()
26
- const badgeElementSize = ref<{
27
- width: number;
28
- height: number;
29
- } | never>();
30
-
31
- const hasDefaultSlot = computed(() => !!slots.default);
32
- const style = computed(() => {
33
- const [xPosition, yPosition] = props.position.split('-')
34
- return {
35
- ...(xPosition === 'right' && { right: `-${get(badgeElementSize.value, 'width', 0) / 2}px` }),
36
- ...(xPosition === 'left' && { left: `-${get(badgeElementSize.value, 'width', 0) / 2}px` }),
37
- ...(yPosition === 'top' && { top: `-${get(badgeElementSize.value, 'height', 0) / 2}px` }),
38
- ...(yPosition === 'bottom' && { bottom: `-${get(badgeElementSize.value, 'height', 0) / 2}px` }),
39
- }
40
- });
41
- </script>
42
-
43
- <template>
44
- <!-- eslint-disable vue/no-multiple-template-root -->
45
- <div
46
- v-if="hasDefaultSlot"
47
- :class="$style.badge"
48
- >
49
- <div :class="$style.wrapper">
50
- <slot />
51
-
52
- <ui3n-badge-simple
53
- :dot="dot"
54
- :value="value"
55
- :color="color"
56
- :text-color="textColor"
57
- :style="style"
58
- :class="$style.content"
59
- @change:size="badgeElementSize = $event"
60
- />
61
- </div>
62
- </div>
63
-
64
- <ui3n-badge-simple
65
- v-else
66
- :dot="dot"
67
- :value="value"
68
- :color="color"
69
- :text-color="textColor"
70
- />
71
- </template>
72
-
73
- <style lang="scss" module>
74
- .badge {
75
- --ui3n-badge-size: 20px;
76
-
77
- position: relative;
78
- }
79
-
80
- .wrapper {
81
- position: relative;
82
- width: max-content;
83
- }
84
-
85
- .content {
86
- position: absolute;
87
- z-index: 5;
88
- }
89
- </style>
@@ -1,70 +0,0 @@
1
- <script lang="ts" setup>
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
- import { Icon } from '@iconify/vue'
4
-
5
- export interface Ui3nIconProps {
6
- icon: string;
7
- title?: string;
8
- inline?: boolean;
9
- width?: string | number;
10
- height?: string | number;
11
- horizontalFlip?: boolean;
12
- verticalFlip?: boolean;
13
- flip?: string;
14
- rotate?: number;
15
- color?: string;
16
- onLoad?: Function;
17
- }
18
-
19
- export interface Ui3nIconEmits {
20
- (ev: 'click', value: Event): void;
21
- }
22
-
23
- const props = withDefaults(
24
- defineProps<Ui3nIconProps>(),
25
- {
26
- title: '',
27
- width: 16,
28
- height: 16,
29
- rotate: 0,
30
- color: 'var(--color-icon-control-primary-default)',
31
- },
32
- );
33
- const emits = defineEmits<Ui3nIconEmits>()
34
-
35
- const onLoad = (value: any) => {
36
- if (props.onLoad) {
37
- props.onLoad(value)
38
- }
39
- }
40
- const onClick = (ev: Event) => {
41
- emits('click', ev)
42
- }
43
- </script>
44
-
45
- <template>
46
- <icon
47
- :class="$style.icon"
48
- :icon="icon"
49
- :title="title"
50
- :inline="inline"
51
- :width="width"
52
- :height="height"
53
- :horizontal-flip="horizontalFlip"
54
- :vertical-flip="verticalFlip"
55
- :flip="flip"
56
- :rotate="rotate"
57
- :color="color"
58
- :on-load="onLoad"
59
- @click="onClick"
60
- />
61
- </template>
62
-
63
- <style lang="scss" module>
64
- .icon {
65
- min-width: v-bind(width);
66
- min-height: v-bind(height);
67
- flex-grow: 0;
68
- flex-shrink: 0;
69
- }
70
- </style>
@@ -1,328 +0,0 @@
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;
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;
26
- }
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;
32
- }
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';
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
- emits('go', entity.fullPath);
83
- }
84
- };
85
- const onRightClick = (ev: MouseEvent) => {
86
- handleClick(ev);
87
- const entity = handleClick(ev);
88
- if (entity) {
89
- emits('action', { action: 'open:menu', entity });
90
- }
91
- };
92
-
93
- const handleActions = (ev: MouseEvent, action: EntityAction, entity: ListingEntryTypeExtended) => {
94
- ev.preventDefault();
95
- ev.stopImmediatePropagation();
96
- emits('action', { action, entity });
97
- };
98
- </script>
99
-
100
- <template>
101
- <div :class="$style.table">
102
- <div :class="$style.header">
103
- <div
104
- :class="[$style.cellHeader, $style.cellHeaderSortable, $style.columnName]"
105
- @click="changeSort('name')"
106
- >
107
- <span :class="$style.cellHeaderText">Name</span>
108
- <ui3n-table-sort-icon
109
- v-if="sortField === 'name'"
110
- :value="sortDirection"
111
- :size="18"
112
- />
113
- </div>
114
- <div
115
- :class="[$style.cellHeader, $style.cellHeaderSortable, $style.columnType]"
116
- @click="changeSort('type')"
117
- >
118
- <span :class="$style.cellHeaderText">Type</span>
119
- <ui3n-table-sort-icon
120
- v-if="sortField === 'type'"
121
- :value="sortDirection"
122
- :size="18"
123
- />
124
- </div>
125
-
126
- <div
127
- :class="[$style.cellHeader, $style.cellHeaderSortable, $style.columnChangeAt]"
128
- @click="changeSort('changedAt')"
129
- >
130
- <span :class="$style.cellHeaderText">Changed At</span>
131
- <ui3n-table-sort-icon
132
- v-if="sortField === 'changedAt'"
133
- :value="sortDirection"
134
- :size="18"
135
- />
136
- </div>
137
- </div>
138
-
139
- <div :class="$style.content">
140
- <div
141
- v-for="item in sortedItems"
142
- :id="item.id"
143
- :key="item.id"
144
- :class="$style.row"
145
- @click="onClick"
146
- @click.right="onRightClick"
147
- >
148
- <icon
149
- :icon="item.isFolder ? 'folder' : 'subject'"
150
- :width="16"
151
- :height="16"
152
- :class="$style.rowIcon"
153
- />
154
- <div :class="[$style.cellRow, $style.columnName]">
155
- {{ item.name }}
156
- </div>
157
- <div :class="[$style.cellRow, $style.columnType]">
158
- {{ item.ext || '' }}
159
- </div>
160
- <div :class="[$style.cellRow, $style.columnChangeAt]">
161
- {{ getTimeAsString(item.mtime!) }}
162
- </div>
163
-
164
- <icon
165
- v-if="item.isFolder"
166
- icon="bookmark"
167
- :width="12"
168
- :height="12"
169
- :class="$style.rowBookmark"
170
- @click="handleActions($event, 'add:favorites', item)"
171
- />
172
-
173
- <icon
174
- icon="baseline-edit"
175
- :width="12"
176
- :height="12"
177
- :class="$style.rowRename"
178
- @click="handleActions($event, 'rename', item)"
179
- />
180
- </div>
181
-
182
- <div
183
- v-if="!sortedItems.length"
184
- :class="$style.emptyText"
185
- >
186
- {{ placeholder }}
187
- </div>
188
- </div>
189
- </div>
190
- </template>
191
-
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;
254
- }
255
-
256
- .rowIcon {
257
- color: var(--color-icon-table-accent-hover);
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
- }
298
-
299
- .columnType {
300
- position: relative;
301
- width: 56px;
302
- display: flex;
303
- justify-content: center;
304
- align-items: center;
305
-
306
-
307
- .rowCell {
308
- font-size: var(--font-10);
309
- }
310
- }
311
-
312
- .columnChangeAt {
313
- position: relative;
314
- width: 104px;
315
-
316
- .rowCell {
317
- font-size: var(--font-12);
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
- }
328
- </style>
File without changes
File without changes