@dhis2/analytics 26.2.0-cumulative-values-alpha.1 → 26.3.0-alpha.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 (41) hide show
  1. package/build/cjs/api/analytics/Analytics.js +7 -0
  2. package/build/cjs/api/analytics/AnalyticsBase.js +24 -6
  3. package/build/cjs/api/analytics/AnalyticsRequest.js +33 -10
  4. package/build/cjs/api/analytics/AnalyticsRequestBase.js +3 -1
  5. package/build/cjs/api/analytics/AnalyticsRequestPropertiesMixin.js +19 -0
  6. package/build/cjs/api/analytics/AnalyticsTrackedEntities.js +31 -0
  7. package/build/cjs/api/analytics/utils.js +23 -2
  8. package/build/cjs/modules/layout/dimension.js +9 -2
  9. package/build/cjs/modules/layout/dimensionCreate.js +3 -0
  10. package/build/es/api/analytics/Analytics.js +7 -0
  11. package/build/es/api/analytics/AnalyticsBase.js +24 -6
  12. package/build/es/api/analytics/AnalyticsRequest.js +33 -10
  13. package/build/es/api/analytics/AnalyticsRequestBase.js +3 -1
  14. package/build/es/api/analytics/AnalyticsRequestPropertiesMixin.js +19 -0
  15. package/build/es/api/analytics/AnalyticsTrackedEntities.js +24 -0
  16. package/build/es/api/analytics/utils.js +20 -1
  17. package/build/es/modules/layout/dimension.js +7 -1
  18. package/build/es/modules/layout/dimensionCreate.js +4 -1
  19. package/package.json +1 -1
  20. package/build/cjs/api/analytics/__tests__/AnalyticsTrackedEntities.spec.js +0 -44
  21. package/build/cjs/api/analytics/__tests__/__snapshots__/AnalyticsTrackedEntities.spec.js.snap +0 -3
  22. package/build/cjs/components/RichText/Editor.bk/Editor.js +0 -40
  23. package/build/cjs/components/RichText/Editor.bk/__tests__/Editor.spec.js +0 -29
  24. package/build/cjs/components/RichText/Editor.bk/__tests__/convertCtrlKey.spec.js +0 -205
  25. package/build/cjs/components/RichText/Editor.bk/convertCtrlKey.js +0 -87
  26. package/build/cjs/components/RichText/Parser.bk/MdParser.js +0 -107
  27. package/build/cjs/components/RichText/Parser.bk/Parser.js +0 -34
  28. package/build/cjs/components/RichText/Parser.bk/__tests__/MdParser.spec.js +0 -34
  29. package/build/cjs/components/RichText/Parser.bk/__tests__/Parser.spec.js +0 -41
  30. package/build/cjs/visualizations/config/generators/dhis/singleValue.js.xp1 +0 -478
  31. package/build/es/api/analytics/__tests__/AnalyticsTrackedEntities.spec.js +0 -41
  32. package/build/es/api/analytics/__tests__/__snapshots__/AnalyticsTrackedEntities.spec.js.snap +0 -3
  33. package/build/es/components/RichText/Editor.bk/Editor.js +0 -30
  34. package/build/es/components/RichText/Editor.bk/__tests__/Editor.spec.js +0 -26
  35. package/build/es/components/RichText/Editor.bk/__tests__/convertCtrlKey.spec.js +0 -202
  36. package/build/es/components/RichText/Editor.bk/convertCtrlKey.js +0 -80
  37. package/build/es/components/RichText/Parser.bk/MdParser.js +0 -99
  38. package/build/es/components/RichText/Parser.bk/Parser.js +0 -24
  39. package/build/es/components/RichText/Parser.bk/__tests__/MdParser.spec.js +0 -31
  40. package/build/es/components/RichText/Parser.bk/__tests__/Parser.spec.js +0 -38
  41. package/build/es/visualizations/config/generators/dhis/singleValue.js.xp1 +0 -478
