@reltio/components 1.4.1711 → 1.4.1712

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. package/cjs/components/workflow/components/TaskActionButtons/TaskActionButtons.js +1 -1
  2. package/cjs/components/workflow/components/WorkflowComments/CollapsedComments.d.ts +8 -16
  3. package/cjs/components/workflow/components/WorkflowComments/CollapsedComments.js +0 -10
  4. package/cjs/components/workflow/components/WorkflowComments/Comment.d.ts +9 -20
  5. package/cjs/components/workflow/components/WorkflowComments/Comment.js +3 -14
  6. package/cjs/components/workflow/components/WorkflowComments/ExpandedComments.d.ts +7 -14
  7. package/cjs/components/workflow/components/WorkflowComments/ExpandedComments.js +2 -11
  8. package/cjs/components/workflow/components/WorkflowComments/WorkflowComments.d.ts +1 -1
  9. package/cjs/components/workflow/components/WorkflowComments/WorkflowComments.js +21 -28
  10. package/cjs/components/workflow/components/WorkflowComments/index.d.ts +1 -1
  11. package/esm/components/workflow/components/TaskActionButtons/TaskActionButtons.js +1 -1
  12. package/esm/components/workflow/components/WorkflowComments/CollapsedComments.d.ts +8 -16
  13. package/esm/components/workflow/components/WorkflowComments/CollapsedComments.js +0 -10
  14. package/esm/components/workflow/components/WorkflowComments/Comment.d.ts +9 -20
  15. package/esm/components/workflow/components/WorkflowComments/Comment.js +3 -14
  16. package/esm/components/workflow/components/WorkflowComments/ExpandedComments.d.ts +7 -14
  17. package/esm/components/workflow/components/WorkflowComments/ExpandedComments.js +2 -11
  18. package/esm/components/workflow/components/WorkflowComments/WorkflowComments.d.ts +1 -1
  19. package/esm/components/workflow/components/WorkflowComments/WorkflowComments.js +21 -28
  20. package/esm/components/workflow/components/WorkflowComments/index.d.ts +1 -1
  21. package/package.json +1 -1
@@ -17,7 +17,7 @@ var TaskActionButtons = function (_a) {
17
17
  assignee: assignee,
18
18
  isOpen: isOpen
19
19
  }), actions = _b.actions, disabled = _b.actionRequestIsInProgress;
20
- var _c = (0, ramda_1.partition)((0, ramda_1.propEq)('text', preferredAction.label), actions), preferredActions = _c[0], otherActions = _c[1];
20
+ var _c = (0, ramda_1.partition)((0, ramda_1.propEq)('text', preferredAction === null || preferredAction === void 0 ? void 0 : preferredAction.label), actions), preferredActions = _c[0], otherActions = _c[1];
21
21
  return (react_1.default.createElement(react_1.default.Fragment, null,
22
22
  otherActions.map(function (action) { return (react_1.default.createElement(Button_1.default, { variant: "outlined", onClick: action.onClick, key: action.text, disabled: disabled }, action.text)); }),
23
23
  preferredActions.map(function (action) { return (react_1.default.createElement(Button_1.default, { variant: "contained", color: "primary", onClick: action.onClick, key: action.text, disabled: disabled }, action.text)); })));
@@ -1,16 +1,8 @@
1
- export function CollapsedComments({ comments, onClick }: {
2
- comments: any;
3
- onClick: any;
4
- }): JSX.Element;
5
- export namespace CollapsedComments {
6
- namespace propTypes {
7
- const comments: PropTypes.Requireable<PropTypes.InferProps<{
8
- author: PropTypes.Requireable<string>;
9
- id: PropTypes.Requireable<string>;
10
- message: PropTypes.Requireable<string>;
11
- time: PropTypes.Requireable<number>;
12
- }>[]>;
13
- const onClick: PropTypes.Requireable<(...args: any[]) => any>;
14
- }
15
- }
16
- import PropTypes from 'prop-types';
1
+ import React from 'react';
2
+ import { WorkflowComment } from '@reltio/mdm-sdk';
3
+ type Props = {
4
+ comments: WorkflowComment[];
5
+ onClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
6
+ };
7
+ export declare const CollapsedComments: ({ comments, onClick }: Props) => JSX.Element;
8
+ export {};
@@ -16,7 +16,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.CollapsedComments = void 0;
18
18
  var react_1 = __importDefault(require("react"));
