@mgdis/core-ui-helpers 1.2.1 → 1.2.2

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 (89) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +8 -8
  3. package/rollup.config.mjs +3 -3
  4. package/src/angular/mg-angular-logger/mg-angular-logger.spec.ts +1 -1
  5. package/src/angular/mg-angular-logger/mg-angular-logger.ts +2 -1
  6. package/src/locale/index.spec.ts +10 -1
  7. package/src/locale/locale.spec.ts +43 -18
  8. package/src/locale/locale.ts +13 -5
  9. package/src/playwright/utils/utils.spec.ts +16 -9
  10. package/src/playwright/utils/utils.ts +14 -6
  11. package/src/stencil/ide/cem.spec.ts +4 -4
  12. package/src/stencil/ide/cem.ts +9 -9
  13. package/src/stencil/ide/ide.ts +26 -26
  14. package/src/storybook/stencil/stencil.spec.ts +30 -6
  15. package/src/storybook/stencil/stencil.ts +24 -13
  16. package/src/tests/index.spec.ts +7 -1
  17. package/src/tests/unit/unit.conf.ts +9 -2
  18. package/src/tests/unit/unit.spec.ts +103 -61
  19. package/src/tests/unit/unit.ts +38 -11
  20. package/src/utils/attributes/id/id.spec.ts +9 -6
  21. package/src/utils/attributes/id/id.ts +3 -2
  22. package/src/utils/components/components.spec.ts +6 -6
  23. package/src/utils/components/components.ts +19 -5
  24. package/src/utils/elements/elements.ts +4 -2
  25. package/src/utils/number/number.spec.ts +2 -2
  26. package/src/utils/object/object.spec.ts +2 -2
  27. package/src/utils/object/object.ts +2 -1
  28. package/src/utils/string/string.spec.ts +12 -5
  29. package/src/utils/string/string.ts +2 -1
  30. package/src/utils/windows/windows.spec.ts +6 -2
  31. package/src/vue/mg-model/mg-model.ts +7 -2
  32. package/vitest.config.mts +1 -1
  33. package/.turbo/turbo-build.log +0 -49
  34. package/dist/angular/index.cjs +0 -27
  35. package/dist/angular/index.cjs.map +0 -1
  36. package/dist/angular/index.d.ts +0 -21
  37. package/dist/angular/index.js +0 -25
  38. package/dist/angular/index.js.map +0 -1
  39. package/dist/angular/index.umd.js +0 -33
  40. package/dist/angular/index.umd.js.map +0 -1
  41. package/dist/locale/index.cjs +0 -188
  42. package/dist/locale/index.cjs.map +0 -1
  43. package/dist/locale/index.d.ts +0 -110
  44. package/dist/locale/index.js +0 -179
  45. package/dist/locale/index.js.map +0 -1
  46. package/dist/locale/index.umd.js +0 -194
  47. package/dist/locale/index.umd.js.map +0 -1
  48. package/dist/playwright/index.cjs +0 -130
  49. package/dist/playwright/index.cjs.map +0 -1
  50. package/dist/playwright/index.d.ts +0 -39
  51. package/dist/playwright/index.js +0 -126
  52. package/dist/playwright/index.js.map +0 -1
  53. package/dist/playwright/index.umd.js +0 -136
  54. package/dist/playwright/index.umd.js.map +0 -1
  55. package/dist/stencil/index.cjs +0 -363
  56. package/dist/stencil/index.cjs.map +0 -1
  57. package/dist/stencil/index.d.ts +0 -222
  58. package/dist/stencil/index.js +0 -357
  59. package/dist/stencil/index.js.map +0 -1
  60. package/dist/stencil/index.umd.js +0 -369
  61. package/dist/stencil/index.umd.js.map +0 -1
  62. package/dist/storybook/index.cjs +0 -2333
  63. package/dist/storybook/index.cjs.map +0 -1
  64. package/dist/storybook/index.d.ts +0 -85
  65. package/dist/storybook/index.js +0 -2327
  66. package/dist/storybook/index.js.map +0 -1
  67. package/dist/storybook/index.umd.js +0 -2339
  68. package/dist/storybook/index.umd.js.map +0 -1
  69. package/dist/tests/index.cjs +0 -300
  70. package/dist/tests/index.cjs.map +0 -1
  71. package/dist/tests/index.d.ts +0 -100
  72. package/dist/tests/index.js +0 -294
  73. package/dist/tests/index.js.map +0 -1
  74. package/dist/tests/index.umd.js +0 -306
  75. package/dist/tests/index.umd.js.map +0 -1
  76. package/dist/utils/index.cjs +0 -433
  77. package/dist/utils/index.cjs.map +0 -1
  78. package/dist/utils/index.d.ts +0 -265
  79. package/dist/utils/index.js +0 -409
  80. package/dist/utils/index.js.map +0 -1
  81. package/dist/utils/index.umd.js +0 -439
  82. package/dist/utils/index.umd.js.map +0 -1
  83. package/dist/vue/index.cjs +0 -1934
  84. package/dist/vue/index.cjs.map +0 -1
  85. package/dist/vue/index.d.ts +0 -35
  86. package/dist/vue/index.js +0 -1932
  87. package/dist/vue/index.js.map +0 -1
  88. package/dist/vue/index.umd.js +0 -1940
  89. package/dist/vue/index.umd.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @mgdis/core-ui-helpers
