@v1nt1248/3nclient-lib 0.0.9 → 0.0.12
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.
- package/dist/components/index.d.ts +20 -1
- package/dist/components/ui3n-dialog.vue.d.ts +73 -0
- package/dist/components/ui3n-drop-files.vue.d.ts +41 -0
- package/dist/components/ui3n-emoji.vue.d.ts +36 -0
- package/dist/components/ui3n-input.vue.d.ts +96 -0
- package/dist/components/ui3n-list.vue.d.ts +45 -0
- package/dist/components/ui3n-menu.vue.d.ts +85 -0
- package/dist/components/ui3n-notification.vue.d.ts +4 -4
- package/dist/components/ui3n-table-sort-icon.vue.d.ts +29 -0
- package/dist/components/ui3n-table.vue.d.ts +42 -0
- package/dist/components/ui3n-text.vue.d.ts +79 -0
- package/dist/directives/index.d.ts +1 -0
- package/dist/directives/ui3n-click-outside.d.ts +10 -0
- package/dist/index.d.ts +31 -0
- package/dist/plugins/dialogs.d.ts +17 -0
- package/dist/plugins/i18n.d.ts +2 -0
- package/dist/plugins/index.d.ts +8 -4
- package/dist/plugins/notifications.d.ts +2 -0
- package/dist/plugins/store-dialogs.d.ts +4 -0
- package/dist/plugins/store-notifications.d.ts +4 -0
- package/dist/plugins/vue-bus.d.ts +2 -0
- package/dist/style.css +1 -1
- package/dist/ui-3n-lib.js +6931 -6186
- package/package.json +7 -2
- package/src/components/index.ts +55 -0
- package/src/components/ui3n-button.vue +4 -5
- package/src/components/ui3n-dialog.vue +311 -0
- package/src/components/ui3n-drop-files.vue +8 -4
- package/src/components/ui3n-emoji.vue +8 -4
- package/src/components/ui3n-list.vue +135 -0
- package/src/components/ui3n-menu.vue +134 -0
- package/src/components/ui3n-notification.vue +2 -13
- package/src/components/ui3n-table-sort-icon.vue +4 -2
- package/src/components/ui3n-table.vue +9 -4
- package/src/components/ui3n-text.vue +9 -5
- package/src/components/ui3n-virtual-scroll.vue +108 -0
- package/dist/types.d.ts +0 -21
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
import { computed, onMounted, ref } from 'vue'
|
|
4
|
+
import { default as vClickOutside } from '../directives/ui3n-click-outside'
|
|
5
|
+
|
|
6
|
+
export interface Ui3nMenuProps {
|
|
7
|
+
offsetX?: number;
|
|
8
|
+
offsetY?: number;
|
|
9
|
+
closeOnClick?: boolean;
|
|
10
|
+
closeOnClickOutside?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface Ui3nMenuEmits {
|
|
15
|
+
(ev: 'open'): void;
|
|
16
|
+
(ev: 'opened'): void;
|
|
17
|
+
(ev: 'close'): void;
|
|
18
|
+
(ev: 'closed'): void;
|
|
19
|
+
(ev: 'click-outside'): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface Ui3nMenuSlots {
|
|
23
|
+
default: () => any;
|
|
24
|
+
menu?: () => any;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const props = withDefaults(defineProps<Ui3nMenuProps>(), {
|
|
28
|
+
offsetX: 0,
|
|
29
|
+
offsetY: 0,
|
|
30
|
+
closeOnClick: true,
|
|
31
|
+
closeOnClickOutside: true,
|
|
32
|
+
disabled: false,
|
|
33
|
+
})
|
|
34
|
+
const emits = defineEmits<Ui3nMenuEmits>()
|
|
35
|
+
defineSlots<Ui3nMenuSlots>()
|
|
36
|
+
|
|
37
|
+
const menuElement = ref<HTMLDivElement | null>(null)
|
|
38
|
+
const menuTriggerElement = ref<HTMLDivElement | null>(null)
|
|
39
|
+
const isShow = ref(false)
|
|
40
|
+
const defaultAnimationDuration = 400
|
|
41
|
+
const menuContentStyle = computed(() => {
|
|
42
|
+
if (!props.offsetX && !props.offsetY) {
|
|
43
|
+
return {}
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
...(props.offsetX && { left: `${props.offsetX}px` }),
|
|
47
|
+
...(props.offsetY && { top: `${menuTriggerElement.value!.clientHeight + props.offsetY}px` }),
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
onMounted(() => {
|
|
52
|
+
menuElement.value!.style.setProperty('--menu-animation-duration', `${defaultAnimationDuration}ms`)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const toggleMenu = () => {
|
|
56
|
+
isShow.value = !isShow.value
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const onContentClick = () => {
|
|
60
|
+
isShow.value = false
|
|
61
|
+
}
|
|
62
|
+
const onClickOutside = () => {
|
|
63
|
+
emits('click-outside')
|
|
64
|
+
if (props.closeOnClickOutside) {
|
|
65
|
+
isShow.value = false
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<template>
|
|
71
|
+
<div
|
|
72
|
+
ref="menuElement"
|
|
73
|
+
class="ui3n-menu"
|
|
74
|
+
>
|
|
75
|
+
<div
|
|
76
|
+
ref="menuTriggerElement"
|
|
77
|
+
class="ui3n-menu__trigger"
|
|
78
|
+
@click.stop="toggleMenu"
|
|
79
|
+
>
|
|
80
|
+
<slot />
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<transition
|
|
84
|
+
name="menu"
|
|
85
|
+
:duration="defaultAnimationDuration"
|
|
86
|
+
@before-enter="emits('open')"
|
|
87
|
+
@after-enter="emits('opened')"
|
|
88
|
+
@before-leave="emits('close')"
|
|
89
|
+
@after-leave="emits('closed')"
|
|
90
|
+
>
|
|
91
|
+
<div
|
|
92
|
+
v-if="isShow"
|
|
93
|
+
v-click-outside="onClickOutside"
|
|
94
|
+
:style="menuContentStyle"
|
|
95
|
+
class="ui3n-menu__content"
|
|
96
|
+
v-on="props.closeOnClick ? { click: onContentClick } : {}"
|
|
97
|
+
>
|
|
98
|
+
<slot name="menu" />
|
|
99
|
+
</div>
|
|
100
|
+
</transition>
|
|
101
|
+
</div>
|
|
102
|
+
</template>
|
|
103
|
+
|
|
104
|
+
<style lang="scss" scoped>
|
|
105
|
+
@import "../assets/styles/mixins";
|
|
106
|
+
|
|
107
|
+
.ui3n-menu {
|
|
108
|
+
--menu-animation-duration: 400ms;
|
|
109
|
+
|
|
110
|
+
position: relative;
|
|
111
|
+
overflow: visible;
|
|
112
|
+
|
|
113
|
+
.menu-enter-active,
|
|
114
|
+
.menu-leave-active {
|
|
115
|
+
transition: opacity var(--menu-animation-duration);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.menu-enter-from,
|
|
119
|
+
.menu-leave-to {
|
|
120
|
+
opacity: 0;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
&__trigger {
|
|
124
|
+
position: relative;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&__content {
|
|
128
|
+
position: absolute;
|
|
129
|
+
border-radius: 4px;
|
|
130
|
+
background-color: var(--system-white, #fff);
|
|
131
|
+
@include elevation(3);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
</style>
|
|
@@ -2,20 +2,9 @@ ui<script lang="ts" setup>
|
|
|
2
2
|
import { computed } from 'vue'
|
|
3
3
|
import Ui3nIcon from './ui3n-icon.vue'
|
|
4
4
|
import Ui3nButton from './ui3n-button.vue'
|
|
5
|
+
import type { Ui3nNotificationProps } from '../constants'
|
|
5
6
|
|
|
6
|
-
const props = defineProps<
|
|
7
|
-
id?: string;
|
|
8
|
-
type?: 'success' | 'warning' | 'info' | 'error';
|
|
9
|
-
content: string;
|
|
10
|
-
icon?: string;
|
|
11
|
-
iconSize?: string | number;
|
|
12
|
-
iconColor?: string;
|
|
13
|
-
position?: 'left' | 'center' | 'right';
|
|
14
|
-
duration?: number;
|
|
15
|
-
teleport?: string;
|
|
16
|
-
onOpen?: () => void;
|
|
17
|
-
onClose?: () => void;
|
|
18
|
-
}>()
|
|
7
|
+
const props = defineProps<Ui3nNotificationProps>()
|
|
19
8
|
const params = computed(() => {
|
|
20
9
|
const {
|
|
21
10
|
id,
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
import { computed } from 'vue'
|
|
3
3
|
import Ui3nIcon from './ui3n-icon.vue'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export interface Ui3nTableSortIconProps {
|
|
6
6
|
size?: string | number;
|
|
7
7
|
color?: string;
|
|
8
8
|
value: 'asc' | 'desc';
|
|
9
|
-
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const props = defineProps<Ui3nTableSortIconProps>()
|
|
10
12
|
|
|
11
13
|
const iconSize = computed(() => props.size ? +props.size : 16)
|
|
12
14
|
const iconColor = computed(() => props.color || 'var(--black-90, #212121)')
|
|
@@ -2,15 +2,20 @@
|
|
|
2
2
|
import { computed, ref } from 'vue'
|
|
3
3
|
import { Icon } from '@iconify/vue'
|
|
4
4
|
import Ui3nTableSortIcon from './ui3n-table-sort-icon.vue'
|
|
5
|
+
import type { ListingEntryTypeExtended, EntityAction, SortField } from '../constants'
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
export interface Ui3nTableProps {
|
|
7
8
|
items: ListingEntryTypeExtended[];
|
|
8
9
|
textIfEmpty?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface Ui3nTableEmits {
|
|
11
13
|
(ev: 'go', name: string): void;
|
|
12
14
|
(ev: 'action', value: { action: EntityAction, entity: ListingEntryTypeExtended }): void;
|
|
13
|
-
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const props = defineProps<Ui3nTableProps>()
|
|
18
|
+
const emit = defineEmits<Ui3nTableEmits>()
|
|
14
19
|
|
|
15
20
|
const sortField = ref<SortField>('name')
|
|
16
21
|
const sortDirection = ref<'asc'|'desc'>('asc')
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
3
|
import { computed, onMounted, ref, watch } from 'vue'
|
|
4
|
-
import { patchTextareaMaxRowsSupport } from '../
|
|
4
|
+
import { patchTextareaMaxRowsSupport } from '../tools'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
export interface Ui3nTextProps {
|
|
7
7
|
text: string;
|
|
8
8
|
rows?: number;
|
|
9
9
|
maxRows?: number;
|
|
@@ -11,15 +11,19 @@
|
|
|
11
11
|
placeholder?: string;
|
|
12
12
|
rules?: Array<(v: string) => any>;
|
|
13
13
|
disabled?: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface Ui3nTextEmits {
|
|
16
17
|
(ev: 'init', value: HTMLTextAreaElement): void;
|
|
17
18
|
(ev: 'input', value: string): void;
|
|
18
19
|
(ev: 'focus', value: Event): void;
|
|
19
20
|
(ev: 'blur', value: Event): void;
|
|
20
21
|
(ev: 'update:text', value: string): void;
|
|
21
22
|
(ev: 'update:valid', value: boolean): void;
|
|
22
|
-
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const props = defineProps<Ui3nTextProps>()
|
|
26
|
+
const emit = defineEmits<Ui3nTextEmits>()
|
|
23
27
|
|
|
24
28
|
const textareaElement = ref<HTMLTextAreaElement | null>(null)
|
|
25
29
|
const isFocused = ref(false)
|
|
@@ -0,0 +1,108 @@
|
|
|
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'
|
|
4
|
+
|
|
5
|
+
export interface Ui3nVirtualScrollProps<T> {
|
|
6
|
+
items: T[];
|
|
7
|
+
minChildHeight: number;
|
|
8
|
+
renderAhread?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Ui3nVirtualScrollSlots<T> {
|
|
12
|
+
item: (item: T, index: number) => any;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(defineProps<Ui3nVirtualScrollProps<T>>(), {
|
|
16
|
+
renderAhread: 20,
|
|
17
|
+
})
|
|
18
|
+
defineSlots<Ui3nVirtualScrollSlots<T>>()
|
|
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))
|
|
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)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
onMounted(() => {
|
|
49
|
+
if (wrapElement.value) {
|
|
50
|
+
scrollTop.value = wrapElement.value.scrollTop
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<template>
|
|
56
|
+
<div
|
|
57
|
+
ref="wrapElement"
|
|
58
|
+
class="ui3n-virtual-scroll"
|
|
59
|
+
@scroll="onScroll"
|
|
60
|
+
>
|
|
61
|
+
<div
|
|
62
|
+
class="ui3n-virtual-scroll__viewport"
|
|
63
|
+
:style="{ height: `${totalHeight}px` }"
|
|
64
|
+
>
|
|
65
|
+
<div
|
|
66
|
+
class="ui3n-virtual-scroll__content"
|
|
67
|
+
:style="{ transform: `translateY(${offsetY}px)` }"
|
|
68
|
+
>
|
|
69
|
+
<div
|
|
70
|
+
v-for="(item, index) in visibleChildren"
|
|
71
|
+
:key="item.id"
|
|
72
|
+
:data-sid="item.id ?? index"
|
|
73
|
+
class="ui3n-virtual-scroll__item"
|
|
74
|
+
>
|
|
75
|
+
<slot
|
|
76
|
+
name="item"
|
|
77
|
+
:item="item"
|
|
78
|
+
:index="startNode + index"
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
</template>
|
|
85
|
+
|
|
86
|
+
<style lang="scss" scoped>
|
|
87
|
+
.ui3n-virtual-scroll {
|
|
88
|
+
position: relative;
|
|
89
|
+
width: 100%;
|
|
90
|
+
height: 100%;
|
|
91
|
+
overflow-y: auto;
|
|
92
|
+
|
|
93
|
+
&__viewport {
|
|
94
|
+
position: relative;
|
|
95
|
+
overflow: hidden;
|
|
96
|
+
will-change: transform;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&__content {
|
|
100
|
+
will-change: transform;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&__item {
|
|
104
|
+
position: relative;
|
|
105
|
+
min-height: 16px;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
</style>
|
package/dist/types.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { VNode } from 'vue';
|
|
2
|
-
import type { Ui3nNotificationProps, VueEventBus } from './constants';
|
|
3
|
-
import type { Ui3nButtonProps, Ui3nButtonEmits } from './components';
|
|
4
|
-
declare module '@vue/runtime-core' {
|
|
5
|
-
interface ComponentCustomProperties {
|
|
6
|
-
$createNotice: (params: Ui3nNotificationProps) => void;
|
|
7
|
-
$locale: string;
|
|
8
|
-
$tr: (key: string, placeholders?: Record<string, string>) => string;
|
|
9
|
-
$changeLocale: (lang: string) => void;
|
|
10
|
-
$emitter: VueEventBus;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
declare module '@v1nt1248/3nclient-lib' {
|
|
14
|
-
class Ui3nButton {
|
|
15
|
-
$props: Ui3nButtonProps;
|
|
16
|
-
$emits: Ui3nButtonEmits;
|
|
17
|
-
$clots: {
|
|
18
|
-
default: () => VNode[];
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
}
|