zuljaman-banner-components 1.0.23 → 1.0.25

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 (117) hide show
  1. package/README.md +228 -131
  2. package/dist/components/BannerRenderer/BannerRenderer.d.ts +8 -0
  3. package/dist/components/BannerRenderer/BannerRenderer.d.ts.map +1 -0
  4. package/dist/components/BannerRenderer/BannerRenderer.js +325 -0
  5. package/dist/components/BannerRenderer/components/CopyElement.d.ts +62 -0
  6. package/dist/components/BannerRenderer/components/CopyElement.d.ts.map +1 -0
  7. package/dist/components/BannerRenderer/components/CopyElement.js +220 -0
  8. package/dist/components/BannerRenderer/components/InteractiveLines.d.ts +26 -0
  9. package/dist/components/BannerRenderer/components/InteractiveLines.d.ts.map +1 -0
  10. package/dist/components/BannerRenderer/components/InteractiveLines.js +172 -0
  11. package/dist/components/BannerRenderer/components/LogoElement.d.ts +55 -0
  12. package/dist/components/BannerRenderer/components/LogoElement.d.ts.map +1 -0
  13. package/dist/components/BannerRenderer/components/LogoElement.js +53 -0
  14. package/dist/components/BannerRenderer/components/VisualGuides.d.ts +43 -0
  15. package/dist/components/BannerRenderer/components/VisualGuides.d.ts.map +1 -0
  16. package/dist/components/BannerRenderer/components/VisualGuides.js +110 -0
  17. package/dist/components/BannerRenderer/components/index.d.ts +12 -0
  18. package/dist/components/BannerRenderer/components/index.d.ts.map +1 -0
  19. package/dist/components/BannerRenderer/components/index.js +14 -0
  20. package/dist/components/BannerRenderer/constants.d.ts +15 -0
  21. package/dist/components/BannerRenderer/constants.d.ts.map +1 -0
  22. package/dist/components/BannerRenderer/constants.js +36 -0
  23. package/dist/components/BannerRenderer/hooks/index.d.ts +14 -0
  24. package/dist/components/BannerRenderer/hooks/index.d.ts.map +1 -0
  25. package/dist/components/BannerRenderer/hooks/index.js +16 -0
  26. package/dist/components/BannerRenderer/hooks/useAutoPositioning/debugPositions.d.ts +30 -0
  27. package/dist/components/BannerRenderer/hooks/useAutoPositioning/debugPositions.d.ts.map +1 -0
  28. package/dist/components/BannerRenderer/hooks/useAutoPositioning/debugPositions.js +87 -0
  29. package/dist/components/BannerRenderer/hooks/useAutoPositioning/index.d.ts +13 -0
  30. package/dist/components/BannerRenderer/hooks/useAutoPositioning/index.d.ts.map +1 -0
  31. package/dist/components/BannerRenderer/hooks/useAutoPositioning/index.js +21 -0
  32. package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAnchorEdgeLocking.d.ts +73 -0
  33. package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAnchorEdgeLocking.d.ts.map +1 -0
  34. package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAnchorEdgeLocking.js +151 -0
  35. package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAutoPositioningMain.d.ts +66 -0
  36. package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAutoPositioningMain.d.ts.map +1 -0
  37. package/dist/components/BannerRenderer/hooks/useAutoPositioning/useAutoPositioningMain.js +335 -0
  38. package/dist/components/BannerRenderer/hooks/useAutoPositioning/useChainPositioning.d.ts +61 -0
  39. package/dist/components/BannerRenderer/hooks/useAutoPositioning/useChainPositioning.d.ts.map +1 -0
  40. package/dist/components/BannerRenderer/hooks/useAutoPositioning/useChainPositioning.js +180 -0
  41. package/dist/components/BannerRenderer/hooks/useAutoPositioning/useHeightCompensation.d.ts +60 -0
  42. package/dist/components/BannerRenderer/hooks/useAutoPositioning/useHeightCompensation.d.ts.map +1 -0
  43. package/dist/components/BannerRenderer/hooks/useAutoPositioning/useHeightCompensation.js +178 -0
  44. package/dist/components/BannerRenderer/hooks/useAutoPositioning.d.ts +8 -0
  45. package/dist/components/BannerRenderer/hooks/useAutoPositioning.d.ts.map +1 -0
  46. package/dist/components/BannerRenderer/hooks/useAutoPositioning.js +12 -0
  47. package/dist/components/BannerRenderer/hooks/useDragSnap.d.ts +30 -0
  48. package/dist/components/BannerRenderer/hooks/useDragSnap.d.ts.map +1 -0
  49. package/dist/components/BannerRenderer/hooks/useDragSnap.js +90 -0
  50. package/dist/components/BannerRenderer/hooks/useElementRefs.d.ts +22 -0
  51. package/dist/components/BannerRenderer/hooks/useElementRefs.d.ts.map +1 -0
  52. package/dist/components/BannerRenderer/hooks/useElementRefs.js +70 -0
  53. package/dist/components/BannerRenderer/hooks/useLineDrawing.d.ts +40 -0
  54. package/dist/components/BannerRenderer/hooks/useLineDrawing.d.ts.map +1 -0
  55. package/dist/components/BannerRenderer/hooks/useLineDrawing.js +198 -0
  56. package/dist/components/BannerRenderer/hooks/useProximityDetection.d.ts +43 -0
  57. package/dist/components/BannerRenderer/hooks/useProximityDetection.d.ts.map +1 -0
  58. package/dist/components/BannerRenderer/hooks/useProximityDetection.js +491 -0
  59. package/dist/components/BannerRenderer/index.d.ts +6 -0
  60. package/dist/components/BannerRenderer/index.d.ts.map +1 -0
  61. package/dist/components/BannerRenderer/index.js +8 -0
  62. package/dist/components/{BannerRenderer.d.ts → BannerRenderer/types.d.ts} +29 -8
  63. package/dist/components/BannerRenderer/types.d.ts.map +1 -0
  64. package/dist/components/BannerRenderer/types.js +5 -0
  65. package/dist/components/BannerRenderer/utils/alignmentUtils.d.ts +38 -0
  66. package/dist/components/BannerRenderer/utils/alignmentUtils.d.ts.map +1 -0
  67. package/dist/components/BannerRenderer/utils/alignmentUtils.js +138 -0
  68. package/dist/components/BannerRenderer/utils/elementCheckUtils.d.ts +22 -0
  69. package/dist/components/BannerRenderer/utils/elementCheckUtils.d.ts.map +1 -0
  70. package/dist/components/BannerRenderer/utils/elementCheckUtils.js +37 -0
  71. package/dist/components/BannerRenderer/utils/elementIdUtils.d.ts +25 -0
  72. package/dist/components/BannerRenderer/utils/elementIdUtils.d.ts.map +1 -0
  73. package/dist/components/BannerRenderer/utils/elementIdUtils.js +56 -0
  74. package/dist/components/BannerRenderer/utils/fontUtils.d.ts +12 -0
  75. package/dist/components/BannerRenderer/utils/fontUtils.d.ts.map +1 -0
  76. package/dist/components/BannerRenderer/utils/fontUtils.js +26 -0
  77. package/dist/components/BannerRenderer/utils/graphUtils.d.ts +54 -0
  78. package/dist/components/BannerRenderer/utils/graphUtils.d.ts.map +1 -0
  79. package/dist/components/BannerRenderer/utils/graphUtils.js +138 -0
  80. package/dist/components/BannerRenderer/utils/index.d.ts +12 -0
  81. package/dist/components/BannerRenderer/utils/index.d.ts.map +1 -0
  82. package/dist/components/BannerRenderer/utils/index.js +27 -0
  83. package/dist/components/BannerRenderer/utils/snapUtils.d.ts +38 -0
  84. package/dist/components/BannerRenderer/utils/snapUtils.d.ts.map +1 -0
  85. package/dist/components/BannerRenderer/utils/snapUtils.js +109 -0
  86. package/dist/components/BannerVisor.d.ts.map +1 -1
  87. package/dist/components/BannerVisor.js +8 -1
  88. package/dist/components/index.js +1 -1
  89. package/dist/components/shared/DraggableElement.d.ts +11 -0
  90. package/dist/components/shared/DraggableElement.d.ts.map +1 -1
  91. package/dist/components/shared/DraggableElement.js +47 -51
  92. package/dist/components/styles/Style1/substyleConfig.d.ts.map +1 -1
  93. package/dist/components/styles/Style1/substyleConfig.js +53 -54
  94. package/dist/components/styles/Style2/substyleConfig.js +78 -78
  95. package/dist/components/styles/Style3/substyleConfig.d.ts.map +1 -1
  96. package/dist/components/styles/Style3/substyleConfig.js +40 -37
  97. package/dist/components/styles/Style4/substyleConfig.js +57 -57
  98. package/dist/components/styles/types/substyleTypes.d.ts +32 -15
  99. package/dist/components/styles/types/substyleTypes.d.ts.map +1 -1
  100. package/dist/components/styles/utils/chainValidation.d.ts +41 -0
  101. package/dist/components/styles/utils/chainValidation.d.ts.map +1 -0
  102. package/dist/components/styles/utils/chainValidation.js +148 -0
  103. package/dist/components/styles/utils/positioningUtils.d.ts +207 -11
  104. package/dist/components/styles/utils/positioningUtils.d.ts.map +1 -1
  105. package/dist/components/styles/utils/positioningUtils.js +520 -19
  106. package/dist/constants/characterLimits.d.ts +4 -16
  107. package/dist/constants/characterLimits.d.ts.map +1 -1
  108. package/dist/constants/characterLimits.js +28 -26
  109. package/dist/constants/styleConfigs.js +6 -6
  110. package/dist/styleConfig.d.ts +4 -4
  111. package/dist/styleConfig.d.ts.map +1 -1
  112. package/dist/styleConfig.js +8 -16
  113. package/dist/types.d.ts +42 -0
  114. package/dist/types.d.ts.map +1 -1
  115. package/package.json +1 -1
  116. package/dist/components/BannerRenderer.d.ts.map +0 -1
  117. package/dist/components/BannerRenderer.js +0 -559
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ /**
3
+ * Alignment utility functions for BannerRenderer
4
+ * Pure functions for calculating alignment guides between elements
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.calculateAlignmentLinesBetween = calculateAlignmentLinesBetween;
8
+ exports.calculateAllAlignmentLines = calculateAllAlignmentLines;
9
+ /**
10
+ * Calculate alignment lines between a dragged element and another element.
11
+ * Uses relative bounds (relative to container center).
12
+ *
13
+ * @param dragged - Relative bounds of the dragged element
14
+ * @param other - Relative bounds of the other element
15
+ * @param tolerance - Alignment tolerance in pixels (default: 0.5)
16
+ * @returns Array of alignment lines
17
+ */
18
+ function calculateAlignmentLinesBetween(dragged, other, tolerance = 0.5) {
19
+ const alignments = [];
20
+ // Vertical lines (horizontal alignment)
21
+ // Left alignment
22
+ if (Math.abs(dragged.left - other.left) < tolerance) {
23
+ alignments.push({
24
+ x: dragged.left,
25
+ y1: Math.min(dragged.top, other.top),
26
+ y2: Math.max(dragged.bottom, other.bottom),
27
+ type: 'left',
28
+ orientation: 'vertical',
29
+ });
30
+ }
31
+ // Center alignment
32
+ if (Math.abs(dragged.centerX - other.centerX) < tolerance) {
33
+ alignments.push({
34
+ x: dragged.centerX,
35
+ y1: Math.min(dragged.top, other.top),
36
+ y2: Math.max(dragged.bottom, other.bottom),
37
+ type: 'center',
38
+ orientation: 'vertical',
39
+ });
40
+ }
41
+ // Right alignment
42
+ if (Math.abs(dragged.right - other.right) < tolerance) {
43
+ alignments.push({
44
+ x: dragged.right,
45
+ y1: Math.min(dragged.top, other.top),
46
+ y2: Math.max(dragged.bottom, other.bottom),
47
+ type: 'right',
48
+ orientation: 'vertical',
49
+ });
50
+ }
51
+ // Cross-border: right of dragged with left of other
52
+ if (Math.abs(dragged.right - other.left) < tolerance) {
53
+ alignments.push({
54
+ x: dragged.right,
55
+ y1: Math.min(dragged.top, other.top),
56
+ y2: Math.max(dragged.bottom, other.bottom),
57
+ type: 'right',
58
+ orientation: 'vertical',
59
+ });
60
+ }
61
+ // Cross-border: left of dragged with right of other
62
+ if (Math.abs(dragged.left - other.right) < tolerance) {
63
+ alignments.push({
64
+ x: dragged.left,
65
+ y1: Math.min(dragged.top, other.top),
66
+ y2: Math.max(dragged.bottom, other.bottom),
67
+ type: 'left',
68
+ orientation: 'vertical',
69
+ });
70
+ }
71
+ // Horizontal lines (vertical alignment)
72
+ // Top alignment
73
+ if (Math.abs(dragged.top - other.top) < tolerance) {
74
+ alignments.push({
75
+ y: dragged.top,
76
+ x1: Math.min(dragged.left, other.left),
77
+ x2: Math.max(dragged.right, other.right),
78
+ type: 'top',
79
+ orientation: 'horizontal',
80
+ });
81
+ }
82
+ // Middle alignment
83
+ if (Math.abs(dragged.centerY - other.centerY) < tolerance) {
84
+ alignments.push({
85
+ y: dragged.centerY,
86
+ x1: Math.min(dragged.left, other.left),
87
+ x2: Math.max(dragged.right, other.right),
88
+ type: 'middle',
89
+ orientation: 'horizontal',
90
+ });
91
+ }
92
+ // Bottom alignment
93
+ if (Math.abs(dragged.bottom - other.bottom) < tolerance) {
94
+ alignments.push({
95
+ y: dragged.bottom,
96
+ x1: Math.min(dragged.left, other.left),
97
+ x2: Math.max(dragged.right, other.right),
98
+ type: 'bottom',
99
+ orientation: 'horizontal',
100
+ });
101
+ }
102
+ // Cross-border: bottom of dragged with top of other
103
+ if (Math.abs(dragged.bottom - other.top) < tolerance) {
104
+ alignments.push({
105
+ y: dragged.bottom,
106
+ x1: Math.min(dragged.left, other.left),
107
+ x2: Math.max(dragged.right, other.right),
108
+ type: 'bottom',
109
+ orientation: 'horizontal',
110
+ });
111
+ }
112
+ // Cross-border: top of dragged with bottom of other
113
+ if (Math.abs(dragged.top - other.bottom) < tolerance) {
114
+ alignments.push({
115
+ y: dragged.top,
116
+ x1: Math.min(dragged.left, other.left),
117
+ x2: Math.max(dragged.right, other.right),
118
+ type: 'top',
119
+ orientation: 'horizontal',
120
+ });
121
+ }
122
+ return alignments;
123
+ }
124
+ /**
125
+ * Calculate all alignment lines between a dragged element and multiple other elements.
126
+ *
127
+ * @param dragged - Relative bounds of the dragged element
128
+ * @param others - Array of relative bounds of other elements
129
+ * @param tolerance - Alignment tolerance in pixels (default: 0.5)
130
+ * @returns Array of all alignment lines
131
+ */
132
+ function calculateAllAlignmentLines(dragged, others, tolerance = 0.5) {
133
+ const alignments = [];
134
+ for (const other of others) {
135
+ alignments.push(...calculateAlignmentLinesBetween(dragged, other, tolerance));
136
+ }
137
+ return alignments;
138
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Element check utility functions for BannerRenderer
3
+ * Pure functions for checking element relationships (overlap, alignment)
4
+ */
5
+ /**
6
+ * Check if two elements are overlapping vertically (one on top of the other).
7
+ *
8
+ * @param bounds1 - DOMRect of first element
9
+ * @param bounds2 - DOMRect of second element
10
+ * @returns True if elements have vertical overlap
11
+ */
12
+ export declare function checkElementsOverlapping(bounds1: DOMRect, bounds2: DOMRect): boolean;
13
+ /**
14
+ * Check if two elements are vertically aligned (one above the other).
15
+ *
16
+ * @param bounds1 - DOMRect of first element
17
+ * @param bounds2 - DOMRect of second element
18
+ * @param horizontalThreshold - Maximum horizontal distance between centers (default: 80px)
19
+ * @returns True if elements are vertically aligned
20
+ */
21
+ export declare function checkVerticallyAligned(bounds1: DOMRect, bounds2: DOMRect, horizontalThreshold?: number): boolean;
22
+ //# sourceMappingURL=elementCheckUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elementCheckUtils.d.ts","sourceRoot":"","sources":["../../../../src/components/BannerRenderer/utils/elementCheckUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAOpF;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,mBAAmB,SAAK,GACvB,OAAO,CAST"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ /**
3
+ * Element check utility functions for BannerRenderer
4
+ * Pure functions for checking element relationships (overlap, alignment)
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.checkElementsOverlapping = checkElementsOverlapping;
8
+ exports.checkVerticallyAligned = checkVerticallyAligned;
9
+ /**
10
+ * Check if two elements are overlapping vertically (one on top of the other).
11
+ *
12
+ * @param bounds1 - DOMRect of first element
13
+ * @param bounds2 - DOMRect of second element
14
+ * @returns True if elements have vertical overlap
15
+ */
16
+ function checkElementsOverlapping(bounds1, bounds2) {
17
+ // Check if there's vertical overlap (not just touching)
18
+ // Overlap exists if one element starts before the other ends
19
+ return ((bounds1.top < bounds2.bottom && bounds1.bottom > bounds2.top) ||
20
+ (bounds2.top < bounds1.bottom && bounds2.bottom > bounds1.top));
21
+ }
22
+ /**
23
+ * Check if two elements are vertically aligned (one above the other).
24
+ *
25
+ * @param bounds1 - DOMRect of first element
26
+ * @param bounds2 - DOMRect of second element
27
+ * @param horizontalThreshold - Maximum horizontal distance between centers (default: 80px)
28
+ * @returns True if elements are vertically aligned
29
+ */
30
+ function checkVerticallyAligned(bounds1, bounds2, horizontalThreshold = 80) {
31
+ // Calculate center X positions
32
+ const centerX1 = bounds1.left + bounds1.width / 2;
33
+ const centerX2 = bounds2.left + bounds2.width / 2;
34
+ // Elements are vertically aligned if their center X positions are close
35
+ const horizontalDiff = Math.abs(centerX1 - centerX2);
36
+ return horizontalDiff <= horizontalThreshold;
37
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Element ID utility functions for BannerRenderer
3
+ * Handles conversion between different ID formats
4
+ */
5
+ import type { CopyConfig } from "../../../types";
6
+ /**
7
+ * Convert element ID from copy-{uuid} to copy-{N} (styleSlot) format.
8
+ * This normalizes IDs to use the canonical copy-N format for storage in completedLines.
9
+ *
10
+ * @param elementId - Element ID in either format ('logo', 'copy-{uuid}', or 'copy-{N}')
11
+ * @param copies - Array of copy configurations
12
+ * @returns Normalized element ID in copy-N format
13
+ */
14
+ export declare function convertToStyleSlotId(elementId: string, copies: CopyConfig[]): string;
15
+ /**
16
+ * Parse element ID to extract the copy index or identify logo.
17
+ *
18
+ * @param elementId - Element ID ('logo' or 'copy-{N}')
19
+ * @returns Object with type and optional index
20
+ */
21
+ export declare function parseElementId(elementId: string): {
22
+ type: 'logo' | 'copy';
23
+ index?: number;
24
+ };
25
+ //# sourceMappingURL=elementIdUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elementIdUtils.d.ts","sourceRoot":"","sources":["../../../../src/components/BannerRenderer/utils/elementIdUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,CAyBpF;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAa3F"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ /**
3
+ * Element ID utility functions for BannerRenderer
4
+ * Handles conversion between different ID formats
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.convertToStyleSlotId = convertToStyleSlotId;
8
+ exports.parseElementId = parseElementId;
9
+ /**
10
+ * Convert element ID from copy-{uuid} to copy-{N} (styleSlot) format.
11
+ * This normalizes IDs to use the canonical copy-N format for storage in completedLines.
12
+ *
13
+ * @param elementId - Element ID in either format ('logo', 'copy-{uuid}', or 'copy-{N}')
14
+ * @param copies - Array of copy configurations
15
+ * @returns Normalized element ID in copy-N format
16
+ */
17
+ function convertToStyleSlotId(elementId, copies) {
18
+ if (elementId === 'logo')
19
+ return 'logo';
20
+ if (elementId.startsWith('copy-')) {
21
+ const suffix = elementId.substring(5); // Remove 'copy-' prefix
22
+ // Check if it's already in copy-N format (just a number)
23
+ if (/^\d+$/.test(suffix)) {
24
+ return elementId; // Already in correct format
25
+ }
26
+ // It's a UUID format - find the copy and get its styleSlot
27
+ const copy = copies.find(c => c.id === suffix);
28
+ if ((copy === null || copy === void 0 ? void 0 : copy.styleSlot) !== undefined) {
29
+ return `copy-${copy.styleSlot}`;
30
+ }
31
+ // Fallback: use array index if styleSlot not defined
32
+ const copyIndex = copies.findIndex(c => c.id === suffix);
33
+ if (copyIndex !== -1) {
34
+ return `copy-${copyIndex}`;
35
+ }
36
+ }
37
+ return elementId;
38
+ }
39
+ /**
40
+ * Parse element ID to extract the copy index or identify logo.
41
+ *
42
+ * @param elementId - Element ID ('logo' or 'copy-{N}')
43
+ * @returns Object with type and optional index
44
+ */
45
+ function parseElementId(elementId) {
46
+ if (elementId === 'logo') {
47
+ return { type: 'logo' };
48
+ }
49
+ if (elementId.startsWith('copy-')) {
50
+ const suffix = elementId.substring(5);
51
+ if (/^\d+$/.test(suffix)) {
52
+ return { type: 'copy', index: parseInt(suffix, 10) };
53
+ }
54
+ }
55
+ return { type: 'copy' };
56
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Font utility functions for BannerRenderer
3
+ */
4
+ /**
5
+ * Convert font weight string to CSS numeric value.
6
+ * Supports both numeric strings ('400', '700') and named values ('thin', 'normal', 'bold').
7
+ *
8
+ * @param weight - Font weight as string (numeric or named)
9
+ * @returns CSS-compatible font weight value
10
+ */
11
+ export declare function getFontWeight(weight: string): string;
12
+ //# sourceMappingURL=fontUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fontUtils.d.ts","sourceRoot":"","sources":["../../../../src/components/BannerRenderer/utils/fontUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAYpD"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ /**
3
+ * Font utility functions for BannerRenderer
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getFontWeight = getFontWeight;
7
+ /**
8
+ * Convert font weight string to CSS numeric value.
9
+ * Supports both numeric strings ('400', '700') and named values ('thin', 'normal', 'bold').
10
+ *
11
+ * @param weight - Font weight as string (numeric or named)
12
+ * @returns CSS-compatible font weight value
13
+ */
14
+ function getFontWeight(weight) {
15
+ // If it's already a numeric string, return it directly
16
+ if (/^\d+$/.test(weight)) {
17
+ return weight;
18
+ }
19
+ // Otherwise, map old string values to numeric equivalents
20
+ switch (weight) {
21
+ case 'thin': return '300';
22
+ case 'normal': return '400';
23
+ case 'bold': return '700';
24
+ default: return '400';
25
+ }
26
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Graph utility functions for BannerRenderer
3
+ * Union-Find data structure and proximity graph algorithms
4
+ */
5
+ /**
6
+ * Union-Find (Disjoint Set) data structure with path compression
7
+ */
8
+ export declare class UnionFind {
9
+ private parent;
10
+ constructor(elements: string[]);
11
+ /**
12
+ * Find the root of an element with path compression
13
+ */
14
+ find(id: string): string;
15
+ /**
16
+ * Union two elements into the same set
17
+ */
18
+ union(id1: string, id2: string): void;
19
+ /**
20
+ * Group all elements by their root (connected components)
21
+ */
22
+ getClusters(): Map<string, string[]>;
23
+ }
24
+ /**
25
+ * Calculate the distance between two DOMRects (edge-to-edge)
26
+ */
27
+ export declare function calculateBoundsDistance(bounds1: DOMRect, bounds2: DOMRect): number;
28
+ /**
29
+ * Build an adjacency graph based on proximity threshold.
30
+ * Returns a map where each element ID maps to a set of neighboring element IDs.
31
+ *
32
+ * @param elementBounds - Map of element IDs to their bounding rects
33
+ * @param proximityThreshold - Maximum distance (in pixels) to consider elements as neighbors
34
+ * @param sizeMultiplier - Size multiplier to scale the distance
35
+ * @returns Adjacency graph
36
+ */
37
+ export declare function buildProximityGraph(elementBounds: Map<string, DOMRect>, proximityThreshold: number, sizeMultiplier?: number): Map<string, Set<string>>;
38
+ /**
39
+ * Find connected clusters from an adjacency graph using Union-Find
40
+ *
41
+ * @param adjacencyGraph - Graph of element connections
42
+ * @returns Map of cluster root to array of element IDs in that cluster
43
+ */
44
+ export declare function findConnectedClusters(adjacencyGraph: Map<string, Set<string>>): Map<string, string[]>;
45
+ /**
46
+ * Create a linear chain of elements ordered by Y position within each cluster.
47
+ * Returns a map where each element (except the last in chain) points to the next.
48
+ *
49
+ * @param clusters - Map of cluster root to element IDs
50
+ * @param elementBounds - Map of element IDs to bounding rects
51
+ * @returns Map of sourceId to targetId representing the chain links
52
+ */
53
+ export declare function createLinearChains(clusters: Map<string, string[]>, elementBounds: Map<string, DOMRect>): Map<string, string>;
54
+ //# sourceMappingURL=graphUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphUtils.d.ts","sourceRoot":"","sources":["../../../../src/components/BannerRenderer/utils/graphUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAsB;gBAExB,QAAQ,EAAE,MAAM,EAAE;IAK9B;;OAEG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAQxB;;OAEG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IAQrC;;OAEG;IACH,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;CAWrC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAYlF;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,kBAAkB,EAAE,MAAM,EAC1B,cAAc,SAAM,GACnB,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAyB1B;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,GACvC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAYvB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAC/B,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAsBrB"}
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ /**
3
+ * Graph utility functions for BannerRenderer
4
+ * Union-Find data structure and proximity graph algorithms
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.UnionFind = void 0;
8
+ exports.calculateBoundsDistance = calculateBoundsDistance;
9
+ exports.buildProximityGraph = buildProximityGraph;
10
+ exports.findConnectedClusters = findConnectedClusters;
11
+ exports.createLinearChains = createLinearChains;
12
+ /**
13
+ * Union-Find (Disjoint Set) data structure with path compression
14
+ */
15
+ class UnionFind {
16
+ constructor(elements) {
17
+ this.parent = new Map();
18
+ elements.forEach(id => this.parent.set(id, id));
19
+ }
20
+ /**
21
+ * Find the root of an element with path compression
22
+ */
23
+ find(id) {
24
+ const p = this.parent.get(id);
25
+ if (p !== id) {
26
+ this.parent.set(id, this.find(p)); // Path compression
27
+ }
28
+ return this.parent.get(id);
29
+ }
30
+ /**
31
+ * Union two elements into the same set
32
+ */
33
+ union(id1, id2) {
34
+ const root1 = this.find(id1);
35
+ const root2 = this.find(id2);
36
+ if (root1 !== root2) {
37
+ this.parent.set(root2, root1);
38
+ }
39
+ }
40
+ /**
41
+ * Group all elements by their root (connected components)
42
+ */
43
+ getClusters() {
44
+ const clusters = new Map();
45
+ this.parent.forEach((_, id) => {
46
+ const root = this.find(id);
47
+ if (!clusters.has(root)) {
48
+ clusters.set(root, []);
49
+ }
50
+ clusters.get(root).push(id);
51
+ });
52
+ return clusters;
53
+ }
54
+ }
55
+ exports.UnionFind = UnionFind;
56
+ /**
57
+ * Calculate the distance between two DOMRects (edge-to-edge)
58
+ */
59
+ function calculateBoundsDistance(bounds1, bounds2) {
60
+ const dx = Math.max(bounds1.left - bounds2.right, bounds2.left - bounds1.right, 0);
61
+ const dy = Math.max(bounds1.top - bounds2.bottom, bounds2.top - bounds1.bottom, 0);
62
+ return Math.sqrt(dx * dx + dy * dy);
63
+ }
64
+ /**
65
+ * Build an adjacency graph based on proximity threshold.
66
+ * Returns a map where each element ID maps to a set of neighboring element IDs.
67
+ *
68
+ * @param elementBounds - Map of element IDs to their bounding rects
69
+ * @param proximityThreshold - Maximum distance (in pixels) to consider elements as neighbors
70
+ * @param sizeMultiplier - Size multiplier to scale the distance
71
+ * @returns Adjacency graph
72
+ */
73
+ function buildProximityGraph(elementBounds, proximityThreshold, sizeMultiplier = 1.0) {
74
+ const adjacencyGraph = new Map();
75
+ const elementIds = Array.from(elementBounds.keys());
76
+ // Initialize graph
77
+ elementIds.forEach(id => adjacencyGraph.set(id, new Set()));
78
+ // Build edges based on proximity
79
+ for (let i = 0; i < elementIds.length; i++) {
80
+ for (let j = i + 1; j < elementIds.length; j++) {
81
+ const id1 = elementIds[i];
82
+ const id2 = elementIds[j];
83
+ const bounds1 = elementBounds.get(id1);
84
+ const bounds2 = elementBounds.get(id2);
85
+ const distance = calculateBoundsDistance(bounds1, bounds2) / sizeMultiplier;
86
+ if (distance <= proximityThreshold) {
87
+ adjacencyGraph.get(id1).add(id2);
88
+ adjacencyGraph.get(id2).add(id1);
89
+ }
90
+ }
91
+ }
92
+ return adjacencyGraph;
93
+ }
94
+ /**
95
+ * Find connected clusters from an adjacency graph using Union-Find
96
+ *
97
+ * @param adjacencyGraph - Graph of element connections
98
+ * @returns Map of cluster root to array of element IDs in that cluster
99
+ */
100
+ function findConnectedClusters(adjacencyGraph) {
101
+ const elementIds = Array.from(adjacencyGraph.keys());
102
+ const uf = new UnionFind(elementIds);
103
+ // Build clusters by unioning connected elements
104
+ elementIds.forEach(id => {
105
+ adjacencyGraph.get(id).forEach(neighbor => {
106
+ uf.union(id, neighbor);
107
+ });
108
+ });
109
+ return uf.getClusters();
110
+ }
111
+ /**
112
+ * Create a linear chain of elements ordered by Y position within each cluster.
113
+ * Returns a map where each element (except the last in chain) points to the next.
114
+ *
115
+ * @param clusters - Map of cluster root to element IDs
116
+ * @param elementBounds - Map of element IDs to bounding rects
117
+ * @returns Map of sourceId to targetId representing the chain links
118
+ */
119
+ function createLinearChains(clusters, elementBounds) {
120
+ const chains = new Map();
121
+ clusters.forEach((clusterElements) => {
122
+ if (clusterElements.length < 2)
123
+ return; // Single element, no chain needed
124
+ // Sort by Y position (top to bottom)
125
+ const sorted = [...clusterElements].sort((id1, id2) => {
126
+ const bounds1 = elementBounds.get(id1);
127
+ const bounds2 = elementBounds.get(id2);
128
+ const y1 = bounds1.top + bounds1.height / 2;
129
+ const y2 = bounds2.top + bounds2.height / 2;
130
+ return y1 - y2;
131
+ });
132
+ // Create sequential links
133
+ for (let i = 0; i < sorted.length - 1; i++) {
134
+ chains.set(sorted[i], sorted[i + 1]);
135
+ }
136
+ });
137
+ return chains;
138
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * BannerRenderer utility functions
3
+ */
4
+ export { getFontWeight } from './fontUtils';
5
+ export { snapRotation, toRelativeBounds, calculateSnapDelta } from './snapUtils';
6
+ export type { RelativeBounds } from './snapUtils';
7
+ export { convertToStyleSlotId, parseElementId } from './elementIdUtils';
8
+ export { checkElementsOverlapping, checkVerticallyAligned } from './elementCheckUtils';
9
+ export { calculateAlignmentLinesBetween, calculateAllAlignmentLines } from './alignmentUtils';
10
+ export type { AlignmentLine } from './alignmentUtils';
11
+ export { UnionFind, calculateBoundsDistance, buildProximityGraph, findConnectedClusters, createLinearChains } from './graphUtils';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/BannerRenderer/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjF,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,8BAA8B,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9F,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ /**
3
+ * BannerRenderer utility functions
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createLinearChains = exports.findConnectedClusters = exports.buildProximityGraph = exports.calculateBoundsDistance = exports.UnionFind = exports.calculateAllAlignmentLines = exports.calculateAlignmentLinesBetween = exports.checkVerticallyAligned = exports.checkElementsOverlapping = exports.parseElementId = exports.convertToStyleSlotId = exports.calculateSnapDelta = exports.toRelativeBounds = exports.snapRotation = exports.getFontWeight = void 0;
7
+ var fontUtils_1 = require("./fontUtils");
8
+ Object.defineProperty(exports, "getFontWeight", { enumerable: true, get: function () { return fontUtils_1.getFontWeight; } });
9
+ var snapUtils_1 = require("./snapUtils");
10
+ Object.defineProperty(exports, "snapRotation", { enumerable: true, get: function () { return snapUtils_1.snapRotation; } });
11
+ Object.defineProperty(exports, "toRelativeBounds", { enumerable: true, get: function () { return snapUtils_1.toRelativeBounds; } });
12
+ Object.defineProperty(exports, "calculateSnapDelta", { enumerable: true, get: function () { return snapUtils_1.calculateSnapDelta; } });
13
+ var elementIdUtils_1 = require("./elementIdUtils");
14
+ Object.defineProperty(exports, "convertToStyleSlotId", { enumerable: true, get: function () { return elementIdUtils_1.convertToStyleSlotId; } });
15
+ Object.defineProperty(exports, "parseElementId", { enumerable: true, get: function () { return elementIdUtils_1.parseElementId; } });
16
+ var elementCheckUtils_1 = require("./elementCheckUtils");
17
+ Object.defineProperty(exports, "checkElementsOverlapping", { enumerable: true, get: function () { return elementCheckUtils_1.checkElementsOverlapping; } });
18
+ Object.defineProperty(exports, "checkVerticallyAligned", { enumerable: true, get: function () { return elementCheckUtils_1.checkVerticallyAligned; } });
19
+ var alignmentUtils_1 = require("./alignmentUtils");
20
+ Object.defineProperty(exports, "calculateAlignmentLinesBetween", { enumerable: true, get: function () { return alignmentUtils_1.calculateAlignmentLinesBetween; } });
21
+ Object.defineProperty(exports, "calculateAllAlignmentLines", { enumerable: true, get: function () { return alignmentUtils_1.calculateAllAlignmentLines; } });
22
+ var graphUtils_1 = require("./graphUtils");
23
+ Object.defineProperty(exports, "UnionFind", { enumerable: true, get: function () { return graphUtils_1.UnionFind; } });
24
+ Object.defineProperty(exports, "calculateBoundsDistance", { enumerable: true, get: function () { return graphUtils_1.calculateBoundsDistance; } });
25
+ Object.defineProperty(exports, "buildProximityGraph", { enumerable: true, get: function () { return graphUtils_1.buildProximityGraph; } });
26
+ Object.defineProperty(exports, "findConnectedClusters", { enumerable: true, get: function () { return graphUtils_1.findConnectedClusters; } });
27
+ Object.defineProperty(exports, "createLinearChains", { enumerable: true, get: function () { return graphUtils_1.createLinearChains; } });
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Snap utility functions for BannerRenderer
3
+ * Pure functions for snapping positions and rotations
4
+ */
5
+ /**
6
+ * Snap angle to nearest cardinal direction (0°, 90°, 180°, 270°)
7
+ * @param angle - Input angle in degrees
8
+ * @param snapThreshold - Degrees threshold for snapping (default: 3)
9
+ * @returns Snapped angle or normalized input angle
10
+ */
11
+ export declare function snapRotation(angle: number, snapThreshold?: number): number;
12
+ /**
13
+ * Element bounds relative to a container center
14
+ */
15
+ export interface RelativeBounds {
16
+ left: number;
17
+ centerX: number;
18
+ right: number;
19
+ top: number;
20
+ centerY: number;
21
+ bottom: number;
22
+ }
23
+ /**
24
+ * Convert DOMRect to relative bounds (relative to container center)
25
+ */
26
+ export declare function toRelativeBounds(bounds: DOMRect, containerBounds: DOMRect, sizeMultiplier: number): RelativeBounds;
27
+ /**
28
+ * Calculate snap delta for position alignment
29
+ * @param draggedBounds - Bounds of the element being dragged
30
+ * @param otherBoundsArray - Array of other elements' bounds to snap to
31
+ * @param snapThreshold - Pixel threshold for snapping (default: 5)
32
+ * @returns Delta to apply to position for snapping
33
+ */
34
+ export declare function calculateSnapDelta(draggedBounds: RelativeBounds, otherBoundsArray: RelativeBounds[], snapThreshold?: number): {
35
+ deltaX: number;
36
+ deltaY: number;
37
+ };
38
+ //# sourceMappingURL=snapUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapUtils.d.ts","sourceRoot":"","sources":["../../../../src/components/BannerRenderer/utils/snapUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,SAAI,GAAG,MAAM,CAgBrE;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,OAAO,EACf,eAAe,EAAE,OAAO,EACxB,cAAc,EAAE,MAAM,GACrB,cAAc,CAShB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,cAAc,EAC7B,gBAAgB,EAAE,cAAc,EAAE,EAClC,aAAa,SAAI,GAChB;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAoDpC"}