@aznabee/freehand-ui 0.1.8 → 0.2.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.
- package/README.md +35 -1
- package/dist/freehand-ui.cjs +14 -9
- package/dist/freehand-ui.js +14 -9
- package/dist/native.cjs +2422 -0
- package/dist/native.d.ts +51 -0
- package/dist/native.js +2428 -0
- package/dist/react.cjs +14 -9
- package/dist/react.js +14 -9
- package/native/package.json +7 -0
- package/package.json +18 -2
- package/react/package.json +7 -0
package/dist/react.cjs
CHANGED
|
@@ -582,8 +582,13 @@ function annotationAnchor(position, rect, offset = 12) {
|
|
|
582
582
|
return point;
|
|
583
583
|
}
|
|
584
584
|
|
|
585
|
-
// src/
|
|
585
|
+
// src/svg-dom.js
|
|
586
586
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
587
|
+
function createSvgElement(tag) {
|
|
588
|
+
return document.createElementNS(SVG_NS, tag);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
// src/renderer.js
|
|
587
592
|
var XML_NS = "http://www.w3.org/XML/1998/namespace";
|
|
588
593
|
var HANDWRITTEN_FONT = '"Caveat", "Kalam", "Patrick Hand", "Bradley Hand", "Segoe Script", "Comic Sans MS", cursive';
|
|
589
594
|
var NOTE_FONT_SIZE = 19;
|
|
@@ -807,7 +812,7 @@ function createBorderBreaks(perimeter, config, random) {
|
|
|
807
812
|
return breaks;
|
|
808
813
|
}
|
|
809
814
|
function createGroup(parent, x, y, rotation = 0) {
|
|
810
|
-
const group =
|
|
815
|
+
const group = createSvgElement("g");
|
|
811
816
|
group.setAttribute(
|
|
812
817
|
"transform",
|
|
813
818
|
`translate(${fmt(x)} ${fmt(y)}) rotate(${rotation.toFixed(1)})`
|
|
@@ -816,7 +821,7 @@ function createGroup(parent, x, y, rotation = 0) {
|
|
|
816
821
|
return group;
|
|
817
822
|
}
|
|
818
823
|
function appendPath(svg, d, style) {
|
|
819
|
-
const path =
|
|
824
|
+
const path = createSvgElement("path");
|
|
820
825
|
path.setAttribute("d", d);
|
|
821
826
|
path.setAttribute("fill", style.fill ?? "none");
|
|
822
827
|
path.setAttribute("stroke", style.color);
|
|
@@ -831,7 +836,7 @@ function appendPath(svg, d, style) {
|
|
|
831
836
|
return path;
|
|
832
837
|
}
|
|
833
838
|
function appendGlow(svg, radius, style) {
|
|
834
|
-
const circle =
|
|
839
|
+
const circle = createSvgElement("circle");
|
|
835
840
|
circle.setAttribute("r", fmt(radius));
|
|
836
841
|
circle.setAttribute("fill", style.color);
|
|
837
842
|
circle.setAttribute("opacity", String(style.opacity));
|
|
@@ -1135,7 +1140,7 @@ function drawArrow(svg, rect, arrowOptions, style, seed, origin = null, context
|
|
|
1135
1140
|
tipAngle = Math.atan2(end.y - c2y, end.x - c2x);
|
|
1136
1141
|
}
|
|
1137
1142
|
}
|
|
1138
|
-
const group =
|
|
1143
|
+
const group = createSvgElement("g");
|
|
1139
1144
|
svg.appendChild(group);
|
|
1140
1145
|
const shaftPaths = [];
|
|
1141
1146
|
if (ghost) {
|
|
@@ -1225,8 +1230,8 @@ function createNoteText(svg, text, style, options = {}) {
|
|
|
1225
1230
|
const lines = wrapWords(text, options.wordsPerLine ?? DEFAULT_WORDS_PER_LINE);
|
|
1226
1231
|
const lineHeight = fontSize * 1.05;
|
|
1227
1232
|
const rtl = options.rtl ?? isRtlText(text);
|
|
1228
|
-
const group =
|
|
1229
|
-
const textEl =
|
|
1233
|
+
const group = createSvgElement("g");
|
|
1234
|
+
const textEl = createSvgElement("text");
|
|
1230
1235
|
textEl.setAttribute("x", "0");
|
|
1231
1236
|
textEl.setAttribute("y", "0");
|
|
1232
1237
|
textEl.setAttribute("fill", style.color);
|
|
@@ -1245,7 +1250,7 @@ function createNoteText(svg, text, style, options = {}) {
|
|
|
1245
1250
|
textEl.setAttributeNS(XML_NS, "xml:lang", options.locale);
|
|
1246
1251
|
}
|
|
1247
1252
|
const tspans = lines.map((line, index) => {
|
|
1248
|
-
const tspan =
|
|
1253
|
+
const tspan = createSvgElement("tspan");
|
|
1249
1254
|
tspan.textContent = line;
|
|
1250
1255
|
tspan.setAttribute("x", "0");
|
|
1251
1256
|
tspan.setAttribute("dy", index === 0 ? "0" : String(lineHeight));
|
|
@@ -1309,7 +1314,7 @@ function placeNoteText(note, box, style, seed, options = {}) {
|
|
|
1309
1314
|
return note.group;
|
|
1310
1315
|
}
|
|
1311
1316
|
function createOverlaySvg(left, top, width, height) {
|
|
1312
|
-
const svg =
|
|
1317
|
+
const svg = createSvgElement("svg");
|
|
1313
1318
|
svg.setAttribute("class", OVERLAY_CLASS);
|
|
1314
1319
|
svg.setAttribute("xmlns", SVG_NS);
|
|
1315
1320
|
svg.setAttribute("width", String(width));
|
package/dist/react.js
CHANGED
|
@@ -565,8 +565,13 @@ function annotationAnchor(position, rect, offset = 12) {
|
|
|
565
565
|
return point;
|
|
566
566
|
}
|
|
567
567
|
|
|
568
|
-
// src/
|
|
568
|
+
// src/svg-dom.js
|
|
569
569
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
570
|
+
function createSvgElement(tag) {
|
|
571
|
+
return document.createElementNS(SVG_NS, tag);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// src/renderer.js
|
|
570
575
|
var XML_NS = "http://www.w3.org/XML/1998/namespace";
|
|
571
576
|
var HANDWRITTEN_FONT = '"Caveat", "Kalam", "Patrick Hand", "Bradley Hand", "Segoe Script", "Comic Sans MS", cursive';
|
|
572
577
|
var NOTE_FONT_SIZE = 19;
|
|
@@ -790,7 +795,7 @@ function createBorderBreaks(perimeter, config, random) {
|
|
|
790
795
|
return breaks;
|
|
791
796
|
}
|
|
792
797
|
function createGroup(parent, x, y, rotation = 0) {
|
|
793
|
-
const group =
|
|
798
|
+
const group = createSvgElement("g");
|
|
794
799
|
group.setAttribute(
|
|
795
800
|
"transform",
|
|
796
801
|
`translate(${fmt(x)} ${fmt(y)}) rotate(${rotation.toFixed(1)})`
|
|
@@ -799,7 +804,7 @@ function createGroup(parent, x, y, rotation = 0) {
|
|
|
799
804
|
return group;
|
|
800
805
|
}
|
|
801
806
|
function appendPath(svg, d, style) {
|
|
802
|
-
const path =
|
|
807
|
+
const path = createSvgElement("path");
|
|
803
808
|
path.setAttribute("d", d);
|
|
804
809
|
path.setAttribute("fill", style.fill ?? "none");
|
|
805
810
|
path.setAttribute("stroke", style.color);
|
|
@@ -814,7 +819,7 @@ function appendPath(svg, d, style) {
|
|
|
814
819
|
return path;
|
|
815
820
|
}
|
|
816
821
|
function appendGlow(svg, radius, style) {
|
|
817
|
-
const circle =
|
|
822
|
+
const circle = createSvgElement("circle");
|
|
818
823
|
circle.setAttribute("r", fmt(radius));
|
|
819
824
|
circle.setAttribute("fill", style.color);
|
|
820
825
|
circle.setAttribute("opacity", String(style.opacity));
|
|
@@ -1118,7 +1123,7 @@ function drawArrow(svg, rect, arrowOptions, style, seed, origin = null, context
|
|
|
1118
1123
|
tipAngle = Math.atan2(end.y - c2y, end.x - c2x);
|
|
1119
1124
|
}
|
|
1120
1125
|
}
|
|
1121
|
-
const group =
|
|
1126
|
+
const group = createSvgElement("g");
|
|
1122
1127
|
svg.appendChild(group);
|
|
1123
1128
|
const shaftPaths = [];
|
|
1124
1129
|
if (ghost) {
|
|
@@ -1208,8 +1213,8 @@ function createNoteText(svg, text, style, options = {}) {
|
|
|
1208
1213
|
const lines = wrapWords(text, options.wordsPerLine ?? DEFAULT_WORDS_PER_LINE);
|
|
1209
1214
|
const lineHeight = fontSize * 1.05;
|
|
1210
1215
|
const rtl = options.rtl ?? isRtlText(text);
|
|
1211
|
-
const group =
|
|
1212
|
-
const textEl =
|
|
1216
|
+
const group = createSvgElement("g");
|
|
1217
|
+
const textEl = createSvgElement("text");
|
|
1213
1218
|
textEl.setAttribute("x", "0");
|
|
1214
1219
|
textEl.setAttribute("y", "0");
|
|
1215
1220
|
textEl.setAttribute("fill", style.color);
|
|
@@ -1228,7 +1233,7 @@ function createNoteText(svg, text, style, options = {}) {
|
|
|
1228
1233
|
textEl.setAttributeNS(XML_NS, "xml:lang", options.locale);
|
|
1229
1234
|
}
|
|
1230
1235
|
const tspans = lines.map((line, index) => {
|
|
1231
|
-
const tspan =
|
|
1236
|
+
const tspan = createSvgElement("tspan");
|
|
1232
1237
|
tspan.textContent = line;
|
|
1233
1238
|
tspan.setAttribute("x", "0");
|
|
1234
1239
|
tspan.setAttribute("dy", index === 0 ? "0" : String(lineHeight));
|
|
@@ -1292,7 +1297,7 @@ function placeNoteText(note, box, style, seed, options = {}) {
|
|
|
1292
1297
|
return note.group;
|
|
1293
1298
|
}
|
|
1294
1299
|
function createOverlaySvg(left, top, width, height) {
|
|
1295
|
-
const svg =
|
|
1300
|
+
const svg = createSvgElement("svg");
|
|
1296
1301
|
svg.setAttribute("class", OVERLAY_CLASS);
|
|
1297
1302
|
svg.setAttribute("xmlns", SVG_NS);
|
|
1298
1303
|
svg.setAttribute("width", String(width));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aznabee/freehand-ui",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Wrap any existing web element with a beautiful, responsive, hand-drawn doodle layer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/freehand-ui.cjs",
|
|
@@ -17,10 +17,17 @@
|
|
|
17
17
|
"types": "./dist/react.d.ts",
|
|
18
18
|
"import": "./dist/react.js",
|
|
19
19
|
"require": "./dist/react.cjs"
|
|
20
|
+
},
|
|
21
|
+
"./native": {
|
|
22
|
+
"types": "./dist/native.d.ts",
|
|
23
|
+
"import": "./dist/native.js",
|
|
24
|
+
"require": "./dist/native.cjs"
|
|
20
25
|
}
|
|
21
26
|
},
|
|
22
27
|
"files": [
|
|
23
28
|
"dist",
|
|
29
|
+
"native",
|
|
30
|
+
"react",
|
|
24
31
|
"README.md",
|
|
25
32
|
"LICENSE"
|
|
26
33
|
],
|
|
@@ -48,15 +55,24 @@
|
|
|
48
55
|
"sketch",
|
|
49
56
|
"ui",
|
|
50
57
|
"react",
|
|
58
|
+
"react-native",
|
|
51
59
|
"gpt-hand-drawn-style"
|
|
52
60
|
],
|
|
53
61
|
"license": "MIT",
|
|
54
62
|
"peerDependencies": {
|
|
55
|
-
"react": ">=17"
|
|
63
|
+
"react": ">=17",
|
|
64
|
+
"react-native": ">=0.70",
|
|
65
|
+
"react-native-svg": ">=13"
|
|
56
66
|
},
|
|
57
67
|
"peerDependenciesMeta": {
|
|
58
68
|
"react": {
|
|
59
69
|
"optional": true
|
|
70
|
+
},
|
|
71
|
+
"react-native": {
|
|
72
|
+
"optional": true
|
|
73
|
+
},
|
|
74
|
+
"react-native-svg": {
|
|
75
|
+
"optional": true
|
|
60
76
|
}
|
|
61
77
|
},
|
|
62
78
|
"devDependencies": {
|