@mieweb/ui 0.10.0-dev.7 → 0.10.0-dev.9

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.
Files changed (38) hide show
  1. package/dist/{chunk-XEPDIFEA.js → chunk-4A3W4TQF.js} +16 -3
  2. package/dist/chunk-4A3W4TQF.js.map +1 -0
  3. package/dist/{chunk-WNAA6CLE.cjs → chunk-AR7AKDM2.cjs} +2 -2
  4. package/dist/{chunk-WNAA6CLE.cjs.map → chunk-AR7AKDM2.cjs.map} +1 -1
  5. package/dist/{chunk-XCENM6ED.cjs → chunk-ASSDGS4F.cjs} +16 -3
  6. package/dist/chunk-ASSDGS4F.cjs.map +1 -0
  7. package/dist/{chunk-JHULS3EC.js → chunk-AWJBOND5.js} +2 -2
  8. package/dist/{chunk-JHULS3EC.js.map → chunk-AWJBOND5.js.map} +1 -1
  9. package/dist/chunk-BM35CACB.js +148 -0
  10. package/dist/chunk-BM35CACB.js.map +1 -0
  11. package/dist/{chunk-WIAQQNFU.cjs → chunk-FS4VZUFV.cjs} +31 -2
  12. package/dist/chunk-FS4VZUFV.cjs.map +1 -0
  13. package/dist/{chunk-22CYDCXA.js → chunk-HACNIFO3.js} +31 -3
  14. package/dist/chunk-HACNIFO3.js.map +1 -0
  15. package/dist/chunk-VPTASZ2O.cjs +171 -0
  16. package/dist/chunk-VPTASZ2O.cjs.map +1 -0
  17. package/dist/components/SuperChat/index.cjs +442 -267
  18. package/dist/components/SuperChat/index.cjs.map +1 -1
  19. package/dist/components/SuperChat/index.js +439 -264
  20. package/dist/components/SuperChat/index.js.map +1 -1
  21. package/dist/hooks/index.cjs +22 -13
  22. package/dist/hooks/index.d.cts +101 -1
  23. package/dist/hooks/index.d.ts +101 -1
  24. package/dist/hooks/index.js +2 -1
  25. package/dist/index.cjs +193 -70
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +1 -1
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.js +146 -30
  30. package/dist/index.js.map +1 -1
  31. package/dist/styles.css +1 -1
  32. package/dist/tailwind-preset.cjs +4 -4
  33. package/dist/tailwind-preset.js +1 -1
  34. package/package.json +1 -1
  35. package/dist/chunk-22CYDCXA.js.map +0 -1
  36. package/dist/chunk-WIAQQNFU.cjs.map +0 -1
  37. package/dist/chunk-XCENM6ED.cjs.map +0 -1
  38. package/dist/chunk-XEPDIFEA.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -75,7 +75,7 @@ export { Slider, SliderProps, sliderRangeVariants, sliderThumbVariants, sliderTr
75
75
  export { Switch, SwitchProps, switchThumbVariants, switchTrackVariants } from './components/Switch/index.cjs';
76
76
  export { Table, TableBody, TableBodyProps, TableCaption, TableCaptionProps, TableCell, TableCellProps, TableFooter, TableFooterProps, TableHead, TableHeadProps, TableHeader, TableHeaderProps, TableProps, TableRow, TableRowProps } from './components/Table/index.cjs';
77
77
  import { UseScrollSpyOptions } from './hooks/index.cjs';
78
- export { Direction, DragOverState, HoverPreviewState, KeyboardShortcutOptions, MediaTransportState, RTL_LOCALES, UseDragReorderOptions, UseDragReorderReturn, UseMediaTransportOptions, UseMediaTransportReturn, UseScrollSpyReturn, UseYouTubeHoverPreviewOptions, UseYouTubeHoverPreviewReturn, dragIndicatorClasses, isDarkMode, isRtlLocale, reorderIds, useClickOutside, useCommandK, useDirection, useDragReorder, useEscapeKey, useFocusTrap, useIsDarkMode, useIsDesktop, useIsLargeDesktop, useIsMobile, useIsMobileOrTablet, useIsSmallTablet, useIsTablet, useKeyboardShortcut, useLiveAnnouncement, useMediaQuery, useMediaTransport, usePrefersReducedMotion, useScrollSpy, useYouTubeHoverPreview } from './hooks/index.cjs';
78
+ export { Direction, DragOverState, HoverPreviewState, KeyboardShortcutOptions, MediaTransportState, RTL_LOCALES, UseDragReorderOptions, UseDragReorderReturn, UseMediaTransportOptions, UseMediaTransportReturn, UseScrollSpyReturn, UseStickToBottomOptions, UseStickToBottomReturn, UseYouTubeHoverPreviewOptions, UseYouTubeHoverPreviewReturn, dragIndicatorClasses, isDarkMode, isRtlLocale, reorderIds, useClickOutside, useCommandK, useDirection, useDragReorder, useEscapeKey, useFocusTrap, useIsDarkMode, useIsDesktop, useIsLargeDesktop, useIsMobile, useIsMobileOrTablet, useIsSmallTablet, useIsTablet, useKeyboardShortcut, useLiveAnnouncement, useMediaQuery, useMediaTransport, usePrefersReducedMotion, useScrollSpy, useStickToBottom, useStreamEndedBelowFold, useYouTubeHoverPreview } from './hooks/index.cjs';
79
79
  export { Tabs, TabsContent, TabsContentProps, TabsList, TabsListProps, TabsProps, TabsTrigger, TabsTriggerProps, tabsListVariants, tabsTriggerVariants } from './components/Tabs/index.cjs';
80
80
  export { SmallMuted, Text, TextProps, textVariants } from './components/Text/index.cjs';
81
81
  export { Textarea, TextareaProps, textareaVariants } from './components/Textarea/index.cjs';
package/dist/index.d.ts CHANGED
@@ -75,7 +75,7 @@ export { Slider, SliderProps, sliderRangeVariants, sliderThumbVariants, sliderTr
75
75
  export { Switch, SwitchProps, switchThumbVariants, switchTrackVariants } from './components/Switch/index.js';
76
76
  export { Table, TableBody, TableBodyProps, TableCaption, TableCaptionProps, TableCell, TableCellProps, TableFooter, TableFooterProps, TableHead, TableHeadProps, TableHeader, TableHeaderProps, TableProps, TableRow, TableRowProps } from './components/Table/index.js';
77
77
  import { UseScrollSpyOptions } from './hooks/index.js';
78
- export { Direction, DragOverState, HoverPreviewState, KeyboardShortcutOptions, MediaTransportState, RTL_LOCALES, UseDragReorderOptions, UseDragReorderReturn, UseMediaTransportOptions, UseMediaTransportReturn, UseScrollSpyReturn, UseYouTubeHoverPreviewOptions, UseYouTubeHoverPreviewReturn, dragIndicatorClasses, isDarkMode, isRtlLocale, reorderIds, useClickOutside, useCommandK, useDirection, useDragReorder, useEscapeKey, useFocusTrap, useIsDarkMode, useIsDesktop, useIsLargeDesktop, useIsMobile, useIsMobileOrTablet, useIsSmallTablet, useIsTablet, useKeyboardShortcut, useLiveAnnouncement, useMediaQuery, useMediaTransport, usePrefersReducedMotion, useScrollSpy, useYouTubeHoverPreview } from './hooks/index.js';
78
+ export { Direction, DragOverState, HoverPreviewState, KeyboardShortcutOptions, MediaTransportState, RTL_LOCALES, UseDragReorderOptions, UseDragReorderReturn, UseMediaTransportOptions, UseMediaTransportReturn, UseScrollSpyReturn, UseStickToBottomOptions, UseStickToBottomReturn, UseYouTubeHoverPreviewOptions, UseYouTubeHoverPreviewReturn, dragIndicatorClasses, isDarkMode, isRtlLocale, reorderIds, useClickOutside, useCommandK, useDirection, useDragReorder, useEscapeKey, useFocusTrap, useIsDarkMode, useIsDesktop, useIsLargeDesktop, useIsMobile, useIsMobileOrTablet, useIsSmallTablet, useIsTablet, useKeyboardShortcut, useLiveAnnouncement, useMediaQuery, useMediaTransport, usePrefersReducedMotion, useScrollSpy, useStickToBottom, useStreamEndedBelowFold, useYouTubeHoverPreview } from './hooks/index.js';
79
79
  export { Tabs, TabsContent, TabsContentProps, TabsList, TabsListProps, TabsProps, TabsTrigger, TabsTriggerProps, tabsListVariants, tabsTriggerVariants } from './components/Tabs/index.js';
80
80
  export { SmallMuted, Text, TextProps, textVariants } from './components/Text/index.js';
81
81
  export { Textarea, TextareaProps, textareaVariants } from './components/Textarea/index.js';
package/dist/index.js CHANGED
@@ -29,8 +29,8 @@ import { Skeleton } from './chunk-ZIUADGAR.js';
29
29
  export { Skeleton, SkeletonCard, SkeletonTable, SkeletonText, skeletonVariants } from './chunk-ZIUADGAR.js';
30
30
  export { SourceTip } from './chunk-Z5V7SAZ4.js';
31
31
  export { Sparkline } from './chunk-CG4ZKJLE.js';
32
- import { SparklesIcon, RefreshIcon, CloseIcon, AIMessageDisplay } from './chunk-22CYDCXA.js';
33
- export { AILogoIcon, AIMessageDisplay, AITypingIndicator, ChatBubble, ChevronIcon, CloseIcon, CollapsiblePill, MCPToolCallDisplay, MessageAvatar, RefreshIcon, ResourceLink, SendIcon, SparklesIcon, SpinnerIcon, ToolStatusIcon, getToolIcon } from './chunk-22CYDCXA.js';
32
+ import { SparklesIcon, RefreshIcon, CloseIcon, JumpToBottomButton, AIMessageDisplay } from './chunk-HACNIFO3.js';
33
+ export { AILogoIcon, AIMessageDisplay, AITypingIndicator, ChatBubble, ChevronIcon, CloseIcon, CollapsiblePill, MCPToolCallDisplay, MessageAvatar, RefreshIcon, ResourceLink, SendIcon, SparklesIcon, SpinnerIcon, ToolStatusIcon, getToolIcon } from './chunk-HACNIFO3.js';
34
34
  import { useTypingEmulation, EmptyState } from './chunk-3M7TAXNR.js';
35
35
  export { AttachmentPreview, ConversationHeader, ConversationListItem, ConversationListSkeleton, DateSeparator, EmptyState, LightboxModal, LoadMoreButton, MessageBubble, MessageList, MessageStatusIcon, MessageThread, MessagingSplitView, ReadReceiptIndicator, SkeletonMessage, TypingIndicator, bubbleVariants, formatDateLabel, formatFileSize, formatLastSeen, getConversationSubtitle, getConversationTitle, groupMessagesByDate, headerVariants, isSameSenderGroup, useMessageScroll, useMessages, useReadReceipts, useTypingEmulation, useTypingIndicator } from './chunk-3M7TAXNR.js';
36
36
  import { notifyComposerMigrationOnce, ChatComposer, DEFAULT_MAX_FILE_SIZE, DEFAULT_ACCEPTED_FILE_TYPES } from './chunk-ACCAXVOG.js';
@@ -95,10 +95,12 @@ export { CalendarView, defaultCalendarLabels } from './chunk-G4D6CLBT.js';
95
95
  export { accentClasses, defaultViewLabels, toDateTime } from './chunk-3YBS4WUQ.js';
96
96
  import { Spinner, SpinnerWithLabel } from './chunk-UA7E7PDS.js';
97
97
  export { FullPageSpinner, Spinner, SpinnerWithLabel, spinnerVariants } from './chunk-UA7E7PDS.js';
98
- import { useDirection, useCommandK, useIsMobile, useMediaQuery } from './chunk-JHULS3EC.js';
99
- export { RTL_LOCALES, isRtlLocale, useCommandK, useDirection, useIsDesktop, useIsLargeDesktop, useIsMobile, useIsMobileOrTablet, useIsSmallTablet, useIsTablet, useKeyboardShortcut, useMediaQuery } from './chunk-JHULS3EC.js';
98
+ import { useDirection, useCommandK, useIsMobile, useMediaQuery } from './chunk-AWJBOND5.js';
99
+ export { RTL_LOCALES, isRtlLocale, useCommandK, useDirection, useIsDesktop, useIsLargeDesktop, useIsMobile, useIsMobileOrTablet, useIsSmallTablet, useIsTablet, useKeyboardShortcut, useMediaQuery } from './chunk-AWJBOND5.js';
100
100
  export { useYouTubeHoverPreview } from './chunk-POWS35OT.js';
101
101
  export { useTheme } from './chunk-KJZNEVYM.js';
102
+ import { useStickToBottom, useStreamEndedBelowFold } from './chunk-BM35CACB.js';
103
+ export { useStickToBottom, useStreamEndedBelowFold } from './chunk-BM35CACB.js';
102
104
  import { useScrollSpy } from './chunk-WBGUYSWY.js';
103
105
  export { useScrollSpy } from './chunk-WBGUYSWY.js';
104
106
  export { DEFAULT_FILLER_WORDS, DEFAULT_MIN_SILENCE_MS, DEFAULT_NL_SILENCE_MS, buildPlaybackSegments, getSpeedAtIndex, initEditableWords, insertSilences, useTranscriptEdits } from './chunk-UUI7WXI5.js';
@@ -107,7 +109,7 @@ export { useMediaTransport } from './chunk-SQHMGT4W.js';
107
109
  import './chunk-7XUN3OQT.js';
108
110
  export { isHtmlEmpty, stripHtmlTags } from './chunk-ERLPVXOV.js';
109
111
  export { formatPhoneNumber, isPhoneNumberEmpty, isValidPhoneNumber, unformatPhoneNumber } from './chunk-ZVPJ2MH6.js';
110
- export { miewebUIPreset, miewebUISafelist } from './chunk-XEPDIFEA.js';
112
+ export { miewebUIPreset, miewebUISafelist } from './chunk-4A3W4TQF.js';
111
113
  export { Accordion } from './chunk-KRU6IGV7.js';
112
114
  import { Alert, AlertTitle, AlertDescription } from './chunk-3JWAABYI.js';
113
115
  export { Alert, AlertDescription, AlertTitle, alertVariants } from './chunk-3JWAABYI.js';
@@ -1512,7 +1514,6 @@ function AIChat({
1512
1514
  renderTextContent,
1513
1515
  renderMessageFooter
1514
1516
  }) {
1515
- const messagesContainerRef = React13.useRef(null);
1516
1517
  React13.useEffect(() => {
1517
1518
  notifyComposerMigrationOnce("AIChat");
1518
1519
  }, []);
@@ -1521,10 +1522,108 @@ function AIChat({
1521
1522
  [session?.messages, messagesProp]
1522
1523
  );
1523
1524
  const isGenerating = session?.isGenerating || isGeneratingProp || false;
1525
+ const prefersReducedMotion = usePrefersReducedMotion();
1526
+ const {
1527
+ containerRef: messagesContainerRef,
1528
+ contentRef: messagesContentRef,
1529
+ isAtBottom,
1530
+ scrollToBottom,
1531
+ anchorToTurnStart,
1532
+ followIfPinned,
1533
+ stopFollowing
1534
+ } = useStickToBottom();
1535
+ const [hasNewBelow, setHasNewBelow] = React13.useState(false);
1536
+ const [turnStartId, setTurnStartId] = React13.useState(null);
1537
+ const [turnMinHeight, setTurnMinHeight] = React13.useState();
1538
+ const anchoredTurnRef = React13.useRef(null);
1539
+ React13.useEffect(() => {
1540
+ setTurnStartId(null);
1541
+ anchoredTurnRef.current = null;
1542
+ scrollToBottom("auto");
1543
+ setHasNewBelow(false);
1544
+ }, [session?.id, scrollToBottom]);
1545
+ const messageCount = messages.length;
1546
+ const prevMessageCountRef = React13.useRef(messageCount);
1547
+ const policySessionRef = React13.useRef(session?.id);
1548
+ const policyBaselinedRef = React13.useRef(false);
1524
1549
  React13.useEffect(() => {
1550
+ if (!policyBaselinedRef.current || policySessionRef.current !== session?.id) {
1551
+ policyBaselinedRef.current = true;
1552
+ policySessionRef.current = session?.id;
1553
+ prevMessageCountRef.current = messageCount;
1554
+ if (messages.at(-1)?.status === "streaming") stopFollowing();
1555
+ return;
1556
+ }
1557
+ const prevCount = prevMessageCountRef.current;
1558
+ if (messageCount === prevCount) return;
1559
+ const grew = messageCount > prevCount;
1560
+ prevMessageCountRef.current = messageCount;
1561
+ const ownMessage = grew ? messages.slice(prevCount).filter((m) => m.role === "user").at(-1) : void 0;
1562
+ if (ownMessage) {
1563
+ setTurnStartId(ownMessage.id);
1564
+ } else if (grew && messages.at(-1)?.status === "streaming") {
1565
+ followIfPinned("auto");
1566
+ stopFollowing();
1567
+ } else if (!followIfPinned("auto") && grew) {
1568
+ setHasNewBelow(true);
1569
+ }
1570
+ }, [messageCount, isAtBottom, session?.id]);
1571
+ React13.useLayoutEffect(() => {
1572
+ if (!turnStartId || anchoredTurnRef.current === turnStartId) return;
1525
1573
  const container = messagesContainerRef.current;
1526
- if (container) container.scrollTop = container.scrollHeight;
1527
- }, [messages]);
1574
+ if (!container) return;
1575
+ const reserve = Math.max(0, container.clientHeight - 32);
1576
+ if (turnMinHeight !== reserve) {
1577
+ setTurnMinHeight(reserve);
1578
+ return;
1579
+ }
1580
+ const target = container.querySelector(
1581
+ '[data-slot="ai-chat-turn"]'
1582
+ );
1583
+ if (target) {
1584
+ anchorToTurnStart(target, prefersReducedMotion ? "auto" : "smooth");
1585
+ anchoredTurnRef.current = turnStartId;
1586
+ }
1587
+ }, [
1588
+ turnStartId,
1589
+ turnMinHeight,
1590
+ anchorToTurnStart,
1591
+ prefersReducedMotion,
1592
+ messagesContainerRef
1593
+ ]);
1594
+ const turnIndex = React13.useMemo(
1595
+ () => turnStartId ? messages.findIndex((m) => m.id === turnStartId) : -1,
1596
+ [messages, turnStartId]
1597
+ );
1598
+ React13.useEffect(() => {
1599
+ if (isAtBottom) setHasNewBelow(false);
1600
+ }, [isAtBottom]);
1601
+ const raiseNewBelow = React13.useCallback(() => setHasNewBelow(true), []);
1602
+ const resumeFollowing = React13.useCallback(
1603
+ () => scrollToBottom("auto"),
1604
+ [scrollToBottom]
1605
+ );
1606
+ useStreamEndedBelowFold(
1607
+ messages.at(-1),
1608
+ isAtBottom,
1609
+ raiseNewBelow,
1610
+ resumeFollowing
1611
+ );
1612
+ const handleJumpToBottom = React13.useCallback(() => {
1613
+ scrollToBottom(prefersReducedMotion ? "auto" : "smooth");
1614
+ }, [scrollToBottom, prefersReducedMotion]);
1615
+ const renderMessageItem = (message) => /* @__PURE__ */ jsx(
1616
+ AIMessageDisplay,
1617
+ {
1618
+ message,
1619
+ userName,
1620
+ showTimestamp: showTimestamps,
1621
+ onLinkClick: handleLinkClick,
1622
+ renderTextContent,
1623
+ renderMessageFooter
1624
+ },
1625
+ message.id
1626
+ );
1528
1627
  const {
1529
1628
  showAttachmentPicker,
1530
1629
  inputTrailing,
@@ -1662,30 +1761,47 @@ function AIChat({
1662
1761
  ]
1663
1762
  }
1664
1763
  ),
1665
- /* @__PURE__ */ jsx(
1764
+ /* @__PURE__ */ jsxs(
1666
1765
  "div",
1667
1766
  {
1668
- ref: messagesContainerRef,
1669
- "data-slot": "ai-chat-messages",
1670
- className: "flex-1 overflow-y-auto px-4 py-4",
1671
- children: messages.length === 0 ? /* @__PURE__ */ jsx(
1672
- AIEmptyState,
1673
- {
1674
- suggestions,
1675
- onSuggestionSelect: handleSuggestionSelect
1676
- }
1677
- ) : /* @__PURE__ */ jsx("div", { className: "space-y-4", children: messages.map((message) => /* @__PURE__ */ jsx(
1678
- AIMessageDisplay,
1679
- {
1680
- message,
1681
- userName,
1682
- showTimestamp: showTimestamps,
1683
- onLinkClick: handleLinkClick,
1684
- renderTextContent,
1685
- renderMessageFooter
1686
- },
1687
- message.id
1688
- )) })
1767
+ "data-slot": "ai-chat-messages-viewport",
1768
+ className: "relative flex min-h-0 flex-1 flex-col",
1769
+ children: [
1770
+ /* @__PURE__ */ jsx(
1771
+ "div",
1772
+ {
1773
+ ref: messagesContainerRef,
1774
+ "data-slot": "ai-chat-messages",
1775
+ className: "flex-1 overflow-y-auto px-4 py-4",
1776
+ children: /* @__PURE__ */ jsx("div", { ref: messagesContentRef, children: messages.length === 0 ? /* @__PURE__ */ jsx(
1777
+ AIEmptyState,
1778
+ {
1779
+ suggestions,
1780
+ onSuggestionSelect: handleSuggestionSelect
1781
+ }
1782
+ ) : /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
1783
+ (turnIndex === -1 ? messages : messages.slice(0, turnIndex)).map(renderMessageItem),
1784
+ turnIndex !== -1 && /* @__PURE__ */ jsx(
1785
+ "div",
1786
+ {
1787
+ "data-slot": "ai-chat-turn",
1788
+ className: "space-y-4",
1789
+ style: { minHeight: turnMinHeight },
1790
+ children: messages.slice(turnIndex).map(renderMessageItem)
1791
+ }
1792
+ )
1793
+ ] }) })
1794
+ }
1795
+ ),
1796
+ !isAtBottom && /* @__PURE__ */ jsx(
1797
+ JumpToBottomButton,
1798
+ {
1799
+ dataSlot: "ai-chat-jump-to-bottom",
1800
+ hasNewMessages: hasNewBelow,
1801
+ onClick: handleJumpToBottom
1802
+ }
1803
+ )
1804
+ ]
1689
1805
  }
1690
1806
  ),
1691
1807
  /* @__PURE__ */ jsxs(