@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":"InkSignatureDialog.js","names":["_sfc_main","InkSignatureDialog_vue_vue_type_script_setup_true_lang_default","InkSignatureDialog_default"],"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":""}
1
+ {"version":3,"file":"InkSignatureDialog.js","names":["_sfc_main","InkSignatureDialog_vue_vue_type_script_setup_true_lang_default","InkSignatureDialog_default"],"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, unless `select`\n * is false or no `signature` tool is registered, selects it for that tool. Escape, Cancel or a\n * 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 = withDefaults(\n defineProps<{\n /** The fonts the Type tab offers. Default: InkRoot's `signatureFonts`. */\n fonts?: readonly string[] | undefined\n /**\n * Whether saving selects the new signature for the `signature` tool, when one is\n * registered. False leaves the tool alone, for a dialog that signs a field with it through\n * `save`.\n */\n select?: boolean\n }>(),\n { fonts: undefined, select: true }\n)\nconst open = defineModel<boolean>('open', { default: false })\nconst emit = defineEmits<{\n /** The new template, once saved (and selected, with `select`). */\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 :select=\"props.select\"\n @saved=\"emit('save', $event)\"\n @close=\"open = false\"\n />\n </DialogContent>\n </DialogPortal>\n </DialogRoot>\n</template>\n"],"mappings":""}
@@ -2,6 +2,12 @@ import { SignatureTemplate } from '@inkbar/core';
2
2
  type __VLS_Props = {
3
3
  /** The fonts the Type tab offers. Default: InkRoot's `signatureFonts`. */
4
4
  fonts?: readonly string[] | undefined;
5
+ /**
6
+ * Whether saving selects the new signature for the `signature` tool, when one is
7
+ * registered. False leaves the tool alone, for a dialog that signs a field with it through
8
+ * `save`.
9
+ */
10
+ select?: boolean;
5
11
  };
6
12
  type __VLS_ModelProps = {
7
13
  'open'?: boolean;
@@ -15,7 +21,10 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_PublicProps, {},
15
21
  "onUpdate:open"?: (value: boolean) => any;
16
22
  onCloseAutoFocus?: (event: Event) => any;
17
23
  onSave?: (template: SignatureTemplate) => any;
18
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
24
+ }>, {
25
+ select: boolean;
26
+ fonts: readonly string[] | undefined;
27
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
19
28
  declare const _default: typeof __VLS_export;
20
29
  export default _default;
21
30
  //# sourceMappingURL=InkSignatureDialog.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"InkSignatureDialog.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkSignatureDialog.vue"],"names":[],"mappings":"AAoFA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAGrD,KAAK,WAAW,GAAG;IACjB,0EAA0E;IAC1E,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;CACtC,CAAC;AAyBF,KAAK,gBAAgB,GAAG;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAKF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAmKxD,QAAA,MAAM,YAAY;;;;;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"InkSignatureDialog.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkSignatureDialog.vue"],"names":[],"mappings":"AAgGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAGrD,KAAK,WAAW,GAAG;IACf,0EAA0E;IAC1E,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;IACrC;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAC;AA4BJ,KAAK,gBAAgB,GAAG;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAOF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAoKxD,QAAA,MAAM,YAAY;;;;;;;;;;;6EAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -5,7 +5,13 @@ import { DialogContent as p, DialogOverlay as m, DialogPortal as h, DialogRoot a
5
5
  //#region src/components/InkSignatureDialog.vue?vue&type=script&setup=true&lang.ts
6
6
  var v = /*@__PURE__*/ i({
7
7
  __name: "InkSignatureDialog",
8
- props: /*@__PURE__*/ a({ fonts: {} }, {
8
+ props: /*@__PURE__*/ a({
9
+ fonts: { default: void 0 },
10
+ select: {
11
+ type: Boolean,
12
+ default: !0
13
+ }
14
+ }, {
9
15
  open: {
10
16
  type: Boolean,
11
17
  default: !1
@@ -41,9 +47,10 @@ var v = /*@__PURE__*/ i({
41
47
  _: 1
42
48
  }), r(e, {
43
49
  fonts: v.fonts,
50
+ select: v.select,
44
51
  onSaved: a[0] ||= (e) => b("save", e),
45
52
  onClose: a[1] ||= (e) => y.value = !1
46
- }, null, 8, ["fonts"])]),
53
+ }, null, 8, ["fonts", "select"])]),
47
54
  _: 1
48
55
  }, 16)]),
49
56
  _: 1
