kviewer 0.3.3 → 0.3.5

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 (47) hide show
  1. package/dist/module.d.mts +1 -1
  2. package/dist/module.json +1 -1
  3. package/dist/runtime/annotation/engine/editor/selector.d.ts +1 -0
  4. package/dist/runtime/annotation/engine/editor/selector.js +17 -5
  5. package/dist/runtime/annotation/engine/painter.d.ts +4 -2
  6. package/dist/runtime/annotation/engine/painter.js +4 -0
  7. package/dist/runtime/annotation/engine/tools/form-field.d.ts +5 -5
  8. package/dist/runtime/annotation/engine/tools/form-field.js +1 -1
  9. package/dist/runtime/annotation/engine/types.d.ts +18 -9
  10. package/dist/runtime/annotation/pdf-export/export-form-fields.js +6 -29
  11. package/dist/runtime/assets/kviewer.css +1 -1
  12. package/dist/runtime/components/AnnotationToolbar.vue +12 -1
  13. package/dist/runtime/components/FormFieldLayer.vue +7 -2
  14. package/dist/runtime/components/PdfPage.vue +24 -1
  15. package/dist/runtime/components/SelectionToolbarItems.d.vue.ts +8 -0
  16. package/dist/runtime/components/SelectionToolbarItems.vue +43 -0
  17. package/dist/runtime/components/SelectionToolbarItems.vue.d.ts +8 -0
  18. package/dist/runtime/components/Viewer.d.vue.ts +24 -17
  19. package/dist/runtime/components/Viewer.vue +60 -37
  20. package/dist/runtime/components/Viewer.vue.d.ts +24 -17
  21. package/dist/runtime/components/ViewerBar.d.vue.ts +4 -4
  22. package/dist/runtime/components/ViewerBar.vue +2 -1
  23. package/dist/runtime/components/ViewerBar.vue.d.ts +4 -4
  24. package/dist/runtime/components/ViewerTabs.d.vue.ts +16 -17
  25. package/dist/runtime/components/ViewerTabs.vue +5 -6
  26. package/dist/runtime/components/ViewerTabs.vue.d.ts +16 -17
  27. package/dist/runtime/components/form-fields/FormFieldWrapper.vue +35 -10
  28. package/dist/runtime/components/form-fields/FormSignatureField.vue +10 -2
  29. package/dist/runtime/components/form-fields/PlacedFieldChrome.d.vue.ts +4 -0
  30. package/dist/runtime/components/form-fields/PlacedFieldChrome.vue +35 -18
  31. package/dist/runtime/components/form-fields/PlacedFieldChrome.vue.d.ts +4 -0
  32. package/dist/runtime/components/form-fields/PlacedFieldToolbar.d.vue.ts +7 -0
  33. package/dist/runtime/components/form-fields/PlacedFieldToolbar.vue +51 -0
  34. package/dist/runtime/components/form-fields/PlacedFieldToolbar.vue.d.ts +7 -0
  35. package/dist/runtime/composables/useFormFields.d.ts +28 -17
  36. package/dist/runtime/composables/useFormFields.js +20 -24
  37. package/dist/runtime/embed/bridge-client.d.ts +4 -2
  38. package/dist/runtime/embed/bridge-client.js +2 -1
  39. package/dist/runtime/embed/bridge-host.d.ts +2 -0
  40. package/dist/runtime/embed/bridge-host.js +16 -0
  41. package/dist/runtime/embed/protocol.d.ts +12 -0
  42. package/dist/runtime/public-types.d.ts +2 -1
  43. package/dist/runtime/selection-items.d.ts +61 -0
  44. package/dist/runtime/selection-items.js +1 -0
  45. package/dist/runtime/toolbar-tools.d.ts +4 -1
  46. package/dist/types.d.mts +1 -1
  47. package/package.json +1 -1
