streetui 2.5.0 → 2.6.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.
package/dist/testing.cjs CHANGED
@@ -1021,6 +1021,11 @@ var TAG_MAP = {
1021
1021
  "list-item": "li",
1022
1022
  image: "img",
1023
1023
  link: "a",
1024
+ // A `code()` node renders as a semantic `<pre>` outer element; the mount/
1025
+ // hydrate branches add a single inner `<code>` holding the escaped source
1026
+ // (mirrors how `text` renders `<span>` + an inner text node). One graph
1027
+ // node → one outer element preserves positional hydration.
1028
+ code: "pre",
1024
1029
  component: "div",
1025
1030
  slot: "div",
1026
1031
  fragment: "div",
@@ -1739,6 +1744,23 @@ function mountNode(ctx, graphNode, parentDom) {
1739
1744
  dom.appendChild(parentDom, el2);
1740
1745
  return instance2;
1741
1746
  }
1747
+ if (graphNode.type === "code") {
1748
+ const source = String(graphNode.getProp("text") ?? "");
1749
+ const pre = dom.createElement("pre");
1750
+ const codeEl = dom.createElement("code");
1751
+ const textNode = dom.createTextNode(source);
1752
+ dom.appendChild(codeEl, textNode);
1753
+ dom.appendChild(pre, codeEl);
1754
+ applyNodeProps(ctx, graphNode, pre);
1755
+ const instance2 = new NodeInstance(graphNode, pre);
1756
+ ctx.instances.set(graphNode.id, instance2);
1757
+ wireEvents(dom, graph, graphNode, pre, instance2);
1758
+ if (graphNode.stateRefs.length !== 0) {
1759
+ wireSignalBindings(ctx, graphNode, instance2, textUpdate(dom, pre, textNode));
1760
+ }
1761
+ dom.appendChild(parentDom, pre);
1762
+ return instance2;
1763
+ }
1742
1764
  if (graphNode.type === "link") {
1743
1765
  const el2 = dom.createElement("a");
1744
1766
  const href = graphNode.getProp("href");
@@ -2120,6 +2142,27 @@ function hydrateNode(ctx, graphNode, domNode, path) {
2120
2142
  }
2121
2143
  return instance;
2122
2144
  }
2145
+ case "code": {
2146
+ let codeEl = dom.firstChild(domNode);
2147
+ if (codeEl === null || dom.isTextNode(codeEl)) {
2148
+ const createdCode = dom.createElement("code");
2149
+ dom.appendChild(domNode, createdCode);
2150
+ codeEl = createdCode;
2151
+ }
2152
+ let textNode = dom.firstChild(codeEl);
2153
+ if (textNode === null || !dom.isTextNode(textNode)) {
2154
+ const created = dom.createTextNode(String(graphNode.getProp("text") ?? ""));
2155
+ dom.appendChild(codeEl, created);
2156
+ textNode = created;
2157
+ }
2158
+ const instance = new NodeInstance(graphNode, domNode);
2159
+ ctx.instances.set(graphNode.id, instance);
2160
+ wireEvents(dom, graph, graphNode, domNode, instance);
2161
+ if (graphNode.stateRefs.length !== 0) {
2162
+ wireSignalBindings(ctx, graphNode, instance, textUpdate(dom, domNode, textNode));
2163
+ }
2164
+ return instance;
2165
+ }
2123
2166
  case "image":
2124
2167
  case "link": {
2125
2168
  const instance = new NodeInstance(graphNode, domNode);
@@ -2271,6 +2314,8 @@ function expectedTag(ctx, graphNode) {
2271
2314
  return "img";
2272
2315
  case "link":
2273
2316
  return "a";
2317
+ case "code":
2318
+ return "pre";
2274
2319
  case "button":
2275
2320
  return "button";
2276
2321
  default:
@@ -3386,6 +3431,16 @@ var ContentBuilderBase = class {
3386
3431
  node.addEvent({ type: "click", handlerKey });
3387
3432
  }
3388
3433
  }
3434
+ code(source, options = {}) {
3435
+ const props = {};
3436
+ if (options.language !== void 0) props["data-language"] = options.language;
3437
+ if (options.class !== void 0) props["class"] = options.class;
3438
+ if (options.id !== void 0) props["id"] = options.id;
3439
+ applyA11yProps(props, options);
3440
+ const node = this._graph.createNode("code", { parent: this._node, props });
3441
+ const resolved = bindValue(this._graph, node, "text", source);
3442
+ node.setProp("text", resolved);
3443
+ }
3389
3444
  };
3390
3445
  var ContainerBuilderBase = class extends ContentBuilderBase {
3391
3446
  section(key, builder, options = {}) {
@@ -4122,7 +4177,7 @@ function trigger(el, type, init = {}) {
4122
4177
  }
4123
4178
 
4124
4179
  // src/version.ts
4125
- var VERSION = "2.5.0";
4180
+ var VERSION = "2.6.0";
4126
4181
  // Annotate the CommonJS export names for ESM import in node:
4127
4182
  0 && (module.exports = {
4128
4183
  VERSION,