@dhis2/analytics 26.6.14 → 26.7.1

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 (54) hide show
  1. package/build/cjs/components/AboutAOUnit/AboutAOUnit.js +5 -3
  2. package/build/cjs/components/Interpretations/InterpretationModal/CommentAddForm.js +5 -4
  3. package/build/cjs/components/Interpretations/InterpretationModal/CommentUpdateForm.js +4 -3
  4. package/build/cjs/components/Interpretations/InterpretationsUnit/InterpretationForm.js +5 -4
  5. package/build/cjs/components/Interpretations/common/Interpretation/InterpretationUpdateForm.js +5 -4
  6. package/build/cjs/components/Interpretations/common/Message/Message.js +2 -2
  7. package/build/cjs/components/Interpretations/common/Message/MessageEditorContainer.js +5 -5
  8. package/build/cjs/components/Interpretations/common/index.js +0 -11
  9. package/build/cjs/components/{Interpretations/common/RichTextEditor/RichTextEditor.js → RichText/Editor/Editor.js} +76 -53
  10. package/build/cjs/components/RichText/Editor/__tests__/Editor.spec.js +38 -0
  11. package/build/cjs/components/RichText/Editor/__tests__/convertCtrlKey.spec.js +204 -0
  12. package/build/cjs/components/{Interpretations/common/RichTextEditor → RichText/Editor}/markdownHandler.js +12 -6
  13. package/build/cjs/components/{Interpretations/common/RichTextEditor/styles/RichTextEditor.style.js → RichText/Editor/styles/Editor.style.js} +2 -2
  14. package/build/cjs/components/RichText/Parser/MdParser.js +106 -0
  15. package/build/cjs/components/RichText/Parser/Parser.js +35 -0
  16. package/build/cjs/components/RichText/Parser/__tests__/MdParser.spec.js +42 -0
  17. package/build/cjs/components/RichText/Parser/__tests__/Parser.spec.js +41 -0
  18. package/build/cjs/components/RichText/index.js +26 -0
  19. package/build/cjs/components/{Interpretations/common/UserMention → UserMention}/UserMentionWrapper.js +19 -9
  20. package/build/cjs/components/{Interpretations/common/UserMention → UserMention}/styles/UserMentionWrapper.style.js +2 -2
  21. package/build/cjs/components/{Interpretations/common/UserMention → UserMention}/useUserSearchResults.js +2 -2
  22. package/build/cjs/index.js +58 -46
  23. package/build/cjs/locales/en/translations.json +11 -11
  24. package/build/cjs/locales/ne/translations.json +15 -15
  25. package/build/es/components/AboutAOUnit/AboutAOUnit.js +5 -3
  26. package/build/es/components/Interpretations/InterpretationModal/CommentAddForm.js +2 -1
  27. package/build/es/components/Interpretations/InterpretationModal/CommentUpdateForm.js +2 -1
  28. package/build/es/components/Interpretations/InterpretationsUnit/InterpretationForm.js +3 -2
  29. package/build/es/components/Interpretations/common/Interpretation/InterpretationUpdateForm.js +2 -1
  30. package/build/es/components/Interpretations/common/Message/Message.js +1 -1
  31. package/build/es/components/Interpretations/common/Message/MessageEditorContainer.js +5 -5
  32. package/build/es/components/Interpretations/common/index.js +0 -1
  33. package/build/es/components/{Interpretations/common/RichTextEditor/RichTextEditor.js → RichText/Editor/Editor.js} +51 -28
  34. package/build/es/components/RichText/Editor/__tests__/Editor.spec.js +35 -0
  35. package/build/es/components/RichText/Editor/__tests__/convertCtrlKey.spec.js +202 -0
  36. package/build/es/components/{Interpretations/common/RichTextEditor → RichText/Editor}/markdownHandler.js +12 -6
  37. package/build/es/components/{Interpretations/common/RichTextEditor/styles/RichTextEditor.style.js → RichText/Editor/styles/Editor.style.js} +2 -2
  38. package/build/es/components/RichText/Parser/MdParser.js +98 -0
  39. package/build/es/components/RichText/Parser/Parser.js +25 -0
  40. package/build/es/components/RichText/Parser/__tests__/MdParser.spec.js +40 -0
  41. package/build/es/components/RichText/Parser/__tests__/Parser.spec.js +38 -0
  42. package/build/es/components/RichText/index.js +3 -0
  43. package/build/es/components/{Interpretations/common/UserMention → UserMention}/UserMentionWrapper.js +19 -8
  44. package/build/es/components/UserMention/styles/UserMentionWrapper.style.js +16 -0
  45. package/build/es/components/{Interpretations/common/UserMention → UserMention}/useUserSearchResults.js +2 -2
  46. package/build/es/index.js +1 -0
  47. package/build/es/locales/en/translations.json +11 -11
  48. package/build/es/locales/ne/translations.json +15 -15
  49. package/package.json +2 -2
  50. package/build/cjs/components/Interpretations/common/RichTextEditor/index.js +0 -12
  51. package/build/es/components/Interpretations/common/RichTextEditor/index.js +0 -1
  52. package/build/es/components/Interpretations/common/UserMention/styles/UserMentionWrapper.style.js +0 -16
  53. /package/build/cjs/components/{Interpretations/common/UserMention → UserMention}/UserList.js +0 -0
  54. /package/build/es/components/{Interpretations/common/UserMention → UserMention}/UserList.js +0 -0
