@onetype/framework 2.0.39 → 2.0.41

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,276 +0,0 @@
1
- transforms.ItemAdd({
2
- id: 'interact',
3
- icon: 'gesture',
4
- name: 'Interact',
5
- description: 'Drag, resize, and gesture interactions. Make elements draggable, resizable, and interactive.',
6
- js: [
7
- 'https://cdn.jsdelivr.net/npm/interactjs@1.10.27/dist/interact.min.js'
8
- ],
9
- config: {
10
- 'draggable': ['boolean', true],
11
- 'resizable': ['boolean', true],
12
- 'rotatable': ['boolean', false],
13
- 'inertia': ['boolean', true],
14
- 'restrict-to-parent': ['boolean', true],
15
- 'grid-x': ['number', 0],
16
- 'grid-y': ['number', 0],
17
- 'min-width': ['number', 50],
18
- 'min-height': ['number', 50],
19
- 'max-width': ['number', 0],
20
- 'max-height': ['number', 0],
21
- 'resize-from-edges': ['boolean', true],
22
- 'resize-from-corners': ['boolean', true],
23
- 'preserve-aspect-ratio': ['boolean', false]
24
- },
25
- code: function(data, node, transformer)
26
- {
27
- const id = 'interact-' + onetype.Generate(8);
28
-
29
- this.setup = () =>
30
- {
31
- // Add interact class and unique identifier
32
- node.classList.add('interact-element');
33
- node.classList.add(id);
34
-
35
- // Set initial position attributes
36
- node.setAttribute('data-x', '0');
37
- node.setAttribute('data-y', '0');
38
- node.setAttribute('data-angle', '0');
39
-
40
- // Add some default styles for visual feedback
41
- node.style.touchAction = 'none';
42
- node.style.userSelect = 'none';
43
- node.style.position = 'relative';
44
-
45
- // Get all children and make them non-interactive
46
- const children = Array.from(node.children);
47
- children.forEach(child =>
48
- {
49
- child.style.pointerEvents = 'auto';
50
- });
51
- };
52
-
53
- this.draggable = () =>
54
- {
55
- if(!data['draggable'])
56
- {
57
- return;
58
- }
59
-
60
- const config = {
61
- inertia: data['inertia'],
62
- listeners: {
63
- move: this.dragMoveListener
64
- }
65
- };
66
-
67
- // Add modifiers
68
- config.modifiers = [];
69
-
70
- // Restrict to parent
71
- if(data['restrict-to-parent'])
72
- {
73
- config.modifiers.push(
74
- interact.modifiers.restrictRect({
75
- restriction: 'parent',
76
- endOnly: false
77
- })
78
- );
79
- }
80
-
81
- // Grid snapping
82
- const gridX = data['grid-x'];
83
- const gridY = data['grid-y'];
84
-
85
- if(gridX > 0 || gridY > 0)
86
- {
87
- config.modifiers.push(
88
- interact.modifiers.snap({
89
- targets: [
90
- interact.snappers.grid({ x: gridX || 1, y: gridY || 1 })
91
- ],
92
- range: Infinity,
93
- relativePoints: [{ x: 0, y: 0 }]
94
- })
95
- );
96
- }
97
-
98
- // Apply draggable configuration
99
- this.interactInstance.draggable(config);
100
- };
101
-
102
- this.resizable = () =>
103
- {
104
- if(!data['resizable'])
105
- {
106
- return;
107
- }
108
-
109
- const config = {
110
- edges: {},
111
- listeners: {
112
- move: this.resizeMoveListener
113
- },
114
- modifiers: []
115
- };
116
-
117
- // Configure resize edges
118
- if(data['resize-from-edges'])
119
- {
120
- config.edges.left = true;
121
- config.edges.right = true;
122
- config.edges.top = true;
123
- config.edges.bottom = true;
124
- }
125
-
126
- if(data['resize-from-corners'])
127
- {
128
- config.edges.left = true;
129
- config.edges.right = true;
130
- config.edges.top = true;
131
- config.edges.bottom = true;
132
- }
133
-
134
- // Preserve aspect ratio
135
- if(data['preserve-aspect-ratio'])
136
- {
137
- config.modifiers.push(
138
- interact.modifiers.aspectRatio({
139
- ratio: 'preserve',
140
- equalDelta: true
141
- })
142
- );
143
- }
144
-
145
- // Restrict edges to parent
146
- if(data['restrict-to-parent'])
147
- {
148
- config.modifiers.push(
149
- interact.modifiers.restrictEdges({
150
- outer: 'parent'
151
- })
152
- );
153
- }
154
-
155
- // Size restrictions
156
- const minWidth = data['min-width'];
157
- const minHeight = data['min-height'];
158
- const maxWidth = data['max-width'];
159
- const maxHeight = data['max-height'];
160
-
161
- const sizeRestrictions = {};
162
-
163
- if(minWidth > 0 || minHeight > 0)
164
- {
165
- sizeRestrictions.min = {};
166
- if(minWidth > 0) sizeRestrictions.min.width = minWidth;
167
- if(minHeight > 0) sizeRestrictions.min.height = minHeight;
168
- }
169
-
170
- if(maxWidth > 0 || maxHeight > 0)
171
- {
172
- sizeRestrictions.max = {};
173
- if(maxWidth > 0) sizeRestrictions.max.width = maxWidth;
174
- if(maxHeight > 0) sizeRestrictions.max.height = maxHeight;
175
- }
176
-
177
- if(Object.keys(sizeRestrictions).length > 0)
178
- {
179
- config.modifiers.push(
180
- interact.modifiers.restrictSize(sizeRestrictions)
181
- );
182
- }
183
-
184
- // Apply resizable configuration
185
- this.interactInstance.resizable(config);
186
- };
187
-
188
- this.rotatable = () =>
189
- {
190
- if(!data['rotatable'])
191
- {
192
- return;
193
- }
194
-
195
- const config = {
196
- listeners: {
197
- move: this.rotateMoveListener
198
- }
199
- };
200
-
201
- // Apply gesturable configuration for rotation
202
- this.interactInstance.gesturable(config);
203
- };
204
-
205
- // Event listener functions
206
- this.dragMoveListener = (event) =>
207
- {
208
- const target = event.target;
209
- const x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx;
210
- const y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
211
-
212
- target.style.transform = `translate(${x}px, ${y}px) rotate(${target.getAttribute('data-angle') || 0}deg)`;
213
-
214
- target.setAttribute('data-x', x);
215
- target.setAttribute('data-y', y);
216
- };
217
-
218
- this.resizeMoveListener = (event) =>
219
- {
220
- const target = event.target;
221
- let x = parseFloat(target.getAttribute('data-x')) || 0;
222
- let y = parseFloat(target.getAttribute('data-y')) || 0;
223
-
224
- // Update element size
225
- target.style.width = event.rect.width + 'px';
226
- target.style.height = event.rect.height + 'px';
227
-
228
- // Translate when resizing from top or left edges
229
- x += event.deltaRect.left;
230
- y += event.deltaRect.top;
231
-
232
- target.style.transform = `translate(${x}px, ${y}px) rotate(${target.getAttribute('data-angle') || 0}deg)`;
233
-
234
- target.setAttribute('data-x', x);
235
- target.setAttribute('data-y', y);
236
- };
237
-
238
- this.rotateMoveListener = (event) =>
239
- {
240
- const target = event.target;
241
- const currentAngle = parseFloat(target.getAttribute('data-angle')) || 0;
242
- const newAngle = currentAngle + event.da;
243
-
244
- const x = parseFloat(target.getAttribute('data-x')) || 0;
245
- const y = parseFloat(target.getAttribute('data-y')) || 0;
246
-
247
- target.style.transform = `translate(${x}px, ${y}px) rotate(${newAngle}deg)`;
248
-
249
- target.setAttribute('data-angle', newAngle);
250
- };
251
-
252
- this.initialize = () =>
253
- {
254
- setTimeout(() =>
255
- {
256
- // Check if interact is available
257
- if(typeof interact === 'undefined')
258
- {
259
- console.error('Interact.js library not loaded');
260
- return;
261
- }
262
-
263
- // Initialize interact instance
264
- this.interactInstance = interact(node);
265
-
266
- // Apply configurations
267
- this.draggable();
268
- this.resizable();
269
- this.rotatable();
270
- }, 100);
271
- };
272
-
273
- this.setup();
274
- this.initialize();
275
- }
276
- });
@@ -1,328 +0,0 @@
1
- transforms.ItemAdd({
2
- id: 'particles',
3
- icon: 'blur_on',
4
- name: 'Particles',
5
- description: 'Animated particle effects background. Create interactive particle systems with customizable behaviors.',
6
- js: [
7
- 'https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js'
8
- ],
9
- config: {
10
- 'preset': ['string', 'default'],
11
- 'particle-number': ['number', 80],
12
- 'particle-color': ['string', '#ffffff'],
13
- 'particle-opacity': ['number', 0.5],
14
- 'particle-size': ['number', 3],
15
- 'particle-size-random': ['boolean', true],
16
- 'particle-shape': ['string', 'circle'],
17
- 'line-linked': ['boolean', true],
18
- 'line-color': ['string', '#ffffff'],
19
- 'line-opacity': ['number', 0.4],
20
- 'line-width': ['number', 1],
21
- 'line-distance': ['number', 150],
22
- 'move-enable': ['boolean', true],
23
- 'move-speed': ['number', 6],
24
- 'move-direction': ['string', 'none'],
25
- 'move-random': ['boolean', false],
26
- 'move-straight': ['boolean', false],
27
- 'move-bounce': ['boolean', false],
28
- 'move-attract': ['boolean', false],
29
- 'interactivity-hover': ['boolean', true],
30
- 'interactivity-click': ['boolean', true],
31
- 'hover-mode': ['string', 'repulse'],
32
- 'click-mode': ['string', 'push'],
33
- 'retina-detect': ['boolean', true]
34
- },
35
- code: function(data, node, transformer)
36
- {
37
- const id = 'particles-' + onetype.Generate(8);
38
-
39
- this.setup = () =>
40
- {
41
- node.classList.add('particles');
42
- node.classList.add(id);
43
-
44
- const particlesId = 'particles-' + identifier;
45
- node.id = particlesId;
46
-
47
- const children = Array.from(node.children);
48
-
49
- if(children.length > 0)
50
- {
51
- const contentWrapper = document.createElement('div');
52
- contentWrapper.className = 'particles-content';
53
-
54
- children.forEach(child =>
55
- {
56
- contentWrapper.appendChild(child);
57
- });
58
-
59
- node.appendChild(contentWrapper);
60
- }
61
-
62
- this.particlesId = particlesId;
63
- };
64
-
65
- this.styles = () =>
66
- {
67
- const style = document.createElement('style');
68
-
69
- style.textContent = `
70
- .particles-${id} {
71
- position: relative;
72
- width: 100%;
73
- height: 100%;
74
- }
75
- .particles-${id} canvas {
76
- position: absolute;
77
- top: 0;
78
- left: 0;
79
- width: 100%;
80
- height: 100%;
81
- pointer-events: auto;
82
- }
83
- .particles-${id} .particles-content {
84
- position: relative;
85
- z-index: 1;
86
- }
87
- `;
88
-
89
- document.head.appendChild(style);
90
- };
91
-
92
- this.presets = () =>
93
- {
94
- const preset = data['preset'];
95
-
96
- const presets = {
97
- 'snow': {
98
- particleNumber: 100,
99
- particleColor: '#ffffff',
100
- particleOpacity: 0.8,
101
- particleSize: 4,
102
- moveSpeed: 2,
103
- moveDirection: 'bottom',
104
- lineLinked: false
105
- },
106
- 'stars': {
107
- particleNumber: 200,
108
- particleColor: '#ffffff',
109
- particleOpacity: 1,
110
- particleSize: 2,
111
- moveSpeed: 0.5,
112
- lineLinked: false,
113
- particleSizeRandom: true
114
- },
115
- 'bubbles': {
116
- particleNumber: 40,
117
- particleColor: '#ffffff',
118
- particleOpacity: 0.4,
119
- particleSize: 8,
120
- moveSpeed: 3,
121
- moveDirection: 'top',
122
- lineLinked: false,
123
- particleShape: 'circle'
124
- },
125
- 'network': {
126
- particleNumber: 60,
127
- particleColor: '#0066cc',
128
- particleOpacity: 0.6,
129
- lineLinked: true,
130
- lineColor: '#0066cc',
131
- lineOpacity: 0.3,
132
- moveSpeed: 4
133
- }
134
- };
135
-
136
- if(presets[preset])
137
- {
138
- return presets[preset];
139
- }
140
-
141
- return null;
142
- };
143
-
144
- this.config = () =>
145
- {
146
- const presetConfig = this.presets();
147
-
148
- const particleNumber = presetConfig?.particleNumber || data['particle-number'];
149
- const particleColor = presetConfig?.particleColor || data['particle-color'];
150
- const particleOpacity = presetConfig?.particleOpacity || data['particle-opacity'];
151
- const particleSize = presetConfig?.particleSize || data['particle-size'];
152
- const particleSizeRandom = presetConfig?.particleSizeRandom ?? data['particle-size-random'];
153
- const particleShape = presetConfig?.particleShape || data['particle-shape'];
154
- const lineLinked = presetConfig?.lineLinked ?? data['line-linked'];
155
- const lineColor = presetConfig?.lineColor || data['line-color'];
156
- const lineOpacity = presetConfig?.lineOpacity || data['line-opacity'];
157
- const lineWidth = data['line-width'];
158
- const lineDistance = data['line-distance'];
159
- const moveSpeed = presetConfig?.moveSpeed || data['move-speed'];
160
- const moveDirection = presetConfig?.moveDirection || data['move-direction'];
161
- const moveRandom = data['move-random'];
162
- const moveStraight = data['move-straight'];
163
- const moveBounce = data['move-bounce'];
164
- const moveAttract = data['move-attract'];
165
-
166
- const config = {
167
- particles: {
168
- number: {
169
- value: particleNumber,
170
- density: {
171
- enable: true,
172
- value_area: 800
173
- }
174
- },
175
- color: {
176
- value: particleColor
177
- },
178
- shape: {
179
- type: particleShape,
180
- stroke: {
181
- width: 0,
182
- color: '#000000'
183
- }
184
- },
185
- opacity: {
186
- value: particleOpacity,
187
- random: false,
188
- anim: {
189
- enable: false,
190
- speed: 1,
191
- opacity_min: 0.1,
192
- sync: false
193
- }
194
- },
195
- size: {
196
- value: particleSize,
197
- random: particleSizeRandom,
198
- anim: {
199
- enable: false,
200
- speed: 40,
201
- size_min: 0.1,
202
- sync: false
203
- }
204
- },
205
- line_linked: {
206
- enable: lineLinked,
207
- distance: lineDistance,
208
- color: lineColor,
209
- opacity: lineOpacity,
210
- width: lineWidth
211
- },
212
- move: {
213
- enable: data['move-enable'],
214
- speed: moveSpeed,
215
- direction: moveDirection,
216
- random: moveRandom,
217
- straight: moveStraight,
218
- out_mode: 'out',
219
- bounce: moveBounce,
220
- attract: {
221
- enable: moveAttract,
222
- rotateX: 600,
223
- rotateY: 1200
224
- }
225
- }
226
- },
227
- interactivity: {
228
- detect_on: 'canvas',
229
- events: {
230
- onhover: {
231
- enable: data['interactivity-hover'],
232
- mode: data['hover-mode']
233
- },
234
- onclick: {
235
- enable: data['interactivity-click'],
236
- mode: data['click-mode']
237
- },
238
- resize: true
239
- },
240
- modes: {
241
- grab: {
242
- distance: 400,
243
- line_linked: {
244
- opacity: 1
245
- }
246
- },
247
- bubble: {
248
- distance: 400,
249
- size: 40,
250
- duration: 2,
251
- opacity: 8,
252
- speed: 3
253
- },
254
- repulse: {
255
- distance: 200,
256
- duration: 0.4
257
- },
258
- push: {
259
- particles_nb: 4
260
- },
261
- remove: {
262
- particles_nb: 2
263
- }
264
- }
265
- },
266
- retina_detect: data['retina-detect']
267
- };
268
-
269
- return config;
270
- };
271
-
272
- this.initialize = () =>
273
- {
274
- setTimeout(() =>
275
- {
276
- if(typeof particlesJS === 'undefined')
277
- {
278
- console.error('Particles.js library not loaded');
279
- return;
280
- }
281
-
282
- particlesJS(this.particlesId, this.config());
283
-
284
- node._particlesInstance = {
285
- refresh: () =>
286
- {
287
- if(window.pJSDom && window.pJSDom.length > 0)
288
- {
289
- window.pJSDom.forEach(instance =>
290
- {
291
- if(instance.pJS && instance.pJS.canvas && instance.pJS.canvas.el)
292
- {
293
- if(instance.pJS.canvas.el.parentNode && instance.pJS.canvas.el.parentNode.id === this.particlesId)
294
- {
295
- instance.pJS.fn.vendors.destroypJS();
296
- window.pJSDom = window.pJSDom.filter(item => item !== instance);
297
- }
298
- }
299
- });
300
- }
301
- particlesJS(this.particlesId, this.config());
302
- },
303
- update: (newConfig) =>
304
- {
305
- if(window.pJSDom && window.pJSDom.length > 0)
306
- {
307
- window.pJSDom.forEach(instance =>
308
- {
309
- if(instance.pJS && instance.pJS.canvas && instance.pJS.canvas.el)
310
- {
311
- if(instance.pJS.canvas.el.parentNode && instance.pJS.canvas.el.parentNode.id === this.particlesId)
312
- {
313
- Object.assign(instance.pJS.particles, newConfig.particles);
314
- instance.pJS.fn.particlesRefresh();
315
- }
316
- }
317
- });
318
- }
319
- }
320
- };
321
- }, 0);
322
- };
323
-
324
- this.setup();
325
- this.styles();
326
- this.initialize();
327
- }
328
- });