@mgdis/core-ui-helpers 1.0.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 (146) hide show
  1. package/.turbo/turbo-build.log +52 -0
  2. package/CHANGELOG.md +12 -0
  3. package/LICENSE +29 -0
  4. package/README.md +95 -0
  5. package/dist/angular/index.cjs +27 -0
  6. package/dist/angular/index.cjs.map +1 -0
  7. package/dist/angular/index.d.ts +21 -0
  8. package/dist/angular/index.js +25 -0
  9. package/dist/angular/index.js.map +1 -0
  10. package/dist/angular/index.umd.js +33 -0
  11. package/dist/angular/index.umd.js.map +1 -0
  12. package/dist/locale/index.cjs +164 -0
  13. package/dist/locale/index.cjs.map +1 -0
  14. package/dist/locale/index.d.ts +103 -0
  15. package/dist/locale/index.js +156 -0
  16. package/dist/locale/index.js.map +1 -0
  17. package/dist/locale/index.umd.js +170 -0
  18. package/dist/locale/index.umd.js.map +1 -0
  19. package/dist/playwright/index.cjs +124 -0
  20. package/dist/playwright/index.cjs.map +1 -0
  21. package/dist/playwright/index.d.ts +35 -0
  22. package/dist/playwright/index.js +120 -0
  23. package/dist/playwright/index.js.map +1 -0
  24. package/dist/playwright/index.umd.js +130 -0
  25. package/dist/playwright/index.umd.js.map +1 -0
  26. package/dist/stencil/index.cjs +281 -0
  27. package/dist/stencil/index.cjs.map +1 -0
  28. package/dist/stencil/index.d.ts +111 -0
  29. package/dist/stencil/index.js +277 -0
  30. package/dist/stencil/index.js.map +1 -0
  31. package/dist/stencil/index.umd.js +287 -0
  32. package/dist/stencil/index.umd.js.map +1 -0
  33. package/dist/storybook/index.cjs +2109 -0
  34. package/dist/storybook/index.cjs.map +1 -0
  35. package/dist/storybook/index.d.ts +85 -0
  36. package/dist/storybook/index.js +2103 -0
  37. package/dist/storybook/index.js.map +1 -0
  38. package/dist/storybook/index.umd.js +2115 -0
  39. package/dist/storybook/index.umd.js.map +1 -0
  40. package/dist/tests/index.cjs +166 -0
  41. package/dist/tests/index.cjs.map +1 -0
  42. package/dist/tests/index.d.ts +91 -0
  43. package/dist/tests/index.js +161 -0
  44. package/dist/tests/index.js.map +1 -0
  45. package/dist/tests/index.umd.js +172 -0
  46. package/dist/tests/index.umd.js.map +1 -0
  47. package/dist/utils/index.cjs +433 -0
  48. package/dist/utils/index.cjs.map +1 -0
  49. package/dist/utils/index.d.ts +265 -0
  50. package/dist/utils/index.js +409 -0
  51. package/dist/utils/index.js.map +1 -0
  52. package/dist/utils/index.umd.js +439 -0
  53. package/dist/utils/index.umd.js.map +1 -0
  54. package/dist/vue/index.cjs +1934 -0
  55. package/dist/vue/index.cjs.map +1 -0
  56. package/dist/vue/index.d.ts +35 -0
  57. package/dist/vue/index.js +1932 -0
  58. package/dist/vue/index.js.map +1 -0
  59. package/dist/vue/index.umd.js +1940 -0
  60. package/dist/vue/index.umd.js.map +1 -0
  61. package/json-doc.test.json +253 -0
  62. package/package.json +80 -0
  63. package/rollup.config.mjs +61 -0
  64. package/src/angular/index.spec.ts +8 -0
  65. package/src/angular/index.ts +1 -0
  66. package/src/angular/mg-angular-logger/index.ts +1 -0
  67. package/src/angular/mg-angular-logger/mg-angular-logger.conf.ts +3 -0
  68. package/src/angular/mg-angular-logger/mg-angular-logger.spec.ts +40 -0
  69. package/src/angular/mg-angular-logger/mg-angular-logger.ts +23 -0
  70. package/src/locale/index.spec.ts +14 -0
  71. package/src/locale/index.ts +1 -0
  72. package/src/locale/locale.spec.ts +173 -0
  73. package/src/locale/locale.ts +166 -0
  74. package/src/playwright/config/index.ts +43 -0
  75. package/src/playwright/index.spec.ts +16 -0
  76. package/src/playwright/index.ts +4 -0
  77. package/src/playwright/utils/__snapshots__/utils.spec.ts.snap +48 -0
  78. package/src/playwright/utils/index.ts +1 -0
  79. package/src/playwright/utils/utils.spec.ts +43 -0
  80. package/src/playwright/utils/utils.ts +64 -0
  81. package/src/stencil/ide/__snapshots__/ide.spec.ts.snap +527 -0
  82. package/src/stencil/ide/ide.spec.ts +25 -0
  83. package/src/stencil/ide/ide.ts +214 -0
  84. package/src/stencil/ide/index.ts +1 -0
  85. package/src/stencil/index.spec.ts +12 -0
  86. package/src/stencil/index.ts +1 -0
  87. package/src/storybook/index.spec.ts +15 -0
  88. package/src/storybook/index.ts +1 -0
  89. package/src/storybook/stencil/__snapshots__/stencil.spec.ts.snap +329 -0
  90. package/src/storybook/stencil/index.ts +1 -0
  91. package/src/storybook/stencil/stencil-shim.d.ts +1 -0
  92. package/src/storybook/stencil/stencil.conf.ts +4 -0
  93. package/src/storybook/stencil/stencil.spec.ts +142 -0
  94. package/src/storybook/stencil/stencil.ts +366 -0
  95. package/src/tests/index.spec.ts +13 -0
  96. package/src/tests/index.ts +1 -0
  97. package/src/tests/unit/__snapshots__/unit.spec.ts.snap +52 -0
  98. package/src/tests/unit/index.ts +1 -0
  99. package/src/tests/unit/unit.conf.ts +9 -0
  100. package/src/tests/unit/unit.spec.ts +44 -0
  101. package/src/tests/unit/unit.ts +171 -0
  102. package/src/utils/attributes/class-list/class-list.spec.ts +36 -0
  103. package/src/utils/attributes/class-list/class-list.ts +51 -0
  104. package/src/utils/attributes/class-list/index.ts +1 -0
  105. package/src/utils/attributes/id/id.spec.ts +51 -0
  106. package/src/utils/attributes/id/id.ts +46 -0
  107. package/src/utils/attributes/id/index.ts +1 -0
  108. package/src/utils/attributes/index.ts +3 -0
  109. package/src/utils/attributes/to-kebab-case/index.ts +1 -0
  110. package/src/utils/attributes/to-kebab-case/to-kebab-case.spec.ts +29 -0
  111. package/src/utils/attributes/to-kebab-case/to-kebab-case.ts +23 -0
  112. package/src/utils/components/__snapshots__/components.spec.ts.snap +313 -0
  113. package/src/utils/components/components.conf.ts +11 -0
  114. package/src/utils/components/components.spec.ts +192 -0
  115. package/src/utils/components/components.ts +138 -0
  116. package/src/utils/components/index.ts +2 -0
  117. package/src/utils/date/date.spec.ts +12 -0
  118. package/src/utils/date/date.ts +20 -0
  119. package/src/utils/date/index.ts +1 -0
  120. package/src/utils/elements/elements.spec.ts +17 -0
  121. package/src/utils/elements/elements.ts +16 -0
  122. package/src/utils/elements/index.ts +1 -0
  123. package/src/utils/index.spec.ts +84 -0
  124. package/src/utils/index.ts +8 -0
  125. package/src/utils/number/index.ts +1 -0
  126. package/src/utils/number/number.spec.ts +14 -0
  127. package/src/utils/number/number.ts +6 -0
  128. package/src/utils/object/index.ts +2 -0
  129. package/src/utils/object/object.conf.ts +4 -0
  130. package/src/utils/object/object.spec.ts +98 -0
  131. package/src/utils/object/object.ts +26 -0
  132. package/src/utils/string/index.ts +1 -0
  133. package/src/utils/string/string.spec.ts +47 -0
  134. package/src/utils/string/string.ts +38 -0
  135. package/src/utils/windows/index.ts +1 -0
  136. package/src/utils/windows/windows.spec.ts +65 -0
  137. package/src/utils/windows/windows.ts +50 -0
  138. package/src/vue/index.spec.ts +8 -0
  139. package/src/vue/index.ts +1 -0
  140. package/src/vue/mg-model/index.ts +1 -0
  141. package/src/vue/mg-model/mg-model.conf.ts +6 -0
  142. package/src/vue/mg-model/mg-model.spec.ts +50 -0
  143. package/src/vue/mg-model/mg-model.ts +50 -0
  144. package/tsconfig.json +17 -0
  145. package/typedoc.json +14 -0
  146. package/vitest.config.mts +13 -0
