@muonic/muon 0.0.2-experimental-150-4a59267.0 → 0.0.2-experimental-152-a931dc2.0

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.
@@ -5,6 +5,8 @@ import { Image } from '@muon/components/image';
5
5
  import styles from './card-styles.css';
6
6
 
7
7
  /**
8
+ * A card is a container for content.
9
+ *
8
10
  * @element card
9
11
  */
10
12
  export class Card extends ScopedElementsMixin(ImageHolderMixin(CardMixin(MuonElement))) {
@@ -9,8 +9,8 @@ import {
9
9
 
10
10
  import styles from './image-styles.css';
11
11
 
12
- /**.
13
- * Loading images with default lazy loading
12
+ /**
13
+ * Loading images with default lazy loading.
14
14
  *
15
15
  * @element image
16
16
  */
@@ -205,8 +205,8 @@ export class Inputter extends ScopedElementsMixin(ValidationMixin(MaskMixin(Muon
205
205
  }
206
206
  }
207
207
 
208
- /**.
209
- * InputterDetail component to handle helper text
208
+ /**
209
+ * InputterDetail component to handle helper text.
210
210
  *
211
211
  * @element inputter-detail
212
212
  * @private
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muonic/muon",
3
- "version": "0.0.2-experimental-150-4a59267.0",
3
+ "version": "0.0.2-experimental-152-a931dc2.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -33,7 +33,6 @@
33
33
  "chokidar": "3.5.3",
34
34
  "chroma-js": "2.4.2",
35
35
  "command-line-args": "5.2.1",
36
- "deep-equal": "2.0.5",
37
36
  "deepmerge": "4.2.2",
38
37
  "glob": "8.0.3",
39
38
  "glob-to-regexp": "0.4.1",
package/rollup.config.mjs CHANGED
@@ -3,7 +3,8 @@ import { rollupPlugins } from '@muonic/muon/scripts/rollup-plugins.mjs';
3
3
  import virtual from '@rollup/plugin-virtual';
4
4
  import { nodeResolve } from '@rollup/plugin-node-resolve';
5
5
  import { createBasicConfig } from '@open-wc/building-rollup';
6
- import { componentDefiner } from '@muonic/muon/scripts/utils/index.mjs';
6
+ import { componentDefiner, getDestination } from '@muonic/muon/scripts/utils/index.mjs';
7
+ import path from 'path';
7
8
 
8
9
  const config = createBasicConfig();
9
10
  const input = 'index.js';
@@ -22,7 +23,7 @@ export default merge(config, {
22
23
  output: {
23
24
  ...config.output,
24
25
  dir: undefined,
25
- file: 'dist/index.js',
26
+ file: path.join(getDestination(), 'index.js'),
26
27
  sourcemap: false,
27
28
  inlineDynamicImports: true
28
29
  }
@@ -7,7 +7,7 @@ import postcssPreset from 'postcss-preset-env';
7
7
  import postcssImport from 'postcss-import';
8
8
  import postcssVariables from 'postcss-simple-vars';
9
9
  import litcssPlugin from 'rollup-plugin-lit-css';
10
- import { getConfig, createTokens, sourceFilesAnalyzer, getAliasPaths } from './utils/index.mjs';
10
+ import { cleanup, getConfig, getDestination, createTokens, sourceFilesAnalyzer, getAliasPaths } from './utils/index.mjs';
11
11
 
12
12
  import path from 'path';
13
13
  import fs from 'fs';
@@ -22,13 +22,11 @@ const muonPlugin = () => {
22
22
  return {
23
23
  name: 'muon',
24
24
  async buildStart() {
25
- const destination = config?.destination || 'dist';
26
- if (!fs.existsSync(destination)) {
27
- fs.mkdirSync(destination, { recursive: true });
28
- }
29
- const cejson = await sourceFilesAnalyzer();
30
-
31
- fs.writeFileSync(path.join(destination, 'custom-elements.json'), cejson);
25
+ const destination = getDestination();
26
+ cleanup(destination, true).then(async () => {
27
+ const cejson = await sourceFilesAnalyzer();
28
+ fs.writeFileSync(path.join(destination, 'custom-elements.json'), cejson);
29
+ });
32
30
  }
33
31
  };
34
32
  };
@@ -21,6 +21,16 @@ export default {
21
21
  }
22
22
  ]
23
23
  },
24
+ ref: {
25
+ buildPath: path.join(buildPath, 'json/'),
26
+ transforms: ['color/css', 'size/rem'],
27
+ files: [
28
+ {
29
+ destination: 'muon-tokens-reference.json',
30
+ format: 'json/reference'
31
+ }
32
+ ]
33
+ },
24
34
  es6: {
25
35
  buildPath: path.join(buildPath, 'es6/'),
26
36
  transforms: ['name/cti/constant', 'color/css', 'size/rem'],
@@ -1,11 +1,9 @@
1
1
  import ts from 'typescript';
2
2
  import { analyzeText, analyzeSourceFile, transformAnalyzerResult } from 'web-component-analyzer';
3
- import { analyzeAndTransformGlobs } from 'web-component-analyzer/lib/cjs/cli.js';
4
3
  import StyleDictionary from 'style-dictionary';
5
4
  import formatHelpers from 'style-dictionary/lib/common/formatHelpers/index.js';
6
5
  import _ from 'lodash';
7
6
  import appRoot from 'app-root-path';
8
- import deepEqual from 'deep-equal';
9
7
  import glob from 'glob';
10
8
  import globToRegExp from 'glob-to-regexp';
11
9
  import fs from 'fs';
@@ -14,6 +12,7 @@ import path from 'path';
14
12
  import styleConfig from '../style-dictionary.mjs';
15
13
  import colorTransform from '../../tokens/utils/transforms/color.js';
16
14
  import stringTransform from '../../tokens/utils/transforms/string.js';
15
+ import jsonReference from '../../tokens/utils/formats/reference.js';
17
16
 
18
17
  import { fileURLToPath } from 'url';
19
18
 
@@ -22,14 +21,27 @@ const __dirname = path.dirname(__filename);
22
21
 
23
22
  let config = {};
24
23
 
25
- const cleanup = (destination) => {
24
+ const cleanup = (destination, cleanOnRollup = false) => {
26
25
  return new Promise((resolve) => {
27
- fs.rmSync(destination, { force: true, recursive: true });
28
- fs.rmSync(path.join(__filename, '..', '..', '..', 'build'), { force: true, recursive: true });
26
+ const cemFilePath = path.join(destination, 'custom-elements.json');
27
+ const buildPath = path.join(__filename, '..', '..', '..', 'build');
29
28
 
30
- fs.mkdirSync(destination);
31
- fs.mkdirSync(path.join(__filename, '..', '..', '..', 'build'));
29
+ if (fs.existsSync(destination)) {
30
+ if (cleanOnRollup) {
31
+ // eslint-disable-next-line no-unused-expressions
32
+ fs.existsSync(cemFilePath) && fs.rmSync(cemFilePath);
33
+ } else {
34
+ fs.rmSync(destination, { force: true, recursive: true });
35
+ fs.rmSync(buildPath, { force: true, recursive: true });
36
+ }
37
+ }
32
38
 
39
+ if (!fs.existsSync(destination)) {
40
+ fs.mkdirSync(destination);
41
+ }
42
+ if (!cleanOnRollup) {
43
+ fs.mkdirSync(buildPath);
44
+ }
33
45
  return resolve();
34
46
  });
35
47
  };
@@ -223,6 +235,8 @@ const styleDictionary = async () => {
223
235
 
224
236
  const styleDict = StyleDictionary.extend(styleConfig);
225
237
 
238
+ styleDict.registerFormat(jsonReference);
239
+
226
240
  styleDict.registerFormat({
227
241
  name: 'css/fonts',
228
242
  formatter: cssFontTemplate
@@ -266,9 +280,13 @@ const componentDefiner = async () => {
266
280
  return componentDefinition;
267
281
  };
268
282
 
269
- const runner = async (file, overrideDestination) => {
283
+ const getDestination = () => {
270
284
  const config = getConfig();
271
- const destination = overrideDestination || config?.destination || 'dist';
285
+ return config?.destination || 'dist';
286
+ };
287
+
288
+ const runner = async (file, overrideDestination) => {
289
+ const destination = overrideDestination || getDestination();
272
290
 
273
291
  cleanup(destination).then(async () => {
274
292
  import(file);
@@ -276,7 +294,9 @@ const runner = async (file, overrideDestination) => {
276
294
  };
277
295
 
278
296
  export {
297
+ cleanup,
279
298
  getConfig,
299
+ getDestination,
280
300
  filterPathToCustomElements,
281
301
  createTokens,
282
302
  componentDefiner,
@@ -3,7 +3,7 @@ const fs = require('fs');
3
3
  const pathIsInside = require('path-is-inside');
4
4
 
5
5
  const findStories = async (dir = process.cwd()) => {
6
- const { getConfig, filterPathToCustomElements } = await import('../scripts/utils/index.mjs');
6
+ const { getConfig, getDestination, filterPathToCustomElements } = await import('../scripts/utils/index.mjs');
7
7
 
8
8
  const config = getConfig();
9
9
  const componentsList = config?.components?.included;
@@ -21,7 +21,7 @@ const findStories = async (dir = process.cwd()) => {
21
21
  ) {
22
22
  return [path.relative(dir, patterns)];
23
23
  } else {
24
- const destination = config?.destination || 'dist';
24
+ const destination = getDestination();
25
25
  const symlink = path.join(destination, 'stories');
26
26
 
27
27
  if (!fs.existsSync(symlink)) {
@@ -191,7 +191,7 @@ describe('form-element-validation', () => {
191
191
  await formElement.updateComplete;
192
192
  let validationMessage = shadowRoot.querySelector('.validation');
193
193
  expect(validationMessage).to.not.be.null; // eslint-disable-line no-unused-expressions
194
- expect(validationMessage.textContent.trim().toLowerCase()).contains('fill out this field.', 'validation message has correct value');
194
+ expect(validationMessage.textContent.trim().toLowerCase()).contains('this field is required', 'validation message has correct value');
195
195
 
196
196
  await fillIn(inputElement, 'test validation');
197
197
  expect(formElement.value).to.equal('test validation', '`value` property has value `test validation`');
@@ -0,0 +1,17 @@
1
+ module.exports = {
2
+ name: 'json/reference',
3
+ formatter: function ({ dictionary }) {
4
+ const tokens = dictionary.allTokens.map((token) => {
5
+ token.usesReference = dictionary.usesReference(token.original.value);
6
+ if (token.usesReference) {
7
+ token.references = dictionary.getReferences(token.original.value);
8
+ }
9
+
10
+ token.nestedName = token.path.join('.').toLowerCase();
11
+
12
+ return token;
13
+ });
14
+
15
+ return JSON.stringify(tokens, null, 2);
16
+ }
17
+ };