@inkbar/svelte 0.3.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 (66) hide show
  1. package/README.md +17 -12
  2. package/dist/components/InkAnnotation.svelte +0 -12
  3. package/dist/components/InkAnnotation.svelte.d.ts.map +1 -1
  4. package/dist/components/InkColorMenu.svelte +247 -0
  5. package/dist/components/InkColorMenu.svelte.d.ts +35 -0
  6. package/dist/components/InkColorMenu.svelte.d.ts.map +1 -0
  7. package/dist/components/InkHighlightMenu.svelte +175 -0
  8. package/dist/components/InkHighlightMenu.svelte.d.ts +16 -0
  9. package/dist/components/InkHighlightMenu.svelte.d.ts.map +1 -0
  10. package/dist/components/InkLineStyleMenu.svelte +141 -0
  11. package/dist/components/InkLineStyleMenu.svelte.d.ts +15 -0
  12. package/dist/components/InkLineStyleMenu.svelte.d.ts.map +1 -0
  13. package/dist/components/InkRoot.svelte +90 -3
  14. package/dist/components/InkRoot.svelte.d.ts +27 -2
  15. package/dist/components/InkRoot.svelte.d.ts.map +1 -1
  16. package/dist/components/InkShapeMenu.svelte +161 -0
  17. package/dist/components/InkShapeMenu.svelte.d.ts +15 -0
  18. package/dist/components/InkShapeMenu.svelte.d.ts.map +1 -0
  19. package/dist/components/InkSignatureDialog.svelte +70 -0
  20. package/dist/components/InkSignatureDialog.svelte.d.ts +22 -0
  21. package/dist/components/InkSignatureDialog.svelte.d.ts.map +1 -0
  22. package/dist/components/InkSignatureMenu.svelte +267 -0
  23. package/dist/components/InkSignatureMenu.svelte.d.ts +18 -0
  24. package/dist/components/InkSignatureMenu.svelte.d.ts.map +1 -0
  25. package/dist/components/InkTextStyleMenu.svelte +225 -0
  26. package/dist/components/InkTextStyleMenu.svelte.d.ts +15 -0
  27. package/dist/components/InkTextStyleMenu.svelte.d.ts.map +1 -0
  28. package/dist/components/{InkNotePopover.svelte → InkThreadPopover.svelte} +44 -32
  29. package/dist/components/InkThreadPopover.svelte.d.ts +9 -0
  30. package/dist/components/InkThreadPopover.svelte.d.ts.map +1 -0
  31. package/dist/components/InkToolButton.svelte +23 -7
  32. package/dist/components/InkToolButton.svelte.d.ts.map +1 -1
  33. package/dist/components/InkViewport.svelte +26 -2
  34. package/dist/components/InkViewport.svelte.d.ts.map +1 -1
  35. package/dist/components/SignatureForm.svelte +219 -0
  36. package/dist/components/SignatureForm.svelte.d.ts +10 -0
  37. package/dist/components/SignatureForm.svelte.d.ts.map +1 -0
  38. package/dist/components/ThreadForm.svelte +4 -2
  39. package/dist/components/ThreadForm.svelte.d.ts +1 -0
  40. package/dist/components/ThreadForm.svelte.d.ts.map +1 -1
  41. package/dist/components/child-snippet.d.ts +8 -0
  42. package/dist/components/child-snippet.d.ts.map +1 -1
  43. package/dist/components/child-snippet.js +15 -0
  44. package/dist/components/popover-focus.d.ts +16 -2
  45. package/dist/components/popover-focus.d.ts.map +1 -1
  46. package/dist/components/popover-focus.js +24 -3
  47. package/dist/context.d.ts +21 -2
  48. package/dist/context.d.ts.map +1 -1
  49. package/dist/hooks/useAnnotations.svelte.d.ts +1333 -578
  50. package/dist/hooks/useAnnotations.svelte.d.ts.map +1 -1
  51. package/dist/hooks/useAnnotations.svelte.js +1 -7
  52. package/dist/hooks/useToolOptions.svelte.d.ts +11 -0
  53. package/dist/hooks/useToolOptions.svelte.d.ts.map +1 -0
  54. package/dist/hooks/useToolOptions.svelte.js +19 -0
  55. package/dist/hooks/useToolStyle.svelte.d.ts +33 -0
  56. package/dist/hooks/useToolStyle.svelte.d.ts.map +1 -0
  57. package/dist/hooks/useToolStyle.svelte.js +33 -0
  58. package/dist/index.d.ts +21 -6
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +10 -2
  61. package/package.json +5 -5
  62. package/dist/components/InkNotePopover.svelte.d.ts +0 -9
  63. package/dist/components/InkNotePopover.svelte.d.ts.map +0 -1
  64. package/dist/components/InkSuggestionCard.svelte +0 -121
  65. package/dist/components/InkSuggestionCard.svelte.d.ts +0 -9
  66. package/dist/components/InkSuggestionCard.svelte.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useAnnotations.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/hooks/useAnnotations.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE/D,wBAAgB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAkBX,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACrB,+CAA+C;kBACjC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBACf,MAAM,SAAS,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAC9B,MAAM;kBACL,MAAM,EAAE;EAEzB"}
