@inkbar/vue 0.4.0 → 0.6.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 (73) hide show
  1. package/README.md +23 -7
  2. package/dist/components/InkAnnotation.js.map +1 -1
  3. package/dist/components/InkAnnotation.vue.d.ts.map +1 -1
  4. package/dist/components/InkAnnotation.vue_vue_type_script_setup_true_lang.js +16 -24
  5. package/dist/components/InkAnnotation.vue_vue_type_script_setup_true_lang.js.map +1 -1
  6. package/dist/components/InkColorMenu.js.map +1 -1
  7. package/dist/components/InkColorMenu.vue.d.ts +2 -0
  8. package/dist/components/InkColorMenu.vue.d.ts.map +1 -1
  9. package/dist/components/InkColorMenu.vue_vue_type_script_setup_true_lang.js +3 -2
  10. package/dist/components/InkColorMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  11. package/dist/components/InkCommand.js +7 -0
  12. package/dist/components/InkCommand.js.map +1 -0
  13. package/dist/components/InkCommand.vue.d.ts +23 -0
  14. package/dist/components/InkCommand.vue.d.ts.map +1 -0
  15. package/dist/components/InkCommand.vue_vue_type_script_setup_true_lang.js +51 -0
  16. package/dist/components/InkCommand.vue_vue_type_script_setup_true_lang.js.map +1 -0
  17. package/dist/components/InkHighlightMenu.js.map +1 -1
  18. package/dist/components/InkHighlightMenu.vue.d.ts +2 -2
  19. package/dist/components/InkHighlightMenu.vue.d.ts.map +1 -1
  20. package/dist/components/InkHighlightMenu.vue_vue_type_script_setup_true_lang.js +118 -108
  21. package/dist/components/InkHighlightMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  22. package/dist/components/InkPageInput.js.map +1 -1
  23. package/dist/components/InkPageInput.vue.d.ts.map +1 -1
  24. package/dist/components/InkPageInput.vue_vue_type_script_setup_true_lang.js +1 -1
  25. package/dist/components/InkPageInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
  26. package/dist/components/InkRoot.js.map +1 -1
  27. package/dist/components/InkRoot.vue.d.ts +415 -424
  28. package/dist/components/InkRoot.vue.d.ts.map +1 -1
  29. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js +145 -102
  30. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js.map +1 -1
  31. package/dist/components/InkShapeMenu.js.map +1 -1
  32. package/dist/components/InkShapeMenu.vue.d.ts +2 -2
  33. package/dist/components/InkShapeMenu.vue.d.ts.map +1 -1
  34. package/dist/components/InkShapeMenu.vue_vue_type_script_setup_true_lang.js +99 -91
  35. package/dist/components/InkShapeMenu.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 +2 -2
  38. package/dist/components/InkSignatureMenu.vue.d.ts.map +1 -1
  39. package/dist/components/InkSignatureMenu.vue_vue_type_script_setup_true_lang.js +156 -151
  40. package/dist/components/InkSignatureMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  41. package/dist/components/InkToolButton.js.map +1 -1
  42. package/dist/components/InkToolButton.vue.d.ts.map +1 -1
  43. package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js +36 -35
  44. package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  45. package/dist/components/InkViewport.js.map +1 -1
  46. package/dist/components/InkViewport.vue.d.ts.map +1 -1
  47. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js +14 -4
  48. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js.map +1 -1
  49. package/dist/composables/useAnnotations.d.ts +915 -1386
  50. package/dist/composables/useAnnotations.d.ts.map +1 -1
  51. package/dist/composables/useAnnotations.js +13 -18
  52. package/dist/composables/useAnnotations.js.map +1 -1
  53. package/dist/composables/useCommand.d.ts +23 -0
  54. package/dist/composables/useCommand.d.ts.map +1 -0
  55. package/dist/composables/useCommand.js +22 -0
  56. package/dist/composables/useCommand.js.map +1 -0
  57. package/dist/context.d.ts +22 -4
  58. package/dist/context.d.ts.map +1 -1
  59. package/dist/context.js.map +1 -1
  60. package/dist/index.d.ts +4 -2
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +27 -26
  63. package/dist/ref-history.d.ts +12 -3
  64. package/dist/ref-history.d.ts.map +1 -1
  65. package/dist/ref-history.js +27 -16
  66. package/dist/ref-history.js.map +1 -1
  67. package/package.json +5 -5
  68. package/dist/components/InkSuggestionCard.js +0 -7
  69. package/dist/components/InkSuggestionCard.js.map +0 -1
  70. package/dist/components/InkSuggestionCard.vue.d.ts +0 -16
  71. package/dist/components/InkSuggestionCard.vue.d.ts.map +0 -1
  72. package/dist/components/InkSuggestionCard.vue_vue_type_script_setup_true_lang.js +0 -85
  73. package/dist/components/InkSuggestionCard.vue_vue_type_script_setup_true_lang.js.map +0 -1
@@ -4,210 +4,215 @@ import { useTool as n } from "../composables/useTool.js";
4
4
  import { useToolOptions as r } from "../composables/useToolOptions.js";
5
5
  import i from "./InkIcon.js";
6
6
  import ee from "./InkSignatureDialog.js";