@@ -0,0 +1,277 @@
1
+ /*
2
+ Stencil Client Platform v4.28.2 | MIT Licensed | https://stenciljs.com
3
+ */
4
+ var __defProp = Object.defineProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+
10
+ // src/utils/result.ts
11
+ var result_exports = {};
12
+ __export(result_exports, {
13
+ err: () => err,
14
+ map: () => map,
15
+ ok: () => ok,
16
+ unwrap: () => unwrap,
17
+ unwrapErr: () => unwrapErr
18
+ });
19
+ var ok = (value) => ({
20
+ isOk: true,
21
+ isErr: false,
22
+ value
23
+ });
24
+ var err = (value) => ({
25
+ isOk: false,
26
+ isErr: true,
27
+ value
28
+ });
29
+ function map(result, fn) {
30
+ if (result.isOk) {
31
+ const val = fn(result.value);
32
+ if (val instanceof Promise) {
33
+ return val.then((newVal) => ok(newVal));
34
+ } else {
35
+ return ok(val);
36
+ }
37
+ }
38
+ if (result.isErr) {
39
+ const value = result.value;
40
+ return err(value);
41
+ }
42
+ throw "should never get here";
43
+ }
44
+ var unwrap = (result) => {
45
+ if (result.isOk) {
46
+ return result.value;
47
+ } else {
48
+ throw result.value;
49
+ }
50
+ };
51
+ var unwrapErr = (result) => {
52
+ if (result.isErr) {
53
+ return result.value;
54
+ } else {
55
+ throw result.value;
56
+ }
57
+ };
58
+
59
+ /**
60
+ * Retrieve Component Storybook URL from file path
61
+ * @param storybookBaseUrl - Storybook Base URL
62
+ * @param filePath - Component file path
63
+ * @returns Component Storybook URL
64
+ */
65
+ const getStorybookUrl = (storybookBaseUrl, filePath) => {
66
+ if (!filePath) {
67
+ return;
68
+ }
69
+ const split = filePath.split('/');
70
+ return `${storybookBaseUrl}${split.slice(2, split.length - 1).join('-')}--docs`;
71
+ };
72
+
73
+ /**
74
+ * Retrieve Component source URL from file path
75
+ * @param sourcesBaseUrl - Source base URL
76
+ * @param filePath - Component file path
77
+ * @returns Component source URL
78
+ */
79
+ const getSourcesUrl = (sourcesBaseUrl, filePath) => {
80
+ if (!filePath) {
81
+ return;
82
+ }
83
+ return `${sourcesBaseUrl}${filePath}`;
84
+ };
85
+ /**
86
+ * Get Component element description
87
+ * @param component - Component
88
+ * @returns Component element description
89
+ */
90
+ const getElementDescription = (component) => {
91
+ // Init description
92
+ let description = component.overview ? `${component.overview}\n\n` : '';
93
+ // Attributes
94
+ const attributes = component.props.filter(({ attr }) => attr !== undefined);
95
+ if (attributes.length) {
96
+ description += `Attributes:\n`;
97
+ description += attributes.map(({ attr, docs }) => `- \`${attr}\`: ${docs}\n`).join('');
98
+ description += '\n';
99
+ }
100
+ // Properties
101
+ const properties = component.props.filter(({ attr }) => attr === undefined);
102
+ if (properties.length) {
103
+ description += `Properties:\n`;
104
+ description += properties.map(({ name, docs }) => `- \`${name}\`: ${docs}\n`).join('');
105
+ description += '\n';
106
+ }
107
+ // Methods
108
+ if (component.methods.length) {
109
+ description += `Methods:\n`;
110
+ description += component.methods.map(({ name, docs }) => `- \`${name}\`: ${docs}\n`).join('');
111
+ description += '\n';
112
+ }
113
+ // Events
114
+ if (component.events.length) {
115
+ description += `Events:\n`;
116
+ description += component.events.map(({ event, docs }) => `- \`${event}\`: ${docs}\n`).join('');
117
+ description += '\n';
118
+ }
119
+ // Listeners
120
+ if (component.listeners.length) {
121
+ description += `Listeners:\n`;
122
+ description += component.listeners.map(({ event }) => `- \`${event}\`\n`).join('');
123
+ description += '\n';
124
+ }
125
+ // Slots
126
+ if (component.slots.length) {
127
+ description += `Slots:\n`;
128
+ description += component.slots.map(({ name, docs }) => `- \`${name}\`: ${docs}\n`).join('');
129
+ description += '\n';
130
+ }
131
+ // Return
132
+ return description;
133
+ };
134
+ /**
135
+ * Get Props Description
136
+ * @param prop - Component Property
137
+ * @returns Props Description
138
+ */
139
+ const getAttributeDescription = (prop) => {
140
+ return `${prop.docs}\n\nType: \`${prop.type}\``;
141
+ };
142
+ /**
143
+ * Generate Web Types metadata for IntelliJ's IDE
144
+ * @param name - Library name
145
+ * @param version - Library version
146
+ * @param jsonDocs - Stencil JSON doc
147
+ * @param storybookBaseUrl - Storybook Base Url
148
+ * @returns Web Types metadata
149
+ * @example
150
+ * ```ts
151
+ * const webTypesJson = webTypesGenerator('@mgdis/mg-components', '1.0.0', jsonDocs, 'https://storybook.example.com');
152
+ * ```
153
+ */
154
+ const webTypesGenerator = (name, version, jsonDocs, storybookBaseUrl) => ({
155
+ '$schema': 'https://json.schemastore.org/web-types',
156
+ name,
157
+ version,
158
+ 'description-markup': 'markdown',
159
+ 'contributions': {
160
+ html: {
161
+ elements: jsonDocs.components.map(component => {
162
+ const docUrl = getStorybookUrl(storybookBaseUrl, component.filePath);
163
+ return {
164
+ 'name': component.tag,
165
+ 'description': getElementDescription(component),
166
+ 'doc-url': docUrl,
167
+ 'attributes': component.props
168
+ .filter(prop => prop.attr)
169
+ .map(prop => ({
170
+ 'name': prop.attr,
171
+ 'description': getAttributeDescription(prop),
172
+ 'doc-url': docUrl,
173
+ 'value': {
174
+ type: prop.type,
175
+ default: prop.default,
176
+ required: prop.required,
177
+ },
178
+ })),
179
+ 'js': {
180
+ properties: component.props.map(prop => ({
181
+ 'name': prop.name,
182
+ 'description': getAttributeDescription(prop),
183
+ 'doc-url': docUrl,
184
+ 'value': {
185
+ type: prop.type,
186
+ default: prop.default,
187
+ required: prop.required,
188
+ },
189
+ })),
190
+ events: component.events.map(event => ({
191
+ name: event.event,
192
+ description: event.docs,
193
+ })),
194
+ },
195
+ 'css': {
196
+ properties: component.styles.map(style => ({
197
+ name: style.name,
198
+ description: style.docs,
199
+ })),
200
+ },
201
+ };
202
+ }),
203
+ },
204
+ },
205
+ });
206
+ /**
207
+ * Create Storybook Reference
208
+ * @param storybookBaseUrl - Storybook Base Url
209
+ * @param filePath - Component file path
210
+ * @returns Storybook Reference
211
+ */
212
+ const getReferences = (storybookBaseUrl, sourceBaseUrl, filePath) => {
213
+ return [
214
+ { name: 'Storybook', url: getStorybookUrl(storybookBaseUrl, filePath) },
215
+ { name: 'Sources', url: getSourcesUrl(sourceBaseUrl, filePath) },
216
+ ];
217
+ };
218
+ /**
219
+ * Get Property possible values
220
+ * @param prop - Component Property
221
+ * @returns Property possible values
222
+ */
223
+ const getValues = (prop) => {
224
+ // Only values Array where all objects have a value seems to be usefull
225
+ if (prop.values.some(({ value }) => value === undefined)) {
226
+ return;
227
+ }
228
+ return prop.values.map(({ value }) => ({ name: value }));
229
+ };
230
+ /**
231
+ * Generate custom HTML datasets for VS Code
232
+ * @param jsonDocs - Stencil JSON doc
233
+ * @param storybookBaseUrl - Storybook Base Url
234
+ * @returns custom HTML datasets
235
+ * @example
236
+ * ```ts
237
+ * const customDataJson = vsCodeGenerator(jsonDocs, 'https://storybook.example.com', 'https://sources.example.com');
238
+ * ```
239
+ */
240
+ const vsCodeGenerator = (jsonDocs, storybookBaseUrl, sourceBaseUrl) => ({
241
+ version: 1.1,
242
+ tags: jsonDocs.components.map(component => {
243
+ const references = getReferences(storybookBaseUrl, sourceBaseUrl, component.filePath);
244
+ return {
245
+ name: component.tag,
246
+ description: getElementDescription(component),
247
+ attributes: component.props.map(prop => ({
248
+ name: prop.attr ?? prop.name,
249
+ description: getAttributeDescription(prop),
250
+ values: getValues(prop),
251
+ references,
252
+ })),
253
+ references,
254
+ };
255
+ }),
256
+ globalAttributes: [],
257
+ valueSets: [],
258
+ });
259
+ /**
260
+ * Generate custom CSS datasets for VS Code
261
+ * @param jsonDocs - Stencil JSON doc
262
+ * @returns custom CSS datasets
263
+ * @example
264
+ * ```ts
265
+ * const customDataJson = vsCodeCssGenerator(jsonDocs);
266
+ * ```
267
+ */
268
+ const vsCodeCssGenerator = (jsonDocs) => ({
269
+ version: 1.1,
270
+ properties: jsonDocs.components.flatMap(component => component.styles.map(style => ({
271
+ name: style.name,
272
+ description: style.docs,
273
+ }))),
274
+ });
275
+
276
+ export { vsCodeCssGenerator, vsCodeGenerator, webTypesGenerator };
277
+ //# sourceMappingURL=index.js.map