@innertia-solutions/ui 0.1.6 → 0.1.9

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": "@innertia-solutions/ui",
3
- "version": "0.1.6",
3
+ "version": "0.1.9",
4
4
  "description": "Innertia Solutions — Nuxt UI layer: components and composables",
5
5
  "keywords": [
6
6
  "nuxt",
@@ -22,8 +22,7 @@
22
22
  },
23
23
  "peerDependencies": {
24
24
  "nuxt": ">=3.0.0",
25
- "vue": ">=3.0.0",
26
- "preline": ">=2.0.0"
25
+ "vue": ">=3.0.0"
27
26
  },
28
27
  "devDependencies": {
29
28
  "nuxt": "^3.16.0",
@@ -6,72 +6,62 @@ declare global {
6
6
  }
7
7
  }
8
8
 
9
- export default defineNuxtPlugin(async () => {
9
+ export default defineNuxtPlugin(() => {
10
10
  if (!process.client) return
11
11
 
12
- try {
13
- await import('preline')
14
-
15
- const initPreline = () => {
16
- try { window.HSStaticMethods?.autoInit?.() } catch (_) {}
17
- try { window.HSThemeAppearance?.init?.() } catch (_) {}
18
- }
19
-
20
- const performMultipleInits = () => {
21
- initPreline()
22
- setTimeout(initPreline, 50)
23
- setTimeout(initPreline, 200)
24
- setTimeout(initPreline, 500)
25
- }
12
+ const initPreline = () => {
13
+ try { window.HSStaticMethods?.autoInit?.() } catch (_) {}
14
+ try { window.HSThemeAppearance?.init?.() } catch (_) {}
15
+ }
26
16
 
27
- // Inicialización inicial
28
- if (document.readyState === 'loading') {
29
- document.addEventListener('DOMContentLoaded', performMultipleInits)
30
- } else {
31
- nextTick(performMultipleInits)
32
- }
17
+ const performMultipleInits = () => {
18
+ initPreline()
19
+ setTimeout(initPreline, 50)
20
+ setTimeout(initPreline, 200)
21
+ setTimeout(initPreline, 500)
22
+ }
33
23
 
34
- const nuxtApp = useNuxtApp()
24
+ if (document.readyState === 'loading') {
25
+ document.addEventListener('DOMContentLoaded', performMultipleInits)
26
+ } else {
27
+ nextTick(performMultipleInits)
28
+ }
35
29
 
36
- // Re-inicializar en cada cambio de página
37
- nuxtApp.hooks.hook('page:finish', () => {
38
- requestAnimationFrame(performMultipleInits)
39
- })
30
+ const nuxtApp = useNuxtApp()
40
31
 
41
- nuxtApp.hooks.hookOnce('app:mounted', () => {
42
- performMultipleInits()
43
- })
32
+ nuxtApp.hooks.hook('page:finish', () => {
33
+ requestAnimationFrame(performMultipleInits)
34
+ })
44
35
 
45
- // MutationObserver: reinicializar cuando aparezcan elementos Preline en el DOM
46
- const observer = new MutationObserver((mutations) => {
47
- const hasPreline = mutations.some(({ addedNodes }) =>
48
- Array.from(addedNodes).some((node) => {
49
- if (node.nodeType !== Node.ELEMENT_NODE) return false
50
- const el = node as Element
51
- return (
52
- el.querySelector?.('[data-hs-overlay],[data-hs-dropdown],[data-hs-select]') ||
53
- el.hasAttribute?.('data-hs-overlay') ||
54
- el.hasAttribute?.('data-hs-dropdown') ||
55
- el.hasAttribute?.('data-hs-select') ||
56
- (typeof el.className === 'string' && el.className.includes('hs-'))
57
- )
58
- })
59
- )
60
- if (hasPreline) {
61
- setTimeout(initPreline, 10)
62
- setTimeout(initPreline, 100)
63
- }
64
- })
36
+ nuxtApp.hooks.hookOnce('app:mounted', () => {
37
+ performMultipleInits()
38
+ })
65
39
 
66
- if (document.readyState === 'loading') {
67
- document.addEventListener('DOMContentLoaded', () =>
68
- observer.observe(document.body, { childList: true, subtree: true })
69
- )
70
- } else {
71
- observer.observe(document.body, { childList: true, subtree: true })
40
+ const observer = new MutationObserver((mutations) => {
41
+ const hasPreline = mutations.some(({ addedNodes }) =>
42
+ Array.from(addedNodes).some((node) => {
43
+ if (node.nodeType !== Node.ELEMENT_NODE) return false
44
+ const el = node as Element
45
+ return (
46
+ el.querySelector?.('[data-hs-overlay],[data-hs-dropdown],[data-hs-select]') ||
47
+ el.hasAttribute?.('data-hs-overlay') ||
48
+ el.hasAttribute?.('data-hs-dropdown') ||
49
+ el.hasAttribute?.('data-hs-select') ||
50
+ (typeof el.className === 'string' && el.className.includes('hs-'))
51
+ )
52
+ })
53
+ )
54
+ if (hasPreline) {
55
+ setTimeout(initPreline, 10)
56
+ setTimeout(initPreline, 100)
72
57
  }
58
+ })
73
59
 
74
- } catch (e) {
75
- console.warn('[innertia-ui] Error al cargar Preline:', e)
60
+ if (document.readyState === 'loading') {
61
+ document.addEventListener('DOMContentLoaded', () =>
62
+ observer.observe(document.body, { childList: true, subtree: true })
63
+ )
64
+ } else {
65
+ observer.observe(document.body, { childList: true, subtree: true })
76
66
  }
77
67
  })