@teammodlr/ui-kit 2.3.2 → 2.3.4

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.
@@ -1,33 +1,24 @@
1
1
  <template>
2
- <slot/>
2
+ <slot />
3
3
  <template v-if="Object.keys(dialogMap).length > 0">
4
- <template v-for="dialog in Object.values(dialogMap)">
5
- <MDialog
6
- v-if="dialog.options.open"
7
- :key="dialog.key"
8
- v-bind="filteredOptions(dialog.options)"
9
- ref="setDialogRef(dialog.key)"
10
- @close="remove(dialog.key)"
11
- @on-close="handleClose(dialog.key)"
12
- @on-open="handleOpen(dialog.key)"
13
- >
4
+ <template v-for="dialog in Object.values(dialogMap)" :key="dialog.key">
5
+ <MDialog v-model:open="dialog.options.open" v-bind="filteredOptions(dialog.options)"
6
+ ref="setDialogRef(dialog.key)" @close="remove(dialog.key)" @on-close="handleClose(dialog.key)"
7
+ @on-open="handleOpen(dialog.key)">
14
8
  <template #default>
15
- <MRenderer
16
- v-if="dialog.options.render"
17
- :h="dialog.options.render"
18
- :props="dialog.options.props"
19
- />
9
+ <MRenderer v-if="dialog.options.render" :h="dialog.options.render" :props="dialog.options.props" />
20
10
  </template>
21
11
  </MDialog>
22
12
  </template>
23
13
  </template>
24
14
  </template>
25
15
  <script lang="ts">
26
- import {defineComponent, reactive, provide, ref} from 'vue';
27
- import type {DialogApiInjection, DialogOptions, DialogReactive} from './types';
16
+ import { defineComponent, reactive, provide, ref, nextTick } from 'vue';
17
+ import type { DialogApiInjection, DialogOptions, DialogReactive } from './types';
28
18
  import MDialog from '../dialog/Dialog.vue';
29
19
  import MRenderer from '../renderer/renderer';
30
20
 
