@miurajs/miura-render 0.0.0 → 0.1.1
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/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/src/binding-manager/binding-manager.d.ts +30 -0
- package/dist/src/binding-manager/binding-manager.d.ts.map +1 -0
- package/dist/src/binding-manager/binding-manager.js +245 -0
- package/dist/src/binding-manager/binding-manager.js.map +1 -0
- package/dist/src/binding-manager/binding-type.d.ts +24 -0
- package/dist/src/binding-manager/binding-type.d.ts.map +1 -0
- package/dist/src/binding-manager/binding-type.js +25 -0
- package/dist/src/binding-manager/binding-type.js.map +1 -0
- package/dist/src/binding-manager/bindings/async-binding.d.ts +23 -0
- package/dist/src/binding-manager/bindings/async-binding.d.ts.map +1 -0
- package/dist/src/binding-manager/bindings/async-binding.js +67 -0
- package/dist/src/binding-manager/bindings/async-binding.js.map +1 -0
- package/dist/src/binding-manager/bindings/attribute-binding.d.ts +41 -0
- package/dist/src/binding-manager/bindings/attribute-binding.d.ts.map +1 -0
- package/dist/src/binding-manager/bindings/attribute-binding.js +79 -0
- package/dist/src/binding-manager/bindings/attribute-binding.js.map +1 -0
- package/dist/src/binding-manager/bindings/bind-binding.d.ts +30 -0
- package/dist/src/binding-manager/bindings/bind-binding.d.ts.map +1 -0
- package/dist/src/binding-manager/bindings/bind-binding.js +81 -0
- package/dist/src/binding-manager/bindings/bind-binding.js.map +1 -0
- package/dist/src/binding-manager/bindings/binding.d.ts +6 -0
- package/dist/src/binding-manager/bindings/binding.d.ts.map +1 -0
- package/dist/src/binding-manager/bindings/binding.js +2 -0
- package/dist/src/binding-manager/bindings/binding.js.map +1 -0
- package/dist/src/binding-manager/bindings/boolean-binding.d.ts +18 -0
- package/dist/src/binding-manager/bindings/boolean-binding.d.ts.map +1 -0
- package/dist/src/binding-manager/bindings/boolean-binding.js +65 -0
- package/dist/src/binding-manager/bindings/boolean-binding.js.map +1 -0
- package/dist/src/binding-manager/bindings/class-binding.d.ts +10 -0
- package/dist/src/binding-manager/bindings/class-binding.d.ts.map +1 -0
- package/dist/src/binding-manager/bindings/class-binding.js +68 -0
- package/dist/src/binding-manager/bindings/class-binding.js.map +1 -0
- package/dist/src/binding-manager/bindings/directive-binding.d.ts +15 -0
- package/dist/src/binding-manager/bindings/directive-binding.d.ts.map +1 -0
- package/dist/src/binding-manager/bindings/directive-binding.js +70 -0
- package/dist/src/binding-manager/bindings/directive-binding.js.map +1 -0
- package/dist/src/binding-manager/bindings/event-binding.d.ts +14 -0
- package/dist/src/binding-manager/bindings/event-binding.d.ts.map +1 -0
- package/dist/src/binding-manager/bindings/event-binding.js +73 -0
- package/dist/src/binding-manager/bindings/event-binding.js.map +1 -0
- package/dist/src/binding-manager/bindings/node-binding.d.ts +36 -0
- package/dist/src/binding-manager/bindings/node-binding.d.ts.map +1 -0
- package/dist/src/binding-manager/bindings/node-binding.js +235 -0
- package/dist/src/binding-manager/bindings/node-binding.js.map +1 -0
- package/dist/src/binding-manager/bindings/object-class-binding.d.ts +16 -0
- package/dist/src/binding-manager/bindings/object-class-binding.d.ts.map +1 -0
- package/dist/src/binding-manager/bindings/object-class-binding.js +42 -0
- package/dist/src/binding-manager/bindings/object-class-binding.js.map +1 -0
- package/dist/src/binding-manager/bindings/object-style-binding.d.ts +16 -0
- package/dist/src/binding-manager/bindings/object-style-binding.d.ts.map +1 -0
- package/dist/src/binding-manager/bindings/object-style-binding.js +38 -0
- package/dist/src/binding-manager/bindings/object-style-binding.js.map +1 -0
- package/dist/src/binding-manager/bindings/property-binding.d.ts +12 -0
- package/dist/src/binding-manager/bindings/property-binding.d.ts.map +1 -0
- package/dist/src/binding-manager/bindings/property-binding.js +44 -0
- package/dist/src/binding-manager/bindings/property-binding.js.map +1 -0
- package/dist/src/binding-manager/bindings/reference-binding.d.ts +14 -0
- package/dist/src/binding-manager/bindings/reference-binding.d.ts.map +1 -0
- package/dist/src/binding-manager/bindings/reference-binding.js +44 -0
- package/dist/src/binding-manager/bindings/reference-binding.js.map +1 -0
- package/dist/src/binding-manager/bindings/spread-binding.d.ts +16 -0
- package/dist/src/binding-manager/bindings/spread-binding.d.ts.map +1 -0
- package/dist/src/binding-manager/bindings/spread-binding.js +40 -0
- package/dist/src/binding-manager/bindings/spread-binding.js.map +1 -0
- package/dist/src/binding-manager/bindings/style-binding.d.ts +10 -0
- package/dist/src/binding-manager/bindings/style-binding.d.ts.map +1 -0
- package/dist/src/binding-manager/bindings/style-binding.js +44 -0
- package/dist/src/binding-manager/bindings/style-binding.js.map +1 -0
- package/dist/src/compiler/code-factory.d.ts +45 -0
- package/dist/src/compiler/code-factory.d.ts.map +1 -0
- package/dist/src/compiler/code-factory.js +211 -0
- package/dist/src/compiler/code-factory.js.map +1 -0
- package/dist/src/compiler/compiler.d.ts +77 -0
- package/dist/src/compiler/compiler.d.ts.map +1 -0
- package/dist/src/compiler/compiler.js +77 -0
- package/dist/src/compiler/compiler.js.map +1 -0
- package/dist/src/compiler/constants.d.ts +5 -0
- package/dist/src/compiler/constants.d.ts.map +1 -0
- package/dist/src/compiler/constants.js +9 -0
- package/dist/src/compiler/constants.js.map +1 -0
- package/dist/src/css-result.d.ts +27 -0
- package/dist/src/css-result.d.ts.map +1 -0
- package/dist/src/css-result.js +56 -0
- package/dist/src/css-result.js.map +1 -0
- package/dist/src/css.d.ts +26 -0
- package/dist/src/css.d.ts.map +1 -0
- package/dist/src/css.js +62 -0
- package/dist/src/css.js.map +1 -0
- package/dist/src/directives/animate.directive.d.ts +42 -0
- package/dist/src/directives/animate.directive.d.ts.map +1 -0
- package/dist/src/directives/animate.directive.js +349 -0
- package/dist/src/directives/animate.directive.js.map +1 -0
- package/dist/src/directives/await.d.ts +68 -0
- package/dist/src/directives/await.d.ts.map +1 -0
- package/dist/src/directives/await.js +70 -0
- package/dist/src/directives/await.js.map +1 -0
- package/dist/src/directives/choose.d.ts +28 -0
- package/dist/src/directives/choose.d.ts.map +1 -0
- package/dist/src/directives/choose.js +30 -0
- package/dist/src/directives/choose.js.map +1 -0
- package/dist/src/directives/decorator-example.d.ts +8 -0
- package/dist/src/directives/decorator-example.d.ts.map +1 -0
- package/dist/src/directives/decorator-example.js +32 -0
- package/dist/src/directives/decorator-example.js.map +1 -0
- package/dist/src/directives/decorators.d.ts +3 -0
- package/dist/src/directives/decorators.d.ts.map +1 -0
- package/dist/src/directives/decorators.js +17 -0
- package/dist/src/directives/decorators.js.map +1 -0
- package/dist/src/directives/directive-manager.d.ts +26 -0
- package/dist/src/directives/directive-manager.d.ts.map +1 -0
- package/dist/src/directives/directive-manager.js +114 -0
- package/dist/src/directives/directive-manager.js.map +1 -0
- package/dist/src/directives/directive.d.ts +38 -0
- package/dist/src/directives/directive.d.ts.map +1 -0
- package/dist/src/directives/directive.js +18 -0
- package/dist/src/directives/directive.js.map +1 -0
- package/dist/src/directives/focus.directive.d.ts +16 -0
- package/dist/src/directives/focus.directive.d.ts.map +1 -0
- package/dist/src/directives/focus.directive.js +29 -0
- package/dist/src/directives/focus.directive.js.map +1 -0
- package/dist/src/directives/gesture.directive.d.ts +58 -0
- package/dist/src/directives/gesture.directive.d.ts.map +1 -0
- package/dist/src/directives/gesture.directive.js +331 -0
- package/dist/src/directives/gesture.directive.js.map +1 -0
- package/dist/src/directives/index.d.ts +34 -0
- package/dist/src/directives/index.d.ts.map +1 -0
- package/dist/src/directives/index.js +35 -0
- package/dist/src/directives/index.js.map +1 -0
- package/dist/src/directives/intersection.directive.d.ts +18 -0
- package/dist/src/directives/intersection.directive.d.ts.map +1 -0
- package/dist/src/directives/intersection.directive.js +50 -0
- package/dist/src/directives/intersection.directive.js.map +1 -0
- package/dist/src/directives/keyed-diff.d.ts +30 -0
- package/dist/src/directives/keyed-diff.d.ts.map +1 -0
- package/dist/src/directives/keyed-diff.js +185 -0
- package/dist/src/directives/keyed-diff.js.map +1 -0
- package/dist/src/directives/lazy-setup.d.ts +3 -0
- package/dist/src/directives/lazy-setup.d.ts.map +1 -0
- package/dist/src/directives/lazy-setup.js +55 -0
- package/dist/src/directives/lazy-setup.js.map +1 -0
- package/dist/src/directives/lazy.directive.d.ts +19 -0
- package/dist/src/directives/lazy.directive.d.ts.map +1 -0
- package/dist/src/directives/lazy.directive.js +73 -0
- package/dist/src/directives/lazy.directive.js.map +1 -0
- package/dist/src/directives/media.directive.d.ts +31 -0
- package/dist/src/directives/media.directive.d.ts.map +1 -0
- package/dist/src/directives/media.directive.js +105 -0
- package/dist/src/directives/media.directive.js.map +1 -0
- package/dist/src/directives/mutation.directive.d.ts +11 -0
- package/dist/src/directives/mutation.directive.d.ts.map +1 -0
- package/dist/src/directives/mutation.directive.js +56 -0
- package/dist/src/directives/mutation.directive.js.map +1 -0
- package/dist/src/directives/repeat.d.ts +50 -0
- package/dist/src/directives/repeat.d.ts.map +1 -0
- package/dist/src/directives/repeat.js +47 -0
- package/dist/src/directives/repeat.js.map +1 -0
- package/dist/src/directives/resize.directive.d.ts +14 -0
- package/dist/src/directives/resize.directive.d.ts.map +1 -0
- package/dist/src/directives/resize.directive.js +81 -0
- package/dist/src/directives/resize.directive.js.map +1 -0
- package/dist/src/directives/setup.d.ts +9 -0
- package/dist/src/directives/setup.d.ts.map +1 -0
- package/dist/src/directives/setup.js +9 -0
- package/dist/src/directives/setup.js.map +1 -0
- package/dist/src/directives/structural/async.directive.d.ts +39 -0
- package/dist/src/directives/structural/async.directive.d.ts.map +1 -0
- package/dist/src/directives/structural/async.directive.js +115 -0
- package/dist/src/directives/structural/async.directive.js.map +1 -0
- package/dist/src/directives/structural/for.directive.d.ts +37 -0
- package/dist/src/directives/structural/for.directive.d.ts.map +1 -0
- package/dist/src/directives/structural/for.directive.js +209 -0
- package/dist/src/directives/structural/for.directive.js.map +1 -0
- package/dist/src/directives/structural/if.directive.d.ts +54 -0
- package/dist/src/directives/structural/if.directive.d.ts.map +1 -0
- package/dist/src/directives/structural/if.directive.js +210 -0
- package/dist/src/directives/structural/if.directive.js.map +1 -0
- package/dist/src/directives/structural/structural.directive.d.ts +11 -0
- package/dist/src/directives/structural/structural.directive.d.ts.map +1 -0
- package/dist/src/directives/structural/structural.directive.js +29 -0
- package/dist/src/directives/structural/structural.directive.js.map +1 -0
- package/dist/src/directives/structural/switch.directive.d.ts +12 -0
- package/dist/src/directives/structural/switch.directive.d.ts.map +1 -0
- package/dist/src/directives/structural/switch.directive.js +69 -0
- package/dist/src/directives/structural/switch.directive.js.map +1 -0
- package/dist/src/directives/structural/virtual-scroll.directive.d.ts +50 -0
- package/dist/src/directives/structural/virtual-scroll.directive.d.ts.map +1 -0
- package/dist/src/directives/structural/virtual-scroll.directive.js +165 -0
- package/dist/src/directives/structural/virtual-scroll.directive.js.map +1 -0
- package/dist/src/directives/utils.d.ts +61 -0
- package/dist/src/directives/utils.d.ts.map +1 -0
- package/dist/src/directives/utils.js +121 -0
- package/dist/src/directives/utils.js.map +1 -0
- package/dist/src/directives/validate.directive.d.ts +41 -0
- package/dist/src/directives/validate.directive.d.ts.map +1 -0
- package/dist/src/directives/validate.directive.js +161 -0
- package/dist/src/directives/validate.directive.js.map +1 -0
- package/dist/src/directives/virtual-scroll.d.ts +91 -0
- package/dist/src/directives/virtual-scroll.d.ts.map +1 -0
- package/dist/src/directives/virtual-scroll.js +78 -0
- package/dist/src/directives/virtual-scroll.js.map +1 -0
- package/dist/src/directives/when.d.ts +24 -0
- package/dist/src/directives/when.d.ts.map +1 -0
- package/dist/src/directives/when.js +25 -0
- package/dist/src/directives/when.js.map +1 -0
- package/dist/src/html.d.ts +23 -0
- package/dist/src/html.d.ts.map +1 -0
- package/dist/src/html.js +37 -0
- package/dist/src/html.js.map +1 -0
- package/dist/src/modifiers/capture-modifier.d.ts +6 -0
- package/dist/src/modifiers/capture-modifier.d.ts.map +1 -0
- package/dist/src/modifiers/capture-modifier.js +14 -0
- package/dist/src/modifiers/capture-modifier.js.map +1 -0
- package/dist/src/modifiers/event-modifiers.d.ts +38 -0
- package/dist/src/modifiers/event-modifiers.d.ts.map +1 -0
- package/dist/src/modifiers/event-modifiers.js +90 -0
- package/dist/src/modifiers/event-modifiers.js.map +1 -0
- package/dist/src/modifiers/key-modifiers.d.ts +8 -0
- package/dist/src/modifiers/key-modifiers.d.ts.map +1 -0
- package/dist/src/modifiers/key-modifiers.js +29 -0
- package/dist/src/modifiers/key-modifiers.js.map +1 -0
- package/dist/src/modifiers/mouse-modifiers.d.ts +8 -0
- package/dist/src/modifiers/mouse-modifiers.d.ts.map +1 -0
- package/dist/src/modifiers/mouse-modifiers.js +15 -0
- package/dist/src/modifiers/mouse-modifiers.js.map +1 -0
- package/dist/src/modifiers/once-modifier.d.ts +6 -0
- package/dist/src/modifiers/once-modifier.d.ts.map +1 -0
- package/dist/src/modifiers/once-modifier.js +11 -0
- package/dist/src/modifiers/once-modifier.js.map +1 -0
- package/dist/src/modifiers/passive-modifier.d.ts +6 -0
- package/dist/src/modifiers/passive-modifier.d.ts.map +1 -0
- package/dist/src/modifiers/passive-modifier.js +14 -0
- package/dist/src/modifiers/passive-modifier.js.map +1 -0
- package/dist/src/processor/parser.d.ts +74 -0
- package/dist/src/processor/parser.d.ts.map +1 -0
- package/dist/src/processor/parser.js +345 -0
- package/dist/src/processor/parser.js.map +1 -0
- package/dist/src/processor/processor.d.ts +68 -0
- package/dist/src/processor/processor.d.ts.map +1 -0
- package/dist/src/processor/processor.js +138 -0
- package/dist/src/processor/processor.js.map +1 -0
- package/dist/src/processor/template-result.d.ts +74 -0
- package/dist/src/processor/template-result.d.ts.map +1 -0
- package/dist/src/processor/template-result.js +53 -0
- package/dist/src/processor/template-result.js.map +1 -0
- package/dist/src/processor/types.d.ts +16 -0
- package/dist/src/processor/types.d.ts.map +1 -0
- package/dist/src/processor/types.js +13 -0
- package/dist/src/processor/types.js.map +1 -0
- package/dist/src/utils/debug.d.ts +7 -0
- package/dist/src/utils/debug.d.ts.map +1 -0
- package/dist/src/utils/debug.js +7 -0
- package/dist/src/utils/debug.js.map +1 -0
- package/dist/src/utils/performance.d.ts +50 -0
- package/dist/src/utils/performance.d.ts.map +1 -0
- package/dist/src/utils/performance.js +51 -0
- package/dist/src/utils/performance.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +8 -10
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { BaseDirective } from './directive';
|
|
2
|
+
interface AnimationOptions {
|
|
3
|
+
trigger?: 'click' | 'hover' | 'visible' | 'custom';
|
|
4
|
+
animation?: string;
|
|
5
|
+
duration?: string | number;
|
|
6
|
+
delay?: string | number;
|
|
7
|
+
easing?: string;
|
|
8
|
+
threshold?: number;
|
|
9
|
+
onStart?: () => void;
|
|
10
|
+
onEnd?: () => void;
|
|
11
|
+
onCancel?: () => void;
|
|
12
|
+
enter?: string;
|
|
13
|
+
exit?: string;
|
|
14
|
+
onEnter?: () => void;
|
|
15
|
+
onExit?: () => void;
|
|
16
|
+
onComplete?: () => void;
|
|
17
|
+
}
|
|
18
|
+
export declare class AnimateDirective extends BaseDirective {
|
|
19
|
+
private options;
|
|
20
|
+
private isAnimating;
|
|
21
|
+
private animationId;
|
|
22
|
+
private intersectionObserver;
|
|
23
|
+
private eventListeners;
|
|
24
|
+
mount(element: Element): void;
|
|
25
|
+
private setupTriggers;
|
|
26
|
+
private addEventListener;
|
|
27
|
+
private setupIntersectionObserver;
|
|
28
|
+
private handleClick;
|
|
29
|
+
private handleHover;
|
|
30
|
+
private playAnimation;
|
|
31
|
+
private applyAnimation;
|
|
32
|
+
private getDuration;
|
|
33
|
+
private getDelay;
|
|
34
|
+
private addAnimationStyles;
|
|
35
|
+
update(options: AnimationOptions): void;
|
|
36
|
+
private cleanup;
|
|
37
|
+
unmount(): void;
|
|
38
|
+
play(): void;
|
|
39
|
+
stop(): void;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=animate.directive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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AAQ;IAQhB,OAAO,CAAC,kBAAkB;IAwI1B,MAAM,CAAC,OAAO,EAAE,gBAAgB;IAUhC,OAAO,CAAC,OAAO;IAcf,OAAO;IAWP,IAAI;IAMJ,IAAI;CAWP"}
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { BaseDirective } from './directive';
|
|
2
|
+
import { debugLog } from '../utils/debug';
|
|
3
|
+
export class AnimateDirective extends BaseDirective {
|
|
4
|
+
options = {};
|
|
5
|
+
isAnimating = false;
|
|
6
|
+
animationId = null;
|
|
7
|
+
intersectionObserver = null;
|
|
8
|
+
eventListeners = [];
|
|
9
|
+
mount(element) {
|
|
10
|
+
debugLog('animate', 'Mounting animate directive');
|
|
11
|
+
this.options = {
|
|
12
|
+
trigger: 'click',
|
|
13
|
+
duration: '0.3s',
|
|
14
|
+
easing: 'ease-out',
|
|
15
|
+
threshold: 0.1,
|
|
16
|
+
...this.options
|
|
17
|
+
};
|
|
18
|
+
this.setupTriggers(element);
|
|
19
|
+
this.addAnimationStyles();
|
|
20
|
+
}
|
|
21
|
+
setupTriggers(element) {
|
|
22
|
+
if (element instanceof HTMLElement) {
|
|
23
|
+
switch (this.options.trigger) {
|
|
24
|
+
case 'click':
|
|
25
|
+
this.addEventListener(element, 'click', this.handleClick.bind(this));
|
|
26
|
+
break;
|
|
27
|
+
case 'hover':
|
|
28
|
+
this.addEventListener(element, 'mouseenter', this.handleHover.bind(this));
|
|
29
|
+
break;
|
|
30
|
+
case 'visible':
|
|
31
|
+
this.setupIntersectionObserver(element);
|
|
32
|
+
break;
|
|
33
|
+
case 'custom':
|
|
34
|
+
// Custom trigger - no automatic setup
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
addEventListener(element, event, handler) {
|
|
40
|
+
element.addEventListener(event, handler);
|
|
41
|
+
this.eventListeners.push({ element, event, handler });
|
|
42
|
+
}
|
|
43
|
+
setupIntersectionObserver(element) {
|
|
44
|
+
if ('IntersectionObserver' in window) {
|
|
45
|
+
this.intersectionObserver = new IntersectionObserver((entries) => {
|
|
46
|
+
entries.forEach(entry => {
|
|
47
|
+
if (entry.isIntersecting) {
|
|
48
|
+
this.playAnimation(element);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}, {
|
|
52
|
+
threshold: this.options.threshold,
|
|
53
|
+
rootMargin: '50px'
|
|
54
|
+
});
|
|
55
|
+
this.intersectionObserver.observe(element);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
handleClick = (event) => {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
this.playAnimation(event.target);
|
|
61
|
+
};
|
|
62
|
+
handleHover = (event) => {
|
|
63
|
+
this.playAnimation(event.target);
|
|
64
|
+
};
|
|
65
|
+
playAnimation(element) {
|
|
66
|
+
if (this.isAnimating || !element)
|
|
67
|
+
return;
|
|
68
|
+
debugLog('animate', 'Playing animation:', this.options.animation);
|
|
69
|
+
this.isAnimating = true;
|
|
70
|
+
this.options.onStart?.();
|
|
71
|
+
if (element instanceof HTMLElement) {
|
|
72
|
+
const animationType = this.options.animation || 'fadeIn';
|
|
73
|
+
const duration = this.getDuration();
|
|
74
|
+
const delay = this.getDelay();
|
|
75
|
+
// Apply animation
|
|
76
|
+
this.applyAnimation(element, animationType, duration, delay);
|
|
77
|
+
// Set up completion callback
|
|
78
|
+
const handleAnimationEnd = () => {
|
|
79
|
+
element.removeEventListener('animationend', handleAnimationEnd);
|
|
80
|
+
element.removeEventListener('transitionend', handleAnimationEnd);
|
|
81
|
+
this.isAnimating = false;
|
|
82
|
+
this.options.onEnd?.();
|
|
83
|
+
debugLog('animate', 'Animation completed');
|
|
84
|
+
};
|
|
85
|
+
element.addEventListener('animationend', handleAnimationEnd);
|
|
86
|
+
element.addEventListener('transitionend', handleAnimationEnd);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
applyAnimation(element, animationType, duration, delay) {
|
|
90
|
+
// Clear any existing animations and transitions to prevent conflicts
|
|
91
|
+
element.style.animation = '';
|
|
92
|
+
element.style.transition = '';
|
|
93
|
+
element.style.transform = '';
|
|
94
|
+
element.style.opacity = '';
|
|
95
|
+
// Force a reflow to ensure styles are cleared
|
|
96
|
+
element.offsetHeight;
|
|
97
|
+
switch (animationType) {
|
|
98
|
+
case 'bounce':
|
|
99
|
+
element.style.animation = `bounce ${duration} ${delay} ease-in-out`;
|
|
100
|
+
break;
|
|
101
|
+
case 'fadeIn':
|
|
102
|
+
element.style.opacity = '0';
|
|
103
|
+
element.style.animation = `fadeIn ${duration} ${delay} ease-out`;
|
|
104
|
+
break;
|
|
105
|
+
case 'fadeOut':
|
|
106
|
+
element.style.animation = `fadeOut ${duration} ${delay} ease-in`;
|
|
107
|
+
break;
|
|
108
|
+
case 'slideInLeft':
|
|
109
|
+
element.style.transform = 'translate3d(-100%, 0, 0)';
|
|
110
|
+
element.style.opacity = '0';
|
|
111
|
+
element.style.animation = `slideInLeft ${duration} ${delay} ease-out`;
|
|
112
|
+
break;
|
|
113
|
+
case 'slideInRight':
|
|
114
|
+
element.style.transform = 'translate3d(100%, 0, 0)';
|
|
115
|
+
element.style.opacity = '0';
|
|
116
|
+
element.style.animation = `slideInRight ${duration} ${delay} ease-out`;
|
|
117
|
+
break;
|
|
118
|
+
case 'slideInUp':
|
|
119
|
+
element.style.transform = 'translate3d(0, 100%, 0)';
|
|
120
|
+
element.style.opacity = '0';
|
|
121
|
+
element.style.animation = `slideInUp ${duration} ${delay} ease-out`;
|
|
122
|
+
break;
|
|
123
|
+
case 'slideInDown':
|
|
124
|
+
element.style.transform = 'translate3d(0, -100%, 0)';
|
|
125
|
+
element.style.opacity = '0';
|
|
126
|
+
element.style.animation = `slideInDown ${duration} ${delay} ease-out`;
|
|
127
|
+
break;
|
|
128
|
+
case 'rotate':
|
|
129
|
+
element.style.animation = `rotate ${duration} ${delay} ease-in-out`;
|
|
130
|
+
break;
|
|
131
|
+
case 'scale':
|
|
132
|
+
element.style.animation = `scale ${duration} ${delay} ease-out`;
|
|
133
|
+
break;
|
|
134
|
+
case 'shake':
|
|
135
|
+
element.style.animation = `shake ${duration} ${delay} ease-in-out`;
|
|
136
|
+
break;
|
|
137
|
+
case 'pulse':
|
|
138
|
+
element.style.animation = `pulse ${duration} ${delay} ease-in-out`;
|
|
139
|
+
break;
|
|
140
|
+
case 'progress':
|
|
141
|
+
element.style.transition = `width ${duration} ${delay} ease-out`;
|
|
142
|
+
element.style.width = '100%';
|
|
143
|
+
break;
|
|
144
|
+
default:
|
|
145
|
+
// Custom animation or fallback
|
|
146
|
+
if (this.options.enter) {
|
|
147
|
+
element.style.animation = `${this.options.enter} ${duration} ${delay}`;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// Default fade in
|
|
151
|
+
element.style.opacity = '0';
|
|
152
|
+
element.style.animation = `fadeIn ${duration} ${delay} ease-out`;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
getDuration() {
|
|
157
|
+
const duration = this.options.duration;
|
|
158
|
+
if (typeof duration === 'number') {
|
|
159
|
+
return `${duration}ms`;
|
|
160
|
+
}
|
|
161
|
+
return duration;
|
|
162
|
+
}
|
|
163
|
+
getDelay() {
|
|
164
|
+
const delay = this.options.delay;
|
|
165
|
+
if (typeof delay === 'number') {
|
|
166
|
+
return `${delay}ms`;
|
|
167
|
+
}
|
|
168
|
+
return delay ? `${delay}` : '0s';
|
|
169
|
+
}
|
|
170
|
+
addAnimationStyles() {
|
|
171
|
+
// Add CSS keyframes if they don't exist
|
|
172
|
+
if (!document.getElementById('miura-animation-styles')) {
|
|
173
|
+
const style = document.createElement('style');
|
|
174
|
+
style.id = 'miura-animation-styles';
|
|
175
|
+
style.textContent = `
|
|
176
|
+
@keyframes bounce {
|
|
177
|
+
0%, 20%, 53%, 80%, 100% {
|
|
178
|
+
transform: translate3d(0,0,0);
|
|
179
|
+
}
|
|
180
|
+
40%, 43% {
|
|
181
|
+
transform: translate3d(0,-30px,0);
|
|
182
|
+
}
|
|
183
|
+
70% {
|
|
184
|
+
transform: translate3d(0,-15px,0);
|
|
185
|
+
}
|
|
186
|
+
90% {
|
|
187
|
+
transform: translate3d(0,-4px,0);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@keyframes fadeIn {
|
|
192
|
+
from {
|
|
193
|
+
opacity: 0;
|
|
194
|
+
transform: scale(0.9);
|
|
195
|
+
}
|
|
196
|
+
to {
|
|
197
|
+
opacity: 1;
|
|
198
|
+
transform: scale(1);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@keyframes fadeOut {
|
|
203
|
+
from {
|
|
204
|
+
opacity: 1;
|
|
205
|
+
transform: scale(1);
|
|
206
|
+
}
|
|
207
|
+
to {
|
|
208
|
+
opacity: 0;
|
|
209
|
+
transform: scale(0.9);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
@keyframes slideInLeft {
|
|
214
|
+
from {
|
|
215
|
+
transform: translate3d(-100%, 0, 0);
|
|
216
|
+
opacity: 0;
|
|
217
|
+
}
|
|
218
|
+
to {
|
|
219
|
+
transform: translate3d(0, 0, 0);
|
|
220
|
+
opacity: 1;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@keyframes slideInRight {
|
|
225
|
+
from {
|
|
226
|
+
transform: translate3d(100%, 0, 0);
|
|
227
|
+
opacity: 0;
|
|
228
|
+
}
|
|
229
|
+
to {
|
|
230
|
+
transform: translate3d(0, 0, 0);
|
|
231
|
+
opacity: 1;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
@keyframes slideInUp {
|
|
236
|
+
from {
|
|
237
|
+
transform: translate3d(0, 100%, 0);
|
|
238
|
+
opacity: 0;
|
|
239
|
+
}
|
|
240
|
+
to {
|
|
241
|
+
transform: translate3d(0, 0, 0);
|
|
242
|
+
opacity: 1;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
@keyframes slideInDown {
|
|
247
|
+
from {
|
|
248
|
+
transform: translate3d(0, -100%, 0);
|
|
249
|
+
opacity: 0;
|
|
250
|
+
}
|
|
251
|
+
to {
|
|
252
|
+
transform: translate3d(0, 0, 0);
|
|
253
|
+
opacity: 1;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
@keyframes rotate {
|
|
258
|
+
from {
|
|
259
|
+
transform: rotate(0deg);
|
|
260
|
+
}
|
|
261
|
+
to {
|
|
262
|
+
transform: rotate(360deg);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
@keyframes scale {
|
|
267
|
+
0% {
|
|
268
|
+
transform: scale(1);
|
|
269
|
+
}
|
|
270
|
+
50% {
|
|
271
|
+
transform: scale(1.2);
|
|
272
|
+
}
|
|
273
|
+
100% {
|
|
274
|
+
transform: scale(1);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
@keyframes shake {
|
|
279
|
+
0%, 100% {
|
|
280
|
+
transform: translateX(0);
|
|
281
|
+
}
|
|
282
|
+
10%, 30%, 50%, 70%, 90% {
|
|
283
|
+
transform: translateX(-10px);
|
|
284
|
+
}
|
|
285
|
+
20%, 40%, 60%, 80% {
|
|
286
|
+
transform: translateX(10px);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
@keyframes pulse {
|
|
291
|
+
0% {
|
|
292
|
+
transform: scale(1);
|
|
293
|
+
}
|
|
294
|
+
50% {
|
|
295
|
+
transform: scale(1.1);
|
|
296
|
+
}
|
|
297
|
+
100% {
|
|
298
|
+
transform: scale(1);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
`;
|
|
302
|
+
document.head.appendChild(style);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
update(options) {
|
|
306
|
+
this.options = { ...this.options, ...options };
|
|
307
|
+
// Re-setup triggers if trigger changed
|
|
308
|
+
if (this.element) {
|
|
309
|
+
this.cleanup();
|
|
310
|
+
this.setupTriggers(this.element);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
cleanup() {
|
|
314
|
+
// Remove event listeners
|
|
315
|
+
this.eventListeners.forEach(({ element, event, handler }) => {
|
|
316
|
+
element.removeEventListener(event, handler);
|
|
317
|
+
});
|
|
318
|
+
this.eventListeners = [];
|
|
319
|
+
// Disconnect intersection observer
|
|
320
|
+
if (this.intersectionObserver) {
|
|
321
|
+
this.intersectionObserver.disconnect();
|
|
322
|
+
this.intersectionObserver = null;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
unmount() {
|
|
326
|
+
this.cleanup();
|
|
327
|
+
if (this.animationId) {
|
|
328
|
+
cancelAnimationFrame(this.animationId);
|
|
329
|
+
}
|
|
330
|
+
this.isAnimating = false;
|
|
331
|
+
}
|
|
332
|
+
// Public methods for programmatic control
|
|
333
|
+
play() {
|
|
334
|
+
if (this.element) {
|
|
335
|
+
this.playAnimation(this.element);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
stop() {
|
|
339
|
+
if (this.element && this.isAnimating) {
|
|
340
|
+
this.isAnimating = false;
|
|
341
|
+
this.options.onCancel?.();
|
|
342
|
+
if (this.element instanceof HTMLElement) {
|
|
343
|
+
this.element.style.animation = '';
|
|
344
|
+
this.element.style.transition = '';
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
//# sourceMappingURL=animate.directive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animate.directive.js","sourceRoot":"","sources":["../../../src/directives/animate.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAwB1C,MAAM,OAAO,gBAAiB,SAAQ,aAAa;IACvC,OAAO,GAAqB,EAAE,CAAC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AEzB,mCAAmC;QACnC,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC5B,IAAI,CAAC,oBAAoB,CAAC,UAAU,EAAE,CAAC;YACvC,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;QACrC,CAAC;IACL,CAAC;IAED,OAAO;QACH,IAAI,CAAC,OAAO,EAAE,CAAC;QAEf,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3C,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC7B,CAAC;IAED,0CAA0C;IAC1C,IAAI;QACA,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrC,CAAC;IACL,CAAC;IAED,IAAI;QACA,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;YACzB,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;YAE1B,IAAI,IAAI,CAAC,OAAO,YAAY,WAAW,EAAE,CAAC;gBACtC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC;gBAClC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,EAAE,CAAC;YACvC,CAAC;QACL,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { TemplateResult } from '../processor/template-result';
|
|
2
|
+
/**
|
|
3
|
+
* Result object for the `asyncReplace` directive.
|
|
4
|
+
* Holds the current state of the tracked promise so the template
|
|
5
|
+
* engine can render the appropriate branch on each update cycle.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AsyncResult {
|
|
8
|
+
readonly state: 'pending' | 'resolved' | 'rejected';
|
|
9
|
+
readonly value?: unknown | undefined;
|
|
10
|
+
readonly error?: unknown | undefined;
|
|
11
|
+
constructor(state: 'pending' | 'resolved' | 'rejected', value?: unknown | undefined, error?: unknown | undefined);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Tracks a Promise and triggers a component re-render when it settles.
|
|
15
|
+
*
|
|
16
|
+
* Usage inside a component's `template()`:
|
|
17
|
+
* ```ts
|
|
18
|
+
* // Create the tracker once (e.g. in onMount or a reactive getter)
|
|
19
|
+
* this._userTracker = createAsyncTracker(fetchUser(id), () => this.requestUpdate());
|
|
20
|
+
*
|
|
21
|
+
* // In template():
|
|
22
|
+
* ${resolveAsync(this._userTracker,
|
|
23
|
+
* (user) => html`<p>Hello ${user.name}</p>`, // resolved
|
|
24
|
+
* () => html`<p>Loading...</p>`, // pending
|
|
25
|
+
* (err) => html`<p>Error: ${err.message}</p>` // rejected
|
|
26
|
+
* )}
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export interface AsyncTracker<T = unknown> {
|
|
30
|
+
/** Current state of the tracked promise */
|
|
31
|
+
readonly state: 'pending' | 'resolved' | 'rejected';
|
|
32
|
+
/** Resolved value (only when state === 'resolved') */
|
|
33
|
+
readonly value?: T;
|
|
34
|
+
/** Rejection reason (only when state === 'rejected') */
|
|
35
|
+
readonly error?: unknown;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create an AsyncTracker that calls `onSettle` when the promise resolves or rejects.
|
|
39
|
+
* The component should call `this.requestUpdate()` inside `onSettle` to trigger a re-render.
|
|
40
|
+
*
|
|
41
|
+
* @param promise - The Promise to track
|
|
42
|
+
* @param onSettle - Callback invoked when the promise settles (resolve or reject)
|
|
43
|
+
*/
|
|
44
|
+
export declare function createAsyncTracker<T>(promise: Promise<T>, onSettle: () => void): AsyncTracker<T>;
|
|
45
|
+
/**
|
|
46
|
+
* Resolve an AsyncTracker into a template based on its current state.
|
|
47
|
+
* Returns the appropriate branch template.
|
|
48
|
+
*
|
|
49
|
+
* @param tracker - The AsyncTracker to resolve
|
|
50
|
+
* @param resolved - Template function for the resolved state
|
|
51
|
+
* @param pending - Template function for the pending state (optional)
|
|
52
|
+
* @param rejected - Template function for the rejected state (optional)
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* template() {
|
|
57
|
+
* return html`
|
|
58
|
+
* ${resolveAsync(this.dataTracker,
|
|
59
|
+
* (data) => html`<div>${data.name}</div>`,
|
|
60
|
+
* () => html`<span>Loading...</span>`,
|
|
61
|
+
* (err) => html`<span class="error">${err}</span>`
|
|
62
|
+
* )}
|
|
63
|
+
* `;
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function resolveAsync<T, R extends TemplateResult>(tracker: AsyncTracker<T>, resolved: (value: T) => R, pending?: () => R, rejected?: (error: unknown) => R): R | undefined;
|
|
68
|
+
//# sourceMappingURL=await.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"await.d.ts","sourceRoot":"","sources":["../../../src/directives/await.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D;;;;GAIG;AACH,qBAAa,WAAW;aAEA,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU;aAC1C,KAAK,CAAC,EAAE,OAAO;aACf,KAAK,CAAC,EAAE,OAAO;gBAFf,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,EAC1C,KAAK,CAAC,EAAE,OAAO,YAAA,EACf,KAAK,CAAC,EAAE,OAAO,YAAA;CAEtC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO;IACrC,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;IACpD,sDAAsD;IACtD,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACnB,wDAAwD;IACxD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAChC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,QAAQ,EAAE,MAAM,IAAI,GACrB,YAAY,CAAC,CAAC,CAAC,CAmBjB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,cAAc,EACpD,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,EACzB,OAAO,CAAC,EAAE,MAAM,CAAC,EACjB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,GACjC,CAAC,GAAG,SAAS,CASf"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result object for the `asyncReplace` directive.
|
|
3
|
+
* Holds the current state of the tracked promise so the template
|
|
4
|
+
* engine can render the appropriate branch on each update cycle.
|
|
5
|
+
*/
|
|
6
|
+
export class AsyncResult {
|
|
7
|
+
state;
|
|
8
|
+
value;
|
|
9
|
+
error;
|
|
10
|
+
constructor(state, value, error) {
|
|
11
|
+
this.state = state;
|
|
12
|
+
this.value = value;
|
|
13
|
+
this.error = error;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Create an AsyncTracker that calls `onSettle` when the promise resolves or rejects.
|
|
18
|
+
* The component should call `this.requestUpdate()` inside `onSettle` to trigger a re-render.
|
|
19
|
+
*
|
|
20
|
+
* @param promise - The Promise to track
|
|
21
|
+
* @param onSettle - Callback invoked when the promise settles (resolve or reject)
|
|
22
|
+
*/
|
|
23
|
+
export function createAsyncTracker(promise, onSettle) {
|
|
24
|
+
const tracker = {
|
|
25
|
+
state: 'pending'
|
|
26
|
+
};
|
|
27
|
+
promise.then((value) => {
|
|
28
|
+
tracker.state = 'resolved';
|
|
29
|
+
tracker.value = value;
|
|
30
|
+
onSettle();
|
|
31
|
+
}, (error) => {
|
|
32
|
+
tracker.state = 'rejected';
|
|
33
|
+
tracker.error = error;
|
|
34
|
+
onSettle();
|
|
35
|
+
});
|
|
36
|
+
return tracker;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Resolve an AsyncTracker into a template based on its current state.
|
|
40
|
+
* Returns the appropriate branch template.
|
|
41
|
+
*
|
|
42
|
+
* @param tracker - The AsyncTracker to resolve
|
|
43
|
+
* @param resolved - Template function for the resolved state
|
|
44
|
+
* @param pending - Template function for the pending state (optional)
|
|
45
|
+
* @param rejected - Template function for the rejected state (optional)
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* template() {
|
|
50
|
+
* return html`
|
|
51
|
+
* ${resolveAsync(this.dataTracker,
|
|
52
|
+
* (data) => html`<div>${data.name}</div>`,
|
|
53
|
+
* () => html`<span>Loading...</span>`,
|
|
54
|
+
* (err) => html`<span class="error">${err}</span>`
|
|
55
|
+
* )}
|
|
56
|
+
* `;
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export function resolveAsync(tracker, resolved, pending, rejected) {
|
|
61
|
+
switch (tracker.state) {
|
|
62
|
+
case 'pending':
|
|
63
|
+
return pending?.();
|
|
64
|
+
case 'resolved':
|
|
65
|
+
return resolved(tracker.value);
|
|
66
|
+
case 'rejected':
|
|
67
|
+
return rejected?.(tracker.error);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=await.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"await.js","sourceRoot":"","sources":["../../../src/directives/await.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,WAAW;IAEA;IACA;IACA;IAHpB,YACoB,KAA0C,EAC1C,KAAe,EACf,KAAe;QAFf,UAAK,GAAL,KAAK,CAAqC;QAC1C,UAAK,GAAL,KAAK,CAAU;QACf,UAAK,GAAL,KAAK,CAAU;IAChC,CAAC;CACP;AA2BD;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAC9B,OAAmB,EACnB,QAAoB;IAEpB,MAAM,OAAO,GAA+E;QACxF,KAAK,EAAE,SAAS;KACnB,CAAC;IAEF,OAAO,CAAC,IAAI,CACR,CAAC,KAAK,EAAE,EAAE;QACN,OAAO,CAAC,KAAK,GAAG,UAAU,CAAC;QAC3B,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;QACtB,QAAQ,EAAE,CAAC;IACf,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;QACN,OAAO,CAAC,KAAK,GAAG,UAAU,CAAC;QAC3B,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;QACtB,QAAQ,EAAE,CAAC;IACf,CAAC,CACJ,CAAC;IAEF,OAAO,OAAO,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,YAAY,CACxB,OAAwB,EACxB,QAAyB,EACzB,OAAiB,EACjB,QAAgC;IAEhC,QAAQ,OAAO,CAAC,KAAK,EAAE,CAAC;QACpB,KAAK,SAAS;YACV,OAAO,OAAO,EAAE,EAAE,CAAC;QACvB,KAAK,UAAU;YACX,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAU,CAAC,CAAC;QACxC,KAAK,UAAU;YACX,OAAO,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { TemplateResult } from '../processor/template-result';
|
|
2
|
+
/**
|
|
3
|
+
* A single case in a choose() call: [value, templateFn].
|
|
4
|
+
*/
|
|
5
|
+
export type ChoiceCase<V, T extends TemplateResult> = [V, () => T];
|
|
6
|
+
/**
|
|
7
|
+
* Multi-branch conditional rendering directive.
|
|
8
|
+
*
|
|
9
|
+
* Evaluates `value` against a list of cases and renders the matching branch.
|
|
10
|
+
* Only the matched branch's template function is called.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* ```ts
|
|
14
|
+
* html`
|
|
15
|
+
* ${choose(this.page, [
|
|
16
|
+
* ['home', () => html`<home-page></home-page>`],
|
|
17
|
+
* ['about', () => html`<about-page></about-page>`],
|
|
18
|
+
* ['contact', () => html`<contact-page></contact-page>`],
|
|
19
|
+
* ], () => html`<not-found></not-found>`)}
|
|
20
|
+
* `
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param value - The value to match against cases
|
|
24
|
+
* @param cases - Array of [matchValue, templateFn] tuples
|
|
25
|
+
* @param defaultCase - Optional template function when no case matches
|
|
26
|
+
*/
|
|
27
|
+
export declare function choose<V, T extends TemplateResult>(value: V, cases: ChoiceCase<V, T>[], defaultCase?: () => T): T | undefined;
|
|
28
|
+
//# sourceMappingURL=choose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"choose.d.ts","sourceRoot":"","sources":["../../../src/directives/choose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,cAAc,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,cAAc,EAC9C,KAAK,EAAE,CAAC,EACR,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EACzB,WAAW,CAAC,EAAE,MAAM,CAAC,GACtB,CAAC,GAAG,SAAS,CAOf"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-branch conditional rendering directive.
|
|
3
|
+
*
|
|
4
|
+
* Evaluates `value` against a list of cases and renders the matching branch.
|
|
5
|
+
* Only the matched branch's template function is called.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```ts
|
|
9
|
+
* html`
|
|
10
|
+
* ${choose(this.page, [
|
|
11
|
+
* ['home', () => html`<home-page></home-page>`],
|
|
12
|
+
* ['about', () => html`<about-page></about-page>`],
|
|
13
|
+
* ['contact', () => html`<contact-page></contact-page>`],
|
|
14
|
+
* ], () => html`<not-found></not-found>`)}
|
|
15
|
+
* `
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param value - The value to match against cases
|
|
19
|
+
* @param cases - Array of [matchValue, templateFn] tuples
|
|
20
|
+
* @param defaultCase - Optional template function when no case matches
|
|
21
|
+
*/
|
|
22
|
+
export function choose(value, cases, defaultCase) {
|
|
23
|
+
for (const [caseValue, templateFn] of cases) {
|
|
24
|
+
if (caseValue === value) {
|
|
25
|
+
return templateFn();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return defaultCase?.();
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=choose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"choose.js","sourceRoot":"","sources":["../../../src/directives/choose.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,MAAM,CAClB,KAAQ,EACR,KAAyB,EACzB,WAAqB;IAErB,KAAK,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,IAAI,KAAK,EAAE,CAAC;QAC1C,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;YACtB,OAAO,UAAU,EAAE,CAAC;QACxB,CAAC;IACL,CAAC;IACD,OAAO,WAAW,EAAE,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseDirective } from './directive';
|
|
2
|
+
export declare class ExampleDirective extends BaseDirective {
|
|
3
|
+
mount(element: Element): void;
|
|
4
|
+
}
|
|
5
|
+
export declare class LazyExampleDirective extends BaseDirective {
|
|
6
|
+
mount(element: Element): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=decorator-example.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorator-example.d.ts","sourceRoot":"","sources":["../../../src/directives/decorator-example.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,qBACa,gBAAiB,SAAQ,aAAa;IAC/C,KAAK,CAAC,OAAO,EAAE,OAAO;CAGzB;AAGD,qBACa,oBAAqB,SAAQ,aAAa;IACnD,KAAK,CAAC,OAAO,EAAE,OAAO;CAGzB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { directive, lazyDirective } from './decorators';
|
|
8
|
+
import { BaseDirective } from './directive';
|
|
9
|
+
// Example of a regular directive (always loaded)
|
|
10
|
+
let ExampleDirective = class ExampleDirective extends BaseDirective {
|
|
11
|
+
mount(element) {
|
|
12
|
+
console.log('Example directive mounted');
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
ExampleDirective = __decorate([
|
|
16
|
+
directive('example')
|
|
17
|
+
], ExampleDirective);
|
|
18
|
+
export { ExampleDirective };
|
|
19
|
+
// Example of a lazy directive (loaded on-demand)
|
|
20
|
+
let LazyExampleDirective = class LazyExampleDirective extends BaseDirective {
|
|
21
|
+
mount(element) {
|
|
22
|
+
console.log('Lazy example directive mounted');
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
LazyExampleDirective = __decorate([
|
|
26
|
+
lazyDirective('lazy-example')
|
|
27
|
+
], LazyExampleDirective);
|
|
28
|
+
export { LazyExampleDirective };
|
|
29
|
+
// Usage in templates:
|
|
30
|
+
// <div #example>Regular directive</div>
|
|
31
|
+
// <div #lazy-example>Lazy directive</div>
|
|
32
|
+
//# sourceMappingURL=decorator-example.js.map
|