@@ -1,4 +1,4 @@
1
- import { acceptSuggestion, repliesTo } from '@inkbar/core';
1
+ import { repliesTo } from '@inkbar/core';
2
2
  import { useInkContext } from '../context.js';
3
3
  export function useAnnotations() {
4
4
  const ctx = useInkContext('useAnnotations()');
@@ -23,11 +23,5 @@ export function useAnnotations() {
23
23
  update: (id, patch) => store()?.update(id, patch),
24
24
  remove: (id) => store()?.remove(id) ?? false,
25
25
  select: (ids) => store()?.select(ids),
26
- /** Keeps a suggested redaction as the user's own, in the default redaction colour. */
27
- accept: (id) => {
28
- const s = store();
29
- return s ? acceptSuggestion(s, id) : undefined;
30
- },
31
- dismiss: (id) => store()?.remove(id) ?? false,
32
26
  };
33
27
  }
@@ -0,0 +1,11 @@
1
+ import type { ToolId } from '@inkbar/core/dom';
2
+ /**
3
+ * A tool's options and a setter that merges a patch into them without switching tools.
4
+ * `id` may be a getter. Options are empty, and the setter does nothing, until the viewport
5
+ * has mounted.
6
+ */
7
+ export declare function useToolOptions<O extends object = object>(id: ToolId | (() => ToolId)): {
8
+ readonly options: O;
9
+ setOptions: (patch: Partial<O>) => void;
10
+ };
11
+ //# sourceMappingURL=useToolOptions.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToolOptions.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/hooks/useToolOptions.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAI9C;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EACtD,EAAE,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAC1B;IAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IAAC,UAAU,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;CAAE,CAUlE"}
@@ -0,0 +1,19 @@
1
+ import { useInkContext } from '../context.js';
2
+ import { useReadable } from '../use-readable.svelte.js';
3
+ const NO_OPTIONS = {};
4
+ /**
5
+ * A tool's options and a setter that merges a patch into them without switching tools.
6
+ * `id` may be a getter. Options are empty, and the setter does nothing, until the viewport
7
+ * has mounted.
8
+ */
9
+ export function useToolOptions(id) {
10
+ const ctx = useInkContext('useToolOptions()');
11
+ const toolId = () => (typeof id === 'function' ? id() : id);
12
+ const options = useReadable(() => ctx.tools?.options(toolId()), NO_OPTIONS);
13
+ return {
14
+ get options() {
15
+ return options.current;
16
+ },
17
+ setOptions: (patch) => ctx.tools?.setOptions(toolId(), patch),
18
+ };
19
+ }
@@ -0,0 +1,33 @@
1
+ import type { CurrentStyle, StyleGroup, StyleKey, StyleProps } from '@inkbar/core';
2
+ interface ToolStyleView {
3
+ readonly current: CurrentStyle;
4
+ readonly supported: ReadonlySet<StyleKey>;
5
+ /** A group's own style. */
6
+ get: (group: StyleGroup) => Readonly<StyleProps>;
7
+ }
8
+ /** The tool style for the active tool or the selection. */
9
+ export interface ToolStyleHandle extends ToolStyleView {
10
+ set: (patch: StyleProps, opts?: {
11
+ group?: StyleGroup;
12
+ apply?: boolean;
13
+ }) => void;
14
+ }
15
+ /** The tool style scoped to one group: `set` writes that group, so it takes no options. */
16
+ export interface ScopedToolStyleHandle extends ToolStyleView {
17
+ set: (patch: StyleProps) => void;
18
+ }
19
+ /** A style group, or a getter for one that may change (a prop). */
20
+ export type StyleGroupSource = StyleGroup | undefined | (() => StyleGroup | undefined);
21
+ /**
22
+ * The tool style the style controls read and write: `current` shows the selection's values
23
+ * (`'mixed'` where they differ), else the active tool's group; `supported` names the props
24
+ * the active tool or the selection has. `set` updates the group and the selected annotations.
25
+ *
26
+ * With `group` (or a getter for it, so a prop can change it), the style as a control for that group sees it, whatever tool is active: the
27
+ * selection's when it is all in the group, else the group's own; `set` updates the group, and
28
+ * the selection only when it is all in the group.
29
+ */
30
+ export declare function useToolStyle(): ToolStyleHandle;
31
+ export declare function useToolStyle(group: StyleGroupSource): ScopedToolStyleHandle;
32
+ export {};
33
+ //# sourceMappingURL=useToolStyle.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToolStyle.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/hooks/useToolStyle.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAMlF,UAAU,aAAa;IACrB,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAA;IAC9B,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;IACzC,2BAA2B;IAC3B,GAAG,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,QAAQ,CAAC,UAAU,CAAC,CAAA;CACjD;AAED,2DAA2D;AAC3D,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,GAAG,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,UAAU,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAA;CACjF;AAED,2FAA2F;AAC3F,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC1D,GAAG,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;CACjC;AAED,mEAAmE;AACnE,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,SAAS,GAAG,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC,CAAA;AAEtF;;;;;;;;GAQG;AACH,wBAAgB,YAAY,IAAI,eAAe,CAAA;AAC/C,wBAAgB,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,qBAAqB,CAAA"}
@@ -0,0 +1,33 @@
1
+ import { useInkContext } from '../context.js';
2
+ import { useReadable } from '../use-readable.svelte.js';
3
+ const NO_STYLE = {};
4
+ const NO_PROPS = new Set();
5
+ const EMPTY = {};
6
+ export function useToolStyle(group) {
7
+ const ctx = useInkContext('useToolStyle()');
8
+ const scope = () => typeof group === 'function' ? group() : group;
9
+ const view = () => {
10
+ const style = ctx.toolStyle;
11
+ const g = scope();
12
+ return g && style ? style.scoped(g) : style;
13
+ };
14
+ const current = useReadable(() => view()?.current, NO_STYLE);
15
+ const supported = useReadable(() => view()?.supported, NO_PROPS);
16
+ return {
17
+ get current() {
18
+ return current.current;
19
+ },
20
+ get supported() {
21
+ return supported.current;
22
+ },
23
+ set: (patch, opts) => {
24
+ const style = ctx.toolStyle;
25
+ const g = scope();
26
+ if (g)
27
+ style?.scoped(g).set(patch);
28
+ else
29
+ style?.set(patch, opts);
30
+ },
31
+ get: (group) => ctx.toolStyle?.get(group) ?? EMPTY,
32
+ };
33
+ }
package/dist/index.d.ts CHANGED
@@ -3,11 +3,14 @@ export { useInkContext } from './context.js';
3
3
  export type { InkContext, InkHistory, InkStatus } from './context.js';
