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/index.cjs CHANGED
@@ -45,6 +45,7 @@ __export(src_exports, {
45
45
  NodeInstance: () => NodeInstance,
46
46
  PageBuilderImpl: () => PageBuilderImpl,
47
47
  ROUTER_OUTLET_ID: () => ROUTER_OUTLET_ID,
48
+ ROUTER_OUTLET_KEY: () => ROUTER_OUTLET_KEY,
48
49
  Runtime: () => Runtime,
49
50
  RuntimeNodeInstance: () => RuntimeNodeInstance,
50
51
  STATE_MARKER_ATTR: () => STATE_MARKER_ATTR,
@@ -211,7 +212,7 @@ __export(src_exports, {
211
212
  module.exports = __toCommonJS(src_exports);
212
213
 
213
214
  // src/version.ts
214
- var VERSION = "2.5.0";
215
+ var VERSION = "2.6.0";
215
216
 
216
217
  // ../state/src/signal.ts
217
218
  var _activeConsumer = null;
@@ -1721,6 +1722,16 @@ var ContentBuilderBase = class {
1721
1722
  node.addEvent({ type: "click", handlerKey });
1722
1723
  }
1723
1724
  }
1725
+ code(source, options = {}) {
1726
+ const props = {};
1727
+ if (options.language !== void 0) props["data-language"] = options.language;
1728
+ if (options.class !== void 0) props["class"] = options.class;
1729
+ if (options.id !== void 0) props["id"] = options.id;
1730
+ applyA11yProps(props, options);
1731
+ const node = this._graph.createNode("code", { parent: this._node, props });
1732
+ const resolved = bindValue(this._graph, node, "text", source);
1733
+ node.setProp("text", resolved);
1734
+ }
1724
1735
  };
1725
1736
  var ContainerBuilderBase = class extends ContentBuilderBase {
1726
1737
  section(key, builder, options = {}) {
@@ -3451,6 +3462,11 @@ var TAG_MAP = {
3451
3462
  "list-item": "li",
3452
3463
  image: "img",
3453
3464
  link: "a",
3465
+ // A `code()` node renders as a semantic `<pre>` outer element; the mount/
3466
+ // hydrate branches add a single inner `<code>` holding the escaped source
3467
+ // (mirrors how `text` renders `<span>` + an inner text node). One graph
3468
+ // node → one outer element preserves positional hydration.
3469
+ code: "pre",
3454
3470
  component: "div",
3455
3471
  slot: "div",
3456
3472
  fragment: "div",
@@ -4206,6 +4222,23 @@ function mountNode(ctx, graphNode, parentDom) {
4206
4222
  dom.appendChild(parentDom, el2);
4207
4223
  return instance2;
4208
4224
  }
4225
+ if (graphNode.type === "code") {
4226
+ const source = String(graphNode.getProp("text") ?? "");
4227
+ const pre = dom.createElement("pre");
4228
+ const codeEl = dom.createElement("code");
4229
+ const textNode = dom.createTextNode(source);
4230
+ dom.appendChild(codeEl, textNode);
4231
+ dom.appendChild(pre, codeEl);
4232
+ applyNodeProps(ctx, graphNode, pre);
4233
+ const instance2 = new NodeInstance(graphNode, pre);
4234
+ ctx.instances.set(graphNode.id, instance2);
4235
+ wireEvents(dom, graph, graphNode, pre, instance2);
4236
+ if (graphNode.stateRefs.length !== 0) {
4237
+ wireSignalBindings(ctx, graphNode, instance2, textUpdate(dom, pre, textNode));
4238
+ }
4239
+ dom.appendChild(parentDom, pre);
4240
+ return instance2;
4241
+ }
4209
4242
  if (graphNode.type === "link") {
4210
4243
  const el2 = dom.createElement("a");
4211
4244
  const href = graphNode.getProp("href");
@@ -4594,6 +4627,27 @@ function hydrateNode(ctx, graphNode, domNode, path) {
4594
4627
  }
4595
4628
  return instance;
4596
4629
  }
4630
+ case "code": {
4631
+ let codeEl = dom.firstChild(domNode);
4632
+ if (codeEl === null || dom.isTextNode(codeEl)) {
4633
+ const createdCode = dom.createElement("code");
4634
+ dom.appendChild(domNode, createdCode);
4635
+ codeEl = createdCode;
4636
+ }
4637
+ let textNode = dom.firstChild(codeEl);
4638
+ if (textNode === null || !dom.isTextNode(textNode)) {
4639
+ const created = dom.createTextNode(String(graphNode.getProp("text") ?? ""));
4640
+ dom.appendChild(codeEl, created);
4641
+ textNode = created;
4642
+ }
4643
+ const instance = new NodeInstance(graphNode, domNode);
4644
+ ctx.instances.set(graphNode.id, instance);
4645
+ wireEvents(dom, graph, graphNode, domNode, instance);
4646
+ if (graphNode.stateRefs.length !== 0) {
4647
+ wireSignalBindings(ctx, graphNode, instance, textUpdate(dom, domNode, textNode));
4648
+ }
4649
+ return instance;
4650
+ }
4597
4651
  case "image":
4598
4652
  case "link": {
4599
4653
  const instance = new NodeInstance(graphNode, domNode);
@@ -4745,6 +4799,8 @@ function expectedTag(ctx, graphNode) {
4745
4799
  return "img";
4746
4800
  case "link":
4747
4801
  return "a";
4802
+ case "code":
4803
+ return "pre";
4748
4804
  case "button":
4749
4805
  return "button";
4750
4806
  default:
@@ -5194,8 +5250,9 @@ function createRouter(options) {
5194
5250
 
5195
5251
  // ../router/src/mount-router.ts
5196
5252
  var ROUTER_OUTLET_ID = "streetui-router-outlet";
5253
+ var ROUTER_OUTLET_KEY = "router-outlet";
5197
5254
  function routerOutlet(scope, id = ROUTER_OUTLET_ID) {
5198
- scope.container("router-outlet", () => {
5255
+ scope.container(ROUTER_OUTLET_KEY, () => {
5199
5256
  }, { id });
5200
5257
  }
5201
5258
  function isExternalHref(href) {
@@ -6620,6 +6677,7 @@ function defineConfig(config) {
6620
6677
  NodeInstance,
6621
6678
  PageBuilderImpl,
6622
6679
  ROUTER_OUTLET_ID,
6680
+ ROUTER_OUTLET_KEY,
6623
6681
  Runtime,
6624
6682
  RuntimeNodeInstance,
6625
6683
  STATE_MARKER_ATTR,