@justeattakeaway/pie-button 0.39.0 → 0.39.1
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 +76 -76
- package/dist/react.d.ts +1 -1
- package/dist/react.js +16 -70
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ import '@justeattakeaway/pie-button';
|
|
|
61
61
|
```js
|
|
62
62
|
// React
|
|
63
63
|
// For React, you will need to import our React-specific component build
|
|
64
|
-
// which wraps the web component using
|
|
64
|
+
// which wraps the web component using @lit/react
|
|
65
65
|
import { PieButton } from '@justeattakeaway/pie-button/dist/react';
|
|
66
66
|
```
|
|
67
67
|
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { unsafeCSS as wt, LitElement as xt, html as N, nothing as O } from "lit";
|
|
2
|
-
import { property as
|
|
2
|
+
import { property as p } from "lit/decorators.js";
|
|
3
3
|
import { ifDefined as Et } from "lit/directives/if-defined.js";
|
|
4
4
|
import "@justeattakeaway/pie-spinner";
|
|
5
|
-
const R = (d, n, a) => function(
|
|
6
|
-
const
|
|
7
|
-
Object.defineProperty(
|
|
5
|
+
const R = (d, n, a) => function(b, y) {
|
|
6
|
+
const u = `#${y}`;
|
|
7
|
+
Object.defineProperty(b, y, {
|
|
8
8
|
get() {
|
|
9
|
-
return this[
|
|
9
|
+
return this[u];
|
|
10
10
|
},
|
|
11
11
|
set(f) {
|
|
12
|
-
|
|
13
|
-
n.includes(f) ? this[b] = f : (console.error(
|
|
12
|
+
n.includes(f) ? this[u] = f : (console.error(
|
|
14
13
|
`<${d}> Invalid value "${f}" provided for property "${y}".`,
|
|
15
14
|
`Must be one of: ${n.join(" | ")}.`,
|
|
16
15
|
`Falling back to default value: "${a}"`
|
|
17
|
-
), this[
|
|
18
|
-
}
|
|
16
|
+
), this[u] = a);
|
|
17
|
+
},
|
|
18
|
+
configurable: !0
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
function kt(d, n) {
|
|
@@ -34,7 +34,7 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
34
34
|
], Lt = ["leading", "trailing"], Pt = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], _t = ["post", "get", "dialog"], $t = ["_self", "_blank", "_parent", "_top"], Ft = `*,*:before,*:after{box-sizing:border-box}.o-btn{--btn-border-radius: var(--dt-radius-rounded-e);--btn-font-family: var(--dt-font-interactive-m-family);--btn-font-weight: var(--dt-font-interactive-m-weight);--btn-bg-color: var(--dt-color-interactive-brand);--btn-text-color: var(--dt-color-content-interactive-primary);--btn-height--xsmall: 32px;--btn-height--small: 40px;--btn-height--medium: 48px;--btn-height--large: 56px;position:relative;display:flex;gap:var(--dt-spacing-b);align-items:center;justify-content:center;box-sizing:border-box;height:var(--btn-height);padding:var(--btn-padding);border:none;border-radius:var(--btn-border-radius);outline:none;background-color:var(--btn-bg-color);font-family:var(--btn-font-family);font-size:var(--btn-font-size);font-weight:var(--btn-font-weight);color:var(--btn-text-color);line-height:var(--btn-line-height);cursor:pointer;user-select:none;inline-size:var(--btn-inline-size)}.o-btn[variant=primary]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + var(--hover-modifier)))}.o-btn[variant=primary]:active:not(:disabled),.o-btn[variant=primary][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + var(--active-modifier)))}.o-btn[variant=primary][size=xsmall],.o-btn[variant=primary][size=small-productive]{--btn-bg-color: var(--dt-color-interactive-primary)}.o-btn[variant=primary][size=xsmall]:hover:not(:disabled),.o-btn[variant=primary][size=small-productive]:hover:not(:disabled){--hover-modifier: var(--dt-color-hover-02);--btn-bg-color: hsl(var(--dt-color-interactive-primary-h), var(--dt-color-interactive-primary-s), calc(var(--dt-color-interactive-primary-l) + var(--hover-modifier)))}.o-btn[variant=primary][size=xsmall]:active:not(:disabled),.o-btn[variant=primary][size=xsmall][isLoading]:not(:disabled),.o-btn[variant=primary][size=small-productive]:active:not(:disabled),.o-btn[variant=primary][size=small-productive][isLoading]:not(:disabled){--active-modifier: var(--dt-color-active-02);--btn-bg-color: hsl(var(--dt-color-interactive-primary-h), var(--dt-color-interactive-primary-s), calc(var(--dt-color-interactive-primary-l) + var(--active-modifier)))}.o-btn[variant=secondary]{--btn-bg-color: var(--dt-color-interactive-secondary);--btn-text-color: var(--dt-color-content-interactive-secondary)}.o-btn[variant=secondary]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-interactive-secondary-h), var(--dt-color-interactive-secondary-s), calc(var(--dt-color-interactive-secondary-l) + var(--hover-modifier)))}.o-btn[variant=secondary]:active:not(:disabled),.o-btn[variant=secondary][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-interactive-secondary-h), var(--dt-color-interactive-secondary-s), calc(var(--dt-color-interactive-secondary-l) + var(--active-modifier)))}.o-btn[variant=outline]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-interactive-secondary);border:1px solid var(--dt-color-border-strong)}.o-btn[variant=outline]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--hover-modifier))}.o-btn[variant=outline]:active:not(:disabled),.o-btn[variant=outline][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--active-modifier))}.o-btn[variant=ghost]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-link)}.o-btn[variant=ghost]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--hover-modifier))}.o-btn[variant=ghost]:active:not(:disabled),.o-btn[variant=ghost][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--active-modifier))}.o-btn[variant=inverse]{--btn-bg-color: var(--dt-color-interactive-inverse);--btn-text-color: var(--dt-color-content-interactive-secondary)}.o-btn[variant=inverse]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-interactive-inverse-h), var(--dt-color-interactive-inverse-s), calc(var(--dt-color-interactive-inverse-l) + var(--hover-modifier)))}.o-btn[variant=inverse]:active:not(:disabled),.o-btn[variant=inverse][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-interactive-inverse-h), var(--dt-color-interactive-inverse-s), calc(var(--dt-color-interactive-inverse-l) + var(--active-modifier)))}.o-btn[variant=ghost-inverse],.o-btn[variant=outline-inverse]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-interactive-primary)}.o-btn[variant=ghost-inverse]:hover:not(:disabled),.o-btn[variant=outline-inverse]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), var(--dt-color-container-default-l), var(--hover-modifier))}.o-btn[variant=ghost-inverse]:active:not(:disabled),.o-btn[variant=ghost-inverse][isLoading]:not(:disabled),.o-btn[variant=outline-inverse]:active:not(:disabled),.o-btn[variant=outline-inverse][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), var(--dt-color-container-default-l), var(--active-modifier))}.o-btn[variant=outline-inverse]{border:1px solid var(--dt-color-border-strong)}.o-btn[variant=destructive]{--btn-bg-color: var(--dt-color-support-error)}.o-btn[variant=destructive]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-support-error-h), var(--dt-color-support-error-s), calc(var(--dt-color-support-error-l) + var(--hover-modifier)))}.o-btn[variant=destructive]:active:not(:disabled),.o-btn[variant=destructive][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-support-error-h), var(--dt-color-support-error-s), calc(var(--dt-color-support-error-l) + var(--active-modifier)))}.o-btn[variant=destructive-ghost]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-interactive-error)}.o-btn[variant=destructive-ghost]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--hover-modifier))}.o-btn[variant=destructive-ghost]:active:not(:disabled),.o-btn[variant=destructive-ghost][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--active-modifier))}.o-btn[isFullWidth]{--btn-inline-size: 100%}.o-btn[disabled]{--btn-text-color: var(--dt-color-content-disabled) !important;cursor:not-allowed}.o-btn[disabled]:not([variant=ghost],[variant=ghost-inverse],[variant=destructive-ghost]){--btn-bg-color: var(--dt-color-disabled-01) !important}.o-btn[disabled][variant=outline]{border-color:var(--dt-color-disabled-01)!important}.o-btn[size=xsmall]{--btn-height: var(--btn-height--xsmall);--btn-padding: 6px var(--dt-spacing-b);--btn-font-size: calc(var(--dt-font-size-14) * 1px);--btn-line-height: calc(var(--dt-font-size-14-line-height) * 1px);--btn-icon-size: 16px}@media (min-width: 768px){.o-btn[size=xsmall][isResponsive]{--btn-height: var(--btn-height--small);--btn-padding: 8px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-16) * 1px);--btn-line-height: calc(var(--dt-font-size-16-line-height) * 1px);--btn-icon-size: 20px}.o-btn[size=xsmall][isResponsive][responsiveSize=expressive]{--btn-height: var(--btn-height--small);--btn-padding: 6px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--btn-icon-size: 20px}}.o-btn[size=small-expressive]{--btn-height: var(--btn-height--small);--btn-padding: 6px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--btn-icon-size: 20px}@media (min-width: 768px){.o-btn[size=small-expressive][isResponsive]{--btn-height: var(--btn-height--medium);--btn-padding: 10px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--btn-icon-size: 24px}}.o-btn[size=small-productive]{--btn-height: var(--btn-height--small);--btn-padding: 8px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-16) * 1px);--btn-line-height: calc(var(--dt-font-size-16-line-height) * 1px);--btn-icon-size: 20px}@media (min-width: 768px){.o-btn[size=small-productive][isResponsive]{--btn-height: var(--btn-height--medium);--btn-padding: 10px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--btn-icon-size: 24px}}.o-btn[size=medium]{--btn-height: var(--btn-height--medium);--btn-padding: 10px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--btn-icon-size: 24px}@media (min-width: 768px){.o-btn[size=medium][isResponsive]{--btn-height: var(--btn-height--large);--btn-padding: 14px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--btn-icon-size: 24px}}.o-btn[size=large]{--btn-height: var(--btn-height--large);--btn-padding: 14px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--btn-icon-size: 24px}.o-btn[isLoading]>*:not(pie-spinner){visibility:hidden}.o-btn[isLoading] pie-spinner{position:absolute}.o-btn:focus-visible{box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer);outline:none}::slotted(svg){height:var(--btn-icon-size);width:var(--btn-icon-size)}
|
|
35
35
|
`;
|
|
36
36
|
(function() {
|
|
37
|
-
const d = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(),
|
|
37
|
+
const d = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), A = {
|
|
38
38
|
ariaAtomic: "aria-atomic",
|
|
39
39
|
ariaAutoComplete: "aria-autocomplete",
|
|
40
40
|
ariaBusy: "aria-busy",
|
|
@@ -86,16 +86,16 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
86
86
|
return r;
|
|
87
87
|
},
|
|
88
88
|
set(l) {
|
|
89
|
-
r = l, i.isConnected ? i.setAttribute(o, l) :
|
|
89
|
+
r = l, i.isConnected ? i.setAttribute(o, l) : k.set(i, t);
|
|
90
90
|
}
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
-
function
|
|
94
|
+
function j(i) {
|
|
95
95
|
const t = c.get(i), { form: e } = t;
|
|
96
96
|
X(i, e, t), Q(i, t.labels);
|
|
97
97
|
}
|
|
98
|
-
const
|
|
98
|
+
const q = (i, t = !1) => {
|
|
99
99
|
const e = document.createTreeWalker(i, NodeFilter.SHOW_ELEMENT, {
|
|
100
100
|
acceptNode(l) {
|
|
101
101
|
return c.has(l) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
@@ -105,11 +105,11 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
105
105
|
const o = !t || i.disabled;
|
|
106
106
|
for (; r; )
|
|
107
107
|
r.formDisabledCallback && o && $(r, i.disabled), r = e.nextNode();
|
|
108
|
-
},
|
|
108
|
+
}, U = { attributes: !0, attributeFilter: ["disabled", "name"] }, z = T() ? new MutationObserver((i) => {
|
|
109
109
|
for (const t of i) {
|
|
110
110
|
const e = t.target;
|
|
111
|
-
if (t.attributeName === "disabled" && (e.constructor.formAssociated ? $(e, e.hasAttribute("disabled")) : e.localName === "fieldset" &&
|
|
112
|
-
const r = c.get(e), o =
|
|
111
|
+
if (t.attributeName === "disabled" && (e.constructor.formAssociated ? $(e, e.hasAttribute("disabled")) : e.localName === "fieldset" && q(e)), t.attributeName === "name" && e.constructor.formAssociated) {
|
|
112
|
+
const r = c.get(e), o = M.get(e);
|
|
113
113
|
r.setFormValue(o);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
@@ -119,11 +119,11 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
119
119
|
const { addedNodes: e, removedNodes: r } = t, o = Array.from(e), l = Array.from(r);
|
|
120
120
|
o.forEach((s) => {
|
|
121
121
|
var g;
|
|
122
|
-
if (c.has(s) && s.constructor.formAssociated &&
|
|
123
|
-
const v =
|
|
122
|
+
if (c.has(s) && s.constructor.formAssociated && j(s), k.has(s)) {
|
|
123
|
+
const v = k.get(s);
|
|
124
124
|
Object.keys(A).filter((w) => v[w] !== null).forEach((w) => {
|
|
125
125
|
s.setAttribute(A[w], v[w]);
|
|
126
|
-
}),
|
|
126
|
+
}), k.delete(s);
|
|
127
127
|
}
|
|
128
128
|
if (F.has(s)) {
|
|
129
129
|
const v = F.get(s);
|
|
@@ -137,12 +137,12 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
137
137
|
});
|
|
138
138
|
let w = E.nextNode();
|
|
139
139
|
for (; w; )
|
|
140
|
-
|
|
140
|
+
j(w), w = E.nextNode();
|
|
141
141
|
}
|
|
142
|
-
s.localName === "fieldset" && ((g =
|
|
142
|
+
s.localName === "fieldset" && ((g = z.observe) == null || g.call(z, s, U), q(s, !0));
|
|
143
143
|
}), l.forEach((s) => {
|
|
144
144
|
const g = c.get(s);
|
|
145
|
-
g && a.get(g) && G(g),
|
|
145
|
+
g && a.get(g) && G(g), u.has(s) && u.get(s).disconnect();
|
|
146
146
|
});
|
|
147
147
|
});
|
|
148
148
|
}
|
|
@@ -175,7 +175,7 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
175
175
|
return e.type = "hidden", e.name = i.getAttribute("name"), i.after(e), a.get(t).push(e), e;
|
|
176
176
|
}, st = (i, t) => {
|
|
177
177
|
var e;
|
|
178
|
-
a.set(t, []), (e =
|
|
178
|
+
a.set(t, []), (e = z.observe) == null || e.call(z, i, U);
|
|
179
179
|
}, Q = (i, t) => {
|
|
180
180
|
if (t.length) {
|
|
181
181
|
Array.from(t).forEach((r) => r.addEventListener("click", i.click.bind(i)));
|
|
@@ -242,7 +242,7 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
242
242
|
this.badInput = !1, this.customError = !1, this.patternMismatch = !1, this.rangeOverflow = !1, this.rangeUnderflow = !1, this.stepMismatch = !1, this.tooLong = !1, this.tooShort = !1, this.typeMismatch = !1, this.valid = !0, this.valueMissing = !1, Object.seal(this);
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
|
-
const
|
|
245
|
+
const pt = (i) => (i.badInput = !1, i.customError = !1, i.patternMismatch = !1, i.rangeOverflow = !1, i.rangeUnderflow = !1, i.stepMismatch = !1, i.tooLong = !1, i.tooShort = !1, i.typeMismatch = !1, i.valid = !0, i.valueMissing = !1, i), mt = (i, t, e) => (i.valid = bt(t), Object.keys(t).forEach((r) => i[r] = t[r]), e && S(e), i), bt = (i) => {
|
|
246
246
|
let t = !0;
|
|
247
247
|
for (let e in i)
|
|
248
248
|
e !== "valid" && i[e] !== !1 && (t = !1);
|
|
@@ -403,7 +403,7 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
403
403
|
l.name = r, l.value = o;
|
|
404
404
|
}
|
|
405
405
|
});
|
|
406
|
-
|
|
406
|
+
M.set(e, t);
|
|
407
407
|
}
|
|
408
408
|
setValidity(t, e, r) {
|
|
409
409
|
const o = d.get(this);
|
|
@@ -413,13 +413,13 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
413
413
|
const l = n.get(this), s = {};
|
|
414
414
|
for (const E in t)
|
|
415
415
|
s[E] = t[E];
|
|
416
|
-
Object.keys(s).length === 0 &&
|
|
416
|
+
Object.keys(s).length === 0 && pt(l);
|
|
417
417
|
const g = { ...l, ...s };
|
|
418
418
|
delete g.valid;
|
|
419
|
-
const { valid: v } =
|
|
419
|
+
const { valid: v } = mt(l, g, this.form);
|
|
420
420
|
if (!v && !e)
|
|
421
421
|
throw new DOMException("Failed to execute 'setValidity' on 'ElementInternals': The second argument should not be empty if one or more flags in the first argument are true.");
|
|
422
|
-
|
|
422
|
+
b.set(this, v ? "" : e), o.isConnected ? (o.toggleAttribute("internals-invalid", !v), o.toggleAttribute("internals-valid", v), o.setAttribute("aria-invalid", `${!v}`)) : F.set(o, this);
|
|
423
423
|
}
|
|
424
424
|
get shadowRoot() {
|
|
425
425
|
const t = d.get(this), e = W.get(t);
|
|
@@ -427,7 +427,7 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
427
427
|
}
|
|
428
428
|
get validationMessage() {
|
|
429
429
|
const t = d.get(this);
|
|
430
|
-
return x(t, "Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element."),
|
|
430
|
+
return x(t, "Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element."), b.get(this);
|
|
431
431
|
}
|
|
432
432
|
get validity() {
|
|
433
433
|
const t = d.get(this);
|
|
@@ -498,7 +498,7 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
498
498
|
const r = t.apply(this, e);
|
|
499
499
|
if (W.set(this, r), T()) {
|
|
500
500
|
const o = new MutationObserver(P);
|
|
501
|
-
window.ShadyDOM ? o.observe(this, _) : o.observe(r, _),
|
|
501
|
+
window.ShadyDOM ? o.observe(this, _) : o.observe(r, _), u.set(this, o);
|
|
502
502
|
}
|
|
503
503
|
return r;
|
|
504
504
|
};
|
|
@@ -508,10 +508,10 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
508
508
|
T() && typeof document < "u" && new MutationObserver(P).observe(document.documentElement, _), typeof HTMLFormElement < "u" && gt(), typeof window < "u" && !window.CustomStateSet && (window.CustomStateSet = V);
|
|
509
509
|
}
|
|
510
510
|
})();
|
|
511
|
-
var At = Object.defineProperty, St = Object.getOwnPropertyDescriptor,
|
|
512
|
-
for (var
|
|
513
|
-
(
|
|
514
|
-
return c &&
|
|
511
|
+
var At = Object.defineProperty, St = Object.getOwnPropertyDescriptor, m = (d, n, a, c) => {
|
|
512
|
+
for (var b = c > 1 ? void 0 : c ? St(n, a) : n, y = d.length - 1, u; y >= 0; y--)
|
|
513
|
+
(u = d[y]) && (b = (c ? u(n, a, b) : u(b)) || b);
|
|
514
|
+
return c && b && At(n, a, b), b;
|
|
515
515
|
};
|
|
516
516
|
const L = "pie-button";
|
|
517
517
|
class h extends xt {
|
|
@@ -577,29 +577,29 @@ class h extends xt {
|
|
|
577
577
|
type: n,
|
|
578
578
|
disabled: a,
|
|
579
579
|
isFullWidth: c,
|
|
580
|
-
variant:
|
|
580
|
+
variant: b,
|
|
581
581
|
size: y,
|
|
582
|
-
isLoading:
|
|
582
|
+
isLoading: u,
|
|
583
583
|
isResponsive: f,
|
|
584
|
-
iconPlacement:
|
|
585
|
-
responsiveSize:
|
|
584
|
+
iconPlacement: M,
|
|
585
|
+
responsiveSize: k
|
|
586
586
|
} = this;
|
|
587
587
|
return N`
|
|
588
588
|
<button
|
|
589
589
|
@click=${this._handleClick}
|
|
590
590
|
class="o-btn"
|
|
591
591
|
type=${n}
|
|
592
|
-
variant=${
|
|
592
|
+
variant=${b}
|
|
593
593
|
size=${y}
|
|
594
|
-
responsiveSize=${Et(
|
|
594
|
+
responsiveSize=${Et(k)}
|
|
595
595
|
?disabled=${a}
|
|
596
596
|
?isFullWidth=${c}
|
|
597
597
|
?isResponsive=${f}
|
|
598
|
-
?isLoading=${
|
|
599
|
-
${
|
|
600
|
-
${
|
|
598
|
+
?isLoading=${u}>
|
|
599
|
+
${u ? this.renderSpinner() : O}
|
|
600
|
+
${M === "leading" ? N`<slot name="icon"></slot>` : O}
|
|
601
601
|
<slot></slot>
|
|
602
|
-
${
|
|
602
|
+
${M === "trailing" ? N`<slot name="icon"></slot>` : O}
|
|
603
603
|
</button>`;
|
|
604
604
|
}
|
|
605
605
|
focus() {
|
|
@@ -609,57 +609,57 @@ class h extends xt {
|
|
|
609
609
|
}
|
|
610
610
|
h.formAssociated = !0;
|
|
611
611
|
h.styles = wt(Ft);
|
|
612
|
-
|
|
613
|
-
|
|
612
|
+
m([
|
|
613
|
+
p(),
|
|
614
614
|
R(L, zt, "medium")
|
|
615
615
|
], h.prototype, "size", 2);
|
|
616
|
-
|
|
617
|
-
|
|
616
|
+
m([
|
|
617
|
+
p(),
|
|
618
618
|
R(L, Mt, "submit")
|
|
619
619
|
], h.prototype, "type", 2);
|
|
620
|
-
|
|
621
|
-
|
|
620
|
+
m([
|
|
621
|
+
p(),
|
|
622
622
|
R(L, Ct, "primary")
|
|
623
623
|
], h.prototype, "variant", 2);
|
|
624
|
-
|
|
625
|
-
|
|
624
|
+
m([
|
|
625
|
+
p({ type: String }),
|
|
626
626
|
R(L, Lt, "leading")
|
|
627
627
|
], h.prototype, "iconPlacement", 2);
|
|
628
|
-
|
|
629
|
-
|
|
628
|
+
m([
|
|
629
|
+
p({ type: Boolean })
|
|
630
630
|
], h.prototype, "disabled", 2);
|
|
631
|
-
|
|
632
|
-
|
|
631
|
+
m([
|
|
632
|
+
p({ type: Boolean, reflect: !0 })
|
|
633
633
|
], h.prototype, "isLoading", 2);
|
|
634
|
-
|
|
635
|
-
|
|
634
|
+
m([
|
|
635
|
+
p({ type: Boolean })
|
|
636
636
|
], h.prototype, "isFullWidth", 2);
|
|
637
|
-
|
|
638
|
-
|
|
637
|
+
m([
|
|
638
|
+
p({ type: Boolean })
|
|
639
639
|
], h.prototype, "isResponsive", 2);
|
|
640
|
-
|
|
641
|
-
|
|
640
|
+
m([
|
|
641
|
+
p({ type: String })
|
|
642
642
|
], h.prototype, "name", 2);
|
|
643
|
-
|
|
644
|
-
|
|
643
|
+
m([
|
|
644
|
+
p({ type: String })
|
|
645
645
|
], h.prototype, "value", 2);
|
|
646
|
-
|
|
647
|
-
|
|
646
|
+
m([
|
|
647
|
+
p()
|
|
648
648
|
], h.prototype, "formaction", 2);
|
|
649
|
-
|
|
650
|
-
|
|
649
|
+
m([
|
|
650
|
+
p()
|
|
651
651
|
], h.prototype, "formenctype", 2);
|
|
652
|
-
|
|
653
|
-
|
|
652
|
+
m([
|
|
653
|
+
p()
|
|
654
654
|
], h.prototype, "formmethod", 2);
|
|
655
|
-
|
|
656
|
-
|
|
655
|
+
m([
|
|
656
|
+
p({ type: Boolean })
|
|
657
657
|
], h.prototype, "formnovalidate", 2);
|
|
658
|
-
|
|
659
|
-
|
|
658
|
+
m([
|
|
659
|
+
p()
|
|
660
660
|
], h.prototype, "formtarget", 2);
|
|
661
|
-
|
|
662
|
-
|
|
661
|
+
m([
|
|
662
|
+
p({ type: String })
|
|
663
663
|
], h.prototype, "responsiveSize", 2);
|
|
664
664
|
kt(L, h);
|
|
665
665
|
export {
|
package/dist/react.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CSSResult } from 'lit';
|
|
2
2
|
import type { LitElement } from 'lit';
|
|
3
3
|
import type { PropertyValues } from 'lit';
|
|
4
|
-
import type { ReactWebComponent } from '@lit
|
|
4
|
+
import type { ReactWebComponent } from '@lit/react';
|
|
5
5
|
import type { TemplateResult } from 'lit';
|
|
6
6
|
|
|
7
7
|
export declare interface ButtonProps {
|
package/dist/react.js
CHANGED
|
@@ -1,80 +1,26 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import * as t from "react";
|
|
2
|
+
import { createComponent as e } from "@lit/react";
|
|
3
|
+
import { PieButton as o } from "./index.js";
|
|
4
|
+
import { formEncodingtypes as u, formMethodTypes as y, formTargetTypes as P, iconPlacements as l, responsiveSizes as B, sizes as d, types as g, variants as v } from "./index.js";
|
|
4
5
|
import "lit";
|
|
5
6
|
import "lit/decorators.js";
|
|
6
7
|
import "lit/directives/if-defined.js";
|
|
7
8
|
import "@justeattakeaway/pie-spinner";
|
|
8
|
-
|
|
9
|
-
* @license
|
|
10
|
-
* Copyright 2018 Google LLC
|
|
11
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
12
|
-
*/
|
|
13
|
-
const b = /* @__PURE__ */ new Set(["children", "localName", "ref", "style", "className"]), g = /* @__PURE__ */ new WeakMap(), M = (t, o, m, c, d) => {
|
|
14
|
-
const n = d == null ? void 0 : d[o];
|
|
15
|
-
n === void 0 || m === c ? m == null && o in HTMLElement.prototype ? t.removeAttribute(o) : t[o] = m : ((r, s, u) => {
|
|
16
|
-
let a = g.get(r);
|
|
17
|
-
a === void 0 && g.set(r, a = /* @__PURE__ */ new Map());
|
|
18
|
-
let l = a.get(s);
|
|
19
|
-
u !== void 0 ? l === void 0 ? (a.set(s, l = { handleEvent: u }), r.addEventListener(s, l)) : l.handleEvent = u : l !== void 0 && (a.delete(s), r.removeEventListener(s, l));
|
|
20
|
-
})(t, n, m);
|
|
21
|
-
}, P = (t, o) => {
|
|
22
|
-
typeof t == "function" ? t(o) : t.current = o;
|
|
23
|
-
};
|
|
24
|
-
function B(t = window.React, o, m, c, d) {
|
|
25
|
-
let n, r, s;
|
|
26
|
-
if (o === void 0) {
|
|
27
|
-
const p = t;
|
|
28
|
-
({ tagName: r, elementClass: s, events: c, displayName: d } = p), n = p.react;
|
|
29
|
-
} else
|
|
30
|
-
n = t, s = m, r = o;
|
|
31
|
-
const u = n.Component, a = n.createElement, l = new Set(Object.keys(c ?? {}));
|
|
32
|
-
class f extends u {
|
|
33
|
-
constructor() {
|
|
34
|
-
super(...arguments), this.o = null;
|
|
35
|
-
}
|
|
36
|
-
t(e) {
|
|
37
|
-
if (this.o !== null)
|
|
38
|
-
for (const h in this.i)
|
|
39
|
-
M(this.o, h, this.props[h], e ? e[h] : void 0, c);
|
|
40
|
-
}
|
|
41
|
-
componentDidMount() {
|
|
42
|
-
var e;
|
|
43
|
-
this.t(), (e = this.o) === null || e === void 0 || e.removeAttribute("defer-hydration");
|
|
44
|
-
}
|
|
45
|
-
componentDidUpdate(e) {
|
|
46
|
-
this.t(e);
|
|
47
|
-
}
|
|
48
|
-
render() {
|
|
49
|
-
const { _$Gl: e, ...h } = this.props;
|
|
50
|
-
this.h !== e && (this.u = (i) => {
|
|
51
|
-
e !== null && P(e, i), this.o = i, this.h = e;
|
|
52
|
-
}), this.i = {};
|
|
53
|
-
const v = { ref: this.u };
|
|
54
|
-
for (const [i, y] of Object.entries(h))
|
|
55
|
-
b.has(i) ? v[i === "className" ? "class" : i] = y : l.has(i) || i in s.prototype ? this.i[i] = y : v[i] = y;
|
|
56
|
-
return v.suppressHydrationWarning = !0, a(r, v);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
f.displayName = d ?? s.name;
|
|
60
|
-
const N = n.forwardRef((p, e) => a(f, { ...p, _$Gl: e }, p == null ? void 0 : p.children));
|
|
61
|
-
return N.displayName = f.displayName, N;
|
|
62
|
-
}
|
|
63
|
-
const S = B({
|
|
9
|
+
const a = e({
|
|
64
10
|
displayName: "PieButton",
|
|
65
|
-
elementClass:
|
|
66
|
-
react:
|
|
11
|
+
elementClass: o,
|
|
12
|
+
react: t,
|
|
67
13
|
tagName: "pie-button",
|
|
68
14
|
events: {}
|
|
69
15
|
});
|
|
70
16
|
export {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
17
|
+
a as PieButton,
|
|
18
|
+
u as formEncodingtypes,
|
|
19
|
+
y as formMethodTypes,
|
|
20
|
+
P as formTargetTypes,
|
|
21
|
+
l as iconPlacements,
|
|
22
|
+
B as responsiveSizes,
|
|
23
|
+
d as sizes,
|
|
24
|
+
g as types,
|
|
25
|
+
v as variants
|
|
80
26
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-button",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.1",
|
|
4
4
|
"description": "PIE design system button built using web components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"dist/*.js"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@justeattakeaway/pie-spinner": "0.2.
|
|
41
|
-
"@justeattakeaway/pie-webc-core": "0.
|
|
40
|
+
"@justeattakeaway/pie-spinner": "0.2.2",
|
|
41
|
+
"@justeattakeaway/pie-webc-core": "0.12.0",
|
|
42
42
|
"element-internals-polyfill": "1.3.8"
|
|
43
43
|
}
|
|
44
44
|
}
|