@justeattakeaway/pie-thumbnail 0.8.37 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/custom-elements.json +9 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +165 -108
- package/dist/react.d.ts +3 -1
- package/package.json +5 -4
- package/src/defs.ts +2 -1
- package/src/index.ts +10 -2
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ Ideally, you should install the component using the **`@justeattakeaway/pie-webc
|
|
|
38
38
|
| `backgroundColor` | `"default"`, `"subtle"`, `"strong"`, `"dark"`, `"inverse"`, `"inverse-alternative"` | Sets the background color of the thumbnail container. | `"default"` |
|
|
39
39
|
| `size` | A number between 24 and 128, in multiples of 8 | Sets the size of the thumbnail. | `48` |
|
|
40
40
|
| `aspectRatio` | `"1by1"`, `"4by3"`, `"16by9"` | Sets the aspect-ratio of the thumbnail image. | `"1by1"` |
|
|
41
|
-
| `disabled` | `true`, `false` | When true, the disabled styles are applied.
|
|
41
|
+
| `disabled` | `true`, `false` | When true, the disabled styles are applied. Also applied automatically when the thumbnail is inside a disabled `pie-radio-group` or `pie-checkbox-group`. | `false` |
|
|
42
42
|
| `hasPadding` | `true`, `false` | When true, extra spacing around the thumbnail container is applied. | `false` |
|
|
43
43
|
| `hideDefaultPlaceholder` | `true`, `false` | When true, hides the component default placeholder on image load failure. | `false` |
|
|
44
44
|
| `placeholder` | `{ src?: string, alt?: string }` | Overrides the component default placeholder with a custom one on image load failure. | `{}` |
|
package/custom-elements.json
CHANGED
|
@@ -181,6 +181,15 @@
|
|
|
181
181
|
"privacy": "public",
|
|
182
182
|
"attribute": "placeholder"
|
|
183
183
|
},
|
|
184
|
+
{
|
|
185
|
+
"kind": "field",
|
|
186
|
+
"name": "_parentDisabled",
|
|
187
|
+
"type": {
|
|
188
|
+
"text": "boolean"
|
|
189
|
+
},
|
|
190
|
+
"privacy": "private",
|
|
191
|
+
"default": "false"
|
|
192
|
+
},
|
|
184
193
|
{
|
|
185
194
|
"kind": "field",
|
|
186
195
|
"name": "img",
|
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare class PieThumbnail extends PieElement implements ThumbnailProps {
|
|
|
27
27
|
hideDefaultPlaceholder: boolean;
|
|
28
28
|
backgroundColor: "default" | "subtle" | "strong" | "dark" | "inverse" | "inverse-alternative";
|
|
29
29
|
placeholder: ThumbnailProps['placeholder'];
|
|
30
|
+
private _parentDisabled;
|
|
30
31
|
private img;
|
|
31
32
|
private _hasError;
|
|
32
33
|
/**
|
|
@@ -85,7 +86,8 @@ export declare interface ThumbnailProps {
|
|
|
85
86
|
*/
|
|
86
87
|
alt?: string;
|
|
87
88
|
/**
|
|
88
|
-
* When true, the disabled styles are applied.
|
|
89
|
+
* When true, the disabled styles are applied. Also applied automatically when the thumbnail is
|
|
90
|
+
* inside a disabled `pie-radio-group` or `pie-checkbox-group`.
|
|
89
91
|
*/
|
|
90
92
|
disabled?: boolean;
|
|
91
93
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,35 +1,88 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import { validPropertyValues as u, safeCustomElement as
|
|
3
|
-
import { classMap as
|
|
4
|
-
import { property as
|
|
5
|
-
const
|
|
1
|
+
import { LitElement as x, unsafeCSS as P, html as S } from "lit";
|
|
2
|
+
import { validPropertyValues as u, safeCustomElement as z, parentDisabledContext as E } from "@justeattakeaway/pie-webc-core";
|
|
3
|
+
import { classMap as D } from "lit/directives/class-map.js";
|
|
4
|
+
import { property as n, state as f, query as C } from "lit/decorators.js";
|
|
5
|
+
const d = class d extends x {
|
|
6
6
|
willUpdate() {
|
|
7
|
-
this.getAttribute("v") || this.setAttribute("v",
|
|
7
|
+
this.getAttribute("v") || this.setAttribute("v", d.v);
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
let
|
|
12
|
-
|
|
10
|
+
d.v = "0.9.0";
|
|
11
|
+
let p = d;
|
|
12
|
+
/**
|
|
13
|
+
* @license
|
|
14
|
+
* Copyright 2021 Google LLC
|
|
15
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
16
|
+
*/
|
|
17
|
+
let I = class extends Event {
|
|
18
|
+
constructor(t, a, s, i) {
|
|
19
|
+
super("context-request", { bubbles: !0, composed: !0 }), this.context = t, this.contextTarget = a, this.callback = s, this.subscribe = i ?? !1;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* @license
|
|
24
|
+
* Copyright 2021 Google LLC
|
|
25
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
26
|
+
*/
|
|
27
|
+
class m {
|
|
28
|
+
constructor(t, a, s, i) {
|
|
29
|
+
if (this.subscribe = !1, this.provided = !1, this.value = void 0, this.t = (l, h) => {
|
|
30
|
+
this.unsubscribe && (this.unsubscribe !== h && (this.provided = !1, this.unsubscribe()), this.subscribe || this.unsubscribe()), this.value = l, this.host.requestUpdate(), this.provided && !this.subscribe || (this.provided = !0, this.callback && this.callback(l, h)), this.unsubscribe = h;
|
|
31
|
+
}, this.host = t, a.context !== void 0) {
|
|
32
|
+
const l = a;
|
|
33
|
+
this.context = l.context, this.callback = l.callback, this.subscribe = l.subscribe ?? !1;
|
|
34
|
+
} else this.context = a, this.callback = s, this.subscribe = i ?? !1;
|
|
35
|
+
this.host.addController(this);
|
|
36
|
+
}
|
|
37
|
+
hostConnected() {
|
|
38
|
+
this.dispatchRequest();
|
|
39
|
+
}
|
|
40
|
+
hostDisconnected() {
|
|
41
|
+
this.unsubscribe && (this.unsubscribe(), this.unsubscribe = void 0);
|
|
42
|
+
}
|
|
43
|
+
dispatchRequest() {
|
|
44
|
+
this.host.dispatchEvent(new I(this.context, this.host, this.t, this.subscribe));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @license
|
|
49
|
+
* Copyright 2022 Google LLC
|
|
50
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
51
|
+
*/
|
|
52
|
+
function w({ context: e, subscribe: t }) {
|
|
53
|
+
return (a, s) => {
|
|
54
|
+
typeof s == "object" ? s.addInitializer((function() {
|
|
55
|
+
new m(this, { context: e, callback: (i) => {
|
|
56
|
+
a.set.call(this, i);
|
|
57
|
+
}, subscribe: t });
|
|
58
|
+
})) : a.constructor.addInitializer(((i) => {
|
|
59
|
+
new m(i, { context: e, callback: (l) => {
|
|
60
|
+
i[s] = l;
|
|
61
|
+
}, subscribe: t });
|
|
62
|
+
}));
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const R = [
|
|
13
66
|
"default",
|
|
14
67
|
"outline"
|
|
15
|
-
],
|
|
68
|
+
], $ = [
|
|
16
69
|
"default",
|
|
17
70
|
"subtle",
|
|
18
71
|
"strong",
|
|
19
72
|
"dark",
|
|
20
73
|
"inverse",
|
|
21
74
|
"inverse-alternative"
|
|
22
|
-
],
|
|
75
|
+
], j = {
|
|
23
76
|
default: "c-thumbnail--backgroundDefault",
|
|
24
77
|
subtle: "c-thumbnail--backgroundSubtle",
|
|
25
78
|
strong: "c-thumbnail--backgroundStrong",
|
|
26
79
|
dark: "c-thumbnail--backgroundDark",
|
|
27
80
|
inverse: "c-thumbnail--backgroundInverse",
|
|
28
81
|
"inverse-alternative": "c-thumbnail--backgroundInverseAlternative"
|
|
29
|
-
},
|
|
30
|
-
{ length: (
|
|
31
|
-
(
|
|
32
|
-
)),
|
|
82
|
+
}, A = ["1by1", "4by3", "16by9"], g = 8, v = 24, O = 128, q = Object.freeze(Array.from(
|
|
83
|
+
{ length: (O - v) / g + 1 },
|
|
84
|
+
(e, t) => v + t * g
|
|
85
|
+
)), c = {
|
|
33
86
|
variant: "default",
|
|
34
87
|
size: 48,
|
|
35
88
|
src: "",
|
|
@@ -43,23 +96,23 @@ const D = [
|
|
|
43
96
|
src: "",
|
|
44
97
|
alt: ""
|
|
45
98
|
}
|
|
46
|
-
},
|
|
47
|
-
var
|
|
48
|
-
for (var
|
|
49
|
-
(
|
|
50
|
-
return
|
|
99
|
+
}, B = ":host{display:block}.c-thumbnail{--thumbnail-size: 48px;--thumbnail-border-radius: var(--dt-radius-rounded-b);--thumbnail-bg-color: var(--dt-color-container-default);--thumbnail-padding: calc(var(--dt-spacing-a) / 2);--thumbnail-default-placeholder-padding: var(--dt-spacing-b);--thumbnail-img-border-radius: unset;--thumbnail-img-object-fit: cover;display:flex;justify-content:center;align-items:center;box-sizing:border-box;overflow:hidden;width:var(--thumbnail-size);height:var(--thumbnail-size);border-radius:var(--thumbnail-border-radius);background-color:var(--thumbnail-bg-color)}.c-thumbnail.c-thumbnail--outline{border:1px solid var(--dt-color-border-default)}.c-thumbnail.is-disabled{opacity:.5}.c-thumbnail.c-thumbnail--backgroundSubtle{--thumbnail-bg-color: var(--dt-color-container-subtle)}.c-thumbnail.c-thumbnail--backgroundStrong{--thumbnail-bg-color: var(--dt-color-container-strong)}.c-thumbnail.c-thumbnail--backgroundDark{--thumbnail-bg-color: var(--dt-color-container-dark)}.c-thumbnail.c-thumbnail--backgroundInverse{--thumbnail-bg-color: var(--dt-color-container-inverse)}.c-thumbnail.c-thumbnail--backgroundInverseAlternative{--thumbnail-bg-color: var(--dt-color-container-inverse-alternative)}.c-thumbnail.c-thumbnail--padding{--thumbnail-img-border-radius: calc(var(--thumbnail-border-radius) - var(--thumbnail-padding));padding:var(--thumbnail-padding)}.c-thumbnail.c-thumbnail--4by3{height:calc(var(--thumbnail-size) * 3 / 4)}.c-thumbnail.c-thumbnail--16by9{height:calc(var(--thumbnail-size) * 9 / 16)}.c-thumbnail .c-thumbnail-img{width:100%;height:100%;border-radius:var(--thumbnail-img-border-radius);object-fit:var(--thumbnail-img-object-fit)}.c-thumbnail.is-defaultPlaceholder{--thumbnail-bg-color: var(--dt-color-container-default);--thumbnail-img-object-fit: fill;padding:var(--thumbnail-default-placeholder-padding)}", M = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20fill='none'%20viewBox='0%200%2033%2032'%3e%3cpath%20d='M32.399%2015.493c-.102-.255-1.495-2.753-4.081-5.888a.507.507%200%200%201-.119-.267%2048.162%2048.162%200%200%200-.778-5.436.88.88%200%200%200-.282-.467.928.928%200%200%200-.509-.221l-2.679-.323a.84.84%200%200%200-.071%200c-.15%200-.294.058-.401.161s-.166.243-.166.389v.906c0%20.009-.004.017-.011.023s-.015.01-.025.01c-.015-.003-.018-.006-.021-.008A37.89%2037.89%200%200%200%2017.829.395%202.43%202.43%200%200%200%2016.493%200c-.473%200-.936.138-1.328.395C5.887%205.956.782%2015.005.585%2015.493a.87.87%200%200%200%20.004.757.9.9%200%200%200%20.246.306.93.93%200%200%200%20.356.176l2.672.5c.177.047.335.144.454.279s.193.302.213.479c.023.457.527%2010.691%201.162%2013.345a.89.89%200%200%200%20.328.479c.161.12.358.186.561.185h.02l4.528-.084h.129c.079-.001.155-.032.211-.086s.087-.128.087-.205l-.306-5.093c0-.054-.007-.121-.01-.176a.54.54%200%200%200-.08-.254.56.56%200%200%200-.193-.188c-.407-.236-.747-.566-.992-.96s-.385-.841-.41-1.3c-.142-3.589-.211-7.735-.008-10.981.003-.138.062-.27.165-.366a.545.545%200%200%201%20.76.016c.099.1.152.234.149.372v.041c-.132%202.163-.142%204.72-.095%207.244a.61.61%200%200%200%20.195.435.65.65%200%200%200%20.454.174.65.65%200%200%200%20.448-.189.61.61%200%200%200%20.179-.441c-.048-2.54-.035-5.114.099-7.285.003-.138.062-.27.165-.366a.545.545%200%200%201%20.76.016c.099.1.152.234.149.372v.041c-.132%202.152-.142%204.694-.096%207.204a.61.61%200%200%200%20.194.435.65.65%200%200%200%20.454.175.65.65%200%200%200%20.448-.188.61.61%200%200%200%20.18-.441c-.047-2.529-.034-5.093.101-7.249.003-.138.063-.27.165-.366s.241-.148.383-.145.278.061.377.161.152.234.149.372v.041c-.193%203.154-.13%207.147%200%2010.651a.26.26%200%200%201%200%20.033v.086c0%20.455-.113.902-.331%201.305s-.533.747-.919%201.004a.54.54%200%200%200-.166.177.52.52%200%200%200-.07.229s-.067.538.179%203.144l.241%202.284c.009.067.043.128.095.172s.119.068.188.068h4.053l1.516.012c.07%200%20.137-.024.189-.069s.086-.107.094-.174c.35-3.123.434-4.879.434-4.879-.002-.075-.032-.146-.084-.201s-.123-.09-.199-.099l-1.843-.246c-.122-.015-.238-.064-.331-.142s-.161-.181-.195-.297a.83.83%200%200%201-.024-.275c.747-10.411%204.282-13.92%204.282-13.92a1.05%201.05%200%200%201%20.172-.144.575.575%200%200%201%20.491-.082.57.57%200%200%201%20.223.122.55.55%200%200%201%20.145.205.97.97%200%200%201%20.045.251c.306%203.272.157%208.842-.033%2013.186l-.353%206.583c0%20.057.023.112.065.152s.098.063.156.063l3.037.062h.021a.94.94%200%200%200%20.561-.186.892.892%200%200%200%20.328-.479c.635-2.654%201.134-12.887%201.161-13.344a.877.877%200%200%201%20.214-.479.92.92%200%200%201%20.453-.28l2.672-.5a.92.92%200%200%200%20.499-.317.873.873%200%200%200%20.194-.548.885.885%200%200%200-.101-.368z'%20fill='%23efedea'/%3e%3c/svg%3e";
|
|
100
|
+
var N = Object.defineProperty, T = Object.getOwnPropertyDescriptor, o = (e, t, a, s) => {
|
|
101
|
+
for (var i = s > 1 ? void 0 : s ? T(t, a) : t, l = e.length - 1, h; l >= 0; l--)
|
|
102
|
+
(h = e[l]) && (i = (s ? h(t, a, i) : h(i)) || i);
|
|
103
|
+
return s && i && N(t, a, i), i;
|
|
51
104
|
};
|
|
52
105
|
const b = "pie-thumbnail";
|
|
53
|
-
let
|
|
106
|
+
let r = class extends p {
|
|
54
107
|
constructor() {
|
|
55
|
-
super(...arguments), this.variant =
|
|
108
|
+
super(...arguments), this.variant = c.variant, this.size = c.size, this.aspectRatio = c.aspectRatio, this.src = c.src, this.alt = c.alt, this.disabled = c.disabled, this.hasPadding = c.hasPadding, this.hideDefaultPlaceholder = c.hideDefaultPlaceholder, this.backgroundColor = c.backgroundColor, this.placeholder = c.placeholder, this._parentDisabled = !1, this._hasError = !1;
|
|
56
109
|
}
|
|
57
110
|
/**
|
|
58
111
|
* Determines if the default placeholder should be displayed.
|
|
59
112
|
*/
|
|
60
113
|
get _isDefaultPlaceholderVisible() {
|
|
61
|
-
const { _hasError:
|
|
62
|
-
return
|
|
114
|
+
const { _hasError: e, placeholder: t, hideDefaultPlaceholder: a } = this;
|
|
115
|
+
return e && !(t != null && t.src) && !a;
|
|
63
116
|
}
|
|
64
117
|
/**
|
|
65
118
|
* Returns the appropriate image props based on the following order:
|
|
@@ -69,23 +122,23 @@ let e = class extends m {
|
|
|
69
122
|
* 4. Otherwise, fall back to the provided src (resulting in a broken image).
|
|
70
123
|
*/
|
|
71
124
|
get _controlledSrc() {
|
|
72
|
-
var
|
|
73
|
-
return this._hasError ? (
|
|
125
|
+
var e;
|
|
126
|
+
return this._hasError ? (e = this.placeholder) != null && e.src ? this.placeholder.src : this.hideDefaultPlaceholder ? this.src : M : this.src;
|
|
74
127
|
}
|
|
75
128
|
get _controlledAlt() {
|
|
76
|
-
var
|
|
77
|
-
return this._hasError ? (
|
|
129
|
+
var e;
|
|
130
|
+
return this._hasError ? (e = this.placeholder) != null && e.src ? this.placeholder.alt ?? "" : this.hideDefaultPlaceholder ? this.alt : "" : this.alt;
|
|
78
131
|
}
|
|
79
132
|
/**
|
|
80
133
|
* Assigns CSS variables based on the size prop.
|
|
81
134
|
*/
|
|
82
135
|
_generateSizeStyles() {
|
|
83
|
-
const { size:
|
|
84
|
-
let
|
|
85
|
-
return
|
|
86
|
-
--thumbnail-size: ${
|
|
87
|
-
--thumbnail-border-radius: var(${
|
|
88
|
-
--thumbnail-default-placeholder-padding: var(${
|
|
136
|
+
const { size: e } = this;
|
|
137
|
+
let t = "--dt-radius-rounded-c", a = "--dt-spacing-d";
|
|
138
|
+
return e <= 40 ? (t = "--dt-radius-rounded-a", a = "--dt-spacing-a") : e <= 56 && (t = "--dt-radius-rounded-b", a = "--dt-spacing-b"), `
|
|
139
|
+
--thumbnail-size: ${e}px;
|
|
140
|
+
--thumbnail-border-radius: var(${t});
|
|
141
|
+
--thumbnail-default-placeholder-padding: var(${a});
|
|
89
142
|
`;
|
|
90
143
|
}
|
|
91
144
|
/**
|
|
@@ -100,8 +153,8 @@ let e = class extends m {
|
|
|
100
153
|
*/
|
|
101
154
|
_checkImageError() {
|
|
102
155
|
if (this.img) {
|
|
103
|
-
const { complete:
|
|
104
|
-
|
|
156
|
+
const { complete: e, naturalHeight: t } = this.img;
|
|
157
|
+
e && t === 0 && this._handleImageError.call(this);
|
|
105
158
|
}
|
|
106
159
|
}
|
|
107
160
|
firstUpdated() {
|
|
@@ -109,31 +162,31 @@ let e = class extends m {
|
|
|
109
162
|
}
|
|
110
163
|
render() {
|
|
111
164
|
const {
|
|
112
|
-
variant:
|
|
113
|
-
_controlledSrc:
|
|
114
|
-
_controlledAlt:
|
|
115
|
-
disabled:
|
|
116
|
-
hasPadding:
|
|
117
|
-
_isDefaultPlaceholderVisible:
|
|
118
|
-
backgroundColor:
|
|
119
|
-
aspectRatio:
|
|
120
|
-
} = this,
|
|
165
|
+
variant: e,
|
|
166
|
+
_controlledSrc: t,
|
|
167
|
+
_controlledAlt: a,
|
|
168
|
+
disabled: s,
|
|
169
|
+
hasPadding: i,
|
|
170
|
+
_isDefaultPlaceholderVisible: l,
|
|
171
|
+
backgroundColor: h,
|
|
172
|
+
aspectRatio: y
|
|
173
|
+
} = this, k = {
|
|
121
174
|
"c-thumbnail": !0,
|
|
122
|
-
[`c-thumbnail--${
|
|
123
|
-
[`c-thumbnail--${
|
|
124
|
-
[
|
|
125
|
-
"is-disabled":
|
|
126
|
-
"c-thumbnail--padding":
|
|
127
|
-
"is-defaultPlaceholder":
|
|
128
|
-
},
|
|
129
|
-
return
|
|
175
|
+
[`c-thumbnail--${e}`]: !0,
|
|
176
|
+
[`c-thumbnail--${y}`]: !0,
|
|
177
|
+
[j[h]]: !0,
|
|
178
|
+
"is-disabled": s || this._parentDisabled,
|
|
179
|
+
"c-thumbnail--padding": i,
|
|
180
|
+
"is-defaultPlaceholder": l
|
|
181
|
+
}, _ = this._generateSizeStyles();
|
|
182
|
+
return S`
|
|
130
183
|
<div data-test-id="pie-thumbnail"
|
|
131
|
-
class="${
|
|
132
|
-
style="${
|
|
184
|
+
class="${D(k)}"
|
|
185
|
+
style="${_}">
|
|
133
186
|
<img
|
|
134
187
|
data-test-id="pie-thumbnail-img"
|
|
135
|
-
src="${
|
|
136
|
-
alt="${
|
|
188
|
+
src="${t}"
|
|
189
|
+
alt="${a}"
|
|
137
190
|
class="c-thumbnail-img"
|
|
138
191
|
@error="${this._handleImageError}"
|
|
139
192
|
/>
|
|
@@ -141,56 +194,60 @@ let e = class extends m {
|
|
|
141
194
|
`;
|
|
142
195
|
}
|
|
143
196
|
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
u(b,
|
|
148
|
-
],
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
u(b,
|
|
152
|
-
],
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
u(b,
|
|
156
|
-
],
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
],
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
],
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
],
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
],
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
],
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
u(b,
|
|
175
|
-
],
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
],
|
|
179
|
-
|
|
180
|
-
E
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
197
|
+
r.styles = P(B);
|
|
198
|
+
o([
|
|
199
|
+
n({ type: String }),
|
|
200
|
+
u(b, R, c.variant)
|
|
201
|
+
], r.prototype, "variant", 2);
|
|
202
|
+
o([
|
|
203
|
+
n({ type: Number }),
|
|
204
|
+
u(b, q, c.size)
|
|
205
|
+
], r.prototype, "size", 2);
|
|
206
|
+
o([
|
|
207
|
+
n({ type: String }),
|
|
208
|
+
u(b, A, c.aspectRatio)
|
|
209
|
+
], r.prototype, "aspectRatio", 2);
|
|
210
|
+
o([
|
|
211
|
+
n({ type: String })
|
|
212
|
+
], r.prototype, "src", 2);
|
|
213
|
+
o([
|
|
214
|
+
n({ type: String })
|
|
215
|
+
], r.prototype, "alt", 2);
|
|
216
|
+
o([
|
|
217
|
+
n({ type: Boolean })
|
|
218
|
+
], r.prototype, "disabled", 2);
|
|
219
|
+
o([
|
|
220
|
+
n({ type: Boolean })
|
|
221
|
+
], r.prototype, "hasPadding", 2);
|
|
222
|
+
o([
|
|
223
|
+
n({ type: Boolean })
|
|
224
|
+
], r.prototype, "hideDefaultPlaceholder", 2);
|
|
225
|
+
o([
|
|
226
|
+
n({ type: String }),
|
|
227
|
+
u(b, $, c.backgroundColor)
|
|
228
|
+
], r.prototype, "backgroundColor", 2);
|
|
229
|
+
o([
|
|
230
|
+
n({ type: Object })
|
|
231
|
+
], r.prototype, "placeholder", 2);
|
|
232
|
+
o([
|
|
233
|
+
w({ context: E, subscribe: !0 }),
|
|
234
|
+
f()
|
|
235
|
+
], r.prototype, "_parentDisabled", 2);
|
|
236
|
+
o([
|
|
237
|
+
C("img")
|
|
238
|
+
], r.prototype, "img", 2);
|
|
239
|
+
o([
|
|
240
|
+
f()
|
|
241
|
+
], r.prototype, "_hasError", 2);
|
|
242
|
+
r = o([
|
|
243
|
+
z("pie-thumbnail")
|
|
244
|
+
], r);
|
|
188
245
|
export {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
246
|
+
r as PieThumbnail,
|
|
247
|
+
A as aspectRatios,
|
|
248
|
+
j as backgroundColorClassNames,
|
|
249
|
+
$ as backgroundColors,
|
|
250
|
+
c as defaultProps,
|
|
251
|
+
q as sizes,
|
|
252
|
+
R as variants
|
|
196
253
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ declare class PieThumbnail_2 extends PieElement implements ThumbnailProps {
|
|
|
30
30
|
hideDefaultPlaceholder: boolean;
|
|
31
31
|
backgroundColor: "default" | "subtle" | "strong" | "dark" | "inverse" | "inverse-alternative";
|
|
32
32
|
placeholder: ThumbnailProps['placeholder'];
|
|
33
|
+
private _parentDisabled;
|
|
33
34
|
private img;
|
|
34
35
|
private _hasError;
|
|
35
36
|
/**
|
|
@@ -90,7 +91,8 @@ export declare interface ThumbnailProps {
|
|
|
90
91
|
*/
|
|
91
92
|
alt?: string;
|
|
92
93
|
/**
|
|
93
|
-
* When true, the disabled styles are applied.
|
|
94
|
+
* When true, the disabled styles are applied. Also applied automatically when the thumbnail is
|
|
95
|
+
* inside a disabled `pie-radio-group` or `pie-checkbox-group`.
|
|
94
96
|
*/
|
|
95
97
|
disabled?: boolean;
|
|
96
98
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-thumbnail",
|
|
3
3
|
"description": "PIE Design System Thumbnail built using Web Components",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.9.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/justeattakeaway/pie",
|
|
@@ -42,11 +42,12 @@
|
|
|
42
42
|
"license": "Apache-2.0",
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@justeattakeaway/pie-components-config": "0.21.3",
|
|
45
|
-
"@justeattakeaway/pie-css": "1.
|
|
46
|
-
"@justeattakeaway/pie-monorepo-utils": "0.9.
|
|
45
|
+
"@justeattakeaway/pie-css": "1.5.0",
|
|
46
|
+
"@justeattakeaway/pie-monorepo-utils": "0.9.9"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@justeattakeaway/pie-webc-core": "
|
|
49
|
+
"@justeattakeaway/pie-webc-core": "18.0.0",
|
|
50
|
+
"@lit/context": "1.1.6"
|
|
50
51
|
},
|
|
51
52
|
"customElements": "custom-elements.json",
|
|
52
53
|
"sideEffects": [
|
package/src/defs.ts
CHANGED
|
@@ -51,7 +51,8 @@ export interface ThumbnailProps {
|
|
|
51
51
|
*/
|
|
52
52
|
alt?: string;
|
|
53
53
|
/**
|
|
54
|
-
* When true, the disabled styles are applied.
|
|
54
|
+
* When true, the disabled styles are applied. Also applied automatically when the thumbnail is
|
|
55
|
+
* inside a disabled `pie-radio-group` or `pie-checkbox-group`.
|
|
55
56
|
*/
|
|
56
57
|
disabled?: boolean;
|
|
57
58
|
/**
|
package/src/index.ts
CHANGED
|
@@ -3,9 +3,10 @@ import {
|
|
|
3
3
|
unsafeCSS,
|
|
4
4
|
} from 'lit';
|
|
5
5
|
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
6
|
-
import { safeCustomElement, validPropertyValues } from '@justeattakeaway/pie-webc-core';
|
|
6
|
+
import { safeCustomElement, validPropertyValues, parentDisabledContext } from '@justeattakeaway/pie-webc-core';
|
|
7
7
|
import { classMap } from 'lit/directives/class-map.js';
|
|
8
8
|
import { property, query, state } from 'lit/decorators.js';
|
|
9
|
+
import { consume } from '@lit/context';
|
|
9
10
|
import {
|
|
10
11
|
type ThumbnailProps,
|
|
11
12
|
defaultProps,
|
|
@@ -62,6 +63,13 @@ export class PieThumbnail extends PieElement implements ThumbnailProps {
|
|
|
62
63
|
@property({ type: Object })
|
|
63
64
|
public placeholder: ThumbnailProps['placeholder'] = defaultProps.placeholder;
|
|
64
65
|
|
|
66
|
+
// Whether a disabling ancestor (e.g. `pie-radio-group`) has provided its disabled state, so a
|
|
67
|
+
// thumbnail slotted into a disabled group takes on the disabled styles without the consumer
|
|
68
|
+
// setting `disabled` on it. Defaults to false when there is no provider.
|
|
69
|
+
@consume({ context: parentDisabledContext, subscribe: true })
|
|
70
|
+
@state()
|
|
71
|
+
private _parentDisabled = false;
|
|
72
|
+
|
|
65
73
|
@query('img')
|
|
66
74
|
private img!: HTMLImageElement;
|
|
67
75
|
|
|
@@ -159,7 +167,7 @@ export class PieThumbnail extends PieElement implements ThumbnailProps {
|
|
|
159
167
|
[`c-thumbnail--${variant}`]: true,
|
|
160
168
|
[`c-thumbnail--${aspectRatio}`]: true,
|
|
161
169
|
[backgroundColorClassNames[backgroundColor]]: true,
|
|
162
|
-
'is-disabled': disabled,
|
|
170
|
+
'is-disabled': disabled || this._parentDisabled,
|
|
163
171
|
'c-thumbnail--padding': hasPadding,
|
|
164
172
|
'is-defaultPlaceholder': _isDefaultPlaceholderVisible,
|
|
165
173
|
};
|