@dhis2/analytics 26.6.14 → 26.7.0
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/build/cjs/components/AboutAOUnit/AboutAOUnit.js +5 -3
- package/build/cjs/components/Interpretations/InterpretationModal/CommentAddForm.js +5 -4
- package/build/cjs/components/Interpretations/InterpretationModal/CommentUpdateForm.js +4 -3
- package/build/cjs/components/Interpretations/InterpretationsUnit/InterpretationForm.js +5 -4
- package/build/cjs/components/Interpretations/common/Interpretation/InterpretationUpdateForm.js +5 -4
- package/build/cjs/components/Interpretations/common/Message/Message.js +2 -2
- package/build/cjs/components/Interpretations/common/Message/MessageEditorContainer.js +5 -5
- package/build/cjs/components/Interpretations/common/index.js +0 -11
- package/build/cjs/components/{Interpretations/common/RichTextEditor/RichTextEditor.js → RichText/Editor/Editor.js} +76 -53
- package/build/cjs/components/RichText/Editor/__tests__/Editor.spec.js +38 -0
- package/build/cjs/components/RichText/Editor/__tests__/convertCtrlKey.spec.js +204 -0
- package/build/cjs/components/{Interpretations/common/RichTextEditor → RichText/Editor}/markdownHandler.js +12 -6
- package/build/cjs/components/{Interpretations/common/RichTextEditor/styles/RichTextEditor.style.js → RichText/Editor/styles/Editor.style.js} +2 -2
- package/build/cjs/components/RichText/Parser/MdParser.js +106 -0
- package/build/cjs/components/RichText/Parser/Parser.js +35 -0
- package/build/cjs/components/RichText/Parser/__tests__/MdParser.spec.js +42 -0
- package/build/cjs/components/RichText/Parser/__tests__/Parser.spec.js +41 -0
- package/build/cjs/components/RichText/index.js +26 -0
- package/build/cjs/components/{Interpretations/common/UserMention → UserMention}/UserMentionWrapper.js +19 -9
- package/build/cjs/components/{Interpretations/common/UserMention → UserMention}/styles/UserMentionWrapper.style.js +2 -2
- package/build/cjs/components/{Interpretations/common/UserMention → UserMention}/useUserSearchResults.js +2 -2
- package/build/cjs/index.js +58 -46
- package/build/cjs/locales/en/translations.json +11 -11
- package/build/es/components/AboutAOUnit/AboutAOUnit.js +5 -3
- package/build/es/components/Interpretations/InterpretationModal/CommentAddForm.js +2 -1
- package/build/es/components/Interpretations/InterpretationModal/CommentUpdateForm.js +2 -1
- package/build/es/components/Interpretations/InterpretationsUnit/InterpretationForm.js +3 -2
- package/build/es/components/Interpretations/common/Interpretation/InterpretationUpdateForm.js +2 -1
- package/build/es/components/Interpretations/common/Message/Message.js +1 -1
- package/build/es/components/Interpretations/common/Message/MessageEditorContainer.js +5 -5
- package/build/es/components/Interpretations/common/index.js +0 -1
- package/build/es/components/{Interpretations/common/RichTextEditor/RichTextEditor.js → RichText/Editor/Editor.js} +51 -28
- package/build/es/components/RichText/Editor/__tests__/Editor.spec.js +35 -0
- package/build/es/components/RichText/Editor/__tests__/convertCtrlKey.spec.js +202 -0
- package/build/es/components/{Interpretations/common/RichTextEditor → RichText/Editor}/markdownHandler.js +12 -6
- package/build/es/components/{Interpretations/common/RichTextEditor/styles/RichTextEditor.style.js → RichText/Editor/styles/Editor.style.js} +2 -2
- package/build/es/components/RichText/Parser/MdParser.js +98 -0
- package/build/es/components/RichText/Parser/Parser.js +25 -0
- package/build/es/components/RichText/Parser/__tests__/MdParser.spec.js +40 -0
- package/build/es/components/RichText/Parser/__tests__/Parser.spec.js +38 -0
- package/build/es/components/RichText/index.js +3 -0
- package/build/es/components/{Interpretations/common/UserMention → UserMention}/UserMentionWrapper.js +19 -8
- package/build/es/components/UserMention/styles/UserMentionWrapper.style.js +16 -0
- package/build/es/components/{Interpretations/common/UserMention → UserMention}/useUserSearchResults.js +2 -2
- package/build/es/index.js +1 -0
- package/build/es/locales/en/translations.json +11 -11
- package/package.json +2 -2
- package/build/cjs/components/Interpretations/common/RichTextEditor/index.js +0 -12
- package/build/es/components/Interpretations/common/RichTextEditor/index.js +0 -1
- package/build/es/components/Interpretations/common/UserMention/styles/UserMentionWrapper.style.js +0 -16
- /package/build/cjs/components/{Interpretations/common/UserMention → UserMention}/UserList.js +0 -0
- /package/build/es/components/{Interpretations/common/UserMention → UserMention}/UserList.js +0 -0
package/build/es/components/{Interpretations/common/UserMention → UserMention}/UserMentionWrapper.js
RENAMED
|
@@ -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
|
|
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
|
|
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("
|
|
155
|
+
}, /*#__PURE__*/React.createElement("p", {
|
|
146
156
|
ref: cloneRef,
|
|
147
157
|
className: `jsx-${userMentionWrapperClasses.__hash}`
|
|
148
|
-
}, cloneText)),
|
|
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:
|
|
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",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2/analytics",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.7.0",
|
|
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';
|
package/build/es/components/Interpretations/common/UserMention/styles/UserMentionWrapper.style.js
DELETED
|
@@ -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
|
-
};
|
/package/build/cjs/components/{Interpretations/common/UserMention → UserMention}/UserList.js
RENAMED
|
File without changes
|
|
File without changes
|