@schalkneethling/miyagi-core 4.4.2 → 4.4.4
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.
- package/README.md +7 -2
- package/api/app.js +16 -16
- package/api/index.js +263 -262
- package/bin/miyagi.js +1 -1
- package/dist/css/iframe.css +6 -30
- package/frontend/assets/css/iframe/accordion-tabs.css +39 -39
- package/frontend/assets/css/iframe/jsontree.js.css +149 -149
- package/frontend/assets/css/iframe/prism.css +45 -45
- package/frontend/assets/css/iframe/styleguide/colors.css +27 -27
- package/frontend/assets/css/iframe/styleguide/fonts.css +23 -23
- package/frontend/assets/css/iframe/styleguide/index.css +58 -58
- package/frontend/assets/css/iframe/styleguide/spacings.css +10 -10
- package/frontend/assets/css/iframe.css +191 -191
- package/frontend/assets/css/main/menu/config-switcher.css +21 -21
- package/frontend/assets/css/main/menu/config-switchers.css +34 -34
- package/frontend/assets/css/main/menu/goto.css +16 -16
- package/frontend/assets/css/main/menu/nav.css +49 -49
- package/frontend/assets/css/main/menu/search.css +34 -34
- package/frontend/assets/css/main/menu/title.css +18 -18
- package/frontend/assets/css/main/menu.css +89 -89
- package/frontend/assets/css/main/reset.css +47 -47
- package/frontend/assets/css/main.css +41 -41
- package/frontend/assets/css/shared.css +16 -16
- package/frontend/assets/css/tokens.css +108 -107
- package/frontend/assets/js/_accordion-tabs.js +392 -392
- package/frontend/assets/js/_goto.js +59 -59
- package/frontend/assets/js/_iframe-links.js +14 -14
- package/frontend/assets/js/_is-triggered.js +3 -3
- package/frontend/assets/js/_main.js +369 -369
- package/frontend/assets/js/_mock-data.js +8 -8
- package/frontend/assets/js/_prism.js +1082 -1081
- package/frontend/assets/js/_search.js +186 -186
- package/frontend/assets/js/_socket.js +44 -44
- package/frontend/assets/js/config-switcher/development-mode.js +38 -38
- package/frontend/assets/js/config-switcher/index.js +55 -55
- package/frontend/assets/js/config-switcher/text-direction.js +22 -22
- package/frontend/assets/js/config-switcher/theme.js +68 -68
- package/frontend/assets/js/iframe.build.js +25 -25
- package/frontend/assets/js/iframe.js +38 -38
- package/frontend/assets/js/jsontree.js +979 -976
- package/frontend/assets/js/main.build.js +29 -29
- package/frontend/assets/js/main.js +31 -31
- package/frontend/assets/js/styleguide/color-converter.js +652 -652
- package/frontend/assets/js/styleguide/index.js +100 -100
- package/lib/build/index.js +1014 -1020
- package/lib/cli/app.js +16 -16
- package/lib/cli/component.js +50 -50
- package/lib/cli/doctor.js +130 -121
- package/lib/cli/drupal-assets.js +163 -157
- package/lib/cli/lint.js +196 -196
- package/lib/cli/run.js +150 -146
- package/lib/config.js +86 -86
- package/lib/constants/lint-log-levels.js +6 -6
- package/lib/drupal/load-assets-config.js +59 -60
- package/lib/drupal/resolve-library-assets.js +132 -141
- package/lib/errors.js +20 -20
- package/lib/generator/component.js +124 -124
- package/lib/generator/mocks.js +156 -156
- package/lib/helpers.js +68 -68
- package/lib/i18n/en.js +93 -93
- package/lib/i18n/index.js +8 -8
- package/lib/index.js +13 -13
- package/lib/init/args.js +153 -153
- package/lib/init/config.js +452 -438
- package/lib/init/engines.js +41 -41
- package/lib/init/index.js +83 -83
- package/lib/init/rendering.js +3 -3
- package/lib/init/static.js +90 -90
- package/lib/init/twing/cache.js +27 -27
- package/lib/init/twing/functions.js +37 -37
- package/lib/init/views.js +5 -5
- package/lib/logger.js +72 -72
- package/lib/mocks/get.js +88 -88
- package/lib/mocks/index.js +2 -2
- package/lib/mocks/resolve/ref.js +447 -447
- package/lib/mocks/resolve/tpl.js +218 -218
- package/lib/mocks/resolve.js +154 -154
- package/lib/render/helpers/resolve-assets.js +29 -39
- package/lib/render/helpers.js +27 -27
- package/lib/render/index.js +18 -18
- package/lib/render/views/iframe/component.docs.js +50 -50
- package/lib/render/views/iframe/component.js +249 -248
- package/lib/render/views/iframe/design-tokens/colors.js +38 -38
- package/lib/render/views/iframe/design-tokens/index.js +3 -3
- package/lib/render/views/iframe/design-tokens/sizes.js +35 -35
- package/lib/render/views/iframe/design-tokens/typography.js +37 -37
- package/lib/render/views/iframe/docs.js +42 -42
- package/lib/render/views/iframe/index.js +28 -28
- package/lib/render/views/iframe/variation.js +89 -89
- package/lib/render/views/iframe/variation.standalone.js +69 -68
- package/lib/render/views/main/component.docs.js +38 -38
- package/lib/render/views/main/component.js +55 -55
- package/lib/render/views/main/design-tokens.js +38 -38
- package/lib/render/views/main/docs.js +33 -33
- package/lib/render/views/main/index.js +33 -33
- package/lib/state/components.js +99 -99
- package/lib/state/css.js +33 -33
- package/lib/state/docs.js +72 -72
- package/lib/state/file-contents.js +154 -154
- package/lib/state/helpers.js +53 -53
- package/lib/state/index.js +39 -39
- package/lib/state/menu/index.js +202 -202
- package/lib/state/menu/structure.js +84 -84
- package/lib/state/partials.js +12 -12
- package/lib/state/source-tree.js +51 -51
- package/lib/styleguide/color-names.js +148 -148
- package/lib/styleguide/colors.js +113 -113
- package/lib/styleguide/helpers.js +33 -33
- package/lib/styleguide/index.js +4 -4
- package/lib/styleguide/media-queries.js +18 -18
- package/lib/styleguide/spacings.js +22 -22
- package/lib/styleguide/typography.js +46 -46
- package/lib/validator/mocks.js +110 -83
- package/lib/validator/schemas.js +236 -227
- package/package.json +120 -117
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
import { createSynchronousFunction } from "twing";
|
|
2
2
|
|
|
3
3
|
export const isExpanded = createSynchronousFunction(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
"is_expanded",
|
|
5
|
+
(_context, item, requestedComponent) => {
|
|
6
|
+
if (item.topLevel) return true;
|
|
7
|
+
if (!requestedComponent) return false;
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
return !!(
|
|
10
|
+
item.children?.find(
|
|
11
|
+
({ shortPath }) => shortPath === requestedComponent,
|
|
12
|
+
) ||
|
|
13
|
+
(item.shortPath && item.shortPath === requestedComponent) ||
|
|
14
|
+
requestedComponent.startsWith(item.shortPath)
|
|
15
|
+
);
|
|
16
|
+
},
|
|
17
|
+
[{ name: "item" }, { name: "requestedComponent" }],
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
export const isActiveComponent = createSynchronousFunction(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
"is_active_component",
|
|
22
|
+
(_context, item, requestedComponent, requestedVariation) => {
|
|
23
|
+
if (!requestedComponent) return false;
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
if (requestedComponent === "design-tokens") {
|
|
26
|
+
return (
|
|
27
|
+
item.section === "design-tokens" && item.name == requestedVariation
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
return (
|
|
32
|
+
item.shortPath &&
|
|
33
|
+
item.shortPath === requestedComponent &&
|
|
34
|
+
!requestedVariation
|
|
35
|
+
);
|
|
36
|
+
},
|
|
37
|
+
["item", "requestedComponent", "requestedVariation"],
|
|
38
38
|
);
|
|
39
39
|
|
|
40
40
|
export const isActiveVariant = createSynchronousFunction(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
"is_active_variant",
|
|
42
|
+
(_context, item, requestedComponent, requestedVariation) => {
|
|
43
|
+
if (!item || !requestedComponent || !requestedVariation) return false;
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
return (
|
|
46
|
+
requestedComponent == item.parentShortPath &&
|
|
47
|
+
requestedVariation == item.name
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
["item", "requestedComponent", "requestedVariation"],
|
|
51
51
|
);
|
package/lib/init/views.js
CHANGED
|
@@ -9,11 +9,11 @@ import path from "path";
|
|
|
9
9
|
* @returns {void}
|
|
10
10
|
*/
|
|
11
11
|
export default function initViews() {
|
|
12
|
-
|
|
12
|
+
const views = [path.join(import.meta.dirname, "../../frontend/views")];
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
if (global.config.components.folder) {
|
|
15
|
+
views.push(path.resolve(global.config.components.folder));
|
|
16
|
+
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
global.app.set("views", views);
|
|
19
19
|
}
|
package/lib/logger.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
LINT_LOG_LEVEL_ORDER,
|
|
3
|
+
LINT_LOG_LEVELS,
|
|
4
4
|
} from "./constants/lint-log-levels.js";
|
|
5
5
|
|
|
6
6
|
const COLORS = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
grey: "\x1b[90m",
|
|
8
|
+
red: "\x1b[31m",
|
|
9
|
+
yellow: "\x1b[33m",
|
|
10
|
+
green: "\x1b[32m",
|
|
11
|
+
cyan: "\x1b[36m",
|
|
12
|
+
white: "\x1b[37m",
|
|
13
|
+
reset: "\x1b[0m",
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const TYPES = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
error: { console: "error", label: "Error", color: "red" },
|
|
18
|
+
warn: { console: "warn", label: "Warning", color: "yellow" },
|
|
19
|
+
success: { console: "log", label: "Success", color: "green" },
|
|
20
|
+
info: { console: "info", label: "Info", color: "cyan" },
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -26,51 +26,51 @@ const TYPES = {
|
|
|
26
26
|
* @param {string|Error} [verboseMessage]
|
|
27
27
|
*/
|
|
28
28
|
export default function log(type, message, verboseMessage) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
if (process.env.MIYAGI_JS_API) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (!(type in TYPES)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
if (!shouldLogType(type)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
41
|
+
const date = new Date();
|
|
42
|
+
const year = date.getFullYear();
|
|
43
|
+
const month = pad(date.getMonth() + 1);
|
|
44
|
+
const day = pad(date.getDate());
|
|
45
|
+
const hours = pad(date.getHours());
|
|
46
|
+
const minutes = pad(date.getMinutes());
|
|
47
|
+
const seconds = pad(date.getSeconds());
|
|
48
|
+
const dateStr = `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
|
|
49
|
+
const params = {
|
|
50
|
+
type: TYPES[type].console,
|
|
51
|
+
dateStr,
|
|
52
|
+
color: TYPES[type].color,
|
|
53
|
+
label: TYPES[type].label,
|
|
54
|
+
};
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
if (message) {
|
|
57
|
+
printMessage({
|
|
58
|
+
...params,
|
|
59
|
+
message,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
if (process.env.VERBOSE && verboseMessage) {
|
|
64
|
+
if (type === "error") {
|
|
65
|
+
console.error(verboseMessage);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
printMessage({
|
|
70
|
+
...params,
|
|
71
|
+
message: verboseMessage,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/**
|
|
@@ -78,20 +78,20 @@ export default function log(type, message, verboseMessage) {
|
|
|
78
78
|
* @returns {boolean}
|
|
79
79
|
*/
|
|
80
80
|
function shouldLogType(type) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
if (process.env.MIYAGI_LOG_CONTEXT !== "lint") {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
85
|
+
const configuredLevel = process.env.MIYAGI_LOG_LEVEL || "error";
|
|
86
|
+
const normalizedType = type === "success" ? "info" : type;
|
|
87
|
+
const configuredLevelValue =
|
|
88
|
+
LINT_LOG_LEVEL_ORDER[configuredLevel] ??
|
|
89
|
+
LINT_LOG_LEVEL_ORDER[LINT_LOG_LEVELS.ERROR];
|
|
90
|
+
const typeLevelValue =
|
|
91
|
+
LINT_LOG_LEVEL_ORDER[normalizedType] ??
|
|
92
|
+
LINT_LOG_LEVEL_ORDER[LINT_LOG_LEVELS.INFO];
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
return typeLevelValue <= configuredLevelValue;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/**
|
|
@@ -100,7 +100,7 @@ function shouldLogType(type) {
|
|
|
100
100
|
* @returns {string}
|
|
101
101
|
*/
|
|
102
102
|
function colorize(color, str) {
|
|
103
|
-
|
|
103
|
+
return `${COLORS[color]}${str}`;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
/**
|
|
@@ -108,7 +108,7 @@ function colorize(color, str) {
|
|
|
108
108
|
* @returns {string}
|
|
109
109
|
*/
|
|
110
110
|
function pad(value) {
|
|
111
|
-
|
|
111
|
+
return value.toString().padStart(2, "0");
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
/**
|
|
@@ -120,10 +120,10 @@ function pad(value) {
|
|
|
120
120
|
* @param {string|Error} o.message
|
|
121
121
|
*/
|
|
122
122
|
function printMessage({ type, dateStr, color, label, message }) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
123
|
+
console[type](
|
|
124
|
+
`${colorize("grey", dateStr)} ${colorize(
|
|
125
|
+
color,
|
|
126
|
+
`${label}:`,
|
|
127
|
+
)} ${COLORS.reset}${message}`,
|
|
128
|
+
);
|
|
129
129
|
}
|
package/lib/mocks/get.js
CHANGED
|
@@ -7,109 +7,109 @@ import * as helpers from "../helpers.js";
|
|
|
7
7
|
* @returns {Promise<[]>}
|
|
8
8
|
*/
|
|
9
9
|
export const getComponentData = async function getComponentData(component) {
|
|
10
|
-
|
|
10
|
+
if (!component) return null;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
const componentJson = helpers.cloneDeep(
|
|
13
|
+
global.state.fileContents[
|
|
14
|
+
component.paths.mocks.full(global.config.files.mocks.extension[0])
|
|
15
|
+
] ||
|
|
16
|
+
global.state.fileContents[
|
|
17
|
+
component.paths.mocks.full(global.config.files.mocks.extension[1])
|
|
18
|
+
],
|
|
19
|
+
);
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
let context = null;
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
if (componentJson) {
|
|
24
|
+
context = [];
|
|
25
|
+
const componentDeclaredAssets = componentJson.$assets || null;
|
|
26
|
+
let componentData = helpers.removeInternalKeys(componentJson);
|
|
27
|
+
const rootData = helpers.cloneDeep(componentData);
|
|
28
|
+
const componentVariations = componentJson.$variants;
|
|
29
|
+
let data;
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
if (Object.keys(componentData).length > 0) {
|
|
32
|
+
data = await resolveData(componentData, component);
|
|
33
|
+
} else {
|
|
34
|
+
data = {
|
|
35
|
+
messages: [],
|
|
36
|
+
merged: componentData,
|
|
37
|
+
resolved: componentData,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
if (componentVariations) {
|
|
42
|
+
let startIndex = context.length;
|
|
43
|
+
for (const [index, variationJson] of componentVariations.entries()) {
|
|
44
|
+
if (variationJson.$name) {
|
|
45
|
+
const variationData = helpers.removeInternalKeys(variationJson);
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
const { messages, merged, resolved } = await resolveData(
|
|
48
|
+
variationData,
|
|
49
|
+
component,
|
|
50
|
+
rootData,
|
|
51
|
+
);
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
context[startIndex + index] = {
|
|
54
|
+
messages,
|
|
55
|
+
component: component.paths.dir.short,
|
|
56
|
+
resolved: resolved,
|
|
57
|
+
raw: merged,
|
|
58
|
+
name: variationJson.$name,
|
|
59
|
+
$assets: componentDeclaredAssets,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
64
|
+
if (Object.keys(data.resolved).length > 0) {
|
|
65
|
+
if (!componentJson.$hidden) {
|
|
66
|
+
context.unshift({
|
|
67
|
+
messages: data.messages,
|
|
68
|
+
component: component.paths.dir.short,
|
|
69
|
+
resolved: data.resolved,
|
|
70
|
+
raw: data.merged,
|
|
71
|
+
name: componentJson.$name || config.defaultVariationName,
|
|
72
|
+
$assets: componentDeclaredAssets,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
return context.filter((entry) => entry !== null);
|
|
78
|
+
} else {
|
|
79
|
+
if (Object.keys(componentData).length > 0) {
|
|
80
|
+
const { messages, merged, resolved } = await resolveData(
|
|
81
|
+
componentData,
|
|
82
|
+
component,
|
|
83
|
+
);
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
context.unshift({
|
|
86
|
+
messages,
|
|
87
|
+
component: component.paths.dir.short,
|
|
88
|
+
resolved: componentJson.$hidden ? {} : resolved,
|
|
89
|
+
raw: componentJson.$hidden ? {} : merged,
|
|
90
|
+
name: componentJson.$name || config.defaultVariationName,
|
|
91
|
+
$assets: componentDeclaredAssets,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
return context;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
return context;
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
export const getVariationData = async function getVariationData(
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
component,
|
|
104
|
+
variation,
|
|
105
105
|
) {
|
|
106
|
-
|
|
106
|
+
const data = await getComponentData(component);
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
108
|
+
return (
|
|
109
|
+
data?.filter(
|
|
110
|
+
(entry) =>
|
|
111
|
+
entry.name.toLowerCase().replaceAll(" ", "-") ===
|
|
112
|
+
variation.toLowerCase().replaceAll(" ", "-"),
|
|
113
|
+
)[0] ?? null
|
|
114
|
+
);
|
|
115
115
|
};
|
package/lib/mocks/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
getComponentData as getComponentDataImport,
|
|
3
|
+
getVariationData as getVariationDataImport,
|
|
4
4
|
} from "./get.js";
|
|
5
5
|
import { resolveData as resolveDataImport } from "./resolve.js";
|
|
6
6
|
|