@inkbar/vue 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +35 -8
  2. package/dist/components/InkColorMenu.js +7 -0
  3. package/dist/components/InkColorMenu.js.map +1 -0
  4. package/dist/components/InkColorMenu.vue.d.ts +32 -0
  5. package/dist/components/InkColorMenu.vue.d.ts.map +1 -0
  6. package/dist/components/InkColorMenu.vue_vue_type_script_setup_true_lang.js +152 -0
  7. package/dist/components/InkColorMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  8. package/dist/components/InkHighlightMenu.js +7 -0
  9. package/dist/components/InkHighlightMenu.js.map +1 -0
  10. package/dist/components/InkHighlightMenu.vue.d.ts +17 -0
  11. package/dist/components/InkHighlightMenu.vue.d.ts.map +1 -0
  12. package/dist/components/InkHighlightMenu.vue_vue_type_script_setup_true_lang.js +140 -0
  13. package/dist/components/InkHighlightMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  14. package/dist/components/InkLineStyleMenu.js +7 -0
  15. package/dist/components/InkLineStyleMenu.js.map +1 -0
  16. package/dist/components/InkLineStyleMenu.vue.d.ts +14 -0
  17. package/dist/components/InkLineStyleMenu.vue.d.ts.map +1 -0
  18. package/dist/components/InkLineStyleMenu.vue_vue_type_script_setup_true_lang.js +109 -0
  19. package/dist/components/InkLineStyleMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  20. package/dist/components/InkRoot.js.map +1 -1
  21. package/dist/components/InkRoot.vue.d.ts +606 -62
  22. package/dist/components/InkRoot.vue.d.ts.map +1 -1
  23. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js +117 -88
  24. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js.map +1 -1
  25. package/dist/components/InkShapeMenu.js +7 -0
  26. package/dist/components/InkShapeMenu.js.map +1 -0
  27. package/dist/components/InkShapeMenu.vue.d.ts +18 -0
  28. package/dist/components/InkShapeMenu.vue.d.ts.map +1 -0
  29. package/dist/components/InkShapeMenu.vue_vue_type_script_setup_true_lang.js +118 -0
  30. package/dist/components/InkShapeMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  31. package/dist/components/InkSignatureDialog.js +7 -0
  32. package/dist/components/InkSignatureDialog.js.map +1 -0
  33. package/dist/components/InkSignatureDialog.vue.d.ts +21 -0
  34. package/dist/components/InkSignatureDialog.vue.d.ts.map +1 -0
  35. package/dist/components/InkSignatureDialog.vue_vue_type_script_setup_true_lang.js +58 -0
  36. package/dist/components/InkSignatureDialog.vue_vue_type_script_setup_true_lang.js.map +1 -0
  37. package/dist/components/InkSignatureMenu.js +7 -0
  38. package/dist/components/InkSignatureMenu.js.map +1 -0
  39. package/dist/components/InkSignatureMenu.vue.d.ts +20 -0
  40. package/dist/components/InkSignatureMenu.vue.d.ts.map +1 -0
  41. package/dist/components/InkSignatureMenu.vue_vue_type_script_setup_true_lang.js +213 -0
  42. package/dist/components/InkSignatureMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  43. package/dist/components/InkTextStyleMenu.js +7 -0
  44. package/dist/components/InkTextStyleMenu.js.map +1 -0
  45. package/dist/components/InkTextStyleMenu.vue.d.ts +14 -0
  46. package/dist/components/InkTextStyleMenu.vue.d.ts.map +1 -0
  47. package/dist/components/InkTextStyleMenu.vue_vue_type_script_setup_true_lang.js +200 -0
  48. package/dist/components/InkTextStyleMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  49. package/dist/components/InkThreadPopover.js +7 -0
  50. package/dist/components/InkThreadPopover.js.map +1 -0
  51. package/dist/components/{InkNotePopover.vue.d.ts → InkThreadPopover.vue.d.ts} +4 -4
  52. package/dist/components/InkThreadPopover.vue.d.ts.map +1 -0
  53. package/dist/components/{InkNotePopover.vue_vue_type_script_setup_true_lang.js → InkThreadPopover.vue_vue_type_script_setup_true_lang.js} +45 -43
  54. package/dist/components/InkThreadPopover.vue_vue_type_script_setup_true_lang.js.map +1 -0
  55. package/dist/components/InkToolButton.js.map +1 -1
  56. package/dist/components/InkToolButton.vue.d.ts.map +1 -1
  57. package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js +27 -20
  58. package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  59. package/dist/components/InkViewport.js.map +1 -1
  60. package/dist/components/InkViewport.vue.d.ts +1 -1
  61. package/dist/components/InkViewport.vue.d.ts.map +1 -1
  62. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js +6 -0
  63. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js.map +1 -1
  64. package/dist/components/SignatureForm.js +7 -0
  65. package/dist/components/SignatureForm.js.map +1 -0
  66. package/dist/components/SignatureForm.vue.d.ts +14 -0
  67. package/dist/components/SignatureForm.vue.d.ts.map +1 -0
  68. package/dist/components/SignatureForm.vue_vue_type_script_setup_true_lang.js +181 -0
  69. package/dist/components/SignatureForm.vue_vue_type_script_setup_true_lang.js.map +1 -0
  70. package/dist/composables/useAnnotations.d.ts +1577 -185
  71. package/dist/composables/useAnnotations.d.ts.map +1 -1
  72. package/dist/composables/useAnnotations.js.map +1 -1
  73. package/dist/composables/useToolOptions.d.ts +11 -0
  74. package/dist/composables/useToolOptions.d.ts.map +1 -0
  75. package/dist/composables/useToolOptions.js +16 -0
  76. package/dist/composables/useToolOptions.js.map +1 -0
  77. package/dist/composables/useToolStyle.d.ts +32 -0
  78. package/dist/composables/useToolStyle.d.ts.map +1 -0
  79. package/dist/composables/useToolStyle.js +24 -0
  80. package/dist/composables/useToolStyle.js.map +1 -0
  81. package/dist/context.d.ts +14 -2
  82. package/dist/context.d.ts.map +1 -1
  83. package/dist/context.js.map +1 -1
  84. package/dist/index.d.ts +12 -2
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.js +33 -24
  87. package/package.json +5 -5
  88. package/dist/components/InkNotePopover.js +0 -7
  89. package/dist/components/InkNotePopover.js.map +0 -1
  90. package/dist/components/InkNotePopover.vue.d.ts.map +0 -1
  91. package/dist/components/InkNotePopover.vue_vue_type_script_setup_true_lang.js.map +0 -1
