@vantageos/mosaic-blocks 0.4.9-alpha → 0.5.6-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/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import { Button } from '@base-ui/react/button';
4
4
  import { cva } from 'class-variance-authority';
5
5
  import * as React28 from 'react';
6
- import { useState, useEffect, useRef, useId } from 'react';
6
+ import { useState, useEffect, useRef, useId, useLayoutEffect, useCallback } from 'react';
7
7
  import { Accordion } from '@base-ui/react/accordion';
8
8
  export { Accordion } from '@base-ui/react/accordion';
9
9
  import { Checkbox } from '@base-ui/react/checkbox';
@@ -27,7 +27,7 @@ import { Menu } from '@base-ui/react/menu';
27
27
  import { AlertDialog } from '@base-ui/react/alert-dialog';
28
28
 
29
29
  // src/version.ts
30
- var version = "0.4.9-alpha";
30
+ var version = "0.5.6-alpha";
31
31
  function Placeholder({ label = "mosaic-blocks placeholder" }) {
32
32
  return /* @__PURE__ */ jsx("div", { "data-mosaic-block": "placeholder", children: label });
33
33
  }
@@ -11460,7 +11460,210 @@ function MosaicUrlScraper(props) {
11460
11460
  ] });
11461
11461
  }
11462
11462
  MosaicUrlScraper.displayName = "MosaicUrlScraper";
