@innertia-solutions/ui 0.1.4 → 0.1.6
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/components/App/Button.vue +59 -0
- package/components/App/Dropdown.vue +286 -0
- package/components/App/LinkButton.vue +23 -0
- package/components/App/PageLoadingSpinner.vue +118 -0
- package/components/App/Tag.vue +193 -0
- package/components/Forms/DatePicker.vue +255 -0
- package/components/Forms/Select.vue +82 -71
- package/components/Forms/SelectServer.vue +726 -0
- package/package.json +3 -2
- package/plugins/preline.client.ts +77 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@innertia-solutions/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Innertia Solutions — Nuxt UI layer: components and composables",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nuxt",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"nuxt": ">=3.0.0",
|
|
25
|
-
"vue": ">=3.0.0"
|
|
25
|
+
"vue": ">=3.0.0",
|
|
26
|
+
"preline": ">=2.0.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"nuxt": "^3.16.0",
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
HSStaticMethods?: { autoInit?: () => void }
|
|
4
|
+
HSSelect?: new (el: HTMLElement) => { destroy?: () => void }
|
|
5
|
+
HSThemeAppearance?: { init?: () => void }
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default defineNuxtPlugin(async () => {
|
|
10
|
+
if (!process.client) return
|
|
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
|
+
}
|
|
26
|
+
|
|
27
|
+
// Inicialización inicial
|
|
28
|
+
if (document.readyState === 'loading') {
|
|
29
|
+
document.addEventListener('DOMContentLoaded', performMultipleInits)
|
|
30
|
+
} else {
|
|
31
|
+
nextTick(performMultipleInits)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const nuxtApp = useNuxtApp()
|
|
35
|
+
|
|
36
|
+
// Re-inicializar en cada cambio de página
|
|
37
|
+
nuxtApp.hooks.hook('page:finish', () => {
|
|
38
|
+
requestAnimationFrame(performMultipleInits)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
nuxtApp.hooks.hookOnce('app:mounted', () => {
|
|
42
|
+
performMultipleInits()
|
|
43
|
+
})
|
|
44
|
+
|
|
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
|
+
})
|
|
65
|
+
|
|
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 })
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
} catch (e) {
|
|
75
|
+
console.warn('[innertia-ui] Error al cargar Preline:', e)
|
|
76
|
+
}
|
|
77
|
+
})
|