@proximus/lavender-poke-card 1.4.7-beta.2

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,11 @@
1
+ import '@proximus/lavender-layout';
2
+ /**
3
+ * @summary Row of action buttons + optional overflow icon inside a PokeCard.
4
+ *
5
+ * @slot - Primary action button(s) rendered on the left.
6
+ * @slot more-action - Overflow / "more" action rendered on the right.
7
+ */
8
+ export declare class CardActions extends HTMLElement {
9
+ private template;
10
+ constructor();
11
+ }
@@ -0,0 +1,65 @@
1
+ import '@proximus/lavender-container';
2
+ import '@proximus/lavender-layout';
3
+ import { type Container } from '@proximus/lavender-container';
4
+ import { type Stack } from '@proximus/lavender-layout';
5
+ export declare const cardContainerMediaPositionValues: readonly ["none", "top", "left"];
6
+ export type CardContainerMediaPosition = (typeof cardContainerMediaPositionValues)[number];
7
+ export declare const cardContainerMediaSizeValues: readonly ["cover", "contain"];
8
+ export type CardContainerMediaSize = (typeof cardContainerMediaSizeValues)[number];
9
+ export declare const cardContainerBackgroundColorValues: readonly ["container-primary", "container-secondary", "container-light", "container-default", "container-strong"];
10
+ export type CardContainerBackgroundColor = (typeof cardContainerBackgroundColorValues)[number];
11
+ /**
12
+ * @summary Outer card surface with media support. Delegates background, border and inverted handling to `<px-container>`.
13
+ *
14
+ * @slot heading - Card heading group (`<px-card-heading>`). Rendered at the top of the content area.
15
+ * @slot - Default slot for body content between the heading and actions.
16
+ * @slot actions - Card actions group (`<px-card-actions>`). Rendered at the bottom of the content area.
17
+ *
18
+ * @attr {boolean} inverted - Switches to a dark surface with inverted text colors.
19
+ * @attr {string} src - URL of the card media image.
20
+ * @attr {'none'|'top'|'left'} media-position - Where the media image is rendered.
21
+ * @attr {'cover'|'contain'} media-size - How the media image is fitted.
22
+ * @attr {string} alternative-text - Alt text for the media image.
23
+ * @attr {'s'|'m'|'l'} padding - Inner content padding size.
24
+ * @attr {string} aspect-ratio - Aspect ratio applied to top media (e.g. `'16:9'`, `'1:1'`, `'4:3'`).
25
+ * @attr {'true'|'false'} has-border - Whether the card has a visible border.
26
+ * @attr {'container-primary'|'container-secondary'|'container-light'|'container-default'|'container-strong'} background-color - Surface color preset.
27
+ * @attr {string} background-image - URL of a full-card background image (delegated to `<px-container>`).
28
+ *
29
+ * @cssproperty --card-padding - Resolved inner content padding (driven by `padding`).
30
+ */
31
+ export declare class CardContainer extends HTMLElement {
32
+ #private;
33
+ static get observedAttributes(): string[];
34
+ private template;
35
+ constructor();
36
+ connectedCallback(): void;
37
+ disconnectedCallback(): void;
38
+ attributeChangedCallback(attrName: string, oldValue: string, newValue: string): void;
39
+ get $container(): Container;
40
+ get $cardInner(): Stack;
41
+ get $mediaWrapper(): HTMLElement;
42
+ get $mediaImage(): HTMLImageElement;
43
+ get inverted(): boolean;
44
+ set inverted(value: boolean);
45
+ get src(): string;
46
+ set src(value: string);
47
+ get mediaPosition(): CardContainerMediaPosition;
48
+ set mediaPosition(value: CardContainerMediaPosition);
49
+ get mediaSize(): CardContainerMediaSize;
50
+ set mediaSize(value: CardContainerMediaSize);
51
+ get mediaAltText(): string;
52
+ set mediaAltText(value: string);
53
+ get padding(): string;
54
+ set padding(value: string);
55
+ get aspectRatio(): string;
56
+ set aspectRatio(value: string);
57
+ get hasBorder(): boolean;
58
+ set hasBorder(value: boolean);
59
+ get backgroundColor(): CardContainerBackgroundColor | null;
60
+ set backgroundColor(value: CardContainerBackgroundColor);
61
+ get backgroundImage(): string;
62
+ set backgroundImage(value: string);
63
+ get interactiveState(): string;
64
+ set interactiveState(value: string);
65
+ }
@@ -0,0 +1,10 @@
1
+ import '@proximus/lavender-layout';
2
+ /**
3
+ * @summary Title + subtitle heading group inside a PokeCard.
4
+ *
5
+ * @slot - Card title and subtitle elements (e.g. `<px-h3>`, `<px-p>`), stacked vertically with a tight gap.
6
+ */
7
+ export declare class CardHeading extends HTMLElement {
8
+ private template;
9
+ constructor();
10
+ }
@@ -0,0 +1,3 @@
1
+ export * from './CardContainer';
2
+ export * from './CardHeading';
3
+ export * from './CardActions';
@@ -0,0 +1,278 @@
1
+ var b = (r) => {
2
+ throw TypeError(r);
3
+ };
4
+ var y = (r, a, t) => a.has(r) || b("Cannot " + t);
5
+ var g = (r, a, t) => a.has(r) ? b("Cannot add the same private member more than once") : a instanceof WeakSet ? a.add(r) : a.set(r, t);
6
+ var i = (r, a, t) => (y(r, a, "access private method"), t);
7
+ import "@proximus/lavender-container";
8
+ import "@proximus/lavender-layout";
9
+ import { cssTokenBreakpoints as $, paddingValues as w } from "@proximus/lavender-common";
10
+ const C = ':host{--card-padding: var(--px-padding-s-mobile);display:block;border:var(--px-size-border-m) solid rgba(0,0,0,0)}:host[has-border]{border:var(--px-size-border-s) solid rgba(0,0,0,0)}:host *{box-sizing:border-box}:host([interactive-state="hover"]:hover){border:0 solid rgba(0,0,0,0)}.media-wrapper{display:none;position:relative;overflow:hidden}:host([media-position="top"]) .media-wrapper{display:block;width:100%}:host([media-position="top"]) .media-wrapper img{border-radius:var(--px-radius-main) var(--px-radius-main) 0 0}:host([media-position="left"]) .media-wrapper{display:block;width:33.33%;aspect-ratio:1 / 1;flex-shrink:0}:host([media-position="left"]) .media-wrapper img{border-radius:var(--px-radius-main) 0 0 var(--px-radius-main)}.media-image{display:block;width:100%;height:100%;object-fit:cover}.media-image:not([src]){display:none}:host([media-size="contain"]) .media-image{object-fit:contain}.content{display:block;padding:var(--card-padding);flex:1 1 auto}', k = new CSSStyleSheet();
11
+ k.replaceSync(C);
12
+ const j = [
13
+ "none",
14
+ "top",
15
+ "left"
16
+ ], W = ["cover", "contain"], D = [
17
+ "container-primary",
18
+ "container-secondary",
19
+ "container-light",
20
+ "container-default",
21
+ "container-strong"
22
+ ], R = (r, a, t) => `:host([${r}${t ? `--${t}` : ""}='${a}']) .content`, z = $(
23
+ "padding",
24
+ R,
25
+ w,
26
+ "px-padding"
27
+ );
28
+ var e, v, A, d, c, h, l, p, u, x, o;
29
+ class I extends HTMLElement {
30
+ constructor() {
31
+ super();
32
+ g(this, e);
33
+ this.attachShadow({ mode: "open" }), this.shadowRoot.adoptedStyleSheets = [k, z], this.shadowRoot.innerHTML = this.template();
34
+ }
35
+ static get observedAttributes() {
36
+ return [
37
+ "inverted",
38
+ "src",
39
+ "media-position",
40
+ "media-size",
41
+ "media-alt-text",
42
+ "padding",
43
+ "aspect-ratio",
44
+ "has-border",
45
+ "background-color",
46
+ "background-image",
47
+ "interactive-state"
48
+ ];
49
+ }
50
+ template() {
51
+ return `
52
+ <px-container
53
+ padding="none"
54
+ border-radius="main"
55
+ background-color="container-default"
56
+ >
57
+ <px-stack class="card-inner" direction="column" gap="none" align-items="stretch">
58
+ <div class="media-wrapper">
59
+ <img class="media-image" alt="" />
60
+ </div>
61
+ <px-vstack class="content" gap="s">
62
+ <slot name="heading"></slot>
63
+ <slot></slot>
64
+ <slot name="actions"></slot>
65
+ </px-vstack>
66
+ </px-stack>
67
+ </px-container>
68
+ `;
69
+ }
70
+ connectedCallback() {
71
+ this.hasAttribute("media-position") || this.setAttribute("media-position", "none"), this.hasAttribute("padding") || this.setAttribute("padding", "s"), this.hasAttribute("media-size") || this.setAttribute("media-size", "cover"), i(this, e, d).call(this), i(this, e, c).call(this);
72
+ }
73
+ disconnectedCallback() {
74
+ }
75
+ attributeChangedCallback(t, s, n) {
76
+ var m;
77
+ if (s !== n)
78
+ switch (t) {
79
+ case "src":
80
+ i(this, e, v).call(this, this.$mediaImage, n);
81
+ break;
82
+ case "media-position":
83
+ (m = this.$cardInner) == null || m.setAttribute(
84
+ "direction",
85
+ n === "left" ? "row" : "column"
86
+ );
87
+ break;
88
+ case "media-alt-text":
89
+ n ? (this.$mediaImage.setAttribute("alt", n), this.$mediaImage.removeAttribute("aria-hidden")) : (this.$mediaImage.setAttribute("alt", ""), this.$mediaImage.setAttribute("aria-hidden", "true"));
90
+ break;
91
+ case "aspect-ratio":
92
+ i(this, e, A).call(this, n);
93
+ break;
94
+ case "background-image":
95
+ n ? (this.$container.setAttribute("background-image", n), this.$container.setAttribute("background-size", "cover")) : (this.$container.removeAttribute("background-image"), this.$container.removeAttribute("background-size"));
96
+ break;
97
+ case "background-color":
98
+ i(this, e, d).call(this);
99
+ break;
100
+ case "has-border":
101
+ i(this, e, c).call(this);
102
+ break;
103
+ case "interactive-state":
104
+ i(this, e, p).call(this);
105
+ break;
106
+ case "inverted":
107
+ n !== null ? this.$container.setAttribute("inverted", "") : this.$container.removeAttribute("inverted"), i(this, e, x).call(this), i(this, e, d).call(this);
108
+ break;
109
+ }
110
+ }
111
+ /* ─── Refs ───────────────────────────────────────────────── */
112
+ get $container() {
113
+ return this.shadowRoot.querySelector("px-container");
114
+ }
115
+ get $cardInner() {
116
+ return this.shadowRoot.querySelector(".card-inner");
117
+ }
118
+ get $mediaWrapper() {
119
+ return this.shadowRoot.querySelector(".media-wrapper");
120
+ }
121
+ get $mediaImage() {
122
+ return this.shadowRoot.querySelector(".media-image");
123
+ }
124
+ /* ─── Reflected props ────────────────────────────────────── */
125
+ get inverted() {
126
+ return this.hasAttribute("inverted");
127
+ }
128
+ set inverted(t) {
129
+ this.toggleAttribute("inverted", !!t);
130
+ }
131
+ get src() {
132
+ return this.getAttribute("src");
133
+ }
134
+ set src(t) {
135
+ i(this, e, o).call(this, "src", t);
136
+ }
137
+ get mediaPosition() {
138
+ return this.getAttribute("media-position") || "none";
139
+ }
140
+ set mediaPosition(t) {
141
+ i(this, e, o).call(this, "media-position", t);
142
+ }
143
+ get mediaSize() {
144
+ return this.getAttribute("media-size") || "cover";
145
+ }
146
+ set mediaSize(t) {
147
+ i(this, e, o).call(this, "media-size", t);
148
+ }
149
+ get mediaAltText() {
150
+ return this.getAttribute("media-alt-text");
151
+ }
152
+ set mediaAltText(t) {
153
+ i(this, e, o).call(this, "media-alt-text", t);
154
+ }
155
+ get padding() {
156
+ return this.getAttribute("padding") || "s";
157
+ }
158
+ set padding(t) {
159
+ i(this, e, o).call(this, "padding", t);
160
+ }
161
+ get aspectRatio() {
162
+ return this.getAttribute("aspect-ratio");
163
+ }
164
+ set aspectRatio(t) {
165
+ i(this, e, o).call(this, "aspect-ratio", t);
166
+ }
167
+ get hasBorder() {
168
+ return this.hasAttribute("has-border");
169
+ }
170
+ set hasBorder(t) {
171
+ t && this.setAttribute("has-border", "");
172
+ }
173
+ get backgroundColor() {
174
+ return this.getAttribute(
175
+ "background-color"
176
+ );
177
+ }
178
+ set backgroundColor(t) {
179
+ i(this, e, o).call(this, "background-color", t);
180
+ }
181
+ get backgroundImage() {
182
+ return this.getAttribute("background-image");
183
+ }
184
+ set backgroundImage(t) {
185
+ i(this, e, o).call(this, "background-image", t);
186
+ }
187
+ get interactiveState() {
188
+ return this.getAttribute("interactive-state");
189
+ }
190
+ set interactiveState(t) {
191
+ i(this, e, o).call(this, "interactive-state", t);
192
+ }
193
+ }
194
+ e = new WeakSet(), /* ─── Helpers ─────────────────────────────────────────────── */
195
+ v = function(t, s) {
196
+ s ? t.setAttribute("src", s) : t.removeAttribute("src");
197
+ }, A = function(t) {
198
+ if (!t || t === "auto") {
199
+ this.$mediaWrapper.style.removeProperty("aspect-ratio");
200
+ return;
201
+ }
202
+ const s = t.replace(":", "/").replace(/\s+/g, "");
203
+ this.$mediaWrapper.style.aspectRatio = s.replace("/", " / ");
204
+ }, d = function() {
205
+ if (this.$container) {
206
+ if (i(this, e, u).call(this)) {
207
+ i(this, e, p).call(this);
208
+ return;
209
+ }
210
+ i(this, e, h).call(this);
211
+ }
212
+ }, c = function() {
213
+ this.$container && (i(this, e, u).call(this) || i(this, e, l).call(this));
214
+ }, h = function() {
215
+ const t = this.backgroundColor, s = t || (this.inverted ? "container-strong" : "container-default");
216
+ this.$container.setAttribute("background-color", s);
217
+ }, l = function() {
218
+ this.hasBorder ? (this.$container.setAttribute("border", "s"), this.$container.setAttribute("border-color", "main")) : this.$container.setAttribute("border", "none");
219
+ }, p = function() {
220
+ if (this.$container) {
221
+ if (this.interactiveState === "hover") {
222
+ this.$container.setAttribute("border", "m"), this.$container.setAttribute("border-color", "state-hover"), this.$container.setAttribute("background-color", "state-hover-bordered");
223
+ return;
224
+ }
225
+ i(this, e, l).call(this), i(this, e, h).call(this);
226
+ }
227
+ }, u = function() {
228
+ return this.interactiveState === "hover";
229
+ }, x = function() {
230
+ const t = this.inverted;
231
+ this.querySelectorAll(":scope > *").forEach((s) => {
232
+ t && !s.hasAttribute("inverted") && s.setAttribute("inverted", "");
233
+ });
234
+ }, o = function(t, s) {
235
+ s ? this.setAttribute(t, s) : this.removeAttribute(t);
236
+ };
237
+ customElements.get("px-card-container") || customElements.define("px-card-container", I);
238
+ const B = ":host{display:block}:host(:not(:has(::slotted(*)))){display:none}", S = new CSSStyleSheet();
239
+ S.replaceSync(B);
240
+ class E extends HTMLElement {
241
+ template() {
242
+ return `
243
+ <px-vstack gap="2xs" align-items="flex-start">
244
+ <slot></slot>
245
+ </px-vstack>
246
+ `;
247
+ }
248
+ constructor() {
249
+ super(), this.attachShadow({ mode: "open" }), this.shadowRoot.adoptedStyleSheets = [S], this.shadowRoot.innerHTML = this.template();
250
+ }
251
+ }
252
+ customElements.get("px-card-heading") || customElements.define("px-card-heading", E);
253
+ const T = ":host{display:block}:host(:not(:has(::slotted(*)))){display:none}", f = new CSSStyleSheet();
254
+ f.replaceSync(T);
255
+ class M extends HTMLElement {
256
+ template() {
257
+ return `
258
+ <px-hstack gap="xs" justify-content="flex-end">
259
+ <px-hstack class="actions-buttons" gap="s" align-items="center" grow="1">
260
+ <slot></slot>
261
+ </px-hstack>
262
+ <slot name="more-action"></slot>
263
+ </px-hstack>
264
+ `;
265
+ }
266
+ constructor() {
267
+ super(), this.attachShadow({ mode: "open" }), this.shadowRoot.adoptedStyleSheets = [f], this.shadowRoot.innerHTML = this.template();
268
+ }
269
+ }
270
+ customElements.get("px-card-actions") || customElements.define("px-card-actions", M);
271
+ export {
272
+ M as CardActions,
273
+ I as CardContainer,
274
+ E as CardHeading,
275
+ D as cardContainerBackgroundColorValues,
276
+ j as cardContainerMediaPositionValues,
277
+ W as cardContainerMediaSizeValues
278
+ };
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@proximus/lavender-poke-card",
3
+ "version": "1.4.7-beta.2",
4
+ "description": "PokeCard web components: px-card-container, px-card-heading, px-card-actions",
5
+ "main": "dist/index.es.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "type": "module",
11
+ "scripts": {
12
+ "transform-package-json": "node ../../../scripts/tranformPackageJson.js package.json dist/far/away",
13
+ "clean": "rm -rf dist",
14
+ "build": "npm run clean && NODE_ENV=development vite build && tsc && npm run transform-package-json && npm run wc-manifest",
15
+ "test": "vitest run --coverage",
16
+ "wc-manifest": "cem analyze --globs \"src/*\" --config ../../custom-elements-manifest.config.js --outdir dist"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "dependencies": {
22
+ "@proximus/lavender-container": "*",
23
+ "@proximus/lavender-layout": "*"
24
+ },
25
+ "customElements": "dist/custom-elements.json",
26
+ "web-types": "./dist/web-types.json"
27
+ }