@justeattakeaway/pie-button 0.44.0 → 0.45.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.
@@ -2,6 +2,12 @@
2
2
  "schemaVersion": "1.0.0",
3
3
  "readme": "",
4
4
  "modules": [
5
+ {
6
+ "kind": "javascript-module",
7
+ "path": "src/defs-react.js",
8
+ "declarations": [],
9
+ "exports": []
10
+ },
5
11
  {
6
12
  "kind": "javascript-module",
7
13
  "path": "src/defs.js",
package/dist/index.d.ts CHANGED
@@ -9,15 +9,15 @@ export declare interface ButtonProps {
9
9
  /**
10
10
  * What size the button should be.
11
11
  */
12
- size: typeof sizes[number];
12
+ size?: typeof sizes[number];
13
13
  /**
14
14
  * What type attribute should be applied to the button. For example submit, button.
15
15
  */
16
- type: typeof types[number];
16
+ type?: typeof types[number];
17
17
  /**
18
18
  * What style variant the button should be such as primary, outline or ghost.
19
19
  */
20
- variant: Variant;
20
+ variant?: Variant;
21
21
  /**
22
22
  * The placement of the icon slot, if provided, such as leading or trailing
23
23
  */
@@ -25,19 +25,19 @@ export declare interface ButtonProps {
25
25
  /**
26
26
  * When true, the button element is disabled.
27
27
  */
28
- disabled: boolean;
28
+ disabled?: boolean;
29
29
  /**
30
30
  * When true, the button element will occupy the full width of its container.
31
31
  */
32
- isFullWidth: boolean;
32
+ isFullWidth?: boolean;
33
33
  /**
34
34
  * When true, displays a loading indicator inside the button.
35
35
  */
36
- isLoading: boolean;
36
+ isLoading?: boolean;
37
37
  /**
38
38
  * When true, enables the responsive size feature.
39
39
  */
40
- isResponsive: boolean;
40
+ isResponsive?: boolean;
41
41
  /**
42
42
  * The name of the button, submitted as a pair with the button's value as part of the form data, when that button is used to submit the form.
43
43
  * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attributes)
package/dist/index.js CHANGED
@@ -544,7 +544,7 @@ class v extends kt(wt) {
544
544
  * @private
545
545
  */
546
546
  renderSpinner() {
547
- const { size: s, variant: a, disabled: c } = this, u = s.includes("small") ? "small" : "medium";
547
+ const { size: s, variant: a, disabled: c } = this, u = s && s.includes("small") ? "small" : "medium";
548
548
  let f;
549
549
  return c ? f = a === "ghost-inverse" ? "inverse" : "secondary" : f = ["primary", "destructive", "outline-inverse", "ghost-inverse"].includes(this.variant) ? "inverse" : "secondary", N`
550
550
  <pie-spinner
@@ -568,9 +568,9 @@ class v extends kt(wt) {
568
568
  <button
569
569
  @click=${this._handleClick}
570
570
  class="o-btn"
571
- type=${s}
572
- variant=${u}
573
- size=${f}
571
+ type=${s || "submit"}
572
+ variant=${u || "primary"}
573
+ size=${f || "medium"}
574
574
  responsiveSize=${Et(k)}
575
575
  ?disabled=${a}
576
576
  ?isFullWidth=${c}
package/dist/react.d.ts CHANGED
@@ -3,22 +3,22 @@ import type { FormControlInterface } from '@justeattakeaway/pie-webc-core';
3
3
  import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
4
4
  import type { LitElement } from 'lit';
5
5
  import type { PropertyValues } from 'lit';
6
- import type { ReactWebComponent } from '@lit/react';
6
+ import * as React_2 from 'react';
7
7
  import type { TemplateResult } from 'lit';
8
8
 
9
9
  export declare interface ButtonProps {
10
10
  /**
11
11
  * What size the button should be.
12
12
  */
13
- size: typeof sizes[number];
13
+ size?: typeof sizes[number];
14
14
  /**
15
15
  * What type attribute should be applied to the button. For example submit, button.
16
16
  */
17
- type: typeof types[number];
17
+ type?: typeof types[number];
18
18
  /**
19
19
  * What style variant the button should be such as primary, outline or ghost.
20
20
  */
21
- variant: Variant;
21
+ variant?: Variant;
22
22
  /**
23
23
  * The placement of the icon slot, if provided, such as leading or trailing
24
24
  */
@@ -26,19 +26,19 @@ export declare interface ButtonProps {
26
26
  /**
27
27
  * When true, the button element is disabled.
28
28
  */
29
- disabled: boolean;
29
+ disabled?: boolean;
30
30
  /**
31
31
  * When true, the button element will occupy the full width of its container.
32
32
  */
33
- isFullWidth: boolean;
33
+ isFullWidth?: boolean;
34
34
  /**
35
35
  * When true, displays a loading indicator inside the button.
36
36
  */
37
- isLoading: boolean;
37
+ isLoading?: boolean;
38
38
  /**
39
39
  * When true, enables the responsive size feature.
40
40
  */
41
- isResponsive: boolean;
41
+ isResponsive?: boolean;
42
42
  /**
43
43
  * The name of the button, submitted as a pair with the button's value as part of the form data, when that button is used to submit the form.
44
44
  * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attributes)
@@ -91,7 +91,7 @@ export declare const formTargetTypes: readonly ["_self", "_blank", "_parent", "_
91
91
 
92
92
  export declare const iconPlacements: readonly ["leading", "trailing"];
93
93
 
94
- export declare const PieButton: ReactWebComponent<PieButton_2, {}>;
94
+ export declare const PieButton: React_2.ForwardRefExoticComponent<ButtonProps & React_2.RefAttributes<PieButton_2> & ReactBaseType>;
95
95
 
96
96
  /**
97
97
  * @tagname pie-button
@@ -142,6 +142,8 @@ declare class PieButton_2 extends PieButton_base implements ButtonProps {
142
142
 
143
143
  declare const PieButton_base: GenericConstructor<FormControlInterface> & typeof LitElement;
144
144
 
145
+ declare type ReactBaseType = React_2.ButtonHTMLAttributes<HTMLButtonElement>;
146
+
145
147
  export declare const responsiveSizes: readonly ["productive", "expressive"];
146
148
 
147
149
  export declare const sizes: readonly ["xsmall", "small-productive", "small-expressive", "medium", "large"];
package/dist/react.js CHANGED
@@ -1,27 +1,27 @@
1
1
  import * as t from "react";
2
2
  import { createComponent as e } from "@lit/react";
3
3
  import { PieButton as o } from "./index.js";
4
- import { formEncodingtypes as y, formMethodTypes as P, formTargetTypes as l, iconPlacements as B, responsiveSizes as d, sizes as g, types as v, variants as T } from "./index.js";
4
+ import { formEncodingtypes as y, formMethodTypes as B, formTargetTypes as l, iconPlacements as d, responsiveSizes as g, sizes as v, types as T, variants as x } from "./index.js";
5
5
  import "lit";
6
6
  import "lit/decorators.js";
7
7
  import "lit/directives/if-defined.js";
8
8
  import "@justeattakeaway/pie-webc-core";
9
9
  import "@justeattakeaway/pie-spinner";
10
- const c = e({
10
+ const r = e({
11
11
  displayName: "PieButton",
12
12
  elementClass: o,
13
13
  react: t,
14
14
  tagName: "pie-button",
15
15
  events: {}
16
- });
16
+ }), f = r;
17
17
  export {
18
- c as PieButton,
18
+ f as PieButton,
19
19
  y as formEncodingtypes,
20
- P as formMethodTypes,
20
+ B as formMethodTypes,
21
21
  l as formTargetTypes,
22
- B as iconPlacements,
23
- d as responsiveSizes,
24
- g as sizes,
25
- v as types,
26
- T as variants
22
+ d as iconPlacements,
23
+ g as responsiveSizes,
24
+ v as sizes,
25
+ T as types,
26
+ x as variants
27
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-button",
3
- "version": "0.44.0",
3
+ "version": "0.45.0",
4
4
  "description": "PIE design system button built using web components",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -32,8 +32,8 @@
32
32
  "license": "Apache-2.0",
33
33
  "devDependencies": {
34
34
  "@custom-elements-manifest/analyzer": "0.9.0",
35
- "@justeattakeaway/pie-components-config": "0.8.0",
36
- "@justeattakeaway/pie-wrapper-react": "0.12.0",
35
+ "@justeattakeaway/pie-components-config": "0.9.0",
36
+ "@justeattakeaway/pie-wrapper-react": "0.13.0",
37
37
  "cem-plugin-module-file-extensions": "0.0.5"
38
38
  },
39
39
  "volta": {
@@ -44,8 +44,8 @@
44
44
  "dist/*.js"
45
45
  ],
46
46
  "dependencies": {
47
- "@justeattakeaway/pie-spinner": "0.4.0",
48
- "@justeattakeaway/pie-webc-core": "0.16.0",
47
+ "@justeattakeaway/pie-spinner": "0.5.0",
48
+ "@justeattakeaway/pie-webc-core": "0.17.0",
49
49
  "element-internals-polyfill": "1.3.9"
50
50
  }
51
51
  }
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+
3
+ export type ReactBaseType = React.ButtonHTMLAttributes<HTMLButtonElement>
package/src/defs.ts CHANGED
@@ -17,15 +17,15 @@ export interface ButtonProps {
17
17
  /**
18
18
  * What size the button should be.
19
19
  */
20
- size: typeof sizes[number];
20
+ size?: typeof sizes[number];
21
21
  /**
22
22
  * What type attribute should be applied to the button. For example submit, button.
23
23
  */
24
- type: typeof types[number];
24
+ type?: typeof types[number];
25
25
  /**
26
26
  * What style variant the button should be such as primary, outline or ghost.
27
27
  */
28
- variant: Variant;
28
+ variant?: Variant;
29
29
  /**
30
30
  * The placement of the icon slot, if provided, such as leading or trailing
31
31
  */
@@ -33,20 +33,20 @@ export interface ButtonProps {
33
33
  /**
34
34
  * When true, the button element is disabled.
35
35
  */
36
- disabled: boolean;
36
+ disabled?: boolean;
37
37
  /**
38
38
  * When true, the button element will occupy the full width of its container.
39
39
  */
40
- isFullWidth: boolean;
40
+ isFullWidth?: boolean;
41
41
  /**
42
42
  * When true, displays a loading indicator inside the button.
43
43
  */
44
- isLoading: boolean;
44
+ isLoading?: boolean;
45
45
 
46
46
  /**
47
47
  * When true, enables the responsive size feature.
48
48
  */
49
- isResponsive: boolean;
49
+ isResponsive?: boolean;
50
50
 
51
51
  /**
52
52
  * The name of the button, submitted as a pair with the button's value as part of the form data, when that button is used to submit the form.
package/src/index.ts CHANGED
@@ -197,7 +197,7 @@ export class PieButton extends FormControlMixin(LitElement) implements ButtonPro
197
197
  */
198
198
  private renderSpinner (): TemplateResult {
199
199
  const { size, variant, disabled } = this;
200
- const spinnerSize = size.includes('small') ? 'small' : 'medium'; // includes("small") matches for any small size value and xsmall
200
+ const spinnerSize = size && size.includes('small') ? 'small' : 'medium'; // includes("small") matches for any small size value and xsmall
201
201
  let spinnerVariant;
202
202
  if (disabled) {
203
203
  spinnerVariant = variant === 'ghost-inverse' ? 'inverse' : 'secondary';
@@ -230,9 +230,9 @@ export class PieButton extends FormControlMixin(LitElement) implements ButtonPro
230
230
  <button
231
231
  @click=${this._handleClick}
232
232
  class="o-btn"
233
- type=${type}
234
- variant=${variant}
235
- size=${size}
233
+ type=${type || 'submit'}
234
+ variant=${variant || 'primary'}
235
+ size=${size || 'medium'}
236
236
  responsiveSize=${ifDefined(responsiveSize)}
237
237
  ?disabled=${disabled}
238
238
  ?isFullWidth=${isFullWidth}
package/src/react.ts CHANGED
@@ -1,14 +1,20 @@
1
-
2
1
  import * as React from 'react';
3
2
  import { createComponent } from '@lit/react';
4
- import { PieButton as PieButtonReact } from './index';
3
+ import { PieButton as PieButtonLit } from './index';
4
+ import { ButtonProps } from './defs';
5
5
 
6
6
  export * from './defs';
7
7
 
8
- export const PieButton = createComponent({
8
+ const PieButtonReact = createComponent({
9
9
  displayName: 'PieButton',
10
- elementClass: PieButtonReact,
10
+ elementClass: PieButtonLit,
11
11
  react: React,
12
12
  tagName: 'pie-button',
13
13
  events: {},
14
14
  });
15
+
16
+ type ReactBaseType = React.ButtonHTMLAttributes<HTMLButtonElement>
17
+
18
+
19
+
20
+ export const PieButton = PieButtonReact as React.ForwardRefExoticComponent<React.PropsWithoutRef<ButtonProps> & React.RefAttributes<PieButtonLit> & ReactBaseType>;