compasso 0.4.0 → 0.5.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.
Files changed (100) hide show
  1. package/README.md +115 -5
  2. package/dist/{chunk-ZBDABVIO.js → chunk-2NDET6O5.js} +3 -3
  3. package/dist/{chunk-ZBDABVIO.js.map → chunk-2NDET6O5.js.map} +1 -1
  4. package/dist/{chunk-Q6DVTCXD.js → chunk-3RGYLVTN.js} +18 -6
  5. package/dist/chunk-3RGYLVTN.js.map +1 -0
  6. package/dist/chunk-BM7UJBK5.js +680 -0
  7. package/dist/chunk-BM7UJBK5.js.map +1 -0
  8. package/dist/chunk-DVLWT565.js +372 -0
  9. package/dist/chunk-DVLWT565.js.map +1 -0
  10. package/dist/{chunk-F47C6ZEB.js → chunk-JBDA7E2O.js} +3 -3
  11. package/dist/{chunk-F47C6ZEB.js.map → chunk-JBDA7E2O.js.map} +1 -1
  12. package/dist/chunk-MIJTBYX2.js +982 -0
  13. package/dist/chunk-MIJTBYX2.js.map +1 -0
  14. package/dist/{chunk-JP4N42AY.js → chunk-PJHLWSGD.js} +3 -3
  15. package/dist/{chunk-JP4N42AY.js.map → chunk-PJHLWSGD.js.map} +1 -1
  16. package/dist/{chunk-LRHHUJFZ.js → chunk-RDH4XHA2.js} +3 -3
  17. package/dist/{chunk-LRHHUJFZ.js.map → chunk-RDH4XHA2.js.map} +1 -1
  18. package/dist/{chunk-UJVU7B44.js → chunk-WEHUSHVI.js} +31 -51
  19. package/dist/chunk-WEHUSHVI.js.map +1 -0
  20. package/dist/{chunk-RWPGGWO5.js → chunk-Z66YUOUM.js} +34 -10
  21. package/dist/chunk-Z66YUOUM.js.map +1 -0
  22. package/dist/core/index.cjs +247 -0
  23. package/dist/core/index.cjs.map +1 -1
  24. package/dist/core/index.d.cts +94 -2
  25. package/dist/core/index.d.ts +94 -2
  26. package/dist/core/index.js +1 -1
  27. package/dist/ecomap/index.cjs +34 -11
  28. package/dist/ecomap/index.cjs.map +1 -1
  29. package/dist/ecomap/index.d.cts +12 -0
  30. package/dist/ecomap/index.d.ts +12 -0
  31. package/dist/ecomap/index.js +2 -2
  32. package/dist/fault-tree/index.d.cts +2 -2
  33. package/dist/fault-tree/index.d.ts +2 -2
  34. package/dist/fault-tree/index.js +2 -2
  35. package/dist/fishbone/index.js +2 -2
  36. package/dist/genogram/index.cjs +57 -7
  37. package/dist/genogram/index.cjs.map +1 -1
  38. package/dist/genogram/index.d.cts +22 -6
  39. package/dist/genogram/index.d.ts +22 -6
  40. package/dist/genogram/index.js +2 -2
  41. package/dist/geometry-P-XGqGe7.d.cts +8 -0
  42. package/dist/geometry-P-XGqGe7.d.ts +8 -0
  43. package/dist/grid-BMgUSly1.d.cts +79 -0
  44. package/dist/grid-BMgUSly1.d.ts +79 -0
  45. package/dist/index.cjs +2360 -395
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.cts +14 -7
  48. package/dist/index.d.ts +14 -7
  49. package/dist/index.js +10 -8
  50. package/dist/{kinship-DqEklrDN.d.ts → kinship-BF90HyyS.d.ts} +1 -1
  51. package/dist/{kinship-Dy_ijjJV.d.cts → kinship-BOUss5cT.d.cts} +1 -1
  52. package/dist/{labels-RtFw9tX1.d.cts → labels-B0aOMbHy.d.cts} +12 -0
  53. package/dist/{labels-RtFw9tX1.d.ts → labels-B0aOMbHy.d.ts} +12 -0
  54. package/dist/labels-Br8yjc3C.d.cts +29 -0
  55. package/dist/labels-Br8yjc3C.d.ts +29 -0
  56. package/dist/{labels-DNqRkWuI.d.ts → labels-CuLbFyrz.d.ts} +1 -1
  57. package/dist/labels-D1v1RWZd.d.cts +97 -0
  58. package/dist/labels-D1v1RWZd.d.ts +97 -0
  59. package/dist/{labels-CBQ_3Ec9.d.cts → labels-DhQe7I8m.d.cts} +1 -1
  60. package/dist/layered-DmZluAqe.d.cts +72 -0
  61. package/dist/layered-DmZluAqe.d.ts +72 -0
  62. package/dist/locales/pt-br.cjs +53 -0
  63. package/dist/locales/pt-br.cjs.map +1 -1
  64. package/dist/locales/pt-br.d.cts +11 -5
  65. package/dist/locales/pt-br.d.ts +11 -5
  66. package/dist/locales/pt-br.js +50 -1
  67. package/dist/locales/pt-br.js.map +1 -1
  68. package/dist/org-chart/index.cjs +138 -94
  69. package/dist/org-chart/index.cjs.map +1 -1
  70. package/dist/org-chart/index.d.cts +24 -33
  71. package/dist/org-chart/index.d.ts +24 -33
  72. package/dist/org-chart/index.js +2 -2
  73. package/dist/pedigree/index.d.cts +6 -6
  74. package/dist/pedigree/index.d.ts +6 -6
  75. package/dist/pedigree/index.js +2 -2
  76. package/dist/phylo/index.d.cts +2 -2
  77. package/dist/phylo/index.d.ts +2 -2
  78. package/dist/phylo/index.js +2 -2
  79. package/dist/prisma/index.cjs +882 -0
  80. package/dist/prisma/index.cjs.map +1 -0
  81. package/dist/prisma/index.d.cts +174 -0
  82. package/dist/prisma/index.d.ts +174 -0
  83. package/dist/prisma/index.js +4 -0
  84. package/dist/prisma/index.js.map +1 -0
  85. package/dist/{text-DuO_PwYw.d.cts → text-DDVzpwPZ.d.cts} +1 -8
  86. package/dist/{text-DuO_PwYw.d.ts → text-DDVzpwPZ.d.ts} +1 -8
  87. package/dist/{types-BnMG7TCd.d.cts → types-jE2fdM1t.d.cts} +8 -0
  88. package/dist/{types-BnMG7TCd.d.ts → types-jE2fdM1t.d.ts} +8 -0
  89. package/dist/uml/index.cjs +1214 -0
  90. package/dist/uml/index.cjs.map +1 -0
  91. package/dist/uml/index.d.cts +189 -0
  92. package/dist/uml/index.d.ts +189 -0
  93. package/dist/uml/index.js +4 -0
  94. package/dist/uml/index.js.map +1 -0
  95. package/package.json +28 -2
  96. package/dist/chunk-O3BT2O42.js +0 -145
  97. package/dist/chunk-O3BT2O42.js.map +0 -1
  98. package/dist/chunk-Q6DVTCXD.js.map +0 -1
  99. package/dist/chunk-RWPGGWO5.js.map +0 -1
  100. package/dist/chunk-UJVU7B44.js.map +0 -1
@@ -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
  }