4
4
  export { useReadable } from './use-readable.svelte.js';
5
5
  export type { ReadableRef } from './use-readable.svelte.js';
6
- export type { AnnotationSlotProps, AnnotationState, NotePopoverSlotProps, SuggestionCardSlotProps, } from '@inkbar/core/dom';
7
- export type { ConfidenceBucket } from '@inkbar/core';
6
+ export type { AnnotationSlotProps, AnnotationState, ThreadPopoverSlotProps, } from '@inkbar/core/dom';
7
+ export type { AnnotationDecoration, DecorateAnnotation } from '@inkbar/core/dom';
8
8
  export { useDocument } from './hooks/useDocument.svelte.js';
9
9
  export { useAnnotations } from './hooks/useAnnotations.svelte.js';
10
10
  export { useTool } from './hooks/useTool.svelte.js';
11
+ export { useToolStyle } from './hooks/useToolStyle.svelte.js';
12
+ export type { ScopedToolStyleHandle, StyleGroupSource, ToolStyleHandle, } from './hooks/useToolStyle.svelte.js';
13
+ export { useToolOptions } from './hooks/useToolOptions.svelte.js';
11
14
  export { useSelection } from './hooks/useSelection.svelte.js';
12
15
  export { useZoom } from './hooks/useZoom.svelte.js';
13
16
  export { usePage } from './hooks/usePage.svelte.js';
@@ -36,6 +39,20 @@ export type { InkHistoryButtonProps } from './components/history-button.js';
36
39
  export { default as InkZoomIn } from './components/InkZoomIn.svelte';
