embroidery-qc-image 1.0.35 → 1.0.36
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/components/EmbroideryQCImage.d.ts.map +1 -1
- package/dist/index.esm.js +51 -29
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +51 -29
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -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;AAgLjC,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;AAiiBD,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA2HvD,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;AAgLjC,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;AAiiBD,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA2HvD,CAAC;AAspFF,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
|
@@ -1582,13 +1582,13 @@ const renderSide = (ctx, side, startY, width, height, scaleFactor, imageRefs, mo
|
|
|
1582
1582
|
return currentY - startY;
|
|
1583
1583
|
}
|
|
1584
1584
|
// Compute uniform properties
|
|
1585
|
-
|
|
1586
|
-
|
|
1585
|
+
// Lấy màu từ tất cả ICON positions (sử dụng getIconColors để ưu tiên layer_colors)
|
|
1586
|
+
const iconColorPositions = side.positions.filter((p) => p.type === "ICON");
|
|
1587
1587
|
const iconColorValues = iconColorPositions
|
|
1588
1588
|
.map((p) => {
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
return
|
|
1589
|
+
const iconColors = getIconColors(p);
|
|
1590
|
+
// Join các màu bằng dấu phẩy giống TEXT để so sánh uniform
|
|
1591
|
+
return iconColors?.length ? iconColors.join(",") : null;
|
|
1592
1592
|
})
|
|
1593
1593
|
.filter((color) => Boolean(color));
|
|
1594
1594
|
const uniformProps = computeUniformProperties(textPositions, {
|
|
@@ -1643,38 +1643,62 @@ const renderSide = (ctx, side, startY, width, height, scaleFactor, imageRefs, mo
|
|
|
1643
1643
|
currentY += LAYOUT.LINE_GAP * scaleFactor;
|
|
1644
1644
|
side.positions.forEach((position) => {
|
|
1645
1645
|
if (position.type === "ICON") {
|
|
1646
|
-
const
|
|
1647
|
-
const
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
: position.color ?? null;
|
|
1646
|
+
const iconColors = getIconColors(position);
|
|
1647
|
+
const iconColorValue = iconColors?.length ? iconColors.join(",") : null;
|
|
1648
|
+
// Icon có thể hide color nếu uniform với TEXT, bất kể số lượng màu
|
|
1649
|
+
// (vì TEXT với layer_colors nhiều màu cũng có thể uniform)
|
|
1651
1650
|
const hideColor = shouldShowUniformLabels &&
|
|
1652
1651
|
uniformProps.isUniform.color &&
|
|
1653
1652
|
iconColorValue !== null &&
|
|
1654
|
-
uniformProps.values.color === iconColorValue
|
|
1655
|
-
iconUsesSingleColor;
|
|
1653
|
+
uniformProps.values.color === iconColorValue;
|
|
1656
1654
|
currentY += renderIconPosition(ctx, position, padding, currentY, sideWidth, scaleFactor, imageRefs, { hideColor }, mockupBounds);
|
|
1657
1655
|
currentY += (LAYOUT.LINE_GAP / 3) * scaleFactor;
|
|
1658
1656
|
}
|
|
1659
1657
|
});
|
|
1660
1658
|
return currentY - startY;
|
|
1661
1659
|
};
|
|
1660
|
+
// Helper function để lấy màu từ TEXT position (ưu tiên layer_colors, fallback về character_colors hoặc color)
|
|
1661
|
+
const getTextColors = (position) => {
|
|
1662
|
+
if (position.layer_colors?.length) {
|
|
1663
|
+
return position.layer_colors;
|
|
1664
|
+
}
|
|
1665
|
+
if (position.character_colors?.length) {
|
|
1666
|
+
return position.character_colors;
|
|
1667
|
+
}
|
|
1668
|
+
if (position.color) {
|
|
1669
|
+
return [position.color];
|
|
1670
|
+
}
|
|
1671
|
+
return null;
|
|
1672
|
+
};
|
|
1673
|
+
// Helper function để lấy màu từ ICON position (ưu tiên layer_colors, fallback về color)
|
|
1674
|
+
const getIconColors = (position) => {
|
|
1675
|
+
if (position.layer_colors?.length) {
|
|
1676
|
+
return position.layer_colors;
|
|
1677
|
+
}
|
|
1678
|
+
if (position.color) {
|
|
1679
|
+
return [position.color];
|
|
1680
|
+
}
|
|
1681
|
+
return null;
|
|
1682
|
+
};
|
|
1662
1683
|
const groupTextPositions = (textPositions) => {
|
|
1663
1684
|
const groups = [];
|
|
1664
1685
|
let currentGroup = null;
|
|
1665
1686
|
let currentProps = null;
|
|
1666
1687
|
textPositions.forEach((position) => {
|
|
1688
|
+
const textColors = getTextColors(position);
|
|
1667
1689
|
const posProps = {
|
|
1668
1690
|
font: position.font,
|
|
1669
1691
|
text_shape: position.text_shape,
|
|
1670
1692
|
color: position.color,
|
|
1671
1693
|
character_colors: position.character_colors?.join(","),
|
|
1694
|
+
layer_colors: textColors?.join(","),
|
|
1672
1695
|
};
|
|
1673
1696
|
if (!currentGroup ||
|
|
1674
1697
|
currentProps.font !== posProps.font ||
|
|
1675
1698
|
currentProps.text_shape !== posProps.text_shape ||
|
|
1676
1699
|
currentProps.color !== posProps.color ||
|
|
1677
|
-
currentProps.character_colors !== posProps.character_colors
|
|
1700
|
+
currentProps.character_colors !== posProps.character_colors ||
|
|
1701
|
+
currentProps.layer_colors !== posProps.layer_colors) {
|
|
1678
1702
|
if (currentGroup) {
|
|
1679
1703
|
groups.push(currentGroup);
|
|
1680
1704
|
}
|
|
@@ -1699,9 +1723,12 @@ const computeUniformProperties = (textPositions, options) => {
|
|
|
1699
1723
|
const shapes = new Set(textPositions.map((p) => p.text_shape));
|
|
1700
1724
|
const florals = new Set(textPositions.map((p) => p.floral_pattern ?? "None"));
|
|
1701
1725
|
const colorSources = [
|
|
1702
|
-
...textPositions.map((p) =>
|
|
1703
|
-
|
|
1704
|
-
|
|
1726
|
+
...textPositions.map((p) => {
|
|
1727
|
+
const textColors = getTextColors(p);
|
|
1728
|
+
return textColors?.length
|
|
1729
|
+
? textColors.join(",")
|
|
1730
|
+
: p.color ?? "None";
|
|
1731
|
+
}),
|
|
1705
1732
|
...(options?.additionalColorValues?.map((color) => color ?? "None") ?? []),
|
|
1706
1733
|
];
|
|
1707
1734
|
if (textPositions.length === 0 &&
|
|
@@ -2083,9 +2110,11 @@ displayIndex, showLabels, scaleFactor, imageRefs, mockupBounds = null) => {
|
|
|
2083
2110
|
}
|
|
2084
2111
|
}
|
|
2085
2112
|
if (showLabels.color) {
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2113
|
+
// Ưu tiên layer_colors, fallback về character_colors hoặc color (giống ICON)
|
|
2114
|
+
const textColors = getTextColors(position);
|
|
2115
|
+
if (textColors && textColors.length > 0) {
|
|
2116
|
+
const colorValue = textColors.join(", ");
|
|
2117
|
+
const colors = textColors;
|
|
2089
2118
|
const swatchH = Math.floor(otherFontSize * LAYOUT.SWATCH_HEIGHT_RATIO);
|
|
2090
2119
|
const totalSwatchWidth = calculateSwatchesWidth(colors, swatchH, scaleFactor, imageRefs);
|
|
2091
2120
|
// Tính effectiveMaxWidth cho dòng này để tránh mockup
|
|
@@ -2361,16 +2390,9 @@ const renderIconPosition = (ctx, position, x, y, maxWidth, scaleFactor, imageRef
|
|
|
2361
2390
|
cursorY += iconResult.height;
|
|
2362
2391
|
// Draw color swatches (prefer layer_colors, fallback to single color)
|
|
2363
2392
|
// Nếu icon đã bị xóa thì không cần hiển thị màu chỉ nữa
|
|
2364
|
-
const iconColors = position.is_delete_icon
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
? position.layer_colors
|
|
2368
|
-
: position.color
|
|
2369
|
-
? [position.color]
|
|
2370
|
-
: null;
|
|
2371
|
-
const layerCount = position.layer_colors?.length ?? 0;
|
|
2372
|
-
const hasMultiLayerColors = layerCount > 1;
|
|
2373
|
-
const shouldSkipColorSection = options?.hideColor && !hasMultiLayerColors;
|
|
2393
|
+
const iconColors = position.is_delete_icon ? null : getIconColors(position);
|
|
2394
|
+
// Nếu hideColor = true, ẩn màu của ICON (giống TEXT) bất kể số lượng màu
|
|
2395
|
+
const shouldSkipColorSection = options?.hideColor === true;
|
|
2374
2396
|
if (iconColors?.length && !shouldSkipColorSection) {
|
|
2375
2397
|
// Dòng "Màu chỉ:" của icon dùng OTHER_FONT_SIZE, không dùng iconFontSize
|
|
2376
2398
|
const otherFontSize = LAYOUT.OTHER_FONT_SIZE * scaleFactor;
|