@superdispatch/ui-lab 0.23.0 → 0.23.3

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.
@@ -8,13 +8,9 @@ var ChatContainer = /*#__PURE__*/styled('div').withConfig({
8
8
  componentId: "SD__sc-qksih8-0"
9
9
  })(_ref => {
10
10
  var {
11
- isEmpty,
12
- minWidth,
13
- maxWidth,
14
- minHeight,
15
- maxHeight
11
+ isEmpty
16
12
  } = _ref;
17
- return "\n display: flex;\n flex-direction: column-reverse;\n overflow: auto;\n justify-content: ".concat(isEmpty ? 'center' : 'end', ";\n width: 100%;\n height: 100%;\n min-width: ").concat(minWidth || 432, "px;\n max-width: ").concat(maxWidth || 560, "px;\n min-height: ").concat(minHeight || 368, "px;\n max-height: ").concat(maxHeight || 696, "px;\n padding: 16px;\n box-sizing: border-box;\n");
13
+ return "\n display: flex;\n flex-direction: column-reverse;\n overflow: auto;\n justify-content: ".concat(isEmpty ? 'center' : 'end', ";\n width: 100%;\n height: 100%;\n min-width: 300px;\n max-width: 560px;\n min-height: 368px;\n max-height: 696px;\n padding: 16px;\n box-sizing: border-box;\n");
18
14
  });
19
15
 
