@teammodlr/ui-kit 2.1.67 → 2.1.69
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/lib/components/colorpicker/ColorPicker.vue.d.ts +10 -0
- package/lib/components/dialog/Dialog.vue.d.ts +15 -14
- package/lib/components/dialogprovider/DialogProvider.vue.d.ts +7 -0
- package/lib/components/dialogprovider/types.d.ts +23 -0
- package/lib/components/dialogprovider/useDialog.d.ts +2 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/components/messageprovider/MessageProvider.vue.d.ts +0 -1
- package/lib/components/slider/Slider.vue.d.ts +4 -6
- package/lib/composables/index.d.ts +1 -0
- package/lib/index.cjs.js +9 -9
- package/lib/index.es.js +3060 -2938
- package/package.json +1 -1
- package/src/components/colorpicker/ColorPicker.vue +72 -45
- package/src/components/colorpicker/examples/basic.vue +20 -9
- package/src/components/dialog/Dialog.vue +90 -60
- package/src/components/dialogprovider/DialogProvider.vue +97 -0
- package/src/components/dialogprovider/examples/basic.vue +51 -0
- package/src/components/dialogprovider/examples/index.stories.ts +26 -0
- package/src/components/dialogprovider/examples/index.ts +1 -0
- package/src/components/dialogprovider/types.ts +25 -0
- package/src/components/dialogprovider/useDialog.ts +14 -0
- package/src/components/index.ts +1 -0
- package/src/components/messageprovider/MessageProvider.vue +0 -4
- package/src/components/slider/Slider.vue +111 -76
- package/src/composables/index.ts +1 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<button @click="showDialog">Show Dialog</button>
|
|
4
|
+
<button @click="showDialog2">Show Dialog 2</button>
|
|
5
|
+
{{ testTitle }}
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script lang="ts" setup>
|
|
10
|
+
import {ref, h} from 'vue';
|
|
11
|
+
import {useDialog} from '../useDialog';
|
|
12
|
+
|
|
13
|
+
const dialog = useDialog();
|
|
14
|
+
const testTitle = ref('This is a test');
|
|
15
|
+
|
|
16
|
+
function renderMessage({message}: { message: string }) {
|
|
17
|
+
return h('p', [
|
|
18
|
+
'Here are ',
|
|
19
|
+
h('span', {style: 'color: red'}, [message]),
|
|
20
|
+
' that using render function',
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function showDialog() {
|
|
25
|
+
dialog.create('hello', {
|
|
26
|
+
title: testTitle,
|
|
27
|
+
render: renderMessage,
|
|
28
|
+
props: {message: testTitle},
|
|
29
|
+
open: true,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
testTitle.value = 'changed';
|
|
34
|
+
}, 4000);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function showDialog2() {
|
|
38
|
+
dialog.create('hello-two', {
|
|
39
|
+
title: "Hello Second Dialog",
|
|
40
|
+
render: renderMessage,
|
|
41
|
+
props: {message: testTitle},
|
|
42
|
+
open: true,
|
|
43
|
+
modal: false,
|
|
44
|
+
draggable: true
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
testTitle.value = 'changed again';
|
|
49
|
+
}, 4000);
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import MDialogProvider from '../DialogProvider.vue';
|
|
2
|
+
import { MDialogProviderBasic } from './index';
|
|
3
|
+
|
|
4
|
+
const Template = (args: any) => ({
|
|
5
|
+
components: {
|
|
6
|
+
MDialogProvider,
|
|
7
|
+
MDialogProviderBasic
|
|
8
|
+
},
|
|
9
|
+
setup() {
|
|
10
|
+
return {
|
|
11
|
+
args
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
template: `
|
|
15
|
+
<m-dialog-provider v-bind="args">
|
|
16
|
+
<MDialogProviderBasic />
|
|
17
|
+
</m-dialog-provider>
|
|
18
|
+
`
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
component: MDialogProvider,
|
|
23
|
+
title: 'Components/DialogProvider'
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const Primary = Template.bind({});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as MDialogProviderBasic } from './basic.vue';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Ref, VNodeChild } from 'vue';
|
|
2
|
+
|
|
3
|
+
export type DialogContent = VNodeChild;
|
|
4
|
+
|
|
5
|
+
export interface DialogOptions {
|
|
6
|
+
title?: string | Ref<string>;
|
|
7
|
+
render?: (props: any) => VNodeChild;
|
|
8
|
+
props?: { [key: string]: any };
|
|
9
|
+
onClose?: () => void;
|
|
10
|
+
open?: boolean;
|
|
11
|
+
draggable?: boolean;
|
|
12
|
+
modal?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface DialogReactive {
|
|
16
|
+
key: string;
|
|
17
|
+
options: DialogOptions;
|
|
18
|
+
open: () => void;
|
|
19
|
+
close: () => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface DialogApiInjection {
|
|
23
|
+
create: (key: string, options?: DialogOptions) => DialogReactive;
|
|
24
|
+
remove: (key: string) => void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { inject } from 'vue';
|
|
2
|
+
import type { DialogApiInjection} from "./types";
|
|
3
|
+
|
|
4
|
+
export function useDialog(): DialogApiInjection {
|
|
5
|
+
const api = inject('m-dialog', null);
|
|
6
|
+
|
|
7
|
+
if (api === null) {
|
|
8
|
+
throw new Error(
|
|
9
|
+
`m-dialog api is not provided, ensure component is wrapped in <m-dialog-provider />`
|
|
10
|
+
)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return api;
|
|
14
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -48,4 +48,5 @@ export { default as MVirtualScroll } from './virtualscroll/VirtualScroll.vue';
|
|
|
48
48
|
export { default as MConfirm } from './confirm/Confirm.vue';
|
|
49
49
|
export { default as MConfirmProvider } from './confirm/ConfirmProvider.vue';
|
|
50
50
|
export { default as MDialog } from './dialog/Dialog.vue';
|
|
51
|
+
export { default as MDialogProvider } from './dialogprovider/DialogProvider.vue';
|
|
51
52
|
export { default as MTree } from './tree/Tree.vue';
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
import {
|
|
29
29
|
ref,
|
|
30
30
|
reactive,
|
|
31
|
-
Teleport,
|
|
32
31
|
defineComponent,
|
|
33
32
|
provide,
|
|
34
33
|
computed
|
|
@@ -43,11 +42,8 @@ import type {
|
|
|
43
42
|
} from './types';
|
|
44
43
|
import type { PropType } from 'vue';
|
|
45
44
|
import MMessage from './Message.vue';
|
|
46
|
-
import { useId } from '../../composables/useCachedUid';
|
|
47
45
|
import * as style from './style';
|
|
48
46
|
import { modalScale } from '../../styles/transitions.css';
|
|
49
|
-
import { useIsServer } from '../../composables/useIsServer';
|
|
50
|
-
export type MessageProviderInst = MessageApiInjection;
|
|
51
47
|
|
|
52
48
|
interface PrivateMessageReactive extends MessageReactive {
|
|
53
49
|
key: string;
|
|
@@ -1,76 +1,111 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div :class="style.slider">
|
|
3
|
-
<div :class="style.sliderTransparent">
|
|
4
|
-
<div ref="slider"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
</
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
export default defineComponent({
|
|
21
|
-
name:
|
|
22
|
-
props: {
|
|
23
|
-
modelValue: {
|
|
24
|
-
type: Number,
|
|
25
|
-
required: true
|
|
26
|
-
},
|
|
27
|
-
background: {
|
|
28
|
-
type: String,
|
|
29
|
-
default:
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
dragging.value
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="style.slider">
|
|
3
|
+
<div :class="style.sliderTransparent">
|
|
4
|
+
<div ref="slider" :class="style.sliderBar" :style="{ background: background }" @mousedown="handleMouseDown"
|
|
5
|
+
@touchstart.prevent="handleMouseDown">
|
|
6
|
+
</div>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<div style="position: absolute; inset: 0px 9px;" @mousedown="handleMouseDown"
|
|
10
|
+
@touchstart.prevent="handleMouseDown">
|
|
11
|
+
<div :class="style.hueSliderThumb" :style="{ left: `${modelValue}%` }"></div>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script lang="ts">
|
|
17
|
+
import { defineComponent, ref, onMounted, onUnmounted } from 'vue';
|
|
18
|
+
import * as style from './style';
|
|
19
|
+
|
|
20
|
+
export default defineComponent({
|
|
21
|
+
name: 'MSlider',
|
|
22
|
+
props: {
|
|
23
|
+
modelValue: {
|
|
24
|
+
type: Number,
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
background: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: '',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
emits: ['update:modelValue', 'change'],
|
|
33
|
+
setup(props, { emit }) {
|
|
34
|
+
const slider = ref<HTMLElement | null>(null);
|
|
35
|
+
const dragging = ref(false);
|
|
36
|
+
|
|
37
|
+
const handleMouseDown = (event: MouseEvent | TouchEvent) => {
|
|
38
|
+
dragging.value = true;
|
|
39
|
+
setThumbPosition(event);
|
|
40
|
+
|
|
41
|
+
document.addEventListener('mousemove', onMouseMove);
|
|
42
|
+
document.addEventListener('mouseup', onMouseUp);
|
|
43
|
+
document.addEventListener('touchmove', onTouchMove);
|
|
44
|
+
document.addEventListener('touchend', onTouchEnd);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const onMouseMove = (event: MouseEvent) => {
|
|
48
|
+
if (dragging.value) {
|
|
49
|
+
setThumbPosition(event);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const onMouseUp = () => {
|
|
54
|
+
if (dragging.value) {
|
|
55
|
+
dragging.value = false;
|
|
56
|
+
removeEventListeners();
|
|
57
|
+
emit('change', props.modelValue);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const onTouchMove = (event: TouchEvent) => {
|
|
62
|
+
if (dragging.value) {
|
|
63
|
+
setThumbPosition(event);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const onTouchEnd = () => {
|
|
68
|
+
if (dragging.value) {
|
|
69
|
+
dragging.value = false;
|
|
70
|
+
removeEventListeners();
|
|
71
|
+
emit('change', props.modelValue);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const setThumbPosition = (event: MouseEvent | TouchEvent) => {
|
|
76
|
+
const rect = slider.value?.getBoundingClientRect();
|
|
77
|
+
if (!rect) return;
|
|
78
|
+
|
|
79
|
+
let clientX;
|
|
80
|
+
if (event instanceof MouseEvent) {
|
|
81
|
+
clientX = event.clientX;
|
|
82
|
+
} else if (event instanceof TouchEvent) {
|
|
83
|
+
clientX = event.touches[0].clientX;
|
|
84
|
+
} else {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const position = Math.min(Math.max(clientX - rect.left, 0), rect.width);
|
|
89
|
+
const value = (position / rect.width) * 100;
|
|
90
|
+
emit('update:modelValue', value);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const removeEventListeners = () => {
|
|
94
|
+
document.removeEventListener('mousemove', onMouseMove);
|
|
95
|
+
document.removeEventListener('mouseup', onMouseUp);
|
|
96
|
+
document.removeEventListener('touchmove', onTouchMove);
|
|
97
|
+
document.removeEventListener('touchend', onTouchEnd);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
onUnmounted(() => {
|
|
101
|
+
removeEventListeners();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
handleMouseDown,
|
|
106
|
+
slider,
|
|
107
|
+
style,
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
</script>
|
package/src/composables/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { useMessage } from '../components/messageprovider/useMessage';
|
|
2
|
+
export { useDialog } from '../components/dialogprovider/useDialog';
|
|
2
3
|
export { useConfirm } from '../components/confirm/useConfirm';
|
|
3
4
|
export { usePopper } from './usePopper';
|
|
4
5
|
export { useZIndex } from './useZIndex';
|