11463
+ var chatThreadRootVariants = cva([
11464
+ "relative flex min-h-0 flex-1 flex-col overflow-y-auto"
11465
+ ]);
11466
+ var chatThreadContentVariants = cva([
11467
+ "mx-auto flex w-full max-w-2xl flex-col gap-4 px-4 py-6 sm:px-6"
11468
+ ]);
11469
+ var chatThreadScrollButtonVariants = cva([
11470
+ "absolute bottom-4 left-1/2 -translate-x-1/2 inline-flex size-9",
11471
+ "items-center justify-center rounded-full border border-border bg-card text-foreground shadow-sm",
11472
+ "transition-colors hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
11473
+ ]);
11474
+ function cn73(...classes) {
11475
+ return classes.filter(Boolean).join(" ");
11476
+ }
11477
+ var BOTTOM_THRESHOLD_PX = 24;
11478
+ function isNearBottom(element) {
11479
+ return element.scrollHeight - element.scrollTop - element.clientHeight <= BOTTOM_THRESHOLD_PX;
11480
+ }
11481
+ function MosaicChatThread({
11482
+ children,
11483
+ scrollToBottomLabel,
11484
+ className,
11485
+ ref
11486
+ }) {
11487
+ const containerRef = useRef(null);
11488
+ const isAtBottomRef = useRef(true);
11489
+ const [isAtBottom, setIsAtBottom] = useState(true);
11490
+ function setRefs(node) {
11491
+ containerRef.current = node;
11492
+ if (typeof ref === "function") {
11493
+ ref(node);
11494
+ } else if (ref) {
11495
+ ref.current = node;
11496
+ }
11497
+ }
11498
+ function handleScroll(event) {
11499
+ const atBottom = isNearBottom(event.currentTarget);
11500
+ isAtBottomRef.current = atBottom;
11501
+ setIsAtBottom(atBottom);
11502
+ }
11503
+ function handleScrollToBottomClick() {
11504
+ const element = containerRef.current;
11505
+ if (!element) {
11506
+ return;
11507
+ }
11508
+ element.scrollTop = element.scrollHeight;
11509
+ isAtBottomRef.current = true;
11510
+ setIsAtBottom(true);
11511
+ }
11512
+ useLayoutEffect(() => {
11513
+ const element = containerRef.current;
11514
+ if (element && isAtBottomRef.current) {
11515
+ element.scrollTop = element.scrollHeight;
11516
+ }
11517
+ }, [children]);
11518
+ return /* @__PURE__ */ jsxs(
11519
+ "div",
11520
+ {
11521
+ ref: setRefs,
11522
+ "data-slot": "chat-thread",
11523
+ role: "log",
11524
+ onScroll: handleScroll,
11525
+ className: cn73(chatThreadRootVariants(), className),
11526
+ children: [
11527
+ /* @__PURE__ */ jsx("div", { "data-slot": "chat-thread-content", className: chatThreadContentVariants(), children }),
11528
+ !isAtBottom && /* @__PURE__ */ jsx(
11529
+ "button",
11530
+ {
11531
+ type: "button",
11532
+ "data-slot": "chat-thread-scroll-button",
11533
+ "aria-label": scrollToBottomLabel,
11534
+ onClick: handleScrollToBottomClick,
11535
+ className: chatThreadScrollButtonVariants(),
11536
+ children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\u2193" })
11537
+ }
11538
+ )
11539
+ ]
11540
+ }
11541
+ );
11542
+ }
11543
+ MosaicChatThread.displayName = "MosaicChatThread";
11544
+ var chatComposerRootVariants = cva([
11545
+ "min-w-0 rounded-[14px] border border-border bg-card shadow-sm transition-colors",
11546
+ "focus-within:ring-[1px] focus-within:ring-ring"
11547
+ ]);
11548
+ var chatComposerTextareaVariants = cva([
11549
+ "max-h-40 min-h-12 w-full resize-none bg-transparent px-3 pt-3 pb-1 text-sm outline-none",
11550
+ "placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-60"
11551
+ ]);
11552
+ var chatComposerActionButtonVariants = cva(
11553
+ ["inline-flex size-7 shrink-0 items-center justify-center rounded-md transition-colors"],
11554
+ {
11555
+ variants: {
11556
+ tone: {
11557
+ send: "bg-foreground text-background hover:bg-foreground/90 disabled:cursor-not-allowed disabled:opacity-30",
11558
+ stop: "cursor-pointer bg-foreground/15 text-foreground hover:bg-foreground/25"
11559
+ }
11560
+ },
11561
+ defaultVariants: {
11562
+ tone: "send"
11563
+ }
11564
+ }
11565
+ );
11566
+ function cn74(...classes) {
11567
+ return classes.filter(Boolean).join(" ");
11568
+ }
11569
+ function MosaicChatComposer(props) {
11570
+ const {
11571
+ value,
11572
+ onValueChange,
11573
+ textareaAriaLabel,
11574
+ placeholder,
11575
+ disabled = false,
11576
+ className,
11577
+ ref
11578
+ } = props;
11579
+ const textareaRef = useRef(null);
11580
+ const trimmedValue = value.trim();
11581
+ useEffect(() => {
11582
+ const textarea = textareaRef.current;
11583
+ if (!textarea) {
11584
+ return;
11585
+ }
11586
+ textarea.style.height = "auto";
11587
+ textarea.style.height = `${textarea.scrollHeight}px`;
11588
+ }, [value]);
11589
+ const submitValue = useCallback(() => {
11590
+ if (props.status !== "idle") {
11591
+ return;
11592
+ }
11593
+ const text = value.trim();
11594
+ if (!text || disabled) {
11595
+ return;
11596
+ }
11597
+ props.onSubmit(text);
11598
+ }, [disabled, props, value]);
11599
+ const handleSubmit = useCallback(
11600
+ (event) => {
11601
+ event.preventDefault();
11602
+ submitValue();
11603
+ },
11604
+ [submitValue]
11605
+ );
11606
+ const handleKeyDown = useCallback(
11607
+ (event) => {
11608
+ if (event.key === "Enter" && !event.shiftKey) {
11609
+ event.preventDefault();
11610
+ submitValue();
11611
+ }
11612
+ },
11613
+ [submitValue]
11614
+ );
11615
+ const currentActionLabel = props.status === "responding" ? props.stopButtonAriaLabel : props.sendButtonAriaLabel;
11616
+ return /* @__PURE__ */ jsxs(
11617
+ "form",
11618
+ {
11619
+ ref,
11620
+ "data-slot": "chat-composer",
11621
+ className: cn74(chatComposerRootVariants(), className),
11622
+ onSubmit: handleSubmit,
11623
+ children: [
11624
+ /* @__PURE__ */ jsx(
11625
+ "textarea",
11626
+ {
11627
+ "data-slot": "chat-composer-input",
11628
+ "aria-label": textareaAriaLabel,
11629
+ className: chatComposerTextareaVariants(),
11630
+ disabled,
11631
+ onChange: (event) => onValueChange(event.target.value),
11632
+ onKeyDown: handleKeyDown,
11633
+ placeholder,
11634
+ ref: textareaRef,
11635
+ rows: 1,
11636
+ value
11637
+ }
11638
+ ),
11639
+ /* @__PURE__ */ jsx("div", { className: "flex min-h-9 items-center justify-end gap-2 px-3 pt-1 pb-2", children: props.status === "responding" ? /* @__PURE__ */ jsx(
11640
+ "button",
11641
+ {
11642
+ "aria-label": props.stopButtonAriaLabel,
11643
+ className: chatComposerActionButtonVariants({ tone: "stop" }),
11644
+ "data-slot": "chat-composer-stop-button",
11645
+ onClick: props.onStop,
11646
+ type: "button",
11647
+ children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\u25A0" })
11648
+ }
11649
+ ) : /* @__PURE__ */ jsx(
11650
+ "button",
11651
+ {
11652
+ "aria-label": props.sendButtonAriaLabel,
11653
+ className: chatComposerActionButtonVariants({ tone: "send" }),
11654
+ "data-slot": "chat-composer-send-button",
11655
+ disabled: disabled || trimmedValue.length === 0,
11656
+ type: "submit",
11657
+ children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\u2191" })
11658
+ }
11659
+ ) }),
11660
+ /* @__PURE__ */ jsx("span", { "aria-live": "polite", className: "sr-only", "data-slot": "chat-composer-status-announcer", children: currentActionLabel })
11661
+ ]
11662
+ }
11663
+ );
11664
+ }
11665
+ MosaicChatComposer.displayName = "MosaicChatComposer";
11463
11666
 