37
40
  export { default as InkZoomOut } from './components/InkZoomOut.svelte';
38
41
  export type { InkZoomButtonProps } from './components/zoom-button.js';
42
+ export { default as InkColorMenu } from './components/InkColorMenu.svelte';
43
+ export type { InkColorMenuProps } from './components/InkColorMenu.svelte';
44
+ export { default as InkShapeMenu } from './components/InkShapeMenu.svelte';
45
+ export type { InkShapeMenuProps } from './components/InkShapeMenu.svelte';
46
+ export { default as InkSignatureMenu } from './components/InkSignatureMenu.svelte';
47
+ export type { InkSignatureMenuProps } from './components/InkSignatureMenu.svelte';
48
+ export { default as InkSignatureDialog } from './components/InkSignatureDialog.svelte';
49
+ export type { InkSignatureDialogProps } from './components/InkSignatureDialog.svelte';
50
+ export { default as InkHighlightMenu } from './components/InkHighlightMenu.svelte';
51
+ export type { InkHighlightMenuProps } from './components/InkHighlightMenu.svelte';
52
+ export { default as InkLineStyleMenu } from './components/InkLineStyleMenu.svelte';
53
+ export type { InkLineStyleMenuProps } from './components/InkLineStyleMenu.svelte';
54
+ export { default as InkTextStyleMenu } from './components/InkTextStyleMenu.svelte';
55
+ export type { InkTextStyleMenuProps } from './components/InkTextStyleMenu.svelte';
39
56
  export { default as InkZoomSelect } from './components/InkZoomSelect.svelte';
40
57
  export type { InkZoomSelectProps } from './components/InkZoomSelect.svelte';
41
58
  export { default as InkPageInput } from './components/InkPageInput.svelte';
@@ -46,8 +63,6 @@ export { default as InkPrevPage } from './components/InkPrevPage.svelte';
46
63
  export { default as InkNextPage } from './components/InkNextPage.svelte';
47
64
  export type { InkPageButtonProps } from './components/page-button.js';
48
65
  export type { ChildSnippet } from './components/child-snippet.js';
49
- export { default as InkNotePopover } from './components/InkNotePopover.svelte';
50
- export type { InkNotePopoverProps } from './components/InkNotePopover.svelte';
51
- export { default as InkSuggestionCard } from './components/InkSuggestionCard.svelte';
52
- export type { InkSuggestionCardProps } from './components/InkSuggestionCard.svelte';
66
+ export { default as InkThreadPopover } from './components/InkThreadPopover.svelte';
67
+ export type { InkThreadPopoverProps } from './components/InkThreadPopover.svelte';
53
68
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,gBAAgB,MAAM,6BAA6B,CAAA;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAC3D,YAAY,EACV,mBAAmB,EACnB,eAA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C,CAAA;AACzE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAC1E,YAAY,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iCAAiC,CAAA;AACxE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iCAAiC,CAAA;AACxE,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AACrE,YAAY,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,sCAAsC,CAAA;AAClF,YAAY,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA"}
package/dist/index.js CHANGED
@@ -3,6 +3,8 @@ export { useReadable } from './use-readable.svelte.js';
3
3
  export { useDocument } from './hooks/useDocument.svelte.js';
4
4
  export { useAnnotations } from './hooks/useAnnotations.svelte.js';
5
5
  export { useTool } from './hooks/useTool.svelte.js';
6
+ export { useToolStyle } from './hooks/useToolStyle.svelte.js';
7
+ export { useToolOptions } from './hooks/useToolOptions.svelte.js';
6
8
  export { useSelection } from './hooks/useSelection.svelte.js';
7
9
  export { useZoom } from './hooks/useZoom.svelte.js';
8
10
  export { usePage } from './hooks/usePage.svelte.js';
@@ -20,10 +22,16 @@ export { default as InkUndo } from './components/InkUndo.svelte';
20
22
  export { default as InkRedo } from './components/InkRedo.svelte';
21
23
  export { default as InkZoomIn } from './components/InkZoomIn.svelte';
22
24
  export { default as InkZoomOut } from './components/InkZoomOut.svelte';