@@ -0,0 +1,61 @@
1
+ import type { InjectionKey, Ref } from 'vue';
2
+ import type { FormFieldDefinition, IAnnotationStore } from './annotation/engine/types.js';
3
+ /** What the floating selection popover is currently attached to. Passed to
4
+ * every custom-item callback so a single item list can serve both the
5
+ * Konva annotation selection and the HTML placed-field selection. */
6
+ export interface ViewerSelectionContext {
7
+ /** `'annotation'` = Konva-drawn annotation(s); `'field'` = a user-placed
8
+ * HTML form field (e.g. a signature field). */
9
+ kind: 'annotation' | 'field';
10
+ /** The selected annotation(s): one entry for a single selection, several
11
+ * for a marquee multi-select, empty when `kind` is `'field'`. */
12
+ annotations: IAnnotationStore[];
13
+ /** The selected placed form field. Null when `kind` is `'annotation'`. */
14
+ field: FormFieldDefinition | null;
15
+ }
16
+ /** A custom control appended to the floating selection popover shown when
17
+ * an annotation or a placed form field is selected. Pass an array of
18
+ * these to `<KViewer :selection-items="...">` (or `<KViewerTabs>`).
19
+ *
20
+ * Mirrors the `menuItems` discriminated-union pattern; scoped to the
21
+ * controls a compact floating toolbar can carry. */
22
+ export type ViewerSelectionItem = ViewerSelectionButtonItem | ViewerSelectionSelectItem;
23
+ export interface ViewerSelectionButtonItem {
24
+ type: 'button';
25
+ /** Stable key for Vue list rendering. Keep unique within the array. */
26
+ key: string;
27
+ /** Tooltip / accessible label. Rendered as text when no icon is set. */
28
+ label: string;
29
+ /** Lucide-style icon name. When set, the button is icon-only. */
30
+ icon?: string;
31
+ /** Fired on click with the current selection. */
32
+ onSelect: (ctx: ViewerSelectionContext) => void;
33
+ /** Disables the item without removing it. */
34
+ disabled?: boolean;
35
+ /** Show the item only for selections this predicate accepts. Omit to
36
+ * show it for both annotation and field selections. */
37
+ visible?: (ctx: ViewerSelectionContext) => boolean;
38
+ }
39
+ export interface ViewerSelectionSelectItem {
40
+ type: 'select';
41
+ key: string;
42
+ /** Accessible label / tooltip for the select. */
43
+ label?: string;
44
+ /** Options shown in the dropdown. */
45
+ items: {
46
+ label: string;
47
+ value: string;
48
+ }[];
49
+ /** Current value — a plain (reactive) string, or a getter deriving it
50
+ * from the current selection. */
51
+ value?: string | ((ctx: ViewerSelectionContext) => string | undefined);
52
+ placeholder?: string;
53
+ /** Fired with the chosen option value and the current selection. */
54
+ onUpdate: (value: string, ctx: ViewerSelectionContext) => void;
55
+ disabled?: boolean;
56
+ visible?: (ctx: ViewerSelectionContext) => boolean;
57
+ }
58
+ /** Provided by KViewer so both selection popovers (the Konva annotation
59
+ * toolbar and the placed-field toolbar, which lives deep inside the page
60
+ * DOM layer) can read the host's items without prop-drilling. */
61
+ export declare const SELECTION_ITEMS_KEY: InjectionKey<Ref<ViewerSelectionItem[] | undefined>>;
@@ -0,0 +1 @@
1
+ export const SELECTION_ITEMS_KEY = Symbol("kviewer-selection-items");
@@ -1,7 +1,10 @@
1
1
  import type { InjectionKey, Ref } from 'vue';
2
2
  import { AnnotationType } from './annotation/engine/types.js';
3
3
  /** Built-in tools that live in the top navigation row. Each maps to a
4
- * whole self-contained sub-component. `hand` / `marquee` are readonly-gated. */
4
+ * whole self-contained sub-component. `hand` / `marquee` are readonly-gated.
5
+ * `marquee` has no button in the default toolbar — hand mode rubber-band
6
+ * selects on empty-space mouse drags; the dedicated mode remains for hosts
7
+ * that want touch-capable multi-select via the `tools` prop. */
5
8
  export type ViewerTopToolId = 'menu' | 'pageSettings' | 'zoom' | 'hand' | 'marquee' | 'pageInfo' | 'search';
6
9
  /** Built-in tools that live in the second (annotation) row, controlled
7
10
  * per individual button. IDs match the annotation `name` in
package/dist/types.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { type ActiveTool, type AddFormFieldPayload, type CheckboxStyle, type ExportPdfOptions, type FormFieldDefinition, type FormFieldOrigin, type FormFieldType, type FormFieldValue, type KVIEWER_EMBED_PROTOCOL_VERSION, type KVIEWER_EMBED_UNSUPPORTED_METHOD_ERROR_NAME, type KViewerApi, type KViewerEmbedBridgeOptions, type KViewerEmbedClient, type KViewerEmbedClientOptions, type KViewerEmbedEventName, type KViewerEmbedEventPayloads, type KViewerEmbedMethodName, type KViewerHostApi, type PlacedFieldDefaults, type SignatureData, type SignatureFieldStatus, type SignatureHandlers, type ViewMode, type ViewerBottomToolId, type ViewerLayoutToolId, type ViewerMenuButtonItem, type ViewerMenuCheckboxItem, type ViewerMenuItem, type ViewerMenuSeparatorItem, type ViewerState, type ViewerToolEntry, type ViewerToolId, type ViewerToolSlot, type ViewerTopToolId, type useKViewerEmbedBridge } from '../dist/runtime/public-types.js'
1
+ export { type ActiveTool, type AddFormFieldPayload, type CheckboxStyle, type ExportPdfOptions, type FormFieldDefinition, type FormFieldOrigin, type FormFieldType, type FormFieldValue, type IAnnotationStore, type KVIEWER_EMBED_PROTOCOL_VERSION, type KVIEWER_EMBED_UNSUPPORTED_METHOD_ERROR_NAME, type KViewerApi, type KViewerEmbedBridgeOptions, type KViewerEmbedClient, type KViewerEmbedClientOptions, type KViewerEmbedEventName, type KViewerEmbedEventPayloads, type KViewerEmbedMethodName, type KViewerHostApi, type PlacedFieldDefaults, type SignatureData, type SignatureFieldStatus, type SignatureHandlers, type ViewMode, type ViewerBottomToolId, type ViewerLayoutToolId, type ViewerMenuButtonItem, type ViewerMenuCheckboxItem, type ViewerMenuItem, type ViewerMenuSeparatorItem, type ViewerSelectionButtonItem, type ViewerSelectionContext, type ViewerSelectionItem, type ViewerSelectionSelectItem, type ViewerState, type ViewerToolEntry, type ViewerToolId, type ViewerToolSlot, type ViewerTopToolId, type useKViewerEmbedBridge } from '../dist/runtime/public-types.js'
2
2
 
3
3
  export { default } from './module.mjs'
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kviewer",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Kabema PDF Editor",
5
5
  "repository": "kabema/kviewer",
6
6
  "license": "MIT",