@justeattakeaway/pie-divider 0.9.0 → 0.9.2-next.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
@@ -42,14 +42,28 @@ For full information on using PIE components as part of an application, check ou
42
42
 
43
43
  ### Importing the component
44
44
 
45
+ #### JavaScript
45
46
  ```js
46
- // default
47
+ // Default – for Native JS Applications, Vue, Angular, Svelte, etc.
47
48
  import { PieDivider } from '@justeattakeaway/pie-divider';
48
49
 
49
- // 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
50
60
  import { PieDivider } from '@justeattakeaway/pie-divider/dist/react';
51
61
  ```
52
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
+
53
67
 
54
68
  ## Peer Dependencies
55
69
 
package/dist/index.d.ts CHANGED
File without changes
package/dist/index.js CHANGED
@@ -1,60 +1,60 @@
1
- import { unsafeCSS as u, LitElement as f, html as g } from "lit";
1
+ import { unsafeCSS as h, LitElement as u, html as f } from "lit";
2
2
  import { property as c } from "lit/decorators.js";
3
- const l = (i, e, r) => function(t, o) {
3
+ const l = (i, e, t) => function(r, o) {
4
4
  const n = `#${o}`;
5
- Object.defineProperty(t, o, {
5
+ Object.defineProperty(r, o, {
6
6
  get() {
7
7
  return this[n];
8
8
  },
9
9
  set(s) {
10
- const p = this[n];
11
10
  e.includes(s) ? this[n] = s : (console.error(
12
11
  `<${i}> Invalid value "${s}" provided for property "${o}".`,
13
12
  `Must be one of: ${e.join(" | ")}.`,
14
- `Falling back to default value: "${r}"`
15
- ), this[n] = r), this.requestUpdate(o, p);
16
- }
13
+ `Falling back to default value: "${t}"`
14
+ ), this[n] = t);
15
+ },
16
+ configurable: !0
17
17
  });
18
18
  };
19
- function m(i, e) {
19
+ function g(i, e) {
20
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
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;
22
+ const 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%}
23
+ `, b = ["default", "inverse"], y = ["horizontal", "vertical"];
24
+ var P = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, p = (i, e, t, d) => {
25
+ for (var r = d > 1 ? void 0 : d ? $(e, t) : e, o = i.length - 1, n; o >= 0; o--)
26
+ (n = i[o]) && (r = (d ? n(e, t, r) : n(r)) || r);
27
+ return d && r && P(e, t, r), r;
28
28
  };
29
29
  const v = "pie-divider";
30
- class a extends f {
30
+ class a extends u {
31
31
  constructor() {
32
32
  super(...arguments), this.variant = "default", this.orientation = "horizontal";
33
33
  }
34
34
  render() {
35
- const { variant: e, orientation: r } = this;
36
- return g`
35
+ const { variant: e, orientation: t } = this;
36
+ return f`
37
37
  <hr
38
38
  data-test-id="pie-divider"
39
39
  aria-hidden="true"
40
40
  class="c-divider"
41
41
  variant=${e}
42
- orientation=${r}
42
+ orientation=${t}
43
43
  />`;
44
44
  }
45
45
  }
