@stacksjs/stx 0.2.121 → 0.2.123
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/appearance-bootstrap.d.ts +20 -0
- package/dist/appearance-bootstrap.js +92 -0
- package/dist/cli.js +524 -524
- package/dist/component-renderer.js +18 -5
- package/dist/craft.js +275 -275
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/process.js +5 -1
- package/dist/pwa.js +292 -292
- package/dist/ssg.js +365 -365
- package/package.json +5 -5
|
@@ -222,6 +222,10 @@ function parseComponentProps(rawProps, context, options) {
|
|
|
222
222
|
}
|
|
223
223
|
if (attrName.startsWith(":")) {
|
|
224
224
|
const propName = kebabToCamel(attrName.slice(1)), expression = attrValue === BOOLEAN_ATTRIBUTE_SENTINEL ? propName : attrValue;
|
|
225
|
+
if (propName === "if" || propName === "for" || propName === "show") {
|
|
226
|
+
resolved.clientReactive[propName] = expression;
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
225
229
|
try {
|
|
226
230
|
if (!isExpressionSafe(expression)) {
|
|
227
231
|
if (options.debug)
|
|
@@ -642,11 +646,20 @@ async function processCustomElementTags(template, context, filePath, options, de
|
|
|
642
646
|
}
|
|
643
647
|
}
|
|
644
648
|
function emitClientReactiveAttrs(html, clientReactive) {
|
|
645
|
-
const
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
649
|
+
const componentControlBindings = new Set(["if", "for"]), rootStructuralBindings = new Set(["show"]), rootBindings = Object.entries(clientReactive).filter(([key]) => !componentControlBindings.has(key)), parentBindings = rootBindings.filter(([key]) => !rootStructuralBindings.has(key)).map(([key]) => pascalToKebab(key)).join(" ");
|
|
650
|
+
let output = html;
|
|
651
|
+
const root = rootBindings.length > 0 ? findRenderedComponentRoot(output) : null;
|
|
652
|
+
if (root) {
|
|
653
|
+
const reactiveAttrs = rootBindings.map(([key, expr]) => `:${pascalToKebab(key)}="${expr.replace(/"/g, """)}"`).join(" "), parentBindingAttr = parentBindings ? ` data-stx-parent-bindings="${parentBindings}"` : "";
|
|
654
|
+
output = output.substring(0, root.insertPos) + `${parentBindingAttr} ${reactiveAttrs}` + output.substring(root.insertPos);
|
|
655
|
+
}
|
|
656
|
+
const ifExpression = clientReactive.if;
|
|
657
|
+
if (ifExpression)
|
|
658
|
+
output = `<template :if="${ifExpression.replace(/"/g, """)}">${output}</template>`;
|
|
659
|
+
const forExpression = clientReactive.for;
|
|
660
|
+
if (forExpression)
|
|
661
|
+
output = `<template :for="${forExpression.replace(/"/g, """)}">${output}</template>`;
|
|
662
|
+
return output;
|
|
650
663
|
}
|
|
651
664
|
function findRenderedComponentRoot(html) {
|
|
652
665
|
const scopedRoot = /<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(html);
|