19
- var prop_types_1 = __importDefault(require("prop-types"));
20
19
  var IconButton_1 = __importDefault(require("@mui/material/IconButton"));
21
20
  var Comment_1 = require("./Comment");
22
21
  var styles_1 = require("./styles");
@@ -30,12 +29,3 @@ var CollapsedComments = function (_a) {
30
29
  react_1.default.createElement(Comment_1.Comment, __assign({}, comments[comments.length - 1]))));
31
30
  };
32
31
  exports.CollapsedComments = CollapsedComments;
33
- exports.CollapsedComments.propTypes = {
34
- comments: prop_types_1.default.arrayOf(prop_types_1.default.shape({
35
- author: prop_types_1.default.string,
36
- id: prop_types_1.default.string,
37
- message: prop_types_1.default.string,
38
- time: prop_types_1.default.number
39
- })),
40
- onClick: prop_types_1.default.func
41
- };
@@ -1,20 +1,9 @@
1
- export function Comment({ author, classes, message, time }: {
2
- author: any;
3
- classes: any;
4
- message: any;
5
- time: any;
6
- }): JSX.Element;
7
- export namespace Comment {
8
- namespace defaultProps {
9
- const classes: {};
10
- }
11
- namespace propTypes {
12
- const classes_1: PropTypes.Requireable<object>;
13
- export { classes_1 as classes };
14
- export const author: PropTypes.Requireable<string>;
15
- export const id: PropTypes.Requireable<string>;
16
- export const message: PropTypes.Requireable<string>;
17
- export const time: PropTypes.Requireable<number>;
18
- }
19
- }
20
- import PropTypes from 'prop-types';
1
+ /// <reference types="react" />
2
+ import { WorkflowComment } from '@reltio/mdm-sdk';
3
+ type Props = Pick<WorkflowComment, 'author' | 'message' | 'time'> & {
4
+ classes?: {
5
+ messageContainer?: string;
6
+ };
7
+ };
8
+ export declare const Comment: ({ author, message, time, classes }: Props) => JSX.Element;
9
+ export {};
@@ -5,14 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Comment = void 0;
7
7
  var react_1 = __importDefault(require("react"));
8
- var prop_types_1 = __importDefault(require("prop-types"));
9
- var Avatar_1 = __importDefault(require("@mui/material/Avatar"));
10
- var Person_1 = __importDefault(require("@mui/icons-material/Person"));
11
8
  var ui_i18n_1 = __importDefault(require("ui-i18n"));
12
9
  var classnames_1 = __importDefault(require("classnames"));
10
+ var Avatar_1 = __importDefault(require("@mui/material/Avatar"));
11
+ var Person_1 = __importDefault(require("@mui/icons-material/Person"));
13
12
  var styles_1 = require("./styles");
