@inkbar/vue 0.9.0 → 0.11.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 (104) hide show
  1. package/README.md +63 -2
  2. package/dist/components/InkDownloadButton.js +7 -0
  3. package/dist/components/InkDownloadButton.js.map +1 -0
  4. package/dist/components/InkDownloadButton.vue.d.ts +21 -0
  5. package/dist/components/InkDownloadButton.vue.d.ts.map +1 -0
  6. package/dist/components/InkDownloadButton.vue_vue_type_script_setup_true_lang.js +42 -0
  7. package/dist/components/InkDownloadButton.vue_vue_type_script_setup_true_lang.js.map +1 -0
  8. package/dist/components/InkFindBar.js.map +1 -1
  9. package/dist/components/InkFindBar.vue.d.ts.map +1 -1
  10. package/dist/components/InkFindBar.vue_vue_type_script_setup_true_lang.js +48 -48
  11. package/dist/components/InkFindBar.vue_vue_type_script_setup_true_lang.js.map +1 -1
  12. package/dist/components/InkPanel.js +7 -0
  13. package/dist/components/InkPanel.js.map +1 -0
  14. package/dist/components/InkPanel.vue.d.ts +21 -0
  15. package/dist/components/InkPanel.vue.d.ts.map +1 -0
  16. package/dist/components/InkPanel.vue_vue_type_script_setup_true_lang.js +48 -0
  17. package/dist/components/InkPanel.vue_vue_type_script_setup_true_lang.js.map +1 -0
  18. package/dist/components/InkPrintButton.js +7 -0
  19. package/dist/components/InkPrintButton.js.map +1 -0
  20. package/dist/components/InkPrintButton.vue.d.ts +19 -0
  21. package/dist/components/InkPrintButton.vue.d.ts.map +1 -0
  22. package/dist/components/InkPrintButton.vue_vue_type_script_setup_true_lang.js +39 -0
  23. package/dist/components/InkPrintButton.vue_vue_type_script_setup_true_lang.js.map +1 -0
  24. package/dist/components/InkRecordList.js +7 -0
  25. package/dist/components/InkRecordList.js.map +1 -0
  26. package/dist/components/InkRecordList.vue.d.ts +35 -0
  27. package/dist/components/InkRecordList.vue.d.ts.map +1 -0
  28. package/dist/components/InkRecordList.vue_vue_type_script_setup_true_lang.js +41 -0
  29. package/dist/components/InkRecordList.vue_vue_type_script_setup_true_lang.js.map +1 -0
  30. package/dist/components/InkRoot.js.map +1 -1
  31. package/dist/components/InkRoot.vue.d.ts +39 -0
  32. package/dist/components/InkRoot.vue.d.ts.map +1 -1
  33. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js +45 -45
  34. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js.map +1 -1
  35. package/dist/components/InkSearchResults.js +7 -0
  36. package/dist/components/InkSearchResults.js.map +1 -0
  37. package/dist/components/InkSearchResults.vue.d.ts +9 -0
  38. package/dist/components/InkSearchResults.vue.d.ts.map +1 -0
  39. package/dist/components/InkSearchResults.vue_vue_type_script_setup_true_lang.js +52 -0
  40. package/dist/components/InkSearchResults.vue_vue_type_script_setup_true_lang.js.map +1 -0
  41. package/dist/components/InkSidebar.js +7 -0
  42. package/dist/components/InkSidebar.js.map +1 -0
  43. package/dist/components/InkSidebar.vue.d.ts +34 -0
  44. package/dist/components/InkSidebar.vue.d.ts.map +1 -0
  45. package/dist/components/InkSidebar.vue_vue_type_script_setup_true_lang.js +95 -0
  46. package/dist/components/InkSidebar.vue_vue_type_script_setup_true_lang.js.map +1 -0
  47. package/dist/components/InkThumbnail.js +7 -0
  48. package/dist/components/InkThumbnail.js.map +1 -0
  49. package/dist/components/InkThumbnail.vue.d.ts +18 -0
  50. package/dist/components/InkThumbnail.vue.d.ts.map +1 -0
  51. package/dist/components/InkThumbnail.vue_vue_type_script_setup_true_lang.js +49 -0
  52. package/dist/components/InkThumbnail.vue_vue_type_script_setup_true_lang.js.map +1 -0
  53. package/dist/components/InkThumbnails.js +7 -0
  54. package/dist/components/InkThumbnails.js.map +1 -0
  55. package/dist/components/InkThumbnails.vue.d.ts +27 -0
  56. package/dist/components/InkThumbnails.vue.d.ts.map +1 -0
  57. package/dist/components/InkThumbnails.vue_vue_type_script_setup_true_lang.js +107 -0
  58. package/dist/components/InkThumbnails.vue_vue_type_script_setup_true_lang.js.map +1 -0
  59. package/dist/components/InkViewport.js.map +1 -1
  60. package/dist/components/InkViewport.vue.d.ts +3 -0
  61. package/dist/components/InkViewport.vue.d.ts.map +1 -1
  62. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js +12 -2
  63. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js.map +1 -1
  64. package/dist/components/InkZoomSelect.js.map +1 -1
  65. package/dist/components/InkZoomSelect.vue.d.ts.map +1 -1
  66. package/dist/components/InkZoomSelect.vue_vue_type_script_setup_true_lang.js +1 -1
  67. package/dist/components/InkZoomSelect.vue_vue_type_script_setup_true_lang.js.map +1 -1
  68. package/dist/components/RecordCards.js +7 -0
  69. package/dist/components/RecordCards.js.map +1 -0
  70. package/dist/components/RecordCards.vue.d.ts +25 -0
  71. package/dist/components/RecordCards.vue.d.ts.map +1 -0
  72. package/dist/components/RecordCards.vue_vue_type_script_setup_true_lang.js +120 -0
  73. package/dist/components/RecordCards.vue_vue_type_script_setup_true_lang.js.map +1 -0
  74. package/dist/components/SidebarTrigger.js +7 -0
  75. package/dist/components/SidebarTrigger.js.map +1 -0
  76. package/dist/components/SidebarTrigger.vue.d.ts +9 -0
  77. package/dist/components/SidebarTrigger.vue.d.ts.map +1 -0
  78. package/dist/components/SidebarTrigger.vue_vue_type_script_setup_true_lang.js +33 -0
  79. package/dist/components/SidebarTrigger.vue_vue_type_script_setup_true_lang.js.map +1 -0
  80. package/dist/components/sidebar-context.d.ts +21 -0
  81. package/dist/components/sidebar-context.d.ts.map +1 -0
  82. package/dist/components/sidebar-context.js +7 -0
  83. package/dist/components/sidebar-context.js.map +1 -0
  84. package/dist/composables/useAnnotations.d.ts +91 -0
  85. package/dist/composables/useAnnotations.d.ts.map +1 -1
  86. package/dist/composables/useRecordSelection.d.ts +12 -0
  87. package/dist/composables/useRecordSelection.d.ts.map +1 -0
  88. package/dist/composables/useRecordSelection.js +15 -0
  89. package/dist/composables/useRecordSelection.js.map +1 -0
  90. package/dist/composables/useRecords.d.ts +14 -0
  91. package/dist/composables/useRecords.d.ts.map +1 -0
  92. package/dist/composables/useRecords.js +16 -0
  93. package/dist/composables/useRecords.js.map +1 -0
  94. package/dist/composables/useSearch.d.ts.map +1 -1
  95. package/dist/composables/useSearch.js +1 -0
  96. package/dist/composables/useSearch.js.map +1 -1
  97. package/dist/index.d.ts +11 -0
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +40 -30
  100. package/dist/to-readable.d.ts +7 -0
  101. package/dist/to-readable.d.ts.map +1 -0
  102. package/dist/to-readable.js +11 -0
  103. package/dist/to-readable.js.map +1 -0
  104. package/package.json +5 -5
@@ -2,10 +2,10 @@ import { provideInkContext as e } from "../context.js";
2
2
  import { registeredToolIds as t } from "../composables/useRegisteredTool.js";
3
3
  import { useReadable as n } from "../use-readable.js";
4
4
  import { createRefHistory as r } from "../ref-history.js";
