@edv4h/usketch-plugin-shape-frame 1.0.0 → 3.0.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.
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +138 -135
- package/dist/plugin.js.map +1 -1
- package/dist/shapes/frame.d.ts +3 -2
- package/dist/shapes/frame.d.ts.map +1 -1
- package/dist/shapes/frame.js +2 -1
- package/dist/shapes/frame.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createFramePlugin } from "./plugin.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/plugin.d.ts
CHANGED
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAKX,aAAa,EACb,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAKX,aAAa,EACb,MAAM,uBAAuB,CAAC;AAiE/B,wBAAgB,iBAAiB,IAAI,aAAa,CAwJjD"}
|
package/dist/plugin.js
CHANGED
|
@@ -7,7 +7,8 @@ import { createDefaultFrame, getBoundsFrame, hitTestFrame, renderFrame, resizeFr
|
|
|
7
7
|
* Frames are containers, so they mostly need to show where they are.
|
|
8
8
|
*/
|
|
9
9
|
function SimplifiedFrame({ shape }) {
|
|
10
|
-
const
|
|
10
|
+
const data = shape;
|
|
11
|
+
const label = data.name || data.frameTitle || "Frame";
|
|
11
12
|
const rotation = typeof shape.rotation === "number" ? shape.rotation : 0;
|
|
12
13
|
return (_jsx("div", { style: {
|
|
13
14
|
position: "absolute",
|
|
@@ -34,145 +35,147 @@ function SimplifiedFrame({ shape }) {
|
|
|
34
35
|
function FrameIcon() {
|
|
35
36
|
return (_jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", children: [_jsx("line", { x1: "7", y1: "2", x2: "7", y2: "18", strokeWidth: "1.5", strokeLinecap: "round" }), _jsx("line", { x1: "13", y1: "2", x2: "13", y2: "18", strokeWidth: "1.5", strokeLinecap: "round" }), _jsx("line", { x1: "2", y1: "7", x2: "18", y2: "7", strokeWidth: "1.5", strokeLinecap: "round" }), _jsx("line", { x1: "2", y1: "13", x2: "18", y2: "13", strokeWidth: "1.5", strokeLinecap: "round" })] }));
|
|
36
37
|
}
|
|
37
|
-
export
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
function onPointerMove(toolCtx, event) {
|
|
67
|
-
if (!drawState)
|
|
68
|
-
return;
|
|
69
|
-
const x = Math.min(drawState.startX, event.worldPoint.x);
|
|
70
|
-
const y = Math.min(drawState.startY, event.worldPoint.y);
|
|
71
|
-
const width = Math.abs(event.worldPoint.x - drawState.startX);
|
|
72
|
-
const height = Math.abs(event.worldPoint.y - drawState.startY);
|
|
73
|
-
toolCtx.store.updateShape(drawState.shapeId, { x, y, width, height });
|
|
74
|
-
}
|
|
75
|
-
function onPointerUp(toolCtx) {
|
|
76
|
-
if (!drawState)
|
|
77
|
-
return;
|
|
78
|
-
const shape = toolCtx.store.getShape(drawState.shapeId);
|
|
79
|
-
if (shape && shape.width > 10 && shape.height > 10) {
|
|
80
|
-
toolCtx.store.deleteShape(drawState.shapeId);
|
|
81
|
-
toolCtx.commands.execute(createAddShapeCommand(toolCtx.store, shape));
|
|
38
|
+
export function createFramePlugin() {
|
|
39
|
+
return {
|
|
40
|
+
id: "usketch-plugin-shape-frame",
|
|
41
|
+
name: "フレーム",
|
|
42
|
+
setup(ctx) {
|
|
43
|
+
// Register the "frame" shape type
|
|
44
|
+
ctx.shapes.register("frame", {
|
|
45
|
+
render: renderFrame,
|
|
46
|
+
getBounds: getBoundsFrame,
|
|
47
|
+
hitTest: hitTestFrame,
|
|
48
|
+
resize: resizeFrame,
|
|
49
|
+
createDefault: createDefaultFrame,
|
|
50
|
+
renderTarget: "html",
|
|
51
|
+
minSize: { width: 50, height: 50 },
|
|
52
|
+
simplifiedComponent: SimplifiedFrame,
|
|
53
|
+
});
|
|
54
|
+
// Drawing tool state
|
|
55
|
+
let drawState = null;
|
|
56
|
+
function onPointerDown(toolCtx, event) {
|
|
57
|
+
const id = generateId();
|
|
58
|
+
drawState = { startX: event.worldPoint.x, startY: event.worldPoint.y, shapeId: id };
|
|
59
|
+
const shape = createDefaultFrame({ id, x: event.worldPoint.x, y: event.worldPoint.y });
|
|
60
|
+
shape.width = 0;
|
|
61
|
+
shape.height = 0;
|
|
62
|
+
shape.style = {
|
|
63
|
+
...shape.style,
|
|
64
|
+
stroke: toolCtx.store.getStyleSettings().stroke,
|
|
65
|
+
};
|
|
66
|
+
toolCtx.store.addShape(shape);
|
|
82
67
|
}
|
|
83
|
-
|
|
84
|
-
|
|
68
|
+
function onPointerMove(toolCtx, event) {
|
|
69
|
+
if (!drawState)
|
|
70
|
+
return;
|
|
71
|
+
const x = Math.min(drawState.startX, event.worldPoint.x);
|
|
72
|
+
const y = Math.min(drawState.startY, event.worldPoint.y);
|
|
73
|
+
const width = Math.abs(event.worldPoint.x - drawState.startX);
|
|
74
|
+
const height = Math.abs(event.worldPoint.y - drawState.startY);
|
|
75
|
+
toolCtx.store.updateShape(drawState.shapeId, { x, y, width, height });
|
|
85
76
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
order: 11,
|
|
94
|
-
onPointerDown,
|
|
95
|
-
onPointerMove,
|
|
96
|
-
onPointerUp,
|
|
97
|
-
onDeactivate() {
|
|
98
|
-
if (drawState) {
|
|
99
|
-
ctx.store.deleteShape(drawState.shapeId);
|
|
100
|
-
drawState = null;
|
|
77
|
+
function onPointerUp(toolCtx) {
|
|
78
|
+
if (!drawState)
|
|
79
|
+
return;
|
|
80
|
+
const shape = toolCtx.store.getShape(drawState.shapeId);
|
|
81
|
+
if (shape && shape.width > 10 && shape.height > 10) {
|
|
82
|
+
toolCtx.store.deleteShape(drawState.shapeId);
|
|
83
|
+
toolCtx.commands.execute(createAddShapeCommand(toolCtx.store, shape));
|
|
101
84
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
// ── Auto-parenting ──
|
|
105
|
-
// On move-end: reparent moved shapes (emitted by select tool after move command commits).
|
|
106
|
-
// Use setTimeout to defer reparent until after React finishes the current render cycle,
|
|
107
|
-
// since the emit happens inside a queueMicrotask from the select tool.
|
|
108
|
-
const unsubMoveEnd = ctx.events.on("shapes:move-end", (data) => {
|
|
109
|
-
if (!data?.shapeIds)
|
|
110
|
-
return;
|
|
111
|
-
setTimeout(() => {
|
|
112
|
-
for (const shapeId of data.shapeIds) {
|
|
113
|
-
autoReparent(shapeId);
|
|
85
|
+
else {
|
|
86
|
+
toolCtx.store.deleteShape(drawState.shapeId);
|
|
114
87
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
//
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
88
|
+
drawState = null;
|
|
89
|
+
toolCtx.store.setActiveToolId("select");
|
|
90
|
+
}
|
|
91
|
+
ctx.tools.register("frame-draw", {
|
|
92
|
+
icon: FrameIcon,
|
|
93
|
+
cursor: "crosshair",
|
|
94
|
+
shortcut: "f",
|
|
95
|
+
order: 11,
|
|
96
|
+
onPointerDown,
|
|
97
|
+
onPointerMove,
|
|
98
|
+
onPointerUp,
|
|
99
|
+
onDeactivate() {
|
|
100
|
+
if (drawState) {
|
|
101
|
+
ctx.store.deleteShape(drawState.shapeId);
|
|
102
|
+
drawState = null;
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
// ── Auto-parenting ──
|
|
107
|
+
// On move-end: reparent moved shapes (emitted by select tool after move command commits).
|
|
108
|
+
// Use setTimeout to defer reparent until after React finishes the current render cycle,
|
|
109
|
+
// since the emit happens inside a queueMicrotask from the select tool.
|
|
110
|
+
const unsubMoveEnd = ctx.events.on("shapes:move-end", (data) => {
|
|
111
|
+
if (!data?.shapeIds)
|
|
112
|
+
return;
|
|
113
|
+
setTimeout(() => {
|
|
114
|
+
for (const shapeId of data.shapeIds) {
|
|
115
|
+
autoReparent(shapeId);
|
|
116
|
+
}
|
|
117
|
+
}, 0);
|
|
118
|
+
});
|
|
119
|
+
// On shape:added (e.g. drawing inside a frame)
|
|
120
|
+
const unsubAdded = ctx.store.onMutation((event) => {
|
|
121
|
+
if (event.type !== "shape:added")
|
|
122
|
+
return;
|
|
123
|
+
const payload = event.payload;
|
|
124
|
+
if (!payload?.id)
|
|
125
|
+
return;
|
|
126
|
+
const shape = ctx.store.getShape(payload.id);
|
|
127
|
+
if (!shape || shape.type === "frame" || shape.type === "connector")
|
|
128
|
+
return;
|
|
129
|
+
autoReparent(payload.id);
|
|
130
|
+
});
|
|
131
|
+
function autoReparent(shapeId) {
|
|
132
|
+
const shape = ctx.store.getShape(shapeId);
|
|
133
|
+
if (!shape || shape.type === "frame" || shape.type === "connector")
|
|
134
|
+
return;
|
|
135
|
+
const shapeBounds = { x: shape.x, y: shape.y, width: shape.width, height: shape.height };
|
|
136
|
+
// Find the smallest frame that fully contains this shape
|
|
137
|
+
let bestFrame = null;
|
|
138
|
+
for (const [id, candidate] of ctx.store.getShapes()) {
|
|
139
|
+
if (id === shapeId || candidate.type !== "frame")
|
|
140
|
+
continue;
|
|
141
|
+
const frameBounds = {
|
|
142
|
+
x: candidate.x,
|
|
143
|
+
y: candidate.y,
|
|
144
|
+
width: candidate.width,
|
|
145
|
+
height: candidate.height,
|
|
146
|
+
};
|
|
147
|
+
if (containsAABB(frameBounds, shapeBounds)) {
|
|
148
|
+
if (!bestFrame ||
|
|
149
|
+
candidate.width * candidate.height < bestFrame.width * bestFrame.height) {
|
|
150
|
+
bestFrame = candidate;
|
|
151
|
+
}
|
|
149
152
|
}
|
|
150
153
|
}
|
|
154
|
+
const currentParentId = shape.parentId;
|
|
155
|
+
const newParentId = bestFrame?.id;
|
|
156
|
+
if (currentParentId !== newParentId) {
|
|
157
|
+
ctx.commands.execute(createReparentCommand(ctx.store, [shapeId], newParentId ?? undefined));
|
|
158
|
+
}
|
|
151
159
|
}
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
unsubAdded();
|
|
174
|
-
unsubMove();
|
|
175
|
-
};
|
|
176
|
-
},
|
|
177
|
-
};
|
|
160
|
+
// ── Frame move: move all children along with the frame ──
|
|
161
|
+
const unsubMove = ctx.store.onMutation((event) => {
|
|
162
|
+
if (event.type !== "shape:updated")
|
|
163
|
+
return;
|
|
164
|
+
const payload = event.payload;
|
|
165
|
+
if (!payload?.id)
|
|
166
|
+
return;
|
|
167
|
+
const shape = ctx.store.getShape(payload.id);
|
|
168
|
+
if (!shape || shape.type !== "frame")
|
|
169
|
+
return;
|
|
170
|
+
// This is handled by the select tool which includes children in snapshots
|
|
171
|
+
// when moving a frame. No additional logic needed here.
|
|
172
|
+
});
|
|
173
|
+
return () => {
|
|
174
|
+
unsubMoveEnd();
|
|
175
|
+
unsubAdded();
|
|
176
|
+
unsubMove();
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
}
|
|
178
181
|
//# sourceMappingURL=plugin.js.map
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,EACN,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,WAAW,EACX,WAAW,GACX,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,EACN,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,WAAW,EACX,WAAW,GACX,MAAM,mBAAmB,CAAC;AAG3B;;;GAGG;AACH,SAAS,eAAe,CAAC,EAAE,KAAK,EAAwB;IACvD,MAAM,IAAI,GAAG,KAAuB,CAAC;IACrC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,IAAI,OAAO,CAAC;IACtD,MAAM,QAAQ,GAAG,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACzE,OAAO,CACN,cACC,KAAK,EAAE;YACN,QAAQ,EAAE,UAAU;YACpB,IAAI,EAAE,KAAK,CAAC,CAAC;YACb,GAAG,EAAE,KAAK,CAAC,CAAC;YACZ,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,MAAM,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KAAK,GAAG,SAAS,CAAC,MAAM,EACtE,CAAC;4BACF,SAAS,GAAG,SAAS,CAAC;wBACvB,CAAC;oBACF,CAAC;gBACF,CAAC;gBAED,MAAM,eAAe,GAAG,KAAK,CAAC,QAA8B,CAAC;gBAC7D,MAAM,WAAW,GAAG,SAAS,EAAE,EAAE,CAAC;gBAElC,IAAI,eAAe,KAAK,WAAW,EAAE,CAAC;oBACrC,GAAG,CAAC,QAAQ,CAAC,OAAO,CACnB,qBAAqB,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,WAAW,IAAI,SAAS,CAAC,CACrE,CAAC;gBACH,CAAC;YACF,CAAC;YAED,2DAA2D;YAC3D,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,EAAE;gBAChD,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe;oBAAE,OAAO;gBAC3C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAqC,CAAC;gBAC5D,IAAI,CAAC,OAAO,EAAE,EAAE;oBAAE,OAAO;gBAEzB,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;gBAC7C,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;oBAAE,OAAO;gBAE7C,0EAA0E;gBAC1E,wDAAwD;YACzD,CAAC,CAAC,CAAC;YAEH,OAAO,GAAG,EAAE;gBACX,YAAY,EAAE,CAAC;gBACf,UAAU,EAAE,CAAC;gBACb,SAAS,EAAE,CAAC;YACb,CAAC,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC"}
|
package/dist/shapes/frame.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BoundingBox, Point, ShapeData } from "@edv4h/usketch-shared";
|
|
2
|
-
|
|
2
|
+
import type { FrameShapeData } from "../types.js";
|
|
3
|
+
export declare function renderFrame(shape: ShapeData): import("react/jsx-runtime").JSX.Element;
|
|
3
4
|
export declare function getBoundsFrame(data: ShapeData): BoundingBox;
|
|
4
5
|
export declare function hitTestFrame(data: ShapeData, point: Point): boolean;
|
|
5
6
|
export declare function resizeFrame(data: ShapeData, handle: string, delta: Point): ShapeData;
|
|
@@ -7,5 +8,5 @@ export declare function createDefaultFrame(params: {
|
|
|
7
8
|
id: string;
|
|
8
9
|
x: number;
|
|
9
10
|
y: number;
|
|
10
|
-
}):
|
|
11
|
+
}): FrameShapeData;
|
|
11
12
|
//# sourceMappingURL=frame.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../src/shapes/frame.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../src/shapes/frame.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIlD,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,2CA2C3C;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,GAAG,WAAW,CAE3D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAiBnE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,SAAS,CAuBpF;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,cAAc,CAW/F"}
|
package/dist/shapes/frame.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
const TITLE_HEIGHT = 24;
|
|
3
|
-
export function renderFrame(
|
|
3
|
+
export function renderFrame(shape) {
|
|
4
|
+
const data = shape;
|
|
4
5
|
const title = data.frameTitle ?? "Frame";
|
|
5
6
|
const bgColor = data.style.fill === "transparent" ? "#f8f8f8" : data.style.fill;
|
|
6
7
|
// Position/size is handled by ShapeWrapper (position: absolute; left/top/width/height).
|
package/dist/shapes/frame.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame.js","sourceRoot":"","sources":["../../src/shapes/frame.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"frame.js","sourceRoot":"","sources":["../../src/shapes/frame.tsx"],"names":[],"mappings":";AAGA,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,MAAM,UAAU,WAAW,CAAC,KAAgB;IAC3C,MAAM,IAAI,GAAG,KAAuB,CAAC;IACrC,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,IAAI,OAAO,CAAC;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IAEhF,wFAAwF;IACxF,2EAA2E;IAC3E,OAAO,CACN,8BAEC,cACC,KAAK,EAAE;oBACN,SAAS,EAAE,CAAC,YAAY;oBACxB,MAAM,EAAE,YAAY;oBACpB,OAAO,EAAE,MAAM;oBACf,UAAU,EAAE,QAAQ;oBACpB,WAAW,EAAE,CAAC;oBACd,QAAQ,EAAE,EAAE;oBACZ,UAAU,EAAE,uBAAuB;oBACnC,KAAK,EAAE,MAAM;oBACb,UAAU,EAAE,MAAM;oBAClB,UAAU,EAAE,QAAQ;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,MAAM,GAAG,SAAS,CAAC;IAC3B,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAA4C;IAC9E,OAAO;QACN,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,IAAI,EAAE,OAAO;QACb,CAAC,EAAE,MAAM,CAAC,CAAC;QACX,CAAC,EAAE,MAAM,CAAC,CAAC;QACX,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;QACX,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE;QACzE,UAAU,EAAE,OAAO;KACnB,CAAC;AACH,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,mEAAmE;AACnE,MAAM,WAAW,cAAe,SAAQ,SAAS;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edv4h/usketch-plugin-shape-frame",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@edv4h/usketch-core": "
|
|
16
|
-
"@edv4h/usketch-shared": "
|
|
17
|
-
"@edv4h/usketch-store": "
|
|
15
|
+
"@edv4h/usketch-core": "2.0.0",
|
|
16
|
+
"@edv4h/usketch-shared": "3.0.0",
|
|
17
|
+
"@edv4h/usketch-store": "2.0.1"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"react": ">=19"
|