@justeattakeaway/pie-tag 0.9.5 → 0.9.6

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.
@@ -27,6 +27,14 @@
27
27
  "text": "['small', 'large']"
28
28
  },
29
29
  "default": "['small', 'large']"
30
+ },
31
+ {
32
+ "kind": "variable",
33
+ "name": "defaultProps",
34
+ "type": {
35
+ "text": "DefaultProps"
36
+ },
37
+ "default": "{\n variant: 'neutral',\n size: 'large',\n isStrong: false,\n isDimmed: false,\n}"
30
38
  }
31
39
  ],
32
40
  "exports": [
@@ -45,6 +53,14 @@
45
53
  "name": "sizes",
46
54
  "module": "src/defs.js"
47
55
  }
56
+ },
57
+ {
58
+ "kind": "js",
59
+ "name": "defaultProps",
60
+ "declaration": {
61
+ "name": "defaultProps",
62
+ "module": "src/defs.js"
63
+ }
48
64
  }
49
65
  ]
50
66
  },
@@ -74,7 +90,6 @@
74
90
  "text": "TagProps['variant']"
75
91
  },
76
92
  "privacy": "public",
77
- "default": "'neutral'",
78
93
  "attribute": "variant"
79
94
  },
80
95
  {
@@ -84,27 +99,18 @@
84
99
  "text": "TagProps['size']"
85
100
  },
86
101
  "privacy": "public",
87
- "default": "'large'",
88
102
  "attribute": "size"
89
103
  },
90
104
  {
91
105
  "kind": "field",
92
106
  "name": "isStrong",
93
- "type": {
94
- "text": "boolean"
95
- },
96
107
  "privacy": "public",
97
- "default": "false",
98
108
  "attribute": "isStrong"
99
109
  },
100
110
  {
101
111
  "kind": "field",
102
112
  "name": "isDimmed",
103
- "type": {
104
- "text": "boolean"
105
- },
106
113
  "privacy": "public",
107
- "default": "false",
108
114
  "attribute": "isDimmed"
109
115
  }
110
116
  ],
@@ -114,7 +120,6 @@
114
120
  "type": {
115
121
  "text": "TagProps['variant']"
116
122
  },
117
- "default": "'neutral'",
118
123
  "fieldName": "variant"
119
124
  },
120
125
  {
@@ -122,23 +127,14 @@
122
127
  "type": {
123
128
  "text": "TagProps['size']"
124
129
  },
125
- "default": "'large'",
126
130
  "fieldName": "size"
127
131
  },
128
132
  {
129
133
  "name": "isStrong",
130
- "type": {
131
- "text": "boolean"
132
- },
133
- "default": "false",
134
134
  "fieldName": "isStrong"
135
135
  },
136
136
  {
137
137
  "name": "isDimmed",
138
- "type": {
139
- "text": "boolean"
140
- },
141
- "default": "false",
142
138
  "fieldName": "isDimmed"
143
139
  }
144
140
  ],