14
13
  var Comment = function (_a) {
15
- var author = _a.author, classes = _a.classes, message = _a.message, time = _a.time;
14
+ var author = _a.author, message = _a.message, time = _a.time, _b = _a.classes, classes = _b === void 0 ? {} : _b;
16
15
  var styles = (0, styles_1.useCommentStyles)();
17
16
  return (react_1.default.createElement("div", { className: styles.comment },
18
17
  react_1.default.createElement(Avatar_1.default, { className: styles.avatar },
@@ -24,13 +23,3 @@ var Comment = function (_a) {
24
23
  react_1.default.createElement("div", { className: styles.text }, message))));
25
24
  };
26
25
  exports.Comment = Comment;
27
- exports.Comment.defaultProps = {
28
- classes: {}
29
- };
30
- exports.Comment.propTypes = {
31
- classes: prop_types_1.default.object,
32
- author: prop_types_1.default.string,
33
- id: prop_types_1.default.string,
34
- message: prop_types_1.default.string,
35
- time: prop_types_1.default.number
36
- };
@@ -1,14 +1,7 @@
1
- export function ExpandedComments({ comments }: {
2
- comments: any;
3
- }): any;
4
- export namespace ExpandedComments {
5
- namespace propTypes {
6
- const comments: PropTypes.Requireable<PropTypes.InferProps<{
7
- author: PropTypes.Requireable<string>;
8
- id: PropTypes.Requireable<string>;
9
- message: PropTypes.Requireable<string>;
10
- time: PropTypes.Requireable<number>;
11
- }>[]>;
12
- }
13
- }
14
- import PropTypes from 'prop-types';
1
+ /// <reference types="react" />
2
+ import { WorkflowComment } from '@reltio/mdm-sdk';
3
+ type Props = {
4
+ comments: WorkflowComment[];
5
+ };
6
+ export declare const ExpandedComments: ({ comments }: Props) => JSX.Element;
7
+ export {};
@@ -5,23 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ExpandedComments = void 0;
7
7
  var react_1 = __importDefault(require("react"));
8
- var prop_types_1 = __importDefault(require("prop-types"));
9
8
  var Comment_1 = require("./Comment");
10
9
  var styles_1 = require("./styles");
11
10
  var ExpandedComments = function (_a) {
12
11
  var comments = _a.comments;
13
12
  var styles = (0, styles_1.useExpandedComments)();
14
- return comments.map(function (_a) {
13
+ return (react_1.default.createElement(react_1.default.Fragment, null, comments.map(function (_a) {
15
14
  var author = _a.author, id = _a.id, message = _a.message, time = _a.time;
16
15
  return (react_1.default.createElement(Comment_1.Comment, { classes: { messageContainer: styles.messageContainer }, key: id, author: author, message: message, time: time }));
17
- });
16
+ })));
18
17
  };
19
18
  exports.ExpandedComments = ExpandedComments;
20
- exports.ExpandedComments.propTypes = {
21
- comments: prop_types_1.default.arrayOf(prop_types_1.default.shape({
22
- author: prop_types_1.default.string,
23
- id: prop_types_1.default.string,
24
- message: prop_types_1.default.string,
25
- time: prop_types_1.default.number
26
- }))
27
- };
@@ -7,7 +7,7 @@ type Props = {
7
7
  processInstanceComments: WorkflowComment[];
8
8
  taskId: string;
9
9
  isTaskOpen: boolean;
10
- preferredAction: WorkflowAction;
10
+ preferredAction?: WorkflowAction;
11
11
  };
12
12
  export declare const WorkflowComments: ({ workflowActions: actions, actionRequestIsInProgress, processInstanceComments, taskId, isTaskOpen, preferredAction }: Props) => JSX.Element;
13
13
  export {};
@@ -22,22 +22,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
26
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
27
- if (ar || !(i in from)) {
28
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
29
- ar[i] = from[i];
30
- }
31
- }
32
- return to.concat(ar || Array.prototype.slice.call(from));
33
- };
34
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
35
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
27
  };
37
28
  Object.defineProperty(exports, "__esModule", { value: true });
38
29
  exports.WorkflowComments = void 0;
39
30
  var react_1 = __importStar(require("react"));
40
- var ramda_1 = require("ramda");
41
31
  var Input_1 = __importDefault(require("@mui/material/Input"));
42
32
  var InputAdornment_1 = __importDefault(require("@mui/material/InputAdornment"));
43
33
  var Send_1 = __importDefault(require("@mui/icons-material/Send"));
@@ -49,13 +39,12 @@ var styles_1 = require("./styles");
49
39
  var useWorkflowComments_1 = require("../../hooks/useWorkflowComments");
50
40
  var SmallIconButton_1 = require("../../../SmallIconButton");
51
41
  var ModeSwitcherSelect_1 = require("../../../ModeSwitcherSelect/ModeSwitcherSelect");
