@justeattakeaway/pie-text-input 0.27.0 → 0.27.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.d.ts +1 -1
- package/dist/index.js +137 -138
- package/dist/react.d.ts +1 -1
- package/package.json +5 -5
- package/declaration.d.ts +0 -9
package/dist/index.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export declare class PieTextInput extends PieTextInput_base implements TextInput
|
|
|
49
49
|
readonly: boolean;
|
|
50
50
|
defaultValue: TextInputProps['defaultValue'];
|
|
51
51
|
assistiveText: TextInputProps['assistiveText'];
|
|
52
|
-
status: "default" | "
|
|
52
|
+
status: "default" | "success" | "error";
|
|
53
53
|
step: TextInputProps['step'];
|
|
54
54
|
min: TextInputProps['min'];
|
|
55
55
|
max: TextInputProps['max'];
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import { property as u, query as
|
|
3
|
-
import { ifDefined as
|
|
1
|
+
import { LitElement as ht, nothing as Nt, html as pt, unsafeCSS as Lt } from "lit";
|
|
2
|
+
import { property as u, query as ft } from "lit/decorators.js";
|
|
3
|
+
import { ifDefined as f } from "lit/directives/if-defined.js";
|
|
4
4
|
import { classMap as $t } from "lit/directives/class-map.js";
|
|
5
5
|
import { live as mt } from "lit/directives/live.js";
|
|
6
6
|
import { FormControlMixin as Ot, RtlMixin as Rt, wrapNativeEvent as Pt, validPropertyValues as Z, defineCustomElement as _t } from "@justeattakeaway/pie-webc-core";
|
|
7
7
|
import "@justeattakeaway/pie-assistive-text";
|
|
8
|
-
var Ht = Object.defineProperty, Dt = (
|
|
9
|
-
for (var s = void 0, g =
|
|
10
|
-
(E =
|
|
11
|
-
return s && Ht(l,
|
|
8
|
+
var Ht = Object.defineProperty, Dt = (v, l, h, x) => {
|
|
9
|
+
for (var s = void 0, g = v.length - 1, E; g >= 0; g--)
|
|
10
|
+
(E = v[g]) && (s = E(l, h, s) || s);
|
|
11
|
+
return s && Ht(l, h, s), s;
|
|
12
12
|
};
|
|
13
|
-
class gt extends
|
|
13
|
+
class gt extends ht {
|
|
14
14
|
constructor() {
|
|
15
|
-
super(...arguments), this.v = "0.27.
|
|
15
|
+
super(...arguments), this.v = "0.27.1";
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
Dt([
|
|
@@ -27,8 +27,8 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
27
27
|
readonly: !1
|
|
28
28
|
};
|
|
29
29
|
(function() {
|
|
30
|
-
(function(
|
|
31
|
-
const l = /* @__PURE__ */ new WeakMap(),
|
|
30
|
+
(function(v) {
|
|
31
|
+
const l = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new WeakMap(), x = /* @__PURE__ */ new WeakMap(), s = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), V = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakMap(), $ = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), C = {
|
|
32
32
|
ariaAtomic: "aria-atomic",
|
|
33
33
|
ariaAutoComplete: "aria-autocomplete",
|
|
34
34
|
ariaBusy: "aria-busy",
|
|
@@ -74,21 +74,21 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
74
74
|
}, B = (e, t) => {
|
|
75
75
|
for (let a in C) {
|
|
76
76
|
t[a] = null;
|
|
77
|
-
let
|
|
78
|
-
const
|
|
77
|
+
let i = null;
|
|
78
|
+
const n = C[a];
|
|
79
79
|
Object.defineProperty(t, a, {
|
|
80
80
|
get() {
|
|
81
|
-
return
|
|
81
|
+
return i;
|
|
82
82
|
},
|
|
83
83
|
set(o) {
|
|
84
|
-
|
|
84
|
+
i = o, e.isConnected ? e.setAttribute(n, o) : S.set(e, t);
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
function O(e) {
|
|
90
90
|
const t = s.get(e), { form: a } = t;
|
|
91
|
-
|
|
91
|
+
it(e, a, t), at(e, t.labels);
|
|
92
92
|
}
|
|
93
93
|
const R = (e, t = !1) => {
|
|
94
94
|
const a = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
|
|
@@ -96,23 +96,23 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
96
96
|
return s.has(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
|
-
let
|
|
100
|
-
const
|
|
101
|
-
for (;
|
|
102
|
-
|
|
99
|
+
let i = a.nextNode();
|
|
100
|
+
const n = !t || e.disabled;
|
|
101
|
+
for (; i; )
|
|
102
|
+
i.formDisabledCallback && n && K(i, e.disabled), i = a.nextNode();
|
|
103
103
|
}, P = { attributes: !0, attributeFilter: ["disabled", "name"] }, _ = z() ? new MutationObserver((e) => {
|
|
104
104
|
for (const t of e) {
|
|
105
105
|
const a = t.target;
|
|
106
106
|
if (t.attributeName === "disabled" && (a.constructor.formAssociated ? K(a, a.hasAttribute("disabled")) : a.localName === "fieldset" && R(a)), t.attributeName === "name" && a.constructor.formAssociated) {
|
|
107
|
-
const
|
|
108
|
-
|
|
107
|
+
const i = s.get(a), n = V.get(a);
|
|
108
|
+
i.setFormValue(n);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
}) : {};
|
|
112
112
|
function U(e) {
|
|
113
113
|
e.forEach((t) => {
|
|
114
|
-
const { addedNodes: a, removedNodes:
|
|
115
|
-
|
|
114
|
+
const { addedNodes: a, removedNodes: i } = t, n = Array.from(a), o = Array.from(i);
|
|
115
|
+
n.forEach((r) => {
|
|
116
116
|
var m;
|
|
117
117
|
if (s.has(r) && r.constructor.formAssociated && O(r), S.has(r)) {
|
|
118
118
|
const p = S.get(r);
|
|
@@ -125,7 +125,7 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
125
125
|
r.setAttribute("internals-valid", p.validity.valid.toString()), r.setAttribute("internals-invalid", (!p.validity.valid).toString()), r.setAttribute("aria-invalid", (!p.validity.valid).toString()), I.delete(r);
|
|
126
126
|
}
|
|
127
127
|
if (r.localName === "form") {
|
|
128
|
-
const p =
|
|
128
|
+
const p = y.get(r), k = document.createTreeWalker(r, NodeFilter.SHOW_ELEMENT, {
|
|
129
129
|
acceptNode(X) {
|
|
130
130
|
return s.has(X) && X.constructor.formAssociated && !(p && p.has(X)) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
131
131
|
}
|
|
@@ -137,23 +137,23 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
137
137
|
r.localName === "fieldset" && ((m = _.observe) === null || m === void 0 || m.call(_, r, P), R(r, !0));
|
|
138
138
|
}), o.forEach((r) => {
|
|
139
139
|
const m = s.get(r);
|
|
140
|
-
m && x.get(m) && tt(m),
|
|
140
|
+
m && x.get(m) && tt(m), F.has(r) && F.get(r).disconnect();
|
|
141
141
|
});
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function vt(e) {
|
|
145
145
|
e.forEach((t) => {
|
|
146
146
|
const { removedNodes: a } = t;
|
|
147
|
-
a.forEach((
|
|
148
|
-
const
|
|
149
|
-
s.has(
|
|
147
|
+
a.forEach((i) => {
|
|
148
|
+
const n = $.get(t.target);
|
|
149
|
+
s.has(i) && ot(i), n.disconnect();
|
|
150
150
|
});
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
|
-
const
|
|
153
|
+
const yt = (e) => {
|
|
154
154
|
var t, a;
|
|
155
|
-
const
|
|
156
|
-
!((t = window == null ? void 0 : window.ShadyDOM) === null || t === void 0) && t.inUse && e.mode && e.host && (e = e.host), (a =
|
|
155
|
+
const i = new MutationObserver(vt);
|
|
156
|
+
!((t = window == null ? void 0 : window.ShadyDOM) === null || t === void 0) && t.inUse && e.mode && e.host && (e = e.host), (a = i.observe) === null || a === void 0 || a.call(i, e, { childList: !0 }), $.set(e, i);
|
|
157
157
|
};
|
|
158
158
|
z() && new MutationObserver(U);
|
|
159
159
|
const j = {
|
|
@@ -173,13 +173,13 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
173
173
|
x.set(t, []), (a = _.observe) === null || a === void 0 || a.call(_, e, P);
|
|
174
174
|
}, at = (e, t) => {
|
|
175
175
|
if (t.length) {
|
|
176
|
-
Array.from(t).forEach((
|
|
176
|
+
Array.from(t).forEach((i) => i.addEventListener("click", e.click.bind(e)));
|
|
177
177
|
let a = t[0].id;
|
|
178
178
|
t[0].id || (a = `${t[0].htmlFor}_Label`, t[0].id = a), e.setAttribute("aria-labelledby", a);
|
|
179
179
|
}
|
|
180
180
|
}, H = (e) => {
|
|
181
|
-
const t = Array.from(e.elements).filter((o) => !o.tagName.includes("-") && o.validity).map((o) => o.validity.valid), a =
|
|
182
|
-
e.toggleAttribute("internals-invalid",
|
|
181
|
+
const t = Array.from(e.elements).filter((o) => !o.tagName.includes("-") && o.validity).map((o) => o.validity.valid), a = y.get(e) || [], i = Array.from(a).filter((o) => o.isConnected).map((o) => s.get(o).validity.valid), n = [...t, ...i].includes(!1);
|
|
182
|
+
e.toggleAttribute("internals-invalid", n), e.toggleAttribute("internals-valid", !n);
|
|
183
183
|
}, wt = (e) => {
|
|
184
184
|
H(D(e.target));
|
|
185
185
|
}, xt = (e) => {
|
|
@@ -188,25 +188,25 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
188
188
|
const t = ["button[type=submit]", "input[type=submit]", "button:not([type])"].map((a) => `${a}:not([disabled])`).map((a) => `${a}:not([form])${e.id ? `,${a}[form='${e.id}']` : ""}`).join(",");
|
|
189
189
|
e.addEventListener("click", (a) => {
|
|
190
190
|
if (a.target.closest(t)) {
|
|
191
|
-
const
|
|
191
|
+
const n = y.get(e);
|
|
192
192
|
if (e.noValidate)
|
|
193
193
|
return;
|
|
194
|
-
|
|
194
|
+
n.size && Array.from(n).reverse().map((m) => s.get(m).reportValidity()).includes(!1) && a.preventDefault();
|
|
195
195
|
}
|
|
196
196
|
});
|
|
197
197
|
}, It = (e) => {
|
|
198
|
-
const t =
|
|
198
|
+
const t = y.get(e.target);
|
|
199
199
|
t && t.size && t.forEach((a) => {
|
|
200
200
|
a.constructor.formAssociated && a.formResetCallback && a.formResetCallback.apply(a);
|
|
201
201
|
});
|
|
202
|
-
},
|
|
202
|
+
}, it = (e, t, a) => {
|
|
203
203
|
if (t) {
|
|
204
|
-
const
|
|
205
|
-
if (
|
|
206
|
-
|
|
204
|
+
const i = y.get(t);
|
|
205
|
+
if (i)
|
|
206
|
+
i.add(e);
|
|
207
207
|
else {
|
|
208
|
-
const
|
|
209
|
-
|
|
208
|
+
const n = /* @__PURE__ */ new Set();
|
|
209
|
+
n.add(e), y.set(t, n), Et(t), t.addEventListener("reset", It), t.addEventListener("input", wt), t.addEventListener("change", xt);
|
|
210
210
|
}
|
|
211
211
|
E.set(t, { ref: e, internals: a }), e.constructor.formAssociated && e.formAssociatedCallback && setTimeout(() => {
|
|
212
212
|
e.formAssociatedCallback.apply(e, [t]);
|
|
@@ -218,15 +218,15 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
218
218
|
}, M = (e, t, a = DOMException) => {
|
|
219
219
|
if (!e.constructor.formAssociated)
|
|
220
220
|
throw new a(t);
|
|
221
|
-
},
|
|
222
|
-
const
|
|
223
|
-
return
|
|
224
|
-
s.get(
|
|
221
|
+
}, nt = (e, t, a) => {
|
|
222
|
+
const i = y.get(e);
|
|
223
|
+
return i && i.size && i.forEach((n) => {
|
|
224
|
+
s.get(n)[a]() || (t = !1);
|
|
225
225
|
}), t;
|
|
226
226
|
}, ot = (e) => {
|
|
227
227
|
if (e.constructor.formAssociated) {
|
|
228
|
-
const t = s.get(e), { labels: a, form:
|
|
229
|
-
at(e, a),
|
|
228
|
+
const t = s.get(e), { labels: a, form: i } = t;
|
|
229
|
+
at(e, a), it(e, i, t);
|
|
230
230
|
}
|
|
231
231
|
};
|
|
232
232
|
function z() {
|
|
@@ -237,7 +237,7 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
237
237
|
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);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
const kt = (e) => (e.badInput = !1, e.customError = !1, e.patternMismatch = !1, e.rangeOverflow = !1, e.rangeUnderflow = !1, e.stepMismatch = !1, e.tooLong = !1, e.tooShort = !1, e.typeMismatch = !1, e.valid = !0, e.valueMissing = !1, e), St = (e, t, a) => (e.valid = Ct(t), Object.keys(t).forEach((
|
|
240
|
+
const kt = (e) => (e.badInput = !1, e.customError = !1, e.patternMismatch = !1, e.rangeOverflow = !1, e.rangeUnderflow = !1, e.stepMismatch = !1, e.tooLong = !1, e.tooShort = !1, e.typeMismatch = !1, e.valid = !0, e.valueMissing = !1, e), St = (e, t, a) => (e.valid = Ct(t), Object.keys(t).forEach((i) => e[i] = t[i]), a && H(a), e), Ct = (e) => {
|
|
241
241
|
let t = !0;
|
|
242
242
|
for (let a in e)
|
|
243
243
|
a !== "valid" && e[a] !== !1 && (t = !1);
|
|
@@ -258,9 +258,9 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
258
258
|
add(t) {
|
|
259
259
|
if (!/^--/.test(t) || typeof t != "string")
|
|
260
260
|
throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${t} must start with '--'.`);
|
|
261
|
-
const a = super.add(t),
|
|
262
|
-
return
|
|
263
|
-
rt(
|
|
261
|
+
const a = super.add(t), i = G.get(this), n = `state${t}`;
|
|
262
|
+
return i.isConnected ? rt(i, n) : setTimeout(() => {
|
|
263
|
+
rt(i, n);
|
|
264
264
|
}), a;
|
|
265
265
|
}
|
|
266
266
|
clear() {
|
|
@@ -269,28 +269,27 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
269
269
|
super.clear();
|
|
270
270
|
}
|
|
271
271
|
delete(t) {
|
|
272
|
-
const a = super.delete(t),
|
|
273
|
-
return
|
|
274
|
-
|
|
272
|
+
const a = super.delete(t), i = G.get(this);
|
|
273
|
+
return i.isConnected ? (i.toggleAttribute(`state${t}`, !1), i.part && i.part.remove(`state${t}`)) : setTimeout(() => {
|
|
274
|
+
i.toggleAttribute(`state${t}`, !1), i.part && i.part.remove(`state${t}`);
|
|
275
275
|
}), a;
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
|
-
function st(e, t, a,
|
|
279
|
-
if (
|
|
280
|
-
|
|
281
|
-
return a === "m" ? n : a === "a" ? n.call(e) : n ? n.value : t.get(e);
|
|
278
|
+
function st(e, t, a, i) {
|
|
279
|
+
if (typeof t == "function" ? e !== t || !0 : !t.has(e)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
280
|
+
return a === "m" ? i : a === "a" ? i.call(e) : i ? i.value : t.get(e);
|
|
282
281
|
}
|
|
283
|
-
function
|
|
282
|
+
function Ft(e, t, a, i, n) {
|
|
284
283
|
if (typeof t == "function" ? e !== t || !0 : !t.has(e)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
285
284
|
return t.set(e, a), a;
|
|
286
285
|
}
|
|
287
286
|
var A;
|
|
288
|
-
class
|
|
287
|
+
class Tt {
|
|
289
288
|
constructor(t) {
|
|
290
|
-
A.set(this, void 0),
|
|
289
|
+
A.set(this, void 0), Ft(this, A, t);
|
|
291
290
|
for (let a = 0; a < t.length; a++) {
|
|
292
|
-
let
|
|
293
|
-
this[a] =
|
|
291
|
+
let i = t[a];
|
|
292
|
+
this[a] = i, i.hasAttribute("name") && (this[i.getAttribute("name")] = i);
|
|
294
293
|
}
|
|
295
294
|
Object.freeze(this);
|
|
296
295
|
}
|
|
@@ -311,23 +310,23 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
311
310
|
const e = HTMLFormElement.prototype.checkValidity;
|
|
312
311
|
HTMLFormElement.prototype.checkValidity = a;
|
|
313
312
|
const t = HTMLFormElement.prototype.reportValidity;
|
|
314
|
-
HTMLFormElement.prototype.reportValidity =
|
|
313
|
+
HTMLFormElement.prototype.reportValidity = i;
|
|
315
314
|
function a(...o) {
|
|
316
315
|
let r = e.apply(this, o);
|
|
317
|
-
return
|
|
316
|
+
return nt(this, r, "checkValidity");
|
|
318
317
|
}
|
|
319
|
-
function
|
|
318
|
+
function i(...o) {
|
|
320
319
|
let r = t.apply(this, o);
|
|
321
|
-
return
|
|
320
|
+
return nt(this, r, "reportValidity");
|
|
322
321
|
}
|
|
323
|
-
const { get:
|
|
322
|
+
const { get: n } = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, "elements");
|
|
324
323
|
Object.defineProperty(HTMLFormElement.prototype, "elements", {
|
|
325
324
|
get(...o) {
|
|
326
|
-
const r =
|
|
325
|
+
const r = n.call(this, ...o), m = Array.from(y.get(this) || []);
|
|
327
326
|
if (m.length === 0)
|
|
328
327
|
return r;
|
|
329
328
|
const p = Array.from(r).concat(m).sort((k, b) => k.compareDocumentPosition ? k.compareDocumentPosition(b) & 2 ? 1 : -1 : 0);
|
|
330
|
-
return new
|
|
329
|
+
return new Tt(p);
|
|
331
330
|
}
|
|
332
331
|
});
|
|
333
332
|
}
|
|
@@ -338,21 +337,21 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
338
337
|
constructor(t) {
|
|
339
338
|
if (!t || !t.tagName || t.tagName.indexOf("-") === -1)
|
|
340
339
|
throw new TypeError("Illegal constructor");
|
|
341
|
-
const a = t.getRootNode(),
|
|
342
|
-
this.states = new J(t), l.set(this, t),
|
|
340
|
+
const a = t.getRootNode(), i = new Mt();
|
|
341
|
+
this.states = new J(t), l.set(this, t), h.set(this, i), s.set(t, this), B(t, this), bt(t, this), Object.seal(this), a instanceof DocumentFragment && yt(a);
|
|
343
342
|
}
|
|
344
343
|
checkValidity() {
|
|
345
344
|
const t = l.get(this);
|
|
346
345
|
if (M(t, "Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
|
|
347
346
|
return !0;
|
|
348
|
-
const a =
|
|
347
|
+
const a = h.get(this);
|
|
349
348
|
if (!a.valid) {
|
|
350
|
-
const
|
|
349
|
+
const i = new Event("invalid", {
|
|
351
350
|
bubbles: !1,
|
|
352
351
|
cancelable: !0,
|
|
353
352
|
composed: !1
|
|
354
353
|
});
|
|
355
|
-
t.dispatchEvent(
|
|
354
|
+
t.dispatchEvent(i);
|
|
356
355
|
}
|
|
357
356
|
return a.valid;
|
|
358
357
|
}
|
|
@@ -365,39 +364,39 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
365
364
|
get labels() {
|
|
366
365
|
const t = l.get(this);
|
|
367
366
|
M(t, "Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.");
|
|
368
|
-
const a = t.getAttribute("id"),
|
|
369
|
-
return
|
|
367
|
+
const a = t.getAttribute("id"), i = t.getRootNode();
|
|
368
|
+
return i && a ? i.querySelectorAll(`[for="${a}"]`) : [];
|
|
370
369
|
}
|
|
371
370
|
reportValidity() {
|
|
372
371
|
const t = l.get(this);
|
|
373
372
|
if (M(t, "Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
|
|
374
373
|
return !0;
|
|
375
|
-
const a = this.checkValidity(),
|
|
376
|
-
if (
|
|
374
|
+
const a = this.checkValidity(), i = L.get(this);
|
|
375
|
+
if (i && !t.constructor.formAssociated)
|
|
377
376
|
throw new DOMException("Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.");
|
|
378
|
-
return !a &&
|
|
377
|
+
return !a && i && (t.focus(), i.focus()), a;
|
|
379
378
|
}
|
|
380
379
|
setFormValue(t) {
|
|
381
380
|
const a = l.get(this);
|
|
382
381
|
if (M(a, "Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element."), tt(this), t != null && !(t instanceof FormData)) {
|
|
383
382
|
if (a.getAttribute("name")) {
|
|
384
|
-
const
|
|
385
|
-
|
|
383
|
+
const i = et(a, this);
|
|
384
|
+
i.value = t;
|
|
386
385
|
}
|
|
387
|
-
} else t != null && t instanceof FormData && Array.from(t).reverse().forEach(([
|
|
388
|
-
if (typeof
|
|
386
|
+
} else t != null && t instanceof FormData && Array.from(t).reverse().forEach(([i, n]) => {
|
|
387
|
+
if (typeof n == "string") {
|
|
389
388
|
const o = et(a, this);
|
|
390
|
-
o.name =
|
|
389
|
+
o.name = i, o.value = n;
|
|
391
390
|
}
|
|
392
391
|
});
|
|
393
392
|
V.set(a, t);
|
|
394
393
|
}
|
|
395
|
-
setValidity(t, a,
|
|
396
|
-
const
|
|
397
|
-
if (M(
|
|
394
|
+
setValidity(t, a, i) {
|
|
395
|
+
const n = l.get(this);
|
|
396
|
+
if (M(n, "Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !t)
|
|
398
397
|
throw new TypeError("Failed to execute 'setValidity' on 'ElementInternals': 1 argument required, but only 0 present.");
|
|
399
|
-
L.set(this,
|
|
400
|
-
const o =
|
|
398
|
+
L.set(this, i);
|
|
399
|
+
const o = h.get(this), r = {};
|
|
401
400
|
for (const k in t)
|
|
402
401
|
r[k] = t[k];
|
|
403
402
|
Object.keys(r).length === 0 && kt(o);
|
|
@@ -406,7 +405,7 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
406
405
|
const { valid: p } = St(o, m, this.form);
|
|
407
406
|
if (!p && !a)
|
|
408
407
|
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.");
|
|
409
|
-
g.set(this, p ? "" : a),
|
|
408
|
+
g.set(this, p ? "" : a), n.isConnected ? (n.toggleAttribute("internals-invalid", !p), n.toggleAttribute("internals-valid", p), n.setAttribute("aria-invalid", `${!p}`)) : I.set(n, this);
|
|
410
409
|
}
|
|
411
410
|
get shadowRoot() {
|
|
412
411
|
const t = l.get(this), a = N.get(t);
|
|
@@ -418,7 +417,7 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
418
417
|
}
|
|
419
418
|
get validity() {
|
|
420
419
|
const t = l.get(this);
|
|
421
|
-
return M(t, "Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element."),
|
|
420
|
+
return M(t, "Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element."), h.get(this);
|
|
422
421
|
}
|
|
423
422
|
get willValidate() {
|
|
424
423
|
const t = l.get(this);
|
|
@@ -447,7 +446,7 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
447
446
|
"setValidity",
|
|
448
447
|
"checkValidity",
|
|
449
448
|
"reportValidity"
|
|
450
|
-
].every((
|
|
449
|
+
].every((i) => i in a.internals);
|
|
451
450
|
}
|
|
452
451
|
let ct = !1, dt = !1;
|
|
453
452
|
function Q(e) {
|
|
@@ -460,14 +459,14 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
460
459
|
if (!ct) {
|
|
461
460
|
if (ct = !0, typeof window < "u" && (window.ElementInternals = lt), typeof CustomElementRegistry < "u") {
|
|
462
461
|
const t = CustomElementRegistry.prototype.define;
|
|
463
|
-
CustomElementRegistry.prototype.define = function(a,
|
|
464
|
-
if (
|
|
465
|
-
const o =
|
|
466
|
-
|
|
467
|
-
|
|
462
|
+
CustomElementRegistry.prototype.define = function(a, i, n) {
|
|
463
|
+
if (i.formAssociated) {
|
|
464
|
+
const o = i.prototype.connectedCallback;
|
|
465
|
+
i.prototype.connectedCallback = function() {
|
|
466
|
+
T.has(this) || (T.set(this, !0), this.hasAttribute("disabled") && K(this, !0)), o != null && o.apply(this), ot(this);
|
|
468
467
|
};
|
|
469
468
|
}
|
|
470
|
-
t.call(this, a,
|
|
469
|
+
t.call(this, a, i, n);
|
|
471
470
|
};
|
|
472
471
|
}
|
|
473
472
|
if (typeof HTMLElement < "u" && (HTMLElement.prototype.attachInternals = function() {
|
|
@@ -479,13 +478,13 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
479
478
|
throw new DOMException("DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.");
|
|
480
479
|
return new lt(this);
|
|
481
480
|
}), typeof Element < "u") {
|
|
482
|
-
let t = function(...
|
|
483
|
-
const
|
|
484
|
-
if (N.set(this,
|
|
481
|
+
let t = function(...i) {
|
|
482
|
+
const n = a.apply(this, i);
|
|
483
|
+
if (N.set(this, n), z()) {
|
|
485
484
|
const o = new MutationObserver(U);
|
|
486
|
-
window.ShadyDOM ? o.observe(this, j) : o.observe(
|
|
485
|
+
window.ShadyDOM ? o.observe(this, j) : o.observe(n, j), F.set(this, o);
|
|
487
486
|
}
|
|
488
|
-
return
|
|
487
|
+
return n;
|
|
489
488
|
};
|
|
490
489
|
const a = Element.prototype.attachShadow;
|
|
491
490
|
Element.prototype.attachShadow = t;
|
|
@@ -493,21 +492,21 @@ const zt = "*,*:after,*:before{box-sizing:inherit}.c-textInput{--input-padding-b
|
|
|
493
492
|
z() && typeof document < "u" && new MutationObserver(U).observe(document.documentElement, j), typeof HTMLFormElement < "u" && At(), (e || typeof window < "u" && !window.CustomStateSet) && Q();
|
|
494
493
|
}
|
|
495
494
|
}
|
|
496
|
-
return !!customElements.polyfillWrapFlushCallback || (Vt() ? typeof window < "u" && !window.CustomStateSet && Q(HTMLElement.prototype.attachInternals) : ut(!1)),
|
|
495
|
+
return !!customElements.polyfillWrapFlushCallback || (Vt() ? typeof window < "u" && !window.CustomStateSet && Q(HTMLElement.prototype.attachInternals) : ut(!1)), v.forceCustomStateSetPolyfill = Q, v.forceElementInternalsPolyfill = ut, Object.defineProperty(v, "__esModule", { value: !0 }), v;
|
|
497
496
|
})({});
|
|
498
497
|
})();
|
|
499
|
-
var Ut = Object.defineProperty, d = (
|
|
500
|
-
for (var s = void 0, g =
|
|
501
|
-
(E =
|
|
502
|
-
return s && Ut(l,
|
|
498
|
+
var Ut = Object.defineProperty, d = (v, l, h, x) => {
|
|
499
|
+
for (var s = void 0, g = v.length - 1, E; g >= 0; g--)
|
|
500
|
+
(E = v[g]) && (s = E(l, h, s) || s);
|
|
501
|
+
return s && Ut(l, h, s), s;
|
|
503
502
|
};
|
|
504
503
|
const q = "pie-text-input", Y = "assistive-text", W = class W extends Ot(Rt(gt)) {
|
|
505
504
|
constructor() {
|
|
506
505
|
super(...arguments), this.type = w.type, this.value = w.value, this.disabled = w.disabled, this.readonly = w.readonly, this.status = w.status, this.size = w.size, this.required = !1, this.handleInput = (l) => {
|
|
507
506
|
this.value = l.target.value, this._internals.setFormValue(this.value);
|
|
508
507
|
}, this.handleChange = (l) => {
|
|
509
|
-
const
|
|
510
|
-
this.dispatchEvent(
|
|
508
|
+
const h = Pt(l);
|
|
509
|
+
this.dispatchEvent(h);
|
|
511
510
|
};
|
|
512
511
|
}
|
|
513
512
|
/**
|
|
@@ -542,19 +541,19 @@ const q = "pie-text-input", Y = "assistive-text", W = class W extends Ot(Rt(gt))
|
|
|
542
541
|
render() {
|
|
543
542
|
const {
|
|
544
543
|
assistiveText: l,
|
|
545
|
-
autocomplete:
|
|
544
|
+
autocomplete: h,
|
|
546
545
|
autoFocus: x,
|
|
547
546
|
disabled: s,
|
|
548
547
|
inputmode: g,
|
|
549
548
|
maxlength: E,
|
|
550
|
-
minlength:
|
|
551
|
-
min:
|
|
549
|
+
minlength: F,
|
|
550
|
+
min: y,
|
|
552
551
|
max: V,
|
|
553
552
|
name: S,
|
|
554
553
|
pattern: N,
|
|
555
554
|
step: L,
|
|
556
555
|
placeholder: $,
|
|
557
|
-
readonly:
|
|
556
|
+
readonly: T,
|
|
558
557
|
status: I,
|
|
559
558
|
type: C,
|
|
560
559
|
value: B,
|
|
@@ -565,7 +564,7 @@ const q = "pie-text-input", Y = "assistive-text", W = class W extends Ot(Rt(gt))
|
|
|
565
564
|
[`c-textInput--${O}`]: !0,
|
|
566
565
|
[`c-textInput--${I}`]: !0,
|
|
567
566
|
"is-disabled": s,
|
|
568
|
-
"c-textInput--readonly":
|
|
567
|
+
"c-textInput--readonly": T
|
|
569
568
|
};
|
|
570
569
|
return pt`
|
|
571
570
|
<div
|
|
@@ -578,25 +577,25 @@ const q = "pie-text-input", Y = "assistive-text", W = class W extends Ot(Rt(gt))
|
|
|
578
577
|
<slot name="leadingIcon"></slot>
|
|
579
578
|
<slot name="leadingText"></slot>
|
|
580
579
|
<input
|
|
581
|
-
type=${
|
|
580
|
+
type=${f(C)}
|
|
582
581
|
.value=${mt(B)}
|
|
583
|
-
name=${
|
|
582
|
+
name=${f(S)}
|
|
584
583
|
?disabled=${mt(s)}
|
|
585
|
-
pattern=${
|
|
586
|
-
step=${
|
|
587
|
-
minlength=${
|
|
588
|
-
maxlength=${
|
|
589
|
-
min=${
|
|
590
|
-
max=${
|
|
591
|
-
autocomplete=${h
|
|
584
|
+
pattern=${f(N)}
|
|
585
|
+
step=${f(L)}
|
|
586
|
+
minlength=${f(F)}
|
|
587
|
+
maxlength=${f(E)}
|
|
588
|
+
min=${f(y)}
|
|
589
|
+
max=${f(V)}
|
|
590
|
+
autocomplete=${f(h)}
|
|
592
591
|
?autofocus=${x}
|
|
593
|
-
inputmode=${
|
|
594
|
-
placeholder=${
|
|
595
|
-
?readonly=${
|
|
592
|
+
inputmode=${f(g)}
|
|
593
|
+
placeholder=${f($)}
|
|
594
|
+
?readonly=${T}
|
|
596
595
|
?required=${R}
|
|
597
|
-
aria-describedby=${
|
|
596
|
+
aria-describedby=${f(l ? Y : void 0)}
|
|
598
597
|
aria-invalid=${I === "error" ? "true" : "false"}
|
|
599
|
-
aria-errormessage="${
|
|
598
|
+
aria-errormessage="${f(I === "error" ? Y : void 0)}"
|
|
600
599
|
@input=${this.handleInput}
|
|
601
600
|
@change=${this.handleChange}
|
|
602
601
|
data-test-id="pie-text-input">
|
|
@@ -610,14 +609,14 @@ const q = "pie-text-input", Y = "assistive-text", W = class W extends Ot(Rt(gt))
|
|
|
610
609
|
${l ? pt`
|
|
611
610
|
<pie-assistive-text
|
|
612
611
|
id="${Y}"
|
|
613
|
-
variant=${
|
|
612
|
+
variant=${f(I)}
|
|
614
613
|
data-test-id="pie-text-input-assistive-text">
|
|
615
614
|
${l}
|
|
616
615
|
</pie-assistive-text>
|
|
617
616
|
` : Nt}`;
|
|
618
617
|
}
|
|
619
618
|
};
|
|
620
|
-
W.shadowRootOptions = { ...
|
|
619
|
+
W.shadowRootOptions = { ...ht.shadowRootOptions, delegatesFocus: !0 }, W.styles = Lt(zt);
|
|
621
620
|
let c = W;
|
|
622
621
|
d([
|
|
623
622
|
u({ type: String, reflect: !0 }),
|
|
@@ -683,10 +682,10 @@ d([
|
|
|
683
682
|
u({ type: Boolean })
|
|
684
683
|
], c.prototype, "required");
|
|
685
684
|
d([
|
|
686
|
-
|
|
685
|
+
ft("input")
|
|
687
686
|
], c.prototype, "input");
|
|
688
687
|
d([
|
|
689
|
-
|
|
688
|
+
ft("input")
|
|
690
689
|
], c.prototype, "focusTarget");
|
|
691
690
|
_t(q, c);
|
|
692
691
|
export {
|
package/dist/react.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ declare class PieTextInput_2 extends PieTextInput_base implements TextInputProps
|
|
|
52
52
|
readonly: boolean;
|
|
53
53
|
defaultValue: TextInputProps['defaultValue'];
|
|
54
54
|
assistiveText: TextInputProps['assistiveText'];
|
|
55
|
-
status: "default" | "
|
|
55
|
+
status: "default" | "success" | "error";
|
|
56
56
|
step: TextInputProps['step'];
|
|
57
57
|
min: TextInputProps['min'];
|
|
58
58
|
max: TextInputProps['max'];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-text-input",
|
|
3
3
|
"description": "PIE Design System Input built using Web Components",
|
|
4
|
-
"version": "0.27.
|
|
4
|
+
"version": "0.27.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/justeattakeaway/pie",
|
|
@@ -39,16 +39,16 @@
|
|
|
39
39
|
"license": "Apache-2.0",
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
42
|
-
"@justeattakeaway/pie-components-config": "0.19.
|
|
42
|
+
"@justeattakeaway/pie-components-config": "0.19.1",
|
|
43
43
|
"@justeattakeaway/pie-css": "0.16.0",
|
|
44
|
-
"@justeattakeaway/pie-icons-webc": "1.6.
|
|
44
|
+
"@justeattakeaway/pie-icons-webc": "1.6.2",
|
|
45
45
|
"@justeattakeaway/pie-monorepo-utils": "0.5.0",
|
|
46
46
|
"@justeattakeaway/pie-wrapper-react": "0.14.3",
|
|
47
47
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@justeattakeaway/pie-assistive-text": "0.9.
|
|
51
|
-
"@justeattakeaway/pie-webc-core": "0.25.
|
|
50
|
+
"@justeattakeaway/pie-assistive-text": "0.9.1",
|
|
51
|
+
"@justeattakeaway/pie-webc-core": "0.25.1",
|
|
52
52
|
"element-internals-polyfill": "1.3.11"
|
|
53
53
|
},
|
|
54
54
|
"volta": {
|