20
16
  function emptyPlaceholder(text) {
@@ -28,6 +24,7 @@ function emptyPlaceholder(text) {
28
24
  export var Chat = /*#__PURE__*/forwardRef((_ref2, ref) => {
29
25
  var {
30
26
  children,
27
+ className,
31
28
  emptyText = 'No new messages'
32
29
  } = _ref2;
33
30
  var isEmpty = Children.toArray(children).length === 0;
@@ -35,6 +32,7 @@ export var Chat = /*#__PURE__*/forwardRef((_ref2, ref) => {
35
32
  "data-testid": "chat-container",
36
33
  isEmpty: isEmpty,
37
34
  ref: ref,
35
+ className: className,
38
36
  children: /*#__PURE__*/_jsx(Stack, {
39
37
  space: "small",
40
38
  children: isEmpty ? emptyPlaceholder(emptyText) : children
@@ -1,4 +1,5 @@
1
1
  import { Typography } from '@material-ui/core';
2
+ import { formatDate } from '@superdispatch/dates';
2
3
  import { Inline, Stack } from '@superdispatch/ui';
3
4
  import { Box } from '@superdispatch/ui-lab';
4
5
  import { forwardRef } from 'react';
@@ -12,6 +13,9 @@ export var ChatMessage = /*#__PURE__*/forwardRef((_ref, ref) => {
12
13
  text,
13
14
  variant
14
15
  } = _ref;
16
+ var time = formatDate(dateTime, {
17
+ variant: 'Time'
18
+ });
15
19
  return /*#__PURE__*/_jsxs(Stack, {
16
20
  space: "xxsmall",
17
21
  align: variant === 'outgoing' ? 'right' : 'left',
@@ -27,7 +31,7 @@ export var ChatMessage = /*#__PURE__*/forwardRef((_ref, ref) => {
27
31
  children: role
28
32
  }), /*#__PURE__*/_jsx(Typography, {
29
33
  color: "textSecondary",
30
- children: dateTime
34
+ children: time
31
35
  })]
32
36
  }), /*#__PURE__*/_jsx(Box, {
33
37
  display: "inline-block",
package/dist-src/index.js CHANGED
@@ -3,6 +3,8 @@ export * from "./banner/Banner.js";
3
3
  export * from "./box/Box.js";
4
4
  export * from "./button-area/ButtonArea.js";
5
5
  export * from "./button/Button.js";
6
+ export * from "./chat/Chat.js";
7
+ export * from "./chat/ChatMessage.js";
6
8
  export * from "./container/Container.js";
7
9
  export * from "./description-item/DescriptionItem.js";
8
10
  export * from "./file-drop-zone/FileDropZone.js";
@@ -5,6 +5,8 @@ import { CSSTransitionProps } from 'react-transition-group/CSSTransition';
5
5
  import { SpaceProp, NegativeSpaceProp, ResponsiveProp, ColorProp } from '@superdispatch/ui';
6
6
  import { Property } from 'csstype';
7
7
  import { ButtonBaseProps, AvatarProps, IconButtonProps, TooltipProps } from '@material-ui/core';
8
+ import { PrimitiveDateInput } from '@superdispatch/dates';
9
+ import { DateTime } from 'luxon';
8
10
  import { FileRejection } from 'react-dropzone';
9
11
  import { StyledComponent, DefaultTheme } from 'styled-components';
10
12
 
@@ -119,6 +121,23 @@ interface AnchorButtonProps extends BaseButtonProps<HTMLAnchorElement> {
119
121
  }
120
122
  declare const AnchorButton: ForwardRefExoticComponent<AnchorButtonProps & RefAttributes<HTMLAnchorElement>>;
121
123
 
124
+
125
+ interface ChatProps {
126
+ className?: string;
127
+ children?: React.ReactNode | React.ReactNode[];
128
+ emptyText?: string;
129
+ }
130
+ declare const Chat: ForwardRefExoticComponent<ChatProps & RefAttributes<HTMLDivElement>>;
131
+
132
+ interface ChatMessageProps {
133
+ author: string;
134
+ role: string;
135
+ dateTime: Date | DateTime | PrimitiveDateInput;
136
+ text: string;
137
+ variant: 'incoming' | 'outgoing';
138
+ }
139
+ declare const ChatMessage: ForwardRefExoticComponent<ChatMessageProps & RefAttributes<HTMLDivElement>>;
140
+
122
141
  declare type ContainerProps = HTMLAttributes<HTMLDivElement> & {
123
142
  fullViewportHeight?: boolean;
124
143
  };
@@ -373,4 +392,4 @@ interface TextBoxProps {
373
392
  }
374
393
  declare const TextBox: ForwardRefExoticComponent<TextBoxProps & RefAttributes<HTMLElement>>;
375
394
 
376
- export { Alert, AlertProps, AlertSeverityProp, AnchorButton, AnchorButtonProps, Banner, BorderRadiusProp, BorderWidthProp, Box, BoxProps, Button, ButtonArea, ButtonAreaProps, ButtonProps, ButtonSizeProp, ButtonVariantProp, Container, ContainerProps, DescriptionItem, DescriptionItemProps, FileDropZone, FileDropZoneProps, FileListItem, FileListItemProps, LinkComponentProps, LinkedText, LinkedTextProps, MarginProp, MultilineText, MultilineTextProps, Navbar, NavbarAccordionOptions, NavbarAvatar, NavbarBadge, NavbarBottomBar, NavbarBottomBarItem, NavbarItem, NavbarItemOptions, NavbarItemProps, NavbarLabel, NavbarList, NavbarMenu, NavbarMenuItem, NavbarMenuItemOption, Sidebar, SidebarBackButton, SidebarContainer, SidebarContainerProps, SidebarContent, SidebarContentProps, SidebarDivider, SidebarMenuItem, SidebarMenuItemAction, SidebarMenuItemActionProps, SidebarMenuItemAvatar, SidebarMenuItemAvatarProps, SidebarMenuItemProps, SidebarProps, SidebarSubheader, SidebarSubheaderProps, TextAlignProp, TextBox, TextBoxProps, TextColorProp, TextDisplayProp, TextVariantProp, formatBytes, toBytes, useNavbarContext, useSidebarContext };
395
+ export { Alert, AlertProps, AlertSeverityProp, AnchorButton, AnchorButtonProps, Banner, BorderRadiusProp, BorderWidthProp, Box, BoxProps, Button, ButtonArea, ButtonAreaProps, ButtonProps, ButtonSizeProp, ButtonVariantProp, Chat, ChatMessage, Container, ContainerProps, DescriptionItem, DescriptionItemProps, FileDropZone, FileDropZoneProps, FileListItem, FileListItemProps, LinkComponentProps, LinkedText, LinkedTextProps, MarginProp, MultilineText, MultilineTextProps, Navbar, NavbarAccordionOptions, NavbarAvatar, NavbarBadge, NavbarBottomBar, NavbarBottomBarItem, NavbarItem, NavbarItemOptions, NavbarItemProps, NavbarLabel, NavbarList, NavbarMenu, NavbarMenuItem, NavbarMenuItemOption, Sidebar, SidebarBackButton, SidebarContainer, SidebarContainerProps, SidebarContent, SidebarContentProps, SidebarDivider, SidebarMenuItem, SidebarMenuItemAction, SidebarMenuItemActionProps, SidebarMenuItemAvatar, SidebarMenuItemAvatarProps, SidebarMenuItemProps, SidebarProps, SidebarSubheader, SidebarSubheaderProps, TextAlignProp, TextBox, TextBoxProps, TextColorProp, TextDisplayProp, TextVariantProp, formatBytes, toBytes, useNavbarContext, useSidebarContext };
package/dist-web/index.js CHANGED
@@ -1,13 +1,15 @@
1
1
  import { CheckCircle, Info, Error as Error$1, Image, Refresh, Delete, Menu, ExpandMore, MenuOpen, ArrowBack, OpenInNew } from '@material-ui/icons';
2
2
  import { Alert as Alert$1 } from '@material-ui/lab';
3
- import { Color, parseResponsiveProp, isColorProp, parseSpaceProp, Stack, mergeRefs, useUID, isEmptyReactNode, Columns, Column, Inline, CardButton, useResponsiveValue, useCollapseBreakpoint } from '@superdispatch/ui';
4
- import { forwardRef, useState, useEffect, useRef, useLayoutEffect, Suspense, memo, useContext, createContext, useMemo, createElement } from 'react';
3
+ import { Color, parseResponsiveProp, isColorProp, parseSpaceProp, Stack, Inline, mergeRefs, useUID, isEmptyReactNode, Columns, Column, CardButton, useResponsiveValue, useCollapseBreakpoint } from '@superdispatch/ui';
4
+ import { forwardRef, useState, useEffect, Children, useRef, useLayoutEffect, Suspense, memo, useContext, createContext, useMemo, createElement } from 'react';
5
5
  import styled, { css, keyframes } from 'styled-components';
6
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
7
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
8
8
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
9
9
  import { CSSTransition } from 'react-transition-group';
10
10
  import { ButtonBase, Typography, CircularProgress, SvgIcon, Link, Tooltip, IconButton, BottomNavigation, BottomNavigationAction, Accordion, AccordionSummary, useTheme, useMediaQuery, Drawer, Avatar, MenuItem, Menu as Menu$1, Toolbar, AppBar, Divider as Divider$1, Checkbox } from '@material-ui/core';
11
+ import { formatDate } from '@superdispatch/dates';
12
+ import { Box as Box$1 } from '@superdispatch/ui-lab';
11
13
  import { mdiUpload, mdiFilePdfBox, mdiTextBox } from '@mdi/js';
12
14
  import Dropzone from 'react-dropzone';
13
15
  import { Anchorme } from 'react-anchorme';
@@ -524,6 +526,89 @@ var AnchorButton = /*#__PURE__*/forwardRef((_ref5, ref) => {
524
526
  });
525
527
  if (process.env.NODE_ENV !== "production") AnchorButton.displayName = "AnchorButton";
526
528
 
529
+ var ChatContainer = /*#__PURE__*/styled('div').withConfig({
530
+ displayName: "Chat__ChatContainer",
531
+ componentId: "SD__sc-qksih8-0"
532
+ })(_ref => {
533
+ var {
534
+ isEmpty
535
+ } = _ref;
536
+ return "\n display: flex;\n flex-direction: column-reverse;\n overflow: auto;\n justify-content: ".concat(isEmpty ? 'center' : 'end', ";\n width: 100%;\n height: 100%;\n min-width: 300px;\n max-width: 560px;\n min-height: 368px;\n max-height: 696px;\n padding: 16px;\n box-sizing: border-box;\n");
537
+ });
538
+
539
+ function emptyPlaceholder(text) {
540
+ return /*#__PURE__*/jsx(Typography, {
541
+ color: "textSecondary",
542
+ align: "center",
543
+ children: text
544
+ });
545
+ }
546
+
547
+ var Chat = /*#__PURE__*/forwardRef((_ref2, ref) => {
548
+ var {
549
+ children,
550
+ className,
551
+ emptyText = 'No new messages'
552
+ } = _ref2;
553
+ var isEmpty = Children.toArray(children).length === 0;
554
+ return /*#__PURE__*/jsx(ChatContainer, {
555
+ "data-testid": "chat-container",
556
+ isEmpty: isEmpty,
557
+ ref: ref,
558
+ className: className,
559
+ children: /*#__PURE__*/jsx(Stack, {
560
+ space: "small",
561
+ children: isEmpty ? emptyPlaceholder(emptyText) : children
562
+ })
563
+ });
564
+ });
565
+ if (process.env.NODE_ENV !== "production") Chat.displayName = "Chat";
566
+ Chat.displayName = 'Chat';
567
+
568
+ var ChatMessage = /*#__PURE__*/forwardRef((_ref, ref) => {
569
+ var {
570
+ author,
571
+ role,
572
+ dateTime,
573
+ text,
574
+ variant
575
+ } = _ref;
576
+ var time = formatDate(dateTime, {
577
+ variant: 'Time'
578
+ });
579
+ return /*#__PURE__*/jsxs(Stack, {
580
+ space: "xxsmall",
581
+ align: variant === 'outgoing' ? 'right' : 'left',
582
+ ref: ref,
583
+ "data-testid": "chat-message",
584
+ children: [/*#__PURE__*/jsxs(Inline, {
585
+ verticalAlign: "center",
586
+ children: [/*#__PURE__*/jsx(Typography, {
587
+ color: "textPrimary",
588
+ children: author
589
+ }), /*#__PURE__*/jsx(Typography, {
590
+ color: "textSecondary",
591
+ children: role
592
+ }), /*#__PURE__*/jsx(Typography, {
593
+ color: "textSecondary",
594
+ children: time
595
+ })]
596
+ }), /*#__PURE__*/jsx(Box$1, {
597
+ display: "inline-block",
598
+ padding: "xsmall",
599
+ marginTop: "none",
600
+ borderRadius: "medium",
601
+ backgroundColor: variant === 'outgoing' ? 'Blue50' : 'Silver200',
602
+ children: /*#__PURE__*/jsx(Typography, {
603
+ color: "textPrimary",
604
+ children: text
605
+ })
606
+ })]
607
+ });
608
+ });
609
+ if (process.env.NODE_ENV !== "production") ChatMessage.displayName = "ChatMessage";
610
+ ChatMessage.displayName = 'ChatMessage';
611
+
527
612
  var _excluded$3 = ["fullViewportHeight"];
528
613
  var Container = /*#__PURE__*/forwardRef((_ref, ref) => {
529
614
  var {
@@ -2095,5 +2180,5 @@ var SidebarSubheader = /*#__PURE__*/forwardRef((_ref, ref) => {
2095
2180
  });
2096
2181
  if (process.env.NODE_ENV !== "production") SidebarSubheader.displayName = "SidebarSubheader";
2097
2182
 
2098
- export { Alert, AnchorButton, Banner, Box, Button, ButtonArea, Container, DescriptionItem, FileDropZone, FileListItem, LinkedText, MultilineText, Navbar, NavbarAvatar, NavbarBadge, NavbarBottomBar, NavbarItem, NavbarLabel, NavbarList, NavbarMenu, NavbarMenuItem, Sidebar, SidebarBackButton, SidebarContainer, SidebarContent, SidebarDivider, SidebarMenuItem, SidebarMenuItemAction, SidebarMenuItemAvatar, SidebarSubheader, TextBox, formatBytes, toBytes, useNavbarContext, useSidebarContext };
2183
+ export { Alert, AnchorButton, Banner, Box, Button, ButtonArea, Chat, ChatMessage, Container, DescriptionItem, FileDropZone, FileListItem, LinkedText, MultilineText, Navbar, NavbarAvatar, NavbarBadge, NavbarBottomBar, NavbarItem, NavbarLabel, NavbarList, NavbarMenu, NavbarMenuItem, Sidebar, SidebarBackButton, SidebarContainer, SidebarContent, SidebarDivider, SidebarMenuItem, SidebarMenuItemAction, SidebarMenuItemAvatar, SidebarSubheader, TextBox, formatBytes, toBytes, useNavbarContext, useSidebarContext };
2099
2184
  //# sourceMappingURL=index.js.map