46
- a.styles = u(b);
47
- h([
46
+ a.styles = h(m);
47
+ p([
48
48
  c({ type: String }),
49
- l(v, P, "default")
49
+ l(v, b, "default")
50
50
  ], a.prototype, "variant", 2);
51
- h([
51
+ p([
52
52
  c({ type: String }),
53
53
  l(v, y, "horizontal")
54
54
  ], a.prototype, "orientation", 2);
55
- m(v, a);
55
+ g(v, a);
56
56
  export {
57
57
  a as PieDivider,
58
58
  y as orientations,
59
- P as variants
59
+ b as variants
60
60
  };
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-labs/react';
3
+ import type { ReactWebComponent } from '@lit/react';
4
4
  import type { TemplateResult } from 'lit-html';
5
5
 
6
6
  export declare interface DividerProps {
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 y from "react";
2
+ import { PieDivider as E } from "./index.js";
3
+ import { orientations as k, variants as C } from "./index.js";
4
4
  import "lit";
5
5
  import "lit/decorators.js";
6
6
  /**
@@ -8,64 +8,42 @@ 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);
19
- };
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;
25
- } else
26
- n = c, t = m, s = a;
27
- const v = n.Component, o = n.createElement, r = new Set(Object.keys(p ?? {}));
28
- class f extends v {
29
- constructor() {
30
- super(...arguments), this.o = null;
31
- }
32
- t(e) {
33
- 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
- }
37
- componentDidMount() {
38
- this.t();
39
- }
40
- componentDidUpdate(e) {
41
- this.t(e);
42
- }
43
- 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;
49
- }), 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);
54
- }
55
- }
56
- f.displayName = h ?? t.name;
57
- const N = n.forwardRef((l, e) => o(f, { ...l, _$Gl: e }, l == null ? void 0 : l.children));
58
- return N.displayName = f.displayName, N;
59
- }
60
- const R = b({
11
+ const N = /* @__PURE__ */ new Set(["children", "localName", "ref", "style", "className"]), p = /* @__PURE__ */ new WeakMap(), h = (t, c, s, u, l) => {
12
+ const d = l == null ? void 0 : l[c];
13
+ d === void 0 || s === u ? (t[c] = s, s == null && c in HTMLElement.prototype && t.removeAttribute(c)) : ((a, n, i) => {
14
+ let o = p.get(a);
15
+ o === void 0 && p.set(a, o = /* @__PURE__ */ new Map());
16
+ let r = o.get(n);
17
+ i !== void 0 ? r === void 0 ? (o.set(n, r = { handleEvent: i }), a.addEventListener(n, r)) : r.handleEvent = i : r !== void 0 && (o.delete(n), a.removeEventListener(n, r));
18
+ })(t, d, s);
19
+ }, b = ({ react: t, tagName: c, elementClass: s, events: u, displayName: l }) => {
20
+ const d = new Set(Object.keys(u ?? {})), a = t.forwardRef((n, i) => {
21
+ const o = t.useRef(null), r = t.useRef(null), m = {}, v = {};
22
+ for (const [e, f] of Object.entries(n))
23
+ N.has(e) ? m[e === "className" ? "class" : e] = f : d.has(e) || e in s.prototype ? v[e] = f : m[e] = f;
24
+ return t.useLayoutEffect(() => {
25
+ if (r.current !== null) {
26
+ for (const e in v)
27
+ h(r.current, e, n[e], o.current ? o.current[e] : void 0, u);
28
+ o.current = n;
29
+ }
30
+ }), t.useLayoutEffect(() => {
31
+ var e;
32
+ (e = r.current) == null || e.removeAttribute("defer-hydration");
33
+ }, []), m.suppressHydrationWarning = !0, t.createElement(c, { ...m, ref: t.useCallback((e) => {
34
+ r.current = e, typeof i == "function" ? i(e) : i !== null && (i.current = e);
35
+ }, [i]) });
36
+ });
37
+ return a.displayName = l ?? s.name, a;
38
+ }, D = b({
61
39
  displayName: "PieDivider",
62
- elementClass: g,
63
- react: E,
40
+ elementClass: E,
41
+ react: y,
64
42
  tagName: "pie-divider",
65
43
  events: {}
66
44
  });
67
45
  export {
68
- R as PieDivider,
46
+ D as PieDivider,
69
47
  k as orientations,
70
- G as variants
48
+ C as variants
71
49
  };
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.9.0",
4
+ "version": "0.9.2-next.0",
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": "0.4.0"
31
+ "@justeattakeaway/pie-components-config": "0.6.0"
32
32
  },
33
33
  "dependencies": {
34
- "@justeattakeaway/pie-webc-core": "0.11.0"
34
+ "@justeattakeaway/pie-webc-core": "0.12.0-next.0"
35
35
  },
36
36
  "volta": {
37
37
  "extends": "../../../package.json"