@inkbar/vue 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/dist/components/InkHighlightMenu.js.map +1 -1
- package/dist/components/InkHighlightMenu.vue.d.ts.map +1 -1
- package/dist/components/InkHighlightMenu.vue_vue_type_script_setup_true_lang.js +67 -65
- package/dist/components/InkHighlightMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkRoot.js.map +1 -1
- package/dist/components/InkRoot.vue.d.ts +9 -4
- package/dist/components/InkRoot.vue.d.ts.map +1 -1
- package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js +176 -163
- package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/InkShapeMenu.js.map +1 -1
- package/dist/components/InkShapeMenu.vue.d.ts.map +1 -1
- package/dist/components/InkShapeMenu.vue_vue_type_script_setup_true_lang.js +58 -56
- package/dist/components/InkShapeMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/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/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/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/composables/useRegisteredTool.d.ts +21 -0
- package/dist/composables/useRegisteredTool.d.ts.map +1 -0
- package/dist/composables/useRegisteredTool.js +25 -0
- package/dist/composables/useRegisteredTool.js.map +1 -0
- package/dist/composables/useToolOptions.d.ts +8 -0
- package/dist/composables/useToolOptions.d.ts.map +1 -1
- package/dist/composables/useToolOptions.js +10 -5
- package/dist/composables/useToolOptions.js.map +1 -1
- package/dist/context.d.ts +5 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -20
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InkViewport.vue_vue_type_script_setup_true_lang.js","names":["_useSlots","_openBlock","_createElementBlock","_renderSlot","_createTextVNode","_createElementVNode","_toDisplayString","_createCommentVNode","_Fragment","_renderList","_createBlock","InkPage","_createSlots","_withCtx","_mergeProps","InkSignFieldPopover","_unref","_createVNode","InkFormAlert","InkFormAlert_default","InkPage_default","InkSignFieldPopover_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","InkViewport_vue_vue_type_script_setup_true_lang_default","props","__props","slots","useSlots","ctx","injectInkContext","scroll","useTemplateRef","documentKeys","documentKeyCount","documentKey","doc","key","pages","shallowRef","state","computed","error","engine","signRequest","alertMessage","alertsShown","build","custom","stops","lastReportedZoom","lastReportedPage","teardown","stop","rebuild","e","opts","setup","el","first","mountViewer","a","fn","req","message","id","vp","tc","reportZoom","z","reportPage","p","page","err","onMounted","watch","on","t","m","r","gap","buffer","onBeforeUpdate","next","onBeforeUnmount","openBlock","createElementBlock","renderSlot","_ctx","_cache","createTextVNode","createElementVNode","toDisplayString","createCommentVNode","Fragment","renderList","createBlock","createSlots","withCtx","mergeProps","slotProps","unref","createVNode"],"sources":["../../src/components/InkViewport.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The scroll element is handed to core's `mountViewer`, which builds the viewport, the page\n * layers, the tool controller and the keyboard shortcuts in it; Vue never renders children\n * into it. The engine reports each page host it mounts, and InkPage components rendered here\n * (they render nothing in place) teleport the page-error and custom-annotation slots into them.\n *\n * Two-way zoom and page: the viewport's own changes are reported through the context, and\n * the host's v-model values are applied only when they differ from the viewport's state, so\n * the echo of a reported value does nothing.\n *\n * Form fields render in the engine's form layer. A signature field's \"Sign\" opens\n * `InkSignFieldPopover`, and a form script's alert shows in `InkFormAlert`; both are mounted\n * here, so hosts compose nothing for them.\n */\nimport { mountViewer } from '@inkbar/core/dom'\nimport {\n computed,\n onBeforeUnmount,\n onBeforeUpdate,\n onMounted,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { injectInkContext } from '../context'\n\nimport InkFormAlert from './InkFormAlert.vue'\nimport InkPage from './InkPage.vue'\nimport InkSignFieldPopover from './InkSignFieldPopover.vue'\n\nimport type { AnnotationSlotProps } from './annotation-slot'\nimport type { InkDocument, InkError } from '@inkbar/core'\nimport type {\n LayoutMode,\n PageMount,\n SignFieldRequest,\n ToolId,\n ViewerEngine,\n ViewRotation,\n ZoomValue,\n} from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{\n mode?: LayoutMode\n rotation?: ViewRotation\n /** Gap between pages, CSS px. */\n gap?: number\n /** Pages kept mounted either side of the visible ones. */\n buffer?: number\n }>(),\n { mode: 'continuous', rotation: 0, gap: 16, buffer: 2 }\n)\n\nconst slots = defineSlots<{\n loading?(): unknown\n error?(props: { error: InkError }): unknown\n empty?(): unknown\n annotation?(props: AnnotationSlotProps): unknown\n /** Shown inside a page that failed to render. The rest of the document stays usable. */\n 'page-error'?(props: { error: InkError; page: number }): unknown\n}>()\n\nconst ctx = injectInkContext()\nconst scroll = useTemplateRef<HTMLElement>('scroll')\n\ninterface MountedPage {\n /** The engine build the host belongs to; part of the InkPage key. */\n build: number\n page: number\n host: HTMLElement\n mount: PageMount\n error: InkError | null\n /** Whether the build that mounted the page renders the annotation slot. */\n custom: boolean\n}\n/** A key per document, so the field menu and its dialog start afresh for each one. */\nconst documentKeys = new WeakMap<InkDocument, number>()\nlet documentKeyCount = 0\nfunction documentKey(doc: InkDocument | null): number {\n if (!doc) return 0\n let key = documentKeys.get(doc)\n if (key === undefined) {\n key = ++documentKeyCount\n documentKeys.set(doc, key)\n }\n return key\n}\n\n/** Page hosts, mounts and errors the engine reported; InkPage renders Teleports for them. */\nconst pages = shallowRef<MountedPage[]>([])\n\nconst state = computed(() => ctx.status.value.state)\nconst error = computed<InkError | null>(() =>\n ctx.status.value.state === 'error' ? ctx.status.value.error : null\n)\n\nconst engine = shallowRef<ViewerEngine | null>(null)\n/** The signature field whose menu is open. */\nconst signRequest = shallowRef<SignFieldRequest | null>(null)\n/** The form script's message on show, and how many have been shown. */\nconst alertMessage = shallowRef<string | null>(null)\nconst alertsShown = shallowRef(0)\n/**\n * Numbered before each build starts, so the pages a build mounts carry its own number. A\n * rebuild gives each page a new host and mount, so pages from an earlier build must remount,\n * not be reused.\n */\nlet build = 0\n/** Whether the current build renders the annotation slot. */\nlet custom = false\nlet stops: (() => void)[] = []\n/** The zoom and page last reported to the host. */\nlet lastReportedZoom: ZoomValue | undefined\nlet lastReportedPage: number | undefined\n\nfunction teardown(): void {\n for (const stop of stops) stop()\n stops = []\n // Unmounts every page, which empties `pages` through `onPageUnmount`.\n engine.value?.destroy()\n engine.value = null\n if (ctx.viewport.value) ctx.viewport.value = null\n if (ctx.tools.value) ctx.tools.value = null\n pages.value = []\n // Their fields and the document they came from are gone.\n signRequest.value = null\n alertMessage.value = null\n}\n\nfunction rebuild(opts: Parameters<ViewerEngine['rebuild']>[0]): void {\n const e = engine.value\n if (!e) return\n build += 1\n if (opts.customAnnotations !== undefined) custom = opts.customAnnotations\n e.rebuild(opts)\n}\n\n// Build for a new document or status; the previous engine is torn down first.\nfunction setup(): void {\n teardown()\n lastReportedZoom = undefined\n lastReportedPage = undefined\n const doc = ctx.document.value\n const el = scroll.value\n if (!doc || !el || ctx.status.value.state !== 'ready') return\n let first = true\n build += 1\n custom = !!slots.annotation\n engine.value = mountViewer({\n container: el,\n document: doc,\n zoom: ctx.zoomModel.value ?? 'fit-width',\n ...(ctx.pageModel.value === undefined ? {} : { page: ctx.pageModel.value }),\n mode: props.mode,\n rotation: props.rotation,\n gap: props.gap,\n buffer: props.buffer,\n tool: ctx.tool.value,\n ...(ctx.hostTools.value ? { tools: ctx.hostTools.value } : {}),\n // The engine adds the plugins' tools and layers, and decorates through the host, which\n // reads `decorateAnnotation` first.\n ...(ctx.pluginHost.value ? { plugins: ctx.pluginHost.value } : {}),\n // The engine draws the search matches on the pages.\n ...(ctx.search.value ? { search: ctx.search.value } : {}),\n // Read through, so the watch below can re-apply a new function without a rebuild.\n decorateAnnotation: (a) => ctx.decorateAnnotation.value?.(a),\n ...(ctx.toolStyle.value ? { toolStyle: ctx.toolStyle.value } : {}),\n toolHistory: { batch: (fn) => ctx.history.batch(fn) },\n toolOptions: ctx.toolOptions,\n fonts: [...ctx.fonts.value],\n // Read through, so a new `signatures` store reaches the tool as well as the menus.\n signatureLibrary: () => ctx.signatures.value,\n customAnnotations: custom,\n ...(ctx.formHighlight.value === undefined\n ? {}\n : { formHighlight: ctx.formHighlight.value }),\n // The field's own button again, while its menu is open, closes the menu.\n onSignField: (req) => {\n signRequest.value = signRequest.value?.widget === req.widget ? null : req\n },\n onFormAction: (a) => ctx.reportFormAction(a),\n onFormAlert: (message) => {\n alertMessage.value = message\n alertsShown.value += 1\n },\n onActivate: (id) => ctx.setActivated(id),\n onBuild: (vp, tc) => {\n ctx.viewport.value = vp\n ctx.tools.value = tc\n if (first) {\n // A new document starts from where the viewport opens (its zoom, on the first page:\n // `createViewport` always starts at page 0); only later changes are reported, the\n // restored page among them, since the engine has already scrolled to it.\n first = false\n lastReportedZoom = vp.zoom.get()\n lastReportedPage = 0\n }\n for (const stop of stops) stop()\n const reportZoom = (z: ZoomValue): void => {\n if (z === lastReportedZoom) return\n lastReportedZoom = z\n ctx.reportZoom(z)\n }\n const reportPage = (p: number): void => {\n if (p === lastReportedPage) return\n lastReportedPage = p\n ctx.reportPage(p)\n }\n // A tool that switches itself (a one-shot tool once used) is reported as a pick.\n const followTool = (id: ToolId): void => {\n if (id !== ctx.tool.value) ctx.setTool(id)\n }\n stops = [\n vp.zoom.subscribe(reportZoom),\n vp.currentPage.subscribe(reportPage),\n tc.active.subscribe(followTool),\n ]\n // Whatever the build restored is reported once; nothing is when it matched.\n reportZoom(vp.zoom.get())\n reportPage(vp.currentPage.get())\n },\n onPageMount: (page, mount, host) => {\n pages.value = [...pages.value, { build, page, host, mount, error: null, custom }]\n },\n onPageUnmount: (page) => {\n pages.value = pages.value.filter((p) => p.page !== page)\n },\n onPageError: (page, err) => {\n pages.value = pages.value.map((p) => (p.page === page ? { ...p, error: err } : p))\n },\n })\n}\n\nonMounted(() => {\n ctx.viewportEl.value = scroll.value\n watch([() => ctx.document.value, () => ctx.status.value.state], setup, {\n immediate: true,\n })\n})\n\n// A new decorateAnnotation re-applies to the mounted annotation elements at once.\nwatch(\n () => ctx.decorateAnnotation.value,\n () => engine.value?.redecorate()\n)\n// The tint follows `formHighlight` in place, without a new document.\nwatch(\n () => ctx.formHighlight.value,\n (on) => engine.value?.setFormHighlight(on ?? true)\n)\nwatch(\n () => ctx.zoomModel.value,\n (z: ZoomValue | undefined) => {\n const vp = engine.value?.viewport\n if (vp && z !== undefined && z !== vp.zoom.get()) vp.setZoom(z)\n }\n)\nwatch(\n () => ctx.pageModel.value,\n (p) => {\n const vp = engine.value?.viewport\n if (!vp || p === undefined || p === lastReportedPage) return\n if (p !== vp.currentPage.get()) vp.scrollToPage(p)\n }\n)\nwatch(\n () => ctx.tool.value,\n (t) => {\n const tc = engine.value?.tools\n if (tc && tc.active.get() !== t) tc.set(t)\n }\n)\nwatch(\n () => props.mode,\n (m) => engine.value?.viewport.setMode(m)\n)\nwatch(\n () => props.rotation,\n (r) => engine.value?.viewport.setRotation(r)\n)\n// Gap and buffer are construction options: rebuild for the same document, keeping zoom and page.\n// The slots are already updated when this runs, so it carries the annotation slot too: a slot\n// toggle in the same tick is then recorded here and `onBeforeUpdate` finds nothing left to do.\nwatch([() => props.gap, () => props.buffer], ([gap, buffer]) =>\n rebuild({ gap, buffer, customAnnotations: !!slots.annotation })\n)\n\n// Slots are not reactive, so a change to whether the annotation slot is given is caught here.\n// `onBeforeUpdate` runs after the new slots are in place and before this render: the rebuild\n// swaps `pages` for the new build's pages synchronously, so the render that follows never pairs\n// the annotation slot with an overlay built without it (or the reverse). The rebuild keeps the\n// scroll position.\nonBeforeUpdate(() => {\n const next = !!slots.annotation\n if (engine.value && next !== custom) rebuild({ customAnnotations: next })\n})\n\nonBeforeUnmount(() => {\n teardown()\n if (ctx.viewportEl.value === scroll.value) ctx.viewportEl.value = null\n})\n</script>\n\n<template>\n <div class=\"ink-viewport-root\" data-ink-viewport-root :data-state=\"state\">\n <div v-if=\"state === 'loading'\" class=\"ink-status\" role=\"status\" aria-live=\"polite\">\n <slot name=\"loading\">Loading document…</slot>\n </div>\n <div v-else-if=\"error\" class=\"ink-status ink-error\" role=\"alert\">\n <slot name=\"error\" :error=\"error\">\n <p class=\"ink-error-title\">This document could not be opened.</p>\n <!-- The message comes from the PDF engine and is not written for readers: it stays\n off the page, on the code's tooltip. -->\n <p>\n <code class=\"ink-error-code\" :title=\"error.message\">{{ error.code }}</code>\n </p>\n </slot>\n </div>\n <div v-else-if=\"state === 'idle'\" class=\"ink-status ink-empty\">\n <slot name=\"empty\" />\n </div>\n <div\n ref=\"scroll\"\n class=\"ink-scroll\"\n data-ink-scroll\n tabindex=\"0\"\n role=\"document\"\n aria-label=\"Document\"\n />\n <InkPage\n v-for=\"p in pages\"\n :key=\"`${p.build}:${p.page}`\"\n :page=\"p.page\"\n :host=\"p.host\"\n :mount=\"p.mount\"\n :error=\"p.error\"\n :custom-annotations=\"p.custom\"\n >\n <template v-if=\"slots.annotation\" #annotation=\"slotProps\">\n <slot name=\"annotation\" v-bind=\"slotProps\" />\n </template>\n <template v-if=\"slots['page-error']\" #page-error=\"slotProps\">\n <slot name=\"page-error\" v-bind=\"slotProps\" />\n </template>\n </InkPage>\n <!-- Keyed by document, so the menu and its dialog start afresh for each one. -->\n <InkSignFieldPopover\n :key=\"documentKey(ctx.document.value)\"\n :request=\"signRequest\"\n @close=\"signRequest = null\"\n />\n <InkFormAlert\n :message=\"alertMessage\"\n :shown=\"alertsShown\"\n :fallback=\"scroll\"\n @close=\"alertMessage = null\"\n />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4CA,IAAM4B,IAAQC,GAYRC,IAAQ9B,EAAA,GASRgC,IAAMC,EAAiB,GACvBC,IAASC,EAA4B,QAAQ,GAa7CC,oBAAe,IAAI,QAA6B,GAClDC,IAAmB;EACvB,SAASC,EAAY,GAAiC;GACpD,IAAI,CAACC,GAAK,OAAO;GACjB,IAAIC,IAAMJ,EAAa,IAAIG,CAAG;GAK9B,OAJIC,MAAQ,KAAA,MACV,IAAM,EAAEH,GACRD,EAAa,IAAIG,GAAKC,CAAG,IAEpBA;EACT;EAGA,IAAMC,IAAQC,EAA0B,CAA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B,EAAYtB,EAAAgB,CAAA,CAAG,CAAC,SAAS,KAAK;IACnC,SAASe,EAAA;IACT,SAAK,AAAA6C,EAAA,QAAA,MAAE,EAAA,QAAW;;GAErB3E,EAKEC,GAAA;IAJC,SAAS8B,EAAA;IACT,OAAOC,EAAA;IACP,UAAUf,EAAA;IACV,SAAK,AAAA0D,EAAA,QAAA,MAAE,EAAA,QAAY"}
|
|
1
|
+
{"version":3,"file":"InkViewport.vue_vue_type_script_setup_true_lang.js","names":["_useSlots","_openBlock","_createElementBlock","_renderSlot","_createTextVNode","_createElementVNode","_toDisplayString","_createCommentVNode","_Fragment","_renderList","_createBlock","InkPage","_createSlots","_withCtx","_mergeProps","InkSignFieldPopover","_unref","_createVNode","InkFormAlert","InkFormAlert_default","InkPage_default","InkSignFieldPopover_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","InkViewport_vue_vue_type_script_setup_true_lang_default","props","__props","slots","useSlots","ctx","injectInkContext","scroll","useTemplateRef","documentKeys","documentKeyCount","documentKey","doc","key","pages","shallowRef","state","computed","error","engine","signRequest","alertMessage","alertsShown","build","custom","stops","lastReportedZoom","lastReportedPage","teardown","stop","rebuild","e","opts","setup","el","first","toolIdsOf","mountViewer","a","fn","req","message","id","vp","tc","reportZoom","z","reportPage","p","page","err","onMounted","watch","on","t","m","r","gap","buffer","onBeforeUpdate","next","onBeforeUnmount","openBlock","createElementBlock","renderSlot","_ctx","_cache","createTextVNode","createElementVNode","toDisplayString","createCommentVNode","Fragment","renderList","createBlock","createSlots","withCtx","mergeProps","slotProps","unref","createVNode"],"sources":["../../src/components/InkViewport.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The scroll element is handed to core's `mountViewer`, which builds the viewport, the page\n * layers, the tool controller and the keyboard shortcuts in it; Vue never renders children\n * into it. The engine reports each page host it mounts, and InkPage components rendered here\n * (they render nothing in place) teleport the page-error and custom-annotation slots into them.\n *\n * Two-way zoom and page: the viewport's own changes are reported through the context, and\n * the host's v-model values are applied only when they differ from the viewport's state, so\n * the echo of a reported value does nothing.\n *\n * Form fields render in the engine's form layer. A signature field's \"Sign\" opens\n * `InkSignFieldPopover`, and a form script's alert shows in `InkFormAlert`; both are mounted\n * here, so hosts compose nothing for them.\n */\nimport { mountViewer } from '@inkbar/core/dom'\nimport {\n computed,\n onBeforeUnmount,\n onBeforeUpdate,\n onMounted,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { toolIdsOf } from '../composables/useRegisteredTool'\nimport { injectInkContext } from '../context'\n\nimport InkFormAlert from './InkFormAlert.vue'\nimport InkPage from './InkPage.vue'\nimport InkSignFieldPopover from './InkSignFieldPopover.vue'\n\nimport type { AnnotationSlotProps } from './annotation-slot'\nimport type { InkDocument, InkError } from '@inkbar/core'\nimport type {\n LayoutMode,\n PageMount,\n SignFieldRequest,\n ToolId,\n ViewerEngine,\n ViewRotation,\n ZoomValue,\n} from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{\n mode?: LayoutMode\n rotation?: ViewRotation\n /** Gap between pages, CSS px. */\n gap?: number\n /** Pages kept mounted either side of the visible ones. */\n buffer?: number\n }>(),\n { mode: 'continuous', rotation: 0, gap: 16, buffer: 2 }\n)\n\nconst slots = defineSlots<{\n loading?(): unknown\n error?(props: { error: InkError }): unknown\n empty?(): unknown\n annotation?(props: AnnotationSlotProps): unknown\n /** Shown inside a page that failed to render. The rest of the document stays usable. */\n 'page-error'?(props: { error: InkError; page: number }): unknown\n}>()\n\nconst ctx = injectInkContext()\nconst scroll = useTemplateRef<HTMLElement>('scroll')\n\ninterface MountedPage {\n /** The engine build the host belongs to; part of the InkPage key. */\n build: number\n page: number\n host: HTMLElement\n mount: PageMount\n error: InkError | null\n /** Whether the build that mounted the page renders the annotation slot. */\n custom: boolean\n}\n/** A key per document, so the field menu and its dialog start afresh for each one. */\nconst documentKeys = new WeakMap<InkDocument, number>()\nlet documentKeyCount = 0\nfunction documentKey(doc: InkDocument | null): number {\n if (!doc) return 0\n let key = documentKeys.get(doc)\n if (key === undefined) {\n key = ++documentKeyCount\n documentKeys.set(doc, key)\n }\n return key\n}\n\n/** Page hosts, mounts and errors the engine reported; InkPage renders Teleports for them. */\nconst pages = shallowRef<MountedPage[]>([])\n\nconst state = computed(() => ctx.status.value.state)\nconst error = computed<InkError | null>(() =>\n ctx.status.value.state === 'error' ? ctx.status.value.error : null\n)\n\nconst engine = shallowRef<ViewerEngine | null>(null)\n/** The signature field whose menu is open. */\nconst signRequest = shallowRef<SignFieldRequest | null>(null)\n/** The form script's message on show, and how many have been shown. */\nconst alertMessage = shallowRef<string | null>(null)\nconst alertsShown = shallowRef(0)\n/**\n * Numbered before each build starts, so the pages a build mounts carry its own number. A\n * rebuild gives each page a new host and mount, so pages from an earlier build must remount,\n * not be reused.\n */\nlet build = 0\n/** Whether the current build renders the annotation slot. */\nlet custom = false\nlet stops: (() => void)[] = []\n/** The zoom and page last reported to the host. */\nlet lastReportedZoom: ZoomValue | undefined\nlet lastReportedPage: number | undefined\n\nfunction teardown(): void {\n for (const stop of stops) stop()\n stops = []\n // Unmounts every page, which empties `pages` through `onPageUnmount`.\n engine.value?.destroy()\n engine.value = null\n if (ctx.viewport.value) ctx.viewport.value = null\n if (ctx.tools.value) ctx.tools.value = null\n ctx.openedToolIds.value = null\n pages.value = []\n // Their fields and the document they came from are gone.\n signRequest.value = null\n alertMessage.value = null\n}\n\nfunction rebuild(opts: Parameters<ViewerEngine['rebuild']>[0]): void {\n const e = engine.value\n if (!e) return\n build += 1\n if (opts.customAnnotations !== undefined) custom = opts.customAnnotations\n e.rebuild(opts)\n}\n\n// Build for a new document or status; the previous engine is torn down first.\nfunction setup(): void {\n teardown()\n lastReportedZoom = undefined\n lastReportedPage = undefined\n const doc = ctx.document.value\n const el = scroll.value\n if (!doc || !el || ctx.status.value.state !== 'ready') return\n let first = true\n build += 1\n custom = !!slots.annotation\n // The tools this viewer registers, from the same inputs; a later `tools` waits for a rebuild.\n ctx.openedToolIds.value = toolIdsOf(ctx.hostTools.value, ctx.pluginHost.value)\n engine.value = mountViewer({\n container: el,\n document: doc,\n zoom: ctx.zoomModel.value ?? 'fit-width',\n ...(ctx.pageModel.value === undefined ? {} : { page: ctx.pageModel.value }),\n mode: props.mode,\n rotation: props.rotation,\n gap: props.gap,\n buffer: props.buffer,\n tool: ctx.tool.value,\n ...(ctx.hostTools.value ? { tools: ctx.hostTools.value } : {}),\n // The engine adds the plugins' tools and layers, and decorates through the host, which\n // reads `decorateAnnotation` first.\n ...(ctx.pluginHost.value ? { plugins: ctx.pluginHost.value } : {}),\n // The engine draws the search matches on the pages.\n ...(ctx.search.value ? { search: ctx.search.value } : {}),\n // Read through, so the watch below can re-apply a new function without a rebuild.\n decorateAnnotation: (a) => ctx.decorateAnnotation.value?.(a),\n ...(ctx.toolStyle.value ? { toolStyle: ctx.toolStyle.value } : {}),\n toolHistory: { batch: (fn) => ctx.history.batch(fn) },\n toolOptions: ctx.toolOptions,\n fonts: [...ctx.fonts.value],\n // Read through, so a new `signatures` store reaches the tool as well as the menus.\n signatureLibrary: () => ctx.signatures.value,\n customAnnotations: custom,\n ...(ctx.formHighlight.value === undefined\n ? {}\n : { formHighlight: ctx.formHighlight.value }),\n // The field's own button again, while its menu is open, closes the menu.\n onSignField: (req) => {\n signRequest.value = signRequest.value?.widget === req.widget ? null : req\n },\n onFormAction: (a) => ctx.reportFormAction(a),\n onFormAlert: (message) => {\n alertMessage.value = message\n alertsShown.value += 1\n },\n onActivate: (id) => ctx.setActivated(id),\n onBuild: (vp, tc) => {\n ctx.viewport.value = vp\n ctx.tools.value = tc\n if (first) {\n // A new document starts from where the viewport opens (its zoom, on the first page:\n // `createViewport` always starts at page 0); only later changes are reported, the\n // restored page among them, since the engine has already scrolled to it.\n first = false\n lastReportedZoom = vp.zoom.get()\n lastReportedPage = 0\n }\n for (const stop of stops) stop()\n const reportZoom = (z: ZoomValue): void => {\n if (z === lastReportedZoom) return\n lastReportedZoom = z\n ctx.reportZoom(z)\n }\n const reportPage = (p: number): void => {\n if (p === lastReportedPage) return\n lastReportedPage = p\n ctx.reportPage(p)\n }\n // A tool that switches itself (a one-shot tool once used) is reported as a pick.\n const followTool = (id: ToolId): void => {\n if (id !== ctx.tool.value) ctx.setTool(id)\n }\n stops = [\n vp.zoom.subscribe(reportZoom),\n vp.currentPage.subscribe(reportPage),\n tc.active.subscribe(followTool),\n ]\n // Whatever the build restored is reported once; nothing is when it matched.\n reportZoom(vp.zoom.get())\n reportPage(vp.currentPage.get())\n },\n onPageMount: (page, mount, host) => {\n pages.value = [...pages.value, { build, page, host, mount, error: null, custom }]\n },\n onPageUnmount: (page) => {\n pages.value = pages.value.filter((p) => p.page !== page)\n },\n onPageError: (page, err) => {\n pages.value = pages.value.map((p) => (p.page === page ? { ...p, error: err } : p))\n },\n })\n}\n\nonMounted(() => {\n ctx.viewportEl.value = scroll.value\n watch([() => ctx.document.value, () => ctx.status.value.state], setup, {\n immediate: true,\n })\n})\n\n// A new decorateAnnotation re-applies to the mounted annotation elements at once.\nwatch(\n () => ctx.decorateAnnotation.value,\n () => engine.value?.redecorate()\n)\n// The tint follows `formHighlight` in place, without a new document.\nwatch(\n () => ctx.formHighlight.value,\n (on) => engine.value?.setFormHighlight(on ?? true)\n)\nwatch(\n () => ctx.zoomModel.value,\n (z: ZoomValue | undefined) => {\n const vp = engine.value?.viewport\n if (vp && z !== undefined && z !== vp.zoom.get()) vp.setZoom(z)\n }\n)\nwatch(\n () => ctx.pageModel.value,\n (p) => {\n const vp = engine.value?.viewport\n if (!vp || p === undefined || p === lastReportedPage) return\n if (p !== vp.currentPage.get()) vp.scrollToPage(p)\n }\n)\nwatch(\n () => ctx.tool.value,\n (t) => {\n const tc = engine.value?.tools\n if (tc && tc.active.get() !== t) tc.set(t)\n }\n)\nwatch(\n () => props.mode,\n (m) => engine.value?.viewport.setMode(m)\n)\nwatch(\n () => props.rotation,\n (r) => engine.value?.viewport.setRotation(r)\n)\n// Gap and buffer are construction options: rebuild for the same document, keeping zoom and page.\n// The slots are already updated when this runs, so it carries the annotation slot too: a slot\n// toggle in the same tick is then recorded here and `onBeforeUpdate` finds nothing left to do.\nwatch([() => props.gap, () => props.buffer], ([gap, buffer]) =>\n rebuild({ gap, buffer, customAnnotations: !!slots.annotation })\n)\n\n// Slots are not reactive, so a change to whether the annotation slot is given is caught here.\n// `onBeforeUpdate` runs after the new slots are in place and before this render: the rebuild\n// swaps `pages` for the new build's pages synchronously, so the render that follows never pairs\n// the annotation slot with an overlay built without it (or the reverse). The rebuild keeps the\n// scroll position.\nonBeforeUpdate(() => {\n const next = !!slots.annotation\n if (engine.value && next !== custom) rebuild({ customAnnotations: next })\n})\n\nonBeforeUnmount(() => {\n teardown()\n if (ctx.viewportEl.value === scroll.value) ctx.viewportEl.value = null\n})\n</script>\n\n<template>\n <div class=\"ink-viewport-root\" data-ink-viewport-root :data-state=\"state\">\n <div v-if=\"state === 'loading'\" class=\"ink-status\" role=\"status\" aria-live=\"polite\">\n <slot name=\"loading\">Loading document…</slot>\n </div>\n <div v-else-if=\"error\" class=\"ink-status ink-error\" role=\"alert\">\n <slot name=\"error\" :error=\"error\">\n <p class=\"ink-error-title\">This document could not be opened.</p>\n <!-- The message comes from the PDF engine and is not written for readers: it stays\n off the page, on the code's tooltip. -->\n <p>\n <code class=\"ink-error-code\" :title=\"error.message\">{{ error.code }}</code>\n </p>\n </slot>\n </div>\n <div v-else-if=\"state === 'idle'\" class=\"ink-status ink-empty\">\n <slot name=\"empty\" />\n </div>\n <div\n ref=\"scroll\"\n class=\"ink-scroll\"\n data-ink-scroll\n tabindex=\"0\"\n role=\"document\"\n aria-label=\"Document\"\n />\n <InkPage\n v-for=\"p in pages\"\n :key=\"`${p.build}:${p.page}`\"\n :page=\"p.page\"\n :host=\"p.host\"\n :mount=\"p.mount\"\n :error=\"p.error\"\n :custom-annotations=\"p.custom\"\n >\n <template v-if=\"slots.annotation\" #annotation=\"slotProps\">\n <slot name=\"annotation\" v-bind=\"slotProps\" />\n </template>\n <template v-if=\"slots['page-error']\" #page-error=\"slotProps\">\n <slot name=\"page-error\" v-bind=\"slotProps\" />\n </template>\n </InkPage>\n <!-- Keyed by document, so the menu and its dialog start afresh for each one. -->\n <InkSignFieldPopover\n :key=\"documentKey(ctx.document.value)\"\n :request=\"signRequest\"\n @close=\"signRequest = null\"\n />\n <InkFormAlert\n :message=\"alertMessage\"\n :shown=\"alertsShown\"\n :fallback=\"scroll\"\n @close=\"alertMessage = null\"\n />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6CA,IAAM4B,IAAQC,GAYRC,IAAQ9B,EAAA,GASRgC,IAAMC,EAAiB,GACvBC,IAASC,GAA4B,QAAQ,GAa7CC,oBAAe,IAAI,QAA6B,GAClDC,IAAmB;EACvB,SAASC,EAAY,GAAiC;GACpD,IAAI,CAACC,GAAK,OAAO;GACjB,IAAIC,IAAMJ,EAAa,IAAIG,CAAG;GAK9B,OAJIC,MAAQ,KAAA,MACV,IAAM,EAAEH,GACRD,EAAa,IAAIG,GAAKC,CAAG,IAEpBA;EACT;EAGA,IAAMC,IAAQC,EAA0B,CAAC,CAAC,GAEpCC,IAAQC,QAAeZ,EAAI,OAAO,MAAM,KAAK,GAC7Ca,IAAQD,QACZZ,EAAI,OAAO,MAAM,UAAU,UAAUA,EAAI,OAAO,MAAM,QAAQ,IAChE,GAEMc,IAASJ,EAAgC,IAAI,GAE7CK,IAAcL,EAAoC,IAAI,GAEtDM,IAAeN,EAA0B,IAAI,GAC7CO,IAAcP,EAAW,CAAC,GAM5BQ,IAAQ,GAERC,IAAS,IACTC,IAAwB,CAAC,GAEzBC,GACAC;EAEJ,SAASC,IAAiB;GACxB,KAAK,IAAMC,KAAQJ,GAAO,EAAK;GAW/B,AAVA,IAAQ,CAAC,GAETN,EAAO,OAAO,QAAQ,GACtB,EAAO,QAAQ,MACXd,EAAI,SAAS,UAAO,EAAI,SAAS,QAAQ,OACzCA,EAAI,MAAM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,CAAA,CAAA,KAAAK,GAAA,IAAA,EAAA;GAEvB5F,EAOE,OAAA;IANI,SAAA;IAAJ,KAAI6B;IACJ,OAAM;IACN,mBAAA;IACA,UAAS;IACT,MAAK;IACL,cAAW;;IAEbjC,EAAA,EAAA,GAAAC,EAeUM,GAAA,MAAAC,EAdIgC,EAAA,QAAL,OADTxC,EAAA,GAAAS,EAeUC,GAAA;IAbP,KAAG,GAAKgE,EAAE,MAAK,GAAIA,EAAE;IACrB,MAAMA,EAAE;IACR,MAAMA,EAAE;IACR,OAAOA,EAAE;IACT,OAAOA,EAAE;IACT,sBAAoBA,EAAE;GAEP,GAAA0B,EAAA,EAAA,GAAA,EAAA,GAAA,CAAAvE,EAAM,aAAA;IAAa,MAAA;IACjC,IAAAjB,GAD6C,MAAS,CACtDV,EAA6CyF,EAAA,QAAA,cAA7C9E,EAA6C,EAAA,SAAA,GAAA,GAAb0F,CAAS,CAAA,CAAA,CAAA;;GAE3B,IAAA,KAAA,GAAA1E,EAAK,gBAAA;IAAiB,MAAA;IACpC,IAAAjB,GADgD,MAAS,CACzDV,EAA6CyF,EAAA,QAAA,cAA7C9E,EAA6C,EAAA,SAAA,GAAA,GAAb0F,CAAS,CAAA,CAAA,CAAA;;;;;;;;;IAI7CvG,EAAA,GAAAS,EAIEK,GAAA;IAHC,KAAKuB,EAAYtB,EAAAgB,CAAA,CAAG,CAAC,SAAS,KAAK;IACnC,SAASe,EAAA;IACT,SAAK,AAAA8C,EAAA,QAAA,MAAE,EAAA,QAAW;;GAErB5E,EAKEC,GAAA;IAJC,SAAS8B,EAAA;IACT,OAAOC,EAAA;IACP,UAAUf,EAAA;IACV,SAAK,AAAA2D,EAAA,QAAA,MAAE,EAAA,QAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignatureForm.js","names":["_sfc_main","SignatureForm_vue_vue_type_script_setup_true_lang_default","SignatureForm_default"],"sources":["../../src/components/SignatureForm.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The body of `InkSignatureDialog`, mounted while it is open: one draft per opening. Draw,\n * Type and Image tabs, then Cancel and Save.\n */\nimport {\n createSignatureDraft,\n fontFamilyValue,\n handleRadioKeys,\n handleTabKeys,\n SIGNATURE_LABELS,\n SIGNATURE_TABS,\n type SignatureDraftState,\n type SignatureTab,\n} from '@inkbar/core/dom'\nimport { DialogClose } from 'reka-ui'\nimport { computed, onBeforeUnmount, onMounted, useId, useTemplateRef } from 'vue'\n\nimport { useTool } from '../composables/useTool'\nimport {
|
|
1
|
+
{"version":3,"file":"SignatureForm.js","names":["_sfc_main","SignatureForm_vue_vue_type_script_setup_true_lang_default","SignatureForm_default"],"sources":["../../src/components/SignatureForm.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The body of `InkSignatureDialog`, mounted while it is open: one draft per opening. Draw,\n * Type and Image tabs, then Cancel and Save.\n */\nimport {\n createSignatureDraft,\n fontFamilyValue,\n handleRadioKeys,\n handleTabKeys,\n SIGNATURE_LABELS,\n SIGNATURE_TABS,\n type SignatureDraftState,\n type SignatureTab,\n} from '@inkbar/core/dom'\nimport { DialogClose } from 'reka-ui'\nimport { computed, onBeforeUnmount, onMounted, useId, useTemplateRef } from 'vue'\n\nimport { useHasTool } from '../composables/useRegisteredTool'\nimport { useTool } from '../composables/useTool'\nimport { useToolOptionsWhile } from '../composables/useToolOptions'\nimport { useInkContext } from '../context'\nimport { useReadable } from '../use-readable'\n\nimport type { SignatureOptions, SignatureTemplate } from '@inkbar/core'\n\nconst props = withDefaults(\n defineProps<{ fonts?: readonly string[] | undefined; select?: boolean }>(),\n { fonts: undefined, select: true }\n)\nconst emit = defineEmits<{ saved: [template: SignatureTemplate]; close: [] }>()\n\nconst ctx = useInkContext('InkSignatureDialog')\nconst { setTool } = useTool()\n// Without the signature tool, Save only stores the template, as signing a form field needs.\nconst hasSignatureTool = useHasTool(ctx, 'signature')\nconst { setOptions } = useToolOptionsWhile<SignatureOptions>(\n 'signature',\n hasSignatureTool\n)\nconst draft = createSignatureDraft({ fonts: props.fonts ?? ctx.signatureFonts.value })\nconst IDLE: SignatureDraftState = draft.state.get()\nconst s = useReadable(draft.state, IDLE)\nconst uid = useId()\nconst padHost = useTemplateRef<HTMLDivElement>('pad')\n\nlet detach: (() => void) | undefined\nonMounted(() => {\n if (padHost.value) detach = draft.attachPad(padHost.value)\n})\nonBeforeUnmount(() => {\n detach?.()\n draft.destroy()\n})\n\nfunction save(): void {\n draft.save(ctx.signatures.value).then(\n (t) => {\n if (!t) return\n if (props.select && hasSignatureTool.value) {\n setOptions({ templateId: t.id })\n setTool('signature')\n }\n emit('saved', t)\n emit('close')\n },\n () => {\n // The host's store refused it: the dialog stays open to try again.\n }\n )\n}\n\nconst tabId = (tab: SignatureTab) => `${uid}-tab-${tab}`\nconst panelId = (tab: SignatureTab) => `${uid}-panel-${tab}`\nconst shown = computed(() => s.value.name.trim() || SIGNATURE_LABELS.namePlaceholder)\nconst onTabKeydown = (e: KeyboardEvent) =>\n handleTabKeys(e, e.currentTarget as HTMLElement)\nconst onRadioKeydown = (e: KeyboardEvent) =>\n handleRadioKeys(e, e.currentTarget as HTMLElement)\nconst onName = (e: Event) => draft.setName((e.target as HTMLInputElement).value)\nconst onFile = (e: Event) =>\n void draft.chooseFile((e.target as HTMLInputElement).files?.[0])\n</script>\n\n<template>\n <div\n role=\"tablist\"\n :aria-label=\"SIGNATURE_LABELS.tabs\"\n class=\"ink-tabs\"\n @keydown=\"onTabKeydown\"\n >\n <button\n v-for=\"tab in SIGNATURE_TABS\"\n :id=\"tabId(tab)\"\n :key=\"tab\"\n type=\"button\"\n role=\"tab\"\n :aria-controls=\"panelId(tab)\"\n :aria-selected=\"s.tab === tab\"\n :tabindex=\"s.tab === tab ? 0 : -1\"\n class=\"ink-tab\"\n :data-key=\"tab\"\n :data-state=\"s.tab === tab ? 'active' : 'inactive'\"\n @click=\"draft.setTab(tab)\"\n >\n {{ SIGNATURE_LABELS[tab] }}\n </button>\n </div>\n <div\n :id=\"panelId('draw')\"\n role=\"tabpanel\"\n :aria-labelledby=\"tabId('draw')\"\n class=\"ink-tab-panel\"\n data-key=\"draw\"\n :hidden=\"s.tab !== 'draw'\"\n >\n <div\n ref=\"pad\"\n class=\"ink-signature-pad-host\"\n data-ink-signature-pad-host\n role=\"img\"\n :aria-label=\"SIGNATURE_LABELS.pad\"\n />\n <div class=\"ink-dialog-row\">\n <button\n type=\"button\"\n class=\"ink-button\"\n data-ink-signature-clear\n :disabled=\"s.padEmpty\"\n @click=\"draft.clearPad()\"\n >\n {{ SIGNATURE_LABELS.clear }}\n </button>\n </div>\n </div>\n <div\n :id=\"panelId('type')\"\n role=\"tabpanel\"\n :aria-labelledby=\"tabId('type')\"\n class=\"ink-tab-panel\"\n data-key=\"type\"\n :hidden=\"s.tab !== 'type'\"\n >\n <label class=\"ink-field\">\n <span>{{ SIGNATURE_LABELS.name }}</span>\n <input\n type=\"text\"\n class=\"ink-input\"\n data-ink-signature-name\n autocomplete=\"name\"\n :placeholder=\"SIGNATURE_LABELS.namePlaceholder\"\n :value=\"s.name\"\n @input=\"onName\"\n />\n </label>\n <div\n role=\"radiogroup\"\n :aria-label=\"SIGNATURE_LABELS.fonts\"\n class=\"ink-signature-fonts\"\n @keydown=\"onRadioKeydown\"\n >\n <button\n v-for=\"font in draft.fonts\"\n :key=\"font\"\n type=\"button\"\n role=\"radio\"\n :aria-checked=\"s.font === font\"\n :aria-label=\"font\"\n :tabindex=\"s.font === font ? 0 : -1\"\n class=\"ink-signature-font\"\n :data-key=\"font\"\n :data-state=\"s.font === font ? 'checked' : 'unchecked'\"\n @click=\"draft.setFont(font)\"\n >\n <!-- The font is the option itself, so it is set here, not left to the theme. -->\n <span\n class=\"ink-signature-font-sample\"\n :style=\"{ fontFamily: fontFamilyValue(font) }\"\n >\n {{ shown }}\n </span>\n </button>\n </div>\n </div>\n <div\n :id=\"panelId('image')\"\n role=\"tabpanel\"\n :aria-labelledby=\"tabId('image')\"\n class=\"ink-tab-panel\"\n data-key=\"image\"\n :hidden=\"s.tab !== 'image'\"\n >\n <label class=\"ink-field\">\n <span>{{ SIGNATURE_LABELS.file }}</span>\n <input\n type=\"file\"\n accept=\"image/png,image/jpeg\"\n class=\"ink-input\"\n data-ink-signature-file\n @change=\"onFile\"\n />\n </label>\n <img\n v-if=\"s.image?.kind === 'image'\"\n class=\"ink-signature-image\"\n :src=\"s.image.imagedata\"\n alt=\"\"\n />\n <p v-if=\"s.imageError\" class=\"ink-field-error\" role=\"alert\">{{ s.imageError }}</p>\n </div>\n <p\n v-if=\"s.saveError\"\n class=\"ink-field-error\"\n role=\"alert\"\n data-ink-signature-save-error\n >\n {{ s.saveError }}\n </p>\n <div class=\"ink-dialog-actions\">\n <DialogClose as-child>\n <button type=\"button\" class=\"ink-button\" data-ink-signature-cancel>\n {{ SIGNATURE_LABELS.cancel }}\n </button>\n </DialogClose>\n <button\n type=\"button\"\n class=\"ink-button\"\n data-variant=\"primary\"\n data-ink-signature-save\n :disabled=\"!s.canSave\"\n @click=\"save\"\n >\n {{ SIGNATURE_LABELS.save }}\n </button>\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignatureForm.vue.d.ts","sourceRoot":"","sources":["../../src/components/SignatureForm.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SignatureForm.vue.d.ts","sourceRoot":"","sources":["../../src/components/SignatureForm.vue"],"names":[],"mappings":"AAqQA,OAAO,KAAK,EAAoB,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAGvE,KAAK,WAAW,GAAG;IAAE,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAkS/E,QAAA,MAAM,YAAY;;;;;;;;;6EAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useInkContext as e } from "../context.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useHasTool as t } from "../composables/useRegisteredTool.js";
|
|
3
|
+
import { useReadable as ee } from "../use-readable.js";
|
|
3
4
|
import { useTool as n } from "../composables/useTool.js";
|
|
4
|
-
import {
|
|
5
|
-
import { Fragment as
|
|
6
|
-
import { SIGNATURE_LABELS as _, SIGNATURE_TABS as
|
|
5
|
+
import { useToolOptionsWhile as r } from "../composables/useToolOptions.js";
|
|
6
|
+
import { Fragment as i, computed as te, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createVNode as c, defineComponent as l, normalizeStyle as u, onBeforeUnmount as ne, onMounted as re, openBlock as d, renderList as f, toDisplayString as p, unref as m, useId as h, useTemplateRef as g, withCtx as ie } from "vue";
|
|
7
|
+
import { SIGNATURE_LABELS as _, SIGNATURE_TABS as ae, createSignatureDraft as oe, fontFamilyValue as v, handleRadioKeys as y, handleTabKeys as b } from "@inkbar/core/dom";
|
|
7
8
|
import { DialogClose as x } from "reka-ui";
|
|
8
9
|
//#region src/components/SignatureForm.vue?vue&type=script&setup=true&lang.ts
|
|
9
10
|
var S = ["aria-label"], C = [
|
|
@@ -42,11 +43,11 @@ var S = ["aria-label"], C = [
|
|
|
42
43
|
class: "ink-field-error",
|
|
43
44
|
role: "alert",
|
|
44
45
|
"data-ink-signature-save-error": ""
|
|
45
|
-
},
|
|
46
|
+
}, se = { class: "ink-dialog-actions" }, R = {
|
|
46
47
|
type: "button",
|
|
47
48
|
class: "ink-button",
|
|
48
49
|
"data-ink-signature-cancel": ""
|
|
49
|
-
}, z = ["disabled"], B = /*@__PURE__*/
|
|
50
|
+
}, z = ["disabled"], B = /*@__PURE__*/ l({
|
|
50
51
|
__name: "SignatureForm",
|
|
51
52
|
props: {
|
|
52
53
|
fonts: { default: void 0 },
|
|
@@ -56,128 +57,128 @@ var S = ["aria-label"], C = [
|
|
|
56
57
|
}
|
|
57
58
|
},
|
|
58
59
|
emits: ["saved", "close"],
|
|
59
|
-
setup(
|
|
60
|
-
let V =
|
|
60
|
+
setup(l, { emit: B }) {
|
|
61
|
+
let V = l, H = B, U = e("InkSignatureDialog"), { setTool: W } = n(), G = t(U, "signature"), { setOptions: K } = r("signature", G), q = oe({ fonts: V.fonts ?? U.signatureFonts.value }), ce = q.state.get(), J = ee(q.state, ce), Y = h(), X = g("pad"), Z;
|
|
61
62
|
re(() => {
|
|
62
|
-
X.value && (Z =
|
|
63
|
-
}),
|
|
64
|
-
Z?.(),
|
|
63
|
+
X.value && (Z = q.attachPad(X.value));
|
|
64
|
+
}), ne(() => {
|
|
65
|
+
Z?.(), q.destroy();
|
|
65
66
|
});
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
e && (V.select &&
|
|
67
|
+
function le() {
|
|
68
|
+
q.save(U.signatures.value).then((e) => {
|
|
69
|
+
e && (V.select && G.value && (K({ templateId: e.id }), W("signature")), H("saved", e), H("close"));
|
|
69
70
|
}, () => {});
|
|
70
71
|
}
|
|
71
|
-
let Q = (e) => `${Y}-tab-${e}`, $ = (e) => `${Y}-panel-${e}`,
|
|
72
|
-
return (e, t) => (
|
|
72
|
+
let Q = (e) => `${Y}-tab-${e}`, $ = (e) => `${Y}-panel-${e}`, ue = te(() => J.value.name.trim() || _.namePlaceholder), de = (e) => b(e, e.currentTarget), fe = (e) => y(e, e.currentTarget), pe = (e) => q.setName(e.target.value), me = (e) => void q.chooseFile(e.target.files?.[0]);
|
|
73
|
+
return (e, t) => (d(), o(i, null, [
|
|
73
74
|
s("div", {
|
|
74
75
|
role: "tablist",
|
|
75
|
-
"aria-label":
|
|
76
|
+
"aria-label": m(_).tabs,
|
|
76
77
|
class: "ink-tabs",
|
|
77
|
-
onKeydown:
|
|
78
|
-
}, [(
|
|
78
|
+
onKeydown: de
|
|
79
|
+
}, [(d(!0), o(i, null, f(m(ae), (e) => (d(), o("button", {
|
|
79
80
|
id: Q(e),
|
|
80
81
|
key: e,
|
|
81
82
|
type: "button",
|
|
82
83
|
role: "tab",
|
|
83
84
|
"aria-controls": $(e),
|
|
84
|
-
"aria-selected":
|
|
85
|
-
tabindex:
|
|
85
|
+
"aria-selected": m(J).tab === e,
|
|
86
|
+
tabindex: m(J).tab === e ? 0 : -1,
|
|
86
87
|
class: "ink-tab",
|
|
87
88
|
"data-key": e,
|
|
88
|
-
"data-state":
|
|
89
|
-
onClick: (t) =>
|
|
90
|
-
},
|
|
89
|
+
"data-state": m(J).tab === e ? "active" : "inactive",
|
|
90
|
+
onClick: (t) => m(q).setTab(e)
|
|
91
|
+
}, p(m(_)[e]), 9, C))), 128))], 40, S),
|
|
91
92
|
s("div", {
|
|
92
93
|
id: $("draw"),
|
|
93
94
|
role: "tabpanel",
|
|
94
95
|
"aria-labelledby": Q("draw"),
|
|
95
96
|
class: "ink-tab-panel",
|
|
96
97
|
"data-key": "draw",
|
|
97
|
-
hidden:
|
|
98
|
+
hidden: m(J).tab !== "draw"
|
|
98
99
|
}, [s("div", {
|
|
99
100
|
ref: "pad",
|
|
100
101
|
class: "ink-signature-pad-host",
|
|
101
102
|
"data-ink-signature-pad-host": "",
|
|
102
103
|
role: "img",
|
|
103
|
-
"aria-label":
|
|
104
|
+
"aria-label": m(_).pad
|
|
104
105
|
}, null, 8, T), s("div", E, [s("button", {
|
|
105
106
|
type: "button",
|
|
106
107
|
class: "ink-button",
|
|
107
108
|
"data-ink-signature-clear": "",
|
|
108
|
-
disabled:
|
|
109
|
-
onClick: t[0] ||= (e) =>
|
|
110
|
-
},
|
|
109
|
+
disabled: m(J).padEmpty,
|
|
110
|
+
onClick: t[0] ||= (e) => m(q).clearPad()
|
|
111
|
+
}, p(m(_).clear), 9, D)])], 8, w),
|
|
111
112
|
s("div", {
|
|
112
113
|
id: $("type"),
|
|
113
114
|
role: "tabpanel",
|
|
114
115
|
"aria-labelledby": Q("type"),
|
|
115
116
|
class: "ink-tab-panel",
|
|
116
117
|
"data-key": "type",
|
|
117
|
-
hidden:
|
|
118
|
-
}, [s("label", k, [s("span", null,
|
|
118
|
+
hidden: m(J).tab !== "type"
|
|
119
|
+
}, [s("label", k, [s("span", null, p(m(_).name), 1), s("input", {
|
|
119
120
|
type: "text",
|
|
120
121
|
class: "ink-input",
|
|
121
122
|
"data-ink-signature-name": "",
|
|
122
123
|
autocomplete: "name",
|
|
123
|
-
placeholder:
|
|
124
|
-
value:
|
|
125
|
-
onInput:
|
|
124
|
+
placeholder: m(_).namePlaceholder,
|
|
125
|
+
value: m(J).name,
|
|
126
|
+
onInput: pe
|
|
126
127
|
}, null, 40, A)]), s("div", {
|
|
127
128
|
role: "radiogroup",
|
|
128
|
-
"aria-label":
|
|
129
|
+
"aria-label": m(_).fonts,
|
|
129
130
|
class: "ink-signature-fonts",
|
|
130
|
-
onKeydown:
|
|
131
|
-
}, [(
|
|
131
|
+
onKeydown: fe
|
|
132
|
+
}, [(d(!0), o(i, null, f(m(q).fonts, (e) => (d(), o("button", {
|
|
132
133
|
key: e,
|
|
133
134
|
type: "button",
|
|
134
135
|
role: "radio",
|
|
135
|
-
"aria-checked":
|
|
136
|
+
"aria-checked": m(J).font === e,
|
|
136
137
|
"aria-label": e,
|
|
137
|
-
tabindex:
|
|
138
|
+
tabindex: m(J).font === e ? 0 : -1,
|
|
138
139
|
class: "ink-signature-font",
|
|
139
140
|
"data-key": e,
|
|
140
|
-
"data-state":
|
|
141
|
-
onClick: (t) =>
|
|
141
|
+
"data-state": m(J).font === e ? "checked" : "unchecked",
|
|
142
|
+
onClick: (t) => m(q).setFont(e)
|
|
142
143
|
}, [s("span", {
|
|
143
144
|
class: "ink-signature-font-sample",
|
|
144
|
-
style:
|
|
145
|
-
},
|
|
145
|
+
style: u({ fontFamily: m(v)(e) })
|
|
146
|
+
}, p(ue.value), 5)], 8, M))), 128))], 40, j)], 8, O),
|
|
146
147
|
s("div", {
|
|
147
148
|
id: $("image"),
|
|
148
149
|
role: "tabpanel",
|
|
149
150
|
"aria-labelledby": Q("image"),
|
|
150
151
|
class: "ink-tab-panel",
|
|
151
152
|
"data-key": "image",
|
|
152
|
-
hidden:
|
|
153
|
+
hidden: m(J).tab !== "image"
|
|
153
154
|
}, [
|
|
154
|
-
s("label", P, [s("span", null,
|
|
155
|
+
s("label", P, [s("span", null, p(m(_).file), 1), s("input", {
|
|
155
156
|
type: "file",
|
|
156
157
|
accept: "image/png,image/jpeg",
|
|
157
158
|
class: "ink-input",
|
|
158
159
|
"data-ink-signature-file": "",
|
|
159
|
-
onChange:
|
|
160
|
+
onChange: me
|
|
160
161
|
}, null, 32)]),
|
|
161
|
-
|
|
162
|
+
m(J).image?.kind === "image" ? (d(), o("img", {
|
|
162
163
|
key: 0,
|
|
163
164
|
class: "ink-signature-image",
|
|
164
|
-
src:
|
|
165
|
+
src: m(J).image.imagedata,
|
|
165
166
|
alt: ""
|
|
166
167
|
}, null, 8, F)) : a("", !0),
|
|
167
|
-
|
|
168
|
+
m(J).imageError ? (d(), o("p", I, p(m(J).imageError), 1)) : a("", !0)
|
|
168
169
|
], 8, N),
|
|
169
|
-
|
|
170
|
-
s("div",
|
|
171
|
-
default:
|
|
170
|
+
m(J).saveError ? (d(), o("p", L, p(m(J).saveError), 1)) : a("", !0),
|
|
171
|
+
s("div", se, [c(m(x), { "as-child": "" }, {
|
|
172
|
+
default: ie(() => [s("button", R, p(m(_).cancel), 1)]),
|
|
172
173
|
_: 1
|
|
173
174
|
}), s("button", {
|
|
174
175
|
type: "button",
|
|
175
176
|
class: "ink-button",
|
|
176
177
|
"data-variant": "primary",
|
|
177
178
|
"data-ink-signature-save": "",
|
|
178
|
-
disabled: !
|
|
179
|
-
onClick:
|
|
180
|
-
},
|
|
179
|
+
disabled: !m(J).canSave,
|
|
180
|
+
onClick: le
|
|
181
|
+
}, p(m(_).save), 9, z)])
|
|
181
182
|
], 64));
|
|
182
183
|
}
|
|
183
184
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignatureForm.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_Fragment","_createElementVNode","_unref","_renderList","_toDisplayString","_normalizeStyle","_createCommentVNode","_createVNode","_withCtx","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_15","_hoisted_16","_hoisted_17","_hoisted_18","_hoisted_19","SignatureForm_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","ctx","useInkContext","useTool","useToolOptions","draft","createSignatureDraft","IDLE","s","useReadable","uid","useId","padHost","useTemplateRef","detach","onMounted","onBeforeUnmount","save","t","setOptions","setTool","tabId","tab","panelId","shown","computed","SIGNATURE_LABELS","onTabKeydown","handleTabKeys","onRadioKeydown","handleRadioKeys","onName","onFile","openBlock","createElementBlock","Fragment","createElementVNode","unref","renderList","SIGNATURE_TABS","toDisplayString","_cache","font","normalizeStyle","fontFamilyValue","createCommentVNode","createVNode","DialogClose","withCtx"],"sources":["../../src/components/SignatureForm.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The body of `InkSignatureDialog`, mounted while it is open: one draft per opening. Draw,\n * Type and Image tabs, then Cancel and Save.\n */\nimport {\n createSignatureDraft,\n fontFamilyValue,\n handleRadioKeys,\n handleTabKeys,\n SIGNATURE_LABELS,\n SIGNATURE_TABS,\n type SignatureDraftState,\n type SignatureTab,\n} from '@inkbar/core/dom'\nimport { DialogClose } from 'reka-ui'\nimport { computed, onBeforeUnmount, onMounted, useId, useTemplateRef } from 'vue'\n\nimport { useTool } from '../composables/useTool'\nimport { useToolOptions } from '../composables/useToolOptions'\nimport { useInkContext } from '../context'\nimport { useReadable } from '../use-readable'\n\nimport type { SignatureOptions, SignatureTemplate } from '@inkbar/core'\n\nconst props = withDefaults(\n defineProps<{ fonts?: readonly string[] | undefined; select?: boolean }>(),\n { fonts: undefined, select: true }\n)\nconst emit = defineEmits<{ saved: [template: SignatureTemplate]; close: [] }>()\n\nconst ctx = useInkContext('InkSignatureDialog')\nconst { setTool } = useTool()\nconst { setOptions } = useToolOptions<SignatureOptions>('signature')\nconst draft = createSignatureDraft({ fonts: props.fonts ?? ctx.signatureFonts.value })\nconst IDLE: SignatureDraftState = draft.state.get()\nconst s = useReadable(draft.state, IDLE)\nconst uid = useId()\nconst padHost = useTemplateRef<HTMLDivElement>('pad')\n\nlet detach: (() => void) | undefined\nonMounted(() => {\n if (padHost.value) detach = draft.attachPad(padHost.value)\n})\nonBeforeUnmount(() => {\n detach?.()\n draft.destroy()\n})\n\nfunction save(): void {\n draft.save(ctx.signatures.value).then(\n (t) => {\n if (!t) return\n if (props.select) {\n setOptions({ templateId: t.id })\n setTool('signature')\n }\n emit('saved', t)\n emit('close')\n },\n () => {\n // The host's store refused it: the dialog stays open to try again.\n }\n )\n}\n\nconst tabId = (tab: SignatureTab) => `${uid}-tab-${tab}`\nconst panelId = (tab: SignatureTab) => `${uid}-panel-${tab}`\nconst shown = computed(() => s.value.name.trim() || SIGNATURE_LABELS.namePlaceholder)\nconst onTabKeydown = (e: KeyboardEvent) =>\n handleTabKeys(e, e.currentTarget as HTMLElement)\nconst onRadioKeydown = (e: KeyboardEvent) =>\n handleRadioKeys(e, e.currentTarget as HTMLElement)\nconst onName = (e: Event) => draft.setName((e.target as HTMLInputElement).value)\nconst onFile = (e: Event) =>\n void draft.chooseFile((e.target as HTMLInputElement).files?.[0])\n</script>\n\n<template>\n <div\n role=\"tablist\"\n :aria-label=\"SIGNATURE_LABELS.tabs\"\n class=\"ink-tabs\"\n @keydown=\"onTabKeydown\"\n >\n <button\n v-for=\"tab in SIGNATURE_TABS\"\n :id=\"tabId(tab)\"\n :key=\"tab\"\n type=\"button\"\n role=\"tab\"\n :aria-controls=\"panelId(tab)\"\n :aria-selected=\"s.tab === tab\"\n :tabindex=\"s.tab === tab ? 0 : -1\"\n class=\"ink-tab\"\n :data-key=\"tab\"\n :data-state=\"s.tab === tab ? 'active' : 'inactive'\"\n @click=\"draft.setTab(tab)\"\n >\n {{ SIGNATURE_LABELS[tab] }}\n </button>\n </div>\n <div\n :id=\"panelId('draw')\"\n role=\"tabpanel\"\n :aria-labelledby=\"tabId('draw')\"\n class=\"ink-tab-panel\"\n data-key=\"draw\"\n :hidden=\"s.tab !== 'draw'\"\n >\n <div\n ref=\"pad\"\n class=\"ink-signature-pad-host\"\n data-ink-signature-pad-host\n role=\"img\"\n :aria-label=\"SIGNATURE_LABELS.pad\"\n />\n <div class=\"ink-dialog-row\">\n <button\n type=\"button\"\n class=\"ink-button\"\n data-ink-signature-clear\n :disabled=\"s.padEmpty\"\n @click=\"draft.clearPad()\"\n >\n {{ SIGNATURE_LABELS.clear }}\n </button>\n </div>\n </div>\n <div\n :id=\"panelId('type')\"\n role=\"tabpanel\"\n :aria-labelledby=\"tabId('type')\"\n class=\"ink-tab-panel\"\n data-key=\"type\"\n :hidden=\"s.tab !== 'type'\"\n >\n <label class=\"ink-field\">\n <span>{{ SIGNATURE_LABELS.name }}</span>\n <input\n type=\"text\"\n class=\"ink-input\"\n data-ink-signature-name\n autocomplete=\"name\"\n :placeholder=\"SIGNATURE_LABELS.namePlaceholder\"\n :value=\"s.name\"\n @input=\"onName\"\n />\n </label>\n <div\n role=\"radiogroup\"\n :aria-label=\"SIGNATURE_LABELS.fonts\"\n class=\"ink-signature-fonts\"\n @keydown=\"onRadioKeydown\"\n >\n <button\n v-for=\"font in draft.fonts\"\n :key=\"font\"\n type=\"button\"\n role=\"radio\"\n :aria-checked=\"s.font === font\"\n :aria-label=\"font\"\n :tabindex=\"s.font === font ? 0 : -1\"\n class=\"ink-signature-font\"\n :data-key=\"font\"\n :data-state=\"s.font === font ? 'checked' : 'unchecked'\"\n @click=\"draft.setFont(font)\"\n >\n <!-- The font is the option itself, so it is set here, not left to the theme. -->\n <span\n class=\"ink-signature-font-sample\"\n :style=\"{ fontFamily: fontFamilyValue(font) }\"\n >\n {{ shown }}\n </span>\n </button>\n </div>\n </div>\n <div\n :id=\"panelId('image')\"\n role=\"tabpanel\"\n :aria-labelledby=\"tabId('image')\"\n class=\"ink-tab-panel\"\n data-key=\"image\"\n :hidden=\"s.tab !== 'image'\"\n >\n <label class=\"ink-field\">\n <span>{{ SIGNATURE_LABELS.file }}</span>\n <input\n type=\"file\"\n accept=\"image/png,image/jpeg\"\n class=\"ink-input\"\n data-ink-signature-file\n @change=\"onFile\"\n />\n </label>\n <img\n v-if=\"s.image?.kind === 'image'\"\n class=\"ink-signature-image\"\n :src=\"s.image.imagedata\"\n alt=\"\"\n />\n <p v-if=\"s.imageError\" class=\"ink-field-error\" role=\"alert\">{{ s.imageError }}</p>\n </div>\n <p\n v-if=\"s.saveError\"\n class=\"ink-field-error\"\n role=\"alert\"\n data-ink-signature-save-error\n >\n {{ s.saveError }}\n </p>\n <div class=\"ink-dialog-actions\">\n <DialogClose as-child>\n <button type=\"button\" class=\"ink-button\" data-ink-signature-cancel>\n {{ SIGNATURE_LABELS.cancel }}\n </button>\n </DialogClose>\n <button\n type=\"button\"\n class=\"ink-button\"\n data-variant=\"primary\"\n data-ink-signature-save\n :disabled=\"!s.canSave\"\n @click=\"save\"\n >\n {{ SIGNATURE_LABELS.save }}\n </button>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBA,IAAMgC,IAAQC,GAIRC,IAAOH,GAEPI,IAAMC,EAAc,oBAAoB,GACxC,EAAE,eAAYC,EAAQ,GACtB,EAAE,kBAAeC,GAAiC,WAAW,GAC7DC,IAAQC,GAAqB,EAAE,OAAOR,EAAM,SAASG,EAAI,eAAe,MAAM,CAAC,GAC/EM,IAA4BF,EAAM,MAAM,IAAI,GAC5CG,IAAIC,EAAYJ,EAAM,OAAOE,CAAI,GACjCG,IAAMC,EAAM,GACZC,IAAUC,EAA+B,KAAK,GAEhDC;EAIJ,AAHAC,SAAgB;GACd,AAAIH,EAAQ,UAAO,IAASP,EAAM,UAAUO,EAAQ,KAAK;EAC3D,CA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;;IAEGtC,EAAAsC,CAAA,CAAC,CAAC,cAAX1C,EAAA,GAAAC,EAAkF,KAAlFwB,GAAkFnB,EAAnBF,EAAAsC,CAAA,CAAC,CAAC,UAAU,GAAA,CAAA,KAAAqC,EAAA,IAAA,EAAA;;GAGrE3E,EAAAsC,CAAA,CAAC,CAAC,aADV1C,EAAA,GAAAC,EAOI,KAPJyB,GAOIpB,EADCF,EAAAsC,CAAA,CAAC,CAAC,SAAS,GAAA,CAAA,KAAAqC,EAAA,IAAA,EAAA;GAEhB5E,EAgBM,OAhBNwB,IAgBM,CAfJlB,GAIcL,EAAA6E,CAAA,GAAA,EAJD,YAAA,GAAQ,GAAA;IACnB,SAAAvE,QAES,CAFTP,EAES,UAFTyB,GAEStB,EADJF,EAAAwD,CAAA,CAAgB,CAAC,MAAM,GAAA,CAAA,CAAA,CAAA;;GAG9BzD,CAAAA,GAAAA,EASS,UAAA;IARP,MAAK;IACL,OAAM;IACN,gBAAa;IACb,2BAAA;IACC,UAAQ,CAAGC,EAAAsC,CAAA,CAAC,CAAC;IACb,SAAOS;GAEL,GAAA7C,EAAAF,EAAAwD,CAAA,CAAgB,CAAC,IAAI,GAAA,GAAA/B,CAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"SignatureForm.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_Fragment","_createElementVNode","_unref","_renderList","_toDisplayString","_normalizeStyle","_createCommentVNode","_createVNode","_withCtx","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","_hoisted_15","_hoisted_16","_hoisted_17","_hoisted_18","_hoisted_19","SignatureForm_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","ctx","useInkContext","useTool","hasSignatureTool","useHasTool","useToolOptionsWhile","draft","createSignatureDraft","IDLE","s","useReadable","uid","useId","padHost","useTemplateRef","detach","onMounted","onBeforeUnmount","save","t","setOptions","setTool","tabId","tab","panelId","shown","computed","SIGNATURE_LABELS","onTabKeydown","handleTabKeys","onRadioKeydown","handleRadioKeys","onName","onFile","openBlock","createElementBlock","Fragment","createElementVNode","unref","renderList","SIGNATURE_TABS","toDisplayString","_cache","font","normalizeStyle","fontFamilyValue","createCommentVNode","createVNode","DialogClose","withCtx"],"sources":["../../src/components/SignatureForm.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The body of `InkSignatureDialog`, mounted while it is open: one draft per opening. Draw,\n * Type and Image tabs, then Cancel and Save.\n */\nimport {\n createSignatureDraft,\n fontFamilyValue,\n handleRadioKeys,\n handleTabKeys,\n SIGNATURE_LABELS,\n SIGNATURE_TABS,\n type SignatureDraftState,\n type SignatureTab,\n} from '@inkbar/core/dom'\nimport { DialogClose } from 'reka-ui'\nimport { computed, onBeforeUnmount, onMounted, useId, useTemplateRef } from 'vue'\n\nimport { useHasTool } from '../composables/useRegisteredTool'\nimport { useTool } from '../composables/useTool'\nimport { useToolOptionsWhile } from '../composables/useToolOptions'\nimport { useInkContext } from '../context'\nimport { useReadable } from '../use-readable'\n\nimport type { SignatureOptions, SignatureTemplate } from '@inkbar/core'\n\nconst props = withDefaults(\n defineProps<{ fonts?: readonly string[] | undefined; select?: boolean }>(),\n { fonts: undefined, select: true }\n)\nconst emit = defineEmits<{ saved: [template: SignatureTemplate]; close: [] }>()\n\nconst ctx = useInkContext('InkSignatureDialog')\nconst { setTool } = useTool()\n// Without the signature tool, Save only stores the template, as signing a form field needs.\nconst hasSignatureTool = useHasTool(ctx, 'signature')\nconst { setOptions } = useToolOptionsWhile<SignatureOptions>(\n 'signature',\n hasSignatureTool\n)\nconst draft = createSignatureDraft({ fonts: props.fonts ?? ctx.signatureFonts.value })\nconst IDLE: SignatureDraftState = draft.state.get()\nconst s = useReadable(draft.state, IDLE)\nconst uid = useId()\nconst padHost = useTemplateRef<HTMLDivElement>('pad')\n\nlet detach: (() => void) | undefined\nonMounted(() => {\n if (padHost.value) detach = draft.attachPad(padHost.value)\n})\nonBeforeUnmount(() => {\n detach?.()\n draft.destroy()\n})\n\nfunction save(): void {\n draft.save(ctx.signatures.value).then(\n (t) => {\n if (!t) return\n if (props.select && hasSignatureTool.value) {\n setOptions({ templateId: t.id })\n setTool('signature')\n }\n emit('saved', t)\n emit('close')\n },\n () => {\n // The host's store refused it: the dialog stays open to try again.\n }\n )\n}\n\nconst tabId = (tab: SignatureTab) => `${uid}-tab-${tab}`\nconst panelId = (tab: SignatureTab) => `${uid}-panel-${tab}`\nconst shown = computed(() => s.value.name.trim() || SIGNATURE_LABELS.namePlaceholder)\nconst onTabKeydown = (e: KeyboardEvent) =>\n handleTabKeys(e, e.currentTarget as HTMLElement)\nconst onRadioKeydown = (e: KeyboardEvent) =>\n handleRadioKeys(e, e.currentTarget as HTMLElement)\nconst onName = (e: Event) => draft.setName((e.target as HTMLInputElement).value)\nconst onFile = (e: Event) =>\n void draft.chooseFile((e.target as HTMLInputElement).files?.[0])\n</script>\n\n<template>\n <div\n role=\"tablist\"\n :aria-label=\"SIGNATURE_LABELS.tabs\"\n class=\"ink-tabs\"\n @keydown=\"onTabKeydown\"\n >\n <button\n v-for=\"tab in SIGNATURE_TABS\"\n :id=\"tabId(tab)\"\n :key=\"tab\"\n type=\"button\"\n role=\"tab\"\n :aria-controls=\"panelId(tab)\"\n :aria-selected=\"s.tab === tab\"\n :tabindex=\"s.tab === tab ? 0 : -1\"\n class=\"ink-tab\"\n :data-key=\"tab\"\n :data-state=\"s.tab === tab ? 'active' : 'inactive'\"\n @click=\"draft.setTab(tab)\"\n >\n {{ SIGNATURE_LABELS[tab] }}\n </button>\n </div>\n <div\n :id=\"panelId('draw')\"\n role=\"tabpanel\"\n :aria-labelledby=\"tabId('draw')\"\n class=\"ink-tab-panel\"\n data-key=\"draw\"\n :hidden=\"s.tab !== 'draw'\"\n >\n <div\n ref=\"pad\"\n class=\"ink-signature-pad-host\"\n data-ink-signature-pad-host\n role=\"img\"\n :aria-label=\"SIGNATURE_LABELS.pad\"\n />\n <div class=\"ink-dialog-row\">\n <button\n type=\"button\"\n class=\"ink-button\"\n data-ink-signature-clear\n :disabled=\"s.padEmpty\"\n @click=\"draft.clearPad()\"\n >\n {{ SIGNATURE_LABELS.clear }}\n </button>\n </div>\n </div>\n <div\n :id=\"panelId('type')\"\n role=\"tabpanel\"\n :aria-labelledby=\"tabId('type')\"\n class=\"ink-tab-panel\"\n data-key=\"type\"\n :hidden=\"s.tab !== 'type'\"\n >\n <label class=\"ink-field\">\n <span>{{ SIGNATURE_LABELS.name }}</span>\n <input\n type=\"text\"\n class=\"ink-input\"\n data-ink-signature-name\n autocomplete=\"name\"\n :placeholder=\"SIGNATURE_LABELS.namePlaceholder\"\n :value=\"s.name\"\n @input=\"onName\"\n />\n </label>\n <div\n role=\"radiogroup\"\n :aria-label=\"SIGNATURE_LABELS.fonts\"\n class=\"ink-signature-fonts\"\n @keydown=\"onRadioKeydown\"\n >\n <button\n v-for=\"font in draft.fonts\"\n :key=\"font\"\n type=\"button\"\n role=\"radio\"\n :aria-checked=\"s.font === font\"\n :aria-label=\"font\"\n :tabindex=\"s.font === font ? 0 : -1\"\n class=\"ink-signature-font\"\n :data-key=\"font\"\n :data-state=\"s.font === font ? 'checked' : 'unchecked'\"\n @click=\"draft.setFont(font)\"\n >\n <!-- The font is the option itself, so it is set here, not left to the theme. -->\n <span\n class=\"ink-signature-font-sample\"\n :style=\"{ fontFamily: fontFamilyValue(font) }\"\n >\n {{ shown }}\n </span>\n </button>\n </div>\n </div>\n <div\n :id=\"panelId('image')\"\n role=\"tabpanel\"\n :aria-labelledby=\"tabId('image')\"\n class=\"ink-tab-panel\"\n data-key=\"image\"\n :hidden=\"s.tab !== 'image'\"\n >\n <label class=\"ink-field\">\n <span>{{ SIGNATURE_LABELS.file }}</span>\n <input\n type=\"file\"\n accept=\"image/png,image/jpeg\"\n class=\"ink-input\"\n data-ink-signature-file\n @change=\"onFile\"\n />\n </label>\n <img\n v-if=\"s.image?.kind === 'image'\"\n class=\"ink-signature-image\"\n :src=\"s.image.imagedata\"\n alt=\"\"\n />\n <p v-if=\"s.imageError\" class=\"ink-field-error\" role=\"alert\">{{ s.imageError }}</p>\n </div>\n <p\n v-if=\"s.saveError\"\n class=\"ink-field-error\"\n role=\"alert\"\n data-ink-signature-save-error\n >\n {{ s.saveError }}\n </p>\n <div class=\"ink-dialog-actions\">\n <DialogClose as-child>\n <button type=\"button\" class=\"ink-button\" data-ink-signature-cancel>\n {{ SIGNATURE_LABELS.cancel }}\n </button>\n </DialogClose>\n <button\n type=\"button\"\n class=\"ink-button\"\n data-variant=\"primary\"\n data-ink-signature-save\n :disabled=\"!s.canSave\"\n @click=\"save\"\n >\n {{ SIGNATURE_LABELS.save }}\n </button>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BA,IAAMgC,IAAQC,GAIRC,IAAOH,GAEPI,IAAMC,EAAc,oBAAoB,GACxC,EAAE,eAAYC,EAAQ,GAEtBC,IAAmBC,EAAWJ,GAAK,WAAW,GAC9C,EAAE,kBAAeK,EACrB,aACAF,CACF,GACMG,IAAQC,GAAqB,EAAE,OAAOV,EAAM,SAASG,EAAI,eAAe,MAAM,CAAC,GAC/EQ,KAA4BF,EAAM,MAAM,IAAI,GAC5CG,IAAIC,GAAYJ,EAAM,OAAOE,EAAI,GACjCG,IAAMC,EAAM,GACZC,IAAUC,EAA+B,KAAK,GAEhDC;EAIJ,AAHAC,SAAgB;GACd,AAAIH,EAAQ,UAAO,IAASP,EAAM,UAAUO,EAAQ,KAAK;EAC3D,CAAC,GACDI,SAAsB;GAEpB,AADAF,IAAS,GACTT,EAAM,QAAQ;EAChB,CAAC;EAED,SAASY,KAAa;GACpB,EAAM,KAAKlB,EAAI,WAAW,KAAK,CAAC,CAAC,MAC9B,MAAM;IACL,AAAKmB,MACDtB,EAA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,EAAA;;GAGrE7E,EAAAwC,CAAA,CAAC,CAAC,aADV5C,EAAA,GAAAC,EAOI,KAPJyB,GAOIpB,EADCF,EAAAwC,CAAA,CAAC,CAAC,SAAS,GAAA,CAAA,KAAAqC,EAAA,IAAA,EAAA;GAEhB9E,EAgBM,OAhBNwB,IAgBM,CAfJlB,EAIcL,EAAA+E,CAAA,GAAA,EAJD,YAAA,GAAQ,GAAA;IACnB,SAAAzE,SAES,CAFTP,EAES,UAFTyB,GAEStB,EADJF,EAAA0D,CAAA,CAAgB,CAAC,MAAM,GAAA,CAAA,CAAA,CAAA;;GAG9B3D,CAAAA,GAAAA,EASS,UAAA;IARP,MAAK;IACL,OAAM;IACN,gBAAa;IACb,2BAAA;IACC,UAAQ,CAAGC,EAAAwC,CAAA,CAAC,CAAC;IACb,SAAOS;GAEL,GAAA/C,EAAAF,EAAA0D,CAAA,CAAgB,CAAC,IAAI,GAAA,GAAAjC,CAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MaybeRefOrGetter, Ref } from 'vue';
|
|
2
|
+
import { InkContext } from '../context';
|
|
3
|
+
import { PluginHost, Tool, ToolId } from '@inkbar/core/dom';
|
|
4
|
+
/** `select-text` and `select`, then the host's tools, then the plugins' tools, by id. */
|
|
5
|
+
export declare function toolIdsOf(hostTools: readonly Tool[] | undefined, pluginHost: PluginHost | null): ToolId[];
|
|
6
|
+
/**
|
|
7
|
+
* The tools a control may use: those in `tools` and the plugins now that the open viewer was
|
|
8
|
+
* also built with, so a control never offers a tool the viewer would refuse. A tool added to
|
|
9
|
+
* `tools` counts from the next open; one removed stops at once. With no viewer, `tools` and
|
|
10
|
+
* the plugins alone.
|
|
11
|
+
*/
|
|
12
|
+
export declare function registeredToolIds(hostTools: readonly Tool[] | undefined, pluginHost: PluginHost | null, opened: readonly ToolId[] | null): ToolId[];
|
|
13
|
+
/** Whether a tool by this id is registered, without logging anything when it is not. */
|
|
14
|
+
export declare function useHasTool(ctx: InkContext, id: MaybeRefOrGetter<ToolId>): Readonly<Ref<boolean>>;
|
|
15
|
+
/**
|
|
16
|
+
* Whether a tool by this id is registered: always for `select-text` and `select`, else when
|
|
17
|
+
* InkRoot's `tools` or a plugin has it. When it is not, once the plugins are set up, this logs
|
|
18
|
+
* `InkError('UnknownTool')` to the console, once per component.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useRegisteredTool(id: MaybeRefOrGetter<ToolId>): Readonly<Ref<boolean>>;
|
|
21
|
+
//# sourceMappingURL=useRegisteredTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRegisteredTool.d.ts","sourceRoot":"","sources":["../../src/composables/useRegisteredTool.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,KAAK,gBAAgB,EAAE,KAAK,GAAG,EAAE,MAAM,KAAK,CAAA;AAE/E,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEhE,yFAAyF;AACzF,wBAAgB,SAAS,CACvB,SAAS,EAAE,SAAS,IAAI,EAAE,GAAG,SAAS,EACtC,UAAU,EAAE,UAAU,GAAG,IAAI,GAC5B,MAAM,EAAE,CAIV;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,IAAI,EAAE,GAAG,SAAS,EACtC,UAAU,EAAE,UAAU,GAAG,IAAI,EAC7B,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,GAC/B,MAAM,EAAE,CAGV;AAKD,wFAAwF;AACxF,wBAAgB,UAAU,CACxB,GAAG,EAAE,UAAU,EACf,EAAE,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAC3B,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAExB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAetF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useInkContext as e } from "../context.js";
|
|
2
|
+
import { computed as t, toValue as n, watch as r } from "vue";
|
|
3
|
+
import { unknownTool as i, withHostTools as a } from "@inkbar/core/dom";
|
|
4
|
+
//#region src/composables/useRegisteredTool.ts
|
|
5
|
+
function o(e, t) {
|
|
6
|
+
return a([...e ?? [], ...t?.tools ?? []]).map((e) => e.id);
|
|
7
|
+
}
|
|
8
|
+
function s(e, t, n) {
|
|
9
|
+
let r = o(e, t);
|
|
10
|
+
return n ? r.filter((e) => n.includes(e)) : r;
|
|
11
|
+
}
|
|
12
|
+
var c = (e) => s(e.hostTools.value, e.pluginHost.value, e.openedToolIds.value);
|
|
13
|
+
function l(e, r) {
|
|
14
|
+
return t(() => c(e).includes(n(r)));
|
|
15
|
+
}
|
|
16
|
+
function u(t) {
|
|
17
|
+
let a = e("useRegisteredTool()"), o = l(a, t), s = !1;
|
|
18
|
+
return r([() => a.pluginHost.value !== null, o], ([e, r]) => {
|
|
19
|
+
!e || r || s || (s = !0, console.error(i(n(t), c(a))));
|
|
20
|
+
}, { immediate: !0 }), o;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { s as registeredToolIds, o as toolIdsOf, l as useHasTool, u as useRegisteredTool };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=useRegisteredTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRegisteredTool.js","names":["toolIdsOf","withHostTools","hostTools","pluginHost","t","registeredToolIds","ids","opened","id","idsIn","ctx","useHasTool","computed","toValue","useRegisteredTool","useInkContext","registered","logged","watch","ready","ok","unknownTool"],"sources":["../../src/composables/useRegisteredTool.ts"],"sourcesContent":["import { unknownTool, withHostTools } from '@inkbar/core/dom'\nimport { computed, toValue, watch, type MaybeRefOrGetter, type Ref } from 'vue'\n\nimport { useInkContext, type InkContext } from '../context'\n\nimport type { PluginHost, Tool, ToolId } from '@inkbar/core/dom'\n\n/** `select-text` and `select`, then the host's tools, then the plugins' tools, by id. */\nexport function toolIdsOf(\n hostTools: readonly Tool[] | undefined,\n pluginHost: PluginHost | null\n): ToolId[] {\n return withHostTools([...(hostTools ?? []), ...(pluginHost?.tools ?? [])]).map(\n (t) => t.id\n )\n}\n\n/**\n * The tools a control may use: those in `tools` and the plugins now that the open viewer was\n * also built with, so a control never offers a tool the viewer would refuse. A tool added to\n * `tools` counts from the next open; one removed stops at once. With no viewer, `tools` and\n * the plugins alone.\n */\nexport function registeredToolIds(\n hostTools: readonly Tool[] | undefined,\n pluginHost: PluginHost | null,\n opened: readonly ToolId[] | null\n): ToolId[] {\n const ids = toolIdsOf(hostTools, pluginHost)\n return opened ? ids.filter((id) => opened.includes(id)) : ids\n}\n\nconst idsIn = (ctx: InkContext): ToolId[] =>\n registeredToolIds(ctx.hostTools.value, ctx.pluginHost.value, ctx.openedToolIds.value)\n\n/** Whether a tool by this id is registered, without logging anything when it is not. */\nexport function useHasTool(\n ctx: InkContext,\n id: MaybeRefOrGetter<ToolId>\n): Readonly<Ref<boolean>> {\n return computed(() => idsIn(ctx).includes(toValue(id)))\n}\n\n/**\n * Whether a tool by this id is registered: always for `select-text` and `select`, else when\n * InkRoot's `tools` or a plugin has it. When it is not, once the plugins are set up, this logs\n * `InkError('UnknownTool')` to the console, once per component.\n */\nexport function useRegisteredTool(id: MaybeRefOrGetter<ToolId>): Readonly<Ref<boolean>> {\n const ctx = useInkContext('useRegisteredTool()')\n const registered = useHasTool(ctx, id)\n let logged = false\n // The plugins' tools are known once InkRoot has mounted and set up its plugin host.\n watch(\n [() => ctx.pluginHost.value !== null, registered],\n ([ready, ok]) => {\n if (!ready || ok || logged) return\n logged = true\n console.error(unknownTool(toValue(id), idsIn(ctx)))\n },\n { immediate: true }\n )\n return registered\n}\n"],"mappings":";;;;AAQA,SAAgBA,EACd,GACA,GACU;CACV,OAAOC,EAAc,CAAC,GAAIC,KAAa,CAAC,GAAI,GAAIC,GAAY,SAAS,CAAC,CAAE,CAAC,CAAC,CAAC,KACxE,MAAMC,EAAE,EACX;AACF;AAQA,SAAgBC,EACd,GACA,GACA,GACU;CACV,IAAMC,IAAMN,EAAUE,GAAWC,CAAU;CAC3C,OAAOI,IAASD,EAAI,QAAQ,MAAOC,EAAO,SAASC,CAAE,CAAC,IAAIF;AAC5D;AAEA,IAAMG,KAAS,MACbJ,EAAkBK,EAAI,UAAU,OAAOA,EAAI,WAAW,OAAOA,EAAI,cAAc,KAAK;AAGtF,SAAgBC,EACd,GACA,GACwB;CACxB,OAAOC,QAAeH,EAAMC,CAAG,CAAC,CAAC,SAASG,EAAQL,CAAE,CAAC,CAAC;AACxD;AAOA,SAAgBM,EAAkB,GAAsD;CACtF,IAAMJ,IAAMK,EAAc,qBAAqB,GACzCC,IAAaL,EAAWD,GAAKF,CAAE,GACjCS,IAAS;CAWb,OATAC,EACE,OAAOR,EAAI,WAAW,UAAU,MAAMM,CAAU,IAC/C,CAACG,GAAOC,OAAQ;EACf,AAAI,CAACD,KAASC,KAAMH,MACpB,IAAS,IACT,QAAQ,MAAMI,EAAYR,EAAQL,CAAE,GAAGC,EAAMC,CAAG,CAAC,CAAC;CACpD,GACA,EAAE,WAAW,GAAK,CACpB,GACOM;AACT"}
|
|
@@ -8,4 +8,12 @@ export declare function useToolOptions<O extends object = object>(id: MaybeRefOr
|
|
|
8
8
|
options: Readonly<Ref<O>>;
|
|
9
9
|
setOptions: (patch: Partial<O>) => void;
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* `useToolOptions` that reads and sets nothing while `active` is false, so a control for a
|
|
13
|
+
* missing tool leaves the controller's own `UnknownTool` log alone.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useToolOptionsWhile<O extends object = object>(id: MaybeRefOrGetter<ToolId>, active: MaybeRefOrGetter<boolean>): {
|
|
16
|
+
options: Readonly<Ref<O>>;
|
|
17
|
+
setOptions: (patch: Partial<O>) => void;
|
|
18
|
+
};
|
|
11
19
|
//# sourceMappingURL=useToolOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToolOptions.d.ts","sourceRoot":"","sources":["../../src/composables/useToolOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,gBAAgB,EAAE,KAAK,GAAG,EAAE,MAAM,KAAK,CAAA;AAK9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAI9C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EACtD,EAAE,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAC3B;IAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAAC,UAAU,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"useToolOptions.d.ts","sourceRoot":"","sources":["../../src/composables/useToolOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,gBAAgB,EAAE,KAAK,GAAG,EAAE,MAAM,KAAK,CAAA;AAK9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAI9C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EACtD,EAAE,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAC3B;IAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAAC,UAAU,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;CAAE,CAExE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAC3D,EAAE,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAC5B,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,GAChC;IAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAAC,UAAU,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;CAAE,CAYxE"}
|
|
@@ -3,14 +3,19 @@ import { useReadable as t } from "../use-readable.js";
|
|
|
3
3
|
import { toValue as n } from "vue";
|
|
4
4
|
//#region src/composables/useToolOptions.ts
|
|
5
5
|
var r = {};
|
|
6
|
-
function i(
|
|
7
|
-
|
|
6
|
+
function i(e) {
|
|
7
|
+
return a(e, !0);
|
|
8
|
+
}
|
|
9
|
+
function a(i, a) {
|
|
10
|
+
let o = e("useToolOptions()");
|
|
8
11
|
return {
|
|
9
|
-
options: t(() => a.tools.value?.options(n(i)), r),
|
|
10
|
-
setOptions: (e) =>
|
|
12
|
+
options: t(() => n(a) ? o.tools.value?.options(n(i)) : null, r),
|
|
13
|
+
setOptions: (e) => {
|
|
14
|
+
n(a) && o.tools.value?.setOptions(n(i), e);
|
|
15
|
+
}
|
|
11
16
|
};
|
|
12
17
|
}
|
|
13
18
|
//#endregion
|
|
14
|
-
export { i as useToolOptions };
|
|
19
|
+
export { i as useToolOptions, a as useToolOptionsWhile };
|
|
15
20
|
|
|
16
21
|
//# sourceMappingURL=useToolOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToolOptions.js","names":["NO_OPTIONS","useToolOptions","ctx","useInkContext","useReadable","toValue","
|
|
1
|
+
{"version":3,"file":"useToolOptions.js","names":["NO_OPTIONS","useToolOptions","useToolOptionsWhile","id","ctx","useInkContext","useReadable","toValue","active","patch"],"sources":["../../src/composables/useToolOptions.ts"],"sourcesContent":["import { toValue, type MaybeRefOrGetter, type Ref } from 'vue'\n\nimport { useInkContext } from '../context'\nimport { useReadable } from '../use-readable'\n\nimport type { ToolId } from '@inkbar/core/dom'\n\nconst NO_OPTIONS: object = {}\n\n/**\n * A tool's options and a setter that merges a patch into them without switching tools.\n * Options are empty, and the setter does nothing, until the viewport has mounted.\n */\nexport function useToolOptions<O extends object = object>(\n id: MaybeRefOrGetter<ToolId>\n): { options: Readonly<Ref<O>>; setOptions: (patch: Partial<O>) => void } {\n return useToolOptionsWhile<O>(id, true)\n}\n\n/**\n * `useToolOptions` that reads and sets nothing while `active` is false, so a control for a\n * missing tool leaves the controller's own `UnknownTool` log alone.\n */\nexport function useToolOptionsWhile<O extends object = object>(\n id: MaybeRefOrGetter<ToolId>,\n active: MaybeRefOrGetter<boolean>\n): { options: Readonly<Ref<O>>; setOptions: (patch: Partial<O>) => void } {\n const ctx = useInkContext('useToolOptions()')\n const options = useReadable(\n () => (toValue(active) ? ctx.tools.value?.options(toValue(id)) : null),\n NO_OPTIONS\n ) as Readonly<Ref<O>>\n return {\n options,\n setOptions: (patch) => {\n if (toValue(active)) ctx.tools.value?.setOptions(toValue(id), patch)\n },\n }\n}\n"],"mappings":";;;;AAOA,IAAMA,IAAqB,CAAC;AAM5B,SAAgBC,EACd,GACwE;CACxE,OAAOC,EAAuBC,GAAI,EAAI;AACxC;AAMA,SAAgBD,EACd,GACA,GACwE;CACxE,IAAME,IAAMC,EAAc,kBAAkB;CAK5C,OAAO;EACL,SALcC,QACPC,EAAQC,CAAM,IAAIJ,EAAI,MAAM,OAAO,QAAQG,EAAQJ,CAAE,CAAC,IAAI,MACjEH,CAGA;EACA,aAAa,MAAU;GACrB,AAAIO,EAAQC,CAAM,KAAGJ,EAAI,MAAM,OAAO,WAAWG,EAAQJ,CAAE,GAAGM,CAAK;EACrE;CACF;AACF"}
|
package/dist/context.d.ts
CHANGED
|
@@ -49,6 +49,11 @@ export interface InkContext {
|
|
|
49
49
|
setTool(id: ToolId): void;
|
|
50
50
|
/** Host tools from InkRoot's `tools` prop; InkViewport registers them. */
|
|
51
51
|
hostTools: Readonly<Ref<Tool[] | undefined>>;
|
|
52
|
+
/**
|
|
53
|
+
* The ids of the tools the current viewer was built with, set by InkViewport; `null` while
|
|
54
|
+
* there is none. A tool added to `tools` later is registered from the next build.
|
|
55
|
+
*/
|
|
56
|
+
openedToolIds: ShallowRef<readonly ToolId[] | null>;
|
|
52
57
|
/** InkRoot's `decorateAnnotation` prop. InkViewport re-applies decorations when it changes. */
|
|
53
58
|
decorateAnnotation: Readonly<Ref<DecorateAnnotation | undefined>>;
|
|
54
59
|
/** The font families text boxes offer: InkRoot's `fonts`, else `FONT_FAMILIES`. */
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,SAAS,EACT,SAAS,EACT,aAAa,EACb,gBAAgB,EACjB,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,gBAAgB,EAChB,IAAI,EACJ,cAAc,EACd,MAAM,EACN,WAAW,EACX,SAAS,EACT,QAAQ,EACR,SAAS,EACV,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAE1C,YAAY,EAAE,SAAS,EAAE,CAAA;AAEzB;;;GAGG;AACH,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC/C,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;IAC/B,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;IAC/B,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB;;;;;OAKG;IACH,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,CAAA;CA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