@@ -0,0 +1,58 @@
1
+ import e from "./SignatureForm.js";
2
+ import { createBlock as t, createTextVNode as n, createVNode as r, defineComponent as i, mergeModels as a, mergeProps as o, openBlock as s, toDisplayString as c, unref as l, useModel as u, withCtx as d } from "vue";
3
+ import { SIGNATURE_LABELS as f } from "@inkbar/core/dom";
4
+ import { DialogContent as p, DialogOverlay as m, DialogPortal as h, DialogRoot as g, DialogTitle as _ } from "reka-ui";
5
+ //#region src/components/InkSignatureDialog.vue?vue&type=script&setup=true&lang.ts
6
+ var v = /*@__PURE__*/ i({
7
+ __name: "InkSignatureDialog",
8
+ props: /*@__PURE__*/ a({ fonts: {} }, {
9
+ open: {
10
+ type: Boolean,
11
+ default: !1
12
+ },
13
+ openModifiers: {}
14
+ }),
15
+ emits: /*@__PURE__*/ a(["save", "closeAutoFocus"], ["update:open"]),
16
+ setup(i, { emit: a }) {
17
+ let v = i, y = u(i, "open"), b = a, x = {
18
+ "aria-modal": "true",
19
+ "aria-describedby": void 0
20
+ };
21
+ function S(e) {
22
+ e.preventDefault(), e.target?.querySelector("[role=\"tab\"][aria-selected=\"true\"]")?.focus({ preventScroll: !0 });
23
+ }
24
+ return (i, a) => (s(), t(l(g), {
25
+ open: y.value,
26
+ "onUpdate:open": a[3] ||= (e) => y.value = e
27
+ }, {
28
+ default: d(() => [r(l(h), null, {
29
+ default: d(() => [r(l(m), {
30
+ class: "ink-dialog-overlay",
31
+ "data-ink-dialog-overlay": ""
32
+ }), r(l(p), o({
33
+ class: "ink-dialog ink-signature-dialog",
34
+ "data-ink-signature-dialog": ""
35
+ }, x, {
36
+ onOpenAutoFocus: S,
37
+ onCloseAutoFocus: a[2] ||= (e) => b("closeAutoFocus", e)
38
+ }), {
39
+ default: d(() => [r(l(_), { class: "ink-dialog-title" }, {
40
+ default: d(() => [n(c(l(f).dialog), 1)]),
41
+ _: 1
42
+ }), r(e, {
43
+ fonts: v.fonts,
44
+ onSaved: a[0] ||= (e) => b("save", e),
45
+ onClose: a[1] ||= (e) => y.value = !1
46
+ }, null, 8, ["fonts"])]),
47
+ _: 1
48
+ }, 16)]),
49
+ _: 1
50
+ })]),
51
+ _: 1
52
+ }, 8, ["open"]));
53
+ }
54
+ });
55
+ //#endregion
56
+ export { v as default };
57
+
58
+ //# sourceMappingURL=InkSignatureDialog.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSignatureDialog.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createBlock","_unref","_withCtx","_createVNode","_mergeProps","_createTextVNode","_toDisplayString","SignatureForm","SignatureForm_default","InkSignatureDialog_vue_vue_type_script_setup_true_lang_default","\"open\"","\"openModifiers\"","__emit","props","__props","open","useModel","emit","contentAttrs","onOpenAutoFocus","openBlock","createBlock","unref","DialogRoot","_cache","$event","withCtx","createVNode","DialogPortal","DialogOverlay","DialogContent","mergeProps","DialogTitle","createTextVNode","toDisplayString","SIGNATURE_LABELS"],"sources":["../../src/components/InkSignatureDialog.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * \"Create signature\": a modal with Draw, Type and Image tabs. Draw is a pad with the draw\n * tool's renderer; Type sets a name in one of the host's handwriting fonts; Image takes a PNG\n * or JPEG scan. Save stores the template through InkRoot's signature store and selects it for\n * the `signature` tool. Escape, Cancel or a press outside closes it.\n */\nimport { SIGNATURE_LABELS } from '@inkbar/core/dom'\nimport {\n DialogContent,\n DialogOverlay,\n DialogPortal,\n DialogRoot,\n DialogTitle,\n} from 'reka-ui'\n\nimport SignatureForm from './SignatureForm.vue'\n\nimport type { SignatureTemplate } from '@inkbar/core'\n\nconst props = defineProps<{\n /** The fonts the Type tab offers. Default: InkRoot's `signatureFonts`. */\n fonts?: readonly string[] | undefined\n}>()\nconst open = defineModel<boolean>('open', { default: false })\nconst emit = defineEmits<{\n /** The new template, once saved and selected. */\n save: [template: SignatureTemplate]\n /** Reka's close auto-focus; prevent it to place focus yourself. */\n closeAutoFocus: [event: Event]\n}>()\n\n// Reka's typed props stop at its own; ARIA goes through a bound object. No description: the\n// title says it all.\nconst contentAttrs = { 'aria-modal': 'true', 'aria-describedby': undefined }\n\nfunction onOpenAutoFocus(e: Event): void {\n e.preventDefault()\n ;(e.target as HTMLElement | null)\n ?.querySelector<HTMLElement>('[role=\"tab\"][aria-selected=\"true\"]')\n ?.focus({ preventScroll: true })\n}\n</script>\n\n<template>\n <DialogRoot v-model:open=\"open\">\n <DialogPortal>\n <DialogOverlay class=\"ink-dialog-overlay\" data-ink-dialog-overlay />\n <DialogContent\n class=\"ink-dialog ink-signature-dialog\"\n data-ink-signature-dialog\n v-bind=\"contentAttrs\"\n @open-auto-focus=\"onOpenAutoFocus\"\n @close-auto-focus=\"emit('closeAutoFocus', $event)\"\n >\n <DialogTitle class=\"ink-dialog-title\">{{ SIGNATURE_LABELS.dialog }}</DialogTitle>\n <SignatureForm\n :fonts=\"props.fonts\"\n @saved=\"emit('save', $event)\"\n @close=\"open = false\"\n />\n </DialogContent>\n </DialogPortal>\n </DialogRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;EAoBA,IAAMe,IAAQC,GAIRC,IAAOjB,EAAoBgB,GAAC,MAA0B,GACtDG,IAAOL,GASPM,IAAe;GAAE,cAAc;GAAQ,oBAAoB,KAAA;EAAU;EAE3E,SAASC,EAAgB,GAAgB;GAEtC,AADD,EAAE,eAAe,GAChB,EAAG,QACA,cAA2B,wCAAoC,CAAA,EAC/D,MAAM,EAAE,eAAe,GAAK,CAAC;EACnC;oBAIEpB,EAAA,GAAAC,EAkBaC,EAAAsB,CAAA,GAAA;GAlBO,MAAMR,EAAA;GAAA,iBAAA,AAAAS,EAAA,QAAA,MAAA,EAAI,QAAAC;;GAC5B,SAAAvB,QAgBe,CAhBfC,EAgBeF,EAAA2B,CAAA,GAAA,MAAA;IAfb,SAAA1B,QAAoE,CAApEC,EAAoEF,EAAA4B,CAAA,GAAA;KAArD,OAAM;KAAqB,2BAAA;IAC1C1B,CAAAA,GAAAA,EAagBF,EAAA6B,CAAA,GAbhB1B,EAagB;KAZd,OAAM;KACN,6BAAA;IACQ,GAAAc,GAAY;KACF;KACjB,kBAAgB,AAAAM,EAAA,QAAA,MAAEP,EAAI,kBAAmBQ,CAAM;;KAEhD,SAAAvB,QAAiF,CAAjFC,EAAiFF,EAAA+B,CAAA,GAAA,EAApE,OAAM,mBAAkB,GAAA;MAAC,SAAA9B,QAA6B,CAA1BG,EAAAC,EAAAL,EAAAkC,CAAA,CAAgB,CAAC,MAAM,GAAA,CAAA,CAAA,CAAA;;KAChEhC,CAAAA,GAAAA,EAIEI,GAAA;MAHC,OAAOM,EAAM;MACb,SAAK,AAAAW,EAAA,QAAA,MAAEP,EAAI,QAASQ,CAAM;MAC1B,SAAK,AAAAD,EAAA,QAAA,MAAE,EAAA,QAAI"}
@@ -0,0 +1,7 @@
1
+ import e from "./InkSignatureMenu.vue_vue_type_script_setup_true_lang.js";
2
+ //#region src/components/InkSignatureMenu.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
6
+
7
+ //# sourceMappingURL=InkSignatureMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSignatureMenu.js","names":["_sfc_main","InkSignatureMenu_vue_vue_type_script_setup_true_lang_default","InkSignatureMenu_default"],"sources":["../../src/components/InkSignatureMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * A split button for the signature tool. The main part activates the tool with the chosen\n * signature, or opens the menu when none is chosen; the chevron opens the saved signatures as\n * previews, each with a remove button, and \"Create signature\", which opens\n * `InkSignatureDialog`. Choosing a signature switches to the tool with it.\n */\nimport {\n focusInitialMenuItem,\n handleMenuKeys,\n menuItems,\n SIGNATURE_LABELS,\n signatureMenuModel,\n signaturePreview,\n} from '@inkbar/core/dom'\nimport { ChevronDown, Plus, Signature, Trash2 } from '@inkbar/icons'\nimport {\n PopoverContent,\n PopoverPortal,\n PopoverRoot,\n PopoverTrigger,\n ToolbarButton,\n} from 'reka-ui'\nimport { computed, nextTick, ref, useTemplateRef, watch } from 'vue'\n\nimport { useTool } from '../composables/useTool'\nimport { useToolOptions } from '../composables/useToolOptions'\nimport { useInkContext } from '../context'\nimport { useReadable } from '../use-readable'\n\nimport InkIcon from './InkIcon.vue'\nimport InkSignatureDialog from './InkSignatureDialog.vue'\n\nimport type { SignatureOptions, SignatureTemplate } from '@inkbar/core'\n\nconst props = defineProps<{\n /** The fonts the dialog's Type tab offers. Default: InkRoot's `signatureFonts`. */\n fonts?: readonly string[] | undefined\n}>()\n\nconst NO_TEMPLATES: readonly SignatureTemplate[] = []\n\nconst { tool, setTool } = useTool()\nconst { options, setOptions } = useToolOptions<SignatureOptions>('signature')\nconst ctx = useInkContext('InkSignatureMenu')\nconst templates = useReadable(() => ctx.signatures.value.templates, NO_TEMPLATES)\nconst removeError = useReadable(() => ctx.signatures.value.removeError, undefined)\nconst model = computed(() => signatureMenuModel(templates.value, options.value))\nconst active = computed(() => tool.value === 'signature')\nconst open = ref(false)\nconst creating = ref(false)\n// An old removal error is not news when the menu opens again.\nwatch(open, (isOpen) => {\n if (isOpen) ctx.signatures.value.clearRemoveError()\n})\nconst main = useTemplateRef<{ $el: HTMLElement }>('main')\n\n/** A saved signature drawn small: ink as filled outlines. */\nconst previews = computed(() =>\n model.value.items.map((item) =>\n item.template.kind === 'ink' ? signaturePreview(item.template) : null\n )\n)\n\n/** ArrowDown opens on the first item; a click opens on the checked one. */\nlet focusFirst = false\n/** Set while the menu closes for the dialog, which takes focus instead of the trigger. */\nlet toDialog = false\n\nfunction onTriggerKeydown(e: KeyboardEvent): void {\n if (e.key !== 'ArrowDown' || e.defaultPrevented || open.value) return\n e.preventDefault()\n focusFirst = true\n open.value = true\n}\n\nconst panel = (): HTMLElement | null =>\n document.querySelector<HTMLElement>('[data-ink-menu=\"signature\"] [role=\"menu\"]')\n\nfunction onOpenAutoFocus(e: Event): void {\n e.preventDefault()\n const menu = panel()\n if (menu) {\n if (focusFirst) menuItems(menu)[0]?.focus({ preventScroll: true })\n else focusInitialMenuItem(menu)\n }\n focusFirst = false\n}\n\nfunction onCloseAutoFocus(e: Event): void {\n if (toDialog) e.preventDefault()\n toDialog = false\n}\n\nfunction onMain(): void {\n if (model.value.selected) setTool('signature')\n else open.value = true\n}\n\nfunction choose(id: string): void {\n setOptions({ templateId: id })\n setTool('signature')\n open.value = false\n}\n\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 = panel()\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\nfunction create(): void {\n toDialog = true\n open.value = false\n creating.value = true\n}\n\nfunction onDialogCloseAutoFocus(e: Event): void {\n e.preventDefault()\n main.value?.$el.focus({ preventScroll: true })\n}\n\n// Reka's typed props stop at its own; ARIA and listeners go through bound objects.\nconst mainAttrs = computed(() => ({\n 'aria-pressed': String(active.value),\n 'aria-label': SIGNATURE_LABELS.sign,\n title: SIGNATURE_LABELS.sign,\n onClick: onMain,\n}))\nconst triggerAttrs = {\n 'aria-label': SIGNATURE_LABELS.trigger,\n title: SIGNATURE_LABELS.trigger,\n 'aria-haspopup': 'menu' as const,\n onKeydown: onTriggerKeydown,\n}\nconst menuAttrs = { 'aria-label': SIGNATURE_LABELS.menu }\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\n role=\"group\"\n :aria-label=\"SIGNATURE_LABELS.sign\"\n class=\"ink-split-button ink-signature-menu\"\n data-ink-signature-menu\n >\n <ToolbarButton\n ref=\"main\"\n class=\"ink-tool-button ink-signature-button\"\n data-ink-tool-button\n data-ink-signature-button\n data-tool=\"signature\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"mainAttrs\"\n >\n <slot :active=\"active\"><InkIcon :icon=\"Signature\" /></slot>\n </ToolbarButton>\n <PopoverRoot v-model:open=\"open\">\n <ToolbarButton as-child>\n <PopoverTrigger as-child>\n <button\n type=\"button\"\n class=\"ink-menu-trigger ink-signature-menu-trigger\"\n data-ink-signature-menu-trigger\n :data-state=\"open ? 'open' : 'closed'\"\n v-bind=\"triggerAttrs\"\n >\n <InkIcon :icon=\"ChevronDown\" />\n </button>\n </PopoverTrigger>\n </ToolbarButton>\n <PopoverPortal>\n <PopoverContent\n class=\"ink-select-content ink-menu-content\"\n data-ink-select-content\n data-ink-menu=\"signature\"\n side=\"bottom\"\n align=\"start\"\n :side-offset=\"4\"\n :collision-padding=\"8\"\n v-bind=\"menuAttrs\"\n @open-auto-focus=\"onOpenAutoFocus\"\n @close-auto-focus=\"onCloseAutoFocus\"\n >\n <div v-bind=\"innerAttrs\">\n <template v-if=\"model.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 model.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=\"choose(item.id)\"\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=\"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 </PopoverContent>\n </PopoverPortal>\n </PopoverRoot>\n <InkSignatureDialog\n v-model:open=\"creating\"\n :fonts=\"props.fonts\"\n @close-auto-focus=\"onDialogCloseAutoFocus\"\n />\n </div>\n</template>\n"],"mappings":""}
@@ -0,0 +1,20 @@
1
+ type __VLS_Props = {
2
+ /** The fonts the dialog's Type tab offers. Default: InkRoot's `signatureFonts`. */
3
+ fonts?: readonly string[] | undefined;
4
+ };
5
+ declare var __VLS_7: {
6
+ active: boolean;
7
+ };
8
+ type __VLS_Slots = {} & {
9
+ default?: (props: typeof __VLS_7) => any;
10
+ };
11
+ declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
12
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
13
+ declare const _default: typeof __VLS_export;
14
+ export default _default;
15
+ type __VLS_WithSlots<T, S> = T & {
16
+ new (): {
17
+ $slots: S;
18
+ };
19
+ };
20
+ //# sourceMappingURL=InkSignatureMenu.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSignatureMenu.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkSignatureMenu.vue"],"names":[],"mappings":"AAoUA,KAAK,WAAW,GAAG;IACjB,mFAAmF;IACnF,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;CACtC,CAAC;AA2cF,QAAA,IAAI,OAAO;;CAAW,CAAC;AACvB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAG/C,QAAA,MAAM,UAAU,kSAEd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -0,0 +1,213 @@
1
+ import { useInkContext as e } from "../context.js";
2
+ import { useReadable as t } from "../use-readable.js";
3
+ import { useTool as n } from "../composables/useTool.js";
4
+ import { useToolOptions as r } from "../composables/useToolOptions.js";
5
+ import i from "./InkIcon.js";
6
+ import ee from "./InkSignatureDialog.js";
7
+ import { Fragment as a, computed as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as te, createVNode as u, defineComponent as d, guardReactiveProps as f, mergeProps as p, nextTick as ne, normalizeProps as re, openBlock as m, ref as h, renderList as g, renderSlot as ie, toDisplayString as _, unref as v, useTemplateRef as ae, watch as oe, withCtx as y } from "vue";
8
+ import { SIGNATURE_LABELS as b, focusInitialMenuItem as se, handleMenuKeys as ce, menuItems as le, signatureMenuModel as ue, signaturePreview as de } from "@inkbar/core/dom";
9
+ import { PopoverContent as fe, PopoverPortal as pe, PopoverRoot as x, PopoverTrigger as S, ToolbarButton as C } from "reka-ui";
10
+ import { ChevronDown as w, Plus as T, Signature as E, Trash2 as D } from "@inkbar/icons";
11
+ //#region src/components/InkSignatureMenu.vue?vue&type=script&setup=true&lang.ts
12
+ var O = ["aria-label"], k = ["data-state"], A = ["aria-label"], j = [
13
+ "aria-checked",
14
+ "aria-label",
15
+ "data-key",
16
+ "data-state",
17
+ "onClick"
18
+ ], M = ["data-kind"], N = ["src"], P = ["viewBox"], F = ["d"], I = [
19
+ "aria-label",
20
+ "title",
21
+ "data-key",
22
+ "onClick"
23
+ ], L = {
24
+ key: 1,
25
+ class: "ink-field-error ink-signature-remove-error",
26
+ role: "alert",
27
+ "data-ink-signature-remove-error": ""
28
+ }, R = /*@__PURE__*/ d({
29
+ __name: "InkSignatureMenu",
30
+ props: { fonts: {} },
31
+ setup(d) {
32
+ let R = d, z = [], { tool: B, setTool: V } = n(), { options: me, setOptions: he } = r("signature"), H = e("InkSignatureMenu"), ge = t(() => H.signatures.value.templates, z), U = t(() => H.signatures.value.removeError, void 0), W = o(() => ue(ge.value, me.value)), G = o(() => B.value === "signature"), K = h(!1), q = h(!1);
33
+ oe(K, (e) => {
34
+ e && H.signatures.value.clearRemoveError();
35
+ });
36
+ let J = ae("main"), Y = o(() => W.value.items.map((e) => e.template.kind === "ink" ? de(e.template) : null)), X = !1, Z = !1;
37
+ function _e(e) {
38
+ e.key !== "ArrowDown" || e.defaultPrevented || K.value || (e.preventDefault(), X = !0, K.value = !0);
39
+ }
40
+ let Q = () => document.querySelector("[data-ink-menu=\"signature\"] [role=\"menu\"]");
41
+ function ve(e) {
42
+ e.preventDefault();
43
+ let t = Q();
44
+ t && (X ? le(t)[0]?.focus({ preventScroll: !0 }) : se(t)), X = !1;
45
+ }
46
+ function ye(e) {
47
+ Z && e.preventDefault(), Z = !1;
48
+ }
49
+ function be() {
50
+ W.value.selected ? V("signature") : K.value = !0;
51
+ }
52
+ function xe(e) {
53
+ he({ templateId: e }), V("signature"), K.value = !1;
54
+ }
55
+ function Se(e, t) {
56
+ H.signatures.value.remove(e).then(async () => {
57
+ await ne();
58
+ let e = Q();
59
+ if (!e) return;
60
+ let n = e.querySelectorAll(".ink-signature-item");
61
+ (n[Math.min(t, n.length - 1)] ?? e.querySelector("[data-ink-signature-create]"))?.focus({ preventScroll: !0 });
62
+ }, () => {});
63
+ }
64
+ function Ce() {
65
+ Z = !0, K.value = !1, q.value = !0;
66
+ }
67
+ function $(e) {
68
+ e.preventDefault(), J.value?.$el.focus({ preventScroll: !0 });
69
+ }
70
+ let we = o(() => ({
71
+ "aria-pressed": String(G.value),
72
+ "aria-label": b.sign,
73
+ title: b.sign,
74
+ onClick: be
75
+ })), Te = {
76
+ "aria-label": b.trigger,
77
+ title: b.trigger,
78
+ "aria-haspopup": "menu",
79
+ onKeydown: _e
80
+ }, Ee = { "aria-label": b.menu }, De = {
81
+ role: "menu",
82
+ "aria-label": b.menu,
83
+ onKeydown: (e) => ce(e, e.currentTarget)
84
+ };
85
+ return (e, t) => (m(), c("div", {
86
+ role: "group",
87
+ "aria-label": v(b).sign,
88
+ class: "ink-split-button ink-signature-menu",
89
+ "data-ink-signature-menu": ""
90
+ }, [
91
+ u(v(C), p({
92
+ ref_key: "main",
93
+ ref: J,
94
+ class: "ink-tool-button ink-signature-button",
95
+ "data-ink-tool-button": "",
96
+ "data-ink-signature-button": "",
97
+ "data-tool": "signature",
98
+ "data-state": G.value ? "on" : "off"
99
+ }, we.value), {
100
+ default: y(() => [ie(e.$slots, "default", { active: G.value }, () => [u(i, { icon: v(E) }, null, 8, ["icon"])])]),
101
+ _: 3
102
+ }, 16, ["data-state"]),
103
+ u(v(x), {
104
+ open: K.value,
105
+ "onUpdate:open": t[0] ||= (e) => K.value = e
106
+ }, {
107
+ default: y(() => [u(v(C), { "as-child": "" }, {
108
+ default: y(() => [u(v(S), { "as-child": "" }, {
109
+ default: y(() => [l("button", p({
110
+ type: "button",
111
+ class: "ink-menu-trigger ink-signature-menu-trigger",
112
+ "data-ink-signature-menu-trigger": "",
113
+ "data-state": K.value ? "open" : "closed"
114
+ }, Te), [u(i, { icon: v(w) }, null, 8, ["icon"])], 16, k)]),
115
+ _: 1
116
+ })]),
117
+ _: 1
118
+ }), u(v(pe), null, {
119
+ default: y(() => [u(v(fe), p({
120
+ class: "ink-select-content ink-menu-content",
121
+ "data-ink-select-content": "",
122
+ "data-ink-menu": "signature",
123
+ side: "bottom",
124
+ align: "start",
125
+ "side-offset": 4,
126
+ "collision-padding": 8
127
+ }, Ee, {
128
+ onOpenAutoFocus: ve,
129
+ onCloseAutoFocus: ye
130
+ }), {
131
+ default: y(() => [l("div", re(f(De)), [
132
+ W.value.items.length > 0 ? (m(), c(a, { key: 0 }, [l("div", {
133
+ role: "group",
134
+ "aria-label": v(b).saved,
135
+ class: "ink-signature-list",
136
+ "data-ink-menu-columns": "2"
137
+ }, [(m(!0), c(a, null, g(W.value.items, (e, t) => (m(), c(a, { key: e.id }, [l("button", {
138
+ type: "button",
139
+ role: "menuitemradio",
140
+ "aria-checked": e.checked,
141
+ "aria-label": e.label,
142
+ tabindex: "-1",
143
+ class: "ink-select-item ink-menu-item ink-signature-item",
144
+ "data-ink-select-item": "",
145
+ "data-key": e.id,
146
+ "data-state": e.checked ? "checked" : "unchecked",
147
+ onClick: (t) => xe(e.id)
148
+ }, [l("span", {
149
+ class: "ink-signature-preview",
150
+ "data-kind": e.template.kind
151
+ }, [e.template.kind === "image" ? (m(), c("img", {
152
+ key: 0,
153
+ src: e.template.imagedata,
154
+ alt: "",
155
+ draggable: "false"
156
+ }, null, 8, N)) : (m(), c("svg", {
157
+ key: 1,
158
+ viewBox: Y.value[t]?.viewBox,
159
+ "aria-hidden": "true"
160
+ }, [(m(!0), c(a, null, g(Y.value[t]?.paths ?? [], (e, t) => (m(), c("path", {
161
+ key: t,
162
+ d: e,
163
+ fill: "currentColor"
164
+ }, null, 8, F))), 128))], 8, P))], 8, M)], 8, j), l("button", {
165
+ type: "button",
166
+ role: "menuitem",
167
+ "aria-label": e.removeLabel,
168
+ title: e.removeLabel,
169
+ tabindex: "-1",
170
+ class: "ink-menu-item ink-signature-remove",
171
+ "data-ink-signature-remove": "",
172
+ "data-key": e.id,
173
+ onClick: (n) => Se(e.id, t)
174
+ }, [u(i, {
175
+ icon: v(D),
176
+ size: 16
177
+ }, null, 8, ["icon"])], 8, I)], 64))), 128))], 8, A), t[2] ||= l("div", {
178
+ role: "separator",
179
+ class: "ink-select-separator"
180
+ }, null, -1)], 64)) : s("", !0),
181
+ l("button", {
182
+ type: "button",
183
+ role: "menuitem",
184
+ tabindex: "-1",
185
+ class: "ink-select-item ink-menu-item ink-signature-create",
186
+ "data-ink-select-item": "",
187
+ "data-ink-signature-create": "",
188
+ onClick: Ce
189
+ }, [u(i, {
190
+ icon: v(T),
191
+ size: 16
192
+ }, null, 8, ["icon"]), te(" " + _(v(b).create), 1)]),
193
+ v(U) ? (m(), c("p", L, _(v(U)), 1)) : s("", !0)
194
+ ], 16)]),
195
+ _: 1
196
+ }, 16)]),
197
+ _: 1
198
+ })]),
199
+ _: 1
200
+ }, 8, ["open"]),
201
+ u(ee, {
202
+ open: q.value,
203
+ "onUpdate:open": t[1] ||= (e) => q.value = e,
204
+ fonts: R.fonts,
205
+ onCloseAutoFocus: $
206
+ }, null, 8, ["open", "fonts"])
207
+ ], 8, O));
208
+ }
209
+ });
210
+ //#endregion
211
+ export { R as default };
212
+
213
+ //# sourceMappingURL=InkSignatureMenu.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSignatureMenu.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_unref","_createVNode","_mergeProps","_withCtx","_renderSlot","InkIcon","_createElementVNode","_normalizeProps","_guardReactiveProps","_Fragment","_renderList","_createCommentVNode","_createTextVNode","_toDisplayString","InkSignatureDialog","InkIcon_default","InkSignatureDialog_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","InkSignatureMenu_vue_vue_type_script_setup_true_lang_default","props","__props","NO_TEMPLATES","useTool","useToolOptions","ctx","useInkContext","templates","useReadable","removeError","model","computed","signatureMenuModel","options","active","tool","open","ref","creating","isOpen","main","useTemplateRef","previews","item","signaturePreview","focusFirst","toDialog","onTriggerKeydown","panel","onOpenAutoFocus","menu","menuItems","focusInitialMenuItem","onCloseAutoFocus","onMain","setTool","choose","setOptions","id","remove","nextTick","rows","row","create","onDialogCloseAutoFocus","mainAttrs","SIGNATURE_LABELS","triggerAttrs","menuAttrs","innerAttrs","handleMenuKeys","openBlock","createElementBlock","unref","createVNode","ToolbarButton","mergeProps","withCtx","renderSlot","_ctx","Signature","PopoverRoot","_cache","$event","PopoverTrigger","createElementVNode","ChevronDown","PopoverPortal","PopoverContent","normalizeProps","guardReactiveProps","Fragment","renderList","i","Trash2","createCommentVNode","Plus","createTextVNode","toDisplayString"],"sources":["../../src/components/InkSignatureMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * A split button for the signature tool. The main part activates the tool with the chosen\n * signature, or opens the menu when none is chosen; the chevron opens the saved signatures as\n * previews, each with a remove button, and \"Create signature\", which opens\n * `InkSignatureDialog`. Choosing a signature switches to the tool with it.\n */\nimport {\n focusInitialMenuItem,\n handleMenuKeys,\n menuItems,\n SIGNATURE_LABELS,\n signatureMenuModel,\n signaturePreview,\n} from '@inkbar/core/dom'\nimport { ChevronDown, Plus, Signature, Trash2 } from '@inkbar/icons'\nimport {\n PopoverContent,\n PopoverPortal,\n PopoverRoot,\n PopoverTrigger,\n ToolbarButton,\n} from 'reka-ui'\nimport { computed, nextTick, ref, useTemplateRef, watch } from 'vue'\n\nimport { useTool } from '../composables/useTool'\nimport { useToolOptions } from '../composables/useToolOptions'\nimport { useInkContext } from '../context'\nimport { useReadable } from '../use-readable'\n\nimport InkIcon from './InkIcon.vue'\nimport InkSignatureDialog from './InkSignatureDialog.vue'\n\nimport type { SignatureOptions, SignatureTemplate } from '@inkbar/core'\n\nconst props = defineProps<{\n /** The fonts the dialog's Type tab offers. Default: InkRoot's `signatureFonts`. */\n fonts?: readonly string[] | undefined\n}>()\n\nconst NO_TEMPLATES: readonly SignatureTemplate[] = []\n\nconst { tool, setTool } = useTool()\nconst { options, setOptions } = useToolOptions<SignatureOptions>('signature')\nconst ctx = useInkContext('InkSignatureMenu')\nconst templates = useReadable(() => ctx.signatures.value.templates, NO_TEMPLATES)\nconst removeError = useReadable(() => ctx.signatures.value.removeError, undefined)\nconst model = computed(() => signatureMenuModel(templates.value, options.value))\nconst active = computed(() => tool.value === 'signature')\nconst open = ref(false)\nconst creating = ref(false)\n// An old removal error is not news when the menu opens again.\nwatch(open, (isOpen) => {\n if (isOpen) ctx.signatures.value.clearRemoveError()\n})\nconst main = useTemplateRef<{ $el: HTMLElement }>('main')\n\n/** A saved signature drawn small: ink as filled outlines. */\nconst previews = computed(() =>\n model.value.items.map((item) =>\n item.template.kind === 'ink' ? signaturePreview(item.template) : null\n )\n)\n\n/** ArrowDown opens on the first item; a click opens on the checked one. */\nlet focusFirst = false\n/** Set while the menu closes for the dialog, which takes focus instead of the trigger. */\nlet toDialog = false\n\nfunction onTriggerKeydown(e: KeyboardEvent): void {\n if (e.key !== 'ArrowDown' || e.defaultPrevented || open.value) return\n e.preventDefault()\n focusFirst = true\n open.value = true\n}\n\nconst panel = (): HTMLElement | null =>\n document.querySelector<HTMLElement>('[data-ink-menu=\"signature\"] [role=\"menu\"]')\n\nfunction onOpenAutoFocus(e: Event): void {\n e.preventDefault()\n const menu = panel()\n if (menu) {\n if (focusFirst) menuItems(menu)[0]?.focus({ preventScroll: true })\n else focusInitialMenuItem(menu)\n }\n focusFirst = false\n}\n\nfunction onCloseAutoFocus(e: Event): void {\n if (toDialog) e.preventDefault()\n toDialog = false\n}\n\nfunction onMain(): void {\n if (model.value.selected) setTool('signature')\n else open.value = true\n}\n\nfunction choose(id: string): void {\n setOptions({ templateId: id })\n setTool('signature')\n open.value = false\n}\n\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 = panel()\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\nfunction create(): void {\n toDialog = true\n open.value = false\n creating.value = true\n}\n\nfunction onDialogCloseAutoFocus(e: Event): void {\n e.preventDefault()\n main.value?.$el.focus({ preventScroll: true })\n}\n\n// Reka's typed props stop at its own; ARIA and listeners go through bound objects.\nconst mainAttrs = computed(() => ({\n 'aria-pressed': String(active.value),\n 'aria-label': SIGNATURE_LABELS.sign,\n title: SIGNATURE_LABELS.sign,\n onClick: onMain,\n}))\nconst triggerAttrs = {\n 'aria-label': SIGNATURE_LABELS.trigger,\n title: SIGNATURE_LABELS.trigger,\n 'aria-haspopup': 'menu' as const,\n onKeydown: onTriggerKeydown,\n}\nconst menuAttrs = { 'aria-label': SIGNATURE_LABELS.menu }\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\n role=\"group\"\n :aria-label=\"SIGNATURE_LABELS.sign\"\n class=\"ink-split-button ink-signature-menu\"\n data-ink-signature-menu\n >\n <ToolbarButton\n ref=\"main\"\n class=\"ink-tool-button ink-signature-button\"\n data-ink-tool-button\n data-ink-signature-button\n data-tool=\"signature\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"mainAttrs\"\n >\n <slot :active=\"active\"><InkIcon :icon=\"Signature\" /></slot>\n </ToolbarButton>\n <PopoverRoot v-model:open=\"open\">\n <ToolbarButton as-child>\n <PopoverTrigger as-child>\n <button\n type=\"button\"\n class=\"ink-menu-trigger ink-signature-menu-trigger\"\n data-ink-signature-menu-trigger\n :data-state=\"open ? 'open' : 'closed'\"\n v-bind=\"triggerAttrs\"\n >\n <InkIcon :icon=\"ChevronDown\" />\n </button>\n </PopoverTrigger>\n </ToolbarButton>\n <PopoverPortal>\n <PopoverContent\n class=\"ink-select-content ink-menu-content\"\n data-ink-select-content\n data-ink-menu=\"signature\"\n side=\"bottom\"\n align=\"start\"\n :side-offset=\"4\"\n :collision-padding=\"8\"\n v-bind=\"menuAttrs\"\n @open-auto-focus=\"onOpenAutoFocus\"\n @close-auto-focus=\"onCloseAutoFocus\"\n >\n <div v-bind=\"innerAttrs\">\n <template v-if=\"model.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 model.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=\"choose(item.id)\"\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=\"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 </PopoverContent>\n </PopoverPortal>\n </PopoverRoot>\n <InkSignatureDialog\n v-model:open=\"creating\"\n :fonts=\"props.fonts\"\n @close-auto-focus=\"onDialogCloseAutoFocus\"\n />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCA,IAAM8B,IAAQC,GAKRC,IAA6C,CAAC,GAE9C,EAAE,SAAM,eAAYC,EAAQ,GAC5B,EAAE,aAAS,mBAAeC,EAAiC,WAAW,GACtEC,IAAMC,EAAc,kBAAkB,GACtCC,KAAYC,QAAkBH,EAAI,WAAW,MAAM,WAAWH,CAAY,GAC1EO,IAAcD,QAAkBH,EAAI,WAAW,MAAM,aAAa,KAAA,CAAS,GAC3EK,IAAQC,QAAeC,GAAmBL,GAAU,OAAOM,GAAQ,KAAK,CAAC,GACzEC,IAASH,QAAeI,EAAK,UAAU,WAAW,GAClDC,IAAOC,EAAI,EAAK,GAChBC,IAAWD,EAAI,EAAK;EAE1B,GAAMD,IAAO,MAAW;GACtB,AAAIG,KAAQd,EAAI,WAAW,MAAM,iBAAiB;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,GAAAA,CAAAA,MAAAA,CAAAA,GAAAA,GAAA,MACnCC,EAAGb,EAAA0E,CAAA,CAAgB,CAAC,MAAM,GAAA,CAAA,CAAA,CAAA;OAGpB1E,EAAAqC,CAAA,KADRvC,EAAA,GAAAC,EAOI,KAPJ2B,GAOIb,EADCb,EAAAqC,CAAA,CAAW,GAAA,CAAA,KAAAkE,EAAA,IAAA,EAAA;;;;;;;;GAMxBtG,EAIEa,IAAA;IAHQ,MAAMgC,EAAA;IAAA,iBAAA,AAAA4C,EAAA,QAAA,MAAA,EAAQ,QAAAC;IACrB,OAAO/D,EAAM;IACb,kBAAkB4C"}
@@ -0,0 +1,7 @@
1
+ import e from "./InkTextStyleMenu.vue_vue_type_script_setup_true_lang.js";
2
+ //#region src/components/InkTextStyleMenu.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
6
+
7
+ //# sourceMappingURL=InkTextStyleMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkTextStyleMenu.js","names":["_sfc_main","InkTextStyleMenu_vue_vue_type_script_setup_true_lang_default","InkTextStyleMenu_default"],"sources":["../../src/components/InkTextStyleMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * Font, size, text colour, bold, italic, underline and alignment for the selected text boxes or\n * the text tool. A popover panel rather than a menu list: it holds a select, a number input\n * with a stepper, toggle buttons and a radio group, each named and operable on its own. The\n * trigger carries `data-mixed` when the selection disagrees on any of them.\n */\nimport { handleRadioKeys, textStyleMenuModel } from '@inkbar/core/dom'\nimport {\n ALargeSmall,\n AlignCenter,\n AlignJustify,\n AlignLeft,\n AlignRight,\n Bold,\n Italic,\n Minus,\n Plus,\n Underline,\n} from '@inkbar/icons'\nimport {\n PopoverContent,\n PopoverPortal,\n PopoverRoot,\n PopoverTrigger,\n ToolbarButton,\n} from 'reka-ui'\nimport { computed, mergeProps, ref, useAttrs, watch } from 'vue'\n\nimport { useToolStyle } from '../composables/useToolStyle'\nimport { useInkContext } from '../context'\n\nimport InkColorMenu from './InkColorMenu.vue'\nimport InkIcon from './InkIcon.vue'\n\nconst { fonts } = useInkContext('InkTextStyleMenu')\n// The host's attributes go on the trigger: the root is a renderless popover.\ndefineOptions({ inheritAttrs: false })\nconst attrs = useAttrs()\n\nconst { current, supported, set } = useToolStyle()\nconst open = ref(false)\n/** The size as typed, until it is committed with Enter or blur. */\nconst draft = ref<string | null>(null)\n\nconst model = computed(() =>\n textStyleMenuModel(current.value, supported.value, fonts.value)\n)\nconst sizeShown = computed(\n () =>\n draft.value ?? (model.value.size.value === null ? '' : String(model.value.size.value))\n)\n\nconst TOGGLE_ICONS = { bold: Bold, italic: Italic, underline: Underline }\nconst ALIGN_ICONS = {\n left: AlignLeft,\n center: AlignCenter,\n right: AlignRight,\n justify: AlignJustify,\n}\n\n// The menu closes when the control disables (the selection cleared while it was open).\nwatch(\n () => model.value.enabled,\n (enabled) => {\n if (!enabled) open.value = false\n }\n)\n\nfunction onTriggerKeydown(e: KeyboardEvent): void {\n if (e.key !== 'ArrowDown' || e.defaultPrevented || open.value || !model.value.enabled)\n return\n e.preventDefault()\n open.value = true\n}\n\nfunction commitSize(): void {\n if (draft.value === null) return\n if (draft.value.trim() !== '') {\n const patch = model.value.size.commit(Number(draft.value))\n if (patch) set(patch)\n }\n draft.value = null\n}\nfunction nudge(direction: 1 | -1): void {\n const patch = model.value.size.nudge(direction)\n if (patch) set(patch)\n draft.value = null\n}\n\n// Reka's typed props stop at its own; ARIA goes through bound objects.\nconst triggerAttrs = computed(() => ({\n 'aria-label': model.value.label,\n title: model.value.label,\n 'aria-haspopup': 'dialog' as const,\n onKeydown: onTriggerKeydown,\n 'data-mixed': model.value.mixed ? '' : undefined,\n}))\n/**\n * The trigger's bindings over the host's: both keydown listeners run, the host's first, and a\n * host `disabled` can disable the trigger but not enable it.\n */\nconst triggerBindings = computed(() =>\n mergeProps(attrs, triggerAttrs.value, {\n disabled: (attrs.disabled ?? false) !== false || !model.value.enabled,\n })\n)\nconst menuAttrs = computed(() => ({ 'aria-label': model.value.label }))\n</script>\n\n<template>\n <PopoverRoot v-model:open=\"open\">\n <ToolbarButton as-child>\n <PopoverTrigger as-child>\n <button\n type=\"button\"\n class=\"ink-menu-trigger ink-text-style-menu\"\n data-ink-text-style-menu\n :data-state=\"open ? 'open' : 'closed'\"\n v-bind=\"triggerBindings\"\n >\n <slot><InkIcon :icon=\"ALargeSmall\" /></slot>\n </button>\n </PopoverTrigger>\n </ToolbarButton>\n <PopoverPortal>\n <PopoverContent\n class=\"ink-select-content ink-menu-content ink-text-style-content\"\n data-ink-select-content\n data-ink-menu=\"text-style\"\n side=\"bottom\"\n align=\"start\"\n :side-offset=\"4\"\n :collision-padding=\"8\"\n v-bind=\"menuAttrs\"\n >\n <select\n class=\"ink-text-style-font\"\n :aria-label=\"model.font.label\"\n :value=\"model.font.value\"\n @change=\"set(model.font.patch(($event.target as HTMLSelectElement).value))\"\n >\n <option v-if=\"model.font.value === ''\" value=\"\" disabled hidden>Mixed</option>\n <option v-for=\"f in model.font.options\" :key=\"f\" :value=\"f\">{{ f }}</option>\n </select>\n <div class=\"ink-text-style-row\">\n <InkColorMenu property=\"textColor\" standalone />\n <div class=\"ink-text-style-size\" role=\"group\" aria-label=\"Size\">\n <button\n type=\"button\"\n class=\"ink-text-style-button\"\n aria-label=\"Decrease font size\"\n @click=\"nudge(-1)\"\n >\n <InkIcon :icon=\"Minus\" :size=\"16\" />\n </button>\n <input\n type=\"number\"\n class=\"ink-text-style-input\"\n :aria-label=\"model.size.label\"\n :min=\"model.size.min\"\n :max=\"model.size.max\"\n :step=\"model.size.step\"\n :value=\"sizeShown\"\n @input=\"draft = ($event.target as HTMLInputElement).value\"\n @blur=\"commitSize\"\n @keydown.enter.prevent=\"commitSize\"\n />\n <button\n type=\"button\"\n class=\"ink-text-style-button\"\n aria-label=\"Increase font size\"\n @click=\"nudge(1)\"\n >\n <InkIcon :icon=\"Plus\" :size=\"16\" />\n </button>\n </div>\n </div>\n <div class=\"ink-text-style-row\" role=\"group\" aria-label=\"Emphasis\">\n <button\n v-for=\"t in model.toggles\"\n :key=\"t.key\"\n type=\"button\"\n class=\"ink-text-style-button\"\n :aria-label=\"t.label\"\n :title=\"t.label\"\n :aria-pressed=\"t.pressed\"\n :data-state=\"t.pressed === true ? 'on' : 'off'\"\n :data-mixed=\"t.pressed === 'mixed' ? '' : undefined\"\n @click=\"set(t.patch)\"\n >\n <InkIcon :icon=\"TOGGLE_ICONS[t.key]\" :size=\"16\" />\n </button>\n </div>\n <div\n class=\"ink-text-style-row\"\n role=\"radiogroup\"\n :aria-label=\"model.align.label\"\n @keydown=\"handleRadioKeys($event, $event.currentTarget as HTMLElement)\"\n >\n <button\n v-for=\"c in model.align.choices\"\n :key=\"c.key\"\n type=\"button\"\n role=\"radio\"\n class=\"ink-text-style-button\"\n :aria-label=\"c.label\"\n :title=\"c.label\"\n :aria-checked=\"c.checked\"\n :tabindex=\"c.tabStop ? 0 : -1\"\n :data-state=\"c.checked ? 'on' : 'off'\"\n @click=\"set(c.patch)\"\n >\n <InkIcon :icon=\"ALIGN_ICONS[c.key]\" :size=\"16\" />\n </button>\n </div>\n </PopoverContent>\n </PopoverPortal>\n </PopoverRoot>\n</template>\n"],"mappings":""}
@@ -0,0 +1,14 @@
1
+ declare var __VLS_21: {};
2
+ type __VLS_Slots = {} & {
3
+ default?: (props: typeof __VLS_21) => any;
4
+ };
5
+ declare const __VLS_base: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
6
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
9
+ type __VLS_WithSlots<T, S> = T & {
10
+ new (): {
11
+ $slots: S;
12
+ };
13
+ };
14
+ //# sourceMappingURL=InkTextStyleMenu.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkTextStyleMenu.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkTextStyleMenu.vue"],"names":[],"mappings":"AAgpBA,QAAA,IAAI,QAAQ,IAAY,CAAC;AACzB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAGhD,QAAA,MAAM,UAAU,+QACd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -0,0 +1,200 @@
1
+ import { useInkContext as e } from "../context.js";
2
+ import { useToolStyle as t } from "../composables/useToolStyle.js";
3
+ import n from "./InkIcon.js";
4
+ import ee from "./InkColorMenu.js";
5
+ import { Fragment as r, computed as i, createBlock as te, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createVNode as c, defineComponent as l, mergeProps as u, openBlock as d, ref as f, renderList as p, renderSlot as ne, toDisplayString as re, unref as m, useAttrs as ie, watch as ae, withCtx as h, withKeys as oe, withModifiers as g } from "vue";
6
+ import { handleRadioKeys as _, textStyleMenuModel as v } from "@inkbar/core/dom";
7
+ import { PopoverContent as y, PopoverPortal as b, PopoverRoot as x, PopoverTrigger as S, ToolbarButton as C } from "reka-ui";
8
+ import { ALargeSmall as w, AlignCenter as T, AlignJustify as E, AlignLeft as D, AlignRight as O, Bold as k, Italic as A, Minus as j, Plus as M, Underline as N } from "@inkbar/icons";
9
+ //#region src/components/InkTextStyleMenu.vue?vue&type=script&setup=true&lang.ts
10
+ var P = ["data-state"], F = ["aria-label", "value"], se = {
11
+ key: 0,
12
+ value: "",
13
+ disabled: "",
14
+ hidden: ""
15
+ }, I = ["value"], L = { class: "ink-text-style-row" }, R = {
16
+ class: "ink-text-style-size",
17
+ role: "group",
18
+ "aria-label": "Size"
19
+ }, z = [
20
+ "aria-label",
21
+ "min",
22
+ "max",
23
+ "step",
24
+ "value",
25
+ "onKeydown"
26
+ ], B = {
27
+ class: "ink-text-style-row",
28
+ role: "group",
29
+ "aria-label": "Emphasis"
30
+ }, V = [
31
+ "aria-label",
32
+ "title",
33
+ "aria-pressed",
34
+ "data-state",
35
+ "data-mixed",
36
+ "onClick"
37
+ ], H = ["aria-label"], U = [
38
+ "aria-label",
39
+ "title",
40
+ "aria-checked",
41
+ "tabindex",
42
+ "data-state",
43
+ "onClick"
44
+ ], W = /*@__PURE__*/ l({
45
+ inheritAttrs: !1,
46
+ __name: "InkTextStyleMenu",
47
+ setup(l) {
48
+ let { fonts: W } = e("InkTextStyleMenu"), G = ie(), { current: K, supported: ce, set: q } = t(), J = f(!1), Y = f(null), X = i(() => v(K.value, ce.value, W.value)), le = i(() => Y.value ?? (X.value.size.value === null ? "" : String(X.value.size.value))), ue = {
49
+ bold: k,
50
+ italic: A,
51
+ underline: N
52
+ }, de = {
53
+ left: D,
54
+ center: T,
55
+ right: O,
56
+ justify: E
57
+ };
58
+ ae(() => X.value.enabled, (e) => {
59
+ e || (J.value = !1);
60
+ });
61
+ function Z(e) {
62
+ e.key !== "ArrowDown" || e.defaultPrevented || J.value || !X.value.enabled || (e.preventDefault(), J.value = !0);
63
+ }
64
+ function Q() {
65
+ if (Y.value !== null) {
66
+ if (Y.value.trim() !== "") {
67
+ let e = X.value.size.commit(Number(Y.value));
68
+ e && q(e);
69
+ }
70
+ Y.value = null;
71
+ }
72
+ }
73
+ function $(e) {
74
+ let t = X.value.size.nudge(e);
75
+ t && q(t), Y.value = null;
76
+ }
77
+ let fe = i(() => ({
78
+ "aria-label": X.value.label,
79
+ title: X.value.label,
80
+ "aria-haspopup": "dialog",
81
+ onKeydown: Z,
82
+ "data-mixed": X.value.mixed ? "" : void 0
83
+ })), pe = i(() => u(G, fe.value, { disabled: (G.disabled ?? !1) !== !1 || !X.value.enabled })), me = i(() => ({ "aria-label": X.value.label }));
84
+ return (e, t) => (d(), te(m(x), {
85
+ open: J.value,
86
+ "onUpdate:open": t[5] ||= (e) => J.value = e
87
+ }, {
88
+ default: h(() => [c(m(C), { "as-child": "" }, {
89
+ default: h(() => [c(m(S), { "as-child": "" }, {
90
+ default: h(() => [s("button", u({
91
+ type: "button",
92
+ class: "ink-menu-trigger ink-text-style-menu",
93
+ "data-ink-text-style-menu": "",
94
+ "data-state": J.value ? "open" : "closed"
95
+ }, pe.value), [ne(e.$slots, "default", {}, () => [c(n, { icon: m(w) }, null, 8, ["icon"])])], 16, P)]),
96
+ _: 3
97
+ })]),
98
+ _: 3
99
+ }), c(m(b), null, {
100
+ default: h(() => [c(m(y), u({
101
+ class: "ink-select-content ink-menu-content ink-text-style-content",
102
+ "data-ink-select-content": "",
103
+ "data-ink-menu": "text-style",
104
+ side: "bottom",
105
+ align: "start",
106
+ "side-offset": 4,
107
+ "collision-padding": 8
108
+ }, me.value), {
109
+ default: h(() => [
110
+ s("select", {
111
+ class: "ink-text-style-font",
112
+ "aria-label": X.value.font.label,
113
+ value: X.value.font.value,
114
+ onChange: t[0] ||= (e) => m(q)(X.value.font.patch(e.target.value))
115
+ }, [X.value.font.value === "" ? (d(), o("option", se, "Mixed")) : a("", !0), (d(!0), o(r, null, p(X.value.font.options, (e) => (d(), o("option", {
116
+ key: e,
117
+ value: e
118
+ }, re(e), 9, I))), 128))], 40, F),
119
+ s("div", L, [c(ee, {
120
+ property: "textColor",
121
+ standalone: ""
122
+ }), s("div", R, [
123
+ s("button", {
124
+ type: "button",
125
+ class: "ink-text-style-button",
126
+ "aria-label": "Decrease font size",
127
+ onClick: t[1] ||= (e) => $(-1)
128
+ }, [c(n, {
129
+ icon: m(j),
130
+ size: 16
131
+ }, null, 8, ["icon"])]),
132
+ s("input", {
133
+ type: "number",
134
+ class: "ink-text-style-input",
135
+ "aria-label": X.value.size.label,
136
+ min: X.value.size.min,
137
+ max: X.value.size.max,
138
+ step: X.value.size.step,
139
+ value: le.value,
140
+ onInput: t[2] ||= (e) => Y.value = e.target.value,
141
+ onBlur: Q,
142
+ onKeydown: oe(g(Q, ["prevent"]), ["enter"])
143
+ }, null, 40, z),
144
+ s("button", {
145
+ type: "button",
146
+ class: "ink-text-style-button",
147
+ "aria-label": "Increase font size",
148
+ onClick: t[3] ||= (e) => $(1)
149
+ }, [c(n, {
150
+ icon: m(M),
151
+ size: 16
152
+ }, null, 8, ["icon"])])
153
+ ])]),
154
+ s("div", B, [(d(!0), o(r, null, p(X.value.toggles, (e) => (d(), o("button", {
155
+ key: e.key,
156
+ type: "button",
157
+ class: "ink-text-style-button",
158
+ "aria-label": e.label,
159
+ title: e.label,
160
+ "aria-pressed": e.pressed,
161
+ "data-state": e.pressed === !0 ? "on" : "off",
162
+ "data-mixed": e.pressed === "mixed" ? "" : void 0,
163
+ onClick: (t) => m(q)(e.patch)
164
+ }, [c(n, {
165
+ icon: ue[e.key],
166
+ size: 16
167
+ }, null, 8, ["icon"])], 8, V))), 128))]),
168
+ s("div", {
169
+ class: "ink-text-style-row",
170
+ role: "radiogroup",
171
+ "aria-label": X.value.align.label,
172
+ onKeydown: t[4] ||= (e) => m(_)(e, e.currentTarget)
173
+ }, [(d(!0), o(r, null, p(X.value.align.choices, (e) => (d(), o("button", {
174
+ key: e.key,
175
+ type: "button",
176
+ role: "radio",
177
+ class: "ink-text-style-button",
178
+ "aria-label": e.label,
179
+ title: e.label,
180
+ "aria-checked": e.checked,
181
+ tabindex: e.tabStop ? 0 : -1,
182
+ "data-state": e.checked ? "on" : "off",
183
+ onClick: (t) => m(q)(e.patch)
184
+ }, [c(n, {
185
+ icon: de[e.key],
186
+ size: 16
187
+ }, null, 8, ["icon"])], 8, U))), 128))], 40, H)
188
+ ]),
189
+ _: 1
190
+ }, 16)]),
191
+ _: 1
192
+ })]),
193
+ _: 3
194
+ }, 8, ["open"]));
195
+ }
196
+ });
197
+ //#endregion
198
+ export { W as default };
199
+
200
+ //# sourceMappingURL=InkTextStyleMenu.vue_vue_type_script_setup_true_lang.js.map