@dhis2/analytics 23.11.1 → 23.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/build/cjs/components/Interpretations/InterpretationModal/Comment.js +64 -0
  3. package/build/cjs/components/Interpretations/InterpretationModal/CommentAddForm.js +93 -0
  4. package/build/cjs/components/Interpretations/InterpretationModal/CommentDeleteButton.js +62 -0
  5. package/build/cjs/components/Interpretations/InterpretationModal/CommentUpdateForm.js +95 -0
  6. package/build/cjs/components/Interpretations/InterpretationModal/InterpretationModal.js +187 -0
  7. package/build/cjs/components/Interpretations/InterpretationModal/InterpretationThread.js +100 -0
  8. package/build/cjs/components/Interpretations/InterpretationModal/index.js +13 -0
  9. package/build/cjs/components/Interpretations/InterpretationModal/useModalContentWidth.js +39 -0
  10. package/build/cjs/components/Interpretations/InterpretationsUnit/InterpretationForm.js +94 -0
  11. package/build/cjs/components/Interpretations/InterpretationsUnit/InterpretationList.js +94 -0
  12. package/build/cjs/components/Interpretations/InterpretationsUnit/InterpretationsUnit.js +135 -0
  13. package/build/cjs/components/Interpretations/InterpretationsUnit/index.js +13 -0
  14. package/build/cjs/components/Interpretations/common/Interpretation/Interpretation.js +110 -0
  15. package/build/cjs/components/Interpretations/common/Interpretation/InterpretationDeleteButton.js +58 -0
  16. package/build/cjs/components/Interpretations/common/Interpretation/InterpretationSharingLink.js +50 -0
  17. package/build/cjs/components/Interpretations/common/Interpretation/InterpretationUpdateForm.js +108 -0
  18. package/build/cjs/components/Interpretations/common/Interpretation/index.js +21 -0
  19. package/build/cjs/components/Interpretations/common/Interpretation/useLike.js +53 -0
  20. package/build/cjs/components/Interpretations/common/Message/Message.js +55 -0
  21. package/build/cjs/components/Interpretations/common/Message/MessageButtonStrip.js +33 -0
  22. package/build/cjs/components/Interpretations/common/Message/MessageEditorContainer.js +42 -0
  23. package/build/cjs/components/Interpretations/common/Message/MessageIconButton.js +67 -0
  24. package/build/cjs/components/Interpretations/common/Message/MessageInput.js +31 -0
  25. package/build/cjs/components/Interpretations/common/Message/MessageStatsBar.js +33 -0
  26. package/build/cjs/components/Interpretations/common/Message/index.js +53 -0
  27. package/build/cjs/components/Interpretations/common/RichTextEditor/RichTextEditor.js +262 -0
  28. package/build/cjs/components/Interpretations/common/RichTextEditor/index.js +13 -0
  29. package/build/cjs/components/Interpretations/common/RichTextEditor/markdownHandler.js +148 -0
  30. package/build/cjs/components/Interpretations/common/RichTextEditor/styles/RichTextEditor.style.js +21 -0
  31. package/build/cjs/components/Interpretations/common/UserMention/UserList.js +48 -0
  32. package/build/cjs/components/Interpretations/common/UserMention/UserMentionWrapper.js +226 -0
  33. package/build/cjs/components/Interpretations/common/UserMention/styles/UserMentionWrapper.style.js +30 -0
  34. package/build/cjs/components/Interpretations/common/UserMention/useUserSearchResults.js +78 -0
  35. package/build/cjs/components/Interpretations/common/index.js +44 -0
  36. package/build/cjs/index.js +16 -0
  37. package/build/cjs/locales/ar/translations.json +32 -1
  38. package/build/cjs/locales/ar_EG/translations.json +32 -1
  39. package/build/cjs/locales/ar_IQ/translations.json +32 -1
  40. package/build/cjs/locales/ckb/translations.json +32 -1
  41. package/build/cjs/locales/cs/translations.json +32 -1
  42. package/build/cjs/locales/da/translations.json +32 -1
  43. package/build/cjs/locales/en/translations.json +32 -1
  44. package/build/cjs/locales/es/translations.json +32 -1
  45. package/build/cjs/locales/fr/translations.json +32 -1
  46. package/build/cjs/locales/id/translations.json +32 -1
  47. package/build/cjs/locales/km/translations.json +32 -1
  48. package/build/cjs/locales/lo/translations.json +32 -1
  49. package/build/cjs/locales/my/translations.json +32 -1
  50. package/build/cjs/locales/nb/translations.json +32 -1
  51. package/build/cjs/locales/nl/translations.json +32 -1
  52. package/build/cjs/locales/or/translations.json +32 -1
  53. package/build/cjs/locales/prs/translations.json +32 -1
  54. package/build/cjs/locales/ps/translations.json +32 -1
  55. package/build/cjs/locales/pt/translations.json +32 -1
  56. package/build/cjs/locales/pt_BR/translations.json +32 -1
  57. package/build/cjs/locales/ro/translations.json +32 -1
  58. package/build/cjs/locales/ru/translations.json +32 -1
  59. package/build/cjs/locales/sv/translations.json +32 -1
  60. package/build/cjs/locales/tet/translations.json +32 -1
  61. package/build/cjs/locales/tg/translations.json +32 -1
  62. package/build/cjs/locales/uk/translations.json +32 -1
  63. package/build/cjs/locales/ur/translations.json +32 -1
  64. package/build/cjs/locales/uz/translations.json +32 -1
  65. package/build/cjs/locales/uz_Latn/translations.json +32 -1
  66. package/build/cjs/locales/vi/translations.json +32 -1
  67. package/build/cjs/locales/zh/translations.json +32 -1
  68. package/build/cjs/locales/zh_CN/translations.json +32 -1
  69. package/build/es/components/Interpretations/InterpretationModal/Comment.js +45 -0
  70. package/build/es/components/Interpretations/InterpretationModal/CommentAddForm.js +70 -0
  71. package/build/es/components/Interpretations/InterpretationModal/CommentDeleteButton.js +47 -0
  72. package/build/es/components/Interpretations/InterpretationModal/CommentUpdateForm.js +73 -0
  73. package/build/es/components/Interpretations/InterpretationModal/InterpretationModal.js +165 -0
  74. package/build/es/components/Interpretations/InterpretationModal/InterpretationThread.js +79 -0
  75. package/build/es/components/Interpretations/InterpretationModal/index.js +1 -0
  76. package/build/es/components/Interpretations/InterpretationModal/useModalContentWidth.js +28 -0
  77. package/build/es/components/Interpretations/InterpretationsUnit/InterpretationForm.js +71 -0
  78. package/build/es/components/Interpretations/InterpretationsUnit/InterpretationList.js +78 -0
  79. package/build/es/components/Interpretations/InterpretationsUnit/InterpretationsUnit.js +112 -0
  80. package/build/es/components/Interpretations/InterpretationsUnit/index.js +1 -0
  81. package/build/es/components/Interpretations/common/Interpretation/Interpretation.js +87 -0
  82. package/build/es/components/Interpretations/common/Interpretation/InterpretationDeleteButton.js +43 -0
  83. package/build/es/components/Interpretations/common/Interpretation/InterpretationSharingLink.js +33 -0
  84. package/build/es/components/Interpretations/common/Interpretation/InterpretationUpdateForm.js +85 -0
  85. package/build/es/components/Interpretations/common/Interpretation/index.js +2 -0
  86. package/build/es/components/Interpretations/common/Interpretation/useLike.js +45 -0
  87. package/build/es/components/Interpretations/common/Message/Message.js +41 -0
  88. package/build/es/components/Interpretations/common/Message/MessageButtonStrip.js +21 -0
  89. package/build/es/components/Interpretations/common/Message/MessageEditorContainer.js +30 -0
  90. package/build/es/components/Interpretations/common/Message/MessageIconButton.js +54 -0
  91. package/build/es/components/Interpretations/common/Message/MessageInput.js +16 -0
  92. package/build/es/components/Interpretations/common/Message/MessageStatsBar.js +21 -0
  93. package/build/es/components/Interpretations/common/Message/index.js +6 -0
  94. package/build/es/components/Interpretations/common/RichTextEditor/RichTextEditor.js +240 -0
  95. package/build/es/components/Interpretations/common/RichTextEditor/index.js +1 -0
  96. package/build/es/components/Interpretations/common/RichTextEditor/markdownHandler.js +128 -0
  97. package/build/es/components/Interpretations/common/RichTextEditor/styles/RichTextEditor.style.js +9 -0
  98. package/build/es/components/Interpretations/common/UserMention/UserList.js +33 -0
  99. package/build/es/components/Interpretations/common/UserMention/UserMentionWrapper.js +202 -0
  100. package/build/es/components/Interpretations/common/UserMention/styles/UserMentionWrapper.style.js +17 -0
  101. package/build/es/components/Interpretations/common/UserMention/useUserSearchResults.js +63 -0
  102. package/build/es/components/Interpretations/common/index.js +3 -0
  103. package/build/es/index.js +2 -0
  104. package/build/es/locales/ar/translations.json +32 -1
  105. package/build/es/locales/ar_EG/translations.json +32 -1
  106. package/build/es/locales/ar_IQ/translations.json +32 -1
  107. package/build/es/locales/ckb/translations.json +32 -1
  108. package/build/es/locales/cs/translations.json +32 -1
  109. package/build/es/locales/da/translations.json +32 -1
  110. package/build/es/locales/en/translations.json +32 -1
  111. package/build/es/locales/es/translations.json +32 -1
  112. package/build/es/locales/fr/translations.json +32 -1
  113. package/build/es/locales/id/translations.json +32 -1
  114. package/build/es/locales/km/translations.json +32 -1
  115. package/build/es/locales/lo/translations.json +32 -1
  116. package/build/es/locales/my/translations.json +32 -1
  117. package/build/es/locales/nb/translations.json +32 -1
  118. package/build/es/locales/nl/translations.json +32 -1
  119. package/build/es/locales/or/translations.json +32 -1
  120. package/build/es/locales/prs/translations.json +32 -1
  121. package/build/es/locales/ps/translations.json +32 -1
  122. package/build/es/locales/pt/translations.json +32 -1
  123. package/build/es/locales/pt_BR/translations.json +32 -1
  124. package/build/es/locales/ro/translations.json +32 -1
  125. package/build/es/locales/ru/translations.json +32 -1
  126. package/build/es/locales/sv/translations.json +32 -1
  127. package/build/es/locales/tet/translations.json +32 -1
  128. package/build/es/locales/tg/translations.json +32 -1
  129. package/build/es/locales/uk/translations.json +32 -1
  130. package/build/es/locales/ur/translations.json +32 -1
  131. package/build/es/locales/uz/translations.json +32 -1
  132. package/build/es/locales/uz_Latn/translations.json +32 -1
  133. package/build/es/locales/vi/translations.json +32 -1
  134. package/build/es/locales/zh/translations.json +32 -1
  135. package/build/es/locales/zh_CN/translations.json +32 -1
  136. package/package.json +2 -1
