@aznabee/freehand-ui 0.1.4 → 0.1.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.
package/dist/index.d.ts CHANGED
@@ -14,15 +14,22 @@ export type DecorationType =
14
14
  | "sparkle"
15
15
  | "star"
16
16
  | "twinkle"
17
+ | "glimmer"
17
18
  | "smiley"
18
19
  | "emphasis"
19
- | "arcs"
20
- | "dots"
21
- | "stroke"
22
- | "steam";
20
+ | "arcs";
21
+
22
+ /**
23
+ * Note text, either written once or written per language.
24
+ *
25
+ * A map is keyed by BCP-47 tag - `en`, `pt-BR`, `zh-Hant` - plus an optional
26
+ * `default` for visitors whose language is not covered. Without one, the first
27
+ * translation written is used.
28
+ */
29
+ export type LocalizedText = string | Record<string, string>;
23
30
 
24
31
  export interface NoteOptions {
25
- text: string;
32
+ text: LocalizedText;
26
33
  /**
27
34
  * Which side of the element the note sits on. Always honoured - a note that
28
35
  * would run off screen slides horizontally to stay in view rather than
@@ -37,6 +44,34 @@ export interface NoteOptions {
37
44
  * running off screen.
38
45
  */
39
46
  offset?: { x?: number; y?: number };
47
+ /**
48
+ * Language to write this note in, overriding the top-level `locale` and the
49
+ * visitor's own languages. Only meaningful when `text` is a map.
50
+ */
51
+ locale?: string | string[] | null;
52
+ }
53
+
54
+ export interface ArrowAnimationOptions {
55
+ /**
56
+ * Reveal the stroke with a dash sweep, so the pen appears to travel from the
57
+ * note to the tip. Default `true`. A `dotted` arrow spends its dash pattern
58
+ * on the dots, so those flow toward the tip instead of being drawn on.
59
+ */
60
+ draw?: boolean;
61
+ /** Lean the arrow a few px toward what it points at. Default `true`. */
62
+ drift?: boolean;
63
+ /** Multiplier over every duration - `2` plays twice as fast. Default `1`. */
64
+ speed?: number;
65
+ /** How long the shaft takes to draw, ms, before `speed`. Default `900`. */
66
+ duration?: number;
67
+ /** Wait before the first stroke appears, ms. Default `150`. */
68
+ delay?: number;
69
+ /** How far the lean travels, px. Default `5`. */
70
+ distance?: number;
71
+ /** One full lean-and-return, ms. Default `2200`. */
72
+ driftDuration?: number;
73
+ /** Keep leaning. `false` settles once and stays put. Default `true`. */
74
+ repeat?: boolean;
40
75
  }
41
76
 
42
77
  export interface ArrowOptions {
@@ -50,6 +85,12 @@ export interface ArrowOptions {
50
85
  /** `"edge"` lands just outside the frame; `"center"` points into it. */
51
86
  to?: DoodlePosition | "edge";
52
87
  style?: "curved" | "straight" | "dotted" | "looped";
88
+ /**
89
+ * Motion for the arrow. On by default - the shaft draws itself on and the
90
+ * whole mark leans toward its target. `false` draws it static. Respects
91
+ * `prefers-reduced-motion`.
92
+ */
93
+ animate?: boolean | ArrowAnimationOptions;
53
94
  }
54
95
 
55
96
  export interface DecorationOptions {
@@ -82,7 +123,7 @@ export interface DoodleOptions {
82
123
  opacity?: number;
83
124
  /** Selector for decorating descendants instead of the element itself. */
84
125
  children?: string | null;
85
- note?: string | NoteOptions | null;
126
+ note?: LocalizedText | NoteOptions | null;
86
127
  arrow?: boolean | ArrowOptions;
87
128
  decorations?: boolean | DecorationOptions;
88
129
  /** Lift the pen at random points around the outline. */
@@ -99,6 +140,20 @@ export interface DoodleOptions {
99
140
  * handwriting fallbacks.
100
141
  */
101
142
  autoLoadFont?: boolean;
143
+ /**
144
+ * Which language a multilingual `note` is written in. Omit to follow the
145
+ * visitor's own languages - `navigator.languages`, which is what their
146
+ * operating system is set to - falling back to the document's `lang`.
147
+ *
148
+ * Set it to drive notes from your app's own i18n state instead. Accepts a
149
+ * list, in preference order.
150
+ */
151
+ locale?: string | string[] | null;
152
+ /**
153
+ * Overlay stacking order. Omit to follow the target element's z-index so
154
+ * doodles stay above the annotated element but below modals and other UI.
155
+ */
156
+ zIndex?: number | null;
102
157
  }
103
158
 
104
159
  export interface DoodleInstance {