11464
- export { MosaicAccordion, MosaicAccordionItem, MosaicAccordionPanel, MosaicAccordionTrigger, MosaicActivityFeed, MosaicActivityItem, MosaicAdaptiveGrid, MosaicAdaptiveModal, MosaicAdaptiveNavigation, MosaicAgentCard, MosaicAgentComposer, MosaicAgentComposerDesktop, MosaicAgentComposerMobile, MosaicAgentList, AgentListDesktop as MosaicAgentListDesktop, AgentListMobile as MosaicAgentListMobile, MosaicAgentTeamPreview, MosaicAnimatedList, MosaicAppSidebar, MosaicAvatar, MosaicBadge, MosaicBlurredOrb, MosaicButton, MosaicCard, MosaicCardContent, MosaicCardDescription, MosaicCardFooter, MosaicCardHeader, MosaicCardTitle, MosaicCheckbox, MosaicClerkOrgSwitcher, MosaicClerkWebhookHandler, MosaicCollapsible, MosaicCollapsiblePanel, MosaicCollapsibleTrigger, MosaicCombobox, MosaicCounter, MosaicCreateOrgDialog, MosaicDashboardContent, MosaicDashboardHeader, MosaicDashboardLayout, MosaicDataTable, MosaicDeleteConfirmationDialog, MosaicDeviceProvider, MosaicDocumentUpload, MosaicDropdownMenu, MosaicEmptyState, MosaicFallingPattern, MosaicFeature3Col, MosaicFeatureCenteredMedia, MosaicField, MosaicFieldControl, MosaicFieldDescription, MosaicFieldError, MosaicFieldLabel, MosaicFilterBar, MosaicFilterSidebar, MosaicFooterSimple, MosaicHeroSplit, MosaicInput, MosaicInputGroup, MosaicIntegrationsBadge, MosaicInviteMemberDialog, MosaicKanbanBoard, MosaicKanbanColumn, MosaicLogosGrid, MosaicMainNav, MosaicMarketplaceList, MarketplaceListDesktop as MosaicMarketplaceListDesktop, MarketplaceListMobile as MosaicMarketplaceListMobile, MosaicMemberList, MosaicMemoryCard, MosaicMessageCard, MosaicMessageList, MessageListDesktop as MosaicMessageListDesktop, MessageListMobile as MosaicMessageListMobile, MosaicModuleCard, MosaicModuleForm, MosaicModuleLibrary, MosaicMultiOrgIndicator, MosaicMultiTenantProvider, MosaicNavbar, MosaicOrgPanel, MosaicOrgProfilePage, MosaicOrgRoleBadge, MosaicOrgSwitcher, MosaicPreferencesPanel, MosaicPricingCard, MosaicProfilePanel, MosaicProgress, MosaicQuickActionCard, MosaicQuickActionsMenu, MosaicQuickAgentSelector, MosaicQuickStartPanel, MosaicRadioGroup, MosaicRadioGroupItem, MosaicScrollArea, MosaicSelect, MosaicSelectorModal, MosaicSeparator, MosaicSignInLayout, MosaicSignUpLayout, MosaicSkeleton, MosaicSlider, MosaicStatsGrid, MosaicStepPipeline, MosaicSwitch, MosaicTabs, MosaicTabsList, MosaicTabsPanel, MosaicTabsTrigger, MosaicTemplateCard, MosaicTemplateGallery, MosaicTemplatePreview, MosaicTestimonialsGrid, MosaicTextarea, MosaicThemeProvider, MosaicThemeToggle, MosaicTooltip, MosaicTooltipContent, MosaicTooltipProvider, MosaicTooltipRoot, MosaicTooltipTrigger, MosaicUrlScraper, MosaicUserButton, Placeholder, badgeVariants, buttonVariants, skeletonVariants, useBreakpoint, useDevice, useMosaicWorkspace as useEffectiveWorkspaceId, useIsDesktop, useIsMobile, useIsTablet, useMediaQuery, useMosaicWorkspace, useOrientation, useViewport, version };
11667
+ export { MosaicAccordion, MosaicAccordionItem, MosaicAccordionPanel, MosaicAccordionTrigger, MosaicActivityFeed, MosaicActivityItem, MosaicAdaptiveGrid, MosaicAdaptiveModal, MosaicAdaptiveNavigation, MosaicAgentCard, MosaicAgentComposer, MosaicAgentComposerDesktop, MosaicAgentComposerMobile, MosaicAgentList, AgentListDesktop as MosaicAgentListDesktop, AgentListMobile as MosaicAgentListMobile, MosaicAgentTeamPreview, MosaicAnimatedList, MosaicAppSidebar, MosaicAvatar, MosaicBadge, MosaicBlurredOrb, MosaicButton, MosaicCard, MosaicCardContent, MosaicCardDescription, MosaicCardFooter, MosaicCardHeader, MosaicCardTitle, MosaicChatComposer, MosaicChatThread, MosaicCheckbox, MosaicClerkOrgSwitcher, MosaicClerkWebhookHandler, MosaicCollapsible, MosaicCollapsiblePanel, MosaicCollapsibleTrigger, MosaicCombobox, MosaicCounter, MosaicCreateOrgDialog, MosaicDashboardContent, MosaicDashboardHeader, MosaicDashboardLayout, MosaicDataTable, MosaicDeleteConfirmationDialog, MosaicDeviceProvider, MosaicDocumentUpload, MosaicDropdownMenu, MosaicEmptyState, MosaicFallingPattern, MosaicFeature3Col, MosaicFeatureCenteredMedia, MosaicField, MosaicFieldControl, MosaicFieldDescription, MosaicFieldError, MosaicFieldLabel, MosaicFilterBar, MosaicFilterSidebar, MosaicFooterSimple, MosaicHeroSplit, MosaicInput, MosaicInputGroup, MosaicIntegrationsBadge, MosaicInviteMemberDialog, MosaicKanbanBoard, MosaicKanbanColumn, MosaicLogosGrid, MosaicMainNav, MosaicMarketplaceList, MarketplaceListDesktop as MosaicMarketplaceListDesktop, MarketplaceListMobile as MosaicMarketplaceListMobile, MosaicMemberList, MosaicMemoryCard, MosaicMessageCard, MosaicMessageList, MessageListDesktop as MosaicMessageListDesktop, MessageListMobile as MosaicMessageListMobile, MosaicModuleCard, MosaicModuleForm, MosaicModuleLibrary, MosaicMultiOrgIndicator, MosaicMultiTenantProvider, MosaicNavbar, MosaicOrgPanel, MosaicOrgProfilePage, MosaicOrgRoleBadge, MosaicOrgSwitcher, MosaicPreferencesPanel, MosaicPricingCard, MosaicProfilePanel, MosaicProgress, MosaicQuickActionCard, MosaicQuickActionsMenu, MosaicQuickAgentSelector, MosaicQuickStartPanel, MosaicRadioGroup, MosaicRadioGroupItem, MosaicScrollArea, MosaicSelect, MosaicSelectorModal, MosaicSeparator, MosaicSignInLayout, MosaicSignUpLayout, MosaicSkeleton, MosaicSlider, MosaicStatsGrid, MosaicStepPipeline, MosaicSwitch, MosaicTabs, MosaicTabsList, MosaicTabsPanel, MosaicTabsTrigger, MosaicTemplateCard, MosaicTemplateGallery, MosaicTemplatePreview, MosaicTestimonialsGrid, MosaicTextarea, MosaicThemeProvider, MosaicThemeToggle, MosaicTooltip, MosaicTooltipContent, MosaicTooltipProvider, MosaicTooltipRoot, MosaicTooltipTrigger, MosaicUrlScraper, MosaicUserButton, Placeholder, badgeVariants, buttonVariants, skeletonVariants, useBreakpoint, useDevice, useMosaicWorkspace as useEffectiveWorkspaceId, useIsDesktop, useIsMobile, useIsTablet, useMediaQuery, useMosaicWorkspace, useOrientation, useViewport, version };
11465
11668
  //# sourceMappingURL=index.js.map
11466
11669
  //# sourceMappingURL=index.js.map