@justeattakeaway/pie-divider 0.8.0 → 0.9.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 +21 -63
  2. package/dist/react.js +37 -36
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -13,10 +13,9 @@
13
13
  1. [Introduction](#pie-divider)
14
14
  2. [Installation](#installation)
15
15
  3. [Importing the component](#importing-the-component)
16
- 4. [Local Development](#local-development)
17
- 5. [Peer Dependencies](#peer-dependencies)
18
- 6. [Props](#props)
19
- 7. [Testing](#testing)
16
+ 4. [Peer Dependencies](#peer-dependencies)
17
+ 5. [Props](#props)
18
+ 6. [Contributing](#contributing)
20
19
 
21
20
 
22
21
  ## pie-divider
@@ -43,45 +42,34 @@ For full information on using PIE components as part of an application, check ou
43
42
 
44
43
  ### Importing the component
45
44
 
45
+ #### JavaScript
46
46
  ```js
47
- // default
47
+ // Default – for Native JS Applications, Vue, Angular, Svelte, etc.
48
48
  import { PieDivider } from '@justeattakeaway/pie-divider';
49
49
 
50
- // react
50
+ // If you don't need to reference the imported object, you can simply
51
+ // import the module which registers the component as a custom element.
52
+ import '@justeattakeaway/pie-divider';
53
+ ```
54
+
55
+ #### React
56
+ ```js
57
+ // React
58
+ // For React, you will need to import our React-specific component build
59
+ // which wraps the web component using @lit-labs/react
51
60
  import { PieDivider } from '@justeattakeaway/pie-divider/dist/react';
52
61
  ```
53
62
 
63
+ > [!NOTE]
64
+ > When using the React version of the component, please make sure to also
65
+ > include React as a [peer dependency](#peer-dependencies) in your project.
66
+
54
67
 
55
68
  ## Peer Dependencies
56
69
 
57
70
  > [!IMPORTANT]
58
71
  > When using `pie-divider`, 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.
59
72
 
60
-
61
- ## Local development
62
-
63
- Install the dependencies. Note that this, and the following commands below, should be run from the **root of the monorepo**:
64
-
65
- ```bash
66
- yarn
67
- ```
68
-
69
- To build the `pie-divider` package, run the following command:
70
-
71
- ```bash
72
- yarn build --filter=pie-divider
73
- ```
74
-
75
- 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:
76
-
77
- ```bash
78
- yarn watch --filter=pie-divider
79
-
80
- # in a separate terminal tab, run
81
- yarn dev --filter=pie-storybook
82
- ```
83
-
84
-
85
73
  ## Props
86
74
 
87
75
  | Property | Type | Default | Description |
@@ -99,36 +87,6 @@ In your markup or JSX, you can then use these to set the properties for the `pie
99
87
  <PieDivider />
100
88
  ```
101
89
 
102
- ## Testing
90
+ ## Contributing
103
91
 
104
- ### Browser tests
105
-
106
- To run the browser tests, run the following command from the root of the monorepo:
107
-
108
- ```bash
109
- yarn test:browsers --filter=pie-divider
110
- ```
111
-
112
- ### Visual tests
113
-
114
- To run the visual regression tests, run the following command from the root of the monorepo:
115
-
116
- ```bash
117
- yarn test:visual --filter=pie-divider
118
- ```
119
-
120
- 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.
121
-
122
- #### Setup via bash
123
-
124
- ```bash
125
- export PERCY_TOKEN_PIE_DIVIDER=abcde
126
- ```
127
-
128
- #### Setup via package.json
129
-
130
- Under scripts `test:visual` replace the environment variable with the below:
131
-
132
- ```bash
133
- PERCY_TOKEN_PIE_DIVIDER=abcde
134
- ```
92
+ 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,6 +1,6 @@
1
- import * as E from "react";
2
- import { PieDivider as g } from "./index.js";
3
- import { orientations as k, variants as G } from "./index.js";
1
+ import * as g from "react";
2
+ import { PieDivider as D } from "./index.js";
3
+ import { orientations as k, variants as A } from "./index.js";
4
4
  import "lit";
5
5
  import "lit/decorators.js";
6
6
  /**
@@ -8,64 +8,65 @@ import "lit/decorators.js";
8
8
  * Copyright 2018 Google LLC
9
9
  * SPDX-License-Identifier: BSD-3-Clause
10
10
  */
11
- const M = /* @__PURE__ */ new Set(["children", "localName", "ref", "style", "className"]), D = /* @__PURE__ */ new WeakMap(), P = (c, a, m, p, h) => {
12
- const n = h == null ? void 0 : h[a];
13
- n === void 0 || m === p ? m == null && a in HTMLElement.prototype ? c.removeAttribute(a) : c[a] = m : ((s, t, v) => {
14
- let o = D.get(s);
15
- o === void 0 && D.set(s, o = /* @__PURE__ */ new Map());
16
- let r = o.get(t);
17
- v !== void 0 ? r === void 0 ? (o.set(t, r = { handleEvent: v }), s.addEventListener(t, r)) : r.handleEvent = v : r !== void 0 && (o.delete(t), s.removeEventListener(t, r));
18
- })(c, n, m);
11
+ const E = /* @__PURE__ */ new Set(["children", "localName", "ref", "style", "className"]), w = /* @__PURE__ */ new WeakMap(), b = (t, i, c, m, p) => {
12
+ const s = p == null ? void 0 : p[i];
13
+ s === void 0 || c === m ? c == null && i in HTMLElement.prototype ? t.removeAttribute(i) : t[i] = c : ((r, n, v) => {
14
+ let a = w.get(r);
15
+ a === void 0 && w.set(r, a = /* @__PURE__ */ new Map());
16
+ let l = a.get(n);
17
+ v !== void 0 ? l === void 0 ? (a.set(n, l = { handleEvent: v }), r.addEventListener(n, l)) : l.handleEvent = v : l !== void 0 && (a.delete(n), r.removeEventListener(n, l));
18
+ })(t, s, c);
19
+ }, M = (t, i) => {
20
+ typeof t == "function" ? t(i) : t.current = i;
19
21
  };
20
- function b(c = window.React, a, m, p, h) {
21
- let n, s, t;
22
- if (a === void 0) {
23
- const l = c;
24
- ({ tagName: s, elementClass: t, events: p, displayName: h } = l), n = l.react;
22
+ function P(t = window.React, i, c, m, p) {
23
+ let s, r, n;
24
+ if (i === void 0) {
25
+ const d = t;
26
+ ({ tagName: r, elementClass: n, events: m, displayName: p } = d), s = d.react;
25
27
  } else
26
- n = c, t = m, s = a;
27
- const v = n.Component, o = n.createElement, r = new Set(Object.keys(p ?? {}));
28
+ s = t, n = c, r = i;
29
+ const v = s.Component, a = s.createElement, l = new Set(Object.keys(m ?? {}));
28
30
  class f extends v {
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 u in this.i)
35
- P(this.o, u, this.props[u], e ? e[u] : void 0, p);
36
+ for (const h in this.i)
37
+ b(this.o, h, this.props[h], e ? e[h] : void 0, m);
36
38
  }
37
39
  componentDidMount() {
38
- this.t();
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, ...u } = this.props;
45
- this.h !== e && (this.u = (i) => {
46
- e !== null && ((d, w) => {
47
- typeof d == "function" ? d(w) : d.current = w;
48
- })(e, i), this.o = i, this.h = e;
47
+ const { _$Gl: e, ...h } = this.props;
48
+ this.h !== e && (this.u = (o) => {
49
+ e !== null && M(e, o), this.o = o, this.h = e;
49
50
  }), this.i = {};
50
- const y = { ref: this.u };
51
- for (const [i, d] of Object.entries(u))
52
- M.has(i) ? y[i === "className" ? "class" : i] = d : r.has(i) || i in t.prototype ? this.i[i] = d : y[i] = d;
53
- return o(s, y);
51
+ const u = { ref: this.u };
52
+ for (const [o, y] of Object.entries(h))
53
+ E.has(o) ? u[o === "className" ? "class" : o] = y : l.has(o) || o in n.prototype ? this.i[o] = y : u[o] = y;
54
+ return u.suppressHydrationWarning = !0, a(r, u);
54
55
  }
55
56
  }
56
- f.displayName = h ?? t.name;
57
- const N = n.forwardRef((l, e) => o(f, { ...l, _$Gl: e }, l == null ? void 0 : l.children));
57
+ f.displayName = p ?? n.name;
58
+ const N = s.forwardRef((d, e) => a(f, { ...d, _$Gl: e }, d == null ? void 0 : d.children));
58
59
  return N.displayName = f.displayName, N;
59
60
  }
60
- const R = b({
61
+ const R = P({
61
62
  displayName: "PieDivider",
62
- elementClass: g,
63
- react: E,
63
+ elementClass: D,
64
+ react: g,
64
65
  tagName: "pie-divider",
65
66
  events: {}
66
67
  });
67
68
  export {
68
69
  R as PieDivider,
69
70
  k as orientations,
70
- G as variants
71
+ A as variants
71
72
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-divider",
3
3
  "description": "PIE Design System Divider built using Web Components",
4
- "version": "0.8.0",
4
+ "version": "0.9.1",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",