skema-core 0.1.1 → 0.1.2
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 +12 -3
- package/dist/index.js +447 -74
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +447 -74
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/petersenmatthew/skema/main/assets/logo-dark.svg">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/petersenmatthew/skema/main/assets/logo-light.svg" alt="Skema" width="400">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
A drawing-based website development tool that transforms how you annotate and communicate design changes.
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
---
|
|
4
13
|
|
|
5
14
|
## Overview
|
|
6
15
|
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var tldraw = require('tldraw');
|
|
7
7
|
require('tldraw/tldraw.css');
|
|
8
|
+
var framerMotion = require('framer-motion');
|
|
8
9
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
10
|
|
|
10
11
|
// src/components/Skema.tsx
|
|
@@ -882,7 +883,43 @@ function extractTextFromShapes(shapes) {
|
|
|
882
883
|
}
|
|
883
884
|
return textContent.filter(Boolean).join("\n");
|
|
884
885
|
}
|
|
885
|
-
var
|
|
886
|
+
var SLogoIcon = ({ size = 32 }) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: size, height: size, viewBox: "0 0 166 161", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
887
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
888
|
+
"path",
|
|
889
|
+
{
|
|
890
|
+
d: "M77.0782 5.17419C80.4699 2.21068 85.5301 2.21067 88.9218 5.17419L109.929 23.529C111.161 24.6057 112.663 25.3261 114.274 25.6126L141.769 30.5023C146.225 31.2947 149.399 35.2725 149.183 39.7929L147.86 67.4755C147.782 69.1226 148.157 70.7596 148.945 72.2079L162.203 96.5644C164.372 100.55 163.236 105.527 159.551 108.175L136.957 124.416C135.623 125.375 134.577 126.681 133.932 128.193L123.03 153.753C121.26 157.902 116.692 160.1 112.346 158.894L85.4054 151.422C83.8315 150.985 82.1685 150.985 80.5946 151.422L53.6541 158.894C49.3075 160.1 44.7399 157.902 42.9702 153.753L32.0681 128.193C31.4234 126.681 30.3771 125.375 29.0427 124.416L6.4487 108.175C2.76426 105.527 1.62755 100.55 3.79688 96.5644L17.0547 72.2079C17.8431 70.7596 18.2184 69.1226 18.1397 67.4755L16.8169 39.7929C16.6009 35.2725 19.7752 31.2947 24.2308 30.5023L51.7255 25.6126C53.3366 25.3261 54.8392 24.6057 56.0714 23.529L77.0782 5.17419Z",
|
|
891
|
+
fill: "#FF6800"
|
|
892
|
+
}
|
|
893
|
+
),
|
|
894
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
895
|
+
"path",
|
|
896
|
+
{
|
|
897
|
+
d: "M65.0888 64.1092C65.0888 68.461 73.1316 69.0511 83.5428 69.7887C102.046 71.1901 128.049 73.1078 128 97.9645C128 126.288 106.289 133 83 133C59.7599 132.926 40.4672 128.722 38.0001 97.9645H65.0888C68.0494 105.635 74.9079 107.627 83 107.627C91.0428 107.627 100.911 105.635 100.911 97.9645C100.911 93.6128 92.8684 92.9489 82.4572 92.2113C63.954 90.8099 37.9507 88.8922 38.0001 64.1092C38.0001 35.7858 59.7106 29 83 29C106.24 29.2213 125.533 33.1305 128 64.1092H100.911C97.9506 56.2908 91.0921 54.4468 83 54.4468C74.9572 54.4468 65.0888 56.217 65.0888 64.1092Z",
|
|
898
|
+
fill: "white"
|
|
899
|
+
}
|
|
900
|
+
)
|
|
901
|
+
] });
|
|
902
|
+
var ChevronLeftIcon = ({ size = 24 }) => /* @__PURE__ */ jsxRuntime.jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
903
|
+
"path",
|
|
904
|
+
{
|
|
905
|
+
d: "M15 18L9 12L15 6",
|
|
906
|
+
stroke: "#9CA3AF",
|
|
907
|
+
strokeWidth: "2.5",
|
|
908
|
+
strokeLinecap: "round",
|
|
909
|
+
strokeLinejoin: "round"
|
|
910
|
+
}
|
|
911
|
+
) });
|
|
912
|
+
var ChevronRightIcon = ({ size = 24 }) => /* @__PURE__ */ jsxRuntime.jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
913
|
+
"path",
|
|
914
|
+
{
|
|
915
|
+
d: "M9 6L15 12L9 18",
|
|
916
|
+
stroke: "#9CA3AF",
|
|
917
|
+
strokeWidth: "2.5",
|
|
918
|
+
strokeLinecap: "round",
|
|
919
|
+
strokeLinejoin: "round"
|
|
920
|
+
}
|
|
921
|
+
) });
|
|
922
|
+
var SelectIcon = ({ isSelected }) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "30", height: "30", viewBox: "0 0 25 25", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
886
923
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
887
924
|
"path",
|
|
888
925
|
{
|
|
@@ -899,7 +936,7 @@ var SelectIcon = ({ isSelected }) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { wi
|
|
|
899
936
|
}
|
|
900
937
|
)
|
|
901
938
|
] });
|
|
902
|
-
var DrawIcon = ({ isSelected }) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "
|
|
939
|
+
var DrawIcon = ({ isSelected }) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "30", height: "30", viewBox: "0 0 25 25", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
903
940
|
/* @__PURE__ */ jsxRuntime.jsx("rect", { width: "25", height: "25", rx: "2", fill: isSelected ? "#00C851" : "#00C851", opacity: isSelected ? 1 : 0.7 }),
|
|
904
941
|
/* @__PURE__ */ jsxRuntime.jsx("g", { transform: "translate(12.5, 12.5) scale(1.4) translate(-12.5, -12.5)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
905
942
|
"path",
|
|
@@ -911,7 +948,7 @@ var DrawIcon = ({ isSelected }) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { widt
|
|
|
911
948
|
}
|
|
912
949
|
) })
|
|
913
950
|
] });
|
|
914
|
-
var LassoIcon = ({ isSelected }) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "
|
|
951
|
+
var LassoIcon = ({ isSelected }) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "30", height: "30", viewBox: "0 0 25 25", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
915
952
|
/* @__PURE__ */ jsxRuntime.jsx("rect", { width: "25", height: "25", rx: "12.5", fill: isSelected ? "#2C7FFF" : "#2C7FFF", opacity: isSelected ? 1 : 0.7 }),
|
|
916
953
|
/* @__PURE__ */ jsxRuntime.jsx("g", { transform: "translate(12.5, 12.5) scale(1.4) translate(-12.5, -12.5)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
917
954
|
"path",
|
|
@@ -923,7 +960,7 @@ var LassoIcon = ({ isSelected }) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { wid
|
|
|
923
960
|
}
|
|
924
961
|
) })
|
|
925
962
|
] });
|
|
926
|
-
var EraseIcon = ({ isSelected }) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "
|
|
963
|
+
var EraseIcon = ({ isSelected }) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "36", height: "30", viewBox: "0 0 30 25", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
927
964
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
928
965
|
"path",
|
|
929
966
|
{
|
|
@@ -937,7 +974,7 @@ var EraseIcon = ({ isSelected }) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { wid
|
|
|
937
974
|
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "-2", y1: "-3", x2: "-2", y2: "3", stroke: "white", strokeWidth: "1.5" })
|
|
938
975
|
] }) })
|
|
939
976
|
] });
|
|
940
|
-
var ShapesIcon = ({ isSelected }) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "
|
|
977
|
+
var ShapesIcon = ({ isSelected }) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "30", height: "30", viewBox: "0 0 25 25", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
941
978
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
942
979
|
"path",
|
|
943
980
|
{
|
|
@@ -1140,46 +1177,285 @@ var ShapePicker = ({ isOpen, onClose, onSelectShape, anchorRef }) => {
|
|
|
1140
1177
|
}
|
|
1141
1178
|
);
|
|
1142
1179
|
};
|
|
1143
|
-
var
|
|
1180
|
+
var TOOL_COUNT = 4;
|
|
1181
|
+
var EXIT_DURATION = 0.12;
|
|
1182
|
+
var EXIT_STAGGER = 0.01;
|
|
1183
|
+
var smoothEasing = [0.4, 0, 0.2, 1];
|
|
1184
|
+
var toolVariants = {
|
|
1185
|
+
hidden: {
|
|
1186
|
+
opacity: 0,
|
|
1187
|
+
scale: 0.8,
|
|
1188
|
+
width: 0,
|
|
1189
|
+
marginRight: -6
|
|
1190
|
+
},
|
|
1191
|
+
visible: (i) => ({
|
|
1192
|
+
opacity: 1,
|
|
1193
|
+
scale: 1,
|
|
1194
|
+
width: 40,
|
|
1195
|
+
marginRight: 0,
|
|
1196
|
+
transition: {
|
|
1197
|
+
opacity: { duration: 0.15, delay: i * 0.04 },
|
|
1198
|
+
scale: { type: "spring", stiffness: 400, damping: 25, delay: i * 0.04 },
|
|
1199
|
+
width: { type: "spring", stiffness: 400, damping: 30, delay: i * 0.03 },
|
|
1200
|
+
marginRight: { duration: 0.1, delay: i * 0.03 }
|
|
1201
|
+
}
|
|
1202
|
+
}),
|
|
1203
|
+
exit: (i) => ({
|
|
1204
|
+
opacity: 0,
|
|
1205
|
+
scale: 0.8,
|
|
1206
|
+
width: 0,
|
|
1207
|
+
marginRight: -6,
|
|
1208
|
+
transition: {
|
|
1209
|
+
opacity: { duration: 0.06, ease: "easeOut" },
|
|
1210
|
+
scale: { duration: EXIT_DURATION, ease: smoothEasing },
|
|
1211
|
+
width: { duration: EXIT_DURATION, ease: smoothEasing, delay: EXIT_STAGGER * (TOOL_COUNT - 1 - i) },
|
|
1212
|
+
marginRight: { duration: EXIT_DURATION, ease: smoothEasing, delay: EXIT_STAGGER * (TOOL_COUNT - 1 - i) }
|
|
1213
|
+
}
|
|
1214
|
+
})
|
|
1215
|
+
};
|
|
1216
|
+
var chevronVariants = {
|
|
1217
|
+
hidden: {
|
|
1218
|
+
opacity: 0,
|
|
1219
|
+
scale: 0.8,
|
|
1220
|
+
width: 0
|
|
1221
|
+
},
|
|
1222
|
+
visible: {
|
|
1223
|
+
opacity: 0.6,
|
|
1224
|
+
scale: 1,
|
|
1225
|
+
width: 28,
|
|
1226
|
+
transition: {
|
|
1227
|
+
opacity: { delay: 0.1, duration: 0.1 },
|
|
1228
|
+
scale: { delay: 0.1, type: "spring", stiffness: 500, damping: 30 },
|
|
1229
|
+
width: { delay: 0.08, duration: 0.12, ease: "easeOut" }
|
|
1230
|
+
}
|
|
1231
|
+
},
|
|
1232
|
+
exit: {
|
|
1233
|
+
opacity: 0,
|
|
1234
|
+
scale: 0.8,
|
|
1235
|
+
width: 0,
|
|
1236
|
+
transition: {
|
|
1237
|
+
opacity: { duration: 0.06 },
|
|
1238
|
+
scale: { duration: 0.08 },
|
|
1239
|
+
width: { duration: 0.1, ease: smoothEasing }
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
};
|
|
1243
|
+
var ToolbarButton = ({
|
|
1244
|
+
onClick,
|
|
1245
|
+
isSelected,
|
|
1246
|
+
icon,
|
|
1247
|
+
label,
|
|
1248
|
+
buttonRef,
|
|
1249
|
+
index = 0
|
|
1250
|
+
}) => {
|
|
1144
1251
|
const handleClick = (e) => {
|
|
1145
1252
|
e.preventDefault();
|
|
1146
1253
|
e.stopPropagation();
|
|
1147
1254
|
onClick();
|
|
1148
1255
|
};
|
|
1149
1256
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1150
|
-
|
|
1257
|
+
framerMotion.motion.button,
|
|
1151
1258
|
{
|
|
1152
1259
|
ref: buttonRef,
|
|
1260
|
+
custom: index,
|
|
1261
|
+
variants: toolVariants,
|
|
1262
|
+
initial: "hidden",
|
|
1263
|
+
animate: "visible",
|
|
1264
|
+
exit: "exit",
|
|
1153
1265
|
onClick: handleClick,
|
|
1154
1266
|
title: label,
|
|
1155
1267
|
type: "button",
|
|
1268
|
+
whileHover: { scale: 1.05 },
|
|
1269
|
+
whileTap: { scale: 0.95 },
|
|
1156
1270
|
style: {
|
|
1157
1271
|
display: "flex",
|
|
1158
1272
|
alignItems: "center",
|
|
1159
1273
|
justifyContent: "center",
|
|
1160
|
-
|
|
1161
|
-
|
|
1274
|
+
height: 40,
|
|
1275
|
+
minWidth: 0,
|
|
1162
1276
|
border: "none",
|
|
1163
|
-
borderRadius:
|
|
1277
|
+
borderRadius: 8,
|
|
1164
1278
|
backgroundColor: isSelected ? "rgba(255,255,255,0.15)" : "transparent",
|
|
1165
1279
|
cursor: "pointer",
|
|
1166
|
-
|
|
1167
|
-
|
|
1280
|
+
pointerEvents: "auto",
|
|
1281
|
+
overflow: "hidden",
|
|
1282
|
+
flexShrink: 0
|
|
1168
1283
|
},
|
|
1169
|
-
children:
|
|
1284
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1285
|
+
framerMotion.motion.span,
|
|
1286
|
+
{
|
|
1287
|
+
style: { display: "flex", alignItems: "center", justifyContent: "center" },
|
|
1288
|
+
initial: { opacity: 0, scale: 0.8 },
|
|
1289
|
+
animate: { opacity: 1, scale: 1 },
|
|
1290
|
+
exit: { opacity: 0, scale: 0.8 },
|
|
1291
|
+
transition: { duration: 0.12 },
|
|
1292
|
+
children: icon
|
|
1293
|
+
}
|
|
1294
|
+
)
|
|
1170
1295
|
}
|
|
1171
1296
|
);
|
|
1172
1297
|
};
|
|
1173
|
-
var
|
|
1298
|
+
var LogoShapesButton = ({
|
|
1299
|
+
isExpanded,
|
|
1300
|
+
isHovered,
|
|
1301
|
+
isSelected,
|
|
1302
|
+
onClick,
|
|
1303
|
+
onShapesClick,
|
|
1304
|
+
onMouseEnter,
|
|
1305
|
+
onMouseLeave,
|
|
1306
|
+
buttonRef
|
|
1307
|
+
}) => {
|
|
1308
|
+
const handleClick = (e) => {
|
|
1309
|
+
e.preventDefault();
|
|
1310
|
+
e.stopPropagation();
|
|
1311
|
+
if (isExpanded) {
|
|
1312
|
+
onShapesClick();
|
|
1313
|
+
} else {
|
|
1314
|
+
onClick();
|
|
1315
|
+
}
|
|
1316
|
+
};
|
|
1317
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1318
|
+
framerMotion.motion.button,
|
|
1319
|
+
{
|
|
1320
|
+
ref: buttonRef,
|
|
1321
|
+
onClick: handleClick,
|
|
1322
|
+
onMouseEnter,
|
|
1323
|
+
onMouseLeave,
|
|
1324
|
+
title: isExpanded ? "Shapes (G)" : "Expand toolbar",
|
|
1325
|
+
type: "button",
|
|
1326
|
+
whileHover: { scale: 1.08 },
|
|
1327
|
+
whileTap: { scale: 0.95 },
|
|
1328
|
+
style: {
|
|
1329
|
+
display: "flex",
|
|
1330
|
+
alignItems: "center",
|
|
1331
|
+
justifyContent: "center",
|
|
1332
|
+
width: 40,
|
|
1333
|
+
height: 40,
|
|
1334
|
+
border: "none",
|
|
1335
|
+
borderRadius: 8,
|
|
1336
|
+
backgroundColor: isSelected ? "rgba(255,255,255,0.15)" : "transparent",
|
|
1337
|
+
cursor: "pointer",
|
|
1338
|
+
pointerEvents: "auto",
|
|
1339
|
+
position: "relative"
|
|
1340
|
+
},
|
|
1341
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { mode: "popLayout", children: isExpanded ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1342
|
+
framerMotion.motion.div,
|
|
1343
|
+
{
|
|
1344
|
+
initial: { opacity: 0, scale: 0.8 },
|
|
1345
|
+
animate: { opacity: 1, scale: 1 },
|
|
1346
|
+
exit: { opacity: 0, scale: 0.85 },
|
|
1347
|
+
transition: {
|
|
1348
|
+
type: "spring",
|
|
1349
|
+
stiffness: 500,
|
|
1350
|
+
damping: 30,
|
|
1351
|
+
opacity: { duration: 0.08 }
|
|
1352
|
+
},
|
|
1353
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ShapesIcon, { isSelected })
|
|
1354
|
+
},
|
|
1355
|
+
"shapes"
|
|
1356
|
+
) : isHovered ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1357
|
+
framerMotion.motion.div,
|
|
1358
|
+
{
|
|
1359
|
+
initial: { opacity: 0, x: -3 },
|
|
1360
|
+
animate: { opacity: 1, x: 0 },
|
|
1361
|
+
exit: { opacity: 0, x: 3 },
|
|
1362
|
+
transition: { duration: 0.08, ease: "easeOut" },
|
|
1363
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRightIcon, { size: 20 })
|
|
1364
|
+
},
|
|
1365
|
+
"chevron"
|
|
1366
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1367
|
+
framerMotion.motion.div,
|
|
1368
|
+
{
|
|
1369
|
+
initial: { opacity: 0, scale: 0.9 },
|
|
1370
|
+
animate: { opacity: 1, scale: 1 },
|
|
1371
|
+
exit: { opacity: 0, scale: 0.85 },
|
|
1372
|
+
transition: {
|
|
1373
|
+
type: "spring",
|
|
1374
|
+
stiffness: 500,
|
|
1375
|
+
damping: 30,
|
|
1376
|
+
opacity: { duration: 0.06 }
|
|
1377
|
+
},
|
|
1378
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(SLogoIcon, { size: 32 })
|
|
1379
|
+
},
|
|
1380
|
+
"s"
|
|
1381
|
+
) })
|
|
1382
|
+
}
|
|
1383
|
+
);
|
|
1384
|
+
};
|
|
1385
|
+
var CollapseButton = ({ onClick }) => {
|
|
1386
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1387
|
+
framerMotion.motion.button,
|
|
1388
|
+
{
|
|
1389
|
+
variants: chevronVariants,
|
|
1390
|
+
initial: "hidden",
|
|
1391
|
+
animate: "visible",
|
|
1392
|
+
exit: "exit",
|
|
1393
|
+
onClick: (e) => {
|
|
1394
|
+
e.preventDefault();
|
|
1395
|
+
e.stopPropagation();
|
|
1396
|
+
onClick();
|
|
1397
|
+
},
|
|
1398
|
+
title: "Collapse toolbar",
|
|
1399
|
+
type: "button",
|
|
1400
|
+
whileHover: { opacity: 1, scale: 1.1 },
|
|
1401
|
+
whileTap: { scale: 0.9 },
|
|
1402
|
+
style: {
|
|
1403
|
+
display: "flex",
|
|
1404
|
+
alignItems: "center",
|
|
1405
|
+
justifyContent: "center",
|
|
1406
|
+
height: 40,
|
|
1407
|
+
minWidth: 0,
|
|
1408
|
+
border: "none",
|
|
1409
|
+
borderRadius: 6,
|
|
1410
|
+
backgroundColor: "transparent",
|
|
1411
|
+
cursor: "pointer",
|
|
1412
|
+
pointerEvents: "auto",
|
|
1413
|
+
marginLeft: 2,
|
|
1414
|
+
overflow: "hidden",
|
|
1415
|
+
flexShrink: 0
|
|
1416
|
+
},
|
|
1417
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1418
|
+
framerMotion.motion.span,
|
|
1419
|
+
{
|
|
1420
|
+
style: { display: "flex", alignItems: "center", justifyContent: "center" },
|
|
1421
|
+
initial: { opacity: 0 },
|
|
1422
|
+
animate: { opacity: 1 },
|
|
1423
|
+
exit: { opacity: 0 },
|
|
1424
|
+
transition: { duration: 0.1 },
|
|
1425
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ChevronLeftIcon, { size: 20 })
|
|
1426
|
+
}
|
|
1427
|
+
)
|
|
1428
|
+
}
|
|
1429
|
+
);
|
|
1430
|
+
};
|
|
1431
|
+
var SkemaToolbar = ({ onExpandedChange, onStylePanelChange }) => {
|
|
1174
1432
|
const editor = tldraw.useEditor();
|
|
1175
1433
|
const tools = tldraw.useTools();
|
|
1176
1434
|
const shapesButtonRef = react.useRef(null);
|
|
1435
|
+
const [isExpanded, setIsExpanded] = react.useState(false);
|
|
1436
|
+
const [isLogoHovered, setIsLogoHovered] = react.useState(false);
|
|
1177
1437
|
const [isShapePickerOpen, setIsShapePickerOpen] = react.useState(false);
|
|
1438
|
+
const [isStylePanelOpen, setIsStylePanelOpen] = react.useState(false);
|
|
1178
1439
|
const isSelectSelected = tldraw.useIsToolSelected(tools["select"]);
|
|
1179
1440
|
const isDrawSelected = tldraw.useIsToolSelected(tools["draw"]);
|
|
1180
1441
|
const isLassoSelected = tldraw.useIsToolSelected(tools["lasso-select"]);
|
|
1181
1442
|
const isEraseSelected = tldraw.useIsToolSelected(tools["eraser"]);
|
|
1182
1443
|
const isGeoSelected = tldraw.useIsToolSelected(tools["geo"]);
|
|
1444
|
+
const handleExpand = (expanded) => {
|
|
1445
|
+
setIsExpanded(expanded);
|
|
1446
|
+
onExpandedChange?.(expanded);
|
|
1447
|
+
if (!expanded) {
|
|
1448
|
+
setIsStylePanelOpen(false);
|
|
1449
|
+
onStylePanelChange?.(false);
|
|
1450
|
+
}
|
|
1451
|
+
};
|
|
1452
|
+
const handleLogoClick = () => {
|
|
1453
|
+
handleExpand(true);
|
|
1454
|
+
};
|
|
1455
|
+
const handleCollapse = () => {
|
|
1456
|
+
handleExpand(false);
|
|
1457
|
+
setIsShapePickerOpen(false);
|
|
1458
|
+
};
|
|
1183
1459
|
const handleShapesClick = () => {
|
|
1184
1460
|
setIsShapePickerOpen((prev) => !prev);
|
|
1185
1461
|
};
|
|
@@ -1189,73 +1465,103 @@ var SkemaToolbar = () => {
|
|
|
1189
1465
|
setIsShapePickerOpen(false);
|
|
1190
1466
|
};
|
|
1191
1467
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1192
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1468
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1193
1469
|
"div",
|
|
1194
1470
|
{
|
|
1195
|
-
"data-skema": "toolbar",
|
|
1196
1471
|
style: {
|
|
1197
1472
|
position: "absolute",
|
|
1198
1473
|
bottom: 16,
|
|
1199
|
-
left:
|
|
1200
|
-
|
|
1474
|
+
left: 0,
|
|
1475
|
+
right: 0,
|
|
1201
1476
|
display: "flex",
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
padding: "11px 17px",
|
|
1205
|
-
backgroundColor: "white",
|
|
1206
|
-
borderRadius: 36,
|
|
1207
|
-
boxShadow: "0 2px 10px rgba(0,0,0,0.15)",
|
|
1208
|
-
pointerEvents: "auto",
|
|
1477
|
+
justifyContent: "center",
|
|
1478
|
+
pointerEvents: "none",
|
|
1209
1479
|
zIndex: 99999
|
|
1210
1480
|
},
|
|
1211
|
-
children:
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1481
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1482
|
+
framerMotion.motion.div,
|
|
1483
|
+
{
|
|
1484
|
+
"data-skema": "toolbar",
|
|
1485
|
+
style: {
|
|
1486
|
+
display: "flex",
|
|
1487
|
+
alignItems: "center",
|
|
1488
|
+
gap: 6,
|
|
1489
|
+
padding: "6px 12px",
|
|
1490
|
+
backgroundColor: "white",
|
|
1491
|
+
borderRadius: 28,
|
|
1492
|
+
boxShadow: "0 2px 10px rgba(0,0,0,0.15)",
|
|
1493
|
+
pointerEvents: "auto"
|
|
1494
|
+
},
|
|
1495
|
+
children: [
|
|
1496
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1497
|
+
LogoShapesButton,
|
|
1498
|
+
{
|
|
1499
|
+
isExpanded,
|
|
1500
|
+
isHovered: isLogoHovered,
|
|
1501
|
+
isSelected: isGeoSelected || isShapePickerOpen,
|
|
1502
|
+
onClick: handleLogoClick,
|
|
1503
|
+
onShapesClick: handleShapesClick,
|
|
1504
|
+
onMouseEnter: () => setIsLogoHovered(true),
|
|
1505
|
+
onMouseLeave: () => setIsLogoHovered(false),
|
|
1506
|
+
buttonRef: shapesButtonRef
|
|
1507
|
+
}
|
|
1508
|
+
),
|
|
1509
|
+
/* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { mode: "popLayout", children: isExpanded && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1510
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1511
|
+
ToolbarButton,
|
|
1512
|
+
{
|
|
1513
|
+
onClick: () => editor.setCurrentTool("select"),
|
|
1514
|
+
isSelected: isSelectSelected,
|
|
1515
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(SelectIcon, { isSelected: isSelectSelected }),
|
|
1516
|
+
label: "Select (S)",
|
|
1517
|
+
index: 0
|
|
1518
|
+
},
|
|
1519
|
+
"select"
|
|
1520
|
+
),
|
|
1521
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1522
|
+
ToolbarButton,
|
|
1523
|
+
{
|
|
1524
|
+
onClick: () => editor.setCurrentTool("draw"),
|
|
1525
|
+
isSelected: isDrawSelected,
|
|
1526
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(DrawIcon, { isSelected: isDrawSelected }),
|
|
1527
|
+
label: "Draw (D)",
|
|
1528
|
+
index: 1
|
|
1529
|
+
},
|
|
1530
|
+
"draw"
|
|
1531
|
+
),
|
|
1532
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1533
|
+
ToolbarButton,
|
|
1534
|
+
{
|
|
1535
|
+
onClick: () => editor.setCurrentTool("lasso-select"),
|
|
1536
|
+
isSelected: isLassoSelected,
|
|
1537
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(LassoIcon, { isSelected: isLassoSelected }),
|
|
1538
|
+
label: "Lasso Select (L)",
|
|
1539
|
+
index: 2
|
|
1540
|
+
},
|
|
1541
|
+
"lasso"
|
|
1542
|
+
),
|
|
1543
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1544
|
+
ToolbarButton,
|
|
1545
|
+
{
|
|
1546
|
+
onClick: () => editor.setCurrentTool("eraser"),
|
|
1547
|
+
isSelected: isEraseSelected,
|
|
1548
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(EraseIcon, { isSelected: isEraseSelected }),
|
|
1549
|
+
label: "Eraser (E)",
|
|
1550
|
+
index: 3
|
|
1551
|
+
},
|
|
1552
|
+
"erase"
|
|
1553
|
+
),
|
|
1554
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1555
|
+
CollapseButton,
|
|
1556
|
+
{
|
|
1557
|
+
onClick: handleCollapse
|
|
1558
|
+
},
|
|
1559
|
+
"collapse"
|
|
1560
|
+
)
|
|
1561
|
+
] }) })
|
|
1562
|
+
]
|
|
1563
|
+
}
|
|
1564
|
+
)
|
|
1259
1565
|
}
|
|
1260
1566
|
),
|
|
1261
1567
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2516,6 +2822,8 @@ var Skema = ({
|
|
|
2516
2822
|
const [processingBoundingBox, setProcessingBoundingBox] = react.useState(null);
|
|
2517
2823
|
const [scribbleToast, setScribbleToast] = react.useState(null);
|
|
2518
2824
|
const [internalIsProcessing, setInternalIsProcessing] = react.useState(false);
|
|
2825
|
+
const [isToolbarExpanded, setIsToolbarExpanded] = react.useState(false);
|
|
2826
|
+
const [isStylePanelOpen, setIsStylePanelOpen] = react.useState(false);
|
|
2519
2827
|
const annotationChangesRef = react.useRef(/* @__PURE__ */ new Map());
|
|
2520
2828
|
const {
|
|
2521
2829
|
state: daemonState,
|
|
@@ -3179,6 +3487,65 @@ var Skema = ({
|
|
|
3179
3487
|
},
|
|
3180
3488
|
children: [
|
|
3181
3489
|
/* @__PURE__ */ jsxRuntime.jsx("style", { children: skemaHiddenUiStyles }),
|
|
3490
|
+
!isStylePanelOpen && /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
3491
|
+
.tlui-style-panel__wrapper,
|
|
3492
|
+
.tlui-style-panel {
|
|
3493
|
+
display: none !important;
|
|
3494
|
+
}
|
|
3495
|
+
` }),
|
|
3496
|
+
isStylePanelOpen && /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
3497
|
+
.tlui-style-panel__wrapper {
|
|
3498
|
+
top: 68px !important;
|
|
3499
|
+
right: 16px !important;
|
|
3500
|
+
}
|
|
3501
|
+
` }),
|
|
3502
|
+
isToolbarExpanded && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3503
|
+
"button",
|
|
3504
|
+
{
|
|
3505
|
+
onClick: () => setIsStylePanelOpen((prev) => !prev),
|
|
3506
|
+
title: isStylePanelOpen ? "Hide style settings" : "Show style settings",
|
|
3507
|
+
style: {
|
|
3508
|
+
position: "fixed",
|
|
3509
|
+
top: 16,
|
|
3510
|
+
right: 16,
|
|
3511
|
+
width: 44,
|
|
3512
|
+
height: 44,
|
|
3513
|
+
display: "flex",
|
|
3514
|
+
alignItems: "center",
|
|
3515
|
+
justifyContent: "center",
|
|
3516
|
+
backgroundColor: isStylePanelOpen ? "#FF6800" : "white",
|
|
3517
|
+
border: "none",
|
|
3518
|
+
borderRadius: 12,
|
|
3519
|
+
boxShadow: "0 2px 10px rgba(0,0,0,0.15)",
|
|
3520
|
+
cursor: "pointer",
|
|
3521
|
+
pointerEvents: "auto",
|
|
3522
|
+
zIndex: zIndex + 5,
|
|
3523
|
+
transition: "all 0.2s ease"
|
|
3524
|
+
},
|
|
3525
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
3526
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3527
|
+
"path",
|
|
3528
|
+
{
|
|
3529
|
+
d: "M12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15Z",
|
|
3530
|
+
stroke: isStylePanelOpen ? "white" : "#6B7280",
|
|
3531
|
+
strokeWidth: "2",
|
|
3532
|
+
strokeLinecap: "round",
|
|
3533
|
+
strokeLinejoin: "round"
|
|
3534
|
+
}
|
|
3535
|
+
),
|
|
3536
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3537
|
+
"path",
|
|
3538
|
+
{
|
|
3539
|
+
d: "M19.4 15C19.2669 15.3016 19.2272 15.6362 19.286 15.9606C19.3448 16.285 19.4995 16.5843 19.73 16.82L19.79 16.88C19.976 17.0657 20.1235 17.2863 20.2241 17.5291C20.3248 17.7719 20.3766 18.0322 20.3766 18.295C20.3766 18.5578 20.3248 18.8181 20.2241 19.0609C20.1235 19.3037 19.976 19.5243 19.79 19.71C19.6043 19.896 19.3837 20.0435 19.1409 20.1441C18.8981 20.2448 18.6378 20.2966 18.375 20.2966C18.1122 20.2966 17.8519 20.2448 17.6091 20.1441C17.3663 20.0435 17.1457 19.896 16.96 19.71L16.9 19.65C16.6643 19.4195 16.365 19.2648 16.0406 19.206C15.7162 19.1472 15.3816 19.1869 15.08 19.32C14.7842 19.4468 14.532 19.6572 14.3543 19.9255C14.1766 20.1938 14.0813 20.5082 14.08 20.83V21C14.08 21.5304 13.8693 22.0391 13.4942 22.4142C13.1191 22.7893 12.6104 23 12.08 23C11.5496 23 11.0409 22.7893 10.6658 22.4142C10.2907 22.0391 10.08 21.5304 10.08 21V20.91C10.0723 20.579 9.96512 20.258 9.77251 19.9887C9.5799 19.7194 9.31074 19.5143 9 19.4C8.69838 19.2669 8.36381 19.2272 8.03941 19.286C7.71502 19.3448 7.41568 19.4995 7.18 19.73L7.12 19.79C6.93425 19.976 6.71368 20.1235 6.47088 20.2241C6.22808 20.3248 5.96783 20.3766 5.705 20.3766C5.44217 20.3766 5.18192 20.3248 4.93912 20.2241C4.69632 20.1235 4.47575 19.976 4.29 19.79C4.10405 19.6043 3.95653 19.3837 3.85588 19.1409C3.75523 18.8981 3.70343 18.6378 3.70343 18.375C3.70343 18.1122 3.75523 17.8519 3.85588 17.6091C3.95653 17.3663 4.10405 17.1457 4.29 16.96L4.35 16.9C4.58054 16.6643 4.73519 16.365 4.794 16.0406C4.85282 15.7162 4.81312 15.3816 4.68 15.08C4.55324 14.7842 4.34276 14.532 4.07447 14.3543C3.80618 14.1766 3.49179 14.0813 3.17 14.08H3C2.46957 14.08 1.96086 13.8693 1.58579 13.4942C1.21071 13.1191 1 12.6104 1 12.08C1 11.5496 1.21071 11.0409 1.58579 10.6658C1.96086 10.2907 2.46957 10.08 3 10.08H3.09C3.42099 10.0723 3.742 9.96512 4.0113 9.77251C4.28059 9.5799 4.48572 9.31074 4.6 9C4.73312 8.69838 4.77282 8.36381 4.714 8.03941C4.65519 7.71502 4.50054 7.41568 4.27 7.18L4.21 7.12C4.02405 6.93425 3.87653 6.71368 3.77588 6.47088C3.67523 6.22808 3.62343 5.96783 3.62343 5.705C3.62343 5.44217 3.67523 5.18192 3.77588 4.93912C3.87653 4.69632 4.02405 4.47575 4.21 4.29C4.39575 4.10405 4.61632 3.95653 4.85912 3.85588C5.10192 3.75523 5.36217 3.70343 5.625 3.70343C5.88783 3.70343 6.14808 3.75523 6.39088 3.85588C6.63368 3.95653 6.85425 4.10405 7.04 4.29L7.1 4.35C7.33568 4.58054 7.63502 4.73519 7.95941 4.794C8.28381 4.85282 8.61838 4.81312 8.92 4.68H9C9.29577 4.55324 9.54802 4.34276 9.72569 4.07447C9.90337 3.80618 9.99872 3.49179 10 3.17V3C10 2.46957 10.2107 1.96086 10.5858 1.58579C10.9609 1.21071 11.4696 1 12 1C12.5304 1 13.0391 1.21071 13.4142 1.58579C13.7893 1.96086 14 2.46957 14 3V3.09C14.0013 3.41179 14.0966 3.72618 14.2743 3.99447C14.452 4.26276 14.7042 4.47324 15 4.6C15.3016 4.73312 15.6362 4.77282 15.9606 4.714C16.285 4.65519 16.5843 4.50054 16.82 4.27L16.88 4.21C17.0657 4.02405 17.2863 3.87653 17.5291 3.77588C17.7719 3.67523 18.0322 3.62343 18.295 3.62343C18.5578 3.62343 18.8181 3.67523 19.0609 3.77588C19.3037 3.87653 19.5243 4.02405 19.71 4.21C19.896 4.39575 20.0435 4.61632 20.1441 4.85912C20.2448 5.10192 20.2966 5.36217 20.2966 5.625C20.2966 5.88783 20.2448 6.14808 20.1441 6.39088C20.0435 6.63368 19.896 6.85425 19.71 7.04L19.65 7.1C19.4195 7.33568 19.2648 7.63502 19.206 7.95941C19.1472 8.28381 19.1869 8.61838 19.32 8.92V9C19.4468 9.29577 19.6572 9.54802 19.9255 9.72569C20.1938 9.90337 20.5082 9.99872 20.83 10H21C21.5304 10 22.0391 10.2107 22.4142 10.5858C22.7893 10.9609 23 11.4696 23 12C23 12.5304 22.7893 13.0391 22.4142 13.4142C22.0391 13.7893 21.5304 14 21 14H20.91C20.5882 14.0013 20.2738 14.0966 20.0055 14.2743C19.7372 14.452 19.5268 14.7042 19.4 15Z",
|
|
3540
|
+
stroke: isStylePanelOpen ? "white" : "#6B7280",
|
|
3541
|
+
strokeWidth: "2",
|
|
3542
|
+
strokeLinecap: "round",
|
|
3543
|
+
strokeLinejoin: "round"
|
|
3544
|
+
}
|
|
3545
|
+
)
|
|
3546
|
+
] })
|
|
3547
|
+
}
|
|
3548
|
+
),
|
|
3182
3549
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3183
3550
|
"div",
|
|
3184
3551
|
{
|
|
@@ -3197,7 +3564,13 @@ var Skema = ({
|
|
|
3197
3564
|
hideUi: false,
|
|
3198
3565
|
inferDarkMode: false,
|
|
3199
3566
|
options: { maxPages: 1 },
|
|
3200
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3567
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3568
|
+
SkemaToolbar,
|
|
3569
|
+
{
|
|
3570
|
+
onExpandedChange: setIsToolbarExpanded,
|
|
3571
|
+
onStylePanelChange: setIsStylePanelOpen
|
|
3572
|
+
}
|
|
3573
|
+
)
|
|
3201
3574
|
}
|
|
3202
3575
|
)
|
|
3203
3576
|
}
|