@vantageos/mosaic-blocks 0.5.1-alpha → 0.5.7-alpha
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/README.md +4 -4
- package/dist/index.cjs +431 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +209 -2
- package/dist/index.d.ts +209 -2
- package/dist/index.js +431 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
## 1. Hero & Positioning
|
|
12
12
|
|
|
13
|
-
`@vantageos/mosaic-blocks` is the **React composed-block layer** of the VantageOS Mosaic design system. It provides
|
|
13
|
+
`@vantageos/mosaic-blocks` is the **React composed-block layer** of the VantageOS Mosaic design system. It provides 128 opinionated, fully-typed UI components that integrate natively with:
|
|
14
14
|
|
|
15
15
|
- **Clerk** — auth sign-in/up flows, org switcher, RBAC, webhook sync
|
|
16
16
|
- **Convex** — real-time data binding ready
|
|
@@ -169,7 +169,7 @@ For OKLCH design tokens, pair with `@vantageos/mosaic-tokens` — see [Section 1
|
|
|
169
169
|
|
|
170
170
|
## 6. Component Catalogue Summary
|
|
171
171
|
|
|
172
|
-
|
|
172
|
+
128 exported `Mosaic*` components across 9 sections (145 total named exports including hooks, variant helpers, and unprefixed aliases such as `Tooltip`/`Accordion`). This count is enforced by `src/__tests__/readme-matches-exports.test.ts` — it fails CI if this README drifts from `src/index.ts` again. Full reference: [docs/components-catalog.md](docs/components-catalog.md).
|
|
173
173
|
|
|
174
174
|
> There is **no "Debate" section**. No `Mosaic*` debate component (room/timer/participant) is exported by this package — despite the "absorbed from anydebate" origin story below, the debate UI was never ported. If you need debate-room UI, it does not exist here yet.
|
|
175
175
|
|
|
@@ -179,7 +179,7 @@ For OKLCH design tokens, pair with `@vantageos/mosaic-tokens` — see [Section 1
|
|
|
179
179
|
| Device / Adaptive | `MosaicDeviceProvider`, `MosaicAdaptiveGrid`, `MosaicAdaptiveModal`, `MosaicAdaptiveNavigation` | 4 |
|
|
180
180
|
| Auth / Multi-tenant | `MosaicMultiTenantProvider`, `MosaicSignInLayout`, `MosaicOrgPanel`, `MosaicClerkWebhookHandler` | 14 |
|
|
181
181
|
| Agents & messaging | `MosaicAgentComposer`, `MosaicAgentCard`, `MosaicAgentList`, `MosaicMessageList`, `MosaicMarketplaceList` | 28 |
|
|
182
|
-
| Data display | `MosaicDataTable`, `MosaicKanbanBoard`, `MosaicStepPipeline`, `MosaicActivityFeed`, `MosaicDocumentUpload`, `MosaicUrlScraper` |
|
|
182
|
+
| Data display | `MosaicDataTable`, `MosaicKanbanBoard`, `MosaicStepPipeline`, `MosaicActivityFeed`, `MosaicDocumentUpload`, `MosaicUrlScraper`, `MosaicMarkdown` | 9 |
|
|
183
183
|
| Forms & inputs | `MosaicInput`, `MosaicSelect`, `MosaicField`, `MosaicCombobox`, `MosaicFilterBar` | 17 |
|
|
184
184
|
| Primitives (incl. base-ui atoms) | `MosaicButton`, `MosaicBadge`, `MosaicCard`, `MosaicTabs`, `MosaicTooltip`, `MosaicAccordion` | 30 |
|
|
185
185
|
| Landing & utility blocks | `MosaicHeroSplit`, `MosaicStatsGrid`, `MosaicPricingCard`, `MosaicCounter`, `MosaicThemeToggle` | 13 |
|
|
@@ -470,7 +470,7 @@ This package follows [Semantic Versioning](https://semver.org/). While in alpha
|
|
|
470
470
|
|
|
471
471
|
| Version | Status | Notes |
|
|
472
472
|
|---|---|---|
|
|
473
|
-
| `0.5.
|
|
473
|
+
| `0.5.7-alpha` | Current | 128 exported `Mosaic*` components, adds `MosaicChatThread` (presentational auto-scrolling chat thread), `MosaicChatComposer` (chat input + send/stop button), and `MosaicMarkdown` (dependency-free markdown renderer), Clerk auth, mobile-first, Storybook 10, 30 stories |
|
|
474
474
|
| `0.4.8-alpha` | Historical | 125 shipped `Mosaic*` components — superseded by the Current row above |
|
|
475
475
|
| `0.4.7-alpha` | Historical | 124 shipped `Mosaic*` components — superseded by the Current row above |
|
|
476
476
|
| `0.2.0-alpha` | Historical | anydebate absorb (partial) — counts quoted for this release are historical and superseded by the Current row above; see [CHANGELOG.md](CHANGELOG.md) |
|
package/dist/index.cjs
CHANGED
|
@@ -46,7 +46,7 @@ function _interopNamespace(e) {
|
|
|
46
46
|
var React28__namespace = /*#__PURE__*/_interopNamespace(React28);
|
|
47
47
|
|
|
48
48
|
// src/version.ts
|
|
49
|
-
var version = "0.5.
|
|
49
|
+
var version = "0.5.7-alpha";
|
|
50
50
|
function Placeholder({ label = "mosaic-blocks placeholder" }) {
|
|
51
51
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-mosaic-block": "placeholder", children: label });
|
|
52
52
|
}
|
|
@@ -11560,6 +11560,434 @@ function MosaicChatThread({
|
|
|
11560
11560
|
);
|
|
11561
11561
|
}
|
|
11562
11562
|
MosaicChatThread.displayName = "MosaicChatThread";
|
|
11563
|
+
var chatComposerRootVariants = classVarianceAuthority.cva([
|
|
11564
|
+
"min-w-0 rounded-[14px] border border-border bg-card shadow-sm transition-colors",
|
|
11565
|
+
"focus-within:ring-[1px] focus-within:ring-ring"
|
|
11566
|
+
]);
|
|
11567
|
+
var chatComposerTextareaVariants = classVarianceAuthority.cva([
|
|
11568
|
+
"max-h-40 min-h-12 w-full resize-none bg-transparent px-3 pt-3 pb-1 text-sm outline-none",
|
|
11569
|
+
"placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-60"
|
|
11570
|
+
]);
|
|
11571
|
+
var chatComposerActionButtonVariants = classVarianceAuthority.cva(
|
|
11572
|
+
["inline-flex size-7 shrink-0 items-center justify-center rounded-md transition-colors"],
|
|
11573
|
+
{
|
|
11574
|
+
variants: {
|
|
11575
|
+
tone: {
|
|
11576
|
+
send: "bg-foreground text-background hover:bg-foreground/90 disabled:cursor-not-allowed disabled:opacity-30",
|
|
11577
|
+
stop: "cursor-pointer bg-foreground/15 text-foreground hover:bg-foreground/25"
|
|
11578
|
+
}
|
|
11579
|
+
},
|
|
11580
|
+
defaultVariants: {
|
|
11581
|
+
tone: "send"
|
|
11582
|
+
}
|
|
11583
|
+
}
|
|
11584
|
+
);
|
|
11585
|
+
function cn74(...classes) {
|
|
11586
|
+
return classes.filter(Boolean).join(" ");
|
|
11587
|
+
}
|
|
11588
|
+
function MosaicChatComposer(props) {
|
|
11589
|
+
const {
|
|
11590
|
+
value,
|
|
11591
|
+
onValueChange,
|
|
11592
|
+
textareaAriaLabel,
|
|
11593
|
+
placeholder,
|
|
11594
|
+
disabled = false,
|
|
11595
|
+
className,
|
|
11596
|
+
ref
|
|
11597
|
+
} = props;
|
|
11598
|
+
const textareaRef = React28.useRef(null);
|
|
11599
|
+
const trimmedValue = value.trim();
|
|
11600
|
+
React28.useEffect(() => {
|
|
11601
|
+
const textarea = textareaRef.current;
|
|
11602
|
+
if (!textarea) {
|
|
11603
|
+
return;
|
|
11604
|
+
}
|
|
11605
|
+
textarea.style.height = "auto";
|
|
11606
|
+
textarea.style.height = `${textarea.scrollHeight}px`;
|
|
11607
|
+
}, [value]);
|
|
11608
|
+
const submitValue = React28.useCallback(() => {
|
|
11609
|
+
if (props.status !== "idle") {
|
|
11610
|
+
return;
|
|
11611
|
+
}
|
|
11612
|
+
const text = value.trim();
|
|
11613
|
+
if (!text || disabled) {
|
|
11614
|
+
return;
|
|
11615
|
+
}
|
|
11616
|
+
props.onSubmit(text);
|
|
11617
|
+
}, [disabled, props, value]);
|
|
11618
|
+
const handleSubmit = React28.useCallback(
|
|
11619
|
+
(event) => {
|
|
11620
|
+
event.preventDefault();
|
|
11621
|
+
submitValue();
|
|
11622
|
+
},
|
|
11623
|
+
[submitValue]
|
|
11624
|
+
);
|
|
11625
|
+
const handleKeyDown = React28.useCallback(
|
|
11626
|
+
(event) => {
|
|
11627
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
11628
|
+
event.preventDefault();
|
|
11629
|
+
submitValue();
|
|
11630
|
+
}
|
|
11631
|
+
},
|
|
11632
|
+
[submitValue]
|
|
11633
|
+
);
|
|
11634
|
+
const currentActionLabel = props.status === "responding" ? props.stopButtonAriaLabel : props.sendButtonAriaLabel;
|
|
11635
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11636
|
+
"form",
|
|
11637
|
+
{
|
|
11638
|
+
ref,
|
|
11639
|
+
"data-slot": "chat-composer",
|
|
11640
|
+
className: cn74(chatComposerRootVariants(), className),
|
|
11641
|
+
onSubmit: handleSubmit,
|
|
11642
|
+
children: [
|
|
11643
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11644
|
+
"textarea",
|
|
11645
|
+
{
|
|
11646
|
+
"data-slot": "chat-composer-input",
|
|
11647
|
+
"aria-label": textareaAriaLabel,
|
|
11648
|
+
className: chatComposerTextareaVariants(),
|
|
11649
|
+
disabled,
|
|
11650
|
+
onChange: (event) => onValueChange(event.target.value),
|
|
11651
|
+
onKeyDown: handleKeyDown,
|
|
11652
|
+
placeholder,
|
|
11653
|
+
ref: textareaRef,
|
|
11654
|
+
rows: 1,
|
|
11655
|
+
value
|
|
11656
|
+
}
|
|
11657
|
+
),
|
|
11658
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex min-h-9 items-center justify-end gap-2 px-3 pt-1 pb-2", children: props.status === "responding" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
11659
|
+
"button",
|
|
11660
|
+
{
|
|
11661
|
+
"aria-label": props.stopButtonAriaLabel,
|
|
11662
|
+
className: chatComposerActionButtonVariants({ tone: "stop" }),
|
|
11663
|
+
"data-slot": "chat-composer-stop-button",
|
|
11664
|
+
onClick: props.onStop,
|
|
11665
|
+
type: "button",
|
|
11666
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: "\u25A0" })
|
|
11667
|
+
}
|
|
11668
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
11669
|
+
"button",
|
|
11670
|
+
{
|
|
11671
|
+
"aria-label": props.sendButtonAriaLabel,
|
|
11672
|
+
className: chatComposerActionButtonVariants({ tone: "send" }),
|
|
11673
|
+
"data-slot": "chat-composer-send-button",
|
|
11674
|
+
disabled: disabled || trimmedValue.length === 0,
|
|
11675
|
+
type: "submit",
|
|
11676
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", children: "\u2191" })
|
|
11677
|
+
}
|
|
11678
|
+
) }),
|
|
11679
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-live": "polite", className: "sr-only", "data-slot": "chat-composer-status-announcer", children: currentActionLabel })
|
|
11680
|
+
]
|
|
11681
|
+
}
|
|
11682
|
+
);
|
|
11683
|
+
}
|
|
11684
|
+
MosaicChatComposer.displayName = "MosaicChatComposer";
|
|
11685
|
+
var markdownRootVariants = classVarianceAuthority.cva([
|
|
11686
|
+
"min-w-0 text-[15px] leading-6 text-foreground [&>*:first-child]:mt-0 [&>*:last-child]:mb-0"
|
|
11687
|
+
]);
|
|
11688
|
+
var markdownHeadingVariants = classVarianceAuthority.cva(["font-medium tracking-normal text-foreground"], {
|
|
11689
|
+
variants: {
|
|
11690
|
+
level: {
|
|
11691
|
+
1: "mt-7 mb-4 text-xl leading-7",
|
|
11692
|
+
2: "mt-6 mb-3 text-base leading-6",
|
|
11693
|
+
3: "mt-5 mb-2 text-sm leading-6",
|
|
11694
|
+
4: "mt-4 mb-2 text-sm leading-6",
|
|
11695
|
+
5: "mt-4 mb-2 text-xs leading-5",
|
|
11696
|
+
6: "mt-4 mb-2 text-xs leading-5 text-muted-foreground"
|
|
11697
|
+
}
|
|
11698
|
+
},
|
|
11699
|
+
defaultVariants: {
|
|
11700
|
+
level: 1
|
|
11701
|
+
}
|
|
11702
|
+
});
|
|
11703
|
+
var markdownParagraphVariants = classVarianceAuthority.cva(["mb-3 text-[15px] leading-6 text-foreground"]);
|
|
11704
|
+
var markdownListVariants = classVarianceAuthority.cva(["mb-3 flex flex-col gap-1.5 pl-8 text-[15px] leading-6"], {
|
|
11705
|
+
variants: {
|
|
11706
|
+
ordered: {
|
|
11707
|
+
true: "list-decimal",
|
|
11708
|
+
false: "list-disc"
|
|
11709
|
+
}
|
|
11710
|
+
},
|
|
11711
|
+
defaultVariants: {
|
|
11712
|
+
ordered: false
|
|
11713
|
+
}
|
|
11714
|
+
});
|
|
11715
|
+
var markdownListItemVariants = classVarianceAuthority.cva(["pl-1 text-[15px] leading-6 text-foreground"]);
|
|
11716
|
+
var markdownBlockquoteVariants = classVarianceAuthority.cva([
|
|
11717
|
+
"mb-3 border-l-2 border-border pl-3 text-[15px] leading-6 text-muted-foreground"
|
|
11718
|
+
]);
|
|
11719
|
+
var markdownHrVariants = classVarianceAuthority.cva(["my-4 border-border/70"]);
|
|
11720
|
+
var markdownEmphasisVariants = classVarianceAuthority.cva([], {
|
|
11721
|
+
variants: {
|
|
11722
|
+
tone: {
|
|
11723
|
+
strong: "font-medium text-foreground",
|
|
11724
|
+
emphasis: "italic"
|
|
11725
|
+
}
|
|
11726
|
+
}
|
|
11727
|
+
});
|
|
11728
|
+
var markdownInlineCodeVariants = classVarianceAuthority.cva([
|
|
11729
|
+
"rounded-md border border-border/70 bg-muted/40 px-1.5 py-0.5 font-mono text-[0.92em] text-foreground"
|
|
11730
|
+
]);
|
|
11731
|
+
var markdownCodeBlockVariants = classVarianceAuthority.cva([
|
|
11732
|
+
"mb-3 overflow-x-auto rounded-md border border-border bg-muted/40 p-3 font-mono text-[0.92em] text-foreground"
|
|
11733
|
+
]);
|
|
11734
|
+
var markdownLinkVariants = classVarianceAuthority.cva([
|
|
11735
|
+
"font-medium text-foreground underline decoration-border underline-offset-4 transition-colors hover:decoration-foreground"
|
|
11736
|
+
]);
|
|
11737
|
+
var markdownTableWrapperVariants = classVarianceAuthority.cva(["mb-3 w-full overflow-x-auto"]);
|
|
11738
|
+
var markdownTableVariants = classVarianceAuthority.cva(["w-full border-collapse text-[15px] leading-6"]);
|
|
11739
|
+
var markdownTableCellVariants = classVarianceAuthority.cva(["border border-border px-3 py-1.5"], {
|
|
11740
|
+
variants: {
|
|
11741
|
+
header: {
|
|
11742
|
+
true: "bg-muted/40 font-medium text-foreground",
|
|
11743
|
+
false: "text-foreground"
|
|
11744
|
+
},
|
|
11745
|
+
align: {
|
|
11746
|
+
left: "text-left",
|
|
11747
|
+
center: "text-center",
|
|
11748
|
+
right: "text-right"
|
|
11749
|
+
}
|
|
11750
|
+
},
|
|
11751
|
+
defaultVariants: {
|
|
11752
|
+
header: false,
|
|
11753
|
+
align: "left"
|
|
11754
|
+
}
|
|
11755
|
+
});
|
|
11756
|
+
function cn75(...classes) {
|
|
11757
|
+
return classes.filter(Boolean).join(" ");
|
|
11758
|
+
}
|
|
11759
|
+
function sanitizeHref(rawHref) {
|
|
11760
|
+
const href = rawHref.replace(/[\x00-\x20]/g, "");
|
|
11761
|
+
if (!href) return null;
|
|
11762
|
+
const schemeMatch = /^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(href);
|
|
11763
|
+
if (!schemeMatch) return href;
|
|
11764
|
+
const scheme = schemeMatch[1].toLowerCase();
|
|
11765
|
+
return scheme === "http" || scheme === "https" || scheme === "mailto" ? href : null;
|
|
11766
|
+
}
|
|
11767
|
+
function makeIdSource() {
|
|
11768
|
+
let current = 0;
|
|
11769
|
+
return {
|
|
11770
|
+
next: () => {
|
|
11771
|
+
current += 1;
|
|
11772
|
+
return current;
|
|
11773
|
+
}
|
|
11774
|
+
};
|
|
11775
|
+
}
|
|
11776
|
+
function parseInline(text, ids) {
|
|
11777
|
+
const nodes = [];
|
|
11778
|
+
let buffer = "";
|
|
11779
|
+
let i = 0;
|
|
11780
|
+
const flush = () => {
|
|
11781
|
+
if (buffer.length > 0) {
|
|
11782
|
+
nodes.push(buffer);
|
|
11783
|
+
buffer = "";
|
|
11784
|
+
}
|
|
11785
|
+
};
|
|
11786
|
+
while (i < text.length) {
|
|
11787
|
+
const rest = text.slice(i);
|
|
11788
|
+
const codeMatch = /^`([^`]+)`/.exec(rest);
|
|
11789
|
+
if (codeMatch) {
|
|
11790
|
+
flush();
|
|
11791
|
+
nodes.push(
|
|
11792
|
+
/* @__PURE__ */ jsxRuntime.jsx("code", { className: markdownInlineCodeVariants(), children: codeMatch[1] }, ids.next())
|
|
11793
|
+
);
|
|
11794
|
+
i += codeMatch[0].length;
|
|
11795
|
+
continue;
|
|
11796
|
+
}
|
|
11797
|
+
const linkMatch = /^\[([^\]]*)\]\(((?:[^()]|\([^()]*\))*)\)/.exec(rest);
|
|
11798
|
+
if (linkMatch) {
|
|
11799
|
+
flush();
|
|
11800
|
+
const label = linkMatch[1];
|
|
11801
|
+
const safeHref = sanitizeHref(linkMatch[2]);
|
|
11802
|
+
if (safeHref) {
|
|
11803
|
+
nodes.push(
|
|
11804
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11805
|
+
"a",
|
|
11806
|
+
{
|
|
11807
|
+
href: safeHref,
|
|
11808
|
+
target: "_blank",
|
|
11809
|
+
rel: "noopener noreferrer",
|
|
11810
|
+
className: markdownLinkVariants(),
|
|
11811
|
+
children: parseInline(label, ids)
|
|
11812
|
+
},
|
|
11813
|
+
ids.next()
|
|
11814
|
+
)
|
|
11815
|
+
);
|
|
11816
|
+
} else {
|
|
11817
|
+
nodes.push(...parseInline(label, ids));
|
|
11818
|
+
}
|
|
11819
|
+
i += linkMatch[0].length;
|
|
11820
|
+
continue;
|
|
11821
|
+
}
|
|
11822
|
+
const boldMatch = /^\*\*([^*]+)\*\*/.exec(rest);
|
|
11823
|
+
if (boldMatch) {
|
|
11824
|
+
flush();
|
|
11825
|
+
nodes.push(
|
|
11826
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { className: markdownEmphasisVariants({ tone: "strong" }), children: parseInline(boldMatch[1], ids) }, ids.next())
|
|
11827
|
+
);
|
|
11828
|
+
i += boldMatch[0].length;
|
|
11829
|
+
continue;
|
|
11830
|
+
}
|
|
11831
|
+
const italicMatch = /^\*([^*]+)\*/.exec(rest);
|
|
11832
|
+
if (italicMatch) {
|
|
11833
|
+
flush();
|
|
11834
|
+
nodes.push(
|
|
11835
|
+
/* @__PURE__ */ jsxRuntime.jsx("em", { className: markdownEmphasisVariants({ tone: "emphasis" }), children: parseInline(italicMatch[1], ids) }, ids.next())
|
|
11836
|
+
);
|
|
11837
|
+
i += italicMatch[0].length;
|
|
11838
|
+
continue;
|
|
11839
|
+
}
|
|
11840
|
+
buffer += text[i];
|
|
11841
|
+
i += 1;
|
|
11842
|
+
}
|
|
11843
|
+
flush();
|
|
11844
|
+
return nodes;
|
|
11845
|
+
}
|
|
11846
|
+
var FENCE_RE = /^```(\S*)\s*$/;
|
|
11847
|
+
var HEADING_RE = /^(#{1,6})\s+(.*)$/;
|
|
11848
|
+
var HR_RE = /^(-{3,}|\*{3,}|_{3,})$/;
|
|
11849
|
+
var UNORDERED_ITEM_RE = /^[-*+]\s+/;
|
|
11850
|
+
var ORDERED_ITEM_RE = /^\d+\.\s+/;
|
|
11851
|
+
var BLOCKQUOTE_LINE_RE = /^>\s?/;
|
|
11852
|
+
var TABLE_SEPARATOR_RE = /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/;
|
|
11853
|
+
function parseTableRow(line) {
|
|
11854
|
+
const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
|
|
11855
|
+
return trimmed.split("|").map((cell) => cell.trim());
|
|
11856
|
+
}
|
|
11857
|
+
function parseBlocks(content) {
|
|
11858
|
+
const lines = content.split(/\r?\n/);
|
|
11859
|
+
const blocks = [];
|
|
11860
|
+
let id = 0;
|
|
11861
|
+
const nextId = () => {
|
|
11862
|
+
id += 1;
|
|
11863
|
+
return id;
|
|
11864
|
+
};
|
|
11865
|
+
let i = 0;
|
|
11866
|
+
while (i < lines.length) {
|
|
11867
|
+
const line = lines[i];
|
|
11868
|
+
if (line.trim() === "") {
|
|
11869
|
+
i += 1;
|
|
11870
|
+
continue;
|
|
11871
|
+
}
|
|
11872
|
+
const fenceMatch = FENCE_RE.exec(line);
|
|
11873
|
+
if (fenceMatch) {
|
|
11874
|
+
const language = fenceMatch[1] || void 0;
|
|
11875
|
+
const codeLines = [];
|
|
11876
|
+
i += 1;
|
|
11877
|
+
while (i < lines.length && !/^```\s*$/.test(lines[i])) {
|
|
11878
|
+
codeLines.push(lines[i]);
|
|
11879
|
+
i += 1;
|
|
11880
|
+
}
|
|
11881
|
+
i += 1;
|
|
11882
|
+
blocks.push({ id: nextId(), kind: "code", language, code: codeLines.join("\n") });
|
|
11883
|
+
continue;
|
|
11884
|
+
}
|
|
11885
|
+
const headingMatch = HEADING_RE.exec(line);
|
|
11886
|
+
if (headingMatch) {
|
|
11887
|
+
blocks.push({
|
|
11888
|
+
id: nextId(),
|
|
11889
|
+
kind: "heading",
|
|
11890
|
+
level: headingMatch[1].length,
|
|
11891
|
+
text: headingMatch[2].trim()
|
|
11892
|
+
});
|
|
11893
|
+
i += 1;
|
|
11894
|
+
continue;
|
|
11895
|
+
}
|
|
11896
|
+
if (HR_RE.test(line.trim())) {
|
|
11897
|
+
blocks.push({ id: nextId(), kind: "hr" });
|
|
11898
|
+
i += 1;
|
|
11899
|
+
continue;
|
|
11900
|
+
}
|
|
11901
|
+
if (line.includes("|") && i + 1 < lines.length && TABLE_SEPARATOR_RE.test(lines[i + 1])) {
|
|
11902
|
+
const header = parseTableRow(line);
|
|
11903
|
+
i += 2;
|
|
11904
|
+
const rows = [];
|
|
11905
|
+
while (i < lines.length && lines[i].trim() !== "" && lines[i].includes("|")) {
|
|
11906
|
+
rows.push(parseTableRow(lines[i]));
|
|
11907
|
+
i += 1;
|
|
11908
|
+
}
|
|
11909
|
+
blocks.push({ id: nextId(), kind: "table", header, rows });
|
|
11910
|
+
continue;
|
|
11911
|
+
}
|
|
11912
|
+
if (BLOCKQUOTE_LINE_RE.test(line)) {
|
|
11913
|
+
const quoteLines = [];
|
|
11914
|
+
while (i < lines.length && BLOCKQUOTE_LINE_RE.test(lines[i])) {
|
|
11915
|
+
quoteLines.push(lines[i].replace(BLOCKQUOTE_LINE_RE, ""));
|
|
11916
|
+
i += 1;
|
|
11917
|
+
}
|
|
11918
|
+
blocks.push({ id: nextId(), kind: "blockquote", text: quoteLines.join(" ") });
|
|
11919
|
+
continue;
|
|
11920
|
+
}
|
|
11921
|
+
if (UNORDERED_ITEM_RE.test(line)) {
|
|
11922
|
+
const items = [];
|
|
11923
|
+
while (i < lines.length && UNORDERED_ITEM_RE.test(lines[i])) {
|
|
11924
|
+
items.push({ id: nextId(), text: lines[i].replace(UNORDERED_ITEM_RE, "") });
|
|
11925
|
+
i += 1;
|
|
11926
|
+
}
|
|
11927
|
+
blocks.push({ id: nextId(), kind: "list", ordered: false, items });
|
|
11928
|
+
continue;
|
|
11929
|
+
}
|
|
11930
|
+
if (ORDERED_ITEM_RE.test(line)) {
|
|
11931
|
+
const items = [];
|
|
11932
|
+
while (i < lines.length && ORDERED_ITEM_RE.test(lines[i])) {
|
|
11933
|
+
items.push({ id: nextId(), text: lines[i].replace(ORDERED_ITEM_RE, "") });
|
|
11934
|
+
i += 1;
|
|
11935
|
+
}
|
|
11936
|
+
blocks.push({ id: nextId(), kind: "list", ordered: true, items });
|
|
11937
|
+
continue;
|
|
11938
|
+
}
|
|
11939
|
+
const paragraphLines = [];
|
|
11940
|
+
while (i < lines.length && lines[i].trim() !== "" && !FENCE_RE.test(lines[i]) && !HEADING_RE.test(lines[i]) && !UNORDERED_ITEM_RE.test(lines[i]) && !ORDERED_ITEM_RE.test(lines[i]) && !BLOCKQUOTE_LINE_RE.test(lines[i]) && !HR_RE.test(lines[i].trim())) {
|
|
11941
|
+
paragraphLines.push(lines[i]);
|
|
11942
|
+
i += 1;
|
|
11943
|
+
}
|
|
11944
|
+
blocks.push({ id: nextId(), kind: "paragraph", text: paragraphLines.join(" ") });
|
|
11945
|
+
}
|
|
11946
|
+
return blocks;
|
|
11947
|
+
}
|
|
11948
|
+
function MosaicMarkdown({ content, renderCodeBlock, className, ref }) {
|
|
11949
|
+
const blocks = parseBlocks(content);
|
|
11950
|
+
const ids = makeIdSource();
|
|
11951
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, "data-slot": "markdown", className: cn75(markdownRootVariants(), className), children: blocks.map((block) => {
|
|
11952
|
+
if (block.kind === "heading") {
|
|
11953
|
+
const HeadingTag = `h${block.level}`;
|
|
11954
|
+
return /* @__PURE__ */ jsxRuntime.jsx(HeadingTag, { className: markdownHeadingVariants({ level: block.level }), children: parseInline(block.text, ids) }, block.id);
|
|
11955
|
+
}
|
|
11956
|
+
if (block.kind === "paragraph") {
|
|
11957
|
+
return /* @__PURE__ */ jsxRuntime.jsx("p", { className: markdownParagraphVariants(), children: parseInline(block.text, ids) }, block.id);
|
|
11958
|
+
}
|
|
11959
|
+
if (block.kind === "list") {
|
|
11960
|
+
const ListTag = block.ordered ? "ol" : "ul";
|
|
11961
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ListTag, { className: markdownListVariants({ ordered: block.ordered }), children: block.items.map((item) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: markdownListItemVariants(), children: parseInline(item.text, ids) }, item.id)) }, block.id);
|
|
11962
|
+
}
|
|
11963
|
+
if (block.kind === "blockquote") {
|
|
11964
|
+
return /* @__PURE__ */ jsxRuntime.jsx("blockquote", { className: markdownBlockquoteVariants(), children: parseInline(block.text, ids) }, block.id);
|
|
11965
|
+
}
|
|
11966
|
+
if (block.kind === "hr") {
|
|
11967
|
+
return /* @__PURE__ */ jsxRuntime.jsx("hr", { className: markdownHrVariants() }, block.id);
|
|
11968
|
+
}
|
|
11969
|
+
if (block.kind === "code") {
|
|
11970
|
+
if (renderCodeBlock) {
|
|
11971
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: renderCodeBlock({ language: block.language, code: block.code }) }, block.id);
|
|
11972
|
+
}
|
|
11973
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11974
|
+
"pre",
|
|
11975
|
+
{
|
|
11976
|
+
"data-slot": "markdown-code-block",
|
|
11977
|
+
...block.language ? { "data-language": block.language } : {},
|
|
11978
|
+
className: markdownCodeBlockVariants(),
|
|
11979
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: block.code })
|
|
11980
|
+
},
|
|
11981
|
+
block.id
|
|
11982
|
+
);
|
|
11983
|
+
}
|
|
11984
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: markdownTableWrapperVariants(), children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: markdownTableVariants(), children: [
|
|
11985
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: block.header.map((cell) => /* @__PURE__ */ jsxRuntime.jsx("th", { className: markdownTableCellVariants({ header: true }), children: parseInline(cell, ids) }, ids.next())) }) }),
|
|
11986
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: block.rows.map((row) => /* @__PURE__ */ jsxRuntime.jsx("tr", { children: row.map((cell) => /* @__PURE__ */ jsxRuntime.jsx("td", { className: markdownTableCellVariants({ header: false }), children: parseInline(cell, ids) }, ids.next())) }, ids.next())) })
|
|
11987
|
+
] }) }, block.id);
|
|
11988
|
+
}) });
|
|
11989
|
+
}
|
|
11990
|
+
MosaicMarkdown.displayName = "MosaicMarkdown";
|
|
11563
11991
|
|
|
11564
11992
|
Object.defineProperty(exports, "Accordion", {
|
|
11565
11993
|
enumerable: true,
|
|
@@ -11598,6 +12026,7 @@ exports.MosaicCardDescription = MosaicCardDescription;
|
|
|
11598
12026
|
exports.MosaicCardFooter = MosaicCardFooter;
|
|
11599
12027
|
exports.MosaicCardHeader = MosaicCardHeader;
|
|
11600
12028
|
exports.MosaicCardTitle = MosaicCardTitle;
|
|
12029
|
+
exports.MosaicChatComposer = MosaicChatComposer;
|
|
11601
12030
|
exports.MosaicChatThread = MosaicChatThread;
|
|
11602
12031
|
exports.MosaicCheckbox = MosaicCheckbox;
|
|
11603
12032
|
exports.MosaicClerkOrgSwitcher = MosaicClerkOrgSwitcher;
|
|
@@ -11637,6 +12066,7 @@ exports.MosaicKanbanBoard = MosaicKanbanBoard;
|
|
|
11637
12066
|
exports.MosaicKanbanColumn = MosaicKanbanColumn;
|
|
11638
12067
|
exports.MosaicLogosGrid = MosaicLogosGrid;
|
|
11639
12068
|
exports.MosaicMainNav = MosaicMainNav;
|
|
12069
|
+
exports.MosaicMarkdown = MosaicMarkdown;
|
|
11640
12070
|
exports.MosaicMarketplaceList = MosaicMarketplaceList;
|
|
11641
12071
|
exports.MosaicMarketplaceListDesktop = MarketplaceListDesktop;
|
|
11642
12072
|
exports.MosaicMarketplaceListMobile = MarketplaceListMobile;
|