@meistrari/tela-build 1.74.1 → 1.74.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.
|
@@ -41,7 +41,7 @@ const props = withDefaults(defineProps<{
|
|
|
41
41
|
iconSide: 'left',
|
|
42
42
|
})
|
|
43
43
|
|
|
44
|
-
defineEmits(['click'])
|
|
44
|
+
const emit = defineEmits(['click', 'update:open'])
|
|
45
45
|
|
|
46
46
|
const search = ref('')
|
|
47
47
|
const searchInputEl = ref<HTMLInputElement>()
|
|
@@ -58,6 +58,7 @@ const groups = computed(() => filteredItems.value.reduce((acc, item) => {
|
|
|
58
58
|
}, {} as Record<string, typeof props.items[number][]>))
|
|
59
59
|
|
|
60
60
|
function onToggle(open: boolean) {
|
|
61
|
+
emit('update:open', open)
|
|
61
62
|
if (!open)
|
|
62
63
|
return
|
|
63
64
|
|
|
@@ -24,6 +24,16 @@ Use `TelaDropdownMenu` when clicking triggers a side effect. Use `TelaSelectMenu
|
|
|
24
24
|
|
|
25
25
|
**The test:** If clicking triggers a side effect → `TelaDropdownMenu`. If it updates a bound value → `TelaSelectMenu`.
|
|
26
26
|
|
|
27
|
+
## Loading menu data on open
|
|
28
|
+
|
|
29
|
+
`update:open` emits a boolean whenever the menu opens or closes, including keyboard activation. Use it to fetch menu data only when needed:
|
|
30
|
+
|
|
31
|
+
```vue
|
|
32
|
+
<TelaDropdownMenu :items="items" @update:open="open => open && loadItems()">
|
|
33
|
+
<TelaButton>Open menu</TelaButton>
|
|
34
|
+
</TelaDropdownMenu>
|
|
35
|
+
```
|
|
36
|
+
|
|
27
37
|
## Examples
|
|
28
38
|
|
|
29
39
|
### Basic Usage
|
package/composables/use-pdf.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import * as pdfjsLib from 'pdfjs-dist'
|
|
2
1
|
import type { PDFDocumentProxy, PDFPageProxy, RenderTask } from 'pdfjs-dist'
|
|
3
2
|
import type { Ref } from 'vue'
|
|
4
3
|
import { markRaw, onUnmounted, reactive, watch } from 'vue'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
pdfjsLib
|
|
5
|
+
async function loadPdfLibrary() {
|
|
6
|
+
const pdfjsLib = await import('pdfjs-dist')
|
|
7
|
+
if (!pdfjsLib.GlobalWorkerOptions.workerSrc)
|
|
8
|
+
pdfjsLib.GlobalWorkerOptions.workerSrc = `https://unpkg.com/pdfjs-dist@${pdfjsLib.version}/build/pdf.worker.min.mjs`
|
|
9
|
+
return pdfjsLib
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
function normalizeForMatch(text: string): string {
|
|
@@ -70,7 +72,11 @@ export function usePdf(url: Ref<string>) {
|
|
|
70
72
|
state.loadError = null
|
|
71
73
|
|
|
72
74
|
try {
|
|
73
|
-
const
|
|
75
|
+
const requestedUrl = url.value
|
|
76
|
+
const pdfjsLib = await loadPdfLibrary()
|
|
77
|
+
if (isUnmounted)
|
|
78
|
+
return null
|
|
79
|
+
const loadingTask = pdfjsLib.getDocument(requestedUrl)
|
|
74
80
|
const doc = await loadingTask.promise
|
|
75
81
|
|
|
76
82
|
if (isUnmounted) {
|
|
@@ -304,6 +310,7 @@ export function usePdf(url: Ref<string>) {
|
|
|
304
310
|
}
|
|
305
311
|
}
|
|
306
312
|
|
|
313
|
+
const pdfjsLib = await loadPdfLibrary()
|
|
307
314
|
for (let itemIndex = 0; itemIndex < textItems.length; itemIndex++) {
|
|
308
315
|
if (isUnmounted)
|
|
309
316
|
return
|