@@ -1 +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"}
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, unless `select`\n * is false or no `signature` tool is registered, selects it for that tool. Escape, Cancel or a\n * 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 = withDefaults(\n defineProps<{\n /** The fonts the Type tab offers. Default: InkRoot's `signatureFonts`. */\n fonts?: readonly string[] | undefined\n /**\n * Whether saving selects the new signature for the `signature` tool, when one is\n * registered. False leaves the tool alone, for a dialog that signs a field with it through\n * `save`.\n */\n select?: boolean\n }>(),\n { fonts: undefined, select: true }\n)\nconst open = defineModel<boolean>('open', { default: false })\nconst emit = defineEmits<{\n /** The new template, once saved (and selected, with `select`). */\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 :select=\"props.select\"\n @saved=\"emit('save', $event)\"\n @close=\"open = false\"\n />\n </DialogContent>\n </DialogPortal>\n </DialogRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;EAqBA,IAAMe,IAAQC,GAaRC,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,EAmBaC,EAAAsB,CAAA,GAAA;GAnBO,MAAMR,EAAA;GAAA,iBAAA,AAAAS,EAAA,QAAA,MAAA,EAAI,QAAAC;;GAC5B,SAAAvB,QAiBe,CAjBfC,EAiBeF,EAAA2B,CAAA,GAAA,MAAA;IAhBb,SAAA1B,QAAoE,CAApEC,EAAoEF,EAAA4B,CAAA,GAAA;KAArD,OAAM;KAAqB,2BAAA;IAC1C1B,CAAAA,GAAAA,EAcgBF,EAAA6B,CAAA,GAdhB1B,EAcgB;KAbd,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,EAKEI,GAAA;MAJC,OAAOM,EAAM;MACb,QAAQA,EAAM;MACd,SAAK,AAAAW,EAAA,QAAA,MAAEP,EAAI,QAASQ,CAAM;MAC1B,SAAK,AAAAD,EAAA,QAAA,MAAE,EAAA,QAAI"}
@@ -1 +1 @@
1
- {"version":3,"file":"InkSignatureMenu.js","names":["_sfc_main","InkSignatureMenu_vue_vue_type_script_setup_true_lang_default","InkSignatureMenu_default"],"sources":["../../src/components/InkSignatureMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * A split button for the signature tool. The main part activates the tool with the chosen\n * signature, or opens the menu when none is chosen; the chevron opens the saved signatures as\n * previews, each with a remove button, and \"Create signature\", which opens\n * `InkSignatureDialog`. Choosing a signature switches to the tool with it.\n */\nimport {\n focusInitialMenuItem,\n 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 PopoverAnchor,\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\ndefineOptions({ inheritAttrs: false })\nconst props = defineProps<{\n /** The fonts the dialog's Type tab offers. Default: InkRoot's `signatureFonts`. */\n fonts?: readonly string[] | undefined\n}>()\n\nconst NO_TEMPLATES: readonly SignatureTemplate[] = []\n\nconst { tool, setTool } = useTool()\nconst { options, setOptions } = useToolOptions<SignatureOptions>('signature')\nconst ctx = useInkContext('InkSignatureMenu')\nconst templates = useReadable(() => ctx.signatures.value.templates, NO_TEMPLATES)\nconst 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 <PopoverRoot v-model:open=\"open\">\n <PopoverAnchor as-child>\n <div\n role=\"group\"\n :aria-label=\"SIGNATURE_LABELS.sign\"\n class=\"ink-split-button ink-signature-menu\"\n data-ink-signature-menu\n v-bind=\"$attrs\"\n >\n <ToolbarButton\n ref=\"main\"\n class=\"ink-tool-button ink-signature-button\"\n data-ink-tool-button\n data-ink-signature-button\n data-tool=\"signature\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"mainAttrs\"\n >\n <slot :active=\"active\"><InkIcon :icon=\"Signature\" /></slot>\n </ToolbarButton>\n <ToolbarButton as-child>\n <PopoverTrigger as-child>\n <button\n type=\"button\"\n class=\"ink-menu-trigger ink-signature-menu-trigger\"\n data-ink-signature-menu-trigger\n :data-state=\"open ? 'open' : 'closed'\"\n v-bind=\"triggerAttrs\"\n >\n <InkIcon :icon=\"ChevronDown\" />\n </button>\n </PopoverTrigger>\n </ToolbarButton>\n <PopoverPortal>\n <PopoverContent\n class=\"ink-select-content ink-menu-content\"\n data-ink-select-content\n data-ink-menu=\"signature\"\n side=\"bottom\"\n align=\"start\"\n :side-offset=\"4\"\n :collision-padding=\"8\"\n v-bind=\"menuAttrs\"\n @open-auto-focus=\"onOpenAutoFocus\"\n @close-auto-focus=\"onCloseAutoFocus\"\n >\n <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 <InkSignatureDialog\n v-model:open=\"creating\"\n :fonts=\"props.fonts\"\n @close-auto-focus=\"onDialogCloseAutoFocus\"\n />\n </div>\n </PopoverAnchor>\n </PopoverRoot>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"InkSignatureMenu.js","names":["_sfc_main","InkSignatureMenu_vue_vue_type_script_setup_true_lang_default","InkSignatureMenu_default"],"sources":["../../src/components/InkSignatureMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * A split button for the signature tool. The main part activates the tool with the chosen\n * signature, or opens the menu when none is chosen; the chevron opens the saved signatures as\n * previews, each with a remove button, and \"Create signature\", which opens\n * `InkSignatureDialog`. Choosing a signature switches to the tool with it.\n */\nimport {\n focusInitialMenuItem,\n menuItems,\n SIGNATURE_LABELS,\n signatureMenuModel,\n} from '@inkbar/core/dom'\nimport { ChevronDown, Signature } from '@inkbar/icons'\nimport {\n PopoverAnchor,\n PopoverContent,\n PopoverPortal,\n PopoverRoot,\n PopoverTrigger,\n ToolbarButton,\n} from 'reka-ui'\nimport { computed, ref, useTemplateRef, watch } from 'vue'\n\nimport { useRegisteredTool } from '../composables/useRegisteredTool'\nimport { useTool } from '../composables/useTool'\nimport { useToolOptionsWhile } from '../composables/useToolOptions'\nimport { useInkContext } from '../context'\nimport { useReadable } from '../use-readable'\n\nimport InkIcon from './InkIcon.vue'\nimport InkSignatureDialog from './InkSignatureDialog.vue'\nimport SignatureMenuPanel from './SignatureMenuPanel.vue'\n\nimport type { SignatureOptions, SignatureTemplate } from '@inkbar/core'\n\ndefineOptions({ inheritAttrs: false })\nconst props = defineProps<{\n /** The fonts the dialog's Type tab offers. Default: InkRoot's `signatureFonts`. */\n fonts?: readonly string[] | undefined\n}>()\n\nconst NO_TEMPLATES: readonly SignatureTemplate[] = []\n\nconst { tool, setTool } = useTool()\n// Nothing renders while no `signature` tool is registered.\nconst registered = useRegisteredTool('signature')\nconst { options, setOptions } = useToolOptionsWhile<SignatureOptions>(\n 'signature',\n registered\n)\nconst ctx = useInkContext('InkSignatureMenu')\nconst templates = useReadable(() => ctx.signatures.value.templates, NO_TEMPLATES)\nconst model = computed(() => signatureMenuModel(templates.value, options.value))\nconst active = computed(() => tool.value === 'signature')\nconst open = ref(false)\nconst creating = ref(false)\n// An old removal error is not news when the menu opens again.\nwatch(open, (isOpen) => {\n if (isOpen) ctx.signatures.value.clearRemoveError()\n})\nconst main = useTemplateRef<{ $el: HTMLElement }>('main')\n\n/** ArrowDown opens on the first item; a click opens on the checked one. */\nlet focusFirst = false\n/** Set while the menu closes for the dialog, which takes focus instead of the trigger. */\nlet toDialog = false\n\nfunction onTriggerKeydown(e: KeyboardEvent): void {\n if (e.key !== 'ArrowDown' || e.defaultPrevented || open.value) return\n e.preventDefault()\n focusFirst = true\n open.value = true\n}\n\n// Not a signature field's menu, which shares the attribute.\nconst panel = (): HTMLElement | null =>\n document.querySelector<HTMLElement>(\n '[data-ink-menu=\"signature\"]:not([data-ink-sign-field-menu]) [role=\"menu\"]'\n )\n\nfunction onOpenAutoFocus(e: Event): void {\n e.preventDefault()\n const menu = panel()\n if (menu) {\n if (focusFirst) menuItems(menu)[0]?.focus({ preventScroll: true })\n else focusInitialMenuItem(menu)\n }\n focusFirst = false\n}\n\nfunction onCloseAutoFocus(e: Event): void {\n if (toDialog) e.preventDefault()\n toDialog = false\n}\n\nfunction onMain(): void {\n if (model.value.selected) setTool('signature')\n else open.value = true\n}\n\nfunction choose(id: string): void {\n setOptions({ templateId: id })\n setTool('signature')\n open.value = false\n}\n\nfunction create(): void {\n toDialog = true\n open.value = false\n creating.value = true\n}\n\nfunction onDialogCloseAutoFocus(e: Event): void {\n e.preventDefault()\n main.value?.$el.focus({ preventScroll: true })\n}\n\n// Reka's typed props stop at its own; ARIA and listeners go through bound objects.\nconst mainAttrs = computed(() => ({\n 'aria-pressed': String(active.value),\n 'aria-label': SIGNATURE_LABELS.sign,\n title: SIGNATURE_LABELS.sign,\n onClick: onMain,\n}))\nconst triggerAttrs = {\n 'aria-label': SIGNATURE_LABELS.trigger,\n title: SIGNATURE_LABELS.trigger,\n 'aria-haspopup': 'menu' as const,\n onKeydown: onTriggerKeydown,\n}\nconst menuAttrs = { 'aria-label': SIGNATURE_LABELS.menu }\n</script>\n\n<template>\n <PopoverRoot v-if=\"registered\" v-model:open=\"open\">\n <PopoverAnchor as-child>\n <div\n role=\"group\"\n :aria-label=\"SIGNATURE_LABELS.sign\"\n class=\"ink-split-button ink-signature-menu\"\n data-ink-signature-menu\n v-bind=\"$attrs\"\n >\n <ToolbarButton\n ref=\"main\"\n class=\"ink-tool-button ink-signature-button\"\n data-ink-tool-button\n data-ink-signature-button\n data-tool=\"signature\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"mainAttrs\"\n >\n <slot :active=\"active\"><InkIcon :icon=\"Signature\" /></slot>\n </ToolbarButton>\n <ToolbarButton as-child>\n <PopoverTrigger as-child>\n <button\n type=\"button\"\n class=\"ink-menu-trigger ink-signature-menu-trigger\"\n data-ink-signature-menu-trigger\n :data-state=\"open ? 'open' : 'closed'\"\n v-bind=\"triggerAttrs\"\n >\n <InkIcon :icon=\"ChevronDown\" />\n </button>\n </PopoverTrigger>\n </ToolbarButton>\n <PopoverPortal>\n <PopoverContent\n class=\"ink-select-content ink-menu-content\"\n data-ink-select-content\n data-ink-menu=\"signature\"\n side=\"bottom\"\n align=\"start\"\n :side-offset=\"4\"\n :collision-padding=\"8\"\n v-bind=\"menuAttrs\"\n @open-auto-focus=\"onOpenAutoFocus\"\n @close-auto-focus=\"onCloseAutoFocus\"\n >\n <SignatureMenuPanel\n :items=\"model.items\"\n @choose=\"choose($event.id)\"\n @create=\"create\"\n />\n </PopoverContent>\n </PopoverPortal>\n <InkSignatureDialog\n v-model:open=\"creating\"\n :fonts=\"props.fonts\"\n @close-auto-focus=\"onDialogCloseAutoFocus\"\n />\n </div>\n </PopoverAnchor>\n </PopoverRoot>\n</template>\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"InkSignatureMenu.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkSignatureMenu.vue"],"names":[],"mappings":"AA2UA,KAAK,WAAW,GAAG;IACjB,mFAAmF;IACnF,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;CACtC,CAAC;AA2dF,QAAA,IAAI,QAAQ;;CAAY,CAAC;AACzB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAGhD,QAAA,MAAM,UAAU,kSAEd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"InkSignatureMenu.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkSignatureMenu.vue"],"names":[],"mappings":"AA4OA,KAAK,WAAW,GAAG;IACjB,mFAAmF;IACnF,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;CACtC,CAAC;AAkWF,QAAA,IAAI,QAAQ;;CAAY,CAAC;AACzB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAGhD,QAAA,MAAM,UAAU,kSAEd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -1,100 +1,74 @@
1
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, createBlock as te, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as u, createVNode as d, defineComponent as f, guardReactiveProps as ne, mergeProps as p, nextTick as re, normalizeProps as ie, openBlock as m, ref as h, renderList as g, renderSlot as ae, toDisplayString as _, unref as v, useTemplateRef as oe, watch as se, withCtx as y } from "vue";
8
- import { SIGNATURE_LABELS as b, focusInitialMenuItem as ce, handleMenuKeys as le, menuItems as ue, signatureMenuModel as de, signaturePreview as fe } from "@inkbar/core/dom";
9
- import { PopoverAnchor as pe, PopoverContent as x, PopoverPortal as S, PopoverRoot as C, PopoverTrigger as w, ToolbarButton as T } from "reka-ui";
10
- import { ChevronDown as E, Plus as D, Signature as O, Trash2 as k } from "@inkbar/icons";
2
+ import { useRegisteredTool as t } from "../composables/useRegisteredTool.js";
3
+ import { useReadable as n } from "../use-readable.js";
4
+ import { useTool as r } from "../composables/useTool.js";
5
+ import { useToolOptionsWhile as i } from "../composables/useToolOptions.js";
6
+ import a from "./InkSignatureDialog.js";
7
+ import o from "./InkIcon.js";
8
+ import s from "./SignatureMenuPanel.js";
9
+ import { computed as c, createBlock as l, createCommentVNode as u, createElementVNode as d, createVNode as f, defineComponent as p, mergeProps as m, openBlock as h, ref as g, renderSlot as _, unref as v, useTemplateRef as y, watch as b, withCtx as x } from "vue";
10
+ import { SIGNATURE_LABELS as S, focusInitialMenuItem as C, menuItems as w, signatureMenuModel as T } from "@inkbar/core/dom";
11
+ import { PopoverAnchor as E, PopoverContent as D, PopoverPortal as O, PopoverRoot as k, PopoverTrigger as A, ToolbarButton as j } from "reka-ui";
12
+ import { ChevronDown as M, Signature as N } from "@inkbar/icons";
11
13
  //#region src/components/InkSignatureMenu.vue?vue&type=script&setup=true&lang.ts
