@pingux/astro 2.113.0-alpha.1 → 2.113.0-alpha.2

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 (68) hide show
  1. package/lib/cjs/components/AIComponents/Response/Response.js +5 -4
  2. package/lib/cjs/components/AIComponents/Response/Response.stories.d.ts +1 -0
  3. package/lib/cjs/components/AIComponents/Response/Response.stories.js +26 -15
  4. package/lib/cjs/components/AIComponents/Response/ResponseList.js +19 -17
  5. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownContainer.d.ts +4 -0
  6. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownContainer.js +64 -0
  7. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownListWrapper.d.ts +4 -0
  8. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownListWrapper.js +37 -0
  9. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownTextContainer.d.ts +5 -0
  10. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownTextContainer.js +94 -0
  11. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownTextWrapper.d.ts +4 -0
  12. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownTextWrapper.js +63 -0
  13. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownWrapper.d.ts +4 -0
  14. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownWrapper.js +45 -0
  15. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/ResponseListItem.d.ts +4 -0
  16. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/ResponseListItem.js +64 -0
  17. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/ResponseMarkdown.d.ts +5 -0
  18. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/ResponseMarkdown.js +158 -0
  19. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/ResponseMarkdown.test.d.ts +1 -0
  20. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/ResponseMarkdown.test.js +85 -0
  21. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/index.d.ts +1 -0
  22. package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/index.js +14 -0
  23. package/lib/cjs/components/AIComponents/Response/ResponseText.js +8 -5
  24. package/lib/cjs/components/AIComponents/Response/index.d.ts +1 -0
  25. package/lib/cjs/components/AIComponents/Response/index.js +7 -0
  26. package/lib/cjs/components/Text/Text.stories.js +2 -1
  27. package/lib/cjs/hooks/useTypeAnimation/useTypeAnimation.d.ts +3 -1
  28. package/lib/cjs/hooks/useTypeAnimation/useTypeAnimation.js +3 -1
  29. package/lib/cjs/hooks/useTypeAnimation/useTypeAnimation.test.js +6 -6
  30. package/lib/cjs/hooks/useTypeAnimationWrapper/index.d.ts +1 -0
  31. package/lib/cjs/hooks/useTypeAnimationWrapper/index.js +14 -0
  32. package/lib/cjs/hooks/useTypeAnimationWrapper/useTypeAnimationWrapper.d.ts +5 -0
  33. package/lib/cjs/hooks/useTypeAnimationWrapper/useTypeAnimationWrapper.js +48 -0
  34. package/lib/cjs/hooks/useTypeAnimationWrapper/useTypeAnimationWrapper.test.d.ts +1 -0
  35. package/lib/cjs/hooks/useTypeAnimationWrapper/useTypeAnimationWrapper.test.js +93 -0
  36. package/lib/cjs/index.d.ts +1 -0
  37. package/lib/cjs/index.js +8 -0
  38. package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +39 -0
  39. package/lib/cjs/styles/themes/next-gen/variants/response.d.ts +35 -0
  40. package/lib/cjs/styles/themes/next-gen/variants/response.js +41 -3
  41. package/lib/cjs/styles/themes/next-gen/variants/text.d.ts +4 -0
  42. package/lib/cjs/styles/themes/next-gen/variants/text.js +4 -0
  43. package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +35 -0
  44. package/lib/cjs/types/response.d.ts +39 -6
  45. package/lib/components/AIComponents/Response/Response.js +5 -4
  46. package/lib/components/AIComponents/Response/Response.stories.js +23 -13
  47. package/lib/components/AIComponents/Response/ResponseList.js +19 -17
  48. package/lib/components/AIComponents/Response/ResponseMarkdown/MarkdownContainer.js +50 -0
  49. package/lib/components/AIComponents/Response/ResponseMarkdown/MarkdownListWrapper.js +29 -0
  50. package/lib/components/AIComponents/Response/ResponseMarkdown/MarkdownTextContainer.js +79 -0
  51. package/lib/components/AIComponents/Response/ResponseMarkdown/MarkdownTextWrapper.js +55 -0
  52. package/lib/components/AIComponents/Response/ResponseMarkdown/MarkdownWrapper.js +31 -0
  53. package/lib/components/AIComponents/Response/ResponseMarkdown/ResponseListItem.js +50 -0
  54. package/lib/components/AIComponents/Response/ResponseMarkdown/ResponseMarkdown.js +145 -0
  55. package/lib/components/AIComponents/Response/ResponseMarkdown/ResponseMarkdown.test.js +82 -0
  56. package/lib/components/AIComponents/Response/ResponseMarkdown/index.js +1 -0
  57. package/lib/components/AIComponents/Response/ResponseText.js +7 -4
  58. package/lib/components/AIComponents/Response/index.js +1 -0
  59. package/lib/components/Text/Text.stories.js +2 -1
  60. package/lib/hooks/useTypeAnimation/useTypeAnimation.js +3 -1
  61. package/lib/hooks/useTypeAnimation/useTypeAnimation.test.js +6 -6
  62. package/lib/hooks/useTypeAnimationWrapper/index.js +1 -0
  63. package/lib/hooks/useTypeAnimationWrapper/useTypeAnimationWrapper.js +39 -0
  64. package/lib/hooks/useTypeAnimationWrapper/useTypeAnimationWrapper.test.js +90 -0
  65. package/lib/index.js +1 -0
  66. package/lib/styles/themes/next-gen/variants/response.js +41 -3
  67. package/lib/styles/themes/next-gen/variants/text.js +4 -0
  68. package/package.json +2 -1