package/dist/index.d.ts CHANGED
@@ -1,7 +1,12 @@
1
+ import { ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
1
2
  import type { CSSResult } from 'lit';
2
3
  import type { LitElement } from 'lit';
3
4
  import type { TemplateResult } from 'lit-html';
4
5
 
6
+ export declare type DefaultProps = ComponentDefaultPropsGeneric<TagProps, 'variant' | 'size' | 'isStrong' | 'isDimmed'>;
7
+
8
+ export declare const defaultProps: DefaultProps;
9
+
5
10
  /**
6
11
  * @tagname pie-tag
7
12
  * @slot icon - The icon slot
package/dist/index.js CHANGED
@@ -1,57 +1,63 @@
1
- import { unsafeCSS as p, LitElement as u, html as d, nothing as f } from "lit";
2
- import { property as n } from "lit/decorators.js";
3
- import { validPropertyValues as v, defineCustomElement as b } from "@justeattakeaway/pie-webc-core";
1
+ import { unsafeCSS as f, LitElement as u, html as v, nothing as b } from "lit";
2
+ import { property as i } from "lit/decorators.js";
3
+ import { validPropertyValues as p, defineCustomElement as m } from "@justeattakeaway/pie-webc-core";
4
4
  const h = `*,*:after,*:before{box-sizing:inherit}.c-tag{--tag-bg-color: var(--dt-color-container-strong);--tag-color: var(--dt-color-content-default);--tag-border-radius: var(--dt-radius-rounded-b);--tag-padding-block: 2px;--tag-padding-inline: var(--dt-spacing-b);--tag-font-family: var(--dt-font-body-s-family);--tag-font-weight: var(--dt-font-body-s-weight);--tag-font-size: calc(var(--dt-font-body-s-size) * 1px);--tag-line-height: calc(var(--dt-font-body-s-line-height) * 1px);--tag-transparent-bg-color: transparent;--icon-display-override: block;--icon-size-override: 16px;display:inline-flex;vertical-align:middle;align-items:center;justify-content:center;gap:var(--dt-spacing-a);padding:var(--tag-padding-block) var(--tag-padding-inline);border-radius:var(--tag-border-radius);background-color:var(--tag-bg-color);color:var(--tag-color);font-family:var(--tag-font-family);font-weight:var(--tag-font-weight);font-size:var(--tag-font-size);line-height:var(--tag-line-height)}.c-tag[size=small]{--tag-padding-block: 0;--tag-padding-inline: var(--dt-spacing-a);--tag-border-radius: var(--dt-radius-rounded-a);--tag-font-size: calc(var(--dt-font-caption-size) * 1px);--tag-line-height: calc(var(--dt-font-caption-line-height) * 1px)}.c-tag[variant=neutral][isStrong]{--tag-bg-color: var(--dt-color-container-inverse);--tag-color: var(--dt-color-content-inverse)}.c-tag[variant=blue]{--tag-bg-color: var(--dt-color-support-info-02);--tag-color: var(--dt-color-content-default)}.c-tag[variant=blue][isStrong]{--tag-bg-color: var(--dt-color-support-info);--tag-color: var(--dt-color-content-inverse)}.c-tag[variant=green]{--tag-bg-color: var(--dt-color-support-positive-02);--tag-color: var(--dt-color-content-default)}.c-tag[variant=green][isStrong]{--tag-bg-color: var(--dt-color-support-positive);--tag-color: var(--dt-color-content-inverse)}.c-tag[variant=yellow]{--tag-bg-color: var(--dt-color-support-warning-02);--tag-color: var(--dt-color-content-default)}.c-tag[variant=yellow][isStrong]{--tag-bg-color: var(--dt-color-support-warning);--tag-color: var(--dt-color-content-dark)}.c-tag[variant=red]{--tag-bg-color: var(--dt-color-support-error-02);--tag-color: var(--dt-color-content-default)}.c-tag[variant=red][isStrong]{--tag-bg-color: var(--dt-color-support-error);--tag-color: var(--dt-color-content-light)}.c-tag[variant=brand]{--tag-bg-color: var(--dt-color-support-brand-02);--tag-color: var(--dt-color-content-default)}.c-tag[variant=neutral-alternative]{--tag-bg-color: var(--dt-color-container-default);--tag-color: var(--dt-color-content-default)}.c-tag[variant=outline]{--tag-bg-color: var(--tag-transparent-bg-color);--tag-color: var(--dt-color-content-default);box-shadow:0 0 0 1px var(--dt-color-border-strong)}.c-tag[variant=ghost]{--tag-bg-color: var(--tag-transparent-bg-color);--tag-color: var(--dt-color-content-default)}.c-tag[isDimmed]{opacity:.5}::slotted(svg){display:block;height:var(--icon-size-override);width:var(--icon-size-override)}
5
- `, m = ["neutral-alternative", "neutral", "outline", "ghost", "blue", "green", "yellow", "red", "brand"], y = ["small", "large"];
6
- var z = Object.defineProperty, S = Object.getOwnPropertyDescriptor, i = (l, r, o, a) => {
7
- for (var t = a > 1 ? void 0 : a ? S(r, o) : r, g = l.length - 1, c; g >= 0; g--)
8
- (c = l[g]) && (t = (a ? c(r, o, t) : c(t)) || t);
9
- return a && t && z(r, o, t), t;
5
+ `, y = ["neutral-alternative", "neutral", "outline", "ghost", "blue", "green", "yellow", "red", "brand"], z = ["small", "large"], e = {
6
+ variant: "neutral",
7
+ size: "large",
8
+ isStrong: !1,
9
+ isDimmed: !1
10
10
  };
11
- const s = "pie-tag";
12
- class e extends u {
11
+ var S = Object.defineProperty, w = Object.getOwnPropertyDescriptor, l = (g, o, r, a) => {
12
+ for (var t = a > 1 ? void 0 : a ? w(o, r) : o, c = g.length - 1, s; c >= 0; c--)
13
+ (s = g[c]) && (t = (a ? s(o, r, t) : s(t)) || t);
14
+ return a && t && S(o, r, t), t;
15
+ };
16
+ const d = "pie-tag";
17
+ class n extends u {
13
18
  constructor() {
14
- super(...arguments), this.variant = "neutral", this.size = "large", this.isStrong = !1, this.isDimmed = !1;
19
+ super(...arguments), this.variant = e.variant, this.size = e.size, this.isStrong = e.isStrong, this.isDimmed = e.isDimmed;
15
20
  }
16
21
  render() {
17
22
  const {
18
- variant: r,
19
- size: o,
23
+ variant: o,
24
+ size: r,
20
25
  isStrong: a,
21
26
  isDimmed: t
22
27
  } = this;
23
- return d`
28
+ return v`
24
29
  <div
25
30
  class="c-tag"
26
- variant=${r || "neutral"}
27
- size=${o || "large"}
31
+ variant=${o}
32
+ size=${r}
28
33
  ?isStrong=${a}
29
34
  ?isDimmed=${t}
30
35
  data-test-id="pie-tag"
31
36
  >
32
- ${o === "large" ? d`<slot name="icon"></slot>` : f}
37
+ ${r === "large" ? v`<slot name="icon"></slot>` : b}
33
38
  <slot></slot>
34
39
  </div>`;
35
40
  }
36
41
  }
37
- e.styles = p(h);
38
- i([
39
- n({ type: String }),
40
- v(s, m, "neutral")
41
- ], e.prototype, "variant", 2);
42
- i([
43
- n({ type: String }),
44
- v(s, y, "large")
45
- ], e.prototype, "size", 2);
46
- i([
47
- n({ type: Boolean })
48
- ], e.prototype, "isStrong", 2);
49
- i([
50
- n({ type: Boolean })
51
- ], e.prototype, "isDimmed", 2);
52
- b(s, e);
42
+ n.styles = f(h);
43
+ l([
44
+ i({ type: String }),
45
+ p(d, y, e.variant)
46
+ ], n.prototype, "variant", 2);
47
+ l([
48
+ i({ type: String }),
49
+ p(d, z, e.size)
50
+ ], n.prototype, "size", 2);
51
+ l([
52
+ i({ type: Boolean })
53
+ ], n.prototype, "isStrong", 2);
54
+ l([
55
+ i({ type: Boolean })
56
+ ], n.prototype, "isDimmed", 2);
57
+ m(d, n);
53
58
  export {
54
- e as PieTag,
55
- y as sizes,
56
- m as variants
59
+ n as PieTag,
60
+ e as defaultProps,
61
+ z as sizes,
62
+ y as variants
57
63
  };
package/dist/react.d.ts CHANGED
@@ -1,8 +1,13 @@
1
+ import { ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
1
2
  import type { CSSResult } from 'lit';
2
3
  import type { LitElement } from 'lit';
3
4
  import * as React_2 from 'react';
4
5
  import type { TemplateResult } from 'lit-html';
5
6
 
7
+ export declare type DefaultProps = ComponentDefaultPropsGeneric<TagProps, 'variant' | 'size' | 'isStrong' | 'isDimmed'>;
8
+
9
+ export declare const defaultProps: DefaultProps;
10
+
6
11
  export declare const PieTag: React_2.ForwardRefExoticComponent<TagProps & React_2.RefAttributes<PieTag_2> & ReactBaseType>;
7
12
 
8
13
  /**
package/dist/react.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as e from "react";
2
2
  import { createComponent as t } from "@lit/react";
3
3
  import { PieTag as a } from "./index.js";
4
- import { sizes as P, variants as T } from "./index.js";
4
+ import { defaultProps as P, sizes as f, variants as T } from "./index.js";
5
5
  import "lit";
6
6
  import "lit/decorators.js";
7
7
  import "@justeattakeaway/pie-webc-core";
@@ -14,6 +14,7 @@ const o = t({
14
14
  }), g = o;
15
15
  export {
16
16
  g as PieTag,
17
- P as sizes,
17
+ P as defaultProps,
18
+ f as sizes,
18
19
  T as variants
19
20
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-tag",
3
3
  "description": "PIE Design System Tag built using Web Components",
4
- "version": "0.9.5",
4
+ "version": "0.9.6",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -37,12 +37,12 @@
37
37
  "devDependencies": {
38
38
  "@custom-elements-manifest/analyzer": "0.9.0",
39
39
  "@justeattakeaway/pie-components-config": "0.16.0",
40
- "@justeattakeaway/pie-icons-webc": "0.23.1",
40
+ "@justeattakeaway/pie-icons-webc": "0.24.0",
41
41
  "@justeattakeaway/pie-wrapper-react": "0.14.0",
42
42
  "cem-plugin-module-file-extensions": "0.0.5"
43
43
  },
44
44
  "dependencies": {
45
- "@justeattakeaway/pie-webc-core": "0.22.0"
45
+ "@justeattakeaway/pie-webc-core": "0.23.0"
46
46
  },
47
47
  "volta": {
48
48
  "extends": "../../../package.json"
package/src/defs.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { type ComponentDefaultPropsGeneric } from '@justeattakeaway/pie-webc-core';
2
+
1
3
  export const variants = ['neutral-alternative', 'neutral', 'outline', 'ghost', 'blue', 'green', 'yellow', 'red', 'brand'] as const;
2
4
  export const sizes = ['small', 'large'] as const;
3
5
 
@@ -22,3 +24,12 @@ export interface TagProps {
22
24
  */
23
25
  size?: typeof sizes[number];
24
26
  }
