@inkbar/vue 0.9.0 → 0.11.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.
Files changed (104) hide show
  1. package/README.md +63 -2
  2. package/dist/components/InkDownloadButton.js +7 -0
  3. package/dist/components/InkDownloadButton.js.map +1 -0
  4. package/dist/components/InkDownloadButton.vue.d.ts +21 -0
  5. package/dist/components/InkDownloadButton.vue.d.ts.map +1 -0
  6. package/dist/components/InkDownloadButton.vue_vue_type_script_setup_true_lang.js +42 -0
  7. package/dist/components/InkDownloadButton.vue_vue_type_script_setup_true_lang.js.map +1 -0
  8. package/dist/components/InkFindBar.js.map +1 -1
  9. package/dist/components/InkFindBar.vue.d.ts.map +1 -1
  10. package/dist/components/InkFindBar.vue_vue_type_script_setup_true_lang.js +48 -48
  11. package/dist/components/InkFindBar.vue_vue_type_script_setup_true_lang.js.map +1 -1
  12. package/dist/components/InkPanel.js +7 -0
  13. package/dist/components/InkPanel.js.map +1 -0
  14. package/dist/components/InkPanel.vue.d.ts +21 -0
  15. package/dist/components/InkPanel.vue.d.ts.map +1 -0
  16. package/dist/components/InkPanel.vue_vue_type_script_setup_true_lang.js +48 -0
  17. package/dist/components/InkPanel.vue_vue_type_script_setup_true_lang.js.map +1 -0
  18. package/dist/components/InkPrintButton.js +7 -0
  19. package/dist/components/InkPrintButton.js.map +1 -0
  20. package/dist/components/InkPrintButton.vue.d.ts +19 -0
  21. package/dist/components/InkPrintButton.vue.d.ts.map +1 -0
  22. package/dist/components/InkPrintButton.vue_vue_type_script_setup_true_lang.js +39 -0
  23. package/dist/components/InkPrintButton.vue_vue_type_script_setup_true_lang.js.map +1 -0
  24. package/dist/components/InkRecordList.js +7 -0
  25. package/dist/components/InkRecordList.js.map +1 -0
  26. package/dist/components/InkRecordList.vue.d.ts +35 -0
  27. package/dist/components/InkRecordList.vue.d.ts.map +1 -0
  28. package/dist/components/InkRecordList.vue_vue_type_script_setup_true_lang.js +41 -0
  29. package/dist/components/InkRecordList.vue_vue_type_script_setup_true_lang.js.map +1 -0
  30. package/dist/components/InkRoot.js.map +1 -1
  31. package/dist/components/InkRoot.vue.d.ts +39 -0
  32. package/dist/components/InkRoot.vue.d.ts.map +1 -1
  33. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js +45 -45
  34. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js.map +1 -1
  35. package/dist/components/InkSearchResults.js +7 -0
  36. package/dist/components/InkSearchResults.js.map +1 -0
  37. package/dist/components/InkSearchResults.vue.d.ts +9 -0
  38. package/dist/components/InkSearchResults.vue.d.ts.map +1 -0
  39. package/dist/components/InkSearchResults.vue_vue_type_script_setup_true_lang.js +52 -0
  40. package/dist/components/InkSearchResults.vue_vue_type_script_setup_true_lang.js.map +1 -0
  41. package/dist/components/InkSidebar.js +7 -0
  42. package/dist/components/InkSidebar.js.map +1 -0
  43. package/dist/components/InkSidebar.vue.d.ts +34 -0
  44. package/dist/components/InkSidebar.vue.d.ts.map +1 -0
  45. package/dist/components/InkSidebar.vue_vue_type_script_setup_true_lang.js +95 -0
  46. package/dist/components/InkSidebar.vue_vue_type_script_setup_true_lang.js.map +1 -0
  47. package/dist/components/InkThumbnail.js +7 -0
  48. package/dist/components/InkThumbnail.js.map +1 -0
  49. package/dist/components/InkThumbnail.vue.d.ts +18 -0
  50. package/dist/components/InkThumbnail.vue.d.ts.map +1 -0
  51. package/dist/components/InkThumbnail.vue_vue_type_script_setup_true_lang.js +49 -0
  52. package/dist/components/InkThumbnail.vue_vue_type_script_setup_true_lang.js.map +1 -0
  53. package/dist/components/InkThumbnails.js +7 -0
  54. package/dist/components/InkThumbnails.js.map +1 -0
  55. package/dist/components/InkThumbnails.vue.d.ts +27 -0
  56. package/dist/components/InkThumbnails.vue.d.ts.map +1 -0
  57. package/dist/components/InkThumbnails.vue_vue_type_script_setup_true_lang.js +107 -0
  58. package/dist/components/InkThumbnails.vue_vue_type_script_setup_true_lang.js.map +1 -0
  59. package/dist/components/InkViewport.js.map +1 -1
  60. package/dist/components/InkViewport.vue.d.ts +3 -0
  61. package/dist/components/InkViewport.vue.d.ts.map +1 -1
  62. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js +12 -2
  63. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js.map +1 -1
  64. package/dist/components/InkZoomSelect.js.map +1 -1
  65. package/dist/components/InkZoomSelect.vue.d.ts.map +1 -1
  66. package/dist/components/InkZoomSelect.vue_vue_type_script_setup_true_lang.js +1 -1
  67. package/dist/components/InkZoomSelect.vue_vue_type_script_setup_true_lang.js.map +1 -1
  68. package/dist/components/RecordCards.js +7 -0
  69. package/dist/components/RecordCards.js.map +1 -0
  70. package/dist/components/RecordCards.vue.d.ts +25 -0
  71. package/dist/components/RecordCards.vue.d.ts.map +1 -0
  72. package/dist/components/RecordCards.vue_vue_type_script_setup_true_lang.js +120 -0
  73. package/dist/components/RecordCards.vue_vue_type_script_setup_true_lang.js.map +1 -0
  74. package/dist/components/SidebarTrigger.js +7 -0
  75. package/dist/components/SidebarTrigger.js.map +1 -0
  76. package/dist/components/SidebarTrigger.vue.d.ts +9 -0
  77. package/dist/components/SidebarTrigger.vue.d.ts.map +1 -0
  78. package/dist/components/SidebarTrigger.vue_vue_type_script_setup_true_lang.js +33 -0
  79. package/dist/components/SidebarTrigger.vue_vue_type_script_setup_true_lang.js.map +1 -0
  80. package/dist/components/sidebar-context.d.ts +21 -0
  81. package/dist/components/sidebar-context.d.ts.map +1 -0
  82. package/dist/components/sidebar-context.js +7 -0
  83. package/dist/components/sidebar-context.js.map +1 -0
  84. package/dist/composables/useAnnotations.d.ts +91 -0
  85. package/dist/composables/useAnnotations.d.ts.map +1 -1
  86. package/dist/composables/useRecordSelection.d.ts +12 -0
  87. package/dist/composables/useRecordSelection.d.ts.map +1 -0
  88. package/dist/composables/useRecordSelection.js +15 -0
  89. package/dist/composables/useRecordSelection.js.map +1 -0
  90. package/dist/composables/useRecords.d.ts +14 -0
  91. package/dist/composables/useRecords.d.ts.map +1 -0
  92. package/dist/composables/useRecords.js +16 -0
  93. package/dist/composables/useRecords.js.map +1 -0
  94. package/dist/composables/useSearch.d.ts.map +1 -1
  95. package/dist/composables/useSearch.js +1 -0
  96. package/dist/composables/useSearch.js.map +1 -1
  97. package/dist/index.d.ts +11 -0
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +40 -30
  100. package/dist/to-readable.d.ts +7 -0
  101. package/dist/to-readable.d.ts.map +1 -0
  102. package/dist/to-readable.js +11 -0
  103. package/dist/to-readable.js.map +1 -0
  104. package/package.json +5 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSidebar.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createElementBlock","_mergeProps","_unref","_Fragment","_renderList","_createVNode","SidebarTrigger","_createCommentVNode","_createElementVNode","_normalizeClass","_renderSlot","SidebarTrigger_default","InkSidebar_vue_vue_type_script_setup_true_lang_default","\"open\"","\"openModifiers\"","props","__props","open","useModel","entries","shallowRef","panels","computed","controller","createSidebarController","value","useId","layout","side","visible","list","state","useReadable","register","entry","e","arrange","sorted","x","a","y","b","i","view","s","panel","root","useTemplateRef","onMounted","onBeforeUnmount","openBlock","createElementBlock","mergeProps","unref","createCommentVNode","Fragment","renderList","t","createVNode","createElementVNode","normalizeClass","renderSlot","_ctx"],"sources":["../../src/components/InkSidebar.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * A sidebar of `InkPanel`s: `createSidebar`'s markup on core's sidebar controller, which holds\n * the open state, the ARIA, the keys and the clicks. Rail and tabs render their triggers here;\n * in a stack each panel renders its own header. Panels register as they are set up and take\n * their place in DOM order once mounted, so a panel added later with `v-if` slots in where it\n * stands. A closed panel stays mounted and hidden, and the panels' content stays in place\n * across layouts, so its state survives switching.\n *\n * `v-model:open` is the open panel's id (or null) for rail and tabs, and the expanded ids for\n * stack. Left unbound, the first panel starts open. It needs no document, so it works outside\n * `InkRoot`. The server renders the root, the panels (the open one shown) and the stack\n * headers; rail and tab buttons follow once mounted, as the panels register after the root\n * has rendered.\n */\nimport {\n createSidebarController,\n type SidebarLayout,\n type SidebarOpen,\n type SidebarSide,\n} from '@inkbar/core/dom'\nimport {\n computed,\n onBeforeUnmount,\n onMounted,\n shallowRef,\n useId,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { useReadable } from '../use-readable'\n\nimport { provideSidebarContext, type SidebarPanelEntry } from './sidebar-context'\nimport SidebarTrigger from './SidebarTrigger.vue'\n\nconst props = withDefaults(\n defineProps<{\n side?: SidebarSide | undefined\n layout?: SidebarLayout | undefined\n /** Default true. False hides the whole sidebar and keeps its open panel, content and scroll for when it shows again. */\n visible?: boolean | undefined\n }>(),\n { side: 'left', layout: 'rail', visible: true }\n)\n/** Undefined while unbound and untouched: the controller then opens the first panel. */\nconst open = defineModel<SidebarOpen | undefined>('open')\n\nconst entries = shallowRef<readonly SidebarPanelEntry[]>([])\nconst panels = computed(() => entries.value.map((e) => e.info()))\n\n// Pending until mounted: the panels register one by one while they are set up, and an open id\n// not registered yet is not a removed panel.\nconst controller = createSidebarController({\n layout: props.layout,\n side: props.side,\n visible: props.visible,\n panels: [],\n ...(open.value !== undefined && { open: open.value }),\n pending: true,\n onOpenChange: (value) => {\n open.value = value\n },\n // The same ids on the server and the client.\n idPrefix: useId(),\n})\n// Sync, so a panel set up next reads the attributes its registration gives (on the server too).\nwatch(\n () => [props.layout, props.side, props.visible, panels.value, open.value] as const,\n ([layout, side, visible, list, value]) =>\n controller.update({\n layout,\n side,\n visible,\n panels: list,\n ...(value !== undefined && { open: value }),\n }),\n { flush: 'sync' }\n)\nconst state = useReadable(controller.state, controller.state.get())\n\nfunction register(entry: SidebarPanelEntry): () => void {\n entries.value = [...entries.value, entry]\n return () => {\n entries.value = entries.value.filter((e) => e !== entry)\n }\n}\n\nfunction arrange(): void {\n const list = entries.value\n const sorted = [...list].sort((a, b) => {\n const x = a.element()\n const y = b.element()\n if (!x || !y || x === y) return 0\n return x.compareDocumentPosition(y) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1\n })\n if (sorted.some((e, i) => e !== list[i])) entries.value = sorted\n}\n\nprovideSidebarContext({ controller, state, register, arrange })\n\nconst view = computed(() => {\n const s = state.value\n return {\n root: controller.rootAttrs(),\n tablist: controller.tablistAttrs(),\n triggers: s.panels.map((panel) => ({\n panel,\n attrs: controller.triggerAttrs(panel.id),\n })),\n }\n})\n\nconst root = useTemplateRef<HTMLElement>('root')\n// The controller handles the triggers' clicks and keys, stack headers included.\nonMounted(() => {\n controller.bindTriggers(root.value!)\n controller.update({ pending: false })\n})\nonBeforeUnmount(() => controller.destroy())\n</script>\n\n<template>\n <div ref=\"root\" class=\"ink-sidebar\" v-bind=\"view.root\">\n <div\n v-if=\"state.layout !== 'stack'\"\n :class=\"state.layout === 'rail' ? 'ink-sidebar-rail' : 'ink-sidebar-tabs'\"\n v-bind=\"view.tablist\"\n >\n <button v-for=\"t in view.triggers\" :key=\"t.panel.id\" v-bind=\"t.attrs\">\n <SidebarTrigger :panel=\"t.panel\" :rail=\"state.layout === 'rail'\" />\n </button>\n </div>\n <!-- One element in every layout, so the panels are never remounted. -->\n <div :class=\"{ 'ink-sidebar-panels': state.layout !== 'stack' }\"><slot /></div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAoCA,IAAMiB,IAAQC,GAURC,IAAOnB,EAAoCkB,GAAC,MAAM,GAElDG,IAAUC,EAAyC,CAAC,CAAC,GACrDC,IAASC,QAAeH,EAAQ,MAAM,KAAK,MAAM,EAAE,KAAK,CAAC,CAAC,GAI1DI,IAAaC,EAAwB;GACzC,QAAQT,EAAM;GACd,MAAMA,EAAM;GACZ,SAASA,EAAM;GACf,QAAQ,CAAC;GACT,GAAIE,EAAK,UAAU,KAAA,KAAa,EAAE,MAAMA,EAAK,MAAM;GACnD,SAAS;GACT,eAAe,MAAU;IACvB,EAAK,QAAQQ;GACf;GAEA,UAAUC,EAAM;EACl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GACnCvB,EAAW,OAAO,EAAE,SAAS,GAAM,CAAC;EACtC,CAAC,GACD0B,QAAsB1B,EAAW,QAAQ,CAAC,cAIxCxB,EAAA,GAAAC,EAYM,OAZNC,EAYM;GAZG,SAAA;GAAJ,KAAI6C;GAAO,OAAM;EAAsB,GAAAH,EAAA,MAAK,IAAI,GAAA,CAE3CzC,EAAA6B,CAAA,CAAK,CAAC,WAAM,UASpBvB,EAAAA,IAAAA,EAAAA,KAVAT,EAAA,GAAAC,EAQM,OARNC,EAQM;;GANH,OAAOC,EAAA6B,CAAA,CAAK,CAAC,WAAM,SAAA,qBAAA;EACZ,GAAAY,EAAA,MAAK,OAAO,GAAA,EAEpB5C,EAAA,EAAA,GAAAC,EAESG,GAAA,MAAAC,EAFWuC,EAAA,MAAK,WAAV,OAAf5C,EAAA,GAAAC,EAES,UAFTC,EAES,EAF2B,KAAKwD,EAAE,MAAM,GAAY,GAAA,EAAA,SAAA,GAAA,GAAAA,EAAE,KAAK,GAAA,CAClEpD,EAAmEC,GAAA;GAAlD,OAAOmD,EAAE;GAAQ,MAAMvD,EAAA6B,CAAA,CAAK,CAAC,WAAM;uCAIxDvB,GAAAA,GAAAA,EAAAA,GAAAA,EAAAA,IAAAA,EAA+E,OAAA,EAAzE,OAAKC,EAAA,EAAA,sBAA0BP,EAAA6B,CAAA,CAAK,CAAC,WAAM,QAAA,CAAA,EAAA,GAAA,CAAgBrB,EAAQoD,EAAA,QAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,EAAA"}
