@pingux/astro 2.113.0-alpha.0 → 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.
- package/lib/cjs/components/AIComponents/Response/Response.js +5 -4
- package/lib/cjs/components/AIComponents/Response/Response.stories.d.ts +1 -0
- package/lib/cjs/components/AIComponents/Response/Response.stories.js +26 -15
- package/lib/cjs/components/AIComponents/Response/ResponseList.js +19 -17
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownContainer.d.ts +4 -0
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownContainer.js +64 -0
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownListWrapper.d.ts +4 -0
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownListWrapper.js +37 -0
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownTextContainer.d.ts +5 -0
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownTextContainer.js +94 -0
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownTextWrapper.d.ts +4 -0
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownTextWrapper.js +63 -0
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownWrapper.d.ts +4 -0
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/MarkdownWrapper.js +45 -0
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/ResponseListItem.d.ts +4 -0
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/ResponseListItem.js +64 -0
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/ResponseMarkdown.d.ts +5 -0
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/ResponseMarkdown.js +158 -0
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/ResponseMarkdown.test.d.ts +1 -0
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/ResponseMarkdown.test.js +85 -0
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/index.d.ts +1 -0
- package/lib/cjs/components/AIComponents/Response/ResponseMarkdown/index.js +14 -0
- package/lib/cjs/components/AIComponents/Response/ResponseText.js +8 -5
- package/lib/cjs/components/AIComponents/Response/index.d.ts +1 -0
- package/lib/cjs/components/AIComponents/Response/index.js +7 -0
- package/lib/cjs/components/Text/Text.stories.js +2 -1
- package/lib/cjs/hooks/useTypeAnimation/useTypeAnimation.d.ts +3 -1
- package/lib/cjs/hooks/useTypeAnimation/useTypeAnimation.js +3 -1
- package/lib/cjs/hooks/useTypeAnimation/useTypeAnimation.test.js +6 -6
- package/lib/cjs/hooks/useTypeAnimationWrapper/index.d.ts +1 -0
- package/lib/cjs/hooks/useTypeAnimationWrapper/index.js +14 -0
- package/lib/cjs/hooks/useTypeAnimationWrapper/useTypeAnimationWrapper.d.ts +5 -0
- package/lib/cjs/hooks/useTypeAnimationWrapper/useTypeAnimationWrapper.js +48 -0
- package/lib/cjs/hooks/useTypeAnimationWrapper/useTypeAnimationWrapper.test.d.ts +1 -0
- package/lib/cjs/hooks/useTypeAnimationWrapper/useTypeAnimationWrapper.test.js +93 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +8 -0
- package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +39 -0
- package/lib/cjs/styles/themes/next-gen/variants/response.d.ts +35 -0
- package/lib/cjs/styles/themes/next-gen/variants/response.js +41 -3
- package/lib/cjs/styles/themes/next-gen/variants/text.d.ts +4 -0
- package/lib/cjs/styles/themes/next-gen/variants/text.js +4 -0
- package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +35 -0
- package/lib/cjs/types/response.d.ts +39 -6
- package/lib/components/AIComponents/Response/Response.js +5 -4
- package/lib/components/AIComponents/Response/Response.stories.js +23 -13
- package/lib/components/AIComponents/Response/ResponseList.js +19 -17
- package/lib/components/AIComponents/Response/ResponseMarkdown/MarkdownContainer.js +50 -0
- package/lib/components/AIComponents/Response/ResponseMarkdown/MarkdownListWrapper.js +29 -0
- package/lib/components/AIComponents/Response/ResponseMarkdown/MarkdownTextContainer.js +79 -0
- package/lib/components/AIComponents/Response/ResponseMarkdown/MarkdownTextWrapper.js +55 -0
- package/lib/components/AIComponents/Response/ResponseMarkdown/MarkdownWrapper.js +31 -0
- package/lib/components/AIComponents/Response/ResponseMarkdown/ResponseListItem.js +50 -0
- package/lib/components/AIComponents/Response/ResponseMarkdown/ResponseMarkdown.js +145 -0
- package/lib/components/AIComponents/Response/ResponseMarkdown/ResponseMarkdown.test.js +82 -0
- package/lib/components/AIComponents/Response/ResponseMarkdown/index.js +1 -0
- package/lib/components/AIComponents/Response/ResponseText.js +7 -4
- package/lib/components/AIComponents/Response/index.js +1 -0
- package/lib/components/Text/Text.stories.js +2 -1
- package/lib/hooks/useTypeAnimation/useTypeAnimation.js +3 -1
- package/lib/hooks/useTypeAnimation/useTypeAnimation.test.js +6 -6
- package/lib/hooks/useTypeAnimationWrapper/index.js +1 -0
- package/lib/hooks/useTypeAnimationWrapper/useTypeAnimationWrapper.js +39 -0
- package/lib/hooks/useTypeAnimationWrapper/useTypeAnimationWrapper.test.js +90 -0
- package/lib/index.js +1 -0
- package/lib/styles/themes/next-gen/variants/response.js +41 -3
- package/lib/styles/themes/next-gen/variants/text.js +4 -0
- package/package.json +2 -1
@@ -0,0 +1,55 @@
|
|
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
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
12
|
+
var _excluded = ["as", "children", "isTopLevel", "stateIndex", "isListItem", "parentIndex"];
|
13
|
+
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; }
|
14
|
+
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; }
|
15
|
+
import React from 'react';
|
16
|
+
import useTypeAnimationWrapper from '../../../../hooks/useTypeAnimationWrapper';
|
17
|
+
import ResponseText from '../ResponseText';
|
18
|
+
import MarkdownTextContainer from './MarkdownTextContainer';
|
19
|
+
import ResponseListItem from './ResponseListItem';
|
20
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
21
|
+
var MarkdownTextWrapper = function MarkdownTextWrapper(props) {
|
22
|
+
var as = props.as,
|
23
|
+
children = props.children,
|
24
|
+
isTopLevel = props.isTopLevel,
|
25
|
+
stateIndex = props.stateIndex,
|
26
|
+
isListItem = props.isListItem,
|
27
|
+
parentIndex = props.parentIndex,
|
28
|
+
others = _objectWithoutProperties(props, _excluded);
|
29
|
+
var _useTypeAnimationWrap = useTypeAnimationWrapper(_objectSpread({}, props)),
|
30
|
+
shouldStart = _useTypeAnimationWrap.shouldStart,
|
31
|
+
hasList = _useTypeAnimationWrap.hasList;
|
32
|
+
if (hasList) {
|
33
|
+
return ___EmotionJSX(ResponseListItem, _extends({}, props, {
|
34
|
+
shouldStartAnimation: shouldStart
|
35
|
+
}));
|
36
|
+
}
|
37
|
+
if (children && children.length > 1) {
|
38
|
+
return ___EmotionJSX(MarkdownTextContainer, _extends({}, props, {
|
39
|
+
shouldStartAnimation: shouldStart,
|
40
|
+
parentIndex: isTopLevel ? stateIndex : parentIndex,
|
41
|
+
setAnimationIndex: props.setAnimationIndex
|
42
|
+
}), children);
|
43
|
+
}
|
44
|
+
if (typeof children[0] === 'string') {
|
45
|
+
return ___EmotionJSX(ResponseText, _extends({}, others, {
|
46
|
+
as: as,
|
47
|
+
isListItem: isListItem,
|
48
|
+
shouldStartAnimation: shouldStart,
|
49
|
+
parentIndex: isTopLevel ? stateIndex : parentIndex,
|
50
|
+
text: children[0]
|
51
|
+
}));
|
52
|
+
}
|
53
|
+
return null;
|
54
|
+
};
|
55
|
+
export default MarkdownTextWrapper;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
3
|
+
var _excluded = ["setAnimationIndex", "parentIndex", "className", "animationIndex", "shouldStartAnimation"];
|
4
|
+
import React, { useEffect, useRef } from 'react';
|
5
|
+
import { useStatusClasses } from '../../../../hooks';
|
6
|
+
import { Box } from '../../../../index';
|
7
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
8
|
+
var MarkdownWrapper = function MarkdownWrapper(props) {
|
9
|
+
var setAnimationIndex = props.setAnimationIndex,
|
10
|
+
parentIndex = props.parentIndex,
|
11
|
+
className = props.className,
|
12
|
+
animationIndex = props.animationIndex,
|
13
|
+
shouldStartAnimation = props.shouldStartAnimation,
|
14
|
+
others = _objectWithoutProperties(props, _excluded);
|
15
|
+
var isLoaded = useRef(false);
|
16
|
+
useEffect(function () {
|
17
|
+
if (shouldStartAnimation && setAnimationIndex && animationIndex !== undefined && isLoaded.current === false) {
|
18
|
+
isLoaded.current = true;
|
19
|
+
setAnimationIndex(animationIndex + 1);
|
20
|
+
}
|
21
|
+
}, [setAnimationIndex, parentIndex, animationIndex, shouldStartAnimation]);
|
22
|
+
var _useStatusClasses = useStatusClasses(className, {
|
23
|
+
isNotLoaded: !isLoaded.current
|
24
|
+
}),
|
25
|
+
classNames = _useStatusClasses.classNames;
|
26
|
+
return ___EmotionJSX(Box, _extends({}, others, {
|
27
|
+
className: classNames,
|
28
|
+
variant: "response.markupComplexContainer"
|
29
|
+
}), props.children);
|
30
|
+
};
|
31
|
+
export default MarkdownWrapper;
|
@@ -0,0 +1,50 @@
|
|
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 { Box } from '../../../../index';
|
6
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
7
|
+
var ResponseListItem = function ResponseListItem(props) {
|
8
|
+
var _useState = useState(-1),
|
9
|
+
_useState2 = _slicedToArray(_useState, 2),
|
10
|
+
index = _useState2[0],
|
11
|
+
setIndex = _useState2[1];
|
12
|
+
var children = props.children,
|
13
|
+
parentIndex = props.parentIndex,
|
14
|
+
setAnimationIndex = props.setAnimationIndex,
|
15
|
+
shouldStartAnimation = props.shouldStartAnimation,
|
16
|
+
delay = props.delay,
|
17
|
+
as = props.as;
|
18
|
+
useEffect(function () {
|
19
|
+
if (children && setAnimationIndex && index === children.length && parentIndex !== undefined) {
|
20
|
+
setAnimationIndex(parentIndex + 1);
|
21
|
+
}
|
22
|
+
}, [index]);
|
23
|
+
useEffect(function () {
|
24
|
+
if (shouldStartAnimation) {
|
25
|
+
setIndex(0);
|
26
|
+
}
|
27
|
+
}, [shouldStartAnimation]);
|
28
|
+
return ___EmotionJSX(Box, {
|
29
|
+
as: as
|
30
|
+
}, _mapInstanceProperty(Children).call(Children, _sliceInstanceProperty(children).call(children, 0, 1), function (child, i) {
|
31
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
32
|
+
shouldStartAnimation: index === i,
|
33
|
+
setAnimationIndex: setIndex,
|
34
|
+
animationIndex: i,
|
35
|
+
delay: delay,
|
36
|
+
isListItem: true,
|
37
|
+
parentIndex: index
|
38
|
+
});
|
39
|
+
}), _mapInstanceProperty(Children).call(Children, _sliceInstanceProperty(children).call(children, 1, children.length), function (child, i) {
|
40
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
41
|
+
shouldStartAnimation: index === i + 1,
|
42
|
+
setAnimationIndex: setIndex,
|
43
|
+
animationIndex: i + 1,
|
44
|
+
delay: delay,
|
45
|
+
isListItem: true,
|
46
|
+
parentIndex: index
|
47
|
+
});
|
48
|
+
}));
|
49
|
+
};
|
50
|
+
export default ResponseListItem;
|
@@ -0,0 +1,145 @@
|
|
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 _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
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, { createContext, useCallback, useEffect, useMemo, useState } from 'react';
|
14
|
+
import { compiler } from 'markdown-to-jsx';
|
15
|
+
import MarkdownContainer from './MarkdownContainer';
|
16
|
+
import MarkdownListWrapper from './MarkdownListWrapper';
|
17
|
+
import MarkdownTextWrapper from './MarkdownTextWrapper';
|
18
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
19
|
+
export var ResponseMarkdownContext = /*#__PURE__*/createContext({
|
20
|
+
stateIndex: -1
|
21
|
+
});
|
22
|
+
var ResponseMarkdown = function ResponseMarkdown(componentProps) {
|
23
|
+
var _useState = useState(-1),
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
25
|
+
index = _useState2[0],
|
26
|
+
setIndex = _useState2[1];
|
27
|
+
var parentIndex = componentProps.parentIndex,
|
28
|
+
setAnimationIndex = componentProps.setAnimationIndex,
|
29
|
+
shouldStartAnimation = componentProps.shouldStartAnimation,
|
30
|
+
delay = componentProps.delay,
|
31
|
+
str = componentProps.str;
|
32
|
+
useEffect(function () {
|
33
|
+
if (shouldStartAnimation) {
|
34
|
+
setIndex(0);
|
35
|
+
}
|
36
|
+
}, [shouldStartAnimation]);
|
37
|
+
var commonProps = {
|
38
|
+
setAnimationIndex: setIndex,
|
39
|
+
delay: delay,
|
40
|
+
parentIndex: index,
|
41
|
+
stateIndex: index
|
42
|
+
};
|
43
|
+
var markdown = compiler(str, {
|
44
|
+
wrapper: MarkdownContainer,
|
45
|
+
forceWrapper: true,
|
46
|
+
overrides: {
|
47
|
+
h1: {
|
48
|
+
component: MarkdownTextWrapper,
|
49
|
+
props: _objectSpread({}, commonProps)
|
50
|
+
},
|
51
|
+
h2: {
|
52
|
+
component: MarkdownTextWrapper,
|
53
|
+
props: _objectSpread({}, commonProps)
|
54
|
+
},
|
55
|
+
h3: {
|
56
|
+
component: MarkdownTextWrapper,
|
57
|
+
props: _objectSpread({}, commonProps)
|
58
|
+
},
|
59
|
+
h4: {
|
60
|
+
component: MarkdownTextWrapper,
|
61
|
+
props: _objectSpread({}, commonProps)
|
62
|
+
},
|
63
|
+
h5: {
|
64
|
+
component: MarkdownTextWrapper,
|
65
|
+
props: _objectSpread({}, commonProps)
|
66
|
+
},
|
67
|
+
h6: {
|
68
|
+
component: MarkdownTextWrapper,
|
69
|
+
props: _objectSpread({}, commonProps)
|
70
|
+
},
|
71
|
+
p: {
|
72
|
+
component: MarkdownTextWrapper,
|
73
|
+
props: _objectSpread(_objectSpread({}, commonProps), {}, {
|
74
|
+
as: 'p'
|
75
|
+
})
|
76
|
+
},
|
77
|
+
li: {
|
78
|
+
component: MarkdownTextWrapper,
|
79
|
+
props: {
|
80
|
+
setAnimationIndex: setIndex,
|
81
|
+
delay: delay,
|
82
|
+
as: 'li'
|
83
|
+
}
|
84
|
+
},
|
85
|
+
ul: {
|
86
|
+
component: MarkdownListWrapper,
|
87
|
+
props: {
|
88
|
+
setAnimationIndex: setIndex,
|
89
|
+
delay: delay,
|
90
|
+
stateIndex: index,
|
91
|
+
as: 'ul'
|
92
|
+
}
|
93
|
+
},
|
94
|
+
strong: {
|
95
|
+
component: MarkdownTextWrapper,
|
96
|
+
props: _objectSpread(_objectSpread({}, commonProps), {}, {
|
97
|
+
as: 'strong'
|
98
|
+
})
|
99
|
+
},
|
100
|
+
em: {
|
101
|
+
component: MarkdownTextWrapper,
|
102
|
+
props: _objectSpread(_objectSpread({}, commonProps), {}, {
|
103
|
+
as: 'em'
|
104
|
+
})
|
105
|
+
},
|
106
|
+
i: {
|
107
|
+
component: MarkdownTextWrapper,
|
108
|
+
props: {
|
109
|
+
setAnimationIndex: setIndex,
|
110
|
+
delay: delay,
|
111
|
+
stateIndex: index,
|
112
|
+
as: 'i'
|
113
|
+
}
|
114
|
+
},
|
115
|
+
ol: {
|
116
|
+
component: MarkdownListWrapper,
|
117
|
+
props: {
|
118
|
+
setAnimationIndex: setIndex,
|
119
|
+
delay: delay,
|
120
|
+
stateIndex: index,
|
121
|
+
as: 'ol'
|
122
|
+
}
|
123
|
+
}
|
124
|
+
}
|
125
|
+
});
|
126
|
+
useEffect(function () {
|
127
|
+
if (index === markdown.props.children.length) {
|
128
|
+
setAnimationIndex(parentIndex + 1);
|
129
|
+
}
|
130
|
+
}, [index, markdown.props.children.length]);
|
131
|
+
var setAnimationCallback = useCallback(function (val) {
|
132
|
+
setIndex(val);
|
133
|
+
}, [index, setIndex]);
|
134
|
+
var contextValues = useMemo(function () {
|
135
|
+
return {
|
136
|
+
setAnimationIndex: setAnimationCallback,
|
137
|
+
stateIndex: index,
|
138
|
+
delay: delay
|
139
|
+
};
|
140
|
+
}, [setAnimationCallback, index, delay]);
|
141
|
+
return ___EmotionJSX(ResponseMarkdownContext.Provider, {
|
142
|
+
value: contextValues
|
143
|
+
}, markdown);
|
144
|
+
};
|
145
|
+
export default ResponseMarkdown;
|
@@ -0,0 +1,82 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import React from 'react';
|
3
|
+
import { act, render, screen } from '../../../../utils/testUtils/testWrapper';
|
4
|
+
import Response from '../Response';
|
5
|
+
import ResponseMarkdown from './ResponseMarkdown';
|
6
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
7
|
+
var markdownString = '#Heading\n\n1. First item\n\n - Unordered item\n\n **bold**:not bold';
|
8
|
+
var italics = '*Italics* regular';
|
9
|
+
var secondMarkDownString = 'begin\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 - **What:** SUCCESS';
|
10
|
+
var getComponent = function getComponent() {
|
11
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
12
|
+
return render(___EmotionJSX(Response, _extends({}, props, {
|
13
|
+
delay: 10
|
14
|
+
}), ___EmotionJSX(ResponseMarkdown, {
|
15
|
+
str: markdownString
|
16
|
+
})));
|
17
|
+
};
|
18
|
+
var getComponentWithNesting = function getComponentWithNesting() {
|
19
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
20
|
+
return render(___EmotionJSX(Response, _extends({}, props, {
|
21
|
+
delay: 10
|
22
|
+
}), ___EmotionJSX(ResponseMarkdown, {
|
23
|
+
str: secondMarkDownString
|
24
|
+
})));
|
25
|
+
};
|
26
|
+
var getComponentItalics = function getComponentItalics() {
|
27
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
28
|
+
return render(___EmotionJSX(Response, _extends({}, props, {
|
29
|
+
delay: 10
|
30
|
+
}), ___EmotionJSX(ResponseMarkdown, {
|
31
|
+
str: italics
|
32
|
+
})));
|
33
|
+
};
|
34
|
+
beforeEach(function () {
|
35
|
+
jest.useFakeTimers();
|
36
|
+
});
|
37
|
+
test('renders markdown content correctly', function () {
|
38
|
+
getComponent();
|
39
|
+
for (var i = 0; i < 8 + 1; i += 1) {
|
40
|
+
act(function () {
|
41
|
+
jest.advanceTimersByTime(10);
|
42
|
+
});
|
43
|
+
}
|
44
|
+
expect(screen.queryByText('Heading')).toBeInTheDocument();
|
45
|
+
for (var _i = 0; _i < 10 + 1; _i += 1) {
|
46
|
+
act(function () {
|
47
|
+
jest.advanceTimersByTime(10);
|
48
|
+
});
|
49
|
+
}
|
50
|
+
expect(screen.getByText('First item')).toBeInTheDocument();
|
51
|
+
for (var _i2 = 0; _i2 < 15; _i2 += 1) {
|
52
|
+
act(function () {
|
53
|
+
jest.advanceTimersByTime(10);
|
54
|
+
});
|
55
|
+
}
|
56
|
+
expect(screen.getByText('Unordered item')).toBeInTheDocument();
|
57
|
+
for (var _i3 = 0; _i3 < 13; _i3 += 1) {
|
58
|
+
act(function () {
|
59
|
+
jest.advanceTimersByTime(10);
|
60
|
+
});
|
61
|
+
}
|
62
|
+
expect(screen.getByText('bold')).toBeInTheDocument();
|
63
|
+
expect(screen.getByText(':not bold')).toBeInTheDocument();
|
64
|
+
});
|
65
|
+
test('renders nested markdown content correctly', function () {
|
66
|
+
getComponentWithNesting();
|
67
|
+
for (var i = 0; i < 300; i += 1) {
|
68
|
+
act(function () {
|
69
|
+
jest.advanceTimersByTime(10);
|
70
|
+
});
|
71
|
+
}
|
72
|
+
expect(screen.getByText('What:')).toBeInTheDocument();
|
73
|
+
});
|
74
|
+
test('renders nested markdown content correctly', function () {
|
75
|
+
getComponentItalics();
|
76
|
+
for (var i = 0; i < 15; i += 1) {
|
77
|
+
act(function () {
|
78
|
+
jest.advanceTimersByTime(10);
|
79
|
+
});
|
80
|
+
}
|
81
|
+
expect(screen.getByText('Italics')).toBeInTheDocument();
|
82
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './ResponseMarkdown';
|
@@ -7,7 +7,8 @@ import useTypeAnimation from '../../../hooks/useTypeAnimation/useTypeAnimation';
|
|
7
7
|
import { Text } from '../../../index';
|
8
8
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
9
9
|
var ResponseText = function ResponseText(props) {
|
10
|
-
var delay = props.delay,
|
10
|
+
var _props$delay = props.delay,
|
11
|
+
delay = _props$delay === void 0 ? 10 : _props$delay,
|
11
12
|
text = props.text,
|
12
13
|
shouldStartAnimation = props.shouldStartAnimation,
|
13
14
|
setAnimationIndex = props.setAnimationIndex,
|
@@ -22,16 +23,18 @@ var ResponseText = function ResponseText(props) {
|
|
22
23
|
animationIndex: animationIndex,
|
23
24
|
shouldStartAnimation: shouldStartAnimation
|
24
25
|
};
|
25
|
-
var
|
26
|
-
|
26
|
+
var _useTypeAnimation = useTypeAnimation(animationProps),
|
27
|
+
currentText = _useTypeAnimation.currentText;
|
28
|
+
var hasBullet = isListItem === true && currentText.length > 0;
|
27
29
|
var _useStatusClasses = useStatusClasses(className, {
|
28
30
|
hasBullet: hasBullet
|
29
31
|
}),
|
30
32
|
classNames = _useStatusClasses.classNames;
|
33
|
+
var renderText = "".concat(currentText);
|
31
34
|
return ___EmotionJSX(Text, _extends({}, others, {
|
32
35
|
role: isListItem ? 'listitem' : '',
|
33
36
|
variant: "response",
|
34
37
|
className: classNames
|
35
|
-
}),
|
38
|
+
}), renderText);
|
36
39
|
};
|
37
40
|
export default ResponseText;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
export { default } from './Response';
|
2
2
|
export { default as ResponseAttachment } from './ResponseAttachment';
|
3
3
|
export { default as ResponseList } from './ResponseList';
|
4
|
+
export { default as ResponseMarkdown } from './ResponseMarkdown';
|
4
5
|
export { default as ResponseText } from './ResponseText';
|
5
6
|
export { default as ResponseToolbar } from './ResponseToolbar';
|
6
7
|
export { default as ResponseToolbarIcon } from './ResponseToolbarIcon';
|
@@ -420,7 +420,8 @@ export var CustomWidth = function CustomWidth() {
|
|
420
420
|
return ___EmotionJSX(Box, {
|
421
421
|
width: 200
|
422
422
|
}, ___EmotionJSX(Text, {
|
423
|
-
p: "xl"
|
423
|
+
p: "xl",
|
424
|
+
color: "text.secondary"
|
424
425
|
}, "superlongtextinonelinewithnowhitespacessoitcanbelongerthatanywidth"));
|
425
426
|
};
|
426
427
|
export var CustomStyle = function CustomStyle() {
|
@@ -36,6 +36,8 @@ var useTypeAnimation = function useTypeAnimation(_ref) {
|
|
36
36
|
return null;
|
37
37
|
};
|
38
38
|
}, [currentIndex, delay, text, shouldStartAnimation, setAnimationIndex, animationIndex]);
|
39
|
-
return
|
39
|
+
return {
|
40
|
+
currentText: currentText
|
41
|
+
};
|
40
42
|
};
|
41
43
|
export default useTypeAnimation;
|
@@ -35,14 +35,14 @@ describe('useTypeAnimation', function () {
|
|
35
35
|
return useTypeAnimation(defaultProps);
|
36
36
|
}),
|
37
37
|
result = _renderHook.result;
|
38
|
-
expect(result.current).toBe('');
|
38
|
+
expect(result.current.currentText).toBe('');
|
39
39
|
for (var i = 0; i < text.length; i += 1) {
|
40
40
|
act(function () {
|
41
41
|
jest.advanceTimersByTime(delay);
|
42
42
|
});
|
43
|
-
expect(result.current).toBe(_sliceInstanceProperty(text).call(text, 0, i + 1));
|
43
|
+
expect(result.current.currentText).toBe(_sliceInstanceProperty(text).call(text, 0, i + 1));
|
44
44
|
}
|
45
|
-
expect(result.current).toBe(text);
|
45
|
+
expect(result.current.currentText).toBe(text);
|
46
46
|
});
|
47
47
|
it('should NOT render text when shouldStartAnimation = false', function () {
|
48
48
|
var _renderHook2 = renderHook(function () {
|
@@ -51,13 +51,13 @@ describe('useTypeAnimation', function () {
|
|
51
51
|
}));
|
52
52
|
}),
|
53
53
|
result = _renderHook2.result;
|
54
|
-
expect(result.current).toBe('');
|
54
|
+
expect(result.current.currentText).toBe('');
|
55
55
|
for (var i = 0; i < text.length; i += 1) {
|
56
56
|
act(function () {
|
57
57
|
jest.advanceTimersByTime(delay);
|
58
58
|
});
|
59
|
-
expect(result.current).toBe('');
|
59
|
+
expect(result.current.currentText).toBe('');
|
60
60
|
}
|
61
|
-
expect(result.current).toBe('');
|
61
|
+
expect(result.current.currentText).toBe('');
|
62
62
|
});
|
63
63
|
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './useTypeAnimationWrapper';
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
2
|
+
import { useEffect, useState } from 'react';
|
3
|
+
var useTypeAnimationWrapper = function useTypeAnimationWrapper(props) {
|
4
|
+
var animationIndex = props.animationIndex,
|
5
|
+
stateIndex = props.stateIndex,
|
6
|
+
isTopLevel = props.isTopLevel,
|
7
|
+
shouldStartAnimation = props.shouldStartAnimation,
|
8
|
+
children = props.children;
|
9
|
+
var _useState = useState(false),
|
10
|
+
_useState2 = _slicedToArray(_useState, 2),
|
11
|
+
shouldStart = _useState2[0],
|
12
|
+
setShouldStart = _useState2[1];
|
13
|
+
var _useState3 = useState(false),
|
14
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
15
|
+
hasList = _useState4[0],
|
16
|
+
setHasList = _useState4[1];
|
17
|
+
useEffect(function () {
|
18
|
+
var shouldSetShouldStart = animationIndex === stateIndex && isTopLevel || shouldStartAnimation === true;
|
19
|
+
if (shouldSetShouldStart) {
|
20
|
+
setShouldStart(true);
|
21
|
+
} else {
|
22
|
+
setShouldStart(false);
|
23
|
+
}
|
24
|
+
}, [animationIndex, stateIndex, isTopLevel, shouldStartAnimation]);
|
25
|
+
useEffect(function () {
|
26
|
+
if (!children || children.length < 0) return;
|
27
|
+
for (var i = 0; i < children.length; i += 1) {
|
28
|
+
var _children$i;
|
29
|
+
if ((_children$i = children[i]) !== null && _children$i !== void 0 && _children$i.props && (children[i].props.as === 'ul' || children[i].props.as === 'ol')) {
|
30
|
+
setHasList(true);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}, [children]);
|
34
|
+
return {
|
35
|
+
shouldStart: shouldStart,
|
36
|
+
hasList: hasList
|
37
|
+
};
|
38
|
+
};
|
39
|
+
export default useTypeAnimationWrapper;
|
@@ -0,0 +1,90 @@
|
|
1
|
+
import { renderHook } from '@testing-library/react-hooks';
|
2
|
+
import useTypeAnimationWrapper from './useTypeAnimationWrapper';
|
3
|
+
var animationIndex = 0;
|
4
|
+
var stateIndex = 1;
|
5
|
+
var isTopLevel = false;
|
6
|
+
var shouldStartAnimation = false;
|
7
|
+
var children = [{
|
8
|
+
props: {
|
9
|
+
as: 'ul'
|
10
|
+
}
|
11
|
+
}, {
|
12
|
+
props: {
|
13
|
+
as: 'li'
|
14
|
+
}
|
15
|
+
}, {
|
16
|
+
props: {
|
17
|
+
as: 'ol'
|
18
|
+
}
|
19
|
+
}];
|
20
|
+
describe('useTypeAnimationWrapper', function () {
|
21
|
+
it('should not start animation if animationIndex does not match stateIndex and isTopLevel is false', function () {
|
22
|
+
var _renderHook = renderHook(function () {
|
23
|
+
return useTypeAnimationWrapper({
|
24
|
+
animationIndex: animationIndex,
|
25
|
+
stateIndex: stateIndex,
|
26
|
+
isTopLevel: isTopLevel,
|
27
|
+
shouldStartAnimation: shouldStartAnimation,
|
28
|
+
children: children
|
29
|
+
});
|
30
|
+
}),
|
31
|
+
result = _renderHook.result;
|
32
|
+
expect(result.current.shouldStart).toBe(false);
|
33
|
+
});
|
34
|
+
it('should start animation if animationIndex matches stateIndex and isTopLevel is true', function () {
|
35
|
+
var _renderHook2 = renderHook(function () {
|
36
|
+
return useTypeAnimationWrapper({
|
37
|
+
animationIndex: 1,
|
38
|
+
stateIndex: 1,
|
39
|
+
isTopLevel: true,
|
40
|
+
shouldStartAnimation: shouldStartAnimation,
|
41
|
+
children: children
|
42
|
+
});
|
43
|
+
}),
|
44
|
+
result = _renderHook2.result;
|
45
|
+
expect(result.current.shouldStart).toBe(true);
|
46
|
+
});
|
47
|
+
it('should start animation if shouldStartAnimation is true', function () {
|
48
|
+
var _renderHook3 = renderHook(function () {
|
49
|
+
return useTypeAnimationWrapper({
|
50
|
+
animationIndex: animationIndex,
|
51
|
+
stateIndex: stateIndex,
|
52
|
+
isTopLevel: isTopLevel,
|
53
|
+
shouldStartAnimation: true,
|
54
|
+
children: children
|
55
|
+
});
|
56
|
+
}),
|
57
|
+
result = _renderHook3.result;
|
58
|
+
expect(result.current.shouldStart).toBe(true);
|
59
|
+
});
|
60
|
+
it('should detect if children contain a list', function () {
|
61
|
+
var _renderHook4 = renderHook(function () {
|
62
|
+
return useTypeAnimationWrapper({
|
63
|
+
animationIndex: animationIndex,
|
64
|
+
stateIndex: stateIndex,
|
65
|
+
isTopLevel: isTopLevel,
|
66
|
+
shouldStartAnimation: shouldStartAnimation,
|
67
|
+
children: children
|
68
|
+
});
|
69
|
+
}),
|
70
|
+
result = _renderHook4.result;
|
71
|
+
expect(result.current.hasList).toBe(true);
|
72
|
+
});
|
73
|
+
it('should not detect a list if children do not contain a list', function () {
|
74
|
+
var _renderHook5 = renderHook(function () {
|
75
|
+
return useTypeAnimationWrapper({
|
76
|
+
animationIndex: animationIndex,
|
77
|
+
stateIndex: stateIndex,
|
78
|
+
isTopLevel: isTopLevel,
|
79
|
+
shouldStartAnimation: shouldStartAnimation,
|
80
|
+
children: [{
|
81
|
+
props: {
|
82
|
+
as: 'div'
|
83
|
+
}
|
84
|
+
}]
|
85
|
+
});
|
86
|
+
}),
|
87
|
+
result = _renderHook5.result;
|
88
|
+
expect(result.current.hasList).toBe(false);
|
89
|
+
});
|
90
|
+
});
|
package/lib/index.js
CHANGED
@@ -18,6 +18,7 @@ export { default as PromptInput } from './components/AIComponents/PromptInput';
|
|
18
18
|
export { default as Response } from './components/AIComponents/Response';
|
19
19
|
export { default as ResponseAttachment } from './components/AIComponents/Response/ResponseAttachment';
|
20
20
|
export { default as ResponseList } from './components/AIComponents/Response/ResponseList';
|
21
|
+
export { default as ResponseMarkdown } from './components/AIComponents/Response/ResponseMarkdown';
|
21
22
|
export { default as ResponseText } from './components/AIComponents/Response/ResponseText';
|
22
23
|
export { default as ResponseToolbar } from './components/AIComponents/Response/ResponseToolbar';
|
23
24
|
export { default as ResponseToolbarIcon } from './components/AIComponents/Response/ResponseToolbarIcon';
|