@inkbar/vue 0.0.0-stage → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +137 -2
- package/dist/components/InkAnnotation.js +7 -0
- package/dist/components/InkAnnotation.js.map +1 -0
- package/dist/components/InkAnnotation.vue.d.ts +22 -0
- package/dist/components/InkAnnotation.vue.d.ts.map +1 -0
- package/dist/components/InkAnnotation.vue_vue_type_script_setup_true_lang.js +48 -0
- package/dist/components/InkAnnotation.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkIcon.js +7 -0
- package/dist/components/InkIcon.js.map +1 -0
- package/dist/components/InkIcon.vue.d.ts +11 -0
- package/dist/components/InkIcon.vue.d.ts.map +1 -0
- package/dist/components/InkIcon.vue_vue_type_script_setup_true_lang.js +22 -0
- package/dist/components/InkIcon.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkNextPage.js +7 -0
- package/dist/components/InkNextPage.js.map +1 -0
- package/dist/components/InkNextPage.vue.d.ts +19 -0
- package/dist/components/InkNextPage.vue.d.ts.map +1 -0
- package/dist/components/InkNextPage.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/components/InkNextPage.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkNotePopover.js +7 -0
- package/dist/components/InkNotePopover.js.map +1 -0
- package/dist/components/InkNotePopover.vue.d.ts +15 -0
- package/dist/components/InkNotePopover.vue.d.ts.map +1 -0
- package/dist/components/InkNotePopover.vue_vue_type_script_setup_true_lang.js +132 -0
- package/dist/components/InkNotePopover.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkPage.js +7 -0
- package/dist/components/InkPage.js.map +1 -0
- package/dist/components/InkPage.vue.d.ts +32 -0
- package/dist/components/InkPage.vue.d.ts.map +1 -0
- package/dist/components/InkPage.vue_vue_type_script_setup_true_lang.js +68 -0
- package/dist/components/InkPage.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkPageCount.js +7 -0
- package/dist/components/InkPageCount.js.map +1 -0
- package/dist/components/InkPageCount.vue.d.ts +4 -0
- package/dist/components/InkPageCount.vue.d.ts.map +1 -0
- package/dist/components/InkPageCount.vue_vue_type_script_setup_true_lang.js +18 -0
- package/dist/components/InkPageCount.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkPageInput.js +7 -0
- package/dist/components/InkPageInput.js.map +1 -0
- package/dist/components/InkPageInput.vue.d.ts +4 -0
- package/dist/components/InkPageInput.vue.d.ts.map +1 -0
- package/dist/components/InkPageInput.vue_vue_type_script_setup_true_lang.js +30 -0
- package/dist/components/InkPageInput.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkPrevPage.js +7 -0
- package/dist/components/InkPrevPage.js.map +1 -0
- package/dist/components/InkPrevPage.vue.d.ts +19 -0
- package/dist/components/InkPrevPage.vue.d.ts.map +1 -0
- package/dist/components/InkPrevPage.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/components/InkPrevPage.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkRedo.js +7 -0
- package/dist/components/InkRedo.js.map +1 -0
- package/dist/components/InkRedo.vue.d.ts +19 -0
- package/dist/components/InkRedo.vue.d.ts.map +1 -0
- package/dist/components/InkRedo.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/components/InkRedo.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkRoot.js +7 -0
- package/dist/components/InkRoot.js.map +1 -0
- package/dist/components/InkRoot.vue.d.ts +784 -0
- package/dist/components/InkRoot.vue.d.ts.map +1 -0
- package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js +162 -0
- package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkSuggestionCard.js +7 -0
- package/dist/components/InkSuggestionCard.js.map +1 -0
- package/dist/components/InkSuggestionCard.vue.d.ts +16 -0
- package/dist/components/InkSuggestionCard.vue.d.ts.map +1 -0
- package/dist/components/InkSuggestionCard.vue_vue_type_script_setup_true_lang.js +85 -0
- package/dist/components/InkSuggestionCard.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkToolButton.js +7 -0
- package/dist/components/InkToolButton.js.map +1 -0
- package/dist/components/InkToolButton.vue.d.ts +26 -0
- package/dist/components/InkToolButton.vue.d.ts.map +1 -0
- package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js +53 -0
- package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkToolbar.js +7 -0
- package/dist/components/InkToolbar.js.map +1 -0
- package/dist/components/InkToolbar.vue.d.ts +21 -0
- package/dist/components/InkToolbar.vue.d.ts.map +1 -0
- package/dist/components/InkToolbar.vue_vue_type_script_setup_true_lang.js +29 -0
- package/dist/components/InkToolbar.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkToolbarSeparator.js +7 -0
- package/dist/components/InkToolbarSeparator.js.map +1 -0
- package/dist/components/InkToolbarSeparator.vue.d.ts +4 -0
- package/dist/components/InkToolbarSeparator.vue.d.ts.map +1 -0
- package/dist/components/InkToolbarSeparator.vue_vue_type_script_setup_true_lang.js +17 -0
- package/dist/components/InkToolbarSeparator.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkUndo.js +7 -0
- package/dist/components/InkUndo.js.map +1 -0
- package/dist/components/InkUndo.vue.d.ts +19 -0
- package/dist/components/InkUndo.vue.d.ts.map +1 -0
- package/dist/components/InkUndo.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/components/InkUndo.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkViewport.js +7 -0
- package/dist/components/InkViewport.js.map +1 -0
- package/dist/components/InkViewport.vue.d.ts +39 -0
- package/dist/components/InkViewport.vue.d.ts.map +1 -0
- package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js +148 -0
- package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkZoomIn.js +7 -0
- package/dist/components/InkZoomIn.js.map +1 -0
- package/dist/components/InkZoomIn.vue.d.ts +19 -0
- package/dist/components/InkZoomIn.vue.d.ts.map +1 -0
- package/dist/components/InkZoomIn.vue_vue_type_script_setup_true_lang.js +32 -0
- package/dist/components/InkZoomIn.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkZoomOut.js +7 -0
- package/dist/components/InkZoomOut.js.map +1 -0
- package/dist/components/InkZoomOut.vue.d.ts +19 -0
- package/dist/components/InkZoomOut.vue.d.ts.map +1 -0
- package/dist/components/InkZoomOut.vue_vue_type_script_setup_true_lang.js +32 -0
- package/dist/components/InkZoomOut.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkZoomSelect.js +7 -0
- package/dist/components/InkZoomSelect.js.map +1 -0
- package/dist/components/InkZoomSelect.vue.d.ts +4 -0
- package/dist/components/InkZoomSelect.vue.d.ts.map +1 -0
- package/dist/components/InkZoomSelect.vue_vue_type_script_setup_true_lang.js +115 -0
- package/dist/components/InkZoomSelect.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/annotation-element.d.ts +5 -0
- package/dist/components/annotation-element.d.ts.map +1 -0
- package/dist/components/annotation-element.js +18 -0
- package/dist/components/annotation-element.js.map +1 -0
- package/dist/components/annotation-slot.d.ts +2 -0
- package/dist/components/annotation-slot.d.ts.map +1 -0
- package/dist/components/popover-focus.d.ts +9 -0
- package/dist/components/popover-focus.d.ts.map +1 -0
- package/dist/components/popover-focus.js +15 -0
- package/dist/components/popover-focus.js.map +1 -0
- package/dist/composables/useAnnotations.d.ts +1921 -0
- package/dist/composables/useAnnotations.d.ts.map +1 -0
- package/dist/composables/useAnnotations.js +27 -0
- package/dist/composables/useAnnotations.js.map +1 -0
- package/dist/composables/useDocument.d.ts +12 -0
- package/dist/composables/useDocument.d.ts.map +1 -0
- package/dist/composables/useDocument.js +20 -0
- package/dist/composables/useDocument.js.map +1 -0
- package/dist/composables/useEmbedded.d.ts +6 -0
- package/dist/composables/useEmbedded.d.ts.map +1 -0
- package/dist/composables/useEmbedded.js +15 -0
- package/dist/composables/useEmbedded.js.map +1 -0
- package/dist/composables/useHistory.d.ts +7 -0
- package/dist/composables/useHistory.d.ts.map +1 -0
- package/dist/composables/useHistory.js +9 -0
- package/dist/composables/useHistory.js.map +1 -0
- package/dist/composables/usePage.d.ts +10 -0
- package/dist/composables/usePage.d.ts.map +1 -0
- package/dist/composables/usePage.js +22 -0
- package/dist/composables/usePage.js.map +1 -0
- package/dist/composables/useSelection.d.ts +6 -0
- package/dist/composables/useSelection.d.ts.map +1 -0
- package/dist/composables/useSelection.js +14 -0
- package/dist/composables/useSelection.js.map +1 -0
- package/dist/composables/useTool.d.ts +6 -0
- package/dist/composables/useTool.d.ts.map +1 -0
- package/dist/composables/useTool.js +13 -0
- package/dist/composables/useTool.js.map +1 -0
- package/dist/composables/useZoom.d.ts +9 -0
- package/dist/composables/useZoom.d.ts.map +1 -0
- package/dist/composables/useZoom.js +17 -0
- package/dist/composables/useZoom.js.map +1 -0
- package/dist/context.d.ts +50 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +13 -0
- package/dist/context.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/ref-history.d.ts +18 -0
- package/dist/ref-history.d.ts.map +1 -0
- package/dist/ref-history.js +25 -0
- package/dist/ref-history.js.map +1 -0
- package/dist/use-readable.d.ts +5 -0
- package/dist/use-readable.d.ts.map +1 -0
- package/dist/use-readable.js +16 -0
- package/dist/use-readable.js.map +1 -0
- package/package.json +52 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkPage.js","names":["_sfc_main","InkPage_vue_vue_type_script_setup_true_lang_default","InkPage_default"],"sources":["../../src/components/InkPage.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * One page the viewer engine mounted. Renders nothing in place; Teleports go into the host\n * (page error) and, when the host provides the `annotation` slot, into each annotation's\n * overlay element.\n *\n * The overlay creates and removes those elements as the annotation list changes, outside\n * Vue. So the teleport targets come from a list read after every overlay render: this\n * component subscribes to the store after the overlay does (the engine created the mount\n * first), and core notifies subscribers in order, so the elements already exist when the list\n * arrives here.\n *\n * The engine tracks page errors and sets `data-state=\"error\"` on the host; this component\n * teleports the `page-error` slot into it while `error` is set.\n */\nimport { onBeforeUnmount, onMounted, shallowRef, watch } from 'vue'\n\nimport { injectInkContext } from '../context'\n\nimport InkAnnotation from './InkAnnotation.vue'\n\nimport type { AnnotationSlotProps } from './annotation-slot'\nimport type { Annotation, InkError } from '@inkbar/core'\nimport type { PageMount } from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{\n page: number\n host: HTMLElement\n /** The engine's page mount in `host`. */\n mount: PageMount\n /** The engine's error for this page, `null` while it renders. */\n error: InkError | null\n /** Fixed for the life of the mount: the engine rebuilds when it changes. */\n customAnnotations?: boolean\n }>(),\n { customAnnotations: false }\n)\n\ndefineSlots<{\n annotation?(props: AnnotationSlotProps): unknown\n 'page-error'?(props: { error: InkError; page: number }): unknown\n}>()\n\nconst ctx = injectInkContext()\nconst targets = shallowRef<{ annotation: Annotation; el: HTMLElement }[]>([])\nlet stopList: (() => void) | undefined\n\nfunction stop(): void {\n stopList?.()\n stopList = undefined\n targets.value = []\n}\n\n// Targets are read from the current mount, and read again when InkViewport hands this page a\n// new one (the page left and came back within one tick, under the same key), as React and\n// Svelte do. The watch fires only when one of these values changes, not on an error change.\nfunction start(): void {\n stop()\n const doc = ctx.document.value\n if (!doc || !props.customAnnotations) return\n const mount = props.mount\n const read = (): void => {\n targets.value = doc.annotations.byPage(props.page).flatMap((annotation) => {\n const el = mount.overlay.elementFor(annotation.id)\n return el ? [{ annotation, el }] : []\n })\n }\n stopList = doc.annotations.list.subscribe(read)\n read()\n}\n\nonMounted(() => {\n start()\n watch([() => props.mount, () => props.page, () => props.customAnnotations], start)\n})\n\nonBeforeUnmount(stop)\n</script>\n\n<template>\n <Teleport v-if=\"error\" :to=\"host\">\n <div class=\"ink-page-error\" data-ink-page-error role=\"alert\">\n <slot name=\"page-error\" :error=\"error\" :page=\"page\">\n <p>Page {{ page + 1 }} could not be shown.</p>\n <code class=\"ink-error-code\">{{ error.code }}</code>\n </slot>\n </div>\n </Teleport>\n <Teleport v-for=\"t in targets\" :key=\"t.annotation.id\" :to=\"t.el\">\n <InkAnnotation :annotation=\"t.annotation\" :element=\"t.el\">\n <template #default=\"slotProps\">\n <slot name=\"annotation\" v-bind=\"slotProps\" />\n </template>\n </InkAnnotation>\n </Teleport>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AnnotationSlotProps } from './annotation-slot';
|
|
2
|
+
import { InkError } from '@inkbar/core';
|
|
3
|
+
import { PageMount } from '@inkbar/core/dom';
|
|
4
|
+
type __VLS_Props = {
|
|
5
|
+
page: number;
|
|
6
|
+
host: HTMLElement;
|
|
7
|
+
/** The engine's page mount in `host`. */
|
|
8
|
+
mount: PageMount;
|
|
9
|
+
/** The engine's error for this page, `null` while it renders. */
|
|
10
|
+
error: InkError | null;
|
|
11
|
+
/** Fixed for the life of the mount: the engine rebuilds when it changes. */
|
|
12
|
+
customAnnotations?: boolean;
|
|
13
|
+
};
|
|
14
|
+
type __VLS_Slots = {
|
|
15
|
+
annotation?(props: AnnotationSlotProps): unknown;
|
|
16
|
+
'page-error'?(props: {
|
|
17
|
+
error: InkError;
|
|
18
|
+
page: number;
|
|
19
|
+
}): unknown;
|
|
20
|
+
};
|
|
21
|
+
declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
22
|
+
customAnnotations: boolean;
|
|
23
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
24
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
25
|
+
declare const _default: typeof __VLS_export;
|
|
26
|
+
export default _default;
|
|
27
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
28
|
+
new (): {
|
|
29
|
+
$slots: S;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=InkPage.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkPage.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkPage.vue"],"names":[],"mappings":"AAuHA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAc,QAAQ,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAGjD,KAAK,WAAW,GAAG;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,WAAW,CAAA;IACjB,yCAAyC;IACzC,KAAK,EAAE,SAAS,CAAA;IAChB,iEAAiE;IACjE,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAA;IACtB,4EAA4E;IAC5E,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B,CAAC;AAMJ,KAAK,WAAW,GAAG;IACjB,UAAU,CAAC,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAA;IAChD,YAAY,CAAC,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,QAAQ,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAA;CACjE,CAAC;AAqIF,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,68 @@
|
|
|
1
|
+
import { injectInkContext as e } from "../context.js";
|
|
2
|
+
import t from "./InkAnnotation.js";
|
|
3
|
+
import { Fragment as n, Teleport as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createVNode as c, defineComponent as l, mergeProps as u, onBeforeUnmount as d, onMounted as f, openBlock as p, renderList as m, renderSlot as h, shallowRef as g, toDisplayString as _, watch as v, withCtx as y } from "vue";
|
|
4
|
+
//#region src/components/InkPage.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var b = {
|
|
6
|
+
class: "ink-page-error",
|
|
7
|
+
"data-ink-page-error": "",
|
|
8
|
+
role: "alert"
|
|
9
|
+
}, x = { class: "ink-error-code" }, S = /*@__PURE__*/ l({
|
|
10
|
+
__name: "InkPage",
|
|
11
|
+
props: {
|
|
12
|
+
page: {},
|
|
13
|
+
host: {},
|
|
14
|
+
mount: {},
|
|
15
|
+
error: {},
|
|
16
|
+
customAnnotations: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: !1
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
setup(l) {
|
|
22
|
+
let S = l, C = e(), w = g([]), T;
|
|
23
|
+
function E() {
|
|
24
|
+
T?.(), T = void 0, w.value = [];
|
|
25
|
+
}
|
|
26
|
+
function D() {
|
|
27
|
+
E();
|
|
28
|
+
let e = C.document.value;
|
|
29
|
+
if (!e || !S.customAnnotations) return;
|
|
30
|
+
let t = S.mount, n = () => {
|
|
31
|
+
w.value = e.annotations.byPage(S.page).flatMap((e) => {
|
|
32
|
+
let n = t.overlay.elementFor(e.id);
|
|
33
|
+
return n ? [{
|
|
34
|
+
annotation: e,
|
|
35
|
+
el: n
|
|
36
|
+
}] : [];
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
T = e.annotations.list.subscribe(n), n();
|
|
40
|
+
}
|
|
41
|
+
return f(() => {
|
|
42
|
+
D(), v([
|
|
43
|
+
() => S.mount,
|
|
44
|
+
() => S.page,
|
|
45
|
+
() => S.customAnnotations
|
|
46
|
+
], D);
|
|
47
|
+
}), d(E), (e, d) => (p(), o(n, null, [l.error ? (p(), i(r, {
|
|
48
|
+
key: 0,
|
|
49
|
+
to: l.host
|
|
50
|
+
}, [s("div", b, [h(e.$slots, "page-error", {
|
|
51
|
+
error: l.error,
|
|
52
|
+
page: l.page
|
|
53
|
+
}, () => [s("p", null, "Page " + _(l.page + 1) + " could not be shown.", 1), s("code", x, _(l.error.code), 1)])])], 8, ["to"])) : a("", !0), (p(!0), o(n, null, m(w.value, (n) => (p(), i(r, {
|
|
54
|
+
key: n.annotation.id,
|
|
55
|
+
to: n.el
|
|
56
|
+
}, [c(t, {
|
|
57
|
+
annotation: n.annotation,
|
|
58
|
+
element: n.el
|
|
59
|
+
}, {
|
|
60
|
+
default: y((t) => [h(e.$slots, "annotation", u({ ref_for: !0 }, t))]),
|
|
61
|
+
_: 3
|
|
62
|
+
}, 8, ["annotation", "element"])], 8, ["to"]))), 128))], 64));
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
//#endregion
|
|
66
|
+
export { S as default };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=InkPage.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkPage.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_Fragment","_createBlock","_Teleport","_createElementVNode","_renderSlot","_toDisplayString","_createCommentVNode","_renderList","_createVNode","InkAnnotation","_withCtx","_mergeProps","InkAnnotation_default","_hoisted_1","_hoisted_2","InkPage_vue_vue_type_script_setup_true_lang_default","props","__props","ctx","injectInkContext","targets","shallowRef","stopList","stop","start","doc","mount","read","el","annotation","onMounted","watch","onBeforeUnmount","openBlock","createElementBlock","Fragment","createBlock","Teleport","createElementVNode","renderSlot","_ctx","toDisplayString","createCommentVNode","renderList","t","createVNode","withCtx","mergeProps","slotProps"],"sources":["../../src/components/InkPage.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * One page the viewer engine mounted. Renders nothing in place; Teleports go into the host\n * (page error) and, when the host provides the `annotation` slot, into each annotation's\n * overlay element.\n *\n * The overlay creates and removes those elements as the annotation list changes, outside\n * Vue. So the teleport targets come from a list read after every overlay render: this\n * component subscribes to the store after the overlay does (the engine created the mount\n * first), and core notifies subscribers in order, so the elements already exist when the list\n * arrives here.\n *\n * The engine tracks page errors and sets `data-state=\"error\"` on the host; this component\n * teleports the `page-error` slot into it while `error` is set.\n */\nimport { onBeforeUnmount, onMounted, shallowRef, watch } from 'vue'\n\nimport { injectInkContext } from '../context'\n\nimport InkAnnotation from './InkAnnotation.vue'\n\nimport type { AnnotationSlotProps } from './annotation-slot'\nimport type { Annotation, InkError } from '@inkbar/core'\nimport type { PageMount } from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{\n page: number\n host: HTMLElement\n /** The engine's page mount in `host`. */\n mount: PageMount\n /** The engine's error for this page, `null` while it renders. */\n error: InkError | null\n /** Fixed for the life of the mount: the engine rebuilds when it changes. */\n customAnnotations?: boolean\n }>(),\n { customAnnotations: false }\n)\n\ndefineSlots<{\n annotation?(props: AnnotationSlotProps): unknown\n 'page-error'?(props: { error: InkError; page: number }): unknown\n}>()\n\nconst ctx = injectInkContext()\nconst targets = shallowRef<{ annotation: Annotation; el: HTMLElement }[]>([])\nlet stopList: (() => void) | undefined\n\nfunction stop(): void {\n stopList?.()\n stopList = undefined\n targets.value = []\n}\n\n// Targets are read from the current mount, and read again when InkViewport hands this page a\n// new one (the page left and came back within one tick, under the same key), as React and\n// Svelte do. The watch fires only when one of these values changes, not on an error change.\nfunction start(): void {\n stop()\n const doc = ctx.document.value\n if (!doc || !props.customAnnotations) return\n const mount = props.mount\n const read = (): void => {\n targets.value = doc.annotations.byPage(props.page).flatMap((annotation) => {\n const el = mount.overlay.elementFor(annotation.id)\n return el ? [{ annotation, el }] : []\n })\n }\n stopList = doc.annotations.list.subscribe(read)\n read()\n}\n\nonMounted(() => {\n start()\n watch([() => props.mount, () => props.page, () => props.customAnnotations], start)\n})\n\nonBeforeUnmount(stop)\n</script>\n\n<template>\n <Teleport v-if=\"error\" :to=\"host\">\n <div class=\"ink-page-error\" data-ink-page-error role=\"alert\">\n <slot name=\"page-error\" :error=\"error\" :page=\"page\">\n <p>Page {{ page + 1 }} could not be shown.</p>\n <code class=\"ink-error-code\">{{ error.code }}</code>\n </slot>\n </div>\n </Teleport>\n <Teleport v-for=\"t in targets\" :key=\"t.annotation.id\" :to=\"t.el\">\n <InkAnnotation :annotation=\"t.annotation\" :element=\"t.el\">\n <template #default=\"slotProps\">\n <slot name=\"annotation\" v-bind=\"slotProps\" />\n </template>\n </InkAnnotation>\n </Teleport>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAyBA,IAAMkB,IAAQC,GAmBRC,IAAMC,EAAiB,GACvBC,IAAUC,EAA0D,CAAC,CAAC,GACxEC;EAEJ,SAASC,IAAa;GAGpB,AAFAD,IAAW,GACX,IAAW,KAAA,GACX,EAAQ,QAAQ,CAAC;EACnB;EAKA,SAASE,IAAc;GACrB,EAAK;GACL,IAAMC,IAAMP,EAAI,SAAS;GACzB,IAAI,CAACO,KAAO,CAACT,EAAM,mBAAmB;GACtC,IAAMU,IAAQV,EAAM,OACdW,UAAmB;IACvB,EAAQ,QAAQF,EAAI,YAAY,OAAOT,EAAM,IAAI,CAAC,CAAC,SAAS,MAAe;KACzE,IAAMY,IAAKF,EAAM,QAAQ,WAAWG,EAAW,EAAE;KACjD,OAAOD,IAAK,CAAC;MAAE;MAAY;KAAG,CAAC,IAAI,CAAC;IACtC,CAAC;GACH;GAEA,AADA,IAAWH,EAAI,YAAY,KAAK,UAAUE,CAAI,GAC9CA,EAAK;EACP;SAEAG,QAAgB;GAEd,AADAN,EAAM,GACNO,EAAM;UAAOf,EAAM;UAAaA,EAAM;UAAYA,EAAM;GAAiB,GAAGQ,CAAK;EACnF,CAAC,GAEDQ,EAAgBT,CAAI,cAIFU,EAAA,GAAAC,EAAAC,GAAA,MAAA,CAAAlB,EAAA,SAAhBnB,EAAA,GAAAG,EAOWC,GAAA;;GAPa,IAAIe,EAAA;EAC1Bd,GAAAA,CAAAA,EAKM,OALNU,GAKM,CAJJT,EAGOoC,EAAA,QAAA,cAAA;GAHkB,OAAOvB,EAAA;GAAQ,MAAMA,EAAA;EAA9C,SAGO,CAFLd,EAA8C,KAAA,MAA3C,UAAKE,EAAGY,EAAA,OAAI,CAAA,IAAO,wBAAoB,CAAA,GAC1Cd,EAAoD,QAApDW,GAAoDT,EAApBY,EAAA,MAAM,IAAI,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,GAAA,CAAA,IAAA,CAAA,KAAAyB,EAAA,IAAA,EAAA,IAIhD5C,EAAA,EAAA,GAAAC,EAMWC,GAAA,MAAAO,EANWa,EAAA,QAAL,OAAjBtB,EAAA,GAAAG,EAMWC,GAAA;GANqB,KAAK0C,EAAE,WAAW;GAAK,IAAIA,EAAE;EAC3DpC,GAAAA,CAAAA,EAIgBC,GAAA;GAJA,YAAYmC,EAAE;GAAa,SAASA,EAAE;;GACzC,SAAOlC,GAAE,MAAS,CAC3BN,EAA6CoC,EAAA,QAAA,cAA7C7B,EAA6C,EAAA,SAAA,GAAA,GAAbqC,CAAS,CAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkPageCount.js","names":["_sfc_main","InkPageCount_vue_vue_type_script_setup_true_lang_default","InkPageCount_default"],"sources":["../../src/components/InkPageCount.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport { usePage } from '../composables/usePage'\n\nconst { count } = usePage()\nconst text = computed(() => `of ${count.value}`)\n</script>\n\n<template>\n <span class=\"ink-page-count\" data-ink-page-count aria-live=\"polite\">{{ text }}</span>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare const __VLS_export: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
4
|
+
//# sourceMappingURL=InkPageCount.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkPageCount.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkPageCount.vue"],"names":[],"mappings":"AAoCA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { usePage as e } from "../composables/usePage.js";
|
|
2
|
+
import { computed as t, createElementBlock as n, defineComponent as r, openBlock as i, toDisplayString as a } from "vue";
|
|
3
|
+
//#region src/components/InkPageCount.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var o = {
|
|
5
|
+
class: "ink-page-count",
|
|
6
|
+
"data-ink-page-count": "",
|
|
7
|
+
"aria-live": "polite"
|
|
8
|
+
}, s = /*@__PURE__*/ r({
|
|
9
|
+
__name: "InkPageCount",
|
|
10
|
+
setup(r) {
|
|
11
|
+
let { count: s } = e(), c = t(() => `of ${s.value}`);
|
|
12
|
+
return (e, t) => (i(), n("span", o, a(c.value), 1));
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
//#endregion
|
|
16
|
+
export { s as default };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=InkPageCount.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkPageCount.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_toDisplayString","_hoisted_1","InkPageCount_vue_vue_type_script_setup_true_lang_default","usePage","text","computed","count","openBlock","createElementBlock","toDisplayString"],"sources":["../../src/components/InkPageCount.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport { usePage } from '../composables/usePage'\n\nconst { count } = usePage()\nconst text = computed(() => `of ${count.value}`)\n</script>\n\n<template>\n <span class=\"ink-page-count\" data-ink-page-count aria-live=\"polite\">{{ text }}</span>\n</template>\n"],"mappings":";;;;;;;;;;EAKA,IAAM,EAAE,aAAUK,EAAQ,GACpBC,IAAOC,QAAe,MAAMC,EAAM,OAAO;oBAI7CR,EAAA,GAAAC,EAAqF,QAArFE,GAAqFD,EAAdI,EAAA,KAAI,GAAA,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkPageInput.js","names":["_sfc_main","InkPageInput_vue_vue_type_script_setup_true_lang_default","InkPageInput_default"],"sources":["../../src/components/InkPageInput.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref, watch } from 'vue'\n\nimport { usePage } from '../composables/usePage'\n\nconst { current, count, goTo } = usePage()\n// `v-model` on a number input hands back a number once the user types.\nconst draft = ref<string | number>(String(current.value + 1))\nwatch(current, (c) => (draft.value = String(c + 1)))\n\n/** 1-based in the input, 0-based in the viewport. Out of range resets to the current page. */\nfunction commit(): void {\n const n = Number(draft.value)\n if (Number.isInteger(n) && n >= 1 && n <= count.value) goTo(n - 1)\n else draft.value = String(current.value + 1)\n}\n</script>\n\n<template>\n <input\n v-model=\"draft\"\n class=\"ink-page-input\"\n data-ink-page-input\n type=\"number\"\n inputmode=\"numeric\"\n aria-label=\"Page\"\n :min=\"1\"\n :max=\"count\"\n @change=\"commit\"\n @keydown.enter.prevent=\"commit\"\n />\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare const __VLS_export: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
4
|
+
//# sourceMappingURL=InkPageInput.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkPageInput.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkPageInput.vue"],"names":[],"mappings":"AAuEA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { usePage as e } from "../composables/usePage.js";
|
|
2
|
+
import { createElementBlock as t, defineComponent as n, openBlock as r, ref as i, unref as a, vModelText as o, watch as s, withDirectives as c, withKeys as l, withModifiers as u } from "vue";
|
|
3
|
+
//#region src/components/InkPageInput.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var d = ["max", "onKeydown"], f = /*@__PURE__*/ n({
|
|
5
|
+
__name: "InkPageInput",
|
|
6
|
+
setup(n) {
|
|
7
|
+
let { current: f, count: p, goTo: m } = e(), h = i(String(f.value + 1));
|
|
8
|
+
s(f, (e) => h.value = String(e + 1));
|
|
9
|
+
function g() {
|
|
10
|
+
let e = Number(h.value);
|
|
11
|
+
Number.isInteger(e) && e >= 1 && e <= p.value ? m(e - 1) : h.value = String(f.value + 1);
|
|
12
|
+
}
|
|
13
|
+
return (e, n) => c((r(), t("input", {
|
|
14
|
+
"onUpdate:modelValue": n[0] ||= (e) => h.value = e,
|
|
15
|
+
class: "ink-page-input",
|
|
16
|
+
"data-ink-page-input": "",
|
|
17
|
+
type: "number",
|
|
18
|
+
inputmode: "numeric",
|
|
19
|
+
"aria-label": "Page",
|
|
20
|
+
min: 1,
|
|
21
|
+
max: a(p),
|
|
22
|
+
onChange: g,
|
|
23
|
+
onKeydown: l(u(g, ["prevent"]), ["enter"])
|
|
24
|
+
}, null, 40, d)), [[o, h.value]]);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
//#endregion
|
|
28
|
+
export { f as default };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=InkPageInput.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkPageInput.vue_vue_type_script_setup_true_lang.js","names":["_withDirectives","_openBlock","_createElementBlock","_unref","_withKeys","_withModifiers","_vModelText","_hoisted_1","InkPageInput_vue_vue_type_script_setup_true_lang_default","usePage","draft","ref","current","c","commit","n","count","goTo","withDirectives","openBlock","createElementBlock","_cache","$event","unref","withKeys","withModifiers","vModelText"],"sources":["../../src/components/InkPageInput.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref, watch } from 'vue'\n\nimport { usePage } from '../composables/usePage'\n\nconst { current, count, goTo } = usePage()\n// `v-model` on a number input hands back a number once the user types.\nconst draft = ref<string | number>(String(current.value + 1))\nwatch(current, (c) => (draft.value = String(c + 1)))\n\n/** 1-based in the input, 0-based in the viewport. Out of range resets to the current page. */\nfunction commit(): void {\n const n = Number(draft.value)\n if (Number.isInteger(n) && n >= 1 && n <= count.value) goTo(n - 1)\n else draft.value = String(current.value + 1)\n}\n</script>\n\n<template>\n <input\n v-model=\"draft\"\n class=\"ink-page-input\"\n data-ink-page-input\n type=\"number\"\n inputmode=\"numeric\"\n aria-label=\"Page\"\n :min=\"1\"\n :max=\"count\"\n @change=\"commit\"\n @keydown.enter.prevent=\"commit\"\n />\n</template>\n"],"mappings":";;;;;;EAKA,IAAM,EAAE,YAAS,UAAO,YAASS,EAAQ,GAEnCC,IAAQC,EAAqB,OAAOC,EAAQ,QAAQ,CAAC,CAAC;EAC5D,EAAMA,IAAU,MAAO,EAAM,QAAQ,OAAOC,IAAI,CAAC,CAAE;EAGnD,SAASC,IAAe;GACtB,IAAMC,IAAI,OAAOL,EAAM,KAAK;GAC5B,AAAI,OAAO,UAAUK,CAAC,KAAKA,KAAK,KAAKA,KAAKC,EAAM,QAAOC,EAAKF,IAAI,CAAC,IAC5D,EAAM,QAAQ,OAAOH,EAAQ,QAAQ,CAAC;EAC7C;mBAIEZ,GAAAC,EAAA,GAAAC,EAWE,SAAA;GAVS,uBAAA,AAAAmB,EAAA,QAAA,MAAA,EAAK,QAAAC;GACd,OAAM;GACN,uBAAA;GACA,MAAK;GACL,WAAU;GACV,cAAW;GACV,KAAK;GACL,KAAKnB,EAAAa,CAAA;GACL,UAAQF;GACR,WAAOV,EAAAC,EAAgBS,GAAM,CAAA,SAAA,CAAA,GAAA,CAAA,OAAA,CAAA;EATrB,GAAA,MAAA,IAAAP,CAAA,IAAA,CAAA,CAAAD,GAAAI,EAAA,KAAK,CAAA,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkPrevPage.js","names":["_sfc_main","InkPrevPage_vue_vue_type_script_setup_true_lang_default","InkPrevPage_default"],"sources":["../../src/components/InkPrevPage.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ChevronLeft } from '@inkbar/icons'\nimport { ToolbarButton } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport { usePage } from '../composables/usePage'\n\nimport InkIcon from './InkIcon.vue'\n\nwithDefaults(defineProps<{ asChild?: boolean }>(), { asChild: false })\nconst { current, previous } = usePage()\nconst disabled = computed(() => current.value <= 0)\n// Reka's typed props stop at its own; ARIA and listeners go through a bound object.\nconst attrs = {\n 'aria-label': 'Previous page',\n title: 'Previous page',\n onClick: () => previous(),\n}\n</script>\n\n<template>\n <ToolbarButton\n :as-child=\"asChild\"\n :disabled=\"disabled\"\n class=\"ink-prev-page\"\n data-ink-prev-page\n v-bind=\"attrs\"\n >\n <slot><InkIcon :icon=\"ChevronLeft\" /></slot>\n </ToolbarButton>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
asChild?: boolean;
|
|
3
|
+
};
|
|
4
|
+
declare var __VLS_7: {};
|
|
5
|
+
type __VLS_Slots = {} & {
|
|
6
|
+
default?: (props: typeof __VLS_7) => any;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
9
|
+
asChild: boolean;
|
|
10
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
11
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
14
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
15
|
+
new (): {
|
|
16
|
+
$slots: S;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=InkPrevPage.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkPrevPage.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkPrevPage.vue"],"names":[],"mappings":"AA0CA,KAAK,WAAW,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAwDzC,QAAA,IAAI,OAAO,IAAW,CAAC;AACvB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAG/C,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,33 @@
|
|
|
1
|
+
import { usePage as e } from "../composables/usePage.js";
|
|
2
|
+
import t from "./InkIcon.js";
|
|
3
|
+
import { computed as n, createBlock as r, createVNode as i, defineComponent as a, mergeProps as o, openBlock as s, renderSlot as c, unref as l, withCtx as u } from "vue";
|
|
4
|
+
import { ToolbarButton as d } from "reka-ui";
|
|
5
|
+
import { ChevronLeft as f } from "@inkbar/icons";
|
|
6
|
+
//#region src/components/InkPrevPage.vue?vue&type=script&setup=true&lang.ts
|
|
7
|
+
var p = /*@__PURE__*/ a({
|
|
8
|
+
__name: "InkPrevPage",
|
|
9
|
+
props: { asChild: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: !1
|
|
12
|
+
} },
|
|
13
|
+
setup(a) {
|
|
14
|
+
let { current: p, previous: m } = e(), h = n(() => p.value <= 0), g = {
|
|
15
|
+
"aria-label": "Previous page",
|
|
16
|
+
title: "Previous page",
|
|
17
|
+
onClick: () => m()
|
|
18
|
+
};
|
|
19
|
+
return (e, n) => (s(), r(l(d), o({
|
|
20
|
+
"as-child": a.asChild,
|
|
21
|
+
disabled: h.value,
|
|
22
|
+
class: "ink-prev-page",
|
|
23
|
+
"data-ink-prev-page": ""
|
|
24
|
+
}, g), {
|
|
25
|
+
default: u(() => [c(e.$slots, "default", {}, () => [i(t, { icon: l(f) }, null, 8, ["icon"])])]),
|
|
26
|
+
_: 3
|
|
27
|
+
}, 16, ["as-child", "disabled"]));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
//#endregion
|
|
31
|
+
export { p as default };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=InkPrevPage.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkPrevPage.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_mergeProps","_withCtx","_renderSlot","_createVNode","InkIcon","InkIcon_default","InkPrevPage_vue_vue_type_script_setup_true_lang_default","usePage","disabled","computed","current","attrs","previous","openBlock","createBlock","unref","ToolbarButton","mergeProps","__props","withCtx","renderSlot","_ctx","createVNode","ChevronLeft"],"sources":["../../src/components/InkPrevPage.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ChevronLeft } from '@inkbar/icons'\nimport { ToolbarButton } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport { usePage } from '../composables/usePage'\n\nimport InkIcon from './InkIcon.vue'\n\nwithDefaults(defineProps<{ asChild?: boolean }>(), { asChild: false })\nconst { current, previous } = usePage()\nconst disabled = computed(() => current.value <= 0)\n// Reka's typed props stop at its own; ARIA and listeners go through a bound object.\nconst attrs = {\n 'aria-label': 'Previous page',\n title: 'Previous page',\n onClick: () => previous(),\n}\n</script>\n\n<template>\n <ToolbarButton\n :as-child=\"asChild\"\n :disabled=\"disabled\"\n class=\"ink-prev-page\"\n data-ink-prev-page\n v-bind=\"attrs\"\n >\n <slot><InkIcon :icon=\"ChevronLeft\" /></slot>\n </ToolbarButton>\n</template>\n"],"mappings":";;;;;;;;;;;;;EAUA,IAAM,EAAE,YAAS,gBAAaU,EAAQ,GAChCC,IAAWC,QAAeC,EAAQ,SAAS,CAAC,GAE5CC,IAAQ;GACZ,cAAc;GACd,OAAO;GACP,eAAeC,EAAS;EAC1B;oBAIEf,EAAA,GAAAC,EAQgBC,EAAAiB,CAAA,GARhBhB,EAQgB;GAPb,YAAUkB,EAAA;GACV,UAAUV,EAAA;GACX,OAAM;GACN,sBAAA;EACQ,GAAAG,CAAK,GAAA;GAEb,SAAAV,QAA4C,CAA5CC,EAA4CmB,EAAA,QAAA,WAAA,CAAA,SAAA,CAAtClB,EAA+BC,GAAA,EAArB,MAAML,EAAAwB,CAAA,EAAW,GAAA,MAAA,GAAA,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkRedo.js","names":["_sfc_main","InkRedo_vue_vue_type_script_setup_true_lang_default","InkRedo_default"],"sources":["../../src/components/InkRedo.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Redo2 } from '@inkbar/icons'\nimport { ToolbarButton } from 'reka-ui'\n\nimport { useHistory } from '../composables/useHistory'\n\nimport InkIcon from './InkIcon.vue'\n\nwithDefaults(defineProps<{ asChild?: boolean }>(), { asChild: false })\nconst { canRedo, redo } = useHistory()\n// Reka's typed props stop at its own; ARIA and listeners go through a bound object.\nconst attrs = {\n 'aria-label': 'Redo',\n title: 'Redo',\n onClick: () => redo(),\n}\n</script>\n\n<template>\n <ToolbarButton\n :as-child=\"asChild\"\n :disabled=\"!canRedo\"\n class=\"ink-redo\"\n data-ink-redo\n v-bind=\"attrs\"\n >\n <slot><InkIcon :icon=\"Redo2\" /></slot>\n </ToolbarButton>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
asChild?: boolean;
|
|
3
|
+
};
|
|
4
|
+
declare var __VLS_7: {};
|
|
5
|
+
type __VLS_Slots = {} & {
|
|
6
|
+
default?: (props: typeof __VLS_7) => any;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
9
|
+
asChild: boolean;
|
|
10
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
11
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
14
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
15
|
+
new (): {
|
|
16
|
+
$slots: S;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=InkRedo.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkRedo.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkRedo.vue"],"names":[],"mappings":"AAuCA,KAAK,WAAW,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAyDzC,QAAA,IAAI,OAAO,IAAW,CAAC;AACvB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAG/C,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,33 @@
|
|
|
1
|
+
import { useHistory as e } from "../composables/useHistory.js";
|
|
2
|
+
import t from "./InkIcon.js";
|
|
3
|
+
import { createBlock as n, createVNode as r, defineComponent as i, mergeProps as a, openBlock as o, renderSlot as s, unref as c, withCtx as l } from "vue";
|
|
4
|
+
import { ToolbarButton as u } from "reka-ui";
|
|
5
|
+
import { Redo2 as d } from "@inkbar/icons";
|
|
6
|
+
//#region src/components/InkRedo.vue?vue&type=script&setup=true&lang.ts
|
|
7
|
+
var f = /*@__PURE__*/ i({
|
|
8
|
+
__name: "InkRedo",
|
|
9
|
+
props: { asChild: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: !1
|
|
12
|
+
} },
|
|
13
|
+
setup(i) {
|
|
14
|
+
let { canRedo: f, redo: p } = e(), m = {
|
|
15
|
+
"aria-label": "Redo",
|
|
16
|
+
title: "Redo",
|
|
17
|
+
onClick: () => p()
|
|
18
|
+
};
|
|
19
|
+
return (e, p) => (o(), n(c(u), a({
|
|
20
|
+
"as-child": i.asChild,
|
|
21
|
+
disabled: !c(f),
|
|
22
|
+
class: "ink-redo",
|
|
23
|
+
"data-ink-redo": ""
|
|
24
|
+
}, m), {
|
|
25
|
+
default: l(() => [s(e.$slots, "default", {}, () => [r(t, { icon: c(d) }, null, 8, ["icon"])])]),
|
|
26
|
+
_: 3
|
|
27
|
+
}, 16, ["as-child", "disabled"]));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
//#endregion
|
|
31
|
+
export { f as default };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=InkRedo.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkRedo.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_mergeProps","_withCtx","_renderSlot","_createVNode","InkIcon","InkIcon_default","InkRedo_vue_vue_type_script_setup_true_lang_default","useHistory","attrs","redo","openBlock","createBlock","unref","ToolbarButton","mergeProps","__props","canRedo","withCtx","renderSlot","_ctx","createVNode","Redo2"],"sources":["../../src/components/InkRedo.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Redo2 } from '@inkbar/icons'\nimport { ToolbarButton } from 'reka-ui'\n\nimport { useHistory } from '../composables/useHistory'\n\nimport InkIcon from './InkIcon.vue'\n\nwithDefaults(defineProps<{ asChild?: boolean }>(), { asChild: false })\nconst { canRedo, redo } = useHistory()\n// Reka's typed props stop at its own; ARIA and listeners go through a bound object.\nconst attrs = {\n 'aria-label': 'Redo',\n title: 'Redo',\n onClick: () => redo(),\n}\n</script>\n\n<template>\n <ToolbarButton\n :as-child=\"asChild\"\n :disabled=\"!canRedo\"\n class=\"ink-redo\"\n data-ink-redo\n v-bind=\"attrs\"\n >\n <slot><InkIcon :icon=\"Redo2\" /></slot>\n </ToolbarButton>\n</template>\n"],"mappings":";;;;;;;;;;;;;EASA,IAAM,EAAE,YAAS,YAASU,EAAW,GAE/BC,IAAQ;GACZ,cAAc;GACd,OAAO;GACP,eAAeC,EAAK;EACtB;oBAIEZ,EAAA,GAAAC,EAQgBC,EAAAc,CAAA,GARhBb,EAQgB;GAPb,YAAUe,EAAA;GACV,UAAQ,CAAGhB,EAAAiB,CAAA;GACZ,OAAM;GACN,iBAAA;EACQ,GAAAR,CAAK,GAAA;GAEb,SAAAP,QAAsC,CAAtCC,EAAsCiB,EAAA,QAAA,WAAA,CAAA,SAAA,CAAhChB,EAAyBC,GAAA,EAAf,MAAML,EAAAsB,CAAA,EAAK,GAAA,MAAA,GAAA,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkRoot.js","names":["_sfc_main","InkRoot_vue_vue_type_script_setup_true_lang_default","InkRoot_default"],"sources":["../../src/components/InkRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { InkError, openDocument } from '@inkbar/core'\nimport { cssVariableDefaults } from '@inkbar/core/dom'\nimport { Primitive } from 'reka-ui'\nimport {\n computed,\n onBeforeUnmount,\n onMounted,\n onUpdated,\n ref,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { provideInkContext, type InkHistory, type InkStatus } from '../context'\nimport { createRefHistory } from '../ref-history'\nimport { useReadable } from '../use-readable'\n\nimport type {\n Annotation,\n AnnotationChange,\n AnnotationDefaults,\n DocumentSource,\n InkDocument,\n PdfAssets,\n} from '@inkbar/core'\nimport type { ToolController, ToolId, Viewport, ZoomValue } from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{\n src: DocumentSource | null\n assets: PdfAssets\n password?: string | undefined\n /** Colour defaults. Without it, the theme's CSS variables on the root element apply. */\n defaults?: AnnotationDefaults | undefined\n /**\n * Pass (with v-model) to put annotations under the host's control. The mode is fixed when a\n * document opens: passing or dropping this prop later takes effect on the next open.\n */\n annotations?: Annotation[] | undefined\n tool?: ToolId | undefined\n page?: number | undefined\n zoom?: ZoomValue | undefined\n /** Undo history. Defaults to on for uncontrolled, off for controlled. */\n history?: boolean | undefined\n asChild?: boolean\n }>(),\n {\n password: undefined,\n defaults: undefined,\n annotations: undefined,\n tool: undefined,\n page: undefined,\n zoom: undefined,\n history: undefined,\n asChild: false,\n }\n)\n\nconst emit = defineEmits<{\n 'update:annotations': [next: Annotation[]]\n change: [change: AnnotationChange]\n 'update:tool': [tool: ToolId]\n 'update:page': [page: number]\n 'update:zoom': [zoom: ZoomValue]\n ready: [doc: InkDocument]\n error: [error: InkError]\n activate: [id: string]\n}>()\n\ntype TestHookElement = HTMLElement & { __inkDocument?: InkDocument | undefined }\n\n// A template ref on Primitive is a component instance; the context needs its element.\nconst primitive = useTemplateRef<{ $el: unknown }>('primitive')\nconst rootEl = shallowRef<HTMLElement | null>(null)\nfunction syncRootEl(): void {\n const el = primitive.value?.$el\n rootEl.value = el instanceof HTMLElement ? el : null\n}\n\nconst document = shallowRef<InkDocument | null>(null)\n/** Overrides the document's status while opening, and when opening itself failed. */\nconst override = shallowRef<InkStatus | null>(null)\nconst idle: InkStatus = { state: 'idle' }\nconst documentStatus = useReadable<InkStatus>(() => document.value?.status ?? null, idle)\nconst status = computed<InkStatus>(() => override.value ?? documentStatus.value)\nconst annotationList = useReadable<readonly Annotation[]>(\n () => document.value?.annotations.list ?? null,\n []\n)\nconst selection = useReadable<readonly string[]>(\n () => document.value?.annotations.selection ?? null,\n []\n)\nconst viewport = shallowRef<Viewport | null>(null)\nconst tools = shallowRef<ToolController | null>(null)\nconst internalTool = ref<ToolId>(props.tool ?? 'view')\nconst activated = ref<string | null>(null)\n\nconst controlled = computed(() => props.annotations !== undefined)\n\n/** Signed URLs change; the key does not. Bytes and Blobs are their own identity. */\nfunction identity(src: DocumentSource | null): unknown {\n if (src === null) return null\n if (typeof src === 'string') return src\n if ('key' in src) return src.key\n return src\n}\n\nfunction setTestHook(doc: InkDocument | undefined): void {\n if (import.meta.env.DEV && rootEl.value)\n (rootEl.value as TestHookElement).__inkDocument = doc\n}\n\nlet generation = 0\nfunction release(): void {\n document.value?.destroy()\n document.value = null\n setTestHook(undefined)\n}\n\nasync function open(): Promise<void> {\n const gen = ++generation\n const src = props.src\n release()\n refHistory.clear()\n if (src === null) {\n override.value = null\n return\n }\n override.value = { state: 'loading' }\n syncRootEl()\n let doc: InkDocument\n try {\n doc = await openDocument(src, {\n assets: props.assets,\n password: props.password,\n defaults:\n props.defaults ?? (rootEl.value ? cssVariableDefaults(rootEl.value) : undefined),\n // Controlled hosts get the ref history below; core's own stack stays off.\n history: controlled.value ? false : (props.history ?? true),\n annotations: controlled.value\n ? {\n mode: 'controlled',\n initial: props.annotations ?? [],\n onChange: (next, change) => {\n emit('update:annotations', next)\n emit('change', change)\n },\n }\n : { mode: 'uncontrolled' },\n })\n } catch (cause) {\n if (gen !== generation) return\n const error =\n cause instanceof InkError\n ? cause\n : new InkError(\n 'InvalidPdf',\n cause instanceof Error ? cause.message : String(cause),\n {},\n cause\n )\n override.value = { state: 'error', error }\n emit('error', error)\n return\n }\n if (gen !== generation) {\n doc.destroy()\n return\n }\n // The prop may have changed while the file loaded, when there was no store to apply it to.\n if (doc.annotations.mode === 'controlled' && props.annotations !== undefined)\n doc.annotations.setControlledValue(props.annotations)\n document.value = doc\n override.value = null\n setTestHook(doc)\n const s = doc.status.get()\n if (s.state === 'ready') emit('ready', doc)\n else if (s.state === 'error') emit('error', s.error)\n}\n\nconst refHistory = createRefHistory({\n source: () => props.annotations,\n apply: (list) => document.value?.annotations.replaceAll(list, 'history'),\n enabled: computed(() => controlled.value && props.history === true),\n})\nconst coreCanUndo = useReadable(() => document.value?.history.canUndo ?? null, false)\nconst coreCanRedo = useReadable(() => document.value?.history.canRedo ?? null, false)\nconst inkHistory: InkHistory = {\n canUndo: computed(() =>\n controlled.value ? refHistory.canUndo.value : coreCanUndo.value\n ),\n canRedo: computed(() =>\n controlled.value ? refHistory.canRedo.value : coreCanRedo.value\n ),\n undo: () => (controlled.value ? refHistory.undo() : document.value?.history.undo()),\n redo: () => (controlled.value ? refHistory.redo() : document.value?.history.redo()),\n clear: () => (controlled.value ? refHistory.clear() : document.value?.history.clear()),\n batch: (fn) => {\n if (controlled.value) refHistory.batch(fn)\n else if (document.value) document.value.history.batch(fn)\n else fn()\n },\n}\n\n// Open on the client only: on the server InkRoot renders its empty slot.\nonMounted(() => {\n syncRootEl()\n void open()\n})\nonUpdated(syncRootEl)\n\n// Separate sources, so a new `{ url, key }` object with the same key compares equal.\nwatch([() => identity(props.src), () => props.password], () => void open())\n\nwatch(\n () => props.annotations,\n (next) => {\n if (next && document.value?.annotations.mode === 'controlled')\n document.value.annotations.setControlledValue(next)\n }\n)\n\nwatch(\n () => props.tool,\n (t) => {\n if (t) internalTool.value = t\n }\n)\n\nfunction setTool(id: ToolId): void {\n internalTool.value = id\n emit('update:tool', id)\n}\n\nonBeforeUnmount(() => {\n generation++\n release()\n})\n\nprovideInkContext({\n assets: computed(() => props.assets),\n document,\n status,\n annotations: annotationList,\n selection,\n viewport,\n tools,\n tool: internalTool,\n setTool,\n zoomModel: computed(() => props.zoom),\n pageModel: computed(() => props.page),\n reportZoom: (z) => emit('update:zoom', z),\n reportPage: (p) => emit('update:page', p),\n activated,\n setActivated(id) {\n activated.value = id\n if (id) emit('activate', id)\n },\n history: inkHistory,\n rootEl,\n})\n\n// `history` is what `useHistory()` returns inside the root, for hosts that hold a template ref:\n// a controlled host calls `history.clear()` after loading its saved list.\ndefineExpose({ document, status, rootEl, history: inkHistory })\n</script>\n\n<template>\n <Primitive\n ref=\"primitive\"\n :as-child=\"props.asChild\"\n as=\"div\"\n data-ink-root\n :data-state=\"status.state\"\n >\n <slot :status=\"status\" :document=\"document\" />\n </Primitive>\n</template>\n"],"mappings":""}
|