@@ -0,0 +1,7 @@
1
+ import e from "./InkThumbnail.vue_vue_type_script_setup_true_lang.js";
2
+ //#region src/components/InkThumbnail.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
6
+
7
+ //# sourceMappingURL=InkThumbnail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkThumbnail.js","names":["_sfc_main","InkThumbnail_vue_vue_type_script_setup_true_lang_default","InkThumbnail_default"],"sources":["../../src/components/InkThumbnail.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * One page as a static image, with its live annotations and plugin marks: core's thumbnail\n * painter on this element, which sizes it, names it (\"Page N\" unless `label` says otherwise)\n * and draws it once it nears the visible area. `page` is 0-based. `width` (default 120) or\n * `height` sets the size; the other follows the page. It is not focusable and does nothing on\n * click: wrap it in the control you need. Inside `InkRoot`; it renders empty on the server.\n */\nimport {\n createThumbnailPainter,\n type ThumbnailOptions,\n type ThumbnailPainter,\n} from '@inkbar/core/dom'\nimport { onBeforeUnmount, onMounted, useTemplateRef, watch } from 'vue'\n\nimport { injectInkContext } from '../context'\nimport { toReadable } from '../to-readable'\n\nconst props = withDefaults(\n defineProps<{\n page: number\n width?: number | undefined\n height?: number | undefined\n annotations?: boolean\n marks?: boolean\n label?: string | undefined\n }>(),\n {\n width: undefined,\n height: undefined,\n annotations: true,\n marks: true,\n label: undefined,\n }\n)\n\nconst ctx = injectInkContext()\nconst deps = {\n document: toReadable(() => ctx.document.value),\n pluginHost: toReadable(() => ctx.pluginHost.value),\n}\nconst options = (): ThumbnailOptions => ({\n page: props.page,\n width: props.width,\n height: props.height,\n annotations: props.annotations,\n marks: props.marks,\n label: props.label,\n})\n\nconst el = useTemplateRef<HTMLElement>('el')\nlet painter: ThumbnailPainter | null = null\nonMounted(() => {\n const p = createThumbnailPainter(el.value!, deps, options())\n painter = p\n watch(options, (next) => p.update(next))\n})\nonBeforeUnmount(() => {\n painter?.destroy()\n painter = null\n})\n</script>\n\n<template>\n <!-- The class is the painter's too: kept here, a re-render never drops it. -->\n <div ref=\"el\" class=\"ink-thumbnail\" />\n</template>\n"],"mappings":""}
@@ -0,0 +1,18 @@
1
+ type __VLS_Props = {
2
+ page: number;
3
+ width?: number | undefined;
4
+ height?: number | undefined;
5
+ annotations?: boolean;
6
+ marks?: boolean;
7
+ label?: string | undefined;
8
+ };
9
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
10
+ width: number | undefined;
11
+ annotations: boolean;
12
+ label: string | undefined;
13
+ height: number | undefined;
14
+ marks: boolean;
15
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
16
+ declare const _default: typeof __VLS_export;
17
+ export default _default;
18
+ //# sourceMappingURL=InkThumbnail.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkThumbnail.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkThumbnail.vue"],"names":[],"mappings":"AAuFA,KAAK,WAAW,GAAG;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC3B,CAAC;AA+DJ,QAAA,MAAM,YAAY;;;;;;6EAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -0,0 +1,49 @@
1
+ import { injectInkContext as e } from "../context.js";
2
+ import { toReadable as t } from "../to-readable.js";
3
+ import { createElementBlock as n, defineComponent as r, onBeforeUnmount as i, onMounted as a, openBlock as o, useTemplateRef as s, watch as c } from "vue";
4
+ import { createThumbnailPainter as l } from "@inkbar/core/dom";
5
+ //#region src/components/InkThumbnail.vue?vue&type=script&setup=true&lang.ts
6
+ var u = /*@__PURE__*/ r({
7
+ __name: "InkThumbnail",
8
+ props: {
9
+ page: {},
10
+ width: { default: void 0 },
11
+ height: { default: void 0 },
12
+ annotations: {
13
+ type: Boolean,
14
+ default: !0
15
+ },
16
+ marks: {
17
+ type: Boolean,
18
+ default: !0
19
+ },
20
+ label: { default: void 0 }
21
+ },
22
+ setup(r) {
23
+ let u = r, d = e(), f = {
24
+ document: t(() => d.document.value),
25
+ pluginHost: t(() => d.pluginHost.value)
26
+ }, p = () => ({
27
+ page: u.page,
28
+ width: u.width,
29
+ height: u.height,
30
+ annotations: u.annotations,
31
+ marks: u.marks,
32
+ label: u.label
33
+ }), m = s("el"), h = null;
34
+ return a(() => {
35
+ let e = l(m.value, f, p());
36
+ h = e, c(p, (t) => e.update(t));
37
+ }), i(() => {
38
+ h?.destroy(), h = null;
39
+ }), (e, t) => (o(), n("div", {
40
+ ref_key: "el",
41
+ ref: m,
42
+ class: "ink-thumbnail"
43
+ }, null, 512));
44
+ }
45
+ });
46
+ //#endregion
47
+ export { u as default };
48
+
49
+ //# sourceMappingURL=InkThumbnail.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkThumbnail.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","InkThumbnail_vue_vue_type_script_setup_true_lang_default","props","__props","ctx","injectInkContext","deps","toReadable","options","el","useTemplateRef","painter","onMounted","p","createThumbnailPainter","watch","next","onBeforeUnmount","openBlock","createElementBlock"],"sources":["../../src/components/InkThumbnail.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * One page as a static image, with its live annotations and plugin marks: core's thumbnail\n * painter on this element, which sizes it, names it (\"Page N\" unless `label` says otherwise)\n * and draws it once it nears the visible area. `page` is 0-based. `width` (default 120) or\n * `height` sets the size; the other follows the page. It is not focusable and does nothing on\n * click: wrap it in the control you need. Inside `InkRoot`; it renders empty on the server.\n */\nimport {\n createThumbnailPainter,\n type ThumbnailOptions,\n type ThumbnailPainter,\n} from '@inkbar/core/dom'\nimport { onBeforeUnmount, onMounted, useTemplateRef, watch } from 'vue'\n\nimport { injectInkContext } from '../context'\nimport { toReadable } from '../to-readable'\n\nconst props = withDefaults(\n defineProps<{\n page: number\n width?: number | undefined\n height?: number | undefined\n annotations?: boolean\n marks?: boolean\n label?: string | undefined\n }>(),\n {\n width: undefined,\n height: undefined,\n annotations: true,\n marks: true,\n label: undefined,\n }\n)\n\nconst ctx = injectInkContext()\nconst deps = {\n document: toReadable(() => ctx.document.value),\n pluginHost: toReadable(() => ctx.pluginHost.value),\n}\nconst options = (): ThumbnailOptions => ({\n page: props.page,\n width: props.width,\n height: props.height,\n annotations: props.annotations,\n marks: props.marks,\n label: props.label,\n})\n\nconst el = useTemplateRef<HTMLElement>('el')\nlet painter: ThumbnailPainter | null = null\nonMounted(() => {\n const p = createThumbnailPainter(el.value!, deps, options())\n painter = p\n watch(options, (next) => p.update(next))\n})\nonBeforeUnmount(() => {\n painter?.destroy()\n painter = null\n})\n</script>\n\n<template>\n <!-- The class is the painter's too: kept here, a re-render never drops it. -->\n <div ref=\"el\" class=\"ink-thumbnail\" />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;EAkBA,IAAMG,IAAQC,GAkBRC,IAAMC,EAAiB,GACvBC,IAAO;GACX,UAAUC,QAAiBH,EAAI,SAAS,KAAK;GAC7C,YAAYG,QAAiBH,EAAI,WAAW,KAAK;EACnD,GACMI,WAAmC;GACvC,MAAMN,EAAM;GACZ,OAAOA,EAAM;GACb,QAAQA,EAAM;GACd,aAAaA,EAAM;GACnB,OAAOA,EAAM;GACb,OAAOA,EAAM;EACf,IAEMO,IAAKC,EAA4B,IAAI,GACvCC,IAAmC;SACvCC,QAAgB;GACd,IAAMC,IAAIC,EAAuBL,EAAG,OAAQH,GAAME,EAAQ,CAAC;GAE3D,AADA,IAAUK,GACVE,EAAMP,IAAU,MAASK,EAAE,OAAOG,CAAI,CAAC;EACzC,CAAC,GACDC,QAAsB;GAEpB,AADAN,GAAS,QAAQ,GACjB,IAAU;EACZ,CAAC,cAKCZ,EAAA,GAAAC,EAAsC,OAAA;GAA7B,SAAA;GAAJ,KAAIS;GAAK,OAAM"}
@@ -0,0 +1,7 @@
1
+ import e from "./InkThumbnails.vue_vue_type_script_setup_true_lang.js";
2
+ //#region src/components/InkThumbnails.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
6
+
7
+ //# sourceMappingURL=InkThumbnails.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkThumbnails.js","names":["_sfc_main","InkThumbnails_vue_vue_type_script_setup_true_lang_default","InkThumbnails_default"],"sources":["../../src/components/InkThumbnails.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The pages as a list of thumbnails: `createThumbnails`' markup on core's thumbnails\n * controller, which holds the current page, the keys, the clicks, the Tab stop and the window.\n * Only the items near the visible part are mounted, each placed at its offset over a spacer of\n * the full height, and each holds an `InkThumbnail`. An item is a button that scrolls the\n * viewport to its page; the current page's has `aria-current=\"page\"`.\n *\n * `pages` lists 0-based pages in order (default: all). The `item` slot, given `{ page, current }`,\n * renders inside each item after its number. The item's height is fixed from the page's, so\n * keep what you add out of the flow (position it absolutely) or small. Inside `InkRoot`; it\n * renders empty on the server.\n */\nimport {\n createThumbnailsController,\n THUMBNAIL_WIDTH,\n type ThumbnailsController,\n type ThumbnailsOptions,\n type ThumbnailsState,\n} from '@inkbar/core/dom'\nimport {\n computed,\n onBeforeUnmount,\n onMounted,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { injectInkContext } from '../context'\nimport { toReadable } from '../to-readable'\n\nimport InkThumbnail from './InkThumbnail.vue'\n\nconst props = withDefaults(\n defineProps<{\n pages?: readonly number[] | undefined\n width?: number | undefined\n annotations?: boolean\n marks?: boolean\n }>(),\n { pages: undefined, width: undefined, annotations: true, marks: true }\n)\n\ndefineSlots<{\n item?(props: { page: number; current: boolean }): unknown\n}>()\n\nconst ctx = injectInkContext()\nconst deps = {\n document: toReadable(() => ctx.document.value),\n pluginHost: toReadable(() => ctx.pluginHost.value),\n viewport: toReadable(() => ctx.viewport.value),\n}\nconst options = (): ThumbnailsOptions => ({\n pages: props.pages,\n width: props.width,\n annotations: props.annotations,\n marks: props.marks,\n})\n\nconst state = shallowRef<ThumbnailsState>({\n pages: [],\n current: -1,\n window: { start: 0, end: 0 },\n offsets: [0],\n width: THUMBNAIL_WIDTH,\n})\nlet controller: ThumbnailsController | null = null\nconst items = computed(() => {\n const { pages, current, window, offsets } = state.value\n return pages.slice(window.start, window.end).map((page, k) => {\n const top = offsets[window.start + k]!\n const bottom = offsets[window.start + k + 1]!\n // Only a mounted controller has a window, so `controller` is set here.\n const attrs = controller?.itemAttrs(window.start + k) ?? {}\n return { page, current: page === current, top, height: bottom - top, attrs }\n })\n})\n\nconst scroller = useTemplateRef<HTMLElement>('scroller')\nlet stopState: (() => void) | null = null\nonMounted(() => {\n const c = createThumbnailsController(deps, options())\n controller = c\n state.value = c.state.get()\n stopState = c.state.subscribe((s) => {\n state.value = s\n })\n watch(options, (next) => c.update(next))\n c.attach(scroller.value!)\n})\nonBeforeUnmount(() => {\n stopState?.()\n stopState = null\n controller?.destroy()\n controller = null\n})\n</script>\n\n<template>\n <div ref=\"scroller\" class=\"ink-thumbnails\" data-ink-thumbnails role=\"list\">\n <div\n class=\"ink-thumbnails-spacer\"\n aria-hidden=\"true\"\n :style=\"{ height: `${state.offsets.at(-1) ?? 0}px` }\"\n />\n <div\n v-for=\"item in items\"\n :key=\"item.page\"\n class=\"ink-thumbnails-entry\"\n v-bind=\"item.attrs\"\n :style=\"{ top: `${item.top}px`, height: `${item.height}px` }\"\n >\n <!-- The controller sets the tabindex. The thumbnail names the button \"Page N\"; the\n visible number repeats it. -->\n <button\n type=\"button\"\n class=\"ink-thumbnails-item\"\n :data-ink-thumbnail-item=\"item.page\"\n :aria-current=\"item.current ? 'page' : undefined\"\n >\n <InkThumbnail\n :page=\"item.page\"\n :width=\"state.width\"\n :annotations=\"annotations\"\n :marks=\"marks\"\n />\n <span class=\"ink-thumbnails-label\" aria-hidden=\"true\">{{ item.page + 1 }}</span>\n <slot name=\"item\" :page=\"item.page\" :current=\"item.current\" />\n </button>\n </div>\n </div>\n</template>\n"],"mappings":""}
@@ -0,0 +1,27 @@
1
+ type __VLS_Props = {
2
+ pages?: readonly number[] | undefined;
3
+ width?: number | undefined;
4
+ annotations?: boolean;
5
+ marks?: boolean;
6
+ };
7
+ type __VLS_Slots = {
8
+ item?(props: {
9
+ page: number;
10
+ current: boolean;
11
+ }): unknown;
12
+ };
13
+ declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
14
+ width: number | undefined;
15
+ annotations: boolean;
16
+ marks: boolean;
17
+ pages: readonly number[] | undefined;
18
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
19
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
20
+ declare const _default: typeof __VLS_export;
21
+ export default _default;
22
+ type __VLS_WithSlots<T, S> = T & {
23
+ new (): {
24
+ $slots: S;
25
+ };
26
+ };
27
+ //# sourceMappingURL=InkThumbnails.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkThumbnails.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkThumbnails.vue"],"names":[],"mappings":"AA0KA,KAAK,WAAW,GAAG;IACf,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;IACrC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAC;AAMJ,KAAK,WAAW,GAAG;IACjB,IAAI,CAAC,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAA;CAC1D,CAAC;AAgIF,QAAA,MAAM,UAAU;;;;;6EAGd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -0,0 +1,107 @@
1
+ import { injectInkContext as e } from "../context.js";
2
+ import { toReadable as t } from "../to-readable.js";
3
+ import n from "./InkThumbnail.js";
4
+ import { Fragment as r, computed as i, createElementBlock as a, createElementVNode as o, createVNode as s, defineComponent as c, mergeProps as l, normalizeStyle as u, onBeforeUnmount as d, onMounted as f, openBlock as p, renderList as m, renderSlot as h, shallowRef as g, toDisplayString as _, useTemplateRef as v, watch as y } from "vue";
5
+ import { THUMBNAIL_WIDTH as b, createThumbnailsController as x } from "@inkbar/core/dom";
6
+ //#region src/components/InkThumbnails.vue?vue&type=script&setup=true&lang.ts
7
+ var S = ["data-ink-thumbnail-item", "aria-current"], C = {
8
+ class: "ink-thumbnails-label",
9
+ "aria-hidden": "true"
10
+ }, w = /*@__PURE__*/ c({
11
+ __name: "InkThumbnails",
12
+ props: {
13
+ pages: { default: void 0 },
14
+ width: { default: void 0 },
15
+ annotations: {
16
+ type: Boolean,
17
+ default: !0
18
+ },
19
+ marks: {
20
+ type: Boolean,
21
+ default: !0
22
+ }
23
+ },
24
+ setup(c) {
25
+ let w = c, T = e(), E = {
26
+ document: t(() => T.document.value),
27
+ pluginHost: t(() => T.pluginHost.value),
28
+ viewport: t(() => T.viewport.value)
29
+ }, D = () => ({
30
+ pages: w.pages,
31
+ width: w.width,
32
+ annotations: w.annotations,
33
+ marks: w.marks
34
+ }), O = g({
35
+ pages: [],
36
+ current: -1,
37
+ window: {
38
+ start: 0,
39
+ end: 0
40
+ },
41
+ offsets: [0],
42
+ width: b
43
+ }), k = null, A = i(() => {
44
+ let { pages: e, current: t, window: n, offsets: r } = O.value;
45
+ return e.slice(n.start, n.end).map((e, i) => {
46
+ let a = r[n.start + i], o = r[n.start + i + 1], s = k?.itemAttrs(n.start + i) ?? {};
47
+ return {
48
+ page: e,
49
+ current: e === t,
50
+ top: a,
51
+ height: o - a,
52
+ attrs: s
53
+ };
54
+ });
55
+ }), j = v("scroller"), M = null;
56
+ return f(() => {
57
+ let e = x(E, D());
58
+ k = e, O.value = e.state.get(), M = e.state.subscribe((e) => {
59
+ O.value = e;
60
+ }), y(D, (t) => e.update(t)), e.attach(j.value);
61
+ }), d(() => {
62
+ M?.(), M = null, k?.destroy(), k = null;
63
+ }), (e, t) => (p(), a("div", {
64
+ ref_key: "scroller",
65
+ ref: j,
66
+ class: "ink-thumbnails",
67
+ "data-ink-thumbnails": "",
68
+ role: "list"
69
+ }, [o("div", {
70
+ class: "ink-thumbnails-spacer",
71
+ "aria-hidden": "true",
72
+ style: u({ height: `${O.value.offsets.at(-1) ?? 0}px` })
73
+ }, null, 4), (p(!0), a(r, null, m(A.value, (t) => (p(), a("div", l({
74
+ key: t.page,
75
+ class: "ink-thumbnails-entry"
76
+ }, { ref_for: !0 }, t.attrs, { style: {
77
+ top: `${t.top}px`,
78
+ height: `${t.height}px`
79
+ } }), [o("button", {
80
+ type: "button",
81
+ class: "ink-thumbnails-item",
82
+ "data-ink-thumbnail-item": t.page,
83
+ "aria-current": t.current ? "page" : void 0
84
+ }, [
85
+ s(n, {
86
+ page: t.page,
87
+ width: O.value.width,
88
+ annotations: c.annotations,
89
+ marks: c.marks
90
+ }, null, 8, [
91
+ "page",
92
+ "width",
93
+ "annotations",
94
+ "marks"
95
+ ]),
96
+ o("span", C, _(t.page + 1), 1),
97
+ h(e.$slots, "item", {
98
+ page: t.page,
99
+ current: t.current
100
+ })
101
+ ], 8, S)], 16))), 128))], 512));
102
+ }
103
+ });
104
+ //#endregion
105
+ export { w as default };
106
+
107
+ //# sourceMappingURL=InkThumbnails.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkThumbnails.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createElementVNode","_normalizeStyle","_Fragment","_renderList","_mergeProps","_createVNode","InkThumbnail","_toDisplayString","_renderSlot","InkThumbnail_default","_hoisted_1","_hoisted_2","InkThumbnails_vue_vue_type_script_setup_true_lang_default","props","__props","ctx","injectInkContext","deps","toReadable","options","state","shallowRef","THUMBNAIL_WIDTH","controller","items","computed","pages","window","top","offsets","k","bottom","attrs","page","current","scroller","useTemplateRef","stopState","onMounted","c","createThumbnailsController","s","watch","next","onBeforeUnmount","openBlock","createElementBlock","createElementVNode","normalizeStyle","Fragment","renderList","mergeProps","item","createVNode","toDisplayString","renderSlot","_ctx"],"sources":["../../src/components/InkThumbnails.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The pages as a list of thumbnails: `createThumbnails`' markup on core's thumbnails\n * controller, which holds the current page, the keys, the clicks, the Tab stop and the window.\n * Only the items near the visible part are mounted, each placed at its offset over a spacer of\n * the full height, and each holds an `InkThumbnail`. An item is a button that scrolls the\n * viewport to its page; the current page's has `aria-current=\"page\"`.\n *\n * `pages` lists 0-based pages in order (default: all). The `item` slot, given `{ page, current }`,\n * renders inside each item after its number. The item's height is fixed from the page's, so\n * keep what you add out of the flow (position it absolutely) or small. Inside `InkRoot`; it\n * renders empty on the server.\n */\nimport {\n createThumbnailsController,\n THUMBNAIL_WIDTH,\n type ThumbnailsController,\n type ThumbnailsOptions,\n type ThumbnailsState,\n} from '@inkbar/core/dom'\nimport {\n computed,\n onBeforeUnmount,\n onMounted,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { injectInkContext } from '../context'\nimport { toReadable } from '../to-readable'\n\nimport InkThumbnail from './InkThumbnail.vue'\n\nconst props = withDefaults(\n defineProps<{\n pages?: readonly number[] | undefined\n width?: number | undefined\n annotations?: boolean\n marks?: boolean\n }>(),\n { pages: undefined, width: undefined, annotations: true, marks: true }\n)\n\ndefineSlots<{\n item?(props: { page: number; current: boolean }): unknown\n}>()\n\nconst ctx = injectInkContext()\nconst deps = {\n document: toReadable(() => ctx.document.value),\n pluginHost: toReadable(() => ctx.pluginHost.value),\n viewport: toReadable(() => ctx.viewport.value),\n}\nconst options = (): ThumbnailsOptions => ({\n pages: props.pages,\n width: props.width,\n annotations: props.annotations,\n marks: props.marks,\n})\n\nconst state = shallowRef<ThumbnailsState>({\n pages: [],\n current: -1,\n window: { start: 0, end: 0 },\n offsets: [0],\n width: THUMBNAIL_WIDTH,\n})\nlet controller: ThumbnailsController | null = null\nconst items = computed(() => {\n const { pages, current, window, offsets } = state.value\n return pages.slice(window.start, window.end).map((page, k) => {\n const top = offsets[window.start + k]!\n const bottom = offsets[window.start + k + 1]!\n // Only a mounted controller has a window, so `controller` is set here.\n const attrs = controller?.itemAttrs(window.start + k) ?? {}\n return { page, current: page === current, top, height: bottom - top, attrs }\n })\n})\n\nconst scroller = useTemplateRef<HTMLElement>('scroller')\nlet stopState: (() => void) | null = null\nonMounted(() => {\n const c = createThumbnailsController(deps, options())\n controller = c\n state.value = c.state.get()\n stopState = c.state.subscribe((s) => {\n state.value = s\n })\n watch(options, (next) => c.update(next))\n c.attach(scroller.value!)\n})\nonBeforeUnmount(() => {\n stopState?.()\n stopState = null\n controller?.destroy()\n controller = null\n})\n</script>\n\n<template>\n <div ref=\"scroller\" class=\"ink-thumbnails\" data-ink-thumbnails role=\"list\">\n <div\n class=\"ink-thumbnails-spacer\"\n aria-hidden=\"true\"\n :style=\"{ height: `${state.offsets.at(-1) ?? 0}px` }\"\n />\n <div\n v-for=\"item in items\"\n :key=\"item.page\"\n class=\"ink-thumbnails-entry\"\n v-bind=\"item.attrs\"\n :style=\"{ top: `${item.top}px`, height: `${item.height}px` }\"\n >\n <!-- The controller sets the tabindex. The thumbnail names the button \"Page N\"; the\n visible number repeats it. -->\n <button\n type=\"button\"\n class=\"ink-thumbnails-item\"\n :data-ink-thumbnail-item=\"item.page\"\n :aria-current=\"item.current ? 'page' : undefined\"\n >\n <InkThumbnail\n :page=\"item.page\"\n :width=\"state.width\"\n :annotations=\"annotations\"\n :marks=\"marks\"\n />\n <span class=\"ink-thumbnails-label\" aria-hidden=\"true\">{{ item.page + 1 }}</span>\n <slot name=\"item\" :page=\"item.page\" :current=\"item.current\" />\n </button>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EAkCA,IAAMe,IAAQC,GAcRC,IAAMC,EAAiB,GACvBC,IAAO;GACX,UAAUC,QAAiBH,EAAI,SAAS,KAAK;GAC7C,YAAYG,QAAiBH,EAAI,WAAW,KAAK;GACjD,UAAUG,QAAiBH,EAAI,SAAS,KAAK;EAC/C,GACMI,WAAoC;GACxC,OAAON,EAAM;GACb,OAAOA,EAAM;GACb,aAAaA,EAAM;GACnB,OAAOA,EAAM;EACf,IAEMO,IAAQC,EAA4B;GACxC,OAAO,CAAC;GACR,SAAS;GACT,QAAQ;IAAE,OAAO;IAAG,KAAK;GAAE;GAC3B,SAAS,CAAC,CAAC;GACX,OAAOC;EACT,CAAC,GACGC,IAA0C,MACxCC,IAAQC,QAAe;GAC3B,IAAM,EAAE,UAAO,YAAS,WAAQ,eAAYL,EAAM;GAClD,OAAOM,EAAM,MAAMC,EAAO,OAAOA,EAAO,GAAG,CAAC,CAAC,KAAK,GAAM,MAAM;IAC5D,IAAMC,IAAMC,EAAQF,EAAO,QAAQG,IAC7BC,IAASF,EAAQF,EAAO,QAAQG,IAAI,IAEpCE,IAAQT,GAAY,UAAUI,EAAO,QAAQG,CAAC,KAAK,CAAC;IAC1D,OAAO;KAAE;KAAM,SAASG,MAASC;KAAS;KAAK,QAAQH,IAASH;KAAK;IAAM;GAC7E,CAAC;EACH,CAAC,GAEKO,IAAWC,EAA4B,UAAU,GACnDC,IAAiC;SACrCC,QAAgB;GACd,IAAMC,IAAIC,EAA2BvB,GAAME,EAAQ,CAAC;GAOpD,AANA,IAAaoB,GACb,EAAM,QAAQA,EAAE,MAAM,IAAI,GAC1B,IAAYA,EAAE,MAAM,WAAW,MAAM;IACnC,EAAM,QAAQE;GAChB,CAAC,GACDC,EAAMvB,IAAU,MAASoB,EAAE,OAAOI,CAAI,CAAC,GACvCJ,EAAE,OAAOJ,EAAS,KAAM;EAC1B,CAAC,GACDS,QAAsB;GAIpB,AAHAP,IAAY,GACZ,IAAY,MACZd,GAAY,QAAQ,GACpB,IAAa;EACf,CAAC,cAICzB,EAAA,GAAAC,EA+BM,OAAA;GA/BG,SAAA;GAAJ,KAAIoC;GAAW,OAAM;GAAiB,uBAAA;GAAoB,MAAK;EAClEnC,GAAAA,CAAAA,EAIE,OAAA;GAHA,OAAM;GACN,eAAY;GACX,OAAKC,EAAA,EAAA,QAAA,GAAemB,EAAA,MAAM,QAAQ,GAAE,EAAA,KAAA,EAAA,IAAA,CAAA;EAEvCtB,GAAAA,MAAAA,CAAAA,IAAAA,EAAA,EAAA,GAAAC,EAwBMG,GAAA,MAAAC,EAvBWqB,EAAA,QAAR,OADT1B,EAAA,GAAAC,EAwBM,OAxBNK,EAwBM;GAtBH,KAAKgD,EAAK;GACX,OAAM;EACE,GAAA,EAAA,SAAA,GAAA,GAAAA,EAAK,OAAK,EACjB,OAAK;GAAA,KAAA,GAAYA,EAAK,IAAG;GAAA,QAAA,GAAiBA,EAAK,OAAM;EAAA,EAAA,CAAA,GAAA,CAItDpD,EAcS,UAAA;GAbP,MAAK;GACL,OAAM;GACL,2BAAyBoD,EAAK;GAC9B,gBAAcA,EAAK,UAAO,SAAY,KAAA;;GAEvC/C,EAKEC,GAAA;IAJC,MAAM8C,EAAK;IACX,OAAOhC,EAAA,MAAM;IACb,aAAaN,EAAA;IACb,OAAOA,EAAA;;;;;;;GAEVd,EAAgF,QAAhFW,GAAgFJ,EAAvB6C,EAAK,OAAI,CAAA,GAAA,CAAA;GAClE5C,EAA8DgD,EAAA,QAAA,QAAA;IAA3C,MAAMJ,EAAK;IAAO,SAASA,EAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"InkViewport.js","names":["_sfc_main","InkViewport_vue_vue_type_script_setup_true_lang_default","InkViewport_default"],"sources":["../../src/components/InkViewport.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The scroll element is handed to core's `mountViewer`, which builds the viewport, the page\n * layers, the tool controller and the keyboard shortcuts in it; Vue never renders children\n * into it. The engine reports each page host it mounts, and InkPage components rendered here\n * (they render nothing in place) teleport the page-error and custom-annotation slots into them.\n *\n * Two-way zoom and page: the viewport's own changes are reported through the context, and\n * the host's v-model values are applied only when they differ from the viewport's state, so\n * the echo of a reported value does nothing.\n *\n * Form fields render in the engine's form layer. A signature field's \"Sign\" opens\n * `InkSignFieldPopover`, and a form script's alert shows in `InkFormAlert`; both are mounted\n * here, so hosts compose nothing for them.\n */\nimport { mountViewer } from '@inkbar/core/dom'\nimport {\n computed,\n onBeforeUnmount,\n onBeforeUpdate,\n onMounted,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { toolIdsOf } from '../composables/useRegisteredTool'\nimport { injectInkContext } from '../context'\n\nimport InkFormAlert from './InkFormAlert.vue'\nimport InkPage from './InkPage.vue'\nimport InkSignFieldPopover from './InkSignFieldPopover.vue'\n\nimport type { AnnotationSlotProps } from './annotation-slot'\nimport type { InkDocument, InkError } from '@inkbar/core'\nimport type {\n LayoutMode,\n PageMount,\n SignFieldRequest,\n ToolId,\n ViewerEngine,\n ViewRotation,\n ZoomValue,\n} from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{\n mode?: LayoutMode\n rotation?: ViewRotation\n /** Gap between pages, CSS px. */\n gap?: number\n /** Pages kept mounted either side of the visible ones. */\n buffer?: number\n }>(),\n { mode: 'continuous', rotation: 0, gap: 16, buffer: 2 }\n)\n\nconst slots = defineSlots<{\n loading?(): unknown\n error?(props: { error: InkError }): unknown\n empty?(): unknown\n annotation?(props: AnnotationSlotProps): unknown\n /** Shown inside a page that failed to render. The rest of the document stays usable. */\n 'page-error'?(props: { error: InkError; page: number }): unknown\n}>()\n\nconst ctx = injectInkContext()\nconst scroll = useTemplateRef<HTMLElement>('scroll')\n\ninterface MountedPage {\n /** The engine build the host belongs to; part of the InkPage key. */\n build: number\n page: number\n host: HTMLElement\n mount: PageMount\n error: InkError | null\n /** Whether the build that mounted the page renders the annotation slot. */\n custom: boolean\n}\n/** A key per document, so the field menu and its dialog start afresh for each one. */\nconst documentKeys = new WeakMap<InkDocument, number>()\nlet documentKeyCount = 0\nfunction documentKey(doc: InkDocument | null): number {\n if (!doc) return 0\n let key = documentKeys.get(doc)\n if (key === undefined) {\n key = ++documentKeyCount\n documentKeys.set(doc, key)\n }\n return key\n}\n\n/** Page hosts, mounts and errors the engine reported; InkPage renders Teleports for them. */\nconst pages = shallowRef<MountedPage[]>([])\n\nconst state = computed(() => ctx.status.value.state)\nconst error = computed<InkError | null>(() =>\n ctx.status.value.state === 'error' ? ctx.status.value.error : null\n)\n\nconst engine = shallowRef<ViewerEngine | null>(null)\n/** The signature field whose menu is open. */\nconst signRequest = shallowRef<SignFieldRequest | null>(null)\n/** The form script's message on show, and how many have been shown. */\nconst alertMessage = shallowRef<string | null>(null)\nconst alertsShown = shallowRef(0)\n/**\n * Numbered before each build starts, so the pages a build mounts carry its own number. A\n * rebuild gives each page a new host and mount, so pages from an earlier build must remount,\n * not be reused.\n */\nlet build = 0\n/** Whether the current build renders the annotation slot. */\nlet custom = false\nlet stops: (() => void)[] = []\n/** The zoom and page last reported to the host. */\nlet lastReportedZoom: ZoomValue | undefined\nlet lastReportedPage: number | undefined\n\nfunction teardown(): void {\n for (const stop of stops) stop()\n stops = []\n // Unmounts every page, which empties `pages` through `onPageUnmount`.\n engine.value?.destroy()\n engine.value = null\n if (ctx.viewport.value) ctx.viewport.value = null\n if (ctx.tools.value) ctx.tools.value = null\n ctx.openedToolIds.value = null\n pages.value = []\n // Their fields and the document they came from are gone.\n signRequest.value = null\n alertMessage.value = null\n}\n\nfunction rebuild(opts: Parameters<ViewerEngine['rebuild']>[0]): void {\n const e = engine.value\n if (!e) return\n build += 1\n if (opts.customAnnotations !== undefined) custom = opts.customAnnotations\n e.rebuild(opts)\n}\n\n// Build for a new document or status; the previous engine is torn down first.\nfunction setup(): void {\n teardown()\n lastReportedZoom = undefined\n lastReportedPage = undefined\n const doc = ctx.document.value\n const el = scroll.value\n if (!doc || !el || ctx.status.value.state !== 'ready') return\n let first = true\n build += 1\n custom = !!slots.annotation\n // The tools this viewer registers, from the same inputs; a later `tools` waits for a rebuild.\n ctx.openedToolIds.value = toolIdsOf(ctx.hostTools.value, ctx.pluginHost.value)\n engine.value = mountViewer({\n container: el,\n document: doc,\n zoom: ctx.zoomModel.value ?? 'fit-width',\n ...(ctx.pageModel.value === undefined ? {} : { page: ctx.pageModel.value }),\n mode: props.mode,\n rotation: props.rotation,\n gap: props.gap,\n buffer: props.buffer,\n tool: ctx.tool.value,\n ...(ctx.hostTools.value ? { tools: ctx.hostTools.value } : {}),\n // The engine adds the plugins' tools and layers, and decorates through the host, which\n // reads `decorateAnnotation` first.\n ...(ctx.pluginHost.value ? { plugins: ctx.pluginHost.value } : {}),\n // The engine draws the search matches on the pages.\n ...(ctx.search.value ? { search: ctx.search.value } : {}),\n // Read through, so the watch below can re-apply a new function without a rebuild.\n decorateAnnotation: (a) => ctx.decorateAnnotation.value?.(a),\n ...(ctx.toolStyle.value ? { toolStyle: ctx.toolStyle.value } : {}),\n toolHistory: { batch: (fn) => ctx.history.batch(fn) },\n toolOptions: ctx.toolOptions,\n fonts: [...ctx.fonts.value],\n // Read through, so a new `signatures` store reaches the tool as well as the menus.\n signatureLibrary: () => ctx.signatures.value,\n customAnnotations: custom,\n ...(ctx.formHighlight.value === undefined\n ? {}\n : { formHighlight: ctx.formHighlight.value }),\n // The field's own button again, while its menu is open, closes the menu.\n onSignField: (req) => {\n signRequest.value = signRequest.value?.widget === req.widget ? null : req\n },\n onFormAction: (a) => ctx.reportFormAction(a),\n onFormAlert: (message) => {\n alertMessage.value = message\n alertsShown.value += 1\n },\n onActivate: (id) => ctx.setActivated(id),\n onBuild: (vp, tc) => {\n ctx.viewport.value = vp\n ctx.tools.value = tc\n if (first) {\n // A new document starts from where the viewport opens (its zoom, on the first page:\n // `createViewport` always starts at page 0); only later changes are reported, the\n // restored page among them, since the engine has already scrolled to it.\n first = false\n lastReportedZoom = vp.zoom.get()\n lastReportedPage = 0\n }\n for (const stop of stops) stop()\n const reportZoom = (z: ZoomValue): void => {\n if (z === lastReportedZoom) return\n lastReportedZoom = z\n ctx.reportZoom(z)\n }\n const reportPage = (p: number): void => {\n if (p === lastReportedPage) return\n lastReportedPage = p\n ctx.reportPage(p)\n }\n // A tool that switches itself (a one-shot tool once used) is reported as a pick.\n const followTool = (id: ToolId): void => {\n if (id !== ctx.tool.value) ctx.setTool(id)\n }\n stops = [\n vp.zoom.subscribe(reportZoom),\n vp.currentPage.subscribe(reportPage),\n tc.active.subscribe(followTool),\n ]\n // Whatever the build restored is reported once; nothing is when it matched.\n reportZoom(vp.zoom.get())\n reportPage(vp.currentPage.get())\n },\n onPageMount: (page, mount, host) => {\n pages.value = [...pages.value, { build, page, host, mount, error: null, custom }]\n },\n onPageUnmount: (page) => {\n pages.value = pages.value.filter((p) => p.page !== page)\n },\n onPageError: (page, err) => {\n pages.value = pages.value.map((p) => (p.page === page ? { ...p, error: err } : p))\n },\n })\n}\n\nonMounted(() => {\n ctx.viewportEl.value = scroll.value\n watch([() => ctx.document.value, () => ctx.status.value.state], setup, {\n immediate: true,\n })\n})\n\n// A new decorateAnnotation re-applies to the mounted annotation elements at once.\nwatch(\n () => ctx.decorateAnnotation.value,\n () => engine.value?.redecorate()\n)\n// The tint follows `formHighlight` in place, without a new document.\nwatch(\n () => ctx.formHighlight.value,\n (on) => engine.value?.setFormHighlight(on ?? true)\n)\nwatch(\n () => ctx.zoomModel.value,\n (z: ZoomValue | undefined) => {\n const vp = engine.value?.viewport\n if (vp && z !== undefined && z !== vp.zoom.get()) vp.setZoom(z)\n }\n)\nwatch(\n () => ctx.pageModel.value,\n (p) => {\n const vp = engine.value?.viewport\n if (!vp || p === undefined || p === lastReportedPage) return\n if (p !== vp.currentPage.get()) vp.scrollToPage(p)\n }\n)\nwatch(\n () => ctx.tool.value,\n (t) => {\n const tc = engine.value?.tools\n if (tc && tc.active.get() !== t) tc.set(t)\n }\n)\nwatch(\n () => props.mode,\n (m) => engine.value?.viewport.setMode(m)\n)\nwatch(\n () => props.rotation,\n (r) => engine.value?.viewport.setRotation(r)\n)\n// Gap and buffer are construction options: rebuild for the same document, keeping zoom and page.\n// The slots are already updated when this runs, so it carries the annotation slot too: a slot\n// toggle in the same tick is then recorded here and `onBeforeUpdate` finds nothing left to do.\nwatch([() => props.gap, () => props.buffer], ([gap, buffer]) =>\n rebuild({ gap, buffer, customAnnotations: !!slots.annotation })\n)\n\n// Slots are not reactive, so a change to whether the annotation slot is given is caught here.\n// `onBeforeUpdate` runs after the new slots are in place and before this render: the rebuild\n// swaps `pages` for the new build's pages synchronously, so the render that follows never pairs\n// the annotation slot with an overlay built without it (or the reverse). The rebuild keeps the\n// scroll position.\nonBeforeUpdate(() => {\n const next = !!slots.annotation\n if (engine.value && next !== custom) rebuild({ customAnnotations: next })\n})\n\nonBeforeUnmount(() => {\n teardown()\n if (ctx.viewportEl.value === scroll.value) ctx.viewportEl.value = null\n})\n</script>\n\n<template>\n <div class=\"ink-viewport-root\" data-ink-viewport-root :data-state=\"state\">\n <div v-if=\"state === 'loading'\" class=\"ink-status\" role=\"status\" aria-live=\"polite\">\n <slot name=\"loading\">Loading document…</slot>\n </div>\n <div v-else-if=\"error\" class=\"ink-status ink-error\" role=\"alert\">\n <slot name=\"error\" :error=\"error\">\n <p class=\"ink-error-title\">This document could not be opened.</p>\n <!-- The message comes from the PDF engine and is not written for readers: it stays\n off the page, on the code's tooltip. -->\n <p>\n <code class=\"ink-error-code\" :title=\"error.message\">{{ error.code }}</code>\n </p>\n </slot>\n </div>\n <div v-else-if=\"state === 'idle'\" class=\"ink-status ink-empty\">\n <slot name=\"empty\" />\n </div>\n <div\n ref=\"scroll\"\n class=\"ink-scroll\"\n data-ink-scroll\n tabindex=\"0\"\n role=\"document\"\n aria-label=\"Document\"\n />\n <InkPage\n v-for=\"p in pages\"\n :key=\"`${p.build}:${p.page}`\"\n :page=\"p.page\"\n :host=\"p.host\"\n :mount=\"p.mount\"\n :error=\"p.error\"\n :custom-annotations=\"p.custom\"\n >\n <template v-if=\"slots.annotation\" #annotation=\"slotProps\">\n <slot name=\"annotation\" v-bind=\"slotProps\" />\n </template>\n <template v-if=\"slots['page-error']\" #page-error=\"slotProps\">\n <slot name=\"page-error\" v-bind=\"slotProps\" />\n </template>\n </InkPage>\n <!-- Keyed by document, so the menu and its dialog start afresh for each one. -->\n <InkSignFieldPopover\n :key=\"documentKey(ctx.document.value)\"\n :request=\"signRequest\"\n @close=\"signRequest = null\"\n />\n <InkFormAlert\n :message=\"alertMessage\"\n :shown=\"alertsShown\"\n :fallback=\"scroll\"\n @close=\"alertMessage = null\"\n />\n </div>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"InkViewport.js","names":["_sfc_main","InkViewport_vue_vue_type_script_setup_true_lang_default","InkViewport_default"],"sources":["../../src/components/InkViewport.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The scroll element is handed to core's `mountViewer`, which builds the viewport, the page\n * layers, the tool controller and the keyboard shortcuts in it; Vue never renders children\n * into it. The engine reports each page host it mounts, and InkPage components rendered here\n * (they render nothing in place) teleport the page-error and custom-annotation slots into them.\n *\n * Two-way zoom and page: the viewport's own changes are reported through the context, and\n * the host's v-model values are applied only when they differ from the viewport's state, so\n * the echo of a reported value does nothing.\n *\n * Form fields render in the engine's form layer. A signature field's \"Sign\" opens\n * `InkSignFieldPopover`, and a form script's alert shows in `InkFormAlert`; both are mounted\n * here, so hosts compose nothing for them.\n */\nimport { mountViewer } from '@inkbar/core/dom'\nimport {\n computed,\n onBeforeUnmount,\n onBeforeUpdate,\n onMounted,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { toolIdsOf } from '../composables/useRegisteredTool'\nimport { injectInkContext } from '../context'\n\nimport InkFormAlert from './InkFormAlert.vue'\nimport InkPage from './InkPage.vue'\nimport InkSignFieldPopover from './InkSignFieldPopover.vue'\n\nimport type { AnnotationSlotProps } from './annotation-slot'\nimport type { InkDocument, InkError } from '@inkbar/core'\nimport type {\n LayoutMode,\n PageMount,\n SignFieldRequest,\n ToolId,\n ViewerEngine,\n ViewRotation,\n ZoomValue,\n} from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{\n mode?: LayoutMode\n rotation?: ViewRotation\n /** Gap between pages, CSS px. */\n gap?: number\n /** Pages kept mounted either side of the visible ones. */\n buffer?: number\n /** Pinch to zoom the pages. Off leaves the browser's own touch handling alone. */\n pinchZoom?: boolean\n }>(),\n { mode: 'continuous', rotation: 0, gap: 16, buffer: 2, pinchZoom: true }\n)\n\nconst slots = defineSlots<{\n loading?(): unknown\n error?(props: { error: InkError }): unknown\n empty?(): unknown\n annotation?(props: AnnotationSlotProps): unknown\n /** Shown inside a page that failed to render. The rest of the document stays usable. */\n 'page-error'?(props: { error: InkError; page: number }): unknown\n}>()\n\nconst ctx = injectInkContext()\nconst scroll = useTemplateRef<HTMLElement>('scroll')\n\ninterface MountedPage {\n /** The engine build the host belongs to; part of the InkPage key. */\n build: number\n page: number\n host: HTMLElement\n mount: PageMount\n error: InkError | null\n /** Whether the build that mounted the page renders the annotation slot. */\n custom: boolean\n}\n/** A key per document, so the field menu and its dialog start afresh for each one. */\nconst documentKeys = new WeakMap<InkDocument, number>()\nlet documentKeyCount = 0\nfunction documentKey(doc: InkDocument | null): number {\n if (!doc) return 0\n let key = documentKeys.get(doc)\n if (key === undefined) {\n key = ++documentKeyCount\n documentKeys.set(doc, key)\n }\n return key\n}\n\n/** Page hosts, mounts and errors the engine reported; InkPage renders Teleports for them. */\nconst pages = shallowRef<MountedPage[]>([])\n\nconst state = computed(() => ctx.status.value.state)\nconst error = computed<InkError | null>(() =>\n ctx.status.value.state === 'error' ? ctx.status.value.error : null\n)\n\nconst engine = shallowRef<ViewerEngine | null>(null)\n/** The signature field whose menu is open. */\nconst signRequest = shallowRef<SignFieldRequest | null>(null)\n/** The form script's message on show, and how many have been shown. */\nconst alertMessage = shallowRef<string | null>(null)\nconst alertsShown = shallowRef(0)\n/**\n * Numbered before each build starts, so the pages a build mounts carry its own number. A\n * rebuild gives each page a new host and mount, so pages from an earlier build must remount,\n * not be reused.\n */\nlet build = 0\n/** Whether the current build renders the annotation slot. */\nlet custom = false\nlet stops: (() => void)[] = []\n/** The zoom and page last reported to the host. */\nlet lastReportedZoom: ZoomValue | undefined\nlet lastReportedPage: number | undefined\n\nfunction teardown(): void {\n for (const stop of stops) stop()\n stops = []\n // Unmounts every page, which empties `pages` through `onPageUnmount`.\n engine.value?.destroy()\n engine.value = null\n if (ctx.viewport.value) ctx.viewport.value = null\n if (ctx.tools.value) ctx.tools.value = null\n ctx.openedToolIds.value = null\n pages.value = []\n // Their fields and the document they came from are gone.\n signRequest.value = null\n alertMessage.value = null\n}\n\nfunction rebuild(opts: Parameters<ViewerEngine['rebuild']>[0]): void {\n const e = engine.value\n if (!e) return\n build += 1\n if (opts.customAnnotations !== undefined) custom = opts.customAnnotations\n e.rebuild(opts)\n}\n\n// Build for a new document or status; the previous engine is torn down first.\nfunction setup(): void {\n teardown()\n lastReportedZoom = undefined\n lastReportedPage = undefined\n const doc = ctx.document.value\n const el = scroll.value\n if (!doc || !el || ctx.status.value.state !== 'ready') return\n let first = true\n build += 1\n custom = !!slots.annotation\n // The tools this viewer registers, from the same inputs; a later `tools` waits for a rebuild.\n ctx.openedToolIds.value = toolIdsOf(ctx.hostTools.value, ctx.pluginHost.value)\n engine.value = mountViewer({\n container: el,\n document: doc,\n zoom: ctx.zoomModel.value ?? 'fit-width',\n ...(ctx.pageModel.value === undefined ? {} : { page: ctx.pageModel.value }),\n mode: props.mode,\n rotation: props.rotation,\n gap: props.gap,\n buffer: props.buffer,\n pinchZoom: props.pinchZoom,\n tool: ctx.tool.value,\n ...(ctx.hostTools.value ? { tools: ctx.hostTools.value } : {}),\n // The engine adds the plugins' tools and layers, and decorates through the host, which\n // reads `decorateAnnotation` first.\n ...(ctx.pluginHost.value ? { plugins: ctx.pluginHost.value } : {}),\n // The engine draws the search matches on the pages.\n ...(ctx.search.value ? { search: ctx.search.value } : {}),\n // Read through, so the watch below can re-apply a new function without a rebuild.\n decorateAnnotation: (a) => ctx.decorateAnnotation.value?.(a),\n ...(ctx.toolStyle.value ? { toolStyle: ctx.toolStyle.value } : {}),\n toolHistory: { batch: (fn) => ctx.history.batch(fn) },\n toolOptions: ctx.toolOptions,\n fonts: [...ctx.fonts.value],\n // Read through, so a new `signatures` store reaches the tool as well as the menus.\n signatureLibrary: () => ctx.signatures.value,\n customAnnotations: custom,\n ...(ctx.formHighlight.value === undefined\n ? {}\n : { formHighlight: ctx.formHighlight.value }),\n // The field's own button again, while its menu is open, closes the menu.\n onSignField: (req) => {\n signRequest.value = signRequest.value?.widget === req.widget ? null : req\n },\n onFormAction: (a) => ctx.reportFormAction(a),\n onFormAlert: (message) => {\n alertMessage.value = message\n alertsShown.value += 1\n },\n onActivate: (id) => ctx.setActivated(id),\n onBuild: (vp, tc) => {\n ctx.viewport.value = vp\n ctx.tools.value = tc\n if (first) {\n // A new document starts from where the viewport opens (its zoom, on the first page:\n // `createViewport` always starts at page 0); only later changes are reported, the\n // restored page among them, since the engine has already scrolled to it.\n first = false\n lastReportedZoom = vp.zoom.get()\n lastReportedPage = 0\n }\n for (const stop of stops) stop()\n const reportZoom = (z: ZoomValue): void => {\n if (z === lastReportedZoom) return\n lastReportedZoom = z\n ctx.reportZoom(z)\n }\n const reportPage = (p: number): void => {\n if (p === lastReportedPage) return\n lastReportedPage = p\n ctx.reportPage(p)\n }\n // A tool that switches itself (a one-shot tool once used) is reported as a pick.\n const followTool = (id: ToolId): void => {\n if (id !== ctx.tool.value) ctx.setTool(id)\n }\n stops = [\n vp.zoom.subscribe(reportZoom),\n vp.currentPage.subscribe(reportPage),\n tc.active.subscribe(followTool),\n ]\n // Whatever the build restored is reported once; nothing is when it matched.\n reportZoom(vp.zoom.get())\n reportPage(vp.currentPage.get())\n },\n onPageMount: (page, mount, host) => {\n pages.value = [...pages.value, { build, page, host, mount, error: null, custom }]\n },\n onPageUnmount: (page) => {\n pages.value = pages.value.filter((p) => p.page !== page)\n },\n onPageError: (page, err) => {\n pages.value = pages.value.map((p) => (p.page === page ? { ...p, error: err } : p))\n },\n })\n}\n\nonMounted(() => {\n ctx.viewportEl.value = scroll.value\n watch([() => ctx.document.value, () => ctx.status.value.state], setup, {\n immediate: true,\n })\n})\n\n// A new decorateAnnotation re-applies to the mounted annotation elements at once.\nwatch(\n () => ctx.decorateAnnotation.value,\n () => engine.value?.redecorate()\n)\n// The tint follows `formHighlight` in place, without a new document.\nwatch(\n () => ctx.formHighlight.value,\n (on) => engine.value?.setFormHighlight(on ?? true)\n)\nwatch(\n () => ctx.zoomModel.value,\n (z: ZoomValue | undefined) => {\n const vp = engine.value?.viewport\n if (vp && z !== undefined && z !== vp.zoom.get()) vp.setZoom(z)\n }\n)\nwatch(\n () => ctx.pageModel.value,\n (p) => {\n const vp = engine.value?.viewport\n if (!vp || p === undefined || p === lastReportedPage) return\n if (p !== vp.currentPage.get()) vp.scrollToPage(p)\n }\n)\nwatch(\n () => ctx.tool.value,\n (t) => {\n const tc = engine.value?.tools\n if (tc && tc.active.get() !== t) tc.set(t)\n }\n)\nwatch(\n () => props.mode,\n (m) => engine.value?.viewport.setMode(m)\n)\nwatch(\n () => props.rotation,\n (r) => engine.value?.viewport.setRotation(r)\n)\n// Gap, buffer and pinch zoom are construction options: rebuild for the same document, keeping zoom and page.\n// The slots are already updated when this runs, so it carries the annotation slot too: a slot\n// toggle in the same tick is then recorded here and `onBeforeUpdate` finds nothing left to do.\nwatch(\n [() => props.gap, () => props.buffer, () => props.pinchZoom],\n ([gap, buffer, pinchZoom]) =>\n rebuild({ gap, buffer, pinchZoom, customAnnotations: !!slots.annotation })\n)\n\n// Slots are not reactive, so a change to whether the annotation slot is given is caught here.\n// `onBeforeUpdate` runs after the new slots are in place and before this render: the rebuild\n// swaps `pages` for the new build's pages synchronously, so the render that follows never pairs\n// the annotation slot with an overlay built without it (or the reverse). The rebuild keeps the\n// scroll position.\nonBeforeUpdate(() => {\n const next = !!slots.annotation\n if (engine.value && next !== custom) rebuild({ customAnnotations: next })\n})\n\nonBeforeUnmount(() => {\n teardown()\n if (ctx.viewportEl.value === scroll.value) ctx.viewportEl.value = null\n})\n</script>\n\n<template>\n <div class=\"ink-viewport-root\" data-ink-viewport-root :data-state=\"state\">\n <div v-if=\"state === 'loading'\" class=\"ink-status\" role=\"status\" aria-live=\"polite\">\n <slot name=\"loading\">Loading document…</slot>\n </div>\n <div v-else-if=\"error\" class=\"ink-status ink-error\" role=\"alert\">\n <slot name=\"error\" :error=\"error\">\n <p class=\"ink-error-title\">This document could not be opened.</p>\n <!-- The message comes from the PDF engine and is not written for readers: it stays\n off the page, on the code's tooltip. -->\n <p>\n <code class=\"ink-error-code\" :title=\"error.message\">{{ error.code }}</code>\n </p>\n </slot>\n </div>\n <div v-else-if=\"state === 'idle'\" class=\"ink-status ink-empty\">\n <slot name=\"empty\" />\n </div>\n <div\n ref=\"scroll\"\n class=\"ink-scroll\"\n data-ink-scroll\n tabindex=\"0\"\n role=\"document\"\n aria-label=\"Document\"\n />\n <InkPage\n v-for=\"p in pages\"\n :key=\"`${p.build}:${p.page}`\"\n :page=\"p.page\"\n :host=\"p.host\"\n :mount=\"p.mount\"\n :error=\"p.error\"\n :custom-annotations=\"p.custom\"\n >\n <template v-if=\"slots.annotation\" #annotation=\"slotProps\">\n <slot name=\"annotation\" v-bind=\"slotProps\" />\n </template>\n <template v-if=\"slots['page-error']\" #page-error=\"slotProps\">\n <slot name=\"page-error\" v-bind=\"slotProps\" />\n </template>\n </InkPage>\n <!-- Keyed by document, so the menu and its dialog start afresh for each one. -->\n <InkSignFieldPopover\n :key=\"documentKey(ctx.document.value)\"\n :request=\"signRequest\"\n @close=\"signRequest = null\"\n />\n <InkFormAlert\n :message=\"alertMessage\"\n :shown=\"alertsShown\"\n :fallback=\"scroll\"\n @close=\"alertMessage = null\"\n />\n </div>\n</template>\n"],"mappings":""}
@@ -8,6 +8,8 @@ type __VLS_Props = {
8
8
  gap?: number;
9
9
  /** Pages kept mounted either side of the visible ones. */
10
10
  buffer?: number;
11
+ /** Pinch to zoom the pages. Off leaves the browser's own touch handling alone. */
12
+ pinchZoom?: boolean;
11
13
  };
