@teammodlr/ui-kit 2.1.20 → 2.1.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teammodlr/ui-kit",
3
- "version": "2.1.20",
3
+ "version": "2.1.21",
4
4
  "description": "",
5
5
  "main": "lib/index.cjs.js",
6
6
  "module": "lib/index.es.js",
@@ -1,26 +1,25 @@
1
1
  <template>
2
2
  <slot />
3
- <template>
3
+ <template v-if="!isServer">
4
4
  <Teleport :to="teleportTo ?? 'body'">
5
5
  <transition
6
6
  type="animation"
7
7
  :enter-active-class="modalScale.enterActive"
8
8
  :leave-active-class="modalScale.leaveActive"
9
9
  :enter-from-class="modalScale.enterFrom"
10
- :leave-to-class="modalScale.leaveTo"
11
- >
12
- <div :class="classes">
13
- <MMessage v-for="message in messageList"
14
- :key="message.key"
15
- :internalKey="message.key"
16
- :variant="message.type"
17
- :content="message.content"
18
- :timeout="message.timeout ?? timeout"
19
- ref="messageRefs"
20
- :on-internal-after-leave="onInternalAfterLeave" />
10
+ :leave-to-class="modalScale.leaveTo">
11
+ <div :class="classes">
12
+ <MMessage
13
+ v-for="message in messageList"
14
+ :key="message.key"
15
+ :internalKey="message.key"
16
+ :variant="message.type"
17
+ :content="message.content"
18
+ :timeout="message.timeout ?? timeout"
19
+ ref="messageRefs"
20
+ :on-internal-after-leave="onInternalAfterLeave" />
21
21
  </div>
22
22
  </transition>
23
-
24
23
  </Teleport>
25
24
  </template>
26
25
  </template>
@@ -34,21 +33,29 @@ import {
34
33
  provide,
35
34
  computed
36
35
  } from 'vue';
37
- import type { MessageType, MessageReactive, MessageOptions, MessageApiInjection, ContentType, MessagePlacement } from './types';
36
+ import type {
37
+ MessageType,
38
+ MessageReactive,
39
+ MessageOptions,
40
+ MessageApiInjection,
41
+ ContentType,
42
+ MessagePlacement
43
+ } from './types';
38
44
  import type { PropType } from 'vue';
39
45
  import MMessage from './Message.vue';
40
46
  import { useCachedUid } from '../../composables/useCachedUid';
41
47
  import * as style from './style';
42
48
  import { modalScale } from '../../styles/transitions.css';
49
+ import { useIsServer } from '../../composables/useIsServer';
43
50
  export type MessageProviderInst = MessageApiInjection;
44
51
 
45
52
  interface PrivateMessageReactive extends MessageReactive {
46
- key: string
53
+ key: string;
47
54
  }
48
55
 
49
56
  interface PrivateMessageRef extends MessageReactive {
50
- key: string
51
- hide: () => void
57
+ key: string;
58
+ hide: () => void;
52
59
  }
53
60
 
54
61
  export default defineComponent({
@@ -71,26 +78,27 @@ export default defineComponent({
71
78
  }
72
79
  },
73
80
  setup(props, { slots }) {
81
+ const isServer = useIsServer();
74
82
  const messageListRef = ref<PrivateMessageReactive[]>([]);
75
83
  const messageRefs = ref<Record<string, PrivateMessageRef>>({});
76
84
  const api: MessageApiInjection = {
77
85
  create(content: ContentType, options?: MessageOptions) {
78
- return create(content, { type: 'default', ...options })
86
+ return create(content, { type: 'default', ...options });
79
87
  },
80
88
  info(content: ContentType, options?: MessageOptions) {
81
- return create(content, { ...options, type: 'info' })
89
+ return create(content, { ...options, type: 'info' });
82
90
  },
83
91
  success(content: ContentType, options?: MessageOptions) {
84
- return create(content, { ...options, type: 'success' })
92
+ return create(content, { ...options, type: 'success' });
85
93
  },
86
94
  warning(content: ContentType, options?: MessageOptions) {
87
- return create(content, { ...options, type: 'warning' })
95
+ return create(content, { ...options, type: 'warning' });
88
96
  },
89
97
  error(content: ContentType, options?: MessageOptions) {
90
- return create(content, { ...options, type: 'error' })
98
+ return create(content, { ...options, type: 'error' });
91
99
  },
92
100
  loading(content: ContentType, options?: MessageOptions) {
93
- return create(content, { ...options, type: 'loading' })
101
+ return create(content, { ...options, type: 'loading' });
94
102
  },
95
103
  destroyAll
96
104
  };
@@ -118,14 +126,14 @@ export default defineComponent({
118
126
 
119
127
  function destroyAll(): void {
120
128
  //@ts-ignore
121
- Object.values(messageRefs.value).forEach((messageRef) => {
129
+ Object.values(messageRefs.value).forEach(messageRef => {
122
130
  messageRef.hide();
123
131
  });
124
132
  }
125
133
 
126
134
  function onInternalAfterLeave(key: string): void {
127
135
  messageListRef.value = messageListRef.value.filter(
128
- (message) => message.key !== key
136
+ message => message.key !== key
129
137
  );
130
138
  delete messageRefs.value[key];
131
139
  }
@@ -135,19 +143,20 @@ export default defineComponent({
135
143
  style.wrapper,
136
144
  // @ts-ignore
137
145
  [style.placement[props.placement]]
138
- ]
146
+ ];
139
147
  });
140
148
 
141
149
  return Object.assign(
142
150
  {
143
151
  messageRefs,
144
152
  messageList: messageListRef,
153
+ isServer,
145
154
  onInternalAfterLeave,
146
155
  classes,
147
156
  modalScale
148
157
  },
149
- api,
150
- )
158
+ api
159
+ );
151
160
  }
152
161
  });
153
162
  </script>