synthesisui 0.16.100 → 0.16.101
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/component-codegen.js +30 -0
- package/package.json +1 -1
|
@@ -91,6 +91,36 @@ function elementFor(name, recipe) {
|
|
|
91
91
|
? { tag: "button", attrs: ` type="button"${role}`, voidEl: false }
|
|
92
92
|
: { tag: "div", attrs: role || ' role="separator"', voidEl: false };
|
|
93
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* A BUTTON MAY NOT HOLD BLOCK OR INTERACTIVE CONTENT - the sibling of the guard
|
|
96
|
+
* above, and the same reasoning: the recipe is right and the tag is wrong.
|
|
97
|
+
*
|
|
98
|
+
* Their collapsible-card generated `<button>` around a trigger row AND a panel
|
|
99
|
+
* carrying `{children}`, which is invalid markup a copy-paste ships broken
|
|
100
|
+
* (dono, 02/08). HTML's own containment rule decides it - a slot (content we
|
|
101
|
+
* cannot vouch for), another interactive node, a frontier, or an arranger with
|
|
102
|
+
* children of its own means the root is a box and the button belongs to
|
|
103
|
+
* whatever triggers, which the tree already names.
|
|
104
|
+
*
|
|
105
|
+
* Not a table of libraries: the same test answers for Base UI, Radix, Headless
|
|
106
|
+
* UI and a hand-written disclosure, because it reads the SHAPE.
|
|
107
|
+
*/
|
|
108
|
+
if (tag === "button") {
|
|
109
|
+
const holdsBlock = (nodes) => nodes.some((n) => n.as === "slot" ||
|
|
110
|
+
n.as === "button" ||
|
|
111
|
+
n.as === "field" ||
|
|
112
|
+
n.as === "component" ||
|
|
113
|
+
n.as === "external" ||
|
|
114
|
+
(n.children != null && n.children.length > 0));
|
|
115
|
+
const tree = recipe.preview?.parts;
|
|
116
|
+
if (tree && tree.length > 0 && holdsBlock(tree)) {
|
|
117
|
+
return {
|
|
118
|
+
tag: tree.some((n) => n.as === "heading") ? "article" : "div",
|
|
119
|
+
attrs: "",
|
|
120
|
+
voidEl: false,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
94
124
|
return { tag, attrs, voidEl: isVoid };
|
|
95
125
|
}
|
|
96
126
|
/** Variant axes → typed props. An axis whose options ⊆ {true,false} is a
|
package/package.json
CHANGED