@inkbar/vue 0.6.0 → 0.8.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 (69) hide show
  1. package/README.md +12 -1
  2. package/dist/components/InkFindBar.js +7 -0
  3. package/dist/components/InkFindBar.js.map +1 -0
  4. package/dist/components/InkFindBar.vue.d.ts +4 -0
  5. package/dist/components/InkFindBar.vue.d.ts.map +1 -0
  6. package/dist/components/InkFindBar.vue_vue_type_script_setup_true_lang.js +133 -0
  7. package/dist/components/InkFindBar.vue_vue_type_script_setup_true_lang.js.map +1 -0
  8. package/dist/components/InkFormAlert.js +7 -0
  9. package/dist/components/InkFormAlert.js.map +1 -0
  10. package/dist/components/InkFormAlert.vue.d.ts +16 -0
  11. package/dist/components/InkFormAlert.vue.d.ts.map +1 -0
  12. package/dist/components/InkFormAlert.vue_vue_type_script_setup_true_lang.js +90 -0
  13. package/dist/components/InkFormAlert.vue_vue_type_script_setup_true_lang.js.map +1 -0
  14. package/dist/components/InkRoot.js.map +1 -1
  15. package/dist/components/InkRoot.vue.d.ts +15 -1
  16. package/dist/components/InkRoot.vue.d.ts.map +1 -1
  17. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js +179 -132
  18. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js.map +1 -1
  19. package/dist/components/InkSearchButton.js +7 -0
  20. package/dist/components/InkSearchButton.js.map +1 -0
  21. package/dist/components/InkSearchButton.vue.d.ts +19 -0
  22. package/dist/components/InkSearchButton.vue.d.ts.map +1 -0
  23. package/dist/components/InkSearchButton.vue_vue_type_script_setup_true_lang.js +43 -0
  24. package/dist/components/InkSearchButton.vue_vue_type_script_setup_true_lang.js.map +1 -0
  25. package/dist/components/InkSignFieldPopover.js +7 -0
  26. package/dist/components/InkSignFieldPopover.js.map +1 -0
  27. package/dist/components/InkSignFieldPopover.vue.d.ts +13 -0
  28. package/dist/components/InkSignFieldPopover.vue.d.ts.map +1 -0
  29. package/dist/components/InkSignFieldPopover.vue_vue_type_script_setup_true_lang.js +116 -0
  30. package/dist/components/InkSignFieldPopover.vue_vue_type_script_setup_true_lang.js.map +1 -0
  31. package/dist/components/InkSignatureDialog.js.map +1 -1
  32. package/dist/components/InkSignatureDialog.vue.d.ts +9 -1
  33. package/dist/components/InkSignatureDialog.vue.d.ts.map +1 -1
  34. package/dist/components/InkSignatureDialog.vue_vue_type_script_setup_true_lang.js +9 -2
  35. package/dist/components/InkSignatureDialog.vue_vue_type_script_setup_true_lang.js.map +1 -1
  36. package/dist/components/InkSignatureMenu.js.map +1 -1
  37. package/dist/components/InkSignatureMenu.vue.d.ts.map +1 -1
  38. package/dist/components/InkSignatureMenu.vue_vue_type_script_setup_true_lang.js +72 -159
  39. package/dist/components/InkSignatureMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  40. package/dist/components/InkViewport.js.map +1 -1
  41. package/dist/components/InkViewport.vue.d.ts.map +1 -1
  42. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js +117 -85
  43. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js.map +1 -1
  44. package/dist/components/SignatureForm.js.map +1 -1
  45. package/dist/components/SignatureForm.vue.d.ts +7 -3
  46. package/dist/components/SignatureForm.vue.d.ts.map +1 -1
  47. package/dist/components/SignatureForm.vue_vue_type_script_setup_true_lang.js +27 -21
  48. package/dist/components/SignatureForm.vue_vue_type_script_setup_true_lang.js.map +1 -1
  49. package/dist/components/SignatureMenuPanel.js +7 -0
  50. package/dist/components/SignatureMenuPanel.js.map +1 -0
  51. package/dist/components/SignatureMenuPanel.vue.d.ts +15 -0
  52. package/dist/components/SignatureMenuPanel.vue.d.ts.map +1 -0
  53. package/dist/components/SignatureMenuPanel.vue_vue_type_script_setup_true_lang.js +116 -0
  54. package/dist/components/SignatureMenuPanel.vue_vue_type_script_setup_true_lang.js.map +1 -0
  55. package/dist/composables/useForm.d.ts +18 -0
  56. package/dist/composables/useForm.d.ts.map +1 -0
  57. package/dist/composables/useForm.js +17 -0
  58. package/dist/composables/useForm.js.map +1 -0
  59. package/dist/composables/useSearch.d.ts +12 -0
  60. package/dist/composables/useSearch.d.ts.map +1 -0
  61. package/dist/composables/useSearch.js +27 -0
  62. package/dist/composables/useSearch.js.map +1 -0
  63. package/dist/context.d.ts +14 -2
  64. package/dist/context.d.ts.map +1 -1
  65. package/dist/context.js.map +1 -1
  66. package/dist/index.d.ts +5 -0
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +31 -27
  69. package/package.json +6 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSignFieldPopover.js","names":["_sfc_main","InkSignFieldPopover_vue_vue_type_script_setup_true_lang_default","InkSignFieldPopover_default"],"sources":["../../src/components/InkSignFieldPopover.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The signature menu for a signature field, opened from the field's \"Sign\" button and anchored\n * to its box. It lists the saved signatures and \"Create signature\", as `InkSignatureMenu`\n * does. Picking one signs the field with it (`signField`); a signature made in\n * `InkSignatureDialog` signs the field once saved, without picking the signature tool. Focus\n * returns to the field. InkViewport mounts it, one per document; hosts compose nothing.\n */\nimport { InkError, signField, type SignatureTemplate } from '@inkbar/core'\nimport {\n focusInitialMenuItem,\n SIGNATURE_LABELS,\n signatureMenuModel,\n watchDetached,\n} from '@inkbar/core/dom'\nimport { PopoverContent, PopoverPortal, PopoverRoot } from 'reka-ui'\nimport { computed, onBeforeUnmount, shallowRef, watch } from 'vue'\n\nimport { useInkContext } from '../context'\nimport { useReadable } from '../use-readable'\n\nimport InkSignatureDialog from './InkSignatureDialog.vue'\nimport SignatureMenuPanel from './SignatureMenuPanel.vue'\n\nimport type { InkDocument } from '@inkbar/core'\nimport type { SignFieldRequest } from '@inkbar/core/dom'\n\nconst props = defineProps<{\n /** The field to sign; `null` while the menu is closed. */\n request: SignFieldRequest | null\n}>()\nconst emit = defineEmits<{ close: [] }>()\n\nconst NO_TEMPLATES: readonly SignatureTemplate[] = []\n\nconst ctx = useInkContext('InkSignFieldPopover')\nconst templates = useReadable(() => ctx.signatures.value.templates, NO_TEMPLATES)\n// No signature is \"chosen\" here: each signing picks its own.\nconst model = computed(() => signatureMenuModel(templates.value, {}))\nconst open = computed(() => props.request !== null)\n/** The field the dialog signs once its signature is saved, and the document it is in. */\nconst creatingFor = shallowRef<{ req: SignFieldRequest; doc: InkDocument } | null>(null)\nconst creating = computed({\n get: () => creatingFor.value !== null,\n set: (next) => {\n if (!next) creatingFor.value = null\n },\n})\n/**\n * The request the menu was last open for, kept to return focus once it closes. A request that\n * replaces the open one takes over, so focus returns to the field asked for last.\n */\nlet last: SignFieldRequest | null = null\n/** Set while the menu closes for the dialog, which takes focus instead of the field. */\nlet toDialog = false\n/** Cleared on unmount, so a dialog save that settles after the document went signs nothing. */\nlet alive = true\nonBeforeUnmount(() => {\n alive = false\n})\n\n// The field's box went (its page unmounted, its layer rebuilt): the menu has nothing to stand\n// by.\nwatch(\n () => props.request,\n (req, _, onCleanup) => {\n if (!req) return\n last = req\n onCleanup(watchDetached(req.anchor, () => emit('close')))\n },\n { immediate: true }\n)\n\nconst control = (req: SignFieldRequest | null): HTMLElement | null =>\n req?.anchor.querySelector<HTMLElement>('button.ink-form-control') ?? null\n\n/** Focus goes back to the field's button, or to the scroll element once the field's box has gone. */\nfunction returnFocus(req: SignFieldRequest | null): void {\n const c = control(req)\n ;(c?.isConnected ? c : ctx.viewportEl.value)?.focus({ preventScroll: true })\n}\n\n/** Signs the request's field with `t`; a refusal (signed, read-only by now) goes to `error`. */\nfunction sign(req: SignFieldRequest, doc: InkDocument, t: SignatureTemplate): void {\n // The document the request came from is still the open one.\n if (!alive || ctx.document.value !== doc) return\n try {\n signField(doc, req.field, req.widget, t)\n } catch (e) {\n if (!(e instanceof InkError)) throw e\n ctx.reportError(e)\n }\n}\n\nfunction choose(t: SignatureTemplate): void {\n const req = props.request\n const doc = ctx.document.value\n emit('close')\n if (req && doc) sign(req, doc, t)\n}\n\nfunction create(): void {\n const req = props.request\n const doc = ctx.document.value\n if (!req || !doc) return\n toDialog = true\n creatingFor.value = { req, doc }\n emit('close')\n}\n\nfunction onSaved(t: SignatureTemplate): void {\n const c = creatingFor.value\n if (c) sign(c.req, c.doc, t)\n}\n\n/**\n * A press on this field's own button toggles the menu through the engine; it must not also\n * close it here first, or the click would open it again.\n */\nfunction onInteractOutside(e: CustomEvent<{ originalEvent: Event }>): void {\n const target = e.detail.originalEvent.target\n if (target instanceof Node && props.request?.anchor.contains(target)) e.preventDefault()\n}\n\nfunction onOpenAutoFocus(e: Event): void {\n e.preventDefault()\n // An old removal error is not news when the menu opens again.\n ctx.signatures.value.clearRemoveError()\n const menu = (e.target as HTMLElement | null)?.querySelector<HTMLElement>(\n '[role=\"menu\"]'\n )\n if (menu) focusInitialMenuItem(menu)\n}\n\nfunction onCloseAutoFocus(e: Event): void {\n e.preventDefault()\n if (!toDialog) returnFocus(last)\n toDialog = false\n}\n\nfunction onDialogCloseAutoFocus(e: Event): void {\n e.preventDefault()\n returnFocus(last)\n}\n\nfunction onOpenChange(next: boolean): void {\n if (!next) emit('close')\n}\n\n// Reka's typed props stop at its own; ARIA goes through a bound object.\nconst menuAttrs = { 'aria-label': SIGNATURE_LABELS.menu }\n</script>\n\n<template>\n <PopoverRoot :open=\"open\" @update:open=\"onOpenChange\">\n <PopoverPortal>\n <PopoverContent\n v-if=\"props.request\"\n :reference=\"props.request.anchor\"\n class=\"ink-select-content ink-menu-content\"\n data-ink-select-content\n data-ink-menu=\"signature\"\n :data-ink-sign-field-menu=\"props.request.field\"\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 @interact-outside=\"onInteractOutside\"\n >\n <SignatureMenuPanel :items=\"model.items\" @choose=\"choose\" @create=\"create\" />\n </PopoverContent>\n </PopoverPortal>\n </PopoverRoot>\n <InkSignatureDialog\n v-model:open=\"creating\"\n :select=\"false\"\n @save=\"onSaved\"\n @close-auto-focus=\"onDialogCloseAutoFocus\"\n />\n</template>\n"],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { SignFieldRequest } from '@inkbar/core/dom';
