@inkbar/vue 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +35 -8
  2. package/dist/components/InkColorMenu.js +7 -0
  3. package/dist/components/InkColorMenu.js.map +1 -0
  4. package/dist/components/InkColorMenu.vue.d.ts +32 -0
  5. package/dist/components/InkColorMenu.vue.d.ts.map +1 -0
  6. package/dist/components/InkColorMenu.vue_vue_type_script_setup_true_lang.js +152 -0
  7. package/dist/components/InkColorMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  8. package/dist/components/InkHighlightMenu.js +7 -0
  9. package/dist/components/InkHighlightMenu.js.map +1 -0
  10. package/dist/components/InkHighlightMenu.vue.d.ts +17 -0
  11. package/dist/components/InkHighlightMenu.vue.d.ts.map +1 -0
  12. package/dist/components/InkHighlightMenu.vue_vue_type_script_setup_true_lang.js +140 -0
  13. package/dist/components/InkHighlightMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  14. package/dist/components/InkLineStyleMenu.js +7 -0
  15. package/dist/components/InkLineStyleMenu.js.map +1 -0
  16. package/dist/components/InkLineStyleMenu.vue.d.ts +14 -0
  17. package/dist/components/InkLineStyleMenu.vue.d.ts.map +1 -0
  18. package/dist/components/InkLineStyleMenu.vue_vue_type_script_setup_true_lang.js +109 -0
  19. package/dist/components/InkLineStyleMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  20. package/dist/components/InkRoot.js.map +1 -1
  21. package/dist/components/InkRoot.vue.d.ts +606 -62
  22. package/dist/components/InkRoot.vue.d.ts.map +1 -1
  23. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js +117 -88
  24. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js.map +1 -1
  25. package/dist/components/InkShapeMenu.js +7 -0
  26. package/dist/components/InkShapeMenu.js.map +1 -0
  27. package/dist/components/InkShapeMenu.vue.d.ts +18 -0
  28. package/dist/components/InkShapeMenu.vue.d.ts.map +1 -0
  29. package/dist/components/InkShapeMenu.vue_vue_type_script_setup_true_lang.js +118 -0
  30. package/dist/components/InkShapeMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  31. package/dist/components/InkSignatureDialog.js +7 -0
  32. package/dist/components/InkSignatureDialog.js.map +1 -0
  33. package/dist/components/InkSignatureDialog.vue.d.ts +21 -0
  34. package/dist/components/InkSignatureDialog.vue.d.ts.map +1 -0
  35. package/dist/components/InkSignatureDialog.vue_vue_type_script_setup_true_lang.js +58 -0
  36. package/dist/components/InkSignatureDialog.vue_vue_type_script_setup_true_lang.js.map +1 -0
  37. package/dist/components/InkSignatureMenu.js +7 -0
  38. package/dist/components/InkSignatureMenu.js.map +1 -0
  39. package/dist/components/InkSignatureMenu.vue.d.ts +20 -0
  40. package/dist/components/InkSignatureMenu.vue.d.ts.map +1 -0
  41. package/dist/components/InkSignatureMenu.vue_vue_type_script_setup_true_lang.js +213 -0
  42. package/dist/components/InkSignatureMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  43. package/dist/components/InkTextStyleMenu.js +7 -0
  44. package/dist/components/InkTextStyleMenu.js.map +1 -0
  45. package/dist/components/InkTextStyleMenu.vue.d.ts +14 -0
  46. package/dist/components/InkTextStyleMenu.vue.d.ts.map +1 -0
  47. package/dist/components/InkTextStyleMenu.vue_vue_type_script_setup_true_lang.js +200 -0
  48. package/dist/components/InkTextStyleMenu.vue_vue_type_script_setup_true_lang.js.map +1 -0
  49. package/dist/components/InkThreadPopover.js +7 -0
  50. package/dist/components/InkThreadPopover.js.map +1 -0
  51. package/dist/components/{InkNotePopover.vue.d.ts → InkThreadPopover.vue.d.ts} +4 -4
  52. package/dist/components/InkThreadPopover.vue.d.ts.map +1 -0
  53. package/dist/components/{InkNotePopover.vue_vue_type_script_setup_true_lang.js → InkThreadPopover.vue_vue_type_script_setup_true_lang.js} +45 -43
  54. package/dist/components/InkThreadPopover.vue_vue_type_script_setup_true_lang.js.map +1 -0
  55. package/dist/components/InkToolButton.js.map +1 -1
  56. package/dist/components/InkToolButton.vue.d.ts.map +1 -1
  57. package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js +27 -20
  58. package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  59. package/dist/components/InkViewport.js.map +1 -1
  60. package/dist/components/InkViewport.vue.d.ts +1 -1
  61. package/dist/components/InkViewport.vue.d.ts.map +1 -1
  62. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js +6 -0
  63. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js.map +1 -1
  64. package/dist/components/SignatureForm.js +7 -0
  65. package/dist/components/SignatureForm.js.map +1 -0
  66. package/dist/components/SignatureForm.vue.d.ts +14 -0
  67. package/dist/components/SignatureForm.vue.d.ts.map +1 -0
  68. package/dist/components/SignatureForm.vue_vue_type_script_setup_true_lang.js +181 -0
  69. package/dist/components/SignatureForm.vue_vue_type_script_setup_true_lang.js.map +1 -0
  70. package/dist/composables/useAnnotations.d.ts +1577 -185
  71. package/dist/composables/useAnnotations.d.ts.map +1 -1
  72. package/dist/composables/useAnnotations.js.map +1 -1
  73. package/dist/composables/useToolOptions.d.ts +11 -0
  74. package/dist/composables/useToolOptions.d.ts.map +1 -0
  75. package/dist/composables/useToolOptions.js +16 -0
  76. package/dist/composables/useToolOptions.js.map +1 -0
  77. package/dist/composables/useToolStyle.d.ts +32 -0
  78. package/dist/composables/useToolStyle.d.ts.map +1 -0
  79. package/dist/composables/useToolStyle.js +24 -0
  80. package/dist/composables/useToolStyle.js.map +1 -0
  81. package/dist/context.d.ts +14 -2
  82. package/dist/context.d.ts.map +1 -1
  83. package/dist/context.js.map +1 -1
  84. package/dist/index.d.ts +12 -2
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.js +33 -24
  87. package/package.json +5 -5
  88. package/dist/components/InkNotePopover.js +0 -7
  89. package/dist/components/InkNotePopover.js.map +0 -1
  90. package/dist/components/InkNotePopover.vue.d.ts.map +0 -1
  91. package/dist/components/InkNotePopover.vue_vue_type_script_setup_true_lang.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"InkRoot.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkRoot.vue"],"names":[],"mappings":"AA2RA,OAAO,EAAE,QAAQ,EAAgB,MAAM,cAAc,CAAA;AAcrD,OAAO,EAAqB,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAA;AAI/E,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,SAAS,EACV,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAkB,MAAM,EAAY,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAGnF,KAAK,WAAW,GAAG;IACf,GAAG,EAAE,cAAc,GAAG,IAAI,CAAA;IAC1B,MAAM,EAAE,SAAS,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,wFAAwF;IACxF,QAAQ,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAA;IACzC;;;OAGG;IACH,WAAW,CAAC,EAAE,UAAU,EAAE,GAAG,SAAS,CAAA;IACtC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;IAC5B,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAC;AAoRJ,QAAA,IAAI,OAAO;;;CAAW,CAAC;AACvB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAG/C,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6EAKd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -1,12 +1,12 @@
1
1
  import { provideInkContext as e } from "../context.js";
2
2
  import { useReadable as t } from "../use-readable.js";
3
3
  import { createRefHistory as n } from "../ref-history.js";
4
- import { computed as r, createBlock as i, defineComponent as a, onBeforeUnmount as o, onMounted as s, onUpdated as c, openBlock as l, ref as u, renderSlot as d, shallowRef as f, unref as p, useTemplateRef as m, watch as h, withCtx as g } from "vue";
5
- import { InkError as _, openDocument as v } from "@inkbar/core";
6
- import { cssVariableDefaults as y } from "@inkbar/core/dom";
7
- import { Primitive as b } from "reka-ui";
4
+ import { computed as r, createBlock as ee, defineComponent as i, onBeforeUnmount as a, onMounted as o, onUpdated as s, openBlock as c, ref as l, renderSlot as u, shallowRef as d, unref as f, useTemplateRef as p, watch as m, withCtx as h } from "vue";
5
+ import { InkError as g, createMemorySignatureStore as _, createSignatureLibrary as v, openDocument as y } from "@inkbar/core";
6
+ import { FONT_FAMILIES as b, SIGNATURE_FONTS as x, createToolOptions as S, cssVariableDefaults as C, trackToolStyle as w } from "@inkbar/core/dom";
7
+ import { Primitive as T } from "reka-ui";
8
8
  //#region src/components/InkRoot.vue?vue&type=script&setup=true&lang.ts
