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