@teammodlr/ui-kit 2.1.20 → 2.1.22

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