@justeattakeaway/pie-divider 0.6.0 → 0.8.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.
package/README.md CHANGED
@@ -11,17 +11,53 @@
11
11
  # Table of Contents
12
12
 
13
13
  1. [Introduction](#pie-divider)
14
- 2. [Local Development](#local-development)
14
+ 2. [Installation](#installation)
15
15
  3. [Importing the component](#importing-the-component)
16
- 4. [Props](#props)
17
- 5. [Testing](#testing)
16
+ 4. [Local Development](#local-development)
17
+ 5. [Peer Dependencies](#peer-dependencies)
18
+ 6. [Props](#props)
19
+ 7. [Testing](#testing)
18
20
 
19
- # pie-divider
21
+
22
+ ## pie-divider
20
23
 
21
24
  `pie-divider` is a Web Component built using the Lit library.
22
25
 
23
26
  This component can be easily integrated into various frontend frameworks and customized through a set of properties.
24
27
 
28
+
29
+ ## Installation
30
+
31
+ To install `pie-divider` in your application, run the following on your command line:
32
+
33
+ ```bash
34
+ # npm
35
+ $ npm i @justeattakeaway/pie-divider
36
+
37
+ # yarn
38
+ $ yarn add @justeattakeaway/pie-divider
39
+ ```
40
+
41
+ For full information on using PIE components as part of an application, check out the [Getting Started Guide](https://github.com/justeattakeaway/pie/wiki/Getting-started-with-PIE-Web-Components).
42
+
43
+
44
+ ### Importing the component
45
+
46
+ ```js
47
+ // default
48
+ import { PieDivider } from '@justeattakeaway/pie-divider';
49
+
50
+ // react
51
+ import { PieDivider } from '@justeattakeaway/pie-divider/dist/react';
52
+ ```
53
+
54
+
55
+ ## Peer Dependencies
56
+
57
+ > [!IMPORTANT]
58
+ > 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
+
60
+
25
61
  ## Local development
26
62
 
27
63
  Install the dependencies. Note that this, and the following commands below, should be run from the **root of the monorepo**:
@@ -45,15 +81,6 @@ yarn watch --filter=pie-divider
45
81
  yarn dev --filter=pie-storybook
46
82
  ```
47
83
 
48
- ### Importing the component
49
-
50
- ```js
51
- // default
52
- import { PieDivider } from '@justeattakeaway/pie-divider';
53
-
54
- // react
55
- import { PieDivider } from '@justeattakeaway/pie-divider/dist/react';
56
- ```
57
84
 
58
85
  ## Props
59
86
 
@@ -104,4 +131,4 @@ Under scripts `test:visual` replace the environment variable with the below:
104
131
 
105
132
  ```bash
106
133
  PERCY_TOKEN_PIE_DIVIDER=abcde
107
- ```
134
+ ```
package/dist/index.d.ts CHANGED
@@ -15,6 +15,9 @@ export declare interface DividerProps {
15
15
 
16
16
  export declare const orientations: readonly ["horizontal", "vertical"];
17
17
 
18
+ /**
19
+ * @tagname pie-divider
20
+ */
18
21
  export declare class PieDivider extends LitElement implements DividerProps {
19
22
  variant: DividerProps['variant'];
20
23
  orientation: DividerProps['orientation'];
package/dist/index.js CHANGED
@@ -1,26 +1,30 @@
1
1
  import { unsafeCSS as u, LitElement as f, html as g } from "lit";
2
2
  import { property as c } from "lit/decorators.js";
3
- const l = (n, i, r) => function(e, t) {
4
- const o = `#${t}`;
5
- Object.defineProperty(e, t, {
3
+ const l = (i, e, r) => function(t, o) {
4
+ const n = `#${o}`;
5
+ Object.defineProperty(t, o, {
6
6
  get() {
7
- return this[o];
7
+ return this[n];
8
8
  },
9
9
  set(s) {
10
- const p = this[o];
11
- i.includes(s) ? this[o] = s : (console.error(
12
- `<${n}> Invalid value "${s}" provided for property "${t}".`,
13
- `Must be one of: ${i.join(" | ")}.`,
10
+ const p = this[n];
11
+ e.includes(s) ? this[n] = s : (console.error(
12
+ `<${i}> Invalid value "${s}" provided for property "${o}".`,
13
+ `Must be one of: ${e.join(" | ")}.`,
14
14
  `Falling back to default value: "${r}"`
15
- ), this[o] = r), this.requestUpdate(t, p);
15
+ ), this[n] = r), this.requestUpdate(o, p);
16
16
  }
17
17
  });
18
- }, m = `.c-divider{--divider-bg-color: var(--dt-color-divider-default);--divider-width: 100%;--divider-height: 1px;margin:0;border:0;width:var(--divider-width);height:var(--divider-height);background-color:var(--divider-bg-color)}.c-divider[variant=inverse]{--divider-bg-color: var(--dt-color-divider-inverse)}.c-divider[orientation=vertical]{--divider-width: 1px;--divider-height: 100%}
19
- `, b = ["default", "inverse"], P = ["horizontal", "vertical"];
20
- var $ = Object.defineProperty, y = Object.getOwnPropertyDescriptor, h = (n, i, r, d) => {
21
- for (var e = d > 1 ? void 0 : d ? y(i, r) : i, t = n.length - 1, o; t >= 0; t--)
22
- (o = n[t]) && (e = (d ? o(i, r, e) : o(e)) || e);
23
- return d && e && $(i, r, e), e;
18
+ };
19
+ function m(i, e) {
20
+ customElements.get(i) ? console.warn(`PIE Web Component: "${i}" has already been defined. Please ensure the component is only being defined once in your application.`) : customElements.define(i, e);
21
+ }
22
+ const b = `.c-divider{--divider-bg-color: var(--dt-color-divider-default);--divider-width: 100%;--divider-height: 1px;margin:0;border:0;width:var(--divider-width);height:var(--divider-height);background-color:var(--divider-bg-color)}.c-divider[variant=inverse]{--divider-bg-color: var(--dt-color-divider-inverse)}.c-divider[orientation=vertical]{--divider-width: 1px;--divider-height: 100%}
23
+ `, P = ["default", "inverse"], y = ["horizontal", "vertical"];
24
+ var $ = Object.defineProperty, w = Object.getOwnPropertyDescriptor, h = (i, e, r, d) => {
25
+ for (var t = d > 1 ? void 0 : d ? w(e, r) : e, o = i.length - 1, n; o >= 0; o--)
26
+ (n = i[o]) && (t = (d ? n(e, r, t) : n(t)) || t);
27
+ return d && t && $(e, r, t), t;
24
28
  };
25
29
  const v = "pie-divider";
26
30
  class a extends f {
@@ -28,29 +32,29 @@ class a extends f {
28
32
  super(...arguments), this.variant = "default", this.orientation = "horizontal";
29
33
  }
30
34
  render() {
31
- const { variant: i, orientation: r } = this;
35
+ const { variant: e, orientation: r } = this;
32
36
  return g`
33
37
  <hr
34
38
  data-test-id="pie-divider"
35
39
  aria-hidden="true"
36
40
  class="c-divider"
37
- variant=${i}
41
+ variant=${e}
38
42
  orientation=${r}
39
43
  />`;
40
44
  }
41
45
  }
42
- a.styles = u(m);
46
+ a.styles = u(b);
43
47
  h([
44
48
  c({ type: String }),
45
- l(v, b, "default")
49
+ l(v, P, "default")
46
50
  ], a.prototype, "variant", 2);
47
51
  h([
48
52
  c({ type: String }),
49
- l(v, P, "horizontal")
53
+ l(v, y, "horizontal")
50
54
  ], a.prototype, "orientation", 2);
51
- customElements.define(v, a);
55
+ m(v, a);
52
56
  export {
53
57
  a as PieDivider,
54
- P as orientations,
55
- b as variants
58
+ y as orientations,
59
+ P as variants
56
60
  };
package/dist/react.d.ts CHANGED
@@ -18,6 +18,9 @@ export declare const orientations: readonly ["horizontal", "vertical"];
18
18
 
19
19
  export declare const PieDivider: ReactWebComponent<PieDivider_2, {}>;
20
20
 
21
+ /**
22
+ * @tagname pie-divider
23
+ */
21
24
  declare class PieDivider_2 extends LitElement implements DividerProps {
22
25
  variant: DividerProps['variant'];
23
26
  orientation: DividerProps['orientation'];
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.6.0",
4
+ "version": "0.8.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -31,7 +31,7 @@
31
31
  "@justeattakeaway/pie-components-config": "0.4.0"
32
32
  },
33
33
  "dependencies": {
34
- "@justeattakeaway/pie-webc-core": "0.9.1"
34
+ "@justeattakeaway/pie-webc-core": "0.11.0"
35
35
  },
36
36
  "volta": {
37
37
  "extends": "../../../package.json"
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { LitElement, html, unsafeCSS } from 'lit';
2
2
  import { property } from 'lit/decorators.js';
3
- import { validPropertyValues } from '@justeattakeaway/pie-webc-core';
3
+ import { validPropertyValues, defineCustomElement } from '@justeattakeaway/pie-webc-core';
4
4
  import styles from './divider.scss?inline';
5
5
  import { DividerProps, variants, orientations } from './defs';
6
6
 
@@ -9,6 +9,9 @@ export * from './defs';
9
9
 
10
10
  const componentSelector = 'pie-divider';
11
11
 
12
+ /**
13
+ * @tagname pie-divider
14
+ */
12
15
  export class PieDivider extends LitElement implements DividerProps {
13
16
  @property({ type: String })
14
17
  @validPropertyValues(componentSelector, variants, 'default')
@@ -35,7 +38,7 @@ export class PieDivider extends LitElement implements DividerProps {
35
38
  static styles = unsafeCSS(styles);
36
39
  }
37
40
 
38
- customElements.define(componentSelector, PieDivider);
41
+ defineCustomElement(componentSelector, PieDivider);
39
42
 
40
43
  declare global {
41
44
  interface HTMLElementTagNameMap {
package/LICENSE DELETED
@@ -1,17 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- Copyright (c) Just Eat Takeaway.com
6
-
7
- Licensed under the Apache License, Version 2.0 (the "License");
8
- you may not use this file except in compliance with the License.
9
- You may obtain a copy of the License at
10
-
11
- http://www.apache.org/licenses/LICENSE-2.0
12
-
13
- Unless required by applicable law or agreed to in writing, software
14
- distributed under the License is distributed on an "AS IS" BASIS,
15
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- See the License for the specific language governing permissions and
17
- limitations under the License.