@caseparts-org/caseblocks 0.0.194 → 0.0.196
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/dist/assets/Admonition.css +1 -0
- package/dist/assets/MainNav.css +1 -1
- package/dist/assets/Markdown.css +1 -1
- package/dist/main-browser.d.ts +4 -6
- package/dist/main-browser.js +3 -5
- package/dist/main-client.js +54 -52
- package/dist/main-server.d.ts +2 -0
- package/dist/main-server.js +16 -14
- package/dist/main.d.ts +2 -0
- package/dist/main.js +18 -16
- package/dist/molecules/Admonition/Admonition.d.ts +10 -0
- package/dist/molecules/Admonition/Admonition.js +46 -0
- package/dist/molecules/Admonition/Admonition.stories.d.ts +13 -0
- package/dist/molecules/Admonition/Admonition.stories.js +51 -0
- package/dist/molecules/Markdown/Markdown.d.ts +12 -0
- package/dist/{atoms → molecules}/Markdown/Markdown.js +891 -855
- package/dist/{atoms → molecules}/Markdown/Markdown.stories.d.ts +2 -0
- package/dist/molecules/Markdown/Markdown.stories.js +148 -0
- package/dist/molecules/Markdown/remarkAdmonition.d.ts +15 -0
- package/dist/molecules/Markdown/remarkAdmonition.js +120 -0
- package/dist/{atoms → molecules}/Markdown/usePreprocessedMarkdown.d.ts +1 -1
- package/dist/molecules/Markdown/usePreprocessedMarkdown.js +86 -0
- package/dist/organisms/MainNav/MainNav.js +77 -75
- package/package.json +1 -1
- package/dist/atoms/Markdown/Markdown.d.ts +0 -7
- package/dist/atoms/Markdown/Markdown.stories.js +0 -69
- package/dist/atoms/Markdown/PreprocessedMarkdown.d.ts +0 -10
- package/dist/atoms/Markdown/PreprocessedMarkdown.js +0 -39
- package/dist/atoms/Markdown/PreprocessedMarkdown.stories.d.ts +0 -8
- package/dist/atoms/Markdown/PreprocessedMarkdown.stories.js +0 -73
- package/dist/atoms/Markdown/usePreprocessedMarkdown.js +0 -74
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { Markdown as a } from "./Markdown.js";
|
|
3
|
-
import { usePreprocessedMarkdown as m } from "./usePreprocessedMarkdown.js";
|
|
4
|
-
const g = {
|
|
5
|
-
title: "Case Parts/Atoms/Markdown",
|
|
6
|
-
component: a,
|
|
7
|
-
parameters: { layout: "padded" },
|
|
8
|
-
tags: ["autodocs"]
|
|
9
|
-
}, x = {
|
|
10
|
-
args: {
|
|
11
|
-
children: `# Heading 1
|
|
12
|
-
|
|
13
|
-
Paragraph with a [link](https://example.com).
|
|
14
|
-
|
|
15
|
-
## Heading 2
|
|
16
|
-
|
|
17
|
-
- Item 1
|
|
18
|
-
- Item 2
|
|
19
|
-
|
|
20
|
-
> Blockquote example
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
Inline code: \`const x = 1;\`
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
Code block:
|
|
32
|
-
|
|
33
|
-
\`\`\`ts
|
|
34
|
-
function greet(name: string) {
|
|
35
|
-
console.log('Hello', name);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default greet;
|
|
39
|
-
|
|
40
|
-
\`\`\`
|
|
41
|
-
|
|
42
|
-
| Col A | Col B |
|
|
43
|
-
|------:|:------|
|
|
44
|
-
| 123 | text |`
|
|
45
|
-
}
|
|
46
|
-
}, f = {
|
|
47
|
-
name: "Item Description Variant",
|
|
48
|
-
render: (o) => /* @__PURE__ */ t(({ text: n }) => {
|
|
49
|
-
const r = async (e) => {
|
|
50
|
-
if (await new Promise((l) => setTimeout(l, 50)), /^\d+$/.test(e)) return !0;
|
|
51
|
-
throw new Error("invalid");
|
|
52
|
-
}, { output: s, loading: i } = m(
|
|
53
|
-
n,
|
|
54
|
-
(e) => `https://example.com/parts/${encodeURIComponent(e)}`,
|
|
55
|
-
r,
|
|
56
|
-
!0
|
|
57
|
-
);
|
|
58
|
-
return /* @__PURE__ */ t(a, { ...o, children: i ? "Validating…" : s });
|
|
59
|
-
}, { text: `Kason 171 Latch
|
|
60
|
-
|
|
61
|
-
This fits part [171] and an invalid token [bad]. Already linked should remain: [171](https://example.com/should-stay).
|
|
62
|
-
|
|
63
|
-
Another valid numeric: [172].` })
|
|
64
|
-
};
|
|
65
|
-
export {
|
|
66
|
-
x as Basic,
|
|
67
|
-
f as ItemDescription,
|
|
68
|
-
g as default
|
|
69
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { LinkTarget, ValidateToken, BatchValidateTokens } from './usePreprocessedMarkdown';
|
|
2
|
-
export type PreprocessedMarkdownProps = {
|
|
3
|
-
children?: string | null;
|
|
4
|
-
url: LinkTarget;
|
|
5
|
-
validate?: ValidateToken;
|
|
6
|
-
batchValidate?: BatchValidateTokens;
|
|
7
|
-
className?: string;
|
|
8
|
-
debug?: boolean;
|
|
9
|
-
};
|
|
10
|
-
export declare function PreprocessedMarkdown({ url, validate, batchValidate, debug, className, children, }: PreprocessedMarkdownProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { Markdown as m } from "./Markdown.js";
|
|
3
|
-
import { usePreprocessedMarkdown as c } from "./usePreprocessedMarkdown.js";
|
|
4
|
-
function l({
|
|
5
|
-
url: o,
|
|
6
|
-
validate: e,
|
|
7
|
-
batchValidate: n,
|
|
8
|
-
debug: t,
|
|
9
|
-
className: p,
|
|
10
|
-
children: s
|
|
11
|
-
}) {
|
|
12
|
-
const { output: a } = c(
|
|
13
|
-
s ?? "",
|
|
14
|
-
o,
|
|
15
|
-
e,
|
|
16
|
-
t,
|
|
17
|
-
n
|
|
18
|
-
);
|
|
19
|
-
return /* @__PURE__ */ r(
|
|
20
|
-
m,
|
|
21
|
-
{
|
|
22
|
-
className: p,
|
|
23
|
-
components: {
|
|
24
|
-
a: ({ node: f, ...d }) => /* @__PURE__ */ r(
|
|
25
|
-
"a",
|
|
26
|
-
{
|
|
27
|
-
...d,
|
|
28
|
-
target: "_blank",
|
|
29
|
-
rel: "noopener noreferrer"
|
|
30
|
-
}
|
|
31
|
-
)
|
|
32
|
-
},
|
|
33
|
-
children: a
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
export {
|
|
38
|
-
l as PreprocessedMarkdown
|
|
39
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { PreprocessedMarkdown } from './PreprocessedMarkdown';
|
|
3
|
-
declare const meta: Meta<typeof PreprocessedMarkdown>;
|
|
4
|
-
export default meta;
|
|
5
|
-
type Story = StoryObj<typeof meta>;
|
|
6
|
-
export declare const Playground: Story;
|
|
7
|
-
export declare const ControlsOnly: Story;
|
|
8
|
-
export declare const BatchValidate: Story;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { jsx as n, jsxs as i } from "react/jsx-runtime";
|
|
2
|
-
import { useState as c, useEffect as m } from "react";
|
|
3
|
-
import { PreprocessedMarkdown as s } from "./PreprocessedMarkdown.js";
|
|
4
|
-
const o = `Preprocessed Markdown
|
|
5
|
-
|
|
6
|
-
- Valid token [171] will link
|
|
7
|
-
- Invalid token [ABC] shows a warning when debug is on
|
|
8
|
-
|
|
9
|
-
You can also add more [123] tokens here.`, l = async (e) => {
|
|
10
|
-
if (await new Promise((t) => setTimeout(t, 150)), /^\d+$/.test(e)) return !0;
|
|
11
|
-
throw new Error("Invalid token");
|
|
12
|
-
}, u = async (e) => (await new Promise((t) => setTimeout(t, 150)), new Set(e.filter((t) => /^\d+$/.test(t)))), r = (e) => `https://example.com/items/${encodeURIComponent(e)}`, k = {
|
|
13
|
-
title: "Case Parts/Atoms/Markdown/PreprocessedMarkdown",
|
|
14
|
-
component: s,
|
|
15
|
-
tags: ["autodocs"],
|
|
16
|
-
parameters: {
|
|
17
|
-
controls: { expanded: !0 }
|
|
18
|
-
},
|
|
19
|
-
argTypes: {
|
|
20
|
-
children: { control: "text", description: "Markdown text to preprocess" },
|
|
21
|
-
debug: { control: "boolean", description: "Show warnings for invalid tokens" },
|
|
22
|
-
className: { control: "text" }
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
function h(e) {
|
|
26
|
-
const [t, a] = c(e.children ?? o);
|
|
27
|
-
return m(() => {
|
|
28
|
-
a(e.children ?? o);
|
|
29
|
-
}, [e.children]), /* @__PURE__ */ i("div", { style: { display: "grid", gap: 12 }, children: [
|
|
30
|
-
/* @__PURE__ */ n("label", { style: { fontWeight: 600 }, children: "Edit Markdown (live):" }),
|
|
31
|
-
/* @__PURE__ */ n(
|
|
32
|
-
"textarea",
|
|
33
|
-
{
|
|
34
|
-
value: t,
|
|
35
|
-
onChange: (d) => a(d.target.value),
|
|
36
|
-
rows: 8,
|
|
37
|
-
style: { width: "100%", fontFamily: "monospace" }
|
|
38
|
-
}
|
|
39
|
-
),
|
|
40
|
-
/* @__PURE__ */ n(s, { ...e, children: t })
|
|
41
|
-
] });
|
|
42
|
-
}
|
|
43
|
-
const f = {
|
|
44
|
-
args: {
|
|
45
|
-
children: o,
|
|
46
|
-
url: r,
|
|
47
|
-
validate: l,
|
|
48
|
-
debug: !0
|
|
49
|
-
},
|
|
50
|
-
render: (e) => /* @__PURE__ */ n(h, { ...e })
|
|
51
|
-
}, x = {
|
|
52
|
-
name: "With Controls",
|
|
53
|
-
args: {
|
|
54
|
-
children: o,
|
|
55
|
-
url: r,
|
|
56
|
-
validate: l,
|
|
57
|
-
debug: !1
|
|
58
|
-
}
|
|
59
|
-
}, y = {
|
|
60
|
-
name: "Batch Validate",
|
|
61
|
-
args: {
|
|
62
|
-
children: o,
|
|
63
|
-
url: r,
|
|
64
|
-
batchValidate: u,
|
|
65
|
-
debug: !0
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
export {
|
|
69
|
-
y as BatchValidate,
|
|
70
|
-
x as ControlsOnly,
|
|
71
|
-
f as Playground,
|
|
72
|
-
k as default
|
|
73
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { useState as q, useRef as p, useEffect as v, useMemo as x } from "react";
|
|
2
|
-
function k(n, i, w, y = !1, S) {
|
|
3
|
-
const [H, d] = q(n ?? ""), [P, h] = q(!1), r = p(/* @__PURE__ */ new Map()), E = p(w), R = p(
|
|
4
|
-
S
|
|
5
|
-
);
|
|
6
|
-
v(() => {
|
|
7
|
-
E.current = w, R.current = S;
|
|
8
|
-
}, [w, S]);
|
|
9
|
-
const u = x(() => /\[(.+?)\](?!\()/g, []), f = x(() => {
|
|
10
|
-
if (!n) return [];
|
|
11
|
-
const o = Array.from(n.matchAll(u)).map((l) => l[1]);
|
|
12
|
-
return Array.from(new Set(o));
|
|
13
|
-
}, [n, u]), $ = (o) => {
|
|
14
|
-
const e = o.split(/\r?\n/);
|
|
15
|
-
if (e.length === 0) return o;
|
|
16
|
-
const l = e[0];
|
|
17
|
-
return /^\s*#\s/.test(l) || (e[0] = `# ${l.trim()}`), e.join(`
|
|
18
|
-
`);
|
|
19
|
-
};
|
|
20
|
-
return v(() => {
|
|
21
|
-
if (!n) {
|
|
22
|
-
d(""), h(!1);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (!f.length) {
|
|
26
|
-
d($(n)), h(!1);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
let o = !1;
|
|
30
|
-
h(!0);
|
|
31
|
-
const e = f.filter((g) => !r.current.has(g));
|
|
32
|
-
return (async () => {
|
|
33
|
-
if (e.length) {
|
|
34
|
-
const t = R.current, s = E.current;
|
|
35
|
-
if (t)
|
|
36
|
-
try {
|
|
37
|
-
const c = await t(e), a = c instanceof Set ? c : new Set(c);
|
|
38
|
-
e.forEach((m) => {
|
|
39
|
-
r.current.set(m, a.has(m));
|
|
40
|
-
});
|
|
41
|
-
} catch {
|
|
42
|
-
e.forEach((c) => {
|
|
43
|
-
r.current.set(c, !1);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
else s ? (await Promise.allSettled(
|
|
47
|
-
e.map(async (a) => {
|
|
48
|
-
try {
|
|
49
|
-
await s(a), r.current.set(a, !0);
|
|
50
|
-
} catch {
|
|
51
|
-
r.current.set(a, !1);
|
|
52
|
-
}
|
|
53
|
-
})
|
|
54
|
-
)).forEach((a, m) => {
|
|
55
|
-
const M = e[m];
|
|
56
|
-
r.current.has(M) || r.current.set(M, a.status === "fulfilled");
|
|
57
|
-
}) : e.forEach((c) => {
|
|
58
|
-
r.current.set(c, !0);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
const g = new Set(
|
|
62
|
-
f.filter((t) => r.current.get(t) === !0)
|
|
63
|
-
), j = new Set(
|
|
64
|
-
f.filter((t) => r.current.get(t) === !1)
|
|
65
|
-
), C = (t) => typeof i == "function" ? i(t) : i, A = n.replace(u, (t, s) => g.has(s) ? `**[${s}](${C(s)})**` : t), L = y ? A.replace(u, (t, s) => j.has(s) ? `[${s}]⚠️` : t) : A, O = $(L);
|
|
66
|
-
o || (d(O), h(!1));
|
|
67
|
-
})(), () => {
|
|
68
|
-
o = !0;
|
|
69
|
-
};
|
|
70
|
-
}, [n, f, y, i, u]), { output: H, loading: P, tokens: f };
|
|
71
|
-
}
|
|
72
|
-
export {
|
|
73
|
-
k as usePreprocessedMarkdown
|
|
74
|
-
};
|