@threadlabs/looma 0.50.1 → 0.50.2
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/docs/catalog.json +4 -4
- package/docs/framework-examples.mjs +17 -7
- package/package.json +1 -1
package/docs/catalog.json
CHANGED
|
@@ -498,7 +498,7 @@
|
|
|
498
498
|
],
|
|
499
499
|
"schemaVersion": 1,
|
|
500
500
|
"package": "@threadlabs/looma",
|
|
501
|
-
"version": "0.50.
|
|
501
|
+
"version": "0.50.2",
|
|
502
502
|
"groups": [
|
|
503
503
|
{
|
|
504
504
|
"id": "layout",
|
|
@@ -3588,7 +3588,7 @@
|
|
|
3588
3588
|
"frameworks": {
|
|
3589
3589
|
"html-next": {
|
|
3590
3590
|
"language": "html",
|
|
3591
|
-
"code": "<script
|
|
3591
|
+
"code": "<script\n type=\"module\"\n>\n import \"@threadlabs/looma\";\n import { componentRegistry } from \"@nextwebwg/html-next/runtime\";\n\n const button = document.querySelector(\"#docs-save-changes\");\n button.addEventListener(\"click\", async () => {\n componentRegistry.update(button, { loading: true });\n try {\n await new Promise((resolve) => setTimeout(resolve, 1500));\n } finally {\n componentRegistry.update(button, { loading: false });\n }\n });\n</script>\n\n<ui-button\n id=\"docs-save-changes\"\n variant=\"solid\"\n>Save changes</ui-button>\n"
|
|
3592
3592
|
},
|
|
3593
3593
|
"vue": {
|
|
3594
3594
|
"language": "vue",
|
|
@@ -4919,7 +4919,7 @@
|
|
|
4919
4919
|
"frameworks": {
|
|
4920
4920
|
"html-next": {
|
|
4921
4921
|
"language": "html",
|
|
4922
|
-
"code": "<script
|
|
4922
|
+
"code": "<script\n type=\"module\"\n>\n import \"@threadlabs/looma\";\n import { componentRegistry } from \"@nextwebwg/html-next/runtime\";\n\n const all = document.querySelector(\"#docs-checkbox-all\");\n const items = [...document.querySelectorAll(\".docs-checkbox-item\")];\n const isChecked = (item) => item.querySelector('input[type=\"checkbox\"]').checked;\n\n all.addEventListener(\"change\", (event) => {\n if (typeof event.detail?.checked !== \"boolean\") return;\n for (const item of items) componentRegistry.update(item, { checked: event.detail.checked });\n componentRegistry.update(all, { indeterminate: false });\n });\n\n for (const item of items) item.addEventListener(\"change\", (event) => {\n if (typeof event.detail?.checked !== \"boolean\") return;\n const count = items.filter(isChecked).length;\n componentRegistry.update(all, { checked: count === items.length, indeterminate: count > 0 && count < items.length });\n });\n</script>\n\n<ui-stack\n gap=\"s\"\n>\n <ui-checkbox\n id=\"docs-checkbox-all\"\n indeterminate\n >Select all</ui-checkbox>\n <ui-stack\n gap=\"xs\"\n style=\"padding-inline-start: 1.5rem\"\n >\n <ui-checkbox\n class=\"docs-checkbox-item\"\n checked\n >Design</ui-checkbox>\n <ui-checkbox\n class=\"docs-checkbox-item\"\n >Build</ui-checkbox>\n <ui-checkbox\n class=\"docs-checkbox-item\"\n >Review</ui-checkbox>\n </ui-stack>\n</ui-stack>\n"
|
|
4923
4923
|
}
|
|
4924
4924
|
},
|
|
4925
4925
|
"behavior": "@threadlabs/looma/docs/examples/ui-checkbox/examples/02-checked-indeterminate-and-disabled.behavior.js"
|
|
@@ -19822,7 +19822,7 @@
|
|
|
19822
19822
|
"frameworks": {
|
|
19823
19823
|
"html-next": {
|
|
19824
19824
|
"language": "html",
|
|
19825
|
-
"code": "<script
|
|
19825
|
+
"code": "<script\n type=\"module\"\n>\n import \"@threadlabs/looma\";\n\n const input = document.querySelector(\"#docs-search-input\");\n const status = document.querySelector(\"#docs-search-status\");\n const empty = document.querySelector(\"#docs-search-empty\");\n const results = [\n document.querySelector(\"#docs-result-design-tokens\"),\n document.querySelector(\"#docs-result-token-overrides\"),\n document.querySelector(\"#docs-result-button-variants\")\n ];\n\n function updateResults() {\n const query = input.value.trim().toLowerCase();\n let visible = 0;\n for (const result of results) {\n result.hidden = !result.textContent.toLowerCase().includes(query);\n if (!result.hidden) visible += 1;\n }\n status.textContent = visible + \" result\" + (visible === 1 ? \"\" : \"s\");\n empty.hidden = visible !== 0;\n }\n\n input.addEventListener(\"input\", updateResults);\n</script>\n\n<ui-search-shell\n id=\"docs-search-shell\"\n open\n dismissible\n label=\"Search documentation\"\n>\n <ui-input\n id=\"docs-search-input\"\n slot=\"search\"\n type=\"search\"\n aria-label=\"Search documentation\"\n placeholder=\"Search documentation\"\n ></ui-input>\n <div\n id=\"docs-search-status\"\n slot=\"status\"\n aria-live=\"polite\"\n >3 results</div>\n <div\n id=\"docs-search-results\"\n slot=\"body\"\n >\n <ui-search-result-row\n id=\"docs-result-design-tokens\"\n >\n <strong\n slot=\"title\"\n >Design tokens</strong>\n <span\n slot=\"excerpt\"\n >Color, type, spacing, and motion.</span>\n </ui-search-result-row>\n <ui-search-result-row\n id=\"docs-result-token-overrides\"\n >\n <strong\n slot=\"title\"\n >Token overrides</strong>\n <span\n slot=\"excerpt\"\n >Customize shared and component tokens.</span>\n </ui-search-result-row>\n <ui-search-result-row\n id=\"docs-result-button-variants\"\n >\n <strong\n slot=\"title\"\n >Button variants</strong>\n <span\n slot=\"excerpt\"\n >Choose solid, outline, ghost, or danger.</span>\n </ui-search-result-row>\n <p\n id=\"docs-search-empty\"\n hidden\n >No matching documentation.</p>\n </div>\n <form\n slot=\"footer\"\n method=\"dialog\"\n >\n <ui-button\n type=\"submit\"\n size=\"sm\"\n >Close</ui-button>\n </form>\n</ui-search-shell>\n"
|
|
19826
19826
|
},
|
|
19827
19827
|
"vue": {
|
|
19828
19828
|
"language": "vue",
|
|
@@ -15,11 +15,20 @@ const reserved = new Set('await break case catch class const continue debugger d
|
|
|
15
15
|
export const frameworkLabels = { 'html-next': 'HTML Next', vue: 'Vue', react: 'React', svelte: 'Svelte' };
|
|
16
16
|
|
|
17
17
|
// Derive block layout from the tree. Mixed text and inline adjacency stay together.
|
|
18
|
-
function layout(nodes) {
|
|
18
|
+
function layout(nodes, owner) {
|
|
19
19
|
const structural = nodes.some(node => node.kind === 'slot' || node.kind === 'element' && (node.component || !inlineElements.has(node.tag)));
|
|
20
|
-
const
|
|
20
|
+
const labels = nodes.filter(node => node.kind === 'text' && !formattingSpace(node));
|
|
21
|
+
const namedSlot = node => node.kind === 'element' && node.attributes.some(attribute => attribute.name === 'slot' && attribute.value);
|
|
22
|
+
const slottedLabel = owner?.tag.includes('-') && labels.length === 1 && !labels[0].preserve
|
|
23
|
+
&& nodes.some(namedSlot) && nodes.every(node => node.kind !== 'element' || namedSlot(node));
|
|
24
|
+
const multiline = slottedLabel || structural
|
|
21
25
|
&& !nodes.some(node => node.kind === 'text' && !formattingSpace(node));
|
|
22
|
-
return { multiline, nodes
|
|
26
|
+
if (!multiline) return { multiline, nodes };
|
|
27
|
+
const displayed = nodes.filter(node => !formattingSpace(node)).map(node => {
|
|
28
|
+
if (!slottedLabel || node.kind !== 'text') return node;
|
|
29
|
+
return { ...node, value: node.value.replace(/^[\t\n\r\f ]+|[\t\n\r\f ]+$/g, '') };
|
|
30
|
+
});
|
|
31
|
+
return { multiline, nodes: displayed };
|
|
23
32
|
}
|
|
24
33
|
|
|
25
34
|
function text(node, target) {
|
|
@@ -90,8 +99,8 @@ function snippetBindings(model) {
|
|
|
90
99
|
function printer(model, target) {
|
|
91
100
|
const bindings = target === 'svelte' ? snippetBindings(model) : new Map();
|
|
92
101
|
|
|
93
|
-
function sequence(nodes, depth, forceLines = false) {
|
|
94
|
-
const arranged = layout(nodes);
|
|
102
|
+
function sequence(nodes, depth, forceLines = false, owner) {
|
|
103
|
+
const arranged = layout(nodes, owner);
|
|
95
104
|
const content = arranged.nodes.map(node => (arranged.multiline ? indent(depth) : '') + render(node, depth)).join(arranged.multiline ? '\n' : '');
|
|
96
105
|
return (forceLines && !arranged.multiline ? indent(depth) : '') + content;
|
|
97
106
|
}
|
|
@@ -130,10 +139,11 @@ function printer(model, target) {
|
|
|
130
139
|
const wrapped = attrs.length > 0;
|
|
131
140
|
const start = wrapped ? `<${node.tag}\n${attrs.map(value => indent(depth + 1) + value).join('\n')}\n${indent(depth)}` : `<${node.tag}`;
|
|
132
141
|
const children = target === 'vue' ? node.children : node.children.filter(child => child.kind !== 'slot');
|
|
133
|
-
const
|
|
142
|
+
const owner = target === 'html-next' ? node : undefined;
|
|
143
|
+
const arranged = layout(children, owner);
|
|
134
144
|
if (!arranged.nodes.length && (node.component || target === 'react')) return `${start}${wrapped ? '' : ' '}/>`;
|
|
135
145
|
if (voidElements.has(node.tag)) return `${start}>`;
|
|
136
|
-
const content = sequence(children, depth + 1);
|
|
146
|
+
const content = sequence(children, depth + 1, false, owner);
|
|
137
147
|
return arranged.multiline
|
|
138
148
|
? `${start}>\n${content}\n${indent(depth)}</${node.tag}>`
|
|
139
149
|
: `${start}>${content}</${node.tag}>`;
|