@onetype/framework 2.0.26 → 2.0.27

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 (65) hide show
  1. package/addons/core/assets/back/functions/utils/transform.js +1 -1
  2. package/addons/render/directives/front/js/functions/process/data.js +0 -1
  3. package/addons/render/transforms/addon.js +2 -0
  4. package/addons/render/transforms/functions/data.js +21 -0
  5. package/addons/render/transforms/functions/run.js +11 -0
  6. package/addons/render/transforms/item/functions/load.js +55 -0
  7. package/addons/render/transforms/item/functions/run.js +12 -0
  8. package/addons/render/transforms/items/directives/transform.js +15 -18
  9. package/lib/items/elements/global/heading/heading.css +1 -1
  10. package/lib/items/elements/global/markdown/markdown.js +207 -3
  11. package/lib/items/elements/{sections → navigation}/navbar/navbar.css +9 -9
  12. package/lib/items/elements/{sections → navigation}/navbar/navbar.js +2 -2
  13. package/lib/items/elements/navigation/sidebar/sidebar.css +101 -0
  14. package/lib/items/elements/navigation/sidebar/sidebar.js +56 -0
  15. package/lib/items/elements/{global → navigation}/tabs/tabs.css +6 -6
  16. package/lib/items/elements/{global → navigation}/tabs/tabs.js +2 -2
  17. package/lib/items/elements/sections/pricing/pricing.css +148 -0
  18. package/lib/items/elements/sections/pricing/pricing.js +76 -0
  19. package/lib/items/transforms/accordion/accordion.js +139 -141
  20. package/lib/items/transforms/chart/area.js +130 -133
  21. package/lib/items/transforms/chart/bar.js +116 -119
  22. package/lib/items/transforms/chart/bubble.js +142 -145
  23. package/lib/items/transforms/chart/doughnut.js +104 -107
  24. package/lib/items/transforms/chart/line.js +127 -130
  25. package/lib/items/transforms/chart/pie.js +102 -105
  26. package/lib/items/transforms/chart/radar.js +134 -137
  27. package/lib/items/transforms/chart/scatter.js +127 -130
  28. package/lib/items/transforms/codeflask/codeflask.js +10 -12
  29. package/lib/items/transforms/codemirror/codemirror.js +186 -189
  30. package/lib/items/transforms/comparison/comparison.js +130 -133
  31. package/lib/items/transforms/heatmap/heatmap.js +406 -407
  32. package/lib/items/transforms/interact/interact.js +240 -241
  33. package/lib/items/transforms/particles/particles.js +282 -283
  34. package/lib/items/transforms/sparkline/sparkline.js +207 -208
  35. package/lib/items/transforms/swiper/swiper.js +115 -118
  36. package/lib/items/transforms/tabs/tabs.js +383 -384
  37. package/lib/items/transforms/typed/typed.js +146 -147
  38. package/lib/load.js +8 -16
  39. package/lib/src/mixins/addons.js +10 -10
  40. package/lib/styles/variables.css +1 -1
  41. package/package.json +1 -1
  42. package/addons/render/transforms/functions/load/assets.js +0 -49
  43. /package/{addons/render/directives/front/js/items → lib/items/directives}/100-if.js +0 -0
  44. /package/{addons/render/directives/front/js/items → lib/items/directives}/1000-render.js +0 -0
  45. /package/{addons/render/directives/front/js/items → lib/items/directives}/110-show.js +0 -0
  46. /package/{addons/render/directives/front/js/items → lib/items/directives}/160-slot.js +0 -0
  47. /package/{addons/render/directives/front/js/items → lib/items/directives}/200-for.js +0 -0
  48. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-blur.js +0 -0
  49. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-change.js +0 -0
  50. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-click-outside.js +0 -0
  51. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-click.js +0 -0
  52. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-double-click.js +0 -0
  53. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-focus.js +0 -0
  54. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-input.js +0 -0
  55. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-keydown.js +0 -0
  56. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-keyup.js +0 -0
  57. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-mouse-enter.js +0 -0
  58. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-mouse-leave.js +0 -0
  59. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-mouse-move.js +0 -0
  60. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-scroll.js +0 -0
  61. /package/{addons/render/directives/front/js/items → lib/items/directives}/500-submit.js +0 -0
  62. /package/{addons/render/directives/front/js/items → lib/items/directives}/650-fetch.js +0 -0
  63. /package/{addons/render/directives/front/js/items → lib/items/directives}/660-form.js +0 -0
  64. /package/{addons/render/directives/front/js/items → lib/items/directives}/700-text.js +0 -0
  65. /package/{addons/render/directives/front/js/items → lib/items/directives}/750-html.js +0 -0