52
- var getValue = function (e) { return e.target.value; };
53
42
  var WorkflowComments = function (_a) {
54
43
  var actions = _a.workflowActions, actionRequestIsInProgress = _a.actionRequestIsInProgress, processInstanceComments = _a.processInstanceComments, taskId = _a.taskId, isTaskOpen = _a.isTaskOpen, preferredAction = _a.preferredAction;
55
44
  var styles = (0, styles_1.useWorkflowStyles)();
56
45
  var _b = (0, react_1.useState)(false), expanded = _b[0], setExpanded = _b[1];
57
46
  var _c = (0, react_1.useState)(''), comment = _c[0], setComment = _c[1];
58
- var _d = (0, react_1.useState)(preferredAction.label), currentAction = _d[0], setCurrentAction = _d[1];
47
+ var _d = (0, react_1.useState)(function () { var _a; return (preferredAction === null || preferredAction === void 0 ? void 0 : preferredAction.label) || ((_a = actions[0]) === null || _a === void 0 ? void 0 : _a.text); }), currentAction = _d[0], setCurrentAction = _d[1];
59
48
  var _e = (0, useWorkflowComments_1.useWorkflowComments)({
60
49
  processInstanceComments: processInstanceComments,
61
50
  taskId: taskId,
@@ -65,8 +54,10 @@ var WorkflowComments = function (_a) {
65
54
  writeComment(comment);
66
55
  setComment('');
67
56
  }, [comment, writeComment]);
68
- var onChange = (0, ramda_1.pipe)(getValue, setComment);
69
- var onKeyPressHandler = function (e) {
57
+ var handleChange = (0, react_1.useCallback)(function (event) {
58
+ setComment(event.target.value);
59
+ }, []);
60
+ var handleKeyPress = (0, react_1.useCallback)(function (e) {
70
61
  if (e.key === 'Enter') {
71
62
  if (comment.length > 0 && !e.shiftKey) {
72
63
  e.preventDefault();
@@ -77,18 +68,20 @@ var WorkflowComments = function (_a) {
77
68
  }
78
69
  e.preventDefault();
79
70
  }
80
- };
81
- var BUTTONS_GROUP = (0, react_1.useMemo)(function () { return __spreadArray([], actions.map(function (_a) {
82
- var text = _a.text, onClick = _a.onClick;
83
- return ({
84
- label: text,
85
- onClick: function () {
86
- setCurrentAction(text);
87
- onClick(comment);
88
- },
89
- value: text
71
+ }, [comment, sendComment]);
72
+ var buttonsGroup = (0, react_1.useMemo)(function () {
73
+ return actions.map(function (_a) {
74
+ var text = _a.text, onClick = _a.onClick;
75
+ return ({
76
+ label: text,
77
+ onClick: function () {
78
+ setCurrentAction(text);
79
+ onClick(comment);
80
+ },
81
+ value: text
82
+ });
90
83
  });
91
- }), true); }, [actions, comment]);
84
+ }, [actions, comment]);
92
85
  return (react_1.default.createElement("div", { className: styles.container },
93
86
  react_1.default.createElement("div", { className: styles.title },
94
87
  " ",
@@ -96,9 +89,9 @@ var WorkflowComments = function (_a) {
96
89
  " "),
97
90
  react_1.default.createElement("div", { className: styles.commentsContainer }, expanded || comments.length < 3 ? (react_1.default.createElement(ExpandedComments_1.ExpandedComments, { comments: comments })) : (react_1.default.createElement(CollapsedComments_1.CollapsedComments, { onClick: function () { return setExpanded(true); }, comments: comments }))),
98
91
  !readOnly && (react_1.default.createElement(Input_1.default, { endAdornment: react_1.default.createElement(InputAdornment_1.default, { position: "end", className: styles.sendButton },
99
- react_1.default.createElement(SmallIconButton_1.SmallIconButton, { icon: Send_1.default, disabled: comment.length === 0, onClick: sendComment, "data-reltio-id": "send-button" })), classes: { root: styles.filledInputRoot }, placeholder: ui_i18n_1.default.text('Write a comment'), value: comment, onKeyPress: onKeyPressHandler, onChange: onChange, disableUnderline: true, multiline: true })),
92
+ react_1.default.createElement(SmallIconButton_1.SmallIconButton, { icon: Send_1.default, disabled: comment.length === 0, onClick: sendComment, "data-reltio-id": "send-button" })), classes: { root: styles.filledInputRoot }, placeholder: ui_i18n_1.default.text('Write a comment'), value: comment, onKeyPress: handleKeyPress, onChange: handleChange, disableUnderline: true, multiline: true })),
100
93
  react_1.default.createElement("div", { className: styles.modeSwitcherWrapper },
101
- BUTTONS_GROUP.length === 1 && (react_1.default.createElement(Button_1.default, { variant: "outlined", onClick: BUTTONS_GROUP[0].onClick, disabled: actionRequestIsInProgress }, BUTTONS_GROUP[0].label)),
102
- BUTTONS_GROUP.length > 1 && (react_1.default.createElement(ModeSwitcherSelect_1.ModeSwitcherSelect, { buttonsGroup: BUTTONS_GROUP, value: currentAction, disabled: actionRequestIsInProgress })))));
94
+ buttonsGroup.length === 1 && (react_1.default.createElement(Button_1.default, { variant: "outlined", onClick: buttonsGroup[0].onClick, disabled: actionRequestIsInProgress }, buttonsGroup[0].label)),
95
+ buttonsGroup.length > 1 && (react_1.default.createElement(ModeSwitcherSelect_1.ModeSwitcherSelect, { buttonsGroup: buttonsGroup, value: currentAction, disabled: actionRequestIsInProgress })))));
103
96
  };
