@justeattakeaway/pie-button 1.6.6 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +29 -161
- package/dist/index.d.ts +11 -6
- package/dist/index.js +46 -49
- package/dist/react.d.ts +12 -7
- package/package.json +6 -6
- package/src/index.ts +3 -4
package/custom-elements.json
CHANGED
|
@@ -198,58 +198,47 @@
|
|
|
198
198
|
{
|
|
199
199
|
"kind": "field",
|
|
200
200
|
"name": "tag",
|
|
201
|
-
"privacy": "public"
|
|
202
|
-
"attribute": "tag"
|
|
201
|
+
"privacy": "public"
|
|
203
202
|
},
|
|
204
203
|
{
|
|
205
204
|
"kind": "field",
|
|
206
205
|
"name": "size",
|
|
207
|
-
"privacy": "public"
|
|
208
|
-
"attribute": "size"
|
|
206
|
+
"privacy": "public"
|
|
209
207
|
},
|
|
210
208
|
{
|
|
211
209
|
"kind": "field",
|
|
212
210
|
"name": "type",
|
|
213
|
-
"privacy": "public"
|
|
214
|
-
"attribute": "type"
|
|
211
|
+
"privacy": "public"
|
|
215
212
|
},
|
|
216
213
|
{
|
|
217
214
|
"kind": "field",
|
|
218
215
|
"name": "variant",
|
|
219
|
-
"privacy": "public"
|
|
220
|
-
"attribute": "variant"
|
|
216
|
+
"privacy": "public"
|
|
221
217
|
},
|
|
222
218
|
{
|
|
223
219
|
"kind": "field",
|
|
224
220
|
"name": "iconPlacement",
|
|
225
|
-
"privacy": "public"
|
|
226
|
-
"attribute": "iconPlacement"
|
|
221
|
+
"privacy": "public"
|
|
227
222
|
},
|
|
228
223
|
{
|
|
229
224
|
"kind": "field",
|
|
230
225
|
"name": "disabled",
|
|
231
|
-
"privacy": "public"
|
|
232
|
-
"attribute": "disabled"
|
|
226
|
+
"privacy": "public"
|
|
233
227
|
},
|
|
234
228
|
{
|
|
235
229
|
"kind": "field",
|
|
236
230
|
"name": "isLoading",
|
|
237
|
-
"privacy": "public"
|
|
238
|
-
"attribute": "isLoading",
|
|
239
|
-
"reflects": true
|
|
231
|
+
"privacy": "public"
|
|
240
232
|
},
|
|
241
233
|
{
|
|
242
234
|
"kind": "field",
|
|
243
235
|
"name": "isFullWidth",
|
|
244
|
-
"privacy": "public"
|
|
245
|
-
"attribute": "isFullWidth",
|
|
246
|
-
"reflects": true
|
|
236
|
+
"privacy": "public"
|
|
247
237
|
},
|
|
248
238
|
{
|
|
249
239
|
"kind": "field",
|
|
250
240
|
"name": "isResponsive",
|
|
251
|
-
"privacy": "public"
|
|
252
|
-
"attribute": "isResponsive"
|
|
241
|
+
"privacy": "public"
|
|
253
242
|
},
|
|
254
243
|
{
|
|
255
244
|
"kind": "field",
|
|
@@ -257,8 +246,7 @@
|
|
|
257
246
|
"type": {
|
|
258
247
|
"text": "ButtonProps['name']"
|
|
259
248
|
},
|
|
260
|
-
"privacy": "public"
|
|
261
|
-
"attribute": "name"
|
|
249
|
+
"privacy": "public"
|
|
262
250
|
},
|
|
263
251
|
{
|
|
264
252
|
"kind": "field",
|
|
@@ -266,8 +254,7 @@
|
|
|
266
254
|
"type": {
|
|
267
255
|
"text": "ButtonProps['value']"
|
|
268
256
|
},
|
|
269
|
-
"privacy": "public"
|
|
270
|
-
"attribute": "value"
|
|
257
|
+
"privacy": "public"
|
|
271
258
|
},
|
|
272
259
|
{
|
|
273
260
|
"kind": "field",
|
|
@@ -275,8 +262,7 @@
|
|
|
275
262
|
"type": {
|
|
276
263
|
"text": "ButtonProps['formaction']"
|
|
277
264
|
},
|
|
278
|
-
"privacy": "public"
|
|
279
|
-
"attribute": "formaction"
|
|
265
|
+
"privacy": "public"
|
|
280
266
|
},
|
|
281
267
|
{
|
|
282
268
|
"kind": "field",
|
|
@@ -284,8 +270,7 @@
|
|
|
284
270
|
"type": {
|
|
285
271
|
"text": "ButtonProps['formenctype']"
|
|
286
272
|
},
|
|
287
|
-
"privacy": "public"
|
|
288
|
-
"attribute": "formenctype"
|
|
273
|
+
"privacy": "public"
|
|
289
274
|
},
|
|
290
275
|
{
|
|
291
276
|
"kind": "field",
|
|
@@ -293,8 +278,7 @@
|
|
|
293
278
|
"type": {
|
|
294
279
|
"text": "ButtonProps['formmethod']"
|
|
295
280
|
},
|
|
296
|
-
"privacy": "public"
|
|
297
|
-
"attribute": "formmethod"
|
|
281
|
+
"privacy": "public"
|
|
298
282
|
},
|
|
299
283
|
{
|
|
300
284
|
"kind": "field",
|
|
@@ -302,8 +286,7 @@
|
|
|
302
286
|
"type": {
|
|
303
287
|
"text": "ButtonProps['formnovalidate']"
|
|
304
288
|
},
|
|
305
|
-
"privacy": "public"
|
|
306
|
-
"attribute": "formnovalidate"
|
|
289
|
+
"privacy": "public"
|
|
307
290
|
},
|
|
308
291
|
{
|
|
309
292
|
"kind": "field",
|
|
@@ -311,8 +294,7 @@
|
|
|
311
294
|
"type": {
|
|
312
295
|
"text": "ButtonProps['formtarget']"
|
|
313
296
|
},
|
|
314
|
-
"privacy": "public"
|
|
315
|
-
"attribute": "formtarget"
|
|
297
|
+
"privacy": "public"
|
|
316
298
|
},
|
|
317
299
|
{
|
|
318
300
|
"kind": "field",
|
|
@@ -320,8 +302,7 @@
|
|
|
320
302
|
"type": {
|
|
321
303
|
"text": "ButtonProps['responsiveSize']"
|
|
322
304
|
},
|
|
323
|
-
"privacy": "public"
|
|
324
|
-
"attribute": "responsiveSize"
|
|
305
|
+
"privacy": "public"
|
|
325
306
|
},
|
|
326
307
|
{
|
|
327
308
|
"kind": "field",
|
|
@@ -329,8 +310,7 @@
|
|
|
329
310
|
"type": {
|
|
330
311
|
"text": "ButtonProps['href']"
|
|
331
312
|
},
|
|
332
|
-
"privacy": "public"
|
|
333
|
-
"attribute": "href"
|
|
313
|
+
"privacy": "public"
|
|
334
314
|
},
|
|
335
315
|
{
|
|
336
316
|
"kind": "field",
|
|
@@ -338,8 +318,7 @@
|
|
|
338
318
|
"type": {
|
|
339
319
|
"text": "ButtonProps['rel']"
|
|
340
320
|
},
|
|
341
|
-
"privacy": "public"
|
|
342
|
-
"attribute": "rel"
|
|
321
|
+
"privacy": "public"
|
|
343
322
|
},
|
|
344
323
|
{
|
|
345
324
|
"kind": "field",
|
|
@@ -347,8 +326,16 @@
|
|
|
347
326
|
"type": {
|
|
348
327
|
"text": "ButtonProps['target']"
|
|
349
328
|
},
|
|
350
|
-
"privacy": "public"
|
|
351
|
-
|
|
329
|
+
"privacy": "public"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"kind": "field",
|
|
333
|
+
"name": "shadowRootOptions",
|
|
334
|
+
"type": {
|
|
335
|
+
"text": "object"
|
|
336
|
+
},
|
|
337
|
+
"static": true,
|
|
338
|
+
"default": "{ ...LitElement.shadowRootOptions, delegatesFocus: true }"
|
|
352
339
|
},
|
|
353
340
|
{
|
|
354
341
|
"kind": "method",
|
|
@@ -408,125 +395,6 @@
|
|
|
408
395
|
}
|
|
409
396
|
}
|
|
410
397
|
]
|
|
411
|
-
},
|
|
412
|
-
{
|
|
413
|
-
"kind": "method",
|
|
414
|
-
"name": "focus"
|
|
415
|
-
}
|
|
416
|
-
],
|
|
417
|
-
"attributes": [
|
|
418
|
-
{
|
|
419
|
-
"name": "tag",
|
|
420
|
-
"fieldName": "tag"
|
|
421
|
-
},
|
|
422
|
-
{
|
|
423
|
-
"name": "size",
|
|
424
|
-
"fieldName": "size"
|
|
425
|
-
},
|
|
426
|
-
{
|
|
427
|
-
"name": "type",
|
|
428
|
-
"fieldName": "type"
|
|
429
|
-
},
|
|
430
|
-
{
|
|
431
|
-
"name": "variant",
|
|
432
|
-
"fieldName": "variant"
|
|
433
|
-
},
|
|
434
|
-
{
|
|
435
|
-
"name": "iconPlacement",
|
|
436
|
-
"fieldName": "iconPlacement"
|
|
437
|
-
},
|
|
438
|
-
{
|
|
439
|
-
"name": "disabled",
|
|
440
|
-
"fieldName": "disabled"
|
|
441
|
-
},
|
|
442
|
-
{
|
|
443
|
-
"name": "isLoading",
|
|
444
|
-
"fieldName": "isLoading"
|
|
445
|
-
},
|
|
446
|
-
{
|
|
447
|
-
"name": "isFullWidth",
|
|
448
|
-
"fieldName": "isFullWidth"
|
|
449
|
-
},
|
|
450
|
-
{
|
|
451
|
-
"name": "isResponsive",
|
|
452
|
-
"fieldName": "isResponsive"
|
|
453
|
-
},
|
|
454
|
-
{
|
|
455
|
-
"name": "name",
|
|
456
|
-
"type": {
|
|
457
|
-
"text": "ButtonProps['name']"
|
|
458
|
-
},
|
|
459
|
-
"fieldName": "name"
|
|
460
|
-
},
|
|
461
|
-
{
|
|
462
|
-
"name": "value",
|
|
463
|
-
"type": {
|
|
464
|
-
"text": "ButtonProps['value']"
|
|
465
|
-
},
|
|
466
|
-
"fieldName": "value"
|
|
467
|
-
},
|
|
468
|
-
{
|
|
469
|
-
"name": "formaction",
|
|
470
|
-
"type": {
|
|
471
|
-
"text": "ButtonProps['formaction']"
|
|
472
|
-
},
|
|
473
|
-
"fieldName": "formaction"
|
|
474
|
-
},
|
|
475
|
-
{
|
|
476
|
-
"name": "formenctype",
|
|
477
|
-
"type": {
|
|
478
|
-
"text": "ButtonProps['formenctype']"
|
|
479
|
-
},
|
|
480
|
-
"fieldName": "formenctype"
|
|
481
|
-
},
|
|
482
|
-
{
|
|
483
|
-
"name": "formmethod",
|
|
484
|
-
"type": {
|
|
485
|
-
"text": "ButtonProps['formmethod']"
|
|
486
|
-
},
|
|
487
|
-
"fieldName": "formmethod"
|
|
488
|
-
},
|
|
489
|
-
{
|
|
490
|
-
"name": "formnovalidate",
|
|
491
|
-
"type": {
|
|
492
|
-
"text": "ButtonProps['formnovalidate']"
|
|
493
|
-
},
|
|
494
|
-
"fieldName": "formnovalidate"
|
|
495
|
-
},
|
|
496
|
-
{
|
|
497
|
-
"name": "formtarget",
|
|
498
|
-
"type": {
|
|
499
|
-
"text": "ButtonProps['formtarget']"
|
|
500
|
-
},
|
|
501
|
-
"fieldName": "formtarget"
|
|
502
|
-
},
|
|
503
|
-
{
|
|
504
|
-
"name": "responsiveSize",
|
|
505
|
-
"type": {
|
|
506
|
-
"text": "ButtonProps['responsiveSize']"
|
|
507
|
-
},
|
|
508
|
-
"fieldName": "responsiveSize"
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
"name": "href",
|
|
512
|
-
"type": {
|
|
513
|
-
"text": "ButtonProps['href']"
|
|
514
|
-
},
|
|
515
|
-
"fieldName": "href"
|
|
516
|
-
},
|
|
517
|
-
{
|
|
518
|
-
"name": "rel",
|
|
519
|
-
"type": {
|
|
520
|
-
"text": "ButtonProps['rel']"
|
|
521
|
-
},
|
|
522
|
-
"fieldName": "rel"
|
|
523
|
-
},
|
|
524
|
-
{
|
|
525
|
-
"name": "target",
|
|
526
|
-
"type": {
|
|
527
|
-
"text": "ButtonProps['target']"
|
|
528
|
-
},
|
|
529
|
-
"fieldName": "target"
|
|
530
398
|
}
|
|
531
399
|
],
|
|
532
400
|
"mixins": [
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ClassInfo } from 'lit/directives/class-map.js';
|
|
2
2
|
import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import { CSSResult } from 'lit';
|
|
4
|
+
import { FormControlInterface } from '@justeattakeaway/pie-webc-core';
|
|
5
|
+
import { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
6
6
|
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import { PropertyValues } from 'lit';
|
|
8
|
+
import { TemplateResult } from 'lit';
|
|
9
9
|
|
|
10
10
|
export declare interface ButtonProps {
|
|
11
11
|
/**
|
|
@@ -144,6 +144,12 @@ export declare class PieButton extends PieButton_base implements ButtonProps {
|
|
|
144
144
|
href: ButtonProps['href'];
|
|
145
145
|
rel: ButtonProps['rel'];
|
|
146
146
|
target: ButtonProps['target'];
|
|
147
|
+
static shadowRootOptions: {
|
|
148
|
+
delegatesFocus: boolean;
|
|
149
|
+
mode: ShadowRootMode;
|
|
150
|
+
serializable?: boolean;
|
|
151
|
+
slotAssignment?: SlotAssignmentMode;
|
|
152
|
+
};
|
|
147
153
|
/**
|
|
148
154
|
* This method creates an invisible button of the same type as pie-button. It is then clicked, and immediately removed from the DOM.
|
|
149
155
|
* This is done so that we trigger native form actions, such as submit and reset in the browser. The performance impact of adding and removing a single button to the DOM
|
|
@@ -164,7 +170,6 @@ export declare class PieButton extends PieButton_base implements ButtonProps {
|
|
|
164
170
|
renderAnchor(classes: ClassInfo): TemplateResult<1>;
|
|
165
171
|
renderButton(classes: ClassInfo): TemplateResult<1>;
|
|
166
172
|
render(): TemplateResult<1>;
|
|
167
|
-
focus(): void;
|
|
168
173
|
static styles: CSSResult;
|
|
169
174
|
}
|
|
170
175
|
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LitElement as
|
|
1
|
+
import { LitElement as pt, html as z, nothing as S, unsafeCSS as Lt } from "lit";
|
|
2
2
|
import { classMap as mt } from "lit/directives/class-map.js";
|
|
3
3
|
import { ifDefined as U } from "lit/directives/if-defined.js";
|
|
4
4
|
import { property as m } from "lit/decorators.js";
|
|
@@ -6,7 +6,7 @@ import { FormControlMixin as Tt, validPropertyValues as C, safeCustomElement as
|
|
|
6
6
|
import "@justeattakeaway/pie-spinner";
|
|
7
7
|
(function() {
|
|
8
8
|
(function(l) {
|
|
9
|
-
const r = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(),
|
|
9
|
+
const r = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(), A = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), L = {
|
|
10
10
|
ariaAtomic: "aria-atomic",
|
|
11
11
|
ariaAutoComplete: "aria-autocomplete",
|
|
12
12
|
ariaBusy: "aria-busy",
|
|
@@ -49,7 +49,7 @@ import "@justeattakeaway/pie-spinner";
|
|
|
49
49
|
ariaValueNow: "aria-valuenow",
|
|
50
50
|
ariaValueText: "aria-valuetext",
|
|
51
51
|
role: "role"
|
|
52
|
-
},
|
|
52
|
+
}, ht = (e, t) => {
|
|
53
53
|
for (let i in L) {
|
|
54
54
|
t[i] = null;
|
|
55
55
|
let o = null;
|
|
@@ -59,7 +59,7 @@ import "@justeattakeaway/pie-spinner";
|
|
|
59
59
|
return o;
|
|
60
60
|
},
|
|
61
61
|
set(n) {
|
|
62
|
-
o = n, e.isConnected ? e.setAttribute(a, n) :
|
|
62
|
+
o = n, e.isConnected ? e.setAttribute(a, n) : A.set(e, t);
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
}
|
|
@@ -78,7 +78,7 @@ import "@justeattakeaway/pie-spinner";
|
|
|
78
78
|
const a = !t || e.disabled;
|
|
79
79
|
for (; o; )
|
|
80
80
|
o.formDisabledCallback && a && D(o, e.disabled), o = i.nextNode();
|
|
81
|
-
}, tt = { attributes: !0, attributeFilter: ["disabled", "name"] }, T =
|
|
81
|
+
}, tt = { attributes: !0, attributeFilter: ["disabled", "name"] }, T = O() ? new MutationObserver((e) => {
|
|
82
82
|
for (const t of e) {
|
|
83
83
|
const i = t.target;
|
|
84
84
|
if (t.attributeName === "disabled" && (i.constructor.formAssociated ? D(i, i.hasAttribute("disabled")) : i.localName === "fieldset" && Z(i)), t.attributeName === "name" && i.constructor.formAssociated) {
|
|
@@ -92,11 +92,11 @@ import "@justeattakeaway/pie-spinner";
|
|
|
92
92
|
const { addedNodes: i, removedNodes: o } = t, a = Array.from(i), n = Array.from(o);
|
|
93
93
|
a.forEach((s) => {
|
|
94
94
|
var u;
|
|
95
|
-
if (d.has(s) && s.constructor.formAssociated && Y(s),
|
|
96
|
-
const h =
|
|
95
|
+
if (d.has(s) && s.constructor.formAssociated && Y(s), A.has(s)) {
|
|
96
|
+
const h = A.get(s);
|
|
97
97
|
Object.keys(L).filter((y) => h[y] !== null).forEach((y) => {
|
|
98
98
|
s.setAttribute(L[y], h[y]);
|
|
99
|
-
}),
|
|
99
|
+
}), A.delete(s);
|
|
100
100
|
}
|
|
101
101
|
if (I.has(s)) {
|
|
102
102
|
const h = I.get(s);
|
|
@@ -119,7 +119,7 @@ import "@justeattakeaway/pie-spinner";
|
|
|
119
119
|
});
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function ut(e) {
|
|
123
123
|
e.forEach((t) => {
|
|
124
124
|
const { removedNodes: i } = t;
|
|
125
125
|
i.forEach((o) => {
|
|
@@ -128,12 +128,12 @@ import "@justeattakeaway/pie-spinner";
|
|
|
128
128
|
});
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
const
|
|
131
|
+
const gt = (e) => {
|
|
132
132
|
var t, i;
|
|
133
|
-
const o = new MutationObserver(
|
|
133
|
+
const o = new MutationObserver(ut);
|
|
134
134
|
!((t = window == null ? void 0 : window.ShadyDOM) === null || t === void 0) && t.inUse && e.mode && e.host && (e = e.host), (i = o.observe) === null || i === void 0 || i.call(o, e, { childList: !0 }), Q.set(e, o);
|
|
135
135
|
};
|
|
136
|
-
|
|
136
|
+
O() && new MutationObserver(R);
|
|
137
137
|
const $ = {
|
|
138
138
|
childList: !0,
|
|
139
139
|
subtree: !0
|
|
@@ -146,7 +146,7 @@ import "@justeattakeaway/pie-spinner";
|
|
|
146
146
|
}, it = (e, t) => {
|
|
147
147
|
const i = document.createElement("input");
|
|
148
148
|
return i.type = "hidden", i.name = e.getAttribute("name"), e.after(i), p.get(t).push(i), i;
|
|
149
|
-
},
|
|
149
|
+
}, ft = (e, t) => {
|
|
150
150
|
var i;
|
|
151
151
|
p.set(t, []), (i = T.observe) === null || i === void 0 || i.call(T, e, tt);
|
|
152
152
|
}, ot = (e, t) => {
|
|
@@ -158,11 +158,11 @@ import "@justeattakeaway/pie-spinner";
|
|
|
158
158
|
}, V = (e) => {
|
|
159
159
|
const t = Array.from(e.elements).filter((n) => !n.tagName.includes("-") && n.validity).map((n) => n.validity.valid), i = E.get(e) || [], o = Array.from(i).filter((n) => n.isConnected).map((n) => d.get(n).validity.valid), a = [...t, ...o].includes(!1);
|
|
160
160
|
e.toggleAttribute("internals-invalid", a), e.toggleAttribute("internals-valid", !a);
|
|
161
|
-
}, ft = (e) => {
|
|
162
|
-
V(N(e.target));
|
|
163
161
|
}, yt = (e) => {
|
|
164
162
|
V(N(e.target));
|
|
165
163
|
}, xt = (e) => {
|
|
164
|
+
V(N(e.target));
|
|
165
|
+
}, wt = (e) => {
|
|
166
166
|
const t = ["button[type=submit]", "input[type=submit]", "button:not([type])"].map((i) => `${i}:not([disabled])`).map((i) => `${i}:not([form])${e.id ? `,${i}[form='${e.id}']` : ""}`).join(",");
|
|
167
167
|
e.addEventListener("click", (i) => {
|
|
168
168
|
if (i.target.closest(t)) {
|
|
@@ -172,7 +172,7 @@ import "@justeattakeaway/pie-spinner";
|
|
|
172
172
|
a.size && Array.from(a).reverse().map((u) => d.get(u).reportValidity()).includes(!1) && i.preventDefault();
|
|
173
173
|
}
|
|
174
174
|
});
|
|
175
|
-
},
|
|
175
|
+
}, kt = (e) => {
|
|
176
176
|
const t = E.get(e.target);
|
|
177
177
|
t && t.size && t.forEach((i) => {
|
|
178
178
|
i.constructor.formAssociated && i.formResetCallback && i.formResetCallback.apply(i);
|
|
@@ -184,7 +184,7 @@ import "@justeattakeaway/pie-spinner";
|
|
|
184
184
|
o.add(e);
|
|
185
185
|
else {
|
|
186
186
|
const a = /* @__PURE__ */ new Set();
|
|
187
|
-
a.add(e), E.set(t, a),
|
|
187
|
+
a.add(e), E.set(t, a), wt(t), t.addEventListener("reset", kt), t.addEventListener("input", yt), t.addEventListener("change", xt);
|
|
188
188
|
}
|
|
189
189
|
k.set(t, { ref: e, internals: i }), e.constructor.formAssociated && e.formAssociatedCallback && setTimeout(() => {
|
|
190
190
|
e.formAssociatedCallback.apply(e, [t]);
|
|
@@ -207,15 +207,15 @@ import "@justeattakeaway/pie-spinner";
|
|
|
207
207
|
ot(e, i), rt(e, o, t);
|
|
208
208
|
}
|
|
209
209
|
};
|
|
210
|
-
function
|
|
210
|
+
function O() {
|
|
211
211
|
return typeof MutationObserver < "u";
|
|
212
212
|
}
|
|
213
|
-
class
|
|
213
|
+
class Et {
|
|
214
214
|
constructor() {
|
|
215
215
|
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);
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
const
|
|
218
|
+
const zt = (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), Mt = (e, t, i) => (e.valid = St(t), Object.keys(t).forEach((o) => e[o] = t[o]), i && V(i), e), St = (e) => {
|
|
219
219
|
let t = !0;
|
|
220
220
|
for (let i in e)
|
|
221
221
|
i !== "valid" && e[i] !== !1 && (t = !1);
|
|
@@ -257,14 +257,14 @@ import "@justeattakeaway/pie-spinner";
|
|
|
257
257
|
if (typeof t == "function" ? e !== t || !o : !t.has(e)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
258
258
|
return i === "m" ? o : i === "a" ? o.call(e) : o ? o.value : t.get(e);
|
|
259
259
|
}
|
|
260
|
-
function
|
|
260
|
+
function Ct(e, t, i, o, a) {
|
|
261
261
|
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");
|
|
262
262
|
return t.set(e, i), i;
|
|
263
263
|
}
|
|
264
264
|
var M;
|
|
265
|
-
class
|
|
265
|
+
class Ft {
|
|
266
266
|
constructor(t) {
|
|
267
|
-
M.set(this, void 0),
|
|
267
|
+
M.set(this, void 0), Ct(this, M, t);
|
|
268
268
|
for (let i = 0; i < t.length; i++) {
|
|
269
269
|
let o = t[i];
|
|
270
270
|
this[i] = o, o.hasAttribute("name") && (this[o.getAttribute("name")] = o);
|
|
@@ -304,7 +304,7 @@ import "@justeattakeaway/pie-spinner";
|
|
|
304
304
|
if (u.length === 0)
|
|
305
305
|
return s;
|
|
306
306
|
const h = Array.from(s).concat(u).sort((w, y) => w.compareDocumentPosition ? w.compareDocumentPosition(y) & 2 ? 1 : -1 : 0);
|
|
307
|
-
return new
|
|
307
|
+
return new Ft(h);
|
|
308
308
|
}
|
|
309
309
|
});
|
|
310
310
|
}
|
|
@@ -315,8 +315,8 @@ import "@justeattakeaway/pie-spinner";
|
|
|
315
315
|
constructor(t) {
|
|
316
316
|
if (!t || !t.tagName || t.tagName.indexOf("-") === -1)
|
|
317
317
|
throw new TypeError("Illegal constructor");
|
|
318
|
-
const i = t.getRootNode(), o = new
|
|
319
|
-
this.states = new H(t), r.set(this, t), b.set(this, o), d.set(t, this),
|
|
318
|
+
const i = t.getRootNode(), o = new Et();
|
|
319
|
+
this.states = new H(t), r.set(this, t), b.set(this, o), d.set(t, this), ht(t, this), ft(t, this), Object.seal(this), i instanceof DocumentFragment && gt(i);
|
|
320
320
|
}
|
|
321
321
|
checkValidity() {
|
|
322
322
|
const t = r.get(this);
|
|
@@ -377,10 +377,10 @@ import "@justeattakeaway/pie-spinner";
|
|
|
377
377
|
const n = b.get(this), s = {};
|
|
378
378
|
for (const w in t)
|
|
379
379
|
s[w] = t[w];
|
|
380
|
-
Object.keys(s).length === 0 &&
|
|
380
|
+
Object.keys(s).length === 0 && zt(n);
|
|
381
381
|
const u = Object.assign(Object.assign({}, n), s);
|
|
382
382
|
delete u.valid;
|
|
383
|
-
const { valid: h } =
|
|
383
|
+
const { valid: h } = Mt(n, u, this.form);
|
|
384
384
|
if (!h && !i)
|
|
385
385
|
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.");
|
|
386
386
|
f.set(this, h ? "" : i), a.isConnected ? (a.toggleAttribute("internals-invalid", !h), a.toggleAttribute("internals-valid", h), a.setAttribute("aria-invalid", `${!h}`)) : I.set(a, this);
|
|
@@ -402,7 +402,7 @@ import "@justeattakeaway/pie-spinner";
|
|
|
402
402
|
return x(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"));
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
|
-
function
|
|
405
|
+
function It() {
|
|
406
406
|
if (typeof window > "u" || !window.ElementInternals || !HTMLElement.prototype.attachInternals)
|
|
407
407
|
return !1;
|
|
408
408
|
class e extends HTMLElement {
|
|
@@ -458,7 +458,7 @@ import "@justeattakeaway/pie-spinner";
|
|
|
458
458
|
}), typeof Element < "u") {
|
|
459
459
|
let t = function(...o) {
|
|
460
460
|
const a = i.apply(this, o);
|
|
461
|
-
if (G.set(this, a),
|
|
461
|
+
if (G.set(this, a), O()) {
|
|
462
462
|
const n = new MutationObserver(R);
|
|
463
463
|
window.ShadyDOM ? n.observe(this, $) : n.observe(a, $), _.set(this, n);
|
|
464
464
|
}
|
|
@@ -467,20 +467,20 @@ import "@justeattakeaway/pie-spinner";
|
|
|
467
467
|
const i = Element.prototype.attachShadow;
|
|
468
468
|
Element.prototype.attachShadow = t;
|
|
469
469
|
}
|
|
470
|
-
|
|
470
|
+
O() && typeof document < "u" && new MutationObserver(R).observe(document.documentElement, $), typeof HTMLFormElement < "u" && At(), (e || typeof window < "u" && !window.CustomStateSet) && B();
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
|
-
return !!customElements.polyfillWrapFlushCallback || (
|
|
473
|
+
return !!customElements.polyfillWrapFlushCallback || (It() ? typeof window < "u" && !window.CustomStateSet && B(HTMLElement.prototype.attachInternals) : vt(!1)), l.forceCustomStateSetPolyfill = B, l.forceElementInternalsPolyfill = vt, Object.defineProperty(l, "__esModule", { value: !0 }), l;
|
|
474
474
|
})({});
|
|
475
475
|
})();
|
|
476
|
-
const
|
|
476
|
+
const P = class P extends pt {
|
|
477
477
|
willUpdate() {
|
|
478
|
-
this.getAttribute("v") || this.setAttribute("v",
|
|
478
|
+
this.getAttribute("v") || this.setAttribute("v", P.v);
|
|
479
479
|
}
|
|
480
480
|
};
|
|
481
|
-
|
|
482
|
-
let j =
|
|
483
|
-
const Nt = ["button", "a"],
|
|
481
|
+
P.v = "1.7.0";
|
|
482
|
+
let j = P;
|
|
483
|
+
const Nt = ["button", "a"], Ot = ["xsmall", "small-productive", "small-expressive", "medium", "large"], Jt = ["productive", "expressive"], Pt = ["submit", "button", "reset"], _t = [
|
|
484
484
|
"primary",
|
|
485
485
|
"primary-alternative",
|
|
486
486
|
"secondary",
|
|
@@ -507,7 +507,7 @@ var Dt = Object.defineProperty, Wt = Object.getOwnPropertyDescriptor, v = (l, r,
|
|
|
507
507
|
(k = l[f]) && (d = (p ? k(r, b, d) : k(d)) || d);
|
|
508
508
|
return p && d && Dt(r, b, d), d;
|
|
509
509
|
};
|
|
510
|
-
const
|
|
510
|
+
const F = "pie-button";
|
|
511
511
|
let c = class extends Tt(j) {
|
|
512
512
|
constructor() {
|
|
513
513
|
super(...arguments), this.tag = g.tag, this.size = g.size, this.type = g.type, this.variant = g.variant, this.iconPlacement = g.iconPlacement, this.disabled = g.disabled, this.isLoading = g.isLoading, this.isFullWidth = g.isFullWidth, this.isResponsive = g.isResponsive, this._handleFormKeyDown = (l) => {
|
|
@@ -621,31 +621,28 @@ let c = class extends Tt(j) {
|
|
|
621
621
|
};
|
|
622
622
|
return d === "a" ? this.renderAnchor(k) : this.renderButton(k);
|
|
623
623
|
}
|
|
624
|
-
focus() {
|
|
625
|
-
var l, r;
|
|
626
|
-
(r = (l = this.shadowRoot) == null ? void 0 : l.querySelector("button")) == null || r.focus();
|
|
627
|
-
}
|
|
628
624
|
};
|
|
625
|
+
c.shadowRootOptions = { ...pt.shadowRootOptions, delegatesFocus: !0 };
|
|
629
626
|
c.styles = Lt($t);
|
|
630
627
|
v([
|
|
631
628
|
m({ type: String }),
|
|
632
|
-
C(
|
|
629
|
+
C(F, Nt, g.tag)
|
|
633
630
|
], c.prototype, "tag", 2);
|
|
634
631
|
v([
|
|
635
632
|
m({ type: String }),
|
|
636
|
-
C(
|
|
633
|
+
C(F, Ot, g.size)
|
|
637
634
|
], c.prototype, "size", 2);
|
|
638
635
|
v([
|
|
639
636
|
m({ type: String }),
|
|
640
|
-
C(
|
|
637
|
+
C(F, Pt, g.type)
|
|
641
638
|
], c.prototype, "type", 2);
|
|
642
639
|
v([
|
|
643
640
|
m({ type: String }),
|
|
644
|
-
C(
|
|
641
|
+
C(F, _t, g.variant)
|
|
645
642
|
], c.prototype, "variant", 2);
|
|
646
643
|
v([
|
|
647
644
|
m({ type: String }),
|
|
648
|
-
C(
|
|
645
|
+
C(F, Rt, g.iconPlacement)
|
|
649
646
|
], c.prototype, "iconPlacement", 2);
|
|
650
647
|
v([
|
|
651
648
|
m({ type: Boolean })
|
|
@@ -703,8 +700,8 @@ export {
|
|
|
703
700
|
Yt as formTargetTypes,
|
|
704
701
|
Rt as iconPlacements,
|
|
705
702
|
Jt as responsiveSizes,
|
|
706
|
-
|
|
703
|
+
Ot as sizes,
|
|
707
704
|
Nt as tags,
|
|
708
|
-
|
|
705
|
+
Pt as types,
|
|
709
706
|
_t as variants
|
|
710
707
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ClassInfo } from 'lit/directives/class-map.js';
|
|
2
2
|
import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import { CSSResult } from 'lit';
|
|
4
|
+
import { FormControlInterface } from '@justeattakeaway/pie-webc-core';
|
|
5
|
+
import { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
6
6
|
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
7
|
-
import
|
|
7
|
+
import { PropertyValues } from 'lit';
|
|
8
8
|
import * as React_2 from 'react';
|
|
9
|
-
import
|
|
9
|
+
import { TemplateResult } from 'lit';
|
|
10
10
|
|
|
11
11
|
export declare interface ButtonProps {
|
|
12
12
|
/**
|
|
@@ -116,7 +116,7 @@ export declare const formTargetTypes: readonly ["_self", "_blank", "_parent", "_
|
|
|
116
116
|
|
|
117
117
|
export declare const iconPlacements: readonly ["leading", "trailing"];
|
|
118
118
|
|
|
119
|
-
export declare const PieButton: React_2.ForwardRefExoticComponent<ButtonProps & React_2.RefAttributes<PieButton_2> & ReactBaseType>;
|
|
119
|
+
export declare const PieButton: React_2.ForwardRefExoticComponent<React_2.PropsWithoutRef<ButtonProps> & React_2.RefAttributes<PieButton_2> & ReactBaseType>;
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
122
|
* @tagname pie-button
|
|
@@ -147,6 +147,12 @@ declare class PieButton_2 extends PieButton_base implements ButtonProps {
|
|
|
147
147
|
href: ButtonProps['href'];
|
|
148
148
|
rel: ButtonProps['rel'];
|
|
149
149
|
target: ButtonProps['target'];
|
|
150
|
+
static shadowRootOptions: {
|
|
151
|
+
delegatesFocus: boolean;
|
|
152
|
+
mode: ShadowRootMode;
|
|
153
|
+
serializable?: boolean;
|
|
154
|
+
slotAssignment?: SlotAssignmentMode;
|
|
155
|
+
};
|
|
150
156
|
/**
|
|
151
157
|
* This method creates an invisible button of the same type as pie-button. It is then clicked, and immediately removed from the DOM.
|
|
152
158
|
* This is done so that we trigger native form actions, such as submit and reset in the browser. The performance impact of adding and removing a single button to the DOM
|
|
@@ -167,7 +173,6 @@ declare class PieButton_2 extends PieButton_base implements ButtonProps {
|
|
|
167
173
|
renderAnchor(classes: ClassInfo): TemplateResult<1>;
|
|
168
174
|
renderButton(classes: ClassInfo): TemplateResult<1>;
|
|
169
175
|
render(): TemplateResult<1>;
|
|
170
|
-
focus(): void;
|
|
171
176
|
static styles: CSSResult;
|
|
172
177
|
}
|
|
173
178
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-button",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "PIE design system button built using web components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"license": "Apache-2.0",
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
42
|
-
"@justeattakeaway/pie-components-config": "0.
|
|
43
|
-
"@justeattakeaway/pie-css": "0.
|
|
44
|
-
"@justeattakeaway/pie-monorepo-utils": "0.
|
|
42
|
+
"@justeattakeaway/pie-components-config": "0.21.0",
|
|
43
|
+
"@justeattakeaway/pie-css": "0.21.0",
|
|
44
|
+
"@justeattakeaway/pie-monorepo-utils": "0.7.0",
|
|
45
45
|
"@justeattakeaway/pie-wrapper-react": "0.14.3",
|
|
46
46
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
47
47
|
},
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"dist/*.js"
|
|
54
54
|
],
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@justeattakeaway/pie-spinner": "1.2.
|
|
57
|
-
"@justeattakeaway/pie-webc-core": "1.
|
|
56
|
+
"@justeattakeaway/pie-spinner": "1.2.5",
|
|
57
|
+
"@justeattakeaway/pie-webc-core": "1.1.0",
|
|
58
58
|
"element-internals-polyfill": "1.3.11"
|
|
59
59
|
}
|
|
60
60
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
html, unsafeCSS, nothing, type PropertyValues, type TemplateResult,
|
|
3
|
+
LitElement,
|
|
3
4
|
} from 'lit';
|
|
4
5
|
import { classMap, type ClassInfo } from 'lit/directives/class-map.js';
|
|
5
6
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
@@ -121,6 +122,8 @@ export class PieButton extends FormControlMixin(PieElement) implements ButtonPro
|
|
|
121
122
|
@property({ type: String })
|
|
122
123
|
public target: ButtonProps['target'];
|
|
123
124
|
|
|
125
|
+
static shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };
|
|
126
|
+
|
|
124
127
|
/**
|
|
125
128
|
* This method creates an invisible button of the same type as pie-button. It is then clicked, and immediately removed from the DOM.
|
|
126
129
|
* This is done so that we trigger native form actions, such as submit and reset in the browser. The performance impact of adding and removing a single button to the DOM
|
|
@@ -298,10 +301,6 @@ export class PieButton extends FormControlMixin(PieElement) implements ButtonPro
|
|
|
298
301
|
return this.renderButton(classes);
|
|
299
302
|
}
|
|
300
303
|
|
|
301
|
-
focus () {
|
|
302
|
-
this.shadowRoot?.querySelector('button')?.focus();
|
|
303
|
-
}
|
|
304
|
-
|
|
305
304
|
// Renders a `CSSResult` generated from SCSS by Vite
|
|
306
305
|
static styles = unsafeCSS(styles);
|
|
307
306
|
}
|