25
+ export { default as InkColorMenu } from './components/InkColorMenu.svelte';
26
+ export { default as InkShapeMenu } from './components/InkShapeMenu.svelte';
27
+ export { default as InkSignatureMenu } from './components/InkSignatureMenu.svelte';
28
+ export { default as InkSignatureDialog } from './components/InkSignatureDialog.svelte';
29
+ export { default as InkHighlightMenu } from './components/InkHighlightMenu.svelte';
30
+ export { default as InkLineStyleMenu } from './components/InkLineStyleMenu.svelte';
31
+ export { default as InkTextStyleMenu } from './components/InkTextStyleMenu.svelte';
23
32
  export { default as InkZoomSelect } from './components/InkZoomSelect.svelte';
24
33
  export { default as InkPageInput } from './components/InkPageInput.svelte';
25
34
  export { default as InkPageCount } from './components/InkPageCount.svelte';
26
35
  export { default as InkPrevPage } from './components/InkPrevPage.svelte';
27
36
  export { default as InkNextPage } from './components/InkNextPage.svelte';
28
- export { default as InkNotePopover } from './components/InkNotePopover.svelte';
29
- export { default as InkSuggestionCard } from './components/InkSuggestionCard.svelte';
37
+ export { default as InkThreadPopover } from './components/InkThreadPopover.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkbar/svelte",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Svelte 5 components and hooks for Inkbar, the browser PDF viewer and editor.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://inkbar.dev",
@@ -26,19 +26,19 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "dependencies": {
29
- "@inkbar/icons": "^0.3.0",
29
+ "@inkbar/icons": "^0.5.0",
30
30
  "@internationalized/date": "^3.12.4",
31
31
  "bits-ui": "^2.19.5",
32
32
  "esm-env": "^1.2.0"
33
33
  },
34
34
  "peerDependencies": {
35
- "@inkbar/core": "^0.3.0",
35
+ "@inkbar/core": "^0.5.0",
36
36
  "svelte": "^5.46.4"
37
37
  },
