pns-component-library 1.6.6 → 1.6.7

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": "pns-component-library",
3
- "version": "1.6.6",
3
+ "version": "1.6.7",
4
4
  "main": "dist/pns-component-library.umd.js",
5
5
  "module": "dist/pns-component-library.es.js",
6
6
  "exports": {
@@ -0,0 +1,57 @@
1
+ import { createApp, h } from "vue";
2
+ import Snackbar from "@/components/Snackbar.vue";
3
+
4
+ const floating_snackbar_instances_map = {};
5
+
6
+ export function FloatingSnackbar(snackbar_props = {}, slots) {
7
+ // 1. Check if container exists, create if not
8
+ var floating_snackbar_container = document.getElementById('floating-snackbar-container');
9
+ if (!floating_snackbar_container) {
10
+ floating_snackbar_container = document.createElement('div');
11
+ floating_snackbar_container.id = 'floating-snackbar-container';
12
+ document.body.appendChild(floating_snackbar_container);
13
+ }
14
+
15
+ // 2. Create app instance with unique timestamp ID
16
+ const timestamp = Date.now();
17
+
18
+ // 3. Build event handlers from props (onAction1, onAction2, etc.)
19
+ const event_handlers = {};
20
+ const component_props = {};
21
+
22
+ Object.keys(snackbar_props).forEach(key => {
23
+ if (key === 'onAction' && typeof snackbar_props[key] === 'function') {
24
+ // Handle single action event
25
+ event_handlers.onAction = snackbar_props[key];
26
+ } else if (key === 'onClose') {
27
+ // Handle onClose
28
+ event_handlers.onClose = snackbar_props[key];
29
+ } else {
30
+ // Regular props
31
+ component_props[key] = snackbar_props[key];
32
+ }
33
+ });
34
+
35
+ const appInstance = createApp({
36
+ render: () => h(
37
+ Snackbar,
38
+ {
39
+ ...component_props,
40
+ id: timestamp,
41
+ snackbar_instances_collection: floating_snackbar_instances_map,
42
+ mounted_programmatically: true,
43
+ ...event_handlers
44
+ },
45
+ slots
46
+ )
47
+ });
48
+
49
+ // 4. Record app instance
50
+ floating_snackbar_instances_map[timestamp] = appInstance;
51
+
52
+ // 5. Create root element and mount
53
+ const root_element = document.createElement('div');
54
+ root_element.style.transition = 'all 0.5s ease-out';
55
+ floating_snackbar_container.appendChild(root_element);
56
+ appInstance.mount(root_element);
57
+ }