@@ -1,202 +0,0 @@
1
- import convertCtrlKey from '../convertCtrlKey.js';
2
- describe('convertCtrlKey', () => {
3
- it('does not trigger callback if no ctrl key', () => {
4
- const cb = jest.fn();
5
- const e = {
6
- key: 'j',
7
- preventDefault: () => {}
8
- };
9
- convertCtrlKey(e, cb);
10
- expect(cb).not.toHaveBeenCalled();
11
- });
12
- describe('when ctrl key + "b" pressed', () => {
13
- it('triggers callback with open/close markers and caret pos in between', () => {
14
- const cb = jest.fn();
15
- const e = {
16
- key: 'b',
17
- ctrlKey: true,
18
- target: {
19
- selectionStart: 0,
20
- selectionEnd: 0,
21
- value: 'rainbow dash'
22
- },
23
- preventDefault: () => {}
24
- };
25
- convertCtrlKey(e, cb);
26
- expect(cb).toHaveBeenCalled();
27
- expect(cb).toHaveBeenCalledWith('** rainbow dash', 1);
28
- });
29
- it('triggers callback with open/close markers and caret pos in between (end of text)', () => {
30
- const cb = jest.fn();
31
- const e = {
32
- key: 'b',
33
- ctrlKey: true,
34
- target: {
35
- selectionStart: 22,
36
- selectionEnd: 22,
37
- value: 'rainbow dash is purple'
38
- },
39
- preventDefault: () => {}
40
- };
41
- convertCtrlKey(e, cb);
42
- expect(cb).toHaveBeenCalled();
43
- expect(cb).toHaveBeenCalledWith('rainbow dash is purple **', 24);
44
- });
45
- it('triggers callback with open/close markers mid-text with surrounding spaces (1)', () => {
46
- const cb = jest.fn();
47
- const e = {
48
- key: 'b',
49
- metaKey: true,
50
- target: {
51
- selectionStart: 4,
52
- // caret located just before "quick"
53
- selectionEnd: 4,
54
- value: 'the quick brown fox'
55
- },
56
- preventDefault: () => {}
57
- };
58
- convertCtrlKey(e, cb);
59
- expect(cb).toHaveBeenCalled();
60
- expect(cb).toHaveBeenCalledWith('the ** quick brown fox', 5);
61
- });
62
- it('triggers callback with open/close markers mid-text with surrounding spaces (2)', () => {
63
- const cb = jest.fn();
64
- const e = {
65
- key: 'b',
66
- metaKey: true,
67
- target: {
68
- selectionStart: 3,
69
- // caret located just after "the"
70
- selectionEnd: 3,
71
- value: 'the quick brown fox'
72
- },
73
- preventDefault: () => {}
74
- };
75
- convertCtrlKey(e, cb);
76
- expect(cb).toHaveBeenCalled();
77
- expect(cb).toHaveBeenCalledWith('the ** quick brown fox', 5);
78
- });
79
- it('triggers callback with correct double markers and padding', () => {
80
- const cb = jest.fn();
81
- const e = {
82
- key: 'b',
83
- metaKey: true,
84
- target: {
85
- selectionStart: 9,
86
- // between the underscores
87
- selectionEnd: 9,
88
- value: 'rainbow __'
89
- },
90
- preventDefault: () => {}
91
- };
92
- convertCtrlKey(e, cb);
93
- expect(cb).toHaveBeenCalled();
94
- expect(cb).toHaveBeenCalledWith('rainbow _**_', 10);
95
- });
96
- describe('selected text', () => {
97
- it('triggers callback with open/close markers around text and caret pos after closing marker', () => {
98
- const cb = jest.fn();
99
- const e = {
100
- key: 'b',
101
- metaKey: true,
102
- target: {
103
- selectionStart: 5,
104
- // "ow da" is selected
105
- selectionEnd: 10,
106
- value: 'rainbow dash is purple'
107
- },
108
- preventDefault: () => {}
109
- };
110
- convertCtrlKey(e, cb);
111
- expect(cb).toHaveBeenCalled();
112
- expect(cb).toHaveBeenCalledWith('rainb *ow da* sh is purple', 13);
113
- });
114
- it('triggers callback with open/close markers around text when starting at beginning of line', () => {
115
- const cb = jest.fn();
116
- const e = {
117
- key: 'b',
118
- metaKey: true,
119
- target: {
120
- selectionStart: 0,
121
- // "rainbow" is selected
122
- selectionEnd: 7,
123
- value: 'rainbow dash is purple'
124
- },
125
- preventDefault: () => {}
126
- };
127
- convertCtrlKey(e, cb);
128
- expect(cb).toHaveBeenCalled();
129
- expect(cb).toHaveBeenCalledWith('*rainbow* dash is purple', 9);
130
- });
131
- it('triggers callback with open/close markers around text when ending at end of line', () => {
132
- const cb = jest.fn();
133
- const e = {
134
- key: 'b',
135
- metaKey: true,
136
- target: {
137
- selectionStart: 16,
138
- // "purple" is selected
139
- selectionEnd: 22,
140
- value: 'rainbow dash is purple'
141
- },
142
- preventDefault: () => {}
143
- };
144
- convertCtrlKey(e, cb);
145
- expect(cb).toHaveBeenCalled();
146
- expect(cb).toHaveBeenCalledWith('rainbow dash is *purple*', 24);
147
- });
148
- it('triggers callback with open/close markers around word', () => {
149
- const cb = jest.fn();
150
- const e = {
151
- key: 'b',
152
- metaKey: true,
153
- target: {
154
- selectionStart: 8,
155
- // "dash" is selected
156
- selectionEnd: 12,
157
- value: 'rainbow dash is purple'
158
- },
159
- preventDefault: () => {}
160
- };
161
- convertCtrlKey(e, cb);
162
- expect(cb).toHaveBeenCalled();
163
- expect(cb).toHaveBeenCalledWith('rainbow *dash* is purple', 14);
164
- });
165
- it('triggers callback with leading/trailing spaces trimmed from selection', () => {
166
- const cb = jest.fn();
167
- const e = {
168
- key: 'b',
169
- metaKey: true,
170
- target: {
171
- selectionStart: 8,
172
- // " dash " is selected (note leading and trailing space)
173
- selectionEnd: 13,
174
- value: 'rainbow dash is purple'
175
- },
176
- preventDefault: () => {}
177
- };
178
- convertCtrlKey(e, cb);
179
- expect(cb).toHaveBeenCalled();
180
- expect(cb).toHaveBeenCalledWith('rainbow *dash* is purple', 14);
181
- });
182
- });
183
- });
184
- describe('when ctrl key + "i" pressed', () => {
185
- it('triggers callback with open/close italics markers and caret pos in between', () => {
186
- const cb = jest.fn();
187
- const e = {
188
- key: 'i',
189
- ctrlKey: true,
190
- target: {
191
- selectionStart: 0,
192
- selectionEnd: 0,
193
- value: ''
194
- },
195
- preventDefault: () => {}
196
- };
197
- convertCtrlKey(e, cb);
198
- expect(cb).toHaveBeenCalled();
199
- expect(cb).toHaveBeenCalledWith('__', 1);
200
- });
201
- });
202
- });
@@ -1,80 +0,0 @@
1
- const state = {
2
- boldMode: false,
3
- italicMode: false,
4
- element: null
5
- };
6
- const markerMap = {
7
- italic: '_',
8
- bold: '*'
9
- };
10
- const trim = str => {
11
- const leftSpaces = /^\s+/;
12
- const rightSpaces = /\s+$/;
13
- return str.replace(leftSpaces, '').replace(rightSpaces, '');
14
- };
15
- const toggleMode = mode => {
16
- const prop = `${mode}Mode`;
17
- state[prop] = !state[prop];
18
- };
19
- const insertMarkers = (mode, cb) => {
20
- const {
21
- selectionStart: start,
22
- selectionEnd: end,
23
- value
24
- } = state.element;
25
- const marker = markerMap[mode] || null;
26
- if (!marker || !cb || start < 0) {
27
- return;
28
- }
29
- toggleMode(mode);
30
- let newValue;
31
- let caretPos = end + 1;
32
- const padMarkers = text => {
33
- // is caret between two markers (i.e., "**" or "__")? Then do not add padding
34
- if (start === end && value.length && start > 0) {
35
- if (value[start - 1] === markerMap.bold && value[start] === markerMap.bold || value[start - 1] === markerMap.italic && value[start] === markerMap.italic) {
36
- return text;
37
- }
38
- }
39
- if (value.length && start > 0 && value[start - 1] !== ' ') {
40
- text = ` ${text}`;
41
- ++caretPos;
42
- }
43
- if (value.length && end !== value.length && value[end] !== ' ') {
44
- text = `${text} `;
45
- }
46
- return text;
47
- };
48
- if (start === end) {
49
- //no text
50
- const valueArr = value.split('');
51
- valueArr.splice(start, 0, padMarkers(`${marker}${marker}`));
52
- newValue = valueArr.join('');
53
- } else {
54
- const text = value.slice(start, end);
55
- const trimmedText = trim(text);
56
-
57
- // adjust caretPos based on trimmed text selection
58
- caretPos = caretPos - (text.length - trimmedText.length) + 1;
59
- newValue = [value.slice(0, start), padMarkers(`${marker}${trimmedText}${marker}`), value.slice(end)].join('');
60
- toggleMode(mode);
61
- }
62
- cb(newValue, caretPos);
63
- };
64
- const convertCtrlKey = (event, cb) => {
65
- const {
66
- key,
67
- ctrlKey,
68
- metaKey
69
- } = event;
70
- const element = event.target;
71
- state.element = element;
72
- if (key === 'b' && (ctrlKey || metaKey)) {
73
- event.preventDefault();
74
- insertMarkers('bold', cb);
75
- } else if (key === 'i' && (ctrlKey || metaKey)) {
76
- event.preventDefault();
77
- insertMarkers('italic', cb);
78
- }
79
- };
80
- export default convertCtrlKey;
@@ -1,99 +0,0 @@
1
- import MarkdownIt from 'markdown-it';
2
- const emojiDb = {
3
- ':-)': '\u{1F642}',
4
- ':)': '\u{1F642}',
5
- ':-(': '\u{1F641}',
6
- ':(': '\u{1F641}',
7
- ':+1': '\u{1F44D}',
8
- ':-1': '\u{1F44E}'
9
- };
10
- const codes = {
11
- bold: {
12
- name: 'bold',
13
- char: '*',
14
- domEl: 'strong',
15
- encodedChar: 0x2a,
16
- // see https://regex101.com/r/evswdV/8 for explanation of regexp
17
- regexString: '\\B\\*((?!\\s)[^*]+(?:\\b|[^*\\s]))\\*\\B',
18
- contentFn: val => val
19
- },
20
- italic: {
21
- name: 'italic',
22
- char: '_',
23
- domEl: 'em',
24
- encodedChar: 0x5f,
25
- // see https://regex101.com/r/p6LpjK/6 for explanation of regexp
26
- regexString: '\\b_((?!\\s)[^_]+(?:\\B|[^_\\s]))_\\b',
27
- contentFn: val => val
28
- },
29
- emoji: {
30
- name: 'emoji',
31
- char: ':',
32
- domEl: 'span',
33
- encodedChar: 0x3a,
34
- regexString: '^(:-\\)|:\\)|:\\(|:-\\(|:\\+1|:-1)',
35
- contentFn: val => emojiDb[val]
36
- }
37
- };
38
- let md;
39
- let linksInText;
40
- const markerIsInLinkText = pos => linksInText.some(link => pos >= link.index && pos <= link.lastIndex);
41
- const parse = code => (state, silent) => {
42
- if (silent) {
43
- return false;
44
- }
45
- const start = state.pos;
46
-
47
- // skip parsing emphasis if marker is within a link
48
- if (markerIsInLinkText(start)) {
49
- return false;
50
- }
51
- const marker = state.src.charCodeAt(start);
52
-
53
- // marker character: "_", "*", ":"
54
- if (marker !== codes[code].encodedChar) {
55
- return false;
56
- }
57
- const MARKER_REGEX = new RegExp(codes[code].regexString);
58
- const token = state.src.slice(start);
59
- if (MARKER_REGEX.test(token)) {
60
- const markerMatch = token.match(MARKER_REGEX);
61
-
62
- // skip parsing sections where the marker is not at the start of the token
63
- if (markerMatch.index !== 0) {
64
- return false;
65
- }
66
- const text = markerMatch[1];
67
- state.push(`${codes[code].domEl}_open`, codes[code].domEl, 1);
68
- const t = state.push('text', '', 0);
69
- t.content = codes[code].contentFn(text);
70
- state.push(`${codes.bold.domEl}_close`, codes[code].domEl, -1);
71
- state.pos += markerMatch[0].length;
72
- return true;
73
- }
74
- return false;
75
- };
76
- class MdParser {
77
- constructor() {
78
- // disable all rules, enable autolink for URLs and email addresses
79
- md = new MarkdownIt('zero', {
80
- linkify: true
81
- });
82
-
83
- // *bold* -> <strong>bold</strong>
84
- md.inline.ruler.push('strong', parse(codes.bold.name));
85
-
86
- // _italic_ -> <em>italic</em>
87
- md.inline.ruler.push('italic', parse(codes.italic.name));
88
-
89
- // :-) :) :-( :( :+1 :-1 -> <span>[unicode]</span>
90
- md.inline.ruler.push('emoji', parse(codes.emoji.name));
91
- md.enable(['link', 'linkify', 'strong', 'italic', 'emoji']);
92
- return this;
93
- }
94
- render(text) {
95
- linksInText = md.linkify.match(text) || [];
96
- return md.renderInline(text);
97
- }
98
- }
99
- export default MdParser;
@@ -1,24 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React, { useMemo } from 'react';
3
- import MdParserClass from './MdParser.js';
4
- const Parser = _ref => {
5
- let {
6
- children,
7
- style
8
- } = _ref;
9
- const MdParser = useMemo(() => new MdParserClass(), []);
10
- return children ? /*#__PURE__*/React.createElement("p", {
11
- style: style,
12
- dangerouslySetInnerHTML: {
13
- __html: MdParser.render(children)
14
- }
15
- }) : null;
16
- };
17
- Parser.defaultProps = {
18
- style: null
19
- };
20
- Parser.propTypes = {
21
- children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
22
- style: PropTypes.object
23
- };
24
- export default Parser;
@@ -1,31 +0,0 @@
1
- import MdParser from '../MdParser.js';
2
- const Parser = new MdParser();
3
- describe('MdParser class', () => {
4
- it('converts text into HTML', () => {
5
- const tests = [['_italic_', '<em>italic</em>'], ['*bold*', '<strong>bold</strong>'], ['* not bold because there is a space *', '* not bold because there is a space *'], ['_ not italic because there is a space _', '_ not italic because there is a space _'], [':-)', '<span>\u{1F642}</span>'], [':)', '<span>\u{1F642}</span>'], [':-(', '<span>\u{1F641}</span>'], [':(', '<span>\u{1F641}</span>'], [':+1', '<span>\u{1F44D}</span>'], [':-1', '<span>\u{1F44E}</span>'], ['mixed _italic_ *bold* and :+1', 'mixed <em>italic</em> <strong>bold</strong> and <span>\u{1F44D}</span>'], ['_italic with * inside_', '<em>italic with * inside</em>'], ['*bold with _ inside*', '<strong>bold with _ inside</strong>'],
6
- // italic marker followed by : should work
7
- ['_italic_:', '<em>italic</em>:'], ['_italic_: some text, *bold*: some other text', '<em>italic</em>: some text, <strong>bold</strong>: some other text'],
8
- // bold marker followed by : should work
9
- ['*bold*:', '<strong>bold</strong>:'], ['*bold*: some text, _italic_: some other text', '<strong>bold</strong>: some text, <em>italic</em>: some other text'],
10
- // italic marker inside an italic string not allowed
11
- ['_italic with _ inside_', '_italic with _ inside_'],
12
- // bold marker inside a bold string not allowed
13
- ['*bold with * inside*', '*bold with * inside*'], ['_multiple_ italic in the _same line_', '<em>multiple</em> italic in the <em>same line</em>'],
14
- // nested italic/bold combinations not allowed
15
- ['_italic with *bold* inside_', '<em>italic with *bold* inside</em>'], ['*bold with _italic_ inside*', '<strong>bold with _italic_ inside</strong>'], ['text with : and :)', 'text with : and <span>\u{1F642}</span>'], ['(parenthesis and :))', '(parenthesis and <span>\u{1F642}</span>)'], [':((parenthesis:))', '<span>\u{1F641}</span>(parenthesis<span>\u{1F642}</span>)'], [':+1+1', '<span>\u{1F44D}</span>+1'], ['-1:-1', '-1<span>\u{1F44E}</span>'],
16
- // links
17
- ['example.com/path', '<a href="http://example.com/path">example.com/path</a>'],
18
- // not recognized links with italic marker inside not converted
19
- ['example_with_underscore.com/path', 'example_with_underscore.com/path'], ['example_with_underscore.com/path_with_underscore', 'example_with_underscore.com/path_with_underscore'],
20
- // markers around non-recognized links
21
- ['link example_with_underscore.com/path should _not_ be converted', 'link example_with_underscore.com/path should <em>not</em> be converted'], ['link example_with_underscore.com/path should *not* be converted', 'link example_with_underscore.com/path should <strong>not</strong> be converted'],
22
- // italic marker inside links not converted
23
- ['example.com/path_with_underscore', '<a href="http://example.com/path_with_underscore">example.com/path_with_underscore</a>'], ['_italic_ and *bold* with a example.com/link_with_underscore', '<em>italic</em> and <strong>bold</strong> with a <a href="http://example.com/link_with_underscore">example.com/link_with_underscore</a>'], ['example.com/path with *bold* after :)', '<a href="http://example.com/path">example.com/path</a> with <strong>bold</strong> after <span>\u{1F642}</span>'], ['_before_ example.com/path_with_underscore *after* :)', '<em>before</em> <a href="http://example.com/path_with_underscore">example.com/path_with_underscore</a> <strong>after</strong> <span>\u{1F642}</span>'],
24
- // italic/bold markers right after non-word characters
25
- ['_If % of ART retention rate after 12 months >90(%)_: Sustain the efforts.', '<em>If % of ART retention rate after 12 months &gt;90(%)</em>: Sustain the efforts.'], ['*If % of ART retention rate after 12 months >90(%)*: Sustain the efforts.', '<strong>If % of ART retention rate after 12 months &gt;90(%)</strong>: Sustain the efforts.']];
26
- tests.forEach(test => {
27
- const renderedText = Parser.render(test[0]);
28
- expect(renderedText).toEqual(test[1]);
29
- });
30
- });
31
- });
@@ -1,38 +0,0 @@
1
- import { shallow } from 'enzyme';
2
- import React from 'react';
3
- import Parser from '../Parser.js';
4
- import '../MdParser.js';
5
- jest.mock('../MdParser', () => {
6
- return jest.fn().mockImplementation(() => {
7
- return {
8
- render: () => 'converted text'
9
- };
10
- });
11
- });
12
- describe('RichText: Parser component', () => {
13
- let richTextParser;
14
- const defaultProps = {
15
- style: {
16
- color: 'blue'
17
- }
18
- };
19
- const renderComponent = (props, text) => {
20
- return shallow( /*#__PURE__*/React.createElement(Parser, props, text));
21
- };
22
- it('should have rendered a result', () => {
23
- richTextParser = renderComponent({}, 'test');
24
- expect(richTextParser).toHaveLength(1);
25
- });
26
- it('should have rendered a result with the style prop', () => {
27
- richTextParser = renderComponent(defaultProps, 'test prop');
28
- expect(richTextParser.props().style).toEqual(defaultProps.style);
29
- });
30
- it('should have rendered content', () => {
31
- richTextParser = renderComponent({}, 'plain text');
32
- expect(richTextParser.html()).toEqual('<p>converted text</p>');
33
- });
34
- it('should return null if no children is passed', () => {
35
- richTextParser = renderComponent({}, undefined);
36
- expect(richTextParser.html()).toBe(null);
37
- });
38
- });