kviewer 0.3.4 → 0.3.6

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 (28) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/annotation/engine/painter.d.ts +2 -2
  3. package/dist/runtime/annotation/engine/tools/form-field.d.ts +5 -5
  4. package/dist/runtime/annotation/engine/tools/form-field.js +1 -1
  5. package/dist/runtime/annotation/engine/types.d.ts +18 -9
  6. package/dist/runtime/assets/kviewer.css +1 -1
  7. package/dist/runtime/components/Viewer.d.vue.ts +21 -17
  8. package/dist/runtime/components/Viewer.vue +62 -40
  9. package/dist/runtime/components/Viewer.vue.d.ts +21 -17
  10. package/dist/runtime/components/ViewerTabs.d.vue.ts +12 -17
  11. package/dist/runtime/components/ViewerTabs.vue +3 -6
  12. package/dist/runtime/components/ViewerTabs.vue.d.ts +12 -17
  13. package/dist/runtime/components/form-fields/FormFieldWrapper.vue +21 -9
  14. package/dist/runtime/components/form-fields/FormSignatureField.vue +10 -2
  15. package/dist/runtime/components/form-fields/PlacedFieldChrome.d.vue.ts +4 -0
  16. package/dist/runtime/components/form-fields/PlacedFieldChrome.vue +27 -10
  17. package/dist/runtime/components/form-fields/PlacedFieldChrome.vue.d.ts +4 -0
  18. package/dist/runtime/composables/useFormFields.d.ts +28 -17
  19. package/dist/runtime/composables/useFormFields.js +20 -24
  20. package/dist/runtime/composables/useInertiaPanzoom.d.ts +8 -2
  21. package/dist/runtime/composables/useInertiaPanzoom.js +36 -12
  22. package/dist/runtime/embed/bridge-client.d.ts +4 -2
  23. package/dist/runtime/embed/bridge-client.js +2 -1
  24. package/dist/runtime/embed/bridge-host.d.ts +4 -1
  25. package/dist/runtime/embed/bridge-host.js +24 -0
  26. package/dist/runtime/embed/protocol.d.ts +19 -0
  27. package/dist/runtime/public-types.d.ts +1 -1
  28. package/package.json +1 -1
@@ -21,7 +21,8 @@ type EventHandler<E extends EventName> = (payload: EventPayloads[E]) => void;
21
21
  * an iframe. Wraps `postMessage` into a Promise-based RPC mirroring the
22
22
  * viewer's exposed methods, and surfaces iframe-emitted events
23
23
  * (`ready`, `formEditMode-changed`, `viewedPages-changed`, `all-pages-read`,
24
- * `field-placed`, `signedStatus-changed`) via `on()`.
24
+ * `field-placed`, `field-updated`, `field-removed`, `signedStatus-changed`)
25
+ * and `scroll-boundary`) via `on()`.
25
26
  */
26
27
  export declare class KViewerEmbedClient {
27
28
  private readonly iframe;
@@ -68,7 +69,8 @@ export declare class KViewerEmbedClient {
68
69
  * a push-style signal subscribe via `on('signedStatus-changed', …)`. */
69
70
  getSignedStatus(): Promise<boolean>;
70
71
  /** Per-widget signed-state snapshot (id, fieldName, pageNumber,
71
- * signed, roleId). */
72
+ * signed). Correlate to host data by `id` (see the `meta` bag on
73
+ * `getFormFields()` for grouping, e.g. by signer). */
72
74
  getSignatureFieldStatus(): Promise<SignatureFieldStatus[]>;
73
75
  getFormEditMode(): Promise<boolean>;
74
76
  setFormEditMode(enabled: boolean): Promise<void>;
@@ -104,7 +104,8 @@ export class KViewerEmbedClient {
104
104
  return this.call("getSignedStatus");
105
105
  }
106
106
  /** Per-widget signed-state snapshot (id, fieldName, pageNumber,
107
- * signed, roleId). */
107
+ * signed). Correlate to host data by `id` (see the `meta` bag on
108
+ * `getFormFields()` for grouping, e.g. by signer). */
108
109
  getSignatureFieldStatus() {
109
110
  return this.call("getSignatureFieldStatus");
110
111
  }
@@ -1,7 +1,7 @@
1
1
  import { type Ref } from 'vue';
2
2
  import type { ExportPdfOptions } from '../annotation/pdf-export/export.js';
3
3
  import type { AddFormFieldPayload, FormFieldDefinition, FormFieldValue, IAnnotationStore, PlacedFieldDefaults, SignatureFieldStatus } from '../annotation/engine/types.js';