12
- var A = ["aria-label"], j = ["data-state"], M = ["aria-label"], N = [
13
- "aria-checked",
14
- "aria-label",
15
- "data-key",
16
- "data-state",
17
- "onClick"
18
- ], P = ["data-kind"], F = ["src"], I = ["viewBox"], L = ["d"], R = [
19
- "aria-label",
20
- "title",
21
- "data-key",
22
- "onClick"
23
- ], z = {
24
- key: 1,
25
- class: "ink-field-error ink-signature-remove-error",
26
- role: "alert",
27
- "data-ink-signature-remove-error": ""
28
- }, B = /*@__PURE__*/ f({
14
+ var P = ["aria-label"], F = ["data-state"], I = /*@__PURE__*/ p({
29
15
  inheritAttrs: !1,
30
16
  __name: "InkSignatureMenu",
31
17
  props: { fonts: {} },
32
- setup(f) {
33
- let B = f, me = [], { tool: he, setTool: V } = n(), { options: ge, setOptions: _e } = r("signature"), H = e("InkSignatureMenu"), ve = t(() => H.signatures.value.templates, me), U = t(() => H.signatures.value.removeError, void 0), W = o(() => de(ve.value, ge.value)), G = o(() => he.value === "signature"), K = h(!1), q = h(!1);
34
- se(K, (e) => {
18
+ setup(p) {
19
+ let I = p, L = [], { tool: R, setTool: z } = r(), B = t("signature"), { options: ee, setOptions: V } = i("signature", B), H = e("InkSignatureMenu"), U = n(() => H.signatures.value.templates, L), W = c(() => T(U.value, ee.value)), G = c(() => R.value === "signature"), K = g(!1), q = g(!1);
20
+ b(K, (e) => {
35
21
  e && H.signatures.value.clearRemoveError();
36
22
  });
37
- let J = oe("main"), Y = o(() => W.value.items.map((e) => e.template.kind === "ink" ? fe(e.template) : null)), X = !1, Z = !1;
38
- function ye(e) {
39
- e.key !== "ArrowDown" || e.defaultPrevented || K.value || (e.preventDefault(), X = !0, K.value = !0);
23
+ let J = y("main"), Y = !1, X = !1;
24
+ function Z(e) {
25
+ e.key !== "ArrowDown" || e.defaultPrevented || K.value || (e.preventDefault(), Y = !0, K.value = !0);
40
26
  }
41
- let Q = () => document.querySelector("[data-ink-menu=\"signature\"] [role=\"menu\"]");
42
- function be(e) {
27
+ let Q = () => document.querySelector("[data-ink-menu=\"signature\"]:not([data-ink-sign-field-menu]) [role=\"menu\"]");
28
+ function $(e) {
43
29
  e.preventDefault();
44
30
  let t = Q();
45
- t && (X ? ue(t)[0]?.focus({ preventScroll: !0 }) : ce(t)), X = !1;
31
+ t && (Y ? w(t)[0]?.focus({ preventScroll: !0 }) : C(t)), Y = !1;
46
32
  }
47
- function xe(e) {
48
- Z && e.preventDefault(), Z = !1;
33
+ function te(e) {
34
+ X && e.preventDefault(), X = !1;
49
35
  }
50
- function Se() {
51
- W.value.selected ? V("signature") : K.value = !0;
36
+ function ne() {
37
+ W.value.selected ? z("signature") : K.value = !0;
52
38
  }
53
- function Ce(e) {
54
- _e({ templateId: e }), V("signature"), K.value = !1;
39
+ function re(e) {
40
+ V({ templateId: e }), z("signature"), K.value = !1;
55
41
  }
56
- function $(e, t) {
57
- H.signatures.value.remove(e).then(async () => {
58
- await re();
59
- let e = Q();
60
- if (!e) return;
61
- let n = e.querySelectorAll(".ink-signature-item");
62
- (n[Math.min(t, n.length - 1)] ?? e.querySelector("[data-ink-signature-create]"))?.focus({ preventScroll: !0 });
63
- }, () => {});
42
+ function ie() {
43
+ X = !0, K.value = !1, q.value = !0;
64
44
  }
65
- function we() {
66
- Z = !0, K.value = !1, q.value = !0;
67
- }
68
- function Te(e) {
45
+ function ae(e) {
69
46
  e.preventDefault(), J.value?.$el.focus({ preventScroll: !0 });
70
47
  }
71
- let Ee = o(() => ({
48
+ let oe = c(() => ({
72
49
  "aria-pressed": String(G.value),
73
- "aria-label": b.sign,
74
- title: b.sign,
75
- onClick: Se
76
- })), De = {
77
- "aria-label": b.trigger,
78
- title: b.trigger,
50
+ "aria-label": S.sign,
51
+ title: S.sign,
52
+ onClick: ne
53
+ })), se = {
54
+ "aria-label": S.trigger,
55
+ title: S.trigger,
79
56
  "aria-haspopup": "menu",
80
- onKeydown: ye
81
- }, Oe = { "aria-label": b.menu }, ke = {
82
- role: "menu",
83
- "aria-label": b.menu,
84
- onKeydown: (e) => le(e, e.currentTarget)
85
- };
86
- return (e, t) => (m(), te(v(C), {
57
+ onKeydown: Z
58
+ }, ce = { "aria-label": S.menu };
59
+ return (e, t) => v(B) ? (h(), l(v(k), {
60
+ key: 0,
87
61
  open: K.value,
88
- "onUpdate:open": t[1] ||= (e) => K.value = e
62
+ "onUpdate:open": t[2] ||= (e) => K.value = e
89
63
  }, {
90
- default: y(() => [d(v(pe), { "as-child": "" }, {
91
- default: y(() => [l("div", p({
64
+ default: x(() => [f(v(E), { "as-child": "" }, {
65
+ default: x(() => [d("div", m({
92
66
  role: "group",
93
- "aria-label": v(b).sign,
67
+ "aria-label": v(S).sign,
94
68
  class: "ink-split-button ink-signature-menu",
95
69
  "data-ink-signature-menu": ""
96
70
  }, e.$attrs), [
97
- d(v(T), p({
71
+ f(v(j), m({
98
72
  ref_key: "main",
99
73
  ref: J,
100
74
  class: "ink-tool-button ink-signature-button",
@@ -102,24 +76,24 @@ var A = ["aria-label"], j = ["data-state"], M = ["aria-label"], N = [
102
76
  "data-ink-signature-button": "",
103
77
  "data-tool": "signature",
104
78
  "data-state": G.value ? "on" : "off"
105
- }, Ee.value), {
106
- default: y(() => [ae(e.$slots, "default", { active: G.value }, () => [d(i, { icon: v(O) }, null, 8, ["icon"])])]),
79
+ }, oe.value), {
80
+ default: x(() => [_(e.$slots, "default", { active: G.value }, () => [f(o, { icon: v(N) }, null, 8, ["icon"])])]),
107
81
  _: 3
108
82
  }, 16, ["data-state"]),
109
- d(v(T), { "as-child": "" }, {
110
- default: y(() => [d(v(w), { "as-child": "" }, {
111
- default: y(() => [l("button", p({
83
+ f(v(j), { "as-child": "" }, {
84
+ default: x(() => [f(v(A), { "as-child": "" }, {
85
+ default: x(() => [d("button", m({
112
86
  type: "button",
113
87
  class: "ink-menu-trigger ink-signature-menu-trigger",
114
88
  "data-ink-signature-menu-trigger": "",
115
89
  "data-state": K.value ? "open" : "closed"
116
- }, De), [d(i, { icon: v(E) }, null, 8, ["icon"])], 16, j)]),
90
+ }, se), [f(o, { icon: v(M) }, null, 8, ["icon"])], 16, F)]),
117
91
  _: 1
118
92
  })]),
119
93
  _: 1
120
94
  }),
121
- d(v(S), null, {
122
- default: y(() => [d(v(x), p({
95
+ f(v(O), null, {
96
+ default: x(() => [f(v(D), m({
123
97
  class: "ink-select-content ink-menu-content",
124
98
  "data-ink-select-content": "",
125
99
  "data-ink-menu": "signature",
@@ -127,92 +101,33 @@ var A = ["aria-label"], j = ["data-state"], M = ["aria-label"], N = [
127
101
  align: "start",
128
102
  "side-offset": 4,
129
103
  "collision-padding": 8
130
- }, Oe, {
131
- onOpenAutoFocus: be,
132
- onCloseAutoFocus: xe
104
+ }, ce, {
105
+ onOpenAutoFocus: $,
106
+ onCloseAutoFocus: te
133
107
  }), {
134
- default: y(() => [l("div", ie(ne(ke)), [
135
- W.value.items.length > 0 ? (m(), c(a, { key: 0 }, [l("div", {
136
- role: "group",
137
- "aria-label": v(b).saved,
138
- class: "ink-signature-list",
139
- "data-ink-menu-columns": "2"
140
- }, [(m(!0), c(a, null, g(W.value.items, (e, t) => (m(), c(a, { key: e.id }, [l("button", {
141
- type: "button",
142
- role: "menuitemradio",
143
- "aria-checked": e.checked,
144
- "aria-label": e.label,
145
- tabindex: "-1",
146
- class: "ink-select-item ink-menu-item ink-signature-item",
147
- "data-ink-select-item": "",
148
- "data-key": e.id,
149
- "data-state": e.checked ? "checked" : "unchecked",
150
- onClick: (t) => Ce(e.id)
151
- }, [l("span", {
152
- class: "ink-signature-preview",
153
- "data-kind": e.template.kind
154
- }, [e.template.kind === "image" ? (m(), c("img", {
155
- key: 0,
156
- src: e.template.imagedata,
157
- alt: "",
158
- draggable: "false"
159
- }, null, 8, F)) : (m(), c("svg", {
160
- key: 1,
161
- viewBox: Y.value[t]?.viewBox,
162
- "aria-hidden": "true"
163
- }, [(m(!0), c(a, null, g(Y.value[t]?.paths ?? [], (e, t) => (m(), c("path", {
164
- key: t,
165
- d: e,
166
- fill: "currentColor"
167
- }, null, 8, L))), 128))], 8, I))], 8, P)], 8, N), l("button", {
168
- type: "button",
169
- role: "menuitem",
170
- "aria-label": e.removeLabel,
171
- title: e.removeLabel,
172
- tabindex: "-1",
173
- class: "ink-menu-item ink-signature-remove",
174
- "data-ink-signature-remove": "",
175
- "data-key": e.id,
176
- onClick: (n) => $(e.id, t)
177
- }, [d(i, {
178
- icon: v(k),
179
- size: 16
180
- }, null, 8, ["icon"])], 8, R)], 64))), 128))], 8, M), t[2] ||= l("div", {
181
- role: "separator",
182
- class: "ink-select-separator"
183
- }, null, -1)], 64)) : s("", !0),
184
- l("button", {
185
- type: "button",
186
- role: "menuitem",
187
- tabindex: "-1",
188
- class: "ink-select-item ink-menu-item ink-signature-create",
189
- "data-ink-select-item": "",
190
- "data-ink-signature-create": "",
191
- onClick: we
192
- }, [d(i, {
193
- icon: v(D),
194
- size: 16
195
- }, null, 8, ["icon"]), u(" " + _(v(b).create), 1)]),
196
- v(U) ? (m(), c("p", z, _(v(U)), 1)) : s("", !0)
197
- ], 16)]),
108
+ default: x(() => [f(s, {
109
+ items: W.value.items,
110
+ onChoose: t[0] ||= (e) => re(e.id),
111
+ onCreate: ie
112
+ }, null, 8, ["items"])]),
198
113
  _: 1
199
114
  }, 16)]),
200
115
  _: 1
201
116
  }),
202
- d(ee, {
117
+ f(a, {
203
118
  open: q.value,
204
- "onUpdate:open": t[0] ||= (e) => q.value = e,
205
- fonts: B.fonts,
206
- onCloseAutoFocus: Te
119
+ "onUpdate:open": t[1] ||= (e) => q.value = e,
120
+ fonts: I.fonts,
121
+ onCloseAutoFocus: ae
207
122
  }, null, 8, ["open", "fonts"])
208
- ], 16, A)]),
123
+ ], 16, P)]),
209
124
  _: 3
210
125
  })]),
211
126
  _: 3
212
- }, 8, ["open"]));
127
+ }, 8, ["open"])) : u("", !0);
213
128
  }
214
129
  });
215
130
  //#endregion
216
- export { B as default };
131
+ export { I as default };
217
132
 
218
133
  //# sourceMappingURL=InkSignatureMenu.vue_vue_type_script_setup_true_lang.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InkSignatureMenu.vue_vue_type_script_setup_true_lang.js","names":["$attrs","_openBlock","_createBlock","_unref","_withCtx","_createVNode","_createElementVNode","_mergeProps","_renderSlot","InkIcon","_normalizeProps","_guardReactiveProps","_createElementBlock","_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","createBlock","unref","PopoverRoot","_cache","$event","withCtx","createVNode","PopoverAnchor","createElementVNode","mergeProps","_ctx","ToolbarButton","renderSlot","Signature","PopoverTrigger","ChevronDown","PopoverPortal","PopoverContent","normalizeProps","guardReactiveProps","createElementBlock","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 PopoverAnchor,\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\ndefineOptions({ inheritAttrs: false })\nconst props = defineProps<{\n /** The fonts the dialog's Type tab offers. Default: InkRoot's `signatureFonts`. */\n fonts?: readonly string[] | undefined\n}>()\n\nconst NO_TEMPLATES: readonly SignatureTemplate[] = []\n\nconst { tool, setTool } = useTool()\nconst { options, setOptions } = useToolOptions<SignatureOptions>('signature')\nconst ctx = useInkContext('InkSignatureMenu')\nconst templates = useReadable(() => ctx.signatures.value.templates, NO_TEMPLATES)\nconst 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 <PopoverRoot v-model:open=\"open\">\n <PopoverAnchor as-child>\n <div\n role=\"group\"\n :aria-label=\"SIGNATURE_LABELS.sign\"\n class=\"ink-split-button ink-signature-menu\"\n data-ink-signature-menu\n v-bind=\"$attrs\"\n >\n <ToolbarButton\n ref=\"main\"\n class=\"ink-tool-button ink-signature-button\"\n data-ink-tool-button\n data-ink-signature-button\n data-tool=\"signature\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"mainAttrs\"\n >\n <slot :active=\"active\"><InkIcon :icon=\"Signature\" /></slot>\n </ToolbarButton>\n <ToolbarButton as-child>\n <PopoverTrigger as-child>\n <button\n type=\"button\"\n class=\"ink-menu-trigger ink-signature-menu-trigger\"\n data-ink-signature-menu-trigger\n :data-state=\"open ? 'open' : 'closed'\"\n v-bind=\"triggerAttrs\"\n >\n <InkIcon :icon=\"ChevronDown\" />\n </button>\n </PopoverTrigger>\n </ToolbarButton>\n <PopoverPortal>\n <PopoverContent\n class=\"ink-select-content ink-menu-content\"\n data-ink-select-content\n data-ink-menu=\"signature\"\n side=\"bottom\"\n align=\"start\"\n :side-offset=\"4\"\n :collision-padding=\"8\"\n v-bind=\"menuAttrs\"\n @open-auto-focus=\"onOpenAutoFocus\"\n @close-auto-focus=\"onCloseAutoFocus\"\n >\n <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 <InkSignatureDialog\n v-model:open=\"creating\"\n :fonts=\"props.fonts\"\n @close-auto-focus=\"onDialogCloseAutoFocus\"\n />\n </div>\n </PopoverAnchor>\n </PopoverRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqCA,IAAMgC,IAAQC,GAKRC,KAA6C,CAAC,GAE9C,EAAE,UAAM,eAAYC,EAAQ,GAC5B,EAAE,aAAS,mBAAeC,EAAiC,WAAW,GACtEC,IAAMC,EAAc,kBAAkB,GACtCC,KAAYC,QAAkBH,EAAI,WAAW,MAAM,WAAWH,EAAY,GAC1EO,IAAcD,QAAkBH,EAAI,WAAW,MAAM,aAAa,KAAA,CAAS,GAC3EK,IAAQC,QAAeC,GAAmBL,GAAU,OAAOM,GAAQ,KAAK,CAAC,GACzEC,IAASH,QAAeI,GAAK,UAAU,WAAW,GAClDC,IAAOC,EAAI,EAAK,GAChBC,IAAWD,EAAI,EAAK;EAE1B,GAAMD,IAAO,MAAW;GACtB,AAAIG,KAAQd,EAAI,WAAW,MAAM,iBAAiB;EACpD,CAAC;EACD,IAAMe,IAAOC,GAAqC,MAAM,GAGlDC,IAAWX,QACfD,EAAM,MAAM,MAAM,KAAK,MACrBa,EAAK,SAAS,SAAS,QAAQC,GAAiBD,EAAK,QAAQ,IAAI,IACnE,CACF,GAGIE,IAAa,IAEbC,IAAW;EAEf,SAASC,GAAiB,GAAwB;GAChD,AAAI,EAAE,QAAQ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pB3E,EAAAsC,CAAA,KADRxC,EAAA,GAAAW,EAOI,KAPJkB,GAOIb,EADCd,EAAAsC,CAAA,CAAW,GAAA,CAAA,KAAAoE,EAAA,IAAA,EAAA;;;;;;KAKtBxG,EAIEa,IAAA;MAHQ,MAAMgC,EAAA;MAAA,iBAAA,AAAAqC,EAAA,QAAA,MAAA,EAAQ,QAAAC;MACrB,OAAOxD,EAAM;MACb,kBAAkB4C"}
1
+ {"version":3,"file":"InkSignatureMenu.vue_vue_type_script_setup_true_lang.js","names":["$attrs","_unref","_openBlock","_createBlock","_withCtx","_createVNode","_createElementVNode","_mergeProps","_renderSlot","InkIcon","SignatureMenuPanel","InkSignatureDialog","_createCommentVNode","InkSignatureDialog_default","InkIcon_default","SignatureMenuPanel_default","_hoisted_1","_hoisted_2","InkSignatureMenu_vue_vue_type_script_setup_true_lang_default","props","__props","NO_TEMPLATES","useTool","registered","useRegisteredTool","useToolOptionsWhile","ctx","useInkContext","templates","useReadable","model","computed","signatureMenuModel","options","active","tool","open","ref","creating","isOpen","main","useTemplateRef","focusFirst","toDialog","onTriggerKeydown","panel","onOpenAutoFocus","menu","menuItems","focusInitialMenuItem","onCloseAutoFocus","onMain","setTool","choose","setOptions","id","create","onDialogCloseAutoFocus","mainAttrs","SIGNATURE_LABELS","triggerAttrs","menuAttrs","unref","openBlock","createBlock","PopoverRoot","_cache","$event","withCtx","createVNode","PopoverAnchor","createElementVNode","mergeProps","_ctx","ToolbarButton","renderSlot","Signature","PopoverTrigger","ChevronDown","PopoverPortal","PopoverContent","createCommentVNode"],"sources":["../../src/components/InkSignatureMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * A split button for the signature tool. The main part activates the tool with the chosen\n * signature, or opens the menu when none is chosen; the chevron opens the saved signatures as\n * previews, each with a remove button, and \"Create signature\", which opens\n * `InkSignatureDialog`. Choosing a signature switches to the tool with it.\n */\nimport {\n focusInitialMenuItem,\n menuItems,\n SIGNATURE_LABELS,\n signatureMenuModel,\n} from '@inkbar/core/dom'\nimport { ChevronDown, Signature } from '@inkbar/icons'\nimport {\n PopoverAnchor,\n PopoverContent,\n PopoverPortal,\n PopoverRoot,\n PopoverTrigger,\n ToolbarButton,\n} from 'reka-ui'\nimport { computed, ref, useTemplateRef, watch } from 'vue'\n\nimport { useRegisteredTool } from '../composables/useRegisteredTool'\nimport { useTool } from '../composables/useTool'\nimport { useToolOptionsWhile } from '../composables/useToolOptions'\nimport { useInkContext } from '../context'\nimport { useReadable } from '../use-readable'\n\nimport InkIcon from './InkIcon.vue'\nimport InkSignatureDialog from './InkSignatureDialog.vue'\nimport SignatureMenuPanel from './SignatureMenuPanel.vue'\n\nimport type { SignatureOptions, SignatureTemplate } from '@inkbar/core'\n\ndefineOptions({ inheritAttrs: false })\nconst props = defineProps<{\n /** The fonts the dialog's Type tab offers. Default: InkRoot's `signatureFonts`. */\n fonts?: readonly string[] | undefined\n}>()\n\nconst NO_TEMPLATES: readonly SignatureTemplate[] = []\n\nconst { tool, setTool } = useTool()\n// Nothing renders while no `signature` tool is registered.\nconst registered = useRegisteredTool('signature')\nconst { options, setOptions } = useToolOptionsWhile<SignatureOptions>(\n 'signature',\n registered\n)\nconst ctx = useInkContext('InkSignatureMenu')\nconst templates = useReadable(() => ctx.signatures.value.templates, NO_TEMPLATES)\nconst model = computed(() => signatureMenuModel(templates.value, options.value))\nconst active = computed(() => tool.value === 'signature')\nconst open = ref(false)\nconst creating = ref(false)\n// An old removal error is not news when the menu opens again.\nwatch(open, (isOpen) => {\n if (isOpen) ctx.signatures.value.clearRemoveError()\n})\nconst main = useTemplateRef<{ $el: HTMLElement }>('main')\n\n/** ArrowDown opens on the first item; a click opens on the checked one. */\nlet focusFirst = false\n/** Set while the menu closes for the dialog, which takes focus instead of the trigger. */\nlet toDialog = false\n\nfunction onTriggerKeydown(e: KeyboardEvent): void {\n if (e.key !== 'ArrowDown' || e.defaultPrevented || open.value) return\n e.preventDefault()\n focusFirst = true\n open.value = true\n}\n\n// Not a signature field's menu, which shares the attribute.\nconst panel = (): HTMLElement | null =>\n document.querySelector<HTMLElement>(\n '[data-ink-menu=\"signature\"]:not([data-ink-sign-field-menu]) [role=\"menu\"]'\n )\n\nfunction onOpenAutoFocus(e: Event): void {\n e.preventDefault()\n const menu = panel()\n if (menu) {\n if (focusFirst) menuItems(menu)[0]?.focus({ preventScroll: true })\n else focusInitialMenuItem(menu)\n }\n focusFirst = false\n}\n\nfunction onCloseAutoFocus(e: Event): void {\n if (toDialog) e.preventDefault()\n toDialog = false\n}\n\nfunction onMain(): void {\n if (model.value.selected) setTool('signature')\n else open.value = true\n}\n\nfunction choose(id: string): void {\n setOptions({ templateId: id })\n setTool('signature')\n open.value = false\n}\n\nfunction create(): void {\n toDialog = true\n open.value = false\n creating.value = true\n}\n\nfunction onDialogCloseAutoFocus(e: Event): void {\n e.preventDefault()\n main.value?.$el.focus({ preventScroll: true })\n}\n\n// Reka's typed props stop at its own; ARIA and listeners go through bound objects.\nconst mainAttrs = computed(() => ({\n 'aria-pressed': String(active.value),\n 'aria-label': SIGNATURE_LABELS.sign,\n title: SIGNATURE_LABELS.sign,\n onClick: onMain,\n}))\nconst triggerAttrs = {\n 'aria-label': SIGNATURE_LABELS.trigger,\n title: SIGNATURE_LABELS.trigger,\n 'aria-haspopup': 'menu' as const,\n onKeydown: onTriggerKeydown,\n}\nconst menuAttrs = { 'aria-label': SIGNATURE_LABELS.menu }\n</script>\n\n<template>\n <PopoverRoot v-if=\"registered\" v-model:open=\"open\">\n <PopoverAnchor as-child>\n <div\n role=\"group\"\n :aria-label=\"SIGNATURE_LABELS.sign\"\n class=\"ink-split-button ink-signature-menu\"\n data-ink-signature-menu\n v-bind=\"$attrs\"\n >\n <ToolbarButton\n ref=\"main\"\n class=\"ink-tool-button ink-signature-button\"\n data-ink-tool-button\n data-ink-signature-button\n data-tool=\"signature\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"mainAttrs\"\n >\n <slot :active=\"active\"><InkIcon :icon=\"Signature\" /></slot>\n </ToolbarButton>\n <ToolbarButton as-child>\n <PopoverTrigger as-child>\n <button\n type=\"button\"\n class=\"ink-menu-trigger ink-signature-menu-trigger\"\n data-ink-signature-menu-trigger\n :data-state=\"open ? 'open' : 'closed'\"\n v-bind=\"triggerAttrs\"\n >\n <InkIcon :icon=\"ChevronDown\" />\n </button>\n </PopoverTrigger>\n </ToolbarButton>\n <PopoverPortal>\n <PopoverContent\n class=\"ink-select-content ink-menu-content\"\n data-ink-select-content\n data-ink-menu=\"signature\"\n side=\"bottom\"\n align=\"start\"\n :side-offset=\"4\"\n :collision-padding=\"8\"\n v-bind=\"menuAttrs\"\n @open-auto-focus=\"onOpenAutoFocus\"\n @close-auto-focus=\"onCloseAutoFocus\"\n >\n <SignatureMenuPanel\n :items=\"model.items\"\n @choose=\"choose($event.id)\"\n @create=\"create\"\n />\n </PopoverContent>\n </PopoverPortal>\n <InkSignatureDialog\n v-model:open=\"creating\"\n :fonts=\"props.fonts\"\n @close-auto-focus=\"onDialogCloseAutoFocus\"\n />\n </div>\n </PopoverAnchor>\n </PopoverRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;EAqCA,IAAMmB,IAAQC,GAKRC,IAA6C,CAAC,GAE9C,EAAE,SAAM,eAAYC,EAAQ,GAE5BC,IAAaC,EAAkB,WAAW,GAC1C,EAAE,aAAS,kBAAeC,EAC9B,aACAF,CACF,GACMG,IAAMC,EAAc,kBAAkB,GACtCC,IAAYC,QAAkBH,EAAI,WAAW,MAAM,WAAWL,CAAY,GAC1ES,IAAQC,QAAeC,EAAmBJ,EAAU,OAAOK,GAAQ,KAAK,CAAC,GACzEC,IAASH,QAAeI,EAAK,UAAU,WAAW,GAClDC,IAAOC,EAAI,EAAK,GAChBC,IAAWD,EAAI,EAAK;EAE1B,EAAMD,IAAO,MAAW;GACtB,AAAIG,KAAQb,EAAI,WAAW,MAAM,iBAAiB;EACpD,CAAC;EACD,IAAMc,IAAOC,EAAqC,MAAM,GAGpDC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AA,GAjBjBzE,EAiBiB;OAhBf,OAAM;OACN,2BAAA;OACA,iBAAc;OACd,MAAK;OACL,OAAM;OACL,eAAa;OACb,qBAAmB;MACZ,GAAAsD,IAAS;OACC;OACC;;OAEnB,SAAAzD,QAIE,CAJFC,EAIEK,GAAA;QAHC,OAAOoB,EAAA,MAAM;QACb,UAAM,AAAAoC,EAAA,QAAA,MAAEb,GAAOc,EAAO,EAAE;QACxB,UAAQX;;;;;;KAIfnD,EAIEM,GAAA;MAHQ,MAAM2B,EAAA;MAAA,iBAAA,AAAA4B,EAAA,QAAA,MAAA,EAAQ,QAAAC;MACrB,OAAOhD,EAAM;MACb,kBAAkBsC"}
@@ -1 +1 @@
1
- {"version":3,"file":"InkToolButton.js","names":["_sfc_main","InkToolButton_vue_vue_type_script_setup_true_lang_default","InkToolButton_default"],"sources":["../../src/components/InkToolButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { TOOL_LABELS } from '@inkbar/core/dom'\nimport {\n Highlighter,\n MessageSquare,\n PenLine,\n PenTool,\n Signature,\n Square,\n SquareDashedMousePointer,\n TextCursor,\n Type,\n} from '@inkbar/icons'\nimport { ToolbarButton } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport { useTool } from '../composables/useTool'\nimport { useInkContext } from '../context'\n\nimport InkIcon from './InkIcon.vue'\n\nimport type { ToolId } from '@inkbar/core/dom'\nimport type { IconNode } from '@inkbar/icons'\n\nconst ICONS: Readonly<Partial<Record<ToolId, IconNode>>> = {\n 'select-text': TextCursor,\n select: SquareDashedMousePointer,\n highlight: Highlighter,\n 'redact-area': Square,\n sketch: PenTool,\n draw: PenLine,\n note: MessageSquare,\n freetext: Type,\n signature: Signature,\n}\n\nconst props = withDefaults(\n defineProps<{ tool: ToolId; label?: string | undefined; asChild?: boolean }>(),\n { label: undefined, asChild: false }\n)\n\nconst ctx = useInkContext('InkToolButton')\nconst { tool: current, setTool } = useTool()\nconst active = computed(() => current.value === props.tool)\n/** A host or plugin tool by this id, for the name and icon core has none for. */\nconst own = computed(() =>\n [...(ctx.hostTools.value ?? []), ...(ctx.pluginHost.value?.tools ?? [])].find(\n (t) => t.id === props.tool\n )\n)\n// `label` and the slot win; then core's name and icon; then the tool's own.\nconst name = computed(\n () => props.label ?? TOOL_LABELS[props.tool] ?? own.value?.label ?? props.tool\n)\nconst icon = computed(() => ICONS[props.tool] ?? own.value?.icon)\n// Reka's typed props stop at its own; ARIA and listeners go through a bound object.\nconst attrs = computed(() => ({\n 'aria-pressed': String(active.value),\n 'aria-label': name.value,\n title: name.value,\n onClick: () => setTool(props.tool),\n}))\n</script>\n\n<template>\n <ToolbarButton\n :as-child=\"asChild\"\n class=\"ink-tool-button\"\n data-ink-tool-button\n :data-tool=\"tool\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"attrs\"\n >\n <slot :active=\"active\" :label=\"name\"><InkIcon v-if=\"icon\" :icon=\"icon\" /></slot>\n </ToolbarButton>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"InkToolButton.js","names":["_sfc_main","InkToolButton_vue_vue_type_script_setup_true_lang_default","InkToolButton_default"],"sources":["../../src/components/InkToolButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { TOOL_LABELS, withHostTools } from '@inkbar/core/dom'\nimport { SquareDashedMousePointer, TextCursor } from '@inkbar/icons'\nimport { ToolbarButton } from 'reka-ui'\nimport { computed, mergeProps, useAttrs } from 'vue'\n\nimport { useRegisteredTool } from '../composables/useRegisteredTool'\nimport { useTool } from '../composables/useTool'\nimport { useInkContext } from '../context'\n\nimport InkIcon from './InkIcon.vue'\n\nimport type { ToolId } from '@inkbar/core/dom'\nimport type { IconNode } from '@inkbar/icons'\n\nconst ICONS: Readonly<Partial<Record<ToolId, IconNode>>> = {\n 'select-text': TextCursor,\n select: SquareDashedMousePointer,\n}\n\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{ tool: ToolId; label?: string | undefined; asChild?: boolean }>(),\n { label: undefined, asChild: false }\n)\n\nconst ctx = useInkContext('InkToolButton')\nconst { tool: current, setTool } = useTool()\nconst active = computed(() => current.value === props.tool)\nconst registered = useRegisteredTool(() => props.tool)\n/** The registered tool by this id, for the name and icon core has none for. */\nconst own = computed(() =>\n withHostTools([\n ...(ctx.hostTools.value ?? []),\n ...(ctx.pluginHost.value?.tools ?? []),\n ]).find((t) => t.id === props.tool)\n)\n// `label` and the slot win; then core's name and icon; then the tool's own.\nconst name = computed(\n () => props.label ?? TOOL_LABELS[props.tool] ?? own.value?.label ?? props.tool\n)\nconst icon = computed(() => ICONS[props.tool] ?? own.value?.icon)\n// Reka's typed props stop at its own; ARIA and listeners go through a bound object. A tool\n// nobody registered leaves the button disabled, hidden from assistive tech and unnamed.\nconst hostAttrs = useAttrs()\n// A function, not a computed: `useAttrs()` is not reactive, so the render reads it afresh.\nconst bound = () =>\n registered.value\n ? mergeProps(\n {\n 'aria-pressed': String(active.value),\n 'aria-label': name.value,\n title: name.value,\n onClick: () => setTool(props.tool),\n },\n hostAttrs\n )\n : {\n ...hostAttrs,\n 'aria-hidden': 'true' as const,\n disabled: true,\n 'aria-pressed': undefined,\n 'aria-label': undefined,\n title: undefined,\n onClick: undefined,\n }\n</script>\n\n<template>\n <ToolbarButton\n :as-child=\"asChild\"\n class=\"ink-tool-button\"\n data-ink-tool-button\n :data-tool=\"tool\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"bound()\"\n >\n <template v-if=\"registered\">\n <slot :active=\"active\" :label=\"name\"><InkIcon v-if=\"icon\" :icon=\"icon\" /></slot>\n </template>\n </ToolbarButton>\n</template>\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"InkToolButton.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkToolButton.vue"],"names":[],"mappings":"AAkGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAgB9C,KAAK,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK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