38
38
  "devDependencies": {
39
- "@inkbar/core": "0.3.0",
39
+ "@inkbar/core": "0.5.0",
40
40
  "@inkbar/fixtures": "0.0.0",
41
- "@inkbar/theme": "0.3.0",
41
+ "@inkbar/theme": "0.5.0",
42
42
  "@sveltejs/package": "^3.0.0",
43
43
  "@sveltejs/vite-plugin-svelte": "^7.3.1",
44
44
  "@vitest/browser-playwright": "^5.0.4",
@@ -1,9 +0,0 @@
1
- import type { NotePopoverSlotProps } from '@inkbar/core/dom';
2
- import type { Snippet } from 'svelte';
3
- export interface InkNotePopoverProps {
4
- children?: Snippet<[NotePopoverSlotProps]> | undefined;
5
- }
6
- declare const InkNotePopover: import("svelte").Component<InkNotePopoverProps, {}, "">;
7
- type InkNotePopover = ReturnType<typeof InkNotePopover>;
8
- export default InkNotePopover;
9
- //# sourceMappingURL=InkNotePopover.svelte.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InkNotePopover.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/components/InkNotePopover.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErC,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,oBAAoB,CAAC,CAAC,GAAG,SAAS,CAAA;CACvD;AAwLH,QAAA,MAAM,cAAc,yDAAwC,CAAC;AAC7D,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AACxD,eAAe,cAAc,CAAC"}
@@ -1,121 +0,0 @@
1
- <script module lang="ts">
2
- import type { SuggestionCardSlotProps } from '@inkbar/core/dom'
3
- import type { Snippet } from 'svelte'
4
-
5
- export interface InkSuggestionCardProps {
6
- children?: Snippet<[SuggestionCardSlotProps]> | undefined
7
- }
8
- </script>
9
-
10
- <script lang="ts">
11
- /*
12
- * Review card for a suggested redaction: opens when the activated annotation, or the only
13
- * selected one, is a redaction with `origin: 'suggested'`. Locked suggestions cannot be
14
- * dismissed, so they get no Dismiss button. A press on the overlay selects and activates, so a
15
- * click opens it whatever the tool. Closing clears `activated` and the selection.
16
- */
17
- import { confidenceBucket } from '@inkbar/core'
18
- import { Popover } from 'bits-ui'
19
-
20
- import { useInkContext } from '../context.js'
21
- import { useAnnotations } from '../hooks/useAnnotations.svelte.js'
22
-
23
- import { useAnnotationElement } from './annotation-element.svelte.js'
24
- import { keepOpenOnAnnotation, useFocusReturn } from './popover-focus.js'
25
-
26
- import type { ConfidenceBucket, RedactAnnotation } from '@inkbar/core'
27
-
28
- let { children }: InkSuggestionCardProps = $props()
29
-
30
- const ctx = useInkContext('InkSuggestionCard')
31
- const store = useAnnotations()
32
-
33
- function suggestion(id: string | null | undefined): RedactAnnotation | null {
34
- const a = id ? store.annotations.find((x) => x.id === id) : undefined
35
- return a?.type === 'redact' && a.origin === 'suggested' ? a : null
36
- }
37
- // The activated annotation when it is a suggestion; otherwise the only selected one (a
38
- // marquee selects without activating).
39
- const target = $derived(
40
- suggestion(ctx.activated) ??
41
- (store.selection.length === 1 ? suggestion(store.selection[0]) : null)
42
- )
43
- const anchorRef = useAnnotationElement(
44
- () => ctx.rootEl,
45
- () => target?.id ?? null
46
- )
47
- const anchor = $derived(anchorRef.current)
48
- const focusReturn = useFocusReturn(ctx)
49
- const open = $derived(target !== null && anchor !== null)
50
- const bucket = $derived<ConfidenceBucket | undefined>(
51
- target?.suggestion ? confidenceBucket(target.suggestion.confidence) : undefined
52
- )
53
-
54
- function close(): void {
55
- ctx.setActivated(null)
56
- store.select([])
57
- }
58
- function accept(): void {
59
- if (target) store.accept(target.id)
60
- close()
61
- }
62
- /** Locked annotations cannot be removed: dismissing one does nothing and keeps the card. */
63
- function dismiss(): void {
64
- if (!target || target.locked) return
65
- focusReturn.beforeRemove(anchor, '[data-origin="suggested"]')
66
- store.dismiss(target.id)
67
- close()
68
- }
69
- function onOpenChange(next: boolean): void {
70
- if (!next) close()
71
- }
72
- </script>
73
-
74
- <Popover.Root bind:open={() => open, onOpenChange}>
75
- <Popover.Portal>
76
- {#if target && anchor}
77
- <Popover.Content
78
- class="ink-suggestion-card"
79
- data-ink-suggestion-card=""
80
- role="dialog"
81
- side="bottom"
82
- sideOffset={6}
83
- collisionPadding={8}
84
- aria-label="Suggested redaction"
85
- customAnchor={anchor}
86
- onInteractOutside={keepOpenOnAnnotation}
87
- onOpenAutoFocus={focusReturn.onOpenAutoFocus}
88
- onCloseAutoFocus={(e) => focusReturn.onCloseAutoFocus(e, anchor)}
89
- >
90
- {#if children}
91
- {@render children({
92
- annotation: target,
93
- suggestion: target.suggestion,
94
- bucket,
95
- accept,
96
- dismiss,
97
- close,
98
- })}
99
- {:else}
100
- <p class="ink-suggestion-reason">
101
- <strong>{target.suggestion?.reason ?? 'Suggested redaction'}</strong>
102
- {#if bucket}
103
- <span class="ink-suggestion-confidence" data-confidence={bucket}>
104
- {bucket} confidence
105
- </span>
106
- {/if}
107
- </p>
108
- {#if target.suggestion?.explanation}
109
- <p class="ink-suggestion-explanation">{target.suggestion.explanation}</p>
110
- {/if}
111
- <div class="ink-suggestion-actions">
112
- <button type="button" onclick={accept}>Accept</button>
113
- {#if !target.locked}
114
- <button type="button" onclick={dismiss}>Dismiss</button>
115
- {/if}
116
- </div>
117
- {/if}
118
- </Popover.Content>
119
- {/if}
120
- </Popover.Portal>
121
- </Popover.Root>
@@ -1,9 +0,0 @@
1
- import type { SuggestionCardSlotProps } from '@inkbar/core/dom';
2
- import type { Snippet } from 'svelte';
3
- export interface InkSuggestionCardProps {
4
- children?: Snippet<[SuggestionCardSlotProps]> | undefined;
5
- }
6
- declare const InkSuggestionCard: import("svelte").Component<InkSuggestionCardProps, {}, "">;
7
- type InkSuggestionCard = ReturnType<typeof InkSuggestionCard>;
8
- export default InkSuggestionCard;
9
- //# sourceMappingURL=InkSuggestionCard.svelte.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InkSuggestionCard.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/components/InkSuggestionCard.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,uBAAuB,CAAC,CAAC,GAAG,SAAS,CAAA;CAC1D;AAwHH,QAAA,MAAM,iBAAiB,4DAAwC,CAAC;AAChE,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC9D,eAAe,iBAAiB,CAAC"}