srcdev-nuxt-components 6.2.13 → 7.0.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.
@@ -0,0 +1,174 @@
1
+ /**
2
+ * Composable for managing tooltip guides with automatic sequential popover display
3
+ *
4
+ * @param containerRef - Template ref to the container element containing the popovers
5
+ * @param options - Configuration options
6
+ * @returns Object with guide controls and state
7
+ */
8
+ export const useTooltipsGuide = (
9
+ containerRef: Ref<HTMLElement | null>,
10
+ options: {
11
+ autoStart?: boolean
12
+ startDelay?: number
13
+ } = {}
14
+ ) => {
15
+ const { autoStart = true, startDelay = 2000 } = options
16
+
17
+ // State management
18
+ const isGuideRunning = ref(false)
19
+ const currentTooltipIndex = ref(0)
20
+ const autoRunGuide = ref(autoStart)
21
+
22
+ // Internal popover collection
23
+ const popovers: HTMLElement[] = []
24
+
25
+ /**
26
+ * Initialize popovers array from the container
27
+ */
28
+ const initializePopovers = () => {
29
+ popovers.length = 0 // Clear existing
30
+ containerRef.value?.querySelectorAll<HTMLElement>("[popover]").forEach((popover) => {
31
+ popovers.push(popover)
32
+ })
33
+ }
34
+
35
+ /**
36
+ * Show a tooltip and wait for user dismissal
37
+ */
38
+ const showTooltipAndWaitForDismiss = (popover: HTMLElement): Promise<void> => {
39
+ return new Promise((resolve) => {
40
+ // Find the trigger button that corresponds to this popover
41
+ const popoverId = popover.id
42
+ const triggerButton = document.querySelector<HTMLElement>(
43
+ `[popovertarget="${popoverId}"][popovertargetaction="toggle"]`
44
+ )
45
+
46
+ // Use the trigger button to show the popover to maintain proper anchor relationship
47
+ if (triggerButton) {
48
+ triggerButton.click()
49
+ } else {
50
+ // Fallback if no trigger button found
51
+ popover.togglePopover(true)
52
+ }
53
+
54
+ // Find the close button within this popover
55
+ const closeButton = popover.querySelector<HTMLElement>('[popovertargetaction="hide"]')
56
+
57
+ if (closeButton) {
58
+ // Listen for click on the close button
59
+ const handleClose = () => {
60
+ closeButton.removeEventListener("click", handleClose)
61
+ resolve()
62
+ }
63
+
64
+ closeButton.addEventListener("click", handleClose)
65
+ } else {
66
+ // Fallback: listen for the popover to be hidden
67
+ const handleToggle = () => {
68
+ if (!popover.matches(":popover-open")) {
69
+ popover.removeEventListener("toggle", handleToggle)
70
+ resolve()
71
+ }
72
+ }
73
+
74
+ popover.addEventListener("toggle", handleToggle)
75
+ }
76
+ })
77
+ }
78
+
79
+ /**
80
+ * Start the automatic tooltip guide
81
+ */
82
+ const startGuide = async () => {
83
+ if (isGuideRunning.value || popovers.length === 0) return
84
+
85
+ isGuideRunning.value = true
86
+ currentTooltipIndex.value = 0
87
+
88
+ for (let i = 0; i < popovers.length; i++) {
89
+ const popover = popovers[i]
90
+ if (popover) {
91
+ currentTooltipIndex.value = i
92
+ await showTooltipAndWaitForDismiss(popover)
93
+ }
94
+ }
95
+
96
+ // Guide completed
97
+ autoRunGuide.value = false
98
+ isGuideRunning.value = false
99
+ }
100
+
101
+ /**
102
+ * Restart the tooltip guide
103
+ */
104
+ const restartGuide = async () => {
105
+ if (isGuideRunning.value) return
106
+
107
+ // Close any currently open popovers
108
+ popovers.forEach((popover) => {
109
+ if (popover.matches(":popover-open")) {
110
+ popover.togglePopover(false)
111
+ }
112
+ })
113
+
114
+ // Reset state and start the guide
115
+ autoRunGuide.value = true
116
+ await startGuide()
117
+ }
118
+
119
+ /**
120
+ * Stop the current guide
121
+ */
122
+ const stopGuide = () => {
123
+ if (!isGuideRunning.value) return
124
+
125
+ // Close any currently open popovers
126
+ popovers.forEach((popover) => {
127
+ if (popover.matches(":popover-open")) {
128
+ popover.togglePopover(false)
129
+ }
130
+ })
131
+
132
+ isGuideRunning.value = false
133
+ autoRunGuide.value = false
134
+ }
135
+
136
+ /**
137
+ * Initialize and auto-start if enabled
138
+ */
139
+ const initialize = async () => {
140
+ if (startDelay > 0) {
141
+ await useSleep(startDelay)
142
+ }
143
+
144
+ initializePopovers()
145
+
146
+ if (autoRunGuide.value && popovers.length > 0) {
147
+ await startGuide()
148
+ }
149
+ }
150
+
151
+ // Auto-initialize on mount
152
+ onMounted(initialize)
153
+
154
+ return {
155
+ // State
156
+ isGuideRunning: readonly(isGuideRunning),
157
+ currentTooltipIndex: readonly(currentTooltipIndex),
158
+ autoRunGuide: readonly(autoRunGuide),
159
+
160
+ // Methods
161
+ startGuide,
162
+ restartGuide,
163
+ stopGuide,
164
+ initializePopovers,
165
+
166
+ // Computed
167
+ hasPopovers: computed(() => popovers.length > 0),
168
+ totalPopovers: computed(() => popovers.length),
169
+ }
170
+ }
171
+
172
+ export type TooltipsGuide = ReturnType<typeof useTooltipsGuide>
173
+
174
+ export default useTooltipsGuide
@@ -0,0 +1,10 @@
1
+ export interface AlertMaskConfig {
2
+ backgroundColour?: string
3
+ borderColour?: string
4
+ radiusLeft?: number
5
+ radiusRight?: number
6
+ borderLeft?: number
7
+ borderTop?: number
8
+ borderRight?: number
9
+ borderBottom?: number
10
+ }
@@ -0,0 +1,53 @@
1
+ import type { VNode, ComponentPublicInstance } from "vue"
2
+
3
+ export type DisplayToastTheme =
4
+ | "primary"
5
+ | "secondary"
6
+ | "tertiary"
7
+ | "ghost"
8
+ | "error"
9
+ | "info"
10
+ | "success"
11
+ | "warning"
12
+
13
+ export type DisplayToastPosition = "top" | "bottom"
14
+ export type DisplayToastAlignment = "left" | "center" | "right"
15
+
16
+ export interface DisplayToastAppearanceConfig {
17
+ theme?: DisplayToastTheme
18
+ position?: DisplayToastPosition
19
+ alignment?: DisplayToastAlignment
20
+ fullWidth?: boolean
21
+ }
22
+
23
+ export interface DisplayToastBehaviorConfig {
24
+ autoDismiss?: boolean
25
+ duration?: number
26
+ revealDuration?: number
27
+ returnFocusTo?: HTMLElement | ComponentPublicInstance | null
28
+ }
29
+
30
+ export interface DisplayToastContentConfig {
31
+ text?: string
32
+ title?: string
33
+ description?: string
34
+ customIcon?: string
35
+ }
36
+
37
+ export interface DisplayToastConfig {
38
+ appearance?: DisplayToastAppearanceConfig
39
+ behavior?: DisplayToastBehaviorConfig
40
+ content?: DisplayToastContentConfig
41
+ }
42
+
43
+ export interface DisplayToastProps {
44
+ config?: DisplayToastConfig
45
+ styleClassPassthrough?: string | string[]
46
+ }
47
+
48
+ export interface ToastSlots {
49
+ default?(props?: Record<string, never>): VNode[]
50
+ customToastIcon?(props?: Record<string, never>): VNode[]
51
+ title?(props?: Record<string, never>): VNode[]
52
+ description?(props?: Record<string, never>): VNode[]
53
+ }
@@ -0,0 +1,7 @@
1
+ import type { SVGVariant } from "nuxt-qrcode"
2
+
3
+ export interface QrCodeVariant {
4
+ inner: SVGVariant
5
+ marker: SVGVariant
6
+ pixel: SVGVariant
7
+ }
@@ -5,3 +5,8 @@ export * from "../components/image-galleries/SliderGallery.vue"
5
5
  export * from "../components/display-toast/DisplayToast.vue"
