@justeattakeaway/pie-lottie-player 0.1.1 → 0.2.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.
@@ -26,7 +26,7 @@
26
26
  "type": {
27
27
  "text": "DefaultProps"
28
28
  },
29
- "default": "{\n loopDisabled: false,\n autoPlayDisabled: false,\n speed: 1,\n direction: 'forward',\n}"
29
+ "default": "{\r\n loopDisabled: false,\r\n autoPlayDisabled: false,\r\n speed: 1,\r\n direction: 'forward',\r\n}"
30
30
  }
31
31
  ],
32
32
  "exports": [
package/dist/index.js CHANGED
@@ -1,36 +1,30 @@
1
- import { LitElement as m, isServer as _, html as u, unsafeCSS as f } from "lit";
2
- import { property as o, query as y } from "lit/decorators.js";
3
- import { defineCustomElement as D } from "@justeattakeaway/pie-webc-core";
4
- var b = Object.defineProperty, I = (l, t, i, s) => {
5
- for (var e = void 0, n = l.length - 1, d; n >= 0; n--)
6
- (d = l[n]) && (e = d(t, i, e) || e);
7
- return e && b(t, i, e), e;
8
- };
9
- class h extends m {
10
- constructor() {
11
- super(...arguments), this.v = "0.1.1";
1
+ import { LitElement as m, unsafeCSS as u, isServer as _, html as y } from "lit";
2
+ import { query as f, property as o } from "lit/decorators.js";
3
+ import { safeCustomElement as D } from "@justeattakeaway/pie-webc-core";
4
+ const d = class d extends m {
5
+ willUpdate() {
6
+ this.getAttribute("v") || this.setAttribute("v", d.v);
12
7
  }
13
- }
14
- I([
15
- o({ type: String, reflect: !0 })
16
- ], h.prototype, "v");
17
- const E = ["forward", "reverse"], c = {
8
+ };
9
+ d.v = "0.2.1";
10
+ let p = d;
11
+ const v = ["forward", "reverse"], l = {
18
12
  loopDisabled: !1,
19
13
  autoPlayDisabled: !1,
20
14
  speed: 1,
21
15
  direction: "forward"
22
16
  };
23
- var P = Object.defineProperty, S = Object.getOwnPropertyDescriptor, r = (l, t, i, s) => {
24
- for (var e = s > 1 ? void 0 : s ? S(t, i) : t, n = l.length - 1, d; n >= 0; n--)
25
- (d = l[n]) && (e = (s ? d(t, i, e) : d(e)) || e);
26
- return s && e && P(t, i, e), e;
17
+ var b = Object.defineProperty, P = Object.getOwnPropertyDescriptor, s = (t, e, r, n) => {
18
+ for (var a = n > 1 ? void 0 : n ? P(e, r) : e, c = t.length - 1, h; c >= 0; c--)
19
+ (h = t[c]) && (a = (n ? h(e, r, a) : h(a)) || a);
20
+ return n && a && b(e, r, a), a;
27
21
  };
28
- const g = "pie-lottie-player", p = class p extends h {
22
+ let i = class extends p {
29
23
  constructor() {
30
- super(...arguments), this._animationSrc = "", this._autoPlayDisabled = c.autoPlayDisabled, this._loopDisabled = c.loopDisabled, this._speed = c.speed, this._direction = c.direction;
24
+ super(...arguments), this._animationSrc = "", this._autoPlayDisabled = l.autoPlayDisabled, this._loopDisabled = l.loopDisabled, this._speed = l.speed, this._direction = l.direction;
31
25
  }
32
26
  async firstUpdated() {
33
- const t = await import("./lottie_light_canvas.min-Dwyz9L-n.js").then((i) => i.l);
27
+ const t = await import("./lottie_light_canvas.min-Dwyz9L-n.js").then((e) => e.l);
34
28
  t && t.default && (this._lottie = t.default, this._loadAnimation());
35
29
  }
36
30
  disconnectedCallback() {
@@ -38,7 +32,7 @@ const g = "pie-lottie-player", p = class p extends h {
38
32
  }
39
33
  _loadAnimation() {
40
34
  if (_ || !this._hostElement || !this._lottie || (this._destroyAnimation(), !this.animationSrc && !this.animationData)) return;
41
- const t = window.matchMedia("(prefers-reduced-motion: reduce)").matches, i = t === !0 ? !t : !this.autoPlayDisabled;
35
+ const t = window.matchMedia("(prefers-reduced-motion: reduce)").matches, e = t === !0 ? !t : !this.autoPlayDisabled;
42
36
  try {
43
37
  this._animationInstance = this._lottie.loadAnimation({
44
38
  container: this._hostElement,
@@ -47,11 +41,11 @@ const g = "pie-lottie-player", p = class p extends h {
47
41
  loop: !this.loopDisabled,
48
42
  animationData: this.animationData,
49
43
  path: this.animationSrc,
50
- autoplay: i
44
+ autoplay: e
51
45
  }), this._animationInstance.setSpeed(this.speed), this._updateDirection();
52
- } catch (s) {
53
- const e = s, n = e && e.message && `Error: "${e.message}"`;
54
- console.error(`PieLottiePlayer: the animation couldn't be played. ${n}`);
46
+ } catch (r) {
47
+ const n = r, a = n && n.message && `Error: "${n.message}"`;
48
+ console.error(`PieLottiePlayer: the animation couldn't be played. ${a}`);
55
49
  }
56
50
  }
57
51
  _destroyAnimation() {
@@ -118,36 +112,37 @@ const g = "pie-lottie-player", p = class p extends h {
118
112
  this._animationInstance && this._animationInstance.stop();
119
113
  }
120
114
  render() {
121
- return u`<div aria-hidden="true" data-test-id="pie-lottie-player"></div>`;
115
+ return y`<div aria-hidden="true" data-test-id="pie-lottie-player"></div>`;
122
116
  }
123
117
  // Kept as empty to ensure it will be present during SSR testing
124
118
  };
125
- p.styles = f("");
126
- let a = p;
127
- r([
128
- y("div")
129
- ], a.prototype, "_hostElement", 2);
130
- r([
119
+ i.styles = u("");
120
+ s([
121
+ f("div")
122
+ ], i.prototype, "_hostElement", 2);
123
+ s([
131
124
  o({ type: String, reflect: !0 })
132
- ], a.prototype, "animationSrc", 1);
133
- r([
125
+ ], i.prototype, "animationSrc", 1);
126
+ s([
134
127
  o({ type: Object })
135
- ], a.prototype, "animationData", 1);
136
- r([
128
+ ], i.prototype, "animationData", 1);
129
+ s([
137
130
  o({ type: Boolean })
138
- ], a.prototype, "autoPlayDisabled", 1);
139
- r([
131
+ ], i.prototype, "autoPlayDisabled", 1);
132
+ s([
140
133
  o({ type: Boolean })
141
- ], a.prototype, "loopDisabled", 1);
142
- r([
134
+ ], i.prototype, "loopDisabled", 1);
135
+ s([
143
136
  o({ type: Number, reflect: !0 })
144
- ], a.prototype, "speed", 1);
145
- r([
137
+ ], i.prototype, "speed", 1);
138
+ s([
146
139
  o({ type: String, reflect: !0 })
147
- ], a.prototype, "direction", 1);
148
- D(g, a);
140
+ ], i.prototype, "direction", 1);
141
+ i = s([
142
+ D("pie-lottie-player")
143
+ ], i);
149
144
  export {
150
- a as PieLottiePlayer,
151
- c as defaultProps,
152
- E as directions
145
+ i as PieLottiePlayer,
146
+ l as defaultProps,
147
+ v as directions
153
148
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-lottie-player",
3
3
  "description": "PIE Design System Lottie Player built using Web Components",
4
- "version": "0.1.1",
4
+ "version": "0.2.1",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -31,13 +31,13 @@
31
31
  "license": "Apache-2.0",
32
32
  "devDependencies": {
33
33
  "@custom-elements-manifest/analyzer": "0.9.0",
34
- "@justeattakeaway/pie-components-config": "0.19.1",
34
+ "@justeattakeaway/pie-components-config": "0.20.1",
35
35
  "@justeattakeaway/pie-css": "0.16.0",
36
- "@justeattakeaway/pie-monorepo-utils": "0.5.0",
36
+ "@justeattakeaway/pie-monorepo-utils": "0.5.1",
37
37
  "cem-plugin-module-file-extensions": "0.0.5"
38
38
  },
39
39
  "dependencies": {
40
- "@justeattakeaway/pie-webc-core": "0.25.1",
40
+ "@justeattakeaway/pie-webc-core": "1.0.0",
41
41
  "lottie-web": "5.12.2"
42
42
  },
43
43
  "volta": {
package/src/index.ts CHANGED
@@ -5,7 +5,7 @@ import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElem
5
5
  import { property, query } from 'lit/decorators.js';
6
6
  import { type LottiePlayer, type AnimationItem } from 'lottie-web';
7
7
 
8
- import { defineCustomElement } from '@justeattakeaway/pie-webc-core';
8
+ import { safeCustomElement } from '@justeattakeaway/pie-webc-core';
9
9
  import { type LottiePlayerProps, defaultProps } from './defs';
10
10
 
11
11
  // Valid values available to consumers
@@ -16,6 +16,7 @@ const componentSelector = 'pie-lottie-player';
16
16
  /**
17
17
  * @tagname pie-lottie-player
18
18
  */
19
+ @safeCustomElement('pie-lottie-player')
19
20
  export class PieLottiePlayer extends PieElement implements LottiePlayerProps {
20
21
  @query('div')
21
22
  private _hostElement!: HTMLDivElement;
@@ -200,8 +201,6 @@ export class PieLottiePlayer extends PieElement implements LottiePlayerProps {
200
201
  static styles = unsafeCSS(''); // Kept as empty to ensure it will be present during SSR testing
201
202
  }
202
203
 
203
- defineCustomElement(componentSelector, PieLottiePlayer);
204
-
205
204
  declare global {
206
205
  interface HTMLElementTagNameMap {
207
206
  [componentSelector]: PieLottiePlayer;