@shoper/phoenix_design_system 0.5.0 → 0.5.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.
Files changed (42) hide show
  1. package/build/cjs/packages/phoenix/src/components/modal/modal.js +8 -7
  2. package/build/cjs/packages/phoenix/src/components/modal/modal.js.map +1 -1
  3. package/build/cjs/packages/phoenix/src/components/modal/modal_backdrop.js +3 -2
  4. package/build/cjs/packages/phoenix/src/components/modal/modal_backdrop.js.map +1 -1
  5. package/build/cjs/packages/phoenix/src/components/modal/modal_body.js +2 -2
  6. package/build/cjs/packages/phoenix/src/components/modal/modal_close.js +2 -2
  7. package/build/cjs/packages/phoenix/src/components/modal/modal_footer.js +2 -2
  8. package/build/cjs/packages/phoenix/src/components/modal/modal_header.js +2 -2
  9. package/build/cjs/packages/phoenix/src/components/modal/modal_opener.js +2 -1
  10. package/build/cjs/packages/phoenix/src/components/modal/modal_opener.js.map +1 -1
  11. package/build/cjs/packages/phoenix/src/components/portal/portal.js +2 -1
  12. package/build/cjs/packages/phoenix/src/components/portal/portal.js.map +1 -1
  13. package/build/cjs/packages/phoenix/src/components/portal/portal_target.js +2 -1
  14. package/build/cjs/packages/phoenix/src/components/portal/portal_target.js.map +1 -1
  15. package/build/cjs/packages/phoenix/src/core/decorators/phoenix_custom_element.js +58 -0
  16. package/build/cjs/packages/phoenix/src/core/decorators/phoenix_custom_element.js.map +1 -0
  17. package/build/cjs/packages/phoenix/src/hello_button.js +2 -1
  18. package/build/cjs/packages/phoenix/src/hello_button.js.map +1 -1
  19. package/build/esm/packages/phoenix/src/components/modal/modal.js +9 -8
  20. package/build/esm/packages/phoenix/src/components/modal/modal.js.map +1 -1
  21. package/build/esm/packages/phoenix/src/components/modal/modal_backdrop.js +4 -3
  22. package/build/esm/packages/phoenix/src/components/modal/modal_backdrop.js.map +1 -1
  23. package/build/esm/packages/phoenix/src/components/modal/modal_body.js +2 -2
  24. package/build/esm/packages/phoenix/src/components/modal/modal_close.js +2 -2
  25. package/build/esm/packages/phoenix/src/components/modal/modal_footer.js +2 -2
  26. package/build/esm/packages/phoenix/src/components/modal/modal_header.js +2 -2
  27. package/build/esm/packages/phoenix/src/components/modal/modal_opener.js +3 -2
  28. package/build/esm/packages/phoenix/src/components/modal/modal_opener.js.map +1 -1
  29. package/build/esm/packages/phoenix/src/components/portal/portal.js +3 -2
  30. package/build/esm/packages/phoenix/src/components/portal/portal.js.map +1 -1
  31. package/build/esm/packages/phoenix/src/components/portal/portal_target.js +3 -2
  32. package/build/esm/packages/phoenix/src/components/portal/portal_target.js.map +1 -1
  33. package/build/esm/packages/phoenix/src/core/decorators/phoenix_custom_element.d.ts +21 -0
  34. package/build/esm/packages/phoenix/src/core/decorators/phoenix_custom_element.js +54 -0
  35. package/build/esm/packages/phoenix/src/core/decorators/phoenix_custom_element.js.map +1 -0
  36. package/build/esm/packages/phoenix/src/global_types.d.ts +25 -0
  37. package/build/esm/packages/phoenix/src/global_types.js +2 -0
  38. package/build/esm/packages/phoenix/src/global_types.js.map +1 -0
  39. package/build/esm/packages/phoenix/src/hello_button.js +3 -2
  40. package/build/esm/packages/phoenix/src/hello_button.js.map +1 -1
  41. package/build/esm/packages/phoenix/src/index.d.ts +1 -0
  42. package/package.json +1 -1
@@ -6,6 +6,7 @@ var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
6
6
  var lit = require('lit');
7
7
  var decorators = require('lit/decorators');
8
8
  var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element.js');