5
- import { computed as i, createBlock as a, defineComponent as o, onBeforeUnmount as ee, onMounted as te, onUnmounted as ne, onUpdated as re, openBlock as ie, ref as s, renderSlot as ae, shallowRef as c, unref as oe, useTemplateRef as l, watch as u, withCtx as se } from "vue";
6
- import { InkError as d, createMemorySignatureStore as ce, createSignatureLibrary as le, openDocument as ue, readonly as f, writable as p } from "@inkbar/core";
7
- import { FONT_FAMILIES as de, SIGNATURE_FONTS as fe, attachHistoryKeys as pe, createPluginHost as me, createSearchController as he, createToolOptions as ge, cssVariableDefaults as _e, handleFindKey as ve, keepHistoryFocus as ye, pageSelectionText as be, trackToolStyle as xe, unknownTool as Se, viewerSearchOf as m } from "@inkbar/core/dom";
8
- import { Primitive as Ce } from "reka-ui";
5
+ import { computed as i, createBlock as a, defineComponent as o, onBeforeUnmount as ee, onMounted as te, onUnmounted as ne, onUpdated as re, openBlock as ie, ref as s, renderSlot as ae, shallowRef as c, unref as oe, useTemplateRef as se, watch as l, withCtx as u } from "vue";
6
+ import { InkError as d, createMemorySignatureStore as ce, createSignatureLibrary as le, openDocument as f, readonly as p, writable as m } from "@inkbar/core";
7
+ import { FONT_FAMILIES as ue, SIGNATURE_FONTS as de, attachFileKeys as fe, attachHistoryKeys as pe, createPluginHost as me, createSearchController as he, createToolOptions as ge, cssVariableDefaults as _e, handleFindKey as ve, keepHistoryFocus as ye, pageSelectionText as be, trackToolStyle as xe, unknownTool as Se, viewerSearchOf as Ce } from "@inkbar/core/dom";
8
+ import { Primitive as we } from "reka-ui";
9
9
  //#region src/components/InkRoot.vue?vue&type=script&setup=true&lang.ts