104
97
  exports.WorkflowComments = WorkflowComments;
@@ -1 +1 @@
1
- export { WorkflowComments as default } from "./WorkflowComments";
1
+ export { WorkflowComments as default } from './WorkflowComments';
@@ -11,7 +11,7 @@ export var TaskActionButtons = function (_a) {
11
11
  assignee: assignee,
12
12
  isOpen: isOpen
13
13
  }), actions = _b.actions, disabled = _b.actionRequestIsInProgress;
14
- var _c = partition(propEq('text', preferredAction.label), actions), preferredActions = _c[0], otherActions = _c[1];
14
+ var _c = partition(propEq('text', preferredAction === null || preferredAction === void 0 ? void 0 : preferredAction.label), actions), preferredActions = _c[0], otherActions = _c[1];
15
15
  return (React.createElement(React.Fragment, null,
16
16
  otherActions.map(function (action) { return (React.createElement(Button, { variant: "outlined", onClick: action.onClick, key: action.text, disabled: disabled }, action.text)); }),
17
17
  preferredActions.map(function (action) { return (React.createElement(Button, { variant: "contained", color: "primary", onClick: action.onClick, key: action.text, disabled: disabled }, action.text)); })));
@@ -1,16 +1,8 @@
1
- export function CollapsedComments({ comments, onClick }: {
2
- comments: any;
3
- onClick: any;
4
- }): JSX.Element;
5
- export namespace CollapsedComments {
6
- namespace propTypes {
7
- const comments: PropTypes.Requireable<PropTypes.InferProps<{
8
- author: PropTypes.Requireable<string>;
9
- id: PropTypes.Requireable<string>;
10
- message: PropTypes.Requireable<string>;
11
- time: PropTypes.Requireable<number>;
12
- }>[]>;
13
- const onClick: PropTypes.Requireable<(...args: any[]) => any>;
14
- }
15
- }
16
- import PropTypes from 'prop-types';
1
+ import React from 'react';
2
+ import { WorkflowComment } from '@reltio/mdm-sdk';
3
+ type Props = {
4
+ comments: WorkflowComment[];
5
+ onClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
6
+ };
7
+ export declare const CollapsedComments: ({ comments, onClick }: Props) => JSX.Element;
8
+ export {};
@@ -10,7 +10,6 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import React from 'react';
13
- import PropTypes from 'prop-types';
14
13
  import IconButton from '@mui/material/IconButton';
