@inkbar/vue 0.7.0 → 0.9.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/README.md +14 -2
- package/dist/components/InkFormAlert.js +7 -0
- package/dist/components/InkFormAlert.js.map +1 -0
- package/dist/components/InkFormAlert.vue.d.ts +16 -0
- package/dist/components/InkFormAlert.vue.d.ts.map +1 -0
- package/dist/components/InkFormAlert.vue_vue_type_script_setup_true_lang.js +90 -0
- package/dist/components/InkFormAlert.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkHighlightMenu.js.map +1 -1
- package/dist/components/InkHighlightMenu.vue.d.ts.map +1 -1
- package/dist/components/InkHighlightMenu.vue_vue_type_script_setup_true_lang.js +67 -65
- package/dist/components/InkHighlightMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkRoot.js.map +1 -1
- package/dist/components/InkRoot.vue.d.ts +24 -5
- package/dist/components/InkRoot.vue.d.ts.map +1 -1
- package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js +197 -148
- package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkShapeMenu.js.map +1 -1
- package/dist/components/InkShapeMenu.vue.d.ts.map +1 -1
- package/dist/components/InkShapeMenu.vue_vue_type_script_setup_true_lang.js +58 -56
- package/dist/components/InkShapeMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkSignFieldPopover.js +7 -0
- package/dist/components/InkSignFieldPopover.js.map +1 -0
- package/dist/components/InkSignFieldPopover.vue.d.ts +13 -0
- package/dist/components/InkSignFieldPopover.vue.d.ts.map +1 -0
- package/dist/components/InkSignFieldPopover.vue_vue_type_script_setup_true_lang.js +116 -0
- package/dist/components/InkSignFieldPopover.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkSignatureDialog.js.map +1 -1
- package/dist/components/InkSignatureDialog.vue.d.ts +10 -1
- package/dist/components/InkSignatureDialog.vue.d.ts.map +1 -1
- package/dist/components/InkSignatureDialog.vue_vue_type_script_setup_true_lang.js +9 -2
- package/dist/components/InkSignatureDialog.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkSignatureMenu.js.map +1 -1
- package/dist/components/InkSignatureMenu.vue.d.ts.map +1 -1
- package/dist/components/InkSignatureMenu.vue_vue_type_script_setup_true_lang.js +69 -154
- package/dist/components/InkSignatureMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkToolButton.js.map +1 -1
- package/dist/components/InkToolButton.vue.d.ts.map +1 -1
- package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js +39 -36
- package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkToolbarButton.js +7 -0
- package/dist/components/InkToolbarButton.js.map +1 -0
- package/dist/components/InkToolbarButton.vue.d.ts +22 -0
- package/dist/components/InkToolbarButton.vue.d.ts.map +1 -0
- package/dist/components/InkToolbarButton.vue_vue_type_script_setup_true_lang.js +32 -0
- package/dist/components/InkToolbarButton.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkViewport.js.map +1 -1
- package/dist/components/InkViewport.vue.d.ts.map +1 -1
- package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js +123 -91
- package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/SignatureForm.js.map +1 -1
- package/dist/components/SignatureForm.vue.d.ts +5 -1
- package/dist/components/SignatureForm.vue.d.ts.map +1 -1
- package/dist/components/SignatureForm.vue_vue_type_script_setup_true_lang.js +64 -57
- package/dist/components/SignatureForm.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/SignatureMenuPanel.js +7 -0
- package/dist/components/SignatureMenuPanel.js.map +1 -0
- package/dist/components/SignatureMenuPanel.vue.d.ts +15 -0
- package/dist/components/SignatureMenuPanel.vue.d.ts.map +1 -0
- package/dist/components/SignatureMenuPanel.vue_vue_type_script_setup_true_lang.js +116 -0
- package/dist/components/SignatureMenuPanel.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/composables/useForm.d.ts +18 -0
- package/dist/composables/useForm.d.ts.map +1 -0
- package/dist/composables/useForm.js +17 -0
- package/dist/composables/useForm.js.map +1 -0
- package/dist/composables/useRegisteredTool.d.ts +21 -0
- package/dist/composables/useRegisteredTool.d.ts.map +1 -0
- package/dist/composables/useRegisteredTool.js +25 -0
- package/dist/composables/useRegisteredTool.js.map +1 -0
- package/dist/composables/useToolOptions.d.ts +8 -0
- package/dist/composables/useToolOptions.d.ts.map +1 -1
- package/dist/composables/useToolOptions.js +10 -5
- package/dist/composables/useToolOptions.js.map +1 -1
- package/dist/context.d.ts +12 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -27
- package/package.json +5 -5
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { useInkContext as e } from "../context.js";
|
|
2
|
-
import {
|
|
3
|
-
import n from "
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { useRegisteredTool as t } from "../composables/useRegisteredTool.js";
|
|
3
|
+
import { useTool as n } from "../composables/useTool.js";
|
|
4
|
+
import r from "./InkIcon.js";
|
|
5
|
+
import { computed as i, createBlock as a, createCommentVNode as o, defineComponent as s, mergeProps as c, openBlock as l, renderSlot as u, unref as d, useAttrs as f, withCtx as p } from "vue";
|
|
6
|
+
import { TOOL_LABELS as m, withHostTools as h } from "@inkbar/core/dom";
|
|
7
|
+
import { ToolbarButton as g } from "reka-ui";
|
|
8
|
+
import { SquareDashedMousePointer as _, TextCursor as v } from "@inkbar/icons";
|
|
8
9
|
//#region src/components/InkToolButton.vue?vue&type=script&setup=true&lang.ts
|
|
9
|
-
var
|
|
10
|
+
var y = /*@__PURE__*/ s({
|
|
11
|
+
inheritAttrs: !1,
|
|
10
12
|
__name: "InkToolButton",
|
|
11
13
|
props: {
|
|
12
14
|
tool: {},
|
|
@@ -16,37 +18,38 @@ var C = /*@__PURE__*/ o({
|
|
|
16
18
|
default: !1
|
|
17
19
|
}
|
|
18
20
|
},
|
|
19
|
-
setup(
|
|
20
|
-
let
|
|
21
|
-
"select-text":
|
|
22
|
-
select:
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"aria-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
21
|
+
setup(s) {
|
|
22
|
+
let y = {
|
|
23
|
+
"select-text": v,
|
|
24
|
+
select: _
|
|
25
|
+
}, b = s, x = e("InkToolButton"), { tool: S, setTool: C } = n(), w = i(() => S.value === b.tool), T = t(() => b.tool), E = i(() => h([...x.hostTools.value ?? [], ...x.pluginHost.value?.tools ?? []]).find((e) => e.id === b.tool)), D = i(() => b.label ?? m[b.tool] ?? E.value?.label ?? b.tool), O = i(() => y[b.tool] ?? E.value?.icon), k = f(), A = () => T.value ? c({
|
|
26
|
+
"aria-pressed": String(w.value),
|
|
27
|
+
"aria-label": D.value,
|
|
28
|
+
title: D.value,
|
|
29
|
+
onClick: () => C(b.tool)
|
|
30
|
+
}, k) : {
|
|
31
|
+
...k,
|
|
32
|
+
"aria-hidden": "true",
|
|
33
|
+
disabled: !0,
|
|
34
|
+
"aria-pressed": void 0,
|
|
35
|
+
"aria-label": void 0,
|
|
36
|
+
title: void 0,
|
|
37
|
+
onClick: void 0
|
|
38
|
+
};
|
|
39
|
+
return (e, t) => (l(), a(d(g), c({
|
|
40
|
+
"as-child": s.asChild,
|
|
38
41
|
class: "ink-tool-button",
|
|
39
42
|
"data-ink-tool-button": "",
|
|
40
|
-
"data-tool":
|
|
41
|
-
"data-state":
|
|
42
|
-
},
|
|
43
|
-
default:
|
|
44
|
-
active:
|
|
45
|
-
label:
|
|
46
|
-
}, () => [
|
|
43
|
+
"data-tool": s.tool,
|
|
44
|
+
"data-state": w.value ? "on" : "off"
|
|
45
|
+
}, A()), {
|
|
46
|
+
default: p(() => [d(T) ? u(e.$slots, "default", {
|
|
47
|
+
active: w.value,
|
|
48
|
+
label: D.value
|
|
49
|
+
}, () => [O.value ? (l(), a(r, {
|
|
47
50
|
key: 0,
|
|
48
|
-
icon:
|
|
49
|
-
}, null, 8, ["icon"])) :
|
|
51
|
+
icon: O.value
|
|
52
|
+
}, null, 8, ["icon"])) : o("", !0)], void 0, 0) : o("", !0)]),
|
|
50
53
|
_: 3
|
|
51
54
|
}, 16, [
|
|
52
55
|
"as-child",
|
|
@@ -56,6 +59,6 @@ var C = /*@__PURE__*/ o({
|
|
|
56
59
|
}
|
|
57
60
|
});
|
|
58
61
|
//#endregion
|
|
59
|
-
export {
|
|
62
|
+
export { y as default };
|
|
60
63
|
|
|
61
64
|
//# sourceMappingURL=InkToolButton.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InkToolButton.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_mergeProps","_withCtx","_renderSlot","InkIcon","_createCommentVNode","InkIcon_default","InkToolButton_vue_vue_type_script_setup_true_lang_default","ICONS","TextCursor","SquareDashedMousePointer","
|
|
1
|
+
{"version":3,"file":"InkToolButton.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_mergeProps","_withCtx","_renderSlot","InkIcon","_createCommentVNode","InkIcon_default","InkToolButton_vue_vue_type_script_setup_true_lang_default","ICONS","TextCursor","SquareDashedMousePointer","props","__props","ctx","useInkContext","current","useTool","active","computed","registered","useRegisteredTool","own","withHostTools","t","name","TOOL_LABELS","icon","hostAttrs","useAttrs","bound","mergeProps","setTool","openBlock","createBlock","unref","ToolbarButton","withCtx","renderSlot","_ctx","createCommentVNode"],"sources":["../../src/components/InkToolButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { TOOL_LABELS, withHostTools } from '@inkbar/core/dom'\nimport { SquareDashedMousePointer, TextCursor } from '@inkbar/icons'\nimport { ToolbarButton } from 'reka-ui'\nimport { computed, mergeProps, useAttrs } from 'vue'\n\nimport { useRegisteredTool } from '../composables/useRegisteredTool'\nimport { useTool } from '../composables/useTool'\nimport { useInkContext } from '../context'\n\nimport InkIcon from './InkIcon.vue'\n\nimport type { ToolId } from '@inkbar/core/dom'\nimport type { IconNode } from '@inkbar/icons'\n\nconst ICONS: Readonly<Partial<Record<ToolId, IconNode>>> = {\n 'select-text': TextCursor,\n select: SquareDashedMousePointer,\n}\n\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{ tool: ToolId; label?: string | undefined; asChild?: boolean }>(),\n { label: undefined, asChild: false }\n)\n\nconst ctx = useInkContext('InkToolButton')\nconst { tool: current, setTool } = useTool()\nconst active = computed(() => current.value === props.tool)\nconst registered = useRegisteredTool(() => props.tool)\n/** The registered tool by this id, for the name and icon core has none for. */\nconst own = computed(() =>\n withHostTools([\n ...(ctx.hostTools.value ?? []),\n ...(ctx.pluginHost.value?.tools ?? []),\n ]).find((t) => t.id === props.tool)\n)\n// `label` and the slot win; then core's name and icon; then the tool's own.\nconst name = computed(\n () => props.label ?? TOOL_LABELS[props.tool] ?? own.value?.label ?? props.tool\n)\nconst icon = computed(() => ICONS[props.tool] ?? own.value?.icon)\n// Reka's typed props stop at its own; ARIA and listeners go through a bound object. A tool\n// nobody registered leaves the button disabled, hidden from assistive tech and unnamed.\nconst hostAttrs = useAttrs()\n// A function, not a computed: `useAttrs()` is not reactive, so the render reads it afresh.\nconst bound = () =>\n registered.value\n ? mergeProps(\n {\n 'aria-pressed': String(active.value),\n 'aria-label': name.value,\n title: name.value,\n onClick: () => setTool(props.tool),\n },\n hostAttrs\n )\n : {\n ...hostAttrs,\n 'aria-hidden': 'true' as const,\n disabled: true,\n 'aria-pressed': undefined,\n 'aria-label': undefined,\n title: undefined,\n onClick: undefined,\n }\n</script>\n\n<template>\n <ToolbarButton\n :as-child=\"asChild\"\n class=\"ink-tool-button\"\n data-ink-tool-button\n :data-tool=\"tool\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"bound()\"\n >\n <template v-if=\"registered\">\n <slot :active=\"active\" :label=\"name\"><InkIcon v-if=\"icon\" :icon=\"icon\" /></slot>\n </template>\n </ToolbarButton>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAeA,IAAMU,IAAqD;GACzD,eAAeC;GACf,QAAQC;EACV,GAIMC,IAAQC,GAKRC,IAAMC,EAAc,eAAe,GACnC,EAAE,MAAMC,GAAS,eAAYC,EAAQ,GACrCC,IAASC,QAAeH,EAAQ,UAAUJ,EAAM,IAAI,GACpDQ,IAAaC,QAAwBT,EAAM,IAAI,GAE/CU,IAAMH,QACVI,EAAc,CACZ,GAAIT,EAAI,UAAU,SAAS,CAAC,GAC5B,GAAIA,EAAI,WAAW,OAAO,SAAS,CAAC,CACtC,CAAC,CAAC,CAAC,MAAM,MAAMU,EAAE,OAAOZ,EAAM,IAAI,CACpC,GAEMa,IAAON,QACLP,EAAM,SAASc,EAAYd,EAAM,SAASU,EAAI,OAAO,SAASV,EAAM,IAC5E,GACMe,IAAOR,QAAeV,EAAMG,EAAM,SAASU,EAAI,OAAO,IAAI,GAG1DM,IAAYC,EAAS,GAErBC,UACJV,EAAW,QACPW,EACE;GACE,gBAAgB,OAAOb,EAAO,KAAK;GACnC,cAAcO,EAAK;GACnB,OAAOA,EAAK;GACZ,eAAeO,EAAQpB,EAAM,IAAI;EACnC,GACAgB,CACF,IACA;GACE,GAAGA;GACH,eAAe;GACf,UAAU;GACV,gBAAgB,KAAA;GAChB,cAAc,KAAA;GACd,OAAO,KAAA;GACP,SAAS,KAAA;EACX;oBAIJ7B,EAAA,GAAAC,EAWgBC,EAAAmC,CAAA,GAXhBlC,EAWgB;GAVb,YAAUW,EAAA;GACX,OAAM;GACN,wBAAA;GACC,aAAWA,EAAA;GACX,cAAYK,EAAA,QAAM,OAAA;EACX,GAAAY,EAAK,CAAA,GAAA;GAEb,SAAA3B,QAEW,CAFKF,EAAAmB,CAAA,IACdhB,EAAgFmC,EAAA,QAAA,WAAA;IAAzE,QAAQrB,EAAA;IAAS,OAAOO,EAAA;GAA/B,SAAgF,CAA5BE,EAAA,SAAf5B,EAAA,GAAAC,EAAoCK,GAAA;;IAAd,MAAMsB,EAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkToolbarButton.js","names":["_sfc_main","InkToolbarButton_vue_vue_type_script_setup_true_lang_default","InkToolbarButton_default"],"sources":["../../src/components/InkToolbarButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * Your own button in an `InkToolbar`. It joins the toolbar's arrow-key focus and takes the\n * theme's toolbar button styles; what it shows and does is up to you. Button attributes and\n * listeners, such as `aria-label` and `@click`, pass through to the button.\n */\nimport { ToolbarButton } from 'reka-ui'\n\nimport type { ButtonHTMLAttributes } from 'vue'\n\ninterface InkToolbarButtonProps extends /* @vue-ignore */ ButtonHTMLAttributes {\n asChild?: boolean\n disabled?: boolean\n}\n\nwithDefaults(defineProps<InkToolbarButtonProps>(), { asChild: false, disabled: false })\n// Reka's typed props stop at its own; plain attributes go through a bound object.\nconst attrs = { type: 'button' }\n</script>\n\n<template>\n <ToolbarButton\n :as-child=\"asChild\"\n :disabled=\"disabled\"\n class=\"ink-toolbar-button\"\n data-ink-toolbar-button\n v-bind=\"attrs\"\n >\n <slot />\n </ToolbarButton>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes } from 'vue';
|
|
2
|
+
interface InkToolbarButtonProps extends /* @vue-ignore */ ButtonHTMLAttributes {
|
|
3
|
+
asChild?: boolean;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare var __VLS_7: {};
|
|
7
|
+
type __VLS_Slots = {} & {
|
|
8
|
+
default?: (props: typeof __VLS_7) => any;
|
|
9
|
+
};
|
|
10
|
+
declare const __VLS_base: import('vue').DefineComponent<InkToolbarButtonProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<InkToolbarButtonProps> & Readonly<{}>, {
|
|
11
|
+
asChild: boolean;
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
17
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
18
|
+
new (): {
|
|
19
|
+
$slots: S;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=InkToolbarButton.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkToolbarButton.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkToolbarButton.vue"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,KAAK,CAAA;AAG/C,UAAU,qBAAsB,SAAQ,iBAAiB,CAAC,oBAAoB;IAC5E,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AA2CD,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,32 @@
|
|
|
1
|
+
import { createBlock as e, defineComponent as t, mergeProps as n, openBlock as r, renderSlot as i, unref as a, withCtx as o } from "vue";
|
|
2
|
+
import { ToolbarButton as s } from "reka-ui";
|
|
3
|
+
//#region src/components/InkToolbarButton.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var c = /*@__PURE__*/ t({
|
|
5
|
+
__name: "InkToolbarButton",
|
|
6
|
+
props: {
|
|
7
|
+
asChild: {
|
|
8
|
+
type: Boolean,
|
|
9
|
+
default: !1
|
|
10
|
+
},
|
|
11
|
+
disabled: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: !1
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
setup(t) {
|
|
17
|
+
let c = { type: "button" };
|
|
18
|
+
return (l, u) => (r(), e(a(s), n({
|
|
19
|
+
"as-child": t.asChild,
|
|
20
|
+
disabled: t.disabled,
|
|
21
|
+
class: "ink-toolbar-button",
|
|
22
|
+
"data-ink-toolbar-button": ""
|
|
23
|
+
}, c), {
|
|
24
|
+
default: o(() => [i(l.$slots, "default")]),
|
|
25
|
+
_: 3
|
|
26
|
+
}, 16, ["as-child", "disabled"]));
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
//#endregion
|
|
30
|
+
export { c as default };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=InkToolbarButton.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkToolbarButton.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_mergeProps","_withCtx","_renderSlot","InkToolbarButton_vue_vue_type_script_setup_true_lang_default","attrs","openBlock","createBlock","unref","ToolbarButton","mergeProps","__props","withCtx","renderSlot","_ctx"],"sources":["../../src/components/InkToolbarButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * Your own button in an `InkToolbar`. It joins the toolbar's arrow-key focus and takes the\n * theme's toolbar button styles; what it shows and does is up to you. Button attributes and\n * listeners, such as `aria-label` and `@click`, pass through to the button.\n */\nimport { ToolbarButton } from 'reka-ui'\n\nimport type { ButtonHTMLAttributes } from 'vue'\n\ninterface InkToolbarButtonProps extends /* @vue-ignore */ ButtonHTMLAttributes {\n asChild?: boolean\n disabled?: boolean\n}\n\nwithDefaults(defineProps<InkToolbarButtonProps>(), { asChild: false, disabled: false })\n// Reka's typed props stop at its own; plain attributes go through a bound object.\nconst attrs = { type: 'button' }\n</script>\n\n<template>\n <ToolbarButton\n :as-child=\"asChild\"\n :disabled=\"disabled\"\n class=\"ink-toolbar-button\"\n data-ink-toolbar-button\n v-bind=\"attrs\"\n >\n <slot />\n </ToolbarButton>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;EAiBA,IAAMO,IAAQ,EAAE,MAAM,SAAS;oBAI7BP,EAAA,GAAAC,EAQgBC,EAAAS,CAAA,GARhBR,EAQgB;GAPb,YAAUU,EAAA;GACV,UAAUA,EAAA;GACX,OAAM;GACN,2BAAA;EACQ,GAAAN,CAAK,GAAA;GAEb,SAAAH,QAAQ,CAARC,EAAQW,EAAA,QAAA,SAAA,CAAA,CAAA"}
|
|
@@ -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 */\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 { injectInkContext } from '../context'\n\nimport InkPage from './InkPage.vue'\n\nimport type { AnnotationSlotProps } from './annotation-slot'\nimport type { InkError } from '@inkbar/core'\nimport type {\n LayoutMode,\n PageMount,\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/** 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/**\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 pages.value = []\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 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 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)\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 </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 }>(),\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InkViewport.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkViewport.vue"],"names":[],"mappings":"
|
|
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;IAC3C,KAAK,CAAC,IAAI,OAAO,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;AAwaF,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"}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import { injectInkContext as e } from "../context.js";
|
|
2
|
-
import t from "
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import { toolIdsOf as t } from "../composables/useRegisteredTool.js";
|
|
3
|
+
import n from "./InkFormAlert.js";
|
|
4
|
+
import r from "./InkPage.js";
|
|
5
|
+
import i from "./InkSignFieldPopover.js";
|
|
6
|
+
import { Fragment as a, computed as o, createBlock as s, createCommentVNode as ee, createElementBlock as c, createElementVNode as l, createSlots as u, createTextVNode as d, createVNode as f, defineComponent as p, mergeProps as m, onBeforeUnmount as h, onBeforeUpdate as g, onMounted as _, openBlock as v, renderList as y, renderSlot as b, shallowRef as x, toDisplayString as S, unref as C, useSlots as w, useTemplateRef as te, watch as T, withCtx as E } from "vue";
|
|
7
|
+
import { mountViewer as D } from "@inkbar/core/dom";
|
|
5
8
|
//#region src/components/InkViewport.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
-
var
|
|
9
|
+
var O = ["data-state"], k = {
|
|
7
10
|
key: 0,
|
|
8
11
|
class: "ink-status",
|
|
9
12
|
role: "status",
|
|
10
13
|
"aria-live": "polite"
|
|
11
|
-
},
|
|
14
|
+
}, A = {
|
|
12
15
|
key: 1,
|
|
13
16
|
class: "ink-status ink-error",
|
|
14
17
|
role: "alert"
|
|
15
|
-
},
|
|
18
|
+
}, j = ["title"], M = {
|
|
16
19
|
key: 2,
|
|
17
20
|
class: "ink-status ink-empty"
|
|
18
|
-
},
|
|
21
|
+
}, N = /*@__PURE__*/ p({
|
|
19
22
|
__name: "InkViewport",
|
|
20
23
|
props: {
|
|
21
24
|
mode: { default: "continuous" },
|
|
@@ -23,131 +26,145 @@ var T = ["data-state"], E = {
|
|
|
23
26
|
gap: { default: 16 },
|
|
24
27
|
buffer: { default: 2 }
|
|
25
28
|
},
|
|
26
|
-
setup(
|
|
27
|
-
let
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
setup(p) {
|
|
30
|
+
let N = p, P = w(), F = e(), I = te("scroll"), L = /* @__PURE__ */ new WeakMap(), R = 0;
|
|
31
|
+
function z(e) {
|
|
32
|
+
if (!e) return 0;
|
|
33
|
+
let t = L.get(e);
|
|
34
|
+
return t === void 0 && (t = ++R, L.set(e, t)), t;
|
|
31
35
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
let B = x([]), V = o(() => F.status.value.state), H = o(() => F.status.value.state === "error" ? F.status.value.error : null), U = x(null), W = x(null), G = x(null), K = x(0), q = 0, J = !1, Y = [], X, Z;
|
|
37
|
+
function Q() {
|
|
38
|
+
for (let e of Y) e();
|
|
39
|
+
Y = [], U.value?.destroy(), U.value = null, F.viewport.value && (F.viewport.value = null), F.tools.value && (F.tools.value = null), F.openedToolIds.value = null, B.value = [], W.value = null, G.value = null;
|
|
35
40
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
function $(e) {
|
|
42
|
+
let t = U.value;
|
|
43
|
+
t && (q += 1, e.customAnnotations !== void 0 && (J = e.customAnnotations), t.rebuild(e));
|
|
44
|
+
}
|
|
45
|
+
function ne() {
|
|
46
|
+
Q(), X = void 0, Z = void 0;
|
|
47
|
+
let e = F.document.value, n = I.value;
|
|
48
|
+
if (!e || !n || F.status.value.state !== "ready") return;
|
|
49
|
+
let r = !0;
|
|
50
|
+
q += 1, J = !!P.annotation, F.openedToolIds.value = t(F.hostTools.value, F.pluginHost.value), U.value = D({
|
|
51
|
+
container: n,
|
|
43
52
|
document: e,
|
|
44
|
-
zoom:
|
|
45
|
-
...
|
|
46
|
-
mode:
|
|
47
|
-
rotation:
|
|
48
|
-
gap:
|
|
49
|
-
buffer:
|
|
50
|
-
tool:
|
|
51
|
-
...
|
|
52
|
-
...
|
|
53
|
-
...
|
|
54
|
-
decorateAnnotation: (e) =>
|
|
55
|
-
...
|
|
56
|
-
toolHistory: { batch: (e) =>
|
|
57
|
-
toolOptions:
|
|
58
|
-
fonts: [...
|
|
59
|
-
signatureLibrary: () =>
|
|
60
|
-
customAnnotations:
|
|
61
|
-
|
|
53
|
+
zoom: F.zoomModel.value ?? "fit-width",
|
|
54
|
+
...F.pageModel.value === void 0 ? {} : { page: F.pageModel.value },
|
|
55
|
+
mode: N.mode,
|
|
56
|
+
rotation: N.rotation,
|
|
57
|
+
gap: N.gap,
|
|
58
|
+
buffer: N.buffer,
|
|
59
|
+
tool: F.tool.value,
|
|
60
|
+
...F.hostTools.value ? { tools: F.hostTools.value } : {},
|
|
61
|
+
...F.pluginHost.value ? { plugins: F.pluginHost.value } : {},
|
|
62
|
+
...F.search.value ? { search: F.search.value } : {},
|
|
63
|
+
decorateAnnotation: (e) => F.decorateAnnotation.value?.(e),
|
|
64
|
+
...F.toolStyle.value ? { toolStyle: F.toolStyle.value } : {},
|
|
65
|
+
toolHistory: { batch: (e) => F.history.batch(e) },
|
|
66
|
+
toolOptions: F.toolOptions,
|
|
67
|
+
fonts: [...F.fonts.value],
|
|
68
|
+
signatureLibrary: () => F.signatures.value,
|
|
69
|
+
customAnnotations: J,
|
|
70
|
+
...F.formHighlight.value === void 0 ? {} : { formHighlight: F.formHighlight.value },
|
|
71
|
+
onSignField: (e) => {
|
|
72
|
+
W.value = W.value?.widget === e.widget ? null : e;
|
|
73
|
+
},
|
|
74
|
+
onFormAction: (e) => F.reportFormAction(e),
|
|
75
|
+
onFormAlert: (e) => {
|
|
76
|
+
G.value = e, K.value += 1;
|
|
77
|
+
},
|
|
78
|
+
onActivate: (e) => F.setActivated(e),
|
|
62
79
|
onBuild: (e, t) => {
|
|
63
|
-
|
|
64
|
-
for (let e of
|
|
65
|
-
let
|
|
66
|
-
e !==
|
|
80
|
+
F.viewport.value = e, F.tools.value = t, r && (r = !1, X = e.zoom.get(), Z = 0);
|
|
81
|
+
for (let e of Y) e();
|
|
82
|
+
let n = (e) => {
|
|
83
|
+
e !== X && (X = e, F.reportZoom(e));
|
|
67
84
|
}, i = (e) => {
|
|
68
|
-
e !==
|
|
85
|
+
e !== Z && (Z = e, F.reportPage(e));
|
|
69
86
|
};
|
|
70
|
-
|
|
71
|
-
e.zoom.subscribe(
|
|
87
|
+
Y = [
|
|
88
|
+
e.zoom.subscribe(n),
|
|
72
89
|
e.currentPage.subscribe(i),
|
|
73
90
|
t.active.subscribe((e) => {
|
|
74
|
-
e !==
|
|
91
|
+
e !== F.tool.value && F.setTool(e);
|
|
75
92
|
})
|
|
76
|
-
],
|
|
93
|
+
], n(e.zoom.get()), i(e.currentPage.get());
|
|
77
94
|
},
|
|
78
95
|
onPageMount: (e, t, n) => {
|
|
79
|
-
|
|
80
|
-
build:
|
|
96
|
+
B.value = [...B.value, {
|
|
97
|
+
build: q,
|
|
81
98
|
page: e,
|
|
82
99
|
host: n,
|
|
83
100
|
mount: t,
|
|
84
101
|
error: null,
|
|
85
|
-
custom:
|
|
102
|
+
custom: J
|
|
86
103
|
}];
|
|
87
104
|
},
|
|
88
105
|
onPageUnmount: (e) => {
|
|
89
|
-
|
|
106
|
+
B.value = B.value.filter((t) => t.page !== e);
|
|
90
107
|
},
|
|
91
108
|
onPageError: (e, t) => {
|
|
92
|
-
|
|
109
|
+
B.value = B.value.map((n) => n.page === e ? {
|
|
93
110
|
...n,
|
|
94
111
|
error: t
|
|
95
112
|
} : n);
|
|
96
113
|
}
|
|
97
114
|
});
|
|
98
115
|
}
|
|
99
|
-
return
|
|
100
|
-
|
|
101
|
-
}),
|
|
102
|
-
let t =
|
|
116
|
+
return _(() => {
|
|
117
|
+
F.viewportEl.value = I.value, T([() => F.document.value, () => F.status.value.state], ne, { immediate: !0 });
|
|
118
|
+
}), T(() => F.decorateAnnotation.value, () => U.value?.redecorate()), T(() => F.formHighlight.value, (e) => U.value?.setFormHighlight(e ?? !0)), T(() => F.zoomModel.value, (e) => {
|
|
119
|
+
let t = U.value?.viewport;
|
|
103
120
|
t && e !== void 0 && e !== t.zoom.get() && t.setZoom(e);
|
|
104
|
-
}),
|
|
105
|
-
let t =
|
|
106
|
-
t && e !== void 0 && e !==
|
|
107
|
-
}),
|
|
108
|
-
let t =
|
|
121
|
+
}), T(() => F.pageModel.value, (e) => {
|
|
122
|
+
let t = U.value?.viewport;
|
|
123
|
+
t && e !== void 0 && e !== Z && e !== t.currentPage.get() && t.scrollToPage(e);
|
|
124
|
+
}), T(() => F.tool.value, (e) => {
|
|
125
|
+
let t = U.value?.tools;
|
|
109
126
|
t && t.active.get() !== e && t.set(e);
|
|
110
|
-
}),
|
|
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]) => $({
|
|
111
128
|
gap: e,
|
|
112
129
|
buffer: t,
|
|
113
|
-
customAnnotations: !!
|
|
114
|
-
})),
|
|
115
|
-
let e = !!
|
|
116
|
-
|
|
117
|
-
}),
|
|
118
|
-
|
|
119
|
-
}), (e,
|
|
130
|
+
customAnnotations: !!P.annotation
|
|
131
|
+
})), g(() => {
|
|
132
|
+
let e = !!P.annotation;
|
|
133
|
+
U.value && e !== J && $({ customAnnotations: e });
|
|
134
|
+
}), h(() => {
|
|
135
|
+
Q(), F.viewportEl.value === I.value && (F.viewportEl.value = null);
|
|
136
|
+
}), (e, t) => (v(), c("div", {
|
|
120
137
|
class: "ink-viewport-root",
|
|
121
138
|
"data-ink-viewport-root": "",
|
|
122
|
-
"data-state":
|
|
139
|
+
"data-state": V.value
|
|
123
140
|
}, [
|
|
124
|
-
|
|
141
|
+
V.value === "loading" ? (v(), c("div", k, [b(e.$slots, "loading", {}, () => [t[2] ||= d("Loading document…", -1)])])) : H.value ? (v(), c("div", A, [b(e.$slots, "error", { error: H.value }, () => [t[3] ||= l("p", { class: "ink-error-title" }, "This document could not be opened.", -1), l("p", null, [l("code", {
|
|
125
142
|
class: "ink-error-code",
|
|
126
|
-
title:
|
|
127
|
-
},
|
|
128
|
-
|
|
143
|
+
title: H.value.message
|
|
144
|
+
}, S(H.value.code), 9, j)])])])) : V.value === "idle" ? (v(), c("div", M, [b(e.$slots, "empty")])) : ee("", !0),
|
|
145
|
+
l("div", {
|
|
129
146
|
ref_key: "scroll",
|
|
130
|
-
ref:
|
|
147
|
+
ref: I,
|
|
131
148
|
class: "ink-scroll",
|
|
132
149
|
"data-ink-scroll": "",
|
|
133
150
|
tabindex: "0",
|
|
134
151
|
role: "document",
|
|
135
152
|
"aria-label": "Document"
|
|
136
153
|
}, null, 512),
|
|
137
|
-
(
|
|
138
|
-
key: `${
|
|
139
|
-
page:
|
|
140
|
-
host:
|
|
141
|
-
mount:
|
|
142
|
-
error:
|
|
143
|
-
"custom-annotations":
|
|
144
|
-
},
|
|
154
|
+
(v(!0), c(a, null, y(B.value, (t) => (v(), s(r, {
|
|
155
|
+
key: `${t.build}:${t.page}`,
|
|
156
|
+
page: t.page,
|
|
157
|
+
host: t.host,
|
|
158
|
+
mount: t.mount,
|
|
159
|
+
error: t.error,
|
|
160
|
+
"custom-annotations": t.custom
|
|
161
|
+
}, u({ _: 2 }, [P.annotation ? {
|
|
145
162
|
name: "annotation",
|
|
146
|
-
fn:
|
|
163
|
+
fn: E((t) => [b(e.$slots, "annotation", m({ ref_for: !0 }, t))]),
|
|
147
164
|
key: "0"
|
|
148
|
-
} : void 0,
|
|
165
|
+
} : void 0, P["page-error"] ? {
|
|
149
166
|
name: "page-error",
|
|
150
|
-
fn:
|
|
167
|
+
fn: E((t) => [b(e.$slots, "page-error", m({ ref_for: !0 }, t))]),
|
|
151
168
|
key: "1"
|
|
152
169
|
} : void 0]), 1032, [
|
|
153
170
|
"page",
|
|
@@ -155,11 +172,26 @@ var T = ["data-state"], E = {
|
|
|
155
172
|
"mount",
|
|
156
173
|
"error",
|
|
157
174
|
"custom-annotations"
|
|
158
|
-
]))), 128))
|
|
159
|
-
|
|
175
|
+
]))), 128)),
|
|
176
|
+
(v(), s(i, {
|
|
177
|
+
key: z(C(F).document.value),
|
|
178
|
+
request: W.value,
|
|
179
|
+
onClose: t[0] ||= (e) => W.value = null
|
|
180
|
+
}, null, 8, ["request"])),
|
|
181
|
+
f(n, {
|
|
182
|
+
message: G.value,
|
|
183
|
+
shown: K.value,
|
|
184
|
+
fallback: I.value,
|
|
185
|
+
onClose: t[1] ||= (e) => G.value = null
|
|
186
|
+
}, null, 8, [
|
|
187
|
+
"message",
|
|
188
|
+
"shown",
|
|
189
|
+
"fallback"
|
|
190
|
+
])
|
|
191
|
+
], 8, O));
|
|
160
192
|
}
|
|
161
193
|
});
|
|
162
194
|
//#endregion
|
|
163
|
-
export {
|
|
195
|
+
export { N as default };
|
|
164
196
|
|
|
165
197
|
//# sourceMappingURL=InkViewport.vue_vue_type_script_setup_true_lang.js.map
|