ux4g-components-web 1.1.1 → 1.2.0

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,6 +1,44 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index');
3
+ /**
4
+ * UX4G Runtime Module
5
+ *
6
+ * Injects the vendor JS (ux4g.js + ux4g-custom.js) into the page as inline scripts.
7
+ * These files handle all interactive behaviors: dropdowns, modals, tooltips,
8
+ * accordions, carousels, drawers, tabs, popovers, toasts, scrollspy, etc.
9
+ *
10
+ * The vendor JS is inlined at build time by the Rollup virtual plugin.
11
+ * At runtime, initRuntime() creates <script> elements with the inlined code.
12
+ *
13
+ * Uses a singleton guard (window.__UX4G_RUNTIME_INITIALIZED__) to ensure
14
+ * the scripts are injected exactly once.
15
+ */
16
+ const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
17
+ /**
18
+ * Initialize the UX4G runtime by injecting the vendor JS scripts into the page.
19
+ *
20
+ * - Safe for SSR — no-ops when window/document are unavailable.
21
+ * - Singleton guard prevents double-injection.
22
+ * - The vendor JS handles its own DOMContentLoaded timing internally.
23
+ * - MutationObserver in the vendor JS auto-initializes dynamically added elements.
24
+ */
25
+ function initRuntime() {
26
+ if (!isBrowser)
27
+ return;
28
+ if (window.__UX4G_RUNTIME_INITIALIZED__)
29
+ return;
30
+ window.__UX4G_RUNTIME_INITIALIZED__ = true;
31
+ // Inject ux4g.js (sets up window.ux4g with all core components)
32
+ const script1 = document.createElement('script');
33
+ script1.setAttribute('data-ux4g-runtime', 'main');
34
+ script1.textContent = __UX4G_VENDOR_MAIN__;
35
+ document.head.appendChild(script1);
36
+ // Inject ux4g-custom.js (extends window.ux4g with custom behaviors)
37
+ const script2 = document.createElement('script');
38
+ script2.setAttribute('data-ux4g-runtime', 'custom');
39
+ script2.textContent = __UX4G_VENDOR_CUSTOM__;
40
+ document.head.appendChild(script2);
41
+ }
4
42
 
5
43
  /**
6
44
  * UX4G Runtime Auto-Bootstrap
@@ -13,4 +51,4 @@ var index = require('./index');
13
51
  * (window.__UX4G_RUNTIME_INITIALIZED__) to ensure initialization happens
14
52
  * exactly once.
15
53
  */
16
- index.initRuntime();
54
+ initRuntime();
@@ -1,4 +1,42 @@
1
- import { initRuntime } from './index';
1
+ /**
2
+ * UX4G Runtime Module
3
+ *
4
+ * Injects the vendor JS (ux4g.js + ux4g-custom.js) into the page as inline scripts.
5
+ * These files handle all interactive behaviors: dropdowns, modals, tooltips,
6
+ * accordions, carousels, drawers, tabs, popovers, toasts, scrollspy, etc.
7
+ *
8
+ * The vendor JS is inlined at build time by the Rollup virtual plugin.
9
+ * At runtime, initRuntime() creates <script> elements with the inlined code.
10
+ *
11
+ * Uses a singleton guard (window.__UX4G_RUNTIME_INITIALIZED__) to ensure
12
+ * the scripts are injected exactly once.
13
+ */
14
+ const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
15
+ /**
16
+ * Initialize the UX4G runtime by injecting the vendor JS scripts into the page.
17
+ *
18
+ * - Safe for SSR — no-ops when window/document are unavailable.
19
+ * - Singleton guard prevents double-injection.
20
+ * - The vendor JS handles its own DOMContentLoaded timing internally.
21
+ * - MutationObserver in the vendor JS auto-initializes dynamically added elements.
22
+ */
23
+ function initRuntime() {
24
+ if (!isBrowser)
25
+ return;
26
+ if (window.__UX4G_RUNTIME_INITIALIZED__)
27
+ return;
28
+ window.__UX4G_RUNTIME_INITIALIZED__ = true;
29
+ // Inject ux4g.js (sets up window.ux4g with all core components)
30
+ const script1 = document.createElement('script');
31
+ script1.setAttribute('data-ux4g-runtime', 'main');
32
+ script1.textContent = __UX4G_VENDOR_MAIN__;
33
+ document.head.appendChild(script1);
34
+ // Inject ux4g-custom.js (extends window.ux4g with custom behaviors)
35
+ const script2 = document.createElement('script');
36
+ script2.setAttribute('data-ux4g-runtime', 'custom');
37
+ script2.textContent = __UX4G_VENDOR_CUSTOM__;
38
+ document.head.appendChild(script2);
39
+ }
2
40
 
3
41
  /**
4
42
  * UX4G Runtime Auto-Bootstrap