6
6
  export * from "../components/alert-mask/AlertMaskCore.vue"
7
7
  export * from "../components/canvas-switcher/CanvasSwitcher.vue"
8
+
9
+ // Export types from the components directory
10
+ export * from "./components/display-toast.d"
11
+ export * from "./components/qr-code.d"
12
+ export * from "./components/alert-mask-core.d"
package/nuxt.config.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  export default defineNuxtConfig({
3
3
  devtools: { enabled: true },
4
4
  // css: ["modern-normalize", "./app/assets/styles/main.css"],
5
- modules: ["@nuxt/eslint", "@nuxt/icon", "@nuxt/image", "@nuxtjs/i18n"],
5
+ modules: ["@nuxt/eslint", "@nuxt/icon", "@nuxt/image", "@nuxtjs/i18n", "nuxt-qrcode"],
6
6
  i18n: {
7
7
  defaultLocale: "en",
8
8
  locales: ["en"],
@@ -41,5 +41,6 @@ export default defineNuxtConfig({
41
41
  compatibilityDate: "2024-11-01",
42
42
  typescript: {
43
43
  includeWorkspace: true,
44
+ strict: true,
44
45
  },
45
46
  })
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "srcdev-nuxt-components",
3
3
  "type": "module",
4
- "version": "6.2.13",
4
+ "version": "7.0.0",
5
5
  "main": "nuxt.config.ts",
6
+ "types": "types.d.ts",
6
7
  "scripts": {
7
8
  "clean": "rm -rf .nuxt && rm -rf .output && rm -rf .playground/.nuxt && rm -rf .playground/.output",
8
9
  "cleanall": "rm -rf node_modules && rm -rf .nuxt && rm -rf .output && rm -rf .playground/.nuxt && rm -rf .playground/.output && rm -rf .playground/node_modules && rm package-lock.json",
@@ -18,7 +19,8 @@
18
19
  },
19
20
  "files": [
20
21
  "app/",
21
- "nuxt.config.ts"
22
+ "nuxt.config.ts",
23
+ "types.d.ts"
22
24
  ],
23
25
  "devDependencies": {
24
26
  "@iconify-json/akar-icons": "1.2.7",
@@ -35,9 +37,11 @@
35
37
  "eslint": "9.39.1",
36
38
  "focus-trap-vue": "4.1.0",
37
39
  "nuxt": "4.2.1",
40
+ "nuxt-qrcode": "^0.4.8",
38
41
  "patch-package": "8.0.1",
39
42
  "release-it": "19.0.6",
40
- "typescript": "5.9.3"
43
+ "typescript": "5.9.3",
44
+ "vue-tsc": "^3.2.1"
41
45
  },
42
46
  "release-it": {
43
47
  "$schema": "https://unpkg.com/release-it/schema/release-it.json",
package/types.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ // Layer type exports for consumers
2
+ export * from "./app/types/components/display-toast.d"
3
+ export * from "./app/types/components/qr-code.d"
4
+ export * from "./app/types/components/alert-mask-core.d"