@justeattakeaway/pie-link 0.11.0 → 0.11.1
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/README.md +20 -6
- package/dist/react.js +42 -41
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,14 +41,28 @@ For full information on using PIE components as part of an application, check ou
|
|
|
41
41
|
|
|
42
42
|
### Importing the component
|
|
43
43
|
|
|
44
|
+
#### JavaScript
|
|
44
45
|
```js
|
|
45
|
-
//
|
|
46
|
+
// Default – for Native JS Applications, Vue, Angular, Svelte, etc.
|
|
46
47
|
import { PieLink } from '@justeattakeaway/pie-link';
|
|
47
48
|
|
|
48
|
-
//
|
|
49
|
+
// If you don't need to reference the imported object, you can simply
|
|
50
|
+
// import the module which registers the component as a custom element.
|
|
51
|
+
import '@justeattakeaway/pie-link';
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### React
|
|
55
|
+
```js
|
|
56
|
+
// React
|
|
57
|
+
// For React, you will need to import our React-specific component build
|
|
58
|
+
// which wraps the web component using @lit-labs/react
|
|
49
59
|
import { PieLink } from '@justeattakeaway/pie-link/dist/react';
|
|
50
60
|
```
|
|
51
61
|
|
|
62
|
+
> [!NOTE]
|
|
63
|
+
> When using the React version of the component, please make sure to also
|
|
64
|
+
> include React as a [peer dependency](#peer-dependencies) in your project.
|
|
65
|
+
|
|
52
66
|
|
|
53
67
|
## Peer Dependencies
|
|
54
68
|
|
|
@@ -57,12 +71,12 @@ import { PieLink } from '@justeattakeaway/pie-link/dist/react';
|
|
|
57
71
|
|
|
58
72
|
## Props
|
|
59
73
|
|
|
60
|
-
| Property | Type
|
|
61
|
-
| ------------- |
|
|
74
|
+
| Property | Type | Default | Description |
|
|
75
|
+
| ------------- | --------- | ----------- | ---------------------------------------------------------------------------------------------------- |
|
|
62
76
|
| tag | `String` | `a` | The rendered HTML element of the link, one of `tags` – `a`, `button` |
|
|
63
77
|
| variant | `String` | `default` | Variant of the link, one of `variants` – `default`, `high-visibility`, `inverse` |
|
|
64
78
|
| size | `String` | `medium` | Size of the link, one of `sizes` – `medium`, `small` |
|
|
65
|
-
| underline
|
|
79
|
+
| underline | `String` | `default` | The underline behaviour of the link, one of `underlineTypes` – `default`, `reversed`. The `reverse` type can only be used if `isStandalone` is set to `true` |
|
|
66
80
|
| href | `String` | `undefined` | Native html `href` attribute |
|
|
67
81
|
| rel | `String` | `undefined` | Native html `rel` attribute |
|
|
68
82
|
| target | `String` | `undefined` | Native html `target` attribute |
|
|
@@ -71,7 +85,7 @@ import { PieLink } from '@justeattakeaway/pie-link/dist/react';
|
|
|
71
85
|
| isStandalone | `Boolean` | `false` | If `true`, sets the link as a block element |
|
|
72
86
|
| hasVisited | `Boolean` | `false` | If `true`, the link will apply the styles for the visited state |
|
|
73
87
|
| iconPlacement | `String` | `leading` | Icon placements of the icon slot, if provided, one of `iconPlacements` - `leading`, `trailing`. Can only be used if `isStandalone` is `true` |
|
|
74
|
-
| aria
|
|
88
|
+
| aria | `object` | `undefined` | The ARIA labels used for the link. |
|
|
75
89
|
|
|
76
90
|
In your markup or JSX, you can then use these to set the properties for the `pie-link` component:
|
|
77
91
|
|
package/dist/react.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { PieLink as
|
|
3
|
-
import { buttonTypes as j, iconPlacements as
|
|
1
|
+
import * as k from "react";
|
|
2
|
+
import { PieLink as w } from "./index.js";
|
|
3
|
+
import { buttonTypes as j, iconPlacements as A, sizes as D, tags as G, underlineTypes as H, variants as O } from "./index.js";
|
|
4
4
|
import "lit";
|
|
5
5
|
import "lit/decorators.js";
|
|
6
6
|
/**
|
|
@@ -8,68 +8,69 @@ import "lit/decorators.js";
|
|
|
8
8
|
* Copyright 2018 Google LLC
|
|
9
9
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
10
10
|
*/
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
})(
|
|
11
|
+
const L = /* @__PURE__ */ new Set(["children", "localName", "ref", "style", "className"]), g = /* @__PURE__ */ new WeakMap(), E = (t, i, p, d, m) => {
|
|
12
|
+
const o = m == null ? void 0 : m[i];
|
|
13
|
+
o === void 0 || p === d ? p == null && i in HTMLElement.prototype ? t.removeAttribute(i) : t[i] = p : ((r, n, h) => {
|
|
14
|
+
let a = g.get(r);
|
|
15
|
+
a === void 0 && g.set(r, a = /* @__PURE__ */ new Map());
|
|
16
|
+
let l = a.get(n);
|
|
17
|
+
h !== void 0 ? l === void 0 ? (a.set(n, l = { handleEvent: h }), r.addEventListener(n, l)) : l.handleEvent = h : l !== void 0 && (a.delete(n), r.removeEventListener(n, l));
|
|
18
|
+
})(t, o, p);
|
|
19
|
+
}, b = (t, i) => {
|
|
20
|
+
typeof t == "function" ? t(i) : t.current = i;
|
|
19
21
|
};
|
|
20
|
-
function
|
|
21
|
-
let
|
|
22
|
-
if (
|
|
23
|
-
const
|
|
24
|
-
({ tagName:
|
|
22
|
+
function P(t = window.React, i, p, d, m) {
|
|
23
|
+
let o, r, n;
|
|
24
|
+
if (i === void 0) {
|
|
25
|
+
const c = t;
|
|
26
|
+
({ tagName: r, elementClass: n, events: d, displayName: m } = c), o = c.react;
|
|
25
27
|
} else
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
class f extends
|
|
28
|
+
o = t, n = p, r = i;
|
|
29
|
+
const h = o.Component, a = o.createElement, l = new Set(Object.keys(d ?? {}));
|
|
30
|
+
class f extends h {
|
|
29
31
|
constructor() {
|
|
30
32
|
super(...arguments), this.o = null;
|
|
31
33
|
}
|
|
32
34
|
t(e) {
|
|
33
35
|
if (this.o !== null)
|
|
34
|
-
for (const
|
|
35
|
-
|
|
36
|
+
for (const u in this.i)
|
|
37
|
+
E(this.o, u, this.props[u], e ? e[u] : void 0, d);
|
|
36
38
|
}
|
|
37
39
|
componentDidMount() {
|
|
38
|
-
|
|
40
|
+
var e;
|
|
41
|
+
this.t(), (e = this.o) === null || e === void 0 || e.removeAttribute("defer-hydration");
|
|
39
42
|
}
|
|
40
43
|
componentDidUpdate(e) {
|
|
41
44
|
this.t(e);
|
|
42
45
|
}
|
|
43
46
|
render() {
|
|
44
|
-
const { _$Gl: e, ...
|
|
45
|
-
this.h !== e && (this.u = (
|
|
46
|
-
e !== null && (
|
|
47
|
-
typeof c == "function" ? c(k) : c.current = k;
|
|
48
|
-
})(e, i), this.o = i, this.h = e;
|
|
47
|
+
const { _$Gl: e, ...u } = this.props;
|
|
48
|
+
this.h !== e && (this.u = (s) => {
|
|
49
|
+
e !== null && b(e, s), this.o = s, this.h = e;
|
|
49
50
|
}), this.i = {};
|
|
50
|
-
const
|
|
51
|
-
for (const [
|
|
52
|
-
|
|
53
|
-
return
|
|
51
|
+
const v = { ref: this.u };
|
|
52
|
+
for (const [s, y] of Object.entries(u))
|
|
53
|
+
L.has(s) ? v[s === "className" ? "class" : s] = y : l.has(s) || s in n.prototype ? this.i[s] = y : v[s] = y;
|
|
54
|
+
return v.suppressHydrationWarning = !0, a(r, v);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
|
-
f.displayName =
|
|
57
|
-
const N =
|
|
57
|
+
f.displayName = m ?? n.name;
|
|
58
|
+
const N = o.forwardRef((c, e) => a(f, { ...c, _$Gl: e }, c == null ? void 0 : c.children));
|
|
58
59
|
return N.displayName = f.displayName, N;
|
|
59
60
|
}
|
|
60
|
-
const R =
|
|
61
|
+
const R = P({
|
|
61
62
|
displayName: "PieLink",
|
|
62
|
-
elementClass:
|
|
63
|
-
react:
|
|
63
|
+
elementClass: w,
|
|
64
|
+
react: k,
|
|
64
65
|
tagName: "pie-link",
|
|
65
66
|
events: {}
|
|
66
67
|
});
|
|
67
68
|
export {
|
|
68
69
|
R as PieLink,
|
|
69
70
|
j as buttonTypes,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
A as iconPlacements,
|
|
72
|
+
D as sizes,
|
|
73
|
+
G as tags,
|
|
74
|
+
H as underlineTypes,
|
|
75
|
+
O as variants
|
|
75
76
|
};
|