2
+ type __VLS_Props = {
3
+ /** The field to sign; `null` while the menu is closed. */
4
+ request: SignFieldRequest | null;
5
+ };
6
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
7
+ close: () => any;
8
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
9
+ onClose?: () => any;
10
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
11
+ declare const _default: typeof __VLS_export;
12
+ export default _default;
13
+ //# sourceMappingURL=InkSignFieldPopover.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSignFieldPopover.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkSignFieldPopover.vue"],"names":[],"mappings":"AAiNA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGxD,KAAK,WAAW,GAAG;IACjB,0DAA0D;IAC1D,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAA;CACjC,CAAC;AA4RF,QAAA,MAAM,YAAY;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -0,0 +1,116 @@
1
+ import { useInkContext as e } from "../context.js";
2
+ import { useReadable as t } from "../use-readable.js";
3
+ import n from "./InkSignatureDialog.js";
4
+ import r from "./SignatureMenuPanel.js";
5
+ import { Fragment as i, computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createVNode as l, defineComponent as u, mergeProps as d, onBeforeUnmount as f, openBlock as p, shallowRef as m, unref as h, watch as g, withCtx as _ } from "vue";
6
+ import { InkError as v, signField as y } from "@inkbar/core";
7
+ import { SIGNATURE_LABELS as b, focusInitialMenuItem as x, signatureMenuModel as S, watchDetached as C } from "@inkbar/core/dom";
8
+ import { PopoverContent as w, PopoverPortal as T, PopoverRoot as E } from "reka-ui";
9
+ //#region src/components/InkSignFieldPopover.vue?vue&type=script&setup=true&lang.ts
10
+ var D = /*@__PURE__*/ u({
11
+ __name: "InkSignFieldPopover",
12
+ props: { request: {} },
13
+ emits: ["close"],
14
+ setup(u, { emit: D }) {
15
+ let O = u, k = D, A = [], j = e("InkSignFieldPopover"), M = t(() => j.signatures.value.templates, A), N = a(() => S(M.value, {})), P = a(() => O.request !== null), F = m(null), I = a({
16
+ get: () => F.value !== null,
17
+ set: (e) => {
18
+ e || (F.value = null);
19
+ }
20
+ }), L = null, R = !1, z = !0;
21
+ f(() => {
22
+ z = !1;
23
+ }), g(() => O.request, (e, t, n) => {
24
+ e && (L = e, n(C(e.anchor, () => k("close"))));
25
+ }, { immediate: !0 });
26
+ let B = (e) => e?.anchor.querySelector("button.ink-form-control") ?? null;
27
+ function V(e) {
28
+ let t = B(e);
29
+ (t?.isConnected ? t : j.viewportEl.value)?.focus({ preventScroll: !0 });
30
+ }
31
+ function H(e, t, n) {
32
+ if (z && j.document.value === t) try {
33
+ y(t, e.field, e.widget, n);
34
+ } catch (e) {
35
+ if (!(e instanceof v)) throw e;
36
+ j.reportError(e);
37
+ }
38
+ }
39
+ function U(e) {
40
+ let t = O.request, n = j.document.value;
41
+ k("close"), t && n && H(t, n, e);
42
+ }
43
+ function W() {
44
+ let e = O.request, t = j.document.value;
45
+ e && t && (R = !0, F.value = {
46
+ req: e,
47
+ doc: t
48
+ }, k("close"));
49
+ }
50
+ function G(e) {
51
+ let t = F.value;
52
+ t && H(t.req, t.doc, e);
53
+ }
54
+ function K(e) {
55
+ let t = e.detail.originalEvent.target;
56
+ t instanceof Node && O.request?.anchor.contains(t) && e.preventDefault();
57
+ }
58
+ function q(e) {
59
+ e.preventDefault(), j.signatures.value.clearRemoveError();
60
+ let t = e.target?.querySelector("[role=\"menu\"]");
61
+ t && x(t);
62
+ }
63
+ function J(e) {
64
+ e.preventDefault(), R || V(L), R = !1;
65
+ }
66
+ function Y(e) {
67
+ e.preventDefault(), V(L);
68
+ }
69
+ function X(e) {
70
+ e || k("close");
71
+ }
72
+ let Z = { "aria-label": b.menu };
73
+ return (e, t) => (p(), c(i, null, [l(h(E), {
74
+ open: P.value,
75
+ "onUpdate:open": X
76
+ }, {
77
+ default: _(() => [l(h(T), null, {
78
+ default: _(() => [O.request ? (p(), o(h(w), d({
79
+ key: 0,
80
+ reference: O.request.anchor,
81
+ class: "ink-select-content ink-menu-content",
82
+ "data-ink-select-content": "",
83
+ "data-ink-menu": "signature",
84
+ "data-ink-sign-field-menu": O.request.field,
85
+ side: "bottom",
86
+ align: "start",
87
+ "side-offset": 4,
88
+ "collision-padding": 8
89
+ }, Z, {
90
+ onOpenAutoFocus: q,
91
+ onCloseAutoFocus: J,
92
+ onInteractOutside: K
93
+ }), {
94
+ default: _(() => [l(r, {
95
+ items: N.value.items,
96
+ onChoose: U,
97
+ onCreate: W
98
+ }, null, 8, ["items"])]),
99
+ _: 1
100
+ }, 16, ["reference", "data-ink-sign-field-menu"])) : s("", !0)]),
101
+ _: 1
102
+ })]),
103
+ _: 1
104
+ }, 8, ["open"]), l(n, {
105
+ open: I.value,
106
+ "onUpdate:open": t[0] ||= (e) => I.value = e,
107
+ select: !1,
108
+ onSave: G,
109
+ onCloseAutoFocus: Y
110
+ }, null, 8, ["open"])], 64));
111
+ }
112
+ });
113
+ //#endregion
114
+ export { D as default };
115
+
116
+ //# sourceMappingURL=InkSignFieldPopover.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSignFieldPopover.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_Fragment","_createVNode","_unref","_withCtx","_createBlock","_mergeProps","SignatureMenuPanel","_createCommentVNode","InkSignatureDialog","InkSignatureDialog_default","SignatureMenuPanel_default","InkSignFieldPopover_vue_vue_type_script_setup_true_lang_default","__emit","props","__props","emit","NO_TEMPLATES","ctx","useInkContext","templates","useReadable","model","computed","signatureMenuModel","open","creatingFor","shallowRef","creating","next","last","toDialog","alive","onBeforeUnmount","watch","req","onCleanup","watchDetached","control","returnFocus","c","sign","doc","t","InkError","choose","create","onSaved","onInteractOutside","target","onOpenAutoFocus","menu","focusInitialMenuItem","onCloseAutoFocus","onDialogCloseAutoFocus","onOpenChange","menuAttrs","SIGNATURE_LABELS","openBlock","createElementBlock","Fragment","createVNode","unref","PopoverRoot","withCtx","PopoverPortal","createBlock","PopoverContent","mergeProps","createCommentVNode","_cache","$event"],"sources":["../../src/components/InkSignFieldPopover.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The signature menu for a signature field, opened from the field's \"Sign\" button and anchored\n * to its box. It lists the saved signatures and \"Create signature\", as `InkSignatureMenu`\n * does. Picking one signs the field with it (`signField`); a signature made in\n * `InkSignatureDialog` signs the field once saved, without picking the signature tool. Focus\n * returns to the field. InkViewport mounts it, one per document; hosts compose nothing.\n */\nimport { InkError, signField, type SignatureTemplate } from '@inkbar/core'\nimport {\n focusInitialMenuItem,\n SIGNATURE_LABELS,\n signatureMenuModel,\n watchDetached,\n} from '@inkbar/core/dom'\nimport { PopoverContent, PopoverPortal, PopoverRoot } from 'reka-ui'\nimport { computed, onBeforeUnmount, shallowRef, watch } from 'vue'\n\nimport { useInkContext } from '../context'\nimport { useReadable } from '../use-readable'\n\nimport InkSignatureDialog from './InkSignatureDialog.vue'\nimport SignatureMenuPanel from './SignatureMenuPanel.vue'\n\nimport type { InkDocument } from '@inkbar/core'\nimport type { SignFieldRequest } from '@inkbar/core/dom'\n\nconst props = defineProps<{\n /** The field to sign; `null` while the menu is closed. */\n request: SignFieldRequest | null\n}>()\nconst emit = defineEmits<{ close: [] }>()\n\nconst NO_TEMPLATES: readonly SignatureTemplate[] = []\n\nconst ctx = useInkContext('InkSignFieldPopover')\nconst templates = useReadable(() => ctx.signatures.value.templates, NO_TEMPLATES)\n// No signature is \"chosen\" here: each signing picks its own.\nconst model = computed(() => signatureMenuModel(templates.value, {}))\nconst open = computed(() => props.request !== null)\n/** The field the dialog signs once its signature is saved, and the document it is in. */\nconst creatingFor = shallowRef<{ req: SignFieldRequest; doc: InkDocument } | null>(null)\nconst creating = computed({\n get: () => creatingFor.value !== null,\n set: (next) => {\n if (!next) creatingFor.value = null\n },\n})\n/**\n * The request the menu was last open for, kept to return focus once it closes. A request that\n * replaces the open one takes over, so focus returns to the field asked for last.\n */\nlet last: SignFieldRequest | null = null\n/** Set while the menu closes for the dialog, which takes focus instead of the field. */\nlet toDialog = false\n/** Cleared on unmount, so a dialog save that settles after the document went signs nothing. */\nlet alive = true\nonBeforeUnmount(() => {\n alive = false\n})\n\n// The field's box went (its page unmounted, its layer rebuilt): the menu has nothing to stand\n// by.\nwatch(\n () => props.request,\n (req, _, onCleanup) => {\n if (!req) return\n last = req\n onCleanup(watchDetached(req.anchor, () => emit('close')))\n },\n { immediate: true }\n)\n\nconst control = (req: SignFieldRequest | null): HTMLElement | null =>\n req?.anchor.querySelector<HTMLElement>('button.ink-form-control') ?? null\n\n/** Focus goes back to the field's button, or to the scroll element once the field's box has gone. */\nfunction returnFocus(req: SignFieldRequest | null): void {\n const c = control(req)\n ;(c?.isConnected ? c : ctx.viewportEl.value)?.focus({ preventScroll: true })\n}\n\n/** Signs the request's field with `t`; a refusal (signed, read-only by now) goes to `error`. */\nfunction sign(req: SignFieldRequest, doc: InkDocument, t: SignatureTemplate): void {\n // The document the request came from is still the open one.\n if (!alive || ctx.document.value !== doc) return\n try {\n signField(doc, req.field, req.widget, t)\n } catch (e) {\n if (!(e instanceof InkError)) throw e\n ctx.reportError(e)\n }\n}\n\nfunction choose(t: SignatureTemplate): void {\n const req = props.request\n const doc = ctx.document.value\n emit('close')\n if (req && doc) sign(req, doc, t)\n}\n\nfunction create(): void {\n const req = props.request\n const doc = ctx.document.value\n if (!req || !doc) return\n toDialog = true\n creatingFor.value = { req, doc }\n emit('close')\n}\n\nfunction onSaved(t: SignatureTemplate): void {\n const c = creatingFor.value\n if (c) sign(c.req, c.doc, t)\n}\n\n/**\n * A press on this field's own button toggles the menu through the engine; it must not also\n * close it here first, or the click would open it again.\n */\nfunction onInteractOutside(e: CustomEvent<{ originalEvent: Event }>): void {\n const target = e.detail.originalEvent.target\n if (target instanceof Node && props.request?.anchor.contains(target)) e.preventDefault()\n}\n\nfunction onOpenAutoFocus(e: Event): void {\n e.preventDefault()\n // An old removal error is not news when the menu opens again.\n ctx.signatures.value.clearRemoveError()\n const menu = (e.target as HTMLElement | null)?.querySelector<HTMLElement>(\n '[role=\"menu\"]'\n )\n if (menu) focusInitialMenuItem(menu)\n}\n\nfunction onCloseAutoFocus(e: Event): void {\n e.preventDefault()\n if (!toDialog) returnFocus(last)\n toDialog = false\n}\n\nfunction onDialogCloseAutoFocus(e: Event): void {\n e.preventDefault()\n returnFocus(last)\n}\n\nfunction onOpenChange(next: boolean): void {\n if (!next) emit('close')\n}\n\n// Reka's typed props stop at its own; ARIA goes through a bound object.\nconst menuAttrs = { 'aria-label': SIGNATURE_LABELS.menu }\n</script>\n\n<template>\n <PopoverRoot :open=\"open\" @update:open=\"onOpenChange\">\n <PopoverPortal>\n <PopoverContent\n v-if=\"props.request\"\n :reference=\"props.request.anchor\"\n class=\"ink-select-content ink-menu-content\"\n data-ink-select-content\n data-ink-menu=\"signature\"\n :data-ink-sign-field-menu=\"props.request.field\"\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 @interact-outside=\"onInteractOutside\"\n >\n <SignatureMenuPanel :items=\"model.items\" @choose=\"choose\" @create=\"create\" />\n </PopoverContent>\n </PopoverPortal>\n </PopoverRoot>\n <InkSignatureDialog\n v-model:open=\"creating\"\n :select=\"false\"\n @save=\"onSaved\"\n @close-auto-focus=\"onDialogCloseAutoFocus\"\n />\n</template>\n"],"mappings":";;;;;;;;;;;;;;EA2BA,IAAMe,IAAQC,GAIRC,IAAOH,GAEPI,IAA6C,CAAC,GAE9CC,IAAMC,EAAc,qBAAqB,GACzCC,IAAYC,QAAkBH,EAAI,WAAW,MAAM,WAAWD,CAAY,GAE1EK,IAAQC,QAAeC,EAAmBJ,EAAU,OAAO,CAAC,CAAC,CAAC,GAC9DK,IAAOF,QAAeT,EAAM,YAAY,IAAI,GAE5CY,IAAcC,EAA+D,IAAI,GACjFC,IAAWL,EAAS;GACxB,WAAWG,EAAY,UAAU;GACjC,MAAM,MAAS;IACb,AAAKG,MAAM,EAAY,QAAQ;GACjC;EACF,CAAC,GAKGC,IAAgC,MAEhCC,IAAW,IAEXC,IAAQ;EAOZ,AANAC,QAAsB;GACpB,IAAQ;EACV,CAAC,GAIDC,QACQpB,EAAM,UACX,GAAK,GAAG,MAAc;GACrB,AAAKqB,MACL,IAAOA,GACPC,EAAUC,EAAcF,EAAI,cAAcnB,EAAK,OAAO,CAAC,CAAC;EAC1D,GACA,EAAE,WAAW,GAAK,CACpB;EAEA,IAAMsB,KAAW,MACfH,GAAK,OAAO,cAA2B,yBAAyB,KAAK;EAGvE,SAASI,EAAY,GAAoC;GACvD,IAAMC,IAAIF,EAAQH,CAAG;GACpB,CAACK,GAAG,cAAcA,IAAItB,EAAI,WAAW,MAAA,EAAQ,MAAM,EAAE,eAAe,GAAK,CAAC;EAC7E;EAGA,SAASuB,EAAK,GAAuB,GAAkB,GAA4B;GAEjF,IAAKT,KAASd,EAAI,SAAS,UAAUwB,GACrC,IAAI;IACF,EAAUA,GAAKP,EAAI,OAAOA,EAAI,QAAQQ,CAAC;GACzC,SAAS,GAAG;IACV,IAAI,EAAE,aAAaC,IAAW,MAAM;IACpC,EAAI,YAAY,CAAC;GACnB;EACF;EAEA,SAASC,EAAO,GAA4B;GAC1C,IAAMV,IAAMrB,EAAM,SACZ4B,IAAMxB,EAAI,SAAS;GAEzB,AADAF,EAAK,OAAO,GACRmB,KAAOO,KAAKD,EAAKN,GAAKO,GAAKC,CAAC;EAClC;EAEA,SAASG,IAAe;GACtB,IAAMX,IAAMrB,EAAM,SACZ4B,IAAMxB,EAAI,SAAS;GACzB,AAAKiB,KAAQO,MACb,IAAW,IACX,EAAY,QAAQ;IAAE;IAAK;GAAI,GAC/B1B,EAAK,OAAO;EACd;EAEA,SAAS+B,EAAQ,GAA4B;GAC3C,IAAMP,IAAId,EAAY;GACtB,AAAIc,KAAGC,EAAKD,EAAE,KAAKA,EAAE,KAAKG,CAAC;EAC7B;EAMA,SAASK,EAAkB,GAAgD;GACzE,IAAMC,IAAS,EAAE,OAAO,cAAc;GACtC,AAAIA,aAAkB,QAAQnC,EAAM,SAAS,OAAO,SAASmC,CAAM,KAAG,EAAE,eAAe;EACzF;EAEA,SAASC,EAAgB,GAAgB;GAGvC,AAFA,EAAE,eAAe,GAEjBhC,EAAI,WAAW,MAAM,iBAAiB;GACtC,IAAMiC,IAAQ,EAAE,QAA+B,cAC7C,iBACF;GACA,AAAIA,KAAMC,EAAqBD,CAAI;EACrC;EAEA,SAASE,EAAiB,GAAgB;GAGxC,AAFA,EAAE,eAAe,GACZtB,KAAUQ,EAAYT,CAAI,GAC/B,IAAW;EACb;EAEA,SAASwB,EAAuB,GAAgB;GAE9C,AADA,EAAE,eAAe,GACjBf,EAAYT,CAAI;EAClB;EAEA,SAASyB,EAAa,GAAqB;GACzC,AAAK1B,KAAMb,EAAK,OAAO;EACzB;EAGA,IAAMwC,IAAY,EAAE,cAAcC,EAAiB,KAAK;oBAItDvD,EAAAA,GAAAA,EAAAA,GAAAA,MAAAA,CAAAA,EAqBcC,EAAA4D,CAAA,GAAA;GArBA,MAAMtC,EAAA;GAAO,iBAAa8B;;GACtC,SAAAnD,QAmBgB,CAnBhBF,EAmBgBC,EAAA8D,CAAA,GAAA,MAAA;IAlBd,SAAA7D,QAiBiB,CAhBTU,EAAM,WADdf,EAAA,GAAAM,EAiBiBF,EAAAgE,CAAA,GAjBjB7D,EAiBiB;;KAfd,WAAWQ,EAAM,QAAQ;KAC1B,OAAM;KACN,2BAAA;KACA,iBAAc;KACb,4BAA0BA,EAAM,QAAQ;KACzC,MAAK;KACL,OAAM;KACL,eAAa;KACb,qBAAmB;IACZ,GAAA0C,GAAS;KACC;KACC;KACA;;KAEnB,SAAApD,QAA6E,CAA7EF,EAA6EK,GAAA;MAAxD,OAAOe,EAAA,MAAM;MAAQ,UAAQuB;MAAS,UAAQC;;;;;;;EAIzE5C,GAAAA,GAAAA,CAAAA,MAAAA,CAAAA,GAAAA,EAKEO,GAAA;GAJQ,MAAMmB,EAAA;GAAA,iBAAA,AAAA0C,EAAA,QAAA,MAAA,EAAQ,QAAAC;GACrB,QAAQ;GACR,QAAMxB;GACN,kBAAkBO"}
@@ -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, selects it for 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 = 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. False leaves the tool\n * alone, for a dialog that signs a field with it through `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,11 @@ 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. False leaves the tool
7
+ * alone, for a dialog that signs a field with it through `save`.
8
+ */
9
+ select?: boolean;
5
10
  };
6
11
  type __VLS_ModelProps = {
7
12
  'open'?: boolean;
@@ -15,7 +20,10 @@ declare const __VLS_export: import('vue').DefineComponent<__VLS_PublicProps, {},
15
20
  "onUpdate:open"?: (value: boolean) => any;
16
21
  onCloseAutoFocus?: (event: Event) => any;
17
22
  onSave?: (template: SignatureTemplate) => any;
18
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
23
+ }>, {
24
+ select: boolean;
25
+ fonts: readonly string[] | undefined;
26
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
19
27
  declare const _default: typeof __VLS_export;
20
28
  export default _default;
21
29
  //# 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":"AA6FA,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;;;OAGG;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, selects it for 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 = 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. False leaves the tool\n * alone, for a dialog that signs a field with it through `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":";;;;;;;;;;;;;;;;;;;;;;EAoBA,IAAMe,IAAQC,GAYRC,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 { useTool } from '../composables/useTool'\nimport { useToolOptions } from '../composables/useToolOptions'\nimport { useInkContext } from '../context'\nimport { useReadable } from '../use-readable'\n\nimport InkIcon from './InkIcon.vue'\nimport InkSignatureDialog from './InkSignatureDialog.vue'\nimport SignatureMenuPanel from './SignatureMenuPanel.vue'\n\nimport type { SignatureOptions, SignatureTemplate } from '@inkbar/core'\n\ndefineOptions({ inheritAttrs: false })\nconst props = defineProps<{\n /** The fonts the dialog's Type tab offers. Default: InkRoot's `signatureFonts`. */\n fonts?: readonly string[] | undefined\n}>()\n\nconst NO_TEMPLATES: readonly SignatureTemplate[] = []\n\nconst { tool, setTool } = useTool()\nconst { options, setOptions } = useToolOptions<SignatureOptions>('signature')\nconst ctx = useInkContext('InkSignatureMenu')\nconst templates = useReadable(() => ctx.signatures.value.templates, NO_TEMPLATES)\nconst model = computed(() => signatureMenuModel(templates.value, options.value))\nconst active = computed(() => tool.value === 'signature')\nconst open = ref(false)\nconst creating = ref(false)\n// An old removal error is not news when the menu opens again.\nwatch(open, (isOpen) => {\n if (isOpen) ctx.signatures.value.clearRemoveError()\n})\nconst main = useTemplateRef<{ $el: HTMLElement }>('main')\n\n/** ArrowDown opens on the first item; a click opens on the checked one. */\nlet focusFirst = false\n/** Set while the menu closes for the dialog, which takes focus instead of the trigger. */\nlet toDialog = false\n\nfunction onTriggerKeydown(e: KeyboardEvent): void {\n if (e.key !== 'ArrowDown' || e.defaultPrevented || open.value) return\n e.preventDefault()\n focusFirst = true\n open.value = true\n}\n\n// Not a signature field's menu, which shares the attribute.\nconst panel = (): HTMLElement | null =>\n document.querySelector<HTMLElement>(\n '[data-ink-menu=\"signature\"]:not([data-ink-sign-field-menu]) [role=\"menu\"]'\n )\n\nfunction onOpenAutoFocus(e: Event): void {\n e.preventDefault()\n const menu = panel()\n if (menu) {\n if (focusFirst) menuItems(menu)[0]?.focus({ preventScroll: true })\n else focusInitialMenuItem(menu)\n }\n focusFirst = false\n}\n\nfunction onCloseAutoFocus(e: Event): void {\n if (toDialog) e.preventDefault()\n toDialog = false\n}\n\nfunction onMain(): void {\n if (model.value.selected) setTool('signature')\n else open.value = true\n}\n\nfunction choose(id: string): void {\n setOptions({ templateId: id })\n setTool('signature')\n open.value = false\n}\n\nfunction create(): void {\n toDialog = true\n open.value = false\n creating.value = true\n}\n\nfunction onDialogCloseAutoFocus(e: Event): void {\n e.preventDefault()\n main.value?.$el.focus({ preventScroll: true })\n}\n\n// Reka's typed props stop at its own; ARIA and listeners go through bound objects.\nconst mainAttrs = computed(() => ({\n 'aria-pressed': String(active.value),\n 'aria-label': SIGNATURE_LABELS.sign,\n title: SIGNATURE_LABELS.sign,\n onClick: onMain,\n}))\nconst triggerAttrs = {\n 'aria-label': SIGNATURE_LABELS.trigger,\n title: SIGNATURE_LABELS.trigger,\n 'aria-haspopup': 'menu' as const,\n onKeydown: onTriggerKeydown,\n}\nconst menuAttrs = { 'aria-label': SIGNATURE_LABELS.menu }\n</script>\n\n<template>\n <PopoverRoot v-model:open=\"open\">\n <PopoverAnchor as-child>\n <div\n role=\"group\"\n :aria-label=\"SIGNATURE_LABELS.sign\"\n class=\"ink-split-button ink-signature-menu\"\n data-ink-signature-menu\n v-bind=\"$attrs\"\n >\n <ToolbarButton\n ref=\"main\"\n class=\"ink-tool-button ink-signature-button\"\n data-ink-tool-button\n data-ink-signature-button\n data-tool=\"signature\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"mainAttrs\"\n >\n <slot :active=\"active\"><InkIcon :icon=\"Signature\" /></slot>\n </ToolbarButton>\n <ToolbarButton as-child>\n <PopoverTrigger as-child>\n <button\n type=\"button\"\n class=\"ink-menu-trigger ink-signature-menu-trigger\"\n data-ink-signature-menu-trigger\n :data-state=\"open ? 'open' : 'closed'\"\n v-bind=\"triggerAttrs\"\n >\n <InkIcon :icon=\"ChevronDown\" />\n </button>\n </PopoverTrigger>\n </ToolbarButton>\n <PopoverPortal>\n <PopoverContent\n class=\"ink-select-content ink-menu-content\"\n data-ink-select-content\n data-ink-menu=\"signature\"\n side=\"bottom\"\n align=\"start\"\n :side-offset=\"4\"\n :collision-padding=\"8\"\n v-bind=\"menuAttrs\"\n @open-auto-focus=\"onOpenAutoFocus\"\n @close-auto-focus=\"onCloseAutoFocus\"\n >\n <SignatureMenuPanel\n :items=\"model.items\"\n @choose=\"choose($event.id)\"\n @create=\"create\"\n />\n </PopoverContent>\n </PopoverPortal>\n <InkSignatureDialog\n v-model:open=\"creating\"\n :fonts=\"props.fonts\"\n @close-auto-focus=\"onDialogCloseAutoFocus\"\n />\n </div>\n </PopoverAnchor>\n </PopoverRoot>\n</template>\n"],"mappings":""}