10
10
  var h = /*@__PURE__*/ o({
11
11
  __name: "InkRoot",
@@ -54,17 +54,17 @@ var h = /*@__PURE__*/ o({
54
54
  "activate"
55
55
  ],
56
56
  setup(o, { expose: h, emit: g }) {
57
- let _ = o, v = g, y = l("primitive"), b = c(null);
57
+ let _ = o, v = g, y = se("primitive"), b = c(null);
58
58
  function x() {
59
59
  let e = y.value?.$el;
60
60
  b.value = e instanceof HTMLElement ? e : null;
61
61
  }
62
- let S = c(null), C = c(null), we = n(() => S.value?.status ?? null, { state: "idle" }), w = i(() => C.value ?? we.value), Te = n(() => S.value?.annotations.list ?? null, []), Ee = n(() => S.value?.annotations.selection ?? null, []), T = c(null), E = c(null), D = s(_.tool ?? "select-text"), O = s(null), k = i(() => _.annotations !== void 0), De = i(() => _.fields !== void 0);
62
+ let S = c(null), C = c(null), Te = n(() => S.value?.status ?? null, { state: "idle" }), w = i(() => C.value ?? Te.value), Ee = n(() => S.value?.annotations.list ?? null, []), De = n(() => S.value?.annotations.selection ?? null, []), T = c(null), E = c(null), D = s(_.tool ?? "select-text"), O = s(null), k = i(() => _.annotations !== void 0), Oe = i(() => _.fields !== void 0);
63
63
  function A(e) {
64
64
  O.value = e, e && v("activate", e);
65
65
  }
66
66
  let j = () => {};
67
- function Oe(e) {
67
+ function ke(e) {
68
68
  return e === null ? null : typeof e == "string" ? e : "key" in e ? e.key : e;
69
69
  }
70
70
  let M = 0, N = j;
@@ -82,7 +82,7 @@ var h = /*@__PURE__*/ o({
82
82
  C.value = { state: "loading" }, x();
83
83
  let n;
84
84
  try {
85
- n = await ue(t, {
85
+ n = await f(t, {
86
86
  assets: _.assets,
87
87
  password: _.password,
88
88
  defaults: _.defaults ?? (b.value ? _e(b.value) : void 0),
@@ -94,7 +94,7 @@ var h = /*@__PURE__*/ o({
94
94
  v("update:annotations", e), v("change", t);
95
95
  }
96
96
  } : { mode: "uncontrolled" },
97
- fields: De.value ? {
97
+ fields: Oe.value ? {
98
98
  mode: "controlled",
99
99
  initial: _.fields ?? {},
100
100
  onChange: (e, t) => v("update:fields", e, t)
@@ -128,9 +128,9 @@ var h = /*@__PURE__*/ o({
128
128
  apply: (e) => S.value?.annotations.replaceAll(e, "history"),
129
129
  enabled: i(() => k.value && _.history === !0),
130
130
  store: () => S.value?.annotations.mode === "controlled" ? S.value.annotations : null
131
- }), ke = n(() => S.value?.history.canUndo ?? null, !1), Ae = n(() => S.value?.history.canRedo ?? null, !1), L = {
132
- canUndo: i(() => k.value ? I.canUndo.value : ke.value),
133
- canRedo: i(() => k.value ? I.canRedo.value : Ae.value),
131
+ }), Ae = n(() => S.value?.history.canUndo ?? null, !1), je = n(() => S.value?.history.canRedo ?? null, !1), L = {
132
+ canUndo: i(() => k.value ? I.canUndo.value : Ae.value),
133
+ canRedo: i(() => k.value ? I.canRedo.value : je.value),
134
134
  undo: () => k.value ? I.undo() : S.value?.history.undo(),
135
135
  redo: () => k.value ? I.redo() : S.value?.history.redo(),
136
136
  clear: () => k.value ? I.clear() : S.value?.history.clear(),
@@ -140,42 +140,42 @@ var h = /*@__PURE__*/ o({
140
140
  track: (e) => k.value ? I.track(e) : S.value?.history.track(e) ?? j,
141
141
  react: (e) => k.value ? I.react(e) : S.value?.history.react(e) ?? j
142
142
  };
143
- u(b, (e, t, n) => {
143
+ l(b, (e, t, n) => {
144
144
  if (!e) return;
145
145
  let r = pe(e, () => ({
146
146
  canUndo: L.canUndo.value,
147
147
  canRedo: L.canRedo.value,
148
148
  undo: L.undo,
149
149
  redo: L.redo
150
- })), i = ye(e, () => e.querySelector("[data-ink-scroll]"));
150
+ })), i = ye(e, () => e.querySelector("[data-ink-scroll]")), a = fe(e, () => S.value);
151
151
  e.addEventListener("keydown", W), n(() => {
152
- r(), i(), e.removeEventListener("keydown", W);
152
+ r(), i(), a(), e.removeEventListener("keydown", W);
153
153
  });
154
154
  }, { immediate: !0 });
155
- let R = p(null);
156
- u(S, (e) => R.set(e), { flush: "sync" });
157
- let z = c(null), B = p(null);
158
- u(z, (e) => B.set(e), { flush: "sync" });
159
- let V = p(null);
160
- u(O, (e) => V.set(e), { flush: "sync" });
155
+ let R = m(null);
156
+ l(S, (e) => R.set(e), { flush: "sync" });
157
+ let z = c(null), B = m(null);
158
+ l(z, (e) => B.set(e), { flush: "sync" });
159
+ let V = m(null);
160
+ l(O, (e) => V.set(e), { flush: "sync" });
161
161
  let H = c(null), U = c(null);
162
- function je() {
162
+ function Me() {
163
163
  let e = he({
164
- document: f(R),
164
+ document: p(R),
165
165
  viewport: () => T.value
166
166
  });
167
167
  U.value = e, H.value = me({
168
168
  plugins: _.plugins ?? [],
169
- document: f(R),
169
+ document: p(R),
170
170
  history: () => L,
171
- activated: f(V),
171
+ activated: p(V),
172
172
  setActivated: (e) => {
173
173
  (e === null || S.value?.annotations.get(e)) && A(e);
174
174
  },
175
- root: f(B),
175
+ root: p(B),
176
176
  decorate: () => _.decorateAnnotation,
177
177
  viewport: () => T.value,
178
- search: m(e)
178
+ search: Ce(e)
179
179
  });
180
180
  }
181
181
  function W(e) {
@@ -183,7 +183,7 @@ var h = /*@__PURE__*/ o({
183
183
  t && n instanceof HTMLElement && ve(e, t, () => be(n));
184
184
  }
185
185
  let G = c(null), K;
186
- u(S, (e) => {
186
+ l(S, (e) => {
187
187
  if (!e) {
188
188
  G.value = null, K = void 0;
189
189
  return;
@@ -198,28 +198,28 @@ var h = /*@__PURE__*/ o({
198
198
  }, {
199
199
  immediate: !0,
200
200
  flush: "sync"
201
- }), u(D, (e) => K?.(e)), te(() => {
201
+ }), l(D, (e) => K?.(e)), te(() => {
202
202
  x();
203
203
  try {
204
- je();
204
+ Me();
205
205
  } finally {
206
206
  q.value = !0, F();
207
207
  }
208
- }), re(x), u([() => Oe(_.src), () => _.password], () => void F()), u(() => _.annotations, (e) => {
208
+ }), re(x), l([() => ke(_.src), () => _.password], () => void F()), l(() => _.annotations, (e) => {
209
209
  e && S.value?.annotations.mode === "controlled" && S.value.annotations.setControlledValue(e);
210
- }), u(() => _.fields, (e) => {
210
+ }), l(() => _.fields, (e) => {
211
211
  e && S.value?.form.setControlledValue(e);
212
212
  });
213
213
  let q = s(!1), J = c(null), Y = i(() => t(_.tools, H.value, J.value)), X = (e) => !q.value || Y.value.includes(e), Z = (e) => console.error(Se(e, Y.value));
214
214
  function Q(e) {
215
215
  Z(e), D.value = "select-text", v("update:tool", "select-text");
216
216
  }
217
- u(() => _.tool, (e) => {
217
+ l(() => _.tool, (e) => {
218
218
  e && (X(e) ? D.value = e : Q(e));
219
- }), u([q, Y], () => {
219
+ }), l([q, Y], () => {
220
220
  X(D.value) || Q(D.value);
221
221
  });
222
- function Me(e) {
222
+ function Ne(e) {
223
223
  if (!X(e)) {
224
224
  Z(e);
225
225
  return;
@@ -233,25 +233,25 @@ var h = /*@__PURE__*/ o({
233
233
  H.value?.destroy(), H.value = null, U.value?.destroy(), U.value = null;
234
234
  });
235
235
  let $ = i(() => le(_.signatures ?? ce()));
236
- u($, (e) => void e.refresh(), { immediate: !0 });
237
- let Ne = ge();
236
+ l($, (e) => void e.refresh(), { immediate: !0 });
237
+ let Pe = ge();
238
238
  return e({
239
239
  assets: i(() => _.assets),
240
240
  document: S,
241
241
  status: w,
242
- annotations: Te,
243
- selection: Ee,
242
+ annotations: Ee,
243
+ selection: De,
244
244
  viewport: T,
245
245
  tools: E,
246
246
  tool: D,
247
- setTool: Me,
247
+ setTool: Ne,
248
248
  hostTools: i(() => _.tools),
249
249
  openedToolIds: J,
250
250
  decorateAnnotation: i(() => _.decorateAnnotation),
251
- fonts: i(() => _.fonts ?? de),
252
- toolOptions: Ne,
251
+ fonts: i(() => _.fonts ?? ue),
252
+ toolOptions: Pe,
253
253
  signatures: $,
254
- signatureFonts: i(() => _.signatureFonts ?? fe),
254
+ signatureFonts: i(() => _.signatureFonts ?? de),
255
255
  toolStyle: G,
256
256
  zoomModel: i(() => _.zoom),
257
257
  pageModel: i(() => _.page),
@@ -272,7 +272,7 @@ var h = /*@__PURE__*/ o({
272
272
  status: w,
273
273
  rootEl: b,
274
274
  history: L
275
- }), (e, t) => (ie(), a(oe(Ce), {
275
+ }), (e, t) => (ie(), a(oe(we), {
276
276
  ref_key: "primitive",
277
277
  ref: y,
278
278
  "as-child": _.asChild,
@@ -280,7 +280,7 @@ var h = /*@__PURE__*/ o({
280
280
  "data-ink-root": "",
281
281
  "data-state": w.value.state
282
282
  }, {
283
- default: se(() => [ae(e.$slots, "default", {
283
+ default: u(() => [ae(e.$slots, "default", {
284
284
  status: w.value,
285
285
  document: S.value
286
286
  })]),
@@ -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","toolController","internalTool","ref","activated","controlled","fieldsControlled","setActivated","id","noop","identity","src","generation","stopFormErrors","release","doc","open","gen","refHistory","openDocument","cssVariableDefaults","next","change","cause","error","InkError","held","s","early","createRefHistory","list","coreCanUndo","coreCanRedo","inkHistory","fn","store","stopKeys","attachHistoryKeys","stopFocus","keepHistoryFocus","onKeydown","onCleanup","hostDocument","writable","viewportEl","hostRoot","hostActivated","pluginHost","search","setUpPlugins","controller","createSearchController","readonly","createPluginHost","viewerSearchOf","root","handleFindKey","pageSelectionText","toolStyle","setStyleTool","watch","tracker","trackToolStyle","onMounted","onUpdated","mounted","openedToolIds","toolIds","registeredToolIds","isRegistered","logUnknownTool","unknownTool","fallBack","t","setTool","tc","onBeforeUnmount","onUnmounted","signatures","createSignatureLibrary","createMemorySignatureStore","lib","toolOptions","createToolOptions","provideInkContext","FONT_FAMILIES","SIGNATURE_FONTS","z","p","a","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 readonly,\n writable,\n} from '@inkbar/core'\nimport {\n attachHistoryKeys,\n createPluginHost,\n createSearchController,\n createToolOptions,\n handleFindKey,\n pageSelectionText,\n viewerSearchOf,\n cssVariableDefaults,\n FONT_FAMILIES,\n keepHistoryFocus,\n SIGNATURE_FONTS,\n trackToolStyle,\n unknownTool,\n} from '@inkbar/core/dom'\nimport { Primitive } from 'reka-ui'\nimport {\n computed,\n onBeforeUnmount,\n onUnmounted,\n onMounted,\n onUpdated,\n ref,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { registeredToolIds } from '../composables/useRegisteredTool'\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 FieldsChange,\n FieldValues,\n FormAction,\n InkDocument,\n PdfAssets,\n SignatureStore,\n} from '@inkbar/core'\nimport type {\n DecorateAnnotation,\n InkPlugin,\n PluginHost,\n SearchController,\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 /**\n * Pass (with `v-model:fields`) to put the form's field values under the host's control. A\n * commit shows at once and is reported after; the host's push wins. The mode is fixed when\n * a document opens, as for `annotations`.\n */\n fields?: FieldValues | undefined\n /** Tints fillable form fields. Default true. A change applies to the open document in place. */\n formHighlight?: boolean | undefined\n tool?: ToolId | undefined\n /**\n * The creation tools, such as `allTools()` or a pick of the tool factories. `select-text`\n * and `select` are always present; a tool with either id replaces it. They are read when a\n * document opens: a tool added later is usable from the next open, one removed stops at\n * once. When the active tool goes, the viewer switches to `select-text` and emits\n * `update:tool`. A controlled `tool` naming a missing tool is reported back as\n * `select-text` and is not applied again when the tool appears later. Each mounted control\n * for a missing tool logs its own `UnknownTool`.\n */\n tools?: Tool[] | undefined\n /**\n * Plugins, set up once when the root is created; a later change to this prop is not\n * applied. Their tools join `tools`, their decoration and page layers apply to every\n * document, and their commands are placed with `InkCommand` or `useCommand`.\n */\n plugins?: InkPlugin[] | undefined\n /**\n * Adds `data-*` attributes, classes and a screen-reader description to each annotation's\n * element (see `DecorateAnnotation`). Decorations re-apply whenever the annotations change\n * and when this prop changes, without rebuilding the viewer. Pass a new function when its\n * output would change for any other reason.\n */\n decorateAnnotation?: DecorateAnnotation | 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 fields: undefined,\n formHighlight: undefined,\n tool: undefined,\n tools: undefined,\n plugins: undefined,\n decorateAnnotation: 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 /** Committed field values, in full, with what changed them. */\n 'update:fields': [next: FieldValues, change: FieldsChange]\n /** The form asked to submit, open a link, send mail, print or prompt. Inkbar does none. */\n 'form-action': [action: FormAction]\n 'update:tool': [tool: ToolId]\n 'update:page': [page: number]\n 'update:zoom': [zoom: ZoomValue]\n ready: [doc: InkDocument]\n /**\n * Opening failed, or later a form script failed or a signature field refused its signing.\n * An error from while the document opened comes after `ready`.\n */\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)\nconst fieldsControlled = computed(() => props.fields !== undefined)\n\nfunction setActivated(id: string | null): void {\n activated.value = id\n if (id) emit('activate', id)\n}\n\nconst noop = () => {}\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\nlet stopFormErrors: () => void = noop\nfunction release(): void {\n stopFormErrors()\n stopFormErrors = noop\n // Cleared first, so the plugins close their stores while the document is still alive.\n const doc = document.value\n document.value = null\n doc?.destroy()\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 fields: fieldsControlled.value\n ? {\n mode: 'controlled',\n initial: props.fields ?? {},\n onChange: (next, change) => emit('update:fields', next, change),\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 // The same for the fields; a document whose fields opened uncontrolled ignores the push.\n if (props.fields !== undefined) doc.form.setControlledValue(props.fields)\n // A form script that fails leaves the form fillable; the failure goes to `error`. Subscribed\n // before anyone hears of the document, so the form replays the errors from while it opened\n // here, not to a listener added in `ready`; they are held until `ready` has gone out.\n let held: InkError[] | undefined = []\n stopFormErrors = doc.form.on('error', (e) => {\n if (held) held.push(e)\n else emit('error', e)\n })\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 const early = held\n held = undefined\n if (gen === generation) for (const e of early) emit('error', e)\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 store: () =>\n document.value?.annotations.mode === 'controlled' ? document.value.annotations : null,\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 track: (store) =>\n controlled.value\n ? refHistory.track(store)\n : (document.value?.history.track(store) ?? noop),\n react: (fn) =>\n controlled.value ? refHistory.react(fn) : (document.value?.history.react(fn) ?? noop),\n}\n\n// The undo and redo keys anywhere in the root do what InkUndo and InkRedo do. When either\n// button undoes or redoes the last step and disables itself, focus goes back to the document.\n// The find key listens here too.\nwatch(\n rootEl,\n (el, _prev, onCleanup) => {\n if (!el) return\n const stopKeys = attachHistoryKeys(el, () => ({\n canUndo: inkHistory.canUndo.value,\n canRedo: inkHistory.canRedo.value,\n undo: inkHistory.undo,\n redo: inkHistory.redo,\n }))\n const stopFocus = keepHistoryFocus(el, () =>\n el.querySelector<HTMLElement>('[data-ink-scroll]')\n )\n // Not a template listener: Vue leaves those on the element when it unmounts.\n el.addEventListener('keydown', onKeydown)\n onCleanup(() => {\n stopKeys()\n stopFocus()\n el.removeEventListener('keydown', onKeydown)\n })\n },\n { immediate: true }\n)\n\n/*\n * One plugin host for the root's life, built once mounted so that no `setup` runs on the\n * server, where nothing would clean it up. Until then `pluginHost` is null, and InkCommand\n * renders its command disabled. The host follows `hostDocument`, which is set after `document`\n * (a sync watch): when the host reads `inkHistory` for a new document, it is that document's\n * history.\n */\nconst hostDocument = writable<InkDocument | null>(null)\nwatch(document, (doc) => hostDocument.set(doc), { flush: 'sync' })\nconst viewportEl = shallowRef<HTMLElement | null>(null)\nconst hostRoot = writable<HTMLElement | null>(null)\nwatch(viewportEl, (el) => hostRoot.set(el), { flush: 'sync' })\nconst hostActivated = writable<string | null>(null)\nwatch(activated, (id) => hostActivated.set(id), { flush: 'sync' })\nconst pluginHost = shallowRef<PluginHost | null>(null)\n/** One search controller for the root's life, built with the plugin host that shares it. */\nconst search = shallowRef<SearchController | null>(null)\nfunction setUpPlugins(): void {\n const controller = createSearchController({\n document: readonly(hostDocument),\n viewport: () => viewport.value,\n })\n search.value = controller\n pluginHost.value = createPluginHost({\n plugins: props.plugins ?? [],\n document: readonly(hostDocument),\n history: () => inkHistory,\n activated: readonly(hostActivated),\n // As in `createViewer`: an id not in the open document is ignored.\n setActivated: (id) => {\n if (id === null || document.value?.annotations.get(id)) setActivated(id)\n },\n root: readonly(hostRoot),\n decorate: () => props.decorateAnnotation,\n viewport: () => viewport.value,\n search: viewerSearchOf(controller),\n })\n}\n\n/** Ctrl/Cmd+F while focus is in the root and a find bar is mounted; else the browser's. */\nfunction onKeydown(e: KeyboardEvent): void {\n const controller = search.value\n const root = e.currentTarget\n if (controller && root instanceof HTMLElement)\n handleFindKey(e, controller, () => pageSelectionText(root))\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 // The plugins' tools too, so a plugin tool's style group applies (the host is set by now:\n // it is built on mount, before the first document opens).\n tools: [...(props.tools ?? []), ...(pluginHost.value?.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// Plugins and the document on the client only: on the server InkRoot renders its empty slot.\n// The plugins first, so the first document opens with their stores and reactions.\nonMounted(() => {\n syncRootEl()\n // A plugin whose setup throws still leaves the document to open; the error then goes to\n // Vue's error handling (`onErrorCaptured`, `app.config.errorHandler`).\n try {\n setUpPlugins()\n } finally {\n mounted.value = true\n void open()\n }\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.fields,\n (next) => {\n if (next) document.value?.form.setControlledValue(next)\n }\n)\n\n/*\n * The tools are known once the plugins are set up on mount. A tool id nobody registered is\n * logged as `UnknownTool`; as the active tool, from a `tool` prop or because it left `tools`,\n * it falls back to `select-text`, reported through `update:tool`. A controlled `tool` that\n * stays on the missing id is not applied again.\n */\nconst mounted = ref(false)\n/** The ids of the tools the current viewer was built with; InkViewport sets them. */\nconst openedToolIds = shallowRef<readonly ToolId[] | null>(null)\nconst toolIds = computed(() =>\n registeredToolIds(props.tools, pluginHost.value, openedToolIds.value)\n)\nconst isRegistered = (id: ToolId): boolean => !mounted.value || toolIds.value.includes(id)\nconst logUnknownTool = (id: ToolId): void => console.error(unknownTool(id, toolIds.value))\n\nfunction fallBack(id: ToolId): void {\n logUnknownTool(id)\n internalTool.value = 'select-text'\n emit('update:tool', 'select-text')\n}\n\nwatch(\n () => props.tool,\n (t) => {\n if (!t) return\n if (isRegistered(t)) internalTool.value = t\n else fallBack(t)\n }\n)\nwatch([mounted, toolIds], () => {\n if (!isRegistered(internalTool.value)) fallBack(internalTool.value)\n})\n\nfunction setTool(id: ToolId): void {\n // As the tool controller does: a missing tool is logged and nothing changes.\n if (!isRegistered(id)) {\n logUnknownTool(id)\n return\n }\n // Picking the active tool again starts it afresh, as after a one-shot tool's use.\n const tc = toolController.value\n if (internalTool.value === id && tc?.active.get() === id) tc.set(id)\n internalTool.value = id\n emit('update:tool', id)\n}\n\nonBeforeUnmount(() => {\n generation++\n release()\n})\n\n// After the children: InkViewport's engine, and the plugin layers with it, are gone by now, as\n// in `createViewer`, so no layer `destroy` runs after the plugins' cleanups.\nonUnmounted(() => {\n pluginHost.value?.destroy()\n pluginHost.value = null\n search.value?.destroy()\n search.value = null\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 openedToolIds,\n decorateAnnotation: computed(() => props.decorateAnnotation),\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,\n pluginHost,\n search,\n viewportEl,\n history: inkHistory,\n rootEl,\n formHighlight: computed(() => props.formHighlight),\n reportFormAction: (a) => emit('form-action', a),\n reportError: (e) => emit('error', e),\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmEA,IAAMQ,IAAQC,GAmFRC,IAAOH,GAsBPI,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,KAAiBC,QAA6BH,EAAS,OAAO,UAAU,MAAM,EAD1D,OAAO,OACmD,CAAI,GAClFI,IAASC,QAA0BJ,EAAS,SAASC,GAAe,KAAK,GACzEI,KAAiBH,QACfH,EAAS,OAAO,YAAY,QAAQ,MAC1C,CAAC,CACH,GACMO,KAAYJ,QACVH,EAAS,OAAO,YAAY,aAAa,MAC/C,CAAC,CACH,GACMQ,IAAWX,EAA4B,IAAI,GAC3CY,IAAiBZ,EAAkC,IAAI,GACvDa,IAAeC,EAAYpB,EAAM,QAAQ,aAAa,GACtDqB,IAAYD,EAAmB,IAAI,GAEnCE,IAAaR,QAAed,EAAM,gBAAgB,KAAA,CAAS,GAC3D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EAAK,eAAesG,CAAC;GACxC,aAAa,MAAMtG,EAAK,eAAeuG,CAAC;GACxC;GACA;GACA;GACA;GACA;GACA,SAASvD;GACT;GACA,eAAepC,QAAed,EAAM,aAAa;GACjD,mBAAmB,MAAME,EAAK,eAAewG,CAAC;GAC9C,cAAc,MAAMxG,EAAK,SAAS,CAAC;EACrC,CAAC,GAIDJ,EAAa;GAAE;GAAU;GAAQ;GAAQ,SAASoD;EAAW,CAAC,cAI5D1D,GAAA,GAAAC,EAQYC,GAAAoH,EAAA,GAAA;GAPN,SAAA;GAAJ,KAAI3G;GACH,YAAUH,EAAM;GACjB,IAAG;GACH,iBAAA;GACC,cAAYa,EAAA,MAAO;;GAEpB,SAAAlB,SAA8C,CAA9CC,GAA8CqH,EAAA,QAAA,WAAA;IAAvC,QAAQpG,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","fieldsControlled","setActivated","id","noop","identity","src","generation","stopFormErrors","release","doc","open","gen","refHistory","openDocument","cssVariableDefaults","next","change","cause","error","InkError","held","s","early","createRefHistory","list","coreCanUndo","coreCanRedo","inkHistory","fn","store","stopKeys","attachHistoryKeys","stopFocus","keepHistoryFocus","stopFileKeys","attachFileKeys","onKeydown","onCleanup","hostDocument","writable","viewportEl","hostRoot","hostActivated","pluginHost","search","setUpPlugins","controller","createSearchController","readonly","createPluginHost","viewerSearchOf","root","handleFindKey","pageSelectionText","toolStyle","setStyleTool","watch","tracker","trackToolStyle","onMounted","onUpdated","mounted","openedToolIds","toolIds","registeredToolIds","isRegistered","logUnknownTool","unknownTool","fallBack","t","setTool","tc","onBeforeUnmount","onUnmounted","signatures","createSignatureLibrary","createMemorySignatureStore","lib","toolOptions","createToolOptions","provideInkContext","FONT_FAMILIES","SIGNATURE_FONTS","z","p","a","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 readonly,\n writable,\n} from '@inkbar/core'\nimport {\n attachFileKeys,\n attachHistoryKeys,\n createPluginHost,\n createSearchController,\n createToolOptions,\n handleFindKey,\n pageSelectionText,\n viewerSearchOf,\n cssVariableDefaults,\n FONT_FAMILIES,\n keepHistoryFocus,\n SIGNATURE_FONTS,\n trackToolStyle,\n unknownTool,\n} from '@inkbar/core/dom'\nimport { Primitive } from 'reka-ui'\nimport {\n computed,\n onBeforeUnmount,\n onUnmounted,\n onMounted,\n onUpdated,\n ref,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { registeredToolIds } from '../composables/useRegisteredTool'\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 FieldsChange,\n FieldValues,\n FormAction,\n InkDocument,\n PdfAssets,\n SignatureStore,\n} from '@inkbar/core'\nimport type {\n DecorateAnnotation,\n InkPlugin,\n PluginHost,\n SearchController,\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 /**\n * Pass (with `v-model:fields`) to put the form's field values under the host's control. A\n * commit shows at once and is reported after; the host's push wins. The mode is fixed when\n * a document opens, as for `annotations`.\n */\n fields?: FieldValues | undefined\n /** Tints fillable form fields. Default true. A change applies to the open document in place. */\n formHighlight?: boolean | undefined\n tool?: ToolId | undefined\n /**\n * The creation tools, such as `allTools()` or a pick of the tool factories. `select-text`\n * and `select` are always present; a tool with either id replaces it. They are read when a\n * document opens: a tool added later is usable from the next open, one removed stops at\n * once. When the active tool goes, the viewer switches to `select-text` and emits\n * `update:tool`. A controlled `tool` naming a missing tool is reported back as\n * `select-text` and is not applied again when the tool appears later. Each mounted control\n * for a missing tool logs its own `UnknownTool`.\n */\n tools?: Tool[] | undefined\n /**\n * Plugins, set up once when the root is created; a later change to this prop is not\n * applied. Their tools join `tools`, their decoration and page layers apply to every\n * document, and their commands are placed with `InkCommand` or `useCommand`.\n */\n plugins?: InkPlugin[] | undefined\n /**\n * Adds `data-*` attributes, classes and a screen-reader description to each annotation's\n * element (see `DecorateAnnotation`). Decorations re-apply whenever the annotations change\n * and when this prop changes, without rebuilding the viewer. Pass a new function when its\n * output would change for any other reason.\n */\n decorateAnnotation?: DecorateAnnotation | 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 fields: undefined,\n formHighlight: undefined,\n tool: undefined,\n tools: undefined,\n plugins: undefined,\n decorateAnnotation: 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 /** Committed field values, in full, with what changed them. */\n 'update:fields': [next: FieldValues, change: FieldsChange]\n /** The form asked to submit, open a link, send mail, print or prompt. Inkbar does none. */\n 'form-action': [action: FormAction]\n 'update:tool': [tool: ToolId]\n 'update:page': [page: number]\n 'update:zoom': [zoom: ZoomValue]\n ready: [doc: InkDocument]\n /**\n * Opening failed, or later a form script failed or a signature field refused its signing.\n * An error from while the document opened comes after `ready`.\n */\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)\nconst fieldsControlled = computed(() => props.fields !== undefined)\n\nfunction setActivated(id: string | null): void {\n activated.value = id\n if (id) emit('activate', id)\n}\n\nconst noop = () => {}\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\nlet stopFormErrors: () => void = noop\nfunction release(): void {\n stopFormErrors()\n stopFormErrors = noop\n // Cleared first, so the plugins close their stores while the document is still alive.\n const doc = document.value\n document.value = null\n doc?.destroy()\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 fields: fieldsControlled.value\n ? {\n mode: 'controlled',\n initial: props.fields ?? {},\n onChange: (next, change) => emit('update:fields', next, change),\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 // The same for the fields; a document whose fields opened uncontrolled ignores the push.\n if (props.fields !== undefined) doc.form.setControlledValue(props.fields)\n // A form script that fails leaves the form fillable; the failure goes to `error`. Subscribed\n // before anyone hears of the document, so the form replays the errors from while it opened\n // here, not to a listener added in `ready`; they are held until `ready` has gone out.\n let held: InkError[] | undefined = []\n stopFormErrors = doc.form.on('error', (e) => {\n if (held) held.push(e)\n else emit('error', e)\n })\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 const early = held\n held = undefined\n if (gen === generation) for (const e of early) emit('error', e)\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 store: () =>\n document.value?.annotations.mode === 'controlled' ? document.value.annotations : null,\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 track: (store) =>\n controlled.value\n ? refHistory.track(store)\n : (document.value?.history.track(store) ?? noop),\n react: (fn) =>\n controlled.value ? refHistory.react(fn) : (document.value?.history.react(fn) ?? noop),\n}\n\n// The undo and redo keys anywhere in the root do what InkUndo and InkRedo do. When either\n// button undoes or redoes the last step and disables itself, focus goes back to the document.\n// The find key listens here too.\nwatch(\n rootEl,\n (el, _prev, onCleanup) => {\n if (!el) return\n const stopKeys = attachHistoryKeys(el, () => ({\n canUndo: inkHistory.canUndo.value,\n canRedo: inkHistory.canRedo.value,\n undo: inkHistory.undo,\n redo: inkHistory.redo,\n }))\n const stopFocus = keepHistoryFocus(el, () =>\n el.querySelector<HTMLElement>('[data-ink-scroll]')\n )\n // Ctrl or Cmd+P prints and +S downloads, as InkPrintButton and InkDownloadButton do.\n const stopFileKeys = attachFileKeys(el, () => document.value)\n // Not a template listener: Vue leaves those on the element when it unmounts.\n el.addEventListener('keydown', onKeydown)\n onCleanup(() => {\n stopKeys()\n stopFocus()\n stopFileKeys()\n el.removeEventListener('keydown', onKeydown)\n })\n },\n { immediate: true }\n)\n\n/*\n * One plugin host for the root's life, built once mounted so that no `setup` runs on the\n * server, where nothing would clean it up. Until then `pluginHost` is null, and InkCommand\n * renders its command disabled. The host follows `hostDocument`, which is set after `document`\n * (a sync watch): when the host reads `inkHistory` for a new document, it is that document's\n * history.\n */\nconst hostDocument = writable<InkDocument | null>(null)\nwatch(document, (doc) => hostDocument.set(doc), { flush: 'sync' })\nconst viewportEl = shallowRef<HTMLElement | null>(null)\nconst hostRoot = writable<HTMLElement | null>(null)\nwatch(viewportEl, (el) => hostRoot.set(el), { flush: 'sync' })\nconst hostActivated = writable<string | null>(null)\nwatch(activated, (id) => hostActivated.set(id), { flush: 'sync' })\nconst pluginHost = shallowRef<PluginHost | null>(null)\n/** One search controller for the root's life, built with the plugin host that shares it. */\nconst search = shallowRef<SearchController | null>(null)\nfunction setUpPlugins(): void {\n const controller = createSearchController({\n document: readonly(hostDocument),\n viewport: () => viewport.value,\n })\n search.value = controller\n pluginHost.value = createPluginHost({\n plugins: props.plugins ?? [],\n document: readonly(hostDocument),\n history: () => inkHistory,\n activated: readonly(hostActivated),\n // As in `createViewer`: an id not in the open document is ignored.\n setActivated: (id) => {\n if (id === null || document.value?.annotations.get(id)) setActivated(id)\n },\n root: readonly(hostRoot),\n decorate: () => props.decorateAnnotation,\n viewport: () => viewport.value,\n search: viewerSearchOf(controller),\n })\n}\n\n/** Ctrl/Cmd+F while focus is in the root and a find bar is mounted; else the browser's. */\nfunction onKeydown(e: KeyboardEvent): void {\n const controller = search.value\n const root = e.currentTarget\n if (controller && root instanceof HTMLElement)\n handleFindKey(e, controller, () => pageSelectionText(root))\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 // The plugins' tools too, so a plugin tool's style group applies (the host is set by now:\n // it is built on mount, before the first document opens).\n tools: [...(props.tools ?? []), ...(pluginHost.value?.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// Plugins and the document on the client only: on the server InkRoot renders its empty slot.\n// The plugins first, so the first document opens with their stores and reactions.\nonMounted(() => {\n syncRootEl()\n // A plugin whose setup throws still leaves the document to open; the error then goes to\n // Vue's error handling (`onErrorCaptured`, `app.config.errorHandler`).\n try {\n setUpPlugins()\n } finally {\n mounted.value = true\n void open()\n }\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.fields,\n (next) => {\n if (next) document.value?.form.setControlledValue(next)\n }\n)\n\n/*\n * The tools are known once the plugins are set up on mount. A tool id nobody registered is\n * logged as `UnknownTool`; as the active tool, from a `tool` prop or because it left `tools`,\n * it falls back to `select-text`, reported through `update:tool`. A controlled `tool` that\n * stays on the missing id is not applied again.\n */\nconst mounted = ref(false)\n/** The ids of the tools the current viewer was built with; InkViewport sets them. */\nconst openedToolIds = shallowRef<readonly ToolId[] | null>(null)\nconst toolIds = computed(() =>\n registeredToolIds(props.tools, pluginHost.value, openedToolIds.value)\n)\nconst isRegistered = (id: ToolId): boolean => !mounted.value || toolIds.value.includes(id)\nconst logUnknownTool = (id: ToolId): void => console.error(unknownTool(id, toolIds.value))\n\nfunction fallBack(id: ToolId): void {\n logUnknownTool(id)\n internalTool.value = 'select-text'\n emit('update:tool', 'select-text')\n}\n\nwatch(\n () => props.tool,\n (t) => {\n if (!t) return\n if (isRegistered(t)) internalTool.value = t\n else fallBack(t)\n }\n)\nwatch([mounted, toolIds], () => {\n if (!isRegistered(internalTool.value)) fallBack(internalTool.value)\n})\n\nfunction setTool(id: ToolId): void {\n // As the tool controller does: a missing tool is logged and nothing changes.\n if (!isRegistered(id)) {\n logUnknownTool(id)\n return\n }\n // Picking the active tool again starts it afresh, as after a one-shot tool's use.\n const tc = toolController.value\n if (internalTool.value === id && tc?.active.get() === id) tc.set(id)\n internalTool.value = id\n emit('update:tool', id)\n}\n\nonBeforeUnmount(() => {\n generation++\n release()\n})\n\n// After the children: InkViewport's engine, and the plugin layers with it, are gone by now, as\n// in `createViewer`, so no layer `destroy` runs after the plugins' cleanups.\nonUnmounted(() => {\n pluginHost.value?.destroy()\n pluginHost.value = null\n search.value?.destroy()\n search.value = null\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 openedToolIds,\n decorateAnnotation: computed(() => props.decorateAnnotation),\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,\n pluginHost,\n search,\n viewportEl,\n history: inkHistory,\n rootEl,\n formHighlight: computed(() => props.formHighlight),\n reportFormAction: (a) => emit('form-action', a),\n reportError: (e) => emit('error', e),\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoEA,IAAMQ,IAAQC,GAmFRC,IAAOH,GAsBPI,IAAYC,GAAiC,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,KAAiBC,QAA6BH,EAAS,OAAO,UAAU,MAAM,EAD1D,OAAO,OACmD,CAAI,GAClFI,IAASC,QAA0BJ,EAAS,SAASC,GAAe,KAAK,GACzEI,KAAiBH,QACfH,EAAS,OAAO,YAAY,QAAQ,MAC1C,CAAC,CACH,GACMO,KAAYJ,QACVH,EAAS,OAAO,YAAY,aAAa,MAC/C,CAAC,CACH,GACMQ,IAAWX,EAA4B,IAAI,GAC3CY,IAAiBZ,EAAkC,IAAI,GACvDa,IAAeC,EAAYpB,EAAM,QAAQ,aAAa,GACtDqB,IAAYD,EAAmB,IAAI,G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,QAAed,EAAM,kBAAkByG,EAAe;GACtE;GACA,WAAW3F,QAAed,EAAM,IAAI;GACpC,WAAWc,QAAed,EAAM,IAAI;GACpC,aAAa,MAAME,EAAK,eAAewG,CAAC;GACxC,aAAa,MAAMxG,EAAK,eAAeyG,CAAC;GACxC;GACA;GACA;GACA;GACA;GACA,SAASzD;GACT;GACA,eAAepC,QAAed,EAAM,aAAa;GACjD,mBAAmB,MAAME,EAAK,eAAe0G,CAAC;GAC9C,cAAc,MAAM1G,EAAK,SAAS,CAAC;EACrC,CAAC,GAIDJ,EAAa;GAAE;GAAU;GAAQ;GAAQ,SAASoD;EAAW,CAAC,cAI5D1D,GAAA,GAAAC,EAQYC,GAAAsH,EAAA,GAAA;GAPN,SAAA;GAAJ,KAAI7G;GACH,YAAUH,EAAM;GACjB,IAAG;GACH,iBAAA;GACC,cAAYa,EAAA,MAAO;;GAEpB,SAAAlB,QAA8C,CAA9CC,GAA8CuH,EAAA,QAAA,WAAA;IAAvC,QAAQtG,EAAA;IAAS,UAAUJ,EAAA"}
@@ -0,0 +1,7 @@
1
+ import e from "./InkSearchResults.vue_vue_type_script_setup_true_lang.js";
2
+ //#region src/components/InkSearchResults.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
6
+
7
+ //# sourceMappingURL=InkSearchResults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSearchResults.js","names":["_sfc_main","InkSearchResults_vue_vue_type_script_setup_true_lang_default","InkSearchResults_default"],"sources":["../../src/components/InkSearchResults.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The search hits as a list of cards, for a sidebar panel: `createSearchResults` on core's\n * record list controller over the root's search. One card per hit, with its page and the text\n * around it. Choosing a card makes its hit current, as the find bar's next and previous do, and\n * the current hit is the selected card. Above the cards, a query field (`:field=\"false\"`\n * leaves it out when a find bar is on the page); under them, the find bar's match count.\n * Field and find bar share the search state, so they never disagree. It fills its parent's\n * height. Inside `InkRoot`; it renders empty on the server.\n */\nimport {\n findCountText,\n handleResultsFieldKey,\n isBlankQuery,\n searchSource,\n} from '@inkbar/core/dom'\nimport { Search } from '@inkbar/icons'\nimport { computed } from 'vue'\n\nimport { useSearch } from '../composables/useSearch'\nimport { injectInkContext } from '../context'\n\nimport InkIcon from './InkIcon.vue'\nimport RecordCards from './RecordCards.vue'\n\nwithDefaults(defineProps<{ field?: boolean }>(), { field: true })\n\nconst ctx = injectInkContext()\nconst search = useSearch()\nconst { state } = search\n\nconst source = computed(() => (ctx.search.value ? searchSource(ctx.search.value) : null))\nconst count = computed(() => findCountText(state.value))\n// Nothing found yet is the count's to say while a query is in: \"No results\", or a scan.\nconst blank = computed(() => isBlankQuery(state.value.query))\n</script>\n\n<template>\n <div class=\"ink-search-results\" data-ink-search-results>\n <div v-if=\"field\" class=\"ink-search-results-bar\" role=\"search\">\n <div class=\"ink-input-group\">\n <span class=\"ink-input-accessory\"><InkIcon :icon=\"Search\" /></span>\n <input\n type=\"text\"\n aria-label=\"Find in document\"\n placeholder=\"Search for a word or phrase\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n :value=\"state.query\"\n @input=\"search.setQuery(($event.target as HTMLInputElement).value)\"\n @keydown=\"handleResultsFieldKey($event, search)\"\n />\n </div>\n </div>\n <RecordCards :source=\"source\" :empty-shown=\"blank\">\n <template #empty>Search to list every match.</template>\n </RecordCards>\n <!-- A footer under the cards, hidden while empty. -->\n <div class=\"ink-search-results-count\" data-ink-search-results-count>{{ count }}</div>\n </div>\n</template>\n"],"mappings":""}
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ field?: boolean;
3
+ };
4
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
5
+ field: boolean;
6
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
9
+ //# sourceMappingURL=InkSearchResults.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSearchResults.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkSearchResults.vue"],"names":[],"mappings":"AAwFA,KAAK,WAAW,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AA6GvC,QAAA,MAAM,YAAY;;6EAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -0,0 +1,52 @@
1
+ import { injectInkContext as e } from "../context.js";
2
+ import { useSearch as t } from "../composables/useSearch.js";
3
+ import n from "./InkIcon.js";
4
+ import r from "./RecordCards.js";
5
+ import { computed as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, createVNode as l, defineComponent as u, openBlock as d, toDisplayString as f, unref as p, withCtx as m } from "vue";
6
+ import { findCountText as h, handleResultsFieldKey as g, isBlankQuery as _, searchSource as v } from "@inkbar/core/dom";
7
+ import { Search as y } from "@inkbar/icons";
8
+ //#region src/components/InkSearchResults.vue?vue&type=script&setup=true&lang.ts
9
+ var b = {
10
+ class: "ink-search-results",
11
+ "data-ink-search-results": ""
12
+ }, x = {
13
+ key: 0,
14
+ class: "ink-search-results-bar",
15
+ role: "search"
16
+ }, S = { class: "ink-input-group" }, C = { class: "ink-input-accessory" }, w = ["value"], T = {
17
+ class: "ink-search-results-count",
18
+ "data-ink-search-results-count": ""
19
+ }, E = /*@__PURE__*/ u({
20
+ __name: "InkSearchResults",
21
+ props: { field: {
22
+ type: Boolean,
23
+ default: !0
24
+ } },
25
+ setup(u) {
26
+ let E = e(), D = t(), { state: O } = D, k = i(() => E.search.value ? v(E.search.value) : null), A = i(() => h(O.value)), j = i(() => _(O.value.query));
27
+ return (e, t) => (d(), o("div", b, [
28
+ u.field ? (d(), o("div", x, [s("div", S, [s("span", C, [l(n, { icon: p(y) }, null, 8, ["icon"])]), s("input", {
29
+ type: "text",
30
+ "aria-label": "Find in document",
31
+ placeholder: "Search for a word or phrase",
32
+ autocomplete: "off",
33
+ spellcheck: "false",
34
+ value: p(O).query,
35
+ onInput: t[0] ||= (e) => p(D).setQuery(e.target.value),
36
+ onKeydown: t[1] ||= (e) => p(g)(e, p(D))
37
+ }, null, 40, w)])])) : a("", !0),
38
+ l(r, {
39
+ source: k.value,
40
+ "empty-shown": j.value
41
+ }, {
42
+ empty: m(() => [...t[2] ||= [c("Search to list every match.", -1)]]),
43
+ _: 1
44
+ }, 8, ["source", "empty-shown"]),
45
+ s("div", T, f(A.value), 1)
46
+ ]));
47
+ }
48
+ });
49
+ //#endregion
50
+ export { E as default };
51
+
52
+ //# sourceMappingURL=InkSearchResults.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSearchResults.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_createElementVNode","_createVNode","InkIcon","_unref","_createCommentVNode","RecordCards","_withCtx","_createTextVNode","_toDisplayString","InkIcon_default","RecordCards_default","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","InkSearchResults_vue_vue_type_script_setup_true_lang_default","ctx","injectInkContext","search","useSearch","source","computed","searchSource","count","findCountText","state","blank","isBlankQuery","openBlock","createElementBlock","__props","createElementVNode","createVNode","unref","Search","_cache","$event","handleResultsFieldKey","createCommentVNode","withCtx","createTextVNode","toDisplayString"],"sources":["../../src/components/InkSearchResults.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * The search hits as a list of cards, for a sidebar panel: `createSearchResults` on core's\n * record list controller over the root's search. One card per hit, with its page and the text\n * around it. Choosing a card makes its hit current, as the find bar's next and previous do, and\n * the current hit is the selected card. Above the cards, a query field (`:field=\"false\"`\n * leaves it out when a find bar is on the page); under them, the find bar's match count.\n * Field and find bar share the search state, so they never disagree. It fills its parent's\n * height. Inside `InkRoot`; it renders empty on the server.\n */\nimport {\n findCountText,\n handleResultsFieldKey,\n isBlankQuery,\n searchSource,\n} from '@inkbar/core/dom'\nimport { Search } from '@inkbar/icons'\nimport { computed } from 'vue'\n\nimport { useSearch } from '../composables/useSearch'\nimport { injectInkContext } from '../context'\n\nimport InkIcon from './InkIcon.vue'\nimport RecordCards from './RecordCards.vue'\n\nwithDefaults(defineProps<{ field?: boolean }>(), { field: true })\n\nconst ctx = injectInkContext()\nconst search = useSearch()\nconst { state } = search\n\nconst source = computed(() => (ctx.search.value ? searchSource(ctx.search.value) : null))\nconst count = computed(() => findCountText(state.value))\n// Nothing found yet is the count's to say while a query is in: \"No results\", or a scan.\nconst blank = computed(() => isBlankQuery(state.value.query))\n</script>\n\n<template>\n <div class=\"ink-search-results\" data-ink-search-results>\n <div v-if=\"field\" class=\"ink-search-results-bar\" role=\"search\">\n <div class=\"ink-input-group\">\n <span class=\"ink-input-accessory\"><InkIcon :icon=\"Search\" /></span>\n <input\n type=\"text\"\n aria-label=\"Find in document\"\n placeholder=\"Search for a word or phrase\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n :value=\"state.query\"\n @input=\"search.setQuery(($event.target as HTMLInputElement).value)\"\n @keydown=\"handleResultsFieldKey($event, search)\"\n />\n </div>\n </div>\n <RecordCards :source=\"source\" :empty-shown=\"blank\">\n <template #empty>Search to list every match.</template>\n </RecordCards>\n <!-- A footer under the cards, hidden while empty. -->\n <div class=\"ink-search-results-count\" data-ink-search-results-count>{{ count }}</div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EA2BA,IAAMoB,IAAMC,EAAiB,GACvBC,IAASC,EAAU,GACnB,EAAE,aAAUD,GAEZE,IAASC,QAAgBL,EAAI,OAAO,QAAQM,EAAaN,EAAI,OAAO,KAAK,IAAI,IAAK,GAClFO,IAAQF,QAAeG,EAAcC,EAAM,KAAK,CAAC,GAEjDC,IAAQL,QAAeM,EAAaF,EAAM,MAAM,KAAK,CAAC;oBAI1D7B,EAAA,GAAAC,EAqBM,OArBNY,GAqBM;GApBOqB,EAAA,SAAXlC,EAAA,GAAAC,EAcM,OAdNa,GAcM,CAbJZ,EAYM,OAZNa,GAYM,CAXJb,EAAmE,QAAnEc,GAAmE,CAAjCb,EAA0BC,GAAA,EAAhB,MAAMC,EAAAiC,CAAA,EAAM,GAAA,MAAA,GAAA,CAAA,MAAA,CAAA,CAAA,CAAA,GACxDpC,EASE,SAAA;IARA,MAAK;IACL,cAAW;IACX,aAAY;IACZ,cAAa;IACb,YAAW;IACV,OAAOG,EAAAwB,CAAA,CAAK,CAAC;IACb,SAAK,AAAAU,EAAA,QAAA,MAAElC,EAAAiB,CAAA,CAAM,CAAC,SAAUkB,EAAO,OAA4B,KAAK;IAChE,WAAO,AAAAD,EAAA,QAAA,MAAElC,EAAAoC,CAAA,CAAqB,CAACD,GAAQnC,EAAAiB,CAAA,CAAM;;GAIpDnB,EAEcI,GAAA;IAFA,QAAQiB,EAAA;IAAS,eAAaM,EAAA;;IAC/B,OAAKtB,QAA4B,CAAA,GAAA,AAAA+B,EAAA,OAAA,CAA3B9B,EAAA,+BAA2B,EAAA,CAAA,CAAA,CAAA;;;GAG9CP,EAAqF,OAArFgB,GAAqFR,EAAdiB,EAAA,KAAK,GAAA,CAAA"}
@@ -0,0 +1,7 @@
1
+ import e from "./InkSidebar.vue_vue_type_script_setup_true_lang.js";
2
+ //#region src/components/InkSidebar.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
6
+
7
+ //# sourceMappingURL=InkSidebar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSidebar.js","names":["_sfc_main","InkSidebar_vue_vue_type_script_setup_true_lang_default","InkSidebar_default"],"sources":["../../src/components/InkSidebar.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * A sidebar of `InkPanel`s: `createSidebar`'s markup on core's sidebar controller, which holds\n * the open state, the ARIA, the keys and the clicks. Rail and tabs render their triggers here;\n * in a stack each panel renders its own header. Panels register as they are set up and take\n * their place in DOM order once mounted, so a panel added later with `v-if` slots in where it\n * stands. A closed panel stays mounted and hidden, and the panels' content stays in place\n * across layouts, so its state survives switching.\n *\n * `v-model:open` is the open panel's id (or null) for rail and tabs, and the expanded ids for\n * stack. Left unbound, the first panel starts open. It needs no document, so it works outside\n * `InkRoot`. The server renders the root, the panels (the open one shown) and the stack\n * headers; rail and tab buttons follow once mounted, as the panels register after the root\n * has rendered.\n */\nimport {\n createSidebarController,\n type SidebarLayout,\n type SidebarOpen,\n type SidebarSide,\n} from '@inkbar/core/dom'\nimport {\n computed,\n onBeforeUnmount,\n onMounted,\n shallowRef,\n useId,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { useReadable } from '../use-readable'\n\nimport { provideSidebarContext, type SidebarPanelEntry } from './sidebar-context'\nimport SidebarTrigger from './SidebarTrigger.vue'\n\nconst props = withDefaults(\n defineProps<{\n side?: SidebarSide | undefined\n layout?: SidebarLayout | undefined\n /** Default true. False hides the whole sidebar and keeps its open panel, content and scroll for when it shows again. */\n visible?: boolean | undefined\n }>(),\n { side: 'left', layout: 'rail', visible: true }\n)\n/** Undefined while unbound and untouched: the controller then opens the first panel. */\nconst open = defineModel<SidebarOpen | undefined>('open')\n\nconst entries = shallowRef<readonly SidebarPanelEntry[]>([])\nconst panels = computed(() => entries.value.map((e) => e.info()))\n\n// Pending until mounted: the panels register one by one while they are set up, and an open id\n// not registered yet is not a removed panel.\nconst controller = createSidebarController({\n layout: props.layout,\n side: props.side,\n visible: props.visible,\n panels: [],\n ...(open.value !== undefined && { open: open.value }),\n pending: true,\n onOpenChange: (value) => {\n open.value = value\n },\n // The same ids on the server and the client.\n idPrefix: useId(),\n})\n// Sync, so a panel set up next reads the attributes its registration gives (on the server too).\nwatch(\n () => [props.layout, props.side, props.visible, panels.value, open.value] as const,\n ([layout, side, visible, list, value]) =>\n controller.update({\n layout,\n side,\n visible,\n panels: list,\n ...(value !== undefined && { open: value }),\n }),\n { flush: 'sync' }\n)\nconst state = useReadable(controller.state, controller.state.get())\n\nfunction register(entry: SidebarPanelEntry): () => void {\n entries.value = [...entries.value, entry]\n return () => {\n entries.value = entries.value.filter((e) => e !== entry)\n }\n}\n\nfunction arrange(): void {\n const list = entries.value\n const sorted = [...list].sort((a, b) => {\n const x = a.element()\n const y = b.element()\n if (!x || !y || x === y) return 0\n return x.compareDocumentPosition(y) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1\n })\n if (sorted.some((e, i) => e !== list[i])) entries.value = sorted\n}\n\nprovideSidebarContext({ controller, state, register, arrange })\n\nconst view = computed(() => {\n const s = state.value\n return {\n root: controller.rootAttrs(),\n tablist: controller.tablistAttrs(),\n triggers: s.panels.map((panel) => ({\n panel,\n attrs: controller.triggerAttrs(panel.id),\n })),\n }\n})\n\nconst root = useTemplateRef<HTMLElement>('root')\n// The controller handles the triggers' clicks and keys, stack headers included.\nonMounted(() => {\n controller.bindTriggers(root.value!)\n controller.update({ pending: false })\n})\nonBeforeUnmount(() => controller.destroy())\n</script>\n\n<template>\n <div ref=\"root\" class=\"ink-sidebar\" v-bind=\"view.root\">\n <div\n v-if=\"state.layout !== 'stack'\"\n :class=\"state.layout === 'rail' ? 'ink-sidebar-rail' : 'ink-sidebar-tabs'\"\n v-bind=\"view.tablist\"\n >\n <button v-for=\"t in view.triggers\" :key=\"t.panel.id\" v-bind=\"t.attrs\">\n <SidebarTrigger :panel=\"t.panel\" :rail=\"state.layout === 'rail'\" />\n </button>\n </div>\n <!-- One element in every layout, so the panels are never remounted. -->\n <div :class=\"{ 'ink-sidebar-panels': state.layout !== 'stack' }\"><slot /></div>\n </div>\n</template>\n"],"mappings":""}
@@ -0,0 +1,34 @@
1
+ import { SidebarLayout, SidebarOpen, SidebarSide } from '@inkbar/core/dom';
2
+ type __VLS_Props = {
3
+ side?: SidebarSide | undefined;
4
+ layout?: SidebarLayout | undefined;
5
+ /** Default true. False hides the whole sidebar and keeps its open panel, content and scroll for when it shows again. */
6
+ visible?: boolean | undefined;
7
+ };
8
+ type __VLS_ModelProps = {
9
+ /** Undefined while unbound and untouched: the controller then opens the first panel. */
10
+ 'open'?: SidebarOpen | undefined;
11
+ };
12
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
13
+ declare var __VLS_7: {};
14
+ type __VLS_Slots = {} & {
15
+ default?: (props: typeof __VLS_7) => any;
16
+ };
17
+ declare const __VLS_base: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
18
+ "update:open": (value: SidebarOpen | undefined) => any;
19
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
20
+ "onUpdate:open"?: (value: SidebarOpen | undefined) => any;
21
+ }>, {
22
+ side: SidebarSide | undefined;
23
+ layout: SidebarLayout | undefined;
24
+ visible: boolean | undefined;
25
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
26
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
27
+ declare const _default: typeof __VLS_export;
28
+ export default _default;
29
+ type __VLS_WithSlots<T, S> = T & {
30
+ new (): {
31
+ $slots: S;
32
+ };
33
+ };
34
+ //# sourceMappingURL=InkSidebar.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSidebar.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkSidebar.vue"],"names":[],"mappings":"AAyJA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAA;AAiBzB,KAAK,WAAW,GAAG;IACf,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;IAC9B,MAAM,CAAC,EAAE,aAAa,GAAG,SAAS,CAAA;IAClC,wHAAwH;IACxH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B,CAAC;AAgFJ,KAAK,gBAAgB,GAAG;IACxB,wFAAwF;IACxF,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAChC,CAAC;AAOF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAyDxD,QAAA,IAAI,OAAO,IAAW,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;;;;;;;;6EAId,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"}
@@ -0,0 +1,95 @@
1
+ import { useReadable as e } from "../use-readable.js";
2
+ import { provideSidebarContext as t } from "./sidebar-context.js";
3
+ import n from "./SidebarTrigger.js";
4
+ import { Fragment as r, computed as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createVNode as c, defineComponent as l, mergeModels as u, mergeProps as d, normalizeClass as f, onBeforeUnmount as p, onMounted as m, openBlock as h, renderList as g, renderSlot as _, shallowRef as v, unref as y, useId as b, useModel as x, useTemplateRef as S, watch as C } from "vue";
5
+ import { createSidebarController as w } from "@inkbar/core/dom";
6
+ //#region src/components/InkSidebar.vue?vue&type=script&setup=true&lang.ts
7
+ var T = /*@__PURE__*/ l({
8
+ __name: "InkSidebar",
9
+ props: /*@__PURE__*/ u({
10
+ side: { default: "left" },
11
+ layout: { default: "rail" },
12
+ visible: {
13
+ type: Boolean,
14
+ default: !0
15
+ }
16
+ }, {
17
+ open: {},
18
+ openModifiers: {}
19
+ }),
20
+ emits: ["update:open"],
21
+ setup(l) {
22
+ let u = l, T = x(l, "open"), E = v([]), D = i(() => E.value.map((e) => e.info())), O = w({
23
+ layout: u.layout,
24
+ side: u.side,
25
+ visible: u.visible,
26
+ panels: [],
27
+ ...T.value !== void 0 && { open: T.value },
28
+ pending: !0,
29
+ onOpenChange: (e) => {
30
+ T.value = e;
31
+ },
32
+ idPrefix: b()
33
+ });
34
+ C(() => [
35
+ u.layout,
36
+ u.side,
37
+ u.visible,
38
+ D.value,
39
+ T.value
40
+ ], ([e, t, n, r, i]) => O.update({
41
+ layout: e,
42
+ side: t,
43
+ visible: n,
44
+ panels: r,
45
+ ...i !== void 0 && { open: i }
46
+ }), { flush: "sync" });
47
+ let k = e(O.state, O.state.get());
48
+ function A(e) {
49
+ return E.value = [...E.value, e], () => {
50
+ E.value = E.value.filter((t) => t !== e);
51
+ };
52
+ }
53
+ function j() {
54
+ let e = E.value, t = [...e].sort((e, t) => {
55
+ let n = e.element(), r = t.element();
56
+ return !n || !r || n === r ? 0 : n.compareDocumentPosition(r) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
57
+ });
58
+ t.some((t, n) => t !== e[n]) && (E.value = t);
59
+ }
60
+ t({
61
+ controller: O,
62
+ state: k,
63
+ register: A,
64
+ arrange: j
65
+ });
66
+ let M = i(() => {
67
+ let e = k.value;
68
+ return {
69
+ root: O.rootAttrs(),
70
+ tablist: O.tablistAttrs(),
71
+ triggers: e.panels.map((e) => ({
72
+ panel: e,
73
+ attrs: O.triggerAttrs(e.id)
74
+ }))
75
+ };
76
+ }), N = S("root");
77
+ return m(() => {
78
+ O.bindTriggers(N.value), O.update({ pending: !1 });
79
+ }), p(() => O.destroy()), (e, t) => (h(), o("div", d({
80
+ ref_key: "root",
81
+ ref: N,
82
+ class: "ink-sidebar"
83
+ }, M.value.root), [y(k).layout === "stack" ? a("", !0) : (h(), o("div", d({
84
+ key: 0,
85
+ class: y(k).layout === "rail" ? "ink-sidebar-rail" : "ink-sidebar-tabs"
86
+ }, M.value.tablist), [(h(!0), o(r, null, g(M.value.triggers, (e) => (h(), o("button", d({ key: e.panel.id }, { ref_for: !0 }, e.attrs), [c(n, {
87
+ panel: e.panel,
88
+ rail: y(k).layout === "rail"
89
+ }, null, 8, ["panel", "rail"])], 16))), 128))], 16)), s("div", { class: f({ "ink-sidebar-panels": y(k).layout !== "stack" }) }, [_(e.$slots, "default")], 2)], 16));
90
+ }
91
+ });
92
+ //#endregion
93
+ export { T as default };
94
+
95
+ //# sourceMappingURL=InkSidebar.vue_vue_type_script_setup_true_lang.js.map