@uibit/particles 0.1.1 → 0.2.0
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/custom-elements.json +8 -0
- package/dist/frameworks/angular/index.ts +79 -63
- package/dist/frameworks/astro/index.d.ts +14 -1
- package/dist/frameworks/preact/index.d.ts +1 -0
- package/dist/frameworks/react/index.ts +150 -0
- package/dist/frameworks/stencil/index.d.ts +1 -0
- package/dist/frameworks/svelte/index.svelte +81 -31
- package/dist/frameworks/vue/index.ts +172 -27
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/frameworks/react/index.d.ts +0 -27
package/custom-elements.json
CHANGED
|
@@ -2,75 +2,91 @@ import { Component, ChangeDetectionStrategy, ElementRef, input, effect, booleanA
|
|
|
2
2
|
import '@uibit/particles';
|
|
3
3
|
import type { Particles as HTMLElementClass } from '@uibit/particles';
|
|
4
4
|
import type { Particle, ParticleHoverEffect, ParticleMode } from '@uibit/particles';
|
|
5
|
-
|
|
6
5
|
@Component({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
selector: 'uibit-particles',
|
|
7
|
+
template: '<ng-content></ng-content>',
|
|
8
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
9
|
+
standalone: true
|
|
11
10
|
})
|
|
12
11
|
export class NgxParticles {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
constructor(private el: ElementRef<HTMLElementClass>){
|
|
13
|
+
effect(()=>{
|
|
14
|
+
if (this.el.nativeElement) {
|
|
15
|
+
this.el.nativeElement.count = this.count();
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
effect(()=>{
|
|
19
|
+
if (this.el.nativeElement) {
|
|
20
|
+
this.el.nativeElement.speed = this.speed();
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
effect(()=>{
|
|
24
|
+
if (this.el.nativeElement) {
|
|
25
|
+
this.el.nativeElement.mode = this.mode();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
effect(()=>{
|
|
29
|
+
if (this.el.nativeElement) {
|
|
30
|
+
this.el.nativeElement.connect = this.connect();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
effect(()=>{
|
|
34
|
+
if (this.el.nativeElement) {
|
|
35
|
+
this.el.nativeElement.connectDistance = this.connectDistance();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
effect(()=>{
|
|
39
|
+
if (this.el.nativeElement) {
|
|
40
|
+
this.el.nativeElement.hoverEffect = this.hoverEffect();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
effect(()=>{
|
|
44
|
+
if (this.el.nativeElement) {
|
|
45
|
+
this.el.nativeElement.interactiveRadius = this.interactiveRadius();
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
effect(()=>{
|
|
49
|
+
if (this.el.nativeElement) {
|
|
50
|
+
this.el.nativeElement._resize = this._resize();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
effect(()=>{
|
|
54
|
+
if (this.el.nativeElement) {
|
|
55
|
+
this.el.nativeElement._loop = this._loop();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
effect(()=>{
|
|
59
|
+
if (this.el.nativeElement) {
|
|
60
|
+
this.el.nativeElement.locale = this.locale();
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
readonly count = input<number, any>(50, {
|
|
65
|
+
transform: numberAttribute
|
|
18
66
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.el.nativeElement.speed = this.speed();
|
|
22
|
-
}
|
|
67
|
+
readonly speed = input<number, any>(1, {
|
|
68
|
+
transform: numberAttribute
|
|
23
69
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
70
|
+
readonly mode = input<ParticleMode>('float');
|
|
71
|
+
readonly connect = input<boolean, any>(false, {
|
|
72
|
+
transform: booleanAttribute
|
|
28
73
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.el.nativeElement.connect = this.connect();
|
|
32
|
-
}
|
|
74
|
+
readonly connectDistance = input<number, any>(100, {
|
|
75
|
+
transform: numberAttribute
|
|
33
76
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
77
|
+
readonly hoverEffect = input<ParticleHoverEffect>('repel');
|
|
78
|
+
readonly interactiveRadius = input<number, any>(100, {
|
|
79
|
+
transform: numberAttribute
|
|
38
80
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
if (this.el.nativeElement) {
|
|
51
|
-
this.el.nativeElement._resize = this._resize();
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
effect(() => {
|
|
55
|
-
if (this.el.nativeElement) {
|
|
56
|
-
this.el.nativeElement._loop = this._loop();
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
effect(() => {
|
|
60
|
-
if (this.el.nativeElement) {
|
|
61
|
-
this.el.nativeElement.locale = this.locale();
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
readonly count = input<number, any>(50, { transform: numberAttribute });
|
|
67
|
-
readonly speed = input<number, any>(1, { transform: numberAttribute });
|
|
68
|
-
readonly mode = input<ParticleMode, any>('float');
|
|
69
|
-
readonly connect = input<boolean, any>(false, { transform: booleanAttribute });
|
|
70
|
-
readonly connectDistance = input<number, any>(100, { transform: numberAttribute });
|
|
71
|
-
readonly hoverEffect = input<ParticleHoverEffect, any>('repel');
|
|
72
|
-
readonly interactiveRadius = input<number, any>(100, { transform: numberAttribute });
|
|
73
|
-
readonly _resize = input<any, any>(new ResizeController(this, { callback: (entry) => { const { width, height } = entry.contentRect; this._resizeCanvas(width, height); } }));
|
|
74
|
-
readonly _loop = input<any, any>(new LoopController(this, { autoStart: false, callback: () => this._updateAndDraw() }));
|
|
75
|
-
readonly locale = input<string, any>('');
|
|
81
|
+
readonly _resize = input<any>(new ResizeController(this, {
|
|
82
|
+
callback: (entry)=>{
|
|
83
|
+
const { width, height } = entry.contentRect;
|
|
84
|
+
this._resizeCanvas(width, height);
|
|
85
|
+
}
|
|
86
|
+
}));
|
|
87
|
+
readonly _loop = input<any>(new LoopController(this, {
|
|
88
|
+
autoStart: false,
|
|
89
|
+
callback: ()=>this._updateAndDraw()
|
|
90
|
+
}));
|
|
91
|
+
readonly locale = input<string>('');
|
|
76
92
|
}
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import type { Particles as HTMLElementClass } from '@uibit/particles';
|
|
2
2
|
import '@uibit/particles';
|
|
3
|
+
import type { Particle, ParticleHoverEffect, ParticleMode } from '@uibit/particles';
|
|
3
4
|
|
|
4
5
|
declare global {
|
|
5
6
|
namespace astroHTML.JSX {
|
|
6
7
|
interface IntrinsicElements {
|
|
7
|
-
'uibit-particles': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes
|
|
8
|
+
'uibit-particles': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes & {
|
|
9
|
+
count?: number;
|
|
10
|
+
speed?: number;
|
|
11
|
+
mode?: ParticleMode;
|
|
12
|
+
connect?: boolean;
|
|
13
|
+
connectDistance?: number;
|
|
14
|
+
hoverEffect?: ParticleHoverEffect;
|
|
15
|
+
interactiveRadius?: number;
|
|
16
|
+
_resize?: any;
|
|
17
|
+
_loop?: any;
|
|
18
|
+
locale?: string;
|
|
19
|
+
|
|
20
|
+
};
|
|
8
21
|
}
|
|
9
22
|
}
|
|
10
23
|
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import React, { useRef, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
|
|
2
|
+
import type { Particles as HTMLElementClass } from '@uibit/particles';
|
|
3
|
+
import '@uibit/particles';
|
|
4
|
+
import type { Particle, ParticleHoverEffect, ParticleMode } from '@uibit/particles';
|
|
5
|
+
const useTypeOfLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
6
|
+
export interface ParticlesProps extends Omit<React.HTMLAttributes<HTMLElementClass>, 'count' | 'speed' | 'mode' | 'connect' | 'connectDistance' | 'hoverEffect' | 'interactiveRadius' | '_resize' | '_loop' | 'locale'> {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
count?: number;
|
|
9
|
+
speed?: number;
|
|
10
|
+
mode?: ParticleMode;
|
|
11
|
+
connect?: boolean;
|
|
12
|
+
connectDistance?: number;
|
|
13
|
+
hoverEffect?: ParticleHoverEffect;
|
|
14
|
+
interactiveRadius?: number;
|
|
15
|
+
_resize?: any;
|
|
16
|
+
_loop?: any;
|
|
17
|
+
locale?: string;
|
|
18
|
+
}
|
|
19
|
+
export const Particles = ({ ref, children, ...props }: ParticlesProps & {
|
|
20
|
+
ref?: React.Ref<HTMLElementClass>;
|
|
21
|
+
})=>{
|
|
22
|
+
const innerRef = useRef<HTMLElementClass>(null);
|
|
23
|
+
const propsRef = useRef(props);
|
|
24
|
+
propsRef.current = props;
|
|
25
|
+
useImperativeHandle(ref, ()=>innerRef.current!);
|
|
26
|
+
useTypeOfLayoutEffect(()=>{
|
|
27
|
+
const element = innerRef.current;
|
|
28
|
+
if (element && props.count !== undefined) {
|
|
29
|
+
(element as any).count = props.count;
|
|
30
|
+
}
|
|
31
|
+
}, [
|
|
32
|
+
props.count
|
|
33
|
+
]);
|
|
34
|
+
useTypeOfLayoutEffect(()=>{
|
|
35
|
+
const element = innerRef.current;
|
|
36
|
+
if (element && props.speed !== undefined) {
|
|
37
|
+
(element as any).speed = props.speed;
|
|
38
|
+
}
|
|
39
|
+
}, [
|
|
40
|
+
props.speed
|
|
41
|
+
]);
|
|
42
|
+
useTypeOfLayoutEffect(()=>{
|
|
43
|
+
const element = innerRef.current;
|
|
44
|
+
if (element && props.mode !== undefined) {
|
|
45
|
+
(element as any).mode = props.mode;
|
|
46
|
+
}
|
|
47
|
+
}, [
|
|
48
|
+
props.mode
|
|
49
|
+
]);
|
|
50
|
+
useTypeOfLayoutEffect(()=>{
|
|
51
|
+
const element = innerRef.current;
|
|
52
|
+
if (element && props.connect !== undefined) {
|
|
53
|
+
(element as any).connect = props.connect;
|
|
54
|
+
}
|
|
55
|
+
}, [
|
|
56
|
+
props.connect
|
|
57
|
+
]);
|
|
58
|
+
useTypeOfLayoutEffect(()=>{
|
|
59
|
+
const element = innerRef.current;
|
|
60
|
+
if (element && props.connectDistance !== undefined) {
|
|
61
|
+
(element as any).connectDistance = props.connectDistance;
|
|
62
|
+
}
|
|
63
|
+
}, [
|
|
64
|
+
props.connectDistance
|
|
65
|
+
]);
|
|
66
|
+
useTypeOfLayoutEffect(()=>{
|
|
67
|
+
const element = innerRef.current;
|
|
68
|
+
if (element && props.hoverEffect !== undefined) {
|
|
69
|
+
(element as any).hoverEffect = props.hoverEffect;
|
|
70
|
+
}
|
|
71
|
+
}, [
|
|
72
|
+
props.hoverEffect
|
|
73
|
+
]);
|
|
74
|
+
useTypeOfLayoutEffect(()=>{
|
|
75
|
+
const element = innerRef.current;
|
|
76
|
+
if (element && props.interactiveRadius !== undefined) {
|
|
77
|
+
(element as any).interactiveRadius = props.interactiveRadius;
|
|
78
|
+
}
|
|
79
|
+
}, [
|
|
80
|
+
props.interactiveRadius
|
|
81
|
+
]);
|
|
82
|
+
useTypeOfLayoutEffect(()=>{
|
|
83
|
+
const element = innerRef.current;
|
|
84
|
+
if (element && props._resize !== undefined) {
|
|
85
|
+
(element as any)._resize = props._resize;
|
|
86
|
+
}
|
|
87
|
+
}, [
|
|
88
|
+
props._resize
|
|
89
|
+
]);
|
|
90
|
+
useTypeOfLayoutEffect(()=>{
|
|
91
|
+
const element = innerRef.current;
|
|
92
|
+
if (element && props._loop !== undefined) {
|
|
93
|
+
(element as any)._loop = props._loop;
|
|
94
|
+
}
|
|
95
|
+
}, [
|
|
96
|
+
props._loop
|
|
97
|
+
]);
|
|
98
|
+
useTypeOfLayoutEffect(()=>{
|
|
99
|
+
const element = innerRef.current;
|
|
100
|
+
if (element && props.locale !== undefined) {
|
|
101
|
+
(element as any).locale = props.locale;
|
|
102
|
+
}
|
|
103
|
+
}, [
|
|
104
|
+
props.locale
|
|
105
|
+
]);
|
|
106
|
+
const domProps = {
|
|
107
|
+
...props
|
|
108
|
+
};
|
|
109
|
+
const customPropNames = [
|
|
110
|
+
'count',
|
|
111
|
+
'speed',
|
|
112
|
+
'mode',
|
|
113
|
+
'connect',
|
|
114
|
+
'connectDistance',
|
|
115
|
+
'hoverEffect',
|
|
116
|
+
'interactiveRadius',
|
|
117
|
+
'_resize',
|
|
118
|
+
'_loop',
|
|
119
|
+
'locale'
|
|
120
|
+
];
|
|
121
|
+
for (const key of customPropNames){
|
|
122
|
+
delete (domProps as any)[key];
|
|
123
|
+
}
|
|
124
|
+
return React.createElement('uibit-particles', {
|
|
125
|
+
ref: innerRef,
|
|
126
|
+
...domProps
|
|
127
|
+
}, children);
|
|
128
|
+
};
|
|
129
|
+
declare global {
|
|
130
|
+
namespace React {
|
|
131
|
+
namespace JSX {
|
|
132
|
+
interface IntrinsicElements {
|
|
133
|
+
'uibit-particles': React.ClassAttributes<HTMLElementClass> & React.HTMLAttributes<HTMLElementClass> & {
|
|
134
|
+
children?: React.ReactNode;
|
|
135
|
+
class?: string;
|
|
136
|
+
count?: number;
|
|
137
|
+
speed?: number;
|
|
138
|
+
mode?: ParticleMode;
|
|
139
|
+
connect?: boolean;
|
|
140
|
+
connectDistance?: number;
|
|
141
|
+
hoverEffect?: ParticleHoverEffect;
|
|
142
|
+
interactiveRadius?: number;
|
|
143
|
+
_resize?: any;
|
|
144
|
+
_loop?: any;
|
|
145
|
+
locale?: string;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -2,21 +2,22 @@
|
|
|
2
2
|
import '@uibit/particles';
|
|
3
3
|
import type { Particles as HTMLElementClass } from '@uibit/particles';
|
|
4
4
|
import type { Particle, ParticleHoverEffect, ParticleMode } from '@uibit/particles';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
count =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
count = $bindable(),
|
|
8
|
+
speed = $bindable(),
|
|
9
|
+
mode = $bindable(),
|
|
10
|
+
connect = $bindable(),
|
|
11
|
+
connectDistance = $bindable(),
|
|
12
|
+
hoverEffect = $bindable(),
|
|
13
|
+
interactiveRadius = $bindable(),
|
|
14
|
+
_resize = $bindable(),
|
|
15
|
+
_loop = $bindable(),
|
|
16
|
+
locale = $bindable(),
|
|
17
|
+
children,
|
|
18
|
+
...restProps
|
|
18
19
|
} = $props<{
|
|
19
|
-
children?:
|
|
20
|
+
children?: import('svelte').Snippet;
|
|
20
21
|
count?: number;
|
|
21
22
|
speed?: number;
|
|
22
23
|
mode?: ParticleMode;
|
|
@@ -27,47 +28,96 @@
|
|
|
27
28
|
_resize?: any;
|
|
28
29
|
_loop?: any;
|
|
29
30
|
locale?: string;
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
[key: string]: any;
|
|
31
33
|
}>();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (elementRef && count !== undefined) {
|
|
34
|
+
|
|
35
|
+
let elementRef: HTMLElementClass | null = $state(null);
|
|
36
|
+
|
|
37
|
+
$effect(() => {
|
|
38
|
+
if (elementRef && count !== undefined && elementRef.count !== count) {
|
|
37
39
|
elementRef.count = count;
|
|
38
40
|
}
|
|
39
|
-
if (elementRef && speed !== undefined) {
|
|
41
|
+
if (elementRef && speed !== undefined && elementRef.speed !== speed) {
|
|
40
42
|
elementRef.speed = speed;
|
|
41
43
|
}
|
|
42
|
-
if (elementRef && mode !== undefined) {
|
|
44
|
+
if (elementRef && mode !== undefined && elementRef.mode !== mode) {
|
|
43
45
|
elementRef.mode = mode;
|
|
44
46
|
}
|
|
45
|
-
if (elementRef && connect !== undefined) {
|
|
47
|
+
if (elementRef && connect !== undefined && elementRef.connect !== connect) {
|
|
46
48
|
elementRef.connect = connect;
|
|
47
49
|
}
|
|
48
|
-
if (elementRef && connectDistance !== undefined) {
|
|
50
|
+
if (elementRef && connectDistance !== undefined && elementRef.connectDistance !== connectDistance) {
|
|
49
51
|
elementRef.connectDistance = connectDistance;
|
|
50
52
|
}
|
|
51
|
-
if (elementRef && hoverEffect !== undefined) {
|
|
53
|
+
if (elementRef && hoverEffect !== undefined && elementRef.hoverEffect !== hoverEffect) {
|
|
52
54
|
elementRef.hoverEffect = hoverEffect;
|
|
53
55
|
}
|
|
54
|
-
if (elementRef && interactiveRadius !== undefined) {
|
|
56
|
+
if (elementRef && interactiveRadius !== undefined && elementRef.interactiveRadius !== interactiveRadius) {
|
|
55
57
|
elementRef.interactiveRadius = interactiveRadius;
|
|
56
58
|
}
|
|
57
|
-
if (elementRef && _resize !== undefined) {
|
|
59
|
+
if (elementRef && _resize !== undefined && elementRef._resize !== _resize) {
|
|
58
60
|
elementRef._resize = _resize;
|
|
59
61
|
}
|
|
60
|
-
if (elementRef && _loop !== undefined) {
|
|
62
|
+
if (elementRef && _loop !== undefined && elementRef._loop !== _loop) {
|
|
61
63
|
elementRef._loop = _loop;
|
|
62
64
|
}
|
|
63
|
-
if (elementRef && locale !== undefined) {
|
|
65
|
+
if (elementRef && locale !== undefined && elementRef.locale !== locale) {
|
|
64
66
|
elementRef.locale = locale;
|
|
65
67
|
}
|
|
66
68
|
});
|
|
67
|
-
|
|
69
|
+
|
|
70
|
+
$effect(() => {
|
|
71
|
+
const element = elementRef;
|
|
72
|
+
if (!element) return;
|
|
73
|
+
|
|
74
|
+
const handleEvent = () => {
|
|
75
|
+
if (count !== element.count) {
|
|
76
|
+
count = element.count as any;
|
|
77
|
+
}
|
|
78
|
+
if (speed !== element.speed) {
|
|
79
|
+
speed = element.speed as any;
|
|
80
|
+
}
|
|
81
|
+
if (mode !== element.mode) {
|
|
82
|
+
mode = element.mode as any;
|
|
83
|
+
}
|
|
84
|
+
if (connect !== element.connect) {
|
|
85
|
+
connect = element.connect as any;
|
|
86
|
+
}
|
|
87
|
+
if (connectDistance !== element.connectDistance) {
|
|
88
|
+
connectDistance = element.connectDistance as any;
|
|
89
|
+
}
|
|
90
|
+
if (hoverEffect !== element.hoverEffect) {
|
|
91
|
+
hoverEffect = element.hoverEffect as any;
|
|
92
|
+
}
|
|
93
|
+
if (interactiveRadius !== element.interactiveRadius) {
|
|
94
|
+
interactiveRadius = element.interactiveRadius as any;
|
|
95
|
+
}
|
|
96
|
+
if (_resize !== element._resize) {
|
|
97
|
+
_resize = element._resize as any;
|
|
98
|
+
}
|
|
99
|
+
if (_loop !== element._loop) {
|
|
100
|
+
_loop = element._loop as any;
|
|
101
|
+
}
|
|
102
|
+
if (locale !== element.locale) {
|
|
103
|
+
locale = element.locale as any;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const events = ['change', 'input'];
|
|
108
|
+
for (const event of events) {
|
|
109
|
+
element.addEventListener(event, handleEvent);
|
|
110
|
+
}
|
|
111
|
+
return () => {
|
|
112
|
+
for (const event of events) {
|
|
113
|
+
element.removeEventListener(event, handleEvent);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
|
|
68
118
|
</script>
|
|
69
119
|
|
|
70
|
-
<uibit-particles bind:this={elementRef} {
|
|
120
|
+
<uibit-particles bind:this={elementRef} {...restProps}>
|
|
71
121
|
|
|
72
122
|
{#if children}
|
|
73
123
|
{@render children()}
|
|
@@ -1,32 +1,177 @@
|
|
|
1
|
-
import { defineComponent, h } from 'vue';
|
|
1
|
+
import { defineComponent, h, ref, watch } from 'vue';
|
|
2
2
|
import type { Particles as HTMLElementClass } from '@uibit/particles';
|
|
3
3
|
import '@uibit/particles';
|
|
4
4
|
import type { Particle, ParticleHoverEffect, ParticleMode } from '@uibit/particles';
|
|
5
|
-
|
|
6
5
|
export const Particles = defineComponent({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
6
|
+
name: 'Particles',
|
|
7
|
+
props: {
|
|
8
|
+
count: {
|
|
9
|
+
type: [
|
|
10
|
+
String,
|
|
11
|
+
Number,
|
|
12
|
+
Boolean,
|
|
13
|
+
Array,
|
|
14
|
+
Object
|
|
15
|
+
] as any
|
|
16
|
+
},
|
|
17
|
+
speed: {
|
|
18
|
+
type: [
|
|
19
|
+
String,
|
|
20
|
+
Number,
|
|
21
|
+
Boolean,
|
|
22
|
+
Array,
|
|
23
|
+
Object
|
|
24
|
+
] as any
|
|
25
|
+
},
|
|
26
|
+
mode: {
|
|
27
|
+
type: [
|
|
28
|
+
String,
|
|
29
|
+
Number,
|
|
30
|
+
Boolean,
|
|
31
|
+
Array,
|
|
32
|
+
Object
|
|
33
|
+
] as any
|
|
34
|
+
},
|
|
35
|
+
connect: {
|
|
36
|
+
type: [
|
|
37
|
+
String,
|
|
38
|
+
Number,
|
|
39
|
+
Boolean,
|
|
40
|
+
Array,
|
|
41
|
+
Object
|
|
42
|
+
] as any
|
|
43
|
+
},
|
|
44
|
+
connectDistance: {
|
|
45
|
+
type: [
|
|
46
|
+
String,
|
|
47
|
+
Number,
|
|
48
|
+
Boolean,
|
|
49
|
+
Array,
|
|
50
|
+
Object
|
|
51
|
+
] as any
|
|
52
|
+
},
|
|
53
|
+
hoverEffect: {
|
|
54
|
+
type: [
|
|
55
|
+
String,
|
|
56
|
+
Number,
|
|
57
|
+
Boolean,
|
|
58
|
+
Array,
|
|
59
|
+
Object
|
|
60
|
+
] as any
|
|
61
|
+
},
|
|
62
|
+
interactiveRadius: {
|
|
63
|
+
type: [
|
|
64
|
+
String,
|
|
65
|
+
Number,
|
|
66
|
+
Boolean,
|
|
67
|
+
Array,
|
|
68
|
+
Object
|
|
69
|
+
] as any
|
|
70
|
+
},
|
|
71
|
+
_resize: {
|
|
72
|
+
type: [
|
|
73
|
+
String,
|
|
74
|
+
Number,
|
|
75
|
+
Boolean,
|
|
76
|
+
Array,
|
|
77
|
+
Object
|
|
78
|
+
] as any
|
|
79
|
+
},
|
|
80
|
+
_loop: {
|
|
81
|
+
type: [
|
|
82
|
+
String,
|
|
83
|
+
Number,
|
|
84
|
+
Boolean,
|
|
85
|
+
Array,
|
|
86
|
+
Object
|
|
87
|
+
] as any
|
|
88
|
+
},
|
|
89
|
+
locale: {
|
|
90
|
+
type: [
|
|
91
|
+
String,
|
|
92
|
+
Number,
|
|
93
|
+
Boolean,
|
|
94
|
+
Array,
|
|
95
|
+
Object
|
|
96
|
+
] as any
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
emits: [],
|
|
100
|
+
setup (props, { slots, emit }) {
|
|
101
|
+
const elementRef = ref<HTMLElementClass | null>(null);
|
|
102
|
+
if (false) {
|
|
103
|
+
watch(()=>props.modelValue, (newVal)=>{
|
|
104
|
+
if (elementRef.value && newVal !== undefined && elementRef.value.value !== newVal) {
|
|
105
|
+
elementRef.value.value = newVal;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
watch(()=>props.value, (newVal)=>{
|
|
109
|
+
if (elementRef.value && newVal !== undefined && elementRef.value.value !== newVal) {
|
|
110
|
+
elementRef.value.value = newVal;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
watch(()=>props.count, (newVal)=>{
|
|
115
|
+
if (elementRef.value && newVal !== undefined) {
|
|
116
|
+
(elementRef.value as any).count = newVal;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
watch(()=>props.speed, (newVal)=>{
|
|
120
|
+
if (elementRef.value && newVal !== undefined) {
|
|
121
|
+
(elementRef.value as any).speed = newVal;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
watch(()=>props.mode, (newVal)=>{
|
|
125
|
+
if (elementRef.value && newVal !== undefined) {
|
|
126
|
+
(elementRef.value as any).mode = newVal;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
watch(()=>props.connect, (newVal)=>{
|
|
130
|
+
if (elementRef.value && newVal !== undefined) {
|
|
131
|
+
(elementRef.value as any).connect = newVal;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
watch(()=>props.connectDistance, (newVal)=>{
|
|
135
|
+
if (elementRef.value && newVal !== undefined) {
|
|
136
|
+
(elementRef.value as any).connectDistance = newVal;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
watch(()=>props.hoverEffect, (newVal)=>{
|
|
140
|
+
if (elementRef.value && newVal !== undefined) {
|
|
141
|
+
(elementRef.value as any).hoverEffect = newVal;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
watch(()=>props.interactiveRadius, (newVal)=>{
|
|
145
|
+
if (elementRef.value && newVal !== undefined) {
|
|
146
|
+
(elementRef.value as any).interactiveRadius = newVal;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
watch(()=>props._resize, (newVal)=>{
|
|
150
|
+
if (elementRef.value && newVal !== undefined) {
|
|
151
|
+
(elementRef.value as any)._resize = newVal;
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
watch(()=>props._loop, (newVal)=>{
|
|
155
|
+
if (elementRef.value && newVal !== undefined) {
|
|
156
|
+
(elementRef.value as any)._loop = newVal;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
watch(()=>props.locale, (newVal)=>{
|
|
160
|
+
if (elementRef.value && newVal !== undefined) {
|
|
161
|
+
(elementRef.value as any).locale = newVal;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
return ()=>{
|
|
165
|
+
const eventListeners: Record<string, any> = {};
|
|
166
|
+
const mergedProps = {
|
|
167
|
+
...props,
|
|
168
|
+
...eventListeners,
|
|
169
|
+
ref: elementRef
|
|
170
|
+
};
|
|
171
|
+
if (false && props.modelValue !== undefined) {
|
|
172
|
+
(mergedProps as any).value = props.modelValue;
|
|
173
|
+
}
|
|
174
|
+
return h('uibit-particles', mergedProps, slots.default?.());
|
|
175
|
+
};
|
|
176
|
+
}
|
|
32
177
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { default, Particles } from './particles';
|
|
2
|
-
export type { Particle, ParticleHoverEffect, EffectParticlesConfig } from './types';
|
|
2
|
+
export type { Particle, ParticleHoverEffect, ParticleMode, EffectParticlesConfig } from './types';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EAAE,QAAQ,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EAAE,QAAQ,EAAE,mBAAmB,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uibit/particles",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Renders animated canvas backgrounds across thirteen distinct modes — from drifting particles and code rain to flow fields, aurora curtains, and pulsing grids. All modes react to mouse gestures and compose cleanly as hero backgrounds.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"./particles.css": "./dist/particles.css",
|
|
14
14
|
"./custom-elements.json": "./custom-elements.json",
|
|
15
|
-
"./react": "./dist/frameworks/react/index.
|
|
15
|
+
"./react": "./dist/frameworks/react/index.ts",
|
|
16
16
|
"./vue": "./dist/frameworks/vue/index.ts",
|
|
17
17
|
"./svelte": "./dist/frameworks/svelte/index.svelte",
|
|
18
18
|
"./angular": "./dist/frameworks/angular/index.ts",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@types/node": "^20.19.43",
|
|
53
53
|
"lit": "^3.3.3",
|
|
54
54
|
"typescript": "7.0.2",
|
|
55
|
-
"@uibit/codegen": "0.
|
|
55
|
+
"@uibit/codegen": "0.2.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"lit": "^3.0.0",
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { HTMLAttributes, ClassAttributes } from 'react';
|
|
2
|
-
import type { Particles as HTMLElementClass } from '@uibit/particles';
|
|
3
|
-
import '@uibit/particles';
|
|
4
|
-
import type { Particle, ParticleHoverEffect, ParticleMode } from '@uibit/particles';
|
|
5
|
-
|
|
6
|
-
declare global {
|
|
7
|
-
namespace React {
|
|
8
|
-
namespace JSX {
|
|
9
|
-
interface IntrinsicElements {
|
|
10
|
-
'uibit-particles': ClassAttributes<HTMLElementClass> & HTMLAttributes<HTMLElementClass> & {
|
|
11
|
-
children?: React.ReactNode;
|
|
12
|
-
class?: string;
|
|
13
|
-
count?: number;
|
|
14
|
-
speed?: number;
|
|
15
|
-
mode?: ParticleMode;
|
|
16
|
-
connect?: boolean;
|
|
17
|
-
connectDistance?: number;
|
|
18
|
-
hoverEffect?: ParticleHoverEffect;
|
|
19
|
-
interactiveRadius?: number;
|
|
20
|
-
_resize?: any;
|
|
21
|
-
_loop?: any;
|
|
22
|
-
locale?: string;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|