@retikz/react 0.1.0-alpha.2 → 0.1.0-alpha.4
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/es/index.d.ts +5 -5
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +3 -1
- package/dist/es/kernel/Coordinate.d.ts +23 -0
- package/dist/es/kernel/Coordinate.d.ts.map +1 -0
- package/dist/es/kernel/Coordinate.js +13 -0
- package/dist/es/kernel/Node.d.ts +16 -3
- package/dist/es/kernel/Node.d.ts.map +1 -1
- package/dist/es/kernel/Path.d.ts +12 -0
- package/dist/es/kernel/Path.d.ts.map +1 -1
- package/dist/es/kernel/Step.d.ts +86 -3
- package/dist/es/kernel/Step.d.ts.map +1 -1
- package/dist/es/kernel/Tikz.d.ts +6 -0
- package/dist/es/kernel/Tikz.d.ts.map +1 -1
- package/dist/es/kernel/Tikz.js +6 -2
- package/dist/es/kernel/_builder.d.ts.map +1 -1
- package/dist/es/kernel/_builder.js +135 -15
- package/dist/es/kernel/_displayNames.d.ts +4 -0
- package/dist/es/kernel/_displayNames.d.ts.map +1 -1
- package/dist/es/kernel/_displayNames.js +5 -1
- package/dist/es/kernel/_unbuilder.d.ts.map +1 -1
- package/dist/es/kernel/_unbuilder.js +65 -1
- package/dist/es/kernel/index.d.ts +1 -0
- package/dist/es/kernel/index.d.ts.map +1 -1
- package/dist/es/kernel/index.js +1 -0
- package/dist/es/sugar/Draw.d.ts +20 -2
- package/dist/es/sugar/Draw.d.ts.map +1 -1
- package/dist/es/sugar/Draw.js +57 -3
- package/dist/es/sugar/EdgeLabel.d.ts +20 -0
- package/dist/es/sugar/EdgeLabel.d.ts.map +1 -0
- package/dist/es/sugar/EdgeLabel.js +13 -0
- package/dist/es/sugar/index.d.ts +1 -0
- package/dist/es/sugar/index.d.ts.map +1 -1
- package/dist/es/sugar/index.js +1 -0
- package/dist/lib/index.cjs +4 -0
- package/dist/lib/index.d.ts +5 -5
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/kernel/Coordinate.cjs +13 -0
- package/dist/lib/kernel/Coordinate.d.ts +23 -0
- package/dist/lib/kernel/Coordinate.d.ts.map +1 -0
- package/dist/lib/kernel/Node.d.ts +16 -3
- package/dist/lib/kernel/Node.d.ts.map +1 -1
- package/dist/lib/kernel/Path.d.ts +12 -0
- package/dist/lib/kernel/Path.d.ts.map +1 -1
- package/dist/lib/kernel/Step.d.ts +86 -3
- package/dist/lib/kernel/Step.d.ts.map +1 -1
- package/dist/lib/kernel/Tikz.cjs +6 -2
- package/dist/lib/kernel/Tikz.d.ts +6 -0
- package/dist/lib/kernel/Tikz.d.ts.map +1 -1
- package/dist/lib/kernel/_builder.cjs +133 -13
- package/dist/lib/kernel/_builder.d.ts.map +1 -1
- package/dist/lib/kernel/_displayNames.cjs +6 -0
- package/dist/lib/kernel/_displayNames.d.ts +4 -0
- package/dist/lib/kernel/_displayNames.d.ts.map +1 -1
- package/dist/lib/kernel/_unbuilder.cjs +65 -1
- package/dist/lib/kernel/_unbuilder.d.ts.map +1 -1
- package/dist/lib/kernel/index.cjs +1 -0
- package/dist/lib/kernel/index.d.ts +1 -0
- package/dist/lib/kernel/index.d.ts.map +1 -1
- package/dist/lib/sugar/Draw.cjs +57 -3
- package/dist/lib/sugar/Draw.d.ts +20 -2
- package/dist/lib/sugar/Draw.d.ts.map +1 -1
- package/dist/lib/sugar/EdgeLabel.cjs +13 -0
- package/dist/lib/sugar/EdgeLabel.d.ts +20 -0
- package/dist/lib/sugar/EdgeLabel.d.ts.map +1 -0
- package/dist/lib/sugar/index.cjs +1 -0
- package/dist/lib/sugar/index.d.ts +1 -0
- package/dist/lib/sugar/index.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tikz.d.ts","sourceRoot":"","sources":["../../../src/kernel/Tikz.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,EA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AAC;AAgBF;;;;;;;;;GASG;AACH,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CA2B9B,CAAC"}
|
|
@@ -102,9 +102,37 @@ var buildNode = (props) => ({
|
|
|
102
102
|
outerSep: props.outerSep,
|
|
103
103
|
padding: props.padding,
|
|
104
104
|
margin: props.margin,
|
|
105
|
-
font: props.font
|
|
105
|
+
font: props.font,
|
|
106
|
+
label: props.label
|
|
106
107
|
});
|
|
107
108
|
/**
|
|
109
|
+
* 扫描 Step children,把首个 <EdgeLabel> 翻译为 IRStepLabel;
|
|
110
|
+
* 非字符串 children 静默跳过;多个 <EdgeLabel> 取首个。
|
|
111
|
+
*/
|
|
112
|
+
var readEdgeLabel = (children) => {
|
|
113
|
+
let result;
|
|
114
|
+
react.Children.forEach(children, (child) => {
|
|
115
|
+
if (result !== void 0) return;
|
|
116
|
+
if (!(0, react.isValidElement)(child)) return;
|
|
117
|
+
if (getDisplayName(child) !== "@retikz/EdgeLabel") return;
|
|
118
|
+
const props = child.props;
|
|
119
|
+
if (typeof props.children !== "string") return;
|
|
120
|
+
const out = { text: props.children };
|
|
121
|
+
if (props.position !== void 0) out.position = props.position;
|
|
122
|
+
if (props.side !== void 0) out.side = props.side;
|
|
123
|
+
result = out;
|
|
124
|
+
});
|
|
125
|
+
return result;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* 解析 Step 的 label 来源:prop `label` 优先于 sugar `<EdgeLabel>` child;
|
|
129
|
+
* 都缺省时返回 undefined。
|
|
130
|
+
*/
|
|
131
|
+
var resolveStepLabel = (props) => {
|
|
132
|
+
if (props.label !== void 0) return props.label;
|
|
133
|
+
return readEdgeLabel(props.children);
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
108
136
|
* 扫描 <Path> children 收集 <Step> 序列。
|
|
109
137
|
* 至少 2 段;首段不是 move 时强制改为 move(与 SVG path 的 "M …" 语义对齐);
|
|
110
138
|
* cycle 没有 to 字段,若用户把 cycle 放在首段,coerce 时降级到 move (0,0)。
|
|
@@ -123,46 +151,135 @@ var readPathChildren = (children) => {
|
|
|
123
151
|
});
|
|
124
152
|
return;
|
|
125
153
|
}
|
|
154
|
+
const label = kind === "move" ? void 0 : resolveStepLabel(props);
|
|
126
155
|
if (kind === "step") {
|
|
127
|
-
|
|
156
|
+
const step = {
|
|
128
157
|
type: "step",
|
|
129
158
|
kind: "step",
|
|
130
159
|
via: props.via,
|
|
131
|
-
to: props.to
|
|
160
|
+
to: (0, _retikz_core.parseTargetSugar)(props.to)
|
|
161
|
+
};
|
|
162
|
+
if (label) step.label = label;
|
|
163
|
+
out.push(step);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (kind === "curve") {
|
|
167
|
+
const step = {
|
|
168
|
+
type: "step",
|
|
169
|
+
kind: "curve",
|
|
170
|
+
to: (0, _retikz_core.parseTargetSugar)(props.to),
|
|
171
|
+
control: props.control
|
|
172
|
+
};
|
|
173
|
+
if (label) step.label = label;
|
|
174
|
+
out.push(step);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (kind === "cubic") {
|
|
178
|
+
const step = {
|
|
179
|
+
type: "step",
|
|
180
|
+
kind: "cubic",
|
|
181
|
+
to: (0, _retikz_core.parseTargetSugar)(props.to),
|
|
182
|
+
control1: props.control1,
|
|
183
|
+
control2: props.control2
|
|
184
|
+
};
|
|
185
|
+
if (label) step.label = label;
|
|
186
|
+
out.push(step);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (kind === "bend") {
|
|
190
|
+
const step = {
|
|
191
|
+
type: "step",
|
|
192
|
+
kind: "bend",
|
|
193
|
+
to: (0, _retikz_core.parseTargetSugar)(props.to),
|
|
194
|
+
bendDirection: props.bendDirection
|
|
195
|
+
};
|
|
196
|
+
if (props.bendAngle !== void 0) step.bendAngle = props.bendAngle;
|
|
197
|
+
if (label) step.label = label;
|
|
198
|
+
out.push(step);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if (kind === "arc") {
|
|
202
|
+
const step = {
|
|
203
|
+
type: "step",
|
|
204
|
+
kind: "arc",
|
|
205
|
+
startAngle: props.startAngle,
|
|
206
|
+
endAngle: props.endAngle,
|
|
207
|
+
radius: props.radius
|
|
208
|
+
};
|
|
209
|
+
if (label) step.label = label;
|
|
210
|
+
out.push(step);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (kind === "circlePath") {
|
|
214
|
+
const step = {
|
|
215
|
+
type: "step",
|
|
216
|
+
kind: "circlePath",
|
|
217
|
+
radius: props.radius
|
|
218
|
+
};
|
|
219
|
+
if (label) step.label = label;
|
|
220
|
+
out.push(step);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (kind === "ellipsePath") {
|
|
224
|
+
const step = {
|
|
225
|
+
type: "step",
|
|
226
|
+
kind: "ellipsePath",
|
|
227
|
+
radiusX: props.radiusX,
|
|
228
|
+
radiusY: props.radiusY
|
|
229
|
+
};
|
|
230
|
+
if (label) step.label = label;
|
|
231
|
+
out.push(step);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (kind === "move") {
|
|
235
|
+
out.push({
|
|
236
|
+
type: "step",
|
|
237
|
+
kind: "move",
|
|
238
|
+
to: (0, _retikz_core.parseTargetSugar)(props.to)
|
|
132
239
|
});
|
|
133
240
|
return;
|
|
134
241
|
}
|
|
135
|
-
|
|
242
|
+
const step = {
|
|
136
243
|
type: "step",
|
|
137
|
-
kind,
|
|
138
|
-
to: props.to
|
|
139
|
-
}
|
|
244
|
+
kind: "line",
|
|
245
|
+
to: (0, _retikz_core.parseTargetSugar)(props.to)
|
|
246
|
+
};
|
|
247
|
+
if (label) step.label = label;
|
|
248
|
+
out.push(step);
|
|
140
249
|
});
|
|
141
250
|
if (out.length < 2) throw new Error("<Path> requires at least 2 <Step> children");
|
|
142
251
|
if (out[0].kind !== "move") {
|
|
143
252
|
const first = out[0];
|
|
144
|
-
out[0] =
|
|
253
|
+
out[0] = {
|
|
145
254
|
type: "step",
|
|
146
255
|
kind: "move",
|
|
147
|
-
to: [0, 0]
|
|
148
|
-
} : {
|
|
149
|
-
type: "step",
|
|
150
|
-
kind: "move",
|
|
151
|
-
to: first.to
|
|
256
|
+
to: first.kind === "cycle" || first.kind === "arc" || first.kind === "circlePath" || first.kind === "ellipsePath" ? [0, 0] : first.to
|
|
152
257
|
};
|
|
153
258
|
}
|
|
154
259
|
return out;
|
|
155
260
|
};
|
|
261
|
+
/** 把 <Coordinate> props 翻成 IRChild(占位节点,无视觉) */
|
|
262
|
+
var buildCoordinate = (props) => ({
|
|
263
|
+
type: "coordinate",
|
|
264
|
+
id: props.id,
|
|
265
|
+
position: props.position
|
|
266
|
+
});
|
|
156
267
|
/** 把 <Path> props 翻成 IRChild;step 序列由 readPathChildren 收集 */
|
|
157
268
|
var buildPath = (props) => ({
|
|
158
269
|
type: "path",
|
|
159
270
|
stroke: props.stroke,
|
|
160
271
|
strokeWidth: props.strokeWidth,
|
|
161
272
|
strokeDasharray: props.strokeDasharray,
|
|
273
|
+
lineCap: props.lineCap,
|
|
274
|
+
lineJoin: props.lineJoin,
|
|
275
|
+
thickness: props.thickness,
|
|
162
276
|
arrow: props.arrow,
|
|
163
277
|
arrowShape: props.arrowShape,
|
|
164
278
|
fill: props.fill,
|
|
165
279
|
fillRule: props.fillRule,
|
|
280
|
+
opacity: props.opacity,
|
|
281
|
+
fillOpacity: props.fillOpacity,
|
|
282
|
+
drawOpacity: props.drawOpacity,
|
|
166
283
|
children: readPathChildren(props.children)
|
|
167
284
|
});
|
|
168
285
|
/**
|
|
@@ -183,6 +300,9 @@ var readSceneChildren = (children) => {
|
|
|
183
300
|
case require__displayNames.TIKZ_PATH:
|
|
184
301
|
out.push(buildPath(child.props));
|
|
185
302
|
return;
|
|
303
|
+
case require__displayNames.TIKZ_COORDINATE:
|
|
304
|
+
out.push(buildCoordinate(child.props));
|
|
305
|
+
return;
|
|
186
306
|
}
|
|
187
307
|
if (typeof child.type === "function") {
|
|
188
308
|
const expanded = child.type(child.props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_builder.d.ts","sourceRoot":"","sources":["../../../src/kernel/_builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,SAAS,EAAkB,MAAM,OAAO,CAAC;AACpF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"_builder.d.ts","sourceRoot":"","sources":["../../../src/kernel/_builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,SAAS,EAAkB,MAAM,OAAO,CAAC;AACpF,OAAO,KAAK,EACV,EAAE,EASH,MAAM,cAAc,CAAC;AA8XtB;;;GAGG;AACH,eAAO,MAAM,OAAO,GAAI,UAAU,SAAS,KAAG,EAI5C,CAAC"}
|
|
@@ -7,7 +7,13 @@ var TIKZ_PATH = "@retikz/Path";
|
|
|
7
7
|
var TIKZ_STEP = "@retikz/Step";
|
|
8
8
|
/** <Text> 组件的 displayName(Node 内多行文本带样式) */
|
|
9
9
|
var TIKZ_TEXT = "@retikz/Text";
|
|
10
|
+
/** <EdgeLabel> 组件的 displayName(Step 内边标注) */
|
|
11
|
+
var TIKZ_EDGE_LABEL = "@retikz/EdgeLabel";
|
|
12
|
+
/** <Coordinate> 组件的 displayName(占位节点) */
|
|
13
|
+
var TIKZ_COORDINATE = "@retikz/Coordinate";
|
|
10
14
|
//#endregion
|
|
15
|
+
exports.TIKZ_COORDINATE = TIKZ_COORDINATE;
|
|
16
|
+
exports.TIKZ_EDGE_LABEL = TIKZ_EDGE_LABEL;
|
|
11
17
|
exports.TIKZ_NODE = TIKZ_NODE;
|
|
12
18
|
exports.TIKZ_PATH = TIKZ_PATH;
|
|
13
19
|
exports.TIKZ_STEP = TIKZ_STEP;
|
|
@@ -6,4 +6,8 @@ export declare const TIKZ_PATH = "@retikz/Path";
|
|
|
6
6
|
export declare const TIKZ_STEP = "@retikz/Step";
|
|
7
7
|
/** <Text> 组件的 displayName(Node 内多行文本带样式) */
|
|
8
8
|
export declare const TIKZ_TEXT = "@retikz/Text";
|
|
9
|
+
/** <EdgeLabel> 组件的 displayName(Step 内边标注) */
|
|
10
|
+
export declare const TIKZ_EDGE_LABEL = "@retikz/EdgeLabel";
|
|
11
|
+
/** <Coordinate> 组件的 displayName(占位节点) */
|
|
12
|
+
export declare const TIKZ_COORDINATE = "@retikz/Coordinate";
|
|
9
13
|
//# sourceMappingURL=_displayNames.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_displayNames.d.ts","sourceRoot":"","sources":["../../../src/kernel/_displayNames.ts"],"names":[],"mappings":"AAKA,6BAA6B;AAC7B,eAAO,MAAM,SAAS,iBAAiB,CAAC;AAExC,6BAA6B;AAC7B,eAAO,MAAM,SAAS,iBAAiB,CAAC;AAExC,6BAA6B;AAC7B,eAAO,MAAM,SAAS,iBAAiB,CAAC;AAExC,4CAA4C;AAC5C,eAAO,MAAM,SAAS,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"_displayNames.d.ts","sourceRoot":"","sources":["../../../src/kernel/_displayNames.ts"],"names":[],"mappings":"AAKA,6BAA6B;AAC7B,eAAO,MAAM,SAAS,iBAAiB,CAAC;AAExC,6BAA6B;AAC7B,eAAO,MAAM,SAAS,iBAAiB,CAAC;AAExC,6BAA6B;AAC7B,eAAO,MAAM,SAAS,iBAAiB,CAAC;AAExC,4CAA4C;AAC5C,eAAO,MAAM,SAAS,iBAAiB,CAAC;AAExC,6CAA6C;AAC7C,eAAO,MAAM,eAAe,sBAAsB,CAAC;AAEnD,yCAAyC;AACzC,eAAO,MAAM,eAAe,uBAAuB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_Node = require("./Node.cjs");
|
|
2
2
|
const require_Path = require("./Path.cjs");
|
|
3
3
|
const require_Step = require("./Step.cjs");
|
|
4
|
+
const require_Coordinate = require("./Coordinate.cjs");
|
|
4
5
|
let react = require("react");
|
|
5
6
|
//#region src/kernel/_unbuilder.ts
|
|
6
7
|
/** IR 'node' child → NodeProps;过滤 undefined 字段,不污染 React DevTools 显示 */
|
|
@@ -35,6 +36,7 @@ var nodePropsFromIR = (n) => {
|
|
|
35
36
|
if (n.yScale !== void 0) props.yScale = n.yScale;
|
|
36
37
|
if (n.textColor !== void 0) props.textColor = n.textColor;
|
|
37
38
|
if (n.opacity !== void 0) props.opacity = n.opacity;
|
|
39
|
+
if (n.label !== void 0) props.label = n.label;
|
|
38
40
|
return props;
|
|
39
41
|
};
|
|
40
42
|
/** 单个 IRStep → <Step /> element */
|
|
@@ -47,12 +49,63 @@ var stepToElement = (step, key) => {
|
|
|
47
49
|
key,
|
|
48
50
|
kind: "step",
|
|
49
51
|
via: step.via,
|
|
52
|
+
to: step.to,
|
|
53
|
+
...step.label !== void 0 && { label: step.label }
|
|
54
|
+
});
|
|
55
|
+
if (step.kind === "curve") return (0, react.createElement)(require_Step.Step, {
|
|
56
|
+
key,
|
|
57
|
+
kind: "curve",
|
|
58
|
+
to: step.to,
|
|
59
|
+
control: step.control,
|
|
60
|
+
...step.label !== void 0 && { label: step.label }
|
|
61
|
+
});
|
|
62
|
+
if (step.kind === "cubic") return (0, react.createElement)(require_Step.Step, {
|
|
63
|
+
key,
|
|
64
|
+
kind: "cubic",
|
|
65
|
+
to: step.to,
|
|
66
|
+
control1: step.control1,
|
|
67
|
+
control2: step.control2,
|
|
68
|
+
...step.label !== void 0 && { label: step.label }
|
|
69
|
+
});
|
|
70
|
+
if (step.kind === "bend") return (0, react.createElement)(require_Step.Step, {
|
|
71
|
+
key,
|
|
72
|
+
kind: "bend",
|
|
73
|
+
to: step.to,
|
|
74
|
+
bendDirection: step.bendDirection,
|
|
75
|
+
...step.bendAngle !== void 0 && { bendAngle: step.bendAngle },
|
|
76
|
+
...step.label !== void 0 && { label: step.label }
|
|
77
|
+
});
|
|
78
|
+
if (step.kind === "arc") return (0, react.createElement)(require_Step.Step, {
|
|
79
|
+
key,
|
|
80
|
+
kind: "arc",
|
|
81
|
+
startAngle: step.startAngle,
|
|
82
|
+
endAngle: step.endAngle,
|
|
83
|
+
radius: step.radius,
|
|
84
|
+
...step.label !== void 0 && { label: step.label }
|
|
85
|
+
});
|
|
86
|
+
if (step.kind === "circlePath") return (0, react.createElement)(require_Step.Step, {
|
|
87
|
+
key,
|
|
88
|
+
kind: "circlePath",
|
|
89
|
+
radius: step.radius,
|
|
90
|
+
...step.label !== void 0 && { label: step.label }
|
|
91
|
+
});
|
|
92
|
+
if (step.kind === "ellipsePath") return (0, react.createElement)(require_Step.Step, {
|
|
93
|
+
key,
|
|
94
|
+
kind: "ellipsePath",
|
|
95
|
+
radiusX: step.radiusX,
|
|
96
|
+
radiusY: step.radiusY,
|
|
97
|
+
...step.label !== void 0 && { label: step.label }
|
|
98
|
+
});
|
|
99
|
+
if (step.kind === "move") return (0, react.createElement)(require_Step.Step, {
|
|
100
|
+
key,
|
|
101
|
+
kind: "move",
|
|
50
102
|
to: step.to
|
|
51
103
|
});
|
|
52
104
|
return (0, react.createElement)(require_Step.Step, {
|
|
53
105
|
key,
|
|
54
106
|
kind: step.kind,
|
|
55
|
-
to: step.to
|
|
107
|
+
to: step.to,
|
|
108
|
+
...step.label !== void 0 && { label: step.label }
|
|
56
109
|
});
|
|
57
110
|
};
|
|
58
111
|
/** discriminated union 兜底:编译期保证不漏 case,运行时给出明确错误 */
|
|
@@ -71,12 +124,23 @@ var childToElement = (child, key) => {
|
|
|
71
124
|
stroke: child.stroke,
|
|
72
125
|
strokeWidth: child.strokeWidth,
|
|
73
126
|
strokeDasharray: child.strokeDasharray,
|
|
127
|
+
lineCap: child.lineCap,
|
|
128
|
+
lineJoin: child.lineJoin,
|
|
129
|
+
thickness: child.thickness,
|
|
74
130
|
arrow: child.arrow,
|
|
75
131
|
arrowShape: child.arrowShape,
|
|
76
132
|
fill: child.fill,
|
|
77
133
|
fillRule: child.fillRule,
|
|
134
|
+
opacity: child.opacity,
|
|
135
|
+
fillOpacity: child.fillOpacity,
|
|
136
|
+
drawOpacity: child.drawOpacity,
|
|
78
137
|
children: child.children.map((s, j) => stepToElement(s, j))
|
|
79
138
|
});
|
|
139
|
+
case "coordinate": return (0, react.createElement)(require_Coordinate.Coordinate, {
|
|
140
|
+
key,
|
|
141
|
+
id: child.id,
|
|
142
|
+
position: child.position
|
|
143
|
+
});
|
|
80
144
|
default: return assertNever(child);
|
|
81
145
|
}
|
|
82
146
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_unbuilder.d.ts","sourceRoot":"","sources":["../../../src/kernel/_unbuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,EAAE,EAA2B,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"_unbuilder.d.ts","sourceRoot":"","sources":["../../../src/kernel/_unbuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,EAAE,EAA2B,MAAM,cAAc,CAAC;AAmKhE;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,IAAI,EAAE,KAAG,SACW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/kernel/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/kernel/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC"}
|
package/dist/lib/sugar/Draw.cjs
CHANGED
|
@@ -12,15 +12,21 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
12
12
|
* (useState / useMemo / useEffect 等会抛 "Invalid hook call")。
|
|
13
13
|
*/
|
|
14
14
|
var Draw = (props) => {
|
|
15
|
-
const { way, stroke, strokeWidth, strokeDasharray, arrow, arrowShape, fill, fillRule } = props;
|
|
15
|
+
const { way, stroke, strokeWidth, strokeDasharray, lineCap, lineJoin, thickness, arrow, arrowShape, fill, fillRule, opacity, fillOpacity, drawOpacity } = props;
|
|
16
16
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Path.Path, {
|
|
17
17
|
stroke,
|
|
18
18
|
strokeWidth,
|
|
19
19
|
strokeDasharray,
|
|
20
|
+
lineCap,
|
|
21
|
+
lineJoin,
|
|
22
|
+
thickness,
|
|
20
23
|
arrow,
|
|
21
24
|
arrowShape,
|
|
22
25
|
fill,
|
|
23
26
|
fillRule,
|
|
27
|
+
opacity,
|
|
28
|
+
fillOpacity,
|
|
29
|
+
drawOpacity,
|
|
24
30
|
children: (0, _retikz_core.parseWay)(way).map((s, i) => {
|
|
25
31
|
if (s.kind === "cycle") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Step.Step, { kind: "cycle" }, i);
|
|
26
32
|
if (s.kind === "move") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Step.Step, {
|
|
@@ -30,11 +36,59 @@ var Draw = (props) => {
|
|
|
30
36
|
if (s.kind === "step") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Step.Step, {
|
|
31
37
|
kind: "step",
|
|
32
38
|
via: s.via,
|
|
33
|
-
to: s.to
|
|
39
|
+
to: s.to,
|
|
40
|
+
label: s.label
|
|
41
|
+
}, i);
|
|
42
|
+
if (s.kind === "curve") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Step.Step, {
|
|
43
|
+
kind: "curve",
|
|
44
|
+
to: s.to,
|
|
45
|
+
control: s.control,
|
|
46
|
+
label: s.label
|
|
47
|
+
}, i);
|
|
48
|
+
if (s.kind === "cubic") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Step.Step, {
|
|
49
|
+
kind: "cubic",
|
|
50
|
+
to: s.to,
|
|
51
|
+
control1: s.control1,
|
|
52
|
+
control2: s.control2,
|
|
53
|
+
label: s.label
|
|
54
|
+
}, i);
|
|
55
|
+
if (s.kind === "bend") {
|
|
56
|
+
if (s.bendAngle !== void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Step.Step, {
|
|
57
|
+
kind: "bend",
|
|
58
|
+
to: s.to,
|
|
59
|
+
bendDirection: s.bendDirection,
|
|
60
|
+
bendAngle: s.bendAngle,
|
|
61
|
+
label: s.label
|
|
62
|
+
}, i);
|
|
63
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Step.Step, {
|
|
64
|
+
kind: "bend",
|
|
65
|
+
to: s.to,
|
|
66
|
+
bendDirection: s.bendDirection,
|
|
67
|
+
label: s.label
|
|
68
|
+
}, i);
|
|
69
|
+
}
|
|
70
|
+
if (s.kind === "arc") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Step.Step, {
|
|
71
|
+
kind: "arc",
|
|
72
|
+
startAngle: s.startAngle,
|
|
73
|
+
endAngle: s.endAngle,
|
|
74
|
+
radius: s.radius,
|
|
75
|
+
label: s.label
|
|
76
|
+
}, i);
|
|
77
|
+
if (s.kind === "circlePath") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Step.Step, {
|
|
78
|
+
kind: "circlePath",
|
|
79
|
+
radius: s.radius,
|
|
80
|
+
label: s.label
|
|
81
|
+
}, i);
|
|
82
|
+
if (s.kind === "ellipsePath") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Step.Step, {
|
|
83
|
+
kind: "ellipsePath",
|
|
84
|
+
radiusX: s.radiusX,
|
|
85
|
+
radiusY: s.radiusY,
|
|
86
|
+
label: s.label
|
|
34
87
|
}, i);
|
|
35
88
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Step.Step, {
|
|
36
89
|
kind: "line",
|
|
37
|
-
to: s.to
|
|
90
|
+
to: s.to,
|
|
91
|
+
label: s.label
|
|
38
92
|
}, i);
|
|
39
93
|
})
|
|
40
94
|
});
|
package/dist/lib/sugar/Draw.d.ts
CHANGED
|
@@ -2,7 +2,13 @@ import { FC } from 'react';
|
|
|
2
2
|
import { IRPath, WayDSL } from '@retikz/core';
|
|
3
3
|
/** <Draw> 组件的 props */
|
|
4
4
|
export type DrawProps = {
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* way 数组 DSL:节点 id / 笛卡尔 / 极坐标 / 相对偏移 `{ position, type: DrawWay.Relative | DrawWay.Accumulate }` /
|
|
7
|
+
* 折角算子 `'-|'` `'|-'`(或 `DrawWay.Hv` / `DrawWay.Vh`)/ 闭合 `DrawWay.Cycle` /
|
|
8
|
+
* 曲线算子 `{ curve | cubic | bend }`(infix)/
|
|
9
|
+
* 形状算子 `{ arc | circle | ellipse }`(infix,以"上一项"为圆心,不消耗下一项)/
|
|
10
|
+
* 边标注算子 `{ label }`(infix,修饰下一段)
|
|
11
|
+
*/
|
|
6
12
|
way: WayDSL;
|
|
7
13
|
/** 描边色,省略时用 currentColor */
|
|
8
14
|
stroke?: IRPath['stroke'];
|
|
@@ -10,6 +16,12 @@ export type DrawProps = {
|
|
|
10
16
|
strokeWidth?: IRPath['strokeWidth'];
|
|
11
17
|
/** SVG stroke-dasharray 模式(如 "4 2") */
|
|
12
18
|
strokeDasharray?: IRPath['strokeDasharray'];
|
|
19
|
+
/** 端点形状(SVG `stroke-linecap`) */
|
|
20
|
+
lineCap?: IRPath['lineCap'];
|
|
21
|
+
/** 拐点形状(SVG `stroke-linejoin`) */
|
|
22
|
+
lineJoin?: IRPath['lineJoin'];
|
|
23
|
+
/** 语义 stroke 档位(TikZ `ultra thin` … `ultra thick`);显式 `strokeWidth` 始终优先 */
|
|
24
|
+
thickness?: IRPath['thickness'];
|
|
13
25
|
/**
|
|
14
26
|
* 路径级箭头方向。`'->'` = 终点;`'<-'` = 起点;`'<->'` = 两端;
|
|
15
27
|
* 省略或 `'none'` = 无箭头。
|
|
@@ -19,10 +31,16 @@ export type DrawProps = {
|
|
|
19
31
|
* 箭头形状。默认 `'normal'`。其他:`'open'` / `'stealth'` / `'diamond'` / `'circle'`。
|
|
20
32
|
*/
|
|
21
33
|
arrowShape?: IRPath['arrowShape'];
|
|
22
|
-
/** 闭合区域填充色,省略 = 不填充。配合 way 末尾的 `DrawWay.
|
|
34
|
+
/** 闭合区域填充色,省略 = 不填充。配合 way 末尾的 `DrawWay.Cycle` 画填充形状 */
|
|
23
35
|
fill?: IRPath['fill'];
|
|
24
36
|
/** SVG fill-rule:`'nonzero'`(默认)/ `'evenodd'` */
|
|
25
37
|
fillRule?: IRPath['fillRule'];
|
|
38
|
+
/** 整 path 透明度 0~1 */
|
|
39
|
+
opacity?: IRPath['opacity'];
|
|
40
|
+
/** 仅 fill 透明度 0~1 */
|
|
41
|
+
fillOpacity?: IRPath['fillOpacity'];
|
|
42
|
+
/** 仅 stroke 透明度 0~1(TikZ `draw opacity`) */
|
|
43
|
+
drawOpacity?: IRPath['drawOpacity'];
|
|
26
44
|
};
|
|
27
45
|
/**
|
|
28
46
|
* Sugar 组件——展开为等价的 <Path><Step.../></Path> Kernel 子树。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Draw.d.ts","sourceRoot":"","sources":["../../../src/sugar/Draw.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAKnD,uBAAuB;AACvB,MAAM,MAAM,SAAS,GAAG;IACtB
|
|
1
|
+
{"version":3,"file":"Draw.d.ts","sourceRoot":"","sources":["../../../src/sugar/Draw.tsx"],"names":[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,0 +1,13 @@
|
|
|
1
|
+
const require__displayNames = require("../kernel/_displayNames.cjs");
|
|
2
|
+
//#region src/sugar/EdgeLabel.tsx
|
|
3
|
+
/**
|
|
4
|
+
* Sugar 组件——挂在 <Step> 内作为子节点声明边标注。等价于在 Step 上写
|
|
5
|
+
* `label={{ text, position, side }}` prop;二者并存时 prop 优先。
|
|
6
|
+
*
|
|
7
|
+
* <EdgeLabel> 自身不渲染,由 buildIR 在收集 Step 时识别 displayName 后
|
|
8
|
+
* 提取到 IR `step.label`。
|
|
9
|
+
*/
|
|
10
|
+
var EdgeLabel = () => null;
|
|
11
|
+
EdgeLabel.displayName = require__displayNames.TIKZ_EDGE_LABEL;
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.EdgeLabel = EdgeLabel;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { IRStepLabel } from '@retikz/core';
|
|
3
|
+
/** <EdgeLabel> 组件的 props(ADR-0004) */
|
|
4
|
+
export type EdgeLabelProps = {
|
|
5
|
+
/** 段上位置(TikZ `midway` / `near start` / `near end`),缺省 'midway' */
|
|
6
|
+
position?: IRStepLabel['position'];
|
|
7
|
+
/** 相对段方向 / 视觉方位的偏移侧('sloped' = 沿切线旋转),缺省 'above' */
|
|
8
|
+
side?: IRStepLabel['side'];
|
|
9
|
+
/** 标签文字内容;必须是字符串 */
|
|
10
|
+
children: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Sugar 组件——挂在 <Step> 内作为子节点声明边标注。等价于在 Step 上写
|
|
14
|
+
* `label={{ text, position, side }}` prop;二者并存时 prop 优先。
|
|
15
|
+
*
|
|
16
|
+
* <EdgeLabel> 自身不渲染,由 buildIR 在收集 Step 时识别 displayName 后
|
|
17
|
+
* 提取到 IR `step.label`。
|
|
18
|
+
*/
|
|
19
|
+
export declare const EdgeLabel: FC<EdgeLabelProps>;
|
|
20
|
+
//# sourceMappingURL=EdgeLabel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EdgeLabel.d.ts","sourceRoot":"","sources":["../../../src/sugar/EdgeLabel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,sCAAsC;AACtC,MAAM,MAAM,cAAc,GAAG;IAC3B,kEAAkE;IAClE,QAAQ,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IACnC,oDAAoD;IACpD,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAAc,CAAC"}
|
package/dist/lib/sugar/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sugar/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sugar/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retikz/react",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.4",
|
|
4
4
|
"description": "React adapter for retikz: Kernel/Sugar JSX components and SVG renderer.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/lib/index.cjs",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"react-dom": ">=18"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@retikz/core": "0.1.0-alpha.
|
|
27
|
+
"@retikz/core": "0.1.0-alpha.4"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "^25.6.0",
|