@inkbar/vue 0.8.0 → 0.10.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 +70 -4
- package/dist/components/InkDownloadButton.js +7 -0
- package/dist/components/InkDownloadButton.js.map +1 -0
- package/dist/components/InkDownloadButton.vue.d.ts +21 -0
- package/dist/components/InkDownloadButton.vue.d.ts.map +1 -0
- package/dist/components/InkDownloadButton.vue_vue_type_script_setup_true_lang.js +42 -0
- package/dist/components/InkDownloadButton.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkFindBar.js.map +1 -1
- package/dist/components/InkFindBar.vue.d.ts.map +1 -1
- package/dist/components/InkFindBar.vue_vue_type_script_setup_true_lang.js +48 -48
- package/dist/components/InkFindBar.vue_vue_type_script_setup_true_lang.js.map +1 -1
- 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/InkPanel.js +7 -0
- package/dist/components/InkPanel.js.map +1 -0
- package/dist/components/InkPanel.vue.d.ts +21 -0
- package/dist/components/InkPanel.vue.d.ts.map +1 -0
- package/dist/components/InkPanel.vue_vue_type_script_setup_true_lang.js +48 -0
- package/dist/components/InkPanel.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkPrintButton.js +7 -0
- package/dist/components/InkPrintButton.js.map +1 -0
- package/dist/components/InkPrintButton.vue.d.ts +19 -0
- package/dist/components/InkPrintButton.vue.d.ts.map +1 -0
- package/dist/components/InkPrintButton.vue_vue_type_script_setup_true_lang.js +39 -0
- package/dist/components/InkPrintButton.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkRecordList.js +7 -0
- package/dist/components/InkRecordList.js.map +1 -0
- package/dist/components/InkRecordList.vue.d.ts +35 -0
- package/dist/components/InkRecordList.vue.d.ts.map +1 -0
- package/dist/components/InkRecordList.vue_vue_type_script_setup_true_lang.js +41 -0
- package/dist/components/InkRecordList.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 +48 -4
- package/dist/components/InkRoot.vue.d.ts.map +1 -1
- package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js +177 -164
- package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkSearchResults.js +7 -0
- package/dist/components/InkSearchResults.js.map +1 -0
- package/dist/components/InkSearchResults.vue.d.ts +9 -0
- package/dist/components/InkSearchResults.vue.d.ts.map +1 -0
- package/dist/components/InkSearchResults.vue_vue_type_script_setup_true_lang.js +52 -0
- package/dist/components/InkSearchResults.vue_vue_type_script_setup_true_lang.js.map +1 -0
- 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/InkSidebar.js +7 -0
- package/dist/components/InkSidebar.js.map +1 -0
- package/dist/components/InkSidebar.vue.d.ts +34 -0
- package/dist/components/InkSidebar.vue.d.ts.map +1 -0
- package/dist/components/InkSidebar.vue_vue_type_script_setup_true_lang.js +95 -0
- package/dist/components/InkSidebar.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 +3 -2
- package/dist/components/InkSignatureDialog.vue.d.ts.map +1 -1
- 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 +77 -75
- package/dist/components/InkSignatureMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkThumbnail.js +7 -0
- package/dist/components/InkThumbnail.js.map +1 -0
- package/dist/components/InkThumbnail.vue.d.ts +18 -0
- package/dist/components/InkThumbnail.vue.d.ts.map +1 -0
- package/dist/components/InkThumbnail.vue_vue_type_script_setup_true_lang.js +49 -0
- package/dist/components/InkThumbnail.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/InkThumbnails.js +7 -0
- package/dist/components/InkThumbnails.js.map +1 -0
- package/dist/components/InkThumbnails.vue.d.ts +27 -0
- package/dist/components/InkThumbnails.vue.d.ts.map +1 -0
- package/dist/components/InkThumbnails.vue_vue_type_script_setup_true_lang.js +107 -0
- package/dist/components/InkThumbnails.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 +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 +37 -36
- package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkZoomSelect.js.map +1 -1
- package/dist/components/InkZoomSelect.vue.d.ts.map +1 -1
- package/dist/components/InkZoomSelect.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/InkZoomSelect.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/RecordCards.js +7 -0
- package/dist/components/RecordCards.js.map +1 -0
- package/dist/components/RecordCards.vue.d.ts +25 -0
- package/dist/components/RecordCards.vue.d.ts.map +1 -0
- package/dist/components/RecordCards.vue_vue_type_script_setup_true_lang.js +120 -0
- package/dist/components/RecordCards.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/SidebarTrigger.js +7 -0
- package/dist/components/SidebarTrigger.js.map +1 -0
- package/dist/components/SidebarTrigger.vue.d.ts +9 -0
- package/dist/components/SidebarTrigger.vue.d.ts.map +1 -0
- package/dist/components/SidebarTrigger.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/components/SidebarTrigger.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/SignatureForm.js.map +1 -1
- package/dist/components/SignatureForm.vue.d.ts.map +1 -1
- package/dist/components/SignatureForm.vue_vue_type_script_setup_true_lang.js +56 -55
- package/dist/components/SignatureForm.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/sidebar-context.d.ts +21 -0
- package/dist/components/sidebar-context.d.ts.map +1 -0
- package/dist/components/sidebar-context.js +7 -0
- package/dist/components/sidebar-context.js.map +1 -0
- package/dist/composables/useAnnotations.d.ts +91 -0
- package/dist/composables/useAnnotations.d.ts.map +1 -1
- package/dist/composables/useRecordSelection.d.ts +12 -0
- package/dist/composables/useRecordSelection.d.ts.map +1 -0
- package/dist/composables/useRecordSelection.js +15 -0
- package/dist/composables/useRecordSelection.js.map +1 -0
- package/dist/composables/useRecords.d.ts +14 -0
- package/dist/composables/useRecords.d.ts.map +1 -0
- package/dist/composables/useRecords.js +16 -0
- package/dist/composables/useRecords.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/useSearch.d.ts.map +1 -1
- package/dist/composables/useSearch.js +1 -0
- package/dist/composables/useSearch.js.map +1 -1
- 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 +5 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -29
- package/dist/to-readable.d.ts +7 -0
- package/dist/to-readable.d.ts.map +1 -0
- package/dist/to-readable.js +11 -0
- package/dist/to-readable.js.map +1 -0
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InkSignatureMenu.js","names":["_sfc_main","InkSignatureMenu_vue_vue_type_script_setup_true_lang_default","InkSignatureMenu_default"],"sources":["../../src/components/InkSignatureMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * A split button for the signature tool. The main part activates the tool with the chosen\n * signature, or opens the menu when none is chosen; the chevron opens the saved signatures as\n * previews, each with a remove button, and \"Create signature\", which opens\n * `InkSignatureDialog`. Choosing a signature switches to the tool with it.\n */\nimport {\n focusInitialMenuItem,\n menuItems,\n SIGNATURE_LABELS,\n signatureMenuModel,\n} from '@inkbar/core/dom'\nimport { ChevronDown, Signature } from '@inkbar/icons'\nimport {\n PopoverAnchor,\n PopoverContent,\n PopoverPortal,\n PopoverRoot,\n PopoverTrigger,\n ToolbarButton,\n} from 'reka-ui'\nimport { computed, ref, useTemplateRef, watch } from 'vue'\n\nimport { useTool } from '../composables/useTool'\nimport {
|
|
1
|
+
{"version":3,"file":"InkSignatureMenu.js","names":["_sfc_main","InkSignatureMenu_vue_vue_type_script_setup_true_lang_default","InkSignatureMenu_default"],"sources":["../../src/components/InkSignatureMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * A split button for the signature tool. The main part activates the tool with the chosen\n * signature, or opens the menu when none is chosen; the chevron opens the saved signatures as\n * previews, each with a remove button, and \"Create signature\", which opens\n * `InkSignatureDialog`. Choosing a signature switches to the tool with it.\n */\nimport {\n focusInitialMenuItem,\n menuItems,\n SIGNATURE_LABELS,\n signatureMenuModel,\n} from '@inkbar/core/dom'\nimport { ChevronDown, Signature } from '@inkbar/icons'\nimport {\n PopoverAnchor,\n PopoverContent,\n PopoverPortal,\n PopoverRoot,\n PopoverTrigger,\n ToolbarButton,\n} from 'reka-ui'\nimport { computed, ref, useTemplateRef, watch } from 'vue'\n\nimport { useRegisteredTool } from '../composables/useRegisteredTool'\nimport { useTool } from '../composables/useTool'\nimport { useToolOptionsWhile } from '../composables/useToolOptions'\nimport { useInkContext } from '../context'\nimport { useReadable } from '../use-readable'\n\nimport InkIcon from './InkIcon.vue'\nimport InkSignatureDialog from './InkSignatureDialog.vue'\nimport SignatureMenuPanel from './SignatureMenuPanel.vue'\n\nimport type { SignatureOptions, SignatureTemplate } from '@inkbar/core'\n\ndefineOptions({ inheritAttrs: false })\nconst props = defineProps<{\n /** The fonts the dialog's Type tab offers. Default: InkRoot's `signatureFonts`. */\n fonts?: readonly string[] | undefined\n}>()\n\nconst NO_TEMPLATES: readonly SignatureTemplate[] = []\n\nconst { tool, setTool } = useTool()\n// Nothing renders while no `signature` tool is registered.\nconst registered = useRegisteredTool('signature')\nconst { options, setOptions } = useToolOptionsWhile<SignatureOptions>(\n 'signature',\n registered\n)\nconst ctx = useInkContext('InkSignatureMenu')\nconst templates = useReadable(() => ctx.signatures.value.templates, NO_TEMPLATES)\nconst model = computed(() => signatureMenuModel(templates.value, options.value))\nconst active = computed(() => tool.value === 'signature')\nconst open = ref(false)\nconst creating = ref(false)\n// An old removal error is not news when the menu opens again.\nwatch(open, (isOpen) => {\n if (isOpen) ctx.signatures.value.clearRemoveError()\n})\nconst main = useTemplateRef<{ $el: HTMLElement }>('main')\n\n/** ArrowDown opens on the first item; a click opens on the checked one. */\nlet focusFirst = false\n/** Set while the menu closes for the dialog, which takes focus instead of the trigger. */\nlet toDialog = false\n\nfunction onTriggerKeydown(e: KeyboardEvent): void {\n if (e.key !== 'ArrowDown' || e.defaultPrevented || open.value) return\n e.preventDefault()\n focusFirst = true\n open.value = true\n}\n\n// Not a signature field's menu, which shares the attribute.\nconst panel = (): HTMLElement | null =>\n document.querySelector<HTMLElement>(\n '[data-ink-menu=\"signature\"]:not([data-ink-sign-field-menu]) [role=\"menu\"]'\n )\n\nfunction onOpenAutoFocus(e: Event): void {\n e.preventDefault()\n const menu = panel()\n if (menu) {\n if (focusFirst) menuItems(menu)[0]?.focus({ preventScroll: true })\n else focusInitialMenuItem(menu)\n }\n focusFirst = false\n}\n\nfunction onCloseAutoFocus(e: Event): void {\n if (toDialog) e.preventDefault()\n toDialog = false\n}\n\nfunction onMain(): void {\n if (model.value.selected) setTool('signature')\n else open.value = true\n}\n\nfunction choose(id: string): void {\n setOptions({ templateId: id })\n setTool('signature')\n open.value = false\n}\n\nfunction create(): void {\n toDialog = true\n open.value = false\n creating.value = true\n}\n\nfunction onDialogCloseAutoFocus(e: Event): void {\n e.preventDefault()\n main.value?.$el.focus({ preventScroll: true })\n}\n\n// Reka's typed props stop at its own; ARIA and listeners go through bound objects.\nconst mainAttrs = computed(() => ({\n 'aria-pressed': String(active.value),\n 'aria-label': SIGNATURE_LABELS.sign,\n title: SIGNATURE_LABELS.sign,\n onClick: onMain,\n}))\nconst triggerAttrs = {\n 'aria-label': SIGNATURE_LABELS.trigger,\n title: SIGNATURE_LABELS.trigger,\n 'aria-haspopup': 'menu' as const,\n onKeydown: onTriggerKeydown,\n}\nconst menuAttrs = { 'aria-label': SIGNATURE_LABELS.menu }\n</script>\n\n<template>\n <PopoverRoot v-if=\"registered\" v-model:open=\"open\">\n <PopoverAnchor as-child>\n <div\n role=\"group\"\n :aria-label=\"SIGNATURE_LABELS.sign\"\n class=\"ink-split-button ink-signature-menu\"\n data-ink-signature-menu\n v-bind=\"$attrs\"\n >\n <ToolbarButton\n ref=\"main\"\n class=\"ink-tool-button ink-signature-button\"\n data-ink-tool-button\n data-ink-signature-button\n data-tool=\"signature\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"mainAttrs\"\n >\n <slot :active=\"active\"><InkIcon :icon=\"Signature\" /></slot>\n </ToolbarButton>\n <ToolbarButton as-child>\n <PopoverTrigger as-child>\n <button\n type=\"button\"\n class=\"ink-menu-trigger ink-signature-menu-trigger\"\n data-ink-signature-menu-trigger\n :data-state=\"open ? 'open' : 'closed'\"\n v-bind=\"triggerAttrs\"\n >\n <InkIcon :icon=\"ChevronDown\" />\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=\"signature\"\n side=\"bottom\"\n align=\"start\"\n :side-offset=\"4\"\n :collision-padding=\"8\"\n v-bind=\"menuAttrs\"\n @open-auto-focus=\"onOpenAutoFocus\"\n @close-auto-focus=\"onCloseAutoFocus\"\n >\n <SignatureMenuPanel\n :items=\"model.items\"\n @choose=\"choose($event.id)\"\n @create=\"create\"\n />\n </PopoverContent>\n </PopoverPortal>\n <InkSignatureDialog\n v-model:open=\"creating\"\n :fonts=\"props.fonts\"\n @close-auto-focus=\"onDialogCloseAutoFocus\"\n />\n </div>\n </PopoverAnchor>\n </PopoverRoot>\n</template>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InkSignatureMenu.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkSignatureMenu.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InkSignatureMenu.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkSignatureMenu.vue"],"names":[],"mappings":"AA4OA,KAAK,WAAW,GAAG;IACjB,mFAAmF;IACnF,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;CACtC,CAAC;AAkWF,QAAA,IAAI,QAAQ;;CAAY,CAAC;AACzB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAGhD,QAAA,MAAM,UAAU,kSAEd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -1,97 +1,99 @@
|
|
|
1
1
|
import { useInkContext as e } from "../context.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import i from "
|
|
6
|
-
import a from "./
|
|
7
|
-
import o from "./
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
2
|
+
import { useRegisteredTool as t } from "../composables/useRegisteredTool.js";
|
|
3
|
+
import { useReadable as n } from "../use-readable.js";
|
|
4
|
+
import { useTool as r } from "../composables/useTool.js";
|
|
5
|
+
import { useToolOptionsWhile as i } from "../composables/useToolOptions.js";
|
|
6
|
+
import a from "./InkSignatureDialog.js";
|
|
7
|
+
import o from "./InkIcon.js";
|
|
8
|
+
import s from "./SignatureMenuPanel.js";
|
|
9
|
+
import { computed as c, createBlock as l, createCommentVNode as u, createElementVNode as d, createVNode as f, defineComponent as p, mergeProps as m, openBlock as h, ref as g, renderSlot as _, unref as v, useTemplateRef as y, watch as b, withCtx as x } from "vue";
|
|
10
|
+
import { SIGNATURE_LABELS as S, focusInitialMenuItem as C, menuItems as w, signatureMenuModel as T } from "@inkbar/core/dom";
|
|
11
|
+
import { PopoverAnchor as E, PopoverContent as D, PopoverPortal as O, PopoverRoot as k, PopoverTrigger as A, ToolbarButton as j } from "reka-ui";
|
|
12
|
+
import { ChevronDown as M, Signature as N } from "@inkbar/icons";
|
|
12
13
|
//#region src/components/InkSignatureMenu.vue?vue&type=script&setup=true&lang.ts
|
|
13
|
-
var
|
|
14
|
+
var P = ["aria-label"], F = ["data-state"], I = /*@__PURE__*/ p({
|
|
14
15
|
inheritAttrs: !1,
|
|
15
16
|
__name: "InkSignatureMenu",
|
|
16
17
|
props: { fonts: {} },
|
|
17
|
-
setup(
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
e &&
|
|
18
|
+
setup(p) {
|
|
19
|
+
let I = p, L = [], { tool: R, setTool: z } = r(), B = t("signature"), { options: ee, setOptions: V } = i("signature", B), H = e("InkSignatureMenu"), U = n(() => H.signatures.value.templates, L), W = c(() => T(U.value, ee.value)), G = c(() => R.value === "signature"), K = g(!1), q = g(!1);
|
|
20
|
+
b(K, (e) => {
|
|
21
|
+
e && H.signatures.value.clearRemoveError();
|
|
21
22
|
});
|
|
22
|
-
let
|
|
23
|
-
function
|
|
24
|
-
e.key !== "ArrowDown" || e.defaultPrevented ||
|
|
23
|
+
let J = y("main"), Y = !1, X = !1;
|
|
24
|
+
function Z(e) {
|
|
25
|
+
e.key !== "ArrowDown" || e.defaultPrevented || K.value || (e.preventDefault(), Y = !0, K.value = !0);
|
|
25
26
|
}
|
|
26
|
-
let
|
|
27
|
-
function
|
|
27
|
+
let Q = () => document.querySelector("[data-ink-menu=\"signature\"]:not([data-ink-sign-field-menu]) [role=\"menu\"]");
|
|
28
|
+
function $(e) {
|
|
28
29
|
e.preventDefault();
|
|
29
|
-
let t =
|
|
30
|
-
t && (
|
|
30
|
+
let t = Q();
|
|
31
|
+
t && (Y ? w(t)[0]?.focus({ preventScroll: !0 }) : C(t)), Y = !1;
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
33
|
+
function te(e) {
|
|
34
|
+
X && e.preventDefault(), X = !1;
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
36
|
+
function ne() {
|
|
37
|
+
W.value.selected ? z("signature") : K.value = !0;
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
39
|
+
function re(e) {
|
|
40
|
+
V({ templateId: e }), z("signature"), K.value = !1;
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
42
|
+
function ie() {
|
|
43
|
+
X = !0, K.value = !1, q.value = !0;
|
|
43
44
|
}
|
|
44
|
-
function
|
|
45
|
-
e.preventDefault(),
|
|
45
|
+
function ae(e) {
|
|
46
|
+
e.preventDefault(), J.value?.$el.focus({ preventScroll: !0 });
|
|
46
47
|
}
|
|
47
|
-
let
|
|
48
|
-
"aria-pressed": String(
|
|
49
|
-
"aria-label":
|
|
50
|
-
title:
|
|
51
|
-
onClick:
|
|
52
|
-
})),
|
|
53
|
-
"aria-label":
|
|
54
|
-
title:
|
|
48
|
+
let oe = c(() => ({
|
|
49
|
+
"aria-pressed": String(G.value),
|
|
50
|
+
"aria-label": S.sign,
|
|
51
|
+
title: S.sign,
|
|
52
|
+
onClick: ne
|
|
53
|
+
})), se = {
|
|
54
|
+
"aria-label": S.trigger,
|
|
55
|
+
title: S.trigger,
|
|
55
56
|
"aria-haspopup": "menu",
|
|
56
|
-
onKeydown:
|
|
57
|
-
},
|
|
58
|
-
return (e, t) => (
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
onKeydown: Z
|
|
58
|
+
}, ce = { "aria-label": S.menu };
|
|
59
|
+
return (e, t) => v(B) ? (h(), l(v(k), {
|
|
60
|
+
key: 0,
|
|
61
|
+
open: K.value,
|
|
62
|
+
"onUpdate:open": t[2] ||= (e) => K.value = e
|
|
61
63
|
}, {
|
|
62
|
-
default:
|
|
63
|
-
default:
|
|
64
|
+
default: x(() => [f(v(E), { "as-child": "" }, {
|
|
65
|
+
default: x(() => [d("div", m({
|
|
64
66
|
role: "group",
|
|
65
|
-
"aria-label":
|
|
67
|
+
"aria-label": v(S).sign,
|
|
66
68
|
class: "ink-split-button ink-signature-menu",
|
|
67
69
|
"data-ink-signature-menu": ""
|
|
68
70
|
}, e.$attrs), [
|
|
69
|
-
|
|
71
|
+
f(v(j), m({
|
|
70
72
|
ref_key: "main",
|
|
71
|
-
ref:
|
|
73
|
+
ref: J,
|
|
72
74
|
class: "ink-tool-button ink-signature-button",
|
|
73
75
|
"data-ink-tool-button": "",
|
|
74
76
|
"data-ink-signature-button": "",
|
|
75
77
|
"data-tool": "signature",
|
|
76
|
-
"data-state":
|
|
77
|
-
},
|
|
78
|
-
default:
|
|
78
|
+
"data-state": G.value ? "on" : "off"
|
|
79
|
+
}, oe.value), {
|
|
80
|
+
default: x(() => [_(e.$slots, "default", { active: G.value }, () => [f(o, { icon: v(N) }, null, 8, ["icon"])])]),
|
|
79
81
|
_: 3
|
|
80
82
|
}, 16, ["data-state"]),
|
|
81
|
-
|
|
82
|
-
default:
|
|
83
|
-
default:
|
|
83
|
+
f(v(j), { "as-child": "" }, {
|
|
84
|
+
default: x(() => [f(v(A), { "as-child": "" }, {
|
|
85
|
+
default: x(() => [d("button", m({
|
|
84
86
|
type: "button",
|
|
85
87
|
class: "ink-menu-trigger ink-signature-menu-trigger",
|
|
86
88
|
"data-ink-signature-menu-trigger": "",
|
|
87
|
-
"data-state":
|
|
88
|
-
},
|
|
89
|
+
"data-state": K.value ? "open" : "closed"
|
|
90
|
+
}, se), [f(o, { icon: v(M) }, null, 8, ["icon"])], 16, F)]),
|
|
89
91
|
_: 1
|
|
90
92
|
})]),
|
|
91
93
|
_: 1
|
|
92
94
|
}),
|
|
93
|
-
|
|
94
|
-
default:
|
|
95
|
+
f(v(O), null, {
|
|
96
|
+
default: x(() => [f(v(D), m({
|
|
95
97
|
class: "ink-select-content ink-menu-content",
|
|
96
98
|
"data-ink-select-content": "",
|
|
97
99
|
"data-ink-menu": "signature",
|
|
@@ -99,33 +101,33 @@ var j = ["aria-label"], M = ["data-state"], N = /*@__PURE__*/ d({
|
|
|
99
101
|
align: "start",
|
|
100
102
|
"side-offset": 4,
|
|
101
103
|
"collision-padding": 8
|
|
102
|
-
},
|
|
103
|
-
onOpenAutoFocus:
|
|
104
|
-
onCloseAutoFocus:
|
|
104
|
+
}, ce, {
|
|
105
|
+
onOpenAutoFocus: $,
|
|
106
|
+
onCloseAutoFocus: te
|
|
105
107
|
}), {
|
|
106
|
-
default:
|
|
107
|
-
items:
|
|
108
|
-
onChoose: t[0] ||= (e) =>
|
|
109
|
-
onCreate:
|
|
108
|
+
default: x(() => [f(s, {
|
|
109
|
+
items: W.value.items,
|
|
110
|
+
onChoose: t[0] ||= (e) => re(e.id),
|
|
111
|
+
onCreate: ie
|
|
110
112
|
}, null, 8, ["items"])]),
|
|
111
113
|
_: 1
|
|
112
114
|
}, 16)]),
|
|
113
115
|
_: 1
|
|
114
116
|
}),
|
|
115
|
-
|
|
116
|
-
open:
|
|
117
|
-
"onUpdate:open": t[1] ||= (e) =>
|
|
118
|
-
fonts:
|
|
119
|
-
onCloseAutoFocus:
|
|
117
|
+
f(a, {
|
|
118
|
+
open: q.value,
|
|
119
|
+
"onUpdate:open": t[1] ||= (e) => q.value = e,
|
|
120
|
+
fonts: I.fonts,
|
|
121
|
+
onCloseAutoFocus: ae
|
|
120
122
|
}, null, 8, ["open", "fonts"])
|
|
121
|
-
], 16,
|
|
123
|
+
], 16, P)]),
|
|
122
124
|
_: 3
|
|
123
125
|
})]),
|
|
124
126
|
_: 3
|
|
125
|
-
}, 8, ["open"]));
|
|
127
|
+
}, 8, ["open"])) : u("", !0);
|
|
126
128
|
}
|
|
127
129
|
});
|
|
128
130
|
//#endregion
|
|
129
|
-
export {
|
|
131
|
+
export { I as default };
|
|
130
132
|
|
|
131
133
|
//# sourceMappingURL=InkSignatureMenu.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InkSignatureMenu.vue_vue_type_script_setup_true_lang.js","names":["$attrs","_openBlock","_createBlock","_unref","_withCtx","_createVNode","_createElementVNode","_mergeProps","_renderSlot","InkIcon","SignatureMenuPanel","InkSignatureDialog","InkSignatureDialog_default","InkIcon_default","SignatureMenuPanel_default","_hoisted_1","_hoisted_2","InkSignatureMenu_vue_vue_type_script_setup_true_lang_default","props","__props","NO_TEMPLATES","useTool","useToolOptions","ctx","useInkContext","templates","useReadable","model","computed","signatureMenuModel","options","active","tool","open","ref","creating","isOpen","main","useTemplateRef","focusFirst","toDialog","onTriggerKeydown","panel","onOpenAutoFocus","menu","menuItems","focusInitialMenuItem","onCloseAutoFocus","onMain","setTool","choose","setOptions","id","create","onDialogCloseAutoFocus","mainAttrs","SIGNATURE_LABELS","triggerAttrs","menuAttrs","openBlock","createBlock","unref","PopoverRoot","_cache","$event","withCtx","createVNode","PopoverAnchor","createElementVNode","mergeProps","_ctx","ToolbarButton","renderSlot","Signature","PopoverTrigger","ChevronDown","PopoverPortal","PopoverContent"],"sources":["../../src/components/InkSignatureMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * A split button for the signature tool. The main part activates the tool with the chosen\n * signature, or opens the menu when none is chosen; the chevron opens the saved signatures as\n * previews, each with a remove button, and \"Create signature\", which opens\n * `InkSignatureDialog`. Choosing a signature switches to the tool with it.\n */\nimport {\n focusInitialMenuItem,\n menuItems,\n SIGNATURE_LABELS,\n signatureMenuModel,\n} from '@inkbar/core/dom'\nimport { ChevronDown, Signature } from '@inkbar/icons'\nimport {\n PopoverAnchor,\n PopoverContent,\n PopoverPortal,\n PopoverRoot,\n PopoverTrigger,\n ToolbarButton,\n} from 'reka-ui'\nimport { computed, ref, useTemplateRef, watch } from 'vue'\n\nimport { useTool } from '../composables/useTool'\nimport { useToolOptions } from '../composables/useToolOptions'\nimport { useInkContext } from '../context'\nimport { useReadable } from '../use-readable'\n\nimport InkIcon from './InkIcon.vue'\nimport InkSignatureDialog from './InkSignatureDialog.vue'\nimport SignatureMenuPanel from './SignatureMenuPanel.vue'\n\nimport type { SignatureOptions, SignatureTemplate } from '@inkbar/core'\n\ndefineOptions({ inheritAttrs: false })\nconst props = defineProps<{\n /** The fonts the dialog's Type tab offers. Default: InkRoot's `signatureFonts`. */\n fonts?: readonly string[] | undefined\n}>()\n\nconst NO_TEMPLATES: readonly SignatureTemplate[] = []\n\nconst { tool, setTool } = useTool()\nconst { options, setOptions } = useToolOptions<SignatureOptions>('signature')\nconst ctx = useInkContext('InkSignatureMenu')\nconst templates = useReadable(() => ctx.signatures.value.templates, NO_TEMPLATES)\nconst model = computed(() => signatureMenuModel(templates.value, options.value))\nconst active = computed(() => tool.value === 'signature')\nconst open = ref(false)\nconst creating = ref(false)\n// An old removal error is not news when the menu opens again.\nwatch(open, (isOpen) => {\n if (isOpen) ctx.signatures.value.clearRemoveError()\n})\nconst main = useTemplateRef<{ $el: HTMLElement }>('main')\n\n/** ArrowDown opens on the first item; a click opens on the checked one. */\nlet focusFirst = false\n/** Set while the menu closes for the dialog, which takes focus instead of the trigger. */\nlet toDialog = false\n\nfunction onTriggerKeydown(e: KeyboardEvent): void {\n if (e.key !== 'ArrowDown' || e.defaultPrevented || open.value) return\n e.preventDefault()\n focusFirst = true\n open.value = true\n}\n\n// Not a signature field's menu, which shares the attribute.\nconst panel = (): HTMLElement | null =>\n document.querySelector<HTMLElement>(\n '[data-ink-menu=\"signature\"]:not([data-ink-sign-field-menu]) [role=\"menu\"]'\n )\n\nfunction onOpenAutoFocus(e: Event): void {\n e.preventDefault()\n const menu = panel()\n if (menu) {\n if (focusFirst) menuItems(menu)[0]?.focus({ preventScroll: true })\n else focusInitialMenuItem(menu)\n }\n focusFirst = false\n}\n\nfunction onCloseAutoFocus(e: Event): void {\n if (toDialog) e.preventDefault()\n toDialog = false\n}\n\nfunction onMain(): void {\n if (model.value.selected) setTool('signature')\n else open.value = true\n}\n\nfunction choose(id: string): void {\n setOptions({ templateId: id })\n setTool('signature')\n open.value = false\n}\n\nfunction create(): void {\n toDialog = true\n open.value = false\n creating.value = true\n}\n\nfunction onDialogCloseAutoFocus(e: Event): void {\n e.preventDefault()\n main.value?.$el.focus({ preventScroll: true })\n}\n\n// Reka's typed props stop at its own; ARIA and listeners go through bound objects.\nconst mainAttrs = computed(() => ({\n 'aria-pressed': String(active.value),\n 'aria-label': SIGNATURE_LABELS.sign,\n title: SIGNATURE_LABELS.sign,\n onClick: onMain,\n}))\nconst triggerAttrs = {\n 'aria-label': SIGNATURE_LABELS.trigger,\n title: SIGNATURE_LABELS.trigger,\n 'aria-haspopup': 'menu' as const,\n onKeydown: onTriggerKeydown,\n}\nconst menuAttrs = { 'aria-label': SIGNATURE_LABELS.menu }\n</script>\n\n<template>\n <PopoverRoot v-model:open=\"open\">\n <PopoverAnchor as-child>\n <div\n role=\"group\"\n :aria-label=\"SIGNATURE_LABELS.sign\"\n class=\"ink-split-button ink-signature-menu\"\n data-ink-signature-menu\n v-bind=\"$attrs\"\n >\n <ToolbarButton\n ref=\"main\"\n class=\"ink-tool-button ink-signature-button\"\n data-ink-tool-button\n data-ink-signature-button\n data-tool=\"signature\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"mainAttrs\"\n >\n <slot :active=\"active\"><InkIcon :icon=\"Signature\" /></slot>\n </ToolbarButton>\n <ToolbarButton as-child>\n <PopoverTrigger as-child>\n <button\n type=\"button\"\n class=\"ink-menu-trigger ink-signature-menu-trigger\"\n data-ink-signature-menu-trigger\n :data-state=\"open ? 'open' : 'closed'\"\n v-bind=\"triggerAttrs\"\n >\n <InkIcon :icon=\"ChevronDown\" />\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=\"signature\"\n side=\"bottom\"\n align=\"start\"\n :side-offset=\"4\"\n :collision-padding=\"8\"\n v-bind=\"menuAttrs\"\n @open-auto-focus=\"onOpenAutoFocus\"\n @close-auto-focus=\"onCloseAutoFocus\"\n >\n <SignatureMenuPanel\n :items=\"model.items\"\n @choose=\"choose($event.id)\"\n @create=\"create\"\n />\n </PopoverContent>\n </PopoverPortal>\n <InkSignatureDialog\n v-model:open=\"creating\"\n :fonts=\"props.fonts\"\n @close-auto-focus=\"onDialogCloseAutoFocus\"\n />\n </div>\n </PopoverAnchor>\n </PopoverRoot>\n</template>\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"InkSignatureMenu.vue_vue_type_script_setup_true_lang.js","names":["$attrs","_unref","_openBlock","_createBlock","_withCtx","_createVNode","_createElementVNode","_mergeProps","_renderSlot","InkIcon","SignatureMenuPanel","InkSignatureDialog","_createCommentVNode","InkSignatureDialog_default","InkIcon_default","SignatureMenuPanel_default","_hoisted_1","_hoisted_2","InkSignatureMenu_vue_vue_type_script_setup_true_lang_default","props","__props","NO_TEMPLATES","useTool","registered","useRegisteredTool","useToolOptionsWhile","ctx","useInkContext","templates","useReadable","model","computed","signatureMenuModel","options","active","tool","open","ref","creating","isOpen","main","useTemplateRef","focusFirst","toDialog","onTriggerKeydown","panel","onOpenAutoFocus","menu","menuItems","focusInitialMenuItem","onCloseAutoFocus","onMain","setTool","choose","setOptions","id","create","onDialogCloseAutoFocus","mainAttrs","SIGNATURE_LABELS","triggerAttrs","menuAttrs","unref","openBlock","createBlock","PopoverRoot","_cache","$event","withCtx","createVNode","PopoverAnchor","createElementVNode","mergeProps","_ctx","ToolbarButton","renderSlot","Signature","PopoverTrigger","ChevronDown","PopoverPortal","PopoverContent","createCommentVNode"],"sources":["../../src/components/InkSignatureMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * A split button for the signature tool. The main part activates the tool with the chosen\n * signature, or opens the menu when none is chosen; the chevron opens the saved signatures as\n * previews, each with a remove button, and \"Create signature\", which opens\n * `InkSignatureDialog`. Choosing a signature switches to the tool with it.\n */\nimport {\n focusInitialMenuItem,\n menuItems,\n SIGNATURE_LABELS,\n signatureMenuModel,\n} from '@inkbar/core/dom'\nimport { ChevronDown, Signature } from '@inkbar/icons'\nimport {\n PopoverAnchor,\n PopoverContent,\n PopoverPortal,\n PopoverRoot,\n PopoverTrigger,\n ToolbarButton,\n} from 'reka-ui'\nimport { computed, ref, useTemplateRef, watch } from 'vue'\n\nimport { useRegisteredTool } from '../composables/useRegisteredTool'\nimport { useTool } from '../composables/useTool'\nimport { useToolOptionsWhile } from '../composables/useToolOptions'\nimport { useInkContext } from '../context'\nimport { useReadable } from '../use-readable'\n\nimport InkIcon from './InkIcon.vue'\nimport InkSignatureDialog from './InkSignatureDialog.vue'\nimport SignatureMenuPanel from './SignatureMenuPanel.vue'\n\nimport type { SignatureOptions, SignatureTemplate } from '@inkbar/core'\n\ndefineOptions({ inheritAttrs: false })\nconst props = defineProps<{\n /** The fonts the dialog's Type tab offers. Default: InkRoot's `signatureFonts`. */\n fonts?: readonly string[] | undefined\n}>()\n\nconst NO_TEMPLATES: readonly SignatureTemplate[] = []\n\nconst { tool, setTool } = useTool()\n// Nothing renders while no `signature` tool is registered.\nconst registered = useRegisteredTool('signature')\nconst { options, setOptions } = useToolOptionsWhile<SignatureOptions>(\n 'signature',\n registered\n)\nconst ctx = useInkContext('InkSignatureMenu')\nconst templates = useReadable(() => ctx.signatures.value.templates, NO_TEMPLATES)\nconst model = computed(() => signatureMenuModel(templates.value, options.value))\nconst active = computed(() => tool.value === 'signature')\nconst open = ref(false)\nconst creating = ref(false)\n// An old removal error is not news when the menu opens again.\nwatch(open, (isOpen) => {\n if (isOpen) ctx.signatures.value.clearRemoveError()\n})\nconst main = useTemplateRef<{ $el: HTMLElement }>('main')\n\n/** ArrowDown opens on the first item; a click opens on the checked one. */\nlet focusFirst = false\n/** Set while the menu closes for the dialog, which takes focus instead of the trigger. */\nlet toDialog = false\n\nfunction onTriggerKeydown(e: KeyboardEvent): void {\n if (e.key !== 'ArrowDown' || e.defaultPrevented || open.value) return\n e.preventDefault()\n focusFirst = true\n open.value = true\n}\n\n// Not a signature field's menu, which shares the attribute.\nconst panel = (): HTMLElement | null =>\n document.querySelector<HTMLElement>(\n '[data-ink-menu=\"signature\"]:not([data-ink-sign-field-menu]) [role=\"menu\"]'\n )\n\nfunction onOpenAutoFocus(e: Event): void {\n e.preventDefault()\n const menu = panel()\n if (menu) {\n if (focusFirst) menuItems(menu)[0]?.focus({ preventScroll: true })\n else focusInitialMenuItem(menu)\n }\n focusFirst = false\n}\n\nfunction onCloseAutoFocus(e: Event): void {\n if (toDialog) e.preventDefault()\n toDialog = false\n}\n\nfunction onMain(): void {\n if (model.value.selected) setTool('signature')\n else open.value = true\n}\n\nfunction choose(id: string): void {\n setOptions({ templateId: id })\n setTool('signature')\n open.value = false\n}\n\nfunction create(): void {\n toDialog = true\n open.value = false\n creating.value = true\n}\n\nfunction onDialogCloseAutoFocus(e: Event): void {\n e.preventDefault()\n main.value?.$el.focus({ preventScroll: true })\n}\n\n// Reka's typed props stop at its own; ARIA and listeners go through bound objects.\nconst mainAttrs = computed(() => ({\n 'aria-pressed': String(active.value),\n 'aria-label': SIGNATURE_LABELS.sign,\n title: SIGNATURE_LABELS.sign,\n onClick: onMain,\n}))\nconst triggerAttrs = {\n 'aria-label': SIGNATURE_LABELS.trigger,\n title: SIGNATURE_LABELS.trigger,\n 'aria-haspopup': 'menu' as const,\n onKeydown: onTriggerKeydown,\n}\nconst menuAttrs = { 'aria-label': SIGNATURE_LABELS.menu }\n</script>\n\n<template>\n <PopoverRoot v-if=\"registered\" v-model:open=\"open\">\n <PopoverAnchor as-child>\n <div\n role=\"group\"\n :aria-label=\"SIGNATURE_LABELS.sign\"\n class=\"ink-split-button ink-signature-menu\"\n data-ink-signature-menu\n v-bind=\"$attrs\"\n >\n <ToolbarButton\n ref=\"main\"\n class=\"ink-tool-button ink-signature-button\"\n data-ink-tool-button\n data-ink-signature-button\n data-tool=\"signature\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"mainAttrs\"\n >\n <slot :active=\"active\"><InkIcon :icon=\"Signature\" /></slot>\n </ToolbarButton>\n <ToolbarButton as-child>\n <PopoverTrigger as-child>\n <button\n type=\"button\"\n class=\"ink-menu-trigger ink-signature-menu-trigger\"\n data-ink-signature-menu-trigger\n :data-state=\"open ? 'open' : 'closed'\"\n v-bind=\"triggerAttrs\"\n >\n <InkIcon :icon=\"ChevronDown\" />\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=\"signature\"\n side=\"bottom\"\n align=\"start\"\n :side-offset=\"4\"\n :collision-padding=\"8\"\n v-bind=\"menuAttrs\"\n @open-auto-focus=\"onOpenAutoFocus\"\n @close-auto-focus=\"onCloseAutoFocus\"\n >\n <SignatureMenuPanel\n :items=\"model.items\"\n @choose=\"choose($event.id)\"\n @create=\"create\"\n />\n </PopoverContent>\n </PopoverPortal>\n <InkSignatureDialog\n v-model:open=\"creating\"\n :fonts=\"props.fonts\"\n @close-auto-focus=\"onDialogCloseAutoFocus\"\n />\n </div>\n </PopoverAnchor>\n </PopoverRoot>\n</template>\n"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkThumbnail.js","names":["_sfc_main","InkThumbnail_vue_vue_type_script_setup_true_lang_default","InkThumbnail_default"],"sources":["../../src/components/InkThumbnail.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * One page as a static image, with its live annotations and plugin marks: core's thumbnail\n * painter on this element, which sizes it, names it (\"Page N\" unless `label` says otherwise)\n * and draws it once it nears the visible area. `page` is 0-based. `width` (default 120) or\n * `height` sets the size; the other follows the page. It is not focusable and does nothing on\n * click: wrap it in the control you need. Inside `InkRoot`; it renders empty on the server.\n */\nimport {\n createThumbnailPainter,\n type ThumbnailOptions,\n type ThumbnailPainter,\n} from '@inkbar/core/dom'\nimport { onBeforeUnmount, onMounted, useTemplateRef, watch } from 'vue'\n\nimport { injectInkContext } from '../context'\nimport { toReadable } from '../to-readable'\n\nconst props = withDefaults(\n defineProps<{\n page: number\n width?: number | undefined\n height?: number | undefined\n annotations?: boolean\n marks?: boolean\n label?: string | undefined\n }>(),\n {\n width: undefined,\n height: undefined,\n annotations: true,\n marks: true,\n label: undefined,\n }\n)\n\nconst ctx = injectInkContext()\nconst deps = {\n document: toReadable(() => ctx.document.value),\n pluginHost: toReadable(() => ctx.pluginHost.value),\n}\nconst options = (): ThumbnailOptions => ({\n page: props.page,\n width: props.width,\n height: props.height,\n annotations: props.annotations,\n marks: props.marks,\n label: props.label,\n})\n\nconst el = useTemplateRef<HTMLElement>('el')\nlet painter: ThumbnailPainter | null = null\nonMounted(() => {\n const p = createThumbnailPainter(el.value!, deps, options())\n painter = p\n watch(options, (next) => p.update(next))\n})\nonBeforeUnmount(() => {\n painter?.destroy()\n painter = null\n})\n</script>\n\n<template>\n <!-- The class is the painter's too: kept here, a re-render never drops it. -->\n <div ref=\"el\" class=\"ink-thumbnail\" />\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
page: number;
|
|
3
|
+
width?: number | undefined;
|
|
4
|
+
height?: number | undefined;
|
|
5
|
+
annotations?: boolean;
|
|
6
|
+
marks?: boolean;
|
|
7
|
+
label?: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
10
|
+
width: number | undefined;
|
|
11
|
+
annotations: boolean;
|
|
12
|
+
label: string | undefined;
|
|
13
|
+
height: number | undefined;
|
|
14
|
+
marks: boolean;
|
|
15
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
16
|
+
declare const _default: typeof __VLS_export;
|
|
17
|
+
export default _default;
|
|
18
|
+
//# sourceMappingURL=InkThumbnail.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkThumbnail.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkThumbnail.vue"],"names":[],"mappings":"AAuFA,KAAK,WAAW,GAAG;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC3B,CAAC;AA+DJ,QAAA,MAAM,YAAY;;;;;;6EAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { injectInkContext as e } from "../context.js";
|
|
2
|
+
import { toReadable as t } from "../to-readable.js";
|
|
3
|
+
import { createElementBlock as n, defineComponent as r, onBeforeUnmount as i, onMounted as a, openBlock as o, useTemplateRef as s, watch as c } from "vue";
|
|
4
|
+
import { createThumbnailPainter as l } from "@inkbar/core/dom";
|
|
5
|
+
//#region src/components/InkThumbnail.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
+
var u = /*@__PURE__*/ r({
|
|
7
|
+
__name: "InkThumbnail",
|
|
8
|
+
props: {
|
|
9
|
+
page: {},
|
|
10
|
+
width: { default: void 0 },
|
|
11
|
+
height: { default: void 0 },
|
|
12
|
+
annotations: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: !0
|
|
15
|
+
},
|
|
16
|
+
marks: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: !0
|
|
19
|
+
},
|
|
20
|
+
label: { default: void 0 }
|
|
21
|
+
},
|
|
22
|
+
setup(r) {
|
|
23
|
+
let u = r, d = e(), f = {
|
|
24
|
+
document: t(() => d.document.value),
|
|
25
|
+
pluginHost: t(() => d.pluginHost.value)
|
|
26
|
+
}, p = () => ({
|
|
27
|
+
page: u.page,
|
|
28
|
+
width: u.width,
|
|
29
|
+
height: u.height,
|
|
30
|
+
annotations: u.annotations,
|
|
31
|
+
marks: u.marks,
|
|
32
|
+
label: u.label
|
|
33
|
+
}), m = s("el"), h = null;
|
|
34
|
+
return a(() => {
|
|
35
|
+
let e = l(m.value, f, p());
|
|
36
|
+
h = e, c(p, (t) => e.update(t));
|
|
37
|
+
}), i(() => {
|
|
38
|
+
h?.destroy(), h = null;
|
|
39
|
+
}), (e, t) => (o(), n("div", {
|
|
40
|
+
ref_key: "el",
|
|
41
|
+
ref: m,
|
|
42
|
+
class: "ink-thumbnail"
|
|
43
|
+
}, null, 512));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
//#endregion
|
|
47
|
+
export { u as default };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=InkThumbnail.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkThumbnail.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","InkThumbnail_vue_vue_type_script_setup_true_lang_default","props","__props","ctx","injectInkContext","deps","toReadable","options","el","useTemplateRef","painter","onMounted","p","createThumbnailPainter","watch","next","onBeforeUnmount","openBlock","createElementBlock"],"sources":["../../src/components/InkThumbnail.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * One page as a static image, with its live annotations and plugin marks: core's thumbnail\n * painter on this element, which sizes it, names it (\"Page N\" unless `label` says otherwise)\n * and draws it once it nears the visible area. `page` is 0-based. `width` (default 120) or\n * `height` sets the size; the other follows the page. It is not focusable and does nothing on\n * click: wrap it in the control you need. Inside `InkRoot`; it renders empty on the server.\n */\nimport {\n createThumbnailPainter,\n type ThumbnailOptions,\n type ThumbnailPainter,\n} from '@inkbar/core/dom'\nimport { onBeforeUnmount, onMounted, useTemplateRef, watch } from 'vue'\n\nimport { injectInkContext } from '../context'\nimport { toReadable } from '../to-readable'\n\nconst props = withDefaults(\n defineProps<{\n page: number\n width?: number | undefined\n height?: number | undefined\n annotations?: boolean\n marks?: boolean\n label?: string | undefined\n }>(),\n {\n width: undefined,\n height: undefined,\n annotations: true,\n marks: true,\n label: undefined,\n }\n)\n\nconst ctx = injectInkContext()\nconst deps = {\n document: toReadable(() => ctx.document.value),\n pluginHost: toReadable(() => ctx.pluginHost.value),\n}\nconst options = (): ThumbnailOptions => ({\n page: props.page,\n width: props.width,\n height: props.height,\n annotations: props.annotations,\n marks: props.marks,\n label: props.label,\n})\n\nconst el = useTemplateRef<HTMLElement>('el')\nlet painter: ThumbnailPainter | null = null\nonMounted(() => {\n const p = createThumbnailPainter(el.value!, deps, options())\n painter = p\n watch(options, (next) => p.update(next))\n})\nonBeforeUnmount(() => {\n painter?.destroy()\n painter = null\n})\n</script>\n\n<template>\n <!-- The class is the painter's too: kept here, a re-render never drops it. -->\n <div ref=\"el\" class=\"ink-thumbnail\" />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;EAkBA,IAAMG,IAAQC,GAkBRC,IAAMC,EAAiB,GACvBC,IAAO;GACX,UAAUC,QAAiBH,EAAI,SAAS,KAAK;GAC7C,YAAYG,QAAiBH,EAAI,WAAW,KAAK;EACnD,GACMI,WAAmC;GACvC,MAAMN,EAAM;GACZ,OAAOA,EAAM;GACb,QAAQA,EAAM;GACd,aAAaA,EAAM;GACnB,OAAOA,EAAM;GACb,OAAOA,EAAM;EACf,IAEMO,IAAKC,EAA4B,IAAI,GACvCC,IAAmC;SACvCC,QAAgB;GACd,IAAMC,IAAIC,EAAuBL,EAAG,OAAQH,GAAME,EAAQ,CAAC;GAE3D,AADA,IAAUK,GACVE,EAAMP,IAAU,MAASK,EAAE,OAAOG,CAAI,CAAC;EACzC,CAAC,GACDC,QAAsB;GAEpB,AADAN,GAAS,QAAQ,GACjB,IAAU;EACZ,CAAC,cAKCZ,EAAA,GAAAC,EAAsC,OAAA;GAA7B,SAAA;GAAJ,KAAIS;GAAK,OAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkThumbnails.js","names":["_sfc_main","InkThumbnails_vue_vue_type_script_setup_true_lang_default","InkThumbnails_default"],"sources":["../../src/components/InkThumbnails.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The pages as a list of thumbnails: `createThumbnails`' markup on core's thumbnails\n * controller, which holds the current page, the keys, the clicks, the Tab stop and the window.\n * Only the items near the visible part are mounted, each placed at its offset over a spacer of\n * the full height, and each holds an `InkThumbnail`. An item is a button that scrolls the\n * viewport to its page; the current page's has `aria-current=\"page\"`.\n *\n * `pages` lists 0-based pages in order (default: all). The `item` slot, given `{ page, current }`,\n * renders inside each item after its number. The item's height is fixed from the page's, so\n * keep what you add out of the flow (position it absolutely) or small. Inside `InkRoot`; it\n * renders empty on the server.\n */\nimport {\n createThumbnailsController,\n THUMBNAIL_WIDTH,\n type ThumbnailsController,\n type ThumbnailsOptions,\n type ThumbnailsState,\n} from '@inkbar/core/dom'\nimport {\n computed,\n onBeforeUnmount,\n onMounted,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { injectInkContext } from '../context'\nimport { toReadable } from '../to-readable'\n\nimport InkThumbnail from './InkThumbnail.vue'\n\nconst props = withDefaults(\n defineProps<{\n pages?: readonly number[] | undefined\n width?: number | undefined\n annotations?: boolean\n marks?: boolean\n }>(),\n { pages: undefined, width: undefined, annotations: true, marks: true }\n)\n\ndefineSlots<{\n item?(props: { page: number; current: boolean }): unknown\n}>()\n\nconst ctx = injectInkContext()\nconst deps = {\n document: toReadable(() => ctx.document.value),\n pluginHost: toReadable(() => ctx.pluginHost.value),\n viewport: toReadable(() => ctx.viewport.value),\n}\nconst options = (): ThumbnailsOptions => ({\n pages: props.pages,\n width: props.width,\n annotations: props.annotations,\n marks: props.marks,\n})\n\nconst state = shallowRef<ThumbnailsState>({\n pages: [],\n current: -1,\n window: { start: 0, end: 0 },\n offsets: [0],\n width: THUMBNAIL_WIDTH,\n})\nlet controller: ThumbnailsController | null = null\nconst items = computed(() => {\n const { pages, current, window, offsets } = state.value\n return pages.slice(window.start, window.end).map((page, k) => {\n const top = offsets[window.start + k]!\n const bottom = offsets[window.start + k + 1]!\n // Only a mounted controller has a window, so `controller` is set here.\n const attrs = controller?.itemAttrs(window.start + k) ?? {}\n return { page, current: page === current, top, height: bottom - top, attrs }\n })\n})\n\nconst scroller = useTemplateRef<HTMLElement>('scroller')\nlet stopState: (() => void) | null = null\nonMounted(() => {\n const c = createThumbnailsController(deps, options())\n controller = c\n state.value = c.state.get()\n stopState = c.state.subscribe((s) => {\n state.value = s\n })\n watch(options, (next) => c.update(next))\n c.attach(scroller.value!)\n})\nonBeforeUnmount(() => {\n stopState?.()\n stopState = null\n controller?.destroy()\n controller = null\n})\n</script>\n\n<template>\n <div ref=\"scroller\" class=\"ink-thumbnails\" data-ink-thumbnails role=\"list\">\n <div\n class=\"ink-thumbnails-spacer\"\n aria-hidden=\"true\"\n :style=\"{ height: `${state.offsets.at(-1) ?? 0}px` }\"\n />\n <div\n v-for=\"item in items\"\n :key=\"item.page\"\n class=\"ink-thumbnails-entry\"\n v-bind=\"item.attrs\"\n :style=\"{ top: `${item.top}px`, height: `${item.height}px` }\"\n >\n <!-- The controller sets the tabindex. The thumbnail names the button \"Page N\"; the\n visible number repeats it. -->\n <button\n type=\"button\"\n class=\"ink-thumbnails-item\"\n :data-ink-thumbnail-item=\"item.page\"\n :aria-current=\"item.current ? 'page' : undefined\"\n >\n <InkThumbnail\n :page=\"item.page\"\n :width=\"state.width\"\n :annotations=\"annotations\"\n :marks=\"marks\"\n />\n <span class=\"ink-thumbnails-label\" aria-hidden=\"true\">{{ item.page + 1 }}</span>\n <slot name=\"item\" :page=\"item.page\" :current=\"item.current\" />\n </button>\n </div>\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
pages?: readonly number[] | undefined;
|
|
3
|
+
width?: number | undefined;
|
|
4
|
+
annotations?: boolean;
|
|
5
|
+
marks?: boolean;
|
|
6
|
+
};
|
|
7
|
+
type __VLS_Slots = {
|
|
8
|
+
item?(props: {
|
|
9
|
+
page: number;
|
|
10
|
+
current: boolean;
|
|
11
|
+
}): unknown;
|
|
12
|
+
};
|
|
13
|
+
declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
14
|
+
width: number | undefined;
|
|
15
|
+
annotations: boolean;
|
|
16
|
+
marks: boolean;
|
|
17
|
+
pages: readonly number[] | undefined;
|
|
18
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
19
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
20
|
+
declare const _default: typeof __VLS_export;
|
|
21
|
+
export default _default;
|
|
22
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
23
|
+
new (): {
|
|
24
|
+
$slots: S;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=InkThumbnails.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkThumbnails.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkThumbnails.vue"],"names":[],"mappings":"AA0KA,KAAK,WAAW,GAAG;IACf,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;IACrC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAC;AAMJ,KAAK,WAAW,GAAG;IACjB,IAAI,CAAC,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAA;CAC1D,CAAC;AAgIF,QAAA,MAAM,UAAU;;;;;6EAGd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { injectInkContext as e } from "../context.js";
|
|
2
|
+
import { toReadable as t } from "../to-readable.js";
|
|
3
|
+
import n from "./InkThumbnail.js";
|
|
4
|
+
import { Fragment as r, computed as i, createElementBlock as a, createElementVNode as o, createVNode as s, defineComponent as c, mergeProps as l, normalizeStyle as u, onBeforeUnmount as d, onMounted as f, openBlock as p, renderList as m, renderSlot as h, shallowRef as g, toDisplayString as _, useTemplateRef as v, watch as y } from "vue";
|
|
5
|
+
import { THUMBNAIL_WIDTH as b, createThumbnailsController as x } from "@inkbar/core/dom";
|
|
6
|
+
//#region src/components/InkThumbnails.vue?vue&type=script&setup=true&lang.ts
|
|
7
|
+
var S = ["data-ink-thumbnail-item", "aria-current"], C = {
|
|
8
|
+
class: "ink-thumbnails-label",
|
|
9
|
+
"aria-hidden": "true"
|
|
10
|
+
}, w = /*@__PURE__*/ c({
|
|
11
|
+
__name: "InkThumbnails",
|
|
12
|
+
props: {
|
|
13
|
+
pages: { default: void 0 },
|
|
14
|
+
width: { default: void 0 },
|
|
15
|
+
annotations: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: !0
|
|
18
|
+
},
|
|
19
|
+
marks: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: !0
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
setup(c) {
|
|
25
|
+
let w = c, T = e(), E = {
|
|
26
|
+
document: t(() => T.document.value),
|
|
27
|
+
pluginHost: t(() => T.pluginHost.value),
|
|
28
|
+
viewport: t(() => T.viewport.value)
|
|
29
|
+
}, D = () => ({
|
|
30
|
+
pages: w.pages,
|
|
31
|
+
width: w.width,
|
|
32
|
+
annotations: w.annotations,
|
|
33
|
+
marks: w.marks
|
|
34
|
+
}), O = g({
|
|
35
|
+
pages: [],
|
|
36
|
+
current: -1,
|
|
37
|
+
window: {
|
|
38
|
+
start: 0,
|
|
39
|
+
end: 0
|
|
40
|
+
},
|
|
41
|
+
offsets: [0],
|
|
42
|
+
width: b
|
|
43
|
+
}), k = null, A = i(() => {
|
|
44
|
+
let { pages: e, current: t, window: n, offsets: r } = O.value;
|
|
45
|
+
return e.slice(n.start, n.end).map((e, i) => {
|
|
46
|
+
let a = r[n.start + i], o = r[n.start + i + 1], s = k?.itemAttrs(n.start + i) ?? {};
|
|
47
|
+
return {
|
|
48
|
+
page: e,
|
|
49
|
+
current: e === t,
|
|
50
|
+
top: a,
|
|
51
|
+
height: o - a,
|
|
52
|
+
attrs: s
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
}), j = v("scroller"), M = null;
|
|
56
|
+
return f(() => {
|
|
57
|
+
let e = x(E, D());
|
|
58
|
+
k = e, O.value = e.state.get(), M = e.state.subscribe((e) => {
|
|
59
|
+
O.value = e;
|
|
60
|
+
}), y(D, (t) => e.update(t)), e.attach(j.value);
|
|
61
|
+
}), d(() => {
|
|
62
|
+
M?.(), M = null, k?.destroy(), k = null;
|
|
63
|
+
}), (e, t) => (p(), a("div", {
|
|
64
|
+
ref_key: "scroller",
|
|
65
|
+
ref: j,
|
|
66
|
+
class: "ink-thumbnails",
|
|
67
|
+
"data-ink-thumbnails": "",
|
|
68
|
+
role: "list"
|
|
69
|
+
}, [o("div", {
|
|
70
|
+
class: "ink-thumbnails-spacer",
|
|
71
|
+
"aria-hidden": "true",
|
|
72
|
+
style: u({ height: `${O.value.offsets.at(-1) ?? 0}px` })
|
|
73
|
+
}, null, 4), (p(!0), a(r, null, m(A.value, (t) => (p(), a("div", l({
|
|
74
|
+
key: t.page,
|
|
75
|
+
class: "ink-thumbnails-entry"
|
|
76
|
+
}, { ref_for: !0 }, t.attrs, { style: {
|
|
77
|
+
top: `${t.top}px`,
|
|
78
|
+
height: `${t.height}px`
|
|
79
|
+
} }), [o("button", {
|
|
80
|
+
type: "button",
|
|
81
|
+
class: "ink-thumbnails-item",
|
|
82
|
+
"data-ink-thumbnail-item": t.page,
|
|
83
|
+
"aria-current": t.current ? "page" : void 0
|
|
84
|
+
}, [
|
|
85
|
+
s(n, {
|
|
86
|
+
page: t.page,
|
|
87
|
+
width: O.value.width,
|
|
88
|
+
annotations: c.annotations,
|
|
89
|
+
marks: c.marks
|
|
90
|
+
}, null, 8, [
|
|
91
|
+
"page",
|
|
92
|
+
"width",
|
|
93
|
+
"annotations",
|
|
94
|
+
"marks"
|
|
95
|
+
]),
|
|
96
|
+
o("span", C, _(t.page + 1), 1),
|
|
97
|
+
h(e.$slots, "item", {
|
|
98
|
+
page: t.page,
|
|
99
|
+
current: t.current
|
|
100
|
+
})
|
|
101
|
+
], 8, S)], 16))), 128))], 512));
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
//#endregion
|
|
105
|
+
export { w as default };
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=InkThumbnails.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InkThumbnails.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createElementVNode","_normalizeStyle","_Fragment","_renderList","_mergeProps","_createVNode","InkThumbnail","_toDisplayString","_renderSlot","InkThumbnail_default","_hoisted_1","_hoisted_2","InkThumbnails_vue_vue_type_script_setup_true_lang_default","props","__props","ctx","injectInkContext","deps","toReadable","options","state","shallowRef","THUMBNAIL_WIDTH","controller","items","computed","pages","window","top","offsets","k","bottom","attrs","page","current","scroller","useTemplateRef","stopState","onMounted","c","createThumbnailsController","s","watch","next","onBeforeUnmount","openBlock","createElementBlock","createElementVNode","normalizeStyle","Fragment","renderList","mergeProps","item","createVNode","toDisplayString","renderSlot","_ctx"],"sources":["../../src/components/InkThumbnails.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The pages as a list of thumbnails: `createThumbnails`' markup on core's thumbnails\n * controller, which holds the current page, the keys, the clicks, the Tab stop and the window.\n * Only the items near the visible part are mounted, each placed at its offset over a spacer of\n * the full height, and each holds an `InkThumbnail`. An item is a button that scrolls the\n * viewport to its page; the current page's has `aria-current=\"page\"`.\n *\n * `pages` lists 0-based pages in order (default: all). The `item` slot, given `{ page, current }`,\n * renders inside each item after its number. The item's height is fixed from the page's, so\n * keep what you add out of the flow (position it absolutely) or small. Inside `InkRoot`; it\n * renders empty on the server.\n */\nimport {\n createThumbnailsController,\n THUMBNAIL_WIDTH,\n type ThumbnailsController,\n type ThumbnailsOptions,\n type ThumbnailsState,\n} from '@inkbar/core/dom'\nimport {\n computed,\n onBeforeUnmount,\n onMounted,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { injectInkContext } from '../context'\nimport { toReadable } from '../to-readable'\n\nimport InkThumbnail from './InkThumbnail.vue'\n\nconst props = withDefaults(\n defineProps<{\n pages?: readonly number[] | undefined\n width?: number | undefined\n annotations?: boolean\n marks?: boolean\n }>(),\n { pages: undefined, width: undefined, annotations: true, marks: true }\n)\n\ndefineSlots<{\n item?(props: { page: number; current: boolean }): unknown\n}>()\n\nconst ctx = injectInkContext()\nconst deps = {\n document: toReadable(() => ctx.document.value),\n pluginHost: toReadable(() => ctx.pluginHost.value),\n viewport: toReadable(() => ctx.viewport.value),\n}\nconst options = (): ThumbnailsOptions => ({\n pages: props.pages,\n width: props.width,\n annotations: props.annotations,\n marks: props.marks,\n})\n\nconst state = shallowRef<ThumbnailsState>({\n pages: [],\n current: -1,\n window: { start: 0, end: 0 },\n offsets: [0],\n width: THUMBNAIL_WIDTH,\n})\nlet controller: ThumbnailsController | null = null\nconst items = computed(() => {\n const { pages, current, window, offsets } = state.value\n return pages.slice(window.start, window.end).map((page, k) => {\n const top = offsets[window.start + k]!\n const bottom = offsets[window.start + k + 1]!\n // Only a mounted controller has a window, so `controller` is set here.\n const attrs = controller?.itemAttrs(window.start + k) ?? {}\n return { page, current: page === current, top, height: bottom - top, attrs }\n })\n})\n\nconst scroller = useTemplateRef<HTMLElement>('scroller')\nlet stopState: (() => void) | null = null\nonMounted(() => {\n const c = createThumbnailsController(deps, options())\n controller = c\n state.value = c.state.get()\n stopState = c.state.subscribe((s) => {\n state.value = s\n })\n watch(options, (next) => c.update(next))\n c.attach(scroller.value!)\n})\nonBeforeUnmount(() => {\n stopState?.()\n stopState = null\n controller?.destroy()\n controller = null\n})\n</script>\n\n<template>\n <div ref=\"scroller\" class=\"ink-thumbnails\" data-ink-thumbnails role=\"list\">\n <div\n class=\"ink-thumbnails-spacer\"\n aria-hidden=\"true\"\n :style=\"{ height: `${state.offsets.at(-1) ?? 0}px` }\"\n />\n <div\n v-for=\"item in items\"\n :key=\"item.page\"\n class=\"ink-thumbnails-entry\"\n v-bind=\"item.attrs\"\n :style=\"{ top: `${item.top}px`, height: `${item.height}px` }\"\n >\n <!-- The controller sets the tabindex. The thumbnail names the button \"Page N\"; the\n visible number repeats it. -->\n <button\n type=\"button\"\n class=\"ink-thumbnails-item\"\n :data-ink-thumbnail-item=\"item.page\"\n :aria-current=\"item.current ? 'page' : undefined\"\n >\n <InkThumbnail\n :page=\"item.page\"\n :width=\"state.width\"\n :annotations=\"annotations\"\n :marks=\"marks\"\n />\n <span class=\"ink-thumbnails-label\" aria-hidden=\"true\">{{ item.page + 1 }}</span>\n <slot name=\"item\" :page=\"item.page\" :current=\"item.current\" />\n </button>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EAkCA,IAAMe,IAAQC,GAcRC,IAAMC,EAAiB,GACvBC,IAAO;GACX,UAAUC,QAAiBH,EAAI,SAAS,KAAK;GAC7C,YAAYG,QAAiBH,EAAI,WAAW,KAAK;GACjD,UAAUG,QAAiBH,EAAI,SAAS,KAAK;EAC/C,GACMI,WAAoC;GACxC,OAAON,EAAM;GACb,OAAOA,EAAM;GACb,aAAaA,EAAM;GACnB,OAAOA,EAAM;EACf,IAEMO,IAAQC,EAA4B;GACxC,OAAO,CAAC;GACR,SAAS;GACT,QAAQ;IAAE,OAAO;IAAG,KAAK;GAAE;GAC3B,SAAS,CAAC,CAAC;GACX,OAAOC;EACT,CAAC,GACGC,IAA0C,MACxCC,IAAQC,QAAe;GAC3B,IAAM,EAAE,UAAO,YAAS,WAAQ,eAAYL,EAAM;GAClD,OAAOM,EAAM,MAAMC,EAAO,OAAOA,EAAO,GAAG,CAAC,CAAC,KAAK,GAAM,MAAM;IAC5D,IAAMC,IAAMC,EAAQF,EAAO,QAAQG,IAC7BC,IAASF,EAAQF,EAAO,QAAQG,IAAI,IAEpCE,IAAQT,GAAY,UAAUI,EAAO,QAAQG,CAAC,KAAK,CAAC;IAC1D,OAAO;KAAE;KAAM,SAASG,MAASC;KAAS;KAAK,QAAQH,IAASH;KAAK;IAAM;GAC7E,CAAC;EACH,CAAC,GAEKO,IAAWC,EAA4B,UAAU,GACnDC,IAAiC;SACrCC,QAAgB;GACd,IAAMC,IAAIC,EAA2BvB,GAAME,EAAQ,CAAC;GAOpD,AANA,IAAaoB,GACb,EAAM,QAAQA,EAAE,MAAM,IAAI,GAC1B,IAAYA,EAAE,MAAM,WAAW,MAAM;IACnC,EAAM,QAAQE;GAChB,CAAC,GACDC,EAAMvB,IAAU,MAASoB,EAAE,OAAOI,CAAI,CAAC,GACvCJ,EAAE,OAAOJ,EAAS,KAAM;EAC1B,CAAC,GACDS,QAAsB;GAIpB,AAHAP,IAAY,GACZ,IAAY,MACZd,GAAY,QAAQ,GACpB,IAAa;EACf,CAAC,cAICzB,EAAA,GAAAC,EA+BM,OAAA;GA/BG,SAAA;GAAJ,KAAIoC;GAAW,OAAM;GAAiB,uBAAA;GAAoB,MAAK;EAClEnC,GAAAA,CAAAA,EAIE,OAAA;GAHA,OAAM;GACN,eAAY;GACX,OAAKC,EAAA,EAAA,QAAA,GAAemB,EAAA,MAAM,QAAQ,GAAE,EAAA,KAAA,EAAA,IAAA,CAAA;EAEvCtB,GAAAA,MAAAA,CAAAA,IAAAA,EAAA,EAAA,GAAAC,EAwBMG,GAAA,MAAAC,EAvBWqB,EAAA,QAAR,OADT1B,EAAA,GAAAC,EAwBM,OAxBNK,EAwBM;GAtBH,KAAKgD,EAAK;GACX,OAAM;EACE,GAAA,EAAA,SAAA,GAAA,GAAAA,EAAK,OAAK,EACjB,OAAK;GAAA,KAAA,GAAYA,EAAK,IAAG;GAAA,QAAA,GAAiBA,EAAK,OAAM;EAAA,EAAA,CAAA,GAAA,CAItDpD,EAcS,UAAA;GAbP,MAAK;GACL,OAAM;GACL,2BAAyBoD,EAAK;GAC9B,gBAAcA,EAAK,UAAO,SAAY,KAAA;;GAEvC/C,EAKEC,GAAA;IAJC,MAAM8C,EAAK;IACX,OAAOhC,EAAA,MAAM;IACb,aAAaN,EAAA;IACb,OAAOA,EAAA;;;;;;;GAEVd,EAAgF,QAAhFW,GAAgFJ,EAAvB6C,EAAK,OAAI,CAAA,GAAA,CAAA;GAClE5C,EAA8DgD,EAAA,QAAA,QAAA;IAA3C,MAAMJ,EAAK;IAAO,SAASA,EAAK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InkToolButton.js","names":["_sfc_main","InkToolButton_vue_vue_type_script_setup_true_lang_default","InkToolButton_default"],"sources":["../../src/components/InkToolButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { TOOL_LABELS } from '@inkbar/core/dom'\nimport {
|
|
1
|
+
{"version":3,"file":"InkToolButton.js","names":["_sfc_main","InkToolButton_vue_vue_type_script_setup_true_lang_default","InkToolButton_default"],"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":""}
|