@threadlabs/looma 0.46.1 → 0.46.3
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/README.md +4 -2
- package/components/ui-site-header/ui-site-header.html +0 -3
- package/dist/index.js +1 -1
- package/docs/catalog.json +3 -3
- package/editor/chunks/expressmark.js +51 -5
- package/editor/expressmark.d.ts +3 -1
- package/package.json +2 -2
- package/styles/ui-site-header.css +0 -6
- package/vue/UiSiteHeader.vue +0 -7
- package/vue/chunks/UiSiteHeader.js +1 -1
- package/vue/components.css +0 -7
package/docs/catalog.json
CHANGED
|
@@ -463,7 +463,7 @@
|
|
|
463
463
|
],
|
|
464
464
|
"schemaVersion": 1,
|
|
465
465
|
"package": "@threadlabs/looma",
|
|
466
|
-
"version": "0.46.
|
|
466
|
+
"version": "0.46.3",
|
|
467
467
|
"groups": [
|
|
468
468
|
{
|
|
469
469
|
"id": "layout",
|
|
@@ -17985,7 +17985,7 @@
|
|
|
17985
17985
|
"tag": "ui-site-header",
|
|
17986
17986
|
"package": "@threadlabs/looma",
|
|
17987
17987
|
"root": "header",
|
|
17988
|
-
"description": "Supply brand, navigation, and optional actions once. Below the breakpoint, SiteHeader automatically
|
|
17988
|
+
"description": "Supply brand, navigation, and optional actions once. Below the breakpoint, SiteHeader automatically puts the hamburger in the inline navigation's position beside the brand, with the same gap (mirrored in RTL). Optional actions stay at the trailing edge. It presents the same navigation in a full-height, scrollable drawer with a dark backdrop. It handles focus, Escape, outside press, link selection, and page scroll locking. Applications supply links and routing; no menu slot, duplicate links, IDs, or drawer wiring are needed. Before JavaScript, navigation remains available inline unless a custom native menu supplies its mobile navigation. Native custom menu controls remain usable before upgrade. Use TopBar for contextual application tools.",
|
|
17989
17989
|
"designTokens": {
|
|
17990
17990
|
"sources": [
|
|
17991
17991
|
"packages/looma/src/components/ui-site-header/ui-site-header.html"
|
|
@@ -18261,7 +18261,7 @@
|
|
|
18261
18261
|
"id": "@threadlabs/looma/ui-site-header/01-default",
|
|
18262
18262
|
"name": "01-default",
|
|
18263
18263
|
"title": "Site navigation",
|
|
18264
|
-
"description": "A full-width header keeps its logo visible, places desktop navigation beside it, and puts search and account controls at the trailing edge. Below 64rem, the
|
|
18264
|
+
"description": "A full-width header keeps its logo visible, places desktop navigation beside it, and puts search and account controls at the trailing edge. Below 64rem, the hamburger takes the inline navigation's position beside the logo, keeping the same gap. It opens the same navigation in a full-height, scrollable drawer with a dark backdrop. No menu trigger, duplicate links, IDs, or event wiring are needed. Pass actions individually so the header reserves their adjustable hit areas.",
|
|
18265
18265
|
"markup": "<ui-site-header>\n <a slot=\"brand\" href=\"#home\" aria-label=\"Folio home\"><ui-icon name=\"compass\"></ui-icon>Folio</a>\n <a slot=\"navigation\" href=\"#guide\" aria-current=\"page\">Guide</a>\n <a slot=\"navigation\" href=\"#components\">Components</a>\n <a slot=\"navigation\" href=\"#journal\">Journal</a>\n <ui-icon-button slot=\"actions\" id=\"site-header-search-trigger\" size=\"sm\" label=\"Search pages\"><ui-icon name=\"search\"></ui-icon></ui-icon-button>\n <ui-icon-button slot=\"actions\" id=\"site-header-account-trigger\" size=\"sm\" label=\"Account\"><ui-icon name=\"user-round\"></ui-icon></ui-icon-button>\n</ui-site-header>\n<ui-popover for=\"site-header-search-trigger\"><ui-form-field>\n <label slot=\"label\" for=\"site-header-search\">Search pages</label><ui-input id=\"site-header-search\" type=\"search\" placeholder=\"Find a page\"></ui-input>\n </ui-form-field></ui-popover>\n<ui-popover for=\"site-header-account-trigger\"><nav aria-label=\"Account\">\n <ui-stack gap=\"s\"><a href=\"#profile\">Your profile</a><a href=\"#settings\">Settings</a></ui-stack>\n </nav></ui-popover>",
|
|
18266
18266
|
"resizable": false,
|
|
18267
18267
|
"bindings": "",
|
|
@@ -541,6 +541,49 @@ function headingsOf(document, references) {
|
|
|
541
541
|
visit(document);
|
|
542
542
|
return headings;
|
|
543
543
|
}
|
|
544
|
+
function tocBody(headings, depth, ordered) {
|
|
545
|
+
const ids = assignLoomaHeadingIds(headings);
|
|
546
|
+
const roots = [];
|
|
547
|
+
const stack = [];
|
|
548
|
+
headings.forEach((heading, index) => {
|
|
549
|
+
const level = Number(heading.node.attrs?.level ?? 1);
|
|
550
|
+
if (level > depth || !heading.text) return;
|
|
551
|
+
while (stack.length && stack[stack.length - 1].level >= level) stack.pop();
|
|
552
|
+
const item = {
|
|
553
|
+
type: "listItem",
|
|
554
|
+
body: [{
|
|
555
|
+
type: "paragraph",
|
|
556
|
+
children: [{
|
|
557
|
+
type: "link",
|
|
558
|
+
url: `#${ids[index]}`,
|
|
559
|
+
value: heading.text,
|
|
560
|
+
attributes: {
|
|
561
|
+
target: "_self",
|
|
562
|
+
rel: "noopener noreferrer"
|
|
563
|
+
}
|
|
564
|
+
}]
|
|
565
|
+
}]
|
|
566
|
+
};
|
|
567
|
+
const parent = stack[stack.length - 1]?.item;
|
|
568
|
+
const destination = parent ? parent.body ??= [] : roots;
|
|
569
|
+
let list = destination[destination.length - 1];
|
|
570
|
+
if (list?.type !== "list") {
|
|
571
|
+
list = {
|
|
572
|
+
type: "list",
|
|
573
|
+
ordered,
|
|
574
|
+
...ordered ? { start: 1 } : {},
|
|
575
|
+
children: []
|
|
576
|
+
};
|
|
577
|
+
destination.push(list);
|
|
578
|
+
}
|
|
579
|
+
list.children.push(item);
|
|
580
|
+
stack.push({
|
|
581
|
+
level,
|
|
582
|
+
item
|
|
583
|
+
});
|
|
584
|
+
});
|
|
585
|
+
return roots;
|
|
586
|
+
}
|
|
544
587
|
function customHeadings(headings) {
|
|
545
588
|
const marked = /* @__PURE__ */ new Set();
|
|
546
589
|
for (;;) {
|
|
@@ -896,7 +939,7 @@ function toBareNode(node, path, context) {
|
|
|
896
939
|
fields(node, ["format", "depth"], path);
|
|
897
940
|
const depth = Number(attrs.depth ?? 3);
|
|
898
941
|
const format = string(attrs.format, "plain");
|
|
899
|
-
if (!node.content?.length) {
|
|
942
|
+
if (!node.content?.length && context.tableOfContents !== "entries") {
|
|
900
943
|
const attributes = {};
|
|
901
944
|
if (depth !== 3) attributes.depth = String(depth);
|
|
902
945
|
if (format !== "plain") attributes.format = format;
|
|
@@ -913,7 +956,7 @@ function toBareNode(node, path, context) {
|
|
|
913
956
|
depth: String(depth),
|
|
914
957
|
format
|
|
915
958
|
},
|
|
916
|
-
body: blocks()
|
|
959
|
+
body: node.content?.length ? blocks() : tocBody(context.headings, depth, format === "numbered")
|
|
917
960
|
};
|
|
918
961
|
}
|
|
919
962
|
default: return fail(path, `node ${node.type ?? "unknown"}`);
|
|
@@ -923,7 +966,7 @@ function toBareNode(node, path, context) {
|
|
|
923
966
|
* Maps an editor's saved JSON to the independent Expressive Markdown AST without DOM access.
|
|
924
967
|
* @contract Unsupported nodes, marks and durable attributes throw with their location; input is never
|
|
925
968
|
* mutated. Footnote and link definitions stay where they are, and a table of contents stays a
|
|
926
|
-
* placeholder unless it holds authored navigation.
|
|
969
|
+
* placeholder unless it holds authored navigation or `tableOfContents: "entries"` is requested.
|
|
927
970
|
*/
|
|
928
971
|
function editorDocumentToExpressmark(document, options = {}) {
|
|
929
972
|
if (document.type !== "doc") fail("document", "non-document root");
|
|
@@ -990,7 +1033,9 @@ function editorDocumentToExpressmark(document, options = {}) {
|
|
|
990
1033
|
const context = {
|
|
991
1034
|
custom: customHeadings(headings),
|
|
992
1035
|
definitions,
|
|
993
|
-
references
|
|
1036
|
+
references,
|
|
1037
|
+
headings,
|
|
1038
|
+
tableOfContents: options.tableOfContents
|
|
994
1039
|
};
|
|
995
1040
|
return {
|
|
996
1041
|
type: "document",
|
|
@@ -1505,7 +1550,8 @@ function keepAuthored(source, edited, options) {
|
|
|
1505
1550
|
for (let index = 0; index < current.length;) {
|
|
1506
1551
|
const found = keys.findIndex((key, block) => block > used && key.length > 0 && key.every((value, at) => current[index + at] === value));
|
|
1507
1552
|
if (found >= 0) {
|
|
1508
|
-
|
|
1553
|
+
const original = source.body[found];
|
|
1554
|
+
body.push(options.tableOfContents === "entries" && original.type === "leaf" && original.subType === "toc" ? edited.body[index] : original);
|
|
1509
1555
|
index += keys[found].length;
|
|
1510
1556
|
used = found;
|
|
1511
1557
|
continue;
|
package/editor/expressmark.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { type LoomaReferenceMap } from "./reference-display.js";
|
|
|
4
4
|
/** Conversion-time display snapshot, independent from the authored editor document. */
|
|
5
5
|
export interface EditorMarkdownConversionOptions extends ConversionOptions {
|
|
6
6
|
references?: LoomaReferenceMap;
|
|
7
|
+
/** Write current links for portable exports; authored navigation is always preserved. Defaults to a reader-built placeholder. */
|
|
8
|
+
tableOfContents?: "placeholder" | "entries";
|
|
7
9
|
/**
|
|
8
10
|
* The Markdown the document was read from. Its front matter, every block the editor left
|
|
9
11
|
* unchanged and the spacing between them are written back byte for byte; an edited block keeps
|
|
@@ -24,7 +26,7 @@ export declare class EditorMarkdownConversionError extends Error {
|
|
|
24
26
|
* Maps an editor's saved JSON to the independent Expressive Markdown AST without DOM access.
|
|
25
27
|
* @contract Unsupported nodes, marks and durable attributes throw with their location; input is never
|
|
26
28
|
* mutated. Footnote and link definitions stay where they are, and a table of contents stays a
|
|
27
|
-
* placeholder unless it holds authored navigation.
|
|
29
|
+
* placeholder unless it holds authored navigation or `tableOfContents: "entries"` is requested.
|
|
28
30
|
*/
|
|
29
31
|
export declare function editorDocumentToExpressmark(document: JSONContent, options?: EditorMarkdownConversionOptions): Document;
|
|
30
32
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threadlabs/looma",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Looma components as HTML, Vue, and plain DOM, with design tokens.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"highlight.js": "11.11.2",
|
|
114
114
|
"lowlight": "^3.3.0",
|
|
115
115
|
"lucide": "~0.554.0",
|
|
116
|
-
"expressmark": ">=0.
|
|
116
|
+
"expressmark": ">=0.5.1 <1",
|
|
117
117
|
"parse5": "^8.0.1"
|
|
118
118
|
},
|
|
119
119
|
"peerDependencies": {
|
|
@@ -104,9 +104,6 @@
|
|
|
104
104
|
flex-wrap: nowrap !important;
|
|
105
105
|
align-items: center !important;
|
|
106
106
|
}
|
|
107
|
-
:scope:where([data-component~="ui-site-header"])[data-ui-site-header-state~="drawer"] .brand {
|
|
108
|
-
flex: 1 1 0;
|
|
109
|
-
}
|
|
110
107
|
:scope:where([data-component~="ui-site-header"])[data-ui-site-header-state~="enhanced"][data-ui-site-header-state~="drawer"]:has(.navigation:not(:empty), .custom-menu:not(:empty)) .menu {
|
|
111
108
|
display: grid !important;
|
|
112
109
|
grid-template-columns: minmax(max-content, var(--ui-control-min-block-size)) !important;
|
|
@@ -379,9 +376,6 @@
|
|
|
379
376
|
flex-wrap: nowrap !important;
|
|
380
377
|
align-items: center !important;
|
|
381
378
|
}
|
|
382
|
-
:where([data-component~="ui-site-header"])[data-ui-site-header-state~="drawer"] .brand:where(:scope, :not([data-component], [data-slotted]:not([data-slotted~="ui-site-header"]))) {
|
|
383
|
-
flex: 1 1 0;
|
|
384
|
-
}
|
|
385
379
|
:where([data-component~="ui-site-header"])[data-ui-site-header-state~="enhanced"][data-ui-site-header-state~="drawer"]:has(.navigation:not(:empty), .custom-menu:not(:empty)) .menu:where(:scope, :not([data-component], [data-slotted]:not([data-slotted~="ui-site-header"]))) {
|
|
386
380
|
display: grid !important;
|
|
387
381
|
grid-template-columns: minmax(max-content, var(--ui-control-min-block-size)) !important;
|
package/vue/UiSiteHeader.vue
CHANGED
|
@@ -417,9 +417,6 @@ useComponentHost(() => import('../components/ui-site-header/ui-site-header.js'),
|
|
|
417
417
|
flex-wrap: nowrap !important;
|
|
418
418
|
align-items: center !important;
|
|
419
419
|
}
|
|
420
|
-
:global(:scope[data-ui-site-header-state~="drawer"] .brand:where([data-hn-ui-site-header])) {
|
|
421
|
-
flex: 1 1 0;
|
|
422
|
-
}
|
|
423
420
|
:global(:scope[data-ui-site-header-state~="enhanced"][data-ui-site-header-state~="drawer"]:has(.navigation:not(:empty), .custom-menu:not(:empty))
|
|
424
421
|
.menu:where([data-hn-ui-site-header])) {
|
|
425
422
|
display: grid !important;
|
|
@@ -717,10 +714,6 @@ useComponentHost(() => import('../components/ui-site-header/ui-site-header.js'),
|
|
|
717
714
|
flex-wrap: nowrap !important;
|
|
718
715
|
align-items: center !important;
|
|
719
716
|
}
|
|
720
|
-
:global(:where(.ui-site-header)[data-ui-site-header-state~="drawer"]
|
|
721
|
-
.brand:where(:scope, :not([data-hn], [data-slotted]:not([data-slotted~="ui-site-header"]))):where([data-hn-ui-site-header])) {
|
|
722
|
-
flex: 1 1 0;
|
|
723
|
-
}
|
|
724
717
|
:global(:where(.ui-site-header)[data-ui-site-header-state~="enhanced"][data-ui-site-header-state~="drawer"]:has(.navigation:not(:empty), .custom-menu:not(:empty))
|
|
725
718
|
.menu:where(:scope, :not([data-hn], [data-slotted]:not([data-slotted~="ui-site-header"]))):where([data-hn-ui-site-header])) {
|
|
726
719
|
display: grid !important;
|
package/vue/components.css
CHANGED
|
@@ -10193,9 +10193,6 @@ dialog:where([data-hn-ui-search-shell]) {
|
|
|
10193
10193
|
flex-wrap: nowrap !important;
|
|
10194
10194
|
align-items: center !important;
|
|
10195
10195
|
}
|
|
10196
|
-
:scope[data-ui-site-header-state~="drawer"] .brand:where([data-hn-ui-site-header]) {
|
|
10197
|
-
flex: 1 1 0;
|
|
10198
|
-
}
|
|
10199
10196
|
:scope[data-ui-site-header-state~="enhanced"][data-ui-site-header-state~="drawer"]:has(.navigation:not(:empty), .custom-menu:not(:empty))
|
|
10200
10197
|
.menu:where([data-hn-ui-site-header]) {
|
|
10201
10198
|
display: grid !important;
|
|
@@ -10486,10 +10483,6 @@ dialog:where([data-hn-ui-search-shell]) {
|
|
|
10486
10483
|
flex-wrap: nowrap !important;
|
|
10487
10484
|
align-items: center !important;
|
|
10488
10485
|
}
|
|
10489
|
-
:where(.ui-site-header)[data-ui-site-header-state~="drawer"]
|
|
10490
|
-
.brand:where(:scope, :not([data-hn], [data-slotted]:not([data-slotted~="ui-site-header"]))):where([data-hn-ui-site-header]) {
|
|
10491
|
-
flex: 1 1 0;
|
|
10492
|
-
}
|
|
10493
10486
|
:where(.ui-site-header)[data-ui-site-header-state~="enhanced"][data-ui-site-header-state~="drawer"]:has(.navigation:not(:empty), .custom-menu:not(:empty))
|
|
10494
10487
|
.menu:where(:scope, :not([data-hn], [data-slotted]:not([data-slotted~="ui-site-header"]))):where([data-hn-ui-site-header]) {
|
|
10495
10488
|
display: grid !important;
|