embroidery-qc-image 1.0.23 → 1.0.24

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.
@@ -1 +1 @@
1
- {"version":3,"file":"EmbroideryQCImage.d.ts","sourceRoot":"","sources":["../../src/components/EmbroideryQCImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAY,MAAM,UAAU,CAAC;AAChF,OAAO,yBAAyB,CAAC;AAiKjC,MAAM,WAAW,8BAA8B;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,YAAY,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAoWD,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAqHvD,CAAC;AA27BF,eAAO,MAAM,6BAA6B,GACxC,QAAQ,kBAAkB,EAC1B,UAAS,8BAAmC,KAC3C,OAAO,CAAC,IAAI,GAAG,IAAI,CAuBrB,CAAC;AAEF,eAAO,MAAM,6BAA6B,GACxC,QAAQ,kBAAkB,EAC1B,UAAS,8BAAmC,KAC3C,OAAO,CAAC,MAAM,GAAG,IAAI,CAuBvB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"EmbroideryQCImage.d.ts","sourceRoot":"","sources":["../../src/components/EmbroideryQCImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAY,MAAM,UAAU,CAAC;AAChF,OAAO,yBAAyB,CAAC;AAiKjC,MAAM,WAAW,8BAA8B;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,YAAY,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAoWD,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAqHvD,CAAC;AAm7BF,eAAO,MAAM,6BAA6B,GACxC,QAAQ,kBAAkB,EAC1B,UAAS,8BAAmC,KAC3C,OAAO,CAAC,IAAI,GAAG,IAAI,CAuBrB,CAAC;AAEF,eAAO,MAAM,6BAA6B,GACxC,QAAQ,kBAAkB,EAC1B,UAAS,8BAAmC,KAC3C,OAAO,CAAC,MAAM,GAAG,IAAI,CAuBvB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
package/dist/index.esm.js CHANGED
@@ -31,71 +31,6 @@ function styleInject(css, ref) {
31
31
  var css_248z = ".render-embroidery {\r\n display: inline-block;\r\n position: relative;\r\n width: 100%;\r\n max-width: 100%;\r\n}\r\n\r\n.render-embroidery-canvas {\r\n display: block;\r\n width: 100%;\r\n height: auto;\r\n image-rendering: high-quality;\r\n background: transparent;\r\n}\r\n";
32
32
  styleInject(css_248z);
33
33
 
34
- // ============================================================================
35
- // CONSTANTS
36
- // ============================================================================
37
- const COLOR_MAP = {
38
- "Army (1394)": "#545541",
39
- Army: "#545541",
40
- "Black (8)": "#060608",
41
- Black: "#060608",
42
- "Bubblegum (1309)": "#E77B9F",
43
- Bubblegum: "#E77B9F",
44
- "Carolina Blue (1274)": "#608CC9",
45
- "Carolina Blue": "#608CC9",
46
- "Celadon (1098)": "#8EAD8D",
47
- Celadon: "#8EAD8D",
48
- "Coffee Bean (1145)": "#502B23",
49
- "Coffee Bean": "#502B23",
50
- "Daffodil (1180)": "#FBE30D",
51
- Daffodil: "#FBE30D",
52
- "Dark Gray (1131)": "#2E272E",
53
- "Dark Gray": "#2E272E",
54
- "Doe Skin Beige (1344)": "#AE9B8B",
55
- "Doe Skin Beige": "#AE9B8B",
56
- "Dusty Blue (1373)": "#7B90A9",
57
- "Dusty Blue": "#7B90A9",
58
- "Forest Green (1397)": "#073020",
59
- "Forest Green": "#073020",
60
- "Gold (1425)": "#D2920A",
61
- Gold: "#D2920A",
62
- "Gray (1118)": "#9999A3",
63
- Gray: "#9999A3",
64
- "Ivory (1072)": "#E3DAC9",
65
- Ivory: "#E3DAC9",
66
- "Lavender (1032)": "#9274B6",
67
- Lavender: "#9274B6",
68
- "Light Denim (1133)": "#366696",
69
- "Light Denim": "#366696",
70
- "Light Salmon (1018)": "#E0A793",
71
- "Light Salmon": "#E0A793",
72
- "Maroon (1374)": "#480C1C",
73
- Maroon: "#480C1C",
74
- "Navy Blue (1044)": "#04072A",
75
- "Navy Blue": "#04072A",
76
- "Olive Green (1157)": "#625E1F",
77
- "Olive Green": "#625E1F",
78
- "Orange (1278)": "#D45D03",
79
- Orange: "#D45D03",
80
- "Peach Blush (1053)": "#E2C0B6",
81
- "Peach Blush": "#E2C0B6",
82
- "Pink (1148)": "#EFAFBF",
83
- Pink: "#EFAFBF",
84
- "Purple (1412)": "#37196F",
85
- Purple: "#37196F",
86
- "Red (1037)": "#9D000B",
87
- Red: "#9D000B",
88
- "Silver Sage (1396)": "#424F45",
89
- "Silver Sage": "#424F45",
90
- "Summer Sky (1432)": "#65A8D2",
91
- "Summer Sky": "#65A8D2",
92
- "Terra Cotta (1477)": "#AE3111",
93
- "Terra Cotta": "#AE3111",
94
- "Sand (1055)": "#D2C2AB",
95
- Sand: "#D2C2AB",
96
- "White (9)": "#D8D7DC",
97
- White: "#D8D7DC",
98
- };
99
34
  const DEFAULT_ERROR_COLOR = "#CC1F1A";
100
35
  const DEFAULT_WARNING_COLOR = "#FF8C00";
101
36
  const BASE_URLS = {
@@ -384,43 +319,6 @@ const buildWrappedLines = (ctx, text, maxWidth) => {
384
319
  lines.push(currentLine);
385
320
  return lines;
386
321
  };
387
- const wrapTextMultiColor = (ctx, text, colors, x, y, maxWidth, lineHeight) => {
388
- const words = text.split(" ");
389
- const lines = [];
390
- const lineStartIndices = [0];
391
- let currentLine = words[0];
392
- let currentCharIndex = words[0].length;
393
- for (let i = 1; i < words.length; i++) {
394
- const testLine = currentLine + " " + words[i];
395
- if (ctx.measureText(testLine).width > maxWidth && currentLine.length > 0) {
396
- lines.push(currentLine);
397
- lineStartIndices.push(currentCharIndex + 1);
398
- currentLine = words[i];
399
- currentCharIndex += words[i].length + 1;
400
- }
401
- else {
402
- currentLine = testLine;
403
- currentCharIndex += words[i].length + 1;
404
- }
405
- }
406
- lines.push(currentLine);
407
- let currentY = y;
408
- lines.forEach((line, lineIdx) => {
409
- let currentX = x;
410
- const startCharIdx = lineIdx > 0 ? lineStartIndices[lineIdx] : 0;
411
- for (let i = 0; i < line.length; i++) {
412
- const char = line[i];
413
- const globalCharIdx = startCharIdx + i;
414
- const colorIndex = globalCharIdx % colors.length;
415
- const color = colors[colorIndex];
416
- ctx.fillStyle = COLOR_MAP[color] || LAYOUT.LABEL_COLOR;
417
- ctx.fillText(char, currentX, currentY);
418
- currentX += ctx.measureText(char).width;
419
- }
420
- currentY += lineHeight;
421
- });
422
- return lines.length * lineHeight;
423
- };
424
322
  const drawSwatches = (ctx, colors, startX, startY, swatchHeight, scaleFactor, imageRefs) => {
425
323
  let swatchX = startX;
426
324
  colors.forEach((color) => {
@@ -892,9 +790,25 @@ const renderUniformLabels = (ctx, uniformProps, x, y, maxWidth, scaleFactor, ima
892
790
  let rendered = 0;
893
791
  if (values.font && shouldRenderField("font")) {
894
792
  const allDefault = textPositions.every((p) => p.is_font_default === true);
895
- const fontLabel = allDefault ? `Font: ${values.font} (Mặc định)` : `Font: ${values.font} (Custom)`;
896
- const result = wrapText(ctx, fontLabel, x, cursorY, maxWidth, fontSize + lineGap);
897
- cursorY += result.height;
793
+ // Render "Font: " với font mặc định
794
+ const prefix = "Font: ";
795
+ ctx.font = `${fontSize}px ${LAYOUT.FONT_FAMILY}`;
796
+ const prefixWidth = ctx.measureText(prefix).width;
797
+ let currentX = x + prefixWidth;
798
+ ctx.fillText(prefix, x, cursorY);
799
+ // Render tên font với font từ config
800
+ ctx.font = `${fontSize}px ${values.font}`;
801
+ const fontNameWidth = ctx.measureText(values.font).width;
802
+ ctx.fillText(values.font, currentX, cursorY);
803
+ currentX += fontNameWidth;
804
+ // Render "(Mặc định)" hoặc "(Custom)" với font mặc định
805
+ const suffix = allDefault ? " (Mặc định)" : " (Custom)";
806
+ ctx.font = `${fontSize}px ${LAYOUT.FONT_FAMILY}`;
807
+ ctx.measureText(suffix).width;
808
+ ctx.fillText(suffix, currentX, cursorY);
809
+ // Tính toán height và di chuyển cursorY
810
+ const lineHeight = fontSize + lineGap;
811
+ cursorY += lineHeight;
898
812
  rendered++;
899
813
  }
900
814
  if (values.shape && values.shape !== "None" && shouldRenderField("shape")) {
@@ -943,31 +857,15 @@ const renderTextPosition = (ctx, position, x, y, maxWidth, displayIndex, showLab
943
857
  const textMaxWidth = maxWidth - labelWidth;
944
858
  // Get display text (handle empty/null/undefined)
945
859
  const isEmptyText = !position.text || position.text.trim() === "";
946
- // Draw text content
860
+ // Draw text content - dùng font mặc định và màu đỏ
861
+ ctx.font = `${textFontSize}px ${LAYOUT.FONT_FAMILY}`;
862
+ ctx.fillStyle = DEFAULT_ERROR_COLOR;
947
863
  if (isEmptyText) {
948
- ctx.font = `${textFontSize}px ${LAYOUT.FONT_FAMILY}`;
949
- ctx.fillStyle = LAYOUT.LABEL_COLOR;
950
864
  const textResult = wrapText(ctx, "(không có text)", x + labelWidth, currentY, textMaxWidth, textFontSize);
951
865
  currentY += textResult.height;
952
866
  drawnHeight += textResult.height;
953
867
  }
954
- else if (position.floral_pattern) {
955
- // Khi có floral_pattern, dùng màu mặc định như label
956
- ctx.font = `${textFontSize}px ${position.font}`;
957
- ctx.fillStyle = LAYOUT.LABEL_COLOR;
958
- const textResult = wrapText(ctx, position.text, x + labelWidth, currentY, textMaxWidth, textFontSize);
959
- currentY += textResult.height;
960
- drawnHeight += textResult.height;
961
- }
962
- else if (position.character_colors?.length) {
963
- ctx.font = `${textFontSize}px ${position.font}`;
964
- const textHeight = wrapTextMultiColor(ctx, position.text, position.character_colors, x + labelWidth, currentY, textMaxWidth, textFontSize);
965
- currentY += textHeight;
966
- drawnHeight += textHeight;
967
- }
968
868
  else {
969
- ctx.font = `${textFontSize}px ${position.font}`;
970
- ctx.fillStyle = COLOR_MAP[position.color ?? "None"] || LAYOUT.LABEL_COLOR;
971
869
  const textResult = wrapText(ctx, position.text, x + labelWidth, currentY, textMaxWidth, textFontSize);
972
870
  currentY += textResult.height;
973
871
  drawnHeight += textResult.height;
@@ -983,12 +881,26 @@ const renderTextPosition = (ctx, position, x, y, maxWidth, displayIndex, showLab
983
881
  drawnHeight += result.height;
984
882
  }
985
883
  if (showLabels.font && position.font) {
986
- const fontLabel = position.is_font_default === true
987
- ? `Font: ${position.font} (Mặc định)`
988
- : `Font: ${position.font} (Custom)`;
989
- const result = wrapText(ctx, fontLabel, x, currentY, maxWidth, otherFontSize + lineGap);
990
- currentY += result.height;
991
- drawnHeight += result.height;
884
+ // Render "Font: " với font mặc định
885
+ const prefix = "Font: ";
886
+ ctx.font = `${otherFontSize}px ${LAYOUT.FONT_FAMILY}`;
887
+ const prefixWidth = ctx.measureText(prefix).width;
888
+ let currentX = x + prefixWidth;
889
+ ctx.fillText(prefix, x, currentY);
890
+ // Render tên font với font từ config
891
+ ctx.font = `${otherFontSize}px ${position.font}`;
892
+ const fontNameWidth = ctx.measureText(position.font).width;
893
+ ctx.fillText(position.font, currentX, currentY);
894
+ currentX += fontNameWidth;
895
+ // Render "(Mặc định)" hoặc "(Custom)" với font mặc định
896
+ const suffix = position.is_font_default === true ? " (Mặc định)" : " (Custom)";
897
+ ctx.font = `${otherFontSize}px ${LAYOUT.FONT_FAMILY}`;
898
+ ctx.measureText(suffix).width;
899
+ ctx.fillText(suffix, currentX, currentY);
900
+ // Tính toán height và di chuyển cursorY
901
+ const lineHeight = otherFontSize + lineGap;
902
+ currentY += lineHeight;
903
+ drawnHeight += lineHeight;
992
904
  }
993
905
  if (showLabels.color) {
994
906
  const colorValue = position.character_colors?.join(", ") || position.color;