@@ -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":"AAqOA,KAAK,WAAW,GAAG;IACjB,mFAAmF;IACnF,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;CACtC,CAAC;AAsVF,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"}
@@ -2,124 +2,96 @@ import { useInkContext as e } from "../context.js";
2
2
  import { useReadable as t } from "../use-readable.js";
3
3
  import { useTool as n } from "../composables/useTool.js";
4
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";
5
+ import i from "./InkSignatureDialog.js";
6
+ import a from "./InkIcon.js";
7
+ import o from "./SignatureMenuPanel.js";
8
+ import { computed as s, createBlock as c, createElementVNode as l, createVNode as u, defineComponent as d, mergeProps as f, openBlock as p, ref as m, renderSlot as ee, unref as h, useTemplateRef as g, watch as _, withCtx as v } from "vue";
9
+ import { SIGNATURE_LABELS as y, focusInitialMenuItem as b, menuItems as x, signatureMenuModel as S } from "@inkbar/core/dom";
10
+ import { PopoverAnchor as C, PopoverContent as w, PopoverPortal as T, PopoverRoot as E, PopoverTrigger as D, ToolbarButton as O } from "reka-ui";
11
+ import { ChevronDown as k, Signature as A } from "@inkbar/icons";
11
12
  //#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({
13
+ var j = ["aria-label"], M = ["data-state"], N = /*@__PURE__*/ d({
29
14
  inheritAttrs: !1,
30
15
  __name: "InkSignatureMenu",
31
16
  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) => {
35
- e && H.signatures.value.clearRemoveError();
17
+ setup(d) {
18
+ let N = d, P = [], { tool: F, setTool: I } = n(), { options: L, setOptions: R } = r("signature"), z = e("InkSignatureMenu"), B = t(() => z.signatures.value.templates, P), V = s(() => S(B.value, L.value)), H = s(() => F.value === "signature"), U = m(!1), W = m(!1);
19
+ _(U, (e) => {
20
+ e && z.signatures.value.clearRemoveError();
36
21
  });
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);
22
+ let G = g("main"), K = !1, q = !1;
23
+ function J(e) {
24
+ e.key !== "ArrowDown" || e.defaultPrevented || U.value || (e.preventDefault(), K = !0, U.value = !0);
40
25
  }
41
- let Q = () => document.querySelector("[data-ink-menu=\"signature\"] [role=\"menu\"]");
42
- function be(e) {
26
+ let Y = () => document.querySelector("[data-ink-menu=\"signature\"]:not([data-ink-sign-field-menu]) [role=\"menu\"]");
27
+ function X(e) {
43
28
  e.preventDefault();
44
- let t = Q();
45
- t && (X ? ue(t)[0]?.focus({ preventScroll: !0 }) : ce(t)), X = !1;
29
+ let t = Y();
30
+ t && (K ? x(t)[0]?.focus({ preventScroll: !0 }) : b(t)), K = !1;
46
31
  }
47
- function xe(e) {
48
- Z && e.preventDefault(), Z = !1;
32
+ function Z(e) {
33
+ q && e.preventDefault(), q = !1;
49
34
  }
50
- function Se() {
51
- W.value.selected ? V("signature") : K.value = !0;
35
+ function Q() {
36
+ V.value.selected ? I("signature") : U.value = !0;
52
37
  }
53
- function Ce(e) {
54
- _e({ templateId: e }), V("signature"), K.value = !1;
38
+ function $(e) {
39
+ R({ templateId: e }), I("signature"), U.value = !1;
55
40
  }
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
- }, () => {});
41
+ function te() {
42
+ q = !0, U.value = !1, W.value = !0;
64
43
  }
65
- function we() {
66
- Z = !0, K.value = !1, q.value = !0;
44
+ function ne(e) {
45
+ e.preventDefault(), G.value?.$el.focus({ preventScroll: !0 });
67
46
  }
68
- function Te(e) {
69
- e.preventDefault(), J.value?.$el.focus({ preventScroll: !0 });
70
- }
71
- let Ee = o(() => ({
72
- "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,
47
+ let re = s(() => ({
48
+ "aria-pressed": String(H.value),
49
+ "aria-label": y.sign,
50
+ title: y.sign,
51
+ onClick: Q
52
+ })), ie = {
53
+ "aria-label": y.trigger,
54
+ title: y.trigger,
79
55
  "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), {
87
- open: K.value,
88
- "onUpdate:open": t[1] ||= (e) => K.value = e
56
+ onKeydown: J
57
+ }, ae = { "aria-label": y.menu };
58
+ return (e, t) => (p(), c(h(E), {
59
+ open: U.value,
60
+ "onUpdate:open": t[2] ||= (e) => U.value = e
89
61
  }, {
90
- default: y(() => [d(v(pe), { "as-child": "" }, {
91
- default: y(() => [l("div", p({
62
+ default: v(() => [u(h(C), { "as-child": "" }, {
63
+ default: v(() => [l("div", f({
92
64
  role: "group",
93
- "aria-label": v(b).sign,
65
+ "aria-label": h(y).sign,
94
66
  class: "ink-split-button ink-signature-menu",
95
67
  "data-ink-signature-menu": ""
96
68
  }, e.$attrs), [
97
- d(v(T), p({
69
+ u(h(O), f({
98
70
  ref_key: "main",
99
- ref: J,
71
+ ref: G,
100
72
  class: "ink-tool-button ink-signature-button",
101
73
  "data-ink-tool-button": "",
102
74
  "data-ink-signature-button": "",
103
75
  "data-tool": "signature",
104
- "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"])])]),
76
+ "data-state": H.value ? "on" : "off"
77
+ }, re.value), {
78
+ default: v(() => [ee(e.$slots, "default", { active: H.value }, () => [u(a, { icon: h(A) }, null, 8, ["icon"])])]),
107
79
  _: 3
108
80
  }, 16, ["data-state"]),
109
- d(v(T), { "as-child": "" }, {
110
- default: y(() => [d(v(w), { "as-child": "" }, {
111
- default: y(() => [l("button", p({
81
+ u(h(O), { "as-child": "" }, {
82
+ default: v(() => [u(h(D), { "as-child": "" }, {
83
+ default: v(() => [l("button", f({
112
84
  type: "button",
113
85
  class: "ink-menu-trigger ink-signature-menu-trigger",
114
86
  "data-ink-signature-menu-trigger": "",
115
- "data-state": K.value ? "open" : "closed"
116
- }, De), [d(i, { icon: v(E) }, null, 8, ["icon"])], 16, j)]),
87
+ "data-state": U.value ? "open" : "closed"
88
+ }, ie), [u(a, { icon: h(k) }, null, 8, ["icon"])], 16, M)]),
117
89
  _: 1
118
90
  })]),
119
91
  _: 1
120
92
  }),
121
- d(v(S), null, {
122
- default: y(() => [d(v(x), p({
93
+ u(h(T), null, {
94
+ default: v(() => [u(h(w), f({
123
95
  class: "ink-select-content ink-menu-content",
124
96
  "data-ink-select-content": "",
125
97
  "data-ink-menu": "signature",
@@ -127,85 +99,26 @@ var A = ["aria-label"], j = ["data-state"], M = ["aria-label"], N = [
127
99
  align: "start",
128
100
  "side-offset": 4,
129
101
  "collision-padding": 8
130
- }, Oe, {
131
- onOpenAutoFocus: be,
132
- onCloseAutoFocus: xe
102
+ }, ae, {
103
+ onOpenAutoFocus: X,
104
+ onCloseAutoFocus: Z
133
105
  }), {
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)]),
106
+ default: v(() => [u(o, {
107
+ items: V.value.items,
108
+ onChoose: t[0] ||= (e) => $(e.id),
109
+ onCreate: te
110
+ }, null, 8, ["items"])]),
198
111
  _: 1
199
112
  }, 16)]),
200
113
  _: 1
201
114
  }),
202
- d(ee, {
203
- open: q.value,
204
- "onUpdate:open": t[0] ||= (e) => q.value = e,
205
- fonts: B.fonts,
206
- onCloseAutoFocus: Te
115
+ u(i, {
116
+ open: W.value,
117
+ "onUpdate:open": t[1] ||= (e) => W.value = e,
118
+ fonts: N.fonts,
119
+ onCloseAutoFocus: ne
207
120
  }, null, 8, ["open", "fonts"])
208
- ], 16, A)]),
121
+ ], 16, j)]),
209
122
  _: 3
210
123
  })]),
211
124
  _: 3
@@ -213,6 +126,6 @@ var A = ["aria-label"], j = ["data-state"], M = ["aria-label"], N = [
213
126
  }
214
127
  });
215
128
  //#endregion
216
- export { B as default };
129
+ export { N as default };
217
130
 
218
131
  //# sourceMappingURL=InkSignatureMenu.vue_vue_type_script_setup_true_lang.js.map