@shoper/phoenix_design_system 0.3.4 → 0.4.5
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/build/cjs/packages/phoenix/src/core/decorators/phoenix_custom_element.js +11 -3
- package/build/cjs/packages/phoenix/src/core/decorators/phoenix_custom_element.js.map +1 -1
- package/build/esm/packages/phoenix/src/core/decorators/phoenix_custom_element.d.ts +2 -2
- package/build/esm/packages/phoenix/src/core/decorators/phoenix_custom_element.js +11 -3
- package/build/esm/packages/phoenix/src/core/decorators/phoenix_custom_element.js.map +1 -1
- package/build/esm/packages/phoenix/src/global_types.d.ts +6 -1
- package/build/esm/packages/phoenix/src/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -6,13 +6,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
* Allow for custom element classes with private constructors
|
|
7
7
|
*/
|
|
8
8
|
const legacyCustomElement = (tagName, clazz) => {
|
|
9
|
-
window.customElements.define(tagName, clazz);
|
|
10
9
|
// Cast as any because TS doesn't recognize the return type as being a
|
|
11
10
|
// subtype of the decorated class when clazz is typed as
|
|
12
11
|
// `Constructor<HTMLElement>` for some reason.
|
|
13
12
|
// `Constructor<HTMLElement>` is helpful to make sure the decorator is
|
|
14
13
|
// applied to elements however.
|
|
15
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
defineComponent(tagName, clazz);
|
|
16
16
|
clazz.__componentName__ = tagName;
|
|
17
17
|
return clazz;
|
|
18
18
|
};
|
|
@@ -24,7 +24,7 @@ const standardCustomElement = (tagName, descriptor) => {
|
|
|
24
24
|
// This callback is called once the class is otherwise fully defined
|
|
25
25
|
finisher(clazz) {
|
|
26
26
|
clazz.__componentName__ = tagName;
|
|
27
|
-
|
|
27
|
+
defineComponent(tagName, clazz);
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
};
|
|
@@ -44,7 +44,15 @@ const standardCustomElement = (tagName, descriptor) => {
|
|
|
44
44
|
*/
|
|
45
45
|
const phoenixCustomElement = (tagName) => (classOrDescriptor) => typeof classOrDescriptor === 'function'
|
|
46
46
|
? legacyCustomElement(tagName, classOrDescriptor)
|
|
47
|
-
: standardCustomElement(tagName, classOrDescriptor);
|
|
47
|
+
: standardCustomElement(tagName, classOrDescriptor);
|
|
48
|
+
const defineComponent = (tagName, componentClass) => {
|
|
49
|
+
const isCustomElementAlreadyDefined = customElements.get(tagName);
|
|
50
|
+
if (!isCustomElementAlreadyDefined)
|
|
51
|
+
window.customElements.define(tagName, componentClass);
|
|
52
|
+
if (isCustomElementAlreadyDefined && window.__debug_mode__) {
|
|
53
|
+
console.warn(`Custom element ${tagName} is already defined.`);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
48
56
|
|
|
49
57
|
exports.phoenixCustomElement = phoenixCustomElement;
|
|
50
58
|
//# sourceMappingURL=phoenix_custom_element.js.map
|
|
@@ -1 +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;"}
|
|
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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Allow for custom element classes with private constructors
|
|
3
3
|
*/
|
|
4
|
-
import { ClassDescriptor,
|
|
5
|
-
declare type CustomElementClass = Omit<typeof HTMLElement, 'new'> &
|
|
4
|
+
import { ClassDescriptor, IPhoenixWebComponentClass } from "../../global_types";
|
|
5
|
+
declare type CustomElementClass = Omit<typeof HTMLElement, 'new'> & IPhoenixWebComponentClass;
|
|
6
6
|
/**
|
|
7
7
|
* Class decorator factory that defines the decorated class as a custom element.
|
|
8
8
|
*
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* Allow for custom element classes with private constructors
|
|
3
3
|
*/
|
|
4
4
|
const legacyCustomElement = (tagName, clazz) => {
|
|
5
|
-
window.customElements.define(tagName, clazz);
|
|
6
5
|
// Cast as any because TS doesn't recognize the return type as being a
|
|
7
6
|
// subtype of the decorated class when clazz is typed as
|
|
8
7
|
// `Constructor<HTMLElement>` for some reason.
|
|
9
8
|
// `Constructor<HTMLElement>` is helpful to make sure the decorator is
|
|
10
9
|
// applied to elements however.
|
|
11
10
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
defineComponent(tagName, clazz);
|
|
12
12
|
clazz.__componentName__ = tagName;
|
|
13
13
|
return clazz;
|
|
14
14
|
};
|
|
@@ -20,7 +20,7 @@ const standardCustomElement = (tagName, descriptor) => {
|
|
|
20
20
|
// This callback is called once the class is otherwise fully defined
|
|
21
21
|
finisher(clazz) {
|
|
22
22
|
clazz.__componentName__ = tagName;
|
|
23
|
-
|
|
23
|
+
defineComponent(tagName, clazz);
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
};
|
|
@@ -40,7 +40,15 @@ const standardCustomElement = (tagName, descriptor) => {
|
|
|
40
40
|
*/
|
|
41
41
|
const phoenixCustomElement = (tagName) => (classOrDescriptor) => typeof classOrDescriptor === 'function'
|
|
42
42
|
? legacyCustomElement(tagName, classOrDescriptor)
|
|
43
|
-
: standardCustomElement(tagName, classOrDescriptor);
|
|
43
|
+
: standardCustomElement(tagName, classOrDescriptor);
|
|
44
|
+
const defineComponent = (tagName, componentClass) => {
|
|
45
|
+
const isCustomElementAlreadyDefined = customElements.get(tagName);
|
|
46
|
+
if (!isCustomElementAlreadyDefined)
|
|
47
|
+
window.customElements.define(tagName, componentClass);
|
|
48
|
+
if (isCustomElementAlreadyDefined && window.__debug_mode__) {
|
|
49
|
+
console.warn(`Custom element ${tagName} is already defined.`);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
44
52
|
|
|
45
53
|
export { phoenixCustomElement };
|
|
46
54
|
//# sourceMappingURL=phoenix_custom_element.js.map
|
|
@@ -1 +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;"}
|
|
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;AACA;AACA;AACA;AACA;"}
|
|
@@ -15,6 +15,11 @@ export interface ClassElement {
|
|
|
15
15
|
finisher?: <T>(clazz: Constructor<T>) => void | Constructor<T>;
|
|
16
16
|
descriptor?: PropertyDescriptor;
|
|
17
17
|
}
|
|
18
|
-
export interface
|
|
18
|
+
export interface IPhoenixWebComponentClass {
|
|
19
19
|
__componentName__?: string;
|
|
20
20
|
}
|
|
21
|
+
declare global {
|
|
22
|
+
interface Window {
|
|
23
|
+
__debug_mode__?: boolean;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { IPhoenixWebComponentClass } from "./global_types";
|
|
2
2
|
export { ContextProviderController } from "./core/context/context_provider_controller";
|
|
3
3
|
export { ContextConsumerController } from "./core/context/context_consumer_controller";
|
|
4
4
|
export { PhoenixLightLitElement } from "./core/phoenix_light_lit_element";
|