@shoper/phoenix_design_system 0.3.3 → 0.4.3

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.
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * Allow for custom element classes with private constructors
7
+ */
8
+ const legacyCustomElement = (tagName, clazz) => {
9
+ window.customElements.define(tagName, clazz);
10
+ // Cast as any because TS doesn't recognize the return type as being a
11
+ // subtype of the decorated class when clazz is typed as
12
+ // `Constructor<HTMLElement>` for some reason.
13
+ // `Constructor<HTMLElement>` is helpful to make sure the decorator is
14
+ // applied to elements however.
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ clazz.__componentName__ = tagName;
17
+ return clazz;
18
+ };
19
+ const standardCustomElement = (tagName, descriptor) => {
20
+ const { kind, elements } = descriptor;
21
+ return {
22
+ kind,
23
+ elements,
24
+ // This callback is called once the class is otherwise fully defined
25
+ finisher(clazz) {
26
+ clazz.__componentName__ = tagName;
27
+ window.customElements.define(tagName, clazz);
28
+ }
29
+ };
30
+ };
31
+ /**
32
+ * Class decorator factory that defines the decorated class as a custom element.
33
+ *
34
+ * ```js
35
+ * @customElement('my-element')
36
+ * class MyElement extends LitElement {
37
+ * render() {
38
+ * return html``;
39
+ * }
40
+ * }
41
+ * ```
42
+ * @category Decorator
43
+ * @param tagName The tag name of the custom element to define.
44
+ */
45
+ const phoenixCustomElement = (tagName) => (classOrDescriptor) => typeof classOrDescriptor === 'function'
46
+ ? legacyCustomElement(tagName, classOrDescriptor)
47
+ : standardCustomElement(tagName, classOrDescriptor);
48
+
49
+ exports.phoenixCustomElement = phoenixCustomElement;
50
+ //# sourceMappingURL=phoenix_custom_element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var tslib_es6 = require('../../../external/tslib/tslib.es6.js');
6
6
  var lit = require('lit');
7
7
  var decorators = require('lit/decorators');
8
+ var phoenix_custom_element = require('./core/decorators/phoenix_custom_element.js');
8
9
 