7
- import { Fragment as a, computed as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as te, createVNode as u, defineComponent as d, guardReactiveProps as f, mergeProps as p, nextTick as ne, normalizeProps as re, openBlock as m, ref as h, renderList as g, renderSlot as ie, toDisplayString as _, unref as v, useTemplateRef as ae, watch as oe, withCtx as y } from "vue";
8
- import { SIGNATURE_LABELS as b, focusInitialMenuItem as se, handleMenuKeys as ce, menuItems as le, signatureMenuModel as ue, signaturePreview as de } from "@inkbar/core/dom";
9
- import { PopoverContent as fe, PopoverPortal as pe, PopoverRoot as x, PopoverTrigger as S, ToolbarButton as C } from "reka-ui";
10
- import { ChevronDown as w, Plus as T, Signature as E, Trash2 as D } from "@inkbar/icons";
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";
11
11
  //#region src/components/InkSignatureMenu.vue?vue&type=script&setup=true&lang.ts
12
- var O = ["aria-label"], k = ["data-state"], A = ["aria-label"], j = [
12
+ var A = ["aria-label"], j = ["data-state"], M = ["aria-label"], N = [
13
13
  "aria-checked",
14
14
  "aria-label",
15
15
  "data-key",
16
16
  "data-state",
17
17
  "onClick"
18
- ], M = ["data-kind"], N = ["src"], P = ["viewBox"], F = ["d"], I = [
18
+ ], P = ["data-kind"], F = ["src"], I = ["viewBox"], L = ["d"], R = [
19
19
  "aria-label",
20
20
  "title",
21
21
  "data-key",
22
22
  "onClick"
23
- ], L = {
23
+ ], z = {
24
24
  key: 1,
25
25
  class: "ink-field-error ink-signature-remove-error",
26
26
  role: "alert",
27
27
  "data-ink-signature-remove-error": ""
28
- }, R = /*@__PURE__*/ d({
28
+ }, B = /*@__PURE__*/ f({
29
+ inheritAttrs: !1,
29
30
  __name: "InkSignatureMenu",
30
31
  props: { fonts: {} },
31
- setup(d) {
32
- let R = d, z = [], { tool: B, setTool: V } = n(), { options: me, setOptions: he } = r("signature"), H = e("InkSignatureMenu"), ge = t(() => H.signatures.value.templates, z), U = t(() => H.signatures.value.removeError, void 0), W = o(() => ue(ge.value, me.value)), G = o(() => B.value === "signature"), K = h(!1), q = h(!1);
33
- oe(K, (e) => {
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) => {
34
35
  e && H.signatures.value.clearRemoveError();
35
36
  });
36
- let J = ae("main"), Y = o(() => W.value.items.map((e) => e.template.kind === "ink" ? de(e.template) : null)), X = !1, Z = !1;
37
- function _e(e) {
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) {
38
39
  e.key !== "ArrowDown" || e.defaultPrevented || K.value || (e.preventDefault(), X = !0, K.value = !0);
39
40
  }
40
41
  let Q = () => document.querySelector("[data-ink-menu=\"signature\"] [role=\"menu\"]");
41
- function ve(e) {
42
+ function be(e) {
42
43
  e.preventDefault();
43
44
  let t = Q();
44
- t && (X ? le(t)[0]?.focus({ preventScroll: !0 }) : se(t)), X = !1;
45
+ t && (X ? ue(t)[0]?.focus({ preventScroll: !0 }) : ce(t)), X = !1;
45
46
  }
46
- function ye(e) {
47
+ function xe(e) {
47
48
  Z && e.preventDefault(), Z = !1;
48
49
  }
49
- function be() {
50
+ function Se() {
50
51
  W.value.selected ? V("signature") : K.value = !0;
51
52
  }
52
- function xe(e) {
53
- he({ templateId: e }), V("signature"), K.value = !1;
53
+ function Ce(e) {
54
+ _e({ templateId: e }), V("signature"), K.value = !1;
54
55
  }
55
- function Se(e, t) {
56
+ function $(e, t) {
56
57
  H.signatures.value.remove(e).then(async () => {
57
- await ne();
58
+ await re();
58
59
  let e = Q();
59
60
  if (!e) return;
60
61
  let n = e.querySelectorAll(".ink-signature-item");
61
62
  (n[Math.min(t, n.length - 1)] ?? e.querySelector("[data-ink-signature-create]"))?.focus({ preventScroll: !0 });
62
63
  }, () => {});
63
64
  }
64
- function Ce() {
65
+ function we() {
65
66
  Z = !0, K.value = !1, q.value = !0;
66
67
  }
67
- function $(e) {
68
+ function Te(e) {
68
69
  e.preventDefault(), J.value?.$el.focus({ preventScroll: !0 });
69
70
  }
70
- let we = o(() => ({
71
+ let Ee = o(() => ({
71
72
  "aria-pressed": String(G.value),
72
73
  "aria-label": b.sign,
73
74
  title: b.sign,
74
- onClick: be
75
- })), Te = {
75
+ onClick: Se
76
+ })), De = {
76
77
  "aria-label": b.trigger,
77
78
  title: b.trigger,
78
79
  "aria-haspopup": "menu",
79
- onKeydown: _e
80
- }, Ee = { "aria-label": b.menu }, De = {
80
+ onKeydown: ye
81
+ }, Oe = { "aria-label": b.menu }, ke = {
81
82
  role: "menu",
82
83
  "aria-label": b.menu,
83
- onKeydown: (e) => ce(e, e.currentTarget)
84
+ onKeydown: (e) => le(e, e.currentTarget)
84
85
  };
85
- return (e, t) => (m(), c("div", {
86
- role: "group",
87
- "aria-label": v(b).sign,
88
- class: "ink-split-button ink-signature-menu",
89
- "data-ink-signature-menu": ""
90
- }, [
91
- u(v(C), p({
92
- ref_key: "main",
93
- ref: J,
94
- class: "ink-tool-button ink-signature-button",
95
- "data-ink-tool-button": "",
96
- "data-ink-signature-button": "",
97
- "data-tool": "signature",
98
- "data-state": G.value ? "on" : "off"
99
- }, we.value), {
100
- default: y(() => [ie(e.$slots, "default", { active: G.value }, () => [u(i, { icon: v(E) }, null, 8, ["icon"])])]),
101
- _: 3
102
- }, 16, ["data-state"]),
103
- u(v(x), {
104
- open: K.value,
105
- "onUpdate:open": t[0] ||= (e) => K.value = e
106
- }, {
107
- default: y(() => [u(v(C), { "as-child": "" }, {
108
- default: y(() => [u(v(S), { "as-child": "" }, {
109
- default: y(() => [l("button", p({
110
- type: "button",
111
- class: "ink-menu-trigger ink-signature-menu-trigger",
112
- "data-ink-signature-menu-trigger": "",
113
- "data-state": K.value ? "open" : "closed"
114
- }, Te), [u(i, { icon: v(w) }, null, 8, ["icon"])], 16, k)]),
115
- _: 1
116
- })]),
117
- _: 1
118
- }), u(v(pe), null, {
119
- default: y(() => [u(v(fe), p({
120
- class: "ink-select-content ink-menu-content",
121
- "data-ink-select-content": "",
122
- "data-ink-menu": "signature",
123
- side: "bottom",
124
- align: "start",
125
- "side-offset": 4,
126
- "collision-padding": 8
127
- }, Ee, {
128
- onOpenAutoFocus: ve,
129
- onCloseAutoFocus: ye
130
- }), {
131
- default: y(() => [l("div", re(f(De)), [
132
- W.value.items.length > 0 ? (m(), c(a, { key: 0 }, [l("div", {
133
- role: "group",
134
- "aria-label": v(b).saved,
135
- class: "ink-signature-list",
136
- "data-ink-menu-columns": "2"
137
- }, [(m(!0), c(a, null, g(W.value.items, (e, t) => (m(), c(a, { key: e.id }, [l("button", {
138
- type: "button",
139
- role: "menuitemradio",
140
- "aria-checked": e.checked,
141
- "aria-label": e.label,
142
- tabindex: "-1",
143
- class: "ink-select-item ink-menu-item ink-signature-item",
144
- "data-ink-select-item": "",
145
- "data-key": e.id,
146
- "data-state": e.checked ? "checked" : "unchecked",
147
- onClick: (t) => xe(e.id)
148
- }, [l("span", {
149
- class: "ink-signature-preview",
150
- "data-kind": e.template.kind
151
- }, [e.template.kind === "image" ? (m(), c("img", {
152
- key: 0,
153
- src: e.template.imagedata,
154
- alt: "",
155
- draggable: "false"
156
- }, null, 8, N)) : (m(), c("svg", {
157
- key: 1,
158
- viewBox: Y.value[t]?.viewBox,
159
- "aria-hidden": "true"
160
- }, [(m(!0), c(a, null, g(Y.value[t]?.paths ?? [], (e, t) => (m(), c("path", {
161
- key: t,
162
- d: e,
163
- fill: "currentColor"
164
- }, null, 8, F))), 128))], 8, P))], 8, M)], 8, j), l("button", {
165
- type: "button",
166
- role: "menuitem",
167
- "aria-label": e.removeLabel,
168
- title: e.removeLabel,
169
- tabindex: "-1",
170
- class: "ink-menu-item ink-signature-remove",
171
- "data-ink-signature-remove": "",
172
- "data-key": e.id,
173
- onClick: (n) => Se(e.id, t)
174
- }, [u(i, {
175
- icon: v(D),
176
- size: 16
177
- }, null, 8, ["icon"])], 8, I)], 64))), 128))], 8, A), t[2] ||= l("div", {
178
- role: "separator",
179
- class: "ink-select-separator"
180
- }, null, -1)], 64)) : s("", !0),
181
- l("button", {
86
+ return (e, t) => (m(), te(v(C), {
87
+ open: K.value,
88
+ "onUpdate:open": t[1] ||= (e) => K.value = e
89
+ }, {
90
+ default: y(() => [d(v(pe), { "as-child": "" }, {
91
+ default: y(() => [l("div", p({
92
+ role: "group",
93
+ "aria-label": v(b).sign,
94
+ class: "ink-split-button ink-signature-menu",
95
+ "data-ink-signature-menu": ""
96
+ }, e.$attrs), [
97
+ d(v(T), p({
98
+ ref_key: "main",
99
+ ref: J,
100
+ class: "ink-tool-button ink-signature-button",
101
+ "data-ink-tool-button": "",
102
+ "data-ink-signature-button": "",
103
+ "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"])])]),
107
+ _: 3
108
+ }, 16, ["data-state"]),
109
+ d(v(T), { "as-child": "" }, {
110
+ default: y(() => [d(v(w), { "as-child": "" }, {
111
+ default: y(() => [l("button", p({
182
112
  type: "button",
183
- role: "menuitem",
184
- tabindex: "-1",
185
- class: "ink-select-item ink-menu-item ink-signature-create",
186
- "data-ink-select-item": "",
187
- "data-ink-signature-create": "",
188
- onClick: Ce
189
- }, [u(i, {
190
- icon: v(T),
191
- size: 16
192
- }, null, 8, ["icon"]), te(" " + _(v(b).create), 1)]),
193
- v(U) ? (m(), c("p", L, _(v(U)), 1)) : s("", !0)
194
- ], 16)]),
113
+ class: "ink-menu-trigger ink-signature-menu-trigger",
114
+ "data-ink-signature-menu-trigger": "",
115
+ "data-state": K.value ? "open" : "closed"
116
+ }, De), [d(i, { icon: v(E) }, null, 8, ["icon"])], 16, j)]),
117
+ _: 1
118
+ })]),
195
119
  _: 1
196
- }, 16)]),
197
- _: 1
198
- })]),
199
- _: 1
200
- }, 8, ["open"]),
201
- u(ee, {
202
- open: q.value,
203
- "onUpdate:open": t[1] ||= (e) => q.value = e,
204
- fonts: R.fonts,
205
- onCloseAutoFocus: $
206
- }, null, 8, ["open", "fonts"])
207
- ], 8, O));
120
+ }),
121
+ d(v(S), null, {
122
+ default: y(() => [d(v(x), p({
123
+ class: "ink-select-content ink-menu-content",
124
+ "data-ink-select-content": "",
125
+ "data-ink-menu": "signature",
126
+ side: "bottom",
127
+ align: "start",
128
+ "side-offset": 4,
129
+ "collision-padding": 8
130
+ }, Oe, {
131
+ onOpenAutoFocus: be,
132
+ onCloseAutoFocus: xe
133
+ }), {
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)]),
198
+ _: 1
199
+ }, 16)]),
200
+ _: 1
201
+ }),
202
+ d(ee, {
203
+ open: q.value,
204
+ "onUpdate:open": t[0] ||= (e) => q.value = e,
205
+ fonts: B.fonts,
206
+ onCloseAutoFocus: Te
207
+ }, null, 8, ["open", "fonts"])
208
+ ], 16, A)]),
209
+ _: 3
210
+ })]),
211
+ _: 3
212
+ }, 8, ["open"]));
208
213
  }
209
214
  });
210
215
  //#endregion
211
- export { R as default };
216
+ export { B as default };
212
217
 
213
218
  //# 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":["_openBlock","_createElementBlock","_unref","_createVNode","_mergeProps","_withCtx","_renderSlot","InkIcon","_createElementVNode","_normalizeProps","_guardReactiveProps","_Fragment","_renderList","_createCommentVNode","_createTextVNode","_toDisplayString","InkSignatureDialog","InkIcon_default","InkSignatureDialog_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","_hoisted_7","_hoisted_8","_hoisted_9","_hoisted_10","InkSignatureMenu_vue_vue_type_script_setup_true_lang_default","props","__props","NO_TEMPLATES","useTool","useToolOptions","ctx","useInkContext","templates","useReadable","removeError","model","computed","signatureMenuModel","options","active","tool","open","ref","creating","isOpen","main","useTemplateRef","previews","item","signaturePreview","focusFirst","toDialog","onTriggerKeydown","panel","onOpenAutoFocus","menu","menuItems","focusInitialMenuItem","onCloseAutoFocus","onMain","setTool","choose","setOptions","id","remove","nextTick","rows","row","create","onDialogCloseAutoFocus","mainAttrs","SIGNATURE_LABELS","triggerAttrs","menuAttrs","innerAttrs","handleMenuKeys","openBlock","createElementBlock","unref","createVNode","ToolbarButton","mergeProps","withCtx","renderSlot","_ctx","Signature","PopoverRoot","_cache","$event","PopoverTrigger","createElementVNode","ChevronDown","PopoverPortal","PopoverContent","normalizeProps","guardReactiveProps","Fragment","renderList","i","Trash2","createCommentVNode","Plus","createTextVNode","toDisplayString"],"sources":["../../src/components/InkSignatureMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * A split button for the signature tool. The main part activates the tool with the chosen\n * signature, or opens the menu when none is chosen; the chevron opens the saved signatures as\n * previews, each with a remove button, and \"Create signature\", which opens\n * `InkSignatureDialog`. Choosing a signature switches to the tool with it.\n */\nimport {\n focusInitialMenuItem,\n handleMenuKeys,\n menuItems,\n SIGNATURE_LABELS,\n signatureMenuModel,\n signaturePreview,\n} from '@inkbar/core/dom'\nimport { ChevronDown, Plus, Signature, Trash2 } from '@inkbar/icons'\nimport {\n PopoverContent,\n PopoverPortal,\n PopoverRoot,\n PopoverTrigger,\n ToolbarButton,\n} from 'reka-ui'\nimport { computed, nextTick, ref, useTemplateRef, watch } from 'vue'\n\nimport { useTool } from '../composables/useTool'\nimport { useToolOptions } from '../composables/useToolOptions'\nimport { useInkContext } from '../context'\nimport { useReadable } from '../use-readable'\n\nimport InkIcon from './InkIcon.vue'\nimport InkSignatureDialog from './InkSignatureDialog.vue'\n\nimport type { SignatureOptions, SignatureTemplate } from '@inkbar/core'\n\nconst props = defineProps<{\n /** The fonts the dialog's Type tab offers. Default: InkRoot's `signatureFonts`. */\n fonts?: readonly string[] | undefined\n}>()\n\nconst NO_TEMPLATES: readonly SignatureTemplate[] = []\n\nconst { tool, setTool } = useTool()\nconst { options, setOptions } = useToolOptions<SignatureOptions>('signature')\nconst ctx = useInkContext('InkSignatureMenu')\nconst templates = useReadable(() => ctx.signatures.value.templates, NO_TEMPLATES)\nconst removeError = useReadable(() => ctx.signatures.value.removeError, undefined)\nconst model = computed(() => signatureMenuModel(templates.value, options.value))\nconst active = computed(() => tool.value === 'signature')\nconst open = ref(false)\nconst creating = ref(false)\n// An old removal error is not news when the menu opens again.\nwatch(open, (isOpen) => {\n if (isOpen) ctx.signatures.value.clearRemoveError()\n})\nconst main = useTemplateRef<{ $el: HTMLElement }>('main')\n\n/** A saved signature drawn small: ink as filled outlines. */\nconst previews = computed(() =>\n model.value.items.map((item) =>\n item.template.kind === 'ink' ? signaturePreview(item.template) : null\n )\n)\n\n/** ArrowDown opens on the first item; a click opens on the checked one. */\nlet focusFirst = false\n/** Set while the menu closes for the dialog, which takes focus instead of the trigger. */\nlet toDialog = false\n\nfunction onTriggerKeydown(e: KeyboardEvent): void {\n if (e.key !== 'ArrowDown' || e.defaultPrevented || open.value) return\n e.preventDefault()\n focusFirst = true\n open.value = true\n}\n\nconst panel = (): HTMLElement | null =>\n document.querySelector<HTMLElement>('[data-ink-menu=\"signature\"] [role=\"menu\"]')\n\nfunction onOpenAutoFocus(e: Event): void {\n e.preventDefault()\n const menu = panel()\n if (menu) {\n if (focusFirst) menuItems(menu)[0]?.focus({ preventScroll: true })\n else focusInitialMenuItem(menu)\n }\n focusFirst = false\n}\n\nfunction onCloseAutoFocus(e: Event): void {\n if (toDialog) e.preventDefault()\n toDialog = false\n}\n\nfunction onMain(): void {\n if (model.value.selected) setTool('signature')\n else open.value = true\n}\n\nfunction choose(id: string): void {\n setOptions({ templateId: id })\n setTool('signature')\n open.value = false\n}\n\n/** Removes a template; focus moves to the signature now in its row, else \"Create signature\". */\nfunction remove(id: string, row: number): void {\n ctx.signatures.value.remove(id).then(\n async () => {\n await nextTick()\n const menu = panel()\n if (!menu) return\n const rows = menu.querySelectorAll<HTMLElement>('.ink-signature-item')\n const next =\n rows[Math.min(row, rows.length - 1)] ??\n menu.querySelector<HTMLElement>('[data-ink-signature-create]')\n next?.focus({ preventScroll: true })\n },\n () => {\n // The host's store refused: the signature stays.\n }\n )\n}\n\nfunction create(): void {\n toDialog = true\n open.value = false\n creating.value = true\n}\n\nfunction onDialogCloseAutoFocus(e: Event): void {\n e.preventDefault()\n main.value?.$el.focus({ preventScroll: true })\n}\n\n// Reka's typed props stop at its own; ARIA and listeners go through bound objects.\nconst mainAttrs = computed(() => ({\n 'aria-pressed': String(active.value),\n 'aria-label': SIGNATURE_LABELS.sign,\n title: SIGNATURE_LABELS.sign,\n onClick: onMain,\n}))\nconst triggerAttrs = {\n 'aria-label': SIGNATURE_LABELS.trigger,\n title: SIGNATURE_LABELS.trigger,\n 'aria-haspopup': 'menu' as const,\n onKeydown: onTriggerKeydown,\n}\nconst menuAttrs = { 'aria-label': SIGNATURE_LABELS.menu }\nconst innerAttrs = {\n role: 'menu',\n 'aria-label': SIGNATURE_LABELS.menu,\n onKeydown: (e: KeyboardEvent) => handleMenuKeys(e, e.currentTarget as HTMLElement),\n}\n</script>\n\n<template>\n <div\n role=\"group\"\n :aria-label=\"SIGNATURE_LABELS.sign\"\n class=\"ink-split-button ink-signature-menu\"\n data-ink-signature-menu\n >\n <ToolbarButton\n ref=\"main\"\n class=\"ink-tool-button ink-signature-button\"\n data-ink-tool-button\n data-ink-signature-button\n data-tool=\"signature\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"mainAttrs\"\n >\n <slot :active=\"active\"><InkIcon :icon=\"Signature\" /></slot>\n </ToolbarButton>\n <PopoverRoot v-model:open=\"open\">\n <ToolbarButton as-child>\n <PopoverTrigger as-child>\n <button\n type=\"button\"\n class=\"ink-menu-trigger ink-signature-menu-trigger\"\n data-ink-signature-menu-trigger\n :data-state=\"open ? 'open' : 'closed'\"\n v-bind=\"triggerAttrs\"\n >\n <InkIcon :icon=\"ChevronDown\" />\n </button>\n </PopoverTrigger>\n </ToolbarButton>\n <PopoverPortal>\n <PopoverContent\n class=\"ink-select-content ink-menu-content\"\n data-ink-select-content\n data-ink-menu=\"signature\"\n side=\"bottom\"\n align=\"start\"\n :side-offset=\"4\"\n :collision-padding=\"8\"\n v-bind=\"menuAttrs\"\n @open-auto-focus=\"onOpenAutoFocus\"\n @close-auto-focus=\"onCloseAutoFocus\"\n >\n <div v-bind=\"innerAttrs\">\n <template v-if=\"model.items.length > 0\">\n <div\n role=\"group\"\n :aria-label=\"SIGNATURE_LABELS.saved\"\n class=\"ink-signature-list\"\n data-ink-menu-columns=\"2\"\n >\n <template v-for=\"(item, row) in model.items\" :key=\"item.id\">\n <button\n type=\"button\"\n role=\"menuitemradio\"\n :aria-checked=\"item.checked\"\n :aria-label=\"item.label\"\n tabindex=\"-1\"\n class=\"ink-select-item ink-menu-item ink-signature-item\"\n data-ink-select-item\n :data-key=\"item.id\"\n :data-state=\"item.checked ? 'checked' : 'unchecked'\"\n @click=\"choose(item.id)\"\n >\n <span class=\"ink-signature-preview\" :data-kind=\"item.template.kind\">\n <img\n v-if=\"item.template.kind === 'image'\"\n :src=\"item.template.imagedata\"\n alt=\"\"\n draggable=\"false\"\n />\n <svg v-else :viewBox=\"previews[row]?.viewBox\" aria-hidden=\"true\">\n <path\n v-for=\"(d, i) in previews[row]?.paths ?? []\"\n :key=\"i\"\n :d=\"d\"\n fill=\"currentColor\"\n />\n </svg>\n </span>\n </button>\n <button\n type=\"button\"\n role=\"menuitem\"\n :aria-label=\"item.removeLabel\"\n :title=\"item.removeLabel\"\n tabindex=\"-1\"\n class=\"ink-menu-item ink-signature-remove\"\n data-ink-signature-remove\n :data-key=\"item.id\"\n @click=\"remove(item.id, row)\"\n >\n <InkIcon :icon=\"Trash2\" :size=\"16\" />\n </button>\n </template>\n </div>\n <div role=\"separator\" class=\"ink-select-separator\" />\n </template>\n <button\n type=\"button\"\n role=\"menuitem\"\n tabindex=\"-1\"\n class=\"ink-select-item ink-menu-item ink-signature-create\"\n data-ink-select-item\n data-ink-signature-create\n @click=\"create\"\n >\n <InkIcon :icon=\"Plus\" :size=\"16\" />\n {{ SIGNATURE_LABELS.create }}\n </button>\n <p\n v-if=\"removeError\"\n class=\"ink-field-error ink-signature-remove-error\"\n role=\"alert\"\n data-ink-signature-remove-error\n >\n {{ removeError }}\n </p>\n </div>\n </PopoverContent>\n </PopoverPortal>\n </PopoverRoot>\n <InkSignatureDialog\n v-model:open=\"creating\"\n :fonts=\"props.fonts\"\n @close-auto-focus=\"onDialogCloseAutoFocus\"\n />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCA,IAAM8B,IAAQC,GAKRC,IAA6C,CAAC,GAE9C,EAAE,SAAM,eAAYC,EAAQ,GAC5B,EAAE,aAAS,mBAAeC,EAAiC,WAAW,GACtEC,IAAMC,EAAc,kBAAkB,GACtCC,KAAYC,QAAkBH,EAAI,WAAW,MAAM,WAAWH,CAAY,GAC1EO,IAAcD,QAAkBH,EAAI,WAAW,MAAM,aAAa,KAAA,CAAS,GAC3EK,IAAQC,QAAeC,GAAmBL,GAAU,OAAOM,GAAQ,KAAK,CAAC,GACzEC,IAASH,QAAeI,EAAK,UAAU,WAAW,GAClDC,IAAOC,EAAI,EAAK,GAChBC,IAAWD,EAAI,EAAK;EAE1B,GAAMD,IAAO,MAAW;GACtB,AAAIG,KAAQd,EAAI,WAAW,MAAM,iBAAiB;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,GAA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AAA,CAAA,KAAAkE,EAAA,IAAA,EAAA;;;;;;;;GAMxBtG,EAIEa,IAAA;IAHQ,MAAMgC,EAAA;IAAA,iBAAA,AAAA4C,EAAA,QAAA,MAAA,EAAQ,QAAAC;IACrB,OAAO/D,EAAM;IACb,kBAAkB4C"}
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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,MAAK;SACJ,cAAYiD,EAAK;SACjB,OAAOA,EAAK;SACb,UAAS;SACT,OAAM;SACN,6BAAA;SACC,YAAUA,EAAK;SACf,UAAK,MAAEgB,EAAOhB,EAAK,IAAImB,CAAG;QAE3BrE,GAAAA,CAAAA,EAAqCI,GAAA;SAA3B,MAAMN,EAAAyG,CAAA;SAAS,MAAM;4CAIrC,GAAA,GAAA,EAAA,GAAA,GAAArF,CAAA,GAAA,AAAAgE,EAAA,OAAAjF,EAAqD,OAAA;SAAhD,MAAK;SAAY,OAAM;;QAE9BA,EAWS,UAAA;SAVP,MAAK;SACL,MAAK;SACL,UAAS;SACT,OAAM;SACN,wBAAA;SACA,6BAAA;SACC,SAAOqE;QAERtE,GAAAA,CAAAA,EAAmCI,GAAA;SAAzB,MAAMN,EAAA2G,CAAA;SAAO,MAAM;QAAM9F,GAAAA,MAAAA,GAAAA,CAAAA,MAAAA,CAAAA,GAAAA,EAAA,MACnCC,EAAGd,EAAA2E,CAAA,CAAgB,CAAC,MAAM,GAAA,CAAA,CAAA,CAAA;QAGpB3E,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 +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'\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 { tool: current, setTool } = useTool()\nconst active = computed(() => current.value === props.tool)\n// A host tool has no built-in name or icon: `label` and the slot supply them.\nconst name = computed(() => props.label ?? TOOL_LABELS[props.tool] ?? props.tool)\nconst icon = computed(() => ICONS[props.tool])\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 } 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 +1 @@
1
- {"version":3,"file":"InkToolButton.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkToolButton.vue"],"names":[],"mappings":"AAuFA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM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AAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -1,11 +1,12 @@
1
- import { useTool as e } from "../composables/useTool.js";
2
- import t from "./InkIcon.js";
3
- import { computed as n, createBlock as r, createCommentVNode as i, defineComponent as a, mergeProps as o, openBlock as s, renderSlot as c, unref as l, withCtx as u } from "vue";
4
- import { TOOL_LABELS as d } from "@inkbar/core/dom";
5
- import { ToolbarButton as f } from "reka-ui";
6
- import { Highlighter as p, MessageSquare as m, PenLine as h, PenTool as g, Signature as _, Square as v, SquareDashedMousePointer as y, TextCursor as b, Type as x } from "@inkbar/icons";
1
+ import { useInkContext as e } from "../context.js";
2
+ import { useTool as t } from "../composables/useTool.js";
3
+ import n from "./InkIcon.js";
4
+ import { computed as r, createBlock as i, createCommentVNode as a, defineComponent as o, mergeProps as s, openBlock as c, renderSlot as l, unref as u, withCtx as d } from "vue";
5
+ import { TOOL_LABELS as f } from "@inkbar/core/dom";
6
+ import { ToolbarButton as p } from "reka-ui";
7
+ import { Highlighter as m, MessageSquare as h, PenLine as g, PenTool as _, Signature as v, Square as y, SquareDashedMousePointer as b, TextCursor as x, Type as S } from "@inkbar/icons";
7
8
  //#region src/components/InkToolButton.vue?vue&type=script&setup=true&lang.ts
8
- var S = /*@__PURE__*/ a({
9
+ var C = /*@__PURE__*/ o({
9
10
  __name: "InkToolButton",
10
11
  props: {
11
12
  tool: {},
@@ -15,37 +16,37 @@ var S = /*@__PURE__*/ a({
15
16
  default: !1
16
17
  }
17
18
  },
18
- setup(a) {
19
- let S = {
20
- "select-text": b,
21
- select: y,
22
- highlight: p,
23
- "redact-area": v,
24
- sketch: g,
25
- draw: h,
26
- note: m,
27
- freetext: x,
28
- signature: _
29
- }, C = a, { tool: w, setTool: T } = e(), E = n(() => w.value === C.tool), D = n(() => C.label ?? d[C.tool] ?? C.tool), O = n(() => S[C.tool]), k = n(() => ({
30
- "aria-pressed": String(E.value),
31
- "aria-label": D.value,
32
- title: D.value,
33
- onClick: () => T(C.tool)
19
+ setup(o) {
20
+ let C = {
21
+ "select-text": x,
22
+ select: b,
23
+ highlight: m,
24
+ "redact-area": y,
25
+ sketch: _,
26
+ draw: g,
27
+ note: h,
28
+ freetext: S,
29
+ signature: v
30
+ }, w = o, T = e("InkToolButton"), { tool: E, setTool: D } = t(), O = r(() => E.value === w.tool), k = r(() => [...T.hostTools.value ?? [], ...T.pluginHost.value?.tools ?? []].find((e) => e.id === w.tool)), A = r(() => w.label ?? f[w.tool] ?? k.value?.label ?? w.tool), j = r(() => C[w.tool] ?? k.value?.icon), M = r(() => ({
31
+ "aria-pressed": String(O.value),
32
+ "aria-label": A.value,
33
+ title: A.value,
34
+ onClick: () => D(w.tool)
34
35
  }));
35
- return (e, n) => (s(), r(l(f), o({
36
- "as-child": a.asChild,
36
+ return (e, t) => (c(), i(u(p), s({
37
+ "as-child": o.asChild,
37
38
  class: "ink-tool-button",
38
39
  "data-ink-tool-button": "",
39
- "data-tool": a.tool,
40
- "data-state": E.value ? "on" : "off"
41
- }, k.value), {
42
- default: u(() => [c(e.$slots, "default", {
43
- active: E.value,
44
- label: D.value
45
- }, () => [O.value ? (s(), r(t, {
40
+ "data-tool": o.tool,
41
+ "data-state": O.value ? "on" : "off"
42
+ }, M.value), {
43
+ default: d(() => [l(e.$slots, "default", {
44
+ active: O.value,
45
+ label: A.value
46
+ }, () => [j.value ? (c(), i(n, {
46
47
  key: 0,
47
- icon: O.value
48
- }, null, 8, ["icon"])) : i("", !0)])]),
48
+ icon: j.value
49
+ }, null, 8, ["icon"])) : a("", !0)])]),
49
50
  _: 3
50
51
  }, 16, [
51
52
  "as-child",
@@ -55,6 +56,6 @@ var S = /*@__PURE__*/ a({
55
56
  }
56
57
  });
57
58
  //#endregion
58
- export { S as default };
59
+ export { C as default };
59
60
 
60
61
  //# sourceMappingURL=InkToolButton.vue_vue_type_script_setup_true_lang.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InkToolButton.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_mergeProps","_withCtx","_renderSlot","InkIcon","_createCommentVNode","InkIcon_default","InkToolButton_vue_vue_type_script_setup_true_lang_default","ICONS","TextCursor","SquareDashedMousePointer","Highlighter","Square","PenTool","PenLine","MessageSquare","Type","Signature","props","__props","current","useTool","active","computed","name","TOOL_LABELS","icon","attrs","setTool","openBlock","createBlock","unref","ToolbarButton","mergeProps","withCtx","renderSlot","_ctx","createCommentVNode"],"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'\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 { tool: current, setTool } = useTool()\nconst active = computed(() => current.value === props.tool)\n// A host tool has no built-in name or icon: `label` and the slot supply them.\nconst name = computed(() => props.label ?? TOOL_LABELS[props.tool] ?? props.tool)\nconst icon = computed(() => ICONS[props.tool])\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":";;;;;;;;;;;;;;;;;;EAuBA,IAAMU,IAAqD;GACzD,eAAeC;GACf,QAAQC;GACR,WAAWC;GACX,eAAeC;GACf,QAAQC;GACR,MAAMC;GACN,MAAMC;GACN,UAAUC;GACV,WAAWC;EACb,GAEMC,IAAQC,GAKR,EAAE,MAAMC,GAAS,eAAYC,EAAQ,GACrCC,IAASC,QAAeH,EAAQ,UAAUF,EAAM,IAAI,GAEpDM,IAAOD,QAAeL,EAAM,SAASO,EAAYP,EAAM,SAASA,EAAM,IAAI,GAC1EQ,IAAOH,QAAef,EAAMU,EAAM,KAAK,GAEvCS,IAAQJ,SAAgB;GAC5B,gBAAgB,OAAOD,EAAO,KAAK;GACnC,cAAcE,EAAK;GACnB,OAAOA,EAAK;GACZ,eAAeI,EAAQV,EAAM,IAAI;EACnC,EAAE;oBAIApB,EAAA,GAAAC,EASgBC,EAAAgC,CAAA,GAThB/B,EASgB;GARb,YAAUkB,EAAA;GACX,OAAM;GACN,wBAAA;GACC,aAAWA,EAAA;GACX,cAAYG,EAAA,QAAM,OAAA;EACX,GAAAK,EAAA,KAAK,GAAA;GAEb,SAAAzB,QAAgF,CAAhFC,EAAgFiC,EAAA,QAAA,WAAA;IAAzE,QAAQd,EAAA;IAAS,OAAOE,EAAA;GAA/B,SAAgF,CAA5BE,EAAA,SAAf5B,EAAA,GAAAC,EAAoCK,GAAA;;IAAd,MAAMsB,EAAA"}
1
+ {"version":3,"file":"InkToolButton.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_mergeProps","_withCtx","_renderSlot","InkIcon","_createCommentVNode","InkIcon_default","InkToolButton_vue_vue_type_script_setup_true_lang_default","ICONS","TextCursor","SquareDashedMousePointer","Highlighter","Square","PenTool","PenLine","MessageSquare","Type","Signature","props","__props","ctx","useInkContext","current","useTool","active","computed","own","t","name","TOOL_LABELS","icon","attrs","setTool","openBlock","createBlock","unref","ToolbarButton","mergeProps","withCtx","renderSlot","_ctx","createCommentVNode"],"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":";;;;;;;;;;;;;;;;;;;EAwBA,IAAMU,IAAqD;GACzD,eAAeC;GACf,QAAQC;GACR,WAAWC;GACX,eAAeC;GACf,QAAQC;GACR,MAAMC;GACN,MAAMC;GACN,UAAUC;GACV,WAAWC;EACb,GAEMC,IAAQC,GAKRC,IAAMC,EAAc,eAAe,GACnC,EAAE,MAAMC,GAAS,eAAYC,EAAQ,GACrCC,IAASC,QAAeH,EAAQ,UAAUJ,EAAM,IAAI,GAEpDQ,IAAMD,QACV,CAAC,GAAIL,EAAI,UAAU,SAAS,CAAC,GAAI,GAAIA,EAAI,WAAW,OAAO,SAAS,CAAC,CAAE,CAAC,CAAC,MACtE,MAAMO,EAAE,OAAOT,EAAM,IACxB,CACF,GAEMU,IAAOH,QACLP,EAAM,SAASW,EAAYX,EAAM,SAASQ,EAAI,OAAO,SAASR,EAAM,IAC5E,GACMY,IAAOL,QAAejB,EAAMU,EAAM,SAASQ,EAAI,OAAO,IAAI,GAE1DK,IAAQN,SAAgB;GAC5B,gBAAgB,OAAOD,EAAO,KAAK;GACnC,cAAcI,EAAK;GACnB,OAAOA,EAAK;GACZ,eAAeI,EAAQd,EAAM,IAAI;EACnC,EAAE;oBAIApB,EAAA,GAAAC,EASgBC,EAAAoC,CAAA,GAThBnC,EASgB;GARb,YAAUkB,EAAA;GACX,OAAM;GACN,wBAAA;GACC,aAAWA,EAAA;GACX,cAAYK,EAAA,QAAM,OAAA;EACX,GAAAO,EAAA,KAAK,GAAA;GAEb,SAAA7B,QAAgF,CAAhFC,EAAgFqC,EAAA,QAAA,WAAA;IAAzE,QAAQhB,EAAA;IAAS,OAAOI,EAAA;GAA/B,SAAgF,CAA5BE,EAAA,SAAfhC,EAAA,GAAAC,EAAoCK,GAAA;;IAAd,MAAM0B,EAAA"}