@justeattakeaway/pie-button 0.7.0 → 0.9.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.
@@ -3,4 +3,27 @@ transforming...
3
3
  ✓ 4 modules transformed.
4
4
  rendering chunks...
5
5
  computing gzip size...
6
- dist/pie-button.js 3.69 kB │ gzip: 1.55 kB
6
+ dist/index.js 3.81 kB │ gzip: 1.60 kB
7
+ 
8
+ [vite:dts] Start generate declaration files...
9
+ ../../../node_modules/@types/react-dom/node_modules/@types/react/index.d.ts:3135:14 - error TS2300: Duplicate identifier 'LibraryManagedAttributes'.
10
+
11
+ 3135 type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
12
+    ~~~~~~~~~~~~~~~~~~~~~~~~
13
+
14
+ ../../../node_modules/@types/react/index.d.ts:3135:14
15
+ 3135 type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
16
+    ~~~~~~~~~~~~~~~~~~~~~~~~
17
+ 'LibraryManagedAttributes' was also declared here.
18
+ ../../../node_modules/@types/react/index.d.ts:3135:14 - error TS2300: Duplicate identifier 'LibraryManagedAttributes'.
19
+
20
+ 3135 type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
21
+    ~~~~~~~~~~~~~~~~~~~~~~~~
22
+
23
+ ../../../node_modules/@types/react-dom/node_modules/@types/react/index.d.ts:3135:14
24
+ 3135 type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
25
+    ~~~~~~~~~~~~~~~~~~~~~~~~
26
+ 'LibraryManagedAttributes' was also declared here.
27
+
28
+ [vite:dts] Declaration files built in 17153ms.
29
+ 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [Added] - HTMLElementTagNameMap entry for pie-button element ([#364](https://github.com/justeattakeaway/pie/pull/364)) by [@jamieomaguire](https://github.com/jamieomaguire)
8
+
9
+ - [Added] - Slot functionality to pie-button component and associated SB and example app integrations ([#364](https://github.com/justeattakeaway/pie/pull/364)) by [@jamieomaguire](https://github.com/jamieomaguire)
10
+
11
+ ## 0.8.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [Updated] - Register approach for button web component ([#346](https://github.com/justeattakeaway/pie/pull/346)) by [@fernandofranca](https://github.com/fernandofranca)
16
+
17
+ [Added] - "types" field in package.json for better DX and IDE TypesScript support
18
+ [Updated] - Provide Vite settings for generating TypeScript declaration files during build
19
+
3
20
  ## 0.7.0
4
21
 
5
22
  ### Minor Changes
@@ -1,8 +1,8 @@
1
1
  import { unsafeCSS as f, LitElement as h, html as g } from "lit";
2
2
  import { classMap as m } from "lit/directives/class-map.js";
3
- import { property as p, customElement as v } from "lit/decorators.js";
3
+ import { property as u, customElement as v } from "lit/decorators.js";
4
4
  const x = `.o-btn{border-radius:50rem;border:none;font-family:JetSansDigital;font-weight:700;cursor:pointer;user-select:none;outline:none}.o-btn:focus-visible{outline:2px solid #4996fd}.o-btn--xsmall{padding:6px 8px;min-height:32px;font-size:14px;line-height:20px}.o-btn--small{padding:8px 16px;min-height:40px;font-size:19px;line-height:28px}.o-btn--medium{padding:10px 24px;min-height:48px;font-size:20px;line-height:28px}.o-btn--large{padding:14px 24px;min-height:56px;font-size:20px;line-height:28px}.o-btn--primary{background-color:#f36805;color:#fff}.o-btn--primary:hover{background-color:#df5f05}.o-btn--primary:active{background-color:#b74e04}.o-btn--secondary{background-color:#f5f3f1;color:#242e30}.o-btn--secondary:hover{background-color:#ede9e5}.o-btn--secondary:active{background-color:#dcd4cd}.o-btn--outline{outline:1px solid #dbd9d7;background-color:#fff;color:#303d3f}.o-btn--outline:hover{background-color:#f5f5f5}.o-btn--outline:active{background-color:#e0e0e0}.o-btn--ghost{background-color:#fff;color:#242e30}.o-btn--ghost:hover{background-color:#f5f5f5}.o-btn--ghost:active{background-color:#e0e0e0}.o-btn.o-btn--is-disabled{background-color:#efedea;color:#8c999b;outline:1px solid #efedea;cursor:default}.o-btn.o-btn--is-disabled.o-btn--ghost{background-color:#fff;outline:none}
5
- `, u = (o, n) => function(i, t) {
5
+ `, p = (o, n) => function(i, t) {
6
6
  const e = `#${t}`;
7
7
  Object.defineProperty(i, t, {
8
8
  get() {
@@ -18,14 +18,20 @@ const x = `.o-btn{border-radius:50rem;border:none;font-family:JetSansDigital;fon
18
18
  }
19
19
  });
20
20
  };
21
- var c = /* @__PURE__ */ ((o) => (o.XSMALL = "xsmall", o.SMALL = "small", o.MEDIUM = "medium", o.LARGE = "large", o))(c || {}), d = /* @__PURE__ */ ((o) => (o.SUBMIT = "submit", o.BUTTON = "button", o.RESET = "reset", o.MENU = "menu", o))(d || {}), b = /* @__PURE__ */ ((o) => (o.PRIMARY = "primary", o.SECONDARY = "secondary", o.OUTLINE = "outline", o.GHOST = "ghost", o))(b || {}), y = Object.defineProperty, M = Object.getOwnPropertyDescriptor, a = (o, n, i, t) => {
21
+ var a = /* @__PURE__ */ ((o) => (o.XSMALL = "xsmall", o.SMALL = "small", o.MEDIUM = "medium", o.LARGE = "large", o))(a || {}), d = /* @__PURE__ */ ((o) => (o.SUBMIT = "submit", o.BUTTON = "button", o.RESET = "reset", o.MENU = "menu", o))(d || {}), b = /* @__PURE__ */ ((o) => (o.PRIMARY = "primary", o.SECONDARY = "secondary", o.OUTLINE = "outline", o.GHOST = "ghost", o))(b || {}), y = Object.defineProperty, M = Object.getOwnPropertyDescriptor, c = (o, n, i, t) => {
22
22
  for (var e = t > 1 ? void 0 : t ? M(n, i) : n, r = o.length - 1, s; r >= 0; r--)
23
23
  (s = o[r]) && (e = (t ? s(n, i, e) : s(e)) || e);
24
24
  return t && e && y(n, i, e), e;
25
25
  };
26
+ function k(o) {
27
+ return (n) => {
28
+ if (!customElements.get(o))
29
+ return v(o)(n);
30
+ };
31
+ }
26
32
  let l = class extends h {
27
33
  constructor() {
28
- super(...arguments), this.size = c.MEDIUM, this.type = d.SUBMIT, this.variant = b.PRIMARY, this.disabled = !1;
34
+ super(...arguments), this.size = a.MEDIUM, this.type = d.SUBMIT, this.variant = b.PRIMARY, this.disabled = !1;
29
35
  }
30
36
  render() {
31
37
  const { size: o, type: n, variant: i, disabled: t } = this, e = {
@@ -43,31 +49,31 @@ let l = class extends h {
43
49
  type=${n}
44
50
  ?disabled=${t}
45
51
  @click="${r}">
46
- I'm a PIE button
52
+ <slot></slot>
47
53
  </button>`;
48
54
  }
49
55
  };
50
56
  l.styles = f(x);
51
- a([
52
- p(),
53
- u(Object.values(c), c.MEDIUM)
57
+ c([
58
+ u(),
59
+ p(Object.values(a), a.MEDIUM)
54
60
  ], l.prototype, "size", 2);
55
- a([
56
- p(),
57
- u(Object.values(d), d.SUBMIT)
61
+ c([
62
+ u(),
63
+ p(Object.values(d), d.SUBMIT)
58
64
  ], l.prototype, "type", 2);
59
- a([
60
- p(),
61
- u(Object.values(b), b.PRIMARY)
65
+ c([
66
+ u(),
67
+ p(Object.values(b), b.PRIMARY)
62
68
  ], l.prototype, "variant", 2);
63
- a([
64
- p()
69
+ c([
70
+ u({ type: Boolean, reflect: !0 })
65
71
  ], l.prototype, "disabled", 2);
66
- l = a([
67
- v("pie-button")
72
+ l = c([
73
+ k("pie-button")
68
74
  ], l);
69
75
  export {
70
- c as BUTTON_SIZE,
76
+ a as BUTTON_SIZE,
71
77
  d as BUTTON_TYPE,
72
78
  b as BUTTON_VARIANT,
73
79
  l as PieButton
@@ -0,0 +1 @@
1
+ export * from './src/index'
@@ -0,0 +1,9 @@
1
+ /**
2
+ * A decorator for specifying a list of valid values for a property.
3
+ * If this property's setter is called with an invalid value, an error is logged and the default value will be assigned instead.
4
+ * @param validValues - The array of valid values
5
+ * @param defaultValue - The value to fall back on
6
+ * @returns
7
+ */
8
+ export declare const validPropertyValues: (validValues: any[], defaultValue: any) => (target: any, propertyKey: string) => void;
9
+ //# sourceMappingURL=decorators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../src/decorators.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,gBAAiB,GAAG,EAAE,gBAAgB,GAAG,cAC5C,GAAG,eAAe,MAAM,KAAI,IAyBxD,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Button size variants
3
+ */
4
+ export declare enum BUTTON_SIZE {
5
+ XSMALL = "xsmall",
6
+ SMALL = "small",
7
+ MEDIUM = "medium",
8
+ LARGE = "large"
9
+ }
10
+ /**
11
+ * Button style variants
12
+ */
13
+ export declare enum BUTTON_TYPE {
14
+ SUBMIT = "submit",
15
+ BUTTON = "button",
16
+ RESET = "reset",
17
+ MENU = "menu"
18
+ }
19
+ /**
20
+ * Button style variants
21
+ */
22
+ export declare enum BUTTON_VARIANT {
23
+ PRIMARY = "primary",
24
+ SECONDARY = "secondary",
25
+ OUTLINE = "outline",
26
+ GHOST = "ghost"
27
+ }
28
+ //# sourceMappingURL=defs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defs.d.ts","sourceRoot":"","sources":["../../../src/defs.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,WAAW;IACnB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,KAAK,UAAU;CAClB;AAED;;GAEG;AACH,oBAAY,WAAW;IACnB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,IAAI,SAAS;CAChB;AAED;;GAEG;AACH,oBAAY,cAAc;IACtB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,KAAK,UAAU;CAClB"}
@@ -0,0 +1,17 @@
1
+ import { LitElement } from 'lit';
2
+ import { BUTTON_SIZE, BUTTON_TYPE, BUTTON_VARIANT } from './defs';
3
+ export { BUTTON_SIZE, BUTTON_TYPE, BUTTON_VARIANT };
4
+ export declare class PieButton extends LitElement {
5
+ size: BUTTON_SIZE;
6
+ type: BUTTON_TYPE;
7
+ variant: BUTTON_VARIANT;
8
+ disabled: boolean;
9
+ render(): import("lit-html").TemplateResult<1>;
10
+ static styles: import("lit").CSSResult;
11
+ }
12
+ declare global {
13
+ interface HTMLElementTagNameMap {
14
+ 'pie-button': PieButton;
15
+ }
16
+ }
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,KAAK,CAAC;AAMlD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAGlE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;AAWpD,qBACa,SAAU,SAAQ,UAAU;IAGrC,IAAI,EAAG,WAAW,CAAsB;IAIxC,IAAI,EAAG,WAAW,CAAsB;IAIxC,OAAO,EAAG,cAAc,CAA0B;IAGlD,QAAQ,EAAG,OAAO,CAAS;IAE3B,MAAM;IA2BN,MAAM,CAAC,MAAM,0BAAqB;CACrC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,YAAY,EAAE,SAAS,CAAC;KAC3B;CACJ"}
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-button",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "PIE design system button built using web components",
5
5
  "type": "module",
6
- "main": "dist/pie-button.js",
6
+ "main": "dist/index.js",
7
+ "types": "dist/types/index.d.ts",
7
8
  "scripts": {
8
9
  "build": "run -T vite build",
9
10
  "watch": "run -T vite build --watch",
10
11
  "dev": "run -T vite",
11
- "test": "echo \"Error: no test specified\" && exit 1"
12
+ "test": "echo \"Error: no test specified\" && exit 0"
12
13
  },
13
14
  "author": "JustEatTakeaway - Design System Web Team",
14
15
  "license": "Apache-2.0",
package/src/index.ts CHANGED
@@ -9,7 +9,16 @@ import { BUTTON_SIZE, BUTTON_TYPE, BUTTON_VARIANT } from './defs';
9
9
  // Valid values available to consumers
10
10
  export { BUTTON_SIZE, BUTTON_TYPE, BUTTON_VARIANT };
11
11
 
12
- @customElement('pie-button')
12
+ // TODO: Extract as a utility function in a shared package
13
+ function defineCustomElement(elementName:string) {
14
+ return (elementClass:typeof LitElement) => {
15
+ if(customElements.get(elementName)) return;
16
+
17
+ return customElement(elementName)(elementClass);
18
+ }
19
+ }
20
+
21
+ @defineCustomElement('pie-button')
13
22
  export class PieButton extends LitElement {
14
23
  @property()
15
24
  @validPropertyValues(Object.values(BUTTON_SIZE), BUTTON_SIZE.MEDIUM)
@@ -23,7 +32,7 @@ export class PieButton extends LitElement {
23
32
  @validPropertyValues(Object.values(BUTTON_VARIANT), BUTTON_VARIANT.PRIMARY)
24
33
  variant : BUTTON_VARIANT = BUTTON_VARIANT.PRIMARY;
25
34
 
26
- @property()
35
+ @property({type: Boolean, reflect: true})
27
36
  disabled : boolean = false;
28
37
 
29
38
  render () {
@@ -48,10 +57,16 @@ export class PieButton extends LitElement {
48
57
  type=${type}
49
58
  ?disabled=${disabled}
50
59
  @click="${raiseWCEvent}">
51
- I'm a PIE button
60
+ <slot></slot>
52
61
  </button>`;
53
62
  }
54
63
 
55
64
  // Renders a `CSSResult` generated from SCSS by Vite
56
65
  static styles = unsafeCSS(styles);
57
66
  }
67
+
68
+ declare global {
69
+ interface HTMLElementTagNameMap {
70
+ 'pie-button': PieButton;
71
+ }
72
+ }
package/vite.config.js CHANGED
@@ -1,14 +1,21 @@
1
+ /* eslint-disable import/no-extraneous-dependencies */
1
2
  import { defineConfig } from 'vite';
3
+ import dts from 'vite-plugin-dts';
2
4
 
3
5
  // https://vitejs.dev/config/
4
6
  export default defineConfig({
5
- build: {
6
- lib: {
7
- entry: 'src/index.ts',
8
- formats: ['es'],
7
+ build: {
8
+ lib: {
9
+ entry: 'src/index.ts',
10
+ fileName: 'index',
11
+ formats: ['es'],
12
+ },
13
+ rollupOptions: {
14
+ external: /^lit/,
15
+ },
9
16
  },
10
- rollupOptions: {
11
- external: /^lit/,
12
- },
13
- },
17
+ plugins: [dts({
18
+ insertTypesEntry: true,
19
+ outputDir: 'dist/types',
20
+ })],
14
21
  });