12
14
  type __VLS_Slots = {
13
15
  loading?(): unknown;
@@ -27,6 +29,7 @@ declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {},
27
29
  mode: LayoutMode;
28
30
  gap: number;
29
31
  buffer: number;
32
+ pinchZoom: boolean;
30
33
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
31
34
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
32
35
  declare const _default: typeof __VLS_export;
@@ -1 +1 @@
1
- {"version":3,"file":"InkViewport.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkViewport.vue"],"names":[],"mappings":"AAgZA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,KAAK,EACV,UAAU,EAKV,YAAY,EAEb,MAAM,kBAAkB,CAAA;AAGzB,KAAK,WAAW,GAAG;IACf,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,iCAAiC;IACjC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAC;AAMJ,KAAK,WAAW,GAAG;IACjB,OAAO,CAAC,IAAI,OAAO,CAAA;IACnB,KAAK,CAAC,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAA;IAC3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AO,CAAA;IACjB,UAAU,CAAC,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAA;IAChD,wFAAwF;IACxF,YAAY,CAAC,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,QAAQ,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAA;CACjE,CAAC;AA2aF,QAAA,MAAM,UAAU;;;;;;6EAGd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -24,7 +24,11 @@ var O = ["data-state"], k = {
24
24
  mode: { default: "continuous" },
25
25
  rotation: { default: 0 },
26
26
  gap: { default: 16 },
27
- buffer: { default: 2 }
27
+ buffer: { default: 2 },
28
+ pinchZoom: {
29
+ type: Boolean,
30
+ default: !0
31
+ }
28
32
  },
