@tectra-ng/blocks 0.1.8 → 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,288 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, afterNextRender, booleanAttribute, computed, inject, input, 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_MASCOT_SPRITE = [
|
|
7
|
+
".......A.......",
|
|
8
|
+
".......S.......",
|
|
9
|
+
"....#######....",
|
|
10
|
+
"...#########...",
|
|
11
|
+
"..###########..",
|
|
12
|
+
"..##EE###EE##..",
|
|
13
|
+
"hh##EE###EE##HH",
|
|
14
|
+
"..###########..",
|
|
15
|
+
"..####MMM####..",
|
|
16
|
+
"...#########...",
|
|
17
|
+
"...ll.....LL...",
|
|
18
|
+
"...ll.....LL..."
|
|
19
|
+
];
|
|
20
|
+
const TX_MASCOT_TRICKS = [
|
|
21
|
+
"waving",
|
|
22
|
+
"looking",
|
|
23
|
+
"hopping",
|
|
24
|
+
"dancing",
|
|
25
|
+
"stretching"
|
|
26
|
+
];
|
|
27
|
+
const PART_CHARS = {
|
|
28
|
+
stem: "S",
|
|
29
|
+
antenna: "A",
|
|
30
|
+
"arm-left": "h",
|
|
31
|
+
"arm-right": "H",
|
|
32
|
+
body: "#EM",
|
|
33
|
+
eye: "E",
|
|
34
|
+
mouth: "M",
|
|
35
|
+
"leg-left": "l",
|
|
36
|
+
"leg-right": "L"
|
|
37
|
+
};
|
|
38
|
+
const UPPER_PARTS = [
|
|
39
|
+
"stem",
|
|
40
|
+
"antenna",
|
|
41
|
+
"arm-left",
|
|
42
|
+
"arm-right",
|
|
43
|
+
"body",
|
|
44
|
+
"eye",
|
|
45
|
+
"mouth"
|
|
46
|
+
];
|
|
47
|
+
const LEG_PARTS = ["leg-left", "leg-right"];
|
|
48
|
+
const TX_MASCOT_TRICK_SLOT_MS = 3e3;
|
|
49
|
+
const TX_MASCOT_TRICK_EVERY_SLOTS = 3;
|
|
50
|
+
function txMascotLayers(parts, sprite = TX_MASCOT_SPRITE) {
|
|
51
|
+
return parts.map((part) => ({
|
|
52
|
+
part,
|
|
53
|
+
pixels: sprite.flatMap((row, y) => [...row].flatMap((char, x) => PART_CHARS[part].includes(char) ? [{
|
|
54
|
+
x,
|
|
55
|
+
y
|
|
56
|
+
}] : []))
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
const TX_MASCOT_UPPER_LAYERS = txMascotLayers(UPPER_PARTS);
|
|
60
|
+
const TX_MASCOT_LEG_LAYERS = txMascotLayers(LEG_PARTS);
|
|
61
|
+
var TxMascot = class TxMascot {
|
|
62
|
+
state = input("idle", ...ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []);
|
|
63
|
+
label = input("", ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
|
|
64
|
+
playful = input(true, {
|
|
65
|
+
...ngDevMode ? { debugName: "playful" } : /* istanbul ignore next */ {},
|
|
66
|
+
transform: booleanAttribute
|
|
67
|
+
});
|
|
68
|
+
size = input(void 0, ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
|
|
69
|
+
dt = input(void 0, ...ngDevMode ? [{ debugName: "dt" }] : /* istanbul ignore next */ []);
|
|
70
|
+
pt = input(void 0, ...ngDevMode ? [{ debugName: "pt" }] : /* istanbul ignore next */ []);
|
|
71
|
+
ptOptions = input(void 0, ...ngDevMode ? [{ debugName: "ptOptions" }] : /* istanbul ignore next */ []);
|
|
72
|
+
unstyled = input(void 0, {
|
|
73
|
+
...ngDevMode ? { debugName: "unstyled" } : /* istanbul ignore next */ {},
|
|
74
|
+
transform: optionalBoolean
|
|
75
|
+
});
|
|
76
|
+
isUnstyled = injectUnstyled(this.unstyled);
|
|
77
|
+
passThrough = injectPassThrough("mascot", this, this.pt, this.ptOptions);
|
|
78
|
+
viewBox = `0 0 ${TX_MASCOT_SPRITE[0].length} ${TX_MASCOT_SPRITE.length}`;
|
|
79
|
+
upperLayers = TX_MASCOT_UPPER_LAYERS;
|
|
80
|
+
legLayers = TX_MASCOT_LEG_LAYERS;
|
|
81
|
+
slot = signal(1, ...ngDevMode ? [{ debugName: "slot" }] : /* istanbul ignore next */ []);
|
|
82
|
+
trickOffset = Math.floor(Math.random() * TX_MASCOT_TRICKS.length);
|
|
83
|
+
displayState = computed(() => {
|
|
84
|
+
const state = this.state();
|
|
85
|
+
const slot = this.slot();
|
|
86
|
+
if (state !== "idle" || !this.playful() || slot % 3 !== 0) return state;
|
|
87
|
+
return TX_MASCOT_TRICKS[(Math.floor(slot / 3) + this.trickOffset) % TX_MASCOT_TRICKS.length];
|
|
88
|
+
}, ...ngDevMode ? [{ debugName: "displayState" }] : /* istanbul ignore next */ []);
|
|
89
|
+
hostStyle = computed(() => {
|
|
90
|
+
const size = this.size();
|
|
91
|
+
return {
|
|
92
|
+
...toStyleObject(this.dt(), "--tx-mascot"),
|
|
93
|
+
...size !== void 0 ? { "--tx-mascot-size": typeof size === "number" ? `${size}px` : size } : {},
|
|
94
|
+
...this.passThrough().root?.style
|
|
95
|
+
};
|
|
96
|
+
}, ...ngDevMode ? [{ debugName: "hostStyle" }] : /* istanbul ignore next */ []);
|
|
97
|
+
constructor() {
|
|
98
|
+
const destroyRef = inject(DestroyRef);
|
|
99
|
+
afterNextRender(() => {
|
|
100
|
+
const timer = setInterval(() => this.slot.update((slot) => slot + 1), TX_MASCOT_TRICK_SLOT_MS);
|
|
101
|
+
destroyRef.onDestroy(() => clearInterval(timer));
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
105
|
+
minVersion: "12.0.0",
|
|
106
|
+
version: "22.2.3",
|
|
107
|
+
ngImport: i0,
|
|
108
|
+
type: TxMascot,
|
|
109
|
+
deps: [],
|
|
110
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
111
|
+
});
|
|
112
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
113
|
+
minVersion: "17.0.0",
|
|
114
|
+
version: "22.2.3",
|
|
115
|
+
type: TxMascot,
|
|
116
|
+
isStandalone: true,
|
|
117
|
+
selector: "tx-mascot",
|
|
118
|
+
inputs: {
|
|
119
|
+
state: {
|
|
120
|
+
classPropertyName: "state",
|
|
121
|
+
publicName: "state",
|
|
122
|
+
isSignal: true,
|
|
123
|
+
isRequired: false,
|
|
124
|
+
transformFunction: null
|
|
125
|
+
},
|
|
126
|
+
label: {
|
|
127
|
+
classPropertyName: "label",
|
|
128
|
+
publicName: "label",
|
|
129
|
+
isSignal: true,
|
|
130
|
+
isRequired: false,
|
|
131
|
+
transformFunction: null
|
|
132
|
+
},
|
|
133
|
+
playful: {
|
|
134
|
+
classPropertyName: "playful",
|
|
135
|
+
publicName: "playful",
|
|
136
|
+
isSignal: true,
|
|
137
|
+
isRequired: false,
|
|
138
|
+
transformFunction: null
|
|
139
|
+
},
|
|
140
|
+
size: {
|
|
141
|
+
classPropertyName: "size",
|
|
142
|
+
publicName: "size",
|
|
143
|
+
isSignal: true,
|
|
144
|
+
isRequired: false,
|
|
145
|
+
transformFunction: null
|
|
146
|
+
},
|
|
147
|
+
dt: {
|
|
148
|
+
classPropertyName: "dt",
|
|
149
|
+
publicName: "dt",
|
|
150
|
+
isSignal: true,
|
|
151
|
+
isRequired: false,
|
|
152
|
+
transformFunction: null
|
|
153
|
+
},
|
|
154
|
+
pt: {
|
|
155
|
+
classPropertyName: "pt",
|
|
156
|
+
publicName: "pt",
|
|
157
|
+
isSignal: true,
|
|
158
|
+
isRequired: false,
|
|
159
|
+
transformFunction: null
|
|
160
|
+
},
|
|
161
|
+
ptOptions: {
|
|
162
|
+
classPropertyName: "ptOptions",
|
|
163
|
+
publicName: "ptOptions",
|
|
164
|
+
isSignal: true,
|
|
165
|
+
isRequired: false,
|
|
166
|
+
transformFunction: null
|
|
167
|
+
},
|
|
168
|
+
unstyled: {
|
|
169
|
+
classPropertyName: "unstyled",
|
|
170
|
+
publicName: "unstyled",
|
|
171
|
+
isSignal: true,
|
|
172
|
+
isRequired: false,
|
|
173
|
+
transformFunction: null
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
host: {
|
|
177
|
+
attributes: { "role": "img" },
|
|
178
|
+
properties: {
|
|
179
|
+
"class": "passThrough().root?.class",
|
|
180
|
+
"style": "hostStyle()",
|
|
181
|
+
"attr.data-styled": "!isUnstyled() || null",
|
|
182
|
+
"attr.data-state": "displayState()",
|
|
183
|
+
"attr.aria-label": "label() || null",
|
|
184
|
+
"attr.aria-hidden": "label() ? null : \"true\""
|
|
185
|
+
},
|
|
186
|
+
classAttribute: "tx-mascot"
|
|
187
|
+
},
|
|
188
|
+
ngImport: i0,
|
|
189
|
+
template: "<svg class=\"tx-mascot__svg\" shape-rendering=\"crispEdges\" aria-hidden=\"true\" [attr.viewBox]=\"viewBox\" [class]=\"passThrough().svg?.class\" [style]=\"passThrough().svg?.style\">\n <g class=\"tx-mascot__figure\">\n @for (layer of legLayers; track layer.part) {\n <g [attr.class]=\"'tx-mascot__part tx-mascot__part--' + layer.part\">\n @for (pixel of layer.pixels; track $index) {\n <rect width=\"1\" height=\"1\" [attr.x]=\"pixel.x\" [attr.y]=\"pixel.y\" />\n }\n </g>\n }\n <g class=\"tx-mascot__upper\">\n @for (layer of upperLayers; track layer.part) {\n <g [attr.class]=\"'tx-mascot__part tx-mascot__part--' + layer.part\">\n @for (pixel of layer.pixels; track $index) {\n <rect width=\"1\" height=\"1\" [attr.x]=\"pixel.x\" [attr.y]=\"pixel.y\" />\n }\n </g>\n }\n </g>\n </g>\n</svg>\n",
|
|
190
|
+
styles: [":host{display:inline-block;flex-shrink:0;aspect-ratio:15/12}.tx-mascot__svg{display:block;width:100%;height:100%;overflow:visible}.tx-mascot__figure,.tx-mascot__upper,.tx-mascot__part{transform-box:fill-box;transform-origin:center}:host([data-styled]){width:var(--tx-mascot-size)}:host([data-styled]) .tx-mascot__part--body,:host([data-styled]) .tx-mascot__part--arm-left,:host([data-styled]) .tx-mascot__part--arm-right{fill:var(--tx-mascot-body-color)}:host([data-styled]) .tx-mascot__part--stem,:host([data-styled]) .tx-mascot__part--leg-left,:host([data-styled]) .tx-mascot__part--leg-right{fill:var(--tx-mascot-shade-color)}:host([data-styled]) .tx-mascot__part--antenna{fill:var(--tx-mascot-glow-color)}:host([data-styled]) .tx-mascot__part--eye,:host([data-styled]) .tx-mascot__part--mouth{fill:var(--tx-mascot-eye-color)}:host([data-styled]) .tx-mascot__part--mouth{opacity:0}:host([data-styled][data-state=idle]) .tx-mascot__upper{animation:tx-mascot-bob 1.8s steps(1) infinite}:host([data-styled][data-state=idle]) .tx-mascot__part--eye{animation:tx-mascot-blink 4.2s steps(1) infinite}:host([data-styled][data-state=idle]) .tx-mascot__part--antenna{animation:tx-mascot-glow 2.4s ease-in-out infinite}:host([data-styled][data-state=thinking]) .tx-mascot__upper{animation:tx-mascot-bob .9s steps(1) infinite}:host([data-styled][data-state=thinking]) .tx-mascot__part--eye{animation:tx-mascot-look 2.4s steps(1) infinite}:host([data-styled][data-state=thinking]) .tx-mascot__part--antenna{animation:tx-mascot-glow .6s ease-in-out infinite}:host([data-styled][data-state=thinking]) .tx-mascot__part--arm-left{animation:tx-mascot-arm .9s steps(1) infinite}:host([data-styled][data-state=happy]) .tx-mascot__figure{animation:tx-mascot-jump .9s steps(1) infinite}:host([data-styled][data-state=happy]) .tx-mascot__part--arm-left,:host([data-styled][data-state=happy]) .tx-mascot__part--arm-right{animation:tx-mascot-arm .45s steps(1) infinite}:host([data-styled][data-state=happy]) .tx-mascot__part--mouth{opacity:1}:host([data-styled][data-state=sleeping]) .tx-mascot__upper{animation:tx-mascot-bob 3.2s steps(1) infinite}:host([data-styled][data-state=sleeping]) .tx-mascot__part--eye{transform:scaleY(.34)}:host([data-styled][data-state=sleeping]) .tx-mascot__part--antenna{opacity:.3}:host([data-styled][data-state=walking]) .tx-mascot__upper{animation:tx-mascot-bob .5s steps(1) infinite}:host([data-styled][data-state=walking]) .tx-mascot__part--leg-left{animation:tx-mascot-step .5s steps(1) infinite}:host([data-styled][data-state=walking]) .tx-mascot__part--leg-right{animation:tx-mascot-step .5s steps(1) -.25s infinite}:host([data-styled][data-state=walking]) .tx-mascot__part--eye{animation:tx-mascot-blink 3s steps(1) infinite}:host([data-styled][data-state=waving]) .tx-mascot__upper{animation:tx-mascot-bob 1.5s steps(1) infinite}:host([data-styled][data-state=waving]) .tx-mascot__part--arm-right{animation:tx-mascot-wave .5s steps(1) infinite}:host([data-styled][data-state=waving]) .tx-mascot__part--mouth{opacity:1}:host([data-styled][data-state=looking]) .tx-mascot__part--eye{animation:tx-mascot-glance 3s steps(1) both}:host([data-styled][data-state=looking]) .tx-mascot__part--antenna{animation:tx-mascot-glow 1.5s ease-in-out infinite}:host([data-styled][data-state=hopping]) .tx-mascot__figure{animation:tx-mascot-hop 1.4s steps(1) 2 both}:host([data-styled][data-state=hopping]) .tx-mascot__part--arm-left,:host([data-styled][data-state=hopping]) .tx-mascot__part--arm-right{animation:tx-mascot-arm .35s steps(1) infinite}:host([data-styled][data-state=dancing]) .tx-mascot__upper{animation:tx-mascot-sway .6s steps(1) infinite}:host([data-styled][data-state=dancing]) .tx-mascot__part--arm-left{animation:tx-mascot-arm .6s steps(1) infinite}:host([data-styled][data-state=dancing]) .tx-mascot__part--arm-right{animation:tx-mascot-arm .6s steps(1) -.3s infinite}:host([data-styled][data-state=dancing]) .tx-mascot__part--leg-left{animation:tx-mascot-step .6s steps(1) infinite}:host([data-styled][data-state=dancing]) .tx-mascot__part--leg-right{animation:tx-mascot-step .6s steps(1) -.3s infinite}:host([data-styled][data-state=dancing]) .tx-mascot__part--mouth{opacity:1}:host([data-styled][data-state=stretching]) .tx-mascot__upper{animation:tx-mascot-stretch 3s steps(1) both}:host([data-styled][data-state=stretching]) .tx-mascot__part--arm-left,:host([data-styled][data-state=stretching]) .tx-mascot__part--arm-right{animation:tx-mascot-reach 3s steps(1) both}:host([data-styled][data-state=stretching]) .tx-mascot__part--eye{animation:tx-mascot-yawn 3s steps(1) both}@keyframes tx-mascot-wave{0%{transform:translateY(-1px)}50%{transform:translateY(-3px)}}@keyframes tx-mascot-glance{0%{transform:translate(0)}15%{transform:translate(-1px)}50%{transform:translate(1px)}85%{transform:translate(0)}}@keyframes tx-mascot-hop{0%{transform:translateY(0)}20%{transform:translateY(-2px)}35%{transform:translateY(-3px)}50%{transform:translateY(-2px)}65%{transform:translateY(0)}}@keyframes tx-mascot-sway{0%{transform:translate(-1px)}50%{transform:translate(1px)}}@keyframes tx-mascot-stretch{0%{transform:translateY(0)}20%{transform:translateY(-1px)}75%{transform:translateY(0)}}@keyframes tx-mascot-reach{0%{transform:translateY(0)}15%{transform:translateY(-2px)}30%{transform:translateY(-4px)}70%{transform:translateY(-2px)}80%{transform:translateY(0)}}@keyframes tx-mascot-yawn{0%{transform:scaleY(1)}25%{transform:scaleY(.34)}75%{transform:scaleY(1)}}@keyframes tx-mascot-bob{0%{transform:translateY(0)}50%{transform:translateY(-1px)}}@keyframes tx-mascot-blink{0%{transform:scaleY(1)}92%{transform:scaleY(.34)}96%{transform:scaleY(1)}}@keyframes tx-mascot-look{0%{transform:translate(0)}25%{transform:translate(-1px)}50%{transform:translate(0)}75%{transform:translate(1px)}}@keyframes tx-mascot-glow{0%,to{opacity:1}50%{opacity:.35}}@keyframes tx-mascot-jump{0%{transform:translateY(0)}25%{transform:translateY(-2px)}50%{transform:translateY(-1px)}75%{transform:translateY(0)}}@keyframes tx-mascot-arm{0%{transform:translateY(0)}50%{transform:translateY(-1px)}}@keyframes tx-mascot-step{0%{transform:translateY(0)}50%{transform:translateY(-1px)}}@media(prefers-reduced-motion:reduce){.tx-mascot__figure,.tx-mascot__upper,.tx-mascot__part{animation:none!important}}\n"],
|
|
191
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
195
|
+
minVersion: "12.0.0",
|
|
196
|
+
version: "22.2.3",
|
|
197
|
+
ngImport: i0,
|
|
198
|
+
type: TxMascot,
|
|
199
|
+
decorators: [{
|
|
200
|
+
type: Component,
|
|
201
|
+
args: [{
|
|
202
|
+
selector: "tx-mascot",
|
|
203
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
204
|
+
host: {
|
|
205
|
+
class: "tx-mascot",
|
|
206
|
+
role: "img",
|
|
207
|
+
"[class]": "passThrough().root?.class",
|
|
208
|
+
"[style]": "hostStyle()",
|
|
209
|
+
"[attr.data-styled]": "!isUnstyled() || null",
|
|
210
|
+
"[attr.data-state]": "displayState()",
|
|
211
|
+
"[attr.aria-label]": "label() || null",
|
|
212
|
+
"[attr.aria-hidden]": "label() ? null : \"true\""
|
|
213
|
+
},
|
|
214
|
+
template: "<svg class=\"tx-mascot__svg\" shape-rendering=\"crispEdges\" aria-hidden=\"true\" [attr.viewBox]=\"viewBox\" [class]=\"passThrough().svg?.class\" [style]=\"passThrough().svg?.style\">\n <g class=\"tx-mascot__figure\">\n @for (layer of legLayers; track layer.part) {\n <g [attr.class]=\"'tx-mascot__part tx-mascot__part--' + layer.part\">\n @for (pixel of layer.pixels; track $index) {\n <rect width=\"1\" height=\"1\" [attr.x]=\"pixel.x\" [attr.y]=\"pixel.y\" />\n }\n </g>\n }\n <g class=\"tx-mascot__upper\">\n @for (layer of upperLayers; track layer.part) {\n <g [attr.class]=\"'tx-mascot__part tx-mascot__part--' + layer.part\">\n @for (pixel of layer.pixels; track $index) {\n <rect width=\"1\" height=\"1\" [attr.x]=\"pixel.x\" [attr.y]=\"pixel.y\" />\n }\n </g>\n }\n </g>\n </g>\n</svg>\n",
|
|
215
|
+
styles: [":host{display:inline-block;flex-shrink:0;aspect-ratio:15/12}.tx-mascot__svg{display:block;width:100%;height:100%;overflow:visible}.tx-mascot__figure,.tx-mascot__upper,.tx-mascot__part{transform-box:fill-box;transform-origin:center}:host([data-styled]){width:var(--tx-mascot-size)}:host([data-styled]) .tx-mascot__part--body,:host([data-styled]) .tx-mascot__part--arm-left,:host([data-styled]) .tx-mascot__part--arm-right{fill:var(--tx-mascot-body-color)}:host([data-styled]) .tx-mascot__part--stem,:host([data-styled]) .tx-mascot__part--leg-left,:host([data-styled]) .tx-mascot__part--leg-right{fill:var(--tx-mascot-shade-color)}:host([data-styled]) .tx-mascot__part--antenna{fill:var(--tx-mascot-glow-color)}:host([data-styled]) .tx-mascot__part--eye,:host([data-styled]) .tx-mascot__part--mouth{fill:var(--tx-mascot-eye-color)}:host([data-styled]) .tx-mascot__part--mouth{opacity:0}:host([data-styled][data-state=idle]) .tx-mascot__upper{animation:tx-mascot-bob 1.8s steps(1) infinite}:host([data-styled][data-state=idle]) .tx-mascot__part--eye{animation:tx-mascot-blink 4.2s steps(1) infinite}:host([data-styled][data-state=idle]) .tx-mascot__part--antenna{animation:tx-mascot-glow 2.4s ease-in-out infinite}:host([data-styled][data-state=thinking]) .tx-mascot__upper{animation:tx-mascot-bob .9s steps(1) infinite}:host([data-styled][data-state=thinking]) .tx-mascot__part--eye{animation:tx-mascot-look 2.4s steps(1) infinite}:host([data-styled][data-state=thinking]) .tx-mascot__part--antenna{animation:tx-mascot-glow .6s ease-in-out infinite}:host([data-styled][data-state=thinking]) .tx-mascot__part--arm-left{animation:tx-mascot-arm .9s steps(1) infinite}:host([data-styled][data-state=happy]) .tx-mascot__figure{animation:tx-mascot-jump .9s steps(1) infinite}:host([data-styled][data-state=happy]) .tx-mascot__part--arm-left,:host([data-styled][data-state=happy]) .tx-mascot__part--arm-right{animation:tx-mascot-arm .45s steps(1) infinite}:host([data-styled][data-state=happy]) .tx-mascot__part--mouth{opacity:1}:host([data-styled][data-state=sleeping]) .tx-mascot__upper{animation:tx-mascot-bob 3.2s steps(1) infinite}:host([data-styled][data-state=sleeping]) .tx-mascot__part--eye{transform:scaleY(.34)}:host([data-styled][data-state=sleeping]) .tx-mascot__part--antenna{opacity:.3}:host([data-styled][data-state=walking]) .tx-mascot__upper{animation:tx-mascot-bob .5s steps(1) infinite}:host([data-styled][data-state=walking]) .tx-mascot__part--leg-left{animation:tx-mascot-step .5s steps(1) infinite}:host([data-styled][data-state=walking]) .tx-mascot__part--leg-right{animation:tx-mascot-step .5s steps(1) -.25s infinite}:host([data-styled][data-state=walking]) .tx-mascot__part--eye{animation:tx-mascot-blink 3s steps(1) infinite}:host([data-styled][data-state=waving]) .tx-mascot__upper{animation:tx-mascot-bob 1.5s steps(1) infinite}:host([data-styled][data-state=waving]) .tx-mascot__part--arm-right{animation:tx-mascot-wave .5s steps(1) infinite}:host([data-styled][data-state=waving]) .tx-mascot__part--mouth{opacity:1}:host([data-styled][data-state=looking]) .tx-mascot__part--eye{animation:tx-mascot-glance 3s steps(1) both}:host([data-styled][data-state=looking]) .tx-mascot__part--antenna{animation:tx-mascot-glow 1.5s ease-in-out infinite}:host([data-styled][data-state=hopping]) .tx-mascot__figure{animation:tx-mascot-hop 1.4s steps(1) 2 both}:host([data-styled][data-state=hopping]) .tx-mascot__part--arm-left,:host([data-styled][data-state=hopping]) .tx-mascot__part--arm-right{animation:tx-mascot-arm .35s steps(1) infinite}:host([data-styled][data-state=dancing]) .tx-mascot__upper{animation:tx-mascot-sway .6s steps(1) infinite}:host([data-styled][data-state=dancing]) .tx-mascot__part--arm-left{animation:tx-mascot-arm .6s steps(1) infinite}:host([data-styled][data-state=dancing]) .tx-mascot__part--arm-right{animation:tx-mascot-arm .6s steps(1) -.3s infinite}:host([data-styled][data-state=dancing]) .tx-mascot__part--leg-left{animation:tx-mascot-step .6s steps(1) infinite}:host([data-styled][data-state=dancing]) .tx-mascot__part--leg-right{animation:tx-mascot-step .6s steps(1) -.3s infinite}:host([data-styled][data-state=dancing]) .tx-mascot__part--mouth{opacity:1}:host([data-styled][data-state=stretching]) .tx-mascot__upper{animation:tx-mascot-stretch 3s steps(1) both}:host([data-styled][data-state=stretching]) .tx-mascot__part--arm-left,:host([data-styled][data-state=stretching]) .tx-mascot__part--arm-right{animation:tx-mascot-reach 3s steps(1) both}:host([data-styled][data-state=stretching]) .tx-mascot__part--eye{animation:tx-mascot-yawn 3s steps(1) both}@keyframes tx-mascot-wave{0%{transform:translateY(-1px)}50%{transform:translateY(-3px)}}@keyframes tx-mascot-glance{0%{transform:translate(0)}15%{transform:translate(-1px)}50%{transform:translate(1px)}85%{transform:translate(0)}}@keyframes tx-mascot-hop{0%{transform:translateY(0)}20%{transform:translateY(-2px)}35%{transform:translateY(-3px)}50%{transform:translateY(-2px)}65%{transform:translateY(0)}}@keyframes tx-mascot-sway{0%{transform:translate(-1px)}50%{transform:translate(1px)}}@keyframes tx-mascot-stretch{0%{transform:translateY(0)}20%{transform:translateY(-1px)}75%{transform:translateY(0)}}@keyframes tx-mascot-reach{0%{transform:translateY(0)}15%{transform:translateY(-2px)}30%{transform:translateY(-4px)}70%{transform:translateY(-2px)}80%{transform:translateY(0)}}@keyframes tx-mascot-yawn{0%{transform:scaleY(1)}25%{transform:scaleY(.34)}75%{transform:scaleY(1)}}@keyframes tx-mascot-bob{0%{transform:translateY(0)}50%{transform:translateY(-1px)}}@keyframes tx-mascot-blink{0%{transform:scaleY(1)}92%{transform:scaleY(.34)}96%{transform:scaleY(1)}}@keyframes tx-mascot-look{0%{transform:translate(0)}25%{transform:translate(-1px)}50%{transform:translate(0)}75%{transform:translate(1px)}}@keyframes tx-mascot-glow{0%,to{opacity:1}50%{opacity:.35}}@keyframes tx-mascot-jump{0%{transform:translateY(0)}25%{transform:translateY(-2px)}50%{transform:translateY(-1px)}75%{transform:translateY(0)}}@keyframes tx-mascot-arm{0%{transform:translateY(0)}50%{transform:translateY(-1px)}}@keyframes tx-mascot-step{0%{transform:translateY(0)}50%{transform:translateY(-1px)}}@media(prefers-reduced-motion:reduce){.tx-mascot__figure,.tx-mascot__upper,.tx-mascot__part{animation:none!important}}\n"]
|
|
216
|
+
}]
|
|
217
|
+
}],
|
|
218
|
+
ctorParameters: () => [],
|
|
219
|
+
propDecorators: {
|
|
220
|
+
state: [{
|
|
221
|
+
type: i0.Input,
|
|
222
|
+
args: [{
|
|
223
|
+
isSignal: true,
|
|
224
|
+
alias: "state",
|
|
225
|
+
required: false
|
|
226
|
+
}]
|
|
227
|
+
}],
|
|
228
|
+
label: [{
|
|
229
|
+
type: i0.Input,
|
|
230
|
+
args: [{
|
|
231
|
+
isSignal: true,
|
|
232
|
+
alias: "label",
|
|
233
|
+
required: false
|
|
234
|
+
}]
|
|
235
|
+
}],
|
|
236
|
+
playful: [{
|
|
237
|
+
type: i0.Input,
|
|
238
|
+
args: [{
|
|
239
|
+
isSignal: true,
|
|
240
|
+
alias: "playful",
|
|
241
|
+
required: false
|
|
242
|
+
}]
|
|
243
|
+
}],
|
|
244
|
+
size: [{
|
|
245
|
+
type: i0.Input,
|
|
246
|
+
args: [{
|
|
247
|
+
isSignal: true,
|
|
248
|
+
alias: "size",
|
|
249
|
+
required: false
|
|
250
|
+
}]
|
|
251
|
+
}],
|
|
252
|
+
dt: [{
|
|
253
|
+
type: i0.Input,
|
|
254
|
+
args: [{
|
|
255
|
+
isSignal: true,
|
|
256
|
+
alias: "dt",
|
|
257
|
+
required: false
|
|
258
|
+
}]
|
|
259
|
+
}],
|
|
260
|
+
pt: [{
|
|
261
|
+
type: i0.Input,
|
|
262
|
+
args: [{
|
|
263
|
+
isSignal: true,
|
|
264
|
+
alias: "pt",
|
|
265
|
+
required: false
|
|
266
|
+
}]
|
|
267
|
+
}],
|
|
268
|
+
ptOptions: [{
|
|
269
|
+
type: i0.Input,
|
|
270
|
+
args: [{
|
|
271
|
+
isSignal: true,
|
|
272
|
+
alias: "ptOptions",
|
|
273
|
+
required: false
|
|
274
|
+
}]
|
|
275
|
+
}],
|
|
276
|
+
unstyled: [{
|
|
277
|
+
type: i0.Input,
|
|
278
|
+
args: [{
|
|
279
|
+
isSignal: true,
|
|
280
|
+
alias: "unstyled",
|
|
281
|
+
required: false
|
|
282
|
+
}]
|
|
283
|
+
}]
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
export { TX_MASCOT_LEG_LAYERS, TX_MASCOT_SPRITE, TX_MASCOT_TRICKS, TX_MASCOT_TRICK_EVERY_SLOTS, TX_MASCOT_TRICK_SLOT_MS, TX_MASCOT_UPPER_LAYERS, TxMascot, txMascotLayers };
|
|
287
|
+
|
|
288
|
+
//# sourceMappingURL=tectra-ng-blocks-mascot.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tectra-ng-blocks-mascot.mjs","names":[],"sources":["../../../../packages/blocks/mascot/src/mascot.data.ts","../../../../packages/blocks/mascot/src/mascot.component.ts","../../../../packages/blocks/mascot/src/mascot.component.html"],"sourcesContent":["import { TxMascotBodyPart, TxMascotLayer, TxMascotTrick } from './mascot.types';\n\nexport const TX_MASCOT_SPRITE: readonly string[] = [\n '.......A.......',\n '.......S.......',\n '....#######....',\n '...#########...',\n '..###########..',\n '..##EE###EE##..',\n 'hh##EE###EE##HH',\n '..###########..',\n '..####MMM####..',\n '...#########...',\n '...ll.....LL...',\n '...ll.....LL...',\n];\n\nexport const TX_MASCOT_TRICKS: readonly TxMascotTrick[] = ['waving', 'looking', 'hopping', 'dancing', 'stretching'];\n\nconst PART_CHARS: Record<TxMascotBodyPart, string> = {\n stem: 'S',\n antenna: 'A',\n 'arm-left': 'h',\n 'arm-right': 'H',\n body: '#EM',\n eye: 'E',\n mouth: 'M',\n 'leg-left': 'l',\n 'leg-right': 'L',\n};\n\nconst UPPER_PARTS: TxMascotBodyPart[] = ['stem', 'antenna', 'arm-left', 'arm-right', 'body', 'eye', 'mouth'];\nconst LEG_PARTS: TxMascotBodyPart[] = ['leg-left', 'leg-right'];\n\nexport const TX_MASCOT_TRICK_SLOT_MS = 3000;\nexport const TX_MASCOT_TRICK_EVERY_SLOTS = 3;\n\nexport function txMascotLayers(parts: TxMascotBodyPart[], sprite: readonly string[] = TX_MASCOT_SPRITE): TxMascotLayer[] {\n return parts.map((part) => ({\n part,\n pixels: sprite.flatMap((row, y) => [...row].flatMap((char, x) => (PART_CHARS[part].includes(char) ? [{ x, y }] : []))),\n }));\n}\n\nexport const TX_MASCOT_UPPER_LAYERS = txMascotLayers(UPPER_PARTS);\nexport const TX_MASCOT_LEG_LAYERS = txMascotLayers(LEG_PARTS);\n","import { ChangeDetectionStrategy, Component, DestroyRef, afterNextRender, booleanAttribute, computed, inject, input, signal } from '@angular/core';\nimport { TxPassThrough, TxPassThroughOptions, injectPassThrough, injectUnstyled } from '@tectra-ng/core/config';\nimport { optionalBoolean } from '@tectra-ng/core/utils';\nimport { TectraDeepPartial, TectraMascotTokens, toStyleObject } from '@tectra-ng/themes';\nimport { TX_MASCOT_LEG_LAYERS, TX_MASCOT_SPRITE, TX_MASCOT_TRICKS, TX_MASCOT_TRICK_EVERY_SLOTS, TX_MASCOT_TRICK_SLOT_MS, TX_MASCOT_UPPER_LAYERS } from './mascot.data';\nimport { TxMascotPart, TxMascotState } from './mascot.types';\n\n@Component({\n selector: 'tx-mascot',\n templateUrl: './mascot.component.html',\n styleUrl: './mascot.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'tx-mascot',\n role: 'img',\n '[class]': 'passThrough().root?.class',\n '[style]': 'hostStyle()',\n '[attr.data-styled]': '!isUnstyled() || null',\n '[attr.data-state]': 'displayState()',\n '[attr.aria-label]': 'label() || null',\n '[attr.aria-hidden]': 'label() ? null : \"true\"',\n },\n})\nexport class TxMascot {\n readonly state = input<TxMascotState>('idle');\n readonly label = input<string>('');\n readonly playful = input<boolean, unknown>(true, { transform: booleanAttribute });\n readonly size = input<number | string | undefined>(undefined);\n readonly dt = input<TectraDeepPartial<TectraMascotTokens> | undefined>(undefined);\n readonly pt = input<TxPassThrough<TxMascotPart, TxMascot> | 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('mascot', this, this.pt, this.ptOptions);\n readonly viewBox = `0 0 ${TX_MASCOT_SPRITE[0].length} ${TX_MASCOT_SPRITE.length}`;\n readonly upperLayers = TX_MASCOT_UPPER_LAYERS;\n readonly legLayers = TX_MASCOT_LEG_LAYERS;\n\n private readonly slot = signal(1);\n private readonly trickOffset = Math.floor(Math.random() * TX_MASCOT_TRICKS.length);\n\n readonly displayState = computed<TxMascotState>(() => {\n const state = this.state();\n const slot = this.slot();\n if (state !== 'idle' || !this.playful() || slot % TX_MASCOT_TRICK_EVERY_SLOTS !== 0) {\n return state;\n }\n return TX_MASCOT_TRICKS[(Math.floor(slot / TX_MASCOT_TRICK_EVERY_SLOTS) + this.trickOffset) % TX_MASCOT_TRICKS.length];\n });\n readonly hostStyle = computed(() => {\n const size = this.size();\n return {\n ...toStyleObject(this.dt(), '--tx-mascot'),\n ...(size !== undefined ? { '--tx-mascot-size': typeof size === 'number' ? `${size}px` : size } : {}),\n ...this.passThrough().root?.style,\n };\n });\n\n constructor() {\n const destroyRef = inject(DestroyRef);\n afterNextRender(() => {\n const timer = setInterval(() => this.slot.update((slot) => slot + 1), TX_MASCOT_TRICK_SLOT_MS);\n destroyRef.onDestroy(() => clearInterval(timer));\n });\n }\n}\n","<svg class=\"tx-mascot__svg\" shape-rendering=\"crispEdges\" aria-hidden=\"true\" [attr.viewBox]=\"viewBox\" [class]=\"passThrough().svg?.class\" [style]=\"passThrough().svg?.style\">\n <g class=\"tx-mascot__figure\">\n @for (layer of legLayers; track layer.part) {\n <g [attr.class]=\"'tx-mascot__part tx-mascot__part--' + layer.part\">\n @for (pixel of layer.pixels; track $index) {\n <rect width=\"1\" height=\"1\" [attr.x]=\"pixel.x\" [attr.y]=\"pixel.y\" />\n }\n </g>\n }\n <g class=\"tx-mascot__upper\">\n @for (layer of upperLayers; track layer.part) {\n <g [attr.class]=\"'tx-mascot__part tx-mascot__part--' + layer.part\">\n @for (pixel of layer.pixels; track $index) {\n <rect width=\"1\" height=\"1\" [attr.x]=\"pixel.x\" [attr.y]=\"pixel.y\" />\n }\n </g>\n }\n </g>\n </g>\n</svg>\n"],"mappings":"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"}
|
package/mascot/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Mascot
|
|
2
|
+
|
|
3
|
+
A pixel-art mascot drawn as SVG in the accent colour, with animated states: idle, thinking, happy, sleeping, walking and short tricks (waving, looking, hopping, dancing, stretching). For assistants, empty states and onboarding. While idle it plays a random trick from time to time.
|
|
4
|
+
|
|
5
|
+
```html
|
|
6
|
+
<tx-mascot [state]="thinking() ? 'thinking' : 'idle'" label="Assistant" />
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Inputs
|
|
10
|
+
| Name | Description |
|
|
11
|
+
|---|---|
|
|
12
|
+
| state | `idle`, `thinking`, `happy`, `sleeping`, `walking`, or a trick: `waving`, `looking`, `hopping`, `dancing`, `stretching` |
|
|
13
|
+
| label | Accessible name; empty makes the mascot decorative (`aria-hidden`) |
|
|
14
|
+
| playful | While `state` is `idle`, plays a random trick every 9 seconds; `false` keeps it plain idle |
|
|
15
|
+
| size | Width as a number of px or any CSS length; the height follows (15 : 12). 48px by default |
|
|
16
|
+
| dt | Design tokens of this instance (`mascot`): size and the body, shade, glow and eye colours |
|
|
17
|
+
| pt | Classes and styles of the parts: `root`, `svg` |
|
|
18
|
+
| ptOptions | How `pt` merges with the global pass-through |
|
|
19
|
+
| unstyled | Removes the tectra styles (colours and motion) |
|
|
20
|
+
|
|
21
|
+
## Sprite
|
|
22
|
+
The figure is `TX_MASCOT_SPRITE`, rows of characters on a 15 × 12 grid; `txMascotLayers(parts, sprite)` turns it into pixels per part.
|
|
23
|
+
|
|
24
|
+
## Notes
|
|
25
|
+
- The animations step pixel by pixel and stop under `prefers-reduced-motion`.
|
|
26
|
+
- The first paint is always the given `state`, also on the server; tricks start in the browser.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tectra-ng/blocks",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Ready page blocks for Angular consoles and admin apps on the tectra components: filters panel, page header, empty state, layouts, wizard, command palette and more.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://tectra-ng.com",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"@angular/common": "^22.0.0",
|
|
29
29
|
"@angular/core": "^22.0.0",
|
|
30
30
|
"@angular/router": "^22.0.0",
|
|
31
|
-
"@tectra-ng/core": "^0.1.
|
|
32
|
-
"@tectra-ng/icons": "^0.1.
|
|
33
|
-
"@tectra-ng/qr": "^0.1.
|
|
34
|
-
"@tectra-ng/themes": "^0.1.
|
|
35
|
-
"@tectra-ng/ui": "^0.1.
|
|
31
|
+
"@tectra-ng/core": "^0.1.9",
|
|
32
|
+
"@tectra-ng/icons": "^0.1.9",
|
|
33
|
+
"@tectra-ng/qr": "^0.1.9",
|
|
34
|
+
"@tectra-ng/themes": "^0.1.9",
|
|
35
|
+
"@tectra-ng/ui": "^0.1.9"
|
|
36
36
|
},
|
|
37
37
|
"peerDependenciesMeta": {
|
|
38
38
|
"@angular/router": {
|
|
@@ -103,6 +103,10 @@
|
|
|
103
103
|
"types": "./types/tectra-ng-blocks-kanban.d.ts",
|
|
104
104
|
"default": "./fesm2022/tectra-ng-blocks-kanban.mjs"
|
|
105
105
|
},
|
|
106
|
+
"./mascot": {
|
|
107
|
+
"types": "./types/tectra-ng-blocks-mascot.d.ts",
|
|
108
|
+
"default": "./fesm2022/tectra-ng-blocks-mascot.mjs"
|
|
109
|
+
},
|
|
106
110
|
"./network-status": {
|
|
107
111
|
"types": "./types/tectra-ng-blocks-network-status.d.ts",
|
|
108
112
|
"default": "./fesm2022/tectra-ng-blocks-network-status.mjs"
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { TxPassThroughOptions } from "@tectra-ng/core/config";
|
|
2
|
+
import { TectraDeepPartial } from "@tectra-ng/themes";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export type TxMascotTrick = 'waving' | 'looking' | 'hopping' | 'dancing' | 'stretching';
|
|
5
|
+
export type TxMascotState = 'idle' | 'thinking' | 'happy' | 'sleeping' | 'walking' | TxMascotTrick;
|
|
6
|
+
export type TxMascotBodyPart = 'antenna' | 'stem' | 'body' | 'eye' | 'mouth' | 'arm-left' | 'arm-right' | 'leg-left' | 'leg-right';
|
|
7
|
+
export type TxMascotPart = 'root' | 'svg';
|
|
8
|
+
export interface TxMascotPixel {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
}
|
|
12
|
+
export interface TxMascotLayer {
|
|
13
|
+
part: TxMascotBodyPart;
|
|
14
|
+
pixels: TxMascotPixel[];
|
|
15
|
+
}
|
|
16
|
+
export declare const TX_MASCOT_SPRITE: readonly string[];
|
|
17
|
+
export declare const TX_MASCOT_TRICKS: readonly TxMascotTrick[];
|
|
18
|
+
export declare const TX_MASCOT_TRICK_SLOT_MS = 3000;
|
|
19
|
+
export declare const TX_MASCOT_TRICK_EVERY_SLOTS = 3;
|
|
20
|
+
export declare function txMascotLayers(parts: TxMascotBodyPart[], sprite?: readonly string[]): TxMascotLayer[];
|
|
21
|
+
export declare const TX_MASCOT_UPPER_LAYERS: TxMascotLayer[];
|
|
22
|
+
export declare const TX_MASCOT_LEG_LAYERS: TxMascotLayer[];
|
|
23
|
+
export declare class TxMascot {
|
|
24
|
+
readonly state: import("@angular/core").InputSignal<TxMascotState>;
|
|
25
|
+
readonly label: import("@angular/core").InputSignal<string>;
|
|
26
|
+
readonly playful: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
|
|
27
|
+
readonly size: import("@angular/core").InputSignal<string | number | undefined>;
|
|
28
|
+
readonly dt: import("@angular/core").InputSignal<TectraDeepPartial<{
|
|
29
|
+
root: {
|
|
30
|
+
size: string;
|
|
31
|
+
bodyColor: string;
|
|
32
|
+
shadeColor: string;
|
|
33
|
+
glowColor: string;
|
|
34
|
+
eyeColor: string;
|
|
35
|
+
};
|
|
36
|
+
}> | undefined>;
|
|
37
|
+
readonly pt: import("@angular/core").InputSignal<Partial<Record<TxMascotPart, import("@tectra-ng/core/config").TxPassThroughValue<TxMascot>>> | undefined>;
|
|
38
|
+
readonly ptOptions: import("@angular/core").InputSignal<TxPassThroughOptions | undefined>;
|
|
39
|
+
readonly unstyled: import("@angular/core").InputSignalWithTransform<boolean | undefined, unknown>;
|
|
40
|
+
readonly isUnstyled: import("@angular/core").Signal<boolean>;
|
|
41
|
+
readonly passThrough: import("@angular/core").Signal<Partial<Record<TxMascotPart, import("@tectra-ng/core/config").TxPassThroughPart>>>;
|
|
42
|
+
readonly viewBox: string;
|
|
43
|
+
readonly upperLayers: import("@tectra-ng/blocks/mascot").TxMascotLayer[];
|
|
44
|
+
readonly legLayers: import("@tectra-ng/blocks/mascot").TxMascotLayer[];
|
|
45
|
+
private readonly slot;
|
|
46
|
+
private readonly trickOffset;
|
|
47
|
+
readonly displayState: import("@angular/core").Signal<TxMascotState>;
|
|
48
|
+
readonly hostStyle: import("@angular/core").Signal<{
|
|
49
|
+
'--tx-mascot-size'?: string | undefined;
|
|
50
|
+
}>;
|
|
51
|
+
constructor();
|
|
52
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TxMascot, never>;
|
|
53
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TxMascot, "tx-mascot", never, {
|
|
54
|
+
"state": {
|
|
55
|
+
"alias": "state";
|
|
56
|
+
"required": false;
|
|
57
|
+
"isSignal": true;
|
|
58
|
+
};
|
|
59
|
+
"label": {
|
|
60
|
+
"alias": "label";
|
|
61
|
+
"required": false;
|
|
62
|
+
"isSignal": true;
|
|
63
|
+
};
|
|
64
|
+
"playful": {
|
|
65
|
+
"alias": "playful";
|
|
66
|
+
"required": false;
|
|
67
|
+
"isSignal": true;
|
|
68
|
+
};
|
|
69
|
+
"size": {
|
|
70
|
+
"alias": "size";
|
|
71
|
+
"required": false;
|
|
72
|
+
"isSignal": true;
|
|
73
|
+
};
|
|
74
|
+
"dt": {
|
|
75
|
+
"alias": "dt";
|
|
76
|
+
"required": false;
|
|
77
|
+
"isSignal": true;
|
|
78
|
+
};
|
|
79
|
+
"pt": {
|
|
80
|
+
"alias": "pt";
|
|
81
|
+
"required": false;
|
|
82
|
+
"isSignal": true;
|
|
83
|
+
};
|
|
84
|
+
"ptOptions": {
|
|
85
|
+
"alias": "ptOptions";
|
|
86
|
+
"required": false;
|
|
87
|
+
"isSignal": true;
|
|
88
|
+
};
|
|
89
|
+
"unstyled": {
|
|
90
|
+
"alias": "unstyled";
|
|
91
|
+
"required": false;
|
|
92
|
+
"isSignal": true;
|
|
93
|
+
};
|
|
94
|
+
}, {}, never, never, true, never>;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=tectra-ng-blocks-mascot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tectra-ng-blocks-mascot.d.ts","names":[],"sources":["../../../../packages/blocks/mascot/src/mascot.types.ts","../../../../packages/blocks/mascot/src/mascot.data.ts","../../../../packages/blocks/mascot/src/mascot.component.ts"],"mappings":";;;YAAY;YACA,yEAAyE;YACzE;YACA;iBAEK;EACf;EACA;;iBAGe;EACf,MAAM;EACN,QAAQ;;qBCVG;qBAeA,2BAA2B;qBAiB3B;qBACA;wBAEG,eAAe,OAAO,oBAAoB,6BAA+C;qBAO5F,wBAAsB;qBACtB,sBAAoB;qBCtBpB;WACF,+BAAK,YAAA;WACL,+BAAK;WACL,iCAAO;WACP,8BAAI;WACJ,4BAAE,YAAA;;;;;;;;;WACF,4BAAE,YAAA,QAAA,OAAA,+CAAA,mBAAA;WACF,mCAAS,YAAA;WACT,kCAAQ;WAER,oCAAU;WACV,qCAAW,OAAA,QAAA,OAAA,+CAAA;WACX;WACA,gDAAW;WACX,8CAAS;mBAED;mBACA;WAER,sCAAY,OAAA;WAQZ,mCAAS;;;;SA3BP,MAAA,GAAA,qBAAA;SAAA,MAAA,GAAA,uBAAA;IAAQ;MAAA;MAAA;MAAA;;IAAA;MAAA;MAAA;MAAA;;IAAA;MAAA;MAAA;MAAA;;IAAA;MAAA;MAAA;MAAA;;IAAA;MAAA;MAAA;MAAA;;IAAA;MAAA;MAAA;MAAA;;IAAA;MAAA;MAAA;MAAA;;IAAA;MAAA;MAAA;MAAA"}
|