@@ -1,494 +1,493 @@
1
- onetype.AddonReady('transforms', (transforms) =>
2
- {
3
- transforms.ItemAdd({
4
- id: 'heatmap',
5
- icon: 'gradient',
6
- name: 'Heatmap',
7
- description: 'Visual heatmap data representation. Display data density with color-coded intensity maps.',
8
- js: [
9
- 'https://cdn.jsdelivr.net/npm/heatmap.js@2.0.5/build/heatmap.min.js'
10
- ],
11
- config: {
12
- 'data': ['array', []],
13
- 'max-value': ['number', 100],
14
- 'min-opacity': ['number', 0],
15
- 'max-opacity': ['number', 0.6],
16
- 'radius': ['number', 40],
17
- 'blur': ['number', 0.75],
18
- 'gradient': ['object', {}],
19
- 'container-height': ['number', 400],
20
- 'background-color': ['string', 'transparent'],
21
- 'background-image': ['string', ''],
22
- 'click-tracking': ['boolean', false],
23
- 'move-tracking': ['boolean', false],
24
- 'scroll-tracking': ['boolean', false],
25
- 'touch-tracking': ['boolean', false],
26
- 'auto-resize': ['boolean', true],
27
- 'show-tooltip': ['boolean', false],
28
- 'show-legend': ['boolean', false],
29
- 'legend-position': ['string', 'br'], // tl, tr, bl, br
30
- 'debug': ['boolean', false]
31
- },
32
- code: function(data, item, compile, node, identifier)
1
+ transforms.ItemAdd({
2
+ id: 'heatmap',
3
+ icon: 'gradient',
4
+ name: 'Heatmap',
5
+ description: 'Visual heatmap data representation. Display data density with color-coded intensity maps.',
6
+ js: [
7
+ 'https://cdn.jsdelivr.net/npm/heatmap.js@2.0.5/build/heatmap.min.js'
8
+ ],
9
+ config: {
10
+ 'data': ['array', []],
11
+ 'max-value': ['number', 100],
12
+ 'min-opacity': ['number', 0],
13
+ 'max-opacity': ['number', 0.6],
14
+ 'radius': ['number', 40],
15
+ 'blur': ['number', 0.75],
16
+ 'gradient': ['object', {}],
17
+ 'container-height': ['number', 400],
18
+ 'background-color': ['string', 'transparent'],
19
+ 'background-image': ['string', ''],
20
+ 'click-tracking': ['boolean', false],
21
+ 'move-tracking': ['boolean', false],
22
+ 'scroll-tracking': ['boolean', false],
23
+ 'touch-tracking': ['boolean', false],
24
+ 'auto-resize': ['boolean', true],
25
+ 'show-tooltip': ['boolean', false],
26
+ 'show-legend': ['boolean', false],
27
+ 'legend-position': ['string', 'br'], // tl, tr, bl, br
28
+ 'debug': ['boolean', false]
29
+ },
30
+ code: function(data, node, transformer)
31
+ {
32
+ const id = 'heatmap-' + onetype.Generate(8);
33
+
34
+ this.setup = () =>
33
35
  {
34
- this.setup = () =>
35
- {
36
- node.classList.add('heatmap');
37
- node.classList.add('heatmap-' + identifier);
36
+ node.classList.add('heatmap');
37
+ node.classList.add(id);
38
38
 
39
- // Set container styles
40
- node.style.position = 'relative';
41
- node.style.height = data['container-height'].value + 'px';
42
- node.style.backgroundColor = data['background-color'].value;
39
+ // Set container styles
40
+ node.style.position = 'relative';
41
+ node.style.height = data['container-height'] + 'px';
42
+ node.style.backgroundColor = data['background-color'];
43
43
 
44
- if(data['background-image'].value)
45
- {
46
- node.style.backgroundImage = `url(${data['background-image'].value})`;
47
- node.style.backgroundSize = 'cover';
48
- node.style.backgroundPosition = 'center';
49
- }
44
+ if(data['background-image'])
45
+ {
46
+ node.style.backgroundImage = `url(${data['background-image']})`;
47
+ node.style.backgroundSize = 'cover';
48
+ node.style.backgroundPosition = 'center';
49
+ }
50
+
51
+ // Create heatmap container
52
+ const heatmapContainer = document.createElement('div');
53
+ heatmapContainer.className = 'heatmap-container';
54
+ heatmapContainer.style.position = 'absolute';
55
+ heatmapContainer.style.top = '0';
56
+ heatmapContainer.style.left = '0';
57
+ heatmapContainer.style.width = '100%';
58
+ heatmapContainer.style.height = '100%';
59
+
60
+ // Preserve existing content if any
61
+ const children = Array.from(node.children);
62
+ if(children.length > 0)
63
+ {
64
+ const contentWrapper = document.createElement('div');
65
+ contentWrapper.className = 'heatmap-content';
66
+ contentWrapper.style.position = 'relative';
67
+ contentWrapper.style.zIndex = '2';
50
68
 
51
- // Create heatmap container
52
- const heatmapContainer = document.createElement('div');
53
- heatmapContainer.className = 'heatmap-container';
54
- heatmapContainer.style.position = 'absolute';
55
- heatmapContainer.style.top = '0';
56
- heatmapContainer.style.left = '0';
57
- heatmapContainer.style.width = '100%';
58
- heatmapContainer.style.height = '100%';
59
-
60
- // Preserve existing content if any
61
- const children = Array.from(node.children);
62
- if(children.length > 0)
63
- {
64
- const contentWrapper = document.createElement('div');
65
- contentWrapper.className = 'heatmap-content';
66
- contentWrapper.style.position = 'relative';
67
- contentWrapper.style.zIndex = '2';
69
+ children.forEach(child => contentWrapper.appendChild(child));
70
+ node.appendChild(contentWrapper);
71
+ }
68
72
 
69
- children.forEach(child => contentWrapper.appendChild(child));
70
- node.appendChild(contentWrapper);
71
- }
73
+ node.insertBefore(heatmapContainer, node.firstChild);
74
+ this.container = heatmapContainer;
75
+ };
72
76
 
73
- node.insertBefore(heatmapContainer, node.firstChild);
74
- this.container = heatmapContainer;
75
- };
77
+ this.gradient = () =>
78
+ {
79
+ const customGradient = data['gradient'];
76
80
 
77
- this.gradient = () =>
81
+ // Default gradients based on use case
82
+ if(Object.keys(customGradient).length === 0)
78
83
  {
79
- const customGradient = data['gradient'].value;
84
+ return {
85
+ '.00': 'rgb(0,0,255)',
86
+ '.25': 'rgb(0,255,255)',
87
+ '.50': 'rgb(0,255,0)',
88
+ '.75': 'rgb(255,255,0)',
89
+ '1.0': 'rgb(255,0,0)'
90
+ };
91
+ }
80
92
 
81
- // Default gradients based on use case
82
- if(Object.keys(customGradient).length === 0)
83
- {
84
- return {
85
- '.00': 'rgb(0,0,255)',
86
- '.25': 'rgb(0,255,255)',
87
- '.50': 'rgb(0,255,0)',
88
- '.75': 'rgb(255,255,0)',
89
- '1.0': 'rgb(255,0,0)'
90
- };
91
- }
93
+ return customGradient;
94
+ };
92
95
 
93
- return customGradient;
96
+ this.config = () =>
97
+ {
98
+ return {
99
+ container: this.container,
100
+ radius: data['radius'],
101
+ maxOpacity: data['max-opacity'],
102
+ minOpacity: data['min-opacity'],
103
+ blur: data['blur'],
104
+ gradient: this.gradient()
94
105
  };
106
+ };
95
107
 
96
- this.config = () =>
108
+ this.sampleData = () =>
109
+ {
110
+ // Generate sample data if none provided
111
+ const width = node.offsetWidth;
112
+ const height = node.offsetHeight;
113
+ const points = [];
114
+
115
+ // Create interesting sample pattern
116
+ for(let i = 0; i < 50; i++)
97
117
  {
98
- return {
99
- container: this.container,
100
- radius: data['radius'].value,
101
- maxOpacity: data['max-opacity'].value,
102
- minOpacity: data['min-opacity'].value,
103
- blur: data['blur'].value,
104
- gradient: this.gradient()
105
- };
106
- };
118
+ points.push({
119
+ x: Math.floor(Math.random() * width),
120
+ y: Math.floor(Math.random() * height),
121
+ value: Math.floor(Math.random() * 100)
122
+ });
123
+ }
107
124
 
108
- this.sampleData = () =>
125
+ // Add some hotspots
126
+ for(let i = 0; i < 5; i++)
109
127
  {
110
- // Generate sample data if none provided
111
- const width = node.offsetWidth;
112
- const height = node.offsetHeight;
113
- const points = [];
128
+ const x = Math.floor(Math.random() * width);
129
+ const y = Math.floor(Math.random() * height);
114
130
 
115
- // Create interesting sample pattern
116
- for(let i = 0; i < 50; i++)
131
+ for(let j = 0; j < 20; j++)
117
132
  {
118
133
  points.push({
119
- x: Math.floor(Math.random() * width),
120
- y: Math.floor(Math.random() * height),
121
- value: Math.floor(Math.random() * 100)
134
+ x: x + (Math.random() - 0.5) * 100,
135
+ y: y + (Math.random() - 0.5) * 100,
136
+ value: 80 + Math.floor(Math.random() * 20)
122
137
  });
123
138
  }
139
+ }
124
140
 
125
- // Add some hotspots
126
- for(let i = 0; i < 5; i++)
127
- {
128
- const x = Math.floor(Math.random() * width);
129
- const y = Math.floor(Math.random() * height);
130
-
131
- for(let j = 0; j < 20; j++)
132
- {
133
- points.push({
134
- x: x + (Math.random() - 0.5) * 100,
135
- y: y + (Math.random() - 0.5) * 100,
136
- value: 80 + Math.floor(Math.random() * 20)
137
- });
138
- }
139
- }
141
+ return points;
142
+ };
140
143
 
141
- return points;
142
- };
144
+ this.processData = () =>
145
+ {
146
+ const inputData = data['data'];
143
147
 
144
- this.processData = () =>
148
+ if(!inputData || inputData.length === 0)
145
149
  {
146
- const inputData = data['data'].value;
147
-
148
- if(!inputData || inputData.length === 0)
149
- {
150
- return {
151
- max: data['max-value'].value,
152
- data: this.sampleData()
153
- };
154
- }
155
-
156
- // Ensure data points have correct format
157
- const processedData = inputData.map(point => ({
158
- x: parseInt(point.x || 0),
159
- y: parseInt(point.y || 0),
160
- value: parseInt(point.value || 1)
161
- }));
162
-
163
150
  return {
164
- max: data['max-value'].value,
165
- data: processedData
151
+ max: data['max-value'],
152
+ data: this.sampleData()
166
153
  };
154
+ }
155
+
156
+ // Ensure data points have correct format
157
+ const processedData = inputData.map(point => ({
158
+ x: parseInt(point.x || 0),
159
+ y: parseInt(point.y || 0),
160
+ value: parseInt(point.value || 1)
161
+ }));
162
+
163
+ return {
164
+ max: data['max-value'],
165
+ data: processedData
167
166
  };
167
+ };
168
168
 
169
- this.tooltip = () =>
169
+ this.tooltip = () =>
170
+ {
171
+ if(!data['show-tooltip'])
170
172
  {
171
- if(!data['show-tooltip'].value)
172
- {
173
- return;
174
- }
175
-
176
- const tooltip = document.createElement('div');
177
- tooltip.className = 'heatmap-tooltip';
178
- tooltip.style.cssText = `
179
- position: absolute;
180
- background: rgba(0, 0, 0, 0.8);
181
- color: white;
182
- padding: 5px 10px;
183
- border-radius: 4px;
184
- font-size: 12px;
185
- pointer-events: none;
186
- display: none;
187
- z-index: 1000;
188
- `;
189
-
190
- node.appendChild(tooltip);
191
- this.tooltip = tooltip;
192
-
193
- node.addEventListener('mousemove', (e) =>
194
- {
195
- const rect = node.getBoundingClientRect();
196
- const x = e.clientX - rect.left;
197
- const y = e.clientY - rect.top;
198
-
199
- const value = this.instance.getValueAt({
200
- x: Math.floor(x),
201
- y: Math.floor(y)
202
- });
173
+ return;
174
+ }
175
+
176
+ const tooltip = document.createElement('div');
177
+ tooltip.className = 'heatmap-tooltip';
178
+ tooltip.style.cssText = `
179
+ position: absolute;
180
+ background: rgba(0, 0, 0, 0.8);
181
+ color: white;
182
+ padding: 5px 10px;
183
+ border-radius: 4px;
184
+ font-size: 12px;
185
+ pointer-events: none;
186
+ display: none;
187
+ z-index: 1000;
188
+ `;
189
+
190
+ node.appendChild(tooltip);
191
+ this.tooltip = tooltip;
192
+
193
+ node.addEventListener('mousemove', (e) =>
194
+ {
195
+ const rect = node.getBoundingClientRect();
196
+ const x = e.clientX - rect.left;
197
+ const y = e.clientY - rect.top;
203
198
 
204
- if(value > 0)
205
- {
206
- tooltip.textContent = `Value: ${value}`;
207
- tooltip.style.left = (x + 10) + 'px';
208
- tooltip.style.top = (y - 30) + 'px';
209
- tooltip.style.display = 'block';
210
- }
211
- else
212
- {
213
- tooltip.style.display = 'none';
214
- }
199
+ const value = this.instance.getValueAt({
200
+ x: Math.floor(x),
201
+ y: Math.floor(y)
215
202
  });
216
203
 
217
- node.addEventListener('mouseleave', () =>
204
+ if(value > 0)
218
205
  {
219
- tooltip.style.display = 'none';
220
- });
221
- };
222
-
223
- this.legend = () =>
224
- {
225
- if(!data['show-legend'].value)
206
+ tooltip.textContent = `Value: ${value}`;
207
+ tooltip.style.left = (x + 10) + 'px';
208
+ tooltip.style.top = (y - 30) + 'px';
209
+ tooltip.style.display = 'block';
210
+ }
211
+ else
226
212
  {
227
- return;
213
+ tooltip.style.display = 'none';
228
214
  }
215
+ });
229
216
 
230
- const position = data['legend-position'].value;
231
- const legend = document.createElement('div');
232
- legend.className = 'heatmap-legend';
233
-
234
- const positions = {
235
- 'tl': 'top: 10px; left: 10px;',
236
- 'tr': 'top: 10px; right: 10px;',
237
- 'bl': 'bottom: 10px; left: 10px;',
238
- 'br': 'bottom: 10px; right: 10px;'
239
- };
217
+ node.addEventListener('mouseleave', () =>
218
+ {
219
+ tooltip.style.display = 'none';
220
+ });
221
+ };
240
222
 
241
- legend.style.cssText = `
242
- position: absolute;
243
- ${positions[position]}
244
- background: rgba(255, 255, 255, 0.9);
245
- padding: 10px;
246
- border-radius: 4px;
247
- box-shadow: 0 2px 4px rgba(0,0,0,0.1);
248
- z-index: 10;
249
- `;
250
-
251
- const gradientBar = document.createElement('div');
252
- gradientBar.style.cssText = `
253
- width: 150px;
254
- height: 20px;
255
- background: linear-gradient(to right,
256
- rgb(0,0,255),
257
- rgb(0,255,255),
258
- rgb(0,255,0),
259
- rgb(255,255,0),
260
- rgb(255,0,0)
261
- );
262
- border-radius: 2px;
263
- margin-bottom: 5px;
264
- `;
265
-
266
- const labels = document.createElement('div');
267
- labels.style.cssText = `
268
- display: flex;
269
- justify-content: space-between;
270
- font-size: 11px;
271
- color: #333;
272
- `;
273
- labels.innerHTML = `<span>0</span><span>${data['max-value'].value}</span>`;
274
-
275
- legend.appendChild(gradientBar);
276
- legend.appendChild(labels);
277
- node.appendChild(legend);
223
+ this.legend = () =>
224
+ {
225
+ if(!data['show-legend'])
226
+ {
227
+ return;
228
+ }
229
+
230
+ const position = data['legend-position'];
231
+ const legend = document.createElement('div');
232
+ legend.className = 'heatmap-legend';
233
+
234
+ const positions = {
235
+ 'tl': 'top: 10px; left: 10px;',
236
+ 'tr': 'top: 10px; right: 10px;',
237
+ 'bl': 'bottom: 10px; left: 10px;',
238
+ 'br': 'bottom: 10px; right: 10px;'
278
239
  };
279
240
 
280
- this.tracking = () =>
241
+ legend.style.cssText = `
242
+ position: absolute;
243
+ ${positions[position]}
244
+ background: rgba(255, 255, 255, 0.9);
245
+ padding: 10px;
246
+ border-radius: 4px;
247
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
248
+ z-index: 10;
249
+ `;
250
+
251
+ const gradientBar = document.createElement('div');
252
+ gradientBar.style.cssText = `
253
+ width: 150px;
254
+ height: 20px;
255
+ background: linear-gradient(to right,
256
+ rgb(0,0,255),
257
+ rgb(0,255,255),
258
+ rgb(0,255,0),
259
+ rgb(255,255,0),
260
+ rgb(255,0,0)
261
+ );
262
+ border-radius: 2px;
263
+ margin-bottom: 5px;
264
+ `;
265
+
266
+ const labels = document.createElement('div');
267
+ labels.style.cssText = `
268
+ display: flex;
269
+ justify-content: space-between;
270
+ font-size: 11px;
271
+ color: #333;
272
+ `;
273
+ labels.innerHTML = `<span>0</span><span>${data['max-value']}</span>`;
274
+
275
+ legend.appendChild(gradientBar);
276
+ legend.appendChild(labels);
277
+ node.appendChild(legend);
278
+ };
279
+
280
+ this.tracking = () =>
281
+ {
282
+ const trackedData = [];
283
+ let tracking = false;
284
+
285
+ const addPoint = (e, multiplier = 1) =>
281
286
  {
282
- const trackedData = [];
283
- let tracking = false;
287
+ const rect = node.getBoundingClientRect();
288
+ const x = e.clientX - rect.left;
289
+ const y = e.clientY - rect.top;
284
290
 
285
- const addPoint = (e, multiplier = 1) =>
291
+ if(x >= 0 && x <= rect.width && y >= 0 && y <= rect.height)
286
292
  {
287
- const rect = node.getBoundingClientRect();
288
- const x = e.clientX - rect.left;
289
- const y = e.clientY - rect.top;
290
-
291
- if(x >= 0 && x <= rect.width && y >= 0 && y <= rect.height)
292
- {
293
- const point = {
294
- x: Math.floor(x),
295
- y: Math.floor(y),
296
- value: 10 * multiplier
297
- };
293
+ const point = {
294
+ x: Math.floor(x),
295
+ y: Math.floor(y),
296
+ value: 10 * multiplier
297
+ };
298
298
 
299
- trackedData.push(point);
300
- this.instance.addData(point);
299
+ trackedData.push(point);
300
+ this.instance.addData(point);
301
301
 
302
- if(data['debug'].value)
303
- {
304
- console.log('Heatmap point added:', point);
305
- }
302
+ if(data['debug'])
303
+ {
304
+ console.log('Heatmap point added:', point);
306
305
  }
307
- };
308
-
309
- if(data['click-tracking'].value)
310
- {
311
- node.addEventListener('click', (e) => addPoint(e, 5));
312
306
  }
307
+ };
313
308
 
314
- if(data['move-tracking'].value)
315
- {
316
- node.addEventListener('mousemove', (e) =>
317
- {
318
- if(Math.random() > 0.95) // Sample 5% of movements
319
- {
320
- addPoint(e, 1);
321
- }
322
- });
323
- }
309
+ if(data['click-tracking'])
310
+ {
311
+ node.addEventListener('click', (e) => addPoint(e, 5));
312
+ }
324
313
 
325
- if(data['scroll-tracking'].value)
314
+ if(data['move-tracking'])
315
+ {
316
+ node.addEventListener('mousemove', (e) =>
326
317
  {
327
- let scrollTimer;
328
- node.addEventListener('scroll', (e) =>
318
+ if(Math.random() > 0.95) // Sample 5% of movements
329
319
  {
330
- clearTimeout(scrollTimer);
331
- scrollTimer = setTimeout(() =>
332
- {
333
- const rect = node.getBoundingClientRect();
334
- const centerX = rect.width / 2;
335
- const centerY = rect.height / 2 + node.scrollTop;
336
-
337
- const point = {
338
- x: Math.floor(centerX),
339
- y: Math.floor(centerY),
340
- value: 20
341
- };
342
-
343
- this.instance.addData(point);
344
- }, 100);
345
- });
346
- }
320
+ addPoint(e, 1);
321
+ }
322
+ });
323
+ }
347
324
 
348
- if(data['touch-tracking'].value)
325
+ if(data['scroll-tracking'])
326
+ {
327
+ let scrollTimer;
328
+ node.addEventListener('scroll', (e) =>
349
329
  {
350
- node.addEventListener('touchstart', (e) =>
330
+ clearTimeout(scrollTimer);
331
+ scrollTimer = setTimeout(() =>
351
332
  {
352
- const touch = e.touches[0];
353
- addPoint(touch, 3);
354
- });
333
+ const rect = node.getBoundingClientRect();
334
+ const centerX = rect.width / 2;
335
+ const centerY = rect.height / 2 + node.scrollTop;
355
336
 
356
- node.addEventListener('touchmove', (e) =>
357
- {
358
- if(Math.random() > 0.9) // Sample 10% of touch movements
359
- {
360
- const touch = e.touches[0];
361
- addPoint(touch, 1);
362
- }
363
- });
364
- }
337
+ const point = {
338
+ x: Math.floor(centerX),
339
+ y: Math.floor(centerY),
340
+ value: 20
341
+ };
365
342
 
366
- // Store tracked data for export
367
- node.heatmapData = trackedData;
368
- };
343
+ this.instance.addData(point);
344
+ }, 100);
345
+ });
346
+ }
369
347
 
370
- this.resize = () =>
348
+ if(data['touch-tracking'])
371
349
  {
372
- if(!data['auto-resize'].value)
350
+ node.addEventListener('touchstart', (e) =>
373
351
  {
374
- return;
375
- }
352
+ const touch = e.touches[0];
353
+ addPoint(touch, 3);
354
+ });
376
355
 
377
- let resizeTimer;
378
- const resizeObserver = new ResizeObserver(() =>
356
+ node.addEventListener('touchmove', (e) =>
379
357
  {
380
- clearTimeout(resizeTimer);
381
- resizeTimer = setTimeout(() =>
358
+ if(Math.random() > 0.9) // Sample 10% of touch movements
382
359
  {
383
- if(this.instance)
384
- {
385
- const currentData = this.instance.getData();
386
- this.instance.setData(currentData);
387
- }
388
- }, 250);
360
+ const touch = e.touches[0];
361
+ addPoint(touch, 1);
362
+ }
389
363
  });
364
+ }
390
365
 
391
- resizeObserver.observe(node);
392
- };
366
+ // Store tracked data for export
367
+ node.heatmapData = trackedData;
368
+ };
393
369
 
