@meistrari/tela-build 1.79.0 → 1.79.2
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/CHANGELOG.md +1 -0
- package/components/tela/kbd/kbd-return.vue +8 -0
- package/components/tela/kbd/kbd.mdx +13 -0
- package/components/tela/kbd/kbd.vue +1 -1
- package/components/tela/loaders/splash-screen/splash-screen.mdx +2 -2
- package/components/tela/loaders/splash-screen/splash-screen.vue +33 -38
- package/composables/__tests__/use-pdf.test.ts +140 -0
- package/composables/use-pdf.ts +38 -15
- package/docs/animations.md +4 -0
- package/package.json +1 -1
- package/utils/component-utils.ts +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,7 @@ Latest updates and announcements.
|
|
|
5
5
|
## October 5, 2026
|
|
6
6
|
|
|
7
7
|
- [Floating chat](/templates/chat#floating) adds `position="left" | "right"` (default `right`) to place the launcher and panel in either bottom corner, with matching alignment and mirrored open/close animations.
|
|
8
|
+
- [Kbd](/components/kbd) icon keys render a 12px icon inside the 16×16 key, and Enter is now `TelaKbd icon="i-ph-arrow-bend-down-left"`. `TelaKbdReturn` is deprecated and logs a warning in development.
|
|
8
9
|
|
|
9
10
|
## September 30, 2026
|
|
10
11
|
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use `<TelaKbd icon="i-ph-arrow-bend-down-left" />` instead. Kept for apps that still render it.
|
|
4
|
+
*/
|
|
5
|
+
if (import.meta.dev)
|
|
6
|
+
warnOnce('[tela-build] TelaKbdReturn is deprecated. Use <TelaKbd icon="i-ph-arrow-bend-down-left" /> instead.')
|
|
7
|
+
</script>
|
|
8
|
+
|
|
1
9
|
<template>
|
|
2
10
|
<div h-20px w-20px bg="#EFF0F3" rounded-4px relative>
|
|
3
11
|
<div h-10px w-12px bg="#60798F" rounded-4px absolute class="top-50% translate-y--50% left-50% translate-x--50%" />
|
|
@@ -55,6 +55,19 @@ type KbdProps = {
|
|
|
55
55
|
</div>
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
### Icon Keys
|
|
59
|
+
|
|
60
|
+
Pass `icon` for modifier and special keys. Icon keys are 16×16 with a 12px Phosphor icon, the same height as text keys. Enter uses `i-ph-arrow-bend-down-left` (`TelaKbdReturn` is deprecated).
|
|
61
|
+
|
|
62
|
+
```vue
|
|
63
|
+
<div class="flex gap-1">
|
|
64
|
+
<TelaKbd icon="i-ph-command" />
|
|
65
|
+
<TelaKbd>K</TelaKbd>
|
|
66
|
+
<TelaKbd icon="i-ph-option" />
|
|
67
|
+
<TelaKbd icon="i-ph-arrow-bend-down-left" />
|
|
68
|
+
</div>
|
|
69
|
+
```
|
|
70
|
+
|
|
58
71
|
### Arrow Keys
|
|
59
72
|
|
|
60
73
|
```vue
|
|
@@ -17,7 +17,7 @@ const variantClasses = computed(() => (({
|
|
|
17
17
|
flex items-center justify-center w-16px h-16px text-10px leading-none tracking-normal rounded-5px
|
|
18
18
|
:class="cn(variantClasses)"
|
|
19
19
|
>
|
|
20
|
-
<TelaIcon v-if="icon" :name="icon" class="h-
|
|
20
|
+
<TelaIcon v-if="icon" :name="icon" class="h-12px! w-12px!" />
|
|
21
21
|
<span v-else class="translate-0.25px"><slot /></span>
|
|
22
22
|
</code>
|
|
23
23
|
</template>
|
|
@@ -4,7 +4,7 @@ import { Meta } from '@storybook/blocks';
|
|
|
4
4
|
|
|
5
5
|
# TelaLoadersSplashScreen
|
|
6
6
|
|
|
7
|
-
Full-viewport white overlay shown while the app boots. It centers a `TelaLoadersSquare` and, when `modelValue` turns false,
|
|
7
|
+
Full-viewport white overlay shown while the app boots. It centers a `TelaLoadersSquare` and, when `modelValue` turns false, fades the overlay out over 150 ms (instantly with reduced motion) before emitting `hidden`. Mount it once at the app root and flip the flag when the first page is ready.
|
|
8
8
|
|
|
9
9
|
## Props
|
|
10
10
|
|
|
@@ -23,7 +23,7 @@ type SplashScreenProps = {
|
|
|
23
23
|
|
|
24
24
|
## Basic Usage
|
|
25
25
|
|
|
26
|
-
The overlay keeps rendering during the
|
|
26
|
+
The overlay keeps rendering during the fade and ignores pointer events, so it is safe to set `modelValue` to `false` as soon as data is ready.
|
|
27
27
|
|
|
28
28
|
```vue
|
|
29
29
|
<script setup lang="ts">
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { animate } from 'motion-v'
|
|
3
|
-
|
|
4
2
|
const props = defineProps<{
|
|
5
3
|
modelValue: boolean
|
|
6
4
|
}>()
|
|
@@ -10,44 +8,41 @@ const emit = defineEmits<{
|
|
|
10
8
|
(e: 'hidden'): void
|
|
11
9
|
}>()
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
isAnimatingOut.value = true
|
|
11
|
+
function onHidden() {
|
|
12
|
+
// A new load may have started while the previous splash was fading out.
|
|
13
|
+
if (props.modelValue)
|
|
14
|
+
return
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
'linear-gradient(-160deg,black 120%,transparent calc(120% + 80%),transparent)',
|
|
23
|
-
'linear-gradient(-160deg,black -100%,transparent calc(-100% + 80%),transparent)',
|
|
24
|
-
],
|
|
25
|
-
}, {
|
|
26
|
-
duration: 1,
|
|
27
|
-
delay: 1.2,
|
|
28
|
-
ease: 'backInOut',
|
|
29
|
-
}],
|
|
30
|
-
['#square-screen', {
|
|
31
|
-
opacity: [1, 0],
|
|
32
|
-
}, {
|
|
33
|
-
duration: 0.8,
|
|
34
|
-
ease: 'backInOut',
|
|
35
|
-
}],
|
|
36
|
-
]).finished.then(() => {
|
|
37
|
-
isAnimatingOut.value = false
|
|
38
|
-
emit('update:modelValue', false)
|
|
39
|
-
emit('hidden')
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
}, { immediate: true })
|
|
16
|
+
emit('update:modelValue', false)
|
|
17
|
+
emit('hidden')
|
|
18
|
+
}
|
|
43
19
|
</script>
|
|
44
20
|
|
|
45
21
|
<template>
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
22
|
+
<Transition name="splash" @after-leave="onHidden">
|
|
23
|
+
<div
|
|
24
|
+
v-if="props.modelValue"
|
|
25
|
+
id="square-screen"
|
|
26
|
+
fixed w-100dvw h-100dvh inset-0 z-9999 flex items-center justify-center bg-white
|
|
27
|
+
>
|
|
28
|
+
<TelaLoadersSquare id="square" size="md" />
|
|
29
|
+
</div>
|
|
30
|
+
</Transition>
|
|
53
31
|
</template>
|
|
32
|
+
|
|
33
|
+
<style scoped>
|
|
34
|
+
.splash-leave-active {
|
|
35
|
+
transition: opacity 150ms ease-out;
|
|
36
|
+
pointer-events: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.splash-leave-to {
|
|
40
|
+
opacity: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@media (prefers-reduced-motion: reduce) {
|
|
44
|
+
.splash-leave-active {
|
|
45
|
+
transition: none;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
</style>
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { flushPromises, mount } from '@vue/test-utils'
|
|
3
|
+
import { defineComponent, ref } from 'vue'
|
|
4
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
5
|
+
import { usePdf } from '../use-pdf'
|
|
6
|
+
import { usePdfLoader } from '../use-pdf-loader'
|
|
7
|
+
|
|
8
|
+
const pdf = vi.hoisted(() => ({
|
|
9
|
+
imported: vi.fn(),
|
|
10
|
+
getDocument: vi.fn(),
|
|
11
|
+
worker: { workerSrc: '' },
|
|
12
|
+
}))
|
|
13
|
+
|
|
14
|
+
vi.mock('pdfjs-dist', () => {
|
|
15
|
+
pdf.imported()
|
|
16
|
+
return { version: 'test', GlobalWorkerOptions: pdf.worker, getDocument: pdf.getDocument }
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
function setup() {
|
|
20
|
+
const url = ref('/document.pdf')
|
|
21
|
+
let result!: ReturnType<typeof usePdf>
|
|
22
|
+
const wrapper = mount(defineComponent({
|
|
23
|
+
setup() {
|
|
24
|
+
result = usePdf(url)
|
|
25
|
+
return () => null
|
|
26
|
+
},
|
|
27
|
+
}))
|
|
28
|
+
return { wrapper, result, url }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
pdf.getDocument.mockReset()
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
describe('on-demand PDF engine', () => {
|
|
36
|
+
it('does not evaluate the engine when the composable is imported or mounted', () => {
|
|
37
|
+
const { wrapper } = setup()
|
|
38
|
+
expect(pdf.imported).not.toHaveBeenCalled()
|
|
39
|
+
expect(pdf.getDocument).not.toHaveBeenCalled()
|
|
40
|
+
wrapper.unmount()
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('loads on demand and releases the document on unmount', async () => {
|
|
44
|
+
const doc = { numPages: 3, destroy: vi.fn() }
|
|
45
|
+
pdf.getDocument.mockReturnValue({ promise: Promise.resolve(doc) })
|
|
46
|
+
const { wrapper, result } = setup()
|
|
47
|
+
expect(await result.loadPdf()).toBe(doc)
|
|
48
|
+
expect(pdf.getDocument).toHaveBeenCalledWith('/document.pdf')
|
|
49
|
+
expect(result.state.totalPages).toBe(3)
|
|
50
|
+
expect(result.state.isLoading).toBe(false)
|
|
51
|
+
expect(pdf.worker.workerSrc).toContain('pdfjs-dist@test')
|
|
52
|
+
wrapper.unmount()
|
|
53
|
+
expect(doc.destroy).toHaveBeenCalledOnce()
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('does not start fetching a document if unmounted while importing the engine', async () => {
|
|
57
|
+
const { wrapper, result } = setup()
|
|
58
|
+
const loading = result.loadPdf()
|
|
59
|
+
wrapper.unmount()
|
|
60
|
+
expect(await loading).toBeNull()
|
|
61
|
+
expect(pdf.getDocument).not.toHaveBeenCalled()
|
|
62
|
+
})
|
|
63
|
+
it('loads the latest selection if it changes during the engine import', async () => {
|
|
64
|
+
const doc = { numPages: 2, destroy: vi.fn() }
|
|
65
|
+
pdf.getDocument.mockReturnValue({ promise: Promise.resolve(doc) })
|
|
66
|
+
const { wrapper, result, url } = setup()
|
|
67
|
+
const obsolete = result.loadPdf()
|
|
68
|
+
url.value = '/latest.pdf'
|
|
69
|
+
await flushPromises()
|
|
70
|
+
expect(await obsolete).toBeNull()
|
|
71
|
+
await vi.waitFor(() => expect(result.state.pdfDoc).toBe(doc))
|
|
72
|
+
expect(pdf.getDocument).toHaveBeenCalledOnce()
|
|
73
|
+
expect(pdf.getDocument).toHaveBeenCalledWith('/latest.pdf')
|
|
74
|
+
expect(result.state.pdfDoc).toBe(doc)
|
|
75
|
+
wrapper.unmount()
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('discards and destroys an older document that finishes after the latest load', async () => {
|
|
79
|
+
let resolveOld!: (doc: { numPages: number, destroy: ReturnType<typeof vi.fn> }) => void
|
|
80
|
+
const oldDoc = { numPages: 1, destroy: vi.fn() }
|
|
81
|
+
const latestDoc = { numPages: 2, destroy: vi.fn() }
|
|
82
|
+
pdf.getDocument.mockReturnValueOnce({ promise: new Promise((resolve) => {
|
|
83
|
+
resolveOld = resolve
|
|
84
|
+
}) })
|
|
85
|
+
.mockReturnValueOnce({ promise: Promise.resolve(latestDoc) })
|
|
86
|
+
const { wrapper, result, url } = setup()
|
|
87
|
+
const older = result.loadPdf()
|
|
88
|
+
await flushPromises()
|
|
89
|
+
url.value = '/latest.pdf'
|
|
90
|
+
await flushPromises()
|
|
91
|
+
resolveOld(oldDoc)
|
|
92
|
+
expect(await older).toBeNull()
|
|
93
|
+
expect(oldDoc.destroy).toHaveBeenCalledOnce()
|
|
94
|
+
expect(result.state.pdfDoc).toBe(latestDoc)
|
|
95
|
+
expect(result.state.isLoading).toBe(false)
|
|
96
|
+
wrapper.unmount()
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('releases the previous displayed document when replacing it', async () => {
|
|
100
|
+
const oldDoc = { numPages: 1, destroy: vi.fn() }
|
|
101
|
+
const latestDoc = { numPages: 2, destroy: vi.fn() }
|
|
102
|
+
pdf.getDocument.mockReturnValueOnce({ promise: Promise.resolve(oldDoc) })
|
|
103
|
+
.mockReturnValueOnce({ promise: Promise.resolve(latestDoc) })
|
|
104
|
+
const { wrapper, result, url } = setup()
|
|
105
|
+
await result.loadPdf()
|
|
106
|
+
url.value = '/latest.pdf'
|
|
107
|
+
await flushPromises()
|
|
108
|
+
expect(oldDoc.destroy).toHaveBeenCalledOnce()
|
|
109
|
+
expect(result.state.pdfDoc).toBe(latestDoc)
|
|
110
|
+
wrapper.unmount()
|
|
111
|
+
})
|
|
112
|
+
it('shares automatic and explicit requests for the same URL', async () => {
|
|
113
|
+
const doc = { numPages: 2, destroy: vi.fn() }
|
|
114
|
+
pdf.getDocument.mockReturnValue({ promise: Promise.resolve(doc) })
|
|
115
|
+
const { wrapper, result, url } = setup()
|
|
116
|
+
url.value = '/selected.pdf'
|
|
117
|
+
const first = result.loadPdf()
|
|
118
|
+
const second = result.loadPdf()
|
|
119
|
+
expect(await first).toBe(doc)
|
|
120
|
+
expect(await second).toBe(doc)
|
|
121
|
+
expect(pdf.getDocument).toHaveBeenCalledOnce()
|
|
122
|
+
wrapper.unmount()
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it('returns a valid preview handle through the existing PDF loader wrapper', async () => {
|
|
126
|
+
const doc = { numPages: 3, destroy: vi.fn() }
|
|
127
|
+
pdf.getDocument.mockReturnValue({ promise: Promise.resolve(doc) })
|
|
128
|
+
let loader!: ReturnType<typeof usePdfLoader>
|
|
129
|
+
const wrapper = mount(defineComponent({
|
|
130
|
+
setup() {
|
|
131
|
+
loader = usePdfLoader()
|
|
132
|
+
return () => null
|
|
133
|
+
},
|
|
134
|
+
}))
|
|
135
|
+
const handle = await loader.pdfLoader('/preview.pdf')
|
|
136
|
+
expect(handle?.numPages).toBe(3)
|
|
137
|
+
expect(pdf.getDocument).toHaveBeenCalledOnce()
|
|
138
|
+
wrapper.unmount()
|
|
139
|
+
})
|
|
140
|
+
})
|
package/composables/use-pdf.ts
CHANGED
|
@@ -2,11 +2,18 @@ import type { PDFDocumentProxy, PDFPageProxy, RenderTask } from 'pdfjs-dist'
|
|
|
2
2
|
import type { Ref } from 'vue'
|
|
3
3
|
import { markRaw, onUnmounted, reactive, watch } from 'vue'
|
|
4
4
|
|
|
5
|
+
let pdfLibrary: Promise<typeof import('pdfjs-dist')> | undefined
|
|
6
|
+
|
|
5
7
|
async function loadPdfLibrary() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
pdfLibrary ??= import('pdfjs-dist').then((library) => {
|
|
9
|
+
if (!library.GlobalWorkerOptions.workerSrc)
|
|
10
|
+
library.GlobalWorkerOptions.workerSrc = `https://unpkg.com/pdfjs-dist@${library.version}/build/pdf.worker.min.mjs`
|
|
11
|
+
return library
|
|
12
|
+
}).catch((error) => {
|
|
13
|
+
pdfLibrary = undefined
|
|
14
|
+
throw error
|
|
15
|
+
})
|
|
16
|
+
return await pdfLibrary
|
|
10
17
|
}
|
|
11
18
|
|
|
12
19
|
function normalizeForMatch(text: string): string {
|
|
@@ -48,7 +55,9 @@ export function usePdf(url: Ref<string>) {
|
|
|
48
55
|
|
|
49
56
|
let isUnmounted = false
|
|
50
57
|
const activeRenderTasks = new Map<number, RenderTask>()
|
|
51
|
-
let
|
|
58
|
+
let loadRevision = 0
|
|
59
|
+
let loadingUrl: string | undefined
|
|
60
|
+
let activeLoad: Promise<PDFDocumentProxy | null> | undefined
|
|
52
61
|
const activeCanvasRenders = new WeakMap<
|
|
53
62
|
HTMLCanvasElement,
|
|
54
63
|
{
|
|
@@ -64,36 +73,48 @@ export function usePdf(url: Ref<string>) {
|
|
|
64
73
|
>()
|
|
65
74
|
|
|
66
75
|
async function loadPdf(): Promise<PDFDocumentProxy | null> {
|
|
67
|
-
isExplicitlyLoading = true
|
|
68
76
|
if (isUnmounted)
|
|
69
77
|
return null
|
|
70
78
|
|
|
79
|
+
const requestedUrl = url.value
|
|
80
|
+
if (activeLoad && loadingUrl === requestedUrl)
|
|
81
|
+
return await activeLoad
|
|
82
|
+
|
|
83
|
+
const revision = ++loadRevision
|
|
84
|
+
loadingUrl = requestedUrl
|
|
85
|
+
activeLoad = performLoad(requestedUrl, revision).finally(() => {
|
|
86
|
+
if (revision === loadRevision)
|
|
87
|
+
activeLoad = undefined
|
|
88
|
+
})
|
|
89
|
+
return await activeLoad
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function performLoad(requestedUrl: string, revision: number): Promise<PDFDocumentProxy | null> {
|
|
71
93
|
state.isLoading = true
|
|
72
94
|
state.loadError = null
|
|
73
95
|
|
|
74
96
|
try {
|
|
75
|
-
const requestedUrl = url.value
|
|
76
97
|
const pdfjsLib = await loadPdfLibrary()
|
|
77
|
-
if (isUnmounted)
|
|
98
|
+
if (isUnmounted || revision !== loadRevision)
|
|
78
99
|
return null
|
|
79
100
|
const loadingTask = pdfjsLib.getDocument(requestedUrl)
|
|
80
101
|
const doc = await loadingTask.promise
|
|
81
102
|
|
|
82
|
-
if (isUnmounted) {
|
|
103
|
+
if (isUnmounted || revision !== loadRevision) {
|
|
83
104
|
void doc.destroy()
|
|
84
105
|
return null
|
|
85
106
|
}
|
|
86
107
|
|
|
108
|
+
if (state.pdfDoc && state.pdfDoc !== doc)
|
|
109
|
+
void state.pdfDoc.destroy()
|
|
87
110
|
state.pdfDoc = markRaw(doc)
|
|
88
111
|
state.totalPages = doc.numPages
|
|
89
112
|
state.isLoading = false
|
|
90
|
-
isExplicitlyLoading = false
|
|
91
113
|
|
|
92
114
|
return doc
|
|
93
115
|
}
|
|
94
116
|
catch (err: any) {
|
|
95
|
-
|
|
96
|
-
if (isUnmounted)
|
|
117
|
+
if (isUnmounted || revision !== loadRevision)
|
|
97
118
|
return null
|
|
98
119
|
|
|
99
120
|
console.error('PDF load error:', err)
|
|
@@ -231,6 +252,10 @@ export function usePdf(url: Ref<string>) {
|
|
|
231
252
|
textLayer.style.width = `${viewport.width}px`
|
|
232
253
|
textLayer.style.height = `${viewport.height}px`
|
|
233
254
|
|
|
255
|
+
const pdfjsLib = await loadPdfLibrary()
|
|
256
|
+
if (isUnmounted)
|
|
257
|
+
return
|
|
258
|
+
|
|
234
259
|
const textContent = await page.getTextContent()
|
|
235
260
|
|
|
236
261
|
if (isUnmounted)
|
|
@@ -310,7 +335,6 @@ export function usePdf(url: Ref<string>) {
|
|
|
310
335
|
}
|
|
311
336
|
}
|
|
312
337
|
|
|
313
|
-
const pdfjsLib = await loadPdfLibrary()
|
|
314
338
|
for (let itemIndex = 0; itemIndex < textItems.length; itemIndex++) {
|
|
315
339
|
if (isUnmounted)
|
|
316
340
|
return
|
|
@@ -374,8 +398,7 @@ export function usePdf(url: Ref<string>) {
|
|
|
374
398
|
}
|
|
375
399
|
|
|
376
400
|
watch(url, () => {
|
|
377
|
-
|
|
378
|
-
void loadPdf()
|
|
401
|
+
void loadPdf()
|
|
379
402
|
})
|
|
380
403
|
|
|
381
404
|
onUnmounted(() => {
|
package/docs/animations.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Principles for deciding when to animate, choosing easing and duration, using springs, and building staggered enter animations.
|
|
4
4
|
|
|
5
|
+
## Startup splash
|
|
6
|
+
|
|
7
|
+
The splash leaves when `modelValue` becomes false, using a 150 ms opacity transition with no artificial hold. Pointer events are disabled during exit. Reduced-motion users get no transition. `hidden` emits after the leave completes; an interrupted leave or unmount must not emit a stale completion. Consumers should tie the model to real readiness and avoid a second welcome overlay.
|
|
8
|
+
|
|
5
9
|
Before writing any animation code, answer these questions in order:
|
|
6
10
|
|
|
7
11
|
### 1. Should this animate at all?
|
package/package.json
CHANGED
package/utils/component-utils.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { clsx } from 'clsx'
|
|
2
|
+
import type { ClassValue } from 'clsx'
|
|
2
3
|
import { twMerge } from 'tailwind-merge'
|
|
3
4
|
import { camelize, getCurrentInstance, toHandlerKey } from 'vue'
|
|
4
5
|
|
|
@@ -28,3 +29,12 @@ export function useEmitAsProps<Name extends string>(
|
|
|
28
29
|
})
|
|
29
30
|
return result
|
|
30
31
|
}
|
|
32
|
+
|
|
33
|
+
const warnedMessages = new Set<string>()
|
|
34
|
+
|
|
35
|
+
export function warnOnce(message: string) {
|
|
36
|
+
if (warnedMessages.has(message))
|
|
37
|
+
return
|
|
38
|
+
warnedMessages.add(message)
|
|
39
|
+
console.warn(message)
|
|
40
|
+
}
|