@caseparts-org/caseblocks 0.0.128 → 0.0.129
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/atoms/Markdown/Markdown.stories.js +1 -1
- package/dist/atoms/Markdown/PreprocessedMarkdown.d.ts +8 -0
- package/dist/atoms/Markdown/PreprocessedMarkdown.js +10 -0
- package/dist/atoms/Markdown/{useItemDescriptionMarkdown.d.ts → usePreprocessedMarkdown.d.ts} +2 -2
- package/dist/atoms/Markdown/usePreprocessedMarkdown.js +50 -0
- package/dist/main-client.d.ts +4 -0
- package/dist/main-client.js +63 -59
- package/package.json +1 -1
- package/dist/atoms/Markdown/ItemDescriptionMarkdown.d.ts +0 -8
- package/dist/atoms/Markdown/ItemDescriptionMarkdown.js +0 -10
- package/dist/atoms/Markdown/useItemDescriptionMarkdown.js +0 -56
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { Markdown as a } from "./Markdown.js";
|
|
3
|
-
import {
|
|
3
|
+
import { usePreprocessedMarkdown as m } from "./usePreprocessedMarkdown.js";
|
|
4
4
|
const g = {
|
|
5
5
|
title: "Case Parts/Atoms/Markdown",
|
|
6
6
|
component: a,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LinkTarget, ValidateToken } from './usePreprocessedMarkdown';
|
|
2
|
+
export type PreprocessedMarkdownProps = {
|
|
3
|
+
children?: string | null;
|
|
4
|
+
url: LinkTarget;
|
|
5
|
+
validate: ValidateToken;
|
|
6
|
+
className?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function PreprocessedMarkdown({ children, url, validate, className }: PreprocessedMarkdownProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { Markdown as s } from "./Markdown.js";
|
|
3
|
+
import { usePreprocessedMarkdown as d } from "./usePreprocessedMarkdown.js";
|
|
4
|
+
function u({ children: r, url: o, validate: e, className: t }) {
|
|
5
|
+
const { output: n } = d(r ?? "", o, e);
|
|
6
|
+
return /* @__PURE__ */ p(s, { className: t, children: n });
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
u as PreprocessedMarkdown
|
|
10
|
+
};
|
package/dist/atoms/Markdown/{useItemDescriptionMarkdown.d.ts → usePreprocessedMarkdown.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type ValidateToken = (_token: string) => Promise<unknown>;
|
|
2
2
|
export type LinkTarget = string | ((_token: string) => string);
|
|
3
|
-
export type
|
|
3
|
+
export type PreprocessedMarkdownResult = {
|
|
4
4
|
output: string;
|
|
5
5
|
loading: boolean;
|
|
6
6
|
tokens: string[];
|
|
@@ -9,4 +9,4 @@ export type UseValidatedLinksResult = {
|
|
|
9
9
|
* Extracts bracketed tokens not already followed by parentheses, validates them, and
|
|
10
10
|
* returns the input with validated tokens converted to markdown links.
|
|
11
11
|
*/
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function usePreprocessedMarkdown(input: string | null | undefined, url: LinkTarget, validate: ValidateToken): PreprocessedMarkdownResult;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useState as g, useRef as p, useMemo as w, useEffect as x } from "react";
|
|
2
|
+
function H(r, f, y) {
|
|
3
|
+
const [S, i] = g(r ?? ""), [A, u] = g(!1), n = p(/* @__PURE__ */ new Map()), M = p(y), l = w(() => /\[(.+?)\](?!\()/g, []), o = w(() => {
|
|
4
|
+
if (!r) return [];
|
|
5
|
+
const s = Array.from(r.matchAll(l)).map((a) => a[1]);
|
|
6
|
+
return Array.from(new Set(s));
|
|
7
|
+
}, [r, l]), h = (s) => {
|
|
8
|
+
const e = s.split(/\r?\n/);
|
|
9
|
+
if (e.length === 0) return s;
|
|
10
|
+
const a = e[0];
|
|
11
|
+
return /^\s*#\s/.test(a) || (e[0] = `# ${a.trim()}`), e.join(`
|
|
12
|
+
`);
|
|
13
|
+
};
|
|
14
|
+
return x(() => {
|
|
15
|
+
if (!r) {
|
|
16
|
+
i(""), u(!1);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (!o.length) {
|
|
20
|
+
i(h(r)), u(!1);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
let s = !1;
|
|
24
|
+
u(!0);
|
|
25
|
+
const e = o.filter((d) => !n.current.has(d));
|
|
26
|
+
return (async () => {
|
|
27
|
+
e.length && (await Promise.allSettled(
|
|
28
|
+
e.map(async (t) => {
|
|
29
|
+
try {
|
|
30
|
+
await M.current(t), n.current.set(t, !0);
|
|
31
|
+
} catch {
|
|
32
|
+
n.current.set(t, !1);
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
)).forEach((t, v) => {
|
|
36
|
+
const m = e[v];
|
|
37
|
+
n.current.has(m) || n.current.set(m, t.status === "fulfilled");
|
|
38
|
+
});
|
|
39
|
+
const d = new Set(
|
|
40
|
+
o.filter((c) => n.current.get(c) === !0)
|
|
41
|
+
), R = (c) => typeof f == "function" ? f(c) : f, $ = r.replace(l, (c, t) => d.has(t) ? `[${t}](${R(t)})` : c), q = h($);
|
|
42
|
+
s || (i(q), u(!1));
|
|
43
|
+
})(), () => {
|
|
44
|
+
s = !0;
|
|
45
|
+
};
|
|
46
|
+
}, [r, o, f, l]), { output: S, loading: A, tokens: o };
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
H as usePreprocessedMarkdown
|
|
50
|
+
};
|
package/dist/main-client.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ export { SlideInPanel } from './atoms/SlideInPanel/SlideInPanel';
|
|
|
5
5
|
export type { SlideInPanelProps } from './atoms/SlideInPanel/SlideInPanel';
|
|
6
6
|
export { Markdown } from './atoms/Markdown/Markdown';
|
|
7
7
|
export type { MarkdownProps } from './atoms/Markdown/Markdown';
|
|
8
|
+
export { PreprocessedMarkdown as ItemDescriptionMarkdown } from './atoms/Markdown/PreprocessedMarkdown';
|
|
9
|
+
export type { PreprocessedMarkdownProps as ItemDescriptionMarkdownProps } from './atoms/Markdown/PreprocessedMarkdown';
|
|
10
|
+
export { usePreprocessedMarkdown } from './atoms/Markdown/usePreprocessedMarkdown';
|
|
11
|
+
export type { LinkTarget, ValidateToken } from './atoms/Markdown/usePreprocessedMarkdown';
|
|
8
12
|
export { Tooltip } from './atoms/Tooltip/Tooltip';
|
|
9
13
|
export { Popover } from './atoms/Popover/Popover';
|
|
10
14
|
export type { PopoverProps } from './atoms/Popover/Popover';
|
package/dist/main-client.js
CHANGED
|
@@ -2,91 +2,95 @@ import { Button as e } from "./atoms/Button/Button.js";
|
|
|
2
2
|
import { Flex as p } from "./atoms/Flex/Flex.js";
|
|
3
3
|
import { Column as f, Grid as x } from "./atoms/Grid/Grid.js";
|
|
4
4
|
import { Head as n } from "./atoms/Root/Head.js";
|
|
5
|
-
import { Icon as
|
|
6
|
-
import { Root as
|
|
7
|
-
import { Separator as
|
|
8
|
-
import { Text as
|
|
5
|
+
import { Icon as d } from "./atoms/Icon/Icon.js";
|
|
6
|
+
import { Root as u } from "./atoms/Root/Root.js";
|
|
7
|
+
import { Separator as s } from "./atoms/Separator/Separator.js";
|
|
8
|
+
import { Text as C } from "./atoms/Text/Text.js";
|
|
9
9
|
import { Input as I } from "./atoms/Input/Input.js";
|
|
10
|
-
import { Link as
|
|
11
|
-
import { linkClassName as
|
|
12
|
-
import { configureLink as
|
|
13
|
-
import { LinkButton as
|
|
10
|
+
import { Link as w } from "./atoms/Link/Link.js";
|
|
11
|
+
import { linkClassName as P } from "./atoms/Link/linkClassName.js";
|
|
12
|
+
import { configureLink as v, routerOverride as A } from "./atoms/Link/configureLink.js";
|
|
13
|
+
import { LinkButton as h } from "./atoms/LinkButton/LinkButton.js";
|
|
14
14
|
import { configureImage as F } from "./atoms/Image/configureImage.js";
|
|
15
15
|
import { Logo as V } from "./molecules/Logo/Logo.js";
|
|
16
16
|
import { SearchBox as y } from "./molecules/SearchBox/SearchBox.js";
|
|
17
17
|
import { QuantityInput as z } from "./molecules/QuantityInput/QuantityInput.js";
|
|
18
|
-
import { Pricing as
|
|
19
|
-
import { Availability as
|
|
20
|
-
import { Avatar as
|
|
21
|
-
import { BannerCard as
|
|
18
|
+
import { Pricing as G } from "./molecules/Pricing/Pricing.js";
|
|
19
|
+
import { Availability as Q } from "./molecules/Availability/Availability.js";
|
|
20
|
+
import { Avatar as Z } from "./molecules/Avatar/Avatar.js";
|
|
21
|
+
import { BannerCard as q } from "./molecules/BannerCard/BannerCard.js";
|
|
22
22
|
import { CardLink as J } from "./molecules/CardLink/CardLink.js";
|
|
23
23
|
import { Breadcrumbs as U } from "./molecules/Breadcrumbs/Breadcrumbs.js";
|
|
24
24
|
import { NotFound as X } from "./organisms/NotFound/NotFound.js";
|
|
25
25
|
import { HorizontalScroll as _ } from "./atoms/HorizontalScroll/HorizontalScroll.js";
|
|
26
26
|
import { SlideInPanel as oo } from "./atoms/SlideInPanel/SlideInPanel.js";
|
|
27
27
|
import { Markdown as eo } from "./atoms/Markdown/Markdown.js";
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
28
|
+
import { PreprocessedMarkdown as po } from "./atoms/Markdown/PreprocessedMarkdown.js";
|
|
29
|
+
import { usePreprocessedMarkdown as fo } from "./atoms/Markdown/usePreprocessedMarkdown.js";
|
|
30
|
+
import { Tooltip as ao } from "./atoms/Tooltip/Tooltip.js";
|
|
31
|
+
import { Popover as io } from "./atoms/Popover/Popover.js";
|
|
32
|
+
import { Account as uo } from "./molecules/Account/Account.js";
|
|
33
|
+
import { Chip as so } from "./molecules/Chip/Chip.js";
|
|
34
|
+
import { ToggleView as Co } from "./molecules/ToggleView/ToggleView.js";
|
|
35
|
+
import { CartSlideInPanel as Io } from "./molecules/Cart/CartSlideInPanel.js";
|
|
36
|
+
import { StatefulButton as wo } from "./molecules/StatefulButton/StatefulButton.js";
|
|
37
|
+
import { AnimatedCheckMark as Po } from "./molecules/StatefulButton/AnimatedCheckmark.js";
|
|
38
|
+
import { AddToCart as vo } from "./molecules/AddToCart/AddToCart.js";
|
|
39
|
+
import { Modal as Lo } from "./molecules/Modal/Modal.js";
|
|
40
|
+
import { ImageViewer as To } from "./molecules/ImageViewer/ImageViewer.js";
|
|
41
|
+
import { MainNav as No } from "./organisms/MainNav/MainNav.js";
|
|
42
|
+
import { ChipSelector as bo } from "./organisms/ChipSelector/ChipSelector.js";
|
|
43
|
+
import { Product as Ho } from "./organisms/Product/Product.js";
|
|
44
|
+
import { Carousel as Do } from "./organisms/Carousel/Carousel.js";
|
|
45
|
+
import { Footer as Oo } from "./organisms/Footer/Footer.js";
|
|
46
|
+
import { default as Ro } from "./organisms/SpinZoomViewer/SpinZoomViewer.js";
|
|
45
47
|
export {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
uo as Account,
|
|
49
|
+
vo as AddToCart,
|
|
50
|
+
Po as AnimatedCheckMark,
|
|
51
|
+
Q as Availability,
|
|
52
|
+
Z as Avatar,
|
|
53
|
+
q as BannerCard,
|
|
52
54
|
U as Breadcrumbs,
|
|
53
55
|
e as Button,
|
|
54
56
|
J as CardLink,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
Do as Carousel,
|
|
58
|
+
Io as CartSlideInPanel,
|
|
59
|
+
so as Chip,
|
|
60
|
+
bo as ChipSelector,
|
|
59
61
|
f as Column,
|
|
60
62
|
p as Flex,
|
|
61
|
-
|
|
63
|
+
Oo as Footer,
|
|
62
64
|
x as Grid,
|
|
63
65
|
n as Head,
|
|
64
66
|
_ as HorizontalScroll,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
d as Icon,
|
|
68
|
+
To as ImageViewer,
|
|
67
69
|
I as Input,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
po as ItemDescriptionMarkdown,
|
|
71
|
+
w as Link,
|
|
72
|
+
h as LinkButton,
|
|
70
73
|
V as Logo,
|
|
71
|
-
|
|
74
|
+
No as MainNav,
|
|
72
75
|
eo as Markdown,
|
|
73
|
-
|
|
76
|
+
Lo as Modal,
|
|
74
77
|
X as NotFound,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
io as Popover,
|
|
79
|
+
G as Pricing,
|
|
80
|
+
Ho as Product,
|
|
78
81
|
z as QuantityInput,
|
|
79
|
-
|
|
82
|
+
u as Root,
|
|
80
83
|
y as SearchBox,
|
|
81
|
-
|
|
84
|
+
s as Separator,
|
|
82
85
|
oo as SlideInPanel,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
Ro as SpinZoomViewer,
|
|
87
|
+
wo as StatefulButton,
|
|
88
|
+
C as Text,
|
|
89
|
+
Co as ToggleView,
|
|
90
|
+
ao as Tooltip,
|
|
88
91
|
F as configureImage,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
v as configureLink,
|
|
93
|
+
P as linkClassName,
|
|
94
|
+
A as routerOverride,
|
|
95
|
+
fo as usePreprocessedMarkdown
|
|
92
96
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { LinkTarget, ValidateToken } from './useItemDescriptionMarkdown';
|
|
2
|
-
export type ValidatedMarkdownProps = {
|
|
3
|
-
children?: string | null;
|
|
4
|
-
url: LinkTarget;
|
|
5
|
-
validate: ValidateToken;
|
|
6
|
-
className?: string;
|
|
7
|
-
};
|
|
8
|
-
export declare function ItemDescriptionMarkdown({ children, url, validate, className }: ValidatedMarkdownProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { Markdown as m } from "./Markdown.js";
|
|
3
|
-
import { useItemDescriptionMarkdown as p } from "./useItemDescriptionMarkdown.js";
|
|
4
|
-
function d({ children: o, url: r, validate: t, className: n }) {
|
|
5
|
-
const { output: i } = p(o ?? "", r, t);
|
|
6
|
-
return /* @__PURE__ */ e(m, { className: n, children: i });
|
|
7
|
-
}
|
|
8
|
-
export {
|
|
9
|
-
d as ItemDescriptionMarkdown
|
|
10
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { useState as p, useRef as H, useMemo as S, useEffect as q } from "react";
|
|
2
|
-
function E(r, o, $) {
|
|
3
|
-
const [A, d] = p(r ?? ""), [M, a] = p(!1), s = H(/* @__PURE__ */ new Map()), R = H($), u = S(() => /\[(.+?)\](?!\()/g, []), c = S(() => {
|
|
4
|
-
if (!r) return [];
|
|
5
|
-
const f = Array.from(r.matchAll(u)).map((w) => w[1]);
|
|
6
|
-
return Array.from(new Set(f));
|
|
7
|
-
}, [r, u]);
|
|
8
|
-
return q(() => {
|
|
9
|
-
if (!r) {
|
|
10
|
-
d(""), a(!1);
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if (!c.length) {
|
|
14
|
-
d(((m) => {
|
|
15
|
-
const n = m.split(/\r?\n/);
|
|
16
|
-
if (n.length === 0) return m;
|
|
17
|
-
const g = n[0];
|
|
18
|
-
return /^\s*#\s/.test(g) || (n[0] = `# ${g.trim()}`), n.join(`
|
|
19
|
-
`);
|
|
20
|
-
})(r)), a(!1);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
let f = !1;
|
|
24
|
-
a(!0);
|
|
25
|
-
const i = c.filter((l) => !s.current.has(l));
|
|
26
|
-
return (async () => {
|
|
27
|
-
i.length && (await Promise.allSettled(
|
|
28
|
-
i.map(async (e) => {
|
|
29
|
-
try {
|
|
30
|
-
await R.current(e), s.current.set(e, !0);
|
|
31
|
-
} catch {
|
|
32
|
-
s.current.set(e, !1);
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
)).forEach((e, h) => {
|
|
36
|
-
const y = i[h];
|
|
37
|
-
s.current.has(y) || s.current.set(y, e.status === "fulfilled");
|
|
38
|
-
});
|
|
39
|
-
const l = new Set(
|
|
40
|
-
c.filter((t) => s.current.get(t) === !0)
|
|
41
|
-
), m = (t) => typeof o == "function" ? o(t) : o, n = r.replace(u, (t, e) => l.has(e) ? `[${e}](${m(e)})` : t), j = ((t) => {
|
|
42
|
-
const e = t.split(/\r?\n/);
|
|
43
|
-
if (e.length === 0) return t;
|
|
44
|
-
const h = e[0];
|
|
45
|
-
return /^\s*#\s/.test(h) || (e[0] = `# ${h.trim()}`), e.join(`
|
|
46
|
-
`);
|
|
47
|
-
})(n);
|
|
48
|
-
f || (d(j), a(!1));
|
|
49
|
-
})(), () => {
|
|
50
|
-
f = !0;
|
|
51
|
-
};
|
|
52
|
-
}, [r, c, o, u]), { output: A, loading: M, tokens: c };
|
|
53
|
-
}
|
|
54
|
-
export {
|
|
55
|
-
E as useItemDescriptionMarkdown
|
|
56
|
-
};
|