@inkbar/vue 0.2.0 → 0.4.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 +35 -8
- package/dist/components/InkColorMenu.js +7 -0
- package/dist/components/InkColorMenu.js.map +1 -0
- package/dist/components/InkColorMenu.vue.d.ts +32 -0
- package/dist/components/InkColorMenu.vue.d.ts.map +1 -0
- package/dist/components/InkColorMenu.vue_vue_type_script_setup_true_lang.js +152 -0
- package/dist/components/InkColorMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkHighlightMenu.js +7 -0
- package/dist/components/InkHighlightMenu.js.map +1 -0
- package/dist/components/InkHighlightMenu.vue.d.ts +17 -0
- package/dist/components/InkHighlightMenu.vue.d.ts.map +1 -0
- package/dist/components/InkHighlightMenu.vue_vue_type_script_setup_true_lang.js +140 -0
- package/dist/components/InkHighlightMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkLineStyleMenu.js +7 -0
- package/dist/components/InkLineStyleMenu.js.map +1 -0
- package/dist/components/InkLineStyleMenu.vue.d.ts +14 -0
- package/dist/components/InkLineStyleMenu.vue.d.ts.map +1 -0
- package/dist/components/InkLineStyleMenu.vue_vue_type_script_setup_true_lang.js +109 -0
- package/dist/components/InkLineStyleMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkRoot.js.map +1 -1
- package/dist/components/InkRoot.vue.d.ts +606 -62
- package/dist/components/InkRoot.vue.d.ts.map +1 -1
- package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js +117 -88
- package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkShapeMenu.js +7 -0
- package/dist/components/InkShapeMenu.js.map +1 -0
- package/dist/components/InkShapeMenu.vue.d.ts +18 -0
- package/dist/components/InkShapeMenu.vue.d.ts.map +1 -0
- package/dist/components/InkShapeMenu.vue_vue_type_script_setup_true_lang.js +118 -0
- package/dist/components/InkShapeMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkSignatureDialog.js +7 -0
- package/dist/components/InkSignatureDialog.js.map +1 -0
- package/dist/components/InkSignatureDialog.vue.d.ts +21 -0
- package/dist/components/InkSignatureDialog.vue.d.ts.map +1 -0
- package/dist/components/InkSignatureDialog.vue_vue_type_script_setup_true_lang.js +58 -0
- package/dist/components/InkSignatureDialog.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkSignatureMenu.js +7 -0
- package/dist/components/InkSignatureMenu.js.map +1 -0
- package/dist/components/InkSignatureMenu.vue.d.ts +20 -0
- package/dist/components/InkSignatureMenu.vue.d.ts.map +1 -0
- package/dist/components/InkSignatureMenu.vue_vue_type_script_setup_true_lang.js +213 -0
- package/dist/components/InkSignatureMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkTextStyleMenu.js +7 -0
- package/dist/components/InkTextStyleMenu.js.map +1 -0
- package/dist/components/InkTextStyleMenu.vue.d.ts +14 -0
- package/dist/components/InkTextStyleMenu.vue.d.ts.map +1 -0
- package/dist/components/InkTextStyleMenu.vue_vue_type_script_setup_true_lang.js +200 -0
- package/dist/components/InkTextStyleMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkThreadPopover.js +7 -0
- package/dist/components/InkThreadPopover.js.map +1 -0
- package/dist/components/{InkNotePopover.vue.d.ts → InkThreadPopover.vue.d.ts} +4 -4
- package/dist/components/InkThreadPopover.vue.d.ts.map +1 -0
- package/dist/components/{InkNotePopover.vue_vue_type_script_setup_true_lang.js → InkThreadPopover.vue_vue_type_script_setup_true_lang.js} +45 -43
- package/dist/components/InkThreadPopover.vue_vue_type_script_setup_true_lang.js.map +1 -0
- 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 +27 -20
- package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkViewport.js.map +1 -1
- package/dist/components/InkViewport.vue.d.ts +1 -1
- package/dist/components/InkViewport.vue.d.ts.map +1 -1
- package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js +6 -0
- package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/SignatureForm.js +7 -0
- package/dist/components/SignatureForm.js.map +1 -0
- package/dist/components/SignatureForm.vue.d.ts +14 -0
- package/dist/components/SignatureForm.vue.d.ts.map +1 -0
- package/dist/components/SignatureForm.vue_vue_type_script_setup_true_lang.js +181 -0
- package/dist/components/SignatureForm.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/composables/useAnnotations.d.ts +1577 -185
- package/dist/composables/useAnnotations.d.ts.map +1 -1
- package/dist/composables/useAnnotations.js.map +1 -1
- package/dist/composables/useToolOptions.d.ts +11 -0
- package/dist/composables/useToolOptions.d.ts.map +1 -0
- package/dist/composables/useToolOptions.js +16 -0
- package/dist/composables/useToolOptions.js.map +1 -0
- package/dist/composables/useToolStyle.d.ts +32 -0
- package/dist/composables/useToolStyle.d.ts.map +1 -0
- package/dist/composables/useToolStyle.js +24 -0
- package/dist/composables/useToolStyle.js.map +1 -0
- package/dist/context.d.ts +14 -2
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -24
- package/package.json +5 -5
- package/dist/components/InkNotePopover.js +0 -7
- package/dist/components/InkNotePopover.js.map +0 -1
- package/dist/components/InkNotePopover.vue.d.ts.map +0 -1
- package/dist/components/InkNotePopover.vue_vue_type_script_setup_true_lang.js.map +0 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { useToolStyle as e } from "../composables/useToolStyle.js";
|
|
2
|
+
import t from "./InkIcon.js";
|
|
3
|
+
import { Fragment as n, computed as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, createVNode as l, defineComponent as u, guardReactiveProps as d, mergeProps as f, normalizeProps as p, openBlock as m, ref as h, renderList as g, renderSlot as _, toDisplayString as v, unref as y, useAttrs as b, watch as x, withCtx as S } from "vue";
|
|
4
|
+
import { focusInitialMenuItem as C, handleMenuKeys as w, lineStyleMenuModel as T, menuItems as E } from "@inkbar/core/dom";
|
|
5
|
+
import { PopoverContent as D, PopoverPortal as O, PopoverRoot as k, PopoverTrigger as A, ToolbarButton as j } from "reka-ui";
|
|
6
|
+
import { Check as M, Minus as N } from "@inkbar/icons";
|
|
7
|
+
//#region src/components/InkLineStyleMenu.vue?vue&type=script&setup=true&lang.ts
|
|
8
|
+
var P = ["data-state"], F = [
|
|
9
|
+
"aria-label",
|
|
10
|
+
"aria-disabled",
|
|
11
|
+
"data-disabled"
|
|
12
|
+
], I = {
|
|
13
|
+
class: "ink-menu-label",
|
|
14
|
+
"aria-hidden": "true"
|
|
15
|
+
}, L = [
|
|
16
|
+
"aria-checked",
|
|
17
|
+
"disabled",
|
|
18
|
+
"data-state",
|
|
19
|
+
"onClick"
|
|
20
|
+
], R = {
|
|
21
|
+
key: 0,
|
|
22
|
+
class: "ink-select-indicator"
|
|
23
|
+
}, z = /*@__PURE__*/ u({
|
|
24
|
+
inheritAttrs: !1,
|
|
25
|
+
__name: "InkLineStyleMenu",
|
|
26
|
+
setup(u) {
|
|
27
|
+
let z = b(), { current: B, supported: V, set: H } = e(), U = h(!1), W = r(() => T(B.value, V.value));
|
|
28
|
+
x(() => W.value.enabled, (e) => {
|
|
29
|
+
e || (U.value = !1);
|
|
30
|
+
});
|
|
31
|
+
let G = !1;
|
|
32
|
+
function K(e) {
|
|
33
|
+
e.key !== "ArrowDown" || e.defaultPrevented || U.value || !W.value.enabled || (e.preventDefault(), G = !0, U.value = !0);
|
|
34
|
+
}
|
|
35
|
+
function q(e) {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
let t = document.querySelector("[data-ink-menu=\"line-style\"] [role=\"menu\"]");
|
|
38
|
+
t && (G ? E(t)[0]?.focus({ preventScroll: !0 }) : C(t)), G = !1;
|
|
39
|
+
}
|
|
40
|
+
let J = r(() => ({
|
|
41
|
+
"aria-label": "Line style",
|
|
42
|
+
title: "Line style",
|
|
43
|
+
"aria-haspopup": "menu",
|
|
44
|
+
onKeydown: K,
|
|
45
|
+
"data-mixed": W.value.mixed ? "" : void 0
|
|
46
|
+
})), Y = r(() => f(z, J.value, { disabled: (z.disabled ?? !1) !== !1 || !W.value.enabled })), X = { "aria-label": "Line style" }, Z = {
|
|
47
|
+
role: "menu",
|
|
48
|
+
"aria-label": "Line style",
|
|
49
|
+
onKeydown: (e) => w(e, e.currentTarget)
|
|
50
|
+
};
|
|
51
|
+
return (e, r) => (m(), i(y(k), {
|
|
52
|
+
open: U.value,
|
|
53
|
+
"onUpdate:open": r[0] ||= (e) => U.value = e
|
|
54
|
+
}, {
|
|
55
|
+
default: S(() => [l(y(j), { "as-child": "" }, {
|
|
56
|
+
default: S(() => [l(y(A), { "as-child": "" }, {
|
|
57
|
+
default: S(() => [s("button", f({
|
|
58
|
+
type: "button",
|
|
59
|
+
class: "ink-menu-trigger ink-line-style-menu",
|
|
60
|
+
"data-ink-line-style-menu": "",
|
|
61
|
+
"data-state": U.value ? "open" : "closed"
|
|
62
|
+
}, Y.value), [_(e.$slots, "default", {}, () => [l(t, { icon: y(N) }, null, 8, ["icon"])])], 16, P)]),
|
|
63
|
+
_: 3
|
|
64
|
+
})]),
|
|
65
|
+
_: 3
|
|
66
|
+
}), l(y(O), null, {
|
|
67
|
+
default: S(() => [l(y(D), f({
|
|
68
|
+
class: "ink-select-content ink-menu-content",
|
|
69
|
+
"data-ink-select-content": "",
|
|
70
|
+
"data-ink-menu": "line-style",
|
|
71
|
+
side: "bottom",
|
|
72
|
+
align: "start",
|
|
73
|
+
"side-offset": 4,
|
|
74
|
+
"collision-padding": 8
|
|
75
|
+
}, X, { onOpenAutoFocus: q }), {
|
|
76
|
+
default: S(() => [s("div", p(d(Z)), [(m(!0), o(n, null, g(W.value.sections, (e) => (m(), o("div", {
|
|
77
|
+
key: e.label,
|
|
78
|
+
role: "group",
|
|
79
|
+
class: "ink-menu-group",
|
|
80
|
+
"aria-label": e.label,
|
|
81
|
+
"aria-disabled": e.disabled || void 0,
|
|
82
|
+
"data-disabled": e.disabled ? "" : void 0
|
|
83
|
+
}, [s("div", I, v(e.label), 1), (m(!0), o(n, null, g(e.items, (n) => (m(), o("button", {
|
|
84
|
+
key: n.key,
|
|
85
|
+
type: "button",
|
|
86
|
+
role: "menuitemradio",
|
|
87
|
+
class: "ink-select-item ink-menu-item",
|
|
88
|
+
"data-ink-select-item": "",
|
|
89
|
+
tabindex: "-1",
|
|
90
|
+
"aria-checked": n.checked,
|
|
91
|
+
disabled: e.disabled,
|
|
92
|
+
"data-state": n.checked ? "checked" : "unchecked",
|
|
93
|
+
onClick: (e) => y(H)(n.patch)
|
|
94
|
+
}, [c(v(n.label) + " ", 1), n.checked ? (m(), o("span", R, [l(t, {
|
|
95
|
+
icon: y(M),
|
|
96
|
+
size: 16
|
|
97
|
+
}, null, 8, ["icon"])])) : a("", !0)], 8, L))), 128))], 8, F))), 128))], 16)]),
|
|
98
|
+
_: 1
|
|
99
|
+
}, 16)]),
|
|
100
|
+
_: 1
|
|
101
|
+
})]),
|
|
102
|
+
_: 3
|
|
103
|
+
}, 8, ["open"]));
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
//#endregion
|
|
107
|
+
export { z as default };
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=InkLineStyleMenu.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkLineStyleMenu.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_withCtx","_createVNode","_createElementVNode","_mergeProps","_renderSlot","InkIcon","_normalizeProps","_guardReactiveProps","_createElementBlock","_Fragment","_renderList","_toDisplayString","_createTextVNode","_createCommentVNode","InkIcon_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","InkLineStyleMenu_vue_vue_type_script_setup_true_lang_default","attrs","useAttrs","useToolStyle","open","ref","model","computed","lineStyleMenuModel","current","supported","enabled","focusFirst","onTriggerKeydown","onOpenAutoFocus","menu","menuItems","focusInitialMenuItem","triggerAttrs","triggerBindings","mergeProps","menuAttrs","innerAttrs","handleMenuKeys","openBlock","createBlock","unref","PopoverRoot","_cache","$event","withCtx","createVNode","ToolbarButton","PopoverTrigger","createElementVNode","renderSlot","_ctx","Minus","PopoverPortal","PopoverContent","normalizeProps","guardReactiveProps","createElementBlock","Fragment","renderList","section","toDisplayString","item","set","createTextVNode","Check","createCommentVNode"],"sources":["../../src/components/InkLineStyleMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * Line weight, solid or dashed, and arrowheads, for the selection or the active tool. Each\n * section disables when nothing selected (or no active tool) supports its props. The trigger\n * carries `data-mixed` when the selection disagrees on any of them; a section with no single\n * value shows no checkmark.\n */\nimport {\n focusInitialMenuItem,\n handleMenuKeys,\n lineStyleMenuModel,\n menuItems,\n} from '@inkbar/core/dom'\nimport { Check, Minus } from '@inkbar/icons'\nimport {\n PopoverContent,\n PopoverPortal,\n PopoverRoot,\n PopoverTrigger,\n ToolbarButton,\n} from 'reka-ui'\nimport { computed, mergeProps, ref, useAttrs, watch } from 'vue'\n\nimport { useToolStyle } from '../composables/useToolStyle'\n\nimport InkIcon from './InkIcon.vue'\n\n// The host's attributes go on the trigger: the root is a renderless popover.\ndefineOptions({ inheritAttrs: false })\nconst attrs = useAttrs()\n\nconst { current, supported, set } = useToolStyle()\nconst open = ref(false)\n\nconst model = computed(() => lineStyleMenuModel(current.value, supported.value))\n\n// The menu closes when the control disables (the selection cleared while it was open).\nwatch(\n () => model.value.enabled,\n (enabled) => {\n if (!enabled) open.value = false\n }\n)\n\n/** ArrowDown opens on the first item; a click opens on the checked one. */\nlet focusFirst = false\nfunction onTriggerKeydown(e: KeyboardEvent): void {\n if (e.key !== 'ArrowDown' || e.defaultPrevented || open.value || !model.value.enabled)\n return\n e.preventDefault()\n focusFirst = true\n open.value = true\n}\n\nfunction onOpenAutoFocus(e: Event): void {\n e.preventDefault()\n // One menu is open at a time.\n const menu = document.querySelector('[data-ink-menu=\"line-style\"] [role=\"menu\"]')\n if (menu) {\n if (focusFirst) menuItems(menu)[0]?.focus({ preventScroll: true })\n else focusInitialMenuItem(menu)\n }\n focusFirst = false\n}\n\n// Reka's typed props stop at its own; ARIA goes through bound objects.\nconst triggerAttrs = computed(() => ({\n 'aria-label': 'Line style',\n title: 'Line style',\n 'aria-haspopup': 'menu' as const,\n onKeydown: onTriggerKeydown,\n 'data-mixed': model.value.mixed ? '' : undefined,\n}))\n/**\n * The trigger's bindings over the host's: both keydown listeners run, the host's first, and a\n * host `disabled` can disable the trigger but not enable it.\n */\nconst triggerBindings = computed(() =>\n mergeProps(attrs, triggerAttrs.value, {\n disabled: (attrs.disabled ?? false) !== false || !model.value.enabled,\n })\n)\nconst menuAttrs = { 'aria-label': 'Line style' }\nconst innerAttrs = {\n role: 'menu',\n 'aria-label': 'Line style',\n onKeydown: (e: KeyboardEvent) => handleMenuKeys(e, e.currentTarget as HTMLElement),\n}\n</script>\n\n<template>\n <PopoverRoot v-model:open=\"open\">\n <ToolbarButton as-child>\n <PopoverTrigger as-child>\n <button\n type=\"button\"\n class=\"ink-menu-trigger ink-line-style-menu\"\n data-ink-line-style-menu\n :data-state=\"open ? 'open' : 'closed'\"\n v-bind=\"triggerBindings\"\n >\n <slot><InkIcon :icon=\"Minus\" /></slot>\n </button>\n </PopoverTrigger>\n </ToolbarButton>\n <PopoverPortal>\n <PopoverContent\n class=\"ink-select-content ink-menu-content\"\n data-ink-select-content\n data-ink-menu=\"line-style\"\n side=\"bottom\"\n align=\"start\"\n :side-offset=\"4\"\n :collision-padding=\"8\"\n v-bind=\"menuAttrs\"\n @open-auto-focus=\"onOpenAutoFocus\"\n >\n <div v-bind=\"innerAttrs\">\n <div\n v-for=\"section in model.sections\"\n :key=\"section.label\"\n role=\"group\"\n class=\"ink-menu-group\"\n :aria-label=\"section.label\"\n :aria-disabled=\"section.disabled || undefined\"\n :data-disabled=\"section.disabled ? '' : undefined\"\n >\n <div class=\"ink-menu-label\" aria-hidden=\"true\">{{ section.label }}</div>\n <button\n v-for=\"item in section.items\"\n :key=\"item.key\"\n type=\"button\"\n role=\"menuitemradio\"\n class=\"ink-select-item ink-menu-item\"\n data-ink-select-item\n tabindex=\"-1\"\n :aria-checked=\"item.checked\"\n :disabled=\"section.disabled\"\n :data-state=\"item.checked ? 'checked' : 'unchecked'\"\n @click=\"set(item.patch)\"\n >\n {{ item.label }}\n <span v-if=\"item.checked\" class=\"ink-select-indicator\">\n <InkIcon :icon=\"Check\" :size=\"16\" />\n </span>\n </button>\n </div>\n </div>\n </PopoverContent>\n </PopoverPortal>\n </PopoverRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;EA6BA,IAAMwB,IAAQC,EAAS,GAEjB,EAAE,YAAS,cAAW,WAAQC,EAAa,GAC3CC,IAAOC,EAAI,EAAK,GAEhBC,IAAQC,QAAeC,EAAmBC,EAAQ,OAAOC,EAAU,KAAK,CAAC;EAG/E,QACQJ,EAAM,MAAM,UACjB,MAAY;GACX,AAAKK,MAAS,EAAK,QAAQ;EAC7B,CACF;EAGA,IAAIC,IAAa;EACjB,SAASC,EAAiB,GAAwB;GAChD,AAAI,EAAE,QAAQ,eAAe,EAAE,oBAAoBT,EAAK,SAAS,CAACE,EAAM,MAAM,YAE9E,EAAE,eAAe,GACjB,IAAa,IACb,EAAK,QAAQ;EACf;EAEA,SAASQ,EAAgB,GAAgB;GACvC,EAAE,eAAe;GAEjB,IAAMC,IAAO,SAAS,cAAc,gDAA4C;GAKhF,AAJIA,MACEH,IAAYI,EAAUD,CAAI,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,eAAe,GAAK,CAAC,IAC5DE,EAAqBF,CAAI,IAEhC,IAAa;EACf;EAGA,IAAMG,IAAeX,SAAgB;GACnC,cAAc;GACd,OAAO;GACP,iBAAiB;GACjB,WAAWM;GACX,cAAcP,EAAM,MAAM,QAAQ,KAAK,KAAA;EACzC,EAAE,GAKIa,IAAkBZ,QACtBa,EAAWnB,GAAOiB,EAAa,OAAO,EACpC,WAAWjB,EAAM,YAAY,QAAW,MAAS,CAACK,EAAM,MAAM,QAChE,CAAC,CACH,GACMe,IAAY,EAAE,cAAc,aAAa,GACzCC,IAAa;GACjB,MAAM;GACN,cAAc;GACd,YAAY,MAAqBC,EAAe,GAAG,EAAE,aAA4B;EACnF;oBAIE9C,EAAA,GAAAC,EA2DcC,EAAAgD,CAAA,GAAA;GA3DO,MAAMvB,EAAA;GAAA,iBAAA,AAAAwB,EAAA,QAAA,MAAA,EAAI,QAAAC;;GAC7B,SAAAjD,QAYgB,CAZhBC,EAYgBF,EAAAqD,CAAA,GAAA,EAZD,YAAA,GAAQ,GAAA;IACrB,SAAApD,QAUiB,CAVjBC,EAUiBF,EAAAsD,CAAA,GAAA,EAVD,YAAA,GAAQ,GAAA;KACtB,SAAArD,QAQS,CARTE,EAQS,UARTC,EAQS;MAPP,MAAK;MACL,OAAM;MACN,4BAAA;MACC,cAAYqB,EAAA,QAAI,SAAA;KACT,GAAAe,EAAA,KAAe,GAAA,CAEvBnC,EAAsCoD,EAAA,QAAA,WAAA,CAAA,SAAA,CAAhCvD,EAAyBI,GAAA,EAAf,MAAMN,EAAA0D,CAAA,EAAK,GAAA,MAAA,GAAA,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA,GAAA,IAAA1C,CAAA,CAAA,CAAA;;;;GAIjCd,CAAAA,GAAAA,EA4CgBF,EAAA2D,CAAA,GAAA,MAAA;IA3Cd,SAAA1D,QA0CiB,CA1CjBC,EA0CiBF,EAAA4D,CAAA,GA1CjBxD,EA0CiB;KAzCf,OAAM;KACN,2BAAA;KACA,iBAAc;KACd,MAAK;KACL,OAAM;KACL,eAAa;KACb,qBAAmB;IACZ,GAAAsC,GAAS,EACC,mBAAe,CAAA,GAAA;KAEjC,SAAAzC,QA8BM,CA9BNE,EA8BM,OAAAI,EAAAC,EA9BOmC,CAAU,CAAA,GAAA,EACrB7C,EAAA,EAAA,GAAAW,EA4BMC,GAAA,MAAAC,EA3BcgB,EAAA,MAAM,WAAjB,OADT7B,EAAA,GAAAW,EA4BM,OAAA;MA1BH,KAAKyD,EAAQ;MACd,MAAK;MACL,OAAM;MACL,cAAYA,EAAQ;MACpB,iBAAeA,EAAQ,YAAY,KAAA;MACnC,iBAAeA,EAAQ,WAAQ,KAAQ,KAAA;KAExC/D,GAAAA,CAAAA,EAAwE,OAAxEe,GAAwEN,EAAtBsD,EAAQ,KAAK,GAAA,CAAA,IAC/DpE,EAAA,EAAA,GAAAW,EAiBSC,GAAA,MAAAC,EAhBQuD,EAAQ,QAAhB,OADTpE,EAAA,GAAAW,EAiBS,UAAA;MAfN,KAAK2D,EAAK;MACX,MAAK;MACL,MAAK;MACL,OAAM;MACN,wBAAA;MACA,UAAS;MACR,gBAAcA,EAAK;MACnB,UAAUF,EAAQ;MAClB,cAAYE,EAAK,UAAO,YAAA;MACxB,UAAK,MAAEpE,EAAAqE,CAAA,CAAG,CAACD,EAAK,KAAK;KAEnBvD,GAAAA,CAAAA,EAAAD,EAAAwD,EAAK,KAAK,IAAG,KAChB,CAAA,GAAYA,EAAK,WAAjBtE,EAAA,GAAAW,EAEO,QAFPW,GAEO,CADLlB,EAAoCI,GAAA;MAA1B,MAAMN,EAAAuE,CAAA;MAAQ,MAAM"}
|
|
@@ -1 +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":""}
|
|
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 {\n createMemorySignatureStore,\n createSignatureLibrary,\n InkError,\n openDocument,\n} from '@inkbar/core'\nimport {\n createToolOptions,\n cssVariableDefaults,\n FONT_FAMILIES,\n SIGNATURE_FONTS,\n trackToolStyle,\n} 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 SignatureStore,\n} from '@inkbar/core'\nimport type {\n Tool,\n ToolController,\n ToolId,\n ToolStyle,\n Viewport,\n ZoomValue,\n} 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 /**\n * Host tools, added to the built-ins; one with a built-in's id replaces it. Read when a\n * document opens.\n */\n tools?: Tool[] | undefined\n /**\n * The font families text boxes offer, replacing the PDF standard families\n * (`FONT_FAMILIES`). Fonts beyond those are the PDF writer's to embed.\n */\n fonts?: string[] | undefined\n /**\n * Where saved signatures live. Default: memory, gone on reload.\n * `createLocalSignatureStore` keeps them in the browser; a host can keep them anywhere.\n * A new store takes effect at once, for the menus and the `signature` tool alike.\n */\n signatures?: SignatureStore | undefined\n /** The handwriting fonts a typed signature offers; the host loads them. */\n signatureFonts?: string[] | 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 tools: undefined,\n fonts: undefined,\n signatures: undefined,\n signatureFonts: 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 toolController = shallowRef<ToolController | null>(null)\nconst internalTool = ref<ToolId>(props.tool ?? 'select-text')\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/** The document's tool style; it batches through `inkHistory`, whichever mode is on. */\nconst toolStyle = shallowRef<ToolStyle | null>(null)\nlet setStyleTool: ((id: ToolId) => void) | undefined\nwatch(\n document,\n (doc) => {\n if (!doc) {\n toolStyle.value = null\n setStyleTool = undefined\n return\n }\n const tracker = trackToolStyle({\n store: doc.annotations,\n history: { batch: (fn) => inkHistory.batch(fn) },\n tools: props.tools,\n tool: internalTool.value,\n })\n setStyleTool = (id) => tracker.setTool(id)\n toolStyle.value = tracker.toolStyle\n },\n // Sync: the style is in place before InkViewport's watcher mounts the engine with it.\n { immediate: true, flush: 'sync' }\n)\nwatch(internalTool, (id) => setStyleTool?.(id))\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\nconst signatures = computed(() =>\n createSignatureLibrary(props.signatures ?? createMemorySignatureStore())\n)\nwatch(signatures, (lib) => void lib.refresh(), { immediate: true })\n/** Tool options last as long as the root; the tool style is per document. */\nconst toolOptions = createToolOptions()\n\nprovideInkContext({\n assets: computed(() => props.assets),\n document,\n status,\n annotations: annotationList,\n selection,\n viewport,\n tools: toolController,\n tool: internalTool,\n setTool,\n hostTools: computed(() => props.tools),\n fonts: computed(() => props.fonts ?? FONT_FAMILIES),\n toolOptions,\n signatures,\n signatureFonts: computed(() => props.signatureFonts ?? SIGNATURE_FONTS),\n toolStyle,\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":""}
|