@aznabee/freehand-ui 0.1.1

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.
@@ -0,0 +1,89 @@
1
+ export type DoodlePosition =
2
+ | "top"
3
+ | "top-right"
4
+ | "right"
5
+ | "bottom-right"
6
+ | "bottom"
7
+ | "bottom-left"
8
+ | "left"
9
+ | "top-left"
10
+ | "center";
11
+
12
+ export type DecorationType =
13
+ | "heart"
14
+ | "sparkle"
15
+ | "star"
16
+ | "twinkle"
17
+ | "smiley"
18
+ | "emphasis"
19
+ | "arcs"
20
+ | "dots"
21
+ | "stroke"
22
+ | "steam";
23
+
24
+ export interface NoteOptions {
25
+ text: string;
26
+ /** Preferred side. Flips automatically if it would run off screen. */
27
+ position?: DoodlePosition;
28
+ /** Underline sized to the measured text. Default `true`. */
29
+ underline?: boolean;
30
+ }
31
+
32
+ export interface ArrowOptions {
33
+ from?: DoodlePosition;
34
+ /** `"edge"` lands just outside the frame; `"center"` points into it. */
35
+ to?: DoodlePosition | "edge";
36
+ style?: "curved" | "straight" | "dotted";
37
+ }
38
+
39
+ export interface DecorationOptions {
40
+ /** Marks drawn around the border. Hard-capped at 2. */
41
+ count?: number | null;
42
+ /** Omit to choose automatically from the element's size. */
43
+ style?: "corners" | "sides";
44
+ /** Omit for the curated default set. */
45
+ types?: DecorationType[] | null;
46
+ }
47
+
48
+ export interface BreakOptions {
49
+ /** Omit for 2–5 gaps. */
50
+ count?: number | null;
51
+ /** Shortest gap, px. Default 6. */
52
+ min?: number;
53
+ /** Longest gap, px. Default 30. */
54
+ max?: number;
55
+ }
56
+
57
+ export interface DoodleOptions {
58
+ border?: boolean;
59
+ color?: string;
60
+ strokeWidth?: number;
61
+ roughness?: number;
62
+ padding?: number;
63
+ /** Auto-detected from CSS when omitted. */
64
+ radius?: number | null;
65
+ opacity?: number;
66
+ /** Selector for decorating descendants instead of the element itself. */
67
+ children?: string | null;
68
+ note?: string | NoteOptions | null;
69
+ arrow?: boolean | ArrowOptions;
70
+ decorations?: boolean | DecorationOptions;
71
+ /** Lift the pen at random points around the outline. */
72
+ addBreaks?: boolean | number | BreakOptions;
73
+ }
74
+
75
+ export interface DoodleInstance {
76
+ /** Recalculate geometry and redraw. */
77
+ update(): void;
78
+ /** Remove the overlay and disconnect observers. */
79
+ destroy(): void;
80
+ }
81
+
82
+ /**
83
+ * Wrap a DOM element with a hand-drawn SVG doodle overlay.
84
+ * Calling twice on the same element replaces the previous overlay.
85
+ */
86
+ export function doodle(
87
+ target: string | Element,
88
+ options?: DoodleOptions
89
+ ): DoodleInstance;