@justeattakeaway/pie-card 0.14.2-next.0 → 0.14.3
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/dist/index.js +67 -85
- package/dist/react.js +12 -42
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ import '@justeattakeaway/pie-card';
|
|
|
55
55
|
```js
|
|
56
56
|
// React
|
|
57
57
|
// For React, you will need to import our React-specific component build
|
|
58
|
-
// which wraps the web component using
|
|
58
|
+
// which wraps the web component using @lit/react
|
|
59
59
|
import { PieCard } from '@justeattakeaway/pie-card/dist/react';
|
|
60
60
|
```
|
|
61
61
|
|
package/dist/index.js
CHANGED
|
@@ -1,33 +1,15 @@
|
|
|
1
|
-
import { unsafeCSS as
|
|
2
|
-
import { property as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
r.includes(b) ? this[i] = b : (console.error(
|
|
11
|
-
`<${t}> Invalid value "${b}" provided for property "${c}".`,
|
|
12
|
-
`Must be one of: ${r.join(" | ")}.`,
|
|
13
|
-
`Falling back to default value: "${a}"`
|
|
14
|
-
), this[i] = a);
|
|
15
|
-
},
|
|
16
|
-
configurable: !0
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
function m(t, r) {
|
|
20
|
-
customElements.get(t) ? console.warn(`PIE Web Component: "${t}" has already been defined. Please ensure the component is only being defined once in your application.`) : customElements.define(t, r);
|
|
21
|
-
}
|
|
22
|
-
const $ = `.c-card[isdraggable]{cursor:grab}.c-card[isdraggable]:active{cursor:grabbing}*,*:before,*:after{box-sizing:border-box}.c-card{--card-bg-color: var(--dt-color-container-default);--card-color: var(--dt-color-content-default);--card-radius: var(--dt-radius-rounded-c);--card-border-color: transparent;display:block;position:relative;color:var(--card-color);background-color:var(--card-bg-color);border:1px solid var(--card-border-color);border-radius:var(--card-radius);cursor:pointer;user-select:none;outline:none;text-decoration:none}.c-card[variant=default]{box-shadow:var(--dt-elevation-card)}.c-card[variant=default]:hover:not([disabled]){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--card-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + var(--hover-modifier)))}.c-card[variant=default]:active:not([disabled]){--active-modifier: calc(-1 * var(--dt-color-active-01));--card-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + var(--active-modifier)))}.c-card[variant=outline]{border-color:var(--dt-color-border-strong)}.c-card[variant=outline]:hover:not([disabled]){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--card-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + var(--hover-modifier)))}.c-card[variant=outline]:active:not([disabled]){--active-modifier: calc(-1 * var(--dt-color-active-01));--card-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + var(--active-modifier)))}.c-card[variant=inverse]{--card-bg-color: var(--dt-color-container-dark);--card-color: var(--dt-color-content-inverse);box-shadow:var(--dt-elevation-dark-card)}.c-card[variant=inverse]:hover:not([disabled]){--hover-modifier: var(--dt-color-hover-01);--card-bg-color: hsl(var(--dt-color-container-dark-h), var(--dt-color-container-dark-s), calc(var(--dt-color-container-dark-l) + var(--hover-modifier)))}.c-card[variant=inverse]:active:not([disabled]){--active-modifier: var(--dt-color-active-01);--card-bg-color: hsl(var(--dt-color-container-dark-h), var(--dt-color-container-dark-s), calc(var(--dt-color-container-dark-l) + var(--active-modifier)))}.c-card[variant=outline-inverse]{--card-bg-color: var(--dt-color-container-dark);--card-color: var(--dt-color-content-inverse);border-color:var(--dt-color-border-inverse)}.c-card[variant=outline-inverse]:hover:not([disabled]){--hover-modifier: var(--dt-color-hover-01);--card-bg-color: hsl(var(--dt-color-container-dark-h), var(--dt-color-container-dark-s), calc(var(--dt-color-container-dark-l) + var(--hover-modifier)))}.c-card[variant=outline-inverse]:active:not([disabled]){--active-modifier: var(--dt-color-active-01);--card-bg-color: hsl(var(--dt-color-container-dark-h), var(--dt-color-container-dark-s), calc(var(--dt-color-container-dark-l) + var(--active-modifier)))}.c-card[disabled]{--card-bg-color: var(--dt-color-disabled-01);cursor:not-allowed}.c-card[disabled] ::slotted(*){color:var(--dt-color-content-disabled)}.c-card[disabled] img{opacity:.5}.c-card[disabled][variant=inverse],.c-card[disabled][variant=outline-inverse]{--card-bg-color: var(--dt-color-disabled-01-inverse)}.c-card:focus-visible{box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer);outline:none}
|
|
23
|
-
`, y = ["default", "outline", "inverse", "outline-inverse"], S = ["a", "button"], f = ["a", "b", "c", "d", "e", "f", "g"], k = f.flatMap((t) => [t, ...f.map((r) => `${t},${r}`)]);
|
|
24
|
-
var P = Object.defineProperty, x = Object.getOwnPropertyDescriptor, l = (t, r, a, o) => {
|
|
25
|
-
for (var e = o > 1 ? void 0 : o ? x(r, a) : r, c = t.length - 1, i; c >= 0; c--)
|
|
26
|
-
(i = t[c]) && (e = (o ? i(r, a, e) : i(e)) || e);
|
|
27
|
-
return o && e && P(r, a, e), e;
|
|
1
|
+
import { unsafeCSS as f, LitElement as p, html as g, nothing as i } from "lit";
|
|
2
|
+
import { property as d } from "lit/decorators.js";
|
|
3
|
+
import { validPropertyValues as b, defineCustomElement as h } from "@justeattakeaway/pie-webc-core";
|
|
4
|
+
const m = `.c-card[isdraggable]{cursor:grab}.c-card[isdraggable]:active{cursor:grabbing}*,*:before,*:after{box-sizing:border-box}.c-card{--card-bg-color: var(--dt-color-container-default);--card-color: var(--dt-color-content-default);--card-radius: var(--dt-radius-rounded-c);--card-border-color: transparent;display:block;position:relative;color:var(--card-color);background-color:var(--card-bg-color);border:1px solid var(--card-border-color);border-radius:var(--card-radius);cursor:pointer;user-select:none;outline:none;text-decoration:none}.c-card[variant=default]{box-shadow:var(--dt-elevation-card)}.c-card[variant=default]:hover:not([disabled]){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--card-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + var(--hover-modifier)))}.c-card[variant=default]:active:not([disabled]){--active-modifier: calc(-1 * var(--dt-color-active-01));--card-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + var(--active-modifier)))}.c-card[variant=outline]{border-color:var(--dt-color-border-strong)}.c-card[variant=outline]:hover:not([disabled]){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--card-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + var(--hover-modifier)))}.c-card[variant=outline]:active:not([disabled]){--active-modifier: calc(-1 * var(--dt-color-active-01));--card-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), calc(var(--dt-color-container-default-l) + var(--active-modifier)))}.c-card[variant=inverse]{--card-bg-color: var(--dt-color-container-dark);--card-color: var(--dt-color-content-inverse);box-shadow:var(--dt-elevation-dark-card)}.c-card[variant=inverse]:hover:not([disabled]){--hover-modifier: var(--dt-color-hover-01);--card-bg-color: hsl(var(--dt-color-container-dark-h), var(--dt-color-container-dark-s), calc(var(--dt-color-container-dark-l) + var(--hover-modifier)))}.c-card[variant=inverse]:active:not([disabled]){--active-modifier: var(--dt-color-active-01);--card-bg-color: hsl(var(--dt-color-container-dark-h), var(--dt-color-container-dark-s), calc(var(--dt-color-container-dark-l) + var(--active-modifier)))}.c-card[variant=outline-inverse]{--card-bg-color: var(--dt-color-container-dark);--card-color: var(--dt-color-content-inverse);border-color:var(--dt-color-border-inverse)}.c-card[variant=outline-inverse]:hover:not([disabled]){--hover-modifier: var(--dt-color-hover-01);--card-bg-color: hsl(var(--dt-color-container-dark-h), var(--dt-color-container-dark-s), calc(var(--dt-color-container-dark-l) + var(--hover-modifier)))}.c-card[variant=outline-inverse]:active:not([disabled]){--active-modifier: var(--dt-color-active-01);--card-bg-color: hsl(var(--dt-color-container-dark-h), var(--dt-color-container-dark-s), calc(var(--dt-color-container-dark-l) + var(--active-modifier)))}.c-card[disabled]{--card-bg-color: var(--dt-color-disabled-01);cursor:not-allowed}.c-card[disabled] ::slotted(*){color:var(--dt-color-content-disabled)}.c-card[disabled] img{opacity:.5}.c-card[disabled][variant=inverse],.c-card[disabled][variant=outline-inverse]{--card-bg-color: var(--dt-color-disabled-01-inverse)}.c-card:focus-visible{box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer);outline:none}
|
|
5
|
+
`, y = ["default", "outline", "inverse", "outline-inverse"], $ = ["a", "button"], u = ["a", "b", "c", "d", "e", "f", "g"], S = u.flatMap((l) => [l, ...u.map((o) => `${l},${o}`)]);
|
|
6
|
+
var k = Object.defineProperty, x = Object.getOwnPropertyDescriptor, c = (l, o, a, e) => {
|
|
7
|
+
for (var r = e > 1 ? void 0 : e ? x(o, a) : o, n = l.length - 1, s; n >= 0; n--)
|
|
8
|
+
(s = l[n]) && (r = (e ? s(o, a, r) : s(r)) || r);
|
|
9
|
+
return e && r && k(o, a, r), r;
|
|
28
10
|
};
|
|
29
11
|
const v = "pie-card";
|
|
30
|
-
class
|
|
12
|
+
class t extends p {
|
|
31
13
|
constructor() {
|
|
32
14
|
super(...arguments), this.tag = "button", this.variant = "default", this.disabled = !1, this.isDraggable = !1;
|
|
33
15
|
}
|
|
@@ -38,8 +20,8 @@ class d extends h {
|
|
|
38
20
|
*/
|
|
39
21
|
renderAnchor() {
|
|
40
22
|
var a;
|
|
41
|
-
const
|
|
42
|
-
return
|
|
23
|
+
const o = this.generatePaddingCSS();
|
|
24
|
+
return g`
|
|
43
25
|
<a
|
|
44
26
|
class="c-card"
|
|
45
27
|
data-test-id="pie-card"
|
|
@@ -47,13 +29,13 @@ class d extends h {
|
|
|
47
29
|
?isDraggable="${this.isDraggable}"
|
|
48
30
|
variant=${this.variant}
|
|
49
31
|
?disabled=${this.disabled}
|
|
50
|
-
href=${this.href ||
|
|
51
|
-
target=${this.target ||
|
|
52
|
-
rel=${this.rel ||
|
|
32
|
+
href=${this.href || i}
|
|
33
|
+
target=${this.target || i}
|
|
34
|
+
rel=${this.rel || i}
|
|
53
35
|
role="link"
|
|
54
|
-
aria-label=${((a = this.aria) == null ? void 0 : a.label) ||
|
|
36
|
+
aria-label=${((a = this.aria) == null ? void 0 : a.label) || i}
|
|
55
37
|
aria-disabled=${this.disabled ? "true" : "false"}
|
|
56
|
-
style=${
|
|
38
|
+
style=${o || i}>
|
|
57
39
|
<slot></slot>
|
|
58
40
|
</div>
|
|
59
41
|
</a>`;
|
|
@@ -69,74 +51,74 @@ class d extends h {
|
|
|
69
51
|
* @private
|
|
70
52
|
*/
|
|
71
53
|
generatePaddingCSS() {
|
|
72
|
-
const { padding:
|
|
54
|
+
const { padding: o } = this;
|
|
73
55
|
let a = "";
|
|
74
|
-
if (!
|
|
56
|
+
if (!o)
|
|
75
57
|
return "";
|
|
76
|
-
const
|
|
77
|
-
return
|
|
58
|
+
const e = o.split(",").map((r) => r.trim()).filter((r) => /^[a-g]$/.test(r));
|
|
59
|
+
return e.length > 0 && e.length <= 2 && (a += `var(--dt-spacing-${e[0]})`, e.length > 1 && (a += ` var(--dt-spacing-${e[1]})`)), a ? `padding: ${a}` : "";
|
|
78
60
|
}
|
|
79
61
|
render() {
|
|
80
62
|
const {
|
|
81
|
-
variant:
|
|
63
|
+
variant: o,
|
|
82
64
|
disabled: a,
|
|
83
|
-
tag:
|
|
84
|
-
aria:
|
|
85
|
-
isDraggable:
|
|
86
|
-
} = this,
|
|
87
|
-
return
|
|
65
|
+
tag: e,
|
|
66
|
+
aria: r,
|
|
67
|
+
isDraggable: n
|
|
68
|
+
} = this, s = this.generatePaddingCSS();
|
|
69
|
+
return e === "a" ? this.renderAnchor() : g`
|
|
88
70
|
<div
|
|
89
71
|
class="c-card"
|
|
90
72
|
data-test-id="pie-card"
|
|
91
|
-
tag=${
|
|
92
|
-
?isDraggable="${
|
|
93
|
-
variant=${
|
|
73
|
+
tag=${e}
|
|
74
|
+
?isDraggable="${n}"
|
|
75
|
+
variant=${o}
|
|
94
76
|
?disabled=${a}
|
|
95
77
|
role="button"
|
|
96
78
|
tabindex="0"
|
|
97
|
-
aria-label=${(
|
|
79
|
+
aria-label=${(r == null ? void 0 : r.label) || i}
|
|
98
80
|
aria-disabled=${a ? "true" : "false"}
|
|
99
|
-
style=${
|
|
81
|
+
style=${s || i}>
|
|
100
82
|
<slot></slot>
|
|
101
83
|
</div>
|
|
102
84
|
</div>`;
|
|
103
85
|
}
|
|
104
86
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
],
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
],
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
],
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
],
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
],
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
],
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
],
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
],
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
],
|
|
136
|
-
|
|
87
|
+
t.styles = f(m);
|
|
88
|
+
c([
|
|
89
|
+
d(),
|
|
90
|
+
b(v, $, "button")
|
|
91
|
+
], t.prototype, "tag", 2);
|
|
92
|
+
c([
|
|
93
|
+
d(),
|
|
94
|
+
b(v, y, "default")
|
|
95
|
+
], t.prototype, "variant", 2);
|
|
96
|
+
c([
|
|
97
|
+
d({ type: String, reflect: !0 })
|
|
98
|
+
], t.prototype, "href", 2);
|
|
99
|
+
c([
|
|
100
|
+
d({ type: String, reflect: !0 })
|
|
101
|
+
], t.prototype, "target", 2);
|
|
102
|
+
c([
|
|
103
|
+
d({ type: String, reflect: !0 })
|
|
104
|
+
], t.prototype, "rel", 2);
|
|
105
|
+
c([
|
|
106
|
+
d({ type: Boolean })
|
|
107
|
+
], t.prototype, "disabled", 2);
|
|
108
|
+
c([
|
|
109
|
+
d({ type: Object })
|
|
110
|
+
], t.prototype, "aria", 2);
|
|
111
|
+
c([
|
|
112
|
+
d({ type: Boolean })
|
|
113
|
+
], t.prototype, "isDraggable", 2);
|
|
114
|
+
c([
|
|
115
|
+
d({ type: String }),
|
|
116
|
+
b(v, S, void 0)
|
|
117
|
+
], t.prototype, "padding", 2);
|
|
118
|
+
h(v, t);
|
|
137
119
|
export {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
120
|
+
t as PieCard,
|
|
121
|
+
S as paddingValues,
|
|
122
|
+
$ as tags,
|
|
141
123
|
y as variants
|
|
142
124
|
};
|
package/dist/react.js
CHANGED
|
@@ -1,50 +1,20 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import * as a from "react";
|
|
2
|
+
import { createComponent as e } from "@lit/react";
|
|
3
|
+
import { PieCard as r } from "./index.js";
|
|
4
|
+
import { paddingValues as C, tags as c, variants as f } from "./index.js";
|
|
4
5
|
import "lit";
|
|
5
6
|
import "lit/decorators.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Copyright 2018 Google LLC
|
|
9
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
10
|
-
*/
|
|
11
|
-
const N = /* @__PURE__ */ new Set(["children", "localName", "ref", "style", "className"]), v = /* @__PURE__ */ new WeakMap(), g = (t, i, o, u, l) => {
|
|
12
|
-
const d = l == null ? void 0 : l[i];
|
|
13
|
-
d === void 0 || o === u ? (t[i] = o, o == null && i in HTMLElement.prototype && t.removeAttribute(i)) : ((c, n, a) => {
|
|
14
|
-
let s = v.get(c);
|
|
15
|
-
s === void 0 && v.set(c, s = /* @__PURE__ */ new Map());
|
|
16
|
-
let r = s.get(n);
|
|
17
|
-
a !== void 0 ? r === void 0 ? (s.set(n, r = { handleEvent: a }), c.addEventListener(n, r)) : r.handleEvent = a : r !== void 0 && (s.delete(n), c.removeEventListener(n, r));
|
|
18
|
-
})(t, d, o);
|
|
19
|
-
}, C = ({ react: t, tagName: i, elementClass: o, events: u, displayName: l }) => {
|
|
20
|
-
const d = new Set(Object.keys(u ?? {})), c = t.forwardRef((n, a) => {
|
|
21
|
-
const s = t.useRef(null), r = t.useRef(null), m = {}, p = {};
|
|
22
|
-
for (const [e, f] of Object.entries(n))
|
|
23
|
-
N.has(e) ? m[e === "className" ? "class" : e] = f : d.has(e) || e in o.prototype ? p[e] = f : m[e] = f;
|
|
24
|
-
return t.useLayoutEffect(() => {
|
|
25
|
-
if (r.current !== null) {
|
|
26
|
-
for (const e in p)
|
|
27
|
-
g(r.current, e, n[e], s.current ? s.current[e] : void 0, u);
|
|
28
|
-
s.current = n;
|
|
29
|
-
}
|
|
30
|
-
}), t.useLayoutEffect(() => {
|
|
31
|
-
var e;
|
|
32
|
-
(e = r.current) == null || e.removeAttribute("defer-hydration");
|
|
33
|
-
}, []), m.suppressHydrationWarning = !0, t.createElement(i, { ...m, ref: t.useCallback((e) => {
|
|
34
|
-
r.current = e, typeof a == "function" ? a(e) : a !== null && (a.current = e);
|
|
35
|
-
}, [a]) });
|
|
36
|
-
});
|
|
37
|
-
return c.displayName = l ?? o.name, c;
|
|
38
|
-
}, L = C({
|
|
7
|
+
import "@justeattakeaway/pie-webc-core";
|
|
8
|
+
const s = e({
|
|
39
9
|
displayName: "PieCard",
|
|
40
|
-
elementClass:
|
|
41
|
-
react:
|
|
10
|
+
elementClass: r,
|
|
11
|
+
react: a,
|
|
42
12
|
tagName: "pie-card",
|
|
43
13
|
events: {}
|
|
44
14
|
});
|
|
45
15
|
export {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
16
|
+
s as PieCard,
|
|
17
|
+
C as paddingValues,
|
|
18
|
+
c as tags,
|
|
19
|
+
f as variants
|
|
50
20
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-card",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.3",
|
|
4
4
|
"description": "PIE Design System Card built using Web Components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"author": "Just Eat Takeaway.com - Design System Team",
|
|
29
29
|
"license": "Apache-2.0",
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@justeattakeaway/pie-components-config": "0.6.
|
|
31
|
+
"@justeattakeaway/pie-components-config": "0.6.1"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@justeattakeaway/pie-webc-core": "0.
|
|
34
|
+
"@justeattakeaway/pie-webc-core": "0.13.0"
|
|
35
35
|
},
|
|
36
36
|
"volta": {
|
|
37
37
|
"extends": "../../../package.json"
|