27
+
28
+ export type DefaultProps = ComponentDefaultPropsGeneric<TagProps, 'variant' | 'size' | 'isStrong' | 'isDimmed'>;
29
+
30
+ export const defaultProps: DefaultProps = {
31
+ variant: 'neutral',
32
+ size: 'large',
33
+ isStrong: false,
34
+ isDimmed: false,
35
+ };
package/src/index.ts CHANGED
@@ -4,7 +4,9 @@ import {
4
4
  import { property } from 'lit/decorators.js';
5
5
  import { validPropertyValues, defineCustomElement } from '@justeattakeaway/pie-webc-core';
6
6
  import styles from './tag.scss?inline';
7
- import { TagProps, variants, sizes } from './defs';
7
+ import {
8
+ TagProps, variants, sizes, defaultProps,
9
+ } from './defs';
8
10
 
9
11
  // Valid values available to consumers
10
12
  export * from './defs';
@@ -18,18 +20,18 @@ const componentSelector = 'pie-tag';
18
20
  */
19
21
  export class PieTag extends LitElement implements TagProps {
20
22
  @property({ type: String })
21
- @validPropertyValues(componentSelector, variants, 'neutral')
22
- public variant: TagProps['variant'] = 'neutral';
23
+ @validPropertyValues(componentSelector, variants, defaultProps.variant)
24
+ public variant: TagProps['variant'] = defaultProps.variant;
23
25
 
24
26
  @property({ type: String })
25
- @validPropertyValues(componentSelector, sizes, 'large')
26
- public size : TagProps['size'] = 'large';
27
+ @validPropertyValues(componentSelector, sizes, defaultProps.size)
28
+ public size : TagProps['size'] = defaultProps.size;
27
29
 
28
30
  @property({ type: Boolean })
29
- public isStrong = false;
31
+ public isStrong = defaultProps.isStrong;
30
32
 
31
33
  @property({ type: Boolean })
32
- public isDimmed = false;
34
+ public isDimmed = defaultProps.isDimmed;
33
35
 
34
36
  render () {
35
37
  const {
@@ -41,8 +43,8 @@ export class PieTag extends LitElement implements TagProps {
41
43
  return html`
42
44
  <div
43
45
  class="c-tag"
44
- variant=${variant || 'neutral'}
45
- size=${size || 'large'}
46
+ variant=${variant}
47
+ size=${size}
46
48
  ?isStrong=${isStrong}
47
49
  ?isDimmed=${isDimmed}
48
50
  data-test-id="pie-tag"