394
- this.styles = () =>
370
+ this.resize = () =>
371
+ {
372
+ if(!data['auto-resize'])
395
373
  {
396
- const style = document.createElement('style');
374
+ return;
375
+ }
397
376
 
398
- style.textContent = `
399
- .heatmap-${identifier} {
400
- position: relative;
401
- overflow: hidden;
402
- }
403
- .heatmap-${identifier} canvas {
404
- position: absolute;
405
- top: 0;
406
- left: 0;
407
- pointer-events: ${(data['click-tracking'].value || data['move-tracking'].value) ? 'auto' : 'none'};
408
- }
409
- `;
410
-
411
- document.head.appendChild(style);
412
- };
413
-
414
- this.initialize = () =>
377
+ let resizeTimer;
378
+ const resizeObserver = new ResizeObserver(() =>
415
379
  {
416
- setTimeout(() =>
380
+ clearTimeout(resizeTimer);
381
+ resizeTimer = setTimeout(() =>
417
382
  {
418
- if(typeof h337 === 'undefined')
383
+ if(this.instance)
419
384
  {
420
- console.error('Heatmap.js library not loaded');
421
- return;
385
+ const currentData = this.instance.getData();
386
+ this.instance.setData(currentData);
422
387
  }
388
+ }, 250);
389
+ });
423
390
 
424
- // Create heatmap instance
425
- this.instance = h337.create(this.config());
391
+ resizeObserver.observe(node);
392
+ };
426
393
 