15
14
  import { Comment } from './Comment';
16
15
  import { useCollapsedCommentsStyles } from './styles';
@@ -23,12 +22,3 @@ export var CollapsedComments = function (_a) {
23
22
  React.createElement(IconButton, { className: styles.circleButton, onClick: onClick, size: "large" }, comments.length - 2)),
24
23
  React.createElement(Comment, __assign({}, comments[comments.length - 1]))));
25
24
  };
26
- CollapsedComments.propTypes = {
27
- comments: PropTypes.arrayOf(PropTypes.shape({
28
- author: PropTypes.string,
29
- id: PropTypes.string,
30
- message: PropTypes.string,
31
- time: PropTypes.number
32
- })),
33
- onClick: PropTypes.func
34
- };
@@ -1,20 +1,9 @@
1
- export function Comment({ author, classes, message, time }: {
2
- author: any;
3
- classes: any;
4
- message: any;
5
- time: any;
6
- }): JSX.Element;
7
- export namespace Comment {
8
- namespace defaultProps {
9
- const classes: {};
10
- }
11
- namespace propTypes {
12
- const classes_1: PropTypes.Requireable<object>;
13
- export { classes_1 as classes };
14
- export const author: PropTypes.Requireable<string>;
15
- export const id: PropTypes.Requireable<string>;
16
- export const message: PropTypes.Requireable<string>;
17
- export const time: PropTypes.Requireable<number>;
18
- }
19
- }
20
- import PropTypes from 'prop-types';
1
+ /// <reference types="react" />
2
+ import { WorkflowComment } from '@reltio/mdm-sdk';
3
+ type Props = Pick<WorkflowComment, 'author' | 'message' | 'time'> & {
4
+ classes?: {
5
+ messageContainer?: string;
6
+ };
7
+ };
8
+ export declare const Comment: ({ author, message, time, classes }: Props) => JSX.Element;
9
+ export {};
@@ -1,12 +1,11 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import Avatar from '@mui/material/Avatar';
4
- import Person from '@mui/icons-material/Person';
5
2
  import i18n from 'ui-i18n';
6
3
  import classnames from 'classnames';
4
+ import Avatar from '@mui/material/Avatar';
5
+ import Person from '@mui/icons-material/Person';
7
6
  import { useCommentStyles } from './styles';
8
7
  export var Comment = function (_a) {
9
- var author = _a.author, classes = _a.classes, message = _a.message, time = _a.time;
8
+ var author = _a.author, message = _a.message, time = _a.time, _b = _a.classes, classes = _b === void 0 ? {} : _b;
10
9
  var styles = useCommentStyles();
11
10
  return (React.createElement("div", { className: styles.comment },
12
11
  React.createElement(Avatar, { className: styles.avatar },
@@ -17,13 +16,3 @@ export var Comment = function (_a) {
17
16
  React.createElement("span", { className: styles.date }, i18n.date(time, 'L LT'))),
18
17
  React.createElement("div", { className: styles.text }, message))));
19
18
  };
20
- Comment.defaultProps = {
21
- classes: {}
22
- };
23
- Comment.propTypes = {
24
- classes: PropTypes.object,
25
- author: PropTypes.string,
26
- id: PropTypes.string,
27
- message: PropTypes.string,
28
- time: PropTypes.number
29
- };
@@ -1,14 +1,7 @@
1
- export function ExpandedComments({ comments }: {
2
- comments: any;
3
- }): any;
4
- export namespace ExpandedComments {
5
- namespace propTypes {
6
- const comments: PropTypes.Requireable<PropTypes.InferProps<{
7
- author: PropTypes.Requireable<string>;
8
- id: PropTypes.Requireable<string>;
9
- message: PropTypes.Requireable<string>;
10
- time: PropTypes.Requireable<number>;
11
- }>[]>;
12
- }
13
- }
14
- import PropTypes from 'prop-types';
1
+ /// <reference types="react" />
2
+ import { WorkflowComment } from '@reltio/mdm-sdk';
3
+ type Props = {
4
+ comments: WorkflowComment[];
5
+ };
6
+ export declare const ExpandedComments: ({ comments }: Props) => JSX.Element;
7
+ export {};
@@ -1,20 +1,11 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import { Comment } from './Comment';
4
3
  import { useExpandedComments } from './styles';