@@ -0,0 +1,112 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import { useDataQuery } from '@dhis2/app-runtime';
3
+ import i18n from '@dhis2/d2-i18n';
4
+ import { CircularLoader, IconChevronDown24, IconChevronUp24, colors, spacers } from '@dhis2/ui';
5
+ import cx from 'classnames';
6
+ import PropTypes from 'prop-types';
7
+ import React, { useEffect, useState, useImperativeHandle, forwardRef } from 'react';
8
+ import { InterpretationForm } from './InterpretationForm.js';
9
+ import { InterpretationList } from './InterpretationList.js';
10
+ const interpretationsQuery = {
11
+ interpretations: {
12
+ resource: 'interpretations',
13
+ params: _ref => {
14
+ let {
15
+ type,
16
+ id
17
+ } = _ref;
18
+ return {
19
+ fields: ['access', 'id', 'user[displayName]', 'created', 'text', 'comments[id]', 'likes', 'likedBy[id]'],
20
+ filter: "".concat(type, ".id:eq:").concat(id)
21
+ };
22
+ }
23
+ }
24
+ };
25
+ export const InterpretationsUnit = /*#__PURE__*/forwardRef((_ref2, ref) => {
26
+ let {
27
+ currentUser,
28
+ type,
29
+ id,
30
+ onInterpretationClick,
31
+ onReplyIconClick,
32
+ disabled
33
+ } = _ref2;
34
+ const [isExpanded, setIsExpanded] = useState(true);
35
+ const {
36
+ data,
37
+ loading,
38
+ fetching,
39
+ refetch
40
+ } = useDataQuery(interpretationsQuery, {
41
+ lazy: true
42
+ });
43
+
44
+ const onCompleteAction = () => {
45
+ refetch({
46
+ type,
47
+ id
48
+ });
49
+ };
50
+
51
+ useImperativeHandle(ref, () => ({
52
+ refresh: onCompleteAction
53
+ }), []);
54
+ useEffect(() => {
55
+ if (id) {
56
+ refetch({
57
+ type,
58
+ id
59
+ });
60
+ }
61
+ }, [type, id]);
62
+ return /*#__PURE__*/React.createElement("div", {
63
+ className: _JSXStyle.dynamic([["4120713286", [spacers.dp16, colors.grey400, colors.white, spacers.dp32, colors.grey900]]]) + " " + (cx('container', {
64
+ expanded: isExpanded
65
+ }) || "")
66
+ }, fetching && !loading && /*#__PURE__*/React.createElement("div", {
67
+ className: _JSXStyle.dynamic([["4120713286", [spacers.dp16, colors.grey400, colors.white, spacers.dp32, colors.grey900]]]) + " " + "fetching-loader"
68
+ }, /*#__PURE__*/React.createElement(CircularLoader, {
69
+ small: true
70
+ })), /*#__PURE__*/React.createElement("div", {
71
+ onClick: () => setIsExpanded(!isExpanded),
72
+ className: _JSXStyle.dynamic([["4120713286", [spacers.dp16, colors.grey400, colors.white, spacers.dp32, colors.grey900]]]) + " " + "header"
73
+ }, /*#__PURE__*/React.createElement("span", {
74
+ className: _JSXStyle.dynamic([["4120713286", [spacers.dp16, colors.grey400, colors.white, spacers.dp32, colors.grey900]]]) + " " + "title"
75
+ }, i18n.t('Interpretations')), isExpanded ? /*#__PURE__*/React.createElement(IconChevronUp24, {
76
+ color: colors.grey700
77
+ }) : /*#__PURE__*/React.createElement(IconChevronDown24, {
78
+ color: colors.grey700
79
+ })), isExpanded && /*#__PURE__*/React.createElement(React.Fragment, null, loading && /*#__PURE__*/React.createElement("div", {
80
+ className: _JSXStyle.dynamic([["4120713286", [spacers.dp16, colors.grey400, colors.white, spacers.dp32, colors.grey900]]]) + " " + "loader"
81
+ }, /*#__PURE__*/React.createElement(CircularLoader, {
82
+ small: true
83
+ })), data && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InterpretationForm, {
84
+ currentUser: currentUser,
85
+ type: type,
86
+ id: id,
87
+ onSave: onCompleteAction,
88
+ disabled: disabled
89
+ }), /*#__PURE__*/React.createElement(InterpretationList, {
90
+ currentUser: currentUser,
91
+ interpretations: data.interpretations.interpretations,
92
+ onInterpretationClick: onInterpretationClick,
93
+ onReplyIconClick: onReplyIconClick,
94
+ refresh: onCompleteAction,
95
+ disabled: disabled
96
+ }))), /*#__PURE__*/React.createElement(_JSXStyle, {
97
+ id: "4120713286",
98
+ dynamic: [spacers.dp16, colors.grey400, colors.white, spacers.dp32, colors.grey900]
99
+ }, [".container.__jsx-style-dynamic-selector{position:relative;padding:".concat(spacers.dp16, ";border-bottom:1px solid ").concat(colors.grey400, ";background-color:").concat(colors.white, ";}"), ".fetching-loader.__jsx-style-dynamic-selector{position:absolute;inset:0px;background-color:rgba(255,255,255,0.8);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;z-index:1;}", ".expanded.__jsx-style-dynamic-selector{padding-bottom:".concat(spacers.dp32, ";}"), ".loader.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}", ".header.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;cursor:pointer;}", ".title.__jsx-style-dynamic-selector{font-size:16px;font-weight:500;line-height:21px;color:".concat(colors.grey900, ";}")]));
100
+ });
101
+ InterpretationsUnit.displayName = 'InterpretationsUnit';
102
+ InterpretationsUnit.defaultProps = {
103
+ onInterpretationClick: Function.prototype
104
+ };
105
+ InterpretationsUnit.propTypes = {
106
+ currentUser: PropTypes.object.isRequired,
107
+ id: PropTypes.string.isRequired,
108
+ type: PropTypes.string.isRequired,
109
+ disabled: PropTypes.bool,
110
+ onInterpretationClick: PropTypes.func,
111
+ onReplyIconClick: PropTypes.func
112
+ };
@@ -0,0 +1 @@
1
+ export { InterpretationsUnit } from './InterpretationsUnit.js';
@@ -0,0 +1,87 @@
1
+ import i18n from '@dhis2/d2-i18n';
2
+ import { Button, SharingDialog, IconReply16, IconShare16, IconThumbUp16, IconEdit16 } from '@dhis2/ui';
3
+ import PropTypes from 'prop-types';
4
+ import React, { useState } from 'react';
5
+ import { Message, MessageStatsBar, MessageIconButton } from '../index.js';
6
+ import { InterpretationDeleteButton } from './InterpretationDeleteButton.js';
7
+ import { InterpretationUpdateForm } from './InterpretationUpdateForm.js';
8
+ import { useLike } from './useLike.js';
9
+ export const Interpretation = _ref => {
10
+ let {
11
+ interpretation,
12
+ currentUser,
13
+ onClick,
14
+ onUpdated,
15
+ onDeleted,
16
+ disabled,
17
+ onReplyIconClick
18
+ } = _ref;
19
+ const [isUpdateMode, setIsUpdateMode] = useState(false);
20
+ const [showSharingDialog, setShowSharingDialog] = useState(false);
21
+ const {
22
+ toggleLike,
23
+ isLikedByCurrentUser,
24
+ toggleLikeInProgress
25
+ } = useLike({
26
+ interpretation,
27
+ currentUser,
28
+ onComplete: onUpdated
29
+ });
30
+ const shouldShowButton = !!onClick && !disabled;
31
+ return isUpdateMode ? /*#__PURE__*/React.createElement(InterpretationUpdateForm, {
32
+ close: () => setIsUpdateMode(false),
33
+ id: interpretation.id,
34
+ showSharingLink: interpretation.access.manage,
35
+ onComplete: onUpdated,
36
+ text: interpretation.text,
37
+ currentUser: currentUser
38
+ }) : /*#__PURE__*/React.createElement(Message, {
39
+ text: interpretation.text,
40
+ created: interpretation.created,
41
+ username: interpretation.user.displayName
42
+ }, !disabled && /*#__PURE__*/React.createElement(MessageStatsBar, null, /*#__PURE__*/React.createElement(MessageIconButton, {
43
+ tooltipContent: isLikedByCurrentUser ? i18n.t('Unlike') : i18n.t('Like'),
44
+ iconComponent: IconThumbUp16,
45
+ onClick: toggleLike,
46
+ selected: isLikedByCurrentUser,
47
+ count: interpretation.likes,
48
+ disabled: toggleLikeInProgress
49
+ }), /*#__PURE__*/React.createElement(MessageIconButton, {
50
+ tooltipContent: i18n.t('Reply'),
51
+ iconComponent: IconReply16,
52
+ onClick: () => onReplyIconClick(interpretation.id),
53
+ count: interpretation.comments.length
54
+ }), interpretation.access.manage && /*#__PURE__*/React.createElement(MessageIconButton, {
55
+ iconComponent: IconShare16,
56
+ tooltipContent: i18n.t('Share'),
57
+ onClick: () => setShowSharingDialog(true)
58
+ }), showSharingDialog && /*#__PURE__*/React.createElement(SharingDialog, {
59
+ open: true,
60
+ type: 'interpretation',
61
+ id: interpretation.id,
62
+ onClose: () => setShowSharingDialog(false)
63
+ }), interpretation.access.update && /*#__PURE__*/React.createElement(MessageIconButton, {
64
+ iconComponent: IconEdit16,
65
+ tooltipContent: i18n.t('Edit'),
66
+ onClick: () => setIsUpdateMode(true)
67
+ }), interpretation.access.delete && /*#__PURE__*/React.createElement(InterpretationDeleteButton, {
68
+ id: interpretation.id,
69
+ onComplete: onDeleted
70
+ })), shouldShowButton && /*#__PURE__*/React.createElement(Button, {
71
+ secondary: true,
72
+ small: true,
73
+ onClick: (_, event) => {
74
+ event.stopPropagation();
75
+ onClick(interpretation.id);
76
+ }
77
+ }, i18n.t('See interpretation')));
78
+ };
79
+ Interpretation.propTypes = {
80
+ currentUser: PropTypes.object.isRequired,
81
+ interpretation: PropTypes.object.isRequired,
82
+ onDeleted: PropTypes.func.isRequired,
83
+ onReplyIconClick: PropTypes.func.isRequired,
84
+ onUpdated: PropTypes.func.isRequired,
85
+ disabled: PropTypes.bool,
86
+ onClick: PropTypes.func
87
+ };
@@ -0,0 +1,43 @@
1
+ import { useDataMutation } from '@dhis2/app-runtime';
2
+ import i18n from '@dhis2/d2-i18n';
3
+ import { IconDelete16 } from '@dhis2/ui';
4
+ import PropTypes from 'prop-types';
5
+ import React from 'react';
6
+ import { MessageIconButton } from '../index.js';
7
+ const mutation = {
8
+ resource: 'interpretations',
9
+ id: _ref => {
10
+ let {
11
+ id
12
+ } = _ref;
13
+ return id;
14
+ },
15
+ type: 'delete'
16
+ };
17
+
18
+ const InterpretationDeleteButton = _ref2 => {
19
+ let {
20
+ id,
21
+ onComplete
22
+ } = _ref2;
23
+ const [remove, {
24
+ loading
25
+ }] = useDataMutation(mutation, {
26
+ onComplete,
27
+ variables: {
28
+ id
29
+ }
30
+ });
31
+ return /*#__PURE__*/React.createElement(MessageIconButton, {
32
+ tooltipContent: i18n.t('Delete'),
33
+ iconComponent: IconDelete16,
34
+ onClick: remove,
35
+ disabled: loading
36
+ });
37
+ };
38
+
39
+ InterpretationDeleteButton.propTypes = {
40
+ id: PropTypes.string.isRequired,
41
+ onComplete: PropTypes.func.isRequired
42
+ };
43
+ export { InterpretationDeleteButton };
@@ -0,0 +1,33 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import i18n from '@dhis2/d2-i18n';
3
+ import { SharingDialog, colors, spacers } from '@dhis2/ui';
4
+ import PropTypes from 'prop-types';
5
+ import React, { useState } from 'react';
6
+
7
+ const InterpretationSharingLink = _ref => {
8
+ let {
9
+ type,
10
+ id
11
+ } = _ref;
12
+ const [showSharingDialog, setShowSharingDialog] = useState(false);
13
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
14
+ className: _JSXStyle.dynamic([["3990725326", [spacers.dp4, spacers.dp8, colors.grey800]]]) + " " + "container"
15
+ }, /*#__PURE__*/React.createElement("span", {
16
+ onClick: () => setShowSharingDialog(true),
17
+ className: _JSXStyle.dynamic([["3990725326", [spacers.dp4, spacers.dp8, colors.grey800]]]) + " " + "link"
18
+ }, i18n.t('Manage sharing'))), showSharingDialog && /*#__PURE__*/React.createElement(SharingDialog, {
19
+ open: true,
20
+ type: type,
21
+ id: id,
22
+ onClose: () => setShowSharingDialog(false)
23
+ }), /*#__PURE__*/React.createElement(_JSXStyle, {
24
+ id: "3990725326",
25
+ dynamic: [spacers.dp4, spacers.dp8, colors.grey800]
26
+ }, [".container.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:end;-webkit-justify-content:flex-end;-ms-flex-pack:end;justify-content:flex-end;gap:".concat(spacers.dp4, ";margin-top:").concat(spacers.dp8, ";font-size:13px;color:").concat(colors.grey800, ";cursor:pointer;}"), ".link.__jsx-style-dynamic-selector{-webkit-text-decoration:underline;text-decoration:underline;}"]));
27
+ };
28
+
29
+ InterpretationSharingLink.propTypes = {
30
+ id: PropTypes.string,
31
+ type: PropTypes.string
32
+ };
33
+ export { InterpretationSharingLink };
@@ -0,0 +1,85 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import { useDataMutation } from '@dhis2/app-runtime';
3
+ import i18n from '@dhis2/d2-i18n';
4
+ import { Button, spacers, colors } from '@dhis2/ui';
5
+ import PropTypes from 'prop-types';
6
+ import React, { useState } from 'react';
7
+ import { MessageEditorContainer, RichTextEditor, MessageButtonStrip, InterpretationSharingLink } from '../index.js';
8
+ const mutation = {
9
+ resource: 'interpretations',
10
+ type: 'update',
11
+ partial: false,
12
+ id: _ref => {
13
+ let {
14
+ id
15
+ } = _ref;
16
+ return id;
17
+ },
18
+ data: _ref2 => {
19
+ let {
20
+ interpretationText
21
+ } = _ref2;
22
+ return interpretationText;
23
+ }
24
+ };
25
+ export const InterpretationUpdateForm = _ref3 => {
26
+ let {
27
+ close,
28
+ currentUser,
29
+ id,
30
+ onComplete,
31
+ showSharingLink,
32
+ text
33
+ } = _ref3;
34
+ const [interpretationText, setInterpretationText] = useState(text || '');
35
+ const [update, {
36
+ loading,
37
+ error
38
+ }] = useDataMutation(mutation, {
39
+ onComplete: () => {
40
+ onComplete();
41
+ close();
42
+ },
43
+ variables: {
44
+ id
45
+ }
46
+ });
47
+ const errorText = error ? error.message || i18n.t('Could not update interpretation') : '';
48
+ return /*#__PURE__*/React.createElement("div", {
49
+ className: _JSXStyle.dynamic([["2690082310", [spacers.dp8, spacers.dp8, colors.grey100]]]) + " " + "message"
50
+ }, /*#__PURE__*/React.createElement(MessageEditorContainer, {
51
+ currentUser: currentUser
52
+ }, /*#__PURE__*/React.createElement(RichTextEditor, {
53
+ inputPlaceholder: i18n.t('Enter interpretation text'),
54
+ onChange: setInterpretationText,
55
+ value: interpretationText,
56
+ disabled: loading,
57
+ errorText: errorText
58
+ }), showSharingLink && /*#__PURE__*/React.createElement(InterpretationSharingLink, {
59
+ id: id,
60
+ type: "interpretation"
61
+ }), /*#__PURE__*/React.createElement(MessageButtonStrip, null, /*#__PURE__*/React.createElement(Button, {
62
+ loading: loading,
63
+ primary: true,
64
+ small: true,
65
+ onClick: () => update({
66
+ interpretationText
67
+ })
68
+ }, i18n.t('Update')), /*#__PURE__*/React.createElement(Button, {
69
+ disabled: loading,
70
+ secondary: true,
71
+ small: true,
72
+ onClick: close
73
+ }, i18n.t('Cancel')))), /*#__PURE__*/React.createElement(_JSXStyle, {
74
+ id: "2690082310",
75
+ dynamic: [spacers.dp8, spacers.dp8, colors.grey100]
76
+ }, [".message.__jsx-style-dynamic-selector{padding:0 ".concat(spacers.dp8, " ").concat(spacers.dp8, ";background-color:").concat(colors.grey100, ";border-radius:5px;}")]));
77
+ };
78
+ InterpretationUpdateForm.propTypes = {
79
+ close: PropTypes.func.isRequired,
80
+ currentUser: PropTypes.object.isRequired,
81
+ id: PropTypes.string.isRequired,
82
+ onComplete: PropTypes.func.isRequired,
83
+ showSharingLink: PropTypes.bool,
84
+ text: PropTypes.string
85
+ };
@@ -0,0 +1,2 @@
1
+ export { Interpretation } from './Interpretation.js';
2
+ export { InterpretationSharingLink } from './InterpretationSharingLink.js';
@@ -0,0 +1,45 @@
1
+ import { useDataMutation } from '@dhis2/app-runtime';
2
+ import { useEffect, useRef, useState } from 'react';
3
+
4
+ const useLike = _ref => {
5
+ let {
6
+ interpretation,
7
+ currentUser,
8
+ onComplete
9
+ } = _ref;
10
+ const resource = "interpretations/".concat(interpretation.id, "/like");
11
+ const likeMutationRef = useRef({
12
+ resource,
13
+ type: 'create'
14
+ });
15
+ const unlikeMutationRef = useRef({
16
+ resource,
17
+ type: 'delete'
18
+ });
19
+ const [like, {
20
+ loading: likeLoading
21
+ }] = useDataMutation(likeMutationRef.current, {
22
+ onComplete
23
+ });
24
+ const [unlike, {
25
+ loading: unlikeLoading
26
+ }] = useDataMutation(unlikeMutationRef.current, {
27
+ onComplete
28
+ });
29
+ const [isLikedByCurrentUser, setIsLikedByCurrentUser] = useState(false);
30
+
31
+ const toggleLike = () => {
32
+ isLikedByCurrentUser ? unlike() : like();
33
+ };
34
+
35
+ useEffect(() => {
36
+ setIsLikedByCurrentUser(interpretation.likedBy.some(likedBy => likedBy.id === currentUser.id));
37
+ }, [currentUser, interpretation]);
38
+ return {
39
+ isLikedByCurrentUser,
40
+ toggleLike,
41
+ toggleLikeInProgress: likeLoading || unlikeLoading
42
+ };
43
+ };
44
+
45
+ export { useLike };
@@ -0,0 +1,41 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import { Parser as RichTextParser } from '@dhis2/d2-ui-rich-text';
3
+ import { UserAvatar, spacers, colors } from '@dhis2/ui';
4
+ import moment from 'moment';
5
+ import PropTypes from 'prop-types';
6
+ import React from 'react';
7
+
8
+ const Message = _ref => {
9
+ let {
10
+ children,
11
+ text,
12
+ created,
13
+ username
14
+ } = _ref;
15
+ return /*#__PURE__*/React.createElement("li", {
16
+ className: _JSXStyle.dynamic([["2436588813", [spacers.dp8, colors.grey100, spacers.dp8, colors.grey900, colors.grey600, colors.grey900, spacers.dp8]]]) + " " + "container"
17
+ }, /*#__PURE__*/React.createElement("div", {
18
+ className: _JSXStyle.dynamic([["2436588813", [spacers.dp8, colors.grey100, spacers.dp8, colors.grey900, colors.grey600, colors.grey900, spacers.dp8]]]) + " " + "header"
19
+ }, /*#__PURE__*/React.createElement(UserAvatar, {
20
+ name: username,
21
+ extrasmall: true
22
+ }), username, /*#__PURE__*/React.createElement("time", {
23
+ dateTime: created,
24
+ className: _JSXStyle.dynamic([["2436588813", [spacers.dp8, colors.grey100, spacers.dp8, colors.grey900, colors.grey600, colors.grey900, spacers.dp8]]])
25
+ }, moment(created).format('lll'))), /*#__PURE__*/React.createElement("div", {
26
+ className: _JSXStyle.dynamic([["2436588813", [spacers.dp8, colors.grey100, spacers.dp8, colors.grey900, colors.grey600, colors.grey900, spacers.dp8]]]) + " " + "content"
27
+ }, /*#__PURE__*/React.createElement(RichTextParser, null, text)), /*#__PURE__*/React.createElement("div", {
28
+ className: _JSXStyle.dynamic([["2436588813", [spacers.dp8, colors.grey100, spacers.dp8, colors.grey900, colors.grey600, colors.grey900, spacers.dp8]]]) + " " + "footer"
29
+ }, children), /*#__PURE__*/React.createElement(_JSXStyle, {
30
+ id: "2436588813",
31
+ dynamic: [spacers.dp8, colors.grey100, spacers.dp8, colors.grey900, colors.grey600, colors.grey900, spacers.dp8]
32
+ }, [".container.__jsx-style-dynamic-selector{padding:".concat(spacers.dp8, ";background-color:").concat(colors.grey100, ";border-radius:5px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;gap:").concat(spacers.dp8, ";}"), ".header.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:6px;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;font-size:13px;line-height:16px;color:".concat(colors.grey900, ";}"), ".header.__jsx-style-dynamic-selector time.__jsx-style-dynamic-selector{font-size:12px;color:".concat(colors.grey600, ";}"), ".content.__jsx-style-dynamic-selector{font-size:14px;line-height:19px;color:".concat(colors.grey900, ";}"), ".content.__jsx-style-dynamic-selector p:first-child{margin:0;}", ".footer.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-align-items:flex-start;-webkit-box-align:flex-start;-ms-flex-align:flex-start;align-items:flex-start;gap:".concat(spacers.dp8, ";}")]));
33
+ };
34
+
35
+ Message.propTypes = {
36
+ children: PropTypes.node.isRequired,
37
+ created: PropTypes.string.isRequired,
38
+ text: PropTypes.string.isRequired,
39
+ username: PropTypes.string.isRequired
40
+ };
41
+ export { Message };
@@ -0,0 +1,21 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import { spacers } from '@dhis2/ui';
3
+ import PropTypes from 'prop-types';
4
+ import React from 'react';
5
+
6
+ const MessageButtonStrip = _ref => {
7
+ let {
8
+ children
9
+ } = _ref;
10
+ return /*#__PURE__*/React.createElement("div", {
11
+ className: _JSXStyle.dynamic([["1819118406", [spacers.dp8, spacers.dp8]]]) + " " + "container"
12
+ }, children, /*#__PURE__*/React.createElement(_JSXStyle, {
13
+ id: "1819118406",
14
+ dynamic: [spacers.dp8, spacers.dp8]
15
+ }, [".container.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:".concat(spacers.dp8, ";margin-top:").concat(spacers.dp8, ";}")]));
16
+ };
17
+
18
+ MessageButtonStrip.propTypes = {
19
+ children: PropTypes.node.isRequired
20
+ };
21
+ export { MessageButtonStrip };
@@ -0,0 +1,30 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import { UserAvatar, spacers } from '@dhis2/ui';
3
+ import PropTypes from 'prop-types';
4
+ import React from 'react';
5
+
6
+ const MessageEditorContainer = _ref => {
7
+ let {
8
+ children,
9
+ currentUser
10
+ } = _ref;
11
+ return /*#__PURE__*/React.createElement("div", {
12
+ className: _JSXStyle.dynamic([["3807884305", [spacers.dp8, spacers.dp12]]]) + " " + "container"
13
+ }, /*#__PURE__*/React.createElement("div", {
14
+ className: _JSXStyle.dynamic([["3807884305", [spacers.dp8, spacers.dp12]]]) + " " + "avatar"
15
+ }, /*#__PURE__*/React.createElement(UserAvatar, {
16
+ name: currentUser.name,
17
+ medium: true
18
+ })), /*#__PURE__*/React.createElement("div", {
19
+ className: _JSXStyle.dynamic([["3807884305", [spacers.dp8, spacers.dp12]]]) + " " + "editor"
20
+ }, children), /*#__PURE__*/React.createElement(_JSXStyle, {
21
+ id: "3807884305",
22
+ dynamic: [spacers.dp8, spacers.dp12]
23
+ }, [".container.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:".concat(spacers.dp8, ";margin-top:").concat(spacers.dp12, ";}"), ".avatar.__jsx-style-dynamic-selector{-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;}", ".editor.__jsx-style-dynamic-selector{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;}"]));
24
+ };
25
+
26
+ MessageEditorContainer.propTypes = {
27
+ currentUser: PropTypes.object.isRequired,
28
+ children: PropTypes.node
29
+ };
30
+ export { MessageEditorContainer };
@@ -0,0 +1,54 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import { Tooltip, colors, spacers } from '@dhis2/ui';
3
+ import cx from 'classnames';
4
+ import PropTypes from 'prop-types';
5
+ import React from 'react';
6
+
7
+ const MessageIconButton = _ref => {
8
+ let {
9
+ tooltipContent,
10
+ disabled,
11
+ onClick,
12
+ selected,
13
+ count,
14
+ iconComponent: Icon
15
+ } = _ref;
16
+ return /*#__PURE__*/React.createElement(Tooltip, {
17
+ closeDelay: 200,
18
+ content: tooltipContent
19
+ }, _ref2 => {
20
+ let {
21
+ ref,
22
+ onMouseOver,
23
+ onMouseOut
24
+ } = _ref2;
25
+ return /*#__PURE__*/React.createElement("span", {
26
+ ref: ref,
27
+ onMouseOver: onMouseOver,
28
+ onMouseOut: onMouseOut,
29
+ className: _JSXStyle.dynamic([["3807261824", [spacers.dp4, colors.grey700, colors.teal600, colors.grey900, colors.teal800, colors.teal500, colors.teal700]]]) + " " + "wrapper"
30
+ }, /*#__PURE__*/React.createElement("button", {
31
+ onClick: event => {
32
+ event.stopPropagation();
33
+ onClick();
34
+ },
35
+ disabled: disabled,
36
+ className: _JSXStyle.dynamic([["3807261824", [spacers.dp4, colors.grey700, colors.teal600, colors.grey900, colors.teal800, colors.teal500, colors.teal700]]]) + " " + (cx('button', {
37
+ selected
38
+ }) || "")
39
+ }, count && count, /*#__PURE__*/React.createElement(Icon, null)), /*#__PURE__*/React.createElement(_JSXStyle, {
40
+ id: "3807261824",
41
+ dynamic: [spacers.dp4, colors.grey700, colors.teal600, colors.grey900, colors.teal800, colors.teal500, colors.teal700]
42
+ }, [".wrapper.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;}", ".button.__jsx-style-dynamic-selector{all:unset;cursor:pointer;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;gap:".concat(spacers.dp4, ";-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;font-size:12px;line-height:14px;color:").concat(colors.grey700, ";}"), ".button.selected.__jsx-style-dynamic-selector{color:".concat(colors.teal600, ";font-weight:500;}"), ".button.__jsx-style-dynamic-selector:hover{color:".concat(colors.grey900, ";}"), ".button.selected.__jsx-style-dynamic-selector:hover{color:".concat(colors.teal800, ";}"), ".button.selected.__jsx-style-dynamic-selector svg{color:".concat(colors.teal500, ";}"), ".button.selected.__jsx-style-dynamic-selector:hover svg{color:".concat(colors.teal700, ";}")]));
43
+ });
44
+ };
45
+
46
+ MessageIconButton.propTypes = {
47
+ iconComponent: PropTypes.oneOfType([PropTypes.object, PropTypes.func]).isRequired,
48
+ tooltipContent: PropTypes.string.isRequired,
49
+ count: PropTypes.number,
50
+ disabled: PropTypes.bool,
51
+ selected: PropTypes.bool,
52
+ onClick: PropTypes.func
53
+ };
54
+ export { MessageIconButton };
@@ -0,0 +1,16 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+
3
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+
5
+ import { theme, colors } from '@dhis2/ui';
6
+ import React, { forwardRef } from 'react';
7
+ const MessageInput = /*#__PURE__*/forwardRef((props, ref) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("input", _extends({
8
+ ref: ref
9
+ }, props, {
10
+ className: _JSXStyle.dynamic([["2769305849", [colors.grey900, colors.grey500, theme.focus, colors.grey100, colors.grey500, theme.disabled]]]) + " " + (props && props.className != null && props.className || "input")
11
+ })), /*#__PURE__*/React.createElement(_JSXStyle, {
12
+ id: "2769305849",
13
+ dynamic: [colors.grey900, colors.grey500, theme.focus, colors.grey100, colors.grey500, theme.disabled]
14
+ }, [".input.__jsx-style-dynamic-selector{width:100%;box-sizing:border-box;font-size:14px;line-height:16px;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text;color:".concat(colors.grey900, ";background-color:white;padding:12px 11px 10px;outline:0;border:1px solid ").concat(colors.grey500, ";border-radius:3px;box-shadow:inset 0 1px 2px 0 rgba(48,54,60,0.1);text-overflow:ellipsis;}"), "input.__jsx-style-dynamic-selector:focus{outline:none;box-shadow:0 0 0 3px ".concat(theme.focus, ";}"), "input.disabled.__jsx-style-dynamic-selector{background-color:".concat(colors.grey100, ";border-color:").concat(colors.grey500, ";color:").concat(theme.disabled, ";cursor:not-allowed;}")])));
15
+ MessageInput.displayName = 'MessageInput';
16
+ export { MessageInput };
@@ -0,0 +1,21 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import { spacers } from '@dhis2/ui';
3
+ import PropTypes from 'prop-types';
4
+ import React from 'react';
5
+
6
+ const MessageStatsBar = _ref => {
7
+ let {
8
+ children
9
+ } = _ref;
10
+ return /*#__PURE__*/React.createElement("div", {
11
+ className: _JSXStyle.dynamic([["2534339265", [spacers.dp12]]]) + " " + "container"
12
+ }, children, /*#__PURE__*/React.createElement(_JSXStyle, {
13
+ id: "2534339265",
14
+ dynamic: [spacers.dp12]
15
+ }, [".container.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:".concat(spacers.dp12, ";}")]));
16
+ };
17
+
18
+ MessageStatsBar.propTypes = {
19
+ children: PropTypes.node.isRequired
20
+ };
21
+ export { MessageStatsBar };
@@ -0,0 +1,6 @@
1
+ export { Message } from './Message.js';
2
+ export { MessageButtonStrip } from './MessageButtonStrip.js';
3
+ export { MessageIconButton } from './MessageIconButton.js';
4
+ export { MessageInput } from './MessageInput.js';
5
+ export { MessageEditorContainer } from './MessageEditorContainer.js';
6
+ export { MessageStatsBar } from './MessageStatsBar.js';