29
33
  setup(p) {
30
34
  let N = p, P = w(), F = e(), I = te("scroll"), L = /* @__PURE__ */ new WeakMap(), R = 0;
@@ -56,6 +60,7 @@ var O = ["data-state"], k = {
56
60
  rotation: N.rotation,
57
61
  gap: N.gap,
58
62
  buffer: N.buffer,
63
+ pinchZoom: N.pinchZoom,
59
64
  tool: F.tool.value,
60
65
  ...F.hostTools.value ? { tools: F.hostTools.value } : {},
61
66
  ...F.pluginHost.value ? { plugins: F.pluginHost.value } : {},
@@ -124,9 +129,14 @@ var O = ["data-state"], k = {
124
129
  }), T(() => F.tool.value, (e) => {
125
130
  let t = U.value?.tools;
126
131
  t && t.active.get() !== e && t.set(e);
127
- }), T(() => N.mode, (e) => U.value?.viewport.setMode(e)), T(() => N.rotation, (e) => U.value?.viewport.setRotation(e)), T([() => N.gap, () => N.buffer], ([e, t]) => $({
132
+ }), T(() => N.mode, (e) => U.value?.viewport.setMode(e)), T(() => N.rotation, (e) => U.value?.viewport.setRotation(e)), T([
133
+ () => N.gap,
134
+ () => N.buffer,
135
+ () => N.pinchZoom
136
+ ], ([e, t, n]) => $({
128
137
  gap: e,
129
138
  buffer: t,
139
+ pinchZoom: n,
130
140
  customAnnotations: !!P.annotation
131
141
  })), g(() => {
132
142
  let e = !!P.annotation;
@@ -1 +1 @@
1
- {"version":3,"file":"InkViewport.vue_vue_type_script_setup_true_lang.js","names":["_useSlots","_openBlock","_createElementBlock","_renderSlot","_createTextVNode","_createElementVNode","_toDisplayString","_createCommentVNode","_Fragment","_renderList","_createBlock","InkPage","_createSlots","_withCtx","_mergeProps","InkSignFieldPopover","_unref","_createVNode","InkFormAlert","InkFormAlert_default","InkPage_default","InkSignFieldPopover_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","InkViewport_vue_vue_type_script_setup_true_lang_default","props","__props","slots","useSlots","ctx","injectInkContext","scroll","useTemplateRef","documentKeys","documentKeyCount","documentKey","doc","key","pages","shallowRef","state","computed","error","engine","signRequest","alertMessage","alertsShown","build","custom","stops","lastReportedZoom","lastReportedPage","teardown","stop","rebuild","e","opts","setup","el","first","toolIdsOf","mountViewer","a","fn","req","message","id","vp","tc","reportZoom","z","reportPage","p","page","err","onMounted","watch","on","t","m","r","gap","buffer","onBeforeUpdate","next","onBeforeUnmount","openBlock","createElementBlock","renderSlot","_ctx","_cache","createTextVNode","createElementVNode","toDisplayString","createCommentVNode","Fragment","renderList","createBlock","createSlots","withCtx","mergeProps","slotProps","unref","createVNode"],"sources":["../../src/components/InkViewport.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The scroll element is handed to core's `mountViewer`, which builds the viewport, the page\n * layers, the tool controller and the keyboard shortcuts in it; Vue never renders children\n * into it. The engine reports each page host it mounts, and InkPage components rendered here\n * (they render nothing in place) teleport the page-error and custom-annotation slots into them.\n *\n * Two-way zoom and page: the viewport's own changes are reported through the context, and\n * the host's v-model values are applied only when they differ from the viewport's state, so\n * the echo of a reported value does nothing.\n *\n * Form fields render in the engine's form layer. A signature field's \"Sign\" opens\n * `InkSignFieldPopover`, and a form script's alert shows in `InkFormAlert`; both are mounted\n * here, so hosts compose nothing for them.\n */\nimport { mountViewer } from '@inkbar/core/dom'\nimport {\n computed,\n onBeforeUnmount,\n onBeforeUpdate,\n onMounted,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { toolIdsOf } from '../composables/useRegisteredTool'\nimport { injectInkContext } from '../context'\n\nimport InkFormAlert from './InkFormAlert.vue'\nimport InkPage from './InkPage.vue'\nimport InkSignFieldPopover from './InkSignFieldPopover.vue'\n\nimport type { AnnotationSlotProps } from './annotation-slot'\nimport type { InkDocument, InkError } from '@inkbar/core'\nimport type {\n LayoutMode,\n PageMount,\n SignFieldRequest,\n ToolId,\n ViewerEngine,\n ViewRotation,\n ZoomValue,\n} from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{\n mode?: LayoutMode\n rotation?: ViewRotation\n /** Gap between pages, CSS px. */\n gap?: number\n /** Pages kept mounted either side of the visible ones. */\n buffer?: number\n }>(),\n { mode: 'continuous', rotation: 0, gap: 16, buffer: 2 }\n)\n\nconst slots = defineSlots<{\n loading?(): unknown\n error?(props: { error: InkError }): unknown\n empty?(): unknown\n annotation?(props: AnnotationSlotProps): unknown\n /** Shown inside a page that failed to render. The rest of the document stays usable. */\n 'page-error'?(props: { error: InkError; page: number }): unknown\n}>()\n\nconst ctx = injectInkContext()\nconst scroll = useTemplateRef<HTMLElement>('scroll')\n\ninterface MountedPage {\n /** The engine build the host belongs to; part of the InkPage key. */\n build: number\n page: number\n host: HTMLElement\n mount: PageMount\n error: InkError | null\n /** Whether the build that mounted the page renders the annotation slot. */\n custom: boolean\n}\n/** A key per document, so the field menu and its dialog start afresh for each one. */\nconst documentKeys = new WeakMap<InkDocument, number>()\nlet documentKeyCount = 0\nfunction documentKey(doc: InkDocument | null): number {\n if (!doc) return 0\n let key = documentKeys.get(doc)\n if (key === undefined) {\n key = ++documentKeyCount\n documentKeys.set(doc, key)\n }\n return key\n}\n\n/** Page hosts, mounts and errors the engine reported; InkPage renders Teleports for them. */\nconst pages = shallowRef<MountedPage[]>([])\n\nconst state = computed(() => ctx.status.value.state)\nconst error = computed<InkError | null>(() =>\n ctx.status.value.state === 'error' ? ctx.status.value.error : null\n)\n\nconst engine = shallowRef<ViewerEngine | null>(null)\n/** The signature field whose menu is open. */\nconst signRequest = shallowRef<SignFieldRequest | null>(null)\n/** The form script's message on show, and how many have been shown. */\nconst alertMessage = shallowRef<string | null>(null)\nconst alertsShown = shallowRef(0)\n/**\n * Numbered before each build starts, so the pages a build mounts carry its own number. A\n * rebuild gives each page a new host and mount, so pages from an earlier build must remount,\n * not be reused.\n */\nlet build = 0\n/** Whether the current build renders the annotation slot. */\nlet custom = false\nlet stops: (() => void)[] = []\n/** The zoom and page last reported to the host. */\nlet lastReportedZoom: ZoomValue | undefined\nlet lastReportedPage: number | undefined\n\nfunction teardown(): void {\n for (const stop of stops) stop()\n stops = []\n // Unmounts every page, which empties `pages` through `onPageUnmount`.\n engine.value?.destroy()\n engine.value = null\n if (ctx.viewport.value) ctx.viewport.value = null\n if (ctx.tools.value) ctx.tools.value = null\n ctx.openedToolIds.value = null\n pages.value = []\n // Their fields and the document they came from are gone.\n signRequest.value = null\n alertMessage.value = null\n}\n\nfunction rebuild(opts: Parameters<ViewerEngine['rebuild']>[0]): void {\n const e = engine.value\n if (!e) return\n build += 1\n if (opts.customAnnotations !== undefined) custom = opts.customAnnotations\n e.rebuild(opts)\n}\n\n// Build for a new document or status; the previous engine is torn down first.\nfunction setup(): void {\n teardown()\n lastReportedZoom = undefined\n lastReportedPage = undefined\n const doc = ctx.document.value\n const el = scroll.value\n if (!doc || !el || ctx.status.value.state !== 'ready') return\n let first = true\n build += 1\n custom = !!slots.annotation\n // The tools this viewer registers, from the same inputs; a later `tools` waits for a rebuild.\n ctx.openedToolIds.value = toolIdsOf(ctx.hostTools.value, ctx.pluginHost.value)\n engine.value = mountViewer({\n container: el,\n document: doc,\n zoom: ctx.zoomModel.value ?? 'fit-width',\n ...(ctx.pageModel.value === undefined ? {} : { page: ctx.pageModel.value }),\n mode: props.mode,\n rotation: props.rotation,\n gap: props.gap,\n buffer: props.buffer,\n tool: ctx.tool.value,\n ...(ctx.hostTools.value ? { tools: ctx.hostTools.value } : {}),\n // The engine adds the plugins' tools and layers, and decorates through the host, which\n // reads `decorateAnnotation` first.\n ...(ctx.pluginHost.value ? { plugins: ctx.pluginHost.value } : {}),\n // The engine draws the search matches on the pages.\n ...(ctx.search.value ? { search: ctx.search.value } : {}),\n // Read through, so the watch below can re-apply a new function without a rebuild.\n decorateAnnotation: (a) => ctx.decorateAnnotation.value?.(a),\n ...(ctx.toolStyle.value ? { toolStyle: ctx.toolStyle.value } : {}),\n toolHistory: { batch: (fn) => ctx.history.batch(fn) },\n toolOptions: ctx.toolOptions,\n fonts: [...ctx.fonts.value],\n // Read through, so a new `signatures` store reaches the tool as well as the menus.\n signatureLibrary: () => ctx.signatures.value,\n customAnnotations: custom,\n ...(ctx.formHighlight.value === undefined\n ? {}\n : { formHighlight: ctx.formHighlight.value }),\n // The field's own button again, while its menu is open, closes the menu.\n onSignField: (req) => {\n signRequest.value = signRequest.value?.widget === req.widget ? null : req\n },\n onFormAction: (a) => ctx.reportFormAction(a),\n onFormAlert: (message) => {\n alertMessage.value = message\n alertsShown.value += 1\n },\n onActivate: (id) => ctx.setActivated(id),\n onBuild: (vp, tc) => {\n ctx.viewport.value = vp\n ctx.tools.value = tc\n if (first) {\n // A new document starts from where the viewport opens (its zoom, on the first page:\n // `createViewport` always starts at page 0); only later changes are reported, the\n // restored page among them, since the engine has already scrolled to it.\n first = false\n lastReportedZoom = vp.zoom.get()\n lastReportedPage = 0\n }\n for (const stop of stops) stop()\n const reportZoom = (z: ZoomValue): void => {\n if (z === lastReportedZoom) return\n lastReportedZoom = z\n ctx.reportZoom(z)\n }\n const reportPage = (p: number): void => {\n if (p === lastReportedPage) return\n lastReportedPage = p\n ctx.reportPage(p)\n }\n // A tool that switches itself (a one-shot tool once used) is reported as a pick.\n const followTool = (id: ToolId): void => {\n if (id !== ctx.tool.value) ctx.setTool(id)\n }\n stops = [\n vp.zoom.subscribe(reportZoom),\n vp.currentPage.subscribe(reportPage),\n tc.active.subscribe(followTool),\n ]\n // Whatever the build restored is reported once; nothing is when it matched.\n reportZoom(vp.zoom.get())\n reportPage(vp.currentPage.get())\n },\n onPageMount: (page, mount, host) => {\n pages.value = [...pages.value, { build, page, host, mount, error: null, custom }]\n },\n onPageUnmount: (page) => {\n pages.value = pages.value.filter((p) => p.page !== page)\n },\n onPageError: (page, err) => {\n pages.value = pages.value.map((p) => (p.page === page ? { ...p, error: err } : p))\n },\n })\n}\n\nonMounted(() => {\n ctx.viewportEl.value = scroll.value\n watch([() => ctx.document.value, () => ctx.status.value.state], setup, {\n immediate: true,\n })\n})\n\n// A new decorateAnnotation re-applies to the mounted annotation elements at once.\nwatch(\n () => ctx.decorateAnnotation.value,\n () => engine.value?.redecorate()\n)\n// The tint follows `formHighlight` in place, without a new document.\nwatch(\n () => ctx.formHighlight.value,\n (on) => engine.value?.setFormHighlight(on ?? true)\n)\nwatch(\n () => ctx.zoomModel.value,\n (z: ZoomValue | undefined) => {\n const vp = engine.value?.viewport\n if (vp && z !== undefined && z !== vp.zoom.get()) vp.setZoom(z)\n }\n)\nwatch(\n () => ctx.pageModel.value,\n (p) => {\n const vp = engine.value?.viewport\n if (!vp || p === undefined || p === lastReportedPage) return\n if (p !== vp.currentPage.get()) vp.scrollToPage(p)\n }\n)\nwatch(\n () => ctx.tool.value,\n (t) => {\n const tc = engine.value?.tools\n if (tc && tc.active.get() !== t) tc.set(t)\n }\n)\nwatch(\n () => props.mode,\n (m) => engine.value?.viewport.setMode(m)\n)\nwatch(\n () => props.rotation,\n (r) => engine.value?.viewport.setRotation(r)\n)\n// Gap and buffer are construction options: rebuild for the same document, keeping zoom and page.\n// The slots are already updated when this runs, so it carries the annotation slot too: a slot\n// toggle in the same tick is then recorded here and `onBeforeUpdate` finds nothing left to do.\nwatch([() => props.gap, () => props.buffer], ([gap, buffer]) =>\n rebuild({ gap, buffer, customAnnotations: !!slots.annotation })\n)\n\n// Slots are not reactive, so a change to whether the annotation slot is given is caught here.\n// `onBeforeUpdate` runs after the new slots are in place and before this render: the rebuild\n// swaps `pages` for the new build's pages synchronously, so the render that follows never pairs\n// the annotation slot with an overlay built without it (or the reverse). The rebuild keeps the\n// scroll position.\nonBeforeUpdate(() => {\n const next = !!slots.annotation\n if (engine.value && next !== custom) rebuild({ customAnnotations: next })\n})\n\nonBeforeUnmount(() => {\n teardown()\n if (ctx.viewportEl.value === scroll.value) ctx.viewportEl.value = null\n})\n</script>\n\n<template>\n <div class=\"ink-viewport-root\" data-ink-viewport-root :data-state=\"state\">\n <div v-if=\"state === 'loading'\" class=\"ink-status\" role=\"status\" aria-live=\"polite\">\n <slot name=\"loading\">Loading document…</slot>\n </div>\n <div v-else-if=\"error\" class=\"ink-status ink-error\" role=\"alert\">\n <slot name=\"error\" :error=\"error\">\n <p class=\"ink-error-title\">This document could not be opened.</p>\n <!-- The message comes from the PDF engine and is not written for readers: it stays\n off the page, on the code's tooltip. -->\n <p>\n <code class=\"ink-error-code\" :title=\"error.message\">{{ error.code }}</code>\n </p>\n </slot>\n </div>\n <div v-else-if=\"state === 'idle'\" class=\"ink-status ink-empty\">\n <slot name=\"empty\" />\n </div>\n <div\n ref=\"scroll\"\n class=\"ink-scroll\"\n data-ink-scroll\n tabindex=\"0\"\n role=\"document\"\n aria-label=\"Document\"\n />\n <InkPage\n v-for=\"p in pages\"\n :key=\"`${p.build}:${p.page}`\"\n :page=\"p.page\"\n :host=\"p.host\"\n :mount=\"p.mount\"\n :error=\"p.error\"\n :custom-annotations=\"p.custom\"\n >\n <template v-if=\"slots.annotation\" #annotation=\"slotProps\">\n <slot name=\"annotation\" v-bind=\"slotProps\" />\n </template>\n <template v-if=\"slots['page-error']\" #page-error=\"slotProps\">\n <slot name=\"page-error\" v-bind=\"slotProps\" />\n </template>\n </InkPage>\n <!-- Keyed by document, so the menu and its dialog start afresh for each one. -->\n <InkSignFieldPopover\n :key=\"documentKey(ctx.document.value)\"\n :request=\"signRequest\"\n @close=\"signRequest = null\"\n />\n <InkFormAlert\n :message=\"alertMessage\"\n :shown=\"alertsShown\"\n :fallback=\"scroll\"\n @close=\"alertMessage = null\"\n />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6CA,IAAM4B,IAAQC,GAYRC,IAAQ9B,EAAA,GASRgC,IAAMC,EAAiB,GACvBC,IAASC,GAA4B,QAAQ,GAa7CC,oBAAe,IAAI,QAA6B,GAClDC,IAAmB;EACvB,SAASC,EAAY,GAAiC;GACpD,IAAI,CAACC,GAAK,OAAO;GACjB,IAAIC,IAAMJ,EAAa,IAAIG,CAAG;GAK9B,OAJIC,MAAQ,KAAA,MACV,IAAM,EAAEH,GACRD,EAAa,IAAIG,GAAKC,CAAG,IAEpBA;EACT;EAGA,IAAMC,IAAQC,EAA0B,CAAC,CAAC,GAEpCC,IAAQC,QAAeZ,EAAI,OAAO,MAAM,KAAK,GAC7Ca,IAAQD,QACZZ,EAAI,OAAO,MAAM,UAAU,UAAUA,EAAI,OAAO,MAAM,QAAQ,IAChE,GAEMc,IAASJ,EAAgC,IAAI,GAE7CK,IAAcL,EAAoC,IAAI,GAEtDM,IAAeN,EAA0B,IAAI,GAC7CO,IAAcP,EAAW,CAAC,GAM5BQ,IAAQ,GAERC,IAAS,IACTC,IAAwB,CAAC,GAEzBC,GACAC;EAEJ,SAASC,IAAiB;GACxB,KAAK,IAAMC,KAAQJ,GAAO,EAAK;GAW/B,AAVA,IAAQ,CAAC,GAETN,EAAO,OAAO,QAAQ,GACtB,EAAO,QAAQ,MACXd,EAAI,SAAS,UAAO,EAAI,SAAS,QAAQ,OACzCA,EA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AA,OAAA,CAAA,CAAA,KAAAK,GAAA,IAAA,EAAA;GAEvB5F,EAOE,OAAA;IANI,SAAA;IAAJ,KAAI6B;IACJ,OAAM;IACN,mBAAA;IACA,UAAS;IACT,MAAK;IACL,cAAW;;IAEbjC,EAAA,EAAA,GAAAC,EAeUM,GAAA,MAAAC,EAdIgC,EAAA,QAAL,OADTxC,EAAA,GAAAS,EAeUC,GAAA;IAbP,KAAG,GAAKgE,EAAE,MAAK,GAAIA,EAAE;IACrB,MAAMA,EAAE;IACR,MAAMA,EAAE;IACR,OAAOA,EAAE;IACT,OAAOA,EAAE;IACT,sBAAoBA,EAAE;GAEP,GAAA0B,EAAA,EAAA,GAAA,EAAA,GAAA,CAAAvE,EAAM,aAAA;IAAa,MAAA;IACjC,IAAAjB,GAD6C,MAAS,CACtDV,EAA6CyF,EAAA,QAAA,cAA7C9E,EAA6C,EAAA,SAAA,GAAA,GAAb0F,CAAS,CAAA,CAAA,CAAA;;GAE3B,IAAA,KAAA,GAAA1E,EAAK,gBAAA;IAAiB,MAAA;IACpC,IAAAjB,GADgD,MAAS,CACzDV,EAA6CyF,EAAA,QAAA,cAA7C9E,EAA6C,EAAA,SAAA,GAAA,GAAb0F,CAAS,CAAA,CAAA,CAAA;;;;;;;;;IAI7CvG,EAAA,GAAAS,EAIEK,GAAA;IAHC,KAAKuB,EAAYtB,EAAAgB,CAAA,CAAG,CAAC,SAAS,KAAK;IACnC,SAASe,EAAA;IACT,SAAK,AAAA8C,EAAA,QAAA,MAAE,EAAA,QAAW;;GAErB5E,EAKEC,GAAA;IAJC,SAAS8B,EAAA;IACT,OAAOC,EAAA;IACP,UAAUf,EAAA;IACV,SAAK,AAAA2D,EAAA,QAAA,MAAE,EAAA,QAAY"}
1
+ {"version":3,"file":"InkViewport.vue_vue_type_script_setup_true_lang.js","names":["_useSlots","_openBlock","_createElementBlock","_renderSlot","_createTextVNode","_createElementVNode","_toDisplayString","_createCommentVNode","_Fragment","_renderList","_createBlock","InkPage","_createSlots","_withCtx","_mergeProps","InkSignFieldPopover","_unref","_createVNode","InkFormAlert","InkFormAlert_default","InkPage_default","InkSignFieldPopover_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","InkViewport_vue_vue_type_script_setup_true_lang_default","props","__props","slots","useSlots","ctx","injectInkContext","scroll","useTemplateRef","documentKeys","documentKeyCount","documentKey","doc","key","pages","shallowRef","state","computed","error","engine","signRequest","alertMessage","alertsShown","build","custom","stops","lastReportedZoom","lastReportedPage","teardown","stop","rebuild","e","opts","setup","el","first","toolIdsOf","mountViewer","a","fn","req","message","id","vp","tc","reportZoom","z","reportPage","p","page","err","onMounted","watch","on","t","m","r","gap","buffer","pinchZoom","onBeforeUpdate","next","onBeforeUnmount","openBlock","createElementBlock","renderSlot","_ctx","_cache","createTextVNode","createElementVNode","toDisplayString","createCommentVNode","Fragment","renderList","createBlock","createSlots","withCtx","mergeProps","slotProps","unref","createVNode"],"sources":["../../src/components/InkViewport.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The scroll element is handed to core's `mountViewer`, which builds the viewport, the page\n * layers, the tool controller and the keyboard shortcuts in it; Vue never renders children\n * into it. The engine reports each page host it mounts, and InkPage components rendered here\n * (they render nothing in place) teleport the page-error and custom-annotation slots into them.\n *\n * Two-way zoom and page: the viewport's own changes are reported through the context, and\n * the host's v-model values are applied only when they differ from the viewport's state, so\n * the echo of a reported value does nothing.\n *\n * Form fields render in the engine's form layer. A signature field's \"Sign\" opens\n * `InkSignFieldPopover`, and a form script's alert shows in `InkFormAlert`; both are mounted\n * here, so hosts compose nothing for them.\n */\nimport { mountViewer } from '@inkbar/core/dom'\nimport {\n computed,\n onBeforeUnmount,\n onBeforeUpdate,\n onMounted,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { toolIdsOf } from '../composables/useRegisteredTool'\nimport { injectInkContext } from '../context'\n\nimport InkFormAlert from './InkFormAlert.vue'\nimport InkPage from './InkPage.vue'\nimport InkSignFieldPopover from './InkSignFieldPopover.vue'\n\nimport type { AnnotationSlotProps } from './annotation-slot'\nimport type { InkDocument, InkError } from '@inkbar/core'\nimport type {\n LayoutMode,\n PageMount,\n SignFieldRequest,\n ToolId,\n ViewerEngine,\n ViewRotation,\n ZoomValue,\n} from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{\n mode?: LayoutMode\n rotation?: ViewRotation\n /** Gap between pages, CSS px. */\n gap?: number\n /** Pages kept mounted either side of the visible ones. */\n buffer?: number\n /** Pinch to zoom the pages. Off leaves the browser's own touch handling alone. */\n pinchZoom?: boolean\n }>(),\n { mode: 'continuous', rotation: 0, gap: 16, buffer: 2, pinchZoom: true }\n)\n\nconst slots = defineSlots<{\n loading?(): unknown\n error?(props: { error: InkError }): unknown\n empty?(): unknown\n annotation?(props: AnnotationSlotProps): unknown\n /** Shown inside a page that failed to render. The rest of the document stays usable. */\n 'page-error'?(props: { error: InkError; page: number }): unknown\n}>()\n\nconst ctx = injectInkContext()\nconst scroll = useTemplateRef<HTMLElement>('scroll')\n\ninterface MountedPage {\n /** The engine build the host belongs to; part of the InkPage key. */\n build: number\n page: number\n host: HTMLElement\n mount: PageMount\n error: InkError | null\n /** Whether the build that mounted the page renders the annotation slot. */\n custom: boolean\n}\n/** A key per document, so the field menu and its dialog start afresh for each one. */\nconst documentKeys = new WeakMap<InkDocument, number>()\nlet documentKeyCount = 0\nfunction documentKey(doc: InkDocument | null): number {\n if (!doc) return 0\n let key = documentKeys.get(doc)\n if (key === undefined) {\n key = ++documentKeyCount\n documentKeys.set(doc, key)\n }\n return key\n}\n\n/** Page hosts, mounts and errors the engine reported; InkPage renders Teleports for them. */\nconst pages = shallowRef<MountedPage[]>([])\n\nconst state = computed(() => ctx.status.value.state)\nconst error = computed<InkError | null>(() =>\n ctx.status.value.state === 'error' ? ctx.status.value.error : null\n)\n\nconst engine = shallowRef<ViewerEngine | null>(null)\n/** The signature field whose menu is open. */\nconst signRequest = shallowRef<SignFieldRequest | null>(null)\n/** The form script's message on show, and how many have been shown. */\nconst alertMessage = shallowRef<string | null>(null)\nconst alertsShown = shallowRef(0)\n/**\n * Numbered before each build starts, so the pages a build mounts carry its own number. A\n * rebuild gives each page a new host and mount, so pages from an earlier build must remount,\n * not be reused.\n */\nlet build = 0\n/** Whether the current build renders the annotation slot. */\nlet custom = false\nlet stops: (() => void)[] = []\n/** The zoom and page last reported to the host. */\nlet lastReportedZoom: ZoomValue | undefined\nlet lastReportedPage: number | undefined\n\nfunction teardown(): void {\n for (const stop of stops) stop()\n stops = []\n // Unmounts every page, which empties `pages` through `onPageUnmount`.\n engine.value?.destroy()\n engine.value = null\n if (ctx.viewport.value) ctx.viewport.value = null\n if (ctx.tools.value) ctx.tools.value = null\n ctx.openedToolIds.value = null\n pages.value = []\n // Their fields and the document they came from are gone.\n signRequest.value = null\n alertMessage.value = null\n}\n\nfunction rebuild(opts: Parameters<ViewerEngine['rebuild']>[0]): void {\n const e = engine.value\n if (!e) return\n build += 1\n if (opts.customAnnotations !== undefined) custom = opts.customAnnotations\n e.rebuild(opts)\n}\n\n// Build for a new document or status; the previous engine is torn down first.\nfunction setup(): void {\n teardown()\n lastReportedZoom = undefined\n lastReportedPage = undefined\n const doc = ctx.document.value\n const el = scroll.value\n if (!doc || !el || ctx.status.value.state !== 'ready') return\n let first = true\n build += 1\n custom = !!slots.annotation\n // The tools this viewer registers, from the same inputs; a later `tools` waits for a rebuild.\n ctx.openedToolIds.value = toolIdsOf(ctx.hostTools.value, ctx.pluginHost.value)\n engine.value = mountViewer({\n container: el,\n document: doc,\n zoom: ctx.zoomModel.value ?? 'fit-width',\n ...(ctx.pageModel.value === undefined ? {} : { page: ctx.pageModel.value }),\n mode: props.mode,\n rotation: props.rotation,\n gap: props.gap,\n buffer: props.buffer,\n pinchZoom: props.pinchZoom,\n tool: ctx.tool.value,\n ...(ctx.hostTools.value ? { tools: ctx.hostTools.value } : {}),\n // The engine adds the plugins' tools and layers, and decorates through the host, which\n // reads `decorateAnnotation` first.\n ...(ctx.pluginHost.value ? { plugins: ctx.pluginHost.value } : {}),\n // The engine draws the search matches on the pages.\n ...(ctx.search.value ? { search: ctx.search.value } : {}),\n // Read through, so the watch below can re-apply a new function without a rebuild.\n decorateAnnotation: (a) => ctx.decorateAnnotation.value?.(a),\n ...(ctx.toolStyle.value ? { toolStyle: ctx.toolStyle.value } : {}),\n toolHistory: { batch: (fn) => ctx.history.batch(fn) },\n toolOptions: ctx.toolOptions,\n fonts: [...ctx.fonts.value],\n // Read through, so a new `signatures` store reaches the tool as well as the menus.\n signatureLibrary: () => ctx.signatures.value,\n customAnnotations: custom,\n ...(ctx.formHighlight.value === undefined\n ? {}\n : { formHighlight: ctx.formHighlight.value }),\n // The field's own button again, while its menu is open, closes the menu.\n onSignField: (req) => {\n signRequest.value = signRequest.value?.widget === req.widget ? null : req\n },\n onFormAction: (a) => ctx.reportFormAction(a),\n onFormAlert: (message) => {\n alertMessage.value = message\n alertsShown.value += 1\n },\n onActivate: (id) => ctx.setActivated(id),\n onBuild: (vp, tc) => {\n ctx.viewport.value = vp\n ctx.tools.value = tc\n if (first) {\n // A new document starts from where the viewport opens (its zoom, on the first page:\n // `createViewport` always starts at page 0); only later changes are reported, the\n // restored page among them, since the engine has already scrolled to it.\n first = false\n lastReportedZoom = vp.zoom.get()\n lastReportedPage = 0\n }\n for (const stop of stops) stop()\n const reportZoom = (z: ZoomValue): void => {\n if (z === lastReportedZoom) return\n lastReportedZoom = z\n ctx.reportZoom(z)\n }\n const reportPage = (p: number): void => {\n if (p === lastReportedPage) return\n lastReportedPage = p\n ctx.reportPage(p)\n }\n // A tool that switches itself (a one-shot tool once used) is reported as a pick.\n const followTool = (id: ToolId): void => {\n if (id !== ctx.tool.value) ctx.setTool(id)\n }\n stops = [\n vp.zoom.subscribe(reportZoom),\n vp.currentPage.subscribe(reportPage),\n tc.active.subscribe(followTool),\n ]\n // Whatever the build restored is reported once; nothing is when it matched.\n reportZoom(vp.zoom.get())\n reportPage(vp.currentPage.get())\n },\n onPageMount: (page, mount, host) => {\n pages.value = [...pages.value, { build, page, host, mount, error: null, custom }]\n },\n onPageUnmount: (page) => {\n pages.value = pages.value.filter((p) => p.page !== page)\n },\n onPageError: (page, err) => {\n pages.value = pages.value.map((p) => (p.page === page ? { ...p, error: err } : p))\n },\n })\n}\n\nonMounted(() => {\n ctx.viewportEl.value = scroll.value\n watch([() => ctx.document.value, () => ctx.status.value.state], setup, {\n immediate: true,\n })\n})\n\n// A new decorateAnnotation re-applies to the mounted annotation elements at once.\nwatch(\n () => ctx.decorateAnnotation.value,\n () => engine.value?.redecorate()\n)\n// The tint follows `formHighlight` in place, without a new document.\nwatch(\n () => ctx.formHighlight.value,\n (on) => engine.value?.setFormHighlight(on ?? true)\n)\nwatch(\n () => ctx.zoomModel.value,\n (z: ZoomValue | undefined) => {\n const vp = engine.value?.viewport\n if (vp && z !== undefined && z !== vp.zoom.get()) vp.setZoom(z)\n }\n)\nwatch(\n () => ctx.pageModel.value,\n (p) => {\n const vp = engine.value?.viewport\n if (!vp || p === undefined || p === lastReportedPage) return\n if (p !== vp.currentPage.get()) vp.scrollToPage(p)\n }\n)\nwatch(\n () => ctx.tool.value,\n (t) => {\n const tc = engine.value?.tools\n if (tc && tc.active.get() !== t) tc.set(t)\n }\n)\nwatch(\n () => props.mode,\n (m) => engine.value?.viewport.setMode(m)\n)\nwatch(\n () => props.rotation,\n (r) => engine.value?.viewport.setRotation(r)\n)\n// Gap, buffer and pinch zoom are construction options: rebuild for the same document, keeping zoom and page.\n// The slots are already updated when this runs, so it carries the annotation slot too: a slot\n// toggle in the same tick is then recorded here and `onBeforeUpdate` finds nothing left to do.\nwatch(\n [() => props.gap, () => props.buffer, () => props.pinchZoom],\n ([gap, buffer, pinchZoom]) =>\n rebuild({ gap, buffer, pinchZoom, customAnnotations: !!slots.annotation })\n)\n\n// Slots are not reactive, so a change to whether the annotation slot is given is caught here.\n// `onBeforeUpdate` runs after the new slots are in place and before this render: the rebuild\n// swaps `pages` for the new build's pages synchronously, so the render that follows never pairs\n// the annotation slot with an overlay built without it (or the reverse). The rebuild keeps the\n// scroll position.\nonBeforeUpdate(() => {\n const next = !!slots.annotation\n if (engine.value && next !== custom) rebuild({ customAnnotations: next })\n})\n\nonBeforeUnmount(() => {\n teardown()\n if (ctx.viewportEl.value === scroll.value) ctx.viewportEl.value = null\n})\n</script>\n\n<template>\n <div class=\"ink-viewport-root\" data-ink-viewport-root :data-state=\"state\">\n <div v-if=\"state === 'loading'\" class=\"ink-status\" role=\"status\" aria-live=\"polite\">\n <slot name=\"loading\">Loading document…</slot>\n </div>\n <div v-else-if=\"error\" class=\"ink-status ink-error\" role=\"alert\">\n <slot name=\"error\" :error=\"error\">\n <p class=\"ink-error-title\">This document could not be opened.</p>\n <!-- The message comes from the PDF engine and is not written for readers: it stays\n off the page, on the code's tooltip. -->\n <p>\n <code class=\"ink-error-code\" :title=\"error.message\">{{ error.code }}</code>\n </p>\n </slot>\n </div>\n <div v-else-if=\"state === 'idle'\" class=\"ink-status ink-empty\">\n <slot name=\"empty\" />\n </div>\n <div\n ref=\"scroll\"\n class=\"ink-scroll\"\n data-ink-scroll\n tabindex=\"0\"\n role=\"document\"\n aria-label=\"Document\"\n />\n <InkPage\n v-for=\"p in pages\"\n :key=\"`${p.build}:${p.page}`\"\n :page=\"p.page\"\n :host=\"p.host\"\n :mount=\"p.mount\"\n :error=\"p.error\"\n :custom-annotations=\"p.custom\"\n >\n <template v-if=\"slots.annotation\" #annotation=\"slotProps\">\n <slot name=\"annotation\" v-bind=\"slotProps\" />\n </template>\n <template v-if=\"slots['page-error']\" #page-error=\"slotProps\">\n <slot name=\"page-error\" v-bind=\"slotProps\" />\n </template>\n </InkPage>\n <!-- Keyed by document, so the menu and its dialog start afresh for each one. -->\n <InkSignFieldPopover\n :key=\"documentKey(ctx.document.value)\"\n :request=\"signRequest\"\n @close=\"signRequest = null\"\n />\n <InkFormAlert\n :message=\"alertMessage\"\n :shown=\"alertsShown\"\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OADTxC,EAAA,GAAAS,EAeUC,GAAA;IAbP,KAAG,GAAKgE,EAAE,MAAK,GAAIA,EAAE;IACrB,MAAMA,EAAE;IACR,MAAMA,EAAE;IACR,OAAOA,EAAE;IACT,OAAOA,EAAE;IACT,sBAAoBA,EAAE;GAEP,GAAA2B,EAAA,EAAA,GAAA,EAAA,GAAA,CAAAxE,EAAM,aAAA;IAAa,MAAA;IACjC,IAAAjB,GAD6C,MAAS,CACtDV,EAA6C0F,EAAA,QAAA,cAA7C/E,EAA6C,EAAA,SAAA,GAAA,GAAb2F,CAAS,CAAA,CAAA,CAAA;;GAE3B,IAAA,KAAA,GAAA3E,EAAK,gBAAA;IAAiB,MAAA;IACpC,IAAAjB,GADgD,MAAS,CACzDV,EAA6C0F,EAAA,QAAA,cAA7C/E,EAA6C,EAAA,SAAA,GAAA,GAAb2F,CAAS,CAAA,CAAA,CAAA;;;;;;;;;IAI7CxG,EAAA,GAAAS,EAIEK,GAAA;IAHC,KAAKuB,EAAYtB,EAAAgB,CAAA,CAAG,CAAC,SAAS,KAAK;IACnC,SAASe,EAAA;IACT,SAAK,AAAA+C,EAAA,QAAA,MAAE,EAAA,QAAW;;GAErB7E,EAKEC,GAAA;IAJC,SAAS8B,EAAA;IACT,OAAOC,EAAA;IACP,UAAUf,EAAA;IACV,SAAK,AAAA4D,EAAA,QAAA,MAAE,EAAA,QAAY"}
@@ -1 +1 @@
1
- {"version":3,"file":"InkZoomSelect.js","names":["_sfc_main","InkZoomSelect_vue_vue_type_script_setup_true_lang_default","InkZoomSelect_default"],"sources":["../../src/components/InkZoomSelect.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ZOOM_LEVELS } from '@inkbar/core/dom'\nimport { Check, ChevronDown } from '@inkbar/icons'\nimport {\n SelectContent,\n SelectIcon,\n SelectItem,\n SelectItemIndicator,\n SelectItemText,\n SelectPortal,\n SelectRoot,\n SelectSeparator,\n SelectTrigger,\n SelectValue,\n SelectViewport,\n} from 'reka-ui'\nimport { computed } from 'vue'\n\nimport { useZoom } from '../composables/useZoom'\n\nimport InkIcon from './InkIcon.vue'\n\nimport type { ZoomValue } from '@inkbar/core/dom'\n\nconst CUSTOM = 'custom:'\n\nconst { zoom, scale, setZoom } = useZoom()\n\nconst level = (z: number) => ZOOM_LEVELS.find((l) => Math.abs(l - z) < 0.001)\n/** A numeric zoom that is not one of the levels (zoom in and out multiply). */\nconst custom = computed(() =>\n typeof zoom.value === 'number' && level(zoom.value) === undefined ? zoom.value : null\n)\nconst value = computed(() => {\n const z = zoom.value\n if (typeof z !== 'number') return z\n return custom.value === null ? String(level(z)) : `${CUSTOM}${z}`\n})\n\nfunction onChange(v: unknown): void {\n if (typeof v !== 'string' || v === value.value) return\n const next: ZoomValue =\n v === 'fit-width' || v === 'fit-page' ? v : Number(v.replace(CUSTOM, ''))\n setZoom(next)\n}\n\nconst FITS = [\n { value: 'fit-width', label: 'Fit width' },\n { value: 'fit-page', label: 'Fit page' },\n]\n// Reka's typed props stop at its own; ARIA goes through a bound object.\nconst triggerAttrs = { 'aria-label': 'Zoom' }\nconst percent = (z: number) => `${Math.round(z * 100)}%`\n/** The levels, with a custom zoom in its place among them. */\nconst levels = computed(() => {\n const list = ZOOM_LEVELS.map((l) => ({ z: l, value: String(l), label: percent(l) }))\n const c = custom.value\n if (c !== null) list.push({ z: c, value: `${CUSTOM}${c}`, label: percent(scale.value) })\n return list.sort((a, b) => a.z - b.z)\n})\n</script>\n\n<template>\n <SelectRoot :model-value=\"value\" @update:model-value=\"onChange\">\n <SelectTrigger\n class=\"ink-zoom-select ink-select-trigger\"\n data-ink-zoom-select\n v-bind=\"triggerAttrs\"\n >\n <SelectValue class=\"ink-select-value\" />\n <SelectIcon class=\"ink-select-icon\">\n <InkIcon :icon=\"ChevronDown\" :size=\"16\" />\n </SelectIcon>\n </SelectTrigger>\n <SelectPortal>\n <SelectContent\n class=\"ink-select-content\"\n data-ink-select-content\n position=\"popper\"\n side=\"top\"\n :side-offset=\"4\"\n >\n <SelectViewport>\n <SelectItem\n v-for=\"o in FITS\"\n :key=\"o.value\"\n :value=\"o.value\"\n class=\"ink-select-item\"\n data-ink-select-item\n >\n <SelectItemText>{{ o.label }}</SelectItemText>\n <SelectItemIndicator class=\"ink-select-indicator\">\n <InkIcon :icon=\"Check\" :size=\"16\" />\n </SelectItemIndicator>\n </SelectItem>\n <SelectSeparator class=\"ink-select-separator\" />\n <SelectItem\n v-for=\"o in levels\"\n :key=\"o.value\"\n :value=\"o.value\"\n class=\"ink-select-item\"\n data-ink-select-item\n >\n <SelectItemText>{{ o.label }}</SelectItemText>\n <SelectItemIndicator class=\"ink-select-indicator\">\n <InkIcon :icon=\"Check\" :size=\"16\" />\n </SelectItemIndicator>\n </SelectItem>\n </SelectViewport>\n </SelectContent>\n </SelectPortal>\n </SelectRoot>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"InkZoomSelect.js","names":["_sfc_main","InkZoomSelect_vue_vue_type_script_setup_true_lang_default","InkZoomSelect_default"],"sources":["../../src/components/InkZoomSelect.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ZOOM_LEVELS } from '@inkbar/core/dom'\nimport { Check, ChevronDown } from '@inkbar/icons'\nimport {\n SelectContent,\n SelectIcon,\n SelectItem,\n SelectItemIndicator,\n SelectItemText,\n SelectPortal,\n SelectRoot,\n SelectSeparator,\n SelectTrigger,\n SelectValue,\n SelectViewport,\n} from 'reka-ui'\nimport { computed } from 'vue'\n\nimport { useZoom } from '../composables/useZoom'\n\nimport InkIcon from './InkIcon.vue'\n\nimport type { ZoomValue } from '@inkbar/core/dom'\n\nconst CUSTOM = 'custom:'\n\nconst { zoom, scale, setZoom } = useZoom()\n\nconst level = (z: number) => ZOOM_LEVELS.find((l) => Math.abs(l - z) < 0.001)\n/** A numeric zoom that is not one of the levels (zoom in and out multiply). */\nconst custom = computed(() =>\n typeof zoom.value === 'number' && level(zoom.value) === undefined ? zoom.value : null\n)\nconst value = computed(() => {\n const z = zoom.value\n if (typeof z !== 'number') return z\n return custom.value === null ? String(level(z)) : `${CUSTOM}${z}`\n})\n\nfunction onChange(v: unknown): void {\n if (typeof v !== 'string' || v === value.value) return\n const next: ZoomValue =\n v === 'fit-width' || v === 'fit-page' ? v : Number(v.replace(CUSTOM, ''))\n setZoom(next)\n}\n\nconst FITS = [\n { value: 'fit-width', label: 'Fit width' },\n { value: 'fit-page', label: 'Fit page' },\n]\n// Reka's typed props stop at its own; ARIA goes through a bound object.\nconst triggerAttrs = { 'aria-label': 'Zoom' }\nconst percent = (z: number) => `${Math.round(z * 100)}%`\n/** The levels, with a custom zoom in its place among them. */\nconst levels = computed(() => {\n const list = ZOOM_LEVELS.map((l) => ({ z: l, value: String(l), label: percent(l) }))\n const c = custom.value\n if (c !== null) list.push({ z: c, value: `${CUSTOM}${c}`, label: percent(scale.value) })\n return list.sort((a, b) => a.z - b.z)\n})\n</script>\n\n<template>\n <SelectRoot :model-value=\"value\" @update:model-value=\"onChange\">\n <SelectTrigger\n class=\"ink-select ink-select-trigger ink-zoom-select\"\n data-ink-zoom-select\n v-bind=\"triggerAttrs\"\n >\n <SelectValue class=\"ink-select-value\" />\n <SelectIcon class=\"ink-select-icon\">\n <InkIcon :icon=\"ChevronDown\" :size=\"16\" />\n </SelectIcon>\n </SelectTrigger>\n <SelectPortal>\n <SelectContent\n class=\"ink-select-content\"\n data-ink-select-content\n position=\"popper\"\n side=\"top\"\n :side-offset=\"4\"\n >\n <SelectViewport>\n <SelectItem\n v-for=\"o in FITS\"\n :key=\"o.value\"\n :value=\"o.value\"\n class=\"ink-select-item\"\n data-ink-select-item\n >\n <SelectItemText>{{ o.label }}</SelectItemText>\n <SelectItemIndicator class=\"ink-select-indicator\">\n <InkIcon :icon=\"Check\" :size=\"16\" />\n </SelectItemIndicator>\n </SelectItem>\n <SelectSeparator class=\"ink-select-separator\" />\n <SelectItem\n v-for=\"o in levels\"\n :key=\"o.value\"\n :value=\"o.value\"\n class=\"ink-select-item\"\n data-ink-select-item\n >\n <SelectItemText>{{ o.label }}</SelectItemText>\n <SelectItemIndicator class=\"ink-select-indicator\">\n <InkIcon :icon=\"Check\" :size=\"16\" />\n </SelectItemIndicator>\n </SelectItem>\n </SelectViewport>\n </SelectContent>\n </SelectPortal>\n </SelectRoot>\n</template>\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"InkZoomSelect.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkZoomSelect.vue"],"names":[],"mappings":"AA8bA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"InkZoomSelect.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkZoomSelect.vue"],"names":[],"mappings":"AA+bA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -40,7 +40,7 @@ var k = "custom:", A = /*@__PURE__*/ c({
40
40
  "onUpdate:modelValue": I
41
41
  }, {
42
42
  default: m(() => [s(p(w), l({
43
- class: "ink-zoom-select ink-select-trigger",
43
+ class: "ink-select ink-select-trigger ink-zoom-select",
44
44
  "data-ink-zoom-select": ""
45
45
  }, R), {
46
46
  default: m(() => [s(p(T), { class: "ink-select-value" }), s(p(_), { class: "ink-select-icon" }, {