@@ -1320,10 +1320,14 @@ declare const _default: {
1320
1320
  fontFamily: string;
1321
1321
  fontSize: string;
1322
1322
  display: string;
1323
+ whiteSpace: string;
1323
1324
  lineHeight: string;
1324
1325
  '&.has-bullet': {
1325
1326
  display: string;
1326
1327
  };
1328
+ '&::marker': {
1329
+ color: string;
1330
+ };
1327
1331
  };
1328
1332
  };
1329
1333
  fonts: {
@@ -2661,6 +2665,19 @@ declare const _default: {
2661
2665
  minWidth: string;
2662
2666
  minHeight: string;
2663
2667
  };
2668
+ list: {
2669
+ pl: string;
2670
+ listStyleType: string;
2671
+ listStylePosition: string;
2672
+ '&.is-numeric': {
2673
+ listStyleType: string;
2674
+ };
2675
+ '& > li': {
2676
+ '&:marker': {
2677
+ content: string;
2678
+ };
2679
+ };
2680
+ };
2664
2681
  attachmentWrapper: {
2665
2682
  alignItems: string;
2666
2683
  height: string;
@@ -2678,6 +2695,28 @@ declare const _default: {
2678
2695
  display: string;
2679
2696
  };
2680
2697
  };
2698
+ markupComplexContainer: {
2699
+ display: string;
2700
+ flexDirection: string;
2701
+ '&.is-not-loaded': {
2702
+ display: string;
2703
+ };
2704
+ };
2705
+ textWrapper: {
2706
+ '&.has-bullet': {
2707
+ display: string;
2708
+ };
2709
+ '&.has-rendered': {
2710
+ display: string;
2711
+ };
2712
+ '&.has-block': {
2713
+ display: string;
2714
+ };
2715
+ '&::marker': {
2716
+ color: string;
2717
+ };
2718
+ listStylePosition: string;
2719
+ };
2681
2720
  };
