@uibit/effect-trigger 0.1.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.
@@ -0,0 +1,87 @@
1
+ import { Component, ChangeDetectionStrategy, ElementRef, input, effect, output, booleanAttribute, numberAttribute } from '@angular/core';
2
+ import '@uibit/effect-trigger';
3
+ import type { EffectTrigger as HTMLElementClass } from '@uibit/effect-trigger';
4
+ import type { EffectTriggerType, EffectBehaviorType } from '@uibit/effect-trigger';
5
+
6
+ @Component({
7
+ selector: 'uibit-effect-trigger',
8
+ template: '<ng-content></ng-content>',
9
+ changeDetection: ChangeDetectionStrategy.OnPush,
10
+ standalone: true,
11
+ host: {
12
+ '(uibit-particle-create)': 'uibitParticleCreate.emit($event)'
13
+ }
14
+ })
15
+ export class NgxEffectTrigger {
16
+ constructor(private el: ElementRef<HTMLElementClass>) {
17
+ effect(() => {
18
+ if (this.el.nativeElement) {
19
+ this.el.nativeElement.trigger = this.trigger();
20
+ }
21
+ });
22
+ effect(() => {
23
+ if (this.el.nativeElement) {
24
+ this.el.nativeElement.behavior = this.behavior();
25
+ }
26
+ });
27
+ effect(() => {
28
+ if (this.el.nativeElement) {
29
+ this.el.nativeElement.density = this.density();
30
+ }
31
+ });
32
+ effect(() => {
33
+ if (this.el.nativeElement) {
34
+ this.el.nativeElement.velocity = this.velocity();
35
+ }
36
+ });
37
+ effect(() => {
38
+ if (this.el.nativeElement) {
39
+ this.el.nativeElement.randomize = this.randomize();
40
+ }
41
+ });
42
+ effect(() => {
43
+ if (this.el.nativeElement) {
44
+ this.el.nativeElement.stagger = this.stagger();
45
+ }
46
+ });
47
+ effect(() => {
48
+ if (this.el.nativeElement) {
49
+ this.el.nativeElement.scaleRange = this.scaleRange();
50
+ }
51
+ });
52
+ effect(() => {
53
+ if (this.el.nativeElement) {
54
+ this.el.nativeElement.rotationRange = this.rotationRange();
55
+ }
56
+ });
57
+ effect(() => {
58
+ if (this.el.nativeElement) {
59
+ this.el.nativeElement.keyframes = this.keyframes();
60
+ }
61
+ });
62
+ effect(() => {
63
+ if (this.el.nativeElement) {
64
+ this.el.nativeElement.targetSelector = this.targetSelector();
65
+ }
66
+ });
67
+ effect(() => {
68
+ if (this.el.nativeElement) {
69
+ this.el.nativeElement.destinationSelector = this.destinationSelector();
70
+ }
71
+ });
72
+ }
73
+
74
+ readonly trigger = input<EffectTriggerType, any>('click');
75
+ readonly behavior = input<EffectBehaviorType, any>('float-displace');
76
+ readonly density = input<number, any>(1, { transform: numberAttribute });
77
+ readonly velocity = input<string, any>('1s');
78
+ readonly randomize = input<boolean, any>(false, { transform: booleanAttribute });
79
+ readonly stagger = input<string, any>('0ms');
80
+ readonly scaleRange = input<string, any>('0.5,1.5');
81
+ readonly rotationRange = input<string, any>('-180,180');
82
+ readonly keyframes = input<string | undefined, any>('');
83
+ readonly targetSelector = input<string | undefined, any>('');
84
+ readonly destinationSelector = input<string | undefined, any>('');
85
+
86
+ readonly uibitParticleCreate = output<CustomEvent<{ particle: HTMLElement, index: number, trigger: string }>>();
87
+ }
@@ -0,0 +1,10 @@
1
+ import type { EffectTrigger as HTMLElementClass } from '@uibit/effect-trigger';
2
+ import '@uibit/effect-trigger';
3
+
4
+ declare global {
5
+ namespace astroHTML.JSX {
6
+ interface IntrinsicElements {
7
+ 'uibit-effect-trigger': Partial<HTMLElementClass> & astroHTML.JSX.HTMLAttributes;
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,7 @@
1
+ import { defineNuxtPlugin } from '#app';
2
+
3
+ export default defineNuxtPlugin(() => {
4
+ if (process.client) {
5
+ import('@uibit/effect-trigger');
6
+ }
7
+ });
@@ -0,0 +1,24 @@
1
+ import type { JSX } from 'preact';
2
+ import type { EffectTrigger as HTMLElementClass } from '@uibit/effect-trigger';
3
+ import '@uibit/effect-trigger';
4
+ import type { EffectTriggerType, EffectBehaviorType } from '@uibit/effect-trigger';
5
+
6
+ declare module 'preact' {
7
+ namespace JSX {
8
+ interface IntrinsicElements {
9
+ 'uibit-effect-trigger': JSX.HTMLAttributes<HTMLElementClass> & {
10
+ trigger?: EffectTriggerType;
11
+ behavior?: EffectBehaviorType;
12
+ density?: number;
13
+ velocity?: string;
14
+ randomize?: boolean;
15
+ stagger?: string;
16
+ scaleRange?: string;
17
+ rotationRange?: string;
18
+ keyframes?: string | undefined;
19
+ targetSelector?: string | undefined;
20
+ destinationSelector?: string | undefined;
21
+ };
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,10 @@
1
+ import { component$, Slot } from '@builder.io/qwik';
2
+ import '@uibit/effect-trigger';
3
+
4
+ export const EffectTrigger = component$<any>((props) => {
5
+ return (
6
+ <uibit-effect-trigger {...props}>
7
+ <Slot />
8
+ </uibit-effect-trigger>
9
+ );
10
+ });
@@ -0,0 +1,29 @@
1
+ import type { HTMLAttributes, ClassAttributes } from 'react';
2
+ import type { EffectTrigger as HTMLElementClass } from '@uibit/effect-trigger';
3
+ import '@uibit/effect-trigger';
4
+ import type { EffectTriggerType, EffectBehaviorType } from '@uibit/effect-trigger';
5
+
6
+ declare global {
7
+ namespace React {
8
+ namespace JSX {
9
+ interface IntrinsicElements {
10
+ 'uibit-effect-trigger': ClassAttributes<HTMLElementClass> & HTMLAttributes<HTMLElementClass> & {
11
+ children?: React.ReactNode;
12
+ class?: string;
13
+ trigger?: EffectTriggerType;
14
+ behavior?: EffectBehaviorType;
15
+ density?: number;
16
+ velocity?: string;
17
+ randomize?: boolean;
18
+ stagger?: string;
19
+ scaleRange?: string;
20
+ rotationRange?: string;
21
+ keyframes?: string | undefined;
22
+ targetSelector?: string | undefined;
23
+ destinationSelector?: string | undefined;
24
+ onUibitParticleCreate?: (event: any) => void;
25
+ };
26
+ }
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,25 @@
1
+ import type { JSX } from 'solid-js';
2
+ import type { EffectTrigger as HTMLElementClass } from '@uibit/effect-trigger';
3
+ import '@uibit/effect-trigger';
4
+ import type { EffectTriggerType, EffectBehaviorType } from '@uibit/effect-trigger';
5
+
6
+ declare module 'solid-js' {
7
+ namespace JSX {
8
+ interface IntrinsicElements {
9
+ 'uibit-effect-trigger': Partial<HTMLElementClass> & JSX.HTMLAttributes<HTMLElementClass> & {
10
+ trigger?: EffectTriggerType;
11
+ behavior?: EffectBehaviorType;
12
+ density?: number;
13
+ velocity?: string;
14
+ randomize?: boolean;
15
+ stagger?: string;
16
+ scaleRange?: string;
17
+ rotationRange?: string;
18
+ keyframes?: string | undefined;
19
+ targetSelector?: string | undefined;
20
+ destinationSelector?: string | undefined;
21
+ "on:uibit-particle-create"?: (event: CustomEvent) => void;
22
+ };
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,23 @@
1
+ import type { EffectTrigger as HTMLElementClass } from '@uibit/effect-trigger';
2
+ import '@uibit/effect-trigger';
3
+ import type { EffectTriggerType, EffectBehaviorType } from '@uibit/effect-trigger';
4
+
5
+ declare module '@stencil/core' {
6
+ export namespace JSX {
7
+ interface IntrinsicElements {
8
+ 'uibit-effect-trigger': HTMLElementClass & {
9
+ trigger?: EffectTriggerType;
10
+ behavior?: EffectBehaviorType;
11
+ density?: number;
12
+ velocity?: string;
13
+ randomize?: boolean;
14
+ stagger?: string;
15
+ scaleRange?: string;
16
+ rotationRange?: string;
17
+ keyframes?: string | undefined;
18
+ targetSelector?: string | undefined;
19
+ destinationSelector?: string | undefined;
20
+ };
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,82 @@
1
+ <script lang="ts">
2
+ import '@uibit/effect-trigger';
3
+ import type { EffectTrigger as HTMLElementClass } from '@uibit/effect-trigger';
4
+ import type { EffectTriggerType, EffectBehaviorType } from '@uibit/effect-trigger';
5
+
6
+ let {
7
+ trigger = undefined,
8
+ behavior = undefined,
9
+ density = undefined,
10
+ velocity = undefined,
11
+ randomize = undefined,
12
+ stagger = undefined,
13
+ scaleRange = undefined,
14
+ rotationRange = undefined,
15
+ keyframes = undefined,
16
+ targetSelector = undefined,
17
+ destinationSelector = undefined,
18
+ children
19
+ } = $props<{
20
+ children?: any;
21
+ trigger?: EffectTriggerType;
22
+ behavior?: EffectBehaviorType;
23
+ density?: number;
24
+ velocity?: string;
25
+ randomize?: boolean;
26
+ stagger?: string;
27
+ scaleRange?: string;
28
+ rotationRange?: string;
29
+ keyframes?: string | undefined;
30
+ targetSelector?: string | undefined;
31
+ destinationSelector?: string | undefined;
32
+
33
+ }>();
34
+
35
+ let elementRef: HTMLElementClass | null = $state(null);
36
+
37
+ $effect(() => {
38
+ if (elementRef && trigger !== undefined) {
39
+ elementRef.trigger = trigger;
40
+ }
41
+ if (elementRef && behavior !== undefined) {
42
+ elementRef.behavior = behavior;
43
+ }
44
+ if (elementRef && density !== undefined) {
45
+ elementRef.density = density;
46
+ }
47
+ if (elementRef && velocity !== undefined) {
48
+ elementRef.velocity = velocity;
49
+ }
50
+ if (elementRef && randomize !== undefined) {
51
+ elementRef.randomize = randomize;
52
+ }
53
+ if (elementRef && stagger !== undefined) {
54
+ elementRef.stagger = stagger;
55
+ }
56
+ if (elementRef && scaleRange !== undefined) {
57
+ elementRef.scaleRange = scaleRange;
58
+ }
59
+ if (elementRef && rotationRange !== undefined) {
60
+ elementRef.rotationRange = rotationRange;
61
+ }
62
+ if (elementRef && keyframes !== undefined) {
63
+ elementRef.keyframes = keyframes;
64
+ }
65
+ if (elementRef && targetSelector !== undefined) {
66
+ elementRef.targetSelector = targetSelector;
67
+ }
68
+ if (elementRef && destinationSelector !== undefined) {
69
+ elementRef.destinationSelector = destinationSelector;
70
+ }
71
+ });
72
+
73
+ </script>
74
+
75
+ <uibit-effect-trigger bind:this={elementRef} {...$$restProps}>
76
+
77
+ {#if children}
78
+ {@render children()}
79
+ {:else}
80
+ <slot />
81
+ {/if}
82
+ </uibit-effect-trigger>
@@ -0,0 +1,35 @@
1
+ import { defineComponent, h } from 'vue';
2
+ import type { EffectTrigger as HTMLElementClass } from '@uibit/effect-trigger';
3
+ import '@uibit/effect-trigger';
4
+ import type { EffectTriggerType, EffectBehaviorType } from '@uibit/effect-trigger';
5
+
6
+ export const EffectTrigger = defineComponent({
7
+ name: 'EffectTrigger',
8
+ props: {
9
+ trigger: { type: [String, Number, Boolean, Array, Object] as any },
10
+ behavior: { type: [String, Number, Boolean, Array, Object] as any },
11
+ density: { type: [String, Number, Boolean, Array, Object] as any },
12
+ velocity: { type: [String, Number, Boolean, Array, Object] as any },
13
+ randomize: { type: [String, Number, Boolean, Array, Object] as any },
14
+ stagger: { type: [String, Number, Boolean, Array, Object] as any },
15
+ scaleRange: { type: [String, Number, Boolean, Array, Object] as any },
16
+ rotationRange: { type: [String, Number, Boolean, Array, Object] as any },
17
+ keyframes: { type: [String, Number, Boolean, Array, Object] as any },
18
+ targetSelector: { type: [String, Number, Boolean, Array, Object] as any },
19
+ destinationSelector: { type: [String, Number, Boolean, Array, Object] as any }
20
+ },
21
+ emits: ['uibit-particle-create'],
22
+ setup(props, { slots, emit }) {
23
+ return () => {
24
+ const eventListeners: Record<string, any> = {};
25
+ eventListeners['onUibit-particle-create'] = (event: Event) => {
26
+ emit('uibit-particle-create', event);
27
+ };
28
+
29
+ return h('uibit-effect-trigger', {
30
+ ...props,
31
+ ...eventListeners
32
+ }, slots.default?.());
33
+ };
34
+ }
35
+ });
@@ -0,0 +1,3 @@
1
+ export { default, EffectTrigger } from './effect-trigger';
2
+ export type { EffectTriggerType, EffectBehaviorType, BehaviorContext, BehaviorFn } from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC1D,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default, EffectTrigger } from './effect-trigger';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const styles: import("lit").CSSResult;
2
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,yBAclB,CAAC"}
package/dist/styles.js ADDED
@@ -0,0 +1,17 @@
1
+ import { css } from 'lit';
2
+ export const styles = css `
3
+ :host {
4
+ display: inline-block;
5
+ position: relative;
6
+ }
7
+
8
+ ::slotted([slot="trigger"]) {
9
+ display: inline-block;
10
+ }
11
+
12
+ /* Hide the template asset from standard layout */
13
+ slot[name="asset"] {
14
+ display: none !important;
15
+ }
16
+ `;
17
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;CAcxB,CAAC"}
@@ -0,0 +1,22 @@
1
+ export type EffectTriggerType = 'click' | 'hover' | 'visible' | 'custom';
2
+ export type EffectBehaviorType = 'traverse-x-right' | 'traverse-x-left' | 'traverse-y-up' | 'traverse-y-down' | 'fountain-burst' | 'vortex-attractor' | 'ambient-drift' | 'focal-pop' | 'orbit-halo' | 'float-displace' | string;
3
+ export interface BehaviorContext {
4
+ triggerEl: HTMLElement;
5
+ assetEl: HTMLElement;
6
+ containerEl: HTMLElement;
7
+ density: number;
8
+ velocity: string;
9
+ randomize: boolean;
10
+ stagger: string;
11
+ scaleRange: string;
12
+ rotationRange: string;
13
+ destinationSelector?: string;
14
+ }
15
+ export type BehaviorFn = (ctx: BehaviorContext) => void;
16
+ import type { EffectTrigger } from './effect-trigger';
17
+ declare global {
18
+ interface HTMLElementTagNameMap {
19
+ 'uibit-effect-trigger': EffectTrigger;
20
+ }
21
+ }
22
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEzE,MAAM,MAAM,kBAAkB,GAC1B,kBAAkB,GAClB,iBAAiB,GACjB,eAAe,GACf,iBAAiB,GACjB,gBAAgB,GAChB,kBAAkB,GAClB,eAAe,GACf,WAAW,GACX,YAAY,GACZ,gBAAgB,GAChB,MAAM,CAAC;AAEX,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,WAAW,CAAC;IACvB,OAAO,EAAE,WAAW,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;AAExD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,CAAC,MAAM,CAAC;IACf,UAAU,qBAAqB;QAC3B,sBAAsB,EAAE,aAAa,CAAC;KACzC;CACA"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,91 @@
1
+ {
2
+ "name": "@uibit/effect-trigger",
3
+ "version": "0.1.0",
4
+ "description": "A behavioral engine that intercepts user actions (click, hover, visible) on standard DOM elements to trigger custom particle animations, physics-based viewport crossings, or micro-feedback flows using slotted SVGs or markup templates.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./custom-elements.json": "./custom-elements.json",
14
+ "./react": "./dist/frameworks/react/index.d.ts",
15
+ "./vue": "./dist/frameworks/vue/index.ts",
16
+ "./svelte": "./dist/frameworks/svelte/index.svelte",
17
+ "./angular": "./dist/frameworks/angular/index.ts",
18
+ "./solid": "./dist/frameworks/solid/index.d.ts",
19
+ "./astro": "./dist/frameworks/astro/index.astro",
20
+ "./qwik": "./dist/frameworks/qwik/index.tsx",
21
+ "./nuxt": "./dist/frameworks/nuxt/index.ts",
22
+ "./preact": "./dist/frameworks/preact/index.d.ts",
23
+ "./stencil": "./dist/frameworks/stencil/index.d.ts"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "package.json",
28
+ "README.md",
29
+ "LICENSE",
30
+ "custom-elements.json"
31
+ ],
32
+ "keywords": [
33
+ "effect-trigger",
34
+ "motion",
35
+ "animation",
36
+ "web-component",
37
+ "lit",
38
+ "particles"
39
+ ],
40
+ "author": "Jonathan Rawlings",
41
+ "license": "MIT",
42
+ "dependencies": {
43
+ "@uibit/core": "0.1.0"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^20.19.43",
47
+ "lit": "^3.3.3",
48
+ "typescript": "7.0.2",
49
+ "@uibit/codegen": "0.1.0"
50
+ },
51
+ "peerDependencies": {
52
+ "lit": "^3.0.0",
53
+ "react": ">=18",
54
+ "vue": ">=3",
55
+ "svelte": ">=4 || ^5",
56
+ "@angular/core": ">=14"
57
+ },
58
+ "customElements": "custom-elements.json",
59
+ "peerDependenciesMeta": {
60
+ "react": {
61
+ "optional": true
62
+ },
63
+ "vue": {
64
+ "optional": true
65
+ },
66
+ "svelte": {
67
+ "optional": true
68
+ },
69
+ "@angular/core": {
70
+ "optional": true
71
+ }
72
+ },
73
+ "uibit": {
74
+ "id": "effect-trigger",
75
+ "title": "Effect Trigger",
76
+ "category": "Media",
77
+ "tagName": "uibit-effect-trigger"
78
+ },
79
+ "repository": {
80
+ "type": "git",
81
+ "url": "https://github.com/Rawlings/uibit",
82
+ "directory": "packages/components/effect-trigger"
83
+ },
84
+ "scripts": {
85
+ "build": "cem analyze --globs 'src/**/*.ts' --litelement && uibit-codegen --package . && tsc",
86
+ "dev": "concurrently \"cem analyze --globs 'src/**/*.ts' --litelement --watch\" \"tsc --watch\"",
87
+ "analyze": "cem analyze --globs 'src/**/*.ts' --litelement",
88
+ "typecheck": "tsc --noEmit",
89
+ "test": "vitest run -c ../../../vitest.config.ts --passWithNoTests"
90
+ }
91
+ }