@justeattakeaway/pie-button 0.48.0 → 0.49.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 +105 -31
- package/dist/index.d.ts +36 -8
- package/dist/index.js +314 -272
- package/dist/react.d.ts +36 -8
- package/dist/react.js +14 -12
- package/package.json +4 -3
- package/src/button.scss +2 -1
- package/src/defs.ts +32 -1
- package/src/index.ts +101 -54
package/custom-elements.json
CHANGED
|
@@ -12,6 +12,14 @@
|
|
|
12
12
|
"kind": "javascript-module",
|
|
13
13
|
"path": "src/defs.js",
|
|
14
14
|
"declarations": [
|
|
15
|
+
{
|
|
16
|
+
"kind": "variable",
|
|
17
|
+
"name": "tags",
|
|
18
|
+
"type": {
|
|
19
|
+
"text": "['button', 'a']"
|
|
20
|
+
},
|
|
21
|
+
"default": "['button', 'a']"
|
|
22
|
+
},
|
|
15
23
|
{
|
|
16
24
|
"kind": "variable",
|
|
17
25
|
"name": "sizes",
|
|
@@ -82,10 +90,18 @@
|
|
|
82
90
|
"type": {
|
|
83
91
|
"text": "DefaultProps"
|
|
84
92
|
},
|
|
85
|
-
"default": "{\n size: 'medium',\n type: 'submit',\n variant: 'primary',\n iconPlacement: 'leading',\n disabled: false,\n isLoading: false,\n isFullWidth: false,\n isResponsive: false,\n}"
|
|
93
|
+
"default": "{\n tag: 'button',\n size: 'medium',\n type: 'submit',\n variant: 'primary',\n iconPlacement: 'leading',\n disabled: false,\n isLoading: false,\n isFullWidth: false,\n isResponsive: false,\n}"
|
|
86
94
|
}
|
|
87
95
|
],
|
|
88
96
|
"exports": [
|
|
97
|
+
{
|
|
98
|
+
"kind": "js",
|
|
99
|
+
"name": "tags",
|
|
100
|
+
"declaration": {
|
|
101
|
+
"name": "tags",
|
|
102
|
+
"module": "src/defs.js"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
89
105
|
{
|
|
90
106
|
"kind": "js",
|
|
91
107
|
"name": "sizes",
|
|
@@ -179,39 +195,33 @@
|
|
|
179
195
|
}
|
|
180
196
|
],
|
|
181
197
|
"members": [
|
|
198
|
+
{
|
|
199
|
+
"kind": "field",
|
|
200
|
+
"name": "tag",
|
|
201
|
+
"privacy": "public",
|
|
202
|
+
"attribute": "tag"
|
|
203
|
+
},
|
|
182
204
|
{
|
|
183
205
|
"kind": "field",
|
|
184
206
|
"name": "size",
|
|
185
|
-
"type": {
|
|
186
|
-
"text": "ButtonProps['size']"
|
|
187
|
-
},
|
|
188
207
|
"privacy": "public",
|
|
189
208
|
"attribute": "size"
|
|
190
209
|
},
|
|
191
210
|
{
|
|
192
211
|
"kind": "field",
|
|
193
212
|
"name": "type",
|
|
194
|
-
"type": {
|
|
195
|
-
"text": "ButtonProps['type']"
|
|
196
|
-
},
|
|
197
213
|
"privacy": "public",
|
|
198
214
|
"attribute": "type"
|
|
199
215
|
},
|
|
200
216
|
{
|
|
201
217
|
"kind": "field",
|
|
202
218
|
"name": "variant",
|
|
203
|
-
"type": {
|
|
204
|
-
"text": "ButtonProps['variant']"
|
|
205
|
-
},
|
|
206
219
|
"privacy": "public",
|
|
207
220
|
"attribute": "variant"
|
|
208
221
|
},
|
|
209
222
|
{
|
|
210
223
|
"kind": "field",
|
|
211
224
|
"name": "iconPlacement",
|
|
212
|
-
"type": {
|
|
213
|
-
"text": "ButtonProps['iconPlacement']"
|
|
214
|
-
},
|
|
215
225
|
"privacy": "public",
|
|
216
226
|
"attribute": "iconPlacement"
|
|
217
227
|
},
|
|
@@ -244,7 +254,7 @@
|
|
|
244
254
|
"kind": "field",
|
|
245
255
|
"name": "name",
|
|
246
256
|
"type": {
|
|
247
|
-
"text": "
|
|
257
|
+
"text": "ButtonProps['name']"
|
|
248
258
|
},
|
|
249
259
|
"privacy": "public",
|
|
250
260
|
"attribute": "name"
|
|
@@ -253,7 +263,7 @@
|
|
|
253
263
|
"kind": "field",
|
|
254
264
|
"name": "value",
|
|
255
265
|
"type": {
|
|
256
|
-
"text": "
|
|
266
|
+
"text": "ButtonProps['value']"
|
|
257
267
|
},
|
|
258
268
|
"privacy": "public",
|
|
259
269
|
"attribute": "value"
|
|
@@ -307,11 +317,38 @@
|
|
|
307
317
|
"kind": "field",
|
|
308
318
|
"name": "responsiveSize",
|
|
309
319
|
"type": {
|
|
310
|
-
"text": "ButtonProps['responsiveSize']
|
|
320
|
+
"text": "ButtonProps['responsiveSize']"
|
|
311
321
|
},
|
|
312
322
|
"privacy": "public",
|
|
313
323
|
"attribute": "responsiveSize"
|
|
314
324
|
},
|
|
325
|
+
{
|
|
326
|
+
"kind": "field",
|
|
327
|
+
"name": "href",
|
|
328
|
+
"type": {
|
|
329
|
+
"text": "ButtonProps['href']"
|
|
330
|
+
},
|
|
331
|
+
"privacy": "public",
|
|
332
|
+
"attribute": "href"
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
"kind": "field",
|
|
336
|
+
"name": "rel",
|
|
337
|
+
"type": {
|
|
338
|
+
"text": "ButtonProps['rel']"
|
|
339
|
+
},
|
|
340
|
+
"privacy": "public",
|
|
341
|
+
"attribute": "rel"
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
"kind": "field",
|
|
345
|
+
"name": "target",
|
|
346
|
+
"type": {
|
|
347
|
+
"text": "ButtonProps['target']"
|
|
348
|
+
},
|
|
349
|
+
"privacy": "public",
|
|
350
|
+
"attribute": "target"
|
|
351
|
+
},
|
|
315
352
|
{
|
|
316
353
|
"kind": "method",
|
|
317
354
|
"name": "_simulateNativeButtonClick",
|
|
@@ -347,38 +384,54 @@
|
|
|
347
384
|
},
|
|
348
385
|
"description": "Template for the loading state"
|
|
349
386
|
},
|
|
387
|
+
{
|
|
388
|
+
"kind": "method",
|
|
389
|
+
"name": "renderAnchor",
|
|
390
|
+
"parameters": [
|
|
391
|
+
{
|
|
392
|
+
"name": "classes",
|
|
393
|
+
"type": {
|
|
394
|
+
"text": "ClassInfo"
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
]
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
"kind": "method",
|
|
401
|
+
"name": "renderButton",
|
|
402
|
+
"parameters": [
|
|
403
|
+
{
|
|
404
|
+
"name": "classes",
|
|
405
|
+
"type": {
|
|
406
|
+
"text": "ClassInfo"
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
]
|
|
410
|
+
},
|
|
350
411
|
{
|
|
351
412
|
"kind": "method",
|
|
352
413
|
"name": "focus"
|
|
353
414
|
}
|
|
354
415
|
],
|
|
355
416
|
"attributes": [
|
|
417
|
+
{
|
|
418
|
+
"name": "tag",
|
|
419
|
+
"fieldName": "tag"
|
|
420
|
+
},
|
|
356
421
|
{
|
|
357
422
|
"name": "size",
|
|
358
|
-
"type": {
|
|
359
|
-
"text": "ButtonProps['size']"
|
|
360
|
-
},
|
|
361
423
|
"fieldName": "size"
|
|
362
424
|
},
|
|
363
425
|
{
|
|
364
426
|
"name": "type",
|
|
365
|
-
"type": {
|
|
366
|
-
"text": "ButtonProps['type']"
|
|
367
|
-
},
|
|
368
427
|
"fieldName": "type"
|
|
369
428
|
},
|
|
370
429
|
{
|
|
371
430
|
"name": "variant",
|
|
372
|
-
"type": {
|
|
373
|
-
"text": "ButtonProps['variant']"
|
|
374
|
-
},
|
|
375
431
|
"fieldName": "variant"
|
|
376
432
|
},
|
|
377
433
|
{
|
|
378
434
|
"name": "iconPlacement",
|
|
379
|
-
"type": {
|
|
380
|
-
"text": "ButtonProps['iconPlacement']"
|
|
381
|
-
},
|
|
382
435
|
"fieldName": "iconPlacement"
|
|
383
436
|
},
|
|
384
437
|
{
|
|
@@ -400,14 +453,14 @@
|
|
|
400
453
|
{
|
|
401
454
|
"name": "name",
|
|
402
455
|
"type": {
|
|
403
|
-
"text": "
|
|
456
|
+
"text": "ButtonProps['name']"
|
|
404
457
|
},
|
|
405
458
|
"fieldName": "name"
|
|
406
459
|
},
|
|
407
460
|
{
|
|
408
461
|
"name": "value",
|
|
409
462
|
"type": {
|
|
410
|
-
"text": "
|
|
463
|
+
"text": "ButtonProps['value']"
|
|
411
464
|
},
|
|
412
465
|
"fieldName": "value"
|
|
413
466
|
},
|
|
@@ -449,9 +502,30 @@
|
|
|
449
502
|
{
|
|
450
503
|
"name": "responsiveSize",
|
|
451
504
|
"type": {
|
|
452
|
-
"text": "ButtonProps['responsiveSize']
|
|
505
|
+
"text": "ButtonProps['responsiveSize']"
|
|
453
506
|
},
|
|
454
507
|
"fieldName": "responsiveSize"
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
"name": "href",
|
|
511
|
+
"type": {
|
|
512
|
+
"text": "ButtonProps['href']"
|
|
513
|
+
},
|
|
514
|
+
"fieldName": "href"
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
"name": "rel",
|
|
518
|
+
"type": {
|
|
519
|
+
"text": "ButtonProps['rel']"
|
|
520
|
+
},
|
|
521
|
+
"fieldName": "rel"
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
"name": "target",
|
|
525
|
+
"type": {
|
|
526
|
+
"text": "ButtonProps['target']"
|
|
527
|
+
},
|
|
528
|
+
"fieldName": "target"
|
|
455
529
|
}
|
|
456
530
|
],
|
|
457
531
|
"mixins": [
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ClassInfo } from 'lit/directives/class-map.js';
|
|
1
2
|
import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
|
|
2
3
|
import type { CSSResult } from 'lit';
|
|
3
4
|
import type { FormControlInterface } from '@justeattakeaway/pie-webc-core';
|
|
@@ -7,6 +8,10 @@ import type { PropertyValues } from 'lit';
|
|
|
7
8
|
import type { TemplateResult } from 'lit';
|
|
8
9
|
|
|
9
10
|
export declare interface ButtonProps {
|
|
11
|
+
/**
|
|
12
|
+
* Which HTML element to use when rendering the button.
|
|
13
|
+
*/
|
|
14
|
+
tag?: typeof tags[number];
|
|
10
15
|
/**
|
|
11
16
|
* What size the button should be.
|
|
12
17
|
*/
|
|
@@ -81,9 +86,24 @@ export declare interface ButtonProps {
|
|
|
81
86
|
* What size should be attributed to the button when isResponsive is true and the screen is wide.
|
|
82
87
|
*/
|
|
83
88
|
responsiveSize?: typeof responsiveSizes[number];
|
|
89
|
+
/**
|
|
90
|
+
* If the button is rendered as an anchor element, this attribute will be applied to the `href` attribute on the anchor.
|
|
91
|
+
* [MDN reference](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#href)
|
|
92
|
+
*/
|
|
93
|
+
href?: string;
|
|
94
|
+
/**
|
|
95
|
+
* If the button is rendered as an anchor element, this attribute will be applied to the `rel` attribute on the anchor.
|
|
96
|
+
* [MDN reference](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel)
|
|
97
|
+
*/
|
|
98
|
+
rel?: string;
|
|
99
|
+
/**
|
|
100
|
+
* If the button is rendered as an anchor element, this attribute will be applied to the `target` attribute on the anchor.
|
|
101
|
+
* [MDN reference](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target)
|
|
102
|
+
*/
|
|
103
|
+
target?: string;
|
|
84
104
|
}
|
|
85
105
|
|
|
86
|
-
export declare type DefaultProps = ComponentDefaultProps<ButtonProps, 'size' | 'type' | 'variant' | 'iconPlacement' | 'disabled' | 'isFullWidth' | 'isLoading' | 'isResponsive'>;
|
|
106
|
+
export declare type DefaultProps = ComponentDefaultProps<ButtonProps, 'tag' | 'size' | 'type' | 'variant' | 'iconPlacement' | 'disabled' | 'isFullWidth' | 'isLoading' | 'isResponsive'>;
|
|
87
107
|
|
|
88
108
|
export declare const defaultProps: DefaultProps;
|
|
89
109
|
|
|
@@ -104,22 +124,26 @@ export declare class PieButton extends PieButton_base implements ButtonProps {
|
|
|
104
124
|
connectedCallback(): void;
|
|
105
125
|
disconnectedCallback(): void;
|
|
106
126
|
updated(changedProperties: PropertyValues<this>): void;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
127
|
+
tag: "button" | "a";
|
|
128
|
+
size: "xsmall" | "medium" | "large" | "small-productive" | "small-expressive";
|
|
129
|
+
type: "button" | "submit" | "reset";
|
|
130
|
+
variant: "secondary" | "inverse" | "primary" | "outline" | "outline-inverse" | "ghost" | "ghost-inverse" | "destructive" | "destructive-ghost";
|
|
131
|
+
iconPlacement: "leading" | "trailing";
|
|
111
132
|
disabled: boolean;
|
|
112
133
|
isLoading: boolean;
|
|
113
134
|
isFullWidth: boolean;
|
|
114
135
|
isResponsive: boolean;
|
|
115
|
-
name
|
|
116
|
-
value
|
|
136
|
+
name: ButtonProps['name'];
|
|
137
|
+
value: ButtonProps['value'];
|
|
117
138
|
formaction: ButtonProps['formaction'];
|
|
118
139
|
formenctype: ButtonProps['formenctype'];
|
|
119
140
|
formmethod: ButtonProps['formmethod'];
|
|
120
141
|
formnovalidate: ButtonProps['formnovalidate'];
|
|
121
142
|
formtarget: ButtonProps['formtarget'];
|
|
122
|
-
responsiveSize
|
|
143
|
+
responsiveSize: ButtonProps['responsiveSize'];
|
|
144
|
+
href: ButtonProps['href'];
|
|
145
|
+
rel: ButtonProps['rel'];
|
|
146
|
+
target: ButtonProps['target'];
|
|
123
147
|
/**
|
|
124
148
|
* This method creates an invisible button of the same type as pie-button. It is then clicked, and immediately removed from the DOM.
|
|
125
149
|
* 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
|
|
@@ -137,6 +161,8 @@ export declare class PieButton extends PieButton_base implements ButtonProps {
|
|
|
137
161
|
* @private
|
|
138
162
|
*/
|
|
139
163
|
private renderSpinner;
|
|
164
|
+
renderAnchor(classes: ClassInfo): TemplateResult<1>;
|
|
165
|
+
renderButton(classes: ClassInfo): TemplateResult<1>;
|
|
140
166
|
render(): TemplateResult<1>;
|
|
141
167
|
focus(): void;
|
|
142
168
|
static styles: CSSResult;
|
|
@@ -148,6 +174,8 @@ export declare const responsiveSizes: readonly ["productive", "expressive"];
|
|
|
148
174
|
|
|
149
175
|
export declare const sizes: readonly ["xsmall", "small-productive", "small-expressive", "medium", "large"];
|
|
150
176
|
|
|
177
|
+
export declare const tags: readonly ["button", "a"];
|
|
178
|
+
|
|
151
179
|
export declare const types: readonly ["submit", "button", "reset"];
|
|
152
180
|
|
|
153
181
|
export declare type Variant = typeof variants[number];
|