@pingux/astro 2.112.0-alpha.1 → 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/components/DataTable/DataTable.js +9 -1
- package/lib/cjs/components/DataTable/DataTable.stories.js +23 -16
- package/lib/cjs/components/DataTable/DataTable.styles.d.ts +7 -1
- package/lib/cjs/components/DataTable/DataTable.styles.js +10 -2
- package/lib/cjs/components/DataTable/DataTableBadge.js +5 -32
- package/lib/cjs/components/DataTable/DataTableBadge.test.js +0 -2
- package/lib/cjs/components/Loader/Loader.js +6 -5
- 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/loader.d.ts +2 -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/components/DataTable/DataTable.js +9 -1
- package/lib/components/DataTable/DataTable.stories.js +23 -16
- package/lib/components/DataTable/DataTable.styles.js +10 -2
- package/lib/components/DataTable/DataTableBadge.js +6 -33
- package/lib/components/DataTable/DataTableBadge.test.js +0 -2
- package/lib/components/Loader/Loader.js +6 -5
- package/lib/index.js +1 -0
- package/lib/styles/themes/next-gen/variants/button.js +6 -0
- package/package.json +1 -1
@@ -11,9 +11,6 @@ _Object$defineProperty(exports, "__esModule", {
|
|
11
11
|
exports["default"] = void 0;
|
12
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
13
13
|
var _react = _interopRequireWildcard(require("react"));
|
14
|
-
var _AlertCircleIcon = _interopRequireDefault(require("@pingux/mdi-react/AlertCircleIcon"));
|
15
|
-
var _AlertIcon = _interopRequireDefault(require("@pingux/mdi-react/AlertIcon"));
|
16
|
-
var _CheckIcon = _interopRequireDefault(require("@pingux/mdi-react/CheckIcon"));
|
17
14
|
var _index = require("../../index");
|
18
15
|
var _react2 = require("@emotion/react");
|
19
16
|
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,53 +22,29 @@ var DataTableBadge = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
25
22
|
var componentProps = {
|
26
23
|
'Pending': {
|
27
24
|
badgeProps: {
|
28
|
-
variant: '
|
29
|
-
},
|
30
|
-
iconProps: {
|
31
|
-
icon: _CheckIcon["default"]
|
25
|
+
variant: 'activeStatusBadge'
|
32
26
|
}
|
33
27
|
},
|
34
28
|
'Failed': {
|
35
29
|
badgeProps: {
|
36
|
-
variant: '
|
37
|
-
},
|
38
|
-
iconProps: {
|
39
|
-
icon: _AlertIcon["default"],
|
40
|
-
title: {
|
41
|
-
name: 'Alert Icon'
|
42
|
-
}
|
30
|
+
variant: 'warningStatusBadge'
|
43
31
|
}
|
44
32
|
},
|
45
33
|
'Rejected': {
|
46
34
|
badgeProps: {
|
47
|
-
variant: '
|
48
|
-
},
|
49
|
-
iconProps: {
|
50
|
-
icon: _AlertCircleIcon["default"],
|
51
|
-
title: {
|
52
|
-
name: 'Alert Circle Icon'
|
53
|
-
}
|
35
|
+
variant: 'criticalStatusBadge'
|
54
36
|
}
|
55
37
|
},
|
56
38
|
'Approved': {
|
57
39
|
badgeProps: {
|
58
|
-
variant: '
|
59
|
-
},
|
60
|
-
iconProps: {
|
61
|
-
icon: _CheckIcon["default"],
|
62
|
-
title: {
|
63
|
-
name: 'Check Icon'
|
64
|
-
}
|
40
|
+
variant: 'healthyStatusBadge'
|
65
41
|
}
|
66
42
|
}
|
67
43
|
};
|
68
44
|
return (0, _react2.jsx)(_index.Badge, (0, _extends2["default"])({
|
69
45
|
label: cell,
|
70
46
|
ref: ref
|
71
|
-
}, cell && componentProps[cell].badgeProps)
|
72
|
-
mr: "xs",
|
73
|
-
size: "14px"
|
74
|
-
}, cell && componentProps[cell].iconProps)));
|
47
|
+
}, cell && componentProps[cell].badgeProps));
|
75
48
|
});
|
76
49
|
var _default = DataTableBadge;
|
77
50
|
exports["default"] = _default;
|
@@ -23,7 +23,6 @@ test('renders component with rejected label', function () {
|
|
23
23
|
cell: cell
|
24
24
|
});
|
25
25
|
expect(_react2.screen.queryByText('Rejected')).toBeInTheDocument();
|
26
|
-
expect(_react2.screen.queryByText('Alert Circle Icon')).toBeInTheDocument();
|
27
26
|
});
|
28
27
|
test('renders component with pending label', function () {
|
29
28
|
var cell = 'Pending';
|
@@ -38,7 +37,6 @@ test('renders component with failed label', function () {
|
|
38
37
|
cell: cell
|
39
38
|
});
|
40
39
|
expect(_react2.screen.queryByText('Failed')).toBeInTheDocument();
|
41
|
-
expect(_react2.screen.queryByText('Alert Icon')).toBeInTheDocument();
|
42
40
|
});
|
43
41
|
test('renders component with null cell', function () {
|
44
42
|
var cell = null;
|
@@ -14,11 +14,12 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-c
|
|
14
14
|
var _react = _interopRequireWildcard(require("react"));
|
15
15
|
var _Box = _interopRequireDefault(require("../Box"));
|
16
16
|
var _react2 = require("@emotion/react");
|
17
|
-
var _excluded = ["size"];
|
17
|
+
var _excluded = ["size", "dotProps"];
|
18
18
|
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); }
|
19
19
|
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; }
|
20
20
|
var Loader = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
21
21
|
var size = props.size,
|
22
|
+
dotProps = props.dotProps,
|
22
23
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
23
24
|
return (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({
|
24
25
|
ref: ref,
|
@@ -28,13 +29,13 @@ var Loader = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
28
29
|
role: "alert",
|
29
30
|
"aria-live": "assertive",
|
30
31
|
"aria-label": "Loading in progress"
|
31
|
-
}, others), (0, _react2.jsx)(_Box["default"], {
|
32
|
+
}, others), (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({
|
32
33
|
variant: "loader.dotLeft"
|
33
|
-
}), (0, _react2.jsx)(_Box["default"], {
|
34
|
+
}, dotProps)), (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({
|
34
35
|
variant: "loader.dotCenter"
|
35
|
-
}), (0, _react2.jsx)(_Box["default"], {
|
36
|
+
}, dotProps)), (0, _react2.jsx)(_Box["default"], (0, _extends2["default"])({
|
36
37
|
variant: "loader.dotRight"
|
37
|
-
}));
|
38
|
+
}, dotProps)));
|
38
39
|
});
|
39
40
|
var _default = Loader;
|
40
41
|
exports["default"] = _default;
|
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), {}, {
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { IconSize, StyleProps } from './shared';
|
2
|
+
import { BoxProps } from '.';
|
2
3
|
export interface LoaderProps extends StyleProps {
|
3
4
|
/**
|
4
5
|
* Color key from theme or string value.
|
@@ -6,4 +7,5 @@ export interface LoaderProps extends StyleProps {
|
|
6
7
|
*/
|
7
8
|
color?: string;
|
8
9
|
size?: IconSize;
|
10
|
+
dotProps?: BoxProps;
|
9
11
|
}
|
@@ -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;
|