4
- import { type MethodName } from './protocol.js';
4
+ import { type MethodName, type ScrollBoundaryPayload } from './protocol.js';
5
5
  /**
6
6
  * Surface the bridge calls on the KViewer template ref. Mirrors the
7
7
  * methods defined in `defineExpose` inside Viewer.vue. Kept as a
@@ -27,12 +27,15 @@ export interface KViewerApi {
27
27
  setFieldDefaults: (defaults: PlacedFieldDefaults) => void;
28
28
  setClickToSign: (enabled: boolean) => void;
29
29
  onFieldPlaced: (cb: (field: FormFieldDefinition) => void) => () => void;
30
+ onFieldUpdated: (cb: (field: FormFieldDefinition, patch: Partial<FormFieldDefinition>) => void) => () => void;
31
+ onFieldRemoved: (cb: (field: FormFieldDefinition) => void) => () => void;
30
32
  getSignedStatus: () => boolean;
31
33
  getSignatureFieldStatus: () => SignatureFieldStatus[];
32
34
  onSignedStatusChanged: (cb: (payload: {
33
35
  allSigned: boolean;
34
36
  fields: SignatureFieldStatus[];
35
37
  }) => void) => () => void;
38
+ onScrollBoundary: (cb: (payload: ScrollBoundaryPayload) => void) => () => void;
36
39
  formEditMode: boolean | Ref<boolean>;
37
40
  setFormEditMode: (enabled: boolean) => void;
38
41
  toggleFormEditMode: () => boolean;
@@ -202,6 +202,22 @@ export function useKViewerEmbedBridge(viewerRef, options) {
202
202
  )
203
203
  );
204
204
  }
205
+ if (typeof viewer.onFieldUpdated === "function") {
206
+ events.push("field-updated");
207
+ stopViewerStateWatches.push(
208
+ viewer.onFieldUpdated(
209
+ (field, patch) => postEvent("field-updated", { field, patch })
210
+ )
211
+ );
212
+ }
213
+ if (typeof viewer.onFieldRemoved === "function") {
214
+ events.push("field-removed");
215
+ stopViewerStateWatches.push(
216
+ viewer.onFieldRemoved(
217
+ (field) => postEvent("field-removed", { field })
218
+ )
219
+ );
220
+ }
205
221
  if (typeof viewer.onSignedStatusChanged === "function") {
206
222
  events.push("signedStatus-changed");
207
223
  stopViewerStateWatches.push(
@@ -210,6 +226,14 @@ export function useKViewerEmbedBridge(viewerRef, options) {
210
226
  )
211
227
  );
212
228
  }
229
+ if (typeof viewer.onScrollBoundary === "function") {
230
+ events.push("scroll-boundary");
231
+ stopViewerStateWatches.push(
232
+ viewer.onScrollBoundary(
233
+ (payload) => postEvent("scroll-boundary", payload)
234
+ )
235
+ );
236
+ }
213
237
  if (typeof viewer.allPagesRead === "function") {
214
238
  events.push("all-pages-read");
215
239
  stopViewerStateWatches.push(
@@ -11,6 +11,10 @@ export declare const EVENT_KIND: "kviewer:event";
11
11
  */
12
12
  export declare const UNSUPPORTED_METHOD_ERROR_NAME = "KViewerUnsupportedMethodError";
13
13
  export type ImportAnnotationsMode = 'replace' | 'merge';
14
+ export interface ScrollBoundaryPayload {
15
+ edge: 'start' | 'end';
16
+ deltaY: number;
17
+ }
14
18
  export interface MethodSignatures {
15
19
  getAnnotations: {
16
20
  args: [];
@@ -145,11 +149,26 @@ export interface EventPayloads {
145
149
  /** Fires once when the final unseen page is viewed. Re-arms after
146
150
  * `resetViewedPages()` or a new document. */
147
151
  'all-pages-read': Record<string, never>;
152
+ /** Vertical wheel movement that the embedded viewer could not consume
153
+ * because it reached the start or end of the document. */
154
+ 'scroll-boundary': ScrollBoundaryPayload;
148
155
  /** The user placed a form field via a placement tool. Patch it with
149
156
  * `updateFormField()` to set host-driven properties. */
150
157
  'field-placed': {
151
158
  field: FormFieldDefinition;
152
159
  };
160
+ /** The user changed a field through the viewer UI (moved/resized it or
161
+ * edited its properties). Not fired for `updateFormField()` calls.
162
+ * Continuous edits may fire repeatedly — treat as an upsert. */
163
+ 'field-updated': {
164
+ field: FormFieldDefinition;
165
+ patch: Partial<FormFieldDefinition>;
166
+ };
167
+ /** The user removed a field through the viewer UI. Not fired for
168
+ * `removeFormField()` calls. `field` is the last-known definition. */
169
+ 'field-removed': {
170
+ field: FormFieldDefinition;
171
+ };
153
172
  /** A signature field's signed state changed (signed, cleared, added,
154
173
  * removed, or renamed). Push-style counterpart to `getSignedStatus()`. */
155
174
  'signedStatus-changed': {
@@ -7,7 +7,7 @@ export type { KViewerApi, KViewerHostApi, KViewerEmbedBridgeOptions, } from './e
7
7
  export { useKViewerEmbedBridge } from './embed/bridge-host.js';
8
8
  export type { KViewerEmbedClientOptions } from './embed/bridge-client.js';
9
9
  export { KViewerEmbedClient } from './embed/bridge-client.js';
10
- export type { EventName as KViewerEmbedEventName, EventPayloads as KViewerEmbedEventPayloads, MethodName as KViewerEmbedMethodName, } from './embed/protocol.js';
10
+ export type { EventName as KViewerEmbedEventName, EventPayloads as KViewerEmbedEventPayloads, MethodName as KViewerEmbedMethodName, ScrollBoundaryPayload, } from './embed/protocol.js';
11
11
  export { KVIEWER_EMBED_PROTOCOL_VERSION, UNSUPPORTED_METHOD_ERROR_NAME as KVIEWER_EMBED_UNSUPPORTED_METHOD_ERROR_NAME, } from './embed/protocol.js';
12
12
  export type { ViewerMenuItem, ViewerMenuButtonItem, ViewerMenuCheckboxItem, ViewerMenuSeparatorItem, } from './menu-items.js';
13
13
  export type { ViewerSelectionItem, ViewerSelectionButtonItem, ViewerSelectionSelectItem, ViewerSelectionContext, } from './selection-items.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kviewer",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "Kabema PDF Editor",
5
5
  "repository": "kabema/kviewer",
6
6
  "license": "MIT",