@v1nt1248/3nclient-lib 0.1.67 → 0.1.68
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/ui3n-dialog/types.d.ts +1 -1
- package/dist/ui3n-components.js +2244 -2238
- package/dist/ui3n-plugins.js +1372 -1369
- package/package.json +1 -1
- package/src/components/ui3n-dialog/types.ts +1 -1
- package/src/components/ui3n-dialog/ui3n-dialog.vue +18 -4
- package/src/components/ui3n-menu/ui3n-menu.vue +79 -75
package/package.json
CHANGED
|
@@ -5,7 +5,6 @@ export type Ui3nDialogEvent = 'open' | 'before-close' | 'close' | 'confirm' | 'c
|
|
|
5
5
|
|
|
6
6
|
export interface Ui3nDialogProps {
|
|
7
7
|
id?: string;
|
|
8
|
-
teleport?: string;
|
|
9
8
|
title?: string;
|
|
10
9
|
width?: string | number;
|
|
11
10
|
draggable?: boolean;
|
|
@@ -25,6 +24,7 @@ export interface Ui3nDialogProps {
|
|
|
25
24
|
confirmButtonBackground?: string;
|
|
26
25
|
cancelButtonBackground?: string;
|
|
27
26
|
closeOnClickOverlay?: boolean;
|
|
27
|
+
closeOnEsc?: boolean;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export interface Ui3nDialogComponentProps<T extends Component> {
|
|
@@ -85,6 +85,16 @@
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
function onKeydown(event: KeyboardEvent) {
|
|
89
|
+
const { code } = event;
|
|
90
|
+
console.log('onKeydown: ', code, props.dialogProps?.closeOnEsc);
|
|
91
|
+
if (code === 'Escape' && props.dialogProps?.closeOnEsc) {
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
event.stopPropagation();
|
|
94
|
+
startEmit('cancel');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
88
98
|
function startEmit(event: Ui3nDialogEvent, ev?: Event) {
|
|
89
99
|
if (event === 'click-overlay') {
|
|
90
100
|
emits(event);
|
|
@@ -195,11 +205,15 @@
|
|
|
195
205
|
:style="cssStyle"
|
|
196
206
|
v-on="
|
|
197
207
|
dialogProps?.draggable
|
|
198
|
-
? {
|
|
199
|
-
|
|
208
|
+
? {
|
|
209
|
+
dragstart: onDragstart,
|
|
210
|
+
mousedown: onMousedown,
|
|
211
|
+
mouseup: onMouseup,
|
|
212
|
+
mousemove: onMousemove,
|
|
213
|
+
keydown: onKeydown
|
|
214
|
+
}
|
|
215
|
+
: { keydown: onKeydown }
|
|
200
216
|
"
|
|
201
|
-
@keydown.esc.stop="startEmit('cancel')"
|
|
202
|
-
@keydown.enter.stop="isValid && startEmit('confirm')"
|
|
203
217
|
>
|
|
204
218
|
<div
|
|
205
219
|
v-if="currentDialogProps.title"
|
|
@@ -1,71 +1,75 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { ref, watch } from 'vue';
|
|
3
|
-
import { autoUpdate, flip, useFloating, offset, shift } from '@floating-ui/vue';
|
|
4
|
-
import { default as vClickOutside } from '../../directives/ui3n-click-outside';
|
|
5
|
-
import type { Ui3nMenuEmits, Ui3nMenuProps, Ui3nMenuSlots } from './types';
|
|
2
|
+
import { ref, watch } from 'vue';
|
|
3
|
+
import { autoUpdate, flip, useFloating, offset, shift } from '@floating-ui/vue';
|
|
4
|
+
import { default as vClickOutside } from '../../directives/ui3n-click-outside';
|
|
5
|
+
import type { Ui3nMenuEmits, Ui3nMenuProps, Ui3nMenuSlots } from './types';
|
|
6
6
|
|
|
7
|
-
const props = withDefaults(defineProps<Ui3nMenuProps>(), {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
15
|
-
const emits = defineEmits<Ui3nMenuEmits>();
|
|
16
|
-
defineSlots<Ui3nMenuSlots>();
|
|
7
|
+
const props = withDefaults(defineProps<Ui3nMenuProps>(), {
|
|
8
|
+
positionStrategy: 'absolute',
|
|
9
|
+
offsetX: 0,
|
|
10
|
+
offsetY: 0,
|
|
11
|
+
closeOnClick: true,
|
|
12
|
+
closeOnClickOutside: true,
|
|
13
|
+
disabled: false,
|
|
14
|
+
});
|
|
15
|
+
const emits = defineEmits<Ui3nMenuEmits>();
|
|
16
|
+
defineSlots<Ui3nMenuSlots>();
|
|
17
17
|
|
|
18
|
-
const menuElement = ref<HTMLDivElement | null>(null);
|
|
19
|
-
const menuTriggerElement = ref<HTMLDivElement | null>(null);
|
|
20
|
-
const menuContentElement = ref<HTMLDivElement | null>(null);
|
|
21
|
-
const isShow = ref(false);
|
|
18
|
+
const menuElement = ref<HTMLDivElement | null>(null);
|
|
19
|
+
const menuTriggerElement = ref<HTMLDivElement | null>(null);
|
|
20
|
+
const menuContentElement = ref<HTMLDivElement | null>(null);
|
|
21
|
+
const isShow = ref(false);
|
|
22
22
|
|
|
23
|
-
const { floatingStyles, isPositioned } = useFloating(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
);
|
|
23
|
+
const { floatingStyles, isPositioned } = useFloating(
|
|
24
|
+
menuTriggerElement,
|
|
25
|
+
menuContentElement,
|
|
26
|
+
{
|
|
27
|
+
placement: 'bottom-start',
|
|
28
|
+
strategy: props.positionStrategy,
|
|
29
|
+
middleware: [
|
|
30
|
+
offset({
|
|
31
|
+
mainAxis: props.offsetY,
|
|
32
|
+
crossAxis: props.offsetX + 2,
|
|
33
|
+
}),
|
|
34
|
+
flip({
|
|
35
|
+
fallbackAxisSideDirection: 'end',
|
|
36
|
+
flipAlignment: false,
|
|
37
|
+
fallbackPlacements: ['bottom-end'],
|
|
38
|
+
}),
|
|
39
|
+
shift(),
|
|
40
|
+
],
|
|
41
|
+
whileElementsMounted: props.positionStrategy === 'fixed' ? autoUpdate : undefined,
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
44
|
|
|
45
|
-
function toggleMenu() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
45
|
+
function toggleMenu() {
|
|
46
|
+
if (props.disabled) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
50
|
+
isShow.value = !isShow.value;
|
|
51
|
+
isShow.value ? emits('open') : emits('close');
|
|
52
|
+
}
|
|
54
53
|
|
|
55
|
-
function
|
|
56
|
-
emits('click-outside');
|
|
57
|
-
if (props.closeOnClickOutside) {
|
|
54
|
+
function onContentClick() {
|
|
58
55
|
isShow.value = false;
|
|
59
56
|
emits('close');
|
|
60
57
|
}
|
|
61
|
-
}
|
|
62
58
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
function onClickOutside() {
|
|
60
|
+
emits('click-outside');
|
|
61
|
+
if (props.closeOnClickOutside) {
|
|
62
|
+
isShow.value = false;
|
|
63
|
+
emits('close');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
watch(
|
|
68
|
+
isPositioned,
|
|
69
|
+
val => {
|
|
70
|
+
val ? emits('opened') : emits('closed');
|
|
71
|
+
},
|
|
72
|
+
);
|
|
69
73
|
</script>
|
|
70
74
|
|
|
71
75
|
<template>
|
|
@@ -92,26 +96,26 @@ watch(
|
|
|
92
96
|
</template>
|
|
93
97
|
|
|
94
98
|
<style lang="scss" module>
|
|
95
|
-
@use '../../assets/styles/mixins' as mixins;
|
|
99
|
+
@use '../../assets/styles/mixins' as mixins;
|
|
96
100
|
|
|
97
|
-
.ui3nMenu {
|
|
98
|
-
|
|
101
|
+
.ui3nMenu {
|
|
102
|
+
--ui3n-menu-content-bg: var(--color-bg-control-secondary-default);
|
|
99
103
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
+
position: relative;
|
|
105
|
+
max-width: max-content;
|
|
106
|
+
overflow: visible;
|
|
107
|
+
}
|
|
104
108
|
|
|
105
|
-
.ui3nMenuTrigger {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
+
.ui3nMenuTrigger {
|
|
110
|
+
position: relative;
|
|
111
|
+
max-width: max-content;
|
|
112
|
+
}
|
|
109
113
|
|
|
110
|
-
.ui3nMenuContent {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
114
|
+
.ui3nMenuContent {
|
|
115
|
+
position: absolute;
|
|
116
|
+
border-radius: 4px;
|
|
117
|
+
background-color: var(--ui3n-menu-content-bg);
|
|
118
|
+
z-index: 1000;
|
|
119
|
+
@include mixins.elevation(3);
|
|
120
|
+
}
|
|
117
121
|
</style>
|