compasso 0.3.0 → 0.4.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 +95 -10
- package/dist/{chunk-RWPGGWO5.js → chunk-FYBABYC7.js} +34 -10
- package/dist/chunk-FYBABYC7.js.map +1 -0
- package/dist/{chunk-F47C6ZEB.js → chunk-IPE7JZO5.js} +3 -3
- package/dist/{chunk-F47C6ZEB.js.map → chunk-IPE7JZO5.js.map} +1 -1
- package/dist/{chunk-Q6DVTCXD.js → chunk-LR7BXUWM.js} +18 -6
- package/dist/chunk-LR7BXUWM.js.map +1 -0
- package/dist/{chunk-LRHHUJFZ.js → chunk-M4WA6ME7.js} +3 -3
- package/dist/{chunk-LRHHUJFZ.js.map → chunk-M4WA6ME7.js.map} +1 -1
- package/dist/{chunk-JP4N42AY.js → chunk-PGUMLTIM.js} +3 -3
- package/dist/{chunk-JP4N42AY.js.map → chunk-PGUMLTIM.js.map} +1 -1
- package/dist/{chunk-O3BT2O42.js → chunk-SD4NTRBM.js} +29 -3
- package/dist/chunk-SD4NTRBM.js.map +1 -0
- package/dist/chunk-TAE2UB7D.js +780 -0
- package/dist/chunk-TAE2UB7D.js.map +1 -0
- package/dist/{chunk-ZBDABVIO.js → chunk-WJYYBGZW.js} +3 -3
- package/dist/{chunk-ZBDABVIO.js.map → chunk-WJYYBGZW.js.map} +1 -1
- package/dist/core/index.cjs +30 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +18 -2
- package/dist/core/index.d.ts +18 -2
- package/dist/core/index.js +1 -1
- package/dist/ecomap/index.cjs +34 -11
- package/dist/ecomap/index.cjs.map +1 -1
- package/dist/ecomap/index.d.cts +12 -0
- package/dist/ecomap/index.d.ts +12 -0
- package/dist/ecomap/index.js +2 -2
- package/dist/fault-tree/index.js +2 -2
- package/dist/fishbone/index.js +2 -2
- package/dist/genogram/index.cjs +57 -7
- package/dist/genogram/index.cjs.map +1 -1
- package/dist/genogram/index.d.cts +20 -4
- package/dist/genogram/index.d.ts +20 -4
- package/dist/genogram/index.js +2 -2
- package/dist/index.cjs +1052 -191
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +8 -7
- package/dist/{kinship-DqEklrDN.d.ts → kinship-BF90HyyS.d.ts} +1 -1
- package/dist/{kinship-Dy_ijjJV.d.cts → kinship-BOUss5cT.d.cts} +1 -1
- package/dist/labels-B0aOMbHy.d.cts +103 -0
- package/dist/labels-B0aOMbHy.d.ts +103 -0
- package/dist/{labels-DNqRkWuI.d.ts → labels-CuLbFyrz.d.ts} +1 -1
- package/dist/{labels-CBQ_3Ec9.d.cts → labels-DhQe7I8m.d.cts} +1 -1
- package/dist/locales/pt-br.cjs +19 -0
- package/dist/locales/pt-br.cjs.map +1 -1
- package/dist/locales/pt-br.d.cts +7 -4
- package/dist/locales/pt-br.d.ts +7 -4
- package/dist/locales/pt-br.js +18 -1
- package/dist/locales/pt-br.js.map +1 -1
- package/dist/org-chart/index.cjs +895 -0
- package/dist/org-chart/index.cjs.map +1 -0
- package/dist/org-chart/index.d.cts +185 -0
- package/dist/org-chart/index.d.ts +185 -0
- package/dist/org-chart/index.js +4 -0
- package/dist/org-chart/index.js.map +1 -0
- package/dist/pedigree/index.d.cts +4 -4
- package/dist/pedigree/index.d.ts +4 -4
- package/dist/pedigree/index.js +2 -2
- package/dist/phylo/index.js +2 -2
- package/dist/{types-BnMG7TCd.d.cts → types-jE2fdM1t.d.cts} +8 -0
- package/dist/{types-BnMG7TCd.d.ts → types-jE2fdM1t.d.ts} +8 -0
- package/package.json +28 -11
- package/dist/chunk-O3BT2O42.js.map +0 -1
- package/dist/chunk-Q6DVTCXD.js.map +0 -1
- package/dist/chunk-RWPGGWO5.js.map +0 -1
package/dist/genogram/index.cjs
CHANGED
|
@@ -149,6 +149,32 @@ function qualityLineStyle(quality, lexicon = QUALITY_LEXICON_EN) {
|
|
|
149
149
|
return matched.length === 1 ? matched[0] : "plain";
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
// src/core/annotation.ts
|
|
153
|
+
var round = (n) => Math.round(n * 100) / 100;
|
|
154
|
+
var ANNOTATION_INK = "#52525b";
|
|
155
|
+
var DOT_R = 3;
|
|
156
|
+
var TICK_HALF = 3;
|
|
157
|
+
function annotationDot(cx, cy) {
|
|
158
|
+
return `<circle cx="${round(cx)}" cy="${round(cy)}" r="${DOT_R}" fill="${ANNOTATION_INK}" fill-opacity="0.6"/>`;
|
|
159
|
+
}
|
|
160
|
+
function annotationTick(points) {
|
|
161
|
+
if (points.length < 2) return "";
|
|
162
|
+
const i = Math.floor((points.length - 1) / 2);
|
|
163
|
+
const a = points[i];
|
|
164
|
+
const b = points[i + 1] ?? points[i];
|
|
165
|
+
const mx = (a.x + b.x) / 2;
|
|
166
|
+
const my = (a.y + b.y) / 2;
|
|
167
|
+
const horizontal = Math.abs(a.y - b.y) <= Math.abs(a.x - b.x);
|
|
168
|
+
const x1 = horizontal ? mx : mx - TICK_HALF;
|
|
169
|
+
const x2 = horizontal ? mx : mx + TICK_HALF;
|
|
170
|
+
const y1 = horizontal ? my - TICK_HALF : my;
|
|
171
|
+
const y2 = horizontal ? my + TICK_HALF : my;
|
|
172
|
+
return `<line x1="${round(x1)}" y1="${round(y1)}" x2="${round(x2)}" y2="${round(y2)}" stroke="${ANNOTATION_INK}" stroke-width="1.5"/>`;
|
|
173
|
+
}
|
|
174
|
+
function annotationSwatch(x, yCenter) {
|
|
175
|
+
return annotationDot(x + LEGEND_SWATCH_W / 2, yCenter);
|
|
176
|
+
}
|
|
177
|
+
|
|
152
178
|
// src/genogram/kinship.ts
|
|
153
179
|
var KINSHIP_EN = {
|
|
154
180
|
derived: /* @__PURE__ */ new Set([
|
|
@@ -283,7 +309,8 @@ function computeGenogramLayout(people, unions, parentLinks, relationships, opts
|
|
|
283
309
|
parentId: l.parentId,
|
|
284
310
|
childId: l.childId,
|
|
285
311
|
quality: l.quality,
|
|
286
|
-
edgeId: PARENT_REL_ID_BASE + l.id
|
|
312
|
+
edgeId: PARENT_REL_ID_BASE + l.id,
|
|
313
|
+
annotated: l.annotated ?? false
|
|
287
314
|
}));
|
|
288
315
|
const declaredPairs = new Set(validLinks.map((l) => pairKey(l.parentId, l.childId)));
|
|
289
316
|
const promotedByPair = /* @__PURE__ */ new Map();
|
|
@@ -302,7 +329,7 @@ function computeGenogramLayout(people, unions, parentLinks, relationships, opts
|
|
|
302
329
|
[parentId, childId] = fromIsChild ? [r.toPersonId, r.fromPersonId] : [r.fromPersonId, r.toPersonId];
|
|
303
330
|
}
|
|
304
331
|
if (parentId === childId) continue;
|
|
305
|
-
promotedByPair.set(key, { parentId, childId, quality: r.quality, edgeId: PROMOTED_REL_ID_BASE + r.id });
|
|
332
|
+
promotedByPair.set(key, { parentId, childId, quality: r.quality, edgeId: PROMOTED_REL_ID_BASE + r.id, annotated: r.annotated ?? false });
|
|
306
333
|
}
|
|
307
334
|
const allLinks = [...realLinks, ...promotedByPair.values()].sort((a, b) => a.edgeId - b.edgeId);
|
|
308
335
|
const coupleByPair = /* @__PURE__ */ new Map();
|
|
@@ -635,6 +662,7 @@ function computeGenogramLayout(people, unions, parentLinks, relationships, opts
|
|
|
635
662
|
toPersonId: u.personBId,
|
|
636
663
|
titles: [unionTitle(u)],
|
|
637
664
|
lineStyle: "plain",
|
|
665
|
+
annotated: u.annotated ?? false,
|
|
638
666
|
build: () => {
|
|
639
667
|
const cy = geo.cy(rowOfPerson.get(leftId));
|
|
640
668
|
if (dipLevel === 0) {
|
|
@@ -669,6 +697,7 @@ function computeGenogramLayout(people, unions, parentLinks, relationships, opts
|
|
|
669
697
|
toPersonId: u.personBId,
|
|
670
698
|
titles: [unionTitle(u)],
|
|
671
699
|
lineStyle: "plain",
|
|
700
|
+
annotated: u.annotated ?? false,
|
|
672
701
|
build
|
|
673
702
|
});
|
|
674
703
|
}
|
|
@@ -725,6 +754,7 @@ function computeGenogramLayout(people, unions, parentLinks, relationships, opts
|
|
|
725
754
|
};
|
|
726
755
|
gutterReqs.push(spineReq);
|
|
727
756
|
const aId = (c) => linkOf.get(`${u.personAId}>${c}`).edgeId;
|
|
757
|
+
const aLinkAnnotated = (c) => linkOf.get(`${u.personAId}>${c}`).annotated ?? false;
|
|
728
758
|
const childDrop = (c, parentId) => {
|
|
729
759
|
const link = linkOf.get(`${parentId}>${c}`);
|
|
730
760
|
const edgeId = link.edgeId;
|
|
@@ -737,6 +767,7 @@ function computeGenogramLayout(people, unions, parentLinks, relationships, opts
|
|
|
737
767
|
toPersonId: c,
|
|
738
768
|
titles: [linkTitle(link)],
|
|
739
769
|
lineStyle: "plain",
|
|
770
|
+
annotated: link.annotated,
|
|
740
771
|
build: () => {
|
|
741
772
|
const y = geo.corridorLaneY(sibReq);
|
|
742
773
|
const x = geo.cx(colOrThrow(c)) + arrivalOffset(arr.slot, arrivalCount.get(c) ?? 1);
|
|
@@ -757,6 +788,7 @@ function computeGenogramLayout(people, unions, parentLinks, relationships, opts
|
|
|
757
788
|
toPersonId: null,
|
|
758
789
|
titles: [linkTitle(linkOf.get(`${u.personAId}>${c}`))],
|
|
759
790
|
lineStyle: "plain",
|
|
791
|
+
annotated: aLinkAnnotated(c),
|
|
760
792
|
build: () => {
|
|
761
793
|
const sy = geo.corridorLaneY(sibReq);
|
|
762
794
|
const sx = geo.gutterCenterX(interGutter);
|
|
@@ -782,6 +814,7 @@ function computeGenogramLayout(people, unions, parentLinks, relationships, opts
|
|
|
782
814
|
// declared quality word is dropped from the drawn element (FIX C-2 / SPEC inv #4).
|
|
783
815
|
titles: [aLinkTitle(groupKids[0]), ...groupKids.slice(2).map(aLinkTitle)],
|
|
784
816
|
lineStyle: "plain",
|
|
817
|
+
annotated: [groupKids[0], ...groupKids.slice(2)].some(aLinkAnnotated),
|
|
785
818
|
build: () => {
|
|
786
819
|
const y = geo.corridorLaneY(sibReq);
|
|
787
820
|
const xs = sibSpan();
|
|
@@ -800,6 +833,7 @@ function computeGenogramLayout(people, unions, parentLinks, relationships, opts
|
|
|
800
833
|
titles: [aLinkTitle(groupKids[1])],
|
|
801
834
|
// the A-side link this spine carries, verbatim
|
|
802
835
|
lineStyle: "plain",
|
|
836
|
+
annotated: aLinkAnnotated(groupKids[1]),
|
|
803
837
|
build: () => {
|
|
804
838
|
const sy = geo.corridorLaneY(sibReq);
|
|
805
839
|
const x = geo.gutterCenterX(interGutter);
|
|
@@ -827,6 +861,7 @@ function computeGenogramLayout(people, unions, parentLinks, relationships, opts
|
|
|
827
861
|
titles: [linkTitle(l)],
|
|
828
862
|
lineStyle: "plain",
|
|
829
863
|
dotted: true,
|
|
864
|
+
annotated: l.annotated,
|
|
830
865
|
build
|
|
831
866
|
});
|
|
832
867
|
}
|
|
@@ -839,10 +874,11 @@ function computeGenogramLayout(people, unions, parentLinks, relationships, opts
|
|
|
839
874
|
const title = r.quality !== null ? `${r.type} \xB7 ${r.quality}` : r.type;
|
|
840
875
|
const g = bondGroups.get(key);
|
|
841
876
|
if (g === void 0) {
|
|
842
|
-
bondGroups.set(key, { relIds: [r.id], titles: [title], style, aId: r.fromPersonId, bId: r.toPersonId });
|
|
877
|
+
bondGroups.set(key, { relIds: [r.id], titles: [title], style, aId: r.fromPersonId, bId: r.toPersonId, annotated: r.annotated ?? false });
|
|
843
878
|
} else {
|
|
844
879
|
g.relIds.push(r.id);
|
|
845
880
|
g.titles.push(title);
|
|
881
|
+
if (r.annotated) g.annotated = true;
|
|
846
882
|
}
|
|
847
883
|
}
|
|
848
884
|
const bondList = [...bondGroups.values()].sort((a, b) => Math.max(...a.relIds) - Math.max(...b.relIds));
|
|
@@ -861,6 +897,7 @@ function computeGenogramLayout(people, unions, parentLinks, relationships, opts
|
|
|
861
897
|
toPersonId: g.bId,
|
|
862
898
|
titles: g.titles,
|
|
863
899
|
lineStyle: g.style,
|
|
900
|
+
annotated: g.annotated,
|
|
864
901
|
build
|
|
865
902
|
});
|
|
866
903
|
}
|
|
@@ -957,6 +994,7 @@ function computeGenogramLayout(people, unions, parentLinks, relationships, opts
|
|
|
957
994
|
label: p.label,
|
|
958
995
|
shape: shapeForSex(p.sex),
|
|
959
996
|
deceased: p.deceased,
|
|
997
|
+
annotated: p.annotated ?? false,
|
|
960
998
|
cx: colCenterX[c],
|
|
961
999
|
cy: rowCenterY[r],
|
|
962
1000
|
size: NODE_SIZE,
|
|
@@ -973,6 +1011,7 @@ function computeGenogramLayout(people, unions, parentLinks, relationships, opts
|
|
|
973
1011
|
points: pl.build(),
|
|
974
1012
|
titles: pl.titles,
|
|
975
1013
|
lineStyle: pl.lineStyle,
|
|
1014
|
+
annotated: pl.annotated,
|
|
976
1015
|
...pl.unionStyle !== void 0 ? { unionStyle: pl.unionStyle } : {},
|
|
977
1016
|
...pl.dotted ? { dotted: true } : {}
|
|
978
1017
|
}));
|
|
@@ -1077,6 +1116,7 @@ function elementSvg(el, override) {
|
|
|
1077
1116
|
}
|
|
1078
1117
|
return `<path d="${pathData(pts)}" fill="none" stroke="${EDGE_INK}" stroke-width="${width}" stroke-opacity="${opacity}"${dashAttr}/>`;
|
|
1079
1118
|
};
|
|
1119
|
+
const tick = el.annotated ? annotationTick(el.points) : "";
|
|
1080
1120
|
if (el.kind === "union-bar" || el.kind === "union-elbow") {
|
|
1081
1121
|
const style = resolveUnionStyle(el, override);
|
|
1082
1122
|
const body = [drawLine(style.dash ?? null, STRUCT_WIDTH, STRUCT_OPACITY)];
|
|
@@ -1085,15 +1125,15 @@ function elementSvg(el, override) {
|
|
|
1085
1125
|
const [a, b] = pts.length === 2 ? [pts[0], pts[1]] : longestHSegment(pts);
|
|
1086
1126
|
body.push(slashMarks(a, b, slashes, STRUCT_WIDTH));
|
|
1087
1127
|
}
|
|
1088
|
-
return `<g data-edge-id="${el.edgeId}">${title}${body.join("")}</g>`;
|
|
1128
|
+
return `<g data-edge-id="${el.edgeId}">${title}${body.join("")}${tick}</g>`;
|
|
1089
1129
|
}
|
|
1090
1130
|
if (el.kind === "descent" || el.kind === "sibling-bar") {
|
|
1091
1131
|
const dash = el.dotted ? DOTTED_DASH : null;
|
|
1092
1132
|
const opacity = el.dotted ? DOTTED_OPACITY : STRUCT_OPACITY;
|
|
1093
|
-
return `<g data-edge-id="${el.edgeId}">${title}${drawLine(dash, STRUCT_WIDTH, opacity)}</g>`;
|
|
1133
|
+
return `<g data-edge-id="${el.edgeId}">${title}${drawLine(dash, STRUCT_WIDTH, opacity)}${tick}</g>`;
|
|
1094
1134
|
}
|
|
1095
1135
|
const ink = EDGE_STROKE[el.lineStyle];
|
|
1096
|
-
return `<g data-edge-id="${el.edgeId}">${title}${drawLine(ink.dash, ink.width, ink.opacity)}</g>`;
|
|
1136
|
+
return `<g data-edge-id="${el.edgeId}">${title}${drawLine(ink.dash, ink.width, ink.opacity)}${tick}</g>`;
|
|
1097
1137
|
}
|
|
1098
1138
|
function genogramLayoutSvg(layout, opts = {}) {
|
|
1099
1139
|
const override = opts.unionStyleByRelId ?? /* @__PURE__ */ new Map();
|
|
@@ -1111,6 +1151,9 @@ function genogramLayoutSvg(layout, opts = {}) {
|
|
|
1111
1151
|
`<line x1="${node.cx - half}" y1="${node.cy - half}" x2="${node.cx + half}" y2="${node.cy + half}" stroke="${GLYPH_STROKE}" stroke-width="2"/>`
|
|
1112
1152
|
);
|
|
1113
1153
|
}
|
|
1154
|
+
if (node.annotated) {
|
|
1155
|
+
pieces.push(annotationDot(node.cx + 0.7 * half, node.cy - 0.7 * half));
|
|
1156
|
+
}
|
|
1114
1157
|
const tspans = node.labelLines.map(
|
|
1115
1158
|
(line, i) => `<tspan x="${node.cx}" y="${node.labelTop + 10 + i * LABEL_LINE_H}">${xmlEscape(line)}</tspan>`
|
|
1116
1159
|
).join("");
|
|
@@ -1153,6 +1196,12 @@ function genogramLayoutSvg(layout, opts = {}) {
|
|
|
1153
1196
|
label: labels.isolated
|
|
1154
1197
|
});
|
|
1155
1198
|
}
|
|
1199
|
+
if (opts.annotationLabel !== void 0 && (layout.nodes.some((n) => n.annotated) || layout.elements.some((e) => e.annotated))) {
|
|
1200
|
+
entries.push({
|
|
1201
|
+
swatch: (x, y) => annotationSwatch(x, y),
|
|
1202
|
+
label: opts.annotationLabel
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1156
1205
|
const block = legendBlock(entries, layout.height);
|
|
1157
1206
|
if (block.svg !== "") {
|
|
1158
1207
|
parts.push(block.svg);
|
|
@@ -1204,7 +1253,8 @@ function genogramSvg(input, opts = {}) {
|
|
|
1204
1253
|
const svg = genogramLayoutSvg(layout, {
|
|
1205
1254
|
unionStyleByRelId,
|
|
1206
1255
|
...opts.legend === false ? { legend: false } : {},
|
|
1207
|
-
...opts.svgLabels !== void 0 ? { labels: opts.svgLabels } : {}
|
|
1256
|
+
...opts.svgLabels !== void 0 ? { labels: opts.svgLabels } : {},
|
|
1257
|
+
...opts.annotationLabel !== void 0 ? { annotationLabel: opts.annotationLabel } : {}
|
|
1208
1258
|
});
|
|
1209
1259
|
return { svg, layout };
|
|
1210
1260
|
}
|