5
4
  export var ExpandedComments = function (_a) {
6
5
  var comments = _a.comments;
7
6
  var styles = useExpandedComments();
8
- return comments.map(function (_a) {
7
+ return (React.createElement(React.Fragment, null, comments.map(function (_a) {
9
8
  var author = _a.author, id = _a.id, message = _a.message, time = _a.time;
10
9
  return (React.createElement(Comment, { classes: { messageContainer: styles.messageContainer }, key: id, author: author, message: message, time: time }));
11
- });
12
- };
13
- ExpandedComments.propTypes = {
14
- comments: PropTypes.arrayOf(PropTypes.shape({
15
- author: PropTypes.string,
16
- id: PropTypes.string,
17
- message: PropTypes.string,
18
- time: PropTypes.number
19
- }))
10
+ })));
20
11
  };
@@ -7,7 +7,7 @@ type Props = {
7
7
  processInstanceComments: WorkflowComment[];
8
8
  taskId: string;
9
9
  isTaskOpen: boolean;
10
- preferredAction: WorkflowAction;
10
+ preferredAction?: WorkflowAction;
11
11
  };
12
12
  export declare const WorkflowComments: ({ workflowActions: actions, actionRequestIsInProgress, processInstanceComments, taskId, isTaskOpen, preferredAction }: Props) => JSX.Element;
13
13
  export {};
@@ -1,14 +1,4 @@
1
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
- if (ar || !(i in from)) {
4
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
- ar[i] = from[i];
6
- }
7
- }
8
- return to.concat(ar || Array.prototype.slice.call(from));
9
- };
10
1
  import React, { useCallback, useState, useMemo } from 'react';
11
- import { pipe } from 'ramda';
12
2
  import Input from '@mui/material/Input';
13
3
  import InputAdornment from '@mui/material/InputAdornment';
14
4
  import SendIcon from '@mui/icons-material/Send';
@@ -20,13 +10,12 @@ import { useWorkflowStyles } from './styles';
20
10
  import { useWorkflowComments } from '../../hooks/useWorkflowComments';
21
11
  import { SmallIconButton } from '../../../SmallIconButton';
22
12
  import { ModeSwitcherSelect } from '../../../ModeSwitcherSelect/ModeSwitcherSelect';
