@justeattakeaway/pie-button 0.42.1 → 0.44.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 +509 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +34 -38
- package/dist/react.d.ts +5 -5
- package/package.json +12 -5
- package/src/index.ts +2 -16
- package/src/react.ts +14 -0
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"readme": "",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "src/defs.js",
|
|
8
|
+
"declarations": [
|
|
9
|
+
{
|
|
10
|
+
"kind": "variable",
|
|
11
|
+
"name": "sizes",
|
|
12
|
+
"type": {
|
|
13
|
+
"text": "['xsmall', 'small-productive', 'small-expressive', 'medium', 'large']"
|
|
14
|
+
},
|
|
15
|
+
"default": "['xsmall', 'small-productive', 'small-expressive', 'medium', 'large']"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"kind": "variable",
|
|
19
|
+
"name": "responsiveSizes",
|
|
20
|
+
"type": {
|
|
21
|
+
"text": "['productive', 'expressive']"
|
|
22
|
+
},
|
|
23
|
+
"default": "['productive', 'expressive']"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"kind": "variable",
|
|
27
|
+
"name": "types",
|
|
28
|
+
"type": {
|
|
29
|
+
"text": "['submit', 'button', 'reset']"
|
|
30
|
+
},
|
|
31
|
+
"default": "['submit', 'button', 'reset']"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"kind": "variable",
|
|
35
|
+
"name": "variants",
|
|
36
|
+
"type": {
|
|
37
|
+
"text": "[\n 'primary', 'secondary', 'outline', 'outline-inverse', 'ghost',\n 'inverse', 'ghost-inverse', 'destructive', 'destructive-ghost',\n]"
|
|
38
|
+
},
|
|
39
|
+
"default": "[\n 'primary', 'secondary', 'outline', 'outline-inverse', 'ghost',\n 'inverse', 'ghost-inverse', 'destructive', 'destructive-ghost',\n]"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"kind": "variable",
|
|
43
|
+
"name": "iconPlacements",
|
|
44
|
+
"type": {
|
|
45
|
+
"text": "['leading', 'trailing']"
|
|
46
|
+
},
|
|
47
|
+
"default": "['leading', 'trailing']"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"kind": "variable",
|
|
51
|
+
"name": "formEncodingtypes",
|
|
52
|
+
"type": {
|
|
53
|
+
"text": "['application/x-www-form-urlencoded', 'multipart/form-data', 'text/plain']"
|
|
54
|
+
},
|
|
55
|
+
"default": "['application/x-www-form-urlencoded', 'multipart/form-data', 'text/plain']"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"kind": "variable",
|
|
59
|
+
"name": "formMethodTypes",
|
|
60
|
+
"type": {
|
|
61
|
+
"text": "['post', 'get', 'dialog']"
|
|
62
|
+
},
|
|
63
|
+
"default": "['post', 'get', 'dialog']"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"kind": "variable",
|
|
67
|
+
"name": "formTargetTypes",
|
|
68
|
+
"type": {
|
|
69
|
+
"text": "['_self', '_blank', '_parent', '_top']"
|
|
70
|
+
},
|
|
71
|
+
"default": "['_self', '_blank', '_parent', '_top']"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"exports": [
|
|
75
|
+
{
|
|
76
|
+
"kind": "js",
|
|
77
|
+
"name": "sizes",
|
|
78
|
+
"declaration": {
|
|
79
|
+
"name": "sizes",
|
|
80
|
+
"module": "src/defs.js"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"kind": "js",
|
|
85
|
+
"name": "responsiveSizes",
|
|
86
|
+
"declaration": {
|
|
87
|
+
"name": "responsiveSizes",
|
|
88
|
+
"module": "src/defs.js"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"kind": "js",
|
|
93
|
+
"name": "types",
|
|
94
|
+
"declaration": {
|
|
95
|
+
"name": "types",
|
|
96
|
+
"module": "src/defs.js"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"kind": "js",
|
|
101
|
+
"name": "variants",
|
|
102
|
+
"declaration": {
|
|
103
|
+
"name": "variants",
|
|
104
|
+
"module": "src/defs.js"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"kind": "js",
|
|
109
|
+
"name": "iconPlacements",
|
|
110
|
+
"declaration": {
|
|
111
|
+
"name": "iconPlacements",
|
|
112
|
+
"module": "src/defs.js"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"kind": "js",
|
|
117
|
+
"name": "formEncodingtypes",
|
|
118
|
+
"declaration": {
|
|
119
|
+
"name": "formEncodingtypes",
|
|
120
|
+
"module": "src/defs.js"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"kind": "js",
|
|
125
|
+
"name": "formMethodTypes",
|
|
126
|
+
"declaration": {
|
|
127
|
+
"name": "formMethodTypes",
|
|
128
|
+
"module": "src/defs.js"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"kind": "js",
|
|
133
|
+
"name": "formTargetTypes",
|
|
134
|
+
"declaration": {
|
|
135
|
+
"name": "formTargetTypes",
|
|
136
|
+
"module": "src/defs.js"
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"kind": "javascript-module",
|
|
143
|
+
"path": "src/index.js",
|
|
144
|
+
"declarations": [
|
|
145
|
+
{
|
|
146
|
+
"kind": "class",
|
|
147
|
+
"description": "",
|
|
148
|
+
"name": "PieButton",
|
|
149
|
+
"slots": [
|
|
150
|
+
{
|
|
151
|
+
"description": "The icon slot",
|
|
152
|
+
"name": "icon"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"description": "Default slot",
|
|
156
|
+
"name": ""
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
"members": [
|
|
160
|
+
{
|
|
161
|
+
"kind": "field",
|
|
162
|
+
"name": "size",
|
|
163
|
+
"type": {
|
|
164
|
+
"text": "ButtonProps['size']"
|
|
165
|
+
},
|
|
166
|
+
"privacy": "public",
|
|
167
|
+
"default": "'medium'",
|
|
168
|
+
"attribute": "size"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"kind": "field",
|
|
172
|
+
"name": "type",
|
|
173
|
+
"type": {
|
|
174
|
+
"text": "ButtonProps['type']"
|
|
175
|
+
},
|
|
176
|
+
"privacy": "public",
|
|
177
|
+
"default": "'submit'",
|
|
178
|
+
"attribute": "type"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"kind": "field",
|
|
182
|
+
"name": "variant",
|
|
183
|
+
"type": {
|
|
184
|
+
"text": "ButtonProps['variant']"
|
|
185
|
+
},
|
|
186
|
+
"privacy": "public",
|
|
187
|
+
"default": "'primary'",
|
|
188
|
+
"attribute": "variant"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"kind": "field",
|
|
192
|
+
"name": "iconPlacement",
|
|
193
|
+
"type": {
|
|
194
|
+
"text": "ButtonProps['iconPlacement']"
|
|
195
|
+
},
|
|
196
|
+
"privacy": "public",
|
|
197
|
+
"default": "'leading'",
|
|
198
|
+
"attribute": "iconPlacement"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"kind": "field",
|
|
202
|
+
"name": "disabled",
|
|
203
|
+
"type": {
|
|
204
|
+
"text": "boolean"
|
|
205
|
+
},
|
|
206
|
+
"privacy": "public",
|
|
207
|
+
"default": "false",
|
|
208
|
+
"attribute": "disabled"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"kind": "field",
|
|
212
|
+
"name": "isLoading",
|
|
213
|
+
"type": {
|
|
214
|
+
"text": "boolean"
|
|
215
|
+
},
|
|
216
|
+
"privacy": "public",
|
|
217
|
+
"default": "false",
|
|
218
|
+
"attribute": "isLoading",
|
|
219
|
+
"reflects": true
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"kind": "field",
|
|
223
|
+
"name": "isFullWidth",
|
|
224
|
+
"type": {
|
|
225
|
+
"text": "boolean"
|
|
226
|
+
},
|
|
227
|
+
"privacy": "public",
|
|
228
|
+
"default": "false",
|
|
229
|
+
"attribute": "isFullWidth"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"kind": "field",
|
|
233
|
+
"name": "isResponsive",
|
|
234
|
+
"type": {
|
|
235
|
+
"text": "boolean"
|
|
236
|
+
},
|
|
237
|
+
"privacy": "public",
|
|
238
|
+
"default": "false",
|
|
239
|
+
"attribute": "isResponsive"
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
"kind": "field",
|
|
243
|
+
"name": "name",
|
|
244
|
+
"type": {
|
|
245
|
+
"text": "string | undefined"
|
|
246
|
+
},
|
|
247
|
+
"privacy": "public",
|
|
248
|
+
"attribute": "name"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"kind": "field",
|
|
252
|
+
"name": "value",
|
|
253
|
+
"type": {
|
|
254
|
+
"text": "string | undefined"
|
|
255
|
+
},
|
|
256
|
+
"privacy": "public",
|
|
257
|
+
"attribute": "value"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"kind": "field",
|
|
261
|
+
"name": "formaction",
|
|
262
|
+
"type": {
|
|
263
|
+
"text": "ButtonProps['formaction']"
|
|
264
|
+
},
|
|
265
|
+
"privacy": "public",
|
|
266
|
+
"attribute": "formaction"
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
"kind": "field",
|
|
270
|
+
"name": "formenctype",
|
|
271
|
+
"type": {
|
|
272
|
+
"text": "ButtonProps['formenctype']"
|
|
273
|
+
},
|
|
274
|
+
"privacy": "public",
|
|
275
|
+
"attribute": "formenctype"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"kind": "field",
|
|
279
|
+
"name": "formmethod",
|
|
280
|
+
"type": {
|
|
281
|
+
"text": "ButtonProps['formmethod']"
|
|
282
|
+
},
|
|
283
|
+
"privacy": "public",
|
|
284
|
+
"attribute": "formmethod"
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"kind": "field",
|
|
288
|
+
"name": "formnovalidate",
|
|
289
|
+
"type": {
|
|
290
|
+
"text": "ButtonProps['formnovalidate']"
|
|
291
|
+
},
|
|
292
|
+
"privacy": "public",
|
|
293
|
+
"attribute": "formnovalidate"
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
"kind": "field",
|
|
297
|
+
"name": "formtarget",
|
|
298
|
+
"type": {
|
|
299
|
+
"text": "ButtonProps['formtarget']"
|
|
300
|
+
},
|
|
301
|
+
"privacy": "public",
|
|
302
|
+
"attribute": "formtarget"
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
"kind": "field",
|
|
306
|
+
"name": "responsiveSize",
|
|
307
|
+
"type": {
|
|
308
|
+
"text": "ButtonProps['responsiveSize'] | undefined"
|
|
309
|
+
},
|
|
310
|
+
"privacy": "public",
|
|
311
|
+
"attribute": "responsiveSize"
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
"kind": "method",
|
|
315
|
+
"name": "_simulateNativeButtonClick",
|
|
316
|
+
"privacy": "private",
|
|
317
|
+
"parameters": [
|
|
318
|
+
{
|
|
319
|
+
"name": "btnType",
|
|
320
|
+
"type": {
|
|
321
|
+
"text": "'submit' | 'reset'"
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
],
|
|
325
|
+
"description": "This method creates an invisible button of the same type as pie-button. It is then clicked, and immediately removed from the DOM.\nThis 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\nshould be neglible, however this should be monitored.\nThis is the only viable way of guaranteeing native button behaviour when using a web component in place of an actual HTML button.\n\nTODO: if we need to repeat this logic elsewhere, then we should consider moving this code to a shared class or mixin."
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
"kind": "method",
|
|
329
|
+
"name": "_handleClick",
|
|
330
|
+
"privacy": "private"
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
"kind": "field",
|
|
334
|
+
"name": "_handleFormKeyDown",
|
|
335
|
+
"privacy": "private"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"kind": "method",
|
|
339
|
+
"name": "renderSpinner",
|
|
340
|
+
"privacy": "private",
|
|
341
|
+
"return": {
|
|
342
|
+
"type": {
|
|
343
|
+
"text": "TemplateResult"
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
"description": "Template for the loading state"
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
"kind": "method",
|
|
350
|
+
"name": "focus"
|
|
351
|
+
}
|
|
352
|
+
],
|
|
353
|
+
"attributes": [
|
|
354
|
+
{
|
|
355
|
+
"name": "size",
|
|
356
|
+
"type": {
|
|
357
|
+
"text": "ButtonProps['size']"
|
|
358
|
+
},
|
|
359
|
+
"default": "'medium'",
|
|
360
|
+
"fieldName": "size"
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
"name": "type",
|
|
364
|
+
"type": {
|
|
365
|
+
"text": "ButtonProps['type']"
|
|
366
|
+
},
|
|
367
|
+
"default": "'submit'",
|
|
368
|
+
"fieldName": "type"
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
"name": "variant",
|
|
372
|
+
"type": {
|
|
373
|
+
"text": "ButtonProps['variant']"
|
|
374
|
+
},
|
|
375
|
+
"default": "'primary'",
|
|
376
|
+
"fieldName": "variant"
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
"name": "iconPlacement",
|
|
380
|
+
"type": {
|
|
381
|
+
"text": "ButtonProps['iconPlacement']"
|
|
382
|
+
},
|
|
383
|
+
"default": "'leading'",
|
|
384
|
+
"fieldName": "iconPlacement"
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
"name": "disabled",
|
|
388
|
+
"type": {
|
|
389
|
+
"text": "boolean"
|
|
390
|
+
},
|
|
391
|
+
"default": "false",
|
|
392
|
+
"fieldName": "disabled"
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
"name": "isLoading",
|
|
396
|
+
"type": {
|
|
397
|
+
"text": "boolean"
|
|
398
|
+
},
|
|
399
|
+
"default": "false",
|
|
400
|
+
"fieldName": "isLoading"
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
"name": "isFullWidth",
|
|
404
|
+
"type": {
|
|
405
|
+
"text": "boolean"
|
|
406
|
+
},
|
|
407
|
+
"default": "false",
|
|
408
|
+
"fieldName": "isFullWidth"
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
"name": "isResponsive",
|
|
412
|
+
"type": {
|
|
413
|
+
"text": "boolean"
|
|
414
|
+
},
|
|
415
|
+
"default": "false",
|
|
416
|
+
"fieldName": "isResponsive"
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
"name": "name",
|
|
420
|
+
"type": {
|
|
421
|
+
"text": "string | undefined"
|
|
422
|
+
},
|
|
423
|
+
"fieldName": "name"
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
"name": "value",
|
|
427
|
+
"type": {
|
|
428
|
+
"text": "string | undefined"
|
|
429
|
+
},
|
|
430
|
+
"fieldName": "value"
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
"name": "formaction",
|
|
434
|
+
"type": {
|
|
435
|
+
"text": "ButtonProps['formaction']"
|
|
436
|
+
},
|
|
437
|
+
"fieldName": "formaction"
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
"name": "formenctype",
|
|
441
|
+
"type": {
|
|
442
|
+
"text": "ButtonProps['formenctype']"
|
|
443
|
+
},
|
|
444
|
+
"fieldName": "formenctype"
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
"name": "formmethod",
|
|
448
|
+
"type": {
|
|
449
|
+
"text": "ButtonProps['formmethod']"
|
|
450
|
+
},
|
|
451
|
+
"fieldName": "formmethod"
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
"name": "formnovalidate",
|
|
455
|
+
"type": {
|
|
456
|
+
"text": "ButtonProps['formnovalidate']"
|
|
457
|
+
},
|
|
458
|
+
"fieldName": "formnovalidate"
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
"name": "formtarget",
|
|
462
|
+
"type": {
|
|
463
|
+
"text": "ButtonProps['formtarget']"
|
|
464
|
+
},
|
|
465
|
+
"fieldName": "formtarget"
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
"name": "responsiveSize",
|
|
469
|
+
"type": {
|
|
470
|
+
"text": "ButtonProps['responsiveSize'] | undefined"
|
|
471
|
+
},
|
|
472
|
+
"fieldName": "responsiveSize"
|
|
473
|
+
}
|
|
474
|
+
],
|
|
475
|
+
"mixins": [
|
|
476
|
+
{
|
|
477
|
+
"name": "FormControlMixin",
|
|
478
|
+
"package": "@justeattakeaway/pie-webc-core"
|
|
479
|
+
}
|
|
480
|
+
],
|
|
481
|
+
"superclass": {
|
|
482
|
+
"name": "LitElement",
|
|
483
|
+
"package": "lit"
|
|
484
|
+
},
|
|
485
|
+
"tagName": "pie-button",
|
|
486
|
+
"customElement": true
|
|
487
|
+
}
|
|
488
|
+
],
|
|
489
|
+
"exports": [
|
|
490
|
+
{
|
|
491
|
+
"kind": "js",
|
|
492
|
+
"name": "*",
|
|
493
|
+
"declaration": {
|
|
494
|
+
"name": "*",
|
|
495
|
+
"package": "./defs"
|
|
496
|
+
}
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
"kind": "js",
|
|
500
|
+
"name": "PieButton",
|
|
501
|
+
"declaration": {
|
|
502
|
+
"name": "PieButton",
|
|
503
|
+
"module": "src/index.js"
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
]
|
|
507
|
+
}
|
|
508
|
+
]
|
|
509
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { CSSResult } from 'lit';
|
|
2
|
+
import type { FormControlInterface } from '@justeattakeaway/pie-webc-core';
|
|
3
|
+
import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
2
4
|
import type { LitElement } from 'lit';
|
|
3
5
|
import type { PropertyValues } from 'lit';
|
|
4
6
|
import type { TemplateResult } from 'lit';
|
|
@@ -93,11 +95,7 @@ export declare const iconPlacements: readonly ["leading", "trailing"];
|
|
|
93
95
|
* @slot icon - The icon slot
|
|
94
96
|
* @slot - Default slot
|
|
95
97
|
*/
|
|
96
|
-
export declare class PieButton extends
|
|
97
|
-
static formAssociated: boolean;
|
|
98
|
-
private readonly _internals;
|
|
99
|
-
get form(): HTMLFormElement | null;
|
|
100
|
-
constructor();
|
|
98
|
+
export declare class PieButton extends PieButton_base implements ButtonProps {
|
|
101
99
|
connectedCallback(): void;
|
|
102
100
|
disconnectedCallback(): void;
|
|
103
101
|
updated(changedProperties: PropertyValues<this>): void;
|
|
@@ -139,6 +137,8 @@ export declare class PieButton extends LitElement implements ButtonProps {
|
|
|
139
137
|
static styles: CSSResult;
|
|
140
138
|
}
|
|
141
139
|
|
|
140
|
+
declare const PieButton_base: GenericConstructor<FormControlInterface> & typeof LitElement;
|
|
141
|
+
|
|
142
142
|
export declare const responsiveSizes: readonly ["productive", "expressive"];
|
|
143
143
|
|
|
144
144
|
export declare const sizes: readonly ["xsmall", "small-productive", "small-expressive", "medium", "large"];
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LitElement as wt, html as N, nothing as W, unsafeCSS as xt } from "lit";
|
|
2
2
|
import { property as h } from "lit/decorators.js";
|
|
3
3
|
import { ifDefined as Et } from "lit/directives/if-defined.js";
|
|
4
|
-
import { validPropertyValues as R, defineCustomElement as
|
|
4
|
+
import { FormControlMixin as kt, validPropertyValues as R, defineCustomElement as zt } from "@justeattakeaway/pie-webc-core";
|
|
5
5
|
import "@justeattakeaway/pie-spinner";
|
|
6
|
-
const
|
|
6
|
+
const Mt = ["xsmall", "small-productive", "small-expressive", "medium", "large"], Pt = ["productive", "expressive"], Ct = ["submit", "button", "reset"], Lt = [
|
|
7
7
|
"primary",
|
|
8
8
|
"secondary",
|
|
9
9
|
"outline",
|
|
@@ -13,7 +13,7 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
13
13
|
"ghost-inverse",
|
|
14
14
|
"destructive",
|
|
15
15
|
"destructive-ghost"
|
|
16
|
-
], Lt = ["leading", "trailing"], Pt = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], Dt = ["post", "get", "dialog"], $t = ["_self", "_blank", "_parent", "_top"], Ft = `*,*:before,*:after{box-sizing:border-box}.o-btn{--btn-border-radius: var(--dt-radius-rounded-e);--btn-font-family: var(--dt-font-interactive-m-family);--btn-font-weight: var(--dt-font-interactive-m-weight);--btn-bg-color: var(--dt-color-interactive-brand);--btn-text-color: var(--dt-color-content-interactive-primary);--btn-height--xsmall: 32px;--btn-height--small: 40px;--btn-height--medium: 48px;--btn-height--large: 56px;--icon-display-override: block;position:relative;display:flex;gap:var(--dt-spacing-b);align-items:center;justify-content:center;box-sizing:border-box;height:var(--btn-height);padding:var(--btn-padding);border:none;border-radius:var(--btn-border-radius);outline:none;background-color:var(--btn-bg-color);font-family:var(--btn-font-family);font-size:var(--btn-font-size);font-weight:var(--btn-font-weight);color:var(--btn-text-color);line-height:var(--btn-line-height);cursor:pointer;user-select:none;inline-size:var(--btn-inline-size)}.o-btn[variant=primary]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + var(--hover-modifier)))}.o-btn[variant=primary]:active:not(:disabled),.o-btn[variant=primary][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + var(--active-modifier)))}.o-btn[variant=primary][size=xsmall],.o-btn[variant=primary][size=small-productive]{--btn-bg-color: var(--dt-color-interactive-primary)}.o-btn[variant=primary][size=xsmall]:hover:not(:disabled),.o-btn[variant=primary][size=small-productive]:hover:not(:disabled){--hover-modifier: var(--dt-color-hover-02);--btn-bg-color: hsl(var(--dt-color-interactive-primary-h), var(--dt-color-interactive-primary-s), calc(var(--dt-color-interactive-primary-l) + var(--hover-modifier)))}.o-btn[variant=primary][size=xsmall]:active:not(:disabled),.o-btn[variant=primary][size=xsmall][isLoading]:not(:disabled),.o-btn[variant=primary][size=small-productive]:active:not(:disabled),.o-btn[variant=primary][size=small-productive][isLoading]:not(:disabled){--active-modifier: var(--dt-color-active-02);--btn-bg-color: hsl(var(--dt-color-interactive-primary-h), var(--dt-color-interactive-primary-s), calc(var(--dt-color-interactive-primary-l) + var(--active-modifier)))}.o-btn[variant=secondary]{--btn-bg-color: var(--dt-color-interactive-secondary);--btn-text-color: var(--dt-color-content-interactive-secondary)}.o-btn[variant=secondary]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-interactive-secondary-h), var(--dt-color-interactive-secondary-s), calc(var(--dt-color-interactive-secondary-l) + var(--hover-modifier)))}.o-btn[variant=secondary]:active:not(:disabled),.o-btn[variant=secondary][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-interactive-secondary-h), var(--dt-color-interactive-secondary-s), calc(var(--dt-color-interactive-secondary-l) + var(--active-modifier)))}.o-btn[variant=outline]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-interactive-secondary);border:1px solid var(--dt-color-border-strong)}.o-btn[variant=outline]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--hover-modifier))}.o-btn[variant=outline]:active:not(:disabled),.o-btn[variant=outline][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--active-modifier))}.o-btn[variant=ghost]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-link)}.o-btn[variant=ghost]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--hover-modifier))}.o-btn[variant=ghost]:active:not(:disabled),.o-btn[variant=ghost][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--active-modifier))}.o-btn[variant=inverse]{--btn-bg-color: var(--dt-color-interactive-inverse);--btn-text-color: var(--dt-color-content-interactive-secondary)}.o-btn[variant=inverse]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-interactive-inverse-h), var(--dt-color-interactive-inverse-s), calc(var(--dt-color-interactive-inverse-l) + var(--hover-modifier)))}.o-btn[variant=inverse]:active:not(:disabled),.o-btn[variant=inverse][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-interactive-inverse-h), var(--dt-color-interactive-inverse-s), calc(var(--dt-color-interactive-inverse-l) + var(--active-modifier)))}.o-btn[variant=ghost-inverse],.o-btn[variant=outline-inverse]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-interactive-primary)}.o-btn[variant=ghost-inverse]:hover:not(:disabled),.o-btn[variant=outline-inverse]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), var(--dt-color-container-default-l), var(--hover-modifier))}.o-btn[variant=ghost-inverse]:active:not(:disabled),.o-btn[variant=ghost-inverse][isLoading]:not(:disabled),.o-btn[variant=outline-inverse]:active:not(:disabled),.o-btn[variant=outline-inverse][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), var(--dt-color-container-default-l), var(--active-modifier))}.o-btn[variant=outline-inverse]:not([disabled]){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);--icon-size-override: 16px}@media (min-width: 768px){.o-btn[size=xsmall][isResponsive]{--btn-height: var(--btn-height--small);--btn-padding: 8px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-16) * 1px);--btn-line-height: calc(var(--dt-font-size-16-line-height) * 1px);--icon-size-override: 20px}.o-btn[size=xsmall][isResponsive][responsiveSize=expressive]{--btn-height: var(--btn-height--small);--btn-padding: 6px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--icon-size-override: 20px}}.o-btn[size=small-expressive]{--btn-height: var(--btn-height--small);--btn-padding: 6px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--icon-size-override: 20px}@media (min-width: 768px){.o-btn[size=small-expressive][isResponsive]{--btn-height: var(--btn-height--medium);--btn-padding: 10px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--icon-size-override: 24px}}.o-btn[size=small-productive]{--btn-height: var(--btn-height--small);--btn-padding: 8px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-16) * 1px);--btn-line-height: calc(var(--dt-font-size-16-line-height) * 1px);--icon-size-override: 20px}@media (min-width: 768px){.o-btn[size=small-productive][isResponsive]{--btn-height: var(--btn-height--medium);--btn-padding: 10px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--icon-size-override: 24px}}.o-btn[size=medium]{--btn-height: var(--btn-height--medium);--btn-padding: 10px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--icon-size-override: 24px}@media (min-width: 768px){.o-btn[size=medium][isResponsive]{--btn-height: var(--btn-height--large);--btn-padding: 14px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--icon-size-override: 24px}}.o-btn[size=large]{--btn-height: var(--btn-height--large);--btn-padding: 14px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--icon-size-override: 24px}.o-btn[isLoading]>*:not(pie-spinner){visibility:hidden}.o-btn[isLoading] pie-spinner{position:absolute}.o-btn:focus-visible{box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer);outline:none}::slotted(svg){height:var(--icon-size-override);width:var(--icon-size-override)}
|
|
16
|
+
], Ft = ["leading", "trailing"], Dt = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], $t = ["post", "get", "dialog"], Ot = ["_self", "_blank", "_parent", "_top"], St = `*,*:before,*:after{box-sizing:border-box}.o-btn{--btn-border-radius: var(--dt-radius-rounded-e);--btn-font-family: var(--dt-font-interactive-m-family);--btn-font-weight: var(--dt-font-interactive-m-weight);--btn-bg-color: var(--dt-color-interactive-brand);--btn-text-color: var(--dt-color-content-interactive-primary);--btn-height--xsmall: 32px;--btn-height--small: 40px;--btn-height--medium: 48px;--btn-height--large: 56px;--icon-display-override: block;position:relative;display:flex;gap:var(--dt-spacing-b);align-items:center;justify-content:center;box-sizing:border-box;height:var(--btn-height);padding:var(--btn-padding);border:none;border-radius:var(--btn-border-radius);outline:none;background-color:var(--btn-bg-color);font-family:var(--btn-font-family);font-size:var(--btn-font-size);font-weight:var(--btn-font-weight);color:var(--btn-text-color);line-height:var(--btn-line-height);cursor:pointer;user-select:none;inline-size:var(--btn-inline-size)}.o-btn[variant=primary]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + var(--hover-modifier)))}.o-btn[variant=primary]:active:not(:disabled),.o-btn[variant=primary][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + var(--active-modifier)))}.o-btn[variant=primary][size=xsmall],.o-btn[variant=primary][size=small-productive]{--btn-bg-color: var(--dt-color-interactive-primary)}.o-btn[variant=primary][size=xsmall]:hover:not(:disabled),.o-btn[variant=primary][size=small-productive]:hover:not(:disabled){--hover-modifier: var(--dt-color-hover-02);--btn-bg-color: hsl(var(--dt-color-interactive-primary-h), var(--dt-color-interactive-primary-s), calc(var(--dt-color-interactive-primary-l) + var(--hover-modifier)))}.o-btn[variant=primary][size=xsmall]:active:not(:disabled),.o-btn[variant=primary][size=xsmall][isLoading]:not(:disabled),.o-btn[variant=primary][size=small-productive]:active:not(:disabled),.o-btn[variant=primary][size=small-productive][isLoading]:not(:disabled){--active-modifier: var(--dt-color-active-02);--btn-bg-color: hsl(var(--dt-color-interactive-primary-h), var(--dt-color-interactive-primary-s), calc(var(--dt-color-interactive-primary-l) + var(--active-modifier)))}.o-btn[variant=secondary]{--btn-bg-color: var(--dt-color-interactive-secondary);--btn-text-color: var(--dt-color-content-interactive-secondary)}.o-btn[variant=secondary]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-interactive-secondary-h), var(--dt-color-interactive-secondary-s), calc(var(--dt-color-interactive-secondary-l) + var(--hover-modifier)))}.o-btn[variant=secondary]:active:not(:disabled),.o-btn[variant=secondary][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-interactive-secondary-h), var(--dt-color-interactive-secondary-s), calc(var(--dt-color-interactive-secondary-l) + var(--active-modifier)))}.o-btn[variant=outline]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-interactive-secondary);border:1px solid var(--dt-color-border-strong)}.o-btn[variant=outline]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--hover-modifier))}.o-btn[variant=outline]:active:not(:disabled),.o-btn[variant=outline][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--active-modifier))}.o-btn[variant=ghost]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-link)}.o-btn[variant=ghost]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--hover-modifier))}.o-btn[variant=ghost]:active:not(:disabled),.o-btn[variant=ghost][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-black-h), var(--dt-color-black-s), var(--dt-color-black-l), var(--active-modifier))}.o-btn[variant=inverse]{--btn-bg-color: var(--dt-color-interactive-inverse);--btn-text-color: var(--dt-color-content-interactive-secondary)}.o-btn[variant=inverse]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--btn-bg-color: hsl(var(--dt-color-interactive-inverse-h), var(--dt-color-interactive-inverse-s), calc(var(--dt-color-interactive-inverse-l) + var(--hover-modifier)))}.o-btn[variant=inverse]:active:not(:disabled),.o-btn[variant=inverse][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--btn-bg-color: hsl(var(--dt-color-interactive-inverse-h), var(--dt-color-interactive-inverse-s), calc(var(--dt-color-interactive-inverse-l) + var(--active-modifier)))}.o-btn[variant=ghost-inverse],.o-btn[variant=outline-inverse]{--btn-bg-color: transparent;--btn-text-color: var(--dt-color-content-interactive-primary)}.o-btn[variant=ghost-inverse]:hover:not(:disabled),.o-btn[variant=outline-inverse]:hover:not(:disabled){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--hover-modifier: var(--dt-color-hover-01);--btn-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), var(--dt-color-container-default-l), var(--hover-modifier))}.o-btn[variant=ghost-inverse]:active:not(:disabled),.o-btn[variant=ghost-inverse][isLoading]:not(:disabled),.o-btn[variant=outline-inverse]:active:not(:disabled),.o-btn[variant=outline-inverse][isLoading]:not(:disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--active-modifier: var(--dt-color-active-01);--btn-bg-color: hsl(var(--dt-color-container-default-h), var(--dt-color-container-default-s), var(--dt-color-container-default-l), var(--active-modifier))}.o-btn[variant=outline-inverse]:not([disabled]){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);--icon-size-override: 16px}@media (min-width: 768px){.o-btn[size=xsmall][isResponsive]{--btn-height: var(--btn-height--small);--btn-padding: 8px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-16) * 1px);--btn-line-height: calc(var(--dt-font-size-16-line-height) * 1px);--icon-size-override: 20px}.o-btn[size=xsmall][isResponsive][responsiveSize=expressive]{--btn-height: var(--btn-height--small);--btn-padding: 6px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--icon-size-override: 20px}}.o-btn[size=small-expressive]{--btn-height: var(--btn-height--small);--btn-padding: 6px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--icon-size-override: 20px}@media (min-width: 768px){.o-btn[size=small-expressive][isResponsive]{--btn-height: var(--btn-height--medium);--btn-padding: 10px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--icon-size-override: 24px}}.o-btn[size=small-productive]{--btn-height: var(--btn-height--small);--btn-padding: 8px var(--dt-spacing-d);--btn-font-size: calc(var(--dt-font-size-16) * 1px);--btn-line-height: calc(var(--dt-font-size-16-line-height) * 1px);--icon-size-override: 20px}@media (min-width: 768px){.o-btn[size=small-productive][isResponsive]{--btn-height: var(--btn-height--medium);--btn-padding: 10px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--icon-size-override: 24px}}.o-btn[size=medium]{--btn-height: var(--btn-height--medium);--btn-padding: 10px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--icon-size-override: 24px}@media (min-width: 768px){.o-btn[size=medium][isResponsive]{--btn-height: var(--btn-height--large);--btn-padding: 14px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--icon-size-override: 24px}}.o-btn[size=large]{--btn-height: var(--btn-height--large);--btn-padding: 14px var(--dt-spacing-e);--btn-font-size: calc(var(--dt-font-size-20) * 1px);--btn-line-height: calc(var(--dt-font-size-20-line-height) * 1px);--icon-size-override: 24px}.o-btn[isLoading]>*:not(pie-spinner){visibility:hidden}.o-btn[isLoading] pie-spinner{position:absolute}.o-btn:focus-visible{box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer);outline:none}::slotted(svg){height:var(--icon-size-override);width:var(--icon-size-override)}
|
|
17
17
|
`;
|
|
18
18
|
(function() {
|
|
19
19
|
const p = /* @__PURE__ */ new WeakMap(), s = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), S = {
|
|
@@ -87,7 +87,7 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
87
87
|
const o = !t || i.disabled;
|
|
88
88
|
for (; r; )
|
|
89
89
|
r.formDisabledCallback && o && D(r, i.disabled), r = e.nextNode();
|
|
90
|
-
}, G = { attributes: !0, attributeFilter: ["disabled", "name"] }, z =
|
|
90
|
+
}, G = { attributes: !0, attributeFilter: ["disabled", "name"] }, z = I() ? new MutationObserver((i) => {
|
|
91
91
|
for (const t of i) {
|
|
92
92
|
const e = t.target;
|
|
93
93
|
if (t.attributeName === "disabled" && (e.constructor.formAssociated ? D(e, e.hasAttribute("disabled")) : e.localName === "fieldset" && j(e)), t.attributeName === "name" && e.constructor.formAssociated) {
|
|
@@ -142,7 +142,7 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
142
142
|
const t = new MutationObserver(at);
|
|
143
143
|
(e = t.observe) == null || e.call(t, i, { childList: !0 }), K.set(i, t);
|
|
144
144
|
};
|
|
145
|
-
|
|
145
|
+
I() && new MutationObserver(_);
|
|
146
146
|
const P = {
|
|
147
147
|
childList: !0,
|
|
148
148
|
subtree: !0
|
|
@@ -168,9 +168,9 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
168
168
|
const t = Array.from(i.elements).filter((l) => !l.tagName.includes("-") && l.validity).map((l) => l.validity.valid), e = y.get(i) || [], r = Array.from(e).filter((l) => l.isConnected).map((l) => c.get(l).validity.valid), o = [...t, ...r].includes(!1);
|
|
169
169
|
i.toggleAttribute("internals-invalid", o), i.toggleAttribute("internals-valid", !o);
|
|
170
170
|
}, lt = (i) => {
|
|
171
|
-
A(
|
|
171
|
+
A(T(i.target));
|
|
172
172
|
}, ct = (i) => {
|
|
173
|
-
A(
|
|
173
|
+
A(T(i.target));
|
|
174
174
|
}, dt = (i) => {
|
|
175
175
|
const t = ["button[type=submit]", "input[type=submit]", "button:not([type])"].map((e) => `${e}:not([disabled])`).map((e) => `${e}:not([form])${i.id ? `,${e}[form='${i.id}']` : ""}`).join(",");
|
|
176
176
|
i.addEventListener("click", (e) => {
|
|
@@ -199,9 +199,9 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
199
199
|
i.formAssociatedCallback.apply(i, [t]);
|
|
200
200
|
}, 0), A(t);
|
|
201
201
|
}
|
|
202
|
-
},
|
|
202
|
+
}, T = (i) => {
|
|
203
203
|
let t = i.parentNode;
|
|
204
|
-
return t && t.tagName !== "FORM" && (t =
|
|
204
|
+
return t && t.tagName !== "FORM" && (t = T(t)), t;
|
|
205
205
|
}, x = (i, t, e = DOMException) => {
|
|
206
206
|
if (!i.constructor.formAssociated)
|
|
207
207
|
throw new e(t);
|
|
@@ -216,7 +216,7 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
216
216
|
X(i, e), Y(i, r, t);
|
|
217
217
|
}
|
|
218
218
|
};
|
|
219
|
-
function
|
|
219
|
+
function I() {
|
|
220
220
|
return typeof MutationObserver < "u";
|
|
221
221
|
}
|
|
222
222
|
class ht {
|
|
@@ -354,7 +354,7 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
354
354
|
const t = p.get(this);
|
|
355
355
|
x(t, "Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.");
|
|
356
356
|
let e;
|
|
357
|
-
return t.constructor.formAssociated === !0 && (e =
|
|
357
|
+
return t.constructor.formAssociated === !0 && (e = T(t)), e;
|
|
358
358
|
}
|
|
359
359
|
get labels() {
|
|
360
360
|
const t = p.get(this);
|
|
@@ -478,7 +478,7 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
478
478
|
}), typeof Element < "u") {
|
|
479
479
|
let i = function(...e) {
|
|
480
480
|
const r = t.apply(this, e);
|
|
481
|
-
if (H.set(this, r),
|
|
481
|
+
if (H.set(this, r), I()) {
|
|
482
482
|
const o = new MutationObserver(_);
|
|
483
483
|
window.ShadyDOM ? o.observe(this, P) : o.observe(r, P), g.set(this, o);
|
|
484
484
|
}
|
|
@@ -487,18 +487,18 @@ const zt = ["xsmall", "small-productive", "small-expressive", "medium", "large"]
|
|
|
487
487
|
const t = Element.prototype.attachShadow;
|
|
488
488
|
Element.prototype.attachShadow = i;
|
|
489
489
|
}
|
|
490
|
-
|
|
490
|
+
I() && typeof document < "u" && new MutationObserver(_).observe(document.documentElement, P), typeof HTMLFormElement < "u" && gt(), typeof window < "u" && !window.CustomStateSet && (window.CustomStateSet = V);
|
|
491
491
|
}
|
|
492
492
|
})();
|
|
493
|
-
var
|
|
494
|
-
for (var u = c > 1 ? void 0 : c ?
|
|
493
|
+
var At = Object.defineProperty, Tt = Object.getOwnPropertyDescriptor, m = (p, s, a, c) => {
|
|
494
|
+
for (var u = c > 1 ? void 0 : c ? Tt(s, a) : s, f = p.length - 1, g; f >= 0; f--)
|
|
495
495
|
(g = p[f]) && (u = (c ? g(s, a, u) : g(u)) || u);
|
|
496
|
-
return c && u &&
|
|
496
|
+
return c && u && At(s, a, u), u;
|
|
497
497
|
};
|
|
498
498
|
const L = "pie-button";
|
|
499
|
-
class v extends
|
|
499
|
+
class v extends kt(wt) {
|
|
500
500
|
constructor() {
|
|
501
|
-
super(), this.size = "medium", this.type = "submit", this.variant = "primary", this.iconPlacement = "leading", this.disabled = !1, this.isLoading = !1, this.isFullWidth = !1, this.isResponsive = !1, this._handleFormKeyDown = (s) => {
|
|
501
|
+
super(...arguments), this.size = "medium", this.type = "submit", this.variant = "primary", this.iconPlacement = "leading", this.disabled = !1, this.isLoading = !1, this.isFullWidth = !1, this.isResponsive = !1, this._handleFormKeyDown = (s) => {
|
|
502
502
|
if (!(s.key !== "Enter" || this.type !== "submit" || this.disabled)) {
|
|
503
503
|
if (s.target instanceof HTMLElement) {
|
|
504
504
|
const a = s.target.tagName.toLowerCase();
|
|
@@ -507,10 +507,7 @@ class v extends xt {
|
|
|
507
507
|
}
|
|
508
508
|
s.preventDefault(), this._handleClick();
|
|
509
509
|
}
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
get form() {
|
|
513
|
-
return this._internals.form;
|
|
510
|
+
};
|
|
514
511
|
}
|
|
515
512
|
connectedCallback() {
|
|
516
513
|
var s;
|
|
@@ -590,23 +587,22 @@ class v extends xt {
|
|
|
590
587
|
(a = (s = this.shadowRoot) == null ? void 0 : s.querySelector("button")) == null || a.focus();
|
|
591
588
|
}
|
|
592
589
|
}
|
|
593
|
-
v.
|
|
594
|
-
v.styles = wt(Ft);
|
|
590
|
+
v.styles = xt(St);
|
|
595
591
|
m([
|
|
596
592
|
h(),
|
|
597
|
-
R(L,
|
|
593
|
+
R(L, Mt, "medium")
|
|
598
594
|
], v.prototype, "size", 2);
|
|
599
595
|
m([
|
|
600
596
|
h(),
|
|
601
|
-
R(L,
|
|
597
|
+
R(L, Ct, "submit")
|
|
602
598
|
], v.prototype, "type", 2);
|
|
603
599
|
m([
|
|
604
600
|
h(),
|
|
605
|
-
R(L,
|
|
601
|
+
R(L, Lt, "primary")
|
|
606
602
|
], v.prototype, "variant", 2);
|
|
607
603
|
m([
|
|
608
604
|
h({ type: String }),
|
|
609
|
-
R(L,
|
|
605
|
+
R(L, Ft, "leading")
|
|
610
606
|
], v.prototype, "iconPlacement", 2);
|
|
611
607
|
m([
|
|
612
608
|
h({ type: Boolean })
|
|
@@ -644,15 +640,15 @@ m([
|
|
|
644
640
|
m([
|
|
645
641
|
h({ type: String })
|
|
646
642
|
], v.prototype, "responsiveSize", 2);
|
|
647
|
-
|
|
643
|
+
zt(L, v);
|
|
648
644
|
export {
|
|
649
645
|
v as PieButton,
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
646
|
+
Dt as formEncodingtypes,
|
|
647
|
+
$t as formMethodTypes,
|
|
648
|
+
Ot as formTargetTypes,
|
|
649
|
+
Ft as iconPlacements,
|
|
650
|
+
Pt as responsiveSizes,
|
|
651
|
+
Mt as sizes,
|
|
652
|
+
Ct as types,
|
|
653
|
+
Lt as variants
|
|
658
654
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { CSSResult } from 'lit';
|
|
2
|
+
import type { FormControlInterface } from '@justeattakeaway/pie-webc-core';
|
|
3
|
+
import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
2
4
|
import type { LitElement } from 'lit';
|
|
3
5
|
import type { PropertyValues } from 'lit';
|
|
4
6
|
import type { ReactWebComponent } from '@lit/react';
|
|
@@ -96,11 +98,7 @@ export declare const PieButton: ReactWebComponent<PieButton_2, {}>;
|
|
|
96
98
|
* @slot icon - The icon slot
|
|
97
99
|
* @slot - Default slot
|
|
98
100
|
*/
|
|
99
|
-
declare class PieButton_2 extends
|
|
100
|
-
static formAssociated: boolean;
|
|
101
|
-
private readonly _internals;
|
|
102
|
-
get form(): HTMLFormElement | null;
|
|
103
|
-
constructor();
|
|
101
|
+
declare class PieButton_2 extends PieButton_base implements ButtonProps {
|
|
104
102
|
connectedCallback(): void;
|
|
105
103
|
disconnectedCallback(): void;
|
|
106
104
|
updated(changedProperties: PropertyValues<this>): void;
|
|
@@ -142,6 +140,8 @@ declare class PieButton_2 extends LitElement implements ButtonProps {
|
|
|
142
140
|
static styles: CSSResult;
|
|
143
141
|
}
|
|
144
142
|
|
|
143
|
+
declare const PieButton_base: GenericConstructor<FormControlInterface> & typeof LitElement;
|
|
144
|
+
|
|
145
145
|
export declare const responsiveSizes: readonly ["productive", "expressive"];
|
|
146
146
|
|
|
147
147
|
export declare const sizes: readonly ["xsmall", "small-productive", "small-expressive", "medium", "large"];
|
package/package.json
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-button",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"description": "PIE design system button built using web components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
|
+
"custom-elements.json",
|
|
10
11
|
"src",
|
|
11
12
|
"dist",
|
|
12
13
|
"**/*.d.ts"
|
|
13
14
|
],
|
|
14
15
|
"scripts": {
|
|
15
|
-
"build": "
|
|
16
|
+
"build": "run -T vite build",
|
|
17
|
+
"build:react-wrapper": "npx build-react-wrapper",
|
|
18
|
+
"create:manifest": "yarn cem analyze --litelement",
|
|
16
19
|
"lint:scripts": "run -T eslint .",
|
|
17
20
|
"lint:scripts:fix": "run -T eslint . --fix",
|
|
18
21
|
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
|
|
@@ -28,17 +31,21 @@
|
|
|
28
31
|
"author": "Just Eat Takeaway.com - Design System Team",
|
|
29
32
|
"license": "Apache-2.0",
|
|
30
33
|
"devDependencies": {
|
|
31
|
-
"@
|
|
34
|
+
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
35
|
+
"@justeattakeaway/pie-components-config": "0.8.0",
|
|
36
|
+
"@justeattakeaway/pie-wrapper-react": "0.12.0",
|
|
37
|
+
"cem-plugin-module-file-extensions": "0.0.5"
|
|
32
38
|
},
|
|
33
39
|
"volta": {
|
|
34
40
|
"extends": "../../../package.json"
|
|
35
41
|
},
|
|
42
|
+
"customElements": "custom-elements.json",
|
|
36
43
|
"sideEffects": [
|
|
37
44
|
"dist/*.js"
|
|
38
45
|
],
|
|
39
46
|
"dependencies": {
|
|
40
|
-
"@justeattakeaway/pie-spinner": "0.
|
|
41
|
-
"@justeattakeaway/pie-webc-core": "0.
|
|
47
|
+
"@justeattakeaway/pie-spinner": "0.4.0",
|
|
48
|
+
"@justeattakeaway/pie-webc-core": "0.16.0",
|
|
42
49
|
"element-internals-polyfill": "1.3.9"
|
|
43
50
|
}
|
|
44
51
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from 'lit';
|
|
4
4
|
import { property } from 'lit/decorators.js';
|
|
5
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
|
-
import { validPropertyValues, defineCustomElement } from '@justeattakeaway/pie-webc-core';
|
|
6
|
+
import { validPropertyValues, defineCustomElement, FormControlMixin } from '@justeattakeaway/pie-webc-core';
|
|
7
7
|
import {
|
|
8
8
|
ButtonProps, sizes, types, variants, iconPlacements,
|
|
9
9
|
} from './defs';
|
|
@@ -21,21 +21,7 @@ const componentSelector = 'pie-button';
|
|
|
21
21
|
* @slot icon - The icon slot
|
|
22
22
|
* @slot - Default slot
|
|
23
23
|
*/
|
|
24
|
-
export class PieButton extends LitElement implements ButtonProps {
|
|
25
|
-
// TODO - we may want to consider making the element internals code reusable for other form controls.
|
|
26
|
-
static formAssociated = true;
|
|
27
|
-
|
|
28
|
-
private readonly _internals: ElementInternals;
|
|
29
|
-
|
|
30
|
-
public get form () {
|
|
31
|
-
return this._internals.form;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
constructor () {
|
|
35
|
-
super();
|
|
36
|
-
this._internals = this.attachInternals();
|
|
37
|
-
}
|
|
38
|
-
|
|
24
|
+
export class PieButton extends FormControlMixin(LitElement) implements ButtonProps {
|
|
39
25
|
connectedCallback () {
|
|
40
26
|
super.connectedCallback();
|
|
41
27
|
|
package/src/react.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { createComponent } from '@lit/react';
|
|
4
|
+
import { PieButton as PieButtonReact } from './index';
|
|
5
|
+
|
|
6
|
+
export * from './defs';
|
|
7
|
+
|
|
8
|
+
export const PieButton = createComponent({
|
|
9
|
+
displayName: 'PieButton',
|
|
10
|
+
elementClass: PieButtonReact,
|
|
11
|
+
react: React,
|
|
12
|
+
tagName: 'pie-button',
|
|
13
|
+
events: {},
|
|
14
|
+
});
|