2682
2721
  skeleton: {
2683
2722
  base: {
@@ -12,6 +12,19 @@ declare const _default: {
12
12
  minWidth: string;
13
13
  minHeight: string;
14
14
  };
15
+ list: {
16
+ pl: string;
17
+ listStyleType: string;
18
+ listStylePosition: string;
19
+ '&.is-numeric': {
20
+ listStyleType: string;
21
+ };
22
+ '& > li': {
23
+ '&:marker': {
24
+ content: string;
25
+ };
26
+ };
27
+ };
15
28
  attachmentWrapper: {
16
29
  alignItems: string;
17
30
  height: string;
@@ -29,5 +42,27 @@ declare const _default: {
29
42
  display: string;
30
43
  };
31
44
  };
45
+ markupComplexContainer: {
46
+ display: string;
47
+ flexDirection: string;
48
+ '&.is-not-loaded': {
49
+ display: string;
50
+ };
51
+ };
52
+ textWrapper: {
53
+ '&.has-bullet': {
54
+ display: string;
55
+ };
56
+ '&.has-rendered': {
57
+ display: string;
58
+ };
59
+ '&.has-block': {
60
+ display: string;
61
+ };
62
+ '&::marker': {
63
+ color: string;
64
+ };
65
+ listStylePosition: string;
66
+ };
32
67
  };
33
68
  export default _default;
@@ -8,7 +8,7 @@ exports["default"] = void 0;
8
8
  var iconWrapper = {
9
9
  border: '1px solid',
10
10
  p: 'xs',
11
- borderColor: 'gray-200',
11
+ borderColor: 'border.base',
12
12
  borderRadius: '50%',
13
13
  alignContent: 'center',
14
14
  alignItems: 'center',
@@ -22,7 +22,7 @@ var attachmentWrapper = {
22
22
  alignItems: 'center',
23
23
  height: '60px',
24
24
  border: '1px solid',
25
- borderColor: 'gray-200',
25
+ borderColor: 'border.base',
26
26
  p: 'md',
27
27
  gap: 'sm',
28
28
  borderRadius: '4px',
@@ -30,14 +30,52 @@ var attachmentWrapper = {
30
30
  display: 'none'
31
31
  }
32
32
  };
33
+ var markupComplexContainer = {
34
+ display: 'flex',
35
+ flexDirection: 'column',
36
+ '&.is-not-loaded': {
37
+ display: 'none'
38
+ }
39
+ };
33
40
  var toolbar = {
34
41
  '&.is-not-loaded': {
35
42
  display: 'none'
36
43
  }
37
44
  };
45
+ var list = {
46
+ pl: 'md',
47
+ listStyleType: 'disc',
48
+ listStylePosition: 'inside',
49
+ '&.is-numeric': {
50
+ listStyleType: 'decimal'
51
+ },
52
+ '& > li': {
53
+ '&:marker': {
54
+ content: '"s"'
55
+ }
56
+ }
57
+ };
58
+ var textWrapper = {
59
+ '&.has-bullet': {
60
+ display: 'list-item !important'
61
+ },
62
+ '&.has-rendered': {
63
+ display: 'list-item'
64
+ },
65
+ '&.has-block': {
66
+ display: 'block'
67
+ },
68
+ '&::marker': {
69
+ color: 'text.primary'
70
+ },
71
+ listStylePosition: 'outside'
72
+ };
38
73
  var _default = {
39
74
  iconWrapper: iconWrapper,
75
+ list: list,
40
76
  attachmentWrapper: attachmentWrapper,
41
- toolbar: toolbar
77
+ toolbar: toolbar,
78
+ markupComplexContainer: markupComplexContainer,
79
+ textWrapper: textWrapper
42
80
  };
43
81
  exports["default"] = _default;
@@ -88,9 +88,13 @@ export declare const text: {
88
88
  fontFamily: string;
89
89
  fontSize: string;
90
90
  display: string;
91
+ whiteSpace: string;
91
92
  lineHeight: string;
92
93
  '&.has-bullet': {
93
94
  display: string;
94
95
  };
96
+ '&::marker': {
97
+ color: string;
98
+ };
95
99
  };
96
100
  };
@@ -102,9 +102,13 @@ var text = _objectSpread(_objectSpread({
102
102
  fontFamily: 'standard',
103
103
  fontSize: 'md',
104
104
  display: 'block',
105
+ whiteSpace: 'pre-wrap',
105
106
  lineHeight: '1.6rem',
106
107
  '&.has-bullet': {
107
108
  display: 'list-item'
109
+ },
110
+ '&::marker': {
111
+ color: 'text.primary'
108
112
  }
109
113
  }
110
114
  }, hTags), {}, {
@@ -930,6 +930,19 @@ declare const _default: {
930
930
  minWidth: string;
931
931
  minHeight: string;
932
932
  };
933
+ list: {
934
+ pl: string;
935
+ listStyleType: string;
936
+ listStylePosition: string;
937
+ '&.is-numeric': {
938
+ listStyleType: string;
939
+ };
940
+ '& > li': {
941
+ '&:marker': {
942
+ content: string;
943
+ };
944
+ };
945
+ };
933
946
  attachmentWrapper: {
934
947
  alignItems: string;
935
948
  height: string;
@@ -947,6 +960,28 @@ declare const _default: {
947
960
  display: string;
948
961
  };
949
962
  };
963
+ markupComplexContainer: {
964
+ display: string;
965
+ flexDirection: string;
966
+ '&.is-not-loaded': {
967
+ display: string;
968
+ };
969
+ };
970
+ textWrapper: {
971
+ '&.has-bullet': {
972
+ display: string;
973
+ };
974
+ '&.has-rendered': {
975
+ display: string;
976
+ };
977
+ '&.has-block': {
978
+ display: string;
979
+ };
980
+ '&::marker': {
981
+ color: string;
982
+ };
983
+ listStylePosition: string;
984
+ };
950
985
  };
951
986
  skeleton: {
952
987
  base: {
@@ -9,10 +9,22 @@ interface SharedResponseProps {
9
9
  animationIndex?: number;
10
10
  setAnimationIndex?: (index: number) => void;
11
11
  }
12
- export interface ResponseTextProps extends SharedResponseProps, TextProps {
13
- text: string;
12
+ interface SharedWrapperProps {
13
+ stateIndex: number;
14
+ isTopLevel?: boolean;
15
+ }
16
+ interface SharedParentProps {
17
+ children: ReactNode[];
18
+ parentIndex?: number;
14
19
  delay?: number;
20
+ }
21
+ interface SharedTextProps extends TextProps {
15
22
  isListItem?: boolean;
23
+ parentIndex?: number;
24
+ delay?: number;
25
+ }
26
+ export interface ResponseTextProps extends SharedResponseProps, TextProps, SharedTextProps {
27
+ text: string;
16
28
  }
17
29
  export interface ResponseAttachmentProps extends SharedResponseProps {
18
30
  wrapperProps?: BoxProps;
@@ -22,10 +34,7 @@ export interface ResponseAttachmentProps extends SharedResponseProps {
22
34
  className?: string;
23
35
  text: string;
24
36
  }
25
- export interface ResponseListProps extends SharedResponseProps, BoxProps {
26
- children: ReactNode[];
27
- parentIndex?: number;
28
- delay?: number;
37
+ export interface ResponseListProps extends SharedResponseProps, Omit<BoxProps, 'children'>, SharedParentProps {
29
38
  }
30
39
  export interface ResponseProps extends BoxProps {
31
40
  containerProps?: BoxProps;
@@ -33,6 +42,7 @@ export interface ResponseProps extends BoxProps {
33
42
  textProps?: ResponseTextProps;
34
43
  iconWrapperProps?: IconWrapperProps;
35
44
  shouldStartAnimation?: boolean;
45
+ children: ReactNode;
36
46
  delay?: number;
37
47
  }
38
48
  export interface ResponseToolbarProps extends BoxProps, SharedResponseProps {
@@ -52,4 +62,27 @@ export interface ResponseToolbarIconProps extends IconButtonProps, SharedRespons
52
62
  parentIndex?: number;
53
63
  iconProps?: IconProps;
54
64
  }
65
+ export interface MarkdownListWrapperProps extends ResponseListProps, SharedWrapperProps {
66
+ }
67
+ export interface MarkdownTextWrapperProps extends SharedWrapperProps, SharedTextProps, SharedResponseProps {
68
+ children: ReactNode[] | string[];
69
+ parentIndex?: number;
70
+ }
71
+ export interface MarkdownTextContainerProps extends SharedResponseProps, SharedParentProps {
72
+ className?: string;
73
+ as?: string | React.ReactNode | React.ElementType;
74
+ isListItem?: boolean;
75
+ }
76
+ export interface MarkdownWrapperProps extends BoxProps, SharedWrapperProps, SharedResponseProps {
77
+ parentIndex?: number;
78
+ }
79
+ export type MarkdownContainerProps = BoxProps;
80
+ export interface ResponseListItemProps extends SharedParentProps, SharedResponseProps {
81
+ as?: string | React.ReactNode | React.ElementType;
82
+ }
83
+ export interface ResponseMarkdownContextValue {
84
+ delay?: number;
85
+ stateIndex: number;
86
+ setAnimationIndex?: (key: number) => void;
87
+ }
55
88
  export {};
@@ -10,22 +10,23 @@ var Response = function Response(props) {
10
10
  containerProps = props.containerProps,
11
11
  iconProps = props.iconProps,
12
12
  iconWrapperProps = props.iconWrapperProps,
13
- _props$delay = props.delay,
14
- delay = _props$delay === void 0 ? 10 : _props$delay;
13
+ delay = props.delay;
15
14
  var _useState = useState(0),
16
15
  _useState2 = _slicedToArray(_useState, 2),
17
16
  index = _useState2[0],
18
17
  setIndex = _useState2[1];
18
+ var responseChildren = Children.toArray(children);
19
19
  return ___EmotionJSX(Box, _extends({
20
20
  isRow: true,
21
21
  gap: "md"
22
22
  }, containerProps), ___EmotionJSX(Box, _extends({}, iconWrapperProps, {
23
23
  variant: "response.iconWrapper"
24
24
  }), ___EmotionJSX(Icon, _extends({
25
- icon: AutoAwesomeIcon
25
+ icon: AutoAwesomeIcon,
26
+ color: "text.primary"
26
27
  }, iconProps))), ___EmotionJSX(Box, {
27
28
  gap: "md"
28
- }, _mapInstanceProperty(Children).call(Children, children, function (child, i) {
29
+ }, _mapInstanceProperty(Children).call(Children, responseChildren, function (child, i) {
29
30
  return ___EmotionJSX(React.Fragment, null, /*#__PURE__*/React.cloneElement(child, {
30
31
  shouldStartAnimation: index === i,
31
32
  setAnimationIndex: setIndex,
@@ -1,4 +1,3 @@
1
- import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
1
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
3
2
  import React from 'react';
4
3
  import CopyIcon from '@pingux/mdi-react/ContentCopyIcon';
@@ -6,7 +5,7 @@ import TextIcon from '@pingux/mdi-react/TextIcon';
6
5
  import ThumbDownOutlineIcon from '@pingux/mdi-react/ThumbDownOutlineIcon';
7
6
  import ThumbUpOutlineIcon from '@pingux/mdi-react/ThumbUpOutlineIcon';
8
7
  import VolumeHighIcon from '@pingux/mdi-react/VolumeHighIcon';
9
- import { AstroWrapper, NextGenTheme } from '../../..';
8
+ import Markdown from './ResponseMarkdown/ResponseMarkdown';
10
9
  import Response from './Response';
11
10
  import ResponseAttachment from './ResponseAttachment';
12
11
  import ResponseList from './ResponseList';
@@ -36,10 +35,8 @@ export var Default = function Default(args) {
36
35
  title: 'Rephrase Answer',
37
36
  icon: TextIcon
38
37
  }];
39
- var delay = 20;
40
- return ___EmotionJSX(AstroWrapper, _extends({}, args, {
41
- themeOverrides: [NextGenTheme]
42
- }), ___EmotionJSX(Response, {
38
+ var delay = 40;
39
+ return ___EmotionJSX(Response, {
43
40
  delay: delay
44
41
  }, ___EmotionJSX(ResponseText, {
45
42
  text: testText
@@ -50,12 +47,6 @@ export var Default = function Default(args) {
50
47
  }), ___EmotionJSX(ResponseText, {
51
48
  text: testText
52
49
  }), ___EmotionJSX(ResponseList, null, ___EmotionJSX(ResponseText, {
53
- as: "h5",
54
- sx: {
55
- fontWeight: 2
56
- },
57
- text: "heading"
58
- }), ___EmotionJSX(ResponseText, {
59
50
  as: "li",
60
51
  text: "list item 1"
61
52
  }), ___EmotionJSX(ResponseText, {
@@ -68,5 +59,24 @@ export var Default = function Default(args) {
68
59
  text: "follow up text"
69
60
  }), ___EmotionJSX(ResponseToolbar, null, _mapInstanceProperty(icons).call(icons, function (icon) {
70
61
  return ___EmotionJSX(ResponseToolbarIcon, icon);
71
- }))));
62
+ })));
63
+ };
64
+
65
+ // eslint-disable-next-line no-useless-escape
66
+ var nestedMarkdown = 'The recent login activity shows successful authentication attempts for the user \"bbludis476@gmail.com\" using the \"BXRetail App\". There were no failed authentication attempts recorded. Here are the details of the successful attempts:\n\n1. **Timestamp:** 2025-02-13T09:25:55.946Z\n - **User:** bbludis476@gmail.com\n - **Action:** User Access Allowed\n - **Status:** SUCCESS\n\n2. **Timestamp:** 2025-02-13T09:25:52.377Z\n - **User:** bbludis476@gmail.com\n - **Action:** User Access Allowed\n - **Status:** SUCCESS';
67
+ var italics = '*Italics* bbludis476@gmail.com';
68
+ export var MarkdownStory = function MarkdownStory() {
69
+ return ___EmotionJSX(Response, {
70
+ delay: 20
71
+ }, ___EmotionJSX(ResponseText, {
72
+ text: "Beginning response text"
73
+ }), ___EmotionJSX(Markdown, {
74
+ str: nestedMarkdown
75
+ }), ___EmotionJSX(ResponseText, {
76
+ text: "Follow up response text "
77
+ }), ___EmotionJSX(Markdown, {
78
+ str: italics
79
+ }), ___EmotionJSX(ResponseText, {
80
+ text: "Final response text "
81
+ }));
72
82
  };
@@ -1,9 +1,7 @@
1
- import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
2
1
  import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
3
- var _excluded = ["children", "parentIndex", "setAnimationIndex", "shouldStartAnimation", "delay"];
4
2
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
5
- import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
6
3
  import React, { Children, useEffect, useState } from 'react';
4
+ import { useStatusClasses } from '../../../hooks';
7
5
  import { Box } from '../../../index';
8
6
  import { jsx as ___EmotionJSX } from "@emotion/react";
9
7
  var ResponseList = function ResponseList(props) {
@@ -16,9 +14,9 @@ var ResponseList = function ResponseList(props) {
16
14
  setAnimationIndex = props.setAnimationIndex,
17
15
  shouldStartAnimation = props.shouldStartAnimation,
18
16
  delay = props.delay,
19
- others = _objectWithoutProperties(props, _excluded);
17
+ asProp = props.as;
20
18
  useEffect(function () {
21
- if (children && setAnimationIndex && index === children.length && parentIndex) {
19
+ if (children && setAnimationIndex && index === children.length && parentIndex !== undefined) {
22
20
  setAnimationIndex(parentIndex + 1);
23
21
  }
24
22
  }, [index]);
@@ -27,26 +25,30 @@ var ResponseList = function ResponseList(props) {
27
25
  setIndex(0);
28
26
  }
29
27
  }, [shouldStartAnimation]);
30
- return ___EmotionJSX(Box, others, ___EmotionJSX(React.Fragment, null, /*#__PURE__*/React.cloneElement(children[0], {
31
- shouldStartAnimation: index === 0,
32
- setAnimationIndex: setIndex,
33
- animationIndex: 0,
34
- delay: delay
35
- })), ___EmotionJSX(Box, {
36
- as: "ul",
28
+ var isNumeric = asProp === 'ol';
29
+ var _useStatusClasses = useStatusClasses('', {
30
+ isNumeric: isNumeric
31
+ }),
32
+ classNames = _useStatusClasses.classNames;
33
+ return ___EmotionJSX(Box, {
34
+ as: asProp,
35
+ variant: "response.list",
36
+ className: classNames,
37
37
  sx: {
38
38
  pl: 'md',
39
39
  listStyleType: 'disc',
40
40
  listStylePosition: 'inside'
41
41
  }
42
- }, _mapInstanceProperty(Children).call(Children, _sliceInstanceProperty(children).call(children, 1, children.length), function (child, i) {
42
+ }, _mapInstanceProperty(Children).call(Children, children, function (child, i) {
43
43
  return /*#__PURE__*/React.cloneElement(child, {
44
- shouldStartAnimation: index === i + 1,
44
+ shouldStartAnimation: index === i,
45
45
  setAnimationIndex: setIndex,
46
- animationIndex: i + 1,
46
+ animationIndex: i,
47
47
  delay: delay,
48
- isListItem: true
48
+ isListItem: /*#__PURE__*/React.isValidElement(child) && child.props.as && child.props.as !== 'p',
49
+ parentIndex: index,
50
+ as: 'li'
49
51
  });
50
- })));
52
+ }));
51
53
  };
52
54
  export default ResponseList;
@@ -0,0 +1,50 @@
1
+ import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
2
+ var _excluded = ["children"];
3
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
4
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
5
+ import React, { Children, useContext } from 'react';
6
+ import Box from '../../../Box';
7
+ import MarkdownTextWrapper from './MarkdownTextWrapper';
8
+ import { ResponseMarkdownContext } from './ResponseMarkdown';
9
+ import { jsx as ___EmotionJSX } from "@emotion/react";
10
+ var blockElements = ['div', 'ul', 'ol'];
11
+ var checkContainsBlocks = function checkContainsBlocks(containerChildren) {
12
+ for (var i = 0; i < containerChildren.length; i += 1) {
13
+ var _containerChildren$i;
14
+ if (_includesInstanceProperty(blockElements).call(blockElements, (_containerChildren$i = containerChildren[i]) === null || _containerChildren$i === void 0 || (_containerChildren$i = _containerChildren$i.props) === null || _containerChildren$i === void 0 ? void 0 : _containerChildren$i.as)) {
15
+ return true;
16
+ }
17
+ }
18
+ return false;
19
+ };
20
+ var MarkdownContainer = function MarkdownContainer(props) {
21
+ var children = props.children,
22
+ others = _objectWithoutProperties(props, _excluded);
23
+ var _useContext = useContext(ResponseMarkdownContext),
24
+ setAnimationIndex = _useContext.setAnimationIndex,
25
+ stateIndex = _useContext.stateIndex,
26
+ delay = _useContext.delay;
27
+ var containerChildren = Children.toArray(children);
28
+ var containsBlocks = checkContainsBlocks(containerChildren);
29
+ if (containsBlocks) {
30
+ return ___EmotionJSX(Box, others, _mapInstanceProperty(Children).call(Children, containerChildren, function (child, i) {
31
+ return /*#__PURE__*/React.cloneElement(child, {
32
+ animationIndex: i,
33
+ isTopLevel: true,
34
+ isListItem: false,
35
+ parentIndex: stateIndex,
36
+ stateIndex: stateIndex
37
+ });
38
+ }));
39
+ }
40
+ return ___EmotionJSX(Box, others, ___EmotionJSX(MarkdownTextWrapper, {
41
+ animationIndex: 0,
42
+ isTopLevel: true,
43
+ delay: delay,
44
+ setAnimationIndex: setAnimationIndex,
45
+ parentIndex: stateIndex,
46
+ stateIndex: stateIndex,
47
+ isListItem: false
48
+ }, containerChildren));
49
+ };
50
+ export default MarkdownContainer;
@@ -0,0 +1,29 @@
1
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
2
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
3
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
4
+ import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
5
+ import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
6
+ import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
7
+ import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
8
+ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
9
+ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
10
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
11
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
13
+ import React from 'react';
14
+ import useTypeAnimationWrapper from '../../../../hooks/useTypeAnimationWrapper/useTypeAnimationWrapper';
15
+ import ResponseList from '../ResponseList';
16
+ import { jsx as ___EmotionJSX } from "@emotion/react";
17
+ var MarkdownListWrapper = function MarkdownListWrapper(props) {
18
+ var isTopLevel = props.isTopLevel,
19
+ stateIndex = props.stateIndex,
20
+ parentIndex = props.parentIndex,
21
+ children = props.children;
22
+ var _useTypeAnimationWrap = useTypeAnimationWrapper(_objectSpread({}, props)),
23
+ shouldStart = _useTypeAnimationWrap.shouldStart;
24
+ return ___EmotionJSX(ResponseList, _extends({}, props, {
25
+ parentIndex: isTopLevel ? stateIndex : parentIndex,
26
+ shouldStartAnimation: shouldStart
27
+ }), children);
28
+ };
29
+ export default MarkdownListWrapper;
@@ -0,0 +1,79 @@
1
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
2
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
3
+ import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
4
+ import React, { Children, useEffect, useState } from 'react';
5
+ import { useStatusClasses } from '../../../../hooks';
6
+ import Box from '../../../Box';
7
+ import ResponseText from '../ResponseText';
8
+ import { jsx as ___EmotionJSX } from "@emotion/react";
9
+ export var checkForJSXChild = function checkForJSXChild(children) {
10
+ for (var i = 0; i < children.length; i += 1) {
11
+ if (typeof children[i] !== 'string') {
12
+ return true;
13
+ }
14
+ }
15
+ return false;
16
+ };
17
+ var MarkdownTextContainer = function MarkdownTextContainer(props) {
18
+ var _useState = useState(-1),
19
+ _useState2 = _slicedToArray(_useState, 2),
20
+ index = _useState2[0],
21
+ setIndex = _useState2[1];
22
+ var children = props.children,
23
+ parentIndex = props.parentIndex,
24
+ setAnimationIndex = props.setAnimationIndex,
25
+ shouldStartAnimation = props.shouldStartAnimation,
26
+ delay = props.delay,
27
+ className = props.className,
28
+ isListItem = props.isListItem,
29
+ as = props.as;
30
+ useEffect(function () {
31
+ if (children && setAnimationIndex && index === children.length && parentIndex !== undefined) {
32
+ setAnimationIndex(parentIndex + 1);
33
+ }
34
+ }, [index]);
35
+ useEffect(function () {
36
+ if (shouldStartAnimation) {
37
+ setIndex(0);
38
+ }
39
+ }, [shouldStartAnimation]);
40
+ var hasBullet = index >= 0 && isListItem === true;
41
+
42
+ // this is to force the bullets to render correctly in safari.
43
+ var hasRendered = index !== 1 && isListItem === true;
44
+ var hasBlock = index === -1;
45
+ var _useStatusClasses = useStatusClasses(className, {
46
+ hasBullet: hasBullet,
47
+ hasRendered: hasRendered,
48
+ hasBlock: hasBlock
49
+ }),
50
+ classNames = _useStatusClasses.classNames;
51
+ var markdownTextChildren = Children.toArray(children);
52
+ var hasNonStringChild = checkForJSXChild(markdownTextChildren);
53
+ return ___EmotionJSX(Box, {
54
+ className: classNames,
55
+ variant: "response.textWrapper",
56
+ as: hasNonStringChild ? 'div' : as
57
+ }, ___EmotionJSX(Box, {
58
+ isRow: true
59
+ }, _mapInstanceProperty(Children).call(Children, _sliceInstanceProperty(markdownTextChildren).call(markdownTextChildren, 0, index + 1), function (child, i) {
60
+ if (typeof child === 'string') {
61
+ return ___EmotionJSX(ResponseText, {
62
+ text: child,
63
+ shouldStartAnimation: index === i,
64
+ setAnimationIndex: setIndex,
65
+ animationIndex: i,
66
+ delay: delay,
67
+ parentIndex: index
68
+ });
69
+ }
70
+ return /*#__PURE__*/React.cloneElement(child, {
71
+ shouldStartAnimation: index === i,
72
+ setAnimationIndex: setIndex,
73
+ animationIndex: i,
74
+ delay: delay,
75
+ parentIndex: index
76
+ });
77
+ })));
78
+ };
79
+ export default MarkdownTextContainer;