@yahoo/uds-create-config 5.106.0 → 5.107.1

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.
@@ -1,10 +1,10 @@
1
- import { isRef, kindOf, memberOf, pathOf, ref, refLeaf, splitRef } from "./utils/refs.js";
1
+ import { isRef, kindOf, memberOf, pathOf, ref, refLeaf, sourceOf, splitRef } from "./utils/refs.js";
2
2
  import { defaultsFor } from "./default-conditions.js";
3
3
  import { renderedElement } from "../entities/system/element.js";
4
4
  import { createSliceMemo } from "./memo.js";
5
5
  import { UDS_FORCE_STATES, componentStateDefaults, componentStates } from "./component-states.js";
6
6
  import { unconditionalPreviewProps } from "./preview-store.js";
7
- import { authoredBag, authoredValue, declaredPropDefaults, memberFromLeaf, refListOf, resolveComponentProps, stylePropertyPathFor } from "./projections.js";
7
+ import { LAYER_PROPS, authoredBag, authoredValue, declaredPropDefaults, glyphPropsOf, libraryThroughPin, memberFromLeaf, refListOf, resolveComponentProps, stylePropertyPathFor } from "./projections.js";
8
8
  import { slotHostLayer } from "./slot-host.js";
9
9
  import { forwardRoutes, forwardedLayers, intoName, isValueSlot, renderBindingsOf, routesContent } from "./prop-surface.js";
10
10
  import { withRequiredContentHidden } from "../entities/system/required-content-layers.js";
@@ -1516,7 +1516,69 @@ function moduleProps(config, type, props) {
1516
1516
  }
1517
1517
  return changed ? out : bag;
1518
1518
  };
1519
- return walk(props);
1519
+ const own = walk(props);
1520
+ if (through.length === 0 || !Object.hasOwn(own, "layerProps")) return own;
1521
+ return withLayerGlyphRefs({
1522
+ config,
1523
+ component: type,
1524
+ props: own,
1525
+ where: pathOf(type)
1526
+ });
1527
+ }
1528
+ /** Composed layers call their components directly, so their glyph names need refs before the
1529
+ * registry revives nested values into React components. */
1530
+ function withLayerGlyphRefs({ config, component, props, where }) {
1531
+ const overrides = props[LAYER_PROPS];
1532
+ if (!overrides || typeof overrides !== "object" || Array.isArray(overrides)) return props;
1533
+ const layers = bodyOf(config, splitRef(component).qualifiedPath)?.layers;
1534
+ let next;
1535
+ for (const [layer, value] of Object.entries(overrides)) {
1536
+ const target = layers?.[layer];
1537
+ if (!isRef(target) || kindOf(target) !== "component") continue;
1538
+ if (!value || typeof value !== "object" || Array.isArray(value)) continue;
1539
+ const owner = config.configFor(target);
1540
+ if (!owner) continue;
1541
+ const bag = value;
1542
+ const address = `${where}.${LAYER_PROPS}.${layer}`;
1543
+ const slug = sourceOf(target);
1544
+ let updated;
1545
+ for (const [prop, libraries] of Object.entries(glyphPropsOf(owner, pathOf(target)))) {
1546
+ const name = bag[prop];
1547
+ if (typeof name !== "string") continue;
1548
+ let glyph;
1549
+ if (kindOf(name) === "icon") {
1550
+ if (config.resolveRef(name)) glyph = { __ref: name };
1551
+ } else for (const library of libraries) {
1552
+ const group = splitRef(slug ? libraryThroughPin({
1553
+ config,
1554
+ slug,
1555
+ library
1556
+ }) : library);
1557
+ const candidate = ref("icon", `${group.path}/${name}`, group.source);
1558
+ if (!config.resolveRef(candidate)) continue;
1559
+ glyph = candidate;
1560
+ break;
1561
+ }
1562
+ if (!glyph) console.error(`[uds] ${address}.${prop}: unknown icon ${JSON.stringify(name)}`);
1563
+ updated ??= { ...bag };
1564
+ updated[prop] = glyph;
1565
+ }
1566
+ const inner = updated ?? bag;
1567
+ const nested = withLayerGlyphRefs({
1568
+ config,
1569
+ component: target.__ref,
1570
+ props: inner,
1571
+ where: address
1572
+ });
1573
+ if (nested !== bag) {
1574
+ next ??= { ...overrides };
1575
+ next[layer] = nested;
1576
+ }
1577
+ }
1578
+ return next ? {
1579
+ ...props,
1580
+ [LAYER_PROPS]: next
1581
+ } : props;
1520
1582
  }
1521
1583
  /** Whether any node under `key` (itself excluded) binds `prop` as its content. */
1522
1584
  function subtreeBinds(anatomy, key, prop) {