@inkbar/vue 0.4.0 → 0.5.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 (51) hide show
  1. package/README.md +3 -5
  2. package/dist/components/InkAnnotation.js.map +1 -1
  3. package/dist/components/InkAnnotation.vue.d.ts.map +1 -1
  4. package/dist/components/InkAnnotation.vue_vue_type_script_setup_true_lang.js +16 -24
  5. package/dist/components/InkAnnotation.vue_vue_type_script_setup_true_lang.js.map +1 -1
  6. package/dist/components/InkColorMenu.js.map +1 -1
  7. package/dist/components/InkColorMenu.vue.d.ts +2 -0
  8. package/dist/components/InkColorMenu.vue.d.ts.map +1 -1
  9. package/dist/components/InkColorMenu.vue_vue_type_script_setup_true_lang.js +3 -2
  10. package/dist/components/InkColorMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  11. package/dist/components/InkHighlightMenu.js.map +1 -1
  12. package/dist/components/InkHighlightMenu.vue.d.ts +2 -2
  13. package/dist/components/InkHighlightMenu.vue.d.ts.map +1 -1
  14. package/dist/components/InkHighlightMenu.vue_vue_type_script_setup_true_lang.js +118 -108
  15. package/dist/components/InkHighlightMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  16. package/dist/components/InkRoot.js.map +1 -1
  17. package/dist/components/InkRoot.vue.d.ts +408 -424
  18. package/dist/components/InkRoot.vue.d.ts.map +1 -1
  19. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js +33 -27
  20. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js.map +1 -1
  21. package/dist/components/InkShapeMenu.js.map +1 -1
  22. package/dist/components/InkShapeMenu.vue.d.ts +2 -2
  23. package/dist/components/InkShapeMenu.vue.d.ts.map +1 -1
  24. package/dist/components/InkShapeMenu.vue_vue_type_script_setup_true_lang.js +99 -91
  25. package/dist/components/InkShapeMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  26. package/dist/components/InkSignatureMenu.js.map +1 -1
  27. package/dist/components/InkSignatureMenu.vue.d.ts +2 -2
  28. package/dist/components/InkSignatureMenu.vue.d.ts.map +1 -1
  29. package/dist/components/InkSignatureMenu.vue_vue_type_script_setup_true_lang.js +156 -151
  30. package/dist/components/InkSignatureMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  31. package/dist/components/InkViewport.js.map +1 -1
  32. package/dist/components/InkViewport.vue.d.ts.map +1 -1
  33. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js +9 -2
  34. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js.map +1 -1
  35. package/dist/composables/useAnnotations.d.ts +915 -1386
  36. package/dist/composables/useAnnotations.d.ts.map +1 -1
  37. package/dist/composables/useAnnotations.js +13 -18
  38. package/dist/composables/useAnnotations.js.map +1 -1
  39. package/dist/context.d.ts +8 -1
  40. package/dist/context.d.ts.map +1 -1
  41. package/dist/context.js.map +1 -1
  42. package/dist/index.d.ts +1 -2
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +1 -2
  45. package/package.json +5 -5
  46. package/dist/components/InkSuggestionCard.js +0 -7
  47. package/dist/components/InkSuggestionCard.js.map +0 -1
  48. package/dist/components/InkSuggestionCard.vue.d.ts +0 -16
  49. package/dist/components/InkSuggestionCard.vue.d.ts.map +0 -1
  50. package/dist/components/InkSuggestionCard.vue_vue_type_script_setup_true_lang.js +0 -85
  51. package/dist/components/InkSuggestionCard.vue_vue_type_script_setup_true_lang.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useAnnotations.d.ts","sourceRoot":"","sources":["../../src/composables/useAnnotations.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAc,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEhF,wBAAgB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEvB"}
@@ -1,27 +1,22 @@
1
1
  import { useInkContext as e } from "../context.js";
2
2
  import { computed as t } from "vue";
3
- import { acceptSuggestion as n, repliesTo as r } from "@inkbar/core";
3
+ import { repliesTo as n } from "@inkbar/core";
4
4
  //#region src/composables/useAnnotations.ts
