@justeattakeaway/pie-notification 0.0.0 → 0.1.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.
Files changed (3) hide show
  1. package/README.md +20 -62
  2. package/dist/react.js +33 -32
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -14,9 +14,8 @@
14
14
  2. [Installation](#installation)
15
15
  3. [Importing the component](#importing-the-component)
16
16
  4. [Peer Dependencies](#peer-dependencies)
17
- 5. [Local Development](#local-development)
18
- 6. [Props](#props)
19
- 7. [Testing](#testing)
17
+ 5. [Props](#props)
18
+ 6. [Contributing](#contributing)
20
19
 
21
20
  ## pie-notification
22
21
 
@@ -42,45 +41,34 @@ For full information on using PIE components as part of an application, check ou
42
41
 
43
42
  ### Importing the component
44
43
 
44
+ #### JavaScript
45
45
  ```js
46
- // default
46
+ // Default – for Native JS Applications, Vue, Angular, Svelte, etc.
47
47
  import { PieNotification } from '@justeattakeaway/pie-notification';
48
48
 
49
- // react
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-notification';
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
50
59
  import { PieNotification } from '@justeattakeaway/pie-notification/dist/react';
51
60
  ```
52
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
+
53
66
 
54
67
  ## Peer Dependencies
55
68
 
56
69
  > [!IMPORTANT]
57
70
  > When using `pie-notification`, you will also need to include a couple of dependencies to ensure the component renders as expected. See [the PIE Wiki](https://github.com/justeattakeaway/pie/wiki/Getting-started-with-PIE-Web-Components#expected-dependencies) for more information and how to include these in your application.
58
71
 
59
-
60
- ## Local development
61
-
62
- Install the dependencies. Note that this, and the following commands below, should be run from the **root of the monorepo**:
63
-
64
- ```bash
65
- yarn
66
- ```
67
-
68
- To build the `pie-notification` package, run the following command:
69
-
70
- ```bash
71
- yarn build --filter=pie-notification
72
- ```
73
-
74
- If you'd like to develop using the component storybook, then you should build the component in `watch` mode, and run storybook in a separate terminal tab:
75
-
76
- ```bash
77
- yarn watch --filter=pie-notification
78
-
79
- # in a separate terminal tab, run
80
- yarn dev --filter=pie-storybook
81
- ```
82
-
83
-
84
72
  ## Props
85
73
 
86
74
  | Property | Type | Default | Description |
@@ -97,36 +85,6 @@ In your markup or JSX, you can then use these to set the properties for the `pie
97
85
  <PieNotification></PieNotification>
98
86
  ```
99
87
 
100
- ## Testing
88
+ ## Contributing
101
89
 
102
- ### Browser tests
103
-
104
- To run the browser tests, run the following command from the root of the monorepo:
105
-
106
- ```bash
107
- yarn test:browsers --filter=pie-notification
108
- ```
109
-
110
- ### Visual tests
111
-
112
- To run the visual regression tests, run the following command from the root of the monorepo:
113
-
114
- ```bash
115
- yarn test:visual --filter=pie-notification
116
- ```
117
-
118
- Note: To run these locally, you will need to ensure that any environment variables required are set up on your machine to mirror those on CI (such as Percy tokens). How you achieve this will differ between operating systems.
119
-
120
- #### Setup via bash
121
-
122
- ```bash
123
- export PERCY_TOKEN_PIE_NOTIFICATION=abcde
124
- ```
125
-
126
- #### Setup via package.json
127
-
128
- Under scripts `test:visual` replace the environment variable with the below:
129
-
130
- ```bash
131
- PERCY_TOKEN_PIE_NOTIFICATION=abcde
132
- ```
90
+ Check out our [contributing guide](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide) for more information on [local development](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#local-development) and how to run specific [component tests](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#testing).
package/dist/react.js CHANGED
@@ -1,63 +1,64 @@
1
1
  import * as g from "react";
2
- import { PieNotification as M } from "./index.js";
2
+ import { PieNotification as E } from "./index.js";
3
3
  import "lit";
4
4
  /**
5
5
  * @license
6
6
  * Copyright 2018 Google LLC
7
7
  * SPDX-License-Identifier: BSD-3-Clause
8
8
  */
9
- const P = /* @__PURE__ */ new Set(["children", "localName", "ref", "style", "className"]), E = /* @__PURE__ */ new WeakMap(), b = (d, l, m, p, h) => {
10
- const n = h == null ? void 0 : h[l];
11
- n === void 0 || m === p ? m == null && l in HTMLElement.prototype ? d.removeAttribute(l) : d[l] = m : ((o, t, u) => {
12
- let s = E.get(o);
13
- s === void 0 && E.set(o, s = /* @__PURE__ */ new Map());
14
- let a = s.get(t);
15
- u !== void 0 ? a === void 0 ? (s.set(t, a = { handleEvent: u }), o.addEventListener(t, a)) : a.handleEvent = u : a !== void 0 && (s.delete(t), o.removeEventListener(t, a));
16
- })(d, n, m);
9
+ const b = /* @__PURE__ */ new Set(["children", "localName", "ref", "style", "className"]), w = /* @__PURE__ */ new WeakMap(), M = (t, i, d, m, p) => {
10
+ const s = p == null ? void 0 : p[i];
11
+ s === void 0 || d === m ? d == null && i in HTMLElement.prototype ? t.removeAttribute(i) : t[i] = d : ((a, o, h) => {
12
+ let r = w.get(a);
13
+ r === void 0 && w.set(a, r = /* @__PURE__ */ new Map());
14
+ let l = r.get(o);
15
+ h !== void 0 ? l === void 0 ? (r.set(o, l = { handleEvent: h }), a.addEventListener(o, l)) : l.handleEvent = h : l !== void 0 && (r.delete(o), a.removeEventListener(o, l));
16
+ })(t, s, d);
17
+ }, P = (t, i) => {
18
+ typeof t == "function" ? t(i) : t.current = i;
17
19
  };
18
- function C(d = window.React, l, m, p, h) {
19
- let n, o, t;
20
- if (l === void 0) {
21
- const r = d;
22
- ({ tagName: o, elementClass: t, events: p, displayName: h } = r), n = r.react;
20
+ function C(t = window.React, i, d, m, p) {
21
+ let s, a, o;
22
+ if (i === void 0) {
23
+ const c = t;
24
+ ({ tagName: a, elementClass: o, events: m, displayName: p } = c), s = c.react;
23
25
  } else
24
- n = d, t = m, o = l;
25
- const u = n.Component, s = n.createElement, a = new Set(Object.keys(p ?? {}));
26
- class v extends u {
26
+ s = t, o = d, a = i;
27
+ const h = s.Component, r = s.createElement, l = new Set(Object.keys(m ?? {}));
28
+ class v extends h {
27
29
  constructor() {
28
30
  super(...arguments), this.o = null;
29
31
  }
30
32
  t(e) {
31
33
  if (this.o !== null)
32
- for (const f in this.i)
33
- b(this.o, f, this.props[f], e ? e[f] : void 0, p);
34
+ for (const u in this.i)
35
+ M(this.o, u, this.props[u], e ? e[u] : void 0, m);
34
36
  }
35
37
  componentDidMount() {
36
- this.t();
38
+ var e;
39
+ this.t(), (e = this.o) === null || e === void 0 || e.removeAttribute("defer-hydration");
37
40
  }
38
41
  componentDidUpdate(e) {
39
42
  this.t(e);
40
43
  }
41
44
  render() {
42
- const { _$Gl: e, ...f } = this.props;
43
- this.h !== e && (this.u = (i) => {
44
- e !== null && ((c, w) => {
45
- typeof c == "function" ? c(w) : c.current = w;
46
- })(e, i), this.o = i, this.h = e;
45
+ const { _$Gl: e, ...u } = this.props;
46
+ this.h !== e && (this.u = (n) => {
47
+ e !== null && P(e, n), this.o = n, this.h = e;
47
48
  }), this.i = {};
48
- const N = { ref: this.u };
49
- for (const [i, c] of Object.entries(f))
50
- P.has(i) ? N[i === "className" ? "class" : i] = c : a.has(i) || i in t.prototype ? this.i[i] = c : N[i] = c;
51
- return s(o, N);
49
+ const f = { ref: this.u };
50
+ for (const [n, N] of Object.entries(u))
51
+ b.has(n) ? f[n === "className" ? "class" : n] = N : l.has(n) || n in o.prototype ? this.i[n] = N : f[n] = N;
52
+ return f.suppressHydrationWarning = !0, r(a, f);
52
53
  }
53
54
  }
54
- v.displayName = h ?? t.name;
55
- const y = n.forwardRef((r, e) => s(v, { ...r, _$Gl: e }, r == null ? void 0 : r.children));
55
+ v.displayName = p ?? o.name;
56
+ const y = s.forwardRef((c, e) => r(v, { ...c, _$Gl: e }, c == null ? void 0 : c.children));
56
57
  return y.displayName = v.displayName, y;
57
58
  }
58
59
  const $ = C({
59
60
  displayName: "PieNotification",
60
- elementClass: M,
61
+ elementClass: E,
61
62
  react: g,
62
63
  tagName: "pie-notification",
63
64
  events: {}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-notification",
3
3
  "description": "PIE Design System Notification built using Web Components",
4
- "version": "0.0.0",
4
+ "version": "0.1.1",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -28,10 +28,10 @@
28
28
  "author": "Just Eat Takeaway.com - Design System Team",
29
29
  "license": "Apache-2.0",
30
30
  "devDependencies": {
31
- "@justeattakeaway/pie-components-config": "workspace:*"
31
+ "@justeattakeaway/pie-components-config": "0.4.0"
32
32
  },
33
33
  "dependencies": {
34
- "@justeattakeaway/pie-webc-core": "workspace:*"
34
+ "@justeattakeaway/pie-webc-core": "0.11.0"
35
35
  },
36
36
  "volta": {
37
37
  "extends": "../../../package.json"