@teammodlr/ui-kit 3.0.0-beta.10 → 3.0.0-beta.12

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": "3.0.0-beta.10",
3
+ "version": "3.0.0-beta.12",
4
4
  "description": "",
5
5
  "main": "lib/index.cjs.js",
6
6
  "module": "lib/index.es.js",
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div ref="wrapper" class="m-color-picker">
3
- <PopoverRoot v-model:open="isOpen" @update:open="handleOpenChange">
3
+ <PopoverRoot v-model:open="isOpen">
4
4
  <PopoverTrigger as-child>
5
5
  <div ref="referenceRef">
6
6
  <slot :r="finalColor.r" :g="finalColor.g" :b="finalColor.b" :a="finalColor.a" :hex="hexInput"
@@ -147,7 +147,7 @@ export default defineComponent({
147
147
  },
148
148
  transfer: {
149
149
  type: Boolean,
150
- default: false
150
+ default: true
151
151
  },
152
152
  placement: {
153
153
  type: String as PropType<Placement>,
@@ -441,15 +441,13 @@ export default defineComponent({
441
441
  updateFromHex();
442
442
  };
443
443
 
444
- const handleOpenChange = (value: boolean) => {
445
- const wasOpen = isOpen.value;
446
-
447
- isOpen.value = value;
448
-
449
- if (wasOpen && !value) {
444
+ watch(isOpen, (open, wasOpen) => {
445
+ console.log('[ColorPicker] isOpen watch:', { wasOpen, open, hexInput: hexInput.value });
446
+ if (wasOpen && !open) {
447
+ console.log('[ColorPicker] Emitting onColorChange:', hexInput.value);
450
448
  emit('onColorChange', hexInput.value);
451
449
  }
452
- };
450
+ });
453
451
 
454
452
 
455
453
  return {
@@ -485,7 +483,6 @@ export default defineComponent({
485
483
  transfer,
486
484
  canPickColor,
487
485
  openEyeDropper,
488
- handleOpenChange,
489
486
  onSliderChangeComplete,
490
487
  hexInputUser,
491
488
  toggleInherit,
@@ -12,22 +12,13 @@
12
12
  </div>
13
13
  </template>
14
14
 
15
- <script>
16
- export default {
17
- data() {
18
- return {
19
- colorValue: 'rgba(0,0,0,50%)' // Initial color value
20
- };
21
- },
22
- setup() {
23
- const updateColor = (color) => {
24
- console.log(color);
25
- debugger;
26
- }
15
+ <script setup>
16
+ import { ref } from 'vue';
27
17
 
28
- return {
29
- updateColor
30
- }
31
- }
32
- };
18
+ const colorValue = ref('rgba(0,0,0,50%)');
19
+
20
+ function updateColor(color) {
21
+ console.log(color);
22
+ colorValue.value = color;
23
+ }
33
24
  </script>
@@ -64,7 +64,7 @@ export default defineComponent({
64
64
  },
65
65
  },
66
66
  setup(props) {
67
- const activeMessages = new Map<string, { stop: () => void; closed: boolean; onClose?: () => void }>();
67
+ const activeMessages = new Map<string, { stop: () => void; closed: boolean; currentId: string; onClose?: () => void }>();
68
68
 
69
69
  const sonnerPosition = computed(() => placementMap[props.placement]);
70
70
 
@@ -100,9 +100,9 @@ export default defineComponent({
100
100
  return timeout ?? props.timeout;
101
101
  }
102
102
 
103
- function syncToast(message: PrivateMessageReactive) {
103
+ function createToast(message: PrivateMessageReactive, sonnerId: string) {
104
104
  const options: ExternalToast = {
105
- id: message.id,
105
+ id: sonnerId,
106
106
  duration: normalizeDuration(message.timeout),
107
107
  closeButton: message.closeButton ?? message.closable,
108
108
  richColors: message.richColors,
@@ -133,6 +133,23 @@ export default defineComponent({
133
133
  }
134
134
  }
135
135
 
136
+ function syncToast(message: PrivateMessageReactive) {
137
+ const active = activeMessages.get(message.id);
138
+ if (!active) {
139
+ return;
140
+ }
141
+
142
+ const oldId = active.currentId;
143
+ const newId = Math.random().toString(16).slice(2, 14);
144
+ active.currentId = newId;
145
+
146
+ toast.dismiss(oldId);
147
+
148
+ requestAnimationFrame(() => {
149
+ createToast(message, newId);
150
+ });
151
+ }
152
+
136
153
  function closeMessage(id: string, invokeOnClose: boolean) {
137
154
  const active = activeMessages.get(id);
138
155
  if (!active || active.closed) {
@@ -164,20 +181,29 @@ export default defineComponent({
164
181
  type: options.type,
165
182
  onClose: options.onClose,
166
183
  destroy: () => {
184
+ const active = activeMessages.get(id);
185
+ const sonnerId = active?.currentId ?? id;
167
186
  closeMessage(id, false);
168
- toast.dismiss(id);
187
+ toast.dismiss(sonnerId);
169
188
  },
170
189
  }) as PrivateMessageReactive;
171
190
 
191
+ const sonnerId = Math.random().toString(16).slice(2, 14);
192
+ activeMessages.set(id, { stop: () => {}, closed: false, currentId: sonnerId, onClose: options.onClose });
193
+
172
194
  const stop = watch(
173
195
  () => [message.content, message.type, message.timeout, message.closable, message.closeButton, message.richColors, sonnerPosition.value],
174
- () => {
175
- syncToast(message);
196
+ (_, oldVal) => {
197
+ if (!oldVal) {
198
+ createToast(message, activeMessages.get(id)!.currentId);
199
+ } else {
200
+ syncToast(message);
201
+ }
176
202
  },
177
203
  { immediate: true }
178
204
  );
179
205
 
180
- activeMessages.set(id, { stop, closed: false, onClose: options.onClose });
206
+ activeMessages.get(id)!.stop = stop;
181
207
 
182
208
  return message;
183
209
  }