@oxide/design-system 6.4.0 → 6.4.1-canary.dca2986
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,
|
|
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,20 @@ var Warning12 = ({ className }) => /* @__PURE__ */ jsx(
|
|
|
84
87
|
var Admonition_default = Admonition;
|
|
85
88
|
|
|
86
89
|
// components/src/asciidoc/Section.tsx
|
|
87
|
-
import { Content as Content2, parse as
|
|
90
|
+
import { Content as Content2, parse, RenderInline as RenderInline2 } from "@oxide/react-asciidoc";
|
|
88
91
|
import cn from "classnames";
|
|
89
92
|
import { createElement } from "react";
|
|
90
93
|
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
91
|
-
var stripAnchors = (str) => str.replace(/<a[^>]*>(.*?)<\/a>/gi, "$1");
|
|
92
94
|
var Section = ({ node }) => {
|
|
93
95
|
const level = node.level;
|
|
94
96
|
let title = "";
|
|
95
97
|
let sectNum = node.num;
|
|
96
98
|
sectNum = sectNum && sectNum[0] === "." ? "" : sectNum;
|
|
99
|
+
const titleContent = node.hasCaption ? parse(node.title) : /* @__PURE__ */ jsx2(RenderInline2, { nodes: node.titleInlines });
|
|
97
100
|
title = /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
98
101
|
/* @__PURE__ */ jsx2("span", { className: "anchor", id: node.id || "", "aria-hidden": "true" }),
|
|
99
102
|
/* @__PURE__ */ jsxs2("a", { className: "link group", href: `#${node.id}`, children: [
|
|
100
|
-
|
|
103
|
+
titleContent,
|
|
101
104
|
/* @__PURE__ */ jsx2(Link16Icon_default, { className: "text-accent-secondary ml-2 hidden group-hover:inline-block" })
|
|
102
105
|
] })
|
|
103
106
|
] });
|
|
@@ -106,10 +109,15 @@ var Section = ({ node }) => {
|
|
|
106
109
|
/* @__PURE__ */ jsx2("h1", { className: cn("sect0", node.role), "data-sectnum": sectNum, children: title }),
|
|
107
110
|
/* @__PURE__ */ jsx2(Content2, { blocks: node.blocks })
|
|
108
111
|
] });
|
|
112
|
+
} else if (level === 1) {
|
|
113
|
+
return /* @__PURE__ */ jsxs2("div", { className: cn("sect1", node.role), children: [
|
|
114
|
+
createElement("h2", { "data-sectnum": sectNum }, title),
|
|
115
|
+
/* @__PURE__ */ jsx2("div", { className: "sectionbody", children: /* @__PURE__ */ jsx2(Content2, { blocks: node.blocks }) })
|
|
116
|
+
] });
|
|
109
117
|
} else {
|
|
110
118
|
return /* @__PURE__ */ jsxs2("div", { className: cn(`sect${level}`, node.role), children: [
|
|
111
119
|
createElement(`h${level + 1}`, { "data-sectnum": sectNum }, title),
|
|
112
|
-
/* @__PURE__ */ jsx2(
|
|
120
|
+
/* @__PURE__ */ jsx2(Content2, { blocks: node.blocks })
|
|
113
121
|
] });
|
|
114
122
|
}
|
|
115
123
|
};
|
|
@@ -122,11 +130,12 @@ var Table = ({ node }) => /* @__PURE__ */ jsx3("div", { className: "table-wrappe
|
|
|
122
130
|
var Table_default = Table;
|
|
123
131
|
|
|
124
132
|
// components/src/asciidoc/TableOfContents.tsx
|
|
125
|
-
import { parse as
|
|
133
|
+
import { parse as parse2 } from "@oxide/react-asciidoc";
|
|
126
134
|
import * as Accordion from "@radix-ui/react-accordion";
|
|
127
135
|
import cn2 from "classnames";
|
|
128
136
|
import { Fragment as Fragment2, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
129
137
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
138
|
+
var dropAnchors = (html) => html.includes("<a") ? html.replace(/<(?:a\b[^>]*|\/a)>/g, "") : html;
|
|
130
139
|
function useIntersectionObserver(elements, callback, options) {
|
|
131
140
|
const [observer, setObserver] = useState(null);
|
|
132
141
|
useEffect(() => {
|
|
@@ -300,7 +309,7 @@ var DesktopOutline = ({
|
|
|
300
309
|
style: {
|
|
301
310
|
paddingLeft: `${0.5 + item.level * 0.5}rem`
|
|
302
311
|
},
|
|
303
|
-
children:
|
|
312
|
+
children: parse2(dropAnchors(item.title))
|
|
304
313
|
}
|
|
305
314
|
)
|
|
306
315
|
}
|
|
@@ -338,7 +347,7 @@ var SmallScreenOutline = ({
|
|
|
338
347
|
style: {
|
|
339
348
|
paddingLeft: `${0.5 + item.level * 0.5}rem`
|
|
340
349
|
},
|
|
341
|
-
children:
|
|
350
|
+
children: parse2(dropAnchors(item.title))
|
|
342
351
|
}
|
|
343
352
|
)
|
|
344
353
|
}
|
|
@@ -403,6 +412,7 @@ function useDelegatedReactRouterLinks(navigate, nodeRef, key) {
|
|
|
403
412
|
// components/src/asciidoc/util.ts
|
|
404
413
|
import asciidoctor from "@asciidoctor/core";
|
|
405
414
|
import {
|
|
415
|
+
Inline,
|
|
406
416
|
prepareDocument,
|
|
407
417
|
processDocument
|
|
408
418
|
} from "@oxide/react-asciidoc";
|
|
@@ -2030,20 +2040,26 @@ async function highlightCode(code, lang, { inline = false } = {}) {
|
|
|
2030
2040
|
var highlight = async (block) => {
|
|
2031
2041
|
if (block.type === "listing") {
|
|
2032
2042
|
const literalBlock = block;
|
|
2033
|
-
if (
|
|
2043
|
+
if (typeof literalBlock.source !== "string") {
|
|
2034
2044
|
return block;
|
|
2035
2045
|
}
|
|
2036
|
-
const
|
|
2046
|
+
const lineComment = literalBlock.attributes["line-comment"];
|
|
2047
|
+
const content = Inline.subCalloutsRaw(
|
|
2048
|
+
literalBlock.source,
|
|
2049
|
+
true,
|
|
2050
|
+
lineComment !== void 0 ? String(lineComment) : void 0
|
|
2051
|
+
);
|
|
2052
|
+
const calloutRegex = /<i class="conum" data-value="\d+"><\/i>(?:<b>\(\d+\)<\/b>)?/g;
|
|
2037
2053
|
const callouts = [];
|
|
2038
|
-
const placeholderContent =
|
|
2054
|
+
const placeholderContent = content.replace(calloutRegex, (match) => {
|
|
2039
2055
|
callouts.push(match);
|
|
2040
|
-
return `
|
|
2056
|
+
return `CALLOUTPLACEHOLDER${callouts.length - 1}END`;
|
|
2041
2057
|
});
|
|
2042
2058
|
if (!literalBlock.language) {
|
|
2043
2059
|
return {
|
|
2044
2060
|
...block,
|
|
2045
|
-
content: placeholderContent.replace(
|
|
2046
|
-
/
|
|
2061
|
+
content: Inline.subSpecialchars(placeholderContent).replace(
|
|
2062
|
+
/CALLOUTPLACEHOLDER(\d+)END/g,
|
|
2047
2063
|
(_, index) => callouts[parseInt(index)]
|
|
2048
2064
|
)
|
|
2049
2065
|
};
|
|
@@ -2054,7 +2070,7 @@ var highlight = async (block) => {
|
|
|
2054
2070
|
{ inline: true }
|
|
2055
2071
|
);
|
|
2056
2072
|
const restoredContent = highlightedContent.replace(
|
|
2057
|
-
/
|
|
2073
|
+
/CALLOUTPLACEHOLDER(\d+)END/g,
|
|
2058
2074
|
(_, index) => callouts[parseInt(index)]
|
|
2059
2075
|
);
|
|
2060
2076
|
return {
|
|
@@ -2067,42 +2083,23 @@ var highlight = async (block) => {
|
|
|
2067
2083
|
var attrs = {
|
|
2068
2084
|
sectlinks: "true",
|
|
2069
2085
|
stem: "latexmath",
|
|
2070
|
-
stylesheet: false
|
|
2086
|
+
stylesheet: false,
|
|
2087
|
+
icons: "font"
|
|
2071
2088
|
};
|
|
2072
2089
|
var loadAsciidoctor = ({
|
|
2073
2090
|
extensions = []
|
|
2074
2091
|
}) => {
|
|
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;
|
|
2092
|
+
const ad = asciidoctor();
|
|
2093
|
+
extensions.forEach((extension) => ad.Extensions.register(extension));
|
|
2094
|
+
return ad;
|
|
2095
2095
|
};
|
|
2096
|
-
function convertInlineCallout(node) {
|
|
2097
|
-
return `<i class="conum" data-value="${node.getText()}"></i>`;
|
|
2098
|
-
}
|
|
2099
2096
|
var handleDocument = async (document) => {
|
|
2100
2097
|
const doc = prepareDocument(document);
|
|
2101
2098
|
return await processDocument(doc, highlight);
|
|
2102
2099
|
};
|
|
2103
2100
|
|
|
2104
2101
|
// components/src/asciidoc/index.tsx
|
|
2105
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
2102
|
+
import { Fragment as Fragment3, jsx as jsx5 } from "react/jsx-runtime";
|
|
2106
2103
|
var MinimalDocument = ({ document }) => /* @__PURE__ */ jsx5("div", { id: "content", className: "asciidoc-body w-full", children: /* @__PURE__ */ jsx5(Content4, { blocks: document.blocks }) });
|
|
2107
2104
|
var AsciiDocBlocks = {
|
|
2108
2105
|
Admonition: Admonition_default,
|
|
@@ -2118,74 +2115,23 @@ var renderWithBreaks = (text) => {
|
|
|
2118
2115
|
return segment.replace(/(?:^|(?<=\S))\/(?=\S)/g, "/<wbr/>");
|
|
2119
2116
|
}).join("");
|
|
2120
2117
|
};
|
|
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;
|
|
2118
|
+
var inlineOverrides = {
|
|
2119
|
+
quoted: ({ node }) => {
|
|
2120
|
+
let { __html } = inlineHtml([node]);
|
|
2121
|
+
if (node.subtype === "monospaced") {
|
|
2122
|
+
__html = renderWithBreaks(__html);
|
|
2177
2123
|
}
|
|
2178
|
-
return
|
|
2124
|
+
return /* @__PURE__ */ jsx5(Fragment3, { children: parse3(__html) });
|
|
2179
2125
|
}
|
|
2180
2126
|
};
|
|
2181
2127
|
export {
|
|
2182
2128
|
AsciiDocBlocks,
|
|
2183
2129
|
DesktopOutline,
|
|
2184
|
-
InlineConverter,
|
|
2185
2130
|
SmallScreenOutline,
|
|
2186
2131
|
attrs,
|
|
2187
2132
|
handleDocument,
|
|
2188
2133
|
highlight,
|
|
2134
|
+
inlineOverrides,
|
|
2189
2135
|
loadAsciidoctor,
|
|
2190
2136
|
renderWithBreaks,
|
|
2191
2137
|
useActiveSectionTracking,
|