@jfrader/storybook-docs 0.9.0 → 0.9.2

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/dist/index.js CHANGED
@@ -363,6 +363,9 @@ function serializable(value, ancestors = /* @__PURE__ */ new Set()) {
363
363
  ancestors.delete(value);
364
364
  return result;
365
365
  }
366
+ function jsxRootTag(example) {
367
+ return example.replace(/^\s*\/\/[^\n]*(?:\n|$)/gm, "").match(/<([A-Za-z_$][\w$]*(?:\.[\w$]+)*)[\s/>]/)?.[1]?.split(".")[0];
368
+ }
366
369
  function usageSnippet(componentName, args) {
367
370
  if (!args || Object.keys(args).length === 0) return null;
368
371
  const attributes = [];
@@ -374,8 +377,8 @@ function usageSnippet(componentName, args) {
374
377
  else attributes.push(`${key}={${JSON.stringify(value)}}`);
375
378
  }
376
379
  const opening = `<${componentName}${attributes.length ? ` ${attributes.join(" ")}` : ""}`;
377
- if (args.children === void 0) return attributes.length ? `${opening} />` : null;
378
- if (!serializable(args.children) || args.children !== null && typeof args.children === "object") return null;
380
+ if (args.children === void 0 || args.children === null) return attributes.length ? `${opening} />` : null;
381
+ if (!serializable(args.children) || typeof args.children === "object") return null;
379
382
  const children = typeof args.children === "string" && !/[&<>{}]/.test(args.children) ? args.children : `{${JSON.stringify(args.children)}}`;
380
383
  return `${opening}>${children}</${componentName}>`;
381
384
  }
@@ -389,11 +392,12 @@ function buildUsageSnippet({ componentName, from, args, source, renderSource, js
389
392
  const excerpt = extracted?.startsWith(STORY_EXCERPT);
390
393
  const example = source?.trim() || (excerpt ? generated() || extracted : extracted || generated());
391
394
  if (!example) return null;
395
+ const rootTag = jsxRootTag(example);
392
396
  if (!source?.trim() && example === extracted) {
393
- const rootTag = example.replace(/^\s*\/\/[^\n]*(?:\n|$)/gm, "").trim().match(/^<([A-Za-z_$][\w$]*(?:\.[\w$]+)*)[\s/>]/)?.[1]?.split(".")[0];
394
397
  if (excerpt || rootTag !== rootName || !from.trim()) return example;
395
398
  }
396
399
  if (!from.trim()) return example;
400
+ if (rootTag !== rootName) return example;
397
401
  const imports = [...example.matchAll(/import\s*\{([^}]+)\}\s*from\s*(['"])(.*?)\2/g)];
398
402
  const imported = imports.some((match) => match[3] === from && match[1].split(",").some((name) => name.trim() === rootName));
399
403
  return imported ? example : `import { ${rootName} } from '${from}';
package/dist/styles.css CHANGED
@@ -190,6 +190,11 @@ body {
190
190
  overflow-anchor: none;
191
191
  min-width: 0;
192
192
  }
193
+ /* The sticky nav is only as tall as its list, so the column it lives in paints the panel:
194
+ on a long page the track reaches the page bottom and the background never stops short. */
195
+ .nav-track {
196
+ background: var(--sd-surface);
197
+ }
193
198
  @media (min-width: 1180px) {
194
199
  .rail-track::before {
195
200
  content: '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jfrader/storybook-docs",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "type": "module",
5
5
  "description": "A documentation front for any design system that has Storybook: navigation, live examples and API tables are generated from the story files themselves.",
6
6
  "exports": {