@oxide/design-system 6.3.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";
|
|
@@ -2005,18 +2027,15 @@ var oxide_syntax_default = {
|
|
|
2005
2027
|
};
|
|
2006
2028
|
|
|
2007
2029
|
// components/src/asciidoc/util.ts
|
|
2008
|
-
var
|
|
2030
|
+
var highlighterPromise = null;
|
|
2009
2031
|
var customLanguages = ["oxql", "p4"];
|
|
2010
2032
|
var supportedLanguages = [...Object.keys(bundledLanguages), ...customLanguages];
|
|
2011
|
-
|
|
2012
|
-
if (!
|
|
2033
|
+
function getHighlighter() {
|
|
2034
|
+
if (!highlighterPromise) {
|
|
2013
2035
|
const langs = [{ ...oxql_tmLanguage_default }, { ...p4_tmLanguage_default }];
|
|
2014
|
-
|
|
2015
|
-
themes: [oxide_syntax_default],
|
|
2016
|
-
langs
|
|
2017
|
-
});
|
|
2036
|
+
highlighterPromise = createHighlighter({ themes: [oxide_syntax_default], langs });
|
|
2018
2037
|
}
|
|
2019
|
-
return
|
|
2038
|
+
return highlighterPromise;
|
|
2020
2039
|
}
|
|
2021
2040
|
async function highlightCode(code, lang, { inline = false } = {}) {
|
|
2022
2041
|
const h = await getHighlighter();
|
|
@@ -2033,20 +2052,26 @@ async function highlightCode(code, lang, { inline = false } = {}) {
|
|
|
2033
2052
|
var highlight = async (block) => {
|
|
2034
2053
|
if (block.type === "listing") {
|
|
2035
2054
|
const literalBlock = block;
|
|
2036
|
-
if (
|
|
2055
|
+
if (typeof literalBlock.source !== "string") {
|
|
2037
2056
|
return block;
|
|
2038
2057
|
}
|
|
2039
|
-
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;
|
|
2040
2065
|
const callouts = [];
|
|
2041
|
-
const placeholderContent =
|
|
2066
|
+
const placeholderContent = content.replace(calloutRegex, (match) => {
|
|
2042
2067
|
callouts.push(match);
|
|
2043
|
-
return `
|
|
2068
|
+
return `CALLOUTPLACEHOLDER${callouts.length - 1}END`;
|
|
2044
2069
|
});
|
|
2045
2070
|
if (!literalBlock.language) {
|
|
2046
2071
|
return {
|
|
2047
2072
|
...block,
|
|
2048
|
-
content: placeholderContent.replace(
|
|
2049
|
-
/
|
|
2073
|
+
content: Inline.subSpecialchars(placeholderContent).replace(
|
|
2074
|
+
/CALLOUTPLACEHOLDER(\d+)END/g,
|
|
2050
2075
|
(_, index) => callouts[parseInt(index)]
|
|
2051
2076
|
)
|
|
2052
2077
|
};
|
|
@@ -2057,7 +2082,7 @@ var highlight = async (block) => {
|
|
|
2057
2082
|
{ inline: true }
|
|
2058
2083
|
);
|
|
2059
2084
|
const restoredContent = highlightedContent.replace(
|
|
2060
|
-
/
|
|
2085
|
+
/CALLOUTPLACEHOLDER(\d+)END/g,
|
|
2061
2086
|
(_, index) => callouts[parseInt(index)]
|
|
2062
2087
|
);
|
|
2063
2088
|
return {
|
|
@@ -2070,42 +2095,23 @@ var highlight = async (block) => {
|
|
|
2070
2095
|
var attrs = {
|
|
2071
2096
|
sectlinks: "true",
|
|
2072
2097
|
stem: "latexmath",
|
|
2073
|
-
stylesheet: false
|
|
2098
|
+
stylesheet: false,
|
|
2099
|
+
icons: "font"
|
|
2074
2100
|
};
|
|
2075
2101
|
var loadAsciidoctor = ({
|
|
2076
2102
|
extensions = []
|
|
2077
2103
|
}) => {
|
|
2078
|
-
const
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
constructor() {
|
|
2082
|
-
this.baseConverter = new ad2.Html5Converter();
|
|
2083
|
-
}
|
|
2084
|
-
convert(node, transform) {
|
|
2085
|
-
switch (node.getNodeName()) {
|
|
2086
|
-
case "inline_callout":
|
|
2087
|
-
return convertInlineCallout(node);
|
|
2088
|
-
// We know this is always inline
|
|
2089
|
-
default:
|
|
2090
|
-
break;
|
|
2091
|
-
}
|
|
2092
|
-
return this.baseConverter.convert(node, transform);
|
|
2093
|
-
}
|
|
2094
|
-
}
|
|
2095
|
-
extensions.forEach((extension) => ad2.Extensions.register(extension));
|
|
2096
|
-
ad2.ConverterFactory.register(new InlineConverter2(), ["html5"]);
|
|
2097
|
-
return ad2;
|
|
2104
|
+
const ad = asciidoctor();
|
|
2105
|
+
extensions.forEach((extension) => ad.Extensions.register(extension));
|
|
2106
|
+
return ad;
|
|
2098
2107
|
};
|
|
2099
|
-
function convertInlineCallout(node) {
|
|
2100
|
-
return `<i class="conum" data-value="${node.getText()}"></i>`;
|
|
2101
|
-
}
|
|
2102
2108
|
var handleDocument = async (document) => {
|
|
2103
2109
|
const doc = prepareDocument(document);
|
|
2104
2110
|
return await processDocument(doc, highlight);
|
|
2105
2111
|
};
|
|
2106
2112
|
|
|
2107
2113
|
// components/src/asciidoc/index.tsx
|
|
2108
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
2114
|
+
import { Fragment as Fragment3, jsx as jsx5 } from "react/jsx-runtime";
|
|
2109
2115
|
var MinimalDocument = ({ document }) => /* @__PURE__ */ jsx5("div", { id: "content", className: "asciidoc-body w-full", children: /* @__PURE__ */ jsx5(Content4, { blocks: document.blocks }) });
|
|
2110
2116
|
var AsciiDocBlocks = {
|
|
2111
2117
|
Admonition: Admonition_default,
|
|
@@ -2121,74 +2127,23 @@ var renderWithBreaks = (text) => {
|
|
|
2121
2127
|
return segment.replace(/(?:^|(?<=\S))\/(?=\S)/g, "/<wbr/>");
|
|
2122
2128
|
}).join("");
|
|
2123
2129
|
};
|
|
2124
|
-
var
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
"single": ["‘", "’"],
|
|
2130
|
-
"mark": ["<mark>", "</mark>", true],
|
|
2131
|
-
"superscript": ["<sup>", "</sup>", true],
|
|
2132
|
-
"subscript": ["<sub>", "</sub>", true],
|
|
2133
|
-
"unquoted": ["<span>", "</span>", true],
|
|
2134
|
-
"asciimath": ["\\$", "\\$"],
|
|
2135
|
-
"latexmath": ["\\(", "\\)"]
|
|
2136
|
-
};
|
|
2137
|
-
var chop = (str) => str.substring(0, str.length - 1);
|
|
2138
|
-
var convertInlineQuoted = (node) => {
|
|
2139
|
-
const type = node.getType();
|
|
2140
|
-
const quoteTag = QUOTE_TAGS[type];
|
|
2141
|
-
const [open, close, tag] = quoteTag || ["", ""];
|
|
2142
|
-
let text = node.getText();
|
|
2143
|
-
if (type === "monospaced") {
|
|
2144
|
-
text = renderWithBreaks(text);
|
|
2145
|
-
}
|
|
2146
|
-
const id = node.getId();
|
|
2147
|
-
const role = node.getRole();
|
|
2148
|
-
const idAttr = id ? `id="${id}"` : "";
|
|
2149
|
-
const classAttr = role ? `class="${role}"` : "";
|
|
2150
|
-
const attrs2 = `${idAttr} ${classAttr}`;
|
|
2151
|
-
if (id || role) {
|
|
2152
|
-
if (tag) {
|
|
2153
|
-
return `${chop(open)} ${attrs2}>${text}${close}`;
|
|
2154
|
-
} else {
|
|
2155
|
-
return `<span ${attrs2}>${open}${text}${close}</span>`;
|
|
2156
|
-
}
|
|
2157
|
-
} else {
|
|
2158
|
-
return `${open}${text}${close}`;
|
|
2159
|
-
}
|
|
2160
|
-
};
|
|
2161
|
-
function convertInlineCallout2(node) {
|
|
2162
|
-
return `<i class="conum" data-value="${node.getText()}"></i>`;
|
|
2163
|
-
}
|
|
2164
|
-
var ad = asciidoctor2();
|
|
2165
|
-
var InlineConverter = class {
|
|
2166
|
-
baseConverter;
|
|
2167
|
-
constructor() {
|
|
2168
|
-
this.baseConverter = new ad.Html5Converter();
|
|
2169
|
-
}
|
|
2170
|
-
convert(node, transform) {
|
|
2171
|
-
switch (node.getNodeName()) {
|
|
2172
|
-
case "inline_quoted":
|
|
2173
|
-
return convertInlineQuoted(node);
|
|
2174
|
-
// We know this is always inline
|
|
2175
|
-
case "inline_callout":
|
|
2176
|
-
return convertInlineCallout2(node);
|
|
2177
|
-
// We know this is always inline
|
|
2178
|
-
default:
|
|
2179
|
-
break;
|
|
2130
|
+
var inlineOverrides = {
|
|
2131
|
+
quoted: ({ node }) => {
|
|
2132
|
+
let { __html } = inlineHtml2([node]);
|
|
2133
|
+
if (node.subtype === "monospaced") {
|
|
2134
|
+
__html = renderWithBreaks(__html);
|
|
2180
2135
|
}
|
|
2181
|
-
return
|
|
2136
|
+
return /* @__PURE__ */ jsx5(Fragment3, { children: parse3(__html) });
|
|
2182
2137
|
}
|
|
2183
2138
|
};
|
|
2184
2139
|
export {
|
|
2185
2140
|
AsciiDocBlocks,
|
|
2186
2141
|
DesktopOutline,
|
|
2187
|
-
InlineConverter,
|
|
2188
2142
|
SmallScreenOutline,
|
|
2189
2143
|
attrs,
|
|
2190
2144
|
handleDocument,
|
|
2191
2145
|
highlight,
|
|
2146
|
+
inlineOverrides,
|
|
2192
2147
|
loadAsciidoctor,
|
|
2193
2148
|
renderWithBreaks,
|
|
2194
2149
|
useActiveSectionTracking,
|