@storybook/web-components 11.0.0-rc.2 → 11.0.0-rc.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.
Files changed (2) hide show
  1. package/dist/preset.js +20 -18
  2. package/package.json +2 -2
package/dist/preset.js CHANGED
@@ -424,9 +424,13 @@ function slottedHtml(name, html) {
424
424
  var attrHole = (arg, name, mode) => ({ kind: "attr", arg, ...name !== arg && { name }, mode });
425
425
 
426
426
  // src/docgen/story-docs/html-tree.ts
427
- var INLINE_LIMIT = 80, INDENT = " ";
427
+ import {
428
+ SNIPPET_INDENT as INDENT,
429
+ SNIPPET_PRINT_WIDTH,
430
+ printOpeningTag
431
+ } from "storybook/internal/docs-tools";
428
432
  function printHtml(nodes, marks) {
429
- let tags = /* @__PURE__ */ new Map(), expanded = expandHoles(nodes, tags), marked = marks && { mark: marks.mark, tags }, html = expanded.filter(isPrintable).map((node) => printNode(node, 0, marked)).join(`
433
+ let tags = /* @__PURE__ */ new Map(), expanded = expandHoles(nodes, tags), marked = marks && { mark: marks.mark, measure: marks.unmark, tags }, html = expanded.filter(isPrintable).map((node) => printNode(node, 0, marked)).join(`
430
434
  `);
431
435
  return html + placeholderHoles(expanded, html ? `
432
436
  ` : "", marked);
@@ -484,7 +488,7 @@ var expandHoles = (nodes, tags) => nodes.flatMap((node) => {
484
488
  return node.closed ? `${startTag}${content}</${node.name}>` : `${startTag}${content}`;
485
489
  }
486
490
  let inline = inlineElementText(node, !0, void 0)?.text;
487
- if (inline && indent.length + inline.length <= INLINE_LIMIT)
491
+ if (inline && indent.length + inline.length <= SNIPPET_PRINT_WIDTH)
488
492
  return `${indent}${marks ? inlineElementText(node, !0, marks).text : inline}`;
489
493
  let body = printChildLines(node.children, depth + 1, marks).join(`
490
494
  `) + placeholderHoles(node.children, `
@@ -498,7 +502,7 @@ ${body}`;
498
502
  if (group.length === 0)
499
503
  return;
500
504
  let inline = inlineChildrenText(group, void 0), indent = INDENT.repeat(depth);
501
- inline && inline.hasText && indent.length + inline.text.length <= INLINE_LIMIT ? lines.push(`${indent}${marks ? inlineChildrenText(group, marks).text : inline.text}`) : group.forEach((child) => lines.push(printNode(child, depth, marks))), group = [];
505
+ inline && inline.hasText && indent.length + inline.text.length <= SNIPPET_PRINT_WIDTH ? lines.push(`${indent}${marks ? inlineChildrenText(group, marks).text : inline.text}`) : group.forEach((child) => lines.push(printNode(child, depth, marks))), group = [];
502
506
  };
503
507
  for (let child of children)
504
508
  if (!isPlaceholder(child)) {
@@ -560,20 +564,18 @@ ${body}`;
560
564
  let startTag = printStartTag({ attributes: node.attributes, name: node.name }, depth, marks);
561
565
  return node.closed ? `${startTag}${node.text}</${node.name}>` : `${startTag}${node.text}`;
562
566
  }, printStartTag = (node, depth, marks) => {
563
- let indent = INDENT.repeat(depth), compact = printCompactStartTag(node, void 0);
564
- if (indent.length + compact.length <= INLINE_LIMIT || shown(node.attributes).length === 0)
565
- return `${indent}${marks ? printCompactStartTag(node, marks) : compact}`;
566
- let lines = shown(node.attributes).map(
567
- (attribute) => `${indent}${INDENT}${printHtmlAttribute(attribute, marks)}`
568
- ), omitted = omittedHoles(node.attributes, `
569
- ${indent}${INDENT}`, marks);
570
- return [
571
- `${indent}<${node.name}`,
572
- ...lines.slice(0, -1),
573
- lines.at(-1) + omitted,
574
- `${indent}>`
575
- ].join(`
576
- `);
567
+ let indent = INDENT.repeat(depth), { text } = printOpeningTag(
568
+ {
569
+ open: `<${node.name}`,
570
+ attributes: [
571
+ ...shown(node.attributes).map((attribute) => printHtmlAttribute(attribute, marks)),
572
+ (separator) => omittedHoles(node.attributes, separator, marks)
573
+ ],
574
+ close: ">"
575
+ },
576
+ { indent, measure: marks?.measure }
577
+ );
578
+ return `${indent}${text}`;
577
579
  }, printCompactStartTag = (node, marks) => {
578
580
  let attrs = shown(node.attributes).map((attribute) => printHtmlAttribute(attribute, marks)).join(" "), omitted = omittedHoles(node.attributes, " ", marks);
579
581
  return `<${node.name}${attrs ? ` ${attrs}` : ""}${omitted}>`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/web-components",
3
- "version": "11.0.0-rc.2",
3
+ "version": "11.0.0-rc.4",
4
4
  "description": "Storybook Web Components renderer: Develop, document, and test UI components in isolation",
5
5
  "keywords": [
6
6
  "storybook",
@@ -74,7 +74,7 @@
74
74
  },
75
75
  "peerDependencies": {
76
76
  "lit": "^2.0.0 || ^3.0.0",
77
- "storybook": "^11.0.0-rc.2",
77
+ "storybook": "^11.0.0-rc.4",
78
78
  "typescript": "^5.9.0 || ^6.0.0 || ^7.0.0"
79
79
  },
80
80
  "publishConfig": {