9
10
  exports.HelloButton = class HelloButton extends lit.LitElement {
10
11
  constructor() {
@@ -46,6 +47,6 @@ tslib_es6.__decorate([
46
47
  tslib_es6.__metadata("design:type", Object)
47
48
  ], exports.HelloButton.prototype, "planet", void 0);
48
49
  exports.HelloButton = tslib_es6.__decorate([
49
- decorators.customElement('hello-button')
50
+ phoenix_custom_element.phoenixCustomElement('hello-button')
50
51
  ], exports.HelloButton);
51
52
  //# sourceMappingURL=hello_button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,sCAA0C;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,sCAA0C;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- /*! *****************************************************************************
5
+ /******************************************************************************
6
6
  Copyright (c) Microsoft Corporation.
7
7
 
8
8
  Permission to use, copy, modify, and/or distribute this software for any
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Allow for custom element classes with private constructors
3
+ */
4
+ import { ClassDescriptor, IPhoenixComponentClass } from "../../global_types";
5
+ declare type CustomElementClass = Omit<typeof HTMLElement, 'new'> & IPhoenixComponentClass;
6
+ /**
7
+ * Class decorator factory that defines the decorated class as a custom element.
8
+ *
9
+ * ```js
10
+ * @customElement('my-element')
11
+ * class MyElement extends LitElement {
12
+ * render() {
13
+ * return html``;
14
+ * }
15
+ * }
16
+ * ```
17
+ * @category Decorator
18
+ * @param tagName The tag name of the custom element to define.
19
+ */
20
+ export declare const phoenixCustomElement: (tagName: string) => (classOrDescriptor: CustomElementClass | ClassDescriptor) => any;
21
+ export {};
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Allow for custom element classes with private constructors
3
+ */
4
+ const legacyCustomElement = (tagName, clazz) => {
5
+ window.customElements.define(tagName, clazz);
6
+ // Cast as any because TS doesn't recognize the return type as being a
7
+ // subtype of the decorated class when clazz is typed as
8
+ // `Constructor<HTMLElement>` for some reason.
9
+ // `Constructor<HTMLElement>` is helpful to make sure the decorator is
10
+ // applied to elements however.
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ clazz.__componentName__ = tagName;
13
+ return clazz;
14
+ };
15
+ const standardCustomElement = (tagName, descriptor) => {
16
+ const { kind, elements } = descriptor;
17
+ return {
18
+ kind,
19
+ elements,
20
+ // This callback is called once the class is otherwise fully defined
21
+ finisher(clazz) {
22
+ clazz.__componentName__ = tagName;
23
+ window.customElements.define(tagName, clazz);
24
+ }
25
+ };
26
+ };
27
+ /**
28
+ * Class decorator factory that defines the decorated class as a custom element.
29
+ *
30
+ * ```js
31
+ * @customElement('my-element')
32
+ * class MyElement extends LitElement {
33
+ * render() {
34
+ * return html``;
35
+ * }
36
+ * }
37
+ * ```
38
+ * @category Decorator
39
+ * @param tagName The tag name of the custom element to define.
40
+ */
41
+ const phoenixCustomElement = (tagName) => (classOrDescriptor) => typeof classOrDescriptor === 'function'
42
+ ? legacyCustomElement(tagName, classOrDescriptor)
43
+ : standardCustomElement(tagName, classOrDescriptor);
44
+
45
+ export { phoenixCustomElement };
46
+ //# sourceMappingURL=phoenix_custom_element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -0,0 +1,20 @@
1
+ export declare type Constructor<T> = {
2
+ new (...args: any[]): T;
3
+ };
4
+ export interface ClassDescriptor {
5
+ kind: 'class';
6
+ elements: ClassElement[];
7
+ finisher?: <T>(clazz: Constructor<T>) => void | Constructor<T>;
8
+ }
9
+ export interface ClassElement {
10
+ kind: 'field' | 'method';
11
+ key: PropertyKey;
12
+ placement: 'static' | 'prototype' | 'own';
13
+ initializer?: Function;
14
+ extras?: ClassElement[];
15
+ finisher?: <T>(clazz: Constructor<T>) => void | Constructor<T>;
16
+ descriptor?: PropertyDescriptor;
17
+ }
18
+ export interface IPhoenixComponentClass {
19
+ __componentName__?: string;
20
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=global_types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global_types.js","sourceRoot":"","sources":["../../../../../src/global_types.ts"],"names":[],"mappings":""}
@@ -1,6 +1,7 @@
1
1
  import { __decorate, __metadata } from '../../../external/tslib/tslib.es6.js';
2
2
  import { LitElement, html, css } from 'lit';
3
- import { state, customElement } from 'lit/decorators';
3
+ import { state } from 'lit/decorators';
4
+ import { phoenixCustomElement } from './core/decorators/phoenix_custom_element.js';
4
5
 
5
6
  let HelloButton = class HelloButton extends LitElement {
6
7
  constructor() {
@@ -42,7 +43,7 @@ __decorate([
42
43
  __metadata("design:type", Object)
43
44
  ], HelloButton.prototype, "planet", void 0);
44
45
  HelloButton = __decorate([
45
- customElement('hello-button')
46
+ phoenixCustomElement('hello-button')
46
47
  ], HelloButton);
47
48
 
48
49
  export { HelloButton };
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,sCAA0C;AACjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,sCAA0C;AACjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,3 +1,4 @@
1
+ export { IPhoenixComponentClass } from "./global_types";
1
2
  export { ContextProviderController } from "./core/context/context_provider_controller";
2
3
  export { ContextConsumerController } from "./core/context/context_consumer_controller";
3
4
  export { PhoenixLightLitElement } from "./core/phoenix_light_lit_element";
@@ -1,4 +1,4 @@
1
- /*! *****************************************************************************
1
+ /******************************************************************************
2
2
  Copyright (c) Microsoft Corporation.
3
3
 
4
4
  Permission to use, copy, modify, and/or distribute this software for any
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@shoper/phoenix_design_system",
3
3
  "packageManager": "yarn@3.2.0",
4
4
  "sideEffects": false,
5
- "version": "0.3.3",
5
+ "version": "0.4.3",
6
6
  "description": "phoenix design system",
7
7
  "author": "zefirek",
8
8
  "license": "MIT",