@mgdis/core-ui-helpers 1.2.2 → 1.3.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.
Files changed (149) hide show
  1. package/dist/angular/index.cjs +27 -0
  2. package/dist/angular/index.cjs.map +1 -0
  3. package/dist/angular/index.d.ts +21 -0
  4. package/dist/angular/index.js +25 -0
  5. package/dist/angular/index.js.map +1 -0
  6. package/dist/angular/index.umd.js +33 -0
  7. package/dist/angular/index.umd.js.map +1 -0
  8. package/dist/locale/index.cjs +190 -0
  9. package/dist/locale/index.cjs.map +1 -0
  10. package/dist/locale/index.d.ts +110 -0
  11. package/dist/locale/index.js +181 -0
  12. package/dist/locale/index.js.map +1 -0
  13. package/dist/locale/index.umd.js +196 -0
  14. package/dist/locale/index.umd.js.map +1 -0
  15. package/dist/playwright/index.cjs +137 -0
  16. package/dist/playwright/index.cjs.map +1 -0
  17. package/dist/playwright/index.d.ts +39 -0
  18. package/dist/playwright/index.js +133 -0
  19. package/dist/playwright/index.js.map +1 -0
  20. package/dist/playwright/index.umd.js +143 -0
  21. package/dist/playwright/index.umd.js.map +1 -0
  22. package/dist/stencil/index.cjs +363 -0
  23. package/dist/stencil/index.cjs.map +1 -0
  24. package/dist/stencil/index.d.ts +222 -0
  25. package/dist/stencil/index.js +357 -0
  26. package/dist/stencil/index.js.map +1 -0
  27. package/dist/stencil/index.umd.js +369 -0
  28. package/dist/stencil/index.umd.js.map +1 -0
  29. package/dist/storybook/index.cjs +2335 -0
  30. package/dist/storybook/index.cjs.map +1 -0
  31. package/dist/storybook/index.d.ts +85 -0
  32. package/dist/storybook/index.js +2329 -0
  33. package/dist/storybook/index.js.map +1 -0
  34. package/dist/storybook/index.umd.js +2341 -0
  35. package/dist/storybook/index.umd.js.map +1 -0
  36. package/dist/tests/index.cjs +315 -0
  37. package/dist/tests/index.cjs.map +1 -0
  38. package/dist/tests/index.d.ts +100 -0
  39. package/dist/tests/index.js +309 -0
  40. package/dist/tests/index.js.map +1 -0
  41. package/dist/tests/index.umd.js +321 -0
  42. package/dist/tests/index.umd.js.map +1 -0
  43. package/dist/utils/index.cjs +441 -0
  44. package/dist/utils/index.cjs.map +1 -0
  45. package/dist/utils/index.d.ts +265 -0
  46. package/dist/utils/index.js +417 -0
  47. package/dist/utils/index.js.map +1 -0
  48. package/dist/utils/index.umd.js +447 -0
  49. package/dist/utils/index.umd.js.map +1 -0
  50. package/dist/vue/index.cjs +1935 -0
  51. package/dist/vue/index.cjs.map +1 -0
  52. package/dist/vue/index.d.ts +35 -0
  53. package/dist/vue/index.js +1933 -0
  54. package/dist/vue/index.js.map +1 -0
  55. package/dist/vue/index.umd.js +1941 -0
  56. package/dist/vue/index.umd.js.map +1 -0
  57. package/package.json +4 -1
  58. package/CHANGELOG.md +0 -101
  59. package/json-doc.test.json +0 -264
  60. package/rollup.config.mjs +0 -61
  61. package/src/angular/index.spec.ts +0 -8
  62. package/src/angular/index.ts +0 -1
  63. package/src/angular/mg-angular-logger/index.ts +0 -1
  64. package/src/angular/mg-angular-logger/mg-angular-logger.conf.ts +0 -3
  65. package/src/angular/mg-angular-logger/mg-angular-logger.spec.ts +0 -40
  66. package/src/angular/mg-angular-logger/mg-angular-logger.ts +0 -24
  67. package/src/locale/index.spec.ts +0 -24
  68. package/src/locale/index.ts +0 -1
  69. package/src/locale/locale.spec.ts +0 -291
  70. package/src/locale/locale.ts +0 -201
  71. package/src/playwright/config/index.ts +0 -43
  72. package/src/playwright/index.spec.ts +0 -16
  73. package/src/playwright/index.ts +0 -4
  74. package/src/playwright/utils/__snapshots__/utils.spec.ts.snap +0 -48
  75. package/src/playwright/utils/index.ts +0 -1
  76. package/src/playwright/utils/utils.spec.ts +0 -50
  77. package/src/playwright/utils/utils.ts +0 -77
  78. package/src/stencil/ide/__snapshots__/cem.spec.ts.snap +0 -248
  79. package/src/stencil/ide/__snapshots__/ide.spec.ts.snap +0 -414
  80. package/src/stencil/ide/cem.spec.ts +0 -35
  81. package/src/stencil/ide/cem.ts +0 -96
  82. package/src/stencil/ide/ide.spec.ts +0 -29
  83. package/src/stencil/ide/ide.ts +0 -221
  84. package/src/stencil/ide/index.ts +0 -2
  85. package/src/stencil/index.spec.ts +0 -16
  86. package/src/stencil/index.ts +0 -2
  87. package/src/stencil/normalize-boolean-attributes/index.ts +0 -1
  88. package/src/stencil/normalize-boolean-attributes/normalize-boolean-attributes.spec.ts +0 -63
  89. package/src/stencil/normalize-boolean-attributes/normalize-boolean-attributes.ts +0 -40
  90. package/src/storybook/index.spec.ts +0 -19
  91. package/src/storybook/index.ts +0 -1
  92. package/src/storybook/stencil/__snapshots__/stencil.spec.ts.snap +0 -329
  93. package/src/storybook/stencil/index.ts +0 -1
  94. package/src/storybook/stencil/stencil-shim.d.ts +0 -1
  95. package/src/storybook/stencil/stencil.conf.ts +0 -4
  96. package/src/storybook/stencil/stencil.spec.ts +0 -170
  97. package/src/storybook/stencil/stencil.ts +0 -377
  98. package/src/tests/index.spec.ts +0 -20
  99. package/src/tests/index.ts +0 -1
  100. package/src/tests/unit/__snapshots__/unit.spec.ts.snap +0 -52
  101. package/src/tests/unit/index.ts +0 -1
  102. package/src/tests/unit/unit.conf.ts +0 -16
  103. package/src/tests/unit/unit.spec.ts +0 -206
  104. package/src/tests/unit/unit.ts +0 -333
  105. package/src/utils/attributes/class-list/class-list.spec.ts +0 -36
  106. package/src/utils/attributes/class-list/class-list.ts +0 -51
  107. package/src/utils/attributes/class-list/index.ts +0 -1
  108. package/src/utils/attributes/id/id.spec.ts +0 -54
  109. package/src/utils/attributes/id/id.ts +0 -47
  110. package/src/utils/attributes/id/index.ts +0 -1
  111. package/src/utils/attributes/index.ts +0 -3
  112. package/src/utils/attributes/to-kebab-case/index.ts +0 -1
  113. package/src/utils/attributes/to-kebab-case/to-kebab-case.spec.ts +0 -29
  114. package/src/utils/attributes/to-kebab-case/to-kebab-case.ts +0 -23
  115. package/src/utils/components/__snapshots__/components.spec.ts.snap +0 -313
  116. package/src/utils/components/components.conf.ts +0 -11
  117. package/src/utils/components/components.spec.ts +0 -192
  118. package/src/utils/components/components.ts +0 -152
  119. package/src/utils/components/index.ts +0 -2
  120. package/src/utils/date/date.spec.ts +0 -12
  121. package/src/utils/date/date.ts +0 -20
  122. package/src/utils/date/index.ts +0 -1
  123. package/src/utils/elements/elements.spec.ts +0 -17
  124. package/src/utils/elements/elements.ts +0 -18
  125. package/src/utils/elements/index.ts +0 -1
  126. package/src/utils/index.spec.ts +0 -84
  127. package/src/utils/index.ts +0 -8
  128. package/src/utils/number/index.ts +0 -1
  129. package/src/utils/number/number.spec.ts +0 -14
  130. package/src/utils/number/number.ts +0 -6
  131. package/src/utils/object/index.ts +0 -2
  132. package/src/utils/object/object.conf.ts +0 -4
  133. package/src/utils/object/object.spec.ts +0 -110
  134. package/src/utils/object/object.ts +0 -27
  135. package/src/utils/string/index.ts +0 -1
  136. package/src/utils/string/string.spec.ts +0 -54
  137. package/src/utils/string/string.ts +0 -39
  138. package/src/utils/windows/index.ts +0 -1
  139. package/src/utils/windows/windows.spec.ts +0 -69
  140. package/src/utils/windows/windows.ts +0 -50
  141. package/src/vue/index.spec.ts +0 -8
  142. package/src/vue/index.ts +0 -1
  143. package/src/vue/mg-model/index.ts +0 -1
  144. package/src/vue/mg-model/mg-model.conf.ts +0 -6
  145. package/src/vue/mg-model/mg-model.spec.ts +0 -50
  146. package/src/vue/mg-model/mg-model.ts +0 -55
  147. package/tsconfig.json +0 -17
  148. package/typedoc.json +0 -14
  149. package/vitest.config.mts +0 -13
