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