@muonic/muon 0.0.2-beta.41 → 0.0.2-beta.43

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/.nycrc CHANGED
@@ -7,7 +7,8 @@
7
7
  "exclude": [
8
8
  "**/modular-scale.js",
9
9
  "tests",
10
- "tokens/**/string.js"
10
+ "tokens/**/string.js",
11
+ "js"
11
12
  ],
12
13
  "check-coverage": true,
13
14
  "lines": 99,
package/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.2-beta.43](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.42...v0.0.2-beta.43) (2023-09-07)
6
+
7
+
8
+ ### Features
9
+
10
+ * move registry to internal ([ed355c0](https://github.com/centrica-engineering/muon/commit/ed355c07bbd673f715470a75e44df1636e0035a3))
11
+
12
+ ### [0.0.2-beta.42](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.39...v0.0.2-beta.42) (2023-09-01)
13
+
14
+
15
+ ### Features
16
+
17
+ * bubble the detail toggle event ([9a82a2b](https://github.com/centrica-engineering/muon/commit/9a82a2b35ecd29d9c00d9ae4d68b919ba1188c84))
18
+ * inputter detail max width ([f32f699](https://github.com/centrica-engineering/muon/commit/f32f69945a7210765a70ac8d7f0a5bd868992386))
19
+ * inputter detail width tokens ([c61bc6f](https://github.com/centrica-engineering/muon/commit/c61bc6f782b551229a45024ec984f1b4d07307c7))
20
+ * inputter helper toggle event ([987dd38](https://github.com/centrica-engineering/muon/commit/987dd38fe39192906ae5e813a230342aca599dad))
21
+ * virtual component-export ([5b7190e](https://github.com/centrica-engineering/muon/commit/5b7190ec3e96e5ba5ea228a30ecedb1e9d64ca4d))
22
+
5
23
  ### [0.0.2-beta.41](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.40...v0.0.2-beta.41) (2023-08-23)
6
24
 
7
25
  ### [0.0.2-beta.40](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.10...v0.0.2-beta.40) (2023-08-17)
@@ -0,0 +1,65 @@
1
+ (function () {
2
+ /*
3
+
4
+ Copyright (c) 2020 The Polymer Project Authors. All rights reserved.
5
+ This code may only be used under the BSD style license found at
6
+ http://polymer.github.io/LICENSE.txt
7
+ The complete set of authors may be found at
8
+ http://polymer.github.io/AUTHORS.txt
9
+ The complete set of contributors may be found at
10
+ http://polymer.github.io/CONTRIBUTORS.txt
11
+ Code distributed by Google as part of the polymer project is also
12
+ subject to an additional IP rights grant found at
13
+ http://polymer.github.io/PATENTS.txt
14
+ */
15
+ 'use strict'; function h(b) { var c = 0; return function () { return c < b.length ? { done: !1, value: b[c++] } : { done: !0 } } } function l(b) { var c = "undefined" != typeof Symbol && Symbol.iterator && b[Symbol.iterator]; return c ? c.call(b) : { next: h(b) } } function m(b) { if (!(b instanceof Array)) { b = l(b); for (var c, a = []; !(c = b.next()).done;)a.push(c.value); b = a } return b } var n = "function" == typeof Object.create ? Object.create : function (b) { function c() { } c.prototype = b; return new c };
16
+ function p(b) { b = ["object" == typeof globalThis && globalThis, b, "object" == typeof window && window, "object" == typeof self && self, "object" == typeof global && global]; for (var c = 0; c < b.length; ++c) { var a = b[c]; if (a && a.Math == Math) return a } throw Error("Cannot find global object"); }
17
+ var q = p(this), r = function () { function b() { function a() { } new a; Reflect.construct(a, [], function () { }); return new a instanceof a } if ("undefined" != typeof Reflect && Reflect.construct) { if (b()) return Reflect.construct; var c = Reflect.construct; return function (a, d, e) { a = c(a, d); e && Reflect.setPrototypeOf(a, e.prototype); return a } } return function (a, d, e) { void 0 === e && (e = a); e = n(e.prototype || Object.prototype); return Function.prototype.apply.call(a, e, d) || e } }(), t;
18
+ if ("function" == typeof Object.setPrototypeOf) t = Object.setPrototypeOf; else { var u; a: { var v = { a: !0 }, w = {}; try { w.__proto__ = v; u = w.a; break a } catch (b) { } u = !1 } t = u ? function (b, c) { b.__proto__ = c; if (b.__proto__ !== c) throw new TypeError(b + " is not extensible"); return b } : null } var x = t;
19
+ if (!ShadowRoot.prototype.createElement) {
20
+ var y = window.HTMLElement, A = window.customElements.define, B = window.customElements.get, C = window.customElements, D = new WeakMap, E = new WeakMap, F = new WeakMap, G = new WeakMap; window.CustomElementRegistry = function () { this.l = new Map; this.o = new Map; this.j = new Map; this.h = new Map }; window.CustomElementRegistry.prototype.define = function (b, c) {
21
+ b = b.toLowerCase(); if (void 0 !== this.i(b)) throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': the name \"" + b + '" has already been used with this registry');
22
+ if (void 0 !== this.o.get(c)) throw new DOMException("Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry"); var a = c.prototype.attributeChangedCallback, d = new Set(c.observedAttributes || []); H(c, d, a); a = {
23
+ g: c, connectedCallback: c.prototype.connectedCallback, disconnectedCallback: c.prototype.disconnectedCallback, adoptedCallback: c.prototype.adoptedCallback, attributeChangedCallback: a, formAssociated: c.formAssociated, formAssociatedCallback: c.prototype.formAssociatedCallback,
24
+ formDisabledCallback: c.prototype.formDisabledCallback, formResetCallback: c.prototype.formResetCallback, formStateRestoreCallback: c.prototype.formStateRestoreCallback, observedAttributes: d
25
+ }; this.l.set(b, a); this.o.set(c, a); d = B.call(C, b); d || (d = I(b), A.call(C, b, d)); this === window.customElements && (F.set(c, a), a.s = d); if (d = this.h.get(b)) { this.h.delete(b); d = l(d); for (var e = d.next(); !e.done; e = d.next())e = e.value, E.delete(e), J(e, a, !0) } a = this.j.get(b); void 0 !== a && (a.resolve(c), this.j.delete(b)); return c
26
+ }; window.CustomElementRegistry.prototype.upgrade =
27
+ function () { K.push(this); C.upgrade.apply(C, arguments); K.pop() }; window.CustomElementRegistry.prototype.get = function (b) { var c; return null == (c = this.l.get(b)) ? void 0 : c.g }; window.CustomElementRegistry.prototype.i = function (b) { return this.l.get(b) }; window.CustomElementRegistry.prototype.whenDefined = function (b) { var c = this.i(b); if (void 0 !== c) return Promise.resolve(c.g); var a = this.j.get(b); void 0 === a && (a = {}, a.promise = new Promise(function (d) { return a.resolve = d }), this.j.set(b, a)); return a.promise }; window.CustomElementRegistry.prototype.m =
28
+ function (b, c, a) { var d = this.h.get(c); d || this.h.set(c, d = new Set); a ? d.add(b) : d.delete(b) }; var L; window.HTMLElement = function () { var b = L; if (b) return L = void 0, b; var c = F.get(this.constructor); if (!c) throw new TypeError("Illegal constructor (custom element class must be registered with global customElements registry to be newable)"); b = Reflect.construct(y, [], c.s); Object.setPrototypeOf(b, this.constructor.prototype); D.set(b, c); return b }; window.HTMLElement.prototype = y.prototype; var I = function (b) {
29
+ function c() {
30
+ var a =
31
+ Reflect.construct(y, [], this.constructor); Object.setPrototypeOf(a, HTMLElement.prototype); a: { var d = a.getRootNode(); if (!(d === document || d instanceof ShadowRoot)) { d = K[K.length - 1]; if (d instanceof CustomElementRegistry) { var e = d; break a } d = d.getRootNode(); d === document || d instanceof ShadowRoot || (d = (null == (e = G.get(d)) ? void 0 : e.getRootNode()) || document) } e = d.customElements } e = e || window.customElements; (d = e.i(b)) ? J(a, d) : E.set(a, e); return a
32
+ } q.Object.defineProperty(c, "formAssociated", {
33
+ configurable: !0, enumerable: !0,
34
+ get: function () { var a = window.customElements.i(b); return a ? a.formAssociated : !1 }
35
+ }); c.prototype.connectedCallback = function () { var a = D.get(this); a ? a.connectedCallback && a.connectedCallback.apply(this, arguments) : E.get(this).m(this, b, !0) }; c.prototype.disconnectedCallback = function () { var a = D.get(this); a ? a.disconnectedCallback && a.disconnectedCallback.apply(this, arguments) : E.get(this).m(this, b, !1) }; c.prototype.adoptedCallback = function () {
36
+ var a, d; null == (a = D.get(this)) || null == (d = a.adoptedCallback) || d.apply(this,
37
+ arguments)
38
+ }; c.prototype.formAssociatedCallback = function () { var a = D.get(this); if (a && a.formAssociated) { var d; null == a || null == (d = a.formAssociatedCallback) || d.apply(this, arguments) } }; c.prototype.formDisabledCallback = function () { var a = D.get(this); if (null == a ? 0 : a.formAssociated) { var d; null == a || null == (d = a.formDisabledCallback) || d.apply(this, arguments) } }; c.prototype.formResetCallback = function () { var a = D.get(this); if (null == a ? 0 : a.formAssociated) { var d; null == a || null == (d = a.formResetCallback) || d.apply(this, arguments) } };
39
+ c.prototype.formStateRestoreCallback = function () { var a = D.get(this); if (null == a ? 0 : a.formAssociated) { var d; null == a || null == (d = a.formStateRestoreCallback) || d.apply(this, arguments) } }; return c
40
+ }, H = function (b, c, a) {
41
+ if (0 !== c.size && void 0 !== a) {
42
+ var d = b.prototype.setAttribute; d && (b.prototype.setAttribute = function (f, k) { f = f.toLowerCase(); if (c.has(f)) { var z = this.getAttribute(f); d.call(this, f, k); a.call(this, f, z, k) } else d.call(this, f, k) }); var e = b.prototype.removeAttribute; e && (b.prototype.removeAttribute = function (f) {
43
+ f =
44
+ f.toLowerCase(); if (c.has(f)) { var k = this.getAttribute(f); e.call(this, f); a.call(this, f, k, null) } else e.call(this, f)
45
+ }); var g = b.prototype.toggleAttribute; g && (b.prototype.toggleAttribute = function (f, k) { f = f.toLowerCase(); if (c.has(f)) { var z = this.getAttribute(f); g.call(this, f, k); k = this.getAttribute(f); a.call(this, f, z, k) } else g.call(this, f, k) })
46
+ }
47
+ }, M = function (b) { var c = Object.getPrototypeOf(b); if (c !== window.HTMLElement) return c === y ? Object.setPrototypeOf(b, window.HTMLElement) : M(c) }, J = function (b, c, a) {
48
+ a = void 0 ===
49
+ a ? !1 : a; Object.setPrototypeOf(b, c.g.prototype); D.set(b, c); L = b; try { new c.g } catch (d) { M(c.g), new c.g } c.attributeChangedCallback && c.observedAttributes.forEach(function (d) { b.hasAttribute(d) && c.attributeChangedCallback.call(b, d, null, b.getAttribute(d)) }); a && c.connectedCallback && b.isConnected && c.connectedCallback.call(b)
50
+ }, N = Element.prototype.attachShadow; Element.prototype.attachShadow = function (b) { var c = N.apply(this, arguments); b.customElements && (c.customElements = b.customElements); return c }; var K = [document],
51
+ O = function (b, c, a) { var d = (a ? Object.getPrototypeOf(a) : b.prototype)[c]; b.prototype[c] = function () { K.push(this); var e = d.apply(a || this, arguments); void 0 !== e && G.set(e, this); K.pop(); return e } }; O(ShadowRoot, "createElement", document); O(ShadowRoot, "importNode", document); O(Element, "insertAdjacentHTML"); var P = function (b) { var c = Object.getOwnPropertyDescriptor(b.prototype, "innerHTML"); Object.defineProperty(b.prototype, "innerHTML", Object.assign({}, c, { set: function (a) { K.push(this); c.set.call(this, a); K.pop() } })) }; P(Element);
52
+ P(ShadowRoot); Object.defineProperty(window, "customElements", { value: new CustomElementRegistry, configurable: !0, writable: !0 }); if (window.ElementInternals && window.ElementInternals.prototype.setFormValue) {
53
+ var Q = new WeakMap, R = HTMLElement.prototype.attachInternals, methods = ["setFormValue", "setValidity", "checkValidity", "reportValidity"]; HTMLElement.prototype.attachInternals = function (b) { for (var c = [], a = 0; a < arguments.length; ++a)c[a] = arguments[a]; c = R.call.apply(R, [this].concat(m(c))); Q.set(c, this); return c }; methods.forEach(function (b) {
54
+ var c =
55
+ window.ElementInternals.prototype, a = c[b]; c[b] = function (d) { for (var e = [], g = 0; g < arguments.length; ++g)e[g] = arguments[g]; g = Q.get(this); if (!0 === D.get(g).formAssociated) return null == a ? void 0 : a.call.apply(a, [this].concat(m(e))); throw new DOMException("Failed to execute " + a + " on 'ElementInternals': The target element is not a form-associated custom element."); }
56
+ }); var RadioNodeList = function (b) { var c = r(Array, [].concat(m(b)), this.constructor); c.h = b; return c }, S = RadioNodeList, T = Array; S.prototype = n(T.prototype);
57
+ S.prototype.constructor = S; if (x) x(S, T); else for (var U in T) if ("prototype" != U) if (Object.defineProperties) { var V = Object.getOwnPropertyDescriptor(T, U); V && Object.defineProperty(S, U, V) } else S[U] = T[U]; S.u = T.prototype; q.Object.defineProperty(RadioNodeList.prototype, "value", { configurable: !0, enumerable: !0, get: function () { var b; return (null == (b = this.h.find(function (c) { return !0 === c.checked })) ? void 0 : b.value) || "" } }); var HTMLFormControlsCollection = function (b) {
58
+ var c = this, a = new Map; b.forEach(function (d, e) {
59
+ var g = d.getAttribute("name"),
60
+ f = a.get(g) || []; c[+e] = d; f.push(d); a.set(g, f)
61
+ }); this.length = b.length; a.forEach(function (d, e) { d && (c[e] = 1 === d.length ? d[0] : new RadioNodeList(d)) })
62
+ }; HTMLFormControlsCollection.prototype.namedItem = function (b) { return this[b] }; var W = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, "elements"); Object.defineProperty(HTMLFormElement.prototype, "elements", { get: function () { var b = W.get.call(this, []), c = []; b = l(b); for (var a = b.next(); !a.done; a = b.next()) { a = a.value; var d = D.get(a); d && !0 !== d.formAssociated || c.push(a) } return new HTMLFormControlsCollection(c) } })
63
+ }
64
+ };
65
+ }).call(typeof globalThis === 'object' ? globalThis : window);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muonic/muon",
3
- "version": "0.0.2-beta.41",
3
+ "version": "0.0.2-beta.43",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -28,7 +28,6 @@
28
28
  "@web/dev-server-rollup": "0.5.2",
29
29
  "@web/dev-server-storybook": "0.7.4",
30
30
  "@web/storybook-prebuilt": "0.1.37",
31
- "@webcomponents/scoped-custom-element-registry": "0.0.9",
32
31
  "app-root-path": "3.1.0",
33
32
  "autoprefixer": "10.4.14",
34
33
  "chokidar": "3.5.3",
@@ -38,7 +37,7 @@
38
37
  "deepmerge": "4.3.1",
39
38
  "glob": "10.2.2",
40
39
  "glob-to-regexp": "0.4.1",
41
- "lit": "2.7.3",
40
+ "lit": "2.8.0",
42
41
  "lodash": "4.17.21",
43
42
  "path-is-inside": "1.0.2",
44
43
  "postcss": "8.4.27",
package/rollup.config.mjs CHANGED
@@ -3,7 +3,7 @@ import virtual from '@rollup/plugin-virtual';
3
3
  import { nodeResolve } from '@rollup/plugin-node-resolve';
4
4
  import { createBasicConfig } from '@open-wc/building-rollup';
5
5
  import path from 'path';
6
- import { componentDefiner, getDestination } from '@muonic/muon/scripts/utils/index.mjs';
6
+ import { componentDefiner, componentImportExport, getDestination } from '@muonic/muon/scripts/utils/index.mjs';
7
7
  import { rollupPlugins } from '@muonic/muon/scripts/rollup-plugins.mjs';
8
8
  import minifyHTMLPlugin from 'rollup-plugin-minify-html-literals';
9
9
 
@@ -17,7 +17,8 @@ export default merge(config, {
17
17
  plugins: [
18
18
  minifyHTMLPlugin.default(),
19
19
  virtual({
20
- 'component-definitions.js': componentDefiner()
20
+ 'component-definitions.js': componentDefiner(),
21
+ 'component-export.js': componentImportExport()
21
22
  }),
22
23
  ...rollupPlugins,
23
24
  nodeResolve()
@@ -293,7 +293,7 @@ const createTokens = async () => {
293
293
 
294
294
  const componentDefiner = async () => {
295
295
  const compList = await analyze();
296
- let componentDefinition = `import '@webcomponents/scoped-custom-element-registry';`;
296
+ let componentDefinition = `import '@muonic/muon/js/scoped-custom-element-registry.min.js';`;
297
297
 
298
298
  componentDefinition += compList.map(({ file, exportName }) => {
299
299
  return `import { ${exportName} } from '${file}';
@@ -313,6 +313,23 @@ const componentDefiner = async () => {
313
313
  return componentDefinition;
314
314
  };
315
315
 
316
+ const componentImportExport = async () => {
317
+ const compList = await analyze();
318
+ let componentDefinition = `import '@muonic/muon/js/scoped-custom-element-registry.min.js';`;
319
+
320
+ componentDefinition += compList.map(({ file, exportName }) => {
321
+ return `import { ${exportName} } from '${file}';
322
+ `;
323
+ }).join('');
324
+
325
+ componentDefinition += `
326
+ export {
327
+ ${compList.map(({ exportName }) => exportName).join(',')}
328
+ };`;
329
+
330
+ return componentDefinition;
331
+ };
332
+
316
333
  const runner = async (file, overrideDestination) => {
317
334
  const destination = overrideDestination || getDestination();
318
335
 
@@ -328,6 +345,7 @@ export {
328
345
  filterPathToCustomElements,
329
346
  createTokens,
330
347
  componentDefiner,
348
+ componentImportExport,
331
349
  runner,
332
350
  sourceFilesAnalyzer,
333
351
  getAliasPaths
@@ -64,7 +64,7 @@ testRunner('getConfig config file', async (t) => {
64
64
  const componentsDefinitionMacro = async (t, expected) => {
65
65
  const componentDefinition = await utilsLibrary.componentDefiner();
66
66
  t.true(componentDefinition !== undefined);
67
- t.true(componentDefinition.indexOf(`import '@webcomponents/scoped-custom-element-registry';`) > -1);
67
+ t.true(componentDefinition.indexOf(`import '@muonic/muon/js/scoped-custom-element-registry.min.js';`) > -1);
68
68
  Object.keys(expected).forEach((component) => {
69
69
  t.true(componentDefinition.indexOf(`import { ${expected[component]} } from '${process.cwd()}/components/${component}/src/${component}-component.js';`) > -1);
70
70
  t.true(componentDefinition.indexOf(`customElements.define('muon-${component}', ${expected[component]});`) > -1);
@@ -74,6 +74,17 @@ componentsDefinitionMacro.title = (providedTitle, expected) => `${providedTitle}
74
74
 
75
75
  testRunner('componentDefiner', componentsDefinitionMacro, { card: 'Card', cta: 'Cta', detail: 'Detail', form: 'Form', icon: 'Icon', inputter: 'Inputter', image: 'Image' });
76
76
 
77
+ const componentImportExportMacro = async (t, expected) => {
78
+ const componentImportExport = await utilsLibrary.componentImportExport();
79
+ t.true(componentImportExport !== undefined);
80
+ Object.keys(expected).forEach((component) => {
81
+ t.true(componentImportExport.indexOf(`import { ${expected[component]} } from '${process.cwd()}/components/${component}/src/${component}-component.js';`) > -1);
82
+ });
83
+ };
84
+ componentImportExportMacro.title = (providedTitle, expected) => `${providedTitle} => ${Object.keys(expected)}`;
85
+
86
+ testRunner('componentImportExport', componentImportExportMacro, { card: 'Card', cta: 'Cta', detail: 'Detail', form: 'Form', icon: 'Icon', inputter: 'Inputter', image: 'Image' });
87
+
77
88
  testRunner('getAliasPath glob', async (t) => {
78
89
  const alias = utilsLibrary.getAliasPaths('glob');
79
90
 
@@ -23,7 +23,7 @@ export default {
23
23
  `<html>
24
24
  <head>
25
25
  <script type="module">
26
- import '@webcomponents/scoped-custom-element-registry';
26
+ import '@muonic/muon/js/scoped-custom-element-registry.min.js';
27
27
  </script>
28
28
  </head>
29
29
  <body>
@@ -7,7 +7,7 @@ export default {
7
7
  `<html>
8
8
  <head>
9
9
  <script type="module">
10
- import '@webcomponents/scoped-custom-element-registry';
10
+ import '@muonic/muon/js/scoped-custom-element-registry.min.js';
11
11
  </script>
12
12
  </head>
13
13
  <body>
@@ -39,6 +39,10 @@ export default {
39
39
  branches: 99,
40
40
  functions: 99,
41
41
  lines: 99
42
- }
42
+ },
43
+ exclude: [
44
+ '**/node_modules/**',
45
+ '**/js/*.min.js'
46
+ ]
43
47
  }
44
48
  };