@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 +2 -3
- package/plugins/preline.client.ts +47 -57
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@innertia-solutions/ui",
|
|
3
|
-
"version": "0.1.
|
|
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(
|
|
9
|
+
export default defineNuxtPlugin(() => {
|
|
10
10
|
if (!process.client) return
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
const performMultipleInits = () => {
|
|
18
|
+
initPreline()
|
|
19
|
+
setTimeout(initPreline, 50)
|
|
20
|
+
setTimeout(initPreline, 200)
|
|
21
|
+
setTimeout(initPreline, 500)
|
|
22
|
+
}
|
|
33
23
|
|
|
34
|
-
|
|
24
|
+
if (document.readyState === 'loading') {
|
|
25
|
+
document.addEventListener('DOMContentLoaded', performMultipleInits)
|
|
26
|
+
} else {
|
|
27
|
+
nextTick(performMultipleInits)
|
|
28
|
+
}
|
|
35
29
|
|
|
36
|
-
|
|
37
|
-
nuxtApp.hooks.hook('page:finish', () => {
|
|
38
|
-
requestAnimationFrame(performMultipleInits)
|
|
39
|
-
})
|
|
30
|
+
const nuxtApp = useNuxtApp()
|
|
40
31
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
nuxtApp.hooks.hook('page:finish', () => {
|
|
33
|
+
requestAnimationFrame(performMultipleInits)
|
|
34
|
+
})
|
|
44
35
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
75
|
-
|
|
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
|
})
|