@justeattakeaway/pie-link 0.13.0 → 0.14.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
@@ -18,20 +18,20 @@ export declare interface LinkProps {
18
18
  /**
19
19
  * What HTML element the link should be such as a or button.
20
20
  */
21
- tag: typeof tags[number];
21
+ tag?: typeof tags[number];
22
22
  /**
23
23
  * What style variant the link should be such as default, high-visibility or inverse.
24
24
  */
25
- variant: typeof variants[number];
25
+ variant?: typeof variants[number];
26
26
  /**
27
27
  * What size the link should be.
28
28
  */
29
- size: typeof sizes[number];
29
+ size?: typeof sizes[number];
30
30
  /**
31
31
  * Defines what underline behavior the link should have, such as default or reversed.
32
32
  * The `reversed` type can only be used if the link is a block element (isStandalone = true)
33
33
  */
34
- underline: typeof underlineTypes[number];
34
+ underline?: typeof underlineTypes[number];
35
35
  /**
36
36
  * The URL that the hyperlink should point to
37
37
  */
@@ -47,15 +47,15 @@ export declare interface LinkProps {
47
47
  /**
48
48
  * When true, the link text will be bold.
49
49
  */
50
- isBold: boolean;
50
+ isBold?: boolean;
51
51
  /**
52
52
  * When true, the link will be treated as a block element
53
53
  */
54
- isStandalone: boolean;
54
+ isStandalone?: boolean;
55
55
  /**
56
56
  * When true, the link will apply the styles for the visited state',
57
57
  */
58
- hasVisited: boolean;
58
+ hasVisited?: boolean;
59
59
  /**
60
60
  * The placement of the icon slot, if provided, such as leading or trailing.
61
61
  * Will only apply if the link is a block element (isStandalone = true)
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import { unsafeCSS as u, LitElement as f, html as c, nothing as o } from "lit";
1
+ import { unsafeCSS as v, LitElement as f, html as d, nothing as s } from "lit";
2
2
  import { property as i } from "lit/decorators.js";
3
3
  import { validPropertyValues as a, defineCustomElement as k } from "@justeattakeaway/pie-webc-core";
4
4
  const g = `.c-link{--link-font-family: var(--dt-font-interactive-m-family);--link-font-size: calc(var(--dt-font-size-16) * 1px);--link-line-height: calc(var(--dt-font-size-16-line-height) * 1px);--link-font-weight: var(--dt-font-weight-regular);--link-text-color: var(--dt-color-content-link);--link-text-decoration: var(--dt-font-style-underline);--link-icon-size: 16px;--link-icon-offset-top: var(--dt-spacing-a);display:inline-block;font-family:var(--link-font-family);font-size:var(--link-font-size);line-height:var(--link-line-height);font-weight:var(--link-font-weight);color:var(--link-text-color);text-decoration:var(--link-text-decoration);cursor:pointer}.c-link:hover,.c-link:active{--link-text-decoration: none}.c-link[tag=button]{outline:none;border:none;user-select:none;background:transparent;padding:0}.c-link[variant=high-visibility]{--link-text-color: var(--dt-color-content-link-distinct)}.c-link[variant=inverse]{--link-text-color: var(--dt-color-content-link-inverse)}.c-link[size=small]{--link-font-size: calc(var(--dt-font-size-14) * 1px);--link-line-height: calc(var(--dt-font-size-14-line-height) * 1px);--link-icon-offset-top: 2px}.c-link[underline=reversed][isStandalone]{--link-text-decoration: none}.c-link[underline=reversed][isStandalone]:hover,.c-link[underline=reversed][isStandalone]:active{--link-text-decoration: var(--dt-font-style-underline)}.c-link[isBold]{--link-font-weight: var(--dt-font-weight-bold)}.c-link[isStandalone]{display:block;width:fit-content}.c-link[hasVisited]:visited{color:var(--dt-color-content-link-visited)}.c-link[hasVisited]:visited[variant=inverse]{color:var(--dt-color-content-link-visited-inverse)}.c-link:focus-visible{outline:none;border-radius:2px;box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer)}.c-link-content{display:flex;gap:var(--dt-spacing-a)}::slotted(.c-pieIcon),::slotted(svg){display:inline-flex;margin-block-start:var(--link-icon-offset-top);height:var(--link-icon-size);width:var(--link-icon-size)}
5
5
  `, y = ["default", "high-visibility", "inverse"], m = ["small", "medium"], b = ["leading", "trailing"], x = ["a", "button"], $ = ["submit", "button", "reset", "menu"], S = ["default", "reversed"];
6
- var z = Object.defineProperty, B = Object.getOwnPropertyDescriptor, n = (p, e, s, d) => {
7
- for (var r = d > 1 ? void 0 : d ? B(e, s) : e, h = p.length - 1, v; h >= 0; h--)
8
- (v = p[h]) && (r = (d ? v(e, s, r) : v(r)) || r);
9
- return d && r && z(e, s, r), r;
6
+ var z = Object.defineProperty, B = Object.getOwnPropertyDescriptor, n = (p, e, r, c) => {
7
+ for (var o = c > 1 ? void 0 : c ? B(e, r) : e, h = p.length - 1, u; h >= 0; h--)
8
+ (u = p[h]) && (o = (c ? u(e, r, o) : u(o)) || o);
9
+ return c && o && z(e, r, o), o;
10
10
  };
11
11
  const l = "pie-link";
12
12
  class t extends f {
@@ -19,12 +19,12 @@ class t extends f {
19
19
  * @private
20
20
  */
21
21
  renderContent() {
22
- const { iconPlacement: e, isStandalone: s } = this;
23
- return c`
22
+ const { iconPlacement: e, isStandalone: r } = this;
23
+ return d`
24
24
  <span class="c-link-content">
25
- ${s && e === "leading" ? c`<slot name="icon"></slot>` : o}
25
+ ${r && e === "leading" ? d`<slot name="icon"></slot>` : s}
26
26
  <slot></slot>
27
- ${s && e === "trailing" ? c`<slot name="icon"></slot>` : o}
27
+ ${r && e === "trailing" ? d`<slot name="icon"></slot>` : s}
28
28
  </span>`;
29
29
  }
30
30
  /**
@@ -34,19 +34,19 @@ class t extends f {
34
34
  */
35
35
  renderButton() {
36
36
  var e;
37
- return c`
37
+ return d`
38
38
  <button
39
39
  data-test-id="pie-link"
40
40
  class="c-link"
41
- tag=${this.tag}
42
- variant=${this.variant}
43
- size=${this.size}
44
- underline=${this.underline}
41
+ tag=${this.tag || "button"}
42
+ variant=${this.variant || "default"}
43
+ size=${this.size || "medium"}
44
+ underline=${this.underline || "default"}
45
45
  ?isBold=${this.isBold}
46
46
  ?isStandalone=${this.isStandalone}
47
47
  ?hasVisited=${this.hasVisited}
48
- type=${this.type || o}
49
- aria-label=${((e = this.aria) == null ? void 0 : e.label) || o}>
48
+ type=${this.type || "submit"}
49
+ aria-label=${((e = this.aria) == null ? void 0 : e.label) || s}>
50
50
  ${this.renderContent()}
51
51
  </button>`;
52
52
  }
@@ -57,21 +57,21 @@ class t extends f {
57
57
  */
58
58
  renderAnchor() {
59
59
  var e;
60
- return c`
60
+ return d`
61
61
  <a
62
62
  data-test-id="pie-link"
63
63
  class="c-link"
64
- tag=${this.tag}
65
- variant=${this.variant}
66
- size=${this.size}
67
- underline=${this.underline}
64
+ tag=${this.tag || "a"}
65
+ variant=${this.variant || "default"}
66
+ size=${this.size || "medium"}
67
+ underline=${this.underline || "default"}
68
68
  ?isBold=${this.isBold}
69
69
  ?isStandalone=${this.isStandalone}
70
70
  ?hasVisited=${this.hasVisited}
71
- href=${this.href || o}
72
- target=${this.target || o}
73
- rel=${this.rel || o}
74
- aria-label=${((e = this.aria) == null ? void 0 : e.label) || o}>
71
+ href=${this.href || ""}
72
+ target=${this.target || s}
73
+ rel=${this.rel || s}
74
+ aria-label=${((e = this.aria) == null ? void 0 : e.label) || s}>
75
75
  ${this.renderContent()}
76
76
  </a>`;
77
77
  }
@@ -79,7 +79,7 @@ class t extends f {
79
79
  return this.tag === "button" ? this.renderButton() : this.renderAnchor();
80
80
  }
81
81
  }
82
- t.styles = u(g);
82
+ t.styles = v(g);
83
83
  n([
84
84
  i(),
85
85
  a(l, x, "a")
package/dist/react.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { CSSResult } from 'lit';
2
2
  import type { LitElement } from 'lit';
3
- import type { ReactWebComponent } from '@lit/react';
3
+ import * as React_2 from 'react';
4
4
  import type { TemplateResult } from 'lit';
5
5
 
6
6
  export declare type AriaProps = {
@@ -19,20 +19,20 @@ export declare interface LinkProps {
19
19
  /**
20
20
  * What HTML element the link should be such as a or button.
21
21
  */
22
- tag: typeof tags[number];
22
+ tag?: typeof tags[number];
23
23
  /**
24
24
  * What style variant the link should be such as default, high-visibility or inverse.
25
25
  */
26
- variant: typeof variants[number];
26
+ variant?: typeof variants[number];
27
27
  /**
28
28
  * What size the link should be.
29
29
  */
30
- size: typeof sizes[number];
30
+ size?: typeof sizes[number];
31
31
  /**
32
32
  * Defines what underline behavior the link should have, such as default or reversed.
33
33
  * The `reversed` type can only be used if the link is a block element (isStandalone = true)
34
34
  */
35
- underline: typeof underlineTypes[number];
35
+ underline?: typeof underlineTypes[number];
36
36
  /**
37
37
  * The URL that the hyperlink should point to
38
38
  */
@@ -48,15 +48,15 @@ export declare interface LinkProps {
48
48
  /**
49
49
  * When true, the link text will be bold.
50
50
  */
51
- isBold: boolean;
51
+ isBold?: boolean;
52
52
  /**
53
53
  * When true, the link will be treated as a block element
54
54
  */
55
- isStandalone: boolean;
55
+ isStandalone?: boolean;
56
56
  /**
57
57
  * When true, the link will apply the styles for the visited state',
58
58
  */
59
- hasVisited: boolean;
59
+ hasVisited?: boolean;
60
60
  /**
61
61
  * The placement of the icon slot, if provided, such as leading or trailing.
62
62
  * Will only apply if the link is a block element (isStandalone = true)
@@ -68,7 +68,7 @@ export declare interface LinkProps {
68
68
  type?: typeof buttonTypes[number];
69
69
  }
70
70
 
71
- export declare const PieLink: ReactWebComponent<PieLink_2, {}>;
71
+ export declare const PieLink: React_2.ForwardRefExoticComponent<LinkProps & React_2.RefAttributes<PieLink_2> & React_2.AnchorHTMLAttributes<HTMLAnchorElement> & React_2.ButtonHTMLAttributes<HTMLButtonElement>>;
72
72
 
73
73
  /**
74
74
  * @tagname pie-link
package/dist/react.js CHANGED
@@ -1,23 +1,23 @@
1
1
  import * as e from "react";
2
2
  import { createComponent as i } from "@lit/react";
3
3
  import { PieLink as t } from "./index.js";
4
- import { buttonTypes as l, iconPlacements as k, sizes as P, tags as f, underlineTypes as L, variants as y } from "./index.js";
4
+ import { buttonTypes as l, iconPlacements as P, sizes as L, tags as f, underlineTypes as y, variants as d } from "./index.js";
5
5
  import "lit";
6
6
  import "lit/decorators.js";
7
7
  import "@justeattakeaway/pie-webc-core";
8
- const s = i({
8
+ const n = i({
9
9
  displayName: "PieLink",
10
10
  elementClass: t,
11
11
  react: e,
12
12
  tagName: "pie-link",
13
13
  events: {}
14
- });
14
+ }), p = n;
15
15
  export {
16
- s as PieLink,
16
+ p as PieLink,
17
17
  l as buttonTypes,
18
- k as iconPlacements,
19
- P as sizes,
18
+ P as iconPlacements,
19
+ L as sizes,
20
20
  f as tags,
21
- L as underlineTypes,
22
- y as variants
21
+ y as underlineTypes,
22
+ d as variants
23
23
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-link",
3
3
  "description": "PIE Design System Link built using Web Components",
4
- "version": "0.13.0",
4
+ "version": "0.14.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -32,12 +32,12 @@
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
  "dependencies": {
40
- "@justeattakeaway/pie-webc-core": "0.16.0"
40
+ "@justeattakeaway/pie-webc-core": "0.17.0"
41
41
  },
42
42
  "volta": {
43
43
  "extends": "../../../package.json"
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+
3
+ export type ReactBaseType = React.AnchorHTMLAttributes<HTMLAnchorElement> & React.ButtonHTMLAttributes<HTMLButtonElement>
package/src/defs.ts CHANGED
@@ -17,20 +17,20 @@ export interface LinkProps {
17
17
  /**
18
18
  * What HTML element the link should be such as a or button.
19
19
  */
20
- tag: typeof tags[number];
20
+ tag?: typeof tags[number];
21
21
  /**
22
22
  * What style variant the link should be such as default, high-visibility or inverse.
23
23
  */
24
- variant: typeof variants[number];
24
+ variant?: typeof variants[number];
25
25
  /**
26
26
  * What size the link should be.
27
27
  */
28
- size: typeof sizes[number];
28
+ size?: typeof sizes[number];
29
29
  /**
30
30
  * Defines what underline behavior the link should have, such as default or reversed.
31
31
  * The `reversed` type can only be used if the link is a block element (isStandalone = true)
32
32
  */
33
- underline: typeof underlineTypes[number];
33
+ underline?: typeof underlineTypes[number];
34
34
  /**
35
35
  * The URL that the hyperlink should point to
36
36
  */
@@ -46,15 +46,15 @@ export interface LinkProps {
46
46
  /**
47
47
  * When true, the link text will be bold.
48
48
  */
49
- isBold: boolean;
49
+ isBold?: boolean;
50
50
  /**
51
51
  * When true, the link will be treated as a block element
52
52
  */
53
- isStandalone: boolean;
53
+ isStandalone?: boolean;
54
54
  /**
55
55
  * When true, the link will apply the styles for the visited state',
56
56
  */
57
- hasVisited: boolean;
57
+ hasVisited?: boolean;
58
58
  /**
59
59
  * The placement of the icon slot, if provided, such as leading or trailing.
60
60
  * Will only apply if the link is a block element (isStandalone = true)
package/src/index.ts CHANGED
@@ -97,14 +97,14 @@ export class PieLink extends LitElement implements LinkProps {
97
97
  <button
98
98
  data-test-id="pie-link"
99
99
  class="c-link"
100
- tag=${this.tag}
101
- variant=${this.variant}
102
- size=${this.size}
103
- underline=${this.underline}
100
+ tag=${this.tag || 'button'}
101
+ variant=${this.variant || 'default'}
102
+ size=${this.size || 'medium'}
103
+ underline=${this.underline || 'default'}
104
104
  ?isBold=${this.isBold}
105
105
  ?isStandalone=${this.isStandalone}
106
106
  ?hasVisited=${this.hasVisited}
107
- type=${this.type || nothing}
107
+ type=${this.type || 'submit'}
108
108
  aria-label=${this.aria?.label || nothing}>
109
109
  ${this.renderContent()}
110
110
  </button>`;
@@ -120,14 +120,14 @@ export class PieLink extends LitElement implements LinkProps {
120
120
  <a
121
121
  data-test-id="pie-link"
122
122
  class="c-link"
123
- tag=${this.tag}
124
- variant=${this.variant}
125
- size=${this.size}
126
- underline=${this.underline}
123
+ tag=${this.tag || 'a'}
124
+ variant=${this.variant || 'default'}
125
+ size=${this.size || 'medium'}
126
+ underline=${this.underline || 'default'}
127
127
  ?isBold=${this.isBold}
128
128
  ?isStandalone=${this.isStandalone}
129
129
  ?hasVisited=${this.hasVisited}
130
- href=${this.href || nothing}
130
+ href=${this.href || ''}
131
131
  target=${this.target || nothing}
132
132
  rel=${this.rel || nothing}
133
133
  aria-label=${this.aria?.label || nothing}>
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 { PieLink as PieLinkReact } from './index';
3
+ import { PieLink as PieLinkLit } from './index';
4
+ import { LinkProps } from './defs';
5
5
 
6
6
  export * from './defs';
7
7
 
8
- export const PieLink = createComponent({
8
+ const PieLinkReact = createComponent({
9
9
  displayName: 'PieLink',
10
- elementClass: PieLinkReact,
10
+ elementClass: PieLinkLit,
11
11
  react: React,
12
12
  tagName: 'pie-link',
13
13
  events: {},
14
14
  });
15
+
16
+ type ReactBaseType = React.AnchorHTMLAttributes<HTMLAnchorElement> & React.ButtonHTMLAttributes<HTMLButtonElement>
17
+
18
+
19
+
20
+ export const PieLink = PieLinkReact as React.ForwardRefExoticComponent<React.PropsWithoutRef<LinkProps> & React.RefAttributes<PieLinkLit> & ReactBaseType>;