2
2
 
3
+ ## 1.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 8866809: Update dependencies
8
+
3
9
  ## 1.2.1
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@mgdis/core-ui-helpers",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "license": "ISC",
5
5
  "dependencies": {
6
- "@playwright/test": "1.60.0",
6
+ "@playwright/test": "1.61.1",
7
7
  "@stencil/core": "4.43.5",
8
8
  "lodash": "4.18.1",
9
9
  "vue": "npm:vue@2.7.16"
@@ -13,19 +13,19 @@
13
13
  "@rollup/plugin-node-resolve": "16.0.3",
14
14
  "@rollup/plugin-typescript": "12.3.0",
15
15
  "@types/lodash": "4.17.24",
16
- "@types/node": "24.13.0",
17
- "@vitest/coverage-istanbul": "4.1.9",
16
+ "@types/node": "24.13.3",
17
+ "@vitest/coverage-istanbul": "4.1.10",
18
18
  "@vue/test-utils": "npm:@vue/test-utils@1.3.6",
19
19
  "htmlfy": "1.0.2",
20
- "rollup": "4.62.0",
20
+ "rollup": "4.62.2",
21
21
  "rollup-plugin-dts": "6.4.1",
22
22
  "tslib": "2.8.1",
23
- "typedoc": "0.28.19",
23
+ "typedoc": "0.28.20",
24
24
  "typedoc-plugin-markdown": "4.12.0",
25
- "vitest": "4.1.9",
25
+ "vitest": "4.1.10",
26
26
  "vue-jest": "3.0.7",
27
- "@core-ui/typedoc-config": "1.0.2",
28
27
  "@core-ui/tsconfig": "1.0.11",
28
+ "@core-ui/typedoc-config": "1.0.2",
29
29
  "@core-ui/vitest-config": "1.0.8"
30
30
  },
