storybook-addon-sdc 0.1.4 → 0.1.6
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 +1 -1
- package/dist/preset.js +157 -140
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -185,7 +185,7 @@ The [community will have to decide](https://docs.google.com/document/d/1wCQLXrK1
|
|
|
185
185
|
|
|
186
186
|
## Known issues:
|
|
187
187
|
|
|
188
|
-
- UI Patterns stories format not yet [supported](https://www.drupal.org/project/ui_patterns/issues/3480464).
|
|
188
|
+
- UI Patterns stories format not fully yet [supported](https://www.drupal.org/project/ui_patterns/issues/3480464).
|
|
189
189
|
- Same problem will be with `$ref: json-schema-definitions://` for SDC from Experience Builder.
|
|
190
190
|
- Plugin uses [Experimental indexers](https://storybook.js.org/docs/api/main-config/main-config-indexers)
|
|
191
191
|
|
package/dist/preset.js
CHANGED
|
@@ -28,8 +28,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
));
|
|
29
29
|
|
|
30
30
|
// node_modules/tsup/assets/esm_shims.js
|
|
31
|
+
import { fileURLToPath } from "url";
|
|
32
|
+
import path from "path";
|
|
33
|
+
var getFilename, getDirname, __dirname;
|
|
31
34
|
var init_esm_shims = __esm({
|
|
32
35
|
"node_modules/tsup/assets/esm_shims.js"() {
|
|
36
|
+
getFilename = () => fileURLToPath(import.meta.url);
|
|
37
|
+
getDirname = () => path.dirname(getFilename());
|
|
38
|
+
__dirname = /* @__PURE__ */ getDirname();
|
|
33
39
|
}
|
|
34
40
|
});
|
|
35
41
|
|
|
@@ -2127,7 +2133,7 @@ var require_parse_cst = __commonJS({
|
|
|
2127
2133
|
* @returns {?Node} - null if at a document boundary
|
|
2128
2134
|
*/
|
|
2129
2135
|
};
|
|
2130
|
-
function
|
|
2136
|
+
function parse3(src) {
|
|
2131
2137
|
const cr = [];
|
|
2132
2138
|
if (src.indexOf("\r") !== -1) {
|
|
2133
2139
|
src = src.replace(/\r\n?/g, (match, offset2) => {
|
|
@@ -2158,7 +2164,7 @@ var require_parse_cst = __commonJS({
|
|
|
2158
2164
|
documents.toString = () => documents.join("...\n");
|
|
2159
2165
|
return documents;
|
|
2160
2166
|
}
|
|
2161
|
-
exports.parse =
|
|
2167
|
+
exports.parse = parse3;
|
|
2162
2168
|
}
|
|
2163
2169
|
});
|
|
2164
2170
|
|
|
@@ -2207,10 +2213,10 @@ ${indent}${str}`;
|
|
|
2207
2213
|
return String(this.value);
|
|
2208
2214
|
}
|
|
2209
2215
|
};
|
|
2210
|
-
function collectionFromPath(schema,
|
|
2216
|
+
function collectionFromPath(schema, path2, value) {
|
|
2211
2217
|
let v = value;
|
|
2212
|
-
for (let i =
|
|
2213
|
-
const k =
|
|
2218
|
+
for (let i = path2.length - 1; i >= 0; --i) {
|
|
2219
|
+
const k = path2[i];
|
|
2214
2220
|
if (Number.isInteger(k) && k >= 0) {
|
|
2215
2221
|
const a = [];
|
|
2216
2222
|
a[k] = v;
|
|
@@ -2228,17 +2234,17 @@ ${indent}${str}`;
|
|
|
2228
2234
|
}
|
|
2229
2235
|
return schema.createNode(v, false);
|
|
2230
2236
|
}
|
|
2231
|
-
var isEmptyPath = (
|
|
2237
|
+
var isEmptyPath = (path2) => path2 == null || typeof path2 === "object" && path2[Symbol.iterator]().next().done;
|
|
2232
2238
|
var Collection = class _Collection extends Node {
|
|
2233
2239
|
constructor(schema) {
|
|
2234
2240
|
super();
|
|
2235
2241
|
PlainValue._defineProperty(this, "items", []);
|
|
2236
2242
|
this.schema = schema;
|
|
2237
2243
|
}
|
|
2238
|
-
addIn(
|
|
2239
|
-
if (isEmptyPath(
|
|
2244
|
+
addIn(path2, value) {
|
|
2245
|
+
if (isEmptyPath(path2)) this.add(value);
|
|
2240
2246
|
else {
|
|
2241
|
-
const [key, ...rest] =
|
|
2247
|
+
const [key, ...rest] = path2;
|
|
2242
2248
|
const node = this.get(key, true);
|
|
2243
2249
|
if (node instanceof _Collection) node.addIn(rest, value);
|
|
2244
2250
|
else if (node === void 0 && this.schema) this.set(key, collectionFromPath(this.schema, rest, value));
|
|
@@ -2791,12 +2797,12 @@ ${ctx.indent}`;
|
|
|
2791
2797
|
for (const {
|
|
2792
2798
|
format,
|
|
2793
2799
|
test,
|
|
2794
|
-
resolve:
|
|
2800
|
+
resolve: resolve4
|
|
2795
2801
|
} of tags) {
|
|
2796
2802
|
if (test) {
|
|
2797
2803
|
const match = str.match(test);
|
|
2798
2804
|
if (match) {
|
|
2799
|
-
let res =
|
|
2805
|
+
let res = resolve4.apply(null, match);
|
|
2800
2806
|
if (!(res instanceof Scalar)) res = new Scalar(res);
|
|
2801
2807
|
if (format) res.format = format;
|
|
2802
2808
|
return res;
|
|
@@ -4277,8 +4283,8 @@ ${pair.comment}` : item.comment;
|
|
|
4277
4283
|
}
|
|
4278
4284
|
function warnFileDeprecation(filename) {
|
|
4279
4285
|
if (shouldWarn(true)) {
|
|
4280
|
-
const
|
|
4281
|
-
warn(`The endpoint 'yaml/${
|
|
4286
|
+
const path2 = filename.replace(/.*yaml[/\\]/i, "").replace(/\.js$/, "").replace(/\\/g, "/");
|
|
4287
|
+
warn(`The endpoint 'yaml/${path2}' will be removed in a future release.`, "DeprecationWarning");
|
|
4282
4288
|
}
|
|
4283
4289
|
}
|
|
4284
4290
|
var warned = {};
|
|
@@ -5191,22 +5197,22 @@ ${cbNode.commentBefore}` : cb;
|
|
|
5191
5197
|
assertCollection(this.contents);
|
|
5192
5198
|
return this.contents.add(value);
|
|
5193
5199
|
}
|
|
5194
|
-
addIn(
|
|
5200
|
+
addIn(path2, value) {
|
|
5195
5201
|
assertCollection(this.contents);
|
|
5196
|
-
this.contents.addIn(
|
|
5202
|
+
this.contents.addIn(path2, value);
|
|
5197
5203
|
}
|
|
5198
5204
|
delete(key) {
|
|
5199
5205
|
assertCollection(this.contents);
|
|
5200
5206
|
return this.contents.delete(key);
|
|
5201
5207
|
}
|
|
5202
|
-
deleteIn(
|
|
5203
|
-
if (resolveSeq.isEmptyPath(
|
|
5208
|
+
deleteIn(path2) {
|
|
5209
|
+
if (resolveSeq.isEmptyPath(path2)) {
|
|
5204
5210
|
if (this.contents == null) return false;
|
|
5205
5211
|
this.contents = null;
|
|
5206
5212
|
return true;
|
|
5207
5213
|
}
|
|
5208
5214
|
assertCollection(this.contents);
|
|
5209
|
-
return this.contents.deleteIn(
|
|
5215
|
+
return this.contents.deleteIn(path2);
|
|
5210
5216
|
}
|
|
5211
5217
|
getDefaults() {
|
|
5212
5218
|
return _Document.defaults[this.version] || _Document.defaults[this.options.version] || {};
|
|
@@ -5214,26 +5220,26 @@ ${cbNode.commentBefore}` : cb;
|
|
|
5214
5220
|
get(key, keepScalar) {
|
|
5215
5221
|
return this.contents instanceof resolveSeq.Collection ? this.contents.get(key, keepScalar) : void 0;
|
|
5216
5222
|
}
|
|
5217
|
-
getIn(
|
|
5218
|
-
if (resolveSeq.isEmptyPath(
|
|
5219
|
-
return this.contents instanceof resolveSeq.Collection ? this.contents.getIn(
|
|
5223
|
+
getIn(path2, keepScalar) {
|
|
5224
|
+
if (resolveSeq.isEmptyPath(path2)) return !keepScalar && this.contents instanceof resolveSeq.Scalar ? this.contents.value : this.contents;
|
|
5225
|
+
return this.contents instanceof resolveSeq.Collection ? this.contents.getIn(path2, keepScalar) : void 0;
|
|
5220
5226
|
}
|
|
5221
5227
|
has(key) {
|
|
5222
5228
|
return this.contents instanceof resolveSeq.Collection ? this.contents.has(key) : false;
|
|
5223
5229
|
}
|
|
5224
|
-
hasIn(
|
|
5225
|
-
if (resolveSeq.isEmptyPath(
|
|
5226
|
-
return this.contents instanceof resolveSeq.Collection ? this.contents.hasIn(
|
|
5230
|
+
hasIn(path2) {
|
|
5231
|
+
if (resolveSeq.isEmptyPath(path2)) return this.contents !== void 0;
|
|
5232
|
+
return this.contents instanceof resolveSeq.Collection ? this.contents.hasIn(path2) : false;
|
|
5227
5233
|
}
|
|
5228
5234
|
set(key, value) {
|
|
5229
5235
|
assertCollection(this.contents);
|
|
5230
5236
|
this.contents.set(key, value);
|
|
5231
5237
|
}
|
|
5232
|
-
setIn(
|
|
5233
|
-
if (resolveSeq.isEmptyPath(
|
|
5238
|
+
setIn(path2, value) {
|
|
5239
|
+
if (resolveSeq.isEmptyPath(path2)) this.contents = value;
|
|
5234
5240
|
else {
|
|
5235
5241
|
assertCollection(this.contents);
|
|
5236
|
-
this.contents.setIn(
|
|
5242
|
+
this.contents.setIn(path2, value);
|
|
5237
5243
|
}
|
|
5238
5244
|
}
|
|
5239
5245
|
setSchema(id, customTags) {
|
|
@@ -5438,7 +5444,7 @@ var require_dist = __commonJS({
|
|
|
5438
5444
|
}
|
|
5439
5445
|
return doc;
|
|
5440
5446
|
}
|
|
5441
|
-
function
|
|
5447
|
+
function parse3(src, options) {
|
|
5442
5448
|
const doc = parseDocument(src, options);
|
|
5443
5449
|
doc.warnings.forEach((warning) => warnings.warn(warning));
|
|
5444
5450
|
if (doc.errors.length > 0) throw doc.errors[0];
|
|
@@ -5453,7 +5459,7 @@ var require_dist = __commonJS({
|
|
|
5453
5459
|
createNode,
|
|
5454
5460
|
defaultOptions: Document$1.defaultOptions,
|
|
5455
5461
|
Document,
|
|
5456
|
-
parse:
|
|
5462
|
+
parse: parse3,
|
|
5457
5463
|
parseAllDocuments,
|
|
5458
5464
|
parseCST: parseCst.parse,
|
|
5459
5465
|
parseDocument,
|
|
@@ -5477,9 +5483,9 @@ init_esm_shims();
|
|
|
5477
5483
|
|
|
5478
5484
|
// src/vite-plugin-storybook-yaml-stories.ts
|
|
5479
5485
|
init_esm_shims();
|
|
5480
|
-
var
|
|
5481
|
-
import { readdirSync, readFileSync, existsSync } from "fs";
|
|
5482
|
-
import { dirname, extname, relative, resolve, join } from "path";
|
|
5486
|
+
var import_yaml2 = __toESM(require_yaml(), 1);
|
|
5487
|
+
import { readdirSync, readFileSync as readFileSync2, existsSync } from "fs";
|
|
5488
|
+
import { dirname, extname, relative, resolve as resolve2, join } from "path";
|
|
5483
5489
|
|
|
5484
5490
|
// src/argsGenerator.ts
|
|
5485
5491
|
init_esm_shims();
|
|
@@ -5527,93 +5533,106 @@ var argTypesGenerator_default = (content) => {
|
|
|
5527
5533
|
|
|
5528
5534
|
// src/storiesGenerator.ts
|
|
5529
5535
|
init_esm_shims();
|
|
5530
|
-
var extractArgsAndSlots = (input) => {
|
|
5531
|
-
const args = {};
|
|
5532
|
-
const slots = {};
|
|
5533
|
-
for (const key in input) {
|
|
5534
|
-
const value = input[key];
|
|
5535
|
-
if (Array.isArray(value)) {
|
|
5536
|
-
value.forEach((item) => {
|
|
5537
|
-
if (item.type === "component") {
|
|
5538
|
-
const componentName = item.component.split(":").pop();
|
|
5539
|
-
const kebabCaseName = componentName.replace(/-/g, "");
|
|
5540
|
-
const componentProps = {
|
|
5541
|
-
...item.props || {},
|
|
5542
|
-
...item.slots || {}
|
|
5543
|
-
};
|
|
5544
|
-
const componentContent = `\${${kebabCaseName}.component(${JSON.stringify(componentProps)})}`;
|
|
5545
|
-
slots[key] = (slots[key] || "") + componentContent;
|
|
5546
|
-
} else {
|
|
5547
|
-
slots[key] = (slots[key] || "") + `${item}`;
|
|
5548
|
-
}
|
|
5549
|
-
});
|
|
5550
|
-
} else if (typeof value === "object" && value !== null) {
|
|
5551
|
-
const nested = extractArgsAndSlots(value);
|
|
5552
|
-
Object.assign(args, nested.args);
|
|
5553
|
-
Object.entries(nested.slots).forEach(([nestedKey, nestedContent]) => {
|
|
5554
|
-
slots[nestedKey] = (slots[nestedKey] || "") + nestedContent;
|
|
5555
|
-
});
|
|
5556
|
-
} else {
|
|
5557
|
-
args[key] = value;
|
|
5558
|
-
}
|
|
5559
|
-
}
|
|
5560
|
-
return { args, slots };
|
|
5561
|
-
};
|
|
5562
5536
|
var storiesGenerator_default = (stories) => {
|
|
5563
|
-
|
|
5564
|
-
Object.entries(stories).forEach(([storyKey, story]) => {
|
|
5565
|
-
const { args, slots } = extractArgsAndSlots(story);
|
|
5566
|
-
Object.entries(slots).forEach(([slotName, content]) => {
|
|
5567
|
-
args[slotName] = `${content}`;
|
|
5568
|
-
});
|
|
5569
|
-
generatedStories.push(`
|
|
5537
|
+
return Object.entries(stories).map(([storyKey, { props = {}, slots = {} }]) => `
|
|
5570
5538
|
export const ${storyKey} = {
|
|
5571
5539
|
args: {
|
|
5572
|
-
${
|
|
5573
|
-
|
|
5574
|
-
).join(",\n")}
|
|
5540
|
+
${generateArgs2(props)}
|
|
5541
|
+
${generateArgs2(slots, true)}
|
|
5575
5542
|
},
|
|
5576
5543
|
play: async ({ canvasElement }) => {
|
|
5577
5544
|
Drupal.attachBehaviors(canvasElement, window.drupalSettings);
|
|
5578
5545
|
},
|
|
5579
5546
|
};
|
|
5580
|
-
`);
|
|
5581
|
-
|
|
5582
|
-
|
|
5547
|
+
`).join("\n");
|
|
5548
|
+
};
|
|
5549
|
+
var generateArgs2 = (args, isSlot = false) => {
|
|
5550
|
+
return Object.entries(args).map(([key, value]) => {
|
|
5551
|
+
let argString = `${key}: `;
|
|
5552
|
+
if (Array.isArray(value)) {
|
|
5553
|
+
const arrayContent = value.map(
|
|
5554
|
+
(item) => item?.type === "component" ? generateComponent(item) : JSON.stringify(item)
|
|
5555
|
+
).join(isSlot ? " + " : ", ");
|
|
5556
|
+
argString += `[${arrayContent}]`;
|
|
5557
|
+
} else {
|
|
5558
|
+
argString += JSON.stringify(value);
|
|
5559
|
+
}
|
|
5560
|
+
return `${argString},`;
|
|
5561
|
+
}).join("\n");
|
|
5562
|
+
};
|
|
5563
|
+
var generateComponent = (item) => {
|
|
5564
|
+
const componentName = item.component.split(":").pop();
|
|
5565
|
+
const kebabCaseName = componentName.replace(/-/g, "");
|
|
5566
|
+
const componentProps = {
|
|
5567
|
+
...item.props,
|
|
5568
|
+
...item.slots
|
|
5569
|
+
};
|
|
5570
|
+
return `${kebabCaseName}.component(${JSON.stringify(componentProps)})`;
|
|
5583
5571
|
};
|
|
5584
5572
|
|
|
5585
|
-
// src/
|
|
5586
|
-
|
|
5587
|
-
var
|
|
5588
|
-
|
|
5573
|
+
// src/customRefsTransform.ts
|
|
5574
|
+
init_esm_shims();
|
|
5575
|
+
var import_yaml = __toESM(require_yaml(), 1);
|
|
5576
|
+
import { readFileSync } from "node:fs";
|
|
5577
|
+
import { resolve } from "node:path";
|
|
5578
|
+
var customRefs = (0, import_yaml.parse)(
|
|
5579
|
+
readFileSync(resolve(__dirname, "uiPatternsSchema.yml"), "utf8")
|
|
5580
|
+
);
|
|
5581
|
+
var memo = /* @__PURE__ */ new Map();
|
|
5582
|
+
function resolveRef(ref) {
|
|
5583
|
+
return customRefs[ref.toString()];
|
|
5584
|
+
}
|
|
5585
|
+
function processObject(obj) {
|
|
5586
|
+
if (typeof obj !== "object" || obj === null) {
|
|
5587
|
+
return obj;
|
|
5588
|
+
}
|
|
5589
|
+
if (memo.has(obj)) {
|
|
5590
|
+
return memo.get(obj);
|
|
5591
|
+
}
|
|
5592
|
+
for (const key in obj) {
|
|
5593
|
+
const value = obj[key];
|
|
5594
|
+
if (key === "$ref" && typeof value === "string") {
|
|
5595
|
+
const resolvedRef = resolveRef(value);
|
|
5596
|
+
if (!resolvedRef) {
|
|
5597
|
+
throw new Error(`Reference "${value}" not found in custom schema`);
|
|
5598
|
+
}
|
|
5599
|
+
const processedRef = processObject(resolvedRef);
|
|
5600
|
+
Object.assign(obj, processedRef);
|
|
5601
|
+
delete obj[key];
|
|
5602
|
+
} else if (typeof value === "object") {
|
|
5603
|
+
processObject(value);
|
|
5604
|
+
}
|
|
5605
|
+
}
|
|
5606
|
+
memo.set(obj, { ...obj });
|
|
5607
|
+
return obj;
|
|
5608
|
+
}
|
|
5609
|
+
var customRefsTransform_default = (schema) => {
|
|
5610
|
+
return processObject(schema);
|
|
5589
5611
|
};
|
|
5612
|
+
|
|
5613
|
+
// src/vite-plugin-storybook-yaml-stories.ts
|
|
5614
|
+
var readCDC = (id) => customRefsTransform_default((0, import_yaml2.parse)(readFileSync2(id, "utf8")));
|
|
5615
|
+
var getSubdirectories = (baseDir) => readdirSync(baseDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => join(baseDir, dirent.name));
|
|
5590
5616
|
var resolveComponentPath = (namespace, component) => {
|
|
5591
|
-
const baseComponentDir =
|
|
5592
|
-
const
|
|
5593
|
-
|
|
5594
|
-
...getSubdirectories(baseComponentDir)
|
|
5595
|
-
];
|
|
5596
|
-
const possiblePaths = componentDirectories.map(
|
|
5617
|
+
const baseComponentDir = resolve2("./components");
|
|
5618
|
+
const directories = [baseComponentDir, ...getSubdirectories(baseComponentDir)];
|
|
5619
|
+
const possiblePaths = directories.map(
|
|
5597
5620
|
(dir) => join(dir, component, `${component}.component.yml`)
|
|
5598
5621
|
);
|
|
5599
|
-
return possiblePaths.find(
|
|
5622
|
+
return possiblePaths.find(existsSync);
|
|
5600
5623
|
};
|
|
5601
|
-
var generateImports = (directory) => {
|
|
5602
|
-
const
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
if ([".css", ".js", ".mjs"].includes(extension)) {
|
|
5607
|
-
return `${imports} import '${assetPath}';
|
|
5624
|
+
var generateImports = (directory) => readdirSync(directory).reduce((imports, asset) => {
|
|
5625
|
+
const extension = extname(asset);
|
|
5626
|
+
const assetPath = `./${asset}`;
|
|
5627
|
+
if ([".css", ".js", ".mjs"].includes(extension)) {
|
|
5628
|
+
return `${imports}import '${assetPath}';
|
|
5608
5629
|
`;
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
return `${imports} import COMPONENT from '${assetPath}';
|
|
5630
|
+
} else if (extension === ".twig") {
|
|
5631
|
+
return `${imports}import COMPONENT from '${assetPath}';
|
|
5612
5632
|
`;
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
};
|
|
5633
|
+
}
|
|
5634
|
+
return imports;
|
|
5635
|
+
}, "");
|
|
5617
5636
|
var dynamicImports = (stories) => {
|
|
5618
5637
|
const imports = /* @__PURE__ */ new Set();
|
|
5619
5638
|
const findComponentArgs = (args) => {
|
|
@@ -5625,7 +5644,7 @@ var dynamicImports = (stories) => {
|
|
|
5625
5644
|
const [namespace, componentName] = item.component.split(":");
|
|
5626
5645
|
const resolvedPath = resolveComponentPath(namespace, componentName);
|
|
5627
5646
|
if (resolvedPath) {
|
|
5628
|
-
const kebabCaseName = componentName.replace(
|
|
5647
|
+
const kebabCaseName = componentName.replace(/-/g, "");
|
|
5629
5648
|
imports.add(`import ${kebabCaseName} from '${resolvedPath}';`);
|
|
5630
5649
|
}
|
|
5631
5650
|
}
|
|
@@ -5635,37 +5654,36 @@ var dynamicImports = (stories) => {
|
|
|
5635
5654
|
}
|
|
5636
5655
|
}
|
|
5637
5656
|
};
|
|
5638
|
-
Object.
|
|
5639
|
-
findComponentArgs(
|
|
5657
|
+
Object.values(stories).forEach(({ slots = {}, props = {} }) => {
|
|
5658
|
+
findComponentArgs({ ...slots, ...props });
|
|
5640
5659
|
});
|
|
5641
5660
|
return Array.from(imports).join("\n");
|
|
5642
5661
|
};
|
|
5643
|
-
var vite_plugin_storybook_yaml_stories_default =
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
return `
|
|
5662
|
+
var vite_plugin_storybook_yaml_stories_default = ({ jsonSchemaFakerOptions = {} }) => ({
|
|
5663
|
+
name: "vite-plugin-storybook-yaml-stories",
|
|
5664
|
+
async load(id) {
|
|
5665
|
+
if (!id.endsWith("component.yml")) return;
|
|
5666
|
+
const content = readCDC(id);
|
|
5667
|
+
const imports = generateImports(dirname(id));
|
|
5668
|
+
const storiesImports = dynamicImports(
|
|
5669
|
+
content.thirdPartySettings?.sdcStorybook?.stories || {}
|
|
5670
|
+
);
|
|
5671
|
+
const argTypes = {
|
|
5672
|
+
componentMetadata: { table: { disable: true } },
|
|
5673
|
+
...argTypesGenerator_default(content)
|
|
5674
|
+
};
|
|
5675
|
+
const args = {
|
|
5676
|
+
componentMetadata: {
|
|
5677
|
+
path: relative(process.cwd(), dirname(id)),
|
|
5678
|
+
machineName: id,
|
|
5679
|
+
status: content.status || "stable",
|
|
5680
|
+
name: content.name,
|
|
5681
|
+
group: content.group || "All Components"
|
|
5682
|
+
},
|
|
5683
|
+
...argsGenerator_default(content, jsonSchemaFakerOptions)
|
|
5684
|
+
};
|
|
5685
|
+
const stories = content.thirdPartySettings?.sdcStorybook?.stories ? storiesGenerator_default(content.thirdPartySettings.sdcStorybook.stories) : "";
|
|
5686
|
+
return `
|
|
5669
5687
|
${imports}
|
|
5670
5688
|
${storiesImports}
|
|
5671
5689
|
|
|
@@ -5682,10 +5700,9 @@ export const Basic = {
|
|
|
5682
5700
|
};
|
|
5683
5701
|
|
|
5684
5702
|
${stories}
|
|
5685
|
-
`;
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
};
|
|
5703
|
+
`;
|
|
5704
|
+
}
|
|
5705
|
+
});
|
|
5689
5706
|
var yamlStoriesIndexer = {
|
|
5690
5707
|
test: /component\.yml$/,
|
|
5691
5708
|
createIndex: async (fileName, { makeTitle }) => {
|
|
@@ -5701,7 +5718,7 @@ var yamlStoriesIndexer = {
|
|
|
5701
5718
|
];
|
|
5702
5719
|
const stories = content.thirdPartySettings?.sdcStorybook?.stories;
|
|
5703
5720
|
if (stories) {
|
|
5704
|
-
Object.
|
|
5721
|
+
Object.keys(stories).forEach((storyKey) => {
|
|
5705
5722
|
storiesIndex.push({
|
|
5706
5723
|
type: "story",
|
|
5707
5724
|
importPath: fileName,
|
|
@@ -5717,22 +5734,22 @@ var yamlStoriesIndexer = {
|
|
|
5717
5734
|
// src/preset.ts
|
|
5718
5735
|
import twig from "vite-plugin-twig-drupal";
|
|
5719
5736
|
import { mergeConfig } from "vite";
|
|
5720
|
-
import { resolve as
|
|
5737
|
+
import { resolve as resolve3, join as join2 } from "path";
|
|
5721
5738
|
import fs from "fs";
|
|
5722
5739
|
var getSubdirectories2 = (baseDir) => {
|
|
5723
5740
|
return fs.readdirSync(baseDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => join2(baseDir, dirent.name));
|
|
5724
5741
|
};
|
|
5725
5742
|
var getComponentDirectories = () => {
|
|
5726
|
-
const baseComponentDir =
|
|
5743
|
+
const baseComponentDir = resolve3("./components");
|
|
5727
5744
|
const subdirectories = getSubdirectories2(baseComponentDir);
|
|
5728
5745
|
return [baseComponentDir, ...subdirectories];
|
|
5729
5746
|
};
|
|
5730
5747
|
var resolveComponentPath2 = (namespace, component) => {
|
|
5731
5748
|
const componentDirectories = getComponentDirectories();
|
|
5732
5749
|
const possiblePaths = componentDirectories.map(
|
|
5733
|
-
(dir) =>
|
|
5750
|
+
(dir) => resolve3(`${dir}/${component}/${component}.component.yml`)
|
|
5734
5751
|
);
|
|
5735
|
-
return possiblePaths.find((
|
|
5752
|
+
return possiblePaths.find((path2) => fs.existsSync(path2));
|
|
5736
5753
|
};
|
|
5737
5754
|
function viteFinal(config, options) {
|
|
5738
5755
|
const { namespace } = options.sdcStorybookOptions;
|