@cardenelabs/cdl 0.104.0 → 0.106.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/react.js CHANGED
@@ -973,6 +973,71 @@ var KINDS_FITTING_OWN_TITLE = /* @__PURE__ */ new Set([
973
973
  function fitsOwnTitleWidth(kind) {
974
974
  return KINDS_FITTING_OWN_TITLE.has(kind ?? "");
975
975
  }
976
+ var KINDS_DRAWING_TITLE_OUTSIDE = /* @__PURE__ */ new Set([
977
+ "dyn-rect",
978
+ "dyn-circle",
979
+ "dyn-arc",
980
+ "dyn-wave",
981
+ "dyn-polygon",
982
+ ...KINDS_DRAWING_OWN_PAYLOAD
983
+ ]);
984
+ function drawsTitleOutsideBox(kind) {
985
+ return KINDS_DRAWING_TITLE_OUTSIDE.has(kind ?? "");
986
+ }
987
+ var TITLE_FONT_SIZE_DEFAULT = 18;
988
+ var TITLE_FONT_SIZE = new Map([
989
+ ...["dyn-rect", "dyn-circle", "dyn-arc", "dyn-wave", "dyn-polygon"].map(
990
+ (k) => [k, 13]
991
+ ),
992
+ ...[
993
+ "shape-code-block",
994
+ "shape-cylinder",
995
+ "shape-diamond",
996
+ "shape-iot-sensor",
997
+ "shape-robot-arm",
998
+ "shape-stack",
999
+ "shape-terminal"
1000
+ ].map((k) => [k, 15]),
1001
+ ...[
1002
+ "shape-cloud",
1003
+ "shape-file",
1004
+ "shape-folder",
1005
+ "shape-hexagon",
1006
+ "shape-message-bubble",
1007
+ "shape-window"
1008
+ ].map((k) => [k, 16]),
1009
+ ["shape-kanban-card", 17],
1010
+ ...[
1011
+ "admin",
1012
+ "api",
1013
+ "backend",
1014
+ "cache",
1015
+ "cdn",
1016
+ "cloud",
1017
+ "database",
1018
+ "decision",
1019
+ "developer",
1020
+ "external-user",
1021
+ "frontend",
1022
+ "merkle-tree",
1023
+ "message-bus",
1024
+ "microservice",
1025
+ "oracle",
1026
+ "person",
1027
+ "queue",
1028
+ "service",
1029
+ "signer",
1030
+ "user-group",
1031
+ "webhook"
1032
+ ].map((k) => [k, 20]),
1033
+ ...["card", "event", "function"].map((k) => [k, 24]),
1034
+ ["actor", 32],
1035
+ ["storage", 34]
1036
+ ]);
1037
+ function titleFontSize(kind) {
1038
+ return TITLE_FONT_SIZE.get(kind ?? "") ?? TITLE_FONT_SIZE_DEFAULT;
1039
+ }
1040
+ var TITLE_BOX_PADDING = 52;
976
1041
  var KINDS_DRAWN_BY_GENERIC = [
977
1042
  "person",
978
1043
  "user-group",
@@ -6066,12 +6131,12 @@ function runAxes(laid, diag, violations, counts, push, profile, skippedAxes, \u5
6066
6131
  if (!isRenderedNode(n)) continue;
6067
6132
  const titleTrimmed = n.title?.trim() ?? "";
6068
6133
  if (!titleTrimmed) continue;
6069
- const titleLen = titleTrimmed.length;
6070
- const expectedW = titleLen * 22 + 52;
6134
+ const expectedW = measureTextWidth(titleTrimmed, { fontSize: titleFontSize(n.kind) }) + (drawsTitleOutsideBox(n.kind) ? 0 : TITLE_BOX_PADDING);
6071
6135
  if (expectedW > n.w + 8) {
6072
6136
  push(
6073
6137
  "text-readability",
6074
- `node "${n.id}" title "${n.title}" \u304C node \u5E45 ${n.w}px \u3092\u8D85\u904E\u3059\u308B\u53EF\u80FD\u6027 (\u671F\u5F85 ${expectedW}px)`,
6138
+ // 字ごとの実幅は小数になるので、読む人に出す時だけ丸める (判定は丸めない)
6139
+ `node "${n.id}" title "${n.title}" \u304C node \u5E45 ${n.w}px \u3092\u8D85\u904E\u3059\u308B\u53EF\u80FD\u6027 (\u671F\u5F85 ${Math.round(expectedW)}px)`,
6075
6140
  "warn"
6076
6141
  );
6077
6142
  }