@shoper/phoenix_design_system 0.1.3 → 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.
Files changed (56) hide show
  1. package/build/cjs/external/uuid/dist/esm-browser/regex.js +8 -0
  2. package/build/cjs/external/uuid/dist/esm-browser/regex.js.map +1 -0
  3. package/build/cjs/external/uuid/dist/esm-browser/rng.js +26 -0
  4. package/build/cjs/external/uuid/dist/esm-browser/rng.js.map +1 -0
  5. package/build/cjs/external/uuid/dist/esm-browser/stringify.js +36 -0
  6. package/build/cjs/external/uuid/dist/esm-browser/stringify.js.map +1 -0
  7. package/build/cjs/external/uuid/dist/esm-browser/v4.js +29 -0
  8. package/build/cjs/external/uuid/dist/esm-browser/v4.js.map +1 -0
  9. package/build/cjs/external/uuid/dist/esm-browser/validate.js +12 -0
  10. package/build/cjs/external/uuid/dist/esm-browser/validate.js.map +1 -0
  11. package/build/cjs/packages/phoenix/src/components/portal/portal.js +80 -0
  12. package/build/cjs/packages/phoenix/src/components/portal/portal.js.map +1 -0
  13. package/build/cjs/packages/phoenix/src/components/portal/portal_constants.js +11 -0
  14. package/build/cjs/packages/phoenix/src/components/portal/portal_constants.js.map +1 -0
  15. package/build/cjs/packages/phoenix/src/components/portal/portal_target.js +76 -0
  16. package/build/cjs/packages/phoenix/src/components/portal/portal_target.js.map +1 -0
  17. package/build/cjs/packages/phoenix/src/components/portal/portal_target_error.js +9 -0
  18. package/build/cjs/packages/phoenix/src/components/portal/portal_target_error.js.map +1 -0
  19. package/build/cjs/packages/phoenix/src/{core/hello_button.js → hello_button.js} +1 -1
  20. package/build/cjs/packages/phoenix/src/{core/hello_button.js.map → hello_button.js.map} +1 -1
  21. package/build/cjs/packages/phoenix/src/index.js +15 -1
  22. package/build/cjs/packages/phoenix/src/index.js.map +1 -1
  23. package/build/cjs/packages/star_core/build/esm/external/tslib/tslib.es6.js +1 -1
  24. package/build/esm/external/uuid/dist/esm-browser/regex.js +4 -0
  25. package/build/esm/external/uuid/dist/esm-browser/regex.js.map +1 -0
  26. package/build/esm/external/uuid/dist/esm-browser/rng.js +22 -0
  27. package/build/esm/external/uuid/dist/esm-browser/rng.js.map +1 -0
  28. package/build/esm/external/uuid/dist/esm-browser/stringify.js +32 -0
  29. package/build/esm/external/uuid/dist/esm-browser/stringify.js.map +1 -0
  30. package/build/esm/external/uuid/dist/esm-browser/v4.js +25 -0
  31. package/build/esm/external/uuid/dist/esm-browser/v4.js.map +1 -0
  32. package/build/esm/external/uuid/dist/esm-browser/validate.js +8 -0
  33. package/build/esm/external/uuid/dist/esm-browser/validate.js.map +1 -0
  34. package/build/esm/packages/phoenix/src/components/portal/portal.d.ts +13 -0
  35. package/build/esm/packages/phoenix/src/components/portal/portal.js +78 -0
  36. package/build/esm/packages/phoenix/src/components/portal/portal.js.map +1 -0
  37. package/build/esm/packages/phoenix/src/components/portal/portal_constants.d.ts +10 -0
  38. package/build/esm/packages/phoenix/src/components/portal/portal_constants.js +7 -0
  39. package/build/esm/packages/phoenix/src/components/portal/portal_constants.js.map +1 -0
  40. package/build/esm/packages/phoenix/src/components/portal/portal_target.d.ts +13 -0
  41. package/build/esm/packages/phoenix/src/components/portal/portal_target.js +74 -0
  42. package/build/esm/packages/phoenix/src/components/portal/portal_target.js.map +1 -0
  43. package/build/esm/packages/phoenix/src/components/portal/portal_target_error.d.ts +2 -0
  44. package/build/esm/packages/phoenix/src/components/portal/portal_target_error.js +5 -0
  45. package/build/esm/packages/phoenix/src/components/portal/portal_target_error.js.map +1 -0
  46. package/build/esm/packages/phoenix/src/components/portal/portal_types.d.ts +5 -0
  47. package/build/esm/packages/phoenix/src/components/portal/portal_types.js +2 -0
  48. package/build/esm/packages/phoenix/src/components/portal/portal_types.js.map +1 -0
  49. package/build/esm/packages/phoenix/src/{core/hello_button.d.ts → hello_button.d.ts} +0 -0
  50. package/build/esm/packages/phoenix/src/{core/hello_button.js → hello_button.js} +1 -1
  51. package/build/esm/packages/phoenix/src/{core/hello_button.js.map → hello_button.js.map} +1 -1
  52. package/build/esm/packages/phoenix/src/index.d.ts +3 -1
  53. package/build/esm/packages/phoenix/src/index.js +3 -1
  54. package/build/esm/packages/phoenix/src/index.js.map +1 -1
  55. package/build/esm/packages/star_core/build/esm/external/tslib/tslib.es6.js +1 -1
  56. package/package.json +1 -1
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
6
+
7
+ exports.default = REGEX;
8
+ //# sourceMappingURL=regex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
6
+ // require the crypto API and do not support built-in fallback to lower quality random number
7
+ // generators (like Math.random()).
8
+ var getRandomValues;
9
+ var rnds8 = new Uint8Array(16);
10
+ function rng() {
11
+ // lazy load so that environments that need to polyfill have a chance to do so
12
+ if (!getRandomValues) {
13
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
14
+ // find the complete implementation of crypto (msCrypto) on IE11.
15
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
16
+
17
+ if (!getRandomValues) {
18
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
19
+ }
20
+ }
21
+
22
+ return getRandomValues(rnds8);
23
+ }
24
+
25
+ exports.default = rng;
26
+ //# sourceMappingURL=rng.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;"}
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var validate = require('./validate.js');
6
+
7
+ /**
8
+ * Convert array of 16 byte values to UUID string format of the form:
9
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
10
+ */
11
+
12
+ var byteToHex = [];
13
+
14
+ for (var i = 0; i < 256; ++i) {
15
+ byteToHex.push((i + 0x100).toString(16).substr(1));
16
+ }
17
+
18
+ function stringify(arr) {
19
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
20
+ // Note: Be careful editing this code! It's been tuned for performance
21
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
22
+ var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
23
+ // of the following:
24
+ // - One or more input array values don't map to a hex octet (leading to
25
+ // "undefined" in the uuid)
26
+ // - Invalid input values for the RFC `version` or `variant` fields
27
+
28
+ if (!validate['default'](uuid)) {
29
+ throw TypeError('Stringified UUID is invalid');
30
+ }
31
+
32
+ return uuid;
33
+ }
34
+
35
+ exports.default = stringify;
36
+ //# sourceMappingURL=stringify.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;"}
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var rng = require('./rng.js');
6
+ var stringify = require('./stringify.js');
7
+
8
+ function v4(options, buf, offset) {
9
+ options = options || {};
10
+ var rnds = options.random || (options.rng || rng['default'])(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
11
+
12
+ rnds[6] = rnds[6] & 0x0f | 0x40;
13
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
14
+
15
+ if (buf) {
16
+ offset = offset || 0;
17
+
18
+ for (var i = 0; i < 16; ++i) {
19
+ buf[offset + i] = rnds[i];
20
+ }
21
+
22
+ return buf;
23
+ }
24
+
25
+ return stringify['default'](rnds);
26
+ }
27
+
28
+ exports.default = v4;
29
+ //# sourceMappingURL=v4.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;"}
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var regex = require('./regex.js');
6
+
7
+ function validate(uuid) {
8
+ return typeof uuid === 'string' && regex['default'].test(uuid);
9
+ }
10
+
11
+ exports.default = validate;
12
+ //# sourceMappingURL=validate.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;"}
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
6
+ var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element.js');
7
+ var decorators = require('lit/decorators');
8
+ var portal_constants = require('./portal_constants.js');
9
+ var v4 = require('../../../../../external/uuid/dist/esm-browser/v4.js');
10
+
11
+ exports.HPortal = class HPortal extends phoenix_light_lit_element.PhoenixLightLitElement {
12
+ constructor() {
13
+ super();
14
+ this._id = v4['default']();
15
+ this._initialChildren = [];
16
+ this.to = '';
17
+ this.disabled = false;
18
+ this._initialChildren = [...this.children];
19
+ }
20
+ firstUpdated() {
21
+ const shouldOpenPortal = this._initialChildren.length > 0 && !this.disabled;
22
+ if (shouldOpenPortal) {
23
+ this.openPortal();
24
+ }
25
+ }
26
+ updated(changedProps) {
27
+ const disabledValue = changedProps.get('disabled');
28
+ if (disabledValue === true) {
29
+ this.closePortal();
30
+ }
31
+ else if (disabledValue === false) {
32
+ this.openPortal();
33
+ }
34
+ }
35
+ disconnectedCallback() {
36
+ this.closePortal();
37
+ }
38
+ openPortal() {
39
+ const openPortalEvent = new CustomEvent(portal_constants.PORTAL_EVENTS.open, {
40
+ composed: true,
41
+ detail: {
42
+ portalId: this._id,
43
+ to: this.to,
44
+ content: [...this._initialChildren]
45
+ }
46
+ });
47
+ document.dispatchEvent(openPortalEvent);
48
+ }
49
+ closePortal() {
50
+ const closePortalEvent = new CustomEvent(portal_constants.PORTAL_EVENTS.close, {
51
+ composed: true,
52
+ detail: {
53
+ portalId: this._id,
54
+ to: this.to
55
+ }
56
+ });
57
+ document.dispatchEvent(closePortalEvent);
58
+ }
59
+ };
60
+ tslib_es6.__decorate([
61
+ decorators.state(),
62
+ tslib_es6.__metadata("design:type", Object)
63
+ ], exports.HPortal.prototype, "_id", void 0);
64
+ tslib_es6.__decorate([
65
+ decorators.state(),
66
+ tslib_es6.__metadata("design:type", Array)
67
+ ], exports.HPortal.prototype, "_initialChildren", void 0);
68
+ tslib_es6.__decorate([
69
+ decorators.property({ type: String }),
70
+ tslib_es6.__metadata("design:type", Object)
71
+ ], exports.HPortal.prototype, "to", void 0);
72
+ tslib_es6.__decorate([
73
+ decorators.property({ type: Boolean }),
74
+ tslib_es6.__metadata("design:type", Object)
75
+ ], exports.HPortal.prototype, "disabled", void 0);
76
+ exports.HPortal = tslib_es6.__decorate([
77
+ decorators.customElement('h-portal'),
78
+ tslib_es6.__metadata("design:paramtypes", [])
79
+ ], exports.HPortal);
80
+ //# sourceMappingURL=portal.js.map
@@ -0,0 +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;"}
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const PORTAL_EVENTS = {
6
+ open: `portal.open`,
7
+ close: 'portal.close'
8
+ };
9
+
10
+ exports.PORTAL_EVENTS = PORTAL_EVENTS;
11
+ //# sourceMappingURL=portal_constants.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;"}
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
6
+ var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element.js');
7
+ var decorators = require('lit/decorators');
8
+ var portal_constants = require('./portal_constants.js');
9
+ var portal_target_error = require('./portal_target_error.js');
10
+
11
+ var HPortalTarget_1;
12
+ exports.HPortalTarget = HPortalTarget_1 = class HPortalTarget extends phoenix_light_lit_element.PhoenixLightLitElement {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.name = '';
16
+ this._portalElementsMap = {};
17
+ this.portalElements = ({ detail: { portalId, content, to } }) => {
18
+ var _a;
19
+ if (!this.doesDestinationMatch(to))
20
+ return;
21
+ const newPortalElements = [...content].map((el) => this.appendChild(el));
22
+ const elementsInProtal = (_a = this._portalElementsMap[portalId]) !== null && _a !== void 0 ? _a : [];
23
+ this._portalElementsMap[portalId] = [...newPortalElements, ...elementsInProtal];
24
+ };
25
+ this.removeTeleportedItems = ({ detail: { portalId, to } }) => {
26
+ var _a;
27
+ if (!this.doesDestinationMatch(to))
28
+ return;
29
+ (_a = this._portalElementsMap[portalId]) === null || _a === void 0 ? void 0 : _a.forEach((el) => {
30
+ if (el.parentElement === this) {
31
+ this.removeChild(el);
32
+ }
33
+ });
34
+ this._portalElementsMap[portalId] = [];
35
+ };
36
+ }
37
+ connectedCallback() {
38
+ super.connectedCallback();
39
+ this.allowOnlyOnePortalTargetWithName();
40
+ document.addEventListener(portal_constants.PORTAL_EVENTS.open, this.portalElements, {
41
+ capture: true
42
+ });
43
+ document.addEventListener(portal_constants.PORTAL_EVENTS.close, this.removeTeleportedItems, {
44
+ capture: true
45
+ });
46
+ }
47
+ disconnectedCallback() {
48
+ super.disconnectedCallback();
49
+ document.removeEventListener(portal_constants.PORTAL_EVENTS.open, this.portalElements);
50
+ document.removeEventListener(portal_constants.PORTAL_EVENTS.close, this.removeTeleportedItems);
51
+ HPortalTarget_1.portalTargetsNames.delete(this.name);
52
+ }
53
+ doesDestinationMatch(destination) {
54
+ return destination === this.name;
55
+ }
56
+ allowOnlyOnePortalTargetWithName() {
57
+ if (HPortalTarget_1.portalTargetsNames.has(this.name)) {
58
+ this.remove();
59
+ throw new portal_target_error.PortalTargetError(`Portal target with name "${this.name}" already exists.`);
60
+ }
61
+ HPortalTarget_1.portalTargetsNames.add(this.name);
62
+ }
63
+ };
64
+ exports.HPortalTarget.portalTargetsNames = new Set();
65
+ tslib_es6.__decorate([
66
+ decorators.property({ type: String }),
67
+ tslib_es6.__metadata("design:type", Object)
68
+ ], exports.HPortalTarget.prototype, "name", void 0);
69
+ tslib_es6.__decorate([
70
+ decorators.state(),
71
+ tslib_es6.__metadata("design:type", Object)
72
+ ], exports.HPortalTarget.prototype, "_portalElementsMap", void 0);
73
+ exports.HPortalTarget = HPortalTarget_1 = tslib_es6.__decorate([
74
+ decorators.customElement('h-portal-target')
75
+ ], exports.HPortalTarget);
76
+ //# sourceMappingURL=portal_target.js.map
@@ -0,0 +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;"}
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ class PortalTargetError extends Error {
6
+ }
7
+
8
+ exports.PortalTargetError = PortalTargetError;
9
+ //# sourceMappingURL=portal_target_error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib_es6 = require('../../../../external/tslib/tslib.es6.js');
5
+ var tslib_es6 = require('../../../external/tslib/tslib.es6.js');
6
6
  var lit = require('lit');