21
+
31
22
  export default defineComponent({
32
23
  name: 'DialogProvider',
33
24
  components: {
@@ -61,20 +52,23 @@ export default defineComponent({
61
52
  const dialog: DialogReactive = {
62
53
  key,
63
54
  options: reactiveOptions,
64
- open: () => {
55
+ open: async () => {
65
56
  const dialogComponent = dialogRefs.value[key];
66
57
  if (dialogComponent && dialogComponent.open) {
67
58
  dialogComponent.open();
68
59
  } else {
60
+ await nextTick();
69
61
  dialog.options.open = true;
70
62
  handleOpen(key);
71
63
  }
72
64
  },
73
- close: () => {
65
+ close: async () => {
74
66
  const dialogComponent = dialogRefs.value[key];
75
67
  if (dialogComponent && dialogComponent.close) {
76
68
  dialogComponent.close();
77
69
  } else {
70
+ await nextTick();
71
+ dialog.options.open = false;
78
72
  handleClose(key);
79
73
  }
80
74
  },
@@ -1,54 +1,55 @@
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: false,
45
- onOpen: () => {
46
- console.log('hello world')
47
- }
48
- });
49
-
50
- setTimeout(() => {
51
- testTitle.value = 'changed again';
52
- }, 4000);
53
- }
54
- </script>
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
+ const dlg = dialog.create('hello', {
26
+ title: testTitle,
27
+ render: renderMessage,
28
+ props: {message: testTitle},
29
+ });
30
+
31
+ dlg.open();
32
+
33
+ setTimeout(() => {
34
+ testTitle.value = 'changed';
35
+ }, 4000);
36
+ }
37
+
38
+ function showDialog2() {
39
+ dialog.create('hello-two', {
40
+ title: "Hello Second Dialog",
41
+ render: renderMessage,
42
+ props: {message: testTitle},
43
+ open: true,
44
+ modal: false,
45
+ draggable: false,
46
+ onOpen: () => {
47
+ console.log('hello world')
48
+ }
49
+ });
50
+
51
+ setTimeout(() => {
52
+ testTitle.value = 'changed again';
53
+ }, 4000);
54
+ }
55
+ </script>
@@ -1,97 +1,98 @@
1
- import { style, globalKeyframes } from '@vanilla-extract/css';
2
- import { themeVars } from './theme.css';
3
-
4
- const FADE_NAME = 'fade';
5
- const FADE_DURATION = 0.2;
6
- globalKeyframes(FADE_NAME, {
7
- from: {
8
- opacity: 0
9
- },
10
- to: {
11
- opacity: 1
12
- }
13
- });
14
-
15
- export const fade = {
16
- enterActive: style({
17
- animation: `${FADE_DURATION}s ${FADE_NAME} ${themeVars.transition.default}`
18
- }),
19
-
20
- leaveActive: style({
21
- animation: `${FADE_DURATION}s ${FADE_NAME} ${themeVars.transition.default} reverse`
22
- }),
23
-
24
- enterFrom: style({
25
- opacity: 0
26
- }),
27
-
28
- leaveTo: style({
29
- opacity: 0
30
- })
31
- };
32
-
33
- const SCALE_NAME = 'scale';
34
- const SCALE_DURATION = 0.12;
35
- globalKeyframes(SCALE_NAME, {
36
- '0%': {
37
- opacity: 0,
38
- scale: 0.95
39
- },
40
- '100%': {
41
- opacity: 1,
42
- scale: 1
43
- }
44
- });
45
-
46
- export const scale = {
47
- enterActive: style({
48
- animation: `${SCALE_DURATION}s ${SCALE_NAME} ${themeVars.transition.default}`
49
- }),
50
-
51
- leaveActive: style({
52
- animation: `${SCALE_DURATION}s ${SCALE_NAME} ${themeVars.transition.default} reverse`
53
- }),
54
-
55
- enterFrom: style({
56
- opacity: 0
57
- }),
58
-
59
- leaveTo: style({
60
- opacity: 0
61
- })
62
- };
63
-
64
- const MODAL_NAME = 'modal';
65
- const MODAL_DURATION = 0.5;
66
- globalKeyframes(MODAL_NAME, {
67
- '0%': {
68
- opacity: 0,
69
- scale: 0.95,
70
- // offset bottom
71
- transformOrigin: 'bottom',
72
- transform: `translateY(10%)`
73
- },
74
- '100%': {
75
- opacity: 1,
76
- scale: 1,
77
- transform: `translateY(0%)`
78
- }
79
- });
80
-
81
- export const modalScale = {
82
- enterActive: style({
83
- animation: `${MODAL_DURATION}s ${MODAL_NAME} ${themeVars.transition.default}`
84
- }),
85
-
86
- leaveActive: style({
87
- animation: `${MODAL_DURATION}s ${MODAL_NAME} ${themeVars.transition.default} reverse`
88
- }),
89
-
90
- enterFrom: style({
91
- opacity: 0
92
- }),
93
-
94
- leaveTo: style({
95
- opacity: 0
96
- })
97
- };
1
+ import { style, globalKeyframes } from '@vanilla-extract/css';
2
+ import { themeVars } from './theme.css';
3
+
4
+ const FADE_NAME = 'fade';
5
+ const FADE_DURATION = 0.2;
6
+ globalKeyframes(FADE_NAME, {
7
+ from: {
8
+ opacity: 0
9
+ },
10
+ to: {
11
+ opacity: 1
12
+ }
13
+ });
14
+
15
+ export const fade = {
16
+ enterActive: style({
17
+ animation: `${FADE_DURATION}s ${FADE_NAME} ${themeVars.transition.default}`
18
+ }),
19
+
20
+ leaveActive: style({
21
+ animation: `${FADE_DURATION}s ${FADE_NAME} ${themeVars.transition.default} reverse`
22
+ }),
23
+
24
+ enterFrom: style({
25
+ opacity: 0
26
+ }),
27
+
28
+ leaveTo: style({
29
+ opacity: 0
30
+ })
31
+ };
32
+
33
+ const SCALE_NAME = 'scale';
34
+ const SCALE_DURATION = 0.12;
35
+ globalKeyframes(SCALE_NAME, {
36
+ '0%': {
37
+ opacity: 0,
38
+ scale: 0.95
39
+ },
40
+ '100%': {
41
+ opacity: 1,
42
+ scale: 1
43
+ }
44
+ });
45
+
46
+ export const scale = {
47
+ enterActive: style({
48
+ animation: `${SCALE_DURATION}s ${SCALE_NAME} ${themeVars.transition.default}`
49
+ }),
50
+
51
+ leaveActive: style({
52
+ animation: `${SCALE_DURATION}s ${SCALE_NAME} ${themeVars.transition.default} reverse`
53
+ }),
54
+
55
+ enterFrom: style({
56
+ opacity: 0
57
+ }),
58
+
59
+ leaveTo: style({
60
+ opacity: 0
61
+ })
62
+ };
63
+
64
+ const MODAL_NAME = 'modal';
65
+ const MODAL_DURATION = 0.5;
66
+ globalKeyframes(MODAL_NAME, {
67
+ '0%': {
68
+ opacity: 0,
69
+ scale: 0.95,
70
+ // offset bottom
71
+ transformOrigin: 'bottom',
72
+ transform: `translateY(10%)`
73
+ },
74
+ '100%': {
75
+ opacity: 1,
76
+ scale: 1,
77
+ transform: `translateY(0%)`
78
+ }
79
+ });
80
+
81
+ export const modalScale = {
82
+ enterActive: style({
83
+ animation: `${MODAL_DURATION}s ${MODAL_NAME} ${themeVars.transition.default}`,
84
+ willChange: 'transform, opacity'
85
+ }),
86
+
87
+ leaveActive: style({
88
+ animation: `${MODAL_DURATION}s ${MODAL_NAME} ${themeVars.transition.default} reverse`
89
+ }),
90
+
91
+ enterFrom: style({
92
+ opacity: 0
93
+ }),
94
+
95
+ leaveTo: style({
96
+ opacity: 0
97
+ })
98
+ };