@@ -1,50 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { renderAttributes, renderProperties } from './utils';
3
-
4
- describe('utils', () => {
5
- describe('renderAttributes', () => {
6
- test.each([
7
- undefined,
8
- null,
9
- {},
10
- { name: 'batman' },
11
- { name: '<div class="blu">blu</div>' },
12
- { name: 'batman', user: 'bruce', active: true, id: 1, object: {}, array: [], function: () => {} },
13
- { emptyString: '' },
14
- { name: 0 },
15
- { name: false },
16
- { name: ' ' },
17
- { name: null },
18
- { name: undefined },
19
- ' ',
20
- ])('Should render attributes', (args) => {
21
- const res = renderAttributes(args as Record<string, unknown>);
22
- expect(res).toMatchSnapshot();
23
- });
24
- });
25
-
26
- describe('renderProperties', () => {
27
- test('Should render properties, case id selector', () => {
28
- const res = renderProperties({ object: {} }, '#id');
29
- expect(res).toEqual("\n document.getElementById('id').object={};");
30
- });
31
- test.each([undefined, null, {}, { name: 'batman' }])('Should not render attributes as properties', (args) => {
32
- const res = renderProperties(args as Record<string, unknown>, 'div');
33
- expect(res).toMatchSnapshot();
34
- });
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
- });
49
- });
50
- });
@@ -1,77 +0,0 @@
1
- import { isObject, isValidString } from '../../utils';
2
-
3
- /**
4
- * Render attributes from props objects.
5
- *
6
- * Booleans follow the HTML spec for boolean attributes: `true` emits an empty-value attribute
7
- * (presence implies `true`), `false` omits the attribute entirely. This matches the behaviour
8
- * of the `normalizeBooleanAttributes` Stencil helper.
9
- * @param args - argument to render as string. ex: `{status: 'visible'}`
10
- * @returns formated inline attributed. ex: 'status="visible"'
11
- * @example
12
- * ```ts
13
- * import { renderAttributes } from '@mgdis/core-ui-helpers/dist/playwright';
14
- *
15
- * const attributes = renderAttributes({ status: 'visible', color: 'red', disabled: true, readonly: false });
16
- * console.log(attributes); // Output: 'status="visible" color="red" disabled=""'
17
- * ```
18
- */
19
- export const renderAttributes = (args: Record<string, unknown>): string =>
20
- (isObject<Record<string, never>>(args) &&
21
- Object.keys(args)
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) => {
29
- const attribute: string = key.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
30
- if (args[key] === true) return `${attribute}=""`;
31
- const value: string =
32
- typeof args[key] === 'number' || isValidString(args[key]) ? String(args[key]).replace(/"/g, "'") : '';
33
- return `${attribute}="${value}"`;
34
- })
35
- .join(' ')) ||
36
- '';
37
-
38
- /**
39
- * Render properties from props objects.
40
- * Insert return value in <script></script> element
41
- * @param args - argument to render as script. ex: `{status: 'visible'}`
42
- * @param selector - querySelector get targetted element and bind properties on it
43
- * @returns stringified properties script
44
- * @example
45
- * ```ts
46
- * import { renderProperties } from '@mgdis/core-ui-helpers/dist/playwright';
47
- *
48
- * const propertiesScript = renderProperties({ status: 'visible', color: 'red' }, '.targetElement');
49
- * console.log(propertiesScript);
50
- * // Output: 'document.querySelector(".targetElement").status="visible"; document.querySelector(".targetElement").color="red";'
51
- * ```
52
- */
53
- export const renderProperties = (args: Record<string, unknown>, selector: string): string => {
54
- // has generated id selector starting with "#" create charcters (ex: '#0j3xzw4w7m') make test crashed sometime with "querySelector"
55
- // we use "getElementById" document query
56
- const query: 'querySelector' | 'getElementById' = selector.startsWith('#') ? 'getElementById' : 'querySelector';
57
- if (query === 'getElementById') selector = selector.replace('#', '');
58
-
59
- return args !== null && typeof args === 'object' && Object.keys(args).length > 0
60
- ? `
61
- ${
62
- Object.keys(args)
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
- );
68
- return `document.${query}('${selector}').${key}=${value}`;
69
- }) // stringify json AND keep function values
70
- .join(';') // create string
71
- .split('"<fn>') // remove fn start decorator
72
- .join('')
73
- .split('</fn>"')
74
- .join('') // remove fn end decorator
75
- };`
76
- : '';
77
- };
@@ -1,248 +0,0 @@
1
- // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
-
3
- exports[`cemGenerator > Should generate Custom Elements Manifest v2 1`] = `
4
- {
5
- "modules": [
6
- {
7
- "declarations": [
8
- {
9
- "attributes": [
10
- {
11
- "description": "docs",
12
- "fieldName": "prop",
13
- "name": "prop",
14
- "type": {
15
- "text": "string",
16
- },
17
- },
18
- {
19
- "description": "docs",
20
- "fieldName": "multionetype",
21
- "name": "multionetype",
22
- "type": {
23
- "text": "(string | number)[]",
24
- },
25
- },
26
- {
27
- "description": "docs",
28
- "fieldName": "number",
29
- "name": "number",
30
- "type": {
31
- "text": "number",
32
- },
33
- },
34
- {
35
- "default": "false",
36
- "description": "docs",
37
- "fieldName": "boolean",
38
- "name": "boolean",
39
- "type": {
40
- "text": "boolean",
41
- },
42
- },
43
- {
44
- "description": "docs",
45
- "fieldName": "objecttype",
46
- "name": "objecttype",
47
- "type": {
48
- "text": "{ type: string, value: "blu" | "bli" }",
49
- },
50
- },
51
- {
52
- "description": "docs",
53
- "fieldName": "multitype",
54
- "name": "multitype",
55
- "type": {
56
- "text": ""blu" | "bli"",
57
- },
58
- },
59
- {
60
- "description": "docs",
61
- "fieldName": "multitypewithstring",
62
- "name": "multitypewithstring",
63
- "type": {
64
- "text": "number | string",
65
- },
66
- },
67
- {
68
- "description": "docs",
69
- "fieldName": "arraytypes",
70
- "name": "arraytypes",
71
- "type": {
72
- "text": "number[] | string[]",
73
- },
74
- },
75
- ],
76
- "cssParts": [
77
- {
78
- "description": "docs",
79
- "name": "icon",
80
- },
81
- ],
82
- "cssProperties": [
83
- {
84
- "description": "Custom property documentation",
85
- "name": "--custom-property",
86
- },
87
- ],
88
- "customElement": true,
89
- "description": "",
90
- "events": [
91
- {
92
- "description": "docs",
93
- "name": "event",
94
- "type": {
95
- "text": "CustomEvent<boolean>",
96
- },
97
- },
98
- ],
99
- "kind": "class",
100
- "members": [
101
- {
102
- "attribute": "prop",
103
- "description": "docs",
104
- "kind": "field",
105
- "name": "prop",
106
- "type": {
107
- "text": "string",
108
- },
109
- },
110
- {
111
- "description": "docs",
112
- "kind": "field",
113
- "name": "attr",
114
- "type": {
115
- "text": "string",
116
- },
117
- },
118
- {
119
- "attribute": "multionetype",
120
- "description": "docs",
121
- "kind": "field",
122
- "name": "multionetype",
123
- "type": {
124
- "text": "(string | number)[]",
125
- },
126
- },
127
- {
128
- "attribute": "number",
129
- "description": "docs",
130
- "kind": "field",
131
- "name": "number",
132
- "type": {
133
- "text": "number",
134
- },
135
- },
136
- {
137
- "attribute": "boolean",
138
- "default": "false",
139
- "description": "docs",
140
- "kind": "field",
141
- "name": "boolean",
142
- "type": {
143
- "text": "boolean",
144
- },
145
- },
146
- {
147
- "attribute": "objecttype",
148
- "description": "docs",
149
- "kind": "field",
150
- "name": "objecttype",
151
- "type": {
152
- "text": "{ type: string, value: "blu" | "bli" }",
153
- },
154
- },
155
- {
156
- "attribute": "multitype",
157
- "description": "docs",
158
- "kind": "field",
159
- "name": "multitype",
160
- "type": {
161
- "text": ""blu" | "bli"",
162
- },
163
- },
164
- {
165
- "attribute": "multitypewithstring",
166
- "description": "docs",
167
- "kind": "field",
168
- "name": "multitypewithstring",
169
- "type": {
170
- "text": "number | string",
171
- },
172
- },
173
- {
174
- "attribute": "arraytypes",
175
- "description": "docs",
176
- "kind": "field",
177
- "name": "arraytypes",
178
- "type": {
179
- "text": "number[] | string[]",
180
- },
181
- },
182
- {
183
- "description": "docs",
184
- "kind": "method",
185
- "name": "method",
186
- },
187
- ],
188
- "name": "MyComp",
189
- "slots": [
190
- {
191
- "description": "",
192
- "name": "",
193
- },
194
- {
195
- "description": "",
196
- "name": "title",
197
- },
198
- ],
199
- "tagName": "my-comp",
200
- },
201
- ],
202
- "exports": [
203
- {
204
- "declaration": {
205
- "module": "src/components/atoms/my-comp/my-comp.tsx",
206
- "name": "MyComp",
207
- },
208
- "kind": "custom-element-definition",
209
- "name": "my-comp",
210
- },
211
- ],
212
- "kind": "javascript-module",
213
- "path": "src/components/atoms/my-comp/my-comp.tsx",
214
- },
215
- {
216
- "declarations": [
217
- {
218
- "attributes": [],
219
- "cssParts": [],
220
- "cssProperties": [],
221
- "customElement": true,
222
- "description": "overview",
223
- "events": [],
224
- "kind": "class",
225
- "members": [],
226
- "name": "MySecondComp",
227
- "slots": [],
228
- "tagName": "my-second-comp",
229
- },
230
- ],
231
- "exports": [
232
- {
233
- "declaration": {
234
- "module": "",
235
- "name": "MySecondComp",
236
- },
237
- "kind": "custom-element-definition",
238
- "name": "my-second-comp",
239
- },
240
- ],
241
- "kind": "javascript-module",
242
- "path": "",
243
- },
244
- ],
245
- "readme": "",
246
- "schemaVersion": "2.0.0",
247
- }
248
- `;