9
- var x = /*@__PURE__*/ a({
9
+ var E = /*@__PURE__*/ i({
10
10
  __name: "InkRoot",
11
11
  props: {
12
12
  src: {},
@@ -15,6 +15,10 @@ var x = /*@__PURE__*/ a({
15
15
  defaults: { default: void 0 },
16
16
  annotations: { default: void 0 },
17
17
  tool: { default: void 0 },
18
+ tools: { default: void 0 },
19
+ fonts: { default: void 0 },
20
+ signatures: { default: void 0 },
21
+ signatureFonts: { default: void 0 },
18
22
  page: { default: void 0 },
19
23
  zoom: { default: void 0 },
20
24
  history: {
@@ -36,127 +40,152 @@ var x = /*@__PURE__*/ a({
36
40
  "error",
37
41
  "activate"
38
42
  ],
39
- setup(a, { expose: x, emit: S }) {
40
- let C = a, w = S, T = m("primitive"), E = f(null);
41
- function D() {
42
- let e = T.value?.$el;
43
- E.value = e instanceof HTMLElement ? e : null;
43
+ setup(i, { expose: E, emit: te }) {
44
+ let D = i, O = te, k = p("primitive"), A = d(null);
45
+ function j() {
46
+ let e = k.value?.$el;
47
+ A.value = e instanceof HTMLElement ? e : null;
44
48
  }
45
- let O = f(null), k = f(null), A = t(() => O.value?.status ?? null, { state: "idle" }), j = r(() => k.value ?? A.value), M = t(() => O.value?.annotations.list ?? null, []), N = t(() => O.value?.annotations.selection ?? null, []), P = f(null), F = f(null), I = u(C.tool ?? "view"), L = u(null), R = r(() => C.annotations !== void 0);
46
- function z(e) {
49
+ let M = d(null), N = d(null), P = t(() => M.value?.status ?? null, { state: "idle" }), F = r(() => N.value ?? P.value), I = t(() => M.value?.annotations.list ?? null, []), L = t(() => M.value?.annotations.selection ?? null, []), R = d(null), z = d(null), B = l(D.tool ?? "select-text"), V = l(null), H = r(() => D.annotations !== void 0);
50
+ function U(e) {
47
51
  return e === null ? null : typeof e == "string" ? e : "key" in e ? e.key : e;
48
52
  }
49
- let B = 0;
50
- function V() {
51
- O.value?.destroy(), O.value = null;
53
+ let W = 0;
54
+ function G() {
55
+ M.value?.destroy(), M.value = null;
52
56
  }
53
- async function H() {
54
- let e = ++B, t = C.src;
55
- if (V(), U.clear(), t === null) {
56
- k.value = null;
57
+ async function K() {
58
+ let e = ++W, t = D.src;
59
+ if (G(), q.clear(), t === null) {
60
+ N.value = null;
57
61
  return;
58
62
  }
59
- k.value = { state: "loading" }, D();
63
+ N.value = { state: "loading" }, j();
60
64
  let n;
61
65
  try {
62
- n = await v(t, {
63
- assets: C.assets,
64
- password: C.password,
65
- defaults: C.defaults ?? (E.value ? y(E.value) : void 0),
66
- history: R.value ? !1 : C.history ?? !0,
67
- annotations: R.value ? {
66
+ n = await y(t, {
67
+ assets: D.assets,
68
+ password: D.password,
69
+ defaults: D.defaults ?? (A.value ? C(A.value) : void 0),
70
+ history: H.value ? !1 : D.history ?? !0,
71
+ annotations: H.value ? {
68
72
  mode: "controlled",
69
- initial: C.annotations ?? [],
73
+ initial: D.annotations ?? [],
70
74
  onChange: (e, t) => {
71
- w("update:annotations", e), w("change", t);
75
+ O("update:annotations", e), O("change", t);
72
76
  }
73
77
  } : { mode: "uncontrolled" }
74
78
  });
75
79
  } catch (t) {
76
- if (e !== B) return;
77
- let n = t instanceof _ ? t : new _("InvalidPdf", t instanceof Error ? t.message : String(t), {}, t);
78
- k.value = {
80
+ if (e !== W) return;
81
+ let n = t instanceof g ? t : new g("InvalidPdf", t instanceof Error ? t.message : String(t), {}, t);
82
+ N.value = {
79
83
  state: "error",
80
84
  error: n
81
- }, w("error", n);
85
+ }, O("error", n);
82
86
  return;
83
87
  }
84
- if (e !== B) {
88
+ if (e !== W) {
85
89
  n.destroy();
86
90
  return;
87
91
  }
88
- n.annotations.mode === "controlled" && C.annotations !== void 0 && n.annotations.setControlledValue(C.annotations), O.value = n, k.value = null;
92
+ n.annotations.mode === "controlled" && D.annotations !== void 0 && n.annotations.setControlledValue(D.annotations), M.value = n, N.value = null;
89
93
  let r = n.status.get();
90
- r.state === "ready" ? w("ready", n) : r.state === "error" && w("error", r.error);
94
+ r.state === "ready" ? O("ready", n) : r.state === "error" && O("error", r.error);
91
95
  }
92
- let U = n({
93
- source: () => C.annotations,
94
- apply: (e) => O.value?.annotations.replaceAll(e, "history"),
95
- enabled: r(() => R.value && C.history === !0)
96
- }), W = t(() => O.value?.history.canUndo ?? null, !1), G = t(() => O.value?.history.canRedo ?? null, !1), K = {
97
- canUndo: r(() => R.value ? U.canUndo.value : W.value),
98
- canRedo: r(() => R.value ? U.canRedo.value : G.value),
99
- undo: () => R.value ? U.undo() : O.value?.history.undo(),
100
- redo: () => R.value ? U.redo() : O.value?.history.redo(),
101
- clear: () => R.value ? U.clear() : O.value?.history.clear(),
96
+ let q = n({
97
+ source: () => D.annotations,
98
+ apply: (e) => M.value?.annotations.replaceAll(e, "history"),
99
+ enabled: r(() => H.value && D.history === !0)
100
+ }), J = t(() => M.value?.history.canUndo ?? null, !1), Y = t(() => M.value?.history.canRedo ?? null, !1), X = {
101
+ canUndo: r(() => H.value ? q.canUndo.value : J.value),
102
+ canRedo: r(() => H.value ? q.canRedo.value : Y.value),
103
+ undo: () => H.value ? q.undo() : M.value?.history.undo(),
104
+ redo: () => H.value ? q.redo() : M.value?.history.redo(),
105
+ clear: () => H.value ? q.clear() : M.value?.history.clear(),
102
106
  batch: (e) => {
103
- R.value ? U.batch(e) : O.value ? O.value.history.batch(e) : e();
107
+ H.value ? q.batch(e) : M.value ? M.value.history.batch(e) : e();
104
108
  }
105
- };
106
- s(() => {
107
- D(), H();
108
- }), c(D), h([() => z(C.src), () => C.password], () => void H()), h(() => C.annotations, (e) => {
109
- e && O.value?.annotations.mode === "controlled" && O.value.annotations.setControlledValue(e);
110
- }), h(() => C.tool, (e) => {
111
- e && (I.value = e);
109
+ }, Z = d(null), Q;
110
+ m(M, (e) => {
111
+ if (!e) {
112
+ Z.value = null, Q = void 0;
113
+ return;
114
+ }
115
+ let t = w({
116
+ store: e.annotations,
117
+ history: { batch: (e) => X.batch(e) },
118
+ tools: D.tools,
119
+ tool: B.value
120
+ });
121
+ Q = (e) => t.setTool(e), Z.value = t.toolStyle;
122
+ }, {
123
+ immediate: !0,
124
+ flush: "sync"
125
+ }), m(B, (e) => Q?.(e)), o(() => {
126
+ j(), K();
127
+ }), s(j), m([() => U(D.src), () => D.password], () => void K()), m(() => D.annotations, (e) => {
128
+ e && M.value?.annotations.mode === "controlled" && M.value.annotations.setControlledValue(e);
129
+ }), m(() => D.tool, (e) => {
130
+ e && (B.value = e);
112
131
  });
113
- function q(e) {
114
- I.value = e, w("update:tool", e);
132
+ function ne(e) {
133
+ B.value = e, O("update:tool", e);
115
134
  }
116
- return o(() => {
117
- B++, V();
118
- }), e({
119
- assets: r(() => C.assets),
120
- document: O,
121
- status: j,
122
- annotations: M,
123
- selection: N,
124
- viewport: P,
125
- tools: F,
126
- tool: I,
127
- setTool: q,
128
- zoomModel: r(() => C.zoom),
129
- pageModel: r(() => C.page),
130
- reportZoom: (e) => w("update:zoom", e),
131
- reportPage: (e) => w("update:page", e),
132
- activated: L,
135
+ a(() => {
136
+ W++, G();
137
+ });
138
+ let $ = r(() => v(D.signatures ?? _()));
139
+ m($, (e) => void e.refresh(), { immediate: !0 });
140
+ let re = S();
141
+ return e({
142
+ assets: r(() => D.assets),
143
+ document: M,
144
+ status: F,
145
+ annotations: I,
146
+ selection: L,
147
+ viewport: R,
148
+ tools: z,
149
+ tool: B,
150
+ setTool: ne,
151
+ hostTools: r(() => D.tools),
152
+ fonts: r(() => D.fonts ?? b),
153
+ toolOptions: re,
154
+ signatures: $,
155
+ signatureFonts: r(() => D.signatureFonts ?? x),
156
+ toolStyle: Z,
157
+ zoomModel: r(() => D.zoom),
158
+ pageModel: r(() => D.page),
159
+ reportZoom: (e) => O("update:zoom", e),
160
+ reportPage: (e) => O("update:page", e),
161
+ activated: V,
133
162
  setActivated(e) {
134
- L.value = e, e && w("activate", e);
163
+ V.value = e, e && O("activate", e);
135
164
  },
136
- history: K,
137
- rootEl: E
138
- }), x({
139
- document: O,
140
- status: j,
141
- rootEl: E,
142
- history: K
143
- }), (e, t) => (l(), i(p(b), {
165
+ history: X,
166
+ rootEl: A
167
+ }), E({
168
+ document: M,
169
+ status: F,
170
+ rootEl: A,
171
+ history: X
172
+ }), (e, t) => (c(), ee(f(T), {
144
173
  ref_key: "primitive",
145
- ref: T,
146
- "as-child": C.asChild,
174
+ ref: k,
175
+ "as-child": D.asChild,
147
176
  as: "div",
148
177
  "data-ink-root": "",
149
- "data-state": j.value.state
178
+ "data-state": F.value.state
150
179
  }, {
151
- default: g(() => [d(e.$slots, "default", {
152
- status: j.value,
153
- document: O.value
180
+ default: h(() => [u(e.$slots, "default", {
181
+ status: F.value,
182
+ document: M.value
154
183
  })]),
155
184
  _: 3
156
185
  }, 8, ["as-child", "data-state"]));
157
186
  }
158
187
  });
159
188
  //#endregion
160
- export { x as default };
189
+ export { E as default };
161
190
 
162
191
  //# sourceMappingURL=InkRoot.vue_vue_type_script_setup_true_lang.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InkRoot.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_withCtx","_renderSlot","InkRoot_vue_vue_type_script_setup_true_lang_default","__expose","__emit","props","__props","emit","primitive","useTemplateRef","rootEl","shallowRef","syncRootEl","el","document","override","documentStatus","useReadable","status","computed","annotationList","selection","viewport","tools","internalTool","ref","activated","controlled","identity","src","generation","release","open","gen","refHistory","doc","openDocument","cssVariableDefaults","next","change","cause","error","InkError","s","createRefHistory","list","coreCanUndo","coreCanRedo","inkHistory","fn","onMounted","onUpdated","watch","t","setTool","id","onBeforeUnmount","provideInkContext","z","p","openBlock","createBlock","unref","Primitive","withCtx","renderSlot","_ctx"],"sources":["../../src/components/InkRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { InkError, openDocument } from '@inkbar/core'\nimport { cssVariableDefaults } from '@inkbar/core/dom'\nimport { Primitive } from 'reka-ui'\nimport {\n computed,\n onBeforeUnmount,\n onMounted,\n onUpdated,\n ref,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { provideInkContext, type InkHistory, type InkStatus } from '../context'\nimport { createRefHistory } from '../ref-history'\nimport { useReadable } from '../use-readable'\n\nimport type {\n Annotation,\n AnnotationChange,\n AnnotationDefaults,\n DocumentSource,\n InkDocument,\n PdfAssets,\n} from '@inkbar/core'\nimport type { ToolController, ToolId, Viewport, ZoomValue } from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{\n src: DocumentSource | null\n assets: PdfAssets\n password?: string | undefined\n /** Colour defaults. Without it, the theme's CSS variables on the root element apply. */\n defaults?: AnnotationDefaults | undefined\n /**\n * Pass (with v-model) to put annotations under the host's control. The mode is fixed when a\n * document opens: passing or dropping this prop later takes effect on the next open.\n */\n annotations?: Annotation[] | undefined\n tool?: ToolId | undefined\n page?: number | undefined\n zoom?: ZoomValue | undefined\n /** Undo history. Defaults to on for uncontrolled, off for controlled. */\n history?: boolean | undefined\n asChild?: boolean\n }>(),\n {\n password: undefined,\n defaults: undefined,\n annotations: undefined,\n tool: undefined,\n page: undefined,\n zoom: undefined,\n history: undefined,\n asChild: false,\n }\n)\n\nconst emit = defineEmits<{\n 'update:annotations': [next: Annotation[]]\n change: [change: AnnotationChange]\n 'update:tool': [tool: ToolId]\n 'update:page': [page: number]\n 'update:zoom': [zoom: ZoomValue]\n ready: [doc: InkDocument]\n error: [error: InkError]\n activate: [id: string]\n}>()\n\ntype TestHookElement = HTMLElement & { __inkDocument?: InkDocument | undefined }\n\n// A template ref on Primitive is a component instance; the context needs its element.\nconst primitive = useTemplateRef<{ $el: unknown }>('primitive')\nconst rootEl = shallowRef<HTMLElement | null>(null)\nfunction syncRootEl(): void {\n const el = primitive.value?.$el\n rootEl.value = el instanceof HTMLElement ? el : null\n}\n\nconst document = shallowRef<InkDocument | null>(null)\n/** Overrides the document's status while opening, and when opening itself failed. */\nconst override = shallowRef<InkStatus | null>(null)\nconst idle: InkStatus = { state: 'idle' }\nconst documentStatus = useReadable<InkStatus>(() => document.value?.status ?? null, idle)\nconst status = computed<InkStatus>(() => override.value ?? documentStatus.value)\nconst annotationList = useReadable<readonly Annotation[]>(\n () => document.value?.annotations.list ?? null,\n []\n)\nconst selection = useReadable<readonly string[]>(\n () => document.value?.annotations.selection ?? null,\n []\n)\nconst viewport = shallowRef<Viewport | null>(null)\nconst tools = shallowRef<ToolController | null>(null)\nconst internalTool = ref<ToolId>(props.tool ?? 'view')\nconst activated = ref<string | null>(null)\n\nconst controlled = computed(() => props.annotations !== undefined)\n\n/** Signed URLs change; the key does not. Bytes and Blobs are their own identity. */\nfunction identity(src: DocumentSource | null): unknown {\n if (src === null) return null\n if (typeof src === 'string') return src\n if ('key' in src) return src.key\n return src\n}\n\nfunction setTestHook(doc: InkDocument | undefined): void {\n if (import.meta.env.DEV && rootEl.value)\n (rootEl.value as TestHookElement).__inkDocument = doc\n}\n\nlet generation = 0\nfunction release(): void {\n document.value?.destroy()\n document.value = null\n setTestHook(undefined)\n}\n\nasync function open(): Promise<void> {\n const gen = ++generation\n const src = props.src\n release()\n refHistory.clear()\n if (src === null) {\n override.value = null\n return\n }\n override.value = { state: 'loading' }\n syncRootEl()\n let doc: InkDocument\n try {\n doc = await openDocument(src, {\n assets: props.assets,\n password: props.password,\n defaults:\n props.defaults ?? (rootEl.value ? cssVariableDefaults(rootEl.value) : undefined),\n // Controlled hosts get the ref history below; core's own stack stays off.\n history: controlled.value ? false : (props.history ?? true),\n annotations: controlled.value\n ? {\n mode: 'controlled',\n initial: props.annotations ?? [],\n onChange: (next, change) => {\n emit('update:annotations', next)\n emit('change', change)\n },\n }\n : { mode: 'uncontrolled' },\n })\n } catch (cause) {\n if (gen !== generation) return\n const error =\n cause instanceof InkError\n ? cause\n : new InkError(\n 'InvalidPdf',\n cause instanceof Error ? cause.message : String(cause),\n {},\n cause\n )\n override.value = { state: 'error', error }\n emit('error', error)\n return\n }\n if (gen !== generation) {\n doc.destroy()\n return\n }\n // The prop may have changed while the file loaded, when there was no store to apply it to.\n if (doc.annotations.mode === 'controlled' && props.annotations !== undefined)\n doc.annotations.setControlledValue(props.annotations)\n document.value = doc\n override.value = null\n setTestHook(doc)\n const s = doc.status.get()\n if (s.state === 'ready') emit('ready', doc)\n else if (s.state === 'error') emit('error', s.error)\n}\n\nconst refHistory = createRefHistory({\n source: () => props.annotations,\n apply: (list) => document.value?.annotations.replaceAll(list, 'history'),\n enabled: computed(() => controlled.value && props.history === true),\n})\nconst coreCanUndo = useReadable(() => document.value?.history.canUndo ?? null, false)\nconst coreCanRedo = useReadable(() => document.value?.history.canRedo ?? null, false)\nconst inkHistory: InkHistory = {\n canUndo: computed(() =>\n controlled.value ? refHistory.canUndo.value : coreCanUndo.value\n ),\n canRedo: computed(() =>\n controlled.value ? refHistory.canRedo.value : coreCanRedo.value\n ),\n undo: () => (controlled.value ? refHistory.undo() : document.value?.history.undo()),\n redo: () => (controlled.value ? refHistory.redo() : document.value?.history.redo()),\n clear: () => (controlled.value ? refHistory.clear() : document.value?.history.clear()),\n batch: (fn) => {\n if (controlled.value) refHistory.batch(fn)\n else if (document.value) document.value.history.batch(fn)\n else fn()\n },\n}\n\n// Open on the client only: on the server InkRoot renders its empty slot.\nonMounted(() => {\n syncRootEl()\n void open()\n})\nonUpdated(syncRootEl)\n\n// Separate sources, so a new `{ url, key }` object with the same key compares equal.\nwatch([() => identity(props.src), () => props.password], () => void open())\n\nwatch(\n () => props.annotations,\n (next) => {\n if (next && document.value?.annotations.mode === 'controlled')\n document.value.annotations.setControlledValue(next)\n }\n)\n\nwatch(\n () => props.tool,\n (t) => {\n if (t) internalTool.value = t\n }\n)\n\nfunction setTool(id: ToolId): void {\n internalTool.value = id\n emit('update:tool', id)\n}\n\nonBeforeUnmount(() => {\n generation++\n release()\n})\n\nprovideInkContext({\n assets: computed(() => props.assets),\n document,\n status,\n annotations: annotationList,\n selection,\n viewport,\n tools,\n tool: internalTool,\n setTool,\n zoomModel: computed(() => props.zoom),\n pageModel: computed(() => props.page),\n reportZoom: (z) => emit('update:zoom', z),\n reportPage: (p) => emit('update:page', p),\n activated,\n setActivated(id) {\n activated.value = id\n if (id) emit('activate', id)\n },\n history: inkHistory,\n rootEl,\n})\n\n// `history` is what `useHistory()` returns inside the root, for hosts that hold a template ref:\n// a controlled host calls `history.clear()` after loading its saved list.\ndefineExpose({ document, status, rootEl, history: inkHistory })\n</script>\n\n<template>\n <Primitive\n ref=\"primitive\"\n :as-child=\"props.asChild\"\n as=\"div\"\n data-ink-root\n :data-state=\"status.state\"\n >\n <slot :status=\"status\" :document=\"document\" />\n </Primitive>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BA,IAAMQ,IAAQC,GA+BRC,IAAOH,GAcPI,IAAYC,EAAiC,WAAW,GACxDC,IAASC,EAA+B,IAAI;EAClD,SAASC,IAAmB;GAC1B,IAAMC,IAAKL,EAAU,OAAO;GAC5B,EAAO,QAAQK,aAAc,cAAcA,IAAK;EAClD;EAEA,IAAMC,IAAWH,EAA+B,IAAI,GAE9CI,IAAWJ,EAA6B,IAAI,GAE5CK,IAAiBC,QAA6BH,EAAS,OAAO,UAAU,MAAM,EAD1D,OAAO,OACmD,CAAI,GAClFI,IAASC,QAA0BJ,EAAS,SAASC,EAAe,KAAK,GACzEI,IAAiBH,QACfH,EAAS,OAAO,YAAY,QAAQ,MAC1C,CAAC,CACH,GACMO,IAAYJ,QACVH,EAAS,OAAO,YAAY,aAAa,MAC/C,CAAC,CACH,GACMQ,IAAWX,EAA4B,IAAI,GAC3CY,IAAQZ,EAAkC,IAAI,GAC9Ca,IAAeC,EAAYpB,EAAM,QAAQ,MAAM,GAC/CqB,IAAYD,EAAmB,IAAI,GAEnCE,IAAaR,QAAed,EAAM,gBAAgB,KAAA,CAAS;EAGjE,SAASuB,EAAS,GAAqC;GAIrD,OAHIC,MAAQ,OAAa,OACrB,OAAOA,KAAQ,WAAiBA,IAChC,S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AAmBwB,CAAI;EACtD,CACF,GAEAc,QACQ/C,EAAM,OACX,MAAM;GACL,AAAIgD,MAAG,EAAa,QAAQA;EAC9B,CACF;EAEA,SAASC,EAAQ,GAAkB;GAEjC,AADA,EAAa,QAAQC,GACrBhD,EAAK,eAAegD,CAAE;EACxB;SAEAC,QAAsB;GAEpB,AADA,KACAzB,EAAQ;EACV,CAAC,GAED0B,EAAkB;GAChB,QAAQtC,QAAed,EAAM,MAAM;GACnC;GACA;GACA,aAAae;GACb;GACA;GACA;GACA,MAAMI;GACN;GACA,WAAWL,QAAed,EAAM,IAAI;GACpC,WAAWc,QAAed,EAAM,IAAI;GACpC,aAAa,MAAME,EAAK,eAAemD,CAAC;GACxC,aAAa,MAAMnD,EAAK,eAAeoD,CAAC;GACxC;GACA,aAAa,GAAI;IAEf,AADA,EAAU,QAAQJ,GACdA,KAAIhD,EAAK,YAAYgD,CAAE;GAC7B;GACA,SAASP;GACT;EACF,CAAC,GAID7C,EAAa;GAAE;GAAU;GAAQ;GAAQ,SAAS6C;EAAW,CAAC,cAI5DnD,EAAA,GAAAC,EAQYC,EAAAgE,CAAA,GAAA;GAPN,SAAA;GAAJ,KAAIvD;GACH,YAAUH,EAAM;GACjB,IAAG;GACH,iBAAA;GACC,cAAYa,EAAA,MAAO;;GAEpB,SAAAlB,QAA8C,CAA9CC,EAA8CiE,EAAA,QAAA,WAAA;IAAvC,QAAQhD,EAAA;IAAS,UAAUJ,EAAA"}
1
+ {"version":3,"file":"InkRoot.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_withCtx","_renderSlot","InkRoot_vue_vue_type_script_setup_true_lang_default","__expose","__emit","props","__props","emit","primitive","useTemplateRef","rootEl","shallowRef","syncRootEl","el","document","override","documentStatus","useReadable","status","computed","annotationList","selection","viewport","toolController","internalTool","ref","activated","controlled","identity","src","generation","release","open","gen","refHistory","doc","openDocument","cssVariableDefaults","next","change","cause","error","InkError","s","createRefHistory","list","coreCanUndo","coreCanRedo","inkHistory","fn","toolStyle","setStyleTool","watch","tracker","trackToolStyle","id","onMounted","onUpdated","t","setTool","signatures","createSignatureLibrary","createMemorySignatureStore","lib","toolOptions","createToolOptions","provideInkContext","FONT_FAMILIES","SIGNATURE_FONTS","z","p","openBlock","createBlock","unref","Primitive","withCtx","renderSlot","_ctx"],"sources":["../../src/components/InkRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n createMemorySignatureStore,\n createSignatureLibrary,\n InkError,\n openDocument,\n} from '@inkbar/core'\nimport {\n createToolOptions,\n cssVariableDefaults,\n FONT_FAMILIES,\n SIGNATURE_FONTS,\n trackToolStyle,\n} from '@inkbar/core/dom'\nimport { Primitive } from 'reka-ui'\nimport {\n computed,\n onBeforeUnmount,\n onMounted,\n onUpdated,\n ref,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { provideInkContext, type InkHistory, type InkStatus } from '../context'\nimport { createRefHistory } from '../ref-history'\nimport { useReadable } from '../use-readable'\n\nimport type {\n Annotation,\n AnnotationChange,\n AnnotationDefaults,\n DocumentSource,\n InkDocument,\n PdfAssets,\n SignatureStore,\n} from '@inkbar/core'\nimport type {\n Tool,\n ToolController,\n ToolId,\n ToolStyle,\n Viewport,\n ZoomValue,\n} from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{\n src: DocumentSource | null\n assets: PdfAssets\n password?: string | undefined\n /** Colour defaults. Without it, the theme's CSS variables on the root element apply. */\n defaults?: AnnotationDefaults | undefined\n /**\n * Pass (with v-model) to put annotations under the host's control. The mode is fixed when a\n * document opens: passing or dropping this prop later takes effect on the next open.\n */\n annotations?: Annotation[] | undefined\n tool?: ToolId | undefined\n /**\n * Host tools, added to the built-ins; one with a built-in's id replaces it. Read when a\n * document opens.\n */\n tools?: Tool[] | undefined\n /**\n * The font families text boxes offer, replacing the PDF standard families\n * (`FONT_FAMILIES`). Fonts beyond those are the PDF writer's to embed.\n */\n fonts?: string[] | undefined\n /**\n * Where saved signatures live. Default: memory, gone on reload.\n * `createLocalSignatureStore` keeps them in the browser; a host can keep them anywhere.\n * A new store takes effect at once, for the menus and the `signature` tool alike.\n */\n signatures?: SignatureStore | undefined\n /** The handwriting fonts a typed signature offers; the host loads them. */\n signatureFonts?: string[] | undefined\n page?: number | undefined\n zoom?: ZoomValue | undefined\n /** Undo history. Defaults to on for uncontrolled, off for controlled. */\n history?: boolean | undefined\n asChild?: boolean\n }>(),\n {\n password: undefined,\n defaults: undefined,\n annotations: undefined,\n tool: undefined,\n tools: undefined,\n fonts: undefined,\n signatures: undefined,\n signatureFonts: undefined,\n page: undefined,\n zoom: undefined,\n history: undefined,\n asChild: false,\n }\n)\n\nconst emit = defineEmits<{\n 'update:annotations': [next: Annotation[]]\n change: [change: AnnotationChange]\n 'update:tool': [tool: ToolId]\n 'update:page': [page: number]\n 'update:zoom': [zoom: ZoomValue]\n ready: [doc: InkDocument]\n error: [error: InkError]\n activate: [id: string]\n}>()\n\ntype TestHookElement = HTMLElement & { __inkDocument?: InkDocument | undefined }\n\n// A template ref on Primitive is a component instance; the context needs its element.\nconst primitive = useTemplateRef<{ $el: unknown }>('primitive')\nconst rootEl = shallowRef<HTMLElement | null>(null)\nfunction syncRootEl(): void {\n const el = primitive.value?.$el\n rootEl.value = el instanceof HTMLElement ? el : null\n}\n\nconst document = shallowRef<InkDocument | null>(null)\n/** Overrides the document's status while opening, and when opening itself failed. */\nconst override = shallowRef<InkStatus | null>(null)\nconst idle: InkStatus = { state: 'idle' }\nconst documentStatus = useReadable<InkStatus>(() => document.value?.status ?? null, idle)\nconst status = computed<InkStatus>(() => override.value ?? documentStatus.value)\nconst annotationList = useReadable<readonly Annotation[]>(\n () => document.value?.annotations.list ?? null,\n []\n)\nconst selection = useReadable<readonly string[]>(\n () => document.value?.annotations.selection ?? null,\n []\n)\nconst viewport = shallowRef<Viewport | null>(null)\nconst toolController = shallowRef<ToolController | null>(null)\nconst internalTool = ref<ToolId>(props.tool ?? 'select-text')\nconst activated = ref<string | null>(null)\n\nconst controlled = computed(() => props.annotations !== undefined)\n\n/** Signed URLs change; the key does not. Bytes and Blobs are their own identity. */\nfunction identity(src: DocumentSource | null): unknown {\n if (src === null) return null\n if (typeof src === 'string') return src\n if ('key' in src) return src.key\n return src\n}\n\nfunction setTestHook(doc: InkDocument | undefined): void {\n if (import.meta.env.DEV && rootEl.value)\n (rootEl.value as TestHookElement).__inkDocument = doc\n}\n\nlet generation = 0\nfunction release(): void {\n document.value?.destroy()\n document.value = null\n setTestHook(undefined)\n}\n\nasync function open(): Promise<void> {\n const gen = ++generation\n const src = props.src\n release()\n refHistory.clear()\n if (src === null) {\n override.value = null\n return\n }\n override.value = { state: 'loading' }\n syncRootEl()\n let doc: InkDocument\n try {\n doc = await openDocument(src, {\n assets: props.assets,\n password: props.password,\n defaults:\n props.defaults ?? (rootEl.value ? cssVariableDefaults(rootEl.value) : undefined),\n // Controlled hosts get the ref history below; core's own stack stays off.\n history: controlled.value ? false : (props.history ?? true),\n annotations: controlled.value\n ? {\n mode: 'controlled',\n initial: props.annotations ?? [],\n onChange: (next, change) => {\n emit('update:annotations', next)\n emit('change', change)\n },\n }\n : { mode: 'uncontrolled' },\n })\n } catch (cause) {\n if (gen !== generation) return\n const error =\n cause instanceof InkError\n ? cause\n : new InkError(\n 'InvalidPdf',\n cause instanceof Error ? cause.message : String(cause),\n {},\n cause\n )\n override.value = { state: 'error', error }\n emit('error', error)\n return\n }\n if (gen !== generation) {\n doc.destroy()\n return\n }\n // The prop may have changed while the file loaded, when there was no store to apply it to.\n if (doc.annotations.mode === 'controlled' && props.annotations !== undefined)\n doc.annotations.setControlledValue(props.annotations)\n document.value = doc\n override.value = null\n setTestHook(doc)\n const s = doc.status.get()\n if (s.state === 'ready') emit('ready', doc)\n else if (s.state === 'error') emit('error', s.error)\n}\n\nconst refHistory = createRefHistory({\n source: () => props.annotations,\n apply: (list) => document.value?.annotations.replaceAll(list, 'history'),\n enabled: computed(() => controlled.value && props.history === true),\n})\nconst coreCanUndo = useReadable(() => document.value?.history.canUndo ?? null, false)\nconst coreCanRedo = useReadable(() => document.value?.history.canRedo ?? null, false)\nconst inkHistory: InkHistory = {\n canUndo: computed(() =>\n controlled.value ? refHistory.canUndo.value : coreCanUndo.value\n ),\n canRedo: computed(() =>\n controlled.value ? refHistory.canRedo.value : coreCanRedo.value\n ),\n undo: () => (controlled.value ? refHistory.undo() : document.value?.history.undo()),\n redo: () => (controlled.value ? refHistory.redo() : document.value?.history.redo()),\n clear: () => (controlled.value ? refHistory.clear() : document.value?.history.clear()),\n batch: (fn) => {\n if (controlled.value) refHistory.batch(fn)\n else if (document.value) document.value.history.batch(fn)\n else fn()\n },\n}\n\n/** The document's tool style; it batches through `inkHistory`, whichever mode is on. */\nconst toolStyle = shallowRef<ToolStyle | null>(null)\nlet setStyleTool: ((id: ToolId) => void) | undefined\nwatch(\n document,\n (doc) => {\n if (!doc) {\n toolStyle.value = null\n setStyleTool = undefined\n return\n }\n const tracker = trackToolStyle({\n store: doc.annotations,\n history: { batch: (fn) => inkHistory.batch(fn) },\n tools: props.tools,\n tool: internalTool.value,\n })\n setStyleTool = (id) => tracker.setTool(id)\n toolStyle.value = tracker.toolStyle\n },\n // Sync: the style is in place before InkViewport's watcher mounts the engine with it.\n { immediate: true, flush: 'sync' }\n)\nwatch(internalTool, (id) => setStyleTool?.(id))\n\n// Open on the client only: on the server InkRoot renders its empty slot.\nonMounted(() => {\n syncRootEl()\n void open()\n})\nonUpdated(syncRootEl)\n\n// Separate sources, so a new `{ url, key }` object with the same key compares equal.\nwatch([() => identity(props.src), () => props.password], () => void open())\n\nwatch(\n () => props.annotations,\n (next) => {\n if (next && document.value?.annotations.mode === 'controlled')\n document.value.annotations.setControlledValue(next)\n }\n)\n\nwatch(\n () => props.tool,\n (t) => {\n if (t) internalTool.value = t\n }\n)\n\nfunction setTool(id: ToolId): void {\n internalTool.value = id\n emit('update:tool', id)\n}\n\nonBeforeUnmount(() => {\n generation++\n release()\n})\n\nconst signatures = computed(() =>\n createSignatureLibrary(props.signatures ?? createMemorySignatureStore())\n)\nwatch(signatures, (lib) => void lib.refresh(), { immediate: true })\n/** Tool options last as long as the root; the tool style is per document. */\nconst toolOptions = createToolOptions()\n\nprovideInkContext({\n assets: computed(() => props.assets),\n document,\n status,\n annotations: annotationList,\n selection,\n viewport,\n tools: toolController,\n tool: internalTool,\n setTool,\n hostTools: computed(() => props.tools),\n fonts: computed(() => props.fonts ?? FONT_FAMILIES),\n toolOptions,\n signatures,\n signatureFonts: computed(() => props.signatureFonts ?? SIGNATURE_FONTS),\n toolStyle,\n zoomModel: computed(() => props.zoom),\n pageModel: computed(() => props.page),\n reportZoom: (z) => emit('update:zoom', z),\n reportPage: (p) => emit('update:page', p),\n activated,\n setActivated(id) {\n activated.value = id\n if (id) emit('activate', id)\n },\n history: inkHistory,\n rootEl,\n})\n\n// `history` is what `useHistory()` returns inside the root, for hosts that hold a template ref:\n// a controlled host calls `history.clear()` after loading its saved list.\ndefineExpose({ document, status, rootEl, history: inkHistory })\n</script>\n\n<template>\n <Primitive\n ref=\"primitive\"\n :as-child=\"props.asChild\"\n as=\"div\"\n data-ink-root\n :data-state=\"status.state\"\n >\n <slot :status=\"status\" :document=\"document\" />\n </Primitive>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgDA,IAAMQ,IAAQC,GAqDRC,IAAOH,IAcPI,IAAYC,EAAiC,WAAW,GACxDC,IAASC,EAA+B,IAAI;EAClD,SAASC,IAAmB;GAC1B,IAAMC,IAAKL,EAAU,OAAO;GAC5B,EAAO,QAAQK,aAAc,cAAcA,IAAK;EAClD;EAEA,IAAMC,IAAWH,EAA+B,IAAI,GAE9CI,IAAWJ,EAA6B,IAAI,GAE5CK,IAAiBC,QAA6BH,EAAS,OAAO,UAAU,MAAM,EAD1D,OAAO,OACmD,CAAI,GAClFI,IAASC,QAA0BJ,EAAS,SAASC,EAAe,KAAK,GACzEI,IAAiBH,Q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AAC;EAElE,IAAMC,KAAcC,EAAkB;SAEtCC,EAAkB;GAChB,QAAQ/C,QAAed,EAAM,MAAM;GACnC;GACA;GACA,aAAae;GACb;GACA;GACA,OAAOG;GACP,MAAMC;GACN;GACA,WAAWL,QAAed,EAAM,KAAK;GACrC,OAAOc,QAAed,EAAM,SAAS8D,CAAa;GAClD;GACA;GACA,gBAAgBhD,QAAed,EAAM,kBAAkB+D,CAAe;GACtE;GACA,WAAWjD,QAAed,EAAM,IAAI;GACpC,WAAWc,QAAed,EAAM,IAAI;GACpC,aAAa,MAAME,EAAK,eAAe8D,CAAC;GACxC,aAAa,MAAM9D,EAAK,eAAe+D,CAAC;GACxC;GACA,aAAa,GAAI;IAEf,AADA,EAAU,QAAQf,GACdA,KAAIhD,EAAK,YAAYgD,CAAE;GAC7B;GACA,SAASP;GACT;EACF,CAAC,GAID7C,EAAa;GAAE;GAAU;GAAQ;GAAQ,SAAS6C;EAAW,CAAC,cAI5DnD,EAAA,GAAAC,GAQYC,EAAA2E,CAAA,GAAA;GAPN,SAAA;GAAJ,KAAIlE;GACH,YAAUH,EAAM;GACjB,IAAG;GACH,iBAAA;GACC,cAAYa,EAAA,MAAO;;GAEpB,SAAAlB,QAA8C,CAA9CC,EAA8C4E,EAAA,QAAA,WAAA;IAAvC,QAAQ3D,EAAA;IAAS,UAAUJ,EAAA"}
@@ -0,0 +1,7 @@
1
+ import e from "./InkShapeMenu.vue_vue_type_script_setup_true_lang.js";
2
+ //#region src/components/InkShapeMenu.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
6
+
7
+ //# sourceMappingURL=InkShapeMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkShapeMenu.js","names":["_sfc_main","InkShapeMenu_vue_vue_type_script_setup_true_lang_default","InkShapeMenu_default"],"sources":["../../src/components/InkShapeMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * A split button for the shape tool. The main part activates the tool with the current\n * kind and draws that kind's icon; the chevron opens a two-column grid of kinds. Choosing a\n * kind switches to the tool with it.\n */\nimport {\n focusInitialMenuItem,\n handleMenuKeys,\n menuItems,\n SHAPE_COLUMNS,\n SHAPE_ICONS,\n SHAPE_KINDS,\n shapeMenuModel,\n type ShapeKind,\n type ShapeOptions,\n} from '@inkbar/core/dom'\nimport { ChevronDown } from '@inkbar/icons'\nimport {\n PopoverContent,\n PopoverPortal,\n PopoverRoot,\n PopoverTrigger,\n ToolbarButton,\n} from 'reka-ui'\nimport { computed, ref } from 'vue'\n\nimport { useTool } from '../composables/useTool'\nimport { useToolOptions } from '../composables/useToolOptions'\n\nimport InkIcon from './InkIcon.vue'\n\nconst { tool, setTool } = useTool()\nconst { options, setOptions } = useToolOptions<ShapeOptions>('shape')\nconst open = ref(false)\n\nconst model = computed(() => shapeMenuModel(options.value, SHAPE_KINDS))\nconst active = computed(() => tool.value === 'shape')\nconst icon = computed(() => SHAPE_ICONS[model.value.kind])\n\n/** ArrowDown opens on the first item; a click opens on the checked one. */\nlet focusFirst = false\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\nfunction onOpenAutoFocus(e: Event): void {\n e.preventDefault()\n // One menu is open at a time.\n const menu = document.querySelector('[data-ink-menu=\"shape\"] [role=\"menu\"]')\n if (menu) {\n if (focusFirst) menuItems(menu)[0]?.focus({ preventScroll: true })\n else focusInitialMenuItem(menu)\n }\n focusFirst = false\n}\n\nfunction choose(kind: ShapeKind): void {\n setOptions({ kind })\n setTool('shape')\n open.value = false\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': model.value.label,\n title: model.value.label,\n onClick: () => setTool('shape'),\n}))\nconst triggerAttrs = {\n 'aria-label': 'Choose shape',\n title: 'Choose shape',\n 'aria-haspopup': 'menu' as const,\n onKeydown: onTriggerKeydown,\n}\nconst menuAttrs = { 'aria-label': 'Shapes' }\nconst innerAttrs = {\n role: 'menu',\n 'aria-label': 'Shapes',\n onKeydown: (e: KeyboardEvent) => handleMenuKeys(e, e.currentTarget as HTMLElement),\n}\n</script>\n\n<template>\n <div\n role=\"group\"\n aria-label=\"Shape\"\n class=\"ink-split-button ink-shape-menu\"\n data-ink-shape-menu\n >\n <ToolbarButton\n class=\"ink-tool-button ink-shape-button\"\n data-ink-tool-button\n data-ink-shape-button\n data-tool=\"shape\"\n :data-kind=\"model.kind\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"mainAttrs\"\n >\n <slot :active=\"active\" :kind=\"model.kind\"><InkIcon :icon=\"icon\" /></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-shape-menu-trigger\"\n data-ink-shape-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=\"shape\"\n side=\"bottom\"\n align=\"start\"\n :side-offset=\"4\"\n :collision-padding=\"8\"\n v-bind=\"menuAttrs\"\n @open-auto-focus=\"onOpenAutoFocus\"\n >\n <div v-bind=\"innerAttrs\">\n <div\n role=\"group\"\n aria-label=\"Shapes\"\n class=\"ink-shape-grid\"\n :data-ink-menu-columns=\"SHAPE_COLUMNS\"\n >\n <button\n v-for=\"item in model.items\"\n :key=\"item.kind\"\n type=\"button\"\n role=\"menuitemradio\"\n class=\"ink-select-item ink-menu-item ink-shape-item\"\n data-ink-select-item\n tabindex=\"-1\"\n :data-key=\"item.kind\"\n :aria-checked=\"item.checked\"\n :data-state=\"item.checked ? 'checked' : 'unchecked'\"\n @click=\"choose(item.kind)\"\n >\n <InkIcon :icon=\"SHAPE_ICONS[item.kind]\" :size=\"16\" />\n {{ item.label }}\n </button>\n </div>\n </div>\n </PopoverContent>\n </PopoverPortal>\n </PopoverRoot>\n </div>\n</template>\n"],"mappings":""}
@@ -0,0 +1,18 @@
1
+ import { ShapeKind } from '@inkbar/core/dom';
2
+ declare var __VLS_7: {
3
+ active: boolean;
4
+ kind: ShapeKind;
5
+ };
6
+ type __VLS_Slots = {} & {
7
+ default?: (props: typeof __VLS_7) => any;
8
+ };
9
+ declare const __VLS_base: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
10
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
11
+ declare const _default: typeof __VLS_export;
12
+ export default _default;
13
+ type __VLS_WithSlots<T, S> = T & {
14
+ new (): {
15
+ $slots: S;
16
+ };
17
+ };
18
+ //# sourceMappingURL=InkShapeMenu.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkShapeMenu.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkShapeMenu.vue"],"names":[],"mappings":"AAwKA,OAAO,EAQL,KAAK,SAAS,EAEf,MAAM,kBAAkB,CAAA;AA4RzB,QAAA,IAAI,OAAO;;;CAAW,CAAC;AACvB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAG/C,QAAA,MAAM,UAAU,+QACd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -0,0 +1,118 @@
1
+ import { useTool as e } from "../composables/useTool.js";
2
+ import { useToolOptions as t } from "../composables/useToolOptions.js";
3
+ import n from "./InkIcon.js";
4
+ import { Fragment as r, computed as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, createVNode as c, defineComponent as l, guardReactiveProps as u, mergeProps as d, normalizeProps as f, openBlock as p, ref as m, renderList as h, renderSlot as g, toDisplayString as _, unref as v, withCtx as y } from "vue";
5
+ import { SHAPE_COLUMNS as b, SHAPE_ICONS as x, SHAPE_KINDS as S, focusInitialMenuItem as C, handleMenuKeys as w, menuItems as T, shapeMenuModel as E } from "@inkbar/core/dom";
6
+ import { PopoverContent as D, PopoverPortal as O, PopoverRoot as k, PopoverTrigger as A, ToolbarButton as j } from "reka-ui";
7
+ import { ChevronDown as M } from "@inkbar/icons";
8
+ //#region src/components/InkShapeMenu.vue?vue&type=script&setup=true&lang.ts
9
+ var N = {
10
+ role: "group",
11
+ "aria-label": "Shape",
12
+ class: "ink-split-button ink-shape-menu",
13
+ "data-ink-shape-menu": ""
14
+ }, P = ["data-state"], F = ["data-ink-menu-columns"], I = [
15
+ "data-key",
16
+ "aria-checked",
17
+ "data-state",
18
+ "onClick"
19
+ ], L = /*@__PURE__*/ l({
20
+ __name: "InkShapeMenu",
21
+ setup(l) {
22
+ let { tool: L, setTool: R } = e(), { options: z, setOptions: B } = t("shape"), V = m(!1), H = i(() => E(z.value, S)), U = i(() => L.value === "shape"), W = i(() => x[H.value.kind]), G = !1;
23
+ function K(e) {
24
+ e.key !== "ArrowDown" || e.defaultPrevented || V.value || (e.preventDefault(), G = !0, V.value = !0);
25
+ }
26
+ function q(e) {
27
+ e.preventDefault();
28
+ let t = document.querySelector("[data-ink-menu=\"shape\"] [role=\"menu\"]");
29
+ t && (G ? T(t)[0]?.focus({ preventScroll: !0 }) : C(t)), G = !1;
30
+ }
31
+ function J(e) {
32
+ B({ kind: e }), R("shape"), V.value = !1;
33
+ }
34
+ let Y = i(() => ({
35
+ "aria-pressed": String(U.value),
36
+ "aria-label": H.value.label,
37
+ title: H.value.label,
38
+ onClick: () => R("shape")
39
+ })), X = {
40
+ "aria-label": "Choose shape",
41
+ title: "Choose shape",
42
+ "aria-haspopup": "menu",
43
+ onKeydown: K
44
+ }, Z = { "aria-label": "Shapes" }, Q = {
45
+ role: "menu",
46
+ "aria-label": "Shapes",
47
+ onKeydown: (e) => w(e, e.currentTarget)
48
+ };
49
+ return (e, t) => (p(), a("div", N, [c(v(j), d({
50
+ class: "ink-tool-button ink-shape-button",
51
+ "data-ink-tool-button": "",
52
+ "data-ink-shape-button": "",
53
+ "data-tool": "shape",
54
+ "data-kind": H.value.kind,
55
+ "data-state": U.value ? "on" : "off"
56
+ }, Y.value), {
57
+ default: y(() => [g(e.$slots, "default", {
58
+ active: U.value,
59
+ kind: H.value.kind
60
+ }, () => [c(n, { icon: W.value }, null, 8, ["icon"])])]),
61
+ _: 3
62
+ }, 16, ["data-kind", "data-state"]), c(v(k), {
63
+ open: V.value,
64
+ "onUpdate:open": t[0] ||= (e) => V.value = e
65
+ }, {
66
+ default: y(() => [c(v(j), { "as-child": "" }, {
67
+ default: y(() => [c(v(A), { "as-child": "" }, {
68
+ default: y(() => [o("button", d({
69
+ type: "button",
70
+ class: "ink-menu-trigger ink-shape-menu-trigger",
71
+ "data-ink-shape-menu-trigger": "",
72
+ "data-state": V.value ? "open" : "closed"
73
+ }, X), [c(n, { icon: v(M) }, null, 8, ["icon"])], 16, P)]),
74
+ _: 1
75
+ })]),
76
+ _: 1
77
+ }), c(v(O), null, {
78
+ default: y(() => [c(v(D), d({
79
+ class: "ink-select-content ink-menu-content",
80
+ "data-ink-select-content": "",
81
+ "data-ink-menu": "shape",
82
+ side: "bottom",
83
+ align: "start",
84
+ "side-offset": 4,
85
+ "collision-padding": 8
86
+ }, Z, { onOpenAutoFocus: q }), {
87
+ default: y(() => [o("div", f(u(Q)), [o("div", {
88
+ role: "group",
89
+ "aria-label": "Shapes",
90
+ class: "ink-shape-grid",
91
+ "data-ink-menu-columns": v(b)
92
+ }, [(p(!0), a(r, null, h(H.value.items, (e) => (p(), a("button", {
93
+ key: e.kind,
94
+ type: "button",
95
+ role: "menuitemradio",
96
+ class: "ink-select-item ink-menu-item ink-shape-item",
97
+ "data-ink-select-item": "",
98
+ tabindex: "-1",
99
+ "data-key": e.kind,
100
+ "aria-checked": e.checked,
101
+ "data-state": e.checked ? "checked" : "unchecked",
102
+ onClick: (t) => J(e.kind)
103
+ }, [c(n, {
104
+ icon: v(x)[e.kind],
105
+ size: 16
106
+ }, null, 8, ["icon"]), s(" " + _(e.label), 1)], 8, I))), 128))], 8, F)], 16)]),
107
+ _: 1
108
+ }, 16)]),
109
+ _: 1
110
+ })]),
111
+ _: 1
112
+ }, 8, ["open"])]));
113
+ }
114
+ });
115
+ //#endregion
116
+ export { L as default };
117
+
118
+ //# sourceMappingURL=InkShapeMenu.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkShapeMenu.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createVNode","_unref","_mergeProps","_withCtx","_renderSlot","InkIcon","_createElementVNode","_normalizeProps","_guardReactiveProps","_Fragment","_renderList","_createTextVNode","_toDisplayString","InkIcon_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","InkShapeMenu_vue_vue_type_script_setup_true_lang_default","useTool","useToolOptions","open","ref","model","computed","shapeMenuModel","options","SHAPE_KINDS","active","tool","icon","SHAPE_ICONS","focusFirst","onTriggerKeydown","onOpenAutoFocus","menu","menuItems","focusInitialMenuItem","choose","setOptions","setTool","mainAttrs","triggerAttrs","menuAttrs","innerAttrs","handleMenuKeys","openBlock","createElementBlock","createVNode","unref","ToolbarButton","mergeProps","withCtx","renderSlot","_ctx","PopoverRoot","_cache","$event","PopoverTrigger","createElementVNode","ChevronDown","PopoverPortal","PopoverContent","normalizeProps","guardReactiveProps","SHAPE_COLUMNS","Fragment","renderList","item","createTextVNode","toDisplayString"],"sources":["../../src/components/InkShapeMenu.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * A split button for the shape tool. The main part activates the tool with the current\n * kind and draws that kind's icon; the chevron opens a two-column grid of kinds. Choosing a\n * kind switches to the tool with it.\n */\nimport {\n focusInitialMenuItem,\n handleMenuKeys,\n menuItems,\n SHAPE_COLUMNS,\n SHAPE_ICONS,\n SHAPE_KINDS,\n shapeMenuModel,\n type ShapeKind,\n type ShapeOptions,\n} from '@inkbar/core/dom'\nimport { ChevronDown } from '@inkbar/icons'\nimport {\n PopoverContent,\n PopoverPortal,\n PopoverRoot,\n PopoverTrigger,\n ToolbarButton,\n} from 'reka-ui'\nimport { computed, ref } from 'vue'\n\nimport { useTool } from '../composables/useTool'\nimport { useToolOptions } from '../composables/useToolOptions'\n\nimport InkIcon from './InkIcon.vue'\n\nconst { tool, setTool } = useTool()\nconst { options, setOptions } = useToolOptions<ShapeOptions>('shape')\nconst open = ref(false)\n\nconst model = computed(() => shapeMenuModel(options.value, SHAPE_KINDS))\nconst active = computed(() => tool.value === 'shape')\nconst icon = computed(() => SHAPE_ICONS[model.value.kind])\n\n/** ArrowDown opens on the first item; a click opens on the checked one. */\nlet focusFirst = false\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\nfunction onOpenAutoFocus(e: Event): void {\n e.preventDefault()\n // One menu is open at a time.\n const menu = document.querySelector('[data-ink-menu=\"shape\"] [role=\"menu\"]')\n if (menu) {\n if (focusFirst) menuItems(menu)[0]?.focus({ preventScroll: true })\n else focusInitialMenuItem(menu)\n }\n focusFirst = false\n}\n\nfunction choose(kind: ShapeKind): void {\n setOptions({ kind })\n setTool('shape')\n open.value = false\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': model.value.label,\n title: model.value.label,\n onClick: () => setTool('shape'),\n}))\nconst triggerAttrs = {\n 'aria-label': 'Choose shape',\n title: 'Choose shape',\n 'aria-haspopup': 'menu' as const,\n onKeydown: onTriggerKeydown,\n}\nconst menuAttrs = { 'aria-label': 'Shapes' }\nconst innerAttrs = {\n role: 'menu',\n 'aria-label': 'Shapes',\n onKeydown: (e: KeyboardEvent) => handleMenuKeys(e, e.currentTarget as HTMLElement),\n}\n</script>\n\n<template>\n <div\n role=\"group\"\n aria-label=\"Shape\"\n class=\"ink-split-button ink-shape-menu\"\n data-ink-shape-menu\n >\n <ToolbarButton\n class=\"ink-tool-button ink-shape-button\"\n data-ink-tool-button\n data-ink-shape-button\n data-tool=\"shape\"\n :data-kind=\"model.kind\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"mainAttrs\"\n >\n <slot :active=\"active\" :kind=\"model.kind\"><InkIcon :icon=\"icon\" /></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-shape-menu-trigger\"\n data-ink-shape-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=\"shape\"\n side=\"bottom\"\n align=\"start\"\n :side-offset=\"4\"\n :collision-padding=\"8\"\n v-bind=\"menuAttrs\"\n @open-auto-focus=\"onOpenAutoFocus\"\n >\n <div v-bind=\"innerAttrs\">\n <div\n role=\"group\"\n aria-label=\"Shapes\"\n class=\"ink-shape-grid\"\n :data-ink-menu-columns=\"SHAPE_COLUMNS\"\n >\n <button\n v-for=\"item in model.items\"\n :key=\"item.kind\"\n type=\"button\"\n role=\"menuitemradio\"\n class=\"ink-select-item ink-menu-item ink-shape-item\"\n data-ink-select-item\n tabindex=\"-1\"\n :data-key=\"item.kind\"\n :aria-checked=\"item.checked\"\n :data-state=\"item.checked ? 'checked' : 'unchecked'\"\n @click=\"choose(item.kind)\"\n >\n <InkIcon :icon=\"SHAPE_ICONS[item.kind]\" :size=\"16\" />\n {{ item.label }}\n </button>\n </div>\n </div>\n </PopoverContent>\n </PopoverPortal>\n </PopoverRoot>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAgCA,IAAM,EAAE,SAAM,eAAYqB,EAAQ,GAC5B,EAAE,YAAS,kBAAeC,EAA6B,OAAO,GAC9DC,IAAOC,EAAI,EAAK,GAEhBC,IAAQC,QAAeC,EAAeC,EAAQ,OAAOC,CAAW,CAAC,GACjEC,IAASJ,QAAeK,EAAK,UAAU,OAAO,GAC9CC,IAAON,QAAeO,EAAYR,EAAM,MAAM,KAAK,GAGrDS,IAAa;EACjB,SAASC,EAAiB,GAAwB;GAChD,AAAI,EAAE,QAAQ,eAAe,EAAE,oBAAoBZ,EAAK,UACxD,EAAE,eAAe,GACjB,IAAa,IACb,EAAK,QAAQ;EACf;EAEA,SAASa,EAAgB,GAAgB;GACvC,EAAE,eAAe;GAEjB,IAAMC,IAAO,SAAS,cAAc,2CAAuC;GAK3E,AAJIA,MACEH,IAAYI,EAAUD,CAAI,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,eAAe,GAAK,CAAC,IAC5DE,EAAqBF,CAAI,IAEhC,IAAa;EACf;EAEA,SAASG,EAAO,GAAuB;GAGrC,AAFAC,EAAW,EAAE,QAAK,CAAC,GACnBC,EAAQ,OAAO,GACf,EAAK,QAAQ;EACf;EAGA,IAAMC,IAAYjB,SAAgB;GAChC,gBAAgB,OAAOI,EAAO,KAAK;GACnC,cAAcL,EAAM,MAAM;GAC1B,OAAOA,EAAM,MAAM;GACnB,eAAeiB,EAAQ,OAAO;EAChC,EAAE,GAC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A,CAAA;;;;GAIjCf,CAAAA,GAAAA,EAsCgBC,EAAA4D,CAAA,GAAA,MAAA;IArCd,SAAA1D,QAoCiB,CApCjBH,EAoCiBC,EAAA6D,CAAA,GApCjB5D,EAoCiB;KAnCf,OAAM;KACN,2BAAA;KACA,iBAAc;KACd,MAAK;KACL,OAAM;KACL,eAAa;KACb,qBAAmB;IACZ,GAAAyC,GAAS,EACC,mBAAe,CAAA,GAAA;KAEjC,SAAAxC,QAwBM,CAxBNG,EAwBM,OAAAC,EAAAC,EAxBOoC,CAAU,CAAA,GAAA,CACrBtC,EAsBM,OAAA;MArBJ,MAAK;MACL,cAAW;MACX,OAAM;MACL,yBAAuBL,EAAAgE,CAAA;KAExBnE,GAAAA,EAAAA,EAAA,EAAA,GAAAC,EAeSU,GAAA,MAAAC,EAdQa,EAAA,MAAM,QAAd,OADTzB,EAAA,GAAAC,EAeS,UAAA;MAbN,KAAKqE,EAAK;MACX,MAAK;MACL,MAAK;MACL,OAAM;MACN,wBAAA;MACA,UAAS;MACR,YAAUA,EAAK;MACf,gBAAcA,EAAK;MACnB,cAAYA,EAAK,UAAO,YAAA;MACxB,UAAK,MAAE9B,EAAO8B,EAAK,IAAI;KAExBpE,GAAAA,CAAAA,EAAqDK,GAAA;MAA3C,MAAMJ,EAAA8B,CAAA,CAAW,CAACqC,EAAK;MAAQ,MAAM;KAAMzD,GAAAA,MAAAA,GAAAA,CAAAA,MAAAA,CAAAA,GAAAA,EAAA,MACrDC,EAAGwD,EAAK,KAAK,GAAA,CAAA,CAAA,GAAA,GAAAnD,CAAA"}
@@ -0,0 +1,7 @@
1
+ import e from "./InkSignatureDialog.vue_vue_type_script_setup_true_lang.js";
2
+ //#region src/components/InkSignatureDialog.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
6
+
7
+ //# sourceMappingURL=InkSignatureDialog.js.map
@@ -0,0 +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":""}
@@ -0,0 +1,21 @@
1
+ import { SignatureTemplate } from '@inkbar/core';
2
+ type __VLS_Props = {
3
+ /** The fonts the Type tab offers. Default: InkRoot's `signatureFonts`. */
4
+ fonts?: readonly string[] | undefined;
5
+ };
6
+ type __VLS_ModelProps = {
7
+ 'open'?: boolean;
8
+ };
9
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
10
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
11
+ "update:open": (value: boolean) => any;
12
+ closeAutoFocus: (event: Event) => any;
13
+ save: (template: SignatureTemplate) => any;
14
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
15
+ "onUpdate:open"?: (value: boolean) => any;
16
+ onCloseAutoFocus?: (event: Event) => any;
17
+ onSave?: (template: SignatureTemplate) => any;
18
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
19
+ declare const _default: typeof __VLS_export;
20
+ export default _default;
21
+ //# sourceMappingURL=InkSignatureDialog.vue.d.ts.map
@@ -0,0 +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"}