427
- // Set initial data
428
- this.instance.setData(this.processData());
394
+ this.styles = () =>
395
+ {
396
+ const style = document.createElement('style');
429
397
 
430
- // Add tooltip
431
- this.tooltip();
398
+ style.textContent = `
399
+ .heatmap-${id} {
400
+ position: relative;
401
+ overflow: hidden;
402
+ }
403
+ .heatmap-${id} canvas {
404
+ position: absolute;
405
+ top: 0;
406
+ left: 0;
407
+ pointer-events: ${(data['click-tracking'] || data['move-tracking']) ? 'auto' : 'none'};
408
+ }
409
+ `;
432
410
 
433
- // Add legend
434
- this.legend();
411
+ document.head.appendChild(style);
412
+ };
435
413
 
436
- // Setup tracking
437
- this.tracking();
414
+ this.initialize = () =>
415
+ {
416
+ setTimeout(() =>
417
+ {
418
+ if(typeof h337 === 'undefined')
419
+ {
420
+ console.error('Heatmap.js library not loaded');
421
+ return;
422
+ }
438
423
 
439
- // Setup resize handler
440
- this.resize();
424
+ // Create heatmap instance
425
+ this.instance = h337.create(this.config());
441
426
 
442
- // Expose instance and methods
443
- node.heatmap = this.instance;
427
+ // Set initial data
428
+ this.instance.setData(this.processData());
444
429
 
445
- // Add utility methods
446
- node.setHeatmapData = (newData) =>
447
- {
448
- if(this.instance)
449
- {
450
- this.instance.setData({
451
- max: data['max-value'].value,
452
- data: newData
453
- });
454
- }
455
- };
430
+ // Add tooltip
431
+ this.tooltip();
456
432
 
457
- node.addHeatmapPoint = (point) =>
458
- {
459
- if(this.instance)
460
- {
461
- this.instance.addData(point);
462
- }
463
- };
433
+ // Add legend
434
+ this.legend();
435
+
436
+ // Setup tracking
437
+ this.tracking();
464
438
 
465
- node.clearHeatmap = () =>
439
+ // Setup resize handler
440
+ this.resize();
441
+
442
+ // Expose instance and methods
443
+ node.heatmap = this.instance;
444
+
445
+ // Add utility methods
446
+ node.setHeatmapData = (newData) =>
447
+ {
448
+ if(this.instance)
466
449
  {
467
- if(this.instance)
468
- {
469
- this.instance.setData({max: 1, data: []});
470
- }
471
- };
450
+ this.instance.setData({
451
+ max: data['max-value'],
452
+ data: newData
453
+ });
454
+ }
455
+ };
472
456
 
473
- node.exportHeatmapData = () =>
457
+ node.addHeatmapPoint = (point) =>
458
+ {
459
+ if(this.instance)
474
460
  {
475
- return this.instance ? this.instance.getData() : null;
476
- };
461
+ this.instance.addData(point);
462
+ }
463
+ };
477
464
 
478
- if(data['debug'].value)
465
+ node.clearHeatmap = () =>
466
+ {
467
+ if(this.instance)
479
468
  {
480
- console.log('Heatmap initialized:', {
481
- id: identifier,
482
- config: this.config(),
483
- data: this.processData()
484
- });
469
+ this.instance.setData({max: 1, data: []});
485
470
  }
486
- }, 100);
487
- };
471
+ };
488
472
 
489
- this.setup();
490
- this.styles();
491
- this.initialize();
492
- }
493
- });
494
- });
473
+ node.exportHeatmapData = () =>
474
+ {
475
+ return this.instance ? this.instance.getData() : null;
476
+ };
477
+
478
+ if(data['debug'])
479
+ {
480
+ console.log('Heatmap initialized:', {
481
+ id: identifier,
482
+ config: this.config(),
483
+ data: this.processData()
484
+ });
485
+ }
486
+ }, 100);
487
+ };
488
+
489
+ this.setup();
490
+ this.styles();
491
+ this.initialize();
492
+ }
493
+ });