@tectra-ng/blocks 0.1.7 → 0.1.9

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,34 @@
1
+ # Confetti
2
+
3
+ A one-time burst of confetti from the middle of its box — for a finished onboarding, a confirmed e-mail, a changed password. It covers its positioned parent and takes no clicks.
4
+
5
+ ```html
6
+ <div class="done">
7
+ @if (saved()) {
8
+ <tx-confetti [delay]="380" />
9
+ }
10
+ </div>
11
+ ```
12
+
13
+ ```css
14
+ .done {
15
+ position: relative;
16
+ }
17
+ ```
18
+
19
+ The burst plays once when it appears; `play()` plays it again. Ten pieces fly out in the primary, muted and success colours; give your own with `pieces`. It is decorative (`aria-hidden`); with reduced motion the pieces stand still at their places.
20
+
21
+ ## Inputs
22
+ | Name | Description |
23
+ |---|---|
24
+ | pieces | Pieces (`TxConfettiPiece[]`: `x`, `y` — where it lands from the middle in px, `rotate` in degrees, `tone` `accent` / `neutral` / `success`); ten by default |
25
+ | delay | Wait before the burst in ms, e.g. until a check mark is drawn (default 0) |
26
+ | dt | Design tokens of this instance (`confetti`) |
27
+ | pt | Classes and styles of the parts: `root`, `piece` |
28
+ | ptOptions | How `pt` merges with the global pass-through |
29
+ | unstyled | Removes the tectra styles |
30
+
31
+ ## Methods
32
+ | Name | Description |
33
+ |---|---|
34
+ | play() | Plays the burst again |
@@ -0,0 +1,272 @@
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, computed, input, numberAttribute, signal } from "@angular/core";
3
+ import { injectPassThrough, injectUnstyled } from "@tectra-ng/core/config";
4
+ import { optionalBoolean } from "@tectra-ng/core/utils";
5
+ import { toStyleObject } from "@tectra-ng/themes";
6
+ const TX_CONFETTI_PIECES = [
7
+ {
8
+ x: -150,
9
+ y: -90,
10
+ rotate: 25,
11
+ tone: "accent"
12
+ },
13
+ {
14
+ x: 140,
15
+ y: -110,
16
+ rotate: -35,
17
+ tone: "neutral"
18
+ },
19
+ {
20
+ x: -120,
21
+ y: 120,
22
+ rotate: 60,
23
+ tone: "neutral"
24
+ },
25
+ {
26
+ x: 160,
27
+ y: 80,
28
+ rotate: -15,
29
+ tone: "accent"
30
+ },
31
+ {
32
+ x: -40,
33
+ y: -160,
34
+ rotate: 45,
35
+ tone: "success"
36
+ },
37
+ {
38
+ x: 60,
39
+ y: 160,
40
+ rotate: -50,
41
+ tone: "success"
42
+ },
43
+ {
44
+ x: -180,
45
+ y: 10,
46
+ rotate: 10,
47
+ tone: "accent"
48
+ },
49
+ {
50
+ x: 190,
51
+ y: -20,
52
+ rotate: 80,
53
+ tone: "neutral"
54
+ },
55
+ {
56
+ x: 90,
57
+ y: -170,
58
+ rotate: -70,
59
+ tone: "accent"
60
+ },
61
+ {
62
+ x: -90,
63
+ y: 175,
64
+ rotate: 35,
65
+ tone: "success"
66
+ }
67
+ ];
68
+ var TxConfetti = class TxConfetti {
69
+ pieces = input(TX_CONFETTI_PIECES, ...ngDevMode ? [{ debugName: "pieces" }] : /* istanbul ignore next */ []);
70
+ delay = input(0, {
71
+ ...ngDevMode ? { debugName: "delay" } : /* istanbul ignore next */ {},
72
+ transform: numberAttribute
73
+ });
74
+ dt = input(void 0, ...ngDevMode ? [{ debugName: "dt" }] : /* istanbul ignore next */ []);
75
+ pt = input(void 0, ...ngDevMode ? [{ debugName: "pt" }] : /* istanbul ignore next */ []);
76
+ ptOptions = input(void 0, ...ngDevMode ? [{ debugName: "ptOptions" }] : /* istanbul ignore next */ []);
77
+ unstyled = input(void 0, {
78
+ ...ngDevMode ? { debugName: "unstyled" } : /* istanbul ignore next */ {},
79
+ transform: optionalBoolean
80
+ });
81
+ isUnstyled = injectUnstyled(this.unstyled);
82
+ passThrough = injectPassThrough("confetti", this, this.pt, this.ptOptions);
83
+ hostStyle = computed(() => ({
84
+ ...toStyleObject(this.dt(), "--tx-confetti"),
85
+ ...this.passThrough().root?.style
86
+ }), ...ngDevMode ? [{ debugName: "hostStyle" }] : /* istanbul ignore next */ []);
87
+ run = signal(0, ...ngDevMode ? [{ debugName: "run" }] : /* istanbul ignore next */ []);
88
+ runs = computed(() => [this.run()], ...ngDevMode ? [{ debugName: "runs" }] : /* istanbul ignore next */ []);
89
+ play() {
90
+ this.run.update((run) => run + 1);
91
+ }
92
+ static ɵfac = i0.ɵɵngDeclareFactory({
93
+ minVersion: "12.0.0",
94
+ version: "22.2.3",
95
+ ngImport: i0,
96
+ type: TxConfetti,
97
+ deps: [],
98
+ target: i0.ɵɵFactoryTarget.Component
99
+ });
100
+ static ɵcmp = i0.ɵɵngDeclareComponent({
101
+ minVersion: "17.0.0",
102
+ version: "22.2.3",
103
+ type: TxConfetti,
104
+ isStandalone: true,
105
+ selector: "tx-confetti",
106
+ inputs: {
107
+ pieces: {
108
+ classPropertyName: "pieces",
109
+ publicName: "pieces",
110
+ isSignal: true,
111
+ isRequired: false,
112
+ transformFunction: null
113
+ },
114
+ delay: {
115
+ classPropertyName: "delay",
116
+ publicName: "delay",
117
+ isSignal: true,
118
+ isRequired: false,
119
+ transformFunction: null
120
+ },
121
+ dt: {
122
+ classPropertyName: "dt",
123
+ publicName: "dt",
124
+ isSignal: true,
125
+ isRequired: false,
126
+ transformFunction: null
127
+ },
128
+ pt: {
129
+ classPropertyName: "pt",
130
+ publicName: "pt",
131
+ isSignal: true,
132
+ isRequired: false,
133
+ transformFunction: null
134
+ },
135
+ ptOptions: {
136
+ classPropertyName: "ptOptions",
137
+ publicName: "ptOptions",
138
+ isSignal: true,
139
+ isRequired: false,
140
+ transformFunction: null
141
+ },
142
+ unstyled: {
143
+ classPropertyName: "unstyled",
144
+ publicName: "unstyled",
145
+ isSignal: true,
146
+ isRequired: false,
147
+ transformFunction: null
148
+ }
149
+ },
150
+ host: {
151
+ attributes: { "aria-hidden": "true" },
152
+ properties: {
153
+ "class": "passThrough().root?.class",
154
+ "style": "hostStyle()",
155
+ "style.--tx-confetti-delay.ms": "delay()",
156
+ "attr.data-styled": "!isUnstyled() || null"
157
+ },
158
+ classAttribute: "tx-confetti"
159
+ },
160
+ ngImport: i0,
161
+ template: `
162
+ @for (run of runs(); track run) {
163
+ @for (piece of pieces(); track $index; let index = $index) {
164
+ <span
165
+ class="tx-confetti__piece"
166
+ [attr.data-tone]="piece.tone"
167
+ [style.--tx-confetti-x.px]="piece.x"
168
+ [style.--tx-confetti-y.px]="piece.y"
169
+ [style.--tx-confetti-r.deg]="piece.rotate"
170
+ [style.--tx-confetti-i]="index"
171
+ [class]="passThrough().piece?.class"
172
+ [style]="passThrough().piece?.style"
173
+ ></span>
174
+ }
175
+ }
176
+ `,
177
+ isInline: true,
178
+ styles: [":host{position:absolute;inset:0;overflow:visible;pointer-events:none}.tx-confetti__piece{position:absolute;top:50%;left:50%}:host([data-styled]) .tx-confetti__piece{width:var(--tx-confetti-piece-size);height:var(--tx-confetti-piece-size);margin:calc(var(--tx-confetti-piece-size) / -2) 0 0 calc(var(--tx-confetti-piece-size) / -2);border-radius:var(--tx-confetti-piece-border-radius);background:var(--tx-confetti-colors-accent);animation:tx-confetti-burst var(--tx-confetti-motion-duration) var(--tx-confetti-motion-easing) both;animation-delay:calc(var(--tx-confetti-i) * var(--tx-confetti-motion-stagger) + var(--tx-confetti-delay, 0ms))}:host([data-styled]) .tx-confetti__piece[data-tone=neutral]{width:var(--tx-confetti-piece-neutral-width);height:var(--tx-confetti-piece-neutral-height);margin:calc(var(--tx-confetti-piece-neutral-height) / -2) 0 0 calc(var(--tx-confetti-piece-neutral-width) / -2);background:var(--tx-confetti-colors-neutral)}:host([data-styled]) .tx-confetti__piece[data-tone=success]{border-radius:50%;background:var(--tx-confetti-colors-success)}@keyframes tx-confetti-burst{0%{opacity:0;transform:translate(0) rotate(0) scale(.4)}30%{opacity:1}to{opacity:1;transform:translate(var(--tx-confetti-x),var(--tx-confetti-y)) rotate(var(--tx-confetti-r)) scale(1)}}@media(prefers-reduced-motion:reduce){:host([data-styled]) .tx-confetti__piece{animation:none;transform:translate(var(--tx-confetti-x),var(--tx-confetti-y)) rotate(var(--tx-confetti-r))}}\n"],
179
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
180
+ });
181
+ };
182
+ i0.ɵɵngDeclareClassMetadata({
183
+ minVersion: "12.0.0",
184
+ version: "22.2.3",
185
+ ngImport: i0,
186
+ type: TxConfetti,
187
+ decorators: [{
188
+ type: Component,
189
+ args: [{
190
+ selector: "tx-confetti",
191
+ template: `
192
+ @for (run of runs(); track run) {
193
+ @for (piece of pieces(); track $index; let index = $index) {
194
+ <span
195
+ class="tx-confetti__piece"
196
+ [attr.data-tone]="piece.tone"
197
+ [style.--tx-confetti-x.px]="piece.x"
198
+ [style.--tx-confetti-y.px]="piece.y"
199
+ [style.--tx-confetti-r.deg]="piece.rotate"
200
+ [style.--tx-confetti-i]="index"
201
+ [class]="passThrough().piece?.class"
202
+ [style]="passThrough().piece?.style"
203
+ ></span>
204
+ }
205
+ }
206
+ `,
207
+ changeDetection: ChangeDetectionStrategy.OnPush,
208
+ host: {
209
+ class: "tx-confetti",
210
+ "aria-hidden": "true",
211
+ "[class]": "passThrough().root?.class",
212
+ "[style]": "hostStyle()",
213
+ "[style.--tx-confetti-delay.ms]": "delay()",
214
+ "[attr.data-styled]": "!isUnstyled() || null"
215
+ },
216
+ styles: [":host{position:absolute;inset:0;overflow:visible;pointer-events:none}.tx-confetti__piece{position:absolute;top:50%;left:50%}:host([data-styled]) .tx-confetti__piece{width:var(--tx-confetti-piece-size);height:var(--tx-confetti-piece-size);margin:calc(var(--tx-confetti-piece-size) / -2) 0 0 calc(var(--tx-confetti-piece-size) / -2);border-radius:var(--tx-confetti-piece-border-radius);background:var(--tx-confetti-colors-accent);animation:tx-confetti-burst var(--tx-confetti-motion-duration) var(--tx-confetti-motion-easing) both;animation-delay:calc(var(--tx-confetti-i) * var(--tx-confetti-motion-stagger) + var(--tx-confetti-delay, 0ms))}:host([data-styled]) .tx-confetti__piece[data-tone=neutral]{width:var(--tx-confetti-piece-neutral-width);height:var(--tx-confetti-piece-neutral-height);margin:calc(var(--tx-confetti-piece-neutral-height) / -2) 0 0 calc(var(--tx-confetti-piece-neutral-width) / -2);background:var(--tx-confetti-colors-neutral)}:host([data-styled]) .tx-confetti__piece[data-tone=success]{border-radius:50%;background:var(--tx-confetti-colors-success)}@keyframes tx-confetti-burst{0%{opacity:0;transform:translate(0) rotate(0) scale(.4)}30%{opacity:1}to{opacity:1;transform:translate(var(--tx-confetti-x),var(--tx-confetti-y)) rotate(var(--tx-confetti-r)) scale(1)}}@media(prefers-reduced-motion:reduce){:host([data-styled]) .tx-confetti__piece{animation:none;transform:translate(var(--tx-confetti-x),var(--tx-confetti-y)) rotate(var(--tx-confetti-r))}}\n"]
217
+ }]
218
+ }],
219
+ propDecorators: {
220
+ pieces: [{
221
+ type: i0.Input,
222
+ args: [{
223
+ isSignal: true,
224
+ alias: "pieces",
225
+ required: false
226
+ }]
227
+ }],
228
+ delay: [{
229
+ type: i0.Input,
230
+ args: [{
231
+ isSignal: true,
232
+ alias: "delay",
233
+ required: false
234
+ }]
235
+ }],
236
+ dt: [{
237
+ type: i0.Input,
238
+ args: [{
239
+ isSignal: true,
240
+ alias: "dt",
241
+ required: false
242
+ }]
243
+ }],
244
+ pt: [{
245
+ type: i0.Input,
246
+ args: [{
247
+ isSignal: true,
248
+ alias: "pt",
249
+ required: false
250
+ }]
251
+ }],
252
+ ptOptions: [{
253
+ type: i0.Input,
254
+ args: [{
255
+ isSignal: true,
256
+ alias: "ptOptions",
257
+ required: false
258
+ }]
259
+ }],
260
+ unstyled: [{
261
+ type: i0.Input,
262
+ args: [{
263
+ isSignal: true,
264
+ alias: "unstyled",
265
+ required: false
266
+ }]
267
+ }]
268
+ }
269
+ });
270
+ export { TX_CONFETTI_PIECES, TxConfetti };
271
+
272
+ //# sourceMappingURL=tectra-ng-blocks-confetti.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tectra-ng-blocks-confetti.mjs","names":[],"sources":["../../../../packages/blocks/confetti/src/confetti.types.ts","../../../../packages/blocks/confetti/src/confetti.component.ts"],"sourcesContent":["export type TxConfettiTone = 'accent' | 'neutral' | 'success';\n\nexport interface TxConfettiPiece {\n x: number;\n y: number;\n rotate: number;\n tone: TxConfettiTone;\n}\n\nexport type TxConfettiPart = 'root' | 'piece';\n\nexport const TX_CONFETTI_PIECES: readonly TxConfettiPiece[] = [\n { x: -150, y: -90, rotate: 25, tone: 'accent' },\n { x: 140, y: -110, rotate: -35, tone: 'neutral' },\n { x: -120, y: 120, rotate: 60, tone: 'neutral' },\n { x: 160, y: 80, rotate: -15, tone: 'accent' },\n { x: -40, y: -160, rotate: 45, tone: 'success' },\n { x: 60, y: 160, rotate: -50, tone: 'success' },\n { x: -180, y: 10, rotate: 10, tone: 'accent' },\n { x: 190, y: -20, rotate: 80, tone: 'neutral' },\n { x: 90, y: -170, rotate: -70, tone: 'accent' },\n { x: -90, y: 175, rotate: 35, tone: 'success' },\n];\n","import { ChangeDetectionStrategy, Component, computed, input, numberAttribute, signal } from '@angular/core';\nimport { TxPassThrough, TxPassThroughOptions, injectPassThrough, injectUnstyled } from '@tectra-ng/core/config';\nimport { optionalBoolean } from '@tectra-ng/core/utils';\nimport { TectraConfettiTokens, TectraDeepPartial, toStyleObject } from '@tectra-ng/themes';\nimport { TX_CONFETTI_PIECES, TxConfettiPart, TxConfettiPiece } from './confetti.types';\n\n@Component({\n selector: 'tx-confetti',\n template: `\n @for (run of runs(); track run) {\n @for (piece of pieces(); track $index; let index = $index) {\n <span\n class=\"tx-confetti__piece\"\n [attr.data-tone]=\"piece.tone\"\n [style.--tx-confetti-x.px]=\"piece.x\"\n [style.--tx-confetti-y.px]=\"piece.y\"\n [style.--tx-confetti-r.deg]=\"piece.rotate\"\n [style.--tx-confetti-i]=\"index\"\n [class]=\"passThrough().piece?.class\"\n [style]=\"passThrough().piece?.style\"\n ></span>\n }\n }\n `,\n styleUrl: './confetti.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'tx-confetti',\n 'aria-hidden': 'true',\n '[class]': 'passThrough().root?.class',\n '[style]': 'hostStyle()',\n '[style.--tx-confetti-delay.ms]': 'delay()',\n '[attr.data-styled]': '!isUnstyled() || null',\n },\n})\nexport class TxConfetti {\n readonly pieces = input<readonly TxConfettiPiece[]>(TX_CONFETTI_PIECES);\n readonly delay = input<number, unknown>(0, { transform: numberAttribute });\n readonly dt = input<TectraDeepPartial<TectraConfettiTokens> | undefined>(undefined);\n readonly pt = input<TxPassThrough<TxConfettiPart, TxConfetti> | undefined>(undefined);\n readonly ptOptions = input<TxPassThroughOptions | undefined>(undefined);\n readonly unstyled = input<boolean | undefined, unknown>(undefined, { transform: optionalBoolean });\n\n readonly isUnstyled = injectUnstyled(this.unstyled);\n readonly passThrough = injectPassThrough('confetti', this, this.pt, this.ptOptions);\n readonly hostStyle = computed(() => ({ ...toStyleObject(this.dt(), '--tx-confetti'), ...this.passThrough().root?.style }));\n\n private readonly run = signal(0);\n protected readonly runs = computed(() => [this.run()]);\n\n play(): void {\n this.run.update((run) => run + 1);\n }\n}\n"],"mappings":";;;;;AAWA,MAAa,qBAAiD;CAC5D;EAAE,GAAG;EAAM,GAAG;EAAK,QAAQ;EAAI,MAAM;CAAQ;CAC7C;EAAE,GAAG;EAAK,GAAG;EAAM,QAAQ;EAAK,MAAM;CAAS;CAC/C;EAAE,GAAG;EAAM,GAAG;EAAK,QAAQ;EAAI,MAAM;CAAS;CAC9C;EAAE,GAAG;EAAK,GAAG;EAAI,QAAQ;EAAK,MAAM;CAAQ;CAC5C;EAAE,GAAG;EAAK,GAAG;EAAM,QAAQ;EAAI,MAAM;CAAS;CAC9C;EAAE,GAAG;EAAI,GAAG;EAAK,QAAQ;EAAK,MAAM;CAAS;CAC7C;EAAE,GAAG;EAAM,GAAG;EAAI,QAAQ;EAAI,MAAM;CAAQ;CAC5C;EAAE,GAAG;EAAK,GAAG;EAAK,QAAQ;EAAI,MAAM;CAAS;CAC7C;EAAE,GAAG;EAAI,GAAG;EAAM,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AA,CAAA,q8CAAA;EAAA,CAAA"}
@@ -0,0 +1,250 @@
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, DOCUMENT, DestroyRef, booleanAttribute, computed, inject, input, numberAttribute, signal, viewChild } from "@angular/core";
3
+ import { injectPassThrough, injectUnstyled } from "@tectra-ng/core/config";
4
+ import { optionalBoolean } from "@tectra-ng/core/utils";
5
+ import { toStyleObject } from "@tectra-ng/themes";
6
+ var TxHoverEffect = class TxHoverEffect {
7
+ document = inject(DOCUMENT);
8
+ layer = viewChild.required("layer", ...ngDevMode ? [{ debugName: "layer" }] : /* istanbul ignore next */ []);
9
+ frame = 0;
10
+ constrain = input(100, {
11
+ ...ngDevMode ? { debugName: "constrain" } : /* istanbul ignore next */ {},
12
+ transform: numberAttribute
13
+ });
14
+ disabled = input(false, {
15
+ ...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
16
+ transform: booleanAttribute
17
+ });
18
+ dt = input(void 0, ...ngDevMode ? [{ debugName: "dt" }] : /* istanbul ignore next */ []);
19
+ pt = input(void 0, ...ngDevMode ? [{ debugName: "pt" }] : /* istanbul ignore next */ []);
20
+ ptOptions = input(void 0, ...ngDevMode ? [{ debugName: "ptOptions" }] : /* istanbul ignore next */ []);
21
+ unstyled = input(void 0, {
22
+ ...ngDevMode ? { debugName: "unstyled" } : /* istanbul ignore next */ {},
23
+ transform: optionalBoolean
24
+ });
25
+ isUnstyled = injectUnstyled(this.unstyled);
26
+ passThrough = injectPassThrough("hoverEffect", this, this.pt, this.ptOptions);
27
+ hostStyle = computed(() => ({
28
+ ...toStyleObject(this.dt(), "--tx-hover-effect"),
29
+ ...this.passThrough().root?.style
30
+ }), ...ngDevMode ? [{ debugName: "hostStyle" }] : /* istanbul ignore next */ []);
31
+ tilt = signal({
32
+ x: 0,
33
+ y: 0
34
+ }, ...ngDevMode ? [{ debugName: "tilt" }] : /* istanbul ignore next */ []);
35
+ active = signal(false, ...ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []);
36
+ constructor() {
37
+ inject(DestroyRef).onDestroy(() => this.document.defaultView?.cancelAnimationFrame?.(this.frame));
38
+ }
39
+ onPointerMove(event) {
40
+ const view = this.document.defaultView;
41
+ if (this.disabled() || event.pointerType !== "mouse" || !view || view.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return;
42
+ const { clientX, clientY } = event;
43
+ view.cancelAnimationFrame(this.frame);
44
+ this.frame = view.requestAnimationFrame(() => {
45
+ const box = this.layer().nativeElement.getBoundingClientRect();
46
+ const constrain = this.constrain() || 1;
47
+ this.active.set(true);
48
+ this.tilt.set({
49
+ x: -(clientY - box.y - box.height / 2) / constrain,
50
+ y: (clientX - box.x - box.width / 2) / constrain
51
+ });
52
+ });
53
+ }
54
+ reset() {
55
+ this.document.defaultView?.cancelAnimationFrame?.(this.frame);
56
+ this.active.set(false);
57
+ this.tilt.set({
58
+ x: 0,
59
+ y: 0
60
+ });
61
+ }
62
+ static ɵfac = i0.ɵɵngDeclareFactory({
63
+ minVersion: "12.0.0",
64
+ version: "22.2.3",
65
+ ngImport: i0,
66
+ type: TxHoverEffect,
67
+ deps: [],
68
+ target: i0.ɵɵFactoryTarget.Component
69
+ });
70
+ static ɵcmp = i0.ɵɵngDeclareComponent({
71
+ minVersion: "17.2.0",
72
+ version: "22.2.3",
73
+ type: TxHoverEffect,
74
+ isStandalone: true,
75
+ selector: "tx-hover-effect",
76
+ inputs: {
77
+ constrain: {
78
+ classPropertyName: "constrain",
79
+ publicName: "constrain",
80
+ isSignal: true,
81
+ isRequired: false,
82
+ transformFunction: null
83
+ },
84
+ disabled: {
85
+ classPropertyName: "disabled",
86
+ publicName: "disabled",
87
+ isSignal: true,
88
+ isRequired: false,
89
+ transformFunction: null
90
+ },
91
+ dt: {
92
+ classPropertyName: "dt",
93
+ publicName: "dt",
94
+ isSignal: true,
95
+ isRequired: false,
96
+ transformFunction: null
97
+ },
98
+ pt: {
99
+ classPropertyName: "pt",
100
+ publicName: "pt",
101
+ isSignal: true,
102
+ isRequired: false,
103
+ transformFunction: null
104
+ },
105
+ ptOptions: {
106
+ classPropertyName: "ptOptions",
107
+ publicName: "ptOptions",
108
+ isSignal: true,
109
+ isRequired: false,
110
+ transformFunction: null
111
+ },
112
+ unstyled: {
113
+ classPropertyName: "unstyled",
114
+ publicName: "unstyled",
115
+ isSignal: true,
116
+ isRequired: false,
117
+ transformFunction: null
118
+ }
119
+ },
120
+ host: {
121
+ listeners: {
122
+ "pointermove": "onPointerMove($event)",
123
+ "pointerleave": "reset()"
124
+ },
125
+ properties: {
126
+ "class": "passThrough().root?.class",
127
+ "style": "hostStyle()",
128
+ "attr.data-styled": "!isUnstyled() || null"
129
+ },
130
+ classAttribute: "tx-hover-effect"
131
+ },
132
+ viewQueries: [{
133
+ propertyName: "layer",
134
+ first: true,
135
+ predicate: ["layer"],
136
+ descendants: true,
137
+ isSignal: true
138
+ }],
139
+ ngImport: i0,
140
+ template: `
141
+ <div
142
+ #layer
143
+ class="tx-hover-effect__layer"
144
+ [class.tx-hover-effect__layer--resting]="!active()"
145
+ [style.--tx-hover-effect-x.deg]="tilt().x"
146
+ [style.--tx-hover-effect-y.deg]="tilt().y"
147
+ [class]="passThrough().layer?.class"
148
+ [style]="passThrough().layer?.style"
149
+ >
150
+ <ng-content />
151
+ </div>
152
+ `,
153
+ isInline: true,
154
+ styles: [":host{display:block}.tx-hover-effect__layer{transform:perspective(var(--tx-hover-effect-perspective, 100px)) rotateX(var(--tx-hover-effect-x, 0deg)) rotateY(var(--tx-hover-effect-y, 0deg));will-change:transform}:host([data-styled]) .tx-hover-effect__layer--resting{transition:transform var(--tx-hover-effect-reset-duration) var(--tx-hover-effect-reset-easing)}@media(prefers-reduced-motion:reduce){.tx-hover-effect__layer{transform:none}}\n"],
155
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
156
+ });
157
+ };
158
+ i0.ɵɵngDeclareClassMetadata({
159
+ minVersion: "12.0.0",
160
+ version: "22.2.3",
161
+ ngImport: i0,
162
+ type: TxHoverEffect,
163
+ decorators: [{
164
+ type: Component,
165
+ args: [{
166
+ selector: "tx-hover-effect",
167
+ template: `
168
+ <div
169
+ #layer
170
+ class="tx-hover-effect__layer"
171
+ [class.tx-hover-effect__layer--resting]="!active()"
172
+ [style.--tx-hover-effect-x.deg]="tilt().x"
173
+ [style.--tx-hover-effect-y.deg]="tilt().y"
174
+ [class]="passThrough().layer?.class"
175
+ [style]="passThrough().layer?.style"
176
+ >
177
+ <ng-content />
178
+ </div>
179
+ `,
180
+ changeDetection: ChangeDetectionStrategy.OnPush,
181
+ host: {
182
+ class: "tx-hover-effect",
183
+ "[class]": "passThrough().root?.class",
184
+ "[style]": "hostStyle()",
185
+ "[attr.data-styled]": "!isUnstyled() || null",
186
+ "(pointermove)": "onPointerMove($event)",
187
+ "(pointerleave)": "reset()"
188
+ },
189
+ styles: [":host{display:block}.tx-hover-effect__layer{transform:perspective(var(--tx-hover-effect-perspective, 100px)) rotateX(var(--tx-hover-effect-x, 0deg)) rotateY(var(--tx-hover-effect-y, 0deg));will-change:transform}:host([data-styled]) .tx-hover-effect__layer--resting{transition:transform var(--tx-hover-effect-reset-duration) var(--tx-hover-effect-reset-easing)}@media(prefers-reduced-motion:reduce){.tx-hover-effect__layer{transform:none}}\n"]
190
+ }]
191
+ }],
192
+ ctorParameters: () => [],
193
+ propDecorators: {
194
+ layer: [{
195
+ type: i0.ViewChild,
196
+ args: ["layer", { isSignal: true }]
197
+ }],
198
+ constrain: [{
199
+ type: i0.Input,
200
+ args: [{
201
+ isSignal: true,
202
+ alias: "constrain",
203
+ required: false
204
+ }]
205
+ }],
206
+ disabled: [{
207
+ type: i0.Input,
208
+ args: [{
209
+ isSignal: true,
210
+ alias: "disabled",
211
+ required: false
212
+ }]
213
+ }],
214
+ dt: [{
215
+ type: i0.Input,
216
+ args: [{
217
+ isSignal: true,
218
+ alias: "dt",
219
+ required: false
220
+ }]
221
+ }],
222
+ pt: [{
223
+ type: i0.Input,
224
+ args: [{
225
+ isSignal: true,
226
+ alias: "pt",
227
+ required: false
228
+ }]
229
+ }],
230
+ ptOptions: [{
231
+ type: i0.Input,
232
+ args: [{
233
+ isSignal: true,
234
+ alias: "ptOptions",
235
+ required: false
236
+ }]
237
+ }],
238
+ unstyled: [{
239
+ type: i0.Input,
240
+ args: [{
241
+ isSignal: true,
242
+ alias: "unstyled",
243
+ required: false
244
+ }]
245
+ }]
246
+ }
247
+ });
248
+ export { TxHoverEffect };
249
+
250
+ //# sourceMappingURL=tectra-ng-blocks-hover-effect.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tectra-ng-blocks-hover-effect.mjs","names":[],"sources":["../../../../packages/blocks/hover-effect/src/hover-effect.component.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, DOCUMENT, DestroyRef, ElementRef, booleanAttribute, computed, inject, input, numberAttribute, signal, viewChild } from '@angular/core';\nimport { TxPassThrough, TxPassThroughOptions, injectPassThrough, injectUnstyled } from '@tectra-ng/core/config';\nimport { optionalBoolean } from '@tectra-ng/core/utils';\nimport { TectraDeepPartial, TectraHoverEffectTokens, toStyleObject } from '@tectra-ng/themes';\nimport { TxHoverEffectPart } from './hover-effect.types';\n\n@Component({\n selector: 'tx-hover-effect',\n template: `\n <div\n #layer\n class=\"tx-hover-effect__layer\"\n [class.tx-hover-effect__layer--resting]=\"!active()\"\n [style.--tx-hover-effect-x.deg]=\"tilt().x\"\n [style.--tx-hover-effect-y.deg]=\"tilt().y\"\n [class]=\"passThrough().layer?.class\"\n [style]=\"passThrough().layer?.style\"\n >\n <ng-content />\n </div>\n `,\n styleUrl: './hover-effect.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'tx-hover-effect',\n '[class]': 'passThrough().root?.class',\n '[style]': 'hostStyle()',\n '[attr.data-styled]': '!isUnstyled() || null',\n '(pointermove)': 'onPointerMove($event)',\n '(pointerleave)': 'reset()',\n },\n})\nexport class TxHoverEffect {\n private readonly document = inject(DOCUMENT);\n private readonly layer = viewChild.required<ElementRef<HTMLElement>>('layer');\n private frame = 0;\n\n readonly constrain = input<number, unknown>(100, { transform: numberAttribute });\n readonly disabled = input<boolean, unknown>(false, { transform: booleanAttribute });\n readonly dt = input<TectraDeepPartial<TectraHoverEffectTokens> | undefined>(undefined);\n readonly pt = input<TxPassThrough<TxHoverEffectPart, TxHoverEffect> | undefined>(undefined);\n readonly ptOptions = input<TxPassThroughOptions | undefined>(undefined);\n readonly unstyled = input<boolean | undefined, unknown>(undefined, { transform: optionalBoolean });\n\n readonly isUnstyled = injectUnstyled(this.unstyled);\n readonly passThrough = injectPassThrough('hoverEffect', this, this.pt, this.ptOptions);\n readonly hostStyle = computed(() => ({ ...toStyleObject(this.dt(), '--tx-hover-effect'), ...this.passThrough().root?.style }));\n\n readonly tilt = signal({ x: 0, y: 0 });\n protected readonly active = signal(false);\n\n constructor() {\n inject(DestroyRef).onDestroy(() => this.document.defaultView?.cancelAnimationFrame?.(this.frame));\n }\n\n protected onPointerMove(event: PointerEvent): void {\n const view = this.document.defaultView;\n if (this.disabled() || event.pointerType !== 'mouse' || !view || view.matchMedia?.('(prefers-reduced-motion: reduce)').matches) {\n return;\n }\n const { clientX, clientY } = event;\n view.cancelAnimationFrame(this.frame);\n this.frame = view.requestAnimationFrame(() => {\n const box = this.layer().nativeElement.getBoundingClientRect();\n const constrain = this.constrain() || 1;\n this.active.set(true);\n this.tilt.set({\n x: -(clientY - box.y - box.height / 2) / constrain,\n y: (clientX - box.x - box.width / 2) / constrain,\n });\n });\n }\n\n reset(): void {\n this.document.defaultView?.cancelAnimationFrame?.(this.frame);\n this.active.set(false);\n this.tilt.set({ x: 0, y: 0 });\n }\n}\n"],"mappings":";;;;;AAgCA,IAAa,gBAAb,MAAa,cAAa;CACP,WAAW,OAAO,QAAQ;CAC1B,QAAQ,UAAU,SAAkC,SAAQ,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CACrE,QAA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