23
- var getValue = function (e) { return e.target.value; };
24
13
  export var WorkflowComments = function (_a) {
25
14
  var actions = _a.workflowActions, actionRequestIsInProgress = _a.actionRequestIsInProgress, processInstanceComments = _a.processInstanceComments, taskId = _a.taskId, isTaskOpen = _a.isTaskOpen, preferredAction = _a.preferredAction;
26
15
  var styles = useWorkflowStyles();
27
16
  var _b = useState(false), expanded = _b[0], setExpanded = _b[1];
28
17
  var _c = useState(''), comment = _c[0], setComment = _c[1];
29
- var _d = useState(preferredAction.label), currentAction = _d[0], setCurrentAction = _d[1];
18
+ var _d = useState(function () { var _a; return (preferredAction === null || preferredAction === void 0 ? void 0 : preferredAction.label) || ((_a = actions[0]) === null || _a === void 0 ? void 0 : _a.text); }), currentAction = _d[0], setCurrentAction = _d[1];
30
19
  var _e = useWorkflowComments({
31
20
  processInstanceComments: processInstanceComments,
32
21
  taskId: taskId,
@@ -36,8 +25,10 @@ export var WorkflowComments = function (_a) {
36
25
  writeComment(comment);
37
26
  setComment('');
38
27
  }, [comment, writeComment]);
39
- var onChange = pipe(getValue, setComment);
40
- var onKeyPressHandler = function (e) {
28
+ var handleChange = useCallback(function (event) {
29
+ setComment(event.target.value);
30
+ }, []);
31
+ var handleKeyPress = useCallback(function (e) {
41
32
  if (e.key === 'Enter') {
42
33
  if (comment.length > 0 && !e.shiftKey) {
43
34
  e.preventDefault();
@@ -48,18 +39,20 @@ export var WorkflowComments = function (_a) {
48
39
  }
49
40
  e.preventDefault();
50
41
  }
51
- };
52
- var BUTTONS_GROUP = useMemo(function () { return __spreadArray([], actions.map(function (_a) {
53
- var text = _a.text, onClick = _a.onClick;
54
- return ({
55
- label: text,
56
- onClick: function () {
57
- setCurrentAction(text);
58
- onClick(comment);
59
- },
60
- value: text
42
+ }, [comment, sendComment]);
43
+ var buttonsGroup = useMemo(function () {
44
+ return actions.map(function (_a) {
45
+ var text = _a.text, onClick = _a.onClick;
46
+ return ({
47
+ label: text,
48
+ onClick: function () {
49
+ setCurrentAction(text);
50
+ onClick(comment);
51
+ },
52
+ value: text
53
+ });
61
54
  });
62
- }), true); }, [actions, comment]);
55
+ }, [actions, comment]);
63
56
  return (React.createElement("div", { className: styles.container },
64
57
  React.createElement("div", { className: styles.title },
65
58
  " ",
@@ -67,8 +60,8 @@ export var WorkflowComments = function (_a) {
67
60
  " "),
68
61
  React.createElement("div", { className: styles.commentsContainer }, expanded || comments.length < 3 ? (React.createElement(ExpandedComments, { comments: comments })) : (React.createElement(CollapsedComments, { onClick: function () { return setExpanded(true); }, comments: comments }))),
69
62
  !readOnly && (React.createElement(Input, { endAdornment: React.createElement(InputAdornment, { position: "end", className: styles.sendButton },
70
- React.createElement(SmallIconButton, { icon: SendIcon, disabled: comment.length === 0, onClick: sendComment, "data-reltio-id": "send-button" })), classes: { root: styles.filledInputRoot }, placeholder: i18n.text('Write a comment'), value: comment, onKeyPress: onKeyPressHandler, onChange: onChange, disableUnderline: true, multiline: true })),
63
+ React.createElement(SmallIconButton, { icon: SendIcon, disabled: comment.length === 0, onClick: sendComment, "data-reltio-id": "send-button" })), classes: { root: styles.filledInputRoot }, placeholder: i18n.text('Write a comment'), value: comment, onKeyPress: handleKeyPress, onChange: handleChange, disableUnderline: true, multiline: true })),
71
64
  React.createElement("div", { className: styles.modeSwitcherWrapper },
72
- BUTTONS_GROUP.length === 1 && (React.createElement(Button, { variant: "outlined", onClick: BUTTONS_GROUP[0].onClick, disabled: actionRequestIsInProgress }, BUTTONS_GROUP[0].label)),
73
- BUTTONS_GROUP.length > 1 && (React.createElement(ModeSwitcherSelect, { buttonsGroup: BUTTONS_GROUP, value: currentAction, disabled: actionRequestIsInProgress })))));
65
+ buttonsGroup.length === 1 && (React.createElement(Button, { variant: "outlined", onClick: buttonsGroup[0].onClick, disabled: actionRequestIsInProgress }, buttonsGroup[0].label)),
66
+ buttonsGroup.length > 1 && (React.createElement(ModeSwitcherSelect, { buttonsGroup: buttonsGroup, value: currentAction, disabled: actionRequestIsInProgress })))));
74
67
  };
@@ -1 +1 @@
1
- export { WorkflowComments as default } from "./WorkflowComments";
1
+ export { WorkflowComments as default } from './WorkflowComments';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1711",
3
+ "version": "1.4.1712",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",