7
7
  var decorators = require('lit/decorators');
8
8
 
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,yCAA6C;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;"}
@@ -5,7 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var context_provider_controller = require('./core/context/context_provider_controller.js');
6
6
  var context_consumer_controller = require('./core/context/context_consumer_controller.js');
7
7
  var phoenix_light_lit_element = require('./core/phoenix_light_lit_element.js');
8
- var hello_button = require('./core/hello_button.js');
8
+ var hello_button = require('./hello_button.js');
9
+ var portal = require('./components/portal/portal.js');
10
+ var portal_target = require('./components/portal/portal_target.js');
9
11
 
10
12
 
11
13
 
@@ -18,4 +20,16 @@ Object.defineProperty(exports, 'HelloButton', {
18
20
  return hello_button.HelloButton;
19
21
  }
20
22
  });
23
+ Object.defineProperty(exports, 'HPortal', {
24
+ enumerable: true,
25
+ get: function () {
26
+ return portal.HPortal;
27
+ }
28
+ });
29
+ Object.defineProperty(exports, 'HPortalTarget', {
30
+ enumerable: true,
31
+ get: function () {
32
+ return portal_target.HPortalTarget;
33
+ }
34
+ });
21
35
  //# sourceMappingURL=index.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;"}
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;"}
@@ -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,4 @@
1
+ var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
2
+
3
+ export default REGEX;
4
+ //# sourceMappingURL=regex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;"}
@@ -0,0 +1,22 @@
1
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
2
+ // require the crypto API and do not support built-in fallback to lower quality random number
3
+ // generators (like Math.random()).
4
+ var getRandomValues;
5
+ var rnds8 = new Uint8Array(16);
6
+ function rng() {
7
+ // lazy load so that environments that need to polyfill have a chance to do so
8
+ if (!getRandomValues) {
9
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
10
+ // find the complete implementation of crypto (msCrypto) on IE11.
11
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
12
+
13
+ if (!getRandomValues) {
14
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
15
+ }
16
+ }
17
+
18
+ return getRandomValues(rnds8);
19
+ }
20
+
21
+ export default rng;
22
+ //# sourceMappingURL=rng.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;"}
@@ -0,0 +1,32 @@
1
+ import validate from './validate.js';
2
+
3
+ /**
4
+ * Convert array of 16 byte values to UUID string format of the form:
5
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
6
+ */
7
+
8
+ var byteToHex = [];
9
+
10
+ for (var i = 0; i < 256; ++i) {
11
+ byteToHex.push((i + 0x100).toString(16).substr(1));
12
+ }
13
+
14
+ function stringify(arr) {
15
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
16
+ // Note: Be careful editing this code! It's been tuned for performance
17
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
18
+ var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
19
+ // of the following:
20
+ // - One or more input array values don't map to a hex octet (leading to
21
+ // "undefined" in the uuid)
22
+ // - Invalid input values for the RFC `version` or `variant` fields
23
+
24
+ if (!validate(uuid)) {
25
+ throw TypeError('Stringified UUID is invalid');
26
+ }
27
+
28
+ return uuid;
29
+ }
30
+
31
+ export default stringify;
32
+ //# sourceMappingURL=stringify.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;"}
@@ -0,0 +1,25 @@
1
+ import rng from './rng.js';
2
+ import stringify from './stringify.js';
3
+
4
+ function v4(options, buf, offset) {
5
+ options = options || {};
6
+ var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
7
+
8
+ rnds[6] = rnds[6] & 0x0f | 0x40;
9
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
10
+
11
+ if (buf) {
12
+ offset = offset || 0;
13
+
14
+ for (var i = 0; i < 16; ++i) {
15
+ buf[offset + i] = rnds[i];
16
+ }
17
+
18
+ return buf;
19
+ }
20
+
21
+ return stringify(rnds);
22
+ }
23
+
24
+ export default v4;
25
+ //# sourceMappingURL=v4.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;"}
@@ -0,0 +1,8 @@
1
+ import REGEX from './regex.js';
2
+
3
+ function validate(uuid) {
4
+ return typeof uuid === 'string' && REGEX.test(uuid);
5
+ }
6
+
7
+ export default validate;
8
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -0,0 +1,13 @@
1
+ import { PhoenixLightLitElement } from "../../core/phoenix_light_lit_element";
2
+ export declare class HPortal extends PhoenixLightLitElement {
3
+ _id: string;
4
+ _initialChildren: Element[];
5
+ to: string;
6
+ disabled: boolean;
7
+ constructor();
8
+ firstUpdated(): void;
9
+ updated(changedProps: Map<string, any>): void;
10
+ disconnectedCallback(): void;
11
+ openPortal(): void;
12
+ closePortal(): void;
13
+ }
@@ -0,0 +1,78 @@
1
+ import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
2
+ import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element.js';
3
+ import { state, property, customElement } from 'lit/decorators';
4
+ import { PORTAL_EVENTS } from './portal_constants.js';
5
+ import v4 from '../../../../../external/uuid/dist/esm-browser/v4.js';
6
+
7
+ let HPortal = class HPortal extends PhoenixLightLitElement {
8
+ constructor() {
9
+ super();
10
+ this._id = v4();
11
+ this._initialChildren = [];
12
+ this.to = '';
13
+ this.disabled = false;
14
+ this._initialChildren = [...this.children];
15
+ }
16
+ firstUpdated() {
17
+ const shouldOpenPortal = this._initialChildren.length > 0 && !this.disabled;
18
+ if (shouldOpenPortal) {
19
+ this.openPortal();
20
+ }
21
+ }
22
+ updated(changedProps) {
23
+ const disabledValue = changedProps.get('disabled');
24
+ if (disabledValue === true) {
25
+ this.closePortal();
26
+ }
27
+ else if (disabledValue === false) {
28
+ this.openPortal();
29
+ }
30
+ }
31
+ disconnectedCallback() {
32
+ this.closePortal();
33
+ }
34
+ openPortal() {
35
+ const openPortalEvent = new CustomEvent(PORTAL_EVENTS.open, {
36
+ composed: true,
37
+ detail: {
38
+ portalId: this._id,
39
+ to: this.to,
40
+ content: [...this._initialChildren]
41
+ }
42
+ });
43
+ document.dispatchEvent(openPortalEvent);
44
+ }
45
+ closePortal() {
46
+ const closePortalEvent = new CustomEvent(PORTAL_EVENTS.close, {
47
+ composed: true,
48
+ detail: {
49
+ portalId: this._id,
50
+ to: this.to
51
+ }
52
+ });
53
+ document.dispatchEvent(closePortalEvent);
54
+ }
55
+ };
56
+ __decorate([
57
+ state(),
58
+ __metadata("design:type", Object)
59
+ ], HPortal.prototype, "_id", void 0);
60
+ __decorate([
61
+ state(),
62
+ __metadata("design:type", Array)
63
+ ], HPortal.prototype, "_initialChildren", void 0);
64
+ __decorate([
65
+ property({ type: String }),
66
+ __metadata("design:type", Object)
67
+ ], HPortal.prototype, "to", void 0);
68
+ __decorate([
69
+ property({ type: Boolean }),
70
+ __metadata("design:type", Object)
71
+ ], HPortal.prototype, "disabled", void 0);
72
+ HPortal = __decorate([
73
+ customElement('h-portal'),
74
+ __metadata("design:paramtypes", [])
75
+ ], HPortal);
76
+
77
+ export { HPortal };
78
+ //# sourceMappingURL=portal.js.map
@@ -0,0 +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;"}
@@ -0,0 +1,10 @@
1
+ import { HPortal } from './portal';
2
+ export declare const PORTAL_EVENTS: {
3
+ open: string;
4
+ close: string;
5
+ };
6
+ declare global {
7
+ interface HTMLElementTagNameMap {
8
+ 'h-portal': HPortal;
9
+ }
10
+ }
@@ -0,0 +1,7 @@
1
+ const PORTAL_EVENTS = {
2
+ open: `portal.open`,
3
+ close: 'portal.close'
4
+ };
5
+
6
+ export { PORTAL_EVENTS };
7
+ //# sourceMappingURL=portal_constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;"}
@@ -0,0 +1,13 @@
1
+ import { PhoenixLightLitElement } from "../../core/phoenix_light_lit_element";
2
+ import { TPortalEventData } from './portal_types';
3
+ export declare class HPortalTarget extends PhoenixLightLitElement {
4
+ static portalTargetsNames: Set<string>;
5
+ name: string;
6
+ _portalElementsMap: Record<string, HTMLElement[]>;
7
+ connectedCallback(): void;
8
+ disconnectedCallback(): void;
9
+ portalElements: ({ detail: { portalId, content, to } }: CustomEvent<TPortalEventData>) => void;
10
+ removeTeleportedItems: ({ detail: { portalId, to } }: CustomEvent<TPortalEventData>) => void;
11
+ doesDestinationMatch(destination: string): boolean;
12
+ allowOnlyOnePortalTargetWithName(): void;
13
+ }
@@ -0,0 +1,74 @@
1
+ import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
2
+ import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element.js';
3
+ import { property, state, customElement } from 'lit/decorators';
4
+ import { PORTAL_EVENTS } from './portal_constants.js';
5
+ import { PortalTargetError } from './portal_target_error.js';
6
+
7
+ var HPortalTarget_1;
8
+ let HPortalTarget = HPortalTarget_1 = class HPortalTarget extends PhoenixLightLitElement {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.name = '';
12
+ this._portalElementsMap = {};
13
+ this.portalElements = ({ detail: { portalId, content, to } }) => {
14
+ var _a;
15
+ if (!this.doesDestinationMatch(to))
16
+ return;
17
+ const newPortalElements = [...content].map((el) => this.appendChild(el));
18
+ const elementsInProtal = (_a = this._portalElementsMap[portalId]) !== null && _a !== void 0 ? _a : [];
19
+ this._portalElementsMap[portalId] = [...newPortalElements, ...elementsInProtal];
20
+ };
21
+ this.removeTeleportedItems = ({ detail: { portalId, to } }) => {
22
+ var _a;
23
+ if (!this.doesDestinationMatch(to))
24
+ return;
25
+ (_a = this._portalElementsMap[portalId]) === null || _a === void 0 ? void 0 : _a.forEach((el) => {
26
+ if (el.parentElement === this) {
27
+ this.removeChild(el);
28
+ }
29
+ });
30
+ this._portalElementsMap[portalId] = [];
31
+ };
32
+ }
33
+ connectedCallback() {
34
+ super.connectedCallback();
35
+ this.allowOnlyOnePortalTargetWithName();
36
+ document.addEventListener(PORTAL_EVENTS.open, this.portalElements, {
37
+ capture: true
38
+ });
39
+ document.addEventListener(PORTAL_EVENTS.close, this.removeTeleportedItems, {
40
+ capture: true
41
+ });
42
+ }
43
+ disconnectedCallback() {
44
+ super.disconnectedCallback();
45
+ document.removeEventListener(PORTAL_EVENTS.open, this.portalElements);
46
+ document.removeEventListener(PORTAL_EVENTS.close, this.removeTeleportedItems);
47
+ HPortalTarget_1.portalTargetsNames.delete(this.name);
48
+ }
49
+ doesDestinationMatch(destination) {
50
+ return destination === this.name;
51
+ }
52
+ allowOnlyOnePortalTargetWithName() {
53
+ if (HPortalTarget_1.portalTargetsNames.has(this.name)) {
54
+ this.remove();
55
+ throw new PortalTargetError(`Portal target with name "${this.name}" already exists.`);
56
+ }
57
+ HPortalTarget_1.portalTargetsNames.add(this.name);
58
+ }
59
+ };
60
+ HPortalTarget.portalTargetsNames = new Set();
61
+ __decorate([
62
+ property({ type: String }),
63
+ __metadata("design:type", Object)
64
+ ], HPortalTarget.prototype, "name", void 0);
65
+ __decorate([
66
+ state(),
67
+ __metadata("design:type", Object)
68
+ ], HPortalTarget.prototype, "_portalElementsMap", void 0);
69
+ HPortalTarget = HPortalTarget_1 = __decorate([
70
+ customElement('h-portal-target')
71
+ ], HPortalTarget);
72
+
73
+ export { HPortalTarget };
74
+ //# sourceMappingURL=portal_target.js.map
@@ -0,0 +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;"}
@@ -0,0 +1,2 @@
1
+ export declare class PortalTargetError extends Error {
2
+ }
@@ -0,0 +1,5 @@
1
+ class PortalTargetError extends Error {
2
+ }
3
+
4
+ export { PortalTargetError };
5
+ //# sourceMappingURL=portal_target_error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;"}
@@ -0,0 +1,5 @@
1
+ export declare type TPortalEventData = {
2
+ portalId: string;
3
+ to: string;
4
+ content: Element[];
5
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=portal_types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal_types.js","sourceRoot":"","sources":["../../../../../../../src/components/portal/portal_types.ts"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import { __decorate, __metadata } from '../../../../external/tslib/tslib.es6.js';
1
+ import { __decorate, __metadata } from '../../../external/tslib/tslib.es6.js';
2
2
  import { LitElement, html, css } from 'lit';
3
3
  import { state, customElement } from 'lit/decorators';
4
4
 
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,yCAA6C;AACpF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;"}
@@ -1,4 +1,6 @@
1
1
  export { ContextProviderController } from "./core/context/context_provider_controller";
2
2
  export { ContextConsumerController } from "./core/context/context_consumer_controller";
3
3
  export { PhoenixLightLitElement } from "./core/phoenix_light_lit_element";
4
- export { HelloButton } from './core/hello_button';
4
+ export { HelloButton } from './hello_button';
5
+ export { HPortal } from './components/portal/portal';
6
+ export { HPortalTarget } from './components/portal/portal_target';
@@ -1,5 +1,7 @@
1
1
  export { ContextProviderController } from './core/context/context_provider_controller.js';
2
2
  export { ContextConsumerController } from './core/context/context_consumer_controller.js';
3
3
  export { PhoenixLightLitElement } from './core/phoenix_light_lit_element.js';
4
- export { HelloButton } from './core/hello_button.js';
4
+ export { HelloButton } from './hello_button.js';
5
+ export { HPortal } from './components/portal/portal.js';
6
+ export { HPortalTarget } from './components/portal/portal_target.js';
5
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;"}
1
+ {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;"}
@@ -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.1.3",
5
+ "version": "0.2.1",
6
6
  "description": "phoenix design system",
7
7
  "author": "zefirek",
8
8
  "license": "MIT",