@inkbar/vue 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +14 -2
  2. package/dist/components/InkFormAlert.js +7 -0
  3. package/dist/components/InkFormAlert.js.map +1 -0
  4. package/dist/components/InkFormAlert.vue.d.ts +16 -0
  5. package/dist/components/InkFormAlert.vue.d.ts.map +1 -0
  6. package/dist/components/InkFormAlert.vue_vue_type_script_setup_true_lang.js +90 -0
  7. package/dist/components/InkFormAlert.vue_vue_type_script_setup_true_lang.js.map +1 -0
  8. package/dist/components/InkHighlightMenu.js.map +1 -1
  9. package/dist/components/InkHighlightMenu.vue.d.ts.map +1 -1
  10. package/dist/components/InkHighlightMenu.vue_vue_type_script_setup_true_lang.js +67 -65
  11. package/dist/components/InkHighlightMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  12. package/dist/components/InkRoot.js.map +1 -1
  13. package/dist/components/InkRoot.vue.d.ts +24 -5
  14. package/dist/components/InkRoot.vue.d.ts.map +1 -1
  15. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js +197 -148
  16. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js.map +1 -1
  17. package/dist/components/InkShapeMenu.js.map +1 -1
  18. package/dist/components/InkShapeMenu.vue.d.ts.map +1 -1
  19. package/dist/components/InkShapeMenu.vue_vue_type_script_setup_true_lang.js +58 -56
  20. package/dist/components/InkShapeMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  21. package/dist/components/InkSignFieldPopover.js +7 -0
  22. package/dist/components/InkSignFieldPopover.js.map +1 -0
  23. package/dist/components/InkSignFieldPopover.vue.d.ts +13 -0
  24. package/dist/components/InkSignFieldPopover.vue.d.ts.map +1 -0
  25. package/dist/components/InkSignFieldPopover.vue_vue_type_script_setup_true_lang.js +116 -0
  26. package/dist/components/InkSignFieldPopover.vue_vue_type_script_setup_true_lang.js.map +1 -0
  27. package/dist/components/InkSignatureDialog.js.map +1 -1
  28. package/dist/components/InkSignatureDialog.vue.d.ts +10 -1
  29. package/dist/components/InkSignatureDialog.vue.d.ts.map +1 -1
  30. package/dist/components/InkSignatureDialog.vue_vue_type_script_setup_true_lang.js +9 -2
  31. package/dist/components/InkSignatureDialog.vue_vue_type_script_setup_true_lang.js.map +1 -1
  32. package/dist/components/InkSignatureMenu.js.map +1 -1
  33. package/dist/components/InkSignatureMenu.vue.d.ts.map +1 -1
  34. package/dist/components/InkSignatureMenu.vue_vue_type_script_setup_true_lang.js +69 -154
  35. package/dist/components/InkSignatureMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  36. package/dist/components/InkToolButton.js.map +1 -1
  37. package/dist/components/InkToolButton.vue.d.ts.map +1 -1
  38. package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js +39 -36
  39. package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  40. package/dist/components/InkToolbarButton.js +7 -0
  41. package/dist/components/InkToolbarButton.js.map +1 -0
  42. package/dist/components/InkToolbarButton.vue.d.ts +22 -0
  43. package/dist/components/InkToolbarButton.vue.d.ts.map +1 -0
  44. package/dist/components/InkToolbarButton.vue_vue_type_script_setup_true_lang.js +32 -0
  45. package/dist/components/InkToolbarButton.vue_vue_type_script_setup_true_lang.js.map +1 -0
  46. package/dist/components/InkViewport.js.map +1 -1
  47. package/dist/components/InkViewport.vue.d.ts.map +1 -1
  48. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js +123 -91
  49. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js.map +1 -1
  50. package/dist/components/SignatureForm.js.map +1 -1
  51. package/dist/components/SignatureForm.vue.d.ts +5 -1
  52. package/dist/components/SignatureForm.vue.d.ts.map +1 -1
  53. package/dist/components/SignatureForm.vue_vue_type_script_setup_true_lang.js +64 -57
  54. package/dist/components/SignatureForm.vue_vue_type_script_setup_true_lang.js.map +1 -1
  55. package/dist/components/SignatureMenuPanel.js +7 -0
  56. package/dist/components/SignatureMenuPanel.js.map +1 -0
  57. package/dist/components/SignatureMenuPanel.vue.d.ts +15 -0
  58. package/dist/components/SignatureMenuPanel.vue.d.ts.map +1 -0
  59. package/dist/components/SignatureMenuPanel.vue_vue_type_script_setup_true_lang.js +116 -0
  60. package/dist/components/SignatureMenuPanel.vue_vue_type_script_setup_true_lang.js.map +1 -0
  61. package/dist/composables/useForm.d.ts +18 -0
  62. package/dist/composables/useForm.d.ts.map +1 -0
  63. package/dist/composables/useForm.js +17 -0
  64. package/dist/composables/useForm.js.map +1 -0
  65. package/dist/composables/useRegisteredTool.d.ts +21 -0
  66. package/dist/composables/useRegisteredTool.d.ts.map +1 -0
  67. package/dist/composables/useRegisteredTool.js +25 -0
  68. package/dist/composables/useRegisteredTool.js.map +1 -0
  69. package/dist/composables/useToolOptions.d.ts +8 -0
  70. package/dist/composables/useToolOptions.d.ts.map +1 -1
  71. package/dist/composables/useToolOptions.js +10 -5
  72. package/dist/composables/useToolOptions.js.map +1 -1
  73. package/dist/context.d.ts +12 -1
  74. package/dist/context.d.ts.map +1 -1
  75. package/dist/context.js.map +1 -1
  76. package/dist/index.d.ts +3 -0
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +29 -27
  79. 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","InkPage_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","pages","shallowRef","state","computed","error","engine","build","custom","stops","lastReportedZoom","lastReportedPage","teardown","stop","rebuild","e","opts","setup","doc","el","first","mountViewer","a","fn","id","vp","tc","reportZoom","z","reportPage","p","page","err","onMounted","watch","t","m","r","gap","buffer","onBeforeUpdate","next","onBeforeUnmount","openBlock","createElementBlock","renderSlot","_ctx","_cache","createTextVNode","createElementVNode","toDisplayString","createCommentVNode","Fragment","renderList","createBlock","createSlots","withCtx","mergeProps","slotProps"],"sources":["../../src/components/InkViewport.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The scroll element is handed to core's `mountViewer`, which builds the viewport, the page\n * layers, the tool controller and the keyboard shortcuts in it; Vue never renders children\n * into it. The engine reports each page host it mounts, and InkPage components rendered here\n * (they render nothing in place) teleport the page-error and custom-annotation slots into them.\n *\n * Two-way zoom and page: the viewport's own changes are reported through the context, and\n * the host's v-model values are applied only when they differ from the viewport's state, so\n * the echo of a reported value does nothing.\n */\nimport { mountViewer } from '@inkbar/core/dom'\nimport {\n computed,\n onBeforeUnmount,\n onBeforeUpdate,\n onMounted,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { injectInkContext } from '../context'\n\nimport InkPage from './InkPage.vue'\n\nimport type { AnnotationSlotProps } from './annotation-slot'\nimport type { InkError } from '@inkbar/core'\nimport type {\n LayoutMode,\n PageMount,\n ToolId,\n ViewerEngine,\n ViewRotation,\n ZoomValue,\n} from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{\n mode?: LayoutMode\n rotation?: ViewRotation\n /** Gap between pages, CSS px. */\n gap?: number\n /** Pages kept mounted either side of the visible ones. */\n buffer?: number\n }>(),\n { mode: 'continuous', rotation: 0, gap: 16, buffer: 2 }\n)\n\nconst slots = defineSlots<{\n loading?(): unknown\n error?(props: { error: InkError }): unknown\n empty?(): unknown\n annotation?(props: AnnotationSlotProps): unknown\n /** Shown inside a page that failed to render. The rest of the document stays usable. */\n 'page-error'?(props: { error: InkError; page: number }): unknown\n}>()\n\nconst ctx = injectInkContext()\nconst scroll = useTemplateRef<HTMLElement>('scroll')\n\ninterface MountedPage {\n /** The engine build the host belongs to; part of the InkPage key. */\n build: number\n page: number\n host: HTMLElement\n mount: PageMount\n error: InkError | null\n /** Whether the build that mounted the page renders the annotation slot. */\n custom: boolean\n}\n/** Page hosts, mounts and errors the engine reported; InkPage renders Teleports for them. */\nconst pages = shallowRef<MountedPage[]>([])\n\nconst state = computed(() => ctx.status.value.state)\nconst error = computed<InkError | null>(() =>\n ctx.status.value.state === 'error' ? ctx.status.value.error : null\n)\n\nconst engine = shallowRef<ViewerEngine | null>(null)\n/**\n * Numbered before each build starts, so the pages a build mounts carry its own number. A\n * rebuild gives each page a new host and mount, so pages from an earlier build must remount,\n * not be reused.\n */\nlet build = 0\n/** Whether the current build renders the annotation slot. */\nlet custom = false\nlet stops: (() => void)[] = []\n/** The zoom and page last reported to the host. */\nlet lastReportedZoom: ZoomValue | undefined\nlet lastReportedPage: number | undefined\n\nfunction teardown(): void {\n for (const stop of stops) stop()\n stops = []\n // Unmounts every page, which empties `pages` through `onPageUnmount`.\n engine.value?.destroy()\n engine.value = null\n if (ctx.viewport.value) ctx.viewport.value = null\n if (ctx.tools.value) ctx.tools.value = null\n pages.value = []\n}\n\nfunction rebuild(opts: Parameters<ViewerEngine['rebuild']>[0]): void {\n const e = engine.value\n if (!e) return\n build += 1\n if (opts.customAnnotations !== undefined) custom = opts.customAnnotations\n e.rebuild(opts)\n}\n\n// Build for a new document or status; the previous engine is torn down first.\nfunction setup(): void {\n teardown()\n lastReportedZoom = undefined\n lastReportedPage = undefined\n const doc = ctx.document.value\n const el = scroll.value\n if (!doc || !el || ctx.status.value.state !== 'ready') return\n let first = true\n build += 1\n custom = !!slots.annotation\n engine.value = mountViewer({\n container: el,\n document: doc,\n zoom: ctx.zoomModel.value ?? 'fit-width',\n ...(ctx.pageModel.value === undefined ? {} : { page: ctx.pageModel.value }),\n mode: props.mode,\n rotation: props.rotation,\n gap: props.gap,\n buffer: props.buffer,\n tool: ctx.tool.value,\n ...(ctx.hostTools.value ? { tools: ctx.hostTools.value } : {}),\n // The engine adds the plugins' tools and layers, and decorates through the host, which\n // reads `decorateAnnotation` first.\n ...(ctx.pluginHost.value ? { plugins: ctx.pluginHost.value } : {}),\n // The engine draws the search matches on the pages.\n ...(ctx.search.value ? { search: ctx.search.value } : {}),\n // Read through, so the watch below can re-apply a new function without a rebuild.\n decorateAnnotation: (a) => ctx.decorateAnnotation.value?.(a),\n ...(ctx.toolStyle.value ? { toolStyle: ctx.toolStyle.value } : {}),\n toolHistory: { batch: (fn) => ctx.history.batch(fn) },\n toolOptions: ctx.toolOptions,\n fonts: [...ctx.fonts.value],\n // Read through, so a new `signatures` store reaches the tool as well as the menus.\n signatureLibrary: () => ctx.signatures.value,\n customAnnotations: custom,\n onActivate: (id) => ctx.setActivated(id),\n onBuild: (vp, tc) => {\n ctx.viewport.value = vp\n ctx.tools.value = tc\n if (first) {\n // A new document starts from where the viewport opens (its zoom, on the first page:\n // `createViewport` always starts at page 0); only later changes are reported, the\n // restored page among them, since the engine has already scrolled to it.\n first = false\n lastReportedZoom = vp.zoom.get()\n lastReportedPage = 0\n }\n for (const stop of stops) stop()\n const reportZoom = (z: ZoomValue): void => {\n if (z === lastReportedZoom) return\n lastReportedZoom = z\n ctx.reportZoom(z)\n }\n const reportPage = (p: number): void => {\n if (p === lastReportedPage) return\n lastReportedPage = p\n ctx.reportPage(p)\n }\n // A tool that switches itself (a one-shot tool once used) is reported as a pick.\n const followTool = (id: ToolId): void => {\n if (id !== ctx.tool.value) ctx.setTool(id)\n }\n stops = [\n vp.zoom.subscribe(reportZoom),\n vp.currentPage.subscribe(reportPage),\n tc.active.subscribe(followTool),\n ]\n // Whatever the build restored is reported once; nothing is when it matched.\n reportZoom(vp.zoom.get())\n reportPage(vp.currentPage.get())\n },\n onPageMount: (page, mount, host) => {\n pages.value = [...pages.value, { build, page, host, mount, error: null, custom }]\n },\n onPageUnmount: (page) => {\n pages.value = pages.value.filter((p) => p.page !== page)\n },\n onPageError: (page, err) => {\n pages.value = pages.value.map((p) => (p.page === page ? { ...p, error: err } : p))\n },\n })\n}\n\nonMounted(() => {\n ctx.viewportEl.value = scroll.value\n watch([() => ctx.document.value, () => ctx.status.value.state], setup, {\n immediate: true,\n })\n})\n\n// A new decorateAnnotation re-applies to the mounted annotation elements at once.\nwatch(\n () => ctx.decorateAnnotation.value,\n () => engine.value?.redecorate()\n)\nwatch(\n () => ctx.zoomModel.value,\n (z: ZoomValue | undefined) => {\n const vp = engine.value?.viewport\n if (vp && z !== undefined && z !== vp.zoom.get()) vp.setZoom(z)\n }\n)\nwatch(\n () => ctx.pageModel.value,\n (p) => {\n const vp = engine.value?.viewport\n if (!vp || p === undefined || p === lastReportedPage) return\n if (p !== vp.currentPage.get()) vp.scrollToPage(p)\n }\n)\nwatch(\n () => ctx.tool.value,\n (t) => {\n const tc = engine.value?.tools\n if (tc && tc.active.get() !== t) tc.set(t)\n }\n)\nwatch(\n () => props.mode,\n (m) => engine.value?.viewport.setMode(m)\n)\nwatch(\n () => props.rotation,\n (r) => engine.value?.viewport.setRotation(r)\n)\n// Gap and buffer are construction options: rebuild for the same document, keeping zoom and page.\n// The slots are already updated when this runs, so it carries the annotation slot too: a slot\n// toggle in the same tick is then recorded here and `onBeforeUpdate` finds nothing left to do.\nwatch([() => props.gap, () => props.buffer], ([gap, buffer]) =>\n rebuild({ gap, buffer, customAnnotations: !!slots.annotation })\n)\n\n// Slots are not reactive, so a change to whether the annotation slot is given is caught here.\n// `onBeforeUpdate` runs after the new slots are in place and before this render: the rebuild\n// swaps `pages` for the new build's pages synchronously, so the render that follows never pairs\n// the annotation slot with an overlay built without it (or the reverse). The rebuild keeps the\n// scroll position.\nonBeforeUpdate(() => {\n const next = !!slots.annotation\n if (engine.value && next !== custom) rebuild({ customAnnotations: next })\n})\n\nonBeforeUnmount(() => {\n teardown()\n if (ctx.viewportEl.value === scroll.value) ctx.viewportEl.value = null\n})\n</script>\n\n<template>\n <div class=\"ink-viewport-root\" data-ink-viewport-root :data-state=\"state\">\n <div v-if=\"state === 'loading'\" class=\"ink-status\" role=\"status\" aria-live=\"polite\">\n <slot name=\"loading\">Loading document…</slot>\n </div>\n <div v-else-if=\"error\" class=\"ink-status ink-error\" role=\"alert\">\n <slot name=\"error\" :error=\"error\">\n <p class=\"ink-error-title\">This document could not be opened.</p>\n <!-- The message comes from the PDF engine and is not written for readers: it stays\n off the page, on the code's tooltip. -->\n <p>\n <code class=\"ink-error-code\" :title=\"error.message\">{{ error.code }}</code>\n </p>\n </slot>\n </div>\n <div v-else-if=\"state === 'idle'\" class=\"ink-status ink-empty\">\n <slot name=\"empty\" />\n </div>\n <div\n ref=\"scroll\"\n class=\"ink-scroll\"\n data-ink-scroll\n tabindex=\"0\"\n role=\"document\"\n aria-label=\"Document\"\n />\n <InkPage\n v-for=\"p in pages\"\n :key=\"`${p.build}:${p.page}`\"\n :page=\"p.page\"\n :host=\"p.host\"\n :mount=\"p.mount\"\n :error=\"p.error\"\n :custom-annotations=\"p.custom\"\n >\n <template v-if=\"slots.annotation\" #annotation=\"slotProps\">\n <slot name=\"annotation\" v-bind=\"slotProps\" />\n </template>\n <template v-if=\"slots['page-error']\" #page-error=\"slotProps\">\n <slot name=\"page-error\" v-bind=\"slotProps\" />\n </template>\n </InkPage>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;EAqCA,IAAMsB,IAAQC,GAYRC,IAAQxB,EAAA,GASR0B,IAAMC,EAAiB,GACvBC,IAASC,EAA4B,QAAQ,GAa7CC,IAAQC,EAA0B,CAAC,CAAC,GAEpCC,IAAQC,QAAeP,EAAI,OAAO,MAAM,KAAK,GAC7CQ,IAAQD,QACZP,EAAI,OAAO,MAAM,UAAU,UAAUA,EAAI,OAAO,MAAM,QAAQ,IAChE,GAEMS,IAASJ,EAAgC,IAAI,GAM/CK,IAAQ,GAERC,IAAS,IACTC,IAAwB,CAAC,GAEzBC,GACAC;EAEJ,SAASC,IAAiB;GACxB,KAAK,IAAMC,KAAQJ,GAAO,EAAK;GAO/B,AANA,IAAQ,CAAC,GAETH,EAAO,OA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AAA,GAAA,CAAA5D,EAAM,aAAA;IAAa,MAAA;IACjC,IAAAX,GAD6C,MAAS,CACtDV,EAA6CwE,EAAA,QAAA,cAA7C7D,EAA6C,EAAA,SAAA,GAAA,GAAbyE,CAAS,CAAA,CAAA,CAAA;;GAE3B,IAAA,KAAA,GAAA/D,EAAK,gBAAA;IAAiB,MAAA;IACpC,IAAAX,GADgD,MAAS,CACzDV,EAA6CwE,EAAA,QAAA,cAA7C7D,EAA6C,EAAA,SAAA,GAAA,GAAbyE,CAAS,CAAA,CAAA,CAAA"}
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,OAA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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 { useToolOptions } from '../composables/useToolOptions'\nimport { useInkContext } from '../context'\nimport { useReadable } from '../use-readable'\n\nimport type { SignatureOptions, SignatureTemplate } from '@inkbar/core'\n\nconst props = defineProps<{ fonts?: readonly string[] | undefined }>()\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 setOptions({ templateId: t.id })\n setTool('signature')\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
+ {"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,6 +1,7 @@
1
1
  import { SignatureTemplate } from '@inkbar/core';
2
2
  type __VLS_Props = {
3
3
  fonts?: readonly string[] | undefined;
4
+ select?: boolean;
4
5
  };
5
6
  declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
6
7
  close: () => any;
@@ -8,7 +9,10 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {
8
9
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
9
10
  onClose?: () => any;
10
11
  onSaved?: (template: SignatureTemplate) => any;
11
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
12
+ }>, {
13
+ select: boolean;
14
+ fonts: readonly string[] | undefined;
15
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
12
16
  declare const _default: typeof __VLS_export;
13
17
  export default _default;
14
18
  //# sourceMappingURL=SignatureForm.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SignatureForm.vue.d.ts","sourceRoot":"","sources":["../../src/components/SignatureForm.vue"],"names":[],"mappings":"AAyPA,OAAO,KAAK,EAAoB,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAGvE,KAAK,WAAW,GAAG;IAAE,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;CAAE,CAAC;AAsR7D,QAAA,MAAM,YAAY;;;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
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 { useReadable as t } from "../use-readable.js";
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 { useToolOptions as ee } from "../composables/useToolOptions.js";
5
- import { Fragment as r, computed as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createVNode as te, defineComponent as c, normalizeStyle as ne, onBeforeUnmount as l, onMounted as re, openBlock as u, renderList as d, toDisplayString as f, unref as p, useId as m, useTemplateRef as h, withCtx as ie } from "vue";
6
- import { SIGNATURE_LABELS as g, SIGNATURE_TABS as ae, createSignatureDraft as _, fontFamilyValue as v, handleRadioKeys as y, handleTabKeys as b } from "@inkbar/core/dom";
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 = [
@@ -37,141 +38,147 @@ var S = ["aria-label"], C = [
37
38
  key: 1,
38
39
  class: "ink-field-error",
39
40
  role: "alert"
40
- }, oe = {
41
+ }, L = {
41
42
  key: 0,
42
43
  class: "ink-field-error",
43
44
  role: "alert",
44
45
  "data-ink-signature-save-error": ""
45
- }, L = { class: "ink-dialog-actions" }, R = {
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__*/ c({
50
+ }, z = ["disabled"], B = /*@__PURE__*/ l({
50
51
  __name: "SignatureForm",
51
- props: { fonts: {} },
52
+ props: {
53
+ fonts: { default: void 0 },
54
+ select: {
55
+ type: Boolean,
56
+ default: !0
57
+ }
58
+ },
52
59
  emits: ["saved", "close"],
53
- setup(c, { emit: B }) {
54
- let V = c, H = B, U = e("InkSignatureDialog"), { setTool: W } = n(), { setOptions: G } = ee("signature"), K = _({ fonts: V.fonts ?? U.signatureFonts.value }), q = K.state.get(), J = t(K.state, q), Y = m(), X = h("pad"), Z;
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;
55
62
  re(() => {
56
- X.value && (Z = K.attachPad(X.value));
57
- }), l(() => {
58
- Z?.(), K.destroy();
63
+ X.value && (Z = q.attachPad(X.value));
64
+ }), ne(() => {
65
+ Z?.(), q.destroy();
59
66
  });
60
- function se() {
61
- K.save(U.signatures.value).then((e) => {
62
- e && (G({ templateId: e.id }), W("signature"), H("saved", e), H("close"));
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"));
63
70
  }, () => {});
64
71
  }
65
- let Q = (e) => `${Y}-tab-${e}`, $ = (e) => `${Y}-panel-${e}`, ce = i(() => J.value.name.trim() || g.namePlaceholder), le = (e) => b(e, e.currentTarget), ue = (e) => y(e, e.currentTarget), de = (e) => K.setName(e.target.value), fe = (e) => void K.chooseFile(e.target.files?.[0]);
66
- return (e, t) => (u(), o(r, null, [
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, [
67
74
  s("div", {
68
75
  role: "tablist",
69
- "aria-label": p(g).tabs,
76
+ "aria-label": m(_).tabs,
70
77
  class: "ink-tabs",
71
- onKeydown: le
72
- }, [(u(!0), o(r, null, d(p(ae), (e) => (u(), o("button", {
78
+ onKeydown: de
79
+ }, [(d(!0), o(i, null, f(m(ae), (e) => (d(), o("button", {
73
80
  id: Q(e),
74
81
  key: e,
75
82
  type: "button",
76
83
  role: "tab",
77
84
  "aria-controls": $(e),
78
- "aria-selected": p(J).tab === e,
79
- tabindex: p(J).tab === e ? 0 : -1,
85
+ "aria-selected": m(J).tab === e,
86
+ tabindex: m(J).tab === e ? 0 : -1,
80
87
  class: "ink-tab",
81
88
  "data-key": e,
82
- "data-state": p(J).tab === e ? "active" : "inactive",
83
- onClick: (t) => p(K).setTab(e)
84
- }, f(p(g)[e]), 9, C))), 128))], 40, S),
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),
85
92
  s("div", {
86
93
  id: $("draw"),
87
94
  role: "tabpanel",
88
95
  "aria-labelledby": Q("draw"),
89
96
  class: "ink-tab-panel",
90
97
  "data-key": "draw",
91
- hidden: p(J).tab !== "draw"
98
+ hidden: m(J).tab !== "draw"
92
99
  }, [s("div", {
93
100
  ref: "pad",
94
101
  class: "ink-signature-pad-host",
95
102
  "data-ink-signature-pad-host": "",
96
103
  role: "img",
97
- "aria-label": p(g).pad
104
+ "aria-label": m(_).pad
98
105
  }, null, 8, T), s("div", E, [s("button", {
99
106
  type: "button",
100
107
  class: "ink-button",
101
108
  "data-ink-signature-clear": "",
102
- disabled: p(J).padEmpty,
103
- onClick: t[0] ||= (e) => p(K).clearPad()
104
- }, f(p(g).clear), 9, D)])], 8, w),
109
+ disabled: m(J).padEmpty,
110
+ onClick: t[0] ||= (e) => m(q).clearPad()
111
+ }, p(m(_).clear), 9, D)])], 8, w),
105
112
  s("div", {
106
113
  id: $("type"),
107
114
  role: "tabpanel",
108
115
  "aria-labelledby": Q("type"),
109
116
  class: "ink-tab-panel",
110
117
  "data-key": "type",
111
- hidden: p(J).tab !== "type"
112
- }, [s("label", k, [s("span", null, f(p(g).name), 1), s("input", {
118
+ hidden: m(J).tab !== "type"
119
+ }, [s("label", k, [s("span", null, p(m(_).name), 1), s("input", {
113
120
  type: "text",
114
121
  class: "ink-input",
115
122
  "data-ink-signature-name": "",
116
123
  autocomplete: "name",
117
- placeholder: p(g).namePlaceholder,
118
- value: p(J).name,
119
- onInput: de
124
+ placeholder: m(_).namePlaceholder,
125
+ value: m(J).name,
126
+ onInput: pe
120
127
  }, null, 40, A)]), s("div", {
121
128
  role: "radiogroup",
122
- "aria-label": p(g).fonts,
129
+ "aria-label": m(_).fonts,
123
130
  class: "ink-signature-fonts",
124
- onKeydown: ue
125
- }, [(u(!0), o(r, null, d(p(K).fonts, (e) => (u(), o("button", {
131
+ onKeydown: fe
132
+ }, [(d(!0), o(i, null, f(m(q).fonts, (e) => (d(), o("button", {
126
133
  key: e,
127
134
  type: "button",
128
135
  role: "radio",
129
- "aria-checked": p(J).font === e,
136
+ "aria-checked": m(J).font === e,
130
137
  "aria-label": e,
131
- tabindex: p(J).font === e ? 0 : -1,
138
+ tabindex: m(J).font === e ? 0 : -1,
132
139
  class: "ink-signature-font",
133
140
  "data-key": e,
134
- "data-state": p(J).font === e ? "checked" : "unchecked",
135
- onClick: (t) => p(K).setFont(e)
141
+ "data-state": m(J).font === e ? "checked" : "unchecked",
142
+ onClick: (t) => m(q).setFont(e)
136
143
  }, [s("span", {
137
144
  class: "ink-signature-font-sample",
138
- style: ne({ fontFamily: p(v)(e) })
139
- }, f(ce.value), 5)], 8, M))), 128))], 40, j)], 8, O),
145
+ style: u({ fontFamily: m(v)(e) })
146
+ }, p(ue.value), 5)], 8, M))), 128))], 40, j)], 8, O),
140
147
  s("div", {
141
148
  id: $("image"),
142
149
  role: "tabpanel",
143
150
  "aria-labelledby": Q("image"),
144
151
  class: "ink-tab-panel",
145
152
  "data-key": "image",
146
- hidden: p(J).tab !== "image"
153
+ hidden: m(J).tab !== "image"
147
154
  }, [
148
- s("label", P, [s("span", null, f(p(g).file), 1), s("input", {
155
+ s("label", P, [s("span", null, p(m(_).file), 1), s("input", {
149
156
  type: "file",
150
157
  accept: "image/png,image/jpeg",
151
158
  class: "ink-input",
152
159
  "data-ink-signature-file": "",
153
- onChange: fe
160
+ onChange: me
154
161
  }, null, 32)]),
155
- p(J).image?.kind === "image" ? (u(), o("img", {
162
+ m(J).image?.kind === "image" ? (d(), o("img", {
156
163
  key: 0,
157
164
  class: "ink-signature-image",
158
- src: p(J).image.imagedata,
165
+ src: m(J).image.imagedata,
159
166
  alt: ""
160
167
  }, null, 8, F)) : a("", !0),
161
- p(J).imageError ? (u(), o("p", I, f(p(J).imageError), 1)) : a("", !0)
168
+ m(J).imageError ? (d(), o("p", I, p(m(J).imageError), 1)) : a("", !0)
162
169
  ], 8, N),
163
- p(J).saveError ? (u(), o("p", oe, f(p(J).saveError), 1)) : a("", !0),
164
- s("div", L, [te(p(x), { "as-child": "" }, {
165
- default: ie(() => [s("button", R, f(p(g).cancel), 1)]),
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)]),
166
173
  _: 1
167
174
  }), s("button", {
168
175
  type: "button",
169
176
  class: "ink-button",
170
177
  "data-variant": "primary",
171
178
  "data-ink-signature-save": "",
172
- disabled: !p(J).canSave,
173
- onClick: se
174
- }, f(p(g).save), 9, z)])
179
+ disabled: !m(J).canSave,
180
+ onClick: le
181
+ }, p(m(_).save), 9, z)])
175
182
  ], 64));
176
183
  }
177
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 = defineProps<{ fonts?: readonly string[] | undefined }>()\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 setOptions({ templateId: t.id })\n setTool('signature')\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=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AC;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,oBA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true_lang.js";
2
+ //#region src/components/SignatureMenuPanel.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
6
+
7
+ //# sourceMappingURL=SignatureMenuPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SignatureMenuPanel.js","names":["_sfc_main","SignatureMenuPanel_vue_vue_type_script_setup_true_lang_default","SignatureMenuPanel_default"],"sources":["../../src/components/SignatureMenuPanel.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The panel both signature menus show: the saved signatures as previews, each with a remove\n * button, then \"Create signature\". `InkSignatureMenu` picks a signature for the tool with it;\n * `InkSignFieldPopover` signs a field with it.\n */\nimport { handleMenuKeys, SIGNATURE_LABELS, signaturePreview } from '@inkbar/core/dom'\nimport { Plus, Trash2 } from '@inkbar/icons'\nimport { computed, nextTick, useTemplateRef } from 'vue'\n\nimport { useInkContext } from '../context'\nimport { useReadable } from '../use-readable'\n\nimport InkIcon from './InkIcon.vue'\n\nimport type { SignatureTemplate } from '@inkbar/core'\nimport type { SignatureMenuItem } from '@inkbar/core/dom'\n\nconst props = defineProps<{ items: readonly SignatureMenuItem[] }>()\nconst emit = defineEmits<{ choose: [template: SignatureTemplate]; create: [] }>()\n\nconst ctx = useInkContext('SignatureMenuPanel')\nconst removeError = useReadable(() => ctx.signatures.value.removeError, undefined)\nconst root = useTemplateRef<HTMLElement>('root')\n\n/** A saved signature drawn small: ink as filled outlines. */\nconst previews = computed(() =>\n props.items.map((item) =>\n item.template.kind === 'ink' ? signaturePreview(item.template) : null\n )\n)\n\n/** Removes a template; focus moves to the signature now in its row, else \"Create signature\". */\nfunction remove(id: string, row: number): void {\n ctx.signatures.value.remove(id).then(\n async () => {\n await nextTick()\n const menu = root.value\n if (!menu) return\n const rows = menu.querySelectorAll<HTMLElement>('.ink-signature-item')\n const next =\n rows[Math.min(row, rows.length - 1)] ??\n menu.querySelector<HTMLElement>('[data-ink-signature-create]')\n next?.focus({ preventScroll: true })\n },\n () => {\n // The host's store refused: the signature stays.\n }\n )\n}\n\nconst innerAttrs = {\n role: 'menu',\n 'aria-label': SIGNATURE_LABELS.menu,\n onKeydown: (e: KeyboardEvent) => handleMenuKeys(e, e.currentTarget as HTMLElement),\n}\n</script>\n\n<template>\n <div ref=\"root\" v-bind=\"innerAttrs\">\n <template v-if=\"props.items.length > 0\">\n <div\n role=\"group\"\n :aria-label=\"SIGNATURE_LABELS.saved\"\n class=\"ink-signature-list\"\n data-ink-menu-columns=\"2\"\n >\n <template v-for=\"(item, row) in props.items\" :key=\"item.id\">\n <button\n type=\"button\"\n role=\"menuitemradio\"\n :aria-checked=\"item.checked\"\n :aria-label=\"item.label\"\n tabindex=\"-1\"\n class=\"ink-select-item ink-menu-item ink-signature-item\"\n data-ink-select-item\n :data-key=\"item.id\"\n :data-state=\"item.checked ? 'checked' : 'unchecked'\"\n @click=\"emit('choose', item.template)\"\n >\n <span class=\"ink-signature-preview\" :data-kind=\"item.template.kind\">\n <img\n v-if=\"item.template.kind === 'image'\"\n :src=\"item.template.imagedata\"\n alt=\"\"\n draggable=\"false\"\n />\n <svg v-else :viewBox=\"previews[row]?.viewBox\" aria-hidden=\"true\">\n <path\n v-for=\"(d, i) in previews[row]?.paths ?? []\"\n :key=\"i\"\n :d=\"d\"\n fill=\"currentColor\"\n />\n </svg>\n </span>\n </button>\n <button\n type=\"button\"\n role=\"menuitem\"\n :aria-label=\"item.removeLabel\"\n :title=\"item.removeLabel\"\n tabindex=\"-1\"\n class=\"ink-menu-item ink-signature-remove\"\n data-ink-signature-remove\n :data-key=\"item.id\"\n @click=\"remove(item.id, row)\"\n >\n <InkIcon :icon=\"Trash2\" :size=\"16\" />\n </button>\n </template>\n </div>\n <div role=\"separator\" class=\"ink-select-separator\" />\n </template>\n <button\n type=\"button\"\n role=\"menuitem\"\n tabindex=\"-1\"\n class=\"ink-select-item ink-menu-item ink-signature-create\"\n data-ink-select-item\n data-ink-signature-create\n @click=\"emit('create')\"\n >\n <InkIcon :icon=\"Plus\" :size=\"16\" />\n {{ SIGNATURE_LABELS.create }}\n </button>\n <p\n v-if=\"removeError\"\n class=\"ink-field-error ink-signature-remove-error\"\n role=\"alert\"\n data-ink-signature-remove-error\n >\n {{ removeError }}\n </p>\n </div>\n</template>\n"],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import { SignatureTemplate } from '@inkbar/core';
2
+ import { SignatureMenuItem } from '@inkbar/core/dom';
3
+ type __VLS_Props = {
4
+ items: readonly SignatureMenuItem[];
5
+ };
6
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
7
+ choose: (template: SignatureTemplate) => any;
8
+ create: () => any;
9
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
10
+ onChoose?: (template: SignatureTemplate) => any;
11
+ onCreate?: () => any;
12
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
13
+ declare const _default: typeof __VLS_export;
14
+ export default _default;
15
+ //# sourceMappingURL=SignatureMenuPanel.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SignatureMenuPanel.vue.d.ts","sourceRoot":"","sources":["../../src/components/SignatureMenuPanel.vue"],"names":[],"mappings":"AAwJA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAGzD,KAAK,WAAW,GAAG;IAAE,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAA;CAAE,CAAC;AA0M3D,QAAA,MAAM,YAAY;;;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -0,0 +1,116 @@
1
+ import { useInkContext as e } from "../context.js";
2
+ import { useReadable as t } from "../use-readable.js";
3
+ import n from "./InkIcon.js";
4
+ import { Fragment as r, computed as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, createVNode as l, defineComponent as u, mergeProps as d, nextTick as f, openBlock as p, renderList as m, toDisplayString as h, unref as g, useTemplateRef as _ } from "vue";
5
+ import { SIGNATURE_LABELS as v, handleMenuKeys as y, signaturePreview as b } from "@inkbar/core/dom";
6
+ import { Plus as x, Trash2 as S } from "@inkbar/icons";
7
+ //#region src/components/SignatureMenuPanel.vue?vue&type=script&setup=true&lang.ts
8
+ var C = ["aria-label"], w = [
9
+ "aria-checked",
10
+ "aria-label",
11
+ "data-key",
12
+ "data-state",
13
+ "onClick"
14
+ ], T = ["data-kind"], E = ["src"], D = ["viewBox"], O = ["d"], k = [
15
+ "aria-label",
16
+ "title",
17
+ "data-key",
18
+ "onClick"
19
+ ], A = {
20
+ key: 1,
21
+ class: "ink-field-error ink-signature-remove-error",
22
+ role: "alert",
23
+ "data-ink-signature-remove-error": ""
24
+ }, j = /*@__PURE__*/ u({
25
+ __name: "SignatureMenuPanel",
26
+ props: { items: {} },
27
+ emits: ["choose", "create"],
28
+ setup(u, { emit: j }) {
29
+ let M = u, N = j, P = e("SignatureMenuPanel"), F = t(() => P.signatures.value.removeError, void 0), I = _("root"), L = i(() => M.items.map((e) => e.template.kind === "ink" ? b(e.template) : null));
30
+ function R(e, t) {
31
+ P.signatures.value.remove(e).then(async () => {
32
+ await f();
33
+ let e = I.value;
34
+ if (!e) return;
35
+ let n = e.querySelectorAll(".ink-signature-item");
36
+ (n[Math.min(t, n.length - 1)] ?? e.querySelector("[data-ink-signature-create]"))?.focus({ preventScroll: !0 });
37
+ }, () => {});
38
+ }
39
+ let z = {
40
+ role: "menu",
41
+ "aria-label": v.menu,
42
+ onKeydown: (e) => y(e, e.currentTarget)
43
+ };
44
+ return (e, t) => (p(), o("div", d({
45
+ ref_key: "root",
46
+ ref: I
47
+ }, z), [
48
+ M.items.length > 0 ? (p(), o(r, { key: 0 }, [s("div", {
49
+ role: "group",
50
+ "aria-label": g(v).saved,
51
+ class: "ink-signature-list",
52
+ "data-ink-menu-columns": "2"
53
+ }, [(p(!0), o(r, null, m(M.items, (e, t) => (p(), o(r, { key: e.id }, [s("button", {
54
+ type: "button",
55
+ role: "menuitemradio",
56
+ "aria-checked": e.checked,
57
+ "aria-label": e.label,
58
+ tabindex: "-1",
59
+ class: "ink-select-item ink-menu-item ink-signature-item",
60
+ "data-ink-select-item": "",
61
+ "data-key": e.id,
62
+ "data-state": e.checked ? "checked" : "unchecked",
63
+ onClick: (t) => N("choose", e.template)
64
+ }, [s("span", {
65
+ class: "ink-signature-preview",
66
+ "data-kind": e.template.kind
67
+ }, [e.template.kind === "image" ? (p(), o("img", {
68
+ key: 0,
69
+ src: e.template.imagedata,
70
+ alt: "",
71
+ draggable: "false"
72
+ }, null, 8, E)) : (p(), o("svg", {
73
+ key: 1,
74
+ viewBox: L.value[t]?.viewBox,
75
+ "aria-hidden": "true"
76
+ }, [(p(!0), o(r, null, m(L.value[t]?.paths ?? [], (e, t) => (p(), o("path", {
77
+ key: t,
78
+ d: e,
79
+ fill: "currentColor"
80
+ }, null, 8, O))), 128))], 8, D))], 8, T)], 8, w), s("button", {
81
+ type: "button",
82
+ role: "menuitem",
83
+ "aria-label": e.removeLabel,
84
+ title: e.removeLabel,
85
+ tabindex: "-1",
86
+ class: "ink-menu-item ink-signature-remove",
87
+ "data-ink-signature-remove": "",
88
+ "data-key": e.id,
89
+ onClick: (n) => R(e.id, t)
90
+ }, [l(n, {
91
+ icon: g(S),
92
+ size: 16
93
+ }, null, 8, ["icon"])], 8, k)], 64))), 128))], 8, C), t[1] ||= s("div", {
94
+ role: "separator",
95
+ class: "ink-select-separator"
96
+ }, null, -1)], 64)) : a("", !0),
97
+ s("button", {
98
+ type: "button",
99
+ role: "menuitem",
100
+ tabindex: "-1",
101
+ class: "ink-select-item ink-menu-item ink-signature-create",
102
+ "data-ink-select-item": "",
103
+ "data-ink-signature-create": "",
104
+ onClick: t[0] ||= (e) => N("create")
105
+ }, [l(n, {
106
+ icon: g(x),
107
+ size: 16
108
+ }, null, 8, ["icon"]), c(" " + h(g(v).create), 1)]),
109
+ g(F) ? (p(), o("p", A, h(g(F)), 1)) : a("", !0)
110
+ ], 16));
111
+ }
112
+ });
113
+ //#endregion
114
+ export { j as default };
115
+
116
+ //# sourceMappingURL=SignatureMenuPanel.vue_vue_type_script_setup_true_lang.js.map