31
31
  "exports": {
package/rollup.config.mjs CHANGED
@@ -15,9 +15,9 @@ const getFilePath = (folder, path, filname) => [folder, path, filname].join('/')
15
15
  export default async () => {
16
16
  const folders = await fs.readdir(FOLDER.input, { withFileTypes: true });
17
17
  return folders
18
- .filter(dirent => dirent.isDirectory())
19
- .map(dirent => dirent.name)
20
- .flatMap(folder => {
18
+ .filter((dirent) => dirent.isDirectory())
19
+ .map((dirent) => dirent.name)
20
+ .flatMap((folder) => {
21
21
  const input = getFilePath(FOLDER.input, folder, 'index.ts');
22
22
 
23
23
  return [
@@ -30,7 +30,7 @@ describe('mg-angular-logger', () => {
30
30
  expect(spy).toHaveBeenCalled();
31
31
  });
32
32
 
33
- test.each([mgError, standardError])('Should display error logger is set on "error"', err => {
33
+ test.each([mgError, standardError])('Should display error logger is set on "error"', (err) => {
34
34
  const spy = vi.spyOn(console, 'error');
35
35
  setMgAngularLogger({ level: 'error' });
36
36
  console.error(err);
@@ -18,6 +18,7 @@ export const setMgAngularLogger = (config: ConfigType = { level: 'log' }): void
18
18
  const error = console.error;
19
19
  console.error = (...args: unknown[]) => {
20
20
  // filter error when it come from a mg-components component error
21
- if (config.level === 'error' || !args.some(arg => arg instanceof Error && arg.message.startsWith('<mg-'))) error.call(console, ...args);
21
+ if (config.level === 'error' || !args.some((arg) => arg instanceof Error && arg.message.startsWith('<mg-')))
22
+ error.call(console, ...args);
22
23
  };
23
24
  };
@@ -1,5 +1,14 @@
1
1
  import { describe, expect, test } from 'vitest';
2
- import { defineLocales, localeByte, localeCurrency, localeDate, localeDatePattern, localeNumber, localePercent, localeUnit } from '.';
2
+ import {
3
+ defineLocales,
4
+ localeByte,
5
+ localeCurrency,
6
+ localeDate,
7
+ localeDatePattern,
8
+ localeNumber,
9
+ localePercent,
10
+ localeUnit,
11
+ } from '.';
3
12
 
4
13
  describe('locale', () => {
5
14
  test('import', () => {
@@ -1,12 +1,21 @@
1
1
  import { describe, expect, test } from 'vitest';
2
- import { localeCurrency, localeNumber, localeDate, localePercent, localeUnit, defineLocales, localeDatePattern, localeByte } from './locale';
2
+ import {
3
+ localeCurrency,
4
+ localeNumber,
5
+ localeDate,
6
+ localePercent,
7
+ localeUnit,
8
+ defineLocales,
9
+ localeDatePattern,
10
+ localeByte,
11
+ } from './locale';
3
12
 
4
13
  const messagesFr = { lang: 'fr' };
5
14
  const messagesEn = { lang: 'en' };
6
15
  const messages = { en: messagesEn, fr: messagesFr };
7
16
 
8
17
  describe('locale', () => {
9
- describe.each(['en', 'fr'])('locale: %s', locale => {
18
+ describe.each(['en', 'fr'])('locale: %s', (locale) => {
10
19
  describe('localeCurrency', () => {
11
20
  test('Should Format number to the locale currency', () => {
12
21
  const formatedCurrency = localeCurrency(1234567890.12, locale, 'EUR');
@@ -23,13 +32,16 @@ describe('locale', () => {
23
32
  const formatedCurrency = localeNumber(1234567890, locale, 2);
24
33
  expect(formatedCurrency).toEqual(locale === 'en' ? '1,234,567,890.00' : '1 234 567 890,00');
25
34
  });
26
- test.each([0, 5])('Should Format number to the locale and format the decimal length, case length %s', length => {
27
- const formatedCurrency = localeNumber(1234567890, locale, length);
28
- const decimal = length > 0 ? '00000' : null;
29
- const localePoint = locale === 'en' ? '.' : ',';
30
- const integer = locale === 'en' ? '1,234,567,890' : '1 234 567 890';
31
- expect(formatedCurrency).toEqual(integer + (decimal ? localePoint + decimal : ''));
32
- });
35
+ test.each([0, 5])(
36
+ 'Should Format number to the locale and format the decimal length, case length %s',
37
+ (length) => {
38
+ const formatedCurrency = localeNumber(1234567890, locale, length);
39
+ const decimal = length > 0 ? '00000' : null;
40
+ const localePoint = locale === 'en' ? '.' : ',';
41
+ const integer = locale === 'en' ? '1,234,567,890' : '1 234 567 890';
42
+ expect(formatedCurrency).toEqual(integer + (decimal ? localePoint + decimal : ''));
43
+ }
44
+ );
33
45
  });
34
46
 
35
47
  describe('localeDatePattern', () => {
@@ -43,7 +55,7 @@ describe('locale', () => {
43
55
  });
44
56
 
45
57
  describe('localeDate', () => {
46
- test.each([undefined, '', 'blu'])('Should return empty string: %s', date => {
58
+ test.each([undefined, '', 'blu'])('Should return empty string: %s', (date) => {
47
59
  const formatedDate = localeDate(date, locale);
48
60
  expect(formatedDate).toEqual('');
49
61
  });
@@ -148,15 +160,28 @@ describe('locale', () => {
148
160
  [1234567890.12, 'en', 'kilometer', 'short', 2, '1,234,567,890.12 km'],
149
161
  [23, 'en', 'celsius', 'short', 0, '23°C'],
150
162
  [10, 'en', 'kilometer', 'long', 0, '10 kilometers'],
151
- ])('Should format %s value correctly for locale %s with unit %s', (value, locale, unit, unitDisplay, decimals, expected) => {
152
- const result = localeUnit(value, locale, unit, unitDisplay as Intl.NumberFormatOptions['unitDisplay'], decimals);
153
- // Normalize spaces before comparison
154
- expect(result.replace(/\s/g, ' ')).toBe(expected.replace(/\s/g, ' '));
155
- });
163
+ ])(
164
+ 'Should format %s value correctly for locale %s with unit %s',
165
+ (value, locale, unit, unitDisplay, decimals, expected) => {
166
+ const result = localeUnit(
167
+ value,
168
+ locale,
169
+ unit,
170
+ unitDisplay as Intl.NumberFormatOptions['unitDisplay'],
171
+ decimals
172
+ );
173
+ // Normalize spaces before comparison
174
+ expect(result.replace(/\s/g, ' ')).toBe(expected.replace(/\s/g, ' '));
175
+ }
176
+ );
156
177
 
157
178
  test('Should respect decimal length', () => {
158
- expect(localeUnit(1234.567, 'en', 'kilometer', 'short', 2).replace(/\s/g, ' ')).toBe('1,234.57 km'.replace(/\s/g, ' '));
159
- expect(localeUnit(1234.567, 'fr', 'kilometer', 'short', 2).replace(/\s/g, ' ')).toBe('1 234,57 km'.replace(/\s/g, ' '));
179
+ expect(localeUnit(1234.567, 'en', 'kilometer', 'short', 2).replace(/\s/g, ' ')).toBe(
180
+ '1,234.57 km'.replace(/\s/g, ' ')
181
+ );
182
+ expect(localeUnit(1234.567, 'fr', 'kilometer', 'short', 2).replace(/\s/g, ' ')).toBe(
183
+ '1 234,57 km'.replace(/\s/g, ' ')
184
+ );
160
185
  });
161
186
 
162
187
  test('Should use default unitDisplay and decimalLength when not provided', () => {
@@ -258,7 +283,7 @@ describe('locale', () => {
258
283
  expect(() => localeByte(-10, locale)).toThrowError('localeByte - size must be a positive number.');
259
284
  });
260
285
 
261
- test.each([undefined, null, NaN, []])('Should throw error with %s octets', value => {
286
+ test.each([undefined, null, NaN, []])('Should throw error with %s octets', (value) => {
262
287
  expect(() => localeByte(value as number, locale)).toThrowError('localeByte - size must be a positive number.');
263
288
  });
264
289
  });
@@ -28,11 +28,16 @@ export const localeDatePattern = (locale: string) => {
28
28
  * @param defaultLocale - default messages locale
29
29
  * @returns messages object
30
30
  */
31
- const localeMessages = (element: HTMLElement, messages: ObjectType, defaultLocale: string): { locale: string; messages: ObjectType } => {
31
+ const localeMessages = (
32
+ element: HTMLElement,
33
+ messages: ObjectType,
34
+ defaultLocale: string
35
+ ): { locale: string; messages: ObjectType } => {
32
36
  // Get local
33
37
  const closestLangAttribute: HTMLElement | null = element.closest('[lang]');
34
38
  const closestLang: string[] = Intl.NumberFormat.supportedLocalesOf(closestLangAttribute?.lang as string);
35
- const locale = closestLang.length > 0 && typeof closestLang[0] === 'string' ? closestLang[0] : navigator.language || defaultLocale;
39
+ const locale =
40
+ closestLang.length > 0 && typeof closestLang[0] === 'string' ? closestLang[0] : navigator.language || defaultLocale;
36
41
  // Only keep first subtag
37
42
  const localeSubtag = locale.split('-').shift() as string;
38
43
 
@@ -62,7 +67,8 @@ const localeMessages = (element: HTMLElement, messages: ObjectType, defaultLocal
62
67
  * localeCurrency(1234567890.12, 'fr', 'EUR') // '1 234 567 890,12\xa0€'
63
68
  * ```
64
69
  */
65
- export const localeCurrency = (number: number, locale: string, currency: string): string => new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
70
+ export const localeCurrency = (number: number, locale: string, currency: string): string =>
71
+ new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
66
72
 
67
73
  /**
68
74
  * Format number to locale
@@ -145,7 +151,7 @@ export const localeUnit = (
145
151
  locale: string,
146
152
  unit: Intl.NumberFormatOptions['unit'],
147
153
  unitDisplay: Intl.NumberFormatOptions['unitDisplay'] = 'short',
148
- decimalLength: number = 0,
154
+ decimalLength: number = 0
149
155
  ): string => {
150
156
  return new Intl.NumberFormat(locale, {
151
157
  style: 'unit',
@@ -168,7 +174,9 @@ export const localeUnit = (
168
174
  * ```
169
175
  */
170
176
  export const localeDate = (date: string | undefined, locale: string, config?: Intl.DateTimeFormatOptions): string =>
171
- typeof date !== 'string' || date === '' || !dateRegExp.test(date) ? '' : new Intl.DateTimeFormat(locale, config).format(new Date(date));
177
+ typeof date !== 'string' || date === '' || !dateRegExp.test(date)
178
+ ? ''
179
+ : new Intl.DateTimeFormat(locale, config).format(new Date(date));
172
180
 
173
181
  /**
174
182
  * Get Intl object
@@ -17,7 +17,7 @@ describe('utils', () => {
17
17
  { name: null },
18
18
  { name: undefined },
19
19
  ' ',
20
- ])('Should render attributes', args => {
20
+ ])('Should render attributes', (args) => {
21
21
  const res = renderAttributes(args as Record<string, unknown>);
22
22
  expect(res).toMatchSnapshot();
23
23
  });
@@ -28,16 +28,23 @@ describe('utils', () => {
28
28
  const res = renderProperties({ object: {} }, '#id');
29
29
  expect(res).toEqual("\n document.getElementById('id').object={};");
30
30
  });
31
- test.each([undefined, null, {}, { name: 'batman' }])('Should not render attributes as properties', args => {
31
+ test.each([undefined, null, {}, { name: 'batman' }])('Should not render attributes as properties', (args) => {
32
32
  const res = renderProperties(args as Record<string, unknown>, 'div');
33
33
  expect(res).toMatchSnapshot();
34
34
  });
35
- test.each([undefined, () => {}].map(fn => ({ name: 'batman', user: 'bruce', active: true, id: 1, object: {}, array: [], fn })))(
36
- 'Should render properties, case id selector',
37
- args => {
38
- const res = renderProperties(args, 'div');
39
- expect(res).toMatchSnapshot();
40
- },
41
- );
35
+ test.each(
36
+ [undefined, () => {}].map((fn) => ({
37
+ name: 'batman',
38
+ user: 'bruce',
39
+ active: true,
40
+ id: 1,
41
+ object: {},
42
+ array: [],
43
+ fn,
44
+ }))
45
+ )('Should render properties, case id selector', (args) => {
46
+ const res = renderProperties(args, 'div');
47
+ expect(res).toMatchSnapshot();
48
+ });
42
49
  });
43
50
  });
@@ -19,11 +19,17 @@ import { isObject, isValidString } from '../../utils';
19
19
  export const renderAttributes = (args: Record<string, unknown>): string =>
20
20
  (isObject<Record<string, never>>(args) &&
21
21
  Object.keys(args)
22
- .filter(key => ![null, undefined].includes(args[key]) && !['object', 'function'].includes(typeof args[key]) && args[key] !== false)
23
- .map(key => {
22
+ .filter(
23
+ (key) =>
24
+ ![null, undefined].includes(args[key]) &&
25
+ !['object', 'function'].includes(typeof args[key]) &&
26
+ args[key] !== false
27
+ )
28
+ .map((key) => {
24
29
  const attribute: string = key.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
25
30
  if (args[key] === true) return `${attribute}=""`;
26
- const value: string = typeof args[key] === 'number' || isValidString(args[key]) ? String(args[key]).replace(/"/g, "'") : '';
31
+ const value: string =
32
+ typeof args[key] === 'number' || isValidString(args[key]) ? String(args[key]).replace(/"/g, "'") : '';
27
33
  return `${attribute}="${value}"`;
28
34
  })
29
35
  .join(' ')) ||
@@ -54,9 +60,11 @@ export const renderProperties = (args: Record<string, unknown>, selector: string
54
60
  ? `
55
61
  ${
56
62
  Object.keys(args)
57
- .filter(key => ['object', 'function'].includes(typeof (args as Record<string, never>)[key]))
58
- .map(key => {
59
- const value = JSON.stringify((args as Record<string, never>)[key], (_key, val) => (typeof val === 'function' ? `<fn>${val}</fn>` : val));
63
+ .filter((key) => ['object', 'function'].includes(typeof (args as Record<string, never>)[key]))
64
+ .map((key) => {
65
+ const value = JSON.stringify((args as Record<string, never>)[key], (_key, val) =>
66
+ typeof val === 'function' ? `<fn>${val}</fn>` : val
67
+ );
60
68
  return `document.${query}('${selector}').${key}=${value}`;
61
69
  }) // stringify json AND keep function values
62
70
  .join(';') // create string
@@ -16,10 +16,10 @@ describe('cemGenerator', () => {
16
16
  test('Should map attribute-backed props to both attributes and members', () => {
17
17
  const cem = cemGenerator(jsonDocs as JsonDocs);
18
18
  const decl = cem.modules[0].declarations[0];
19
- const attrBackedProp = decl.attributes.find(a => a.name === 'prop');
19
+ const attrBackedProp = decl.attributes.find((a) => a.name === 'prop');
20
20
  expect(attrBackedProp).toBeDefined();
21
21
  expect(attrBackedProp?.fieldName).toBe('prop');
22
- const member = decl.members.find(m => m.kind === 'field' && m.name === 'prop');
22
+ const member = decl.members.find((m) => m.kind === 'field' && m.name === 'prop');
23
23
  expect(member).toBeDefined();
24
24
  expect((member as { attribute?: string }).attribute).toBe('prop');
25
25
  });
@@ -27,8 +27,8 @@ describe('cemGenerator', () => {
27
27
  test('Should map JS-only props to members only (not attributes)', () => {
28
28
  const cem = cemGenerator(jsonDocs as JsonDocs);
29
29
  const decl = cem.modules[0].declarations[0];
30
- expect(decl.attributes.find(a => a.name === 'attr')).toBeUndefined();
31
- const member = decl.members.find(m => m.kind === 'field' && m.name === 'attr');
30
+ expect(decl.attributes.find((a) => a.name === 'attr')).toBeUndefined();
31
+ const member = decl.members.find((m) => m.kind === 'field' && m.name === 'attr');
32
32
  expect(member).toBeDefined();
33
33
  expect((member as { attribute?: string }).attribute).toBeUndefined();
34
34
  });
@@ -8,12 +8,12 @@ import type { JsonDocs, JsonDocsComponent } from '@stencil/core/internal';
8
8
  const componentToModule = (component: JsonDocsComponent) => {
9
9
  const className = component.tag
10
10
  .split('-')
11
- .map(part => part.charAt(0).toUpperCase() + part.slice(1))
11
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
12
12
  .join('');
13
13
 
14
14
  const attributes = component.props
15
- .filter(prop => prop.attr !== undefined)
16
- .map(prop => ({
15
+ .filter((prop) => prop.attr !== undefined)
16
+ .map((prop) => ({
17
17
  name: prop.attr,
18
18
  description: prop.docs,
19
19
  type: { text: prop.type },
@@ -21,7 +21,7 @@ const componentToModule = (component: JsonDocsComponent) => {
21
21
  fieldName: prop.name,
22
22
  }));
23
23
 
24
- const fieldMembers = component.props.map(prop => ({
24
+ const fieldMembers = component.props.map((prop) => ({
25
25
  kind: 'field' as const,
26
26
  name: prop.name,
27
27
  description: prop.docs,
@@ -30,7 +30,7 @@ const componentToModule = (component: JsonDocsComponent) => {
30
30
  ...(prop.attr !== undefined && { attribute: prop.attr }),
31
31
  }));
32
32
 
33
- const methodMembers = component.methods.map(method => ({
33
+ const methodMembers = component.methods.map((method) => ({
34
34
  kind: 'method' as const,
35
35
  name: method.name,
36
36
  description: method.docs,
@@ -48,20 +48,20 @@ const componentToModule = (component: JsonDocsComponent) => {
48
48
  description: component.overview ?? '',
49
49
  attributes,
50
50
  members: [...fieldMembers, ...methodMembers],
51
- events: component.events.map(event => ({
51
+ events: component.events.map((event) => ({
52
52
  name: event.event,
53
53
  description: event.docs,
54
54
  type: { text: `CustomEvent<${event.detail}>` },
55
55
  })),
56
- slots: component.slots.map(slot => ({
56
+ slots: component.slots.map((slot) => ({
57
57
  name: slot.name,
58
58
  description: slot.docs,
59
59
  })),
60
- cssProperties: component.styles.map(style => ({
60
+ cssProperties: component.styles.map((style) => ({
61
61
  name: style.name,
62
62
  description: style.docs,
63
63
  })),
64
- cssParts: component.parts.map(part => ({
64
+ cssParts: component.parts.map((part) => ({
65
65
  name: part.name,
66
66
  description: part.docs,
67
67
  })),
@@ -89,50 +89,50 @@ const getAttributeDescription = (prop: JsonDocsProp): string => {
89
89
  * ```
90
90
  */
91
91
  export const webTypesGenerator = (name: string, version: string, jsonDocs: JsonDocs, storybookBaseUrl: string) => ({
92
- '$schema': 'https://json.schemastore.org/web-types',
92
+ $schema: 'https://json.schemastore.org/web-types',
93
93
  name,
94
94
  version,
95
95
  'description-markup': 'markdown',
96
- 'contributions': {
96
+ contributions: {
97
97
  html: {
98
- elements: jsonDocs.components.map(component => {
98
+ elements: jsonDocs.components.map((component) => {
99
99
  const docUrl = getStorybookUrl(storybookBaseUrl, component.filePath);
100
100
  return {
101
- 'name': component.tag,
102
- 'description': getElementDescription(component),
101
+ name: component.tag,
102
+ description: getElementDescription(component),
103
103
  'doc-url': docUrl,
104
- 'attributes': component.props
105
- .filter(prop => prop.attr)
106
- .map(prop => ({
107
- 'name': prop.attr,
108
- 'description': getAttributeDescription(prop),
104
+ attributes: component.props
105
+ .filter((prop) => prop.attr)
106
+ .map((prop) => ({
107
+ name: prop.attr,
108
+ description: getAttributeDescription(prop),
109
109
  'doc-url': docUrl,
110
- 'value': {
110
+ value: {
111
111
  type: prop.type,
112
112
  default: prop.default,
113
113
  required: prop.required,
114
114
  },
115
115
  })),
116
- 'js': {
116
+ js: {
117
117
  properties: component.props
118
- .filter(prop => prop.attr === undefined)
119
- .map(prop => ({
120
- 'name': prop.name,
121
- 'description': getAttributeDescription(prop),
118
+ .filter((prop) => prop.attr === undefined)
119
+ .map((prop) => ({
120
+ name: prop.name,
121
+ description: getAttributeDescription(prop),
122
122
  'doc-url': docUrl,
123
- 'value': {
123
+ value: {
124
124
  type: prop.type,
125
125
  default: prop.default,
126
126
  required: prop.required,
127
127
  },
128
128
  })),
129
- events: component.events.map(event => ({
129
+ events: component.events.map((event) => ({
130
130
  name: event.event,
131
131
  description: event.docs,
132
132
  })),
133
133
  },
134
- 'css': {
135
- properties: component.styles.map(style => ({
134
+ css: {
135
+ properties: component.styles.map((style) => ({
136
136
  name: style.name,
137
137
  description: style.docs,
138
138
  })),
@@ -181,14 +181,14 @@ const getValues = (prop: JsonDocsProp): unknown[] | undefined => {
181
181
  */
182
182
  export const vsCodeGenerator = (jsonDocs: JsonDocs, storybookBaseUrl: string, sourceBaseUrl: string) => ({
183
183
  version: 1.1,
184
- tags: jsonDocs.components.map(component => {
184
+ tags: jsonDocs.components.map((component) => {
185
185
  const references = getReferences(storybookBaseUrl, sourceBaseUrl, component.filePath);
186
186
  return {
187
187
  name: component.tag,
188
188
  description: getElementDescription(component),
189
189
  attributes: component.props
190
- .filter(prop => prop.attr !== undefined)
191
- .map(prop => ({
190
+ .filter((prop) => prop.attr !== undefined)
191
+ .map((prop) => ({
192
192
  name: prop.attr,
193
193
  description: getAttributeDescription(prop),
194
194
  values: getValues(prop),
@@ -212,10 +212,10 @@ export const vsCodeGenerator = (jsonDocs: JsonDocs, storybookBaseUrl: string, so
212
212
  */
213
213
  export const vsCodeCssGenerator = (jsonDocs: JsonDocs) => ({
214
214
  version: 1.1,
215
- properties: jsonDocs.components.flatMap(component =>
216
- component.styles.map(style => ({
215
+ properties: jsonDocs.components.flatMap((component) =>
216
+ component.styles.map((style) => ({
217
217
  name: style.name,
218
218
  description: style.docs,
219
- })),
219
+ }))
220
220
  ),
221
221
  });
@@ -20,7 +20,7 @@ describe('stencil', () => {
20
20
  expect(res).toEqual({ name: 'batman', default: true });
21
21
  });
22
22
 
23
- test.each([undefined, ''])('Should get renderable args, case no default args', val => {
23
+ test.each([undefined, ''])('Should get renderable args, case no default args', (val) => {
24
24
  expect.assertions(1);
25
25
  try {
26
26
  filterArgs(val);
@@ -38,7 +38,7 @@ describe('stencil', () => {
38
38
  expect(res).toEqual(undefined);
39
39
  });
40
40
 
41
- test.each([{}, { globals: { locale: 'fr' } }])('should render element from VDOM', args => {
41
+ test.each([{}, { globals: { locale: 'fr' } }])('should render element from VDOM', (args) => {
42
42
  const storyFn = vi.fn();
43
43
 
44
44
  // insert storybook host div
@@ -62,7 +62,17 @@ describe('stencil', () => {
62
62
  { $tag$: 'mg-batman', $attrs$: {}, $children$: null, $text$: null },
63
63
  {
64
64
  $tag$: 'mg-batman',
65
- $attrs$: { boolean: true, text: 'hello', object: {}, array: [], function: () => {}, null: null, undefined: undefined, blank: '', style: 'top:0' },
65
+ $attrs$: {
66
+ boolean: true,
67
+ text: 'hello',
68
+ object: {},
69
+ array: [],
70
+ function: () => {},
71
+ null: null,
72
+ undefined: undefined,
73
+ blank: '',
74
+ style: 'top:0',
75
+ },
66
76
  $children$: null,
67
77
  $text$: null,
68
78
  },
@@ -88,16 +98,30 @@ describe('stencil', () => {
88
98
  {
89
99
  $tag$: 'mg-batman',
90
100
  $attrs$: { boolean: true, text: 'hello', object: {} },
91
- $children$: [{ $tag$: 'baby-batman', $attrs$: {}, $children$: [{ $tag$: null, $attrs$: {}, $children$: null, $text$: 'joker is behind you' }], $text$: null }],
101
+ $children$: [
102
+ {
103
+ $tag$: 'baby-batman',
104
+ $attrs$: {},
105
+ $children$: [{ $tag$: null, $attrs$: {}, $children$: null, $text$: 'joker is behind you' }],
106
+ $text$: null,
107
+ },
108
+ ],
92
109
  $text$: null,
93
110
  },
94
111
  {
95
112
  $tag$: 'blu-blu',
96
- $attrs$: { 'boolean': true, 'false': false, 'text': 'hello', 'blu': 'blu bli bla blo', 'number': 42, 'html-content': 'Help text with html <b>bold</b>, <em>italic</em>.' },
113
+ $attrs$: {
114
+ boolean: true,
115
+ false: false,
116
+ text: 'hello',
117
+ blu: 'blu bli bla blo',
118
+ number: 42,
119
+ 'html-content': 'Help text with html <b>bold</b>, <em>italic</em>.',
120
+ },
97
121
  $children$: null,
98
122
  $text$: null,
99
123
  },
100
- ])('Should render story code exemple', args => {
124
+ ])('Should render story code exemple', (args) => {
101
125
  const res = getStoryHTML(args as unknown as VNode);
102
126
  expect(res).toMatchSnapshot();
103
127
  });