9
+ var phoenix_custom_element = require('../../core/decorators/phoenix_custom_element.js');
9
10
  var portal_constants = require('../portal/portal_constants.js');
10
11
  var modal_constants = require('./modal_constants.js');
11
12
  var ref = require('../../../../../external/lit-html/directives/ref.js');
@@ -58,14 +59,14 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
58
59
  }
59
60
  }
60
61
  };
61
- this._handleCloseFromCloseComponent = (ev) => {
62
+ this._handleCloseFromCloseComponent = async (ev) => {
62
63
  var _a;
63
64
  ev.stopPropagation();
64
65
  if ((_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.contains(ev.target)) {
65
- this.close();
66
+ await this.close();
66
67
  }
67
68
  };
68
- this._bindCloseOnEsc = (ev) => {
69
+ this._bindCloseOnEsc = async (ev) => {
69
70
  ev.stopImmediatePropagation();
70
71
  const $target = ev.target;
71
72
  const closeConditions = [
@@ -78,7 +79,7 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
78
79
  const shouldCloseModal = closeConditions.every((condition) => condition);
79
80
  if (shouldCloseModal) {
80
81
  const [modalToClose] = HModal_1.openModals.slice(-1);
81
- modalToClose === null || modalToClose === void 0 ? void 0 : modalToClose.close();
82
+ await (modalToClose === null || modalToClose === void 0 ? void 0 : modalToClose.close());
82
83
  }
83
84
  };
84
85
  this.hidden = true;
@@ -129,8 +130,6 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
129
130
  return new Promise((resolve) => {
130
131
  var _a;
131
132
  if (!this[modal_constants.MODAL_OPENED_PROP]) {
132
- this[modal_constants.MODAL_OPENED_PROP] = true;
133
- this._dispatchModalOpenedEvent();
134
133
  (_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.classList.add(`modal_visible`, `modal_show-${this.transition}-start`);
135
134
  window.requestAnimationFrame(() => {
136
135
  setTimeout(() => {
@@ -140,6 +139,8 @@ exports.HModal = HModal_1 = class HModal extends phoenix_light_lit_element.Phoen
140
139
  const transitionDuration = parseFloat(getComputedStyle(this._contentRef.value || this).transitionDuration) * 1000;
141
140
  setTimeout(() => {
142
141
  var _a;
142
+ this[modal_constants.MODAL_OPENED_PROP] = true;
143
+ this._dispatchModalOpenedEvent();
143
144
  (_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.classList.remove(`modal_show-${this.transition}-start`, `modal_show-${this.transition}-end`);
144
145
  resolve();
145
146
  }, transitionDuration);
@@ -220,7 +221,7 @@ tslib_es6.__decorate([
220
221
  tslib_es6.__metadata("design:type", Object)
221
222
  ], exports.HModal.prototype, "_lastFocusableElement", void 0);
222
223
  exports.HModal = HModal_1 = tslib_es6.__decorate([
223
- decorators.customElement('h-modal'),
224
+ phoenix_custom_element.phoenixCustomElement('h-modal'),
224
225
  tslib_es6.__metadata("design:paramtypes", [])
225
226
  ], exports.HModal);
226
227
  //# sourceMappingURL=modal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA,kBAAkB,oDAAwD;AAC1E;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;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;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;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,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,oDAAwD;AAC1E;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;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;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;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;"}
@@ -6,6 +6,7 @@ var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
6
6
  var lit = require('lit');
7
7
  var decorators = require('lit/decorators');
8
8
  var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element.js');
9
+ var phoenix_custom_element = require('../../core/decorators/phoenix_custom_element.js');
9
10
  var modal_constants = require('./modal_constants.js');
10
11
  var modal = require('./modal.js');
11
12
 
@@ -52,7 +53,7 @@ exports.HModalBackdrop = class HModalBackdrop extends phoenix_light_lit_element.
52
53
  document.body.style.removeProperty('padding-right');
53
54
  }
54
55
  render() {
55
- return lit.html `<div aria-hidden="true" ?hidden="${!this.visible}" class="modal-backdrop"></div>`;
56
+ return lit.html ` <div aria-hidden="true" ?hidden="${!this.visible}" class="modal-backdrop"></div>`;
56
57
  }
57
58
  };
58
59
  tslib_es6.__decorate([
@@ -60,6 +61,6 @@ tslib_es6.__decorate([
60
61
  tslib_es6.__metadata("design:type", Object)
61
62
  ], exports.HModalBackdrop.prototype, "visible", void 0);
62
63
  exports.HModalBackdrop = tslib_es6.__decorate([
63
- decorators.customElement('h-modal-backdrop')
64
+ phoenix_custom_element.phoenixCustomElement('h-modal-backdrop')
64
65
  ], exports.HModalBackdrop);
65
66
  //# sourceMappingURL=modal_backdrop.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;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;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;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;AACA;AACA;AACA;"}
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
6
- var decorators = require('lit/decorators');
7
6
  var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element.js');
7
+ var phoenix_custom_element = require('../../core/decorators/phoenix_custom_element.js');
8
8
 
9
9
  exports.HModalBody = class HModalBody extends phoenix_light_lit_element.PhoenixLightLitElement {
10
10
  constructor() {
@@ -14,7 +14,7 @@ exports.HModalBody = class HModalBody extends phoenix_light_lit_element.PhoenixL
14
14
  }
15
15
  };
16
16
  exports.HModalBody = tslib_es6.__decorate([
17
- decorators.customElement('h-modal-body'),
17
+ phoenix_custom_element.phoenixCustomElement('h-modal-body'),
18
18
  tslib_es6.__metadata("design:paramtypes", [])
19
19
  ], exports.HModalBody);
20
20
  //# sourceMappingURL=modal_body.js.map
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
6
- var decorators = require('lit/decorators');
7
6
  var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element.js');
7
+ var phoenix_custom_element = require('../../core/decorators/phoenix_custom_element.js');
8
8
  var modal_constants = require('./modal_constants.js');
9
9
 
10
10
  exports.HModalClose = class HModalClose extends phoenix_light_lit_element.PhoenixLightLitElement {
@@ -35,7 +35,7 @@ exports.HModalClose = class HModalClose extends phoenix_light_lit_element.Phoeni
35
35
  }
36
36
  };
37
37
  exports.HModalClose = tslib_es6.__decorate([
38
- decorators.customElement('h-modal-close'),
38
+ phoenix_custom_element.phoenixCustomElement('h-modal-close'),
39
39
  tslib_es6.__metadata("design:paramtypes", [])
40
40
  ], exports.HModalClose);
41
41
  //# sourceMappingURL=modal_close.js.map
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
6
- var decorators = require('lit/decorators');
7
6
  var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element.js');
7
+ var phoenix_custom_element = require('../../core/decorators/phoenix_custom_element.js');
8
8
 
9
9
  exports.HModalFooter = class HModalFooter extends phoenix_light_lit_element.PhoenixLightLitElement {
10
10
  constructor() {
@@ -14,7 +14,7 @@ exports.HModalFooter = class HModalFooter extends phoenix_light_lit_element.Phoe
14
14
  }
15
15
  };
16
16
  exports.HModalFooter = tslib_es6.__decorate([
17
- decorators.customElement('h-modal-footer'),
17
+ phoenix_custom_element.phoenixCustomElement('h-modal-footer'),
18
18
  tslib_es6.__metadata("design:paramtypes", [])
19
19
  ], exports.HModalFooter);
20
20
  //# sourceMappingURL=modal_footer.js.map
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
6
- var decorators = require('lit/decorators');
7
6
  var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element.js');
7
+ var phoenix_custom_element = require('../../core/decorators/phoenix_custom_element.js');
8
8
 
9
9
  exports.HModalHeader = class HModalHeader extends phoenix_light_lit_element.PhoenixLightLitElement {
10
10
  constructor() {
@@ -14,7 +14,7 @@ exports.HModalHeader = class HModalHeader extends phoenix_light_lit_element.Phoe
14
14
  }
15
15
  };
16
16
  exports.HModalHeader = tslib_es6.__decorate([
17
- decorators.customElement('h-modal-header'),
17
+ phoenix_custom_element.phoenixCustomElement('h-modal-header'),
18
18
  tslib_es6.__metadata("design:paramtypes", [])
19
19
  ], exports.HModalHeader);
20
20
  //# sourceMappingURL=modal_header.js.map
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
6
6
  var decorators = require('lit/decorators');
7
7
  var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element.js');
8
+ var phoenix_custom_element = require('../../core/decorators/phoenix_custom_element.js');
8
9
 
9
10
  exports.HModalOpener = class HModalOpener extends phoenix_light_lit_element.PhoenixLightLitElement {
10
11
  constructor() {
@@ -37,7 +38,7 @@ tslib_es6.__decorate([
37
38
  tslib_es6.__metadata("design:type", Object)
38
39
  ], exports.HModalOpener.prototype, "name", void 0);
39
40
  exports.HModalOpener = tslib_es6.__decorate([
40
- decorators.customElement('h-modal-opener'),
41
+ phoenix_custom_element.phoenixCustomElement('h-modal-opener'),
41
42
  tslib_es6.__metadata("design:paramtypes", [])
42
43
  ], exports.HModalOpener);
43
44
  //# sourceMappingURL=modal_opener.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;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,4CAAgD;AACxE;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 decorators = require('lit/decorators');
7
7
  var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element.js');
8
+ var phoenix_custom_element = require('../../core/decorators/phoenix_custom_element.js');
8
9
  var portal_constants = require('./portal_constants.js');
9
10
  var v4 = require('../../../../../external/uuid/dist/esm-browser/v4.js');
10
11
 
@@ -79,7 +80,7 @@ tslib_es6.__decorate([
79
80
  tslib_es6.__metadata("design:type", Object)
80
81
  ], exports.HPortal.prototype, "disabled", void 0);
81
82
  exports.HPortal = tslib_es6.__decorate([
82
- decorators.customElement('h-portal'),
83
+ phoenix_custom_element.phoenixCustomElement('h-portal'),
83
84
  tslib_es6.__metadata("design:paramtypes", [])
84
85
  ], exports.HPortal);
85
86
  //# sourceMappingURL=portal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA,iBAAiB,qDAAyD;AAC1E;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;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,4CAAgD;AACxE;AACA;AACA;AACA;AACA,iBAAiB,qDAAyD;AAC1E;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;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 decorators = require('lit/decorators');
7
7
  var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element.js');
8
+ var phoenix_custom_element = require('../../core/decorators/phoenix_custom_element.js');
8
9
  var portal_target_error = require('./portal_target_error.js');
9
10
  var portal_constants = require('./portal_constants.js');
10
11
 
@@ -71,6 +72,6 @@ tslib_es6.__decorate([
71
72
  tslib_es6.__metadata("design:type", Object)
72
73
  ], exports.HPortalTarget.prototype, "_portalElementsMap", void 0);
73
74
  exports.HPortalTarget = HPortalTarget_1 = tslib_es6.__decorate([
74
- decorators.customElement('h-portal-target')
75
+ phoenix_custom_element.phoenixCustomElement('h-portal-target')
75
76
  ], exports.HPortalTarget);
76
77
  //# sourceMappingURL=portal_target.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;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;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,4CAAgD;AACxE;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -0,0 +1,58 @@
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
+ // Cast as any because TS doesn't recognize the return type as being a
10
+ // subtype of the decorated class when clazz is typed as
11
+ // `Constructor<HTMLElement>` for some reason.
12
+ // `Constructor<HTMLElement>` is helpful to make sure the decorator is
13
+ // applied to elements however.
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ defineComponent(tagName, clazz);
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
+ defineComponent(tagName, clazz);
28
+ }
29
+ };
30
+ };
31
+ /**
32
+ * Class decorator factory that defines the decorated class as a custom element.
33
+ *
34
+ * ```js
35
+ * @phoenixCustomElement('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
+ 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
+ };
56
+
57
+ exports.phoenixCustomElement = phoenixCustomElement;
58
+ //# 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;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;"}
@@ -1,7 +1,8 @@
1
1
  import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
2
2
  import { html } from 'lit';
3
- import { property, state, customElement } from 'lit/decorators';
3
+ import { property, state } from 'lit/decorators';
4
4
  import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element.js';
5
+ import { phoenixCustomElement } from '../../core/decorators/phoenix_custom_element.js';
5
6
  import { PORTAL_TARGET_NAME_PROP } from '../portal/portal_constants.js';
6
7
  import { MODAL_OPENED_PROP, FOCUSABLE_ELEMENTS_WITHIN_MODAL, MODALS_PORTAL_NAME, MODAL_EVENTS } from './modal_constants.js';
7
8
  import { createRef as e, ref as n } from '../../../../../external/lit-html/directives/ref.js';
@@ -54,14 +55,14 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
54
55
  }
55
56
  }
56
57
  };
57
- this._handleCloseFromCloseComponent = (ev) => {
58
+ this._handleCloseFromCloseComponent = async (ev) => {
58
59
  var _a;
59
60
  ev.stopPropagation();
60
61
  if ((_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.contains(ev.target)) {
61
- this.close();
62
+ await this.close();
62
63
  }
63
64
  };
64
- this._bindCloseOnEsc = (ev) => {
65
+ this._bindCloseOnEsc = async (ev) => {
65
66
  ev.stopImmediatePropagation();
66
67
  const $target = ev.target;
67
68
  const closeConditions = [
@@ -74,7 +75,7 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
74
75
  const shouldCloseModal = closeConditions.every((condition) => condition);
75
76
  if (shouldCloseModal) {
76
77
  const [modalToClose] = HModal_1.openModals.slice(-1);
77
- modalToClose === null || modalToClose === void 0 ? void 0 : modalToClose.close();
78
+ await (modalToClose === null || modalToClose === void 0 ? void 0 : modalToClose.close());
78
79
  }
79
80
  };
80
81
  this.hidden = true;
@@ -125,8 +126,6 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
125
126
  return new Promise((resolve) => {
126
127
  var _a;
127
128
  if (!this[MODAL_OPENED_PROP]) {
128
- this[MODAL_OPENED_PROP] = true;
129
- this._dispatchModalOpenedEvent();
130
129
  (_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.classList.add(`modal_visible`, `modal_show-${this.transition}-start`);
131
130
  window.requestAnimationFrame(() => {
132
131
  setTimeout(() => {
@@ -136,6 +135,8 @@ let HModal = HModal_1 = class HModal extends PhoenixLightLitElement {
136
135
  const transitionDuration = parseFloat(getComputedStyle(this._contentRef.value || this).transitionDuration) * 1000;
137
136
  setTimeout(() => {
138
137
  var _a;
138
+ this[MODAL_OPENED_PROP] = true;
139
+ this._dispatchModalOpenedEvent();
139
140
  (_a = this._contentRef.value) === null || _a === void 0 ? void 0 : _a.classList.remove(`modal_show-${this.transition}-start`, `modal_show-${this.transition}-end`);
140
141
  resolve();
141
142
  }, transitionDuration);
@@ -216,7 +217,7 @@ __decorate([
216
217
  __metadata("design:type", Object)
217
218
  ], HModal.prototype, "_lastFocusableElement", void 0);
218
219
  HModal = HModal_1 = __decorate([
219
- customElement('h-modal'),
220
+ phoenixCustomElement('h-modal'),
220
221
  __metadata("design:paramtypes", [])
221
222
  ], HModal);
222
223
 
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;AACA;AACA;AACA;AACA;AACA,yCAAyC,oDAAwD;AACjG;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;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;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;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,uCAAuC,4CAAgD;AACvF;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,oDAAwD;AACjG;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;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;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;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,7 +1,8 @@
1
1
  import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
2
2
  import { html } from 'lit';
3
- import { property, customElement } from 'lit/decorators';
3
+ import { property } from 'lit/decorators';
4
4
  import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element.js';
5
+ import { phoenixCustomElement } from '../../core/decorators/phoenix_custom_element.js';
5
6
  import { MODAL_EVENTS } from './modal_constants.js';
6
7
  import { HModal } from './modal.js';
7
8
 
@@ -48,7 +49,7 @@ let HModalBackdrop = class HModalBackdrop extends PhoenixLightLitElement {
48
49
  document.body.style.removeProperty('padding-right');
49
50
  }
50
51
  render() {
51
- return html `<div aria-hidden="true" ?hidden="${!this.visible}" class="modal-backdrop"></div>`;
52
+ return html ` <div aria-hidden="true" ?hidden="${!this.visible}" class="modal-backdrop"></div>`;
52
53
  }
53
54
  };
54
55
  __decorate([
@@ -56,7 +57,7 @@ __decorate([
56
57
  __metadata("design:type", Object)
57
58
  ], HModalBackdrop.prototype, "visible", void 0);
58
59
  HModalBackdrop = __decorate([
59
- customElement('h-modal-backdrop')
60
+ phoenixCustomElement('h-modal-backdrop')
60
61
  ], HModalBackdrop);
61
62
 
62
63
  export { HModalBackdrop };
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;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;AACA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;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;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,6 +1,6 @@
1
1
  import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
2
- import { customElement } from 'lit/decorators';
3
2
  import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element.js';
3
+ import { phoenixCustomElement } from '../../core/decorators/phoenix_custom_element.js';
4
4
 
5
5
  let HModalBody = class HModalBody extends PhoenixLightLitElement {
6
6
  constructor() {
@@ -10,7 +10,7 @@ let HModalBody = class HModalBody extends PhoenixLightLitElement {
10
10
  }
11
11
  };
12
12
  HModalBody = __decorate([
13
- customElement('h-modal-body'),
13
+ phoenixCustomElement('h-modal-body'),
14
14
  __metadata("design:paramtypes", [])
15
15
  ], HModalBody);
16
16
 
@@ -1,6 +1,6 @@
1
1
  import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
2
- import { customElement } from 'lit/decorators';
3
2
  import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element.js';
3
+ import { phoenixCustomElement } from '../../core/decorators/phoenix_custom_element.js';
4
4
  import { MODAL_EVENTS } from './modal_constants.js';
5
5
 
6
6
  let HModalClose = class HModalClose extends PhoenixLightLitElement {
@@ -31,7 +31,7 @@ let HModalClose = class HModalClose extends PhoenixLightLitElement {
31
31
  }
32
32
  };
33
33
  HModalClose = __decorate([
34
- customElement('h-modal-close'),
34
+ phoenixCustomElement('h-modal-close'),
35
35
  __metadata("design:paramtypes", [])
36
36
  ], HModalClose);
37
37
 
@@ -1,6 +1,6 @@
1
1
  import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
2
- import { customElement } from 'lit/decorators';
3
2
  import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element.js';
3
+ import { phoenixCustomElement } from '../../core/decorators/phoenix_custom_element.js';
4
4
 
5
5
  let HModalFooter = class HModalFooter extends PhoenixLightLitElement {
6
6
  constructor() {
@@ -10,7 +10,7 @@ let HModalFooter = class HModalFooter extends PhoenixLightLitElement {
10
10
  }
11
11
  };
12
12
  HModalFooter = __decorate([
13
- customElement('h-modal-footer'),
13
+ phoenixCustomElement('h-modal-footer'),
14
14
  __metadata("design:paramtypes", [])
15
15
  ], HModalFooter);
16
16
 
@@ -1,6 +1,6 @@
1
1
  import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
2
- import { customElement } from 'lit/decorators';
3
2
  import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element.js';
3
+ import { phoenixCustomElement } from '../../core/decorators/phoenix_custom_element.js';
4
4
 
5
5
  let HModalHeader = class HModalHeader extends PhoenixLightLitElement {
6
6
  constructor() {
@@ -10,7 +10,7 @@ let HModalHeader = class HModalHeader extends PhoenixLightLitElement {
10
10
  }
11
11
  };
12
12
  HModalHeader = __decorate([
13
- customElement('h-modal-header'),
13
+ phoenixCustomElement('h-modal-header'),
14
14
  __metadata("design:paramtypes", [])
15
15
  ], HModalHeader);
16
16
 
@@ -1,6 +1,7 @@
1
1
  import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
2
- import { property, customElement } from 'lit/decorators';
2
+ import { property } from 'lit/decorators';
3
3
  import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element.js';
4
+ import { phoenixCustomElement } from '../../core/decorators/phoenix_custom_element.js';
4
5
 
5
6
  let HModalOpener = class HModalOpener extends PhoenixLightLitElement {
6
7
  constructor() {
@@ -33,7 +34,7 @@ __decorate([
33
34
  __metadata("design:type", Object)
34
35
  ], HModalOpener.prototype, "name", void 0);
35
36
  HModalOpener = __decorate([
36
- customElement('h-modal-opener'),
37
+ phoenixCustomElement('h-modal-opener'),
37
38
  __metadata("design:paramtypes", [])
38
39
  ], HModalOpener);
39
40
 
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;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,4CAAgD;AACvF;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,6 +1,7 @@
1
1
  import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
2
- import { state, property, customElement } from 'lit/decorators';
2
+ import { state, property } from 'lit/decorators';
3
3
  import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element.js';
4
+ import { phoenixCustomElement } from '../../core/decorators/phoenix_custom_element.js';
4
5
  import { PORTAL_EVENTS } from './portal_constants.js';
5
6
  import v4 from '../../../../../external/uuid/dist/esm-browser/v4.js';
6
7
 
@@ -75,7 +76,7 @@ __decorate([
75
76
  __metadata("design:type", Object)
76
77
  ], HPortal.prototype, "disabled", void 0);
77
78
  HPortal = __decorate([
78
- customElement('h-portal'),
79
+ phoenixCustomElement('h-portal'),
79
80
  __metadata("design:paramtypes", [])
80
81
  ], HPortal);
81
82
 
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;AACA;AACA;AACA,eAAe,qDAAyD;AACxE;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;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,4CAAgD;AACvF;AACA;AACA;AACA;AACA,eAAe,qDAAyD;AACxE;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,6 +1,7 @@
1
1
  import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
2
- import { property, state, customElement } from 'lit/decorators';
2
+ import { property, state } from 'lit/decorators';
3
3
  import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element.js';
4
+ import { phoenixCustomElement } from '../../core/decorators/phoenix_custom_element.js';
4
5
  import { PortalTargetError } from './portal_target_error.js';
5
6
  import { PORTAL_EVENTS, PORTAL_TARGET_NAME_PROP } from './portal_constants.js';
6
7
 
@@ -67,7 +68,7 @@ __decorate([
67
68
  __metadata("design:type", Object)
68
69
  ], HPortalTarget.prototype, "_portalElementsMap", void 0);
69
70
  HPortalTarget = HPortalTarget_1 = __decorate([
70
- customElement('h-portal-target')
71
+ phoenixCustomElement('h-portal-target')
71
72
  ], HPortalTarget);
72
73
 
73
74
  export { HPortalTarget };
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,4CAAgD;AACvF;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;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,4CAAgD;AACvF;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Allow for custom element classes with private constructors
3
+ */
4
+ import { ClassDescriptor, IPhoenixWebComponentClass } from "../../global_types";
5
+ declare type CustomElementClass = Omit<typeof HTMLElement, 'new'> & IPhoenixWebComponentClass;
6
+ /**
7
+ * Class decorator factory that defines the decorated class as a custom element.
8
+ *
9
+ * ```js
10
+ * @phoenixCustomElement('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,54 @@
1
+ /**
2
+ * Allow for custom element classes with private constructors
3
+ */
4
+ const legacyCustomElement = (tagName, clazz) => {
5
+ // Cast as any because TS doesn't recognize the return type as being a
6
+ // subtype of the decorated class when clazz is typed as
7
+ // `Constructor<HTMLElement>` for some reason.
8
+ // `Constructor<HTMLElement>` is helpful to make sure the decorator is
9
+ // applied to elements however.
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ defineComponent(tagName, clazz);
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
+ defineComponent(tagName, clazz);
24
+ }
25
+ };
26
+ };
27
+ /**
28
+ * Class decorator factory that defines the decorated class as a custom element.
29
+ *
30
+ * ```js
31
+ * @phoenixCustomElement('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
+ 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
+ };
52
+
53
+ export { phoenixCustomElement };
54
+ //# 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;AACA;AACA;AACA;AACA;"}
@@ -0,0 +1,25 @@
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 IPhoenixWebComponentClass {
19
+ __componentName__?: string;
20
+ }
21
+ declare global {
22
+ interface Window {
23
+ __debug_mode__?: boolean;
24
+ }
25
+ }
@@ -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 { IPhoenixWebComponentClass } 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";
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.5.0",
5
+ "version": "0.5.1",
6
6
  "description": "phoenix design system",
7
7
  "author": "zefirek",
8
8
  "license": "MIT",