@oxide/design-system 6.4.0 → 6.4.1-canary.8495bee
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,8 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as _oxide_react_asciidoc from '@oxide/react-asciidoc';
|
|
3
|
-
import { DocumentSection, Block, DocumentBlock } from '@oxide/react-asciidoc';
|
|
3
|
+
import { DocumentSection, Block, DocumentBlock, InlineOverrides } from '@oxide/react-asciidoc';
|
|
4
4
|
import * as _asciidoctor_core from '@asciidoctor/core';
|
|
5
|
-
import { Document, Registry
|
|
5
|
+
import { Document, Registry } from '@asciidoctor/core';
|
|
6
6
|
|
|
7
7
|
declare function useIntersectionObserver(elements: Element[], callback: IntersectionObserverCallback, options: IntersectionObserverInit): IntersectionObserver | null;
|
|
8
8
|
declare function useActiveSectionTracking(initialSections: Element[], onSectionChange: (element: Element) => void, debug?: boolean): {
|
|
@@ -35,6 +35,7 @@ declare const attrs: {
|
|
|
35
35
|
sectlinks: string;
|
|
36
36
|
stem: string;
|
|
37
37
|
stylesheet: boolean;
|
|
38
|
+
icons: string;
|
|
38
39
|
};
|
|
39
40
|
declare const loadAsciidoctor: ({ extensions, }: {
|
|
40
41
|
extensions?: ((this: Registry) => void)[];
|
|
@@ -63,10 +64,19 @@ declare const AsciiDocBlocks: {
|
|
|
63
64
|
* '/<wbr/>path/<wbr/>to/<wbr/>long/<wbr/>file.txt'
|
|
64
65
|
*/
|
|
65
66
|
declare const renderWithBreaks: (text: string) => string;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
67
|
+
/**
|
|
68
|
+
* Inline-level overrides for the renderer. Pass these to `<Asciidoc>` as
|
|
69
|
+
* `options.inlineOverrides` to apply our customisations to inline content:
|
|
70
|
+
*
|
|
71
|
+
* <Asciidoc document={doc} options={{ overrides: AsciiDocBlocks, inlineOverrides }} />
|
|
72
|
+
*
|
|
73
|
+
* The only customisation today is inserting `<wbr/>` break opportunities into
|
|
74
|
+
* inline monospaced (`code`) spans so long paths and URLs wrap nicely. Every
|
|
75
|
+
* other quoted subtype is rendered exactly as the renderer would by default —
|
|
76
|
+
* we round-trip the node through `inlineHtml` (the renderer's own serialiser)
|
|
77
|
+
* and `parse` it back into React elements, so there's no risk of drifting from
|
|
78
|
+
* the stock output.
|
|
79
|
+
*/
|
|
80
|
+
declare const inlineOverrides: InlineOverrides;
|
|
71
81
|
|
|
72
|
-
export { AsciiDocBlocks, DesktopOutline,
|
|
82
|
+
export { AsciiDocBlocks, DesktopOutline, SmallScreenOutline, attrs, handleDocument, highlight, inlineOverrides, loadAsciidoctor, renderWithBreaks, useActiveSectionTracking, useDelegatedReactRouterLinks, useIntersectionObserver };
|
|
@@ -7,11 +7,14 @@ import {
|
|
|
7
7
|
} from "../../../chunk-H5ZEQGTH.js";
|
|
8
8
|
|
|
9
9
|
// components/src/asciidoc/index.tsx
|
|
10
|
-
import
|
|
11
|
-
|
|
10
|
+
import {
|
|
11
|
+
Content as Content4,
|
|
12
|
+
inlineHtml as inlineHtml2,
|
|
13
|
+
parse as parse3
|
|
14
|
+
} from "@oxide/react-asciidoc";
|
|
12
15
|
|
|
13
16
|
// components/src/asciidoc/Admonition.tsx
|
|
14
|
-
import { Content,
|
|
17
|
+
import { Content, RenderInline } from "@oxide/react-asciidoc";
|
|
15
18
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
19
|
var themeForAdmonition = {
|
|
17
20
|
note: "green-theme",
|
|
@@ -36,8 +39,8 @@ var Admonition = ({ node }) => {
|
|
|
36
39
|
/* @__PURE__ */ jsxs("div", { className: "admonition-content content", children: [
|
|
37
40
|
/* @__PURE__ */ jsx("div", { children: titleCase(attrs2.name.toString()) }),
|
|
38
41
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
39
|
-
node.
|
|
40
|
-
node.
|
|
42
|
+
node.titleInlines && /* @__PURE__ */ jsx("div", { className: "admonition-title", children: /* @__PURE__ */ jsx(RenderInline, { nodes: node.titleInlines }) }),
|
|
43
|
+
node.inlines && /* @__PURE__ */ jsx(RenderInline, { nodes: node.inlines }),
|
|
41
44
|
/* @__PURE__ */ jsx(Content, { blocks: node.blocks })
|
|
42
45
|
] })
|
|
43
46
|
] })
|
|
@@ -84,20 +87,32 @@ var Warning12 = ({ className }) => /* @__PURE__ */ jsx(
|
|
|
84
87
|
var Admonition_default = Admonition;
|
|
85
88
|
|
|
86
89
|
// components/src/asciidoc/Section.tsx
|
|
87
|
-
import {
|
|
90
|
+
import {
|
|
91
|
+
Content as Content2,
|
|
92
|
+
inlineHtml,
|
|
93
|
+
parse,
|
|
94
|
+
RenderInline as RenderInline2
|
|
95
|
+
} from "@oxide/react-asciidoc";
|
|
88
96
|
import cn from "classnames";
|
|
89
97
|
import { createElement } from "react";
|
|
90
98
|
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
91
|
-
var
|
|
99
|
+
var dropAnchorTags = (html) => html?.includes("<a") ? html.replace(/<(?:a\b[^>]*|\/a)>/g, "") : html;
|
|
100
|
+
var stripLinks = (nodes) => nodes.flatMap((node) => {
|
|
101
|
+
if (node.type === "anchor") return stripLinks(node.text);
|
|
102
|
+
if (node.type === "footnote")
|
|
103
|
+
return [{ type: "text", text: dropAnchorTags(inlineHtml([node]).__html), raw: true }];
|
|
104
|
+
return [node];
|
|
105
|
+
});
|
|
92
106
|
var Section = ({ node }) => {
|
|
93
107
|
const level = node.level;
|
|
94
108
|
let title = "";
|
|
95
109
|
let sectNum = node.num;
|
|
96
110
|
sectNum = sectNum && sectNum[0] === "." ? "" : sectNum;
|
|
111
|
+
const titleContent = node.hasCaption ? parse(dropAnchorTags(node.title)) : /* @__PURE__ */ jsx2(RenderInline2, { nodes: node.titleInlines && stripLinks(node.titleInlines) });
|
|
97
112
|
title = /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
98
113
|
/* @__PURE__ */ jsx2("span", { className: "anchor", id: node.id || "", "aria-hidden": "true" }),
|
|
99
114
|
/* @__PURE__ */ jsxs2("a", { className: "link group", href: `#${node.id}`, children: [
|
|
100
|
-
|
|
115
|
+
titleContent,
|
|
101
116
|
/* @__PURE__ */ jsx2(Link16Icon_default, { className: "text-accent-secondary ml-2 hidden group-hover:inline-block" })
|
|
102
117
|
] })
|
|
103
118
|
] });
|
|
@@ -106,10 +121,15 @@ var Section = ({ node }) => {
|
|
|
106
121
|
/* @__PURE__ */ jsx2("h1", { className: cn("sect0", node.role), "data-sectnum": sectNum, children: title }),
|
|
107
122
|
/* @__PURE__ */ jsx2(Content2, { blocks: node.blocks })
|
|
108
123
|
] });
|
|
124
|
+
} else if (level === 1) {
|
|
125
|
+
return /* @__PURE__ */ jsxs2("div", { className: cn("sect1", node.role), children: [
|
|
126
|
+
createElement("h2", { "data-sectnum": sectNum }, title),
|
|
127
|
+
/* @__PURE__ */ jsx2("div", { className: "sectionbody", children: /* @__PURE__ */ jsx2(Content2, { blocks: node.blocks }) })
|
|
128
|
+
] });
|
|
109
129
|
} else {
|
|
110
130
|
return /* @__PURE__ */ jsxs2("div", { className: cn(`sect${level}`, node.role), children: [
|
|
111
131
|
createElement(`h${level + 1}`, { "data-sectnum": sectNum }, title),
|
|
112
|
-
/* @__PURE__ */ jsx2(
|
|
132
|
+
/* @__PURE__ */ jsx2(Content2, { blocks: node.blocks })
|
|
113
133
|
] });
|
|
114
134
|
}
|
|
115
135
|
};
|
|
@@ -122,11 +142,12 @@ var Table = ({ node }) => /* @__PURE__ */ jsx3("div", { className: "table-wrappe
|
|
|
122
142
|
var Table_default = Table;
|
|
123
143
|
|
|
124
144
|
// components/src/asciidoc/TableOfContents.tsx
|
|
125
|
-
import { parse as
|
|
145
|
+
import { parse as parse2 } from "@oxide/react-asciidoc";
|
|
126
146
|
import * as Accordion from "@radix-ui/react-accordion";
|
|
127
147
|
import cn2 from "classnames";
|
|
128
148
|
import { Fragment as Fragment2, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
129
149
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
150
|
+
var dropAnchors = (html) => html.includes("<a") ? html.replace(/<(?:a\b[^>]*|\/a)>/g, "") : html;
|
|
130
151
|
function useIntersectionObserver(elements, callback, options) {
|
|
131
152
|
const [observer, setObserver] = useState(null);
|
|
132
153
|
useEffect(() => {
|
|
@@ -300,7 +321,7 @@ var DesktopOutline = ({
|
|
|
300
321
|
style: {
|
|
301
322
|
paddingLeft: `${0.5 + item.level * 0.5}rem`
|
|
302
323
|
},
|
|
303
|
-
children:
|
|
324
|
+
children: parse2(dropAnchors(item.title))
|
|
304
325
|
}
|
|
305
326
|
)
|
|
306
327
|
}
|
|
@@ -338,7 +359,7 @@ var SmallScreenOutline = ({
|
|
|
338
359
|
style: {
|
|
339
360
|
paddingLeft: `${0.5 + item.level * 0.5}rem`
|
|
340
361
|
},
|
|
341
|
-
children:
|
|
362
|
+
children: parse2(dropAnchors(item.title))
|
|
342
363
|
}
|
|
343
364
|
)
|
|
344
365
|
}
|
|
@@ -403,6 +424,7 @@ function useDelegatedReactRouterLinks(navigate, nodeRef, key) {
|
|
|
403
424
|
// components/src/asciidoc/util.ts
|
|
404
425
|
import asciidoctor from "@asciidoctor/core";
|
|
405
426
|
import {
|
|
427
|
+
Inline,
|
|
406
428
|
prepareDocument,
|
|
407
429
|
processDocument
|
|
408
430
|
} from "@oxide/react-asciidoc";
|
|
@@ -2030,20 +2052,26 @@ async function highlightCode(code, lang, { inline = false } = {}) {
|
|
|
2030
2052
|
var highlight = async (block) => {
|
|
2031
2053
|
if (block.type === "listing") {
|
|
2032
2054
|
const literalBlock = block;
|
|
2033
|
-
if (
|
|
2055
|
+
if (typeof literalBlock.source !== "string") {
|
|
2034
2056
|
return block;
|
|
2035
2057
|
}
|
|
2036
|
-
const
|
|
2058
|
+
const lineComment = literalBlock.attributes["line-comment"];
|
|
2059
|
+
const content = Inline.subCalloutsRaw(
|
|
2060
|
+
literalBlock.source,
|
|
2061
|
+
true,
|
|
2062
|
+
lineComment !== void 0 ? String(lineComment) : void 0
|
|
2063
|
+
);
|
|
2064
|
+
const calloutRegex = /<i class="conum" data-value="\d+"><\/i>(?:<b>\(\d+\)<\/b>)?/g;
|
|
2037
2065
|
const callouts = [];
|
|
2038
|
-
const placeholderContent =
|
|
2066
|
+
const placeholderContent = content.replace(calloutRegex, (match) => {
|
|
2039
2067
|
callouts.push(match);
|
|
2040
|
-
return `
|
|
2068
|
+
return `CALLOUTPLACEHOLDER${callouts.length - 1}END`;
|
|
2041
2069
|
});
|
|
2042
2070
|
if (!literalBlock.language) {
|
|
2043
2071
|
return {
|
|
2044
2072
|
...block,
|
|
2045
|
-
content: placeholderContent.replace(
|
|
2046
|
-
/
|
|
2073
|
+
content: Inline.subSpecialchars(placeholderContent).replace(
|
|
2074
|
+
/CALLOUTPLACEHOLDER(\d+)END/g,
|
|
2047
2075
|
(_, index) => callouts[parseInt(index)]
|
|
2048
2076
|
)
|
|
2049
2077
|
};
|
|
@@ -2054,7 +2082,7 @@ var highlight = async (block) => {
|
|
|
2054
2082
|
{ inline: true }
|
|
2055
2083
|
);
|
|
2056
2084
|
const restoredContent = highlightedContent.replace(
|
|
2057
|
-
/
|
|
2085
|
+
/CALLOUTPLACEHOLDER(\d+)END/g,
|
|
2058
2086
|
(_, index) => callouts[parseInt(index)]
|
|
2059
2087
|
);
|
|
2060
2088
|
return {
|
|
@@ -2067,42 +2095,23 @@ var highlight = async (block) => {
|
|
|
2067
2095
|
var attrs = {
|
|
2068
2096
|
sectlinks: "true",
|
|
2069
2097
|
stem: "latexmath",
|
|
2070
|
-
stylesheet: false
|
|
2098
|
+
stylesheet: false,
|
|
2099
|
+
icons: "font"
|
|
2071
2100
|
};
|
|
2072
2101
|
var loadAsciidoctor = ({
|
|
2073
2102
|
extensions = []
|
|
2074
2103
|
}) => {
|
|
2075
|
-
const
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
constructor() {
|
|
2079
|
-
this.baseConverter = new ad2.Html5Converter();
|
|
2080
|
-
}
|
|
2081
|
-
convert(node, transform) {
|
|
2082
|
-
switch (node.getNodeName()) {
|
|
2083
|
-
case "inline_callout":
|
|
2084
|
-
return convertInlineCallout(node);
|
|
2085
|
-
// We know this is always inline
|
|
2086
|
-
default:
|
|
2087
|
-
break;
|
|
2088
|
-
}
|
|
2089
|
-
return this.baseConverter.convert(node, transform);
|
|
2090
|
-
}
|
|
2091
|
-
}
|
|
2092
|
-
extensions.forEach((extension) => ad2.Extensions.register(extension));
|
|
2093
|
-
ad2.ConverterFactory.register(new InlineConverter2(), ["html5"]);
|
|
2094
|
-
return ad2;
|
|
2104
|
+
const ad = asciidoctor();
|
|
2105
|
+
extensions.forEach((extension) => ad.Extensions.register(extension));
|
|
2106
|
+
return ad;
|
|
2095
2107
|
};
|
|
2096
|
-
function convertInlineCallout(node) {
|
|
2097
|
-
return `<i class="conum" data-value="${node.getText()}"></i>`;
|
|
2098
|
-
}
|
|
2099
2108
|
var handleDocument = async (document) => {
|
|
2100
2109
|
const doc = prepareDocument(document);
|
|
2101
2110
|
return await processDocument(doc, highlight);
|
|
2102
2111
|
};
|
|
2103
2112
|
|
|
2104
2113
|
// components/src/asciidoc/index.tsx
|
|
2105
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
2114
|
+
import { Fragment as Fragment3, jsx as jsx5 } from "react/jsx-runtime";
|
|
2106
2115
|
var MinimalDocument = ({ document }) => /* @__PURE__ */ jsx5("div", { id: "content", className: "asciidoc-body w-full", children: /* @__PURE__ */ jsx5(Content4, { blocks: document.blocks }) });
|
|
2107
2116
|
var AsciiDocBlocks = {
|
|
2108
2117
|
Admonition: Admonition_default,
|
|
@@ -2118,74 +2127,23 @@ var renderWithBreaks = (text) => {
|
|
|
2118
2127
|
return segment.replace(/(?:^|(?<=\S))\/(?=\S)/g, "/<wbr/>");
|
|
2119
2128
|
}).join("");
|
|
2120
2129
|
};
|
|
2121
|
-
var
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
"single": ["‘", "’"],
|
|
2127
|
-
"mark": ["<mark>", "</mark>", true],
|
|
2128
|
-
"superscript": ["<sup>", "</sup>", true],
|
|
2129
|
-
"subscript": ["<sub>", "</sub>", true],
|
|
2130
|
-
"unquoted": ["<span>", "</span>", true],
|
|
2131
|
-
"asciimath": ["\\$", "\\$"],
|
|
2132
|
-
"latexmath": ["\\(", "\\)"]
|
|
2133
|
-
};
|
|
2134
|
-
var chop = (str) => str.substring(0, str.length - 1);
|
|
2135
|
-
var convertInlineQuoted = (node) => {
|
|
2136
|
-
const type = node.getType();
|
|
2137
|
-
const quoteTag = QUOTE_TAGS[type];
|
|
2138
|
-
const [open, close, tag] = quoteTag || ["", ""];
|
|
2139
|
-
let text = node.getText();
|
|
2140
|
-
if (type === "monospaced") {
|
|
2141
|
-
text = renderWithBreaks(text);
|
|
2142
|
-
}
|
|
2143
|
-
const id = node.getId();
|
|
2144
|
-
const role = node.getRole();
|
|
2145
|
-
const idAttr = id ? `id="${id}"` : "";
|
|
2146
|
-
const classAttr = role ? `class="${role}"` : "";
|
|
2147
|
-
const attrs2 = `${idAttr} ${classAttr}`;
|
|
2148
|
-
if (id || role) {
|
|
2149
|
-
if (tag) {
|
|
2150
|
-
return `${chop(open)} ${attrs2}>${text}${close}`;
|
|
2151
|
-
} else {
|
|
2152
|
-
return `<span ${attrs2}>${open}${text}${close}</span>`;
|
|
2153
|
-
}
|
|
2154
|
-
} else {
|
|
2155
|
-
return `${open}${text}${close}`;
|
|
2156
|
-
}
|
|
2157
|
-
};
|
|
2158
|
-
function convertInlineCallout2(node) {
|
|
2159
|
-
return `<i class="conum" data-value="${node.getText()}"></i>`;
|
|
2160
|
-
}
|
|
2161
|
-
var ad = asciidoctor2();
|
|
2162
|
-
var InlineConverter = class {
|
|
2163
|
-
baseConverter;
|
|
2164
|
-
constructor() {
|
|
2165
|
-
this.baseConverter = new ad.Html5Converter();
|
|
2166
|
-
}
|
|
2167
|
-
convert(node, transform) {
|
|
2168
|
-
switch (node.getNodeName()) {
|
|
2169
|
-
case "inline_quoted":
|
|
2170
|
-
return convertInlineQuoted(node);
|
|
2171
|
-
// We know this is always inline
|
|
2172
|
-
case "inline_callout":
|
|
2173
|
-
return convertInlineCallout2(node);
|
|
2174
|
-
// We know this is always inline
|
|
2175
|
-
default:
|
|
2176
|
-
break;
|
|
2130
|
+
var inlineOverrides = {
|
|
2131
|
+
quoted: ({ node }) => {
|
|
2132
|
+
let { __html } = inlineHtml2([node]);
|
|
2133
|
+
if (node.subtype === "monospaced") {
|
|
2134
|
+
__html = renderWithBreaks(__html);
|
|
2177
2135
|
}
|
|
2178
|
-
return
|
|
2136
|
+
return /* @__PURE__ */ jsx5(Fragment3, { children: parse3(__html) });
|
|
2179
2137
|
}
|
|
2180
2138
|
};
|
|
2181
2139
|
export {
|
|
2182
2140
|
AsciiDocBlocks,
|
|
2183
2141
|
DesktopOutline,
|
|
2184
|
-
InlineConverter,
|
|
2185
2142
|
SmallScreenOutline,
|
|
2186
2143
|
attrs,
|
|
2187
2144
|
handleDocument,
|
|
2188
2145
|
highlight,
|
|
2146
|
+
inlineOverrides,
|
|
2189
2147
|
loadAsciidoctor,
|
|
2190
2148
|
renderWithBreaks,
|
|
2191
2149
|
useActiveSectionTracking,
|