@justeattakeaway/pie-button 0.37.0 → 0.37.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/dist/index.js +274 -331
- package/dist/react.js +11 -10
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { unsafeCSS as
|
|
1
|
+
import { unsafeCSS as wt, LitElement as Et, html as N, nothing as R } from "lit";
|
|
2
2
|
import { property as b } from "lit/decorators.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import "@justeattakeaway/pie-spinner";
|
|
4
|
+
const P = (d, n, a) => function(p, y) {
|
|
5
|
+
const m = `#${y}`;
|
|
6
|
+
Object.defineProperty(p, y, {
|
|
6
7
|
get() {
|
|
7
|
-
return this[
|
|
8
|
+
return this[m];
|
|
8
9
|
},
|
|
9
10
|
set(u) {
|
|
10
|
-
const L = this[
|
|
11
|
-
|
|
12
|
-
`<${
|
|
13
|
-
`Must be one of: ${
|
|
14
|
-
`Falling back to default value: "${
|
|
15
|
-
), this[
|
|
11
|
+
const L = this[m];
|
|
12
|
+
n.includes(u) ? this[m] = u : (console.error(
|
|
13
|
+
`<${d}> Invalid value "${u}" provided for property "${y}".`,
|
|
14
|
+
`Must be one of: ${n.join(" | ")}.`,
|
|
15
|
+
`Falling back to default value: "${a}"`
|
|
16
|
+
), this[m] = a), this.requestUpdate(y, L);
|
|
16
17
|
}
|
|
17
18
|
});
|
|
18
19
|
};
|
|
19
|
-
function
|
|
20
|
-
customElements.get(
|
|
20
|
+
function xt(d, n) {
|
|
21
|
+
customElements.get(d) ? console.warn(`PIE Web Component: "${d}" has already been defined. Please ensure the component is only being defined once in your application.`) : customElements.define(d, n);
|
|
21
22
|
}
|
|
22
|
-
const
|
|
23
|
+
const kt = ["xsmall", "small-productive", "small-expressive", "medium", "large"], Mt = ["submit", "button", "reset"], Ct = [
|
|
23
24
|
"primary",
|
|
24
25
|
"secondary",
|
|
25
26
|
"outline",
|
|
@@ -29,10 +30,10 @@ const Ft = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
29
30
|
"ghost-inverse",
|
|
30
31
|
"destructive",
|
|
31
32
|
"destructive-ghost"
|
|
32
|
-
],
|
|
33
|
+
], Lt = ["leading", "trailing"], Vt = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], Nt = ["post", "get", "dialog"], Pt = ["_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-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-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;--btn-height: var(--btn-height--medium);--btn-icon-size: 24px;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: calc(-1 * 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: calc(-1 * 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}.o-btn[size=small-expressive],.o-btn[size=small-productive]{--btn-height: var(--btn-height--small);--btn-icon-size: 20px}.o-btn[size=small-expressive]{--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)}.o-btn[size=small-productive]{--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)}.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)}.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)}
|
|
33
34
|
`;
|
|
34
35
|
(function() {
|
|
35
|
-
const
|
|
36
|
+
const d = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), A = /* @__PURE__ */ new WeakMap(), I = {
|
|
36
37
|
ariaAtomic: "aria-atomic",
|
|
37
38
|
ariaAutoComplete: "aria-autocomplete",
|
|
38
39
|
ariaBusy: "aria-busy",
|
|
@@ -74,196 +75,196 @@ const Ft = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
74
75
|
ariaValueNow: "aria-valuenow",
|
|
75
76
|
ariaValueText: "aria-valuetext",
|
|
76
77
|
role: "role"
|
|
77
|
-
},
|
|
78
|
-
for (let e in
|
|
78
|
+
}, it = (r, t) => {
|
|
79
|
+
for (let e in I) {
|
|
79
80
|
t[e] = null;
|
|
80
81
|
let o = null;
|
|
81
|
-
const
|
|
82
|
+
const i = I[e];
|
|
82
83
|
Object.defineProperty(t, e, {
|
|
83
84
|
get() {
|
|
84
85
|
return o;
|
|
85
86
|
},
|
|
86
|
-
set(
|
|
87
|
-
o =
|
|
87
|
+
set(l) {
|
|
88
|
+
o = l, r.isConnected ? r.setAttribute(i, l) : F.set(r, t);
|
|
88
89
|
}
|
|
89
90
|
});
|
|
90
91
|
}
|
|
91
92
|
};
|
|
92
|
-
function
|
|
93
|
-
const t =
|
|
94
|
-
|
|
93
|
+
function q(r) {
|
|
94
|
+
const t = c.get(r), { form: e } = t;
|
|
95
|
+
X(r, e, t), Q(r, t.labels);
|
|
95
96
|
}
|
|
96
|
-
const
|
|
97
|
+
const U = (r, t = !1) => {
|
|
97
98
|
const e = document.createTreeWalker(r, NodeFilter.SHOW_ELEMENT, {
|
|
98
|
-
acceptNode(
|
|
99
|
-
return
|
|
99
|
+
acceptNode(l) {
|
|
100
|
+
return c.has(l) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
100
101
|
}
|
|
101
102
|
});
|
|
102
103
|
let o = e.nextNode();
|
|
103
|
-
const
|
|
104
|
+
const i = !t || r.disabled;
|
|
104
105
|
for (; o; )
|
|
105
|
-
o.formDisabledCallback &&
|
|
106
|
-
},
|
|
106
|
+
o.formDisabledCallback && i && D(o, r.disabled), o = e.nextNode();
|
|
107
|
+
}, j = { attributes: !0, attributeFilter: ["disabled", "name"] }, k = S() ? new MutationObserver((r) => {
|
|
107
108
|
for (const t of r) {
|
|
108
109
|
const e = t.target;
|
|
109
|
-
if (t.attributeName === "disabled" && (e.constructor.formAssociated ?
|
|
110
|
-
const o =
|
|
111
|
-
o.setFormValue(
|
|
110
|
+
if (t.attributeName === "disabled" && (e.constructor.formAssociated ? D(e, e.hasAttribute("disabled")) : e.localName === "fieldset" && U(e)), t.attributeName === "name" && e.constructor.formAssociated) {
|
|
111
|
+
const o = c.get(e), i = L.get(e);
|
|
112
|
+
o.setFormValue(i);
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
}) : {};
|
|
115
|
-
function
|
|
116
|
+
function _(r) {
|
|
116
117
|
r.forEach((t) => {
|
|
117
|
-
const { addedNodes: e, removedNodes: o } = t,
|
|
118
|
-
|
|
119
|
-
var
|
|
120
|
-
if (
|
|
121
|
-
const
|
|
122
|
-
Object.keys(
|
|
123
|
-
|
|
124
|
-
}),
|
|
118
|
+
const { addedNodes: e, removedNodes: o } = t, i = Array.from(e), l = Array.from(o);
|
|
119
|
+
i.forEach((s) => {
|
|
120
|
+
var f;
|
|
121
|
+
if (c.has(s) && s.constructor.formAssociated && q(s), F.has(s)) {
|
|
122
|
+
const v = F.get(s);
|
|
123
|
+
Object.keys(I).filter((w) => v[w] !== null).forEach((w) => {
|
|
124
|
+
s.setAttribute(I[w], v[w]);
|
|
125
|
+
}), F.delete(s);
|
|
125
126
|
}
|
|
126
|
-
if (
|
|
127
|
-
const
|
|
128
|
-
|
|
127
|
+
if (A.has(s)) {
|
|
128
|
+
const v = A.get(s);
|
|
129
|
+
s.setAttribute("internals-valid", v.validity.valid.toString()), s.setAttribute("internals-invalid", (!v.validity.valid).toString()), s.setAttribute("aria-invalid", (!v.validity.valid).toString()), A.delete(s);
|
|
129
130
|
}
|
|
130
|
-
if (
|
|
131
|
-
const
|
|
132
|
-
acceptNode(
|
|
133
|
-
return
|
|
131
|
+
if (s.localName === "form") {
|
|
132
|
+
const v = u.get(s), x = document.createTreeWalker(s, NodeFilter.SHOW_ELEMENT, {
|
|
133
|
+
acceptNode(ot) {
|
|
134
|
+
return c.has(ot) && !(v && v.has(ot)) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
134
135
|
}
|
|
135
136
|
});
|
|
136
|
-
let w =
|
|
137
|
+
let w = x.nextNode();
|
|
137
138
|
for (; w; )
|
|
138
|
-
|
|
139
|
+
q(w), w = x.nextNode();
|
|
139
140
|
}
|
|
140
|
-
|
|
141
|
-
}),
|
|
142
|
-
const
|
|
143
|
-
|
|
141
|
+
s.localName === "fieldset" && ((f = k.observe) == null || f.call(k, s, j), U(s, !0));
|
|
142
|
+
}), l.forEach((s) => {
|
|
143
|
+
const f = c.get(s);
|
|
144
|
+
f && a.get(f) && G(f), m.has(s) && m.get(s).disconnect();
|
|
144
145
|
});
|
|
145
146
|
});
|
|
146
147
|
}
|
|
147
|
-
function
|
|
148
|
+
function at(r) {
|
|
148
149
|
r.forEach((t) => {
|
|
149
150
|
const { removedNodes: e } = t;
|
|
150
151
|
e.forEach((o) => {
|
|
151
|
-
const
|
|
152
|
-
|
|
152
|
+
const i = B.get(t.target);
|
|
153
|
+
c.has(o) && Z(o), i.disconnect();
|
|
153
154
|
});
|
|
154
155
|
});
|
|
155
156
|
}
|
|
156
|
-
const
|
|
157
|
+
const nt = (r) => {
|
|
157
158
|
var e;
|
|
158
|
-
const t = new MutationObserver(
|
|
159
|
-
(e = t.observe) == null || e.call(t, r, { childList: !0 }),
|
|
159
|
+
const t = new MutationObserver(at);
|
|
160
|
+
(e = t.observe) == null || e.call(t, r, { childList: !0 }), B.set(r, t);
|
|
160
161
|
};
|
|
161
|
-
|
|
162
|
-
const
|
|
162
|
+
S() && new MutationObserver(_);
|
|
163
|
+
const $ = {
|
|
163
164
|
childList: !0,
|
|
164
165
|
subtree: !0
|
|
165
|
-
},
|
|
166
|
+
}, D = (r, t) => {
|
|
166
167
|
r.toggleAttribute("internals-disabled", t), t ? r.setAttribute("aria-disabled", "true") : r.removeAttribute("aria-disabled"), r.formDisabledCallback && r.formDisabledCallback.apply(r, [t]);
|
|
167
|
-
},
|
|
168
|
-
|
|
168
|
+
}, G = (r) => {
|
|
169
|
+
a.get(r).forEach((e) => {
|
|
169
170
|
e.remove();
|
|
170
|
-
}),
|
|
171
|
-
},
|
|
171
|
+
}), a.set(r, []);
|
|
172
|
+
}, J = (r, t) => {
|
|
172
173
|
const e = document.createElement("input");
|
|
173
|
-
return e.type = "hidden", e.name = r.getAttribute("name"), r.after(e),
|
|
174
|
-
},
|
|
174
|
+
return e.type = "hidden", e.name = r.getAttribute("name"), r.after(e), a.get(t).push(e), e;
|
|
175
|
+
}, st = (r, t) => {
|
|
175
176
|
var e;
|
|
176
|
-
|
|
177
|
-
},
|
|
177
|
+
a.set(t, []), (e = k.observe) == null || e.call(k, r, j);
|
|
178
|
+
}, Q = (r, t) => {
|
|
178
179
|
if (t.length) {
|
|
179
180
|
Array.from(t).forEach((o) => o.addEventListener("click", r.click.bind(r)));
|
|
180
181
|
let e = t[0].id;
|
|
181
182
|
t[0].id || (e = `${t[0].htmlFor}_Label`, t[0].id = e), r.setAttribute("aria-labelledby", e);
|
|
182
183
|
}
|
|
183
|
-
},
|
|
184
|
-
const t = Array.from(r.elements).filter((
|
|
185
|
-
r.toggleAttribute("internals-invalid",
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
},
|
|
189
|
-
|
|
190
|
-
},
|
|
184
|
+
}, T = (r) => {
|
|
185
|
+
const t = Array.from(r.elements).filter((l) => !l.tagName.includes("-") && l.validity).map((l) => l.validity.valid), e = u.get(r) || [], o = Array.from(e).filter((l) => l.isConnected).map((l) => c.get(l).validity.valid), i = [...t, ...o].includes(!1);
|
|
186
|
+
r.toggleAttribute("internals-invalid", i), r.toggleAttribute("internals-valid", !i);
|
|
187
|
+
}, lt = (r) => {
|
|
188
|
+
T(z(r.target));
|
|
189
|
+
}, ct = (r) => {
|
|
190
|
+
T(z(r.target));
|
|
191
|
+
}, dt = (r) => {
|
|
191
192
|
const t = ["button[type=submit]", "input[type=submit]", "button:not([type])"].map((e) => `${e}:not([disabled])`).map((e) => `${e}:not([form])${r.id ? `,${e}[form='${r.id}']` : ""}`).join(",");
|
|
192
193
|
r.addEventListener("click", (e) => {
|
|
193
194
|
if (e.target.closest(t)) {
|
|
194
|
-
const
|
|
195
|
+
const i = u.get(r);
|
|
195
196
|
if (r.noValidate)
|
|
196
197
|
return;
|
|
197
|
-
|
|
198
|
+
i.size && Array.from(i).reverse().map((f) => c.get(f).reportValidity()).includes(!1) && e.preventDefault();
|
|
198
199
|
}
|
|
199
200
|
});
|
|
200
|
-
},
|
|
201
|
+
}, vt = (r) => {
|
|
201
202
|
const t = u.get(r.target);
|
|
202
203
|
t && t.size && t.forEach((e) => {
|
|
203
204
|
e.constructor.formAssociated && e.formResetCallback && e.formResetCallback.apply(e);
|
|
204
205
|
});
|
|
205
|
-
},
|
|
206
|
+
}, X = (r, t, e) => {
|
|
206
207
|
if (t) {
|
|
207
208
|
const o = u.get(t);
|
|
208
209
|
if (o)
|
|
209
210
|
o.add(r);
|
|
210
211
|
else {
|
|
211
|
-
const
|
|
212
|
-
|
|
212
|
+
const i = /* @__PURE__ */ new Set();
|
|
213
|
+
i.add(r), u.set(t, i), dt(t), t.addEventListener("reset", vt), t.addEventListener("input", lt), t.addEventListener("change", ct);
|
|
213
214
|
}
|
|
214
|
-
|
|
215
|
+
y.set(t, { ref: r, internals: e }), r.constructor.formAssociated && r.formAssociatedCallback && setTimeout(() => {
|
|
215
216
|
r.formAssociatedCallback.apply(r, [t]);
|
|
216
|
-
}, 0),
|
|
217
|
+
}, 0), T(t);
|
|
217
218
|
}
|
|
218
|
-
},
|
|
219
|
+
}, z = (r) => {
|
|
219
220
|
let t = r.parentNode;
|
|
220
|
-
return t && t.tagName !== "FORM" && (t =
|
|
221
|
-
},
|
|
221
|
+
return t && t.tagName !== "FORM" && (t = z(t)), t;
|
|
222
|
+
}, E = (r, t, e = DOMException) => {
|
|
222
223
|
if (!r.constructor.formAssociated)
|
|
223
224
|
throw new e(t);
|
|
224
|
-
},
|
|
225
|
+
}, Y = (r, t, e) => {
|
|
225
226
|
const o = u.get(r);
|
|
226
|
-
return o && o.size && o.forEach((
|
|
227
|
-
|
|
227
|
+
return o && o.size && o.forEach((i) => {
|
|
228
|
+
c.get(i)[e]() || (t = !1);
|
|
228
229
|
}), t;
|
|
229
|
-
},
|
|
230
|
+
}, Z = (r) => {
|
|
230
231
|
if (r.constructor.formAssociated) {
|
|
231
|
-
const t =
|
|
232
|
-
|
|
232
|
+
const t = c.get(r), { labels: e, form: o } = t;
|
|
233
|
+
Q(r, e), X(r, o, t);
|
|
233
234
|
}
|
|
234
235
|
};
|
|
235
|
-
function
|
|
236
|
+
function S() {
|
|
236
237
|
return typeof MutationObserver < "u";
|
|
237
238
|
}
|
|
238
|
-
class
|
|
239
|
+
class ht {
|
|
239
240
|
constructor() {
|
|
240
241
|
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);
|
|
241
242
|
}
|
|
242
243
|
}
|
|
243
|
-
const
|
|
244
|
+
const mt = (r) => (r.badInput = !1, r.customError = !1, r.patternMismatch = !1, r.rangeOverflow = !1, r.rangeUnderflow = !1, r.stepMismatch = !1, r.tooLong = !1, r.tooShort = !1, r.typeMismatch = !1, r.valid = !0, r.valueMissing = !1, r), ut = (r, t, e) => (r.valid = pt(t), Object.keys(t).forEach((o) => r[o] = t[o]), e && T(e), r), pt = (r) => {
|
|
244
245
|
let t = !0;
|
|
245
246
|
for (let e in r)
|
|
246
247
|
e !== "valid" && r[e] !== !1 && (t = !1);
|
|
247
248
|
return t;
|
|
248
|
-
},
|
|
249
|
-
function
|
|
249
|
+
}, O = /* @__PURE__ */ new WeakMap();
|
|
250
|
+
function tt(r, t) {
|
|
250
251
|
r.toggleAttribute(t, !0), r.part && r.part.add(t);
|
|
251
252
|
}
|
|
252
|
-
class
|
|
253
|
+
class V extends Set {
|
|
253
254
|
static get isPolyfilled() {
|
|
254
255
|
return !0;
|
|
255
256
|
}
|
|
256
257
|
constructor(t) {
|
|
257
258
|
if (super(), !t || !t.tagName || t.tagName.indexOf("-") === -1)
|
|
258
259
|
throw new TypeError("Illegal constructor");
|
|
259
|
-
|
|
260
|
+
O.set(this, t);
|
|
260
261
|
}
|
|
261
262
|
add(t) {
|
|
262
263
|
if (!/^--/.test(t) || typeof t != "string")
|
|
263
264
|
throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${t} must start with '--'.`);
|
|
264
|
-
const e = super.add(t), o =
|
|
265
|
-
return o.isConnected ?
|
|
266
|
-
|
|
265
|
+
const e = super.add(t), o = O.get(this), i = `state${t}`;
|
|
266
|
+
return o.isConnected ? tt(o, i) : setTimeout(() => {
|
|
267
|
+
tt(o, i);
|
|
267
268
|
}), e;
|
|
268
269
|
}
|
|
269
270
|
clear() {
|
|
@@ -272,32 +273,32 @@ const Ft = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
272
273
|
super.clear();
|
|
273
274
|
}
|
|
274
275
|
delete(t) {
|
|
275
|
-
const e = super.delete(t), o =
|
|
276
|
+
const e = super.delete(t), o = O.get(this);
|
|
276
277
|
return o.isConnected ? (o.toggleAttribute(`state${t}`, !1), o.part && o.part.remove(`state${t}`)) : setTimeout(() => {
|
|
277
278
|
o.toggleAttribute(`state${t}`, !1), o.part && o.part.remove(`state${t}`);
|
|
278
279
|
}), e;
|
|
279
280
|
}
|
|
280
281
|
}
|
|
281
|
-
function
|
|
282
|
+
function et(r, t, e, o) {
|
|
282
283
|
if (e === "a" && !o)
|
|
283
284
|
throw new TypeError("Private accessor was defined without a getter");
|
|
284
285
|
if (typeof t == "function" ? r !== t || !o : !t.has(r))
|
|
285
286
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
286
287
|
return e === "m" ? o : e === "a" ? o.call(r) : o ? o.value : t.get(r);
|
|
287
288
|
}
|
|
288
|
-
function
|
|
289
|
+
function ft(r, t, e, o, i) {
|
|
289
290
|
if (o === "m")
|
|
290
291
|
throw new TypeError("Private method is not writable");
|
|
291
|
-
if (o === "a" && !
|
|
292
|
+
if (o === "a" && !i)
|
|
292
293
|
throw new TypeError("Private accessor was defined without a setter");
|
|
293
|
-
if (typeof t == "function" ? r !== t || !
|
|
294
|
+
if (typeof t == "function" ? r !== t || !i : !t.has(r))
|
|
294
295
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
295
|
-
return o === "a" ?
|
|
296
|
+
return o === "a" ? i.call(r, e) : i ? i.value = e : t.set(r, e), e;
|
|
296
297
|
}
|
|
297
|
-
var
|
|
298
|
-
class
|
|
298
|
+
var M;
|
|
299
|
+
class bt {
|
|
299
300
|
constructor(t) {
|
|
300
|
-
|
|
301
|
+
M.set(this, void 0), ft(this, M, t, "f");
|
|
301
302
|
for (let e = 0; e < t.length; e++) {
|
|
302
303
|
let o = t[e];
|
|
303
304
|
this[e] = o, o.hasAttribute("name") && (this[o.getAttribute("name")] = o);
|
|
@@ -305,10 +306,10 @@ const Ft = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
305
306
|
Object.freeze(this);
|
|
306
307
|
}
|
|
307
308
|
get length() {
|
|
308
|
-
return
|
|
309
|
+
return et(this, M, "f").length;
|
|
309
310
|
}
|
|
310
|
-
[(
|
|
311
|
-
return
|
|
311
|
+
[(M = /* @__PURE__ */ new WeakMap(), Symbol.iterator)]() {
|
|
312
|
+
return et(this, M, "f")[Symbol.iterator]();
|
|
312
313
|
}
|
|
313
314
|
item(t) {
|
|
314
315
|
return this[t] == null ? null : this[t];
|
|
@@ -317,45 +318,45 @@ const Ft = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
317
318
|
return this[t] == null ? null : this[t];
|
|
318
319
|
}
|
|
319
320
|
}
|
|
320
|
-
function
|
|
321
|
+
function gt() {
|
|
321
322
|
const r = HTMLFormElement.prototype.checkValidity;
|
|
322
323
|
HTMLFormElement.prototype.checkValidity = e;
|
|
323
324
|
const t = HTMLFormElement.prototype.reportValidity;
|
|
324
325
|
HTMLFormElement.prototype.reportValidity = o;
|
|
325
|
-
function e(...
|
|
326
|
-
let
|
|
327
|
-
return
|
|
326
|
+
function e(...l) {
|
|
327
|
+
let s = r.apply(this, l);
|
|
328
|
+
return Y(this, s, "checkValidity");
|
|
328
329
|
}
|
|
329
|
-
function o(...
|
|
330
|
-
let
|
|
331
|
-
return
|
|
330
|
+
function o(...l) {
|
|
331
|
+
let s = t.apply(this, l);
|
|
332
|
+
return Y(this, s, "reportValidity");
|
|
332
333
|
}
|
|
333
|
-
const { get:
|
|
334
|
+
const { get: i } = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, "elements");
|
|
334
335
|
Object.defineProperty(HTMLFormElement.prototype, "elements", {
|
|
335
|
-
get(...
|
|
336
|
-
const
|
|
337
|
-
if (
|
|
338
|
-
return
|
|
339
|
-
const
|
|
340
|
-
return new
|
|
336
|
+
get(...l) {
|
|
337
|
+
const s = i.call(this, ...l), f = Array.from(u.get(this) || []);
|
|
338
|
+
if (f.length === 0)
|
|
339
|
+
return s;
|
|
340
|
+
const v = Array.from(s).concat(f).sort((x, w) => x.compareDocumentPosition ? x.compareDocumentPosition(w) & 2 ? 1 : -1 : 0);
|
|
341
|
+
return new bt(v);
|
|
341
342
|
}
|
|
342
343
|
});
|
|
343
344
|
}
|
|
344
|
-
class
|
|
345
|
+
class rt {
|
|
345
346
|
static get isPolyfilled() {
|
|
346
347
|
return !0;
|
|
347
348
|
}
|
|
348
349
|
constructor(t) {
|
|
349
350
|
if (!t || !t.tagName || t.tagName.indexOf("-") === -1)
|
|
350
351
|
throw new TypeError("Illegal constructor");
|
|
351
|
-
const e = t.getRootNode(), o = new
|
|
352
|
-
this.states = new
|
|
352
|
+
const e = t.getRootNode(), o = new ht();
|
|
353
|
+
this.states = new V(t), d.set(this, t), n.set(this, o), c.set(t, this), it(t, this), st(t, this), Object.seal(this), e instanceof DocumentFragment && nt(e);
|
|
353
354
|
}
|
|
354
355
|
checkValidity() {
|
|
355
|
-
const t =
|
|
356
|
-
if (
|
|
356
|
+
const t = d.get(this);
|
|
357
|
+
if (E(t, "Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
|
|
357
358
|
return !0;
|
|
358
|
-
const e =
|
|
359
|
+
const e = n.get(this);
|
|
359
360
|
if (!e.valid) {
|
|
360
361
|
const o = new Event("invalid", {
|
|
361
362
|
bubbles: !1,
|
|
@@ -367,76 +368,76 @@ const Ft = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
367
368
|
return e.valid;
|
|
368
369
|
}
|
|
369
370
|
get form() {
|
|
370
|
-
const t =
|
|
371
|
-
|
|
371
|
+
const t = d.get(this);
|
|
372
|
+
E(t, "Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.");
|
|
372
373
|
let e;
|
|
373
|
-
return t.constructor.formAssociated === !0 && (e =
|
|
374
|
+
return t.constructor.formAssociated === !0 && (e = z(t)), e;
|
|
374
375
|
}
|
|
375
376
|
get labels() {
|
|
376
|
-
const t =
|
|
377
|
-
|
|
377
|
+
const t = d.get(this);
|
|
378
|
+
E(t, "Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.");
|
|
378
379
|
const e = t.getAttribute("id"), o = t.getRootNode();
|
|
379
380
|
return o && e ? o.querySelectorAll(`[for="${e}"]`) : [];
|
|
380
381
|
}
|
|
381
382
|
reportValidity() {
|
|
382
|
-
const t =
|
|
383
|
-
if (
|
|
383
|
+
const t = d.get(this);
|
|
384
|
+
if (E(t, "Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
|
|
384
385
|
return !0;
|
|
385
|
-
const e = this.checkValidity(), o =
|
|
386
|
+
const e = this.checkValidity(), o = H.get(this);
|
|
386
387
|
if (o && !t.constructor.formAssociated)
|
|
387
388
|
throw new DOMException("Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.");
|
|
388
389
|
return !e && o && (t.focus(), o.focus()), e;
|
|
389
390
|
}
|
|
390
391
|
setFormValue(t) {
|
|
391
|
-
const e =
|
|
392
|
-
if (
|
|
392
|
+
const e = d.get(this);
|
|
393
|
+
if (E(e, "Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element."), G(this), t != null && !(t instanceof FormData)) {
|
|
393
394
|
if (e.getAttribute("name")) {
|
|
394
|
-
const o =
|
|
395
|
+
const o = J(e, this);
|
|
395
396
|
o.value = t;
|
|
396
397
|
}
|
|
397
398
|
} else
|
|
398
|
-
t != null && t instanceof FormData && Array.from(t).reverse().forEach(([o,
|
|
399
|
-
if (typeof
|
|
400
|
-
const
|
|
401
|
-
|
|
399
|
+
t != null && t instanceof FormData && Array.from(t).reverse().forEach(([o, i]) => {
|
|
400
|
+
if (typeof i == "string") {
|
|
401
|
+
const l = J(e, this);
|
|
402
|
+
l.name = o, l.value = i;
|
|
402
403
|
}
|
|
403
404
|
});
|
|
404
405
|
L.set(e, t);
|
|
405
406
|
}
|
|
406
407
|
setValidity(t, e, o) {
|
|
407
|
-
const
|
|
408
|
-
if (
|
|
408
|
+
const i = d.get(this);
|
|
409
|
+
if (E(i, "Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !t)
|
|
409
410
|
throw new TypeError("Failed to execute 'setValidity' on 'ElementInternals': 1 argument required, but only 0 present.");
|
|
410
|
-
|
|
411
|
-
const
|
|
412
|
-
for (const
|
|
413
|
-
|
|
414
|
-
Object.keys(
|
|
415
|
-
const
|
|
416
|
-
delete
|
|
417
|
-
const { valid:
|
|
418
|
-
if (!
|
|
411
|
+
H.set(this, o);
|
|
412
|
+
const l = n.get(this), s = {};
|
|
413
|
+
for (const x in t)
|
|
414
|
+
s[x] = t[x];
|
|
415
|
+
Object.keys(s).length === 0 && mt(l);
|
|
416
|
+
const f = { ...l, ...s };
|
|
417
|
+
delete f.valid;
|
|
418
|
+
const { valid: v } = ut(l, f, this.form);
|
|
419
|
+
if (!v && !e)
|
|
419
420
|
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.");
|
|
420
|
-
|
|
421
|
+
p.set(this, v ? "" : e), i.isConnected ? (i.toggleAttribute("internals-invalid", !v), i.toggleAttribute("internals-valid", v), i.setAttribute("aria-invalid", `${!v}`)) : A.set(i, this);
|
|
421
422
|
}
|
|
422
423
|
get shadowRoot() {
|
|
423
|
-
const t =
|
|
424
|
+
const t = d.get(this), e = W.get(t);
|
|
424
425
|
return e || null;
|
|
425
426
|
}
|
|
426
427
|
get validationMessage() {
|
|
427
|
-
const t =
|
|
428
|
-
return
|
|
428
|
+
const t = d.get(this);
|
|
429
|
+
return E(t, "Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element."), p.get(this);
|
|
429
430
|
}
|
|
430
431
|
get validity() {
|
|
431
|
-
const t =
|
|
432
|
-
return
|
|
432
|
+
const t = d.get(this);
|
|
433
|
+
return E(t, "Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element."), n.get(this);
|
|
433
434
|
}
|
|
434
435
|
get willValidate() {
|
|
435
|
-
const t =
|
|
436
|
-
return
|
|
436
|
+
const t = d.get(this);
|
|
437
|
+
return E(t, "Failed to read the 'willValidate' property from 'ElementInternals': The target element is not a form-associated custom element."), !(t.disabled || t.hasAttribute("disabled") || t.hasAttribute("readonly"));
|
|
437
438
|
}
|
|
438
439
|
}
|
|
439
|
-
function
|
|
440
|
+
function yt() {
|
|
440
441
|
if (typeof window > "u" || !window.ElementInternals || !HTMLElement.prototype.attachInternals)
|
|
441
442
|
return !1;
|
|
442
443
|
class r extends HTMLElement {
|
|
@@ -460,23 +461,23 @@ const Ft = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
460
461
|
"reportValidity"
|
|
461
462
|
].every((o) => o in e.internals);
|
|
462
463
|
}
|
|
463
|
-
if (
|
|
464
|
+
if (yt()) {
|
|
464
465
|
if (typeof window < "u" && !window.CustomStateSet) {
|
|
465
|
-
window.CustomStateSet =
|
|
466
|
+
window.CustomStateSet = V;
|
|
466
467
|
const r = HTMLElement.prototype.attachInternals;
|
|
467
468
|
HTMLElement.prototype.attachInternals = function(...t) {
|
|
468
469
|
const e = r.call(this, t);
|
|
469
|
-
return e.states = new
|
|
470
|
+
return e.states = new V(this), e;
|
|
470
471
|
};
|
|
471
472
|
}
|
|
472
473
|
} else {
|
|
473
|
-
if (typeof window < "u" && (window.ElementInternals =
|
|
474
|
+
if (typeof window < "u" && (window.ElementInternals = rt), typeof CustomElementRegistry < "u") {
|
|
474
475
|
const r = CustomElementRegistry.prototype.define;
|
|
475
476
|
CustomElementRegistry.prototype.define = function(t, e, o) {
|
|
476
477
|
if (e.formAssociated) {
|
|
477
|
-
const
|
|
478
|
+
const i = e.prototype.connectedCallback;
|
|
478
479
|
e.prototype.connectedCallback = function() {
|
|
479
|
-
|
|
480
|
+
K.has(this) || (K.set(this, !0), this.hasAttribute("disabled") && D(this, !0)), i != null && i.apply(this), Z(this);
|
|
480
481
|
};
|
|
481
482
|
}
|
|
482
483
|
r.call(this, t, e, o);
|
|
@@ -488,98 +489,40 @@ const Ft = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
488
489
|
throw new Error("Failed to execute 'attachInternals' on 'HTMLElement': Unable to attach ElementInternals to non-custom elements.");
|
|
489
490
|
} else
|
|
490
491
|
return {};
|
|
491
|
-
if (
|
|
492
|
+
if (c.has(this))
|
|
492
493
|
throw new DOMException("DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.");
|
|
493
|
-
return new
|
|
494
|
+
return new rt(this);
|
|
494
495
|
}), typeof Element < "u") {
|
|
495
496
|
let r = function(...e) {
|
|
496
497
|
const o = t.apply(this, e);
|
|
497
|
-
if (
|
|
498
|
-
const
|
|
499
|
-
window.ShadyDOM ?
|
|
498
|
+
if (W.set(this, o), S()) {
|
|
499
|
+
const i = new MutationObserver(_);
|
|
500
|
+
window.ShadyDOM ? i.observe(this, $) : i.observe(o, $), m.set(this, i);
|
|
500
501
|
}
|
|
501
502
|
return o;
|
|
502
503
|
};
|
|
503
504
|
const t = Element.prototype.attachShadow;
|
|
504
505
|
Element.prototype.attachShadow = r;
|
|
505
506
|
}
|
|
506
|
-
|
|
507
|
+
S() && typeof document < "u" && new MutationObserver(_).observe(document.documentElement, $), typeof HTMLFormElement < "u" && gt(), typeof window < "u" && !window.CustomStateSet && (window.CustomStateSet = V);
|
|
507
508
|
}
|
|
508
509
|
})();
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
return this[p];
|
|
514
|
-
},
|
|
515
|
-
set(h) {
|
|
516
|
-
const u = this[p];
|
|
517
|
-
a.includes(h) ? this[p] = h : (console.error(
|
|
518
|
-
`<${c}> Invalid value "${h}" provided for property "${v}".`,
|
|
519
|
-
`Must be one of: ${a.join(" | ")}.`,
|
|
520
|
-
`Falling back to default value: "${i}"`
|
|
521
|
-
), this[p] = i), this.requestUpdate(v, u);
|
|
522
|
-
}
|
|
523
|
-
});
|
|
524
|
-
};
|
|
525
|
-
function St(c, a) {
|
|
526
|
-
customElements.get(c) ? console.warn(`PIE Web Component: "${c}" has already been defined. Please ensure the component is only being defined once in your application.`) : customElements.define(c, a);
|
|
527
|
-
}
|
|
528
|
-
const Vt = `*,*:before,*:after{box-sizing:border-box}@keyframes rotate360{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.c-spinner{--spinner-size: 24px;--spinner-left-color: hsl(var(--spinner-base-color-h), var(--spinner-base-color-s), var(--spinner-base-color-l), 1);--spinner-right-color: hsl(var(--spinner-base-color-h), var(--spinner-base-color-s), var(--spinner-base-color-l), .35);block-size:var(--spinner-size);inline-size:var(--spinner-size);border-radius:var(--dt-radius-rounded-e);border-width:calc(var(--spinner-size) / 8);border-style:solid;border-color:var(--spinner-left-color) var(--spinner-right-color) var(--spinner-right-color) var(--spinner-left-color);will-change:transform;animation:rotate360 1.15s linear infinite;--spinner-base-color-h: var(--dt-color-content-brand-h);--spinner-base-color-s: var(--dt-color-content-brand-s);--spinner-base-color-l: var(--dt-color-content-brand-l)}.c-spinner[variant=secondary]{--spinner-base-color-h: var(--dt-color-content-interactive-secondary-h);--spinner-base-color-s: var(--dt-color-content-interactive-secondary-s);--spinner-base-color-l: var(--dt-color-content-interactive-secondary-l)}.c-spinner[variant=inverse]{--spinner-base-color-h: var(--dt-color-content-inverse-h);--spinner-base-color-s: var(--dt-color-content-inverse-s);--spinner-base-color-l: var(--dt-color-content-inverse-l)}.c-spinner[size=xs]{--spinner-size: 16px}.c-spinner[size=s]{--spinner-size: 20px}.c-spinner[size=l]{--spinner-size: 32px}.c-spinner[size=xl]{--spinner-size: 48px}.c-spinner-label{position:absolute;display:block;height:1px;width:1px;overflow:hidden;padding:1px;white-space:nowrap}
|
|
529
|
-
`, $t = ["xs", "s", "m", "l", "xl"], Nt = ["brand", "secondary", "inverse"];
|
|
530
|
-
var Pt = Object.defineProperty, _t = Object.getOwnPropertyDescriptor, H = (c, a, i, s) => {
|
|
531
|
-
for (var v = s > 1 ? void 0 : s ? _t(a, i) : a, p = c.length - 1, h; p >= 0; p--)
|
|
532
|
-
(h = c[p]) && (v = (s ? h(a, i, v) : h(v)) || v);
|
|
533
|
-
return s && v && Pt(a, i, v), v;
|
|
534
|
-
};
|
|
535
|
-
const j = "pie-spinner";
|
|
536
|
-
class C extends lt {
|
|
537
|
-
constructor() {
|
|
538
|
-
super(...arguments), this.size = "m", this.variant = "brand";
|
|
539
|
-
}
|
|
540
|
-
render() {
|
|
541
|
-
const { variant: a, size: i, aria: s } = this;
|
|
542
|
-
return M`
|
|
543
|
-
<div
|
|
544
|
-
data-test-id="pie-spinner"
|
|
545
|
-
class="c-spinner"
|
|
546
|
-
role="status"
|
|
547
|
-
aria-live="polite"
|
|
548
|
-
size="${i}"
|
|
549
|
-
variant="${a}">
|
|
550
|
-
${s != null && s.label ? M`<span class="c-spinner-label">${s.label}</span>` : P}
|
|
551
|
-
</div>`;
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
C.styles = st(Vt);
|
|
555
|
-
H([
|
|
556
|
-
b({ type: Object })
|
|
557
|
-
], C.prototype, "aria", 2);
|
|
558
|
-
H([
|
|
559
|
-
b(),
|
|
560
|
-
ct(j, $t, "m")
|
|
561
|
-
], C.prototype, "size", 2);
|
|
562
|
-
H([
|
|
563
|
-
b(),
|
|
564
|
-
ct(j, Nt, "brand")
|
|
565
|
-
], C.prototype, "variant", 2);
|
|
566
|
-
St(j, C);
|
|
567
|
-
var Ot = Object.defineProperty, Dt = Object.getOwnPropertyDescriptor, y = (c, a, i, s) => {
|
|
568
|
-
for (var v = s > 1 ? void 0 : s ? Dt(a, i) : a, p = c.length - 1, h; p >= 0; p--)
|
|
569
|
-
(h = c[p]) && (v = (s ? h(a, i, v) : h(v)) || v);
|
|
570
|
-
return s && v && Ot(a, i, v), v;
|
|
510
|
+
var At = Object.defineProperty, It = Object.getOwnPropertyDescriptor, g = (d, n, a, c) => {
|
|
511
|
+
for (var p = c > 1 ? void 0 : c ? It(n, a) : n, y = d.length - 1, m; y >= 0; y--)
|
|
512
|
+
(m = d[y]) && (p = (c ? m(n, a, p) : m(p)) || p);
|
|
513
|
+
return c && p && At(n, a, p), p;
|
|
571
514
|
};
|
|
572
|
-
const
|
|
573
|
-
class
|
|
515
|
+
const C = "pie-button";
|
|
516
|
+
class h extends Et {
|
|
574
517
|
constructor() {
|
|
575
|
-
super(), this.size = "medium", this.type = "submit", this.variant = "primary", this.iconPlacement = "leading", this.disabled = !1, this.isLoading = !1, this.isFullWidth = !1, this._handleFormKeyDown = (
|
|
576
|
-
if (!(
|
|
577
|
-
if (
|
|
578
|
-
const
|
|
579
|
-
if (
|
|
518
|
+
super(), this.size = "medium", this.type = "submit", this.variant = "primary", this.iconPlacement = "leading", this.disabled = !1, this.isLoading = !1, this.isFullWidth = !1, this._handleFormKeyDown = (n) => {
|
|
519
|
+
if (!(n.key !== "Enter" || this.type !== "submit" || this.disabled)) {
|
|
520
|
+
if (n.target instanceof HTMLElement) {
|
|
521
|
+
const a = n.target.tagName.toLowerCase();
|
|
522
|
+
if (a === "button" || a === "pie-button")
|
|
580
523
|
return;
|
|
581
524
|
}
|
|
582
|
-
|
|
525
|
+
n.preventDefault(), this._handleClick();
|
|
583
526
|
}
|
|
584
527
|
}, this._internals = this.attachInternals();
|
|
585
528
|
}
|
|
@@ -587,16 +530,16 @@ class f extends lt {
|
|
|
587
530
|
return this._internals.form;
|
|
588
531
|
}
|
|
589
532
|
connectedCallback() {
|
|
590
|
-
var
|
|
591
|
-
super.connectedCallback(), this.type === "submit" && ((
|
|
533
|
+
var n;
|
|
534
|
+
super.connectedCallback(), this.type === "submit" && ((n = this.form) == null || n.addEventListener("keydown", this._handleFormKeyDown));
|
|
592
535
|
}
|
|
593
536
|
disconnectedCallback() {
|
|
594
|
-
var
|
|
595
|
-
super.disconnectedCallback(), this.type === "submit" && ((
|
|
537
|
+
var n;
|
|
538
|
+
super.disconnectedCallback(), this.type === "submit" && ((n = this.form) == null || n.removeEventListener("keydown", this._handleFormKeyDown));
|
|
596
539
|
}
|
|
597
|
-
updated(
|
|
598
|
-
var
|
|
599
|
-
super.updated(
|
|
540
|
+
updated(n) {
|
|
541
|
+
var a, c;
|
|
542
|
+
super.updated(n), n.has("type") && (this.type === "submit" ? (a = this.form) == null || a.addEventListener("keydown", this._handleFormKeyDown) : (c = this.form) == null || c.removeEventListener("keydown", this._handleFormKeyDown));
|
|
600
543
|
}
|
|
601
544
|
/**
|
|
602
545
|
* This method creates an invisible button of the same type as pie-button. It is then clicked, and immediately removed from the DOM.
|
|
@@ -606,11 +549,11 @@ class f extends lt {
|
|
|
606
549
|
*
|
|
607
550
|
* TODO: if we need to repeat this logic elsewhere, then we should consider moving this code to a shared class or mixin.
|
|
608
551
|
*/
|
|
609
|
-
_simulateNativeButtonClick(
|
|
552
|
+
_simulateNativeButtonClick(n) {
|
|
610
553
|
if (!this.form)
|
|
611
554
|
return;
|
|
612
|
-
const
|
|
613
|
-
|
|
555
|
+
const a = document.createElement("button");
|
|
556
|
+
a.type = n, a.style.position = "absolute", a.style.width = "1px", a.style.height = "1px", a.style.padding = "0", a.style.margin = "-1px", a.style.overflow = "hidden", a.style.border = "0", a.style.whiteSpace = "nowrap", n === "submit" && (this.name && (a.name = this.name), this.value && (a.value = this.value), this.formaction && a.setAttribute("formaction", this.formaction), this.formenctype && a.setAttribute("formenctype", this.formenctype), this.formmethod && a.setAttribute("formmethod", this.formmethod), this.formnovalidate && a.setAttribute("formnovalidate", "formnovalidate"), this.formtarget && a.setAttribute("formtarget", this.formtarget)), this.form.append(a), a.click(), a.remove();
|
|
614
557
|
}
|
|
615
558
|
_handleClick() {
|
|
616
559
|
!this.isLoading && this.form && (this.type === "submit" && (this.formnovalidate || this.form.reportValidity()) && this._simulateNativeButtonClick("submit"), this.type === "reset" && this._simulateNativeButtonClick("reset"));
|
|
@@ -621,100 +564,100 @@ class f extends lt {
|
|
|
621
564
|
* @private
|
|
622
565
|
*/
|
|
623
566
|
renderSpinner() {
|
|
624
|
-
const
|
|
625
|
-
return
|
|
567
|
+
const n = this.size.includes("small") ? "s" : "m", c = ["primary", "destructive", "outline-inverse", "ghost-inverse"].includes(this.variant) ? "inverse" : "secondary";
|
|
568
|
+
return N`
|
|
626
569
|
<pie-spinner
|
|
627
|
-
size="${
|
|
628
|
-
variant="${
|
|
570
|
+
size="${n}"
|
|
571
|
+
variant="${c}"
|
|
629
572
|
</pie-spinner>`;
|
|
630
573
|
}
|
|
631
574
|
render() {
|
|
632
575
|
const {
|
|
633
|
-
type:
|
|
634
|
-
disabled:
|
|
635
|
-
isFullWidth:
|
|
636
|
-
variant:
|
|
637
|
-
size:
|
|
638
|
-
isLoading:
|
|
576
|
+
type: n,
|
|
577
|
+
disabled: a,
|
|
578
|
+
isFullWidth: c,
|
|
579
|
+
variant: p,
|
|
580
|
+
size: y,
|
|
581
|
+
isLoading: m,
|
|
639
582
|
iconPlacement: u
|
|
640
583
|
} = this;
|
|
641
|
-
return
|
|
584
|
+
return N`
|
|
642
585
|
<button
|
|
643
586
|
@click=${this._handleClick}
|
|
644
587
|
class="o-btn"
|
|
645
|
-
type=${
|
|
646
|
-
variant=${
|
|
647
|
-
size=${
|
|
648
|
-
?disabled=${
|
|
649
|
-
?isFullWidth=${
|
|
650
|
-
?isLoading=${
|
|
651
|
-
${
|
|
652
|
-
${u === "leading" ?
|
|
588
|
+
type=${n}
|
|
589
|
+
variant=${p}
|
|
590
|
+
size=${y}
|
|
591
|
+
?disabled=${a}
|
|
592
|
+
?isFullWidth=${c}
|
|
593
|
+
?isLoading=${m}>
|
|
594
|
+
${m ? this.renderSpinner() : R}
|
|
595
|
+
${u === "leading" ? N`<slot name="icon"></slot>` : R}
|
|
653
596
|
<slot></slot>
|
|
654
|
-
${u === "trailing" ?
|
|
597
|
+
${u === "trailing" ? N`<slot name="icon"></slot>` : R}
|
|
655
598
|
</button>`;
|
|
656
599
|
}
|
|
657
600
|
focus() {
|
|
658
|
-
var
|
|
659
|
-
(
|
|
601
|
+
var n, a;
|
|
602
|
+
(a = (n = this.shadowRoot) == null ? void 0 : n.querySelector("button")) == null || a.focus();
|
|
660
603
|
}
|
|
661
604
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
605
|
+
h.formAssociated = !0;
|
|
606
|
+
h.styles = wt(Ft);
|
|
607
|
+
g([
|
|
665
608
|
b(),
|
|
666
|
-
|
|
667
|
-
],
|
|
668
|
-
|
|
609
|
+
P(C, kt, "medium")
|
|
610
|
+
], h.prototype, "size", 2);
|
|
611
|
+
g([
|
|
669
612
|
b(),
|
|
670
|
-
|
|
671
|
-
],
|
|
672
|
-
|
|
613
|
+
P(C, Mt, "submit")
|
|
614
|
+
], h.prototype, "type", 2);
|
|
615
|
+
g([
|
|
673
616
|
b(),
|
|
674
|
-
|
|
675
|
-
],
|
|
676
|
-
|
|
617
|
+
P(C, Ct, "primary")
|
|
618
|
+
], h.prototype, "variant", 2);
|
|
619
|
+
g([
|
|
677
620
|
b({ type: String }),
|
|
678
|
-
|
|
679
|
-
],
|
|
680
|
-
|
|
621
|
+
P(C, Lt, "leading")
|
|
622
|
+
], h.prototype, "iconPlacement", 2);
|
|
623
|
+
g([
|
|
681
624
|
b({ type: Boolean })
|
|
682
|
-
],
|
|
683
|
-
|
|
625
|
+
], h.prototype, "disabled", 2);
|
|
626
|
+
g([
|
|
684
627
|
b({ type: Boolean, reflect: !0 })
|
|
685
|
-
],
|
|
686
|
-
|
|
628
|
+
], h.prototype, "isLoading", 2);
|
|
629
|
+
g([
|
|
687
630
|
b({ type: Boolean })
|
|
688
|
-
],
|
|
689
|
-
|
|
631
|
+
], h.prototype, "isFullWidth", 2);
|
|
632
|
+
g([
|
|
690
633
|
b({ type: String })
|
|
691
|
-
],
|
|
692
|
-
|
|
634
|
+
], h.prototype, "name", 2);
|
|
635
|
+
g([
|
|
693
636
|
b({ type: String })
|
|
694
|
-
],
|
|
695
|
-
|
|
637
|
+
], h.prototype, "value", 2);
|
|
638
|
+
g([
|
|
696
639
|
b()
|
|
697
|
-
],
|
|
698
|
-
|
|
640
|
+
], h.prototype, "formaction", 2);
|
|
641
|
+
g([
|
|
699
642
|
b()
|
|
700
|
-
],
|
|
701
|
-
|
|
643
|
+
], h.prototype, "formenctype", 2);
|
|
644
|
+
g([
|
|
702
645
|
b()
|
|
703
|
-
],
|
|
704
|
-
|
|
646
|
+
], h.prototype, "formmethod", 2);
|
|
647
|
+
g([
|
|
705
648
|
b({ type: Boolean })
|
|
706
|
-
],
|
|
707
|
-
|
|
649
|
+
], h.prototype, "formnovalidate", 2);
|
|
650
|
+
g([
|
|
708
651
|
b()
|
|
709
|
-
],
|
|
710
|
-
|
|
652
|
+
], h.prototype, "formtarget", 2);
|
|
653
|
+
xt(C, h);
|
|
711
654
|
export {
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
655
|
+
h as PieButton,
|
|
656
|
+
Vt as formEncodingtypes,
|
|
657
|
+
Nt as formMethodTypes,
|
|
658
|
+
Pt as formTargetTypes,
|
|
659
|
+
Lt as iconPlacements,
|
|
660
|
+
kt as sizes,
|
|
661
|
+
Mt as types,
|
|
662
|
+
Ct as variants
|
|
720
663
|
};
|
package/dist/react.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as w from "react";
|
|
2
2
|
import { PieButton as E } from "./index.js";
|
|
3
|
-
import { formEncodingtypes as
|
|
3
|
+
import { formEncodingtypes as k, formMethodTypes as A, formTargetTypes as D, iconPlacements as G, sizes as H, types as O, variants as S } from "./index.js";
|
|
4
4
|
import "lit";
|
|
5
5
|
import "lit/decorators.js";
|
|
6
|
+
import "@justeattakeaway/pie-spinner";
|
|
6
7
|
/**
|
|
7
8
|
* @license
|
|
8
9
|
* Copyright 2018 Google LLC
|
|
@@ -58,7 +59,7 @@ function B(t = window.React, o, m, p, d) {
|
|
|
58
59
|
const N = i.forwardRef((c, e) => a(f, { ...c, _$Gl: e }, c == null ? void 0 : c.children));
|
|
59
60
|
return N.displayName = f.displayName, N;
|
|
60
61
|
}
|
|
61
|
-
const
|
|
62
|
+
const R = B({
|
|
62
63
|
displayName: "PieButton",
|
|
63
64
|
elementClass: E,
|
|
64
65
|
react: w,
|
|
@@ -66,12 +67,12 @@ const L = B({
|
|
|
66
67
|
events: {}
|
|
67
68
|
});
|
|
68
69
|
export {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
R as PieButton,
|
|
71
|
+
k as formEncodingtypes,
|
|
72
|
+
A as formMethodTypes,
|
|
73
|
+
D as formTargetTypes,
|
|
74
|
+
G as iconPlacements,
|
|
75
|
+
H as sizes,
|
|
76
|
+
O as types,
|
|
77
|
+
S as variants
|
|
77
78
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-button",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.1",
|
|
4
4
|
"description": "PIE design system button built using web components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
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.
|
|
31
|
+
"@justeattakeaway/pie-components-config": "0.5.0"
|
|
32
32
|
},
|
|
33
33
|
"volta": {
|
|
34
34
|
"extends": "../../../package.json"
|