@@ -1,6 +1,6 @@
1
1
  import _JSXStyle from "styled-jsx/style";
2
2
  import i18n from '@dhis2/d2-i18n';
3
- import { CenteredContent, CircularLoader, Menu, MenuSectionHeader, MenuItem, Popper, Card, Portal } from '@dhis2/ui';
3
+ import { CenteredContent, CircularLoader, Layer, Menu, MenuSectionHeader, MenuItem, Popper, Card } from '@dhis2/ui';
4
4
  import PropTypes from 'prop-types';
5
5
  import React, { useState, useRef } from 'react';
6
6
  import { resolvedHeaderStyle, userMentionWrapperClasses } from './styles/UserMentionWrapper.style.js';
@@ -29,6 +29,7 @@ export const UserMentionWrapper = _ref => {
29
29
  inputReference,
30
30
  onUserSelect
31
31
  } = _ref;
32
+ const [listIsOpen, setListIsOpen] = useState(false);
32
33
  const [captureText, setCaptureText] = useState(false);
33
34
  const [capturedText, setCapturedText] = useState('');
34
35
  const [cloneText, setCloneText] = useState('');
@@ -44,6 +45,7 @@ export const UserMentionWrapper = _ref => {
44
45
  searchText: capturedText
45
46
  });
46
47
  const reset = () => {
48
+ setListIsOpen(false);
47
49
  setCaptureText(false);
48
50
  setCapturedText('');
49
51
  setCloneText('');
@@ -52,6 +54,12 @@ export const UserMentionWrapper = _ref => {
52
54
  clear();
53
55
  };
54
56
 
57
+ // focus the input/textarea when the user list is closed by clicking above the input/textarea
58
+ const onClick = () => inputReference.current.focus();
59
+
60
+ // close the user list when clicking in the input/textarea or outside of it (input/textarea blur)
61
+ const onUserListClose = () => reset();
62
+
55
63
  // event bubbles up from the input/textarea
56
64
  const onInput = _ref2 => {
57
65
  let {
@@ -64,7 +72,7 @@ export const UserMentionWrapper = _ref => {
64
72
  if (captureText) {
65
73
  clear();
66
74
  const spacePosition = value.indexOf(' ', captureStartPosition - 1);
67
- const filterValue = value.substring(captureStartPosition, spacePosition > 0 ? spacePosition : selectionEnd + 1);
75
+ const filterValue = value.substring(captureStartPosition, spacePosition > 0 ? spacePosition : selectionEnd + 1).replace(/\n+/, '');
68
76
  if (filterValue !== capturedText) {
69
77
  setCapturedText(filterValue);
70
78
  } else if (filterValue.length === 0) {
@@ -84,6 +92,7 @@ export const UserMentionWrapper = _ref => {
84
92
  selectionStart
85
93
  } = target;
86
94
  if (!captureText && key === '@') {
95
+ setListIsOpen(true);
87
96
  setCaptureText(true);
88
97
  setCaptureStartPosition(selectionStart + 1);
89
98
  setCloneText(target.value.substring(0, selectionStart) + '@');
@@ -135,17 +144,20 @@ export const UserMentionWrapper = _ref => {
135
144
  // position the cursor at the end
136
145
  requestAnimationFrame(() => inputReference.current.setSelectionRange(-1, -1), 0);
137
146
  };
138
- const onClick = user => () => onSelect(user);
147
+ const onUserClick = user => () => onSelect(user);
139
148
  return /*#__PURE__*/React.createElement("div", {
140
149
  onKeyDown: onKeyDown,
141
150
  onInput: onInput,
151
+ onClick: onClick,
142
152
  className: `jsx-${userMentionWrapperClasses.__hash}` + " " + "wrapper"
143
153
  }, children, /*#__PURE__*/React.createElement("div", {
144
154
  className: `jsx-${userMentionWrapperClasses.__hash}` + " " + "clone"
145
- }, /*#__PURE__*/React.createElement("pre", {
155
+ }, /*#__PURE__*/React.createElement("p", {
146
156
  ref: cloneRef,
147
157
  className: `jsx-${userMentionWrapperClasses.__hash}`
148
- }, cloneText)), captureText && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(Popper, {
158
+ }, cloneText)), listIsOpen && /*#__PURE__*/React.createElement(Layer, {
159
+ onBackdropClick: onUserListClose
160
+ }, /*#__PURE__*/React.createElement(Popper, {
149
161
  reference: getVirtualPopperReference(cloneRef),
150
162
  placement: "top-start"
151
163
  }, /*#__PURE__*/React.createElement(Card, null, /*#__PURE__*/React.createElement("div", {
@@ -166,7 +178,7 @@ export const UserMentionWrapper = _ref => {
166
178
  }), !fetching && users.length > 0 && /*#__PURE__*/React.createElement(UserList, {
167
179
  users: users,
168
180
  selectedUserIndex: selectedUserIndex,
169
- onUserClick: onClick,
181
+ onUserClick: onUserClick,
170
182
  pager: pager
171
183
  }), capturedText && !fetching && users.length === 0 && /*#__PURE__*/React.createElement(MenuItem, {
172
184
  dense: true,
@@ -183,5 +195,4 @@ UserMentionWrapper.propTypes = {
183
195
  inputReference: PropTypes.object.isRequired,
184
196
  onUserSelect: PropTypes.func.isRequired,
185
197
  children: PropTypes.node
186
- };
187
- export default UserMentionWrapper;
198
+ };
@@ -0,0 +1,16 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import React from "react";
3
+ import { colors, spacers } from '@dhis2/ui';
4
+ /*
5
+ * Note that the clone and clone > pre styles have been chosen
6
+ * to emulate the styles of the textarea. If we decide to make
7
+ * changes there, they should be refelcted here too.
8
+ */
9
+ export const userMentionWrapperClasses = [".wrapper.jsx-2386066169{width:100%;height:100%;position:relative;}", `.clone.jsx-2386066169{position:absolute;visibility:hidden;inset:0;box-sizing:border-box;padding:${spacers.dp8} 15px;border:1px solid ${colors.grey500};font-size:14px;line-height:${spacers.dp16};z-index:1;pointer-events:none;}`, ".clone.jsx-2386066169>p.jsx-2386066169{display:inline;word-wrap:break-word;overflow-wrap:break-word;font:inherit;margin:0;white-space:break-spaces;}", `.container.jsx-2386066169{background-color:${colors.white};max-height:180px;overflow:auto;}`];
10
+ userMentionWrapperClasses.__hash = "2386066169";
11
+ export const resolvedHeaderStyle = {
12
+ styles: /*#__PURE__*/React.createElement(_JSXStyle, {
13
+ id: "4275958396"
14
+ }, [".jsx-4275958396{position:-webkit-sticky;position:sticky;top:0;}"]),
15
+ className: "jsx-4275958396"
16
+ };
@@ -46,10 +46,10 @@ export const useUserSearchResults = _ref2 => {
46
46
  return () => debouncedRefetch.cancel();
47
47
  }, [searchText, debouncedRefetch]);
48
48
  useEffect(() => {
49
- if (data) {
49
+ if (fetching === false && data) {
50
50
  setData(data.users);
51
51
  }
52
- }, [data]);
52
+ }, [data, fetching]);
53
53
  return {
54
54
  users,
55
55
  pager,
package/build/es/index.js CHANGED
@@ -22,6 +22,7 @@ export * from './components/Toolbar/index.js';
22
22
  export { TranslationDialog } from './components/TranslationDialog/index.js';
23
23
  export { OfflineTooltip } from './components/OfflineTooltip.js';
24
24
  export { CachedDataQueryProvider, useCachedDataQuery } from './components/CachedDataQueryProvider.js';
25
+ export * from './components/RichText/index.js';
25
26
 
26
27
  // Api
27
28
 
@@ -134,17 +134,6 @@
134
134
  "Manage sharing": "Manage sharing",
135
135
  "Could not update interpretation": "Could not update interpretation",
136
136
  "Enter interpretation text": "Enter interpretation text",
137
- "Bold text": "Bold text",
138
- "Italic text": "Italic text",
139
- "Link to a URL": "Link to a URL",
140
- "Mention a user": "Mention a user",
141
- "Add emoji": "Add emoji",
142
- "Preview": "Preview",
143
- "Back to write mode": "Back to write mode",
144
- "Too many results. Try refining the search.": "Too many results. Try refining the search.",
145
- "Search for a user": "Search for a user",
146
- "Searching for \"{{- searchText}}\"": "Searching for \"{{- searchText}}\"",
147
- "No results found": "No results found",
148
137
  "Not available offline": "Not available offline",
149
138
  "Created by": "Created by",
150
139
  "Anyone": "Anyone",
@@ -276,6 +265,13 @@
276
265
  "Six-months": "Six-months",
277
266
  "Financial Years": "Financial Years",
278
267
  "Years": "Years",
268
+ "Bold text": "Bold text",
269
+ "Italic text": "Italic text",
270
+ "Link to a URL": "Link to a URL",
271
+ "Mention a user": "Mention a user",
272
+ "Add emoji": "Add emoji",
273
+ "Preview": "Preview",
274
+ "Back to write mode": "Back to write mode",
279
275
  "Interpretations and details": "Interpretations and details",
280
276
  "Translating to": "Translating to",
281
277
  "Choose a locale": "Choose a locale",
@@ -286,6 +282,10 @@
286
282
  "Cannot save while offline": "Cannot save while offline",
287
283
  "Could not load translations": "Could not load translations",
288
284
  "Retry": "Retry",
285
+ "Too many results. Try refining the search.": "Too many results. Try refining the search.",
286
+ "Search for a user": "Search for a user",
287
+ "Searching for \"{{- searchText}}\"": "Searching for \"{{- searchText}}\"",
288
+ "No results found": "No results found",
289
289
  "Series": "Series",
290
290
  "Category": "Category",
291
291
  "Filter": "Filter",
@@ -134,17 +134,6 @@
134
134
  "Manage sharing": "",
135
135
  "Could not update interpretation": "",
136
136
  "Enter interpretation text": "",
137
- "Bold text": "",
138
- "Italic text": "",
139
- "Link to a URL": "",
140
- "Mention a user": "",
141
- "Add emoji": "",
142
- "Preview": "",
143
- "Back to write mode": "",
144
- "Too many results. Try refining the search.": "",
145
- "Search for a user": "",
146
- "Searching for \"{{- searchText}}\"": "",
147
- "No results found": "कुनै पनि नतिजा भेटिएन",
148
137
  "Not available offline": "",
149
138
  "Created by": "",
150
139
  "Anyone": "",
@@ -203,12 +192,12 @@
203
192
  "Period type": "",
204
193
  "Year": "",
205
194
  "Select year": "",
206
- "Period": "",
195
+ "Period": "अबधि",
207
196
  "Selected Periods": "",
208
197
  "Relative periods": "",
209
198
  "Fixed periods": "",
210
199
  "No periods selected": "",
211
- "Daily": "",
200
+ "Daily": "दैनिक",
212
201
  "Weekly": "",
213
202
  "Weekly (Start Wednesday)": "",
214
203
  "Weekly (Start Thursday)": "",
@@ -225,8 +214,8 @@
225
214
  "Financial year (Start October)": "",
226
215
  "Financial year (Start July)": "",
227
216
  "Financial year (Start April)": "",
228
- "Today": "",
229
- "Yesterday": "",
217
+ "Today": "आज",
218
+ "Yesterday": "हिजो",
230
219
  "Last 3 days": "",
231
220
  "Last 7 days": "",
232
221
  "Last 14 days": "",
@@ -276,6 +265,13 @@
276
265
  "Six-months": "",
277
266
  "Financial Years": "",
278
267
  "Years": "",
268
+ "Bold text": "",
269
+ "Italic text": "",
270
+ "Link to a URL": "",
271
+ "Mention a user": "",
272
+ "Add emoji": "",
273
+ "Preview": "",
274
+ "Back to write mode": "",
279
275
  "Interpretations and details": "",
280
276
  "Translating to": "",
281
277
  "Choose a locale": "",
@@ -286,6 +282,10 @@
286
282
  "Cannot save while offline": "",
287
283
  "Could not load translations": "",
288
284
  "Retry": "",
285
+ "Too many results. Try refining the search.": "",
286
+ "Search for a user": "",
287
+ "Searching for \"{{- searchText}}\"": "",
288
+ "No results found": "कुनै पनि नतिजा भेटिएन",
289
289
  "Series": "",
290
290
  "Category": "",
291
291
  "Filter": "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2/analytics",
3
- "version": "26.6.14",
3
+ "version": "26.7.1",
4
4
  "main": "./build/cjs/index.js",
5
5
  "module": "./build/es/index.js",
6
6
  "exports": {
@@ -59,7 +59,6 @@
59
59
  "styled-jsx": "^4.0.1"
60
60
  },
61
61
  "dependencies": {
62
- "@dhis2/d2-ui-rich-text": "^7.4.1",
63
62
  "@dhis2/multi-calendar-dates": "1.0.0",
64
63
  "@dnd-kit/core": "^6.0.7",
65
64
  "@dnd-kit/sortable": "^7.0.2",
@@ -71,6 +70,7 @@
71
70
  "d3-color": "^1.2.3",
72
71
  "highcharts": "^10.3.3",
73
72
  "lodash": "^4.17.21",
73
+ "markdown-it": "^13.0.1",
74
74
  "mathjs": "^9.4.2",
75
75
  "react-beautiful-dnd": "^10.1.1",
76
76
  "resize-observer-polyfill": "^1.5.1"
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "RichTextEditor", {
7
- enumerable: true,
8
- get: function () {
9
- return _RichTextEditor.RichTextEditor;
10
- }
11
- });
12
- var _RichTextEditor = require("./RichTextEditor.js");
@@ -1 +0,0 @@
1
- export { RichTextEditor } from './RichTextEditor.js';
@@ -1,16 +0,0 @@
1
- import _JSXStyle from "styled-jsx/style";
2
- import React from "react";
3
- import { colors, spacers } from '@dhis2/ui';
4
- /*
5
- * Note that the clone and clone > pre styles have been chosen
6
- * to emulate the styles of the textarea. If we decide to make
7
- * changes there, they should be refelcted here too.
8
- */
9
- export const userMentionWrapperClasses = [".wrapper.jsx-1289989717{position:relative;}", `.clone.jsx-1289989717{position:absolute;visibility:hidden;inset:0;box-sizing:border-box;padding:${spacers.dp8} ${spacers.dp12};border:1px solid ${colors.grey500};font-size:14px;line-height:${spacers.dp16};z-index:1;pointer-events:none;}`, ".clone.jsx-1289989717>pre.jsx-1289989717{display:inline;word-wrap:break-word;overflow-wrap:break-word;font:inherit;margin:0;}", `.container.jsx-1289989717{background-color:${colors.white};max-height:180px;overflow:auto;}`];
10
- userMentionWrapperClasses.__hash = "1289989717";
11
- export const resolvedHeaderStyle = {
12
- styles: /*#__PURE__*/React.createElement(_JSXStyle, {
13
- id: "4275958396"
14
- }, [".jsx-4275958396{position:-webkit-sticky;position:sticky;top:0;}"]),
15
- className: "jsx-4275958396"
16
- };