@pingux/astro 2.112.0-alpha.2 → 2.112.0-alpha.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.
- package/lib/cjs/components/AIComponents/Response/Response.stories.js +24 -24
- package/lib/cjs/components/AIComponents/Response/Response.test.jsx +40 -70
- package/lib/cjs/components/AIComponents/Response/ResponseAttachment.js +3 -2
- package/lib/cjs/components/AIComponents/Response/ResponseToolbar.js +23 -35
- package/lib/cjs/components/AIComponents/Response/ResponseToolbarIcon.d.ts +4 -0
- package/lib/cjs/components/AIComponents/Response/ResponseToolbarIcon.js +57 -0
- package/lib/cjs/components/AIComponents/Response/index.d.ts +1 -0
- package/lib/cjs/components/AIComponents/Response/index.js +8 -1
- 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 +33 -0
- package/lib/cjs/styles/themes/next-gen/variants/button.d.ts +33 -0
- package/lib/cjs/styles/themes/next-gen/variants/button.js +6 -0
- package/lib/cjs/types/response.d.ts +10 -3
- package/lib/components/AIComponents/Response/Response.stories.js +24 -24
- package/lib/components/AIComponents/Response/Response.test.jsx +40 -70
- package/lib/components/AIComponents/Response/ResponseAttachment.js +3 -2
- package/lib/components/AIComponents/Response/ResponseToolbar.js +25 -37
- package/lib/components/AIComponents/Response/ResponseToolbarIcon.js +43 -0
- package/lib/components/AIComponents/Response/index.js +2 -1
- package/lib/index.js +1 -0
- package/lib/styles/themes/next-gen/variants/button.js +6 -0
- package/package.json +1 -1
@@ -7,6 +7,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
7
7
|
});
|
8
8
|
exports["default"] = exports.Default = void 0;
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
10
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
10
11
|
var _react = _interopRequireDefault(require("react"));
|
11
12
|
var _ContentCopyIcon = _interopRequireDefault(require("@pingux/mdi-react/ContentCopyIcon"));
|
12
13
|
var _TextIcon = _interopRequireDefault(require("@pingux/mdi-react/TextIcon"));
|
@@ -19,6 +20,7 @@ var _ResponseAttachment = _interopRequireDefault(require("./ResponseAttachment")
|
|
19
20
|
var _ResponseList = _interopRequireDefault(require("./ResponseList"));
|
20
21
|
var _ResponseText = _interopRequireDefault(require("./ResponseText"));
|
21
22
|
var _ResponseToolbar = _interopRequireDefault(require("./ResponseToolbar"));
|
23
|
+
var _ResponseToolbarIcon = _interopRequireDefault(require("./ResponseToolbarIcon"));
|
22
24
|
var _react2 = require("@emotion/react");
|
23
25
|
var _default = {
|
24
26
|
title: 'Ai Components/Response',
|
@@ -27,28 +29,22 @@ var _default = {
|
|
27
29
|
exports["default"] = _default;
|
28
30
|
var testText = 'Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet';
|
29
31
|
var Default = function Default(args) {
|
30
|
-
var
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
},
|
47
|
-
rephraseButtonProps: {
|
48
|
-
title: 'Rephrase Answer',
|
49
|
-
icon: _TextIcon["default"]
|
50
|
-
}
|
51
|
-
};
|
32
|
+
var icons = [{
|
33
|
+
title: 'Read aloud',
|
34
|
+
icon: _VolumeHighIcon["default"]
|
35
|
+
}, {
|
36
|
+
title: 'Copy',
|
37
|
+
icon: _ContentCopyIcon["default"]
|
38
|
+
}, {
|
39
|
+
title: 'Good Response',
|
40
|
+
icon: _ThumbUpOutlineIcon["default"]
|
41
|
+
}, {
|
42
|
+
title: 'Bad Response',
|
43
|
+
icon: _ThumbDownOutlineIcon["default"]
|
44
|
+
}, {
|
45
|
+
title: 'Rephrase Answer',
|
46
|
+
icon: _TextIcon["default"]
|
47
|
+
}];
|
52
48
|
var delay = 20;
|
53
49
|
return (0, _react2.jsx)(_.AstroWrapper, (0, _extends2["default"])({}, args, {
|
54
50
|
themeOverrides: [_.NextGenTheme]
|
@@ -56,7 +52,9 @@ var Default = function Default(args) {
|
|
56
52
|
delay: delay
|
57
53
|
}, (0, _react2.jsx)(_ResponseText["default"], {
|
58
54
|
text: testText
|
59
|
-
}), (0, _react2.jsx)(_ResponseAttachment["default"],
|
55
|
+
}), (0, _react2.jsx)(_ResponseAttachment["default"], {
|
56
|
+
text: "Attachment Text"
|
57
|
+
}), (0, _react2.jsx)(_ResponseText["default"], {
|
60
58
|
text: testText
|
61
59
|
}), (0, _react2.jsx)(_ResponseText["default"], {
|
62
60
|
text: testText
|
@@ -77,6 +75,8 @@ var Default = function Default(args) {
|
|
77
75
|
text: "list item 3"
|
78
76
|
})), (0, _react2.jsx)(_ResponseText["default"], {
|
79
77
|
text: "follow up text"
|
80
|
-
}), (0, _react2.jsx)(_ResponseToolbar["default"],
|
78
|
+
}), (0, _react2.jsx)(_ResponseToolbar["default"], null, (0, _map["default"])(icons).call(icons, function (icon) {
|
79
|
+
return (0, _react2.jsx)(_ResponseToolbarIcon["default"], icon);
|
80
|
+
}))));
|
81
81
|
};
|
82
82
|
exports.Default = Default;
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import
|
2
|
+
import CopyIcon from '@pingux/mdi-react/ContentCopyIcon';
|
3
|
+
import TextIcon from '@pingux/mdi-react/TextIcon';
|
4
|
+
import ThumbDownOutlineIcon from '@pingux/mdi-react/ThumbDownOutlineIcon';
|
5
|
+
import ThumbUpOutlineIcon from '@pingux/mdi-react/ThumbUpOutlineIcon';
|
6
|
+
import VolumeHighIcon from '@pingux/mdi-react/VolumeHighIcon';
|
7
7
|
|
8
8
|
import { act, render, screen } from '../../../utils/testUtils/testWrapper';
|
9
9
|
|
@@ -12,6 +12,7 @@ import ResponseAttachment from './ResponseAttachment';
|
|
12
12
|
import ResponseList from './ResponseList';
|
13
13
|
import ResponseText from './ResponseText';
|
14
14
|
import ResponseToolbar from './ResponseToolbar';
|
15
|
+
import ResponseToolBarIcon from './ResponseToolbarIcon';
|
15
16
|
|
16
17
|
const delay = 100;
|
17
18
|
|
@@ -24,28 +25,24 @@ const nextText = 'nextText';
|
|
24
25
|
const attachmentWrapperId = 'wrapper-id';
|
25
26
|
const toolbarId = 'id';
|
26
27
|
|
27
|
-
const
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
title: 'Rephrase Answer test',
|
46
|
-
icon: TagIcon,
|
47
|
-
},
|
48
|
-
};
|
28
|
+
const attachmentText = 'Attachment Text';
|
29
|
+
|
30
|
+
const icons = [{
|
31
|
+
title: 'Read aloud test',
|
32
|
+
icon: VolumeHighIcon,
|
33
|
+
}, {
|
34
|
+
title: 'Copy test',
|
35
|
+
icon: CopyIcon,
|
36
|
+
}, {
|
37
|
+
title: 'Good Response test',
|
38
|
+
icon: ThumbUpOutlineIcon,
|
39
|
+
}, {
|
40
|
+
title: 'Bad Response test',
|
41
|
+
icon: ThumbDownOutlineIcon,
|
42
|
+
}, {
|
43
|
+
title: 'Rephrase Answer test',
|
44
|
+
icon: TextIcon,
|
45
|
+
}];
|
49
46
|
|
50
47
|
const defaultProps = {
|
51
48
|
containerProps: {
|
@@ -80,25 +77,25 @@ const getComponentWithList = props => render(
|
|
80
77
|
const getComponentWithToolbar = props => render(
|
81
78
|
<Response {...defaultProps} {...props}>
|
82
79
|
<ResponseText text={defaultProps.text} />
|
83
|
-
<ResponseToolbar data-testid={toolbarId}
|
80
|
+
<ResponseToolbar data-testid={toolbarId}>
|
81
|
+
{icons.map(icon => {
|
82
|
+
return (
|
83
|
+
<ResponseToolBarIcon key={icon.title} {...icon} />
|
84
|
+
);
|
85
|
+
})}
|
86
|
+
</ResponseToolbar>
|
87
|
+
<ResponseText text={defaultProps.text} />
|
84
88
|
</Response>,
|
85
89
|
);
|
86
90
|
|
87
91
|
const getComponentWithAttachment = props => render(
|
88
92
|
<Response {...defaultProps} {...props}>
|
89
93
|
<ResponseText text={defaultProps.text} />
|
90
|
-
<ResponseAttachment wrapperProps={{ 'data-testid': attachmentWrapperId }} />
|
94
|
+
<ResponseAttachment text={attachmentText} wrapperProps={{ 'data-testid': attachmentWrapperId }} />
|
91
95
|
<ResponseText text={defaultProps.text} />
|
92
96
|
</Response>,
|
93
97
|
);
|
94
98
|
|
95
|
-
const getComponentWithToolbarCustomProps = props => render(
|
96
|
-
<Response {...defaultProps} {...props}>
|
97
|
-
<ResponseText text={defaultProps.text} />
|
98
|
-
<ResponseToolbar data-testid={toolbarId} {...customProps} />
|
99
|
-
</Response>,
|
100
|
-
);
|
101
|
-
|
102
99
|
test('component renders', () => {
|
103
100
|
getComponent();
|
104
101
|
const container = screen.getByTestId('container');
|
@@ -166,13 +163,19 @@ test('ResponseToolbar renders correctly', async () => {
|
|
166
163
|
act(() => { jest.advanceTimersByTime(100); });
|
167
164
|
}
|
168
165
|
expect(toolbar).not.toHaveClass('is-not-loaded');
|
166
|
+
for (let i = 1; i < icons.length + 1; i += 1) {
|
167
|
+
act(() => { jest.advanceTimersByTime(100); });
|
168
|
+
expect(screen.getByTitle(icons[i - 1].title)).toBeInTheDocument();
|
169
|
+
expect(screen.getByTitle(icons[i - 1].title)).not.toHaveClass('is-not-loaded');
|
170
|
+
}
|
171
|
+
act(() => { jest.advanceTimersByTime(2000); });
|
169
172
|
});
|
170
173
|
|
171
174
|
test('ResponseAttachment renders correctly', async () => {
|
172
175
|
getComponentWithAttachment();
|
173
176
|
act(() => { jest.advanceTimersByTime(10); });
|
174
177
|
|
175
|
-
expect(screen.getByText(
|
178
|
+
expect(screen.getByText(attachmentText)).toBeInTheDocument();
|
176
179
|
const wrapper = screen.getByTestId(attachmentWrapperId);
|
177
180
|
expect(wrapper).toHaveClass('is-not-loaded');
|
178
181
|
for (let i = 1; i < defaultProps.text.length + 1; i += 1) {
|
@@ -180,36 +183,3 @@ test('ResponseAttachment renders correctly', async () => {
|
|
180
183
|
}
|
181
184
|
expect(wrapper).not.toHaveClass('is-not-loaded');
|
182
185
|
});
|
183
|
-
|
184
|
-
test('ResponseAttachment renders correctly, with custom props', async () => {
|
185
|
-
getComponentWithToolbarCustomProps();
|
186
|
-
act(() => { jest.advanceTimersByTime(10); });
|
187
|
-
|
188
|
-
expect(screen.getByTitle('Read aloud test')).toBeInTheDocument();
|
189
|
-
expect(screen.getByTitle('Copy test')).toBeInTheDocument();
|
190
|
-
expect(screen.getByTitle('Good Response test')).toBeInTheDocument();
|
191
|
-
expect(screen.getByTitle('Bad Response test')).toBeInTheDocument();
|
192
|
-
expect(screen.getByTitle('Rephrase Answer test')).toBeInTheDocument();
|
193
|
-
});
|
194
|
-
|
195
|
-
test('ResponseToolbar conditional rendering of IconButton based on title prop', async () => {
|
196
|
-
render(
|
197
|
-
<Response {...defaultProps}>
|
198
|
-
<ResponseText text={defaultProps.text} />
|
199
|
-
<ResponseToolbar
|
200
|
-
data-testid={toolbarId}
|
201
|
-
readButtonProps={{ title: 'Read aloud' }}
|
202
|
-
copyButtonProps={{ title: '' }}
|
203
|
-
goodButtonProps={{ title: 'Good Response' }}
|
204
|
-
badButtonProps={{ title: '' }}
|
205
|
-
rephraseButtonProps={{ title: 'Rephrase Answer' }}
|
206
|
-
/>
|
207
|
-
</Response>,
|
208
|
-
);
|
209
|
-
|
210
|
-
expect(screen.getByTitle('Read aloud')).toBeInTheDocument();
|
211
|
-
expect(screen.queryByTitle('Copy')).not.toBeInTheDocument();
|
212
|
-
expect(screen.getByTitle('Good Response')).toBeInTheDocument();
|
213
|
-
expect(screen.queryByTitle('Bad Response')).not.toBeInTheDocument();
|
214
|
-
expect(screen.getByTitle('Rephrase Answer')).toBeInTheDocument();
|
215
|
-
});
|
@@ -25,7 +25,8 @@ var ResponseAttachment = function ResponseAttachment(props) {
|
|
25
25
|
iconProps = props.iconProps,
|
26
26
|
className = props.className,
|
27
27
|
animationIndex = props.animationIndex,
|
28
|
-
shouldStartAnimation = props.shouldStartAnimation
|
28
|
+
shouldStartAnimation = props.shouldStartAnimation,
|
29
|
+
text = props.text;
|
29
30
|
var isLoaded = (0, _react.useRef)(false);
|
30
31
|
(0, _react.useEffect)(function () {
|
31
32
|
if (shouldStartAnimation && setAnimationIndex && animationIndex !== undefined && isLoaded.current === false) {
|
@@ -48,7 +49,7 @@ var ResponseAttachment = function ResponseAttachment(props) {
|
|
48
49
|
title: {
|
49
50
|
name: 'attachment icon'
|
50
51
|
}
|
51
|
-
}, iconProps)), (0, _react2.jsx)(_index.Text, textProps,
|
52
|
+
}, iconProps)), (0, _react2.jsx)(_index.Text, textProps, text));
|
52
53
|
};
|
53
54
|
var _default = ResponseAttachment;
|
54
55
|
exports["default"] = _default;
|
@@ -9,49 +9,40 @@ _Object$defineProperty(exports, "__esModule", {
|
|
9
9
|
value: true
|
10
10
|
});
|
11
11
|
exports["default"] = void 0;
|
12
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
12
13
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
13
15
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
14
16
|
var _react = _interopRequireWildcard(require("react"));
|
15
|
-
var _ContentCopyIcon = _interopRequireDefault(require("@pingux/mdi-react/ContentCopyIcon"));
|
16
|
-
var _TextIcon = _interopRequireDefault(require("@pingux/mdi-react/TextIcon"));
|
17
|
-
var _ThumbDownOutlineIcon = _interopRequireDefault(require("@pingux/mdi-react/ThumbDownOutlineIcon"));
|
18
|
-
var _ThumbUpOutlineIcon = _interopRequireDefault(require("@pingux/mdi-react/ThumbUpOutlineIcon"));
|
19
|
-
var _VolumeHighIcon = _interopRequireDefault(require("@pingux/mdi-react/VolumeHighIcon"));
|
20
17
|
var _hooks = require("../../../hooks");
|
21
18
|
var _index = require("../../../index");
|
22
19
|
var _react2 = require("@emotion/react");
|
23
|
-
var _excluded = ["parentIndex", "setAnimationIndex", "
|
20
|
+
var _excluded = ["parentIndex", "setAnimationIndex", "children", "className", "shouldStartAnimation", "animationIndex", "delay"];
|
24
21
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
25
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
26
|
-
var ResponseToolbarIcon = function ResponseToolbarIcon(props) {
|
27
|
-
var title = props.title,
|
28
|
-
icon = props.icon;
|
29
|
-
return (0, _react2.jsx)(_index.IconButton, {
|
30
|
-
title: title
|
31
|
-
}, (0, _react2.jsx)(_index.Icon, {
|
32
|
-
icon: icon,
|
33
|
-
title: {
|
34
|
-
name: title
|
35
|
-
}
|
36
|
-
}));
|
37
|
-
};
|
38
23
|
var ResponseToolbar = function ResponseToolbar(props) {
|
39
24
|
var parentIndex = props.parentIndex,
|
40
25
|
setAnimationIndex = props.setAnimationIndex,
|
41
|
-
|
42
|
-
copyButtonProps = props.copyButtonProps,
|
43
|
-
goodButtonProps = props.goodButtonProps,
|
44
|
-
badButtonProps = props.badButtonProps,
|
45
|
-
rephraseButtonProps = props.rephraseButtonProps,
|
26
|
+
children = props.children,
|
46
27
|
className = props.className,
|
47
28
|
shouldStartAnimation = props.shouldStartAnimation,
|
48
29
|
animationIndex = props.animationIndex,
|
30
|
+
delay = props.delay,
|
49
31
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
50
32
|
var isLoaded = (0, _react.useRef)(false);
|
33
|
+
var _useState = (0, _react.useState)(-1),
|
34
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
35
|
+
index = _useState2[0],
|
36
|
+
setIndex = _useState2[1];
|
37
|
+
(0, _react.useEffect)(function () {
|
38
|
+
if (index === (children === null || children === void 0 ? void 0 : children.length) && animationIndex !== undefined && setAnimationIndex) {
|
39
|
+
setAnimationIndex(animationIndex + 1);
|
40
|
+
}
|
41
|
+
}, [setAnimationIndex, index, shouldStartAnimation, animationIndex, children === null || children === void 0 ? void 0 : children.length]);
|
51
42
|
(0, _react.useEffect)(function () {
|
52
43
|
if (shouldStartAnimation && setAnimationIndex && animationIndex !== undefined && isLoaded.current === false) {
|
53
44
|
isLoaded.current = true;
|
54
|
-
|
45
|
+
setIndex(0);
|
55
46
|
}
|
56
47
|
}, [setAnimationIndex, parentIndex, shouldStartAnimation, animationIndex]);
|
57
48
|
var _useStatusClasses = (0, _hooks.useStatusClasses)(className, {
|
@@ -63,17 +54,14 @@ var ResponseToolbar = function ResponseToolbar(props) {
|
|
63
54
|
gap: "sm",
|
64
55
|
variant: "response.toolbar",
|
65
56
|
className: classNames
|
66
|
-
}, others), (
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
}, badButtonProps)), (rephraseButtonProps === null || rephraseButtonProps === void 0 ? void 0 : rephraseButtonProps.title) && (0, _react2.jsx)(ResponseToolbarIcon, (0, _extends2["default"])({
|
75
|
-
icon: _TextIcon["default"]
|
76
|
-
}, rephraseButtonProps)));
|
57
|
+
}, others), (0, _map["default"])(_react.Children).call(_react.Children, children, function (child, i) {
|
58
|
+
return (0, _react2.jsx)(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].cloneElement(child, {
|
59
|
+
setAnimationIndex: setIndex,
|
60
|
+
animationIndex: i,
|
61
|
+
parentIndex: index,
|
62
|
+
delay: delay
|
63
|
+
}));
|
64
|
+
}));
|
77
65
|
};
|
78
66
|
var _default = ResponseToolbar;
|
79
67
|
exports["default"] = _default;
|
@@ -0,0 +1,57 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _typeof = require("@babel/runtime-corejs3/helpers/typeof");
|
4
|
+
var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
|
5
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
6
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
7
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
8
|
+
_Object$defineProperty(exports, "__esModule", {
|
9
|
+
value: true
|
10
|
+
});
|
11
|
+
exports["default"] = void 0;
|
12
|
+
var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout"));
|
13
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
14
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
15
|
+
var _react = _interopRequireWildcard(require("react"));
|
16
|
+
var _hooks = require("../../../hooks");
|
17
|
+
var _index = require("../../../index");
|
18
|
+
var _react2 = require("@emotion/react");
|
19
|
+
var _excluded = ["title", "icon", "className", "parentIndex", "animationIndex", "setAnimationIndex", "delay", "iconProps"];
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
21
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
22
|
+
var ResponseToolbarIcon = function ResponseToolbarIcon(props) {
|
23
|
+
var title = props.title,
|
24
|
+
icon = props.icon,
|
25
|
+
className = props.className,
|
26
|
+
parentIndex = props.parentIndex,
|
27
|
+
animationIndex = props.animationIndex,
|
28
|
+
setAnimationIndex = props.setAnimationIndex,
|
29
|
+
delay = props.delay,
|
30
|
+
iconProps = props.iconProps,
|
31
|
+
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
32
|
+
var isLoaded = (0, _react.useRef)(false);
|
33
|
+
(0, _react.useEffect)(function () {
|
34
|
+
if (parentIndex === animationIndex && setAnimationIndex && parentIndex !== undefined) {
|
35
|
+
(0, _setTimeout2["default"])(function () {
|
36
|
+
isLoaded.current = true;
|
37
|
+
setAnimationIndex(parentIndex + 1);
|
38
|
+
}, delay);
|
39
|
+
}
|
40
|
+
}, [parentIndex, animationIndex, setAnimationIndex, delay]);
|
41
|
+
var _useStatusClasses = (0, _hooks.useStatusClasses)(className, {
|
42
|
+
isNotLoaded: !isLoaded.current
|
43
|
+
}),
|
44
|
+
classNames = _useStatusClasses.classNames;
|
45
|
+
return (0, _react2.jsx)(_index.IconButton, (0, _extends2["default"])({
|
46
|
+
title: title,
|
47
|
+
className: classNames,
|
48
|
+
variant: "responseToolbar"
|
49
|
+
}, others), (0, _react2.jsx)(_index.Icon, (0, _extends2["default"])({
|
50
|
+
icon: icon,
|
51
|
+
title: {
|
52
|
+
name: title
|
53
|
+
}
|
54
|
+
}, iconProps)));
|
55
|
+
};
|
56
|
+
var _default = ResponseToolbarIcon;
|
57
|
+
exports["default"] = _default;
|
@@ -3,3 +3,4 @@ export { default as ResponseAttachment } from './ResponseAttachment';
|
|
3
3
|
export { default as ResponseList } from './ResponseList';
|
4
4
|
export { default as ResponseText } from './ResponseText';
|
5
5
|
export { default as ResponseToolbar } from './ResponseToolbar';
|
6
|
+
export { default as ResponseToolbarIcon } from './ResponseToolbarIcon';
|
@@ -29,6 +29,12 @@ _Object$defineProperty(exports, "ResponseToolbar", {
|
|
29
29
|
return _ResponseToolbar["default"];
|
30
30
|
}
|
31
31
|
});
|
32
|
+
_Object$defineProperty(exports, "ResponseToolbarIcon", {
|
33
|
+
enumerable: true,
|
34
|
+
get: function get() {
|
35
|
+
return _ResponseToolbarIcon["default"];
|
36
|
+
}
|
37
|
+
});
|
32
38
|
_Object$defineProperty(exports, "default", {
|
33
39
|
enumerable: true,
|
34
40
|
get: function get() {
|
@@ -39,4 +45,5 @@ var _Response = _interopRequireDefault(require("./Response"));
|
|
39
45
|
var _ResponseAttachment = _interopRequireDefault(require("./ResponseAttachment"));
|
40
46
|
var _ResponseList = _interopRequireDefault(require("./ResponseList"));
|
41
47
|
var _ResponseText = _interopRequireDefault(require("./ResponseText"));
|
42
|
-
var _ResponseToolbar = _interopRequireDefault(require("./ResponseToolbar"));
|
48
|
+
var _ResponseToolbar = _interopRequireDefault(require("./ResponseToolbar"));
|
49
|
+
var _ResponseToolbarIcon = _interopRequireDefault(require("./ResponseToolbarIcon"));
|
package/lib/cjs/index.d.ts
CHANGED
@@ -16,6 +16,7 @@ export { default as ResponseAttachment } from './components/AIComponents/Respons
|
|
16
16
|
export { default as ResponseList } from './components/AIComponents/Response/ResponseList';
|
17
17
|
export { default as ResponseText } from './components/AIComponents/Response/ResponseText';
|
18
18
|
export { default as ResponseToolbar } from './components/AIComponents/Response/ResponseToolbar';
|
19
|
+
export { default as ResponseToolbarIcon } from './components/AIComponents/Response/ResponseToolbarIcon';
|
19
20
|
export { default as Suggestions } from './components/AIComponents/Suggestions';
|
20
21
|
export { default as Suggestion } from './components/AIComponents/Suggestions/Suggestion';
|
21
22
|
export { default as ArrayField } from './components/ArrayField';
|
package/lib/cjs/index.js
CHANGED
@@ -26,6 +26,7 @@ var _exportNames = {
|
|
26
26
|
ResponseList: true,
|
27
27
|
ResponseText: true,
|
28
28
|
ResponseToolbar: true,
|
29
|
+
ResponseToolbarIcon: true,
|
29
30
|
Suggestions: true,
|
30
31
|
Suggestion: true,
|
31
32
|
ArrayField: true,
|
@@ -798,6 +799,12 @@ _Object$defineProperty(exports, "ResponseToolbar", {
|
|
798
799
|
return _ResponseToolbar["default"];
|
799
800
|
}
|
800
801
|
});
|
802
|
+
_Object$defineProperty(exports, "ResponseToolbarIcon", {
|
803
|
+
enumerable: true,
|
804
|
+
get: function get() {
|
805
|
+
return _ResponseToolbarIcon["default"];
|
806
|
+
}
|
807
|
+
});
|
801
808
|
_Object$defineProperty(exports, "RockerButton", {
|
802
809
|
enumerable: true,
|
803
810
|
get: function get() {
|
@@ -1072,6 +1079,7 @@ var _ResponseAttachment = _interopRequireDefault(require("./components/AICompone
|
|
1072
1079
|
var _ResponseList = _interopRequireDefault(require("./components/AIComponents/Response/ResponseList"));
|
1073
1080
|
var _ResponseText = _interopRequireDefault(require("./components/AIComponents/Response/ResponseText"));
|
1074
1081
|
var _ResponseToolbar = _interopRequireDefault(require("./components/AIComponents/Response/ResponseToolbar"));
|
1082
|
+
var _ResponseToolbarIcon = _interopRequireDefault(require("./components/AIComponents/Response/ResponseToolbarIcon"));
|
1075
1083
|
var _Suggestions = _interopRequireDefault(require("./components/AIComponents/Suggestions"));
|
1076
1084
|
var _Suggestion = _interopRequireDefault(require("./components/AIComponents/Suggestions/Suggestion"));
|
1077
1085
|
var _ArrayField = _interopRequireWildcard(require("./components/ArrayField"));
|
@@ -783,6 +783,39 @@ declare const _default: {
|
|
783
783
|
transition: string;
|
784
784
|
outline: string;
|
785
785
|
};
|
786
|
+
responseToolbar: {
|
787
|
+
'&.is-not-loaded': {
|
788
|
+
display: string;
|
789
|
+
};
|
790
|
+
display: string;
|
791
|
+
cursor: string;
|
792
|
+
transition: string;
|
793
|
+
outline: string;
|
794
|
+
borderRadius: string;
|
795
|
+
border: string;
|
796
|
+
borderColor: string;
|
797
|
+
path: {
|
798
|
+
fill: string;
|
799
|
+
};
|
800
|
+
'&.is-focused': {
|
801
|
+
outline: string;
|
802
|
+
outlineColor: string;
|
803
|
+
outlineOffset: string;
|
804
|
+
};
|
805
|
+
'&.is-hovered': {
|
806
|
+
backgroundColor: string;
|
807
|
+
path: {
|
808
|
+
fill: string;
|
809
|
+
};
|
810
|
+
};
|
811
|
+
'&.is-pressed': {
|
812
|
+
backgroundColor: string;
|
813
|
+
borderColor: string;
|
814
|
+
path: {
|
815
|
+
fill: string;
|
816
|
+
};
|
817
|
+
};
|
818
|
+
};
|
786
819
|
modalCloseButton: {
|
787
820
|
position: string;
|
788
821
|
top: number;
|
@@ -550,6 +550,39 @@ declare const buttons: {
|
|
550
550
|
transition: string;
|
551
551
|
outline: string;
|
552
552
|
};
|
553
|
+
responseToolbar: {
|
554
|
+
'&.is-not-loaded': {
|
555
|
+
display: string;
|
556
|
+
};
|
557
|
+
display: string;
|
558
|
+
cursor: string;
|
559
|
+
transition: string;
|
560
|
+
outline: string;
|
561
|
+
borderRadius: string;
|
562
|
+
border: string;
|
563
|
+
borderColor: string;
|
564
|
+
path: {
|
565
|
+
fill: string;
|
566
|
+
};
|
567
|
+
'&.is-focused': {
|
568
|
+
outline: string;
|
569
|
+
outlineColor: string;
|
570
|
+
outlineOffset: string;
|
571
|
+
};
|
572
|
+
'&.is-hovered': {
|
573
|
+
backgroundColor: string;
|
574
|
+
path: {
|
575
|
+
fill: string;
|
576
|
+
};
|
577
|
+
};
|
578
|
+
'&.is-pressed': {
|
579
|
+
backgroundColor: string;
|
580
|
+
borderColor: string;
|
581
|
+
path: {
|
582
|
+
fill: string;
|
583
|
+
};
|
584
|
+
};
|
585
|
+
};
|
553
586
|
modalCloseButton: {
|
554
587
|
position: string;
|
555
588
|
top: number;
|
@@ -250,6 +250,12 @@ var iconButtons = {
|
|
250
250
|
base: _objectSpread({}, baseIconButton),
|
251
251
|
nextGen: _objectSpread({}, onyxIconButton),
|
252
252
|
onyx: _objectSpread({}, onyxIconButton),
|
253
|
+
responseToolbar: _objectSpread(_objectSpread({}, baseIconButton), {}, {
|
254
|
+
'&.is-not-loaded': {
|
255
|
+
display: 'none'
|
256
|
+
},
|
257
|
+
display: 'inline-flex'
|
258
|
+
}),
|
253
259
|
modalCloseButton: modalCloseButton,
|
254
260
|
badge: {
|
255
261
|
deleteButton: _objectSpread(_objectSpread({}, baseIconButton), {}, {
|
@@ -20,22 +20,22 @@ export interface ResponseAttachmentProps extends SharedResponseProps {
|
|
20
20
|
iconProps?: IconProps;
|
21
21
|
parentIndex?: number;
|
22
22
|
className?: string;
|
23
|
+
text: string;
|
23
24
|
}
|
24
25
|
export interface ResponseListProps extends SharedResponseProps, BoxProps {
|
25
26
|
children: ReactNode[];
|
26
27
|
parentIndex?: number;
|
27
28
|
delay?: number;
|
28
29
|
}
|
29
|
-
export interface ResponseProps {
|
30
|
+
export interface ResponseProps extends BoxProps {
|
30
31
|
containerProps?: BoxProps;
|
31
32
|
iconProps?: IconProps;
|
32
33
|
textProps?: ResponseTextProps;
|
33
34
|
iconWrapperProps?: IconWrapperProps;
|
34
35
|
shouldStartAnimation?: boolean;
|
35
|
-
children: ReactNode[];
|
36
36
|
delay?: number;
|
37
37
|
}
|
38
|
-
export interface ResponseToolbarProps extends SharedResponseProps {
|
38
|
+
export interface ResponseToolbarProps extends BoxProps, SharedResponseProps {
|
39
39
|
readButtonProps?: IconButtonProps;
|
40
40
|
copyButtonProps?: IconButtonProps;
|
41
41
|
goodButtonProps?: IconButtonProps;
|
@@ -44,5 +44,12 @@ export interface ResponseToolbarProps extends SharedResponseProps {
|
|
44
44
|
containerProps?: BoxProps;
|
45
45
|
parentIndex?: number;
|
46
46
|
className?: string;
|
47
|
+
delay?: number;
|
48
|
+
children: ReactNode[];
|
49
|
+
}
|
50
|
+
export interface ResponseToolbarIconProps extends IconButtonProps, SharedResponseProps {
|
51
|
+
delay?: number;
|
52
|
+
parentIndex?: number;
|
53
|
+
iconProps?: IconProps;
|
47
54
|
}
|
48
55
|
export {};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
2
3
|
import React from 'react';
|
3
4
|
import CopyIcon from '@pingux/mdi-react/ContentCopyIcon';
|
4
5
|
import TextIcon from '@pingux/mdi-react/TextIcon';
|
@@ -11,6 +12,7 @@ import ResponseAttachment from './ResponseAttachment';
|
|
11
12
|
import ResponseList from './ResponseList';
|
12
13
|
import ResponseText from './ResponseText';
|
13
14
|
import ResponseToolbar from './ResponseToolbar';
|
15
|
+
import ResponseToolbarIcon from './ResponseToolbarIcon';
|
14
16
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
15
17
|
export default {
|
16
18
|
title: 'Ai Components/Response',
|
@@ -18,28 +20,22 @@ export default {
|
|
18
20
|
};
|
19
21
|
var testText = 'Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet';
|
20
22
|
export var Default = function Default(args) {
|
21
|
-
var
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
},
|
38
|
-
rephraseButtonProps: {
|
39
|
-
title: 'Rephrase Answer',
|
40
|
-
icon: TextIcon
|
41
|
-
}
|
42
|
-
};
|
23
|
+
var icons = [{
|
24
|
+
title: 'Read aloud',
|
25
|
+
icon: VolumeHighIcon
|
26
|
+
}, {
|
27
|
+
title: 'Copy',
|
28
|
+
icon: CopyIcon
|
29
|
+
}, {
|
30
|
+
title: 'Good Response',
|
31
|
+
icon: ThumbUpOutlineIcon
|
32
|
+
}, {
|
33
|
+
title: 'Bad Response',
|
34
|
+
icon: ThumbDownOutlineIcon
|
35
|
+
}, {
|
36
|
+
title: 'Rephrase Answer',
|
37
|
+
icon: TextIcon
|
38
|
+
}];
|
43
39
|
var delay = 20;
|
44
40
|
return ___EmotionJSX(AstroWrapper, _extends({}, args, {
|
45
41
|
themeOverrides: [NextGenTheme]
|
@@ -47,7 +43,9 @@ export var Default = function Default(args) {
|
|
47
43
|
delay: delay
|
48
44
|
}, ___EmotionJSX(ResponseText, {
|
49
45
|
text: testText
|
50
|
-
}), ___EmotionJSX(ResponseAttachment,
|
46
|
+
}), ___EmotionJSX(ResponseAttachment, {
|
47
|
+
text: "Attachment Text"
|
48
|
+
}), ___EmotionJSX(ResponseText, {
|
51
49
|
text: testText
|
52
50
|
}), ___EmotionJSX(ResponseText, {
|
53
51
|
text: testText
|
@@ -68,5 +66,7 @@ export var Default = function Default(args) {
|
|
68
66
|
text: "list item 3"
|
69
67
|
})), ___EmotionJSX(ResponseText, {
|
70
68
|
text: "follow up text"
|
71
|
-
}), ___EmotionJSX(ResponseToolbar,
|
69
|
+
}), ___EmotionJSX(ResponseToolbar, null, _mapInstanceProperty(icons).call(icons, function (icon) {
|
70
|
+
return ___EmotionJSX(ResponseToolbarIcon, icon);
|
71
|
+
}))));
|
72
72
|
};
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import
|
3
|
-
import
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import
|
2
|
+
import CopyIcon from '@pingux/mdi-react/ContentCopyIcon';
|
3
|
+
import TextIcon from '@pingux/mdi-react/TextIcon';
|
4
|
+
import ThumbDownOutlineIcon from '@pingux/mdi-react/ThumbDownOutlineIcon';
|
5
|
+
import ThumbUpOutlineIcon from '@pingux/mdi-react/ThumbUpOutlineIcon';
|
6
|
+
import VolumeHighIcon from '@pingux/mdi-react/VolumeHighIcon';
|
7
7
|
|
8
8
|
import { act, render, screen } from '../../../utils/testUtils/testWrapper';
|
9
9
|
|
@@ -12,6 +12,7 @@ import ResponseAttachment from './ResponseAttachment';
|
|
12
12
|
import ResponseList from './ResponseList';
|
13
13
|
import ResponseText from './ResponseText';
|
14
14
|
import ResponseToolbar from './ResponseToolbar';
|
15
|
+
import ResponseToolBarIcon from './ResponseToolbarIcon';
|
15
16
|
|
16
17
|
const delay = 100;
|
17
18
|
|
@@ -24,28 +25,24 @@ const nextText = 'nextText';
|
|
24
25
|
const attachmentWrapperId = 'wrapper-id';
|
25
26
|
const toolbarId = 'id';
|
26
27
|
|
27
|
-
const
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
title: 'Rephrase Answer test',
|
46
|
-
icon: TagIcon,
|
47
|
-
},
|
48
|
-
};
|
28
|
+
const attachmentText = 'Attachment Text';
|
29
|
+
|
30
|
+
const icons = [{
|
31
|
+
title: 'Read aloud test',
|
32
|
+
icon: VolumeHighIcon,
|
33
|
+
}, {
|
34
|
+
title: 'Copy test',
|
35
|
+
icon: CopyIcon,
|
36
|
+
}, {
|
37
|
+
title: 'Good Response test',
|
38
|
+
icon: ThumbUpOutlineIcon,
|
39
|
+
}, {
|
40
|
+
title: 'Bad Response test',
|
41
|
+
icon: ThumbDownOutlineIcon,
|
42
|
+
}, {
|
43
|
+
title: 'Rephrase Answer test',
|
44
|
+
icon: TextIcon,
|
45
|
+
}];
|
49
46
|
|
50
47
|
const defaultProps = {
|
51
48
|
containerProps: {
|
@@ -80,25 +77,25 @@ const getComponentWithList = props => render(
|
|
80
77
|
const getComponentWithToolbar = props => render(
|
81
78
|
<Response {...defaultProps} {...props}>
|
82
79
|
<ResponseText text={defaultProps.text} />
|
83
|
-
<ResponseToolbar data-testid={toolbarId}
|
80
|
+
<ResponseToolbar data-testid={toolbarId}>
|
81
|
+
{icons.map(icon => {
|
82
|
+
return (
|
83
|
+
<ResponseToolBarIcon key={icon.title} {...icon} />
|
84
|
+
);
|
85
|
+
})}
|
86
|
+
</ResponseToolbar>
|
87
|
+
<ResponseText text={defaultProps.text} />
|
84
88
|
</Response>,
|
85
89
|
);
|
86
90
|
|
87
91
|
const getComponentWithAttachment = props => render(
|
88
92
|
<Response {...defaultProps} {...props}>
|
89
93
|
<ResponseText text={defaultProps.text} />
|
90
|
-
<ResponseAttachment wrapperProps={{ 'data-testid': attachmentWrapperId }} />
|
94
|
+
<ResponseAttachment text={attachmentText} wrapperProps={{ 'data-testid': attachmentWrapperId }} />
|
91
95
|
<ResponseText text={defaultProps.text} />
|
92
96
|
</Response>,
|
93
97
|
);
|
94
98
|
|
95
|
-
const getComponentWithToolbarCustomProps = props => render(
|
96
|
-
<Response {...defaultProps} {...props}>
|
97
|
-
<ResponseText text={defaultProps.text} />
|
98
|
-
<ResponseToolbar data-testid={toolbarId} {...customProps} />
|
99
|
-
</Response>,
|
100
|
-
);
|
101
|
-
|
102
99
|
test('component renders', () => {
|
103
100
|
getComponent();
|
104
101
|
const container = screen.getByTestId('container');
|
@@ -166,13 +163,19 @@ test('ResponseToolbar renders correctly', async () => {
|
|
166
163
|
act(() => { jest.advanceTimersByTime(100); });
|
167
164
|
}
|
168
165
|
expect(toolbar).not.toHaveClass('is-not-loaded');
|
166
|
+
for (let i = 1; i < icons.length + 1; i += 1) {
|
167
|
+
act(() => { jest.advanceTimersByTime(100); });
|
168
|
+
expect(screen.getByTitle(icons[i - 1].title)).toBeInTheDocument();
|
169
|
+
expect(screen.getByTitle(icons[i - 1].title)).not.toHaveClass('is-not-loaded');
|
170
|
+
}
|
171
|
+
act(() => { jest.advanceTimersByTime(2000); });
|
169
172
|
});
|
170
173
|
|
171
174
|
test('ResponseAttachment renders correctly', async () => {
|
172
175
|
getComponentWithAttachment();
|
173
176
|
act(() => { jest.advanceTimersByTime(10); });
|
174
177
|
|
175
|
-
expect(screen.getByText(
|
178
|
+
expect(screen.getByText(attachmentText)).toBeInTheDocument();
|
176
179
|
const wrapper = screen.getByTestId(attachmentWrapperId);
|
177
180
|
expect(wrapper).toHaveClass('is-not-loaded');
|
178
181
|
for (let i = 1; i < defaultProps.text.length + 1; i += 1) {
|
@@ -180,36 +183,3 @@ test('ResponseAttachment renders correctly', async () => {
|
|
180
183
|
}
|
181
184
|
expect(wrapper).not.toHaveClass('is-not-loaded');
|
182
185
|
});
|
183
|
-
|
184
|
-
test('ResponseAttachment renders correctly, with custom props', async () => {
|
185
|
-
getComponentWithToolbarCustomProps();
|
186
|
-
act(() => { jest.advanceTimersByTime(10); });
|
187
|
-
|
188
|
-
expect(screen.getByTitle('Read aloud test')).toBeInTheDocument();
|
189
|
-
expect(screen.getByTitle('Copy test')).toBeInTheDocument();
|
190
|
-
expect(screen.getByTitle('Good Response test')).toBeInTheDocument();
|
191
|
-
expect(screen.getByTitle('Bad Response test')).toBeInTheDocument();
|
192
|
-
expect(screen.getByTitle('Rephrase Answer test')).toBeInTheDocument();
|
193
|
-
});
|
194
|
-
|
195
|
-
test('ResponseToolbar conditional rendering of IconButton based on title prop', async () => {
|
196
|
-
render(
|
197
|
-
<Response {...defaultProps}>
|
198
|
-
<ResponseText text={defaultProps.text} />
|
199
|
-
<ResponseToolbar
|
200
|
-
data-testid={toolbarId}
|
201
|
-
readButtonProps={{ title: 'Read aloud' }}
|
202
|
-
copyButtonProps={{ title: '' }}
|
203
|
-
goodButtonProps={{ title: 'Good Response' }}
|
204
|
-
badButtonProps={{ title: '' }}
|
205
|
-
rephraseButtonProps={{ title: 'Rephrase Answer' }}
|
206
|
-
/>
|
207
|
-
</Response>,
|
208
|
-
);
|
209
|
-
|
210
|
-
expect(screen.getByTitle('Read aloud')).toBeInTheDocument();
|
211
|
-
expect(screen.queryByTitle('Copy')).not.toBeInTheDocument();
|
212
|
-
expect(screen.getByTitle('Good Response')).toBeInTheDocument();
|
213
|
-
expect(screen.queryByTitle('Bad Response')).not.toBeInTheDocument();
|
214
|
-
expect(screen.getByTitle('Rephrase Answer')).toBeInTheDocument();
|
215
|
-
});
|
@@ -12,7 +12,8 @@ var ResponseAttachment = function ResponseAttachment(props) {
|
|
12
12
|
iconProps = props.iconProps,
|
13
13
|
className = props.className,
|
14
14
|
animationIndex = props.animationIndex,
|
15
|
-
shouldStartAnimation = props.shouldStartAnimation
|
15
|
+
shouldStartAnimation = props.shouldStartAnimation,
|
16
|
+
text = props.text;
|
16
17
|
var isLoaded = useRef(false);
|
17
18
|
useEffect(function () {
|
18
19
|
if (shouldStartAnimation && setAnimationIndex && animationIndex !== undefined && isLoaded.current === false) {
|
@@ -35,6 +36,6 @@ var ResponseAttachment = function ResponseAttachment(props) {
|
|
35
36
|
title: {
|
36
37
|
name: 'attachment icon'
|
37
38
|
}
|
38
|
-
}, iconProps)), ___EmotionJSX(Text, textProps,
|
39
|
+
}, iconProps)), ___EmotionJSX(Text, textProps, text));
|
39
40
|
};
|
40
41
|
export default ResponseAttachment;
|
@@ -1,44 +1,35 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
2
3
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
3
|
-
var _excluded = ["parentIndex", "setAnimationIndex", "
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import TextIcon from '@pingux/mdi-react/TextIcon';
|
7
|
-
import ThumbDownOutlineIcon from '@pingux/mdi-react/ThumbDownOutlineIcon';
|
8
|
-
import ThumbUpOutlineIcon from '@pingux/mdi-react/ThumbUpOutlineIcon';
|
9
|
-
import VolumeHighIcon from '@pingux/mdi-react/VolumeHighIcon';
|
4
|
+
var _excluded = ["parentIndex", "setAnimationIndex", "children", "className", "shouldStartAnimation", "animationIndex", "delay"];
|
5
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
6
|
+
import React, { Children, useEffect, useRef, useState } from 'react';
|
10
7
|
import { useStatusClasses } from '../../../hooks';
|
11
|
-
import { Box
|
8
|
+
import { Box } from '../../../index';
|
12
9
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
13
|
-
var ResponseToolbarIcon = function ResponseToolbarIcon(props) {
|
14
|
-
var title = props.title,
|
15
|
-
icon = props.icon;
|
16
|
-
return ___EmotionJSX(IconButton, {
|
17
|
-
title: title
|
18
|
-
}, ___EmotionJSX(Icon, {
|
19
|
-
icon: icon,
|
20
|
-
title: {
|
21
|
-
name: title
|
22
|
-
}
|
23
|
-
}));
|
24
|
-
};
|
25
10
|
var ResponseToolbar = function ResponseToolbar(props) {
|
26
11
|
var parentIndex = props.parentIndex,
|
27
12
|
setAnimationIndex = props.setAnimationIndex,
|
28
|
-
|
29
|
-
copyButtonProps = props.copyButtonProps,
|
30
|
-
goodButtonProps = props.goodButtonProps,
|
31
|
-
badButtonProps = props.badButtonProps,
|
32
|
-
rephraseButtonProps = props.rephraseButtonProps,
|
13
|
+
children = props.children,
|
33
14
|
className = props.className,
|
34
15
|
shouldStartAnimation = props.shouldStartAnimation,
|
35
16
|
animationIndex = props.animationIndex,
|
17
|
+
delay = props.delay,
|
36
18
|
others = _objectWithoutProperties(props, _excluded);
|
37
19
|
var isLoaded = useRef(false);
|
20
|
+
var _useState = useState(-1),
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
22
|
+
index = _useState2[0],
|
23
|
+
setIndex = _useState2[1];
|
24
|
+
useEffect(function () {
|
25
|
+
if (index === (children === null || children === void 0 ? void 0 : children.length) && animationIndex !== undefined && setAnimationIndex) {
|
26
|
+
setAnimationIndex(animationIndex + 1);
|
27
|
+
}
|
28
|
+
}, [setAnimationIndex, index, shouldStartAnimation, animationIndex, children === null || children === void 0 ? void 0 : children.length]);
|
38
29
|
useEffect(function () {
|
39
30
|
if (shouldStartAnimation && setAnimationIndex && animationIndex !== undefined && isLoaded.current === false) {
|
40
31
|
isLoaded.current = true;
|
41
|
-
|
32
|
+
setIndex(0);
|
42
33
|
}
|
43
34
|
}, [setAnimationIndex, parentIndex, shouldStartAnimation, animationIndex]);
|
44
35
|
var _useStatusClasses = useStatusClasses(className, {
|
@@ -50,16 +41,13 @@ var ResponseToolbar = function ResponseToolbar(props) {
|
|
50
41
|
gap: "sm",
|
51
42
|
variant: "response.toolbar",
|
52
43
|
className: classNames
|
53
|
-
}, others), (
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
}, badButtonProps)), (rephraseButtonProps === null || rephraseButtonProps === void 0 ? void 0 : rephraseButtonProps.title) && ___EmotionJSX(ResponseToolbarIcon, _extends({
|
62
|
-
icon: TextIcon
|
63
|
-
}, rephraseButtonProps)));
|
44
|
+
}, others), _mapInstanceProperty(Children).call(Children, children, function (child, i) {
|
45
|
+
return ___EmotionJSX(React.Fragment, null, /*#__PURE__*/React.cloneElement(child, {
|
46
|
+
setAnimationIndex: setIndex,
|
47
|
+
animationIndex: i,
|
48
|
+
parentIndex: index,
|
49
|
+
delay: delay
|
50
|
+
}));
|
51
|
+
}));
|
64
52
|
};
|
65
53
|
export default ResponseToolbar;
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
3
|
+
var _excluded = ["title", "icon", "className", "parentIndex", "animationIndex", "setAnimationIndex", "delay", "iconProps"];
|
4
|
+
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
5
|
+
import React, { useEffect, useRef } from 'react';
|
6
|
+
import { useStatusClasses } from '../../../hooks';
|
7
|
+
import { Icon, IconButton } from '../../../index';
|
8
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
9
|
+
var ResponseToolbarIcon = function ResponseToolbarIcon(props) {
|
10
|
+
var title = props.title,
|
11
|
+
icon = props.icon,
|
12
|
+
className = props.className,
|
13
|
+
parentIndex = props.parentIndex,
|
14
|
+
animationIndex = props.animationIndex,
|
15
|
+
setAnimationIndex = props.setAnimationIndex,
|
16
|
+
delay = props.delay,
|
17
|
+
iconProps = props.iconProps,
|
18
|
+
others = _objectWithoutProperties(props, _excluded);
|
19
|
+
var isLoaded = useRef(false);
|
20
|
+
useEffect(function () {
|
21
|
+
if (parentIndex === animationIndex && setAnimationIndex && parentIndex !== undefined) {
|
22
|
+
_setTimeout(function () {
|
23
|
+
isLoaded.current = true;
|
24
|
+
setAnimationIndex(parentIndex + 1);
|
25
|
+
}, delay);
|
26
|
+
}
|
27
|
+
}, [parentIndex, animationIndex, setAnimationIndex, delay]);
|
28
|
+
var _useStatusClasses = useStatusClasses(className, {
|
29
|
+
isNotLoaded: !isLoaded.current
|
30
|
+
}),
|
31
|
+
classNames = _useStatusClasses.classNames;
|
32
|
+
return ___EmotionJSX(IconButton, _extends({
|
33
|
+
title: title,
|
34
|
+
className: classNames,
|
35
|
+
variant: "responseToolbar"
|
36
|
+
}, others), ___EmotionJSX(Icon, _extends({
|
37
|
+
icon: icon,
|
38
|
+
title: {
|
39
|
+
name: title
|
40
|
+
}
|
41
|
+
}, iconProps)));
|
42
|
+
};
|
43
|
+
export default ResponseToolbarIcon;
|
@@ -2,4 +2,5 @@ export { default } from './Response';
|
|
2
2
|
export { default as ResponseAttachment } from './ResponseAttachment';
|
3
3
|
export { default as ResponseList } from './ResponseList';
|
4
4
|
export { default as ResponseText } from './ResponseText';
|
5
|
-
export { default as ResponseToolbar } from './ResponseToolbar';
|
5
|
+
export { default as ResponseToolbar } from './ResponseToolbar';
|
6
|
+
export { default as ResponseToolbarIcon } from './ResponseToolbarIcon';
|
package/lib/index.js
CHANGED
@@ -20,6 +20,7 @@ export { default as ResponseAttachment } from './components/AIComponents/Respons
|
|
20
20
|
export { default as ResponseList } from './components/AIComponents/Response/ResponseList';
|
21
21
|
export { default as ResponseText } from './components/AIComponents/Response/ResponseText';
|
22
22
|
export { default as ResponseToolbar } from './components/AIComponents/Response/ResponseToolbar';
|
23
|
+
export { default as ResponseToolbarIcon } from './components/AIComponents/Response/ResponseToolbarIcon';
|
23
24
|
export { default as Suggestions } from './components/AIComponents/Suggestions';
|
24
25
|
export { default as Suggestion } from './components/AIComponents/Suggestions/Suggestion';
|
25
26
|
export { default as ArrayField } from './components/ArrayField';
|
@@ -243,6 +243,12 @@ var iconButtons = {
|
|
243
243
|
base: _objectSpread({}, baseIconButton),
|
244
244
|
nextGen: _objectSpread({}, onyxIconButton),
|
245
245
|
onyx: _objectSpread({}, onyxIconButton),
|
246
|
+
responseToolbar: _objectSpread(_objectSpread({}, baseIconButton), {}, {
|
247
|
+
'&.is-not-loaded': {
|
248
|
+
display: 'none'
|
249
|
+
},
|
250
|
+
display: 'inline-flex'
|
251
|
+
}),
|
246
252
|
modalCloseButton: modalCloseButton,
|
247
253
|
badge: {
|
248
254
|
deleteButton: _objectSpread(_objectSpread({}, baseIconButton), {}, {
|