5
- function i() {
6
- let i = e("useAnnotations()"), a = () => i.document.value?.annotations;
5
+ function r() {
6
+ let r = e("useAnnotations()"), i = () => r.document.value?.annotations;
7
7
  return {
8
- annotations: i.annotations,
9
- selection: i.selection,
10
- selected: t(() => i.selection.value.map((e) => i.annotations.value.find((t) => t.id === e)).filter((e) => !!e)),
11
- byPage: (e) => i.annotations.value.filter((t) => t.page === e),
12
- add: (e) => a()?.add(e),
13
- update: (e, t) => a()?.update(e, t),
14
- remove: (e) => a()?.remove(e) ?? !1,
15
- select: (e) => a()?.select(e),
16
- replies: (e) => r(i.annotations.value, e),
17
- accept: (e) => {
18
- let t = a();
19
- return t ? n(t, e) : void 0;
20
- },
21
- dismiss: (e) => a()?.remove(e) ?? !1
8
+ annotations: r.annotations,
9
+ selection: r.selection,
10
+ selected: t(() => r.selection.value.map((e) => r.annotations.value.find((t) => t.id === e)).filter((e) => !!e)),
11
+ byPage: (e) => r.annotations.value.filter((t) => t.page === e),
12
+ add: (e) => i()?.add(e),
13
+ update: (e, t) => i()?.update(e, t),
14
+ remove: (e) => i()?.remove(e) ?? !1,
15
+ select: (e) => i()?.select(e),
16
+ replies: (e) => n(r.annotations.value, e)
22
17
  };
23
18
  }
24
19
  //#endregion
25
- export { i as useAnnotations };
20
+ export { r as useAnnotations };
26
21
 
27
22
  //# sourceMappingURL=useAnnotations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAnnotations.js","names":["useAnnotations","ctx","useInkContext","store","computed","a","id","page","input","patch","ids","repliesTo","s","acceptSuggestion"],"sources":["../../src/composables/useAnnotations.ts"],"sourcesContent":["import { acceptSuggestion, repliesTo } from '@inkbar/core'\nimport { computed } from 'vue'\n\nimport { useInkContext } from '../context'\n\nimport type { Annotation, AnnotationInput, AnnotationPatch } from '@inkbar/core'\n\nexport function useAnnotations() {\n const ctx = useInkContext('useAnnotations()')\n const store = () => ctx.document.value?.annotations\n return {\n annotations: ctx.annotations,\n selection: ctx.selection,\n selected: computed(() =>\n ctx.selection.value\n .map((id) => ctx.annotations.value.find((a) => a.id === id))\n .filter((a): a is Annotation => !!a)\n ),\n byPage: (page: number) => ctx.annotations.value.filter((a) => a.page === page),\n add: (input: AnnotationInput) => store()?.add(input),\n update: (id: string, patch: AnnotationPatch) => store()?.update(id, patch),\n remove: (id: string) => store()?.remove(id) ?? false,\n select: (ids: string[]) => store()?.select(ids),\n /** Replies in creation order for a note id. */\n replies: (id: string) => repliesTo(ctx.annotations.value, id),\n /** Keeps a suggested redaction as the user's own, in the default redaction colour. */\n accept: (id: string) => {\n const s = store()\n return s ? acceptSuggestion(s, id) : undefined\n },\n dismiss: (id: string) => store()?.remove(id) ?? false,\n }\n}\n"],"mappings":";;;;AAOA,SAAgBA,IAAiB;CAC/B,IAAMC,IAAMC,EAAc,kBAAkB,GACtCC,UAAcF,EAAI,SAAS,OAAO;CACxC,OAAO;EACL,aAAaA,EAAI;EACjB,WAAWA,EAAI;EACf,UAAUG,QACRH,EAAI,UAAU,MACX,KAAK,MAAOA,EAAI,YAAY,MAAM,MAAM,MAAMI,EAAE,OAAOC,CAAE,CAAC,CAAC,CAC3D,QAAQ,MAAuB,CAAC,CAACD,CAAC,CACvC;EACA,SAAS,MAAiBJ,EAAI,YAAY,MAAM,QAAQ,MAAMI,EAAE,SAASE,CAAI;EAC7E,MAAM,MAA2BJ,EAAM,CAAC,EAAE,IAAIK,CAAK;EACnD,SAAS,GAAY,MAA2BL,EAAM,CAAC,EAAE,OAAOG,GAAIG,CAAK;EACzE,SAAS,MAAeN,EAAM,CAAC,EAAE,OAAOG,CAAE,KAAK;EAC/C,SAAS,MAAkBH,EAAM,CAAC,EAAE,OAAOO,CAAG;EAE9C,UAAU,MAAeC,EAAUV,EAAI,YAAY,OAAOK,CAAE;EAE5D,SAAS,MAAe;GACtB,IAAMM,IAAIT,EAAM;GAChB,OAAOS,IAAIC,EAAiBD,GAAGN,CAAE,IAAI,KAAA;EACvC;EACA,UAAU,MAAeH,EAAM,CAAC,EAAE,OAAOG,CAAE,KAAK;CAClD;AACF"}
1
+ {"version":3,"file":"useAnnotations.js","names":["useAnnotations","ctx","useInkContext","store","computed","a","id","page","input","patch","ids","repliesTo"],"sources":["../../src/composables/useAnnotations.ts"],"sourcesContent":["import { repliesTo } from '@inkbar/core'\nimport { computed } from 'vue'\n\nimport { useInkContext } from '../context'\n\nimport type { Annotation, AnnotationInput, AnnotationPatch } from '@inkbar/core'\n\nexport function useAnnotations() {\n const ctx = useInkContext('useAnnotations()')\n const store = () => ctx.document.value?.annotations\n return {\n annotations: ctx.annotations,\n selection: ctx.selection,\n selected: computed(() =>\n ctx.selection.value\n .map((id) => ctx.annotations.value.find((a) => a.id === id))\n .filter((a): a is Annotation => !!a)\n ),\n byPage: (page: number) => ctx.annotations.value.filter((a) => a.page === page),\n add: (input: AnnotationInput) => store()?.add(input),\n update: (id: string, patch: AnnotationPatch) => store()?.update(id, patch),\n remove: (id: string) => store()?.remove(id) ?? false,\n select: (ids: string[]) => store()?.select(ids),\n /** Replies in creation order for a note id. */\n replies: (id: string) => repliesTo(ctx.annotations.value, id),\n }\n}\n"],"mappings":";;;;AAOA,SAAgBA,IAAiB;CAC/B,IAAMC,IAAMC,EAAc,kBAAkB,GACtCC,UAAcF,EAAI,SAAS,OAAO;CACxC,OAAO;EACL,aAAaA,EAAI;EACjB,WAAWA,EAAI;EACf,UAAUG,QACRH,EAAI,UAAU,MACX,KAAK,MAAOA,EAAI,YAAY,MAAM,MAAM,MAAMI,EAAE,OAAOC,CAAE,CAAC,CAAC,CAC3D,QAAQ,MAAuB,CAAC,CAACD,CAAC,CACvC;EACA,SAAS,MAAiBJ,EAAI,YAAY,MAAM,QAAQ,MAAMI,EAAE,SAASE,CAAI;EAC7E,MAAM,MAA2BJ,EAAM,CAAC,EAAE,IAAIK,CAAK;EACnD,SAAS,GAAY,MAA2BL,EAAM,CAAC,EAAE,OAAOG,GAAIG,CAAK;EACzE,SAAS,MAAeN,EAAM,CAAC,EAAE,OAAOG,CAAE,KAAK;EAC/C,SAAS,MAAkBH,EAAM,CAAC,EAAE,OAAOO,CAAG;EAE9C,UAAU,MAAeC,EAAUV,EAAI,YAAY,OAAOK,CAAE;CAC9D;AACF"}
package/dist/context.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Annotation, InkDocument, InkStatus, PdfAssets, SignatureLibrary } from '@inkbar/core';
2
- import { Tool, ToolController, ToolId, ToolOptions, ToolStyle, Viewport, ZoomValue } from '@inkbar/core/dom';
2
+ import { DecorateAnnotation, Tool, ToolController, ToolId, ToolOptions, ToolStyle, Viewport, ZoomValue } from '@inkbar/core/dom';
3
3
  import { Ref, ShallowRef } from 'vue';
4
4
  export type { InkStatus };
5
5
  /** Undo and redo for the current document, whichever mode its annotations are in. */
@@ -32,6 +32,8 @@ export interface InkContext {
32
32
  setTool(id: ToolId): void;
33
33
  /** Host tools from InkRoot's `tools` prop; InkViewport registers them. */
34
34
  hostTools: Readonly<Ref<Tool[] | undefined>>;
35
+ /** InkRoot's `decorateAnnotation` prop. InkViewport re-applies decorations when it changes. */
36
+ decorateAnnotation: Readonly<Ref<DecorateAnnotation | undefined>>;
35
37
  /** The font families text boxes offer: InkRoot's `fonts`, else `FONT_FAMILIES`. */
36
38
  fonts: Readonly<Ref<readonly string[]>>;
37
39
  /** The tools' options for InkRoot's life, so they persist across documents. */
@@ -49,6 +51,11 @@ export interface InkContext {
49
51
  reportPage(p: number): void;
50
52
  /** Last activated annotation (Enter, click with the note tool, etc.). Popovers key off this. */
51
53
  activated: Readonly<Ref<string | null>>;
54
+ /**
55
+ * Activates annotation `id`, or clears the activation with `null`. This is the context's
56
+ * own: unlike core's `Viewer.setActivated`, it emits InkRoot's `activate` for an id, and it
57
+ * does not check that the id is in the document.
58
+ */
52
59
  setActivated(id: string | null): void;
53
60
  history: InkHistory;
54
61
  rootEl: Readonly<Ref<HTMLElement | null>>;
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,SAAS,EACT,SAAS,EACT,gBAAgB,EACjB,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EACV,IAAI,EACJ,cAAc,EACd,MAAM,EACN,WAAW,EACX,SAAS,EACT,QAAQ,EACR,SAAS,EACV,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAE1C,YAAY,EAAE,SAAS,EAAE,CAAA;AAEzB,qFAAqF;AACrF,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;IAC/B,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;IAC/B,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB;;;;;OAKG;IACH,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,CAAA;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC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gBAAgB,CAAC,CAAC,CAAA;IAClD,8FAA8F;IAC9F,cAAc,EAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC,CAAA;IAChD,wEAAwE;IACxE,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,CAAA;IACjD,4FAA4F;IAC5F,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC,CAAA;IAC/C,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAA;IAC5C,UAAU,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;IAC9B,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,gGAAgG;IAChG,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAA;IACvC;;;;OAIG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;IACrC,OAAO,EAAE,UAAU,CAAA;IACnB,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC,CAAA;CAC1C;AAED,eAAO,MAAO,gBAAgB,uIAAE,iBAAiB,0CAAwC,CAAA;AAEzF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAO1D"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":["injectInkContext","provideInkContext","createContext","useInkContext","ctx","getCurrentInstance","consumer"],"sources":["../src/context.ts"],"sourcesContent":["import { createContext } from 'reka-ui'\nimport { getCurrentInstance } from 'vue'\n\nimport type {\n Annotation,\n InkDocument,\n InkStatus,\n PdfAssets,\n SignatureLibrary,\n} from '@inkbar/core'\nimport type {\n Tool,\n ToolController,\n ToolId,\n ToolOptions,\n ToolStyle,\n Viewport,\n ZoomValue,\n} from '@inkbar/core/dom'\nimport type { Ref, ShallowRef } from 'vue'\n\nexport type { InkStatus }\n\n/** Undo and redo for the current document, whichever mode its annotations are in. */\nexport interface InkHistory {\n canUndo: Readonly<Ref<boolean>>\n canRedo: Readonly<Ref<boolean>>\n undo: () => void\n redo: () => void\n clear: () => void\n /**\n * Runs `fn` and records what it changes as one undo step. The host still receives one change\n * per add. Controlled, the history groups the resulting list changes into one step, and\n * `canUndo` updates once the current task ends. Any other change the host applies in that\n * same window joins the step.\n */\n batch: (fn: () => void) => void\n}\n\nexport interface InkContext {\n assets: Readonly<Ref<PdfAssets>>\n document: Readonly<ShallowRef<InkDocument | null>>\n /** `loading` from the moment a document starts opening, then the document's own status. */\n status: Readonly<Ref<InkStatus>>\n annotations: Readonly<Ref<readonly Annotation[]>>\n selection: Readonly<Ref<readonly string[]>>\n /** Set by InkViewport once it has mounted its viewport and tool controller. */\n viewport: ShallowRef<Viewport | null>\n tools: ShallowRef<ToolController | null>\n /** Desired tool; InkViewport applies it to the controller. */\n tool: Readonly<Ref<ToolId>>\n setTool(id: ToolId): void\n /** Host tools from InkRoot's `tools` prop; InkViewport registers them. */\n hostTools: Readonly<Ref<Tool[] | undefined>>\n /** The font families text boxes offer: InkRoot's `fonts`, else `FONT_FAMILIES`. */\n fonts: Readonly<Ref<readonly string[]>>\n /** The tools' options for InkRoot's life, so they persist across documents. */\n toolOptions: ToolOptions\n /** The saved signatures, from InkRoot's `signatures` store (memory by default). */\n signatures: Readonly<ShallowRef<SignatureLibrary>>\n /** The fonts a typed signature offers: InkRoot's `signatureFonts`, else `SIGNATURE_FONTS`. */\n signatureFonts: Readonly<Ref<readonly string[]>>\n /** The open document's tool style; `null` while no document is open. */\n toolStyle: Readonly<ShallowRef<ToolStyle | null>>\n /** Desired zoom and page from the host's v-models; InkViewport applies and reports back. */\n zoomModel: Readonly<Ref<ZoomValue | undefined>>\n pageModel: Readonly<Ref<number | undefined>>\n reportZoom(z: ZoomValue): void\n reportPage(p: number): void\n /** Last activated annotation (Enter, click with the note tool, etc.). Popovers key off this. */\n activated: Readonly<Ref<string | null>>\n setActivated(id: string | null): void\n history: InkHistory\n rootEl: Readonly<Ref<HTMLElement | null>>\n}\n\nexport const [injectInkContext, provideInkContext] = createContext<InkContext>('InkRoot')\n\n/**\n * The context for composables: throws a readable error when called outside a component\n * rendered inside `InkRoot`, instead of Vue's injection warning.\n */\nexport function useInkContext(consumer: string): InkContext {\n const ctx = getCurrentInstance() ? injectInkContext(null) : null\n if (!ctx)\n throw new Error(\n `[inkbar] ${consumer} must be called in a component inside <InkRoot>.`\n )\n return ctx\n}\n"],"mappings":";;;AA4EA,IAAa,CAACA,GAAkBC,KAAqBC,EAA0B,SAAS;AAMxF,SAAgBC,EAAc,GAA8B;CAC1D,IAAMC,IAAMC,EAAmB,IAAIL,EAAiB,IAAI,IAAI;CAC5D,IAAI,CAACI,GACH,MAAU,MACR,YAAYE,EAAS,iDACvB;CACF,OAAOF;AACT"}
1
+ {"version":3,"file":"context.js","names":["injectInkContext","provideInkContext","createContext","useInkContext","ctx","getCurrentInstance","consumer"],"sources":["../src/context.ts"],"sourcesContent":["import { createContext } from 'reka-ui'\nimport { getCurrentInstance } from 'vue'\n\nimport type {\n Annotation,\n InkDocument,\n InkStatus,\n PdfAssets,\n SignatureLibrary,\n} from '@inkbar/core'\nimport type {\n DecorateAnnotation,\n Tool,\n ToolController,\n ToolId,\n ToolOptions,\n ToolStyle,\n Viewport,\n ZoomValue,\n} from '@inkbar/core/dom'\nimport type { Ref, ShallowRef } from 'vue'\n\nexport type { InkStatus }\n\n/** Undo and redo for the current document, whichever mode its annotations are in. */\nexport interface InkHistory {\n canUndo: Readonly<Ref<boolean>>\n canRedo: Readonly<Ref<boolean>>\n undo: () => void\n redo: () => void\n clear: () => void\n /**\n * Runs `fn` and records what it changes as one undo step. The host still receives one change\n * per add. Controlled, the history groups the resulting list changes into one step, and\n * `canUndo` updates once the current task ends. Any other change the host applies in that\n * same window joins the step.\n */\n batch: (fn: () => void) => void\n}\n\nexport interface InkContext {\n assets: Readonly<Ref<PdfAssets>>\n document: Readonly<ShallowRef<InkDocument | null>>\n /** `loading` from the moment a document starts opening, then the document's own status. */\n status: Readonly<Ref<InkStatus>>\n annotations: Readonly<Ref<readonly Annotation[]>>\n selection: Readonly<Ref<readonly string[]>>\n /** Set by InkViewport once it has mounted its viewport and tool controller. */\n viewport: ShallowRef<Viewport | null>\n tools: ShallowRef<ToolController | null>\n /** Desired tool; InkViewport applies it to the controller. */\n tool: Readonly<Ref<ToolId>>\n setTool(id: ToolId): void\n /** Host tools from InkRoot's `tools` prop; InkViewport registers them. */\n hostTools: Readonly<Ref<Tool[] | undefined>>\n /** InkRoot's `decorateAnnotation` prop. InkViewport re-applies decorations when it changes. */\n decorateAnnotation: Readonly<Ref<DecorateAnnotation | undefined>>\n /** The font families text boxes offer: InkRoot's `fonts`, else `FONT_FAMILIES`. */\n fonts: Readonly<Ref<readonly string[]>>\n /** The tools' options for InkRoot's life, so they persist across documents. */\n toolOptions: ToolOptions\n /** The saved signatures, from InkRoot's `signatures` store (memory by default). */\n signatures: Readonly<ShallowRef<SignatureLibrary>>\n /** The fonts a typed signature offers: InkRoot's `signatureFonts`, else `SIGNATURE_FONTS`. */\n signatureFonts: Readonly<Ref<readonly string[]>>\n /** The open document's tool style; `null` while no document is open. */\n toolStyle: Readonly<ShallowRef<ToolStyle | null>>\n /** Desired zoom and page from the host's v-models; InkViewport applies and reports back. */\n zoomModel: Readonly<Ref<ZoomValue | undefined>>\n pageModel: Readonly<Ref<number | undefined>>\n reportZoom(z: ZoomValue): void\n reportPage(p: number): void\n /** Last activated annotation (Enter, click with the note tool, etc.). Popovers key off this. */\n activated: Readonly<Ref<string | null>>\n /**\n * Activates annotation `id`, or clears the activation with `null`. This is the context's\n * own: unlike core's `Viewer.setActivated`, it emits InkRoot's `activate` for an id, and it\n * does not check that the id is in the document.\n */\n setActivated(id: string | null): void\n history: InkHistory\n rootEl: Readonly<Ref<HTMLElement | null>>\n}\n\nexport const [injectInkContext, provideInkContext] = createContext<InkContext>('InkRoot')\n\n/**\n * The context for composables: throws a readable error when called outside a component\n * rendered inside `InkRoot`, instead of Vue's injection warning.\n */\nexport function useInkContext(consumer: string): InkContext {\n const ctx = getCurrentInstance() ? injectInkContext(null) : null\n if (!ctx)\n throw new Error(\n `[inkbar] ${consumer} must be called in a component inside <InkRoot>.`\n )\n return ctx\n}\n"],"mappings":";;;AAoFA,IAAa,CAACA,GAAkBC,KAAqBC,EAA0B,SAAS;AAMxF,SAAgBC,EAAc,GAA8B;CAC1D,IAAMC,IAAMC,EAAmB,IAAIL,EAAiB,IAAI,IAAI;CAC5D,IAAI,CAACI,GACH,MAAU,MACR,YAAYE,EAAS,iDACvB;CACF,OAAOF;AACT"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { default as InkRoot } from './components/InkRoot.vue';
2
2
  export { injectInkContext } from './context';
3
3
  export type { InkContext, InkHistory, InkStatus } from './context';
4
+ export type { AnnotationDecoration, DecorateAnnotation } from '@inkbar/core/dom';
4
5
  export { useReadable } from './use-readable';
5
6
  export { useDocument } from './composables/useDocument';
6
7
  export { useAnnotations } from './composables/useAnnotations';
@@ -39,6 +40,4 @@ export { default as InkPrevPage } from './components/InkPrevPage.vue';
39
40
  export { default as InkNextPage } from './components/InkNextPage.vue';
40
41
  export { default as InkThreadPopover } from './components/InkThreadPopover.vue';
41
42
  export type { ThreadPopoverSlotProps } from './components/InkThreadPopover.vue';
42
- export { default as InkSuggestionCard } from './components/InkSuggestionCard.vue';
43
- export type { ConfidenceBucket, SuggestionCardSlotProps, } from './components/InkSuggestionCard.vue';
44
43
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,EAAE,gB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ACrE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,8BAA8B,CAAA;AACrE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAC/E,YAAY,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAA"}
package/dist/index.js CHANGED
@@ -35,5 +35,4 @@ import N from "./components/InkPageCount.js";
35
35
  import P from "./components/InkPrevPage.js";
36
36
  import F from "./components/InkNextPage.js";
37
37
  import I from "./components/InkThreadPopover.js";
38
- import L from "./components/InkSuggestionCard.js";
39
- export { p as InkAnnotation, S as InkColorMenu, E as InkHighlightMenu, _ as InkIcon, D as InkLineStyleMenu, F as InkNextPage, m as InkPage, N as InkPageCount, M as InkPageInput, P as InkPrevPage, x as InkRedo, n as InkRoot, C as InkShapeMenu, w as InkSignatureDialog, T as InkSignatureMenu, L as InkSuggestionCard, O as InkTextStyleMenu, I as InkThreadPopover, v as InkToolButton, g as InkToolbar, y as InkToolbarSeparator, b as InkUndo, h as InkViewport, k as InkZoomIn, A as InkZoomOut, j as InkZoomSelect, e as injectInkContext, i as useAnnotations, r as useDocument, f as useEmbedded, d as useHistory, u as usePage, t as useReadable, c as useSelection, a as useTool, s as useToolOptions, o as useToolStyle, l as useZoom };
38
+ export { p as InkAnnotation, S as InkColorMenu, E as InkHighlightMenu, _ as InkIcon, D as InkLineStyleMenu, F as InkNextPage, m as InkPage, N as InkPageCount, M as InkPageInput, P as InkPrevPage, x as InkRedo, n as InkRoot, C as InkShapeMenu, w as InkSignatureDialog, T as InkSignatureMenu, O as InkTextStyleMenu, I as InkThreadPopover, v as InkToolButton, g as InkToolbar, y as InkToolbarSeparator, b as InkUndo, h as InkViewport, k as InkZoomIn, A as InkZoomOut, j as InkZoomSelect, e as injectInkContext, i as useAnnotations, r as useDocument, f as useEmbedded, d as useHistory, u as usePage, t as useReadable, c as useSelection, a as useTool, s as useToolOptions, o as useToolStyle, l as useZoom };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkbar/vue",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Vue 3 components and composables for Inkbar, the browser PDF viewer and editor.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://inkbar.dev",
@@ -24,17 +24,17 @@
24
24
  "./package.json": "./package.json"
25
25
  },
26
26
  "dependencies": {
27
- "@inkbar/icons": "^0.4.0",
27
+ "@inkbar/icons": "^0.5.0",
28
28
  "reka-ui": "^2.11.0"
29
29
  },
30
30
  "peerDependencies": {
31
- "@inkbar/core": "^0.4.0",
31
+ "@inkbar/core": "^0.5.0",
32
32
  "vue": "^3.5.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@inkbar/core": "0.4.0",
35
+ "@inkbar/core": "0.5.0",
36
36
  "@inkbar/fixtures": "0.0.0",
37
- "@inkbar/theme": "0.4.0",
37
+ "@inkbar/theme": "0.5.0",
38
38
  "@playwright/experimental-ct-vue": "1.62.1",
39
39
  "@playwright/test": "1.62.1",
40
40
  "@vitejs/plugin-vue": "^6.0.10",
@@ -1,7 +0,0 @@
1
- import e from "./InkSuggestionCard.vue_vue_type_script_setup_true_lang.js";
2
- //#region src/components/InkSuggestionCard.vue
3
- var t = e;
4
- //#endregion
5
- export { t as default };
6
-
7
- //# sourceMappingURL=InkSuggestionCard.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InkSuggestionCard.js","names":["_sfc_main","InkSuggestionCard_vue_vue_type_script_setup_true_lang_default","InkSuggestionCard_default"],"sources":["../../src/components/InkSuggestionCard.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * Review card for a suggested redaction: opens when the activated annotation, or the only\n * selected one, is a redaction with `origin: 'suggested'`. Locked suggestions cannot be\n * dismissed, so they get no Dismiss button. A press on the overlay selects and\n * activates, so a click opens it whatever the tool. Closing clears `activated` and the\n * selection.\n */\nimport { confidenceBucket } from '@inkbar/core'\nimport { PopoverContent, PopoverPortal, PopoverRoot } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport { useAnnotations } from '../composables/useAnnotations'\nimport { injectInkContext } from '../context'\n\nimport { useAnnotationElement } from './annotation-element'\nimport { keepOpenOnAnnotation, useFocusReturn } from './popover-focus'\n\nimport type { ConfidenceBucket, RedactAnnotation } from '@inkbar/core'\nimport type { SuggestionCardSlotProps } from '@inkbar/core/dom'\n\nexport type { ConfidenceBucket } from '@inkbar/core'\n\nexport type { SuggestionCardSlotProps } from '@inkbar/core/dom'\n\ndefineSlots<{ default?(props: SuggestionCardSlotProps): unknown }>()\n\nconst ctx = injectInkContext()\nconst {\n annotations,\n selection,\n accept: acceptId,\n dismiss: dismissId,\n select,\n} = useAnnotations()\n\nfunction suggestion(id: string | null | undefined): RedactAnnotation | null {\n const a = id ? annotations.value.find((x) => x.id === id) : undefined\n return a?.type === 'redact' && a.origin === 'suggested' ? a : null\n}\n// The activated annotation when it is a suggestion; otherwise the only selected one (a\n// marquee selects without activating).\nconst target = computed<RedactAnnotation | null>(\n () =>\n suggestion(ctx.activated.value) ??\n (selection.value.length === 1 ? suggestion(selection.value[0]) : null)\n)\nconst anchor = useAnnotationElement(\n ctx,\n computed(() => target.value?.id ?? null)\n)\nconst focusReturn = useFocusReturn(ctx)\nconst open = computed(() => target.value !== null && anchor.value !== null)\nconst bucket = computed<ConfidenceBucket | undefined>(() =>\n target.value?.suggestion\n ? confidenceBucket(target.value.suggestion.confidence)\n : undefined\n)\n\nfunction close(): void {\n ctx.setActivated(null)\n select([])\n}\nfunction accept(): void {\n if (target.value) acceptId(target.value.id)\n close()\n}\n/** Locked annotations cannot be removed: dismissing one does nothing and keeps the card. */\nfunction dismiss(): void {\n const t = target.value\n if (!t || t.locked) return\n focusReturn.beforeRemove(anchor.value, '[data-origin=\"suggested\"]')\n dismissId(t.id)\n close()\n}\nfunction onOpenChange(next: boolean): void {\n if (!next) close()\n}\n</script>\n\n<template>\n <PopoverRoot :open=\"open\" @update:open=\"onOpenChange\">\n <PopoverPortal>\n <PopoverContent\n v-if=\"target && anchor\"\n :reference=\"anchor\"\n class=\"ink-suggestion-card\"\n data-ink-suggestion-card\n side=\"bottom\"\n :side-offset=\"6\"\n :collision-padding=\"8\"\n v-bind=\"{ 'aria-label': 'Suggested redaction' }\"\n @interact-outside=\"keepOpenOnAnnotation\"\n @close-auto-focus=\"focusReturn.onCloseAutoFocus($event, anchor)\"\n >\n <slot\n :annotation=\"target\"\n :suggestion=\"target.suggestion\"\n :bucket=\"bucket\"\n :accept=\"accept\"\n :dismiss=\"dismiss\"\n :close=\"close\"\n >\n <p class=\"ink-suggestion-reason\">\n <strong>{{ target.suggestion?.reason ?? 'Suggested redaction' }}</strong>\n <span\n v-if=\"bucket\"\n class=\"ink-suggestion-confidence\"\n :data-confidence=\"bucket\"\n >\n {{ bucket }} confidence\n </span>\n </p>\n <p v-if=\"target.suggestion?.explanation\" class=\"ink-suggestion-explanation\">\n {{ target.suggestion.explanation }}\n </p>\n <div class=\"ink-suggestion-actions\">\n <button type=\"button\" @click=\"accept\">Accept</button>\n <button v-if=\"!target.locked\" type=\"button\" @click=\"dismiss\">Dismiss</button>\n </div>\n </slot>\n </PopoverContent>\n </PopoverPortal>\n </PopoverRoot>\n</template>\n"],"mappings":""}
@@ -1,16 +0,0 @@
1
- import { SuggestionCardSlotProps } from '@inkbar/core/dom';
2
- export type { ConfidenceBucket } from '@inkbar/core';
3
- export type { SuggestionCardSlotProps } from '@inkbar/core/dom';
4
- type __VLS_Slots = {
5
- default?(props: SuggestionCardSlotProps): unknown;
6
- };
7
- 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>;
8
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
9
- declare const _default: typeof __VLS_export;
10
- export default _default;
11
- type __VLS_WithSlots<T, S> = T & {
12
- new (): {
13
- $slots: S;
14
- };
15
- };
16
- //# sourceMappingURL=InkSuggestionCard.vue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InkSuggestionCard.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkSuggestionCard.vue"],"names":[],"mappings":"AAiJA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAE/D,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAEpD,YAAY,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAG/D,KAAK,WAAW,GAAG;IAAE,OAAO,CAAC,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAA;CAAE,CAAC;AAwMzE,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"}
@@ -1,85 +0,0 @@
1
- import { injectInkContext as e } from "../context.js";
2
- import { useAnnotations as t } from "../composables/useAnnotations.js";
3
- import { useAnnotationElement as n } from "./annotation-element.js";
4
- import { keepOpenOnAnnotation as r, useFocusReturn as i } from "./popover-focus.js";
5
- import { computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createVNode as u, defineComponent as d, mergeProps as f, openBlock as p, renderSlot as m, toDisplayString as h, unref as g, withCtx as _ } from "vue";
6
- import { confidenceBucket as v } from "@inkbar/core";
7
- import { PopoverContent as y, PopoverPortal as b, PopoverRoot as x } from "reka-ui";
8
- //#region src/components/InkSuggestionCard.vue?vue&type=script&setup=true&lang.ts
9
- var S = { class: "ink-suggestion-reason" }, C = ["data-confidence"], w = {
10
- key: 0,
11
- class: "ink-suggestion-explanation"
12
- }, T = { class: "ink-suggestion-actions" }, E = /*@__PURE__*/ d({
13
- __name: "InkSuggestionCard",
14
- setup(d) {
15
- let E = e(), { annotations: D, selection: O, accept: k, dismiss: A, select: j } = t();
16
- function M(e) {
17
- let t = e ? D.value.find((t) => t.id === e) : void 0;
18
- return t?.type === "redact" && t.origin === "suggested" ? t : null;
19
- }
20
- let N = a(() => M(E.activated.value) ?? (O.value.length === 1 ? M(O.value[0]) : null)), P = n(E, a(() => N.value?.id ?? null)), F = i(E), I = a(() => N.value !== null && P.value !== null), L = a(() => N.value?.suggestion ? v(N.value.suggestion.confidence) : void 0);
21
- function R() {
22
- E.setActivated(null), j([]);
23
- }
24
- function z() {
25
- N.value && k(N.value.id), R();
26
- }
27
- function B() {
28
- let e = N.value;
29
- e && !e.locked && (F.beforeRemove(P.value, "[data-origin=\"suggested\"]"), A(e.id), R());
30
- }
31
- function V(e) {
32
- e || R();
33
- }
34
- return (e, t) => (p(), o(g(x), {
35
- open: I.value,
36
- "onUpdate:open": V
37
- }, {
38
- default: _(() => [u(g(b), null, {
39
- default: _(() => [N.value && g(P) ? (p(), o(g(y), f({
40
- key: 0,
41
- reference: g(P),
42
- class: "ink-suggestion-card",
43
- "data-ink-suggestion-card": "",
44
- side: "bottom",
45
- "side-offset": 6,
46
- "collision-padding": 8
47
- }, { "aria-label": "Suggested redaction" }, {
48
- onInteractOutside: g(r),
49
- onCloseAutoFocus: t[0] ||= (e) => g(F).onCloseAutoFocus(e, g(P))
50
- }), {
51
- default: _(() => [m(e.$slots, "default", {
52
- annotation: N.value,
53
- suggestion: N.value.suggestion,
54
- bucket: L.value,
55
- accept: z,
56
- dismiss: B,
57
- close: R
58
- }, () => [
59
- l("p", S, [l("strong", null, h(N.value.suggestion?.reason ?? "Suggested redaction"), 1), L.value ? (p(), c("span", {
60
- key: 0,
61
- class: "ink-suggestion-confidence",
62
- "data-confidence": L.value
63
- }, h(L.value) + " confidence ", 9, C)) : s("", !0)]),
64
- N.value.suggestion?.explanation ? (p(), c("p", w, h(N.value.suggestion.explanation), 1)) : s("", !0),
65
- l("div", T, [l("button", {
66
- type: "button",
67
- onClick: z
68
- }, "Accept"), N.value.locked ? s("", !0) : (p(), c("button", {
69
- key: 0,
70
- type: "button",
71
- onClick: B
72
- }, "Dismiss"))])
73
- ])]),
74
- _: 3
75
- }, 16, ["reference", "onInteractOutside"])) : s("", !0)]),
76
- _: 3
77
- })]),
78
- _: 3
79
- }, 8, ["open"]));
80
- }
81
- });
82
- //#endregion
83
- export { E as default };
84
-
85
- //# sourceMappingURL=InkSuggestionCard.vue_vue_type_script_setup_true_lang.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InkSuggestionCard.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_withCtx","_createVNode","_mergeProps","_renderSlot","_createElementVNode","_toDisplayString","_createElementBlock","_createCommentVNode","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","InkSuggestionCard_vue_vue_type_script_setup_true_lang_default","ctx","injectInkContext","acceptId","dismissId","useAnnotations","suggestion","a","id","annotations","x","target","computed","selection","anchor","useAnnotationElement","focusReturn","useFocusReturn","open","bucket","confidenceBucket","close","select","accept","dismiss","t","onOpenChange","next","openBlock","createBlock","unref","PopoverRoot","withCtx","createVNode","PopoverPortal","PopoverContent","mergeProps","keepOpenOnAnnotation","_cache","$event","renderSlot","_ctx","createElementVNode","toDisplayString","createElementBlock","createCommentVNode"],"sources":["../../src/components/InkSuggestionCard.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * Review card for a suggested redaction: opens when the activated annotation, or the only\n * selected one, is a redaction with `origin: 'suggested'`. Locked suggestions cannot be\n * dismissed, so they get no Dismiss button. A press on the overlay selects and\n * activates, so a click opens it whatever the tool. Closing clears `activated` and the\n * selection.\n */\nimport { confidenceBucket } from '@inkbar/core'\nimport { PopoverContent, PopoverPortal, PopoverRoot } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport { useAnnotations } from '../composables/useAnnotations'\nimport { injectInkContext } from '../context'\n\nimport { useAnnotationElement } from './annotation-element'\nimport { keepOpenOnAnnotation, useFocusReturn } from './popover-focus'\n\nimport type { ConfidenceBucket, RedactAnnotation } from '@inkbar/core'\nimport type { SuggestionCardSlotProps } from '@inkbar/core/dom'\n\nexport type { ConfidenceBucket } from '@inkbar/core'\n\nexport type { SuggestionCardSlotProps } from '@inkbar/core/dom'\n\ndefineSlots<{ default?(props: SuggestionCardSlotProps): unknown }>()\n\nconst ctx = injectInkContext()\nconst {\n annotations,\n selection,\n accept: acceptId,\n dismiss: dismissId,\n select,\n} = useAnnotations()\n\nfunction suggestion(id: string | null | undefined): RedactAnnotation | null {\n const a = id ? annotations.value.find((x) => x.id === id) : undefined\n return a?.type === 'redact' && a.origin === 'suggested' ? a : null\n}\n// The activated annotation when it is a suggestion; otherwise the only selected one (a\n// marquee selects without activating).\nconst target = computed<RedactAnnotation | null>(\n () =>\n suggestion(ctx.activated.value) ??\n (selection.value.length === 1 ? suggestion(selection.value[0]) : null)\n)\nconst anchor = useAnnotationElement(\n ctx,\n computed(() => target.value?.id ?? null)\n)\nconst focusReturn = useFocusReturn(ctx)\nconst open = computed(() => target.value !== null && anchor.value !== null)\nconst bucket = computed<ConfidenceBucket | undefined>(() =>\n target.value?.suggestion\n ? confidenceBucket(target.value.suggestion.confidence)\n : undefined\n)\n\nfunction close(): void {\n ctx.setActivated(null)\n select([])\n}\nfunction accept(): void {\n if (target.value) acceptId(target.value.id)\n close()\n}\n/** Locked annotations cannot be removed: dismissing one does nothing and keeps the card. */\nfunction dismiss(): void {\n const t = target.value\n if (!t || t.locked) return\n focusReturn.beforeRemove(anchor.value, '[data-origin=\"suggested\"]')\n dismissId(t.id)\n close()\n}\nfunction onOpenChange(next: boolean): void {\n if (!next) close()\n}\n</script>\n\n<template>\n <PopoverRoot :open=\"open\" @update:open=\"onOpenChange\">\n <PopoverPortal>\n <PopoverContent\n v-if=\"target && anchor\"\n :reference=\"anchor\"\n class=\"ink-suggestion-card\"\n data-ink-suggestion-card\n side=\"bottom\"\n :side-offset=\"6\"\n :collision-padding=\"8\"\n v-bind=\"{ 'aria-label': 'Suggested redaction' }\"\n @interact-outside=\"keepOpenOnAnnotation\"\n @close-auto-focus=\"focusReturn.onCloseAutoFocus($event, anchor)\"\n >\n <slot\n :annotation=\"target\"\n :suggestion=\"target.suggestion\"\n :bucket=\"bucket\"\n :accept=\"accept\"\n :dismiss=\"dismiss\"\n :close=\"close\"\n >\n <p class=\"ink-suggestion-reason\">\n <strong>{{ target.suggestion?.reason ?? 'Suggested redaction' }}</strong>\n <span\n v-if=\"bucket\"\n class=\"ink-suggestion-confidence\"\n :data-confidence=\"bucket\"\n >\n {{ bucket }} confidence\n </span>\n </p>\n <p v-if=\"target.suggestion?.explanation\" class=\"ink-suggestion-explanation\">\n {{ target.suggestion.explanation }}\n </p>\n <div class=\"ink-suggestion-actions\">\n <button type=\"button\" @click=\"accept\">Accept</button>\n <button v-if=\"!target.locked\" type=\"button\" @click=\"dismiss\">Dismiss</button>\n </div>\n </slot>\n </PopoverContent>\n </PopoverPortal>\n </PopoverRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;;EA2BA,IAAMgB,IAAMC,EAAiB,GACvB,EACJ,gBACA,cACA,QAAQC,GACR,SAASC,GACT,cACEC,EAAe;EAEnB,SAASC,EAAW,GAAwD;GAC1E,IAAMC,IAAIC,IAAKC,EAAY,MAAM,MAAM,MAAMC,EAAE,OAAOF,CAAE,IAAI,KAAA;GAC5D,OAAOD,GAAG,SAAS,YAAYA,EAAE,WAAW,cAAcA,IAAI;EAChE;EAGA,IAAMI,IAASC,QAEXN,EAAWL,EAAI,UAAU,KAAK,MAC7BY,EAAU,MAAM,WAAW,IAAIP,EAAWO,EAAU,MAAM,EAAE,IAAI,KACrE,GACMC,IAASC,EACbd,GACAW,QAAeD,EAAO,OAAO,MAAM,IAAI,CACzC,GACMK,IAAcC,EAAehB,CAAG,GAChCiB,IAAON,QAAeD,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