@dhis2-ui/organisation-unit-tree 10.16.3-alpha.1 → 10.16.4

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 (110) hide show
  1. package/build/cjs/__e2e__/children_as_child_nodes.js +8 -11
  2. package/build/cjs/__e2e__/common.js +19 -26
  3. package/build/cjs/__e2e__/controlled_expanded.js +7 -10
  4. package/build/cjs/__e2e__/displaying_loading_error.js +1 -4
  5. package/build/cjs/__e2e__/expanded.js +25 -34
  6. package/build/cjs/__e2e__/force_reload.js +15 -22
  7. package/build/cjs/__e2e__/get-organisation-unit-data.js +25 -29
  8. package/build/cjs/__e2e__/highlight.js +7 -10
  9. package/build/cjs/__e2e__/loading_state.js +7 -13
  10. package/build/cjs/__e2e__/multi_selection.js +8 -11
  11. package/build/cjs/__e2e__/no_selection.js +15 -21
  12. package/build/cjs/__e2e__/path_based_filtering.js +16 -22
  13. package/build/cjs/__e2e__/single_selection.js +10 -16
  14. package/build/cjs/__e2e__/sub_unit_as_root.js +5 -7
  15. package/build/cjs/__e2e__/tree_api.js +15 -21
  16. package/build/cjs/__stories__/custom-expanded-imperative-open.js +7 -10
  17. package/build/cjs/__stories__/custom-node-label.js +4 -5
  18. package/build/cjs/__stories__/development-stories.js +6 -8
  19. package/build/cjs/__stories__/force-reload-all.js +1 -2
  20. package/build/cjs/__stories__/loading-error-grandchild.js +1 -4
  21. package/build/cjs/__stories__/loading.js +1 -4
  22. package/build/cjs/__stories__/multiple-roots.js +9 -12
  23. package/build/cjs/__stories__/root-error.js +1 -4
  24. package/build/cjs/__stories__/root-loading.js +1 -4
  25. package/build/cjs/__stories__/shared.js +46 -79
  26. package/build/cjs/features/controlled_expanded/index.js +3 -6
  27. package/build/cjs/locales/index.js +49 -27
  28. package/build/cjs/organisation-unit-node/error-message.js +10 -13
  29. package/build/cjs/organisation-unit-node/label/disabled-selection-label.js +9 -12
  30. package/build/cjs/organisation-unit-node/label/icon-empty.js +19 -22
  31. package/build/cjs/organisation-unit-node/label/icon-folder-closed.js +25 -28
  32. package/build/cjs/organisation-unit-node/label/icon-folder-open.js +34 -37
  33. package/build/cjs/organisation-unit-node/label/icon-single.js +28 -31
  34. package/build/cjs/organisation-unit-node/label/icon.js +6 -7
  35. package/build/cjs/organisation-unit-node/label/iconized-checkbox.js +12 -13
  36. package/build/cjs/organisation-unit-node/label/label-container.js +13 -16
  37. package/build/cjs/organisation-unit-node/label/label.js +27 -30
  38. package/build/cjs/organisation-unit-node/label/single-selection-label.js +18 -21
  39. package/build/cjs/organisation-unit-node/organisation-unit-node-children.js +27 -29
  40. package/build/cjs/organisation-unit-node/organisation-unit-node.js +22 -23
  41. package/build/cjs/organisation-unit-node/use-open-state.js +8 -9
  42. package/build/cjs/organisation-unit-node/use-org-children.js +14 -21
  43. package/build/cjs/organisation-unit-node/use-org-children.test.js +40 -59
  44. package/build/cjs/organisation-unit-node/use-org-data/use-org-data.js +13 -20
  45. package/build/cjs/organisation-unit-node/use-org-data/use-org-data.test.js +17 -27
  46. package/build/cjs/organisation-unit-tree/default-render-node-label/default-render-node-label.js +3 -6
  47. package/build/cjs/organisation-unit-tree/organisation-unit-tree-root-error.js +9 -12
  48. package/build/cjs/organisation-unit-tree/organisation-unit-tree-root-loading.js +10 -13
  49. package/build/cjs/organisation-unit-tree/organisation-unit-tree.js +24 -26
  50. package/build/cjs/organisation-unit-tree/use-expanded/create-expand-handlers.js +14 -17
  51. package/build/cjs/organisation-unit-tree/use-expanded/use-expanded.js +8 -9
  52. package/build/cjs/organisation-unit-tree/use-root-org-data/patch-missing-display-name.js +1 -2
  53. package/build/cjs/organisation-unit-tree/use-root-org-data/use-root-org-data.js +10 -14
  54. package/build/cjs/organisation-unit-tree/use-root-org-data/use-root-org-unit.test.js +32 -46
  55. package/build/es/__e2e__/children_as_child_nodes.js +8 -11
  56. package/build/es/__e2e__/common.js +18 -24
  57. package/build/es/__e2e__/controlled_expanded.js +6 -8
  58. package/build/es/__e2e__/displaying_loading_error.js +1 -4
  59. package/build/es/__e2e__/expanded.js +25 -34
  60. package/build/es/__e2e__/force_reload.js +14 -20
  61. package/build/es/__e2e__/get-organisation-unit-data.js +25 -29
  62. package/build/es/__e2e__/highlight.js +7 -10
  63. package/build/es/__e2e__/loading_state.js +7 -13
  64. package/build/es/__e2e__/multi_selection.js +8 -11
  65. package/build/es/__e2e__/no_selection.js +15 -21
  66. package/build/es/__e2e__/path_based_filtering.js +16 -22
  67. package/build/es/__e2e__/single_selection.js +10 -16
  68. package/build/es/__e2e__/sub_unit_as_root.js +4 -5
  69. package/build/es/__e2e__/tree_api.js +15 -21
  70. package/build/es/__stories__/custom-expanded-imperative-open.js +6 -8
  71. package/build/es/__stories__/custom-node-label.js +4 -5
  72. package/build/es/__stories__/development-stories.js +5 -6
  73. package/build/es/__stories__/loading-error-grandchild.js +1 -4
  74. package/build/es/__stories__/loading.js +1 -4
  75. package/build/es/__stories__/multiple-roots.js +9 -12
  76. package/build/es/__stories__/root-error.js +1 -4
  77. package/build/es/__stories__/root-loading.js +1 -4
  78. package/build/es/__stories__/shared.js +45 -77
  79. package/build/es/features/controlled_expanded/index.js +3 -6
  80. package/build/es/locales/index.js +40 -18
  81. package/build/es/organisation-unit-node/error-message.js +10 -13
  82. package/build/es/organisation-unit-node/label/disabled-selection-label.js +9 -12
  83. package/build/es/organisation-unit-node/label/icon-empty.js +19 -22
  84. package/build/es/organisation-unit-node/label/icon-folder-closed.js +25 -28
  85. package/build/es/organisation-unit-node/label/icon-folder-open.js +34 -37
  86. package/build/es/organisation-unit-node/label/icon-single.js +28 -31
  87. package/build/es/organisation-unit-node/label/icon.js +6 -7
  88. package/build/es/organisation-unit-node/label/iconized-checkbox.js +12 -13
  89. package/build/es/organisation-unit-node/label/label-container.js +13 -16
  90. package/build/es/organisation-unit-node/label/label.js +27 -30
  91. package/build/es/organisation-unit-node/label/single-selection-label.js +18 -21
  92. package/build/es/organisation-unit-node/organisation-unit-node-children.js +27 -29
  93. package/build/es/organisation-unit-node/organisation-unit-node.js +22 -23
  94. package/build/es/organisation-unit-node/use-open-state.js +8 -9
  95. package/build/es/organisation-unit-node/use-org-children.js +14 -21
  96. package/build/es/organisation-unit-node/use-org-children.test.js +40 -59
  97. package/build/es/organisation-unit-node/use-org-data/use-org-data.js +13 -20
  98. package/build/es/organisation-unit-node/use-org-data/use-org-data.test.js +17 -27
  99. package/build/es/organisation-unit-tree/default-render-node-label/default-render-node-label.js +3 -6
  100. package/build/es/organisation-unit-tree/organisation-unit-tree-root-error.js +9 -12
  101. package/build/es/organisation-unit-tree/organisation-unit-tree-root-loading.js +10 -13
  102. package/build/es/organisation-unit-tree/organisation-unit-tree.js +23 -24
  103. package/build/es/organisation-unit-tree/use-expanded/create-expand-handlers.js +14 -17
  104. package/build/es/organisation-unit-tree/use-expanded/use-expanded.js +8 -9
  105. package/build/es/organisation-unit-tree/use-root-org-data/patch-missing-display-name.js +1 -2
  106. package/build/es/organisation-unit-tree/use-root-org-data/use-root-org-data.js +10 -14
  107. package/build/es/organisation-unit-tree/use-root-org-data/use-root-org-unit.test.js +32 -46
  108. package/package.json +6 -6
  109. package/src/locales/index.js +57 -18
  110. package/src/organisation-unit-tree/use-root-org-data/use-root-org-unit.test.js +14 -14
@@ -3,19 +3,18 @@ import { Checkbox } from '@dhis2-ui/checkbox';
3
3
  import PropTypes from 'prop-types';
4
4
  import React from 'react';
5
5
  import { Icon } from './icon.js';
6
- export const IconizedCheckbox = _ref => {
7
- let {
8
- checked,
9
- dataTest,
10
- hasChildren,
11
- indeterminate,
12
- children,
13
- loading,
14
- name,
15
- open,
16
- value,
17
- onChange
18
- } = _ref;
6
+ export const IconizedCheckbox = ({
7
+ checked,
8
+ dataTest,
9
+ hasChildren,
10
+ indeterminate,
11
+ children,
12
+ loading,
13
+ name,
14
+ open,
15
+ value,
16
+ onChange
17
+ }) => {
19
18
  const icon = /*#__PURE__*/React.createElement(Icon, {
20
19
  loading: loading,
21
20
  open: open,
@@ -10,22 +10,19 @@ import React from 'react';
10
10
  * @param {React.Component|React.Component[]} props.children
11
11
  * @returns {React.Component}
12
12
  */
13
- export const LabelContainer = _ref => {
14
- let {
15
- highlighted,
16
- children
17
- } = _ref;
18
- return /*#__PURE__*/React.createElement("div", {
19
- className: _JSXStyle.dynamic([["1387769986", [colors.teal200]]]) + " " + (cx({
20
- highlighted
21
- }) || "")
22
- }, /*#__PURE__*/React.createElement("span", {
23
- className: _JSXStyle.dynamic([["1387769986", [colors.teal200]]])
24
- }, children), /*#__PURE__*/React.createElement(_JSXStyle, {
25
- id: "1387769986",
26
- dynamic: [colors.teal200]
27
- }, ["div.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", "span.__jsx-style-dynamic-selector{display:block;}", `.highlighted.__jsx-style-dynamic-selector{background:${colors.teal200};padding-inline-end:4px;}`]));
28
- };
13
+ export const LabelContainer = ({
14
+ highlighted,
15
+ children
16
+ }) => /*#__PURE__*/React.createElement("div", {
17
+ className: _JSXStyle.dynamic([["1387769986", [colors.teal200]]]) + " " + (cx({
18
+ highlighted
19
+ }) || "")
20
+ }, /*#__PURE__*/React.createElement("span", {
21
+ className: _JSXStyle.dynamic([["1387769986", [colors.teal200]]])
22
+ }, children), /*#__PURE__*/React.createElement(_JSXStyle, {
23
+ id: "1387769986",
24
+ dynamic: [colors.teal200]
25
+ }, ["div.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", "span.__jsx-style-dynamic-selector{display:block;}", `.highlighted.__jsx-style-dynamic-selector{background:${colors.teal200};padding-inline-end:4px;}`]));
29
26
  LabelContainer.propTypes = {
30
27
  children: PropTypes.node,
31
28
  highlighted: PropTypes.bool
@@ -5,13 +5,12 @@ import { DisabledSelectionLabel } from './disabled-selection-label.js';
5
5
  import { IconizedCheckbox } from './iconized-checkbox.js';
6
6
  import { LabelContainer } from './label-container.js';
7
7
  import { SingleSelectionLabel } from './single-selection-label.js';
8
- const createNewSelected = _ref => {
9
- let {
10
- selected,
11
- path,
12
- checked,
13
- singleSelection
14
- } = _ref;
8
+ const createNewSelected = ({
9
+ selected,
10
+ path,
11
+ checked,
12
+ singleSelection
13
+ }) => {
15
14
  const pathIndex = selected.indexOf(path);
16
15
  if (checked && pathIndex !== -1) {
17
16
  return selected;
@@ -35,29 +34,27 @@ const createNewSelected = _ref => {
35
34
  const nextSlice = selected.slice(pathIndex + 1);
36
35
  return [...prevSlice, ...nextSlice];
37
36
  };
38
- const Label = _ref2 => {
39
- let {
40
- checked,
41
- children,
42
- dataTest,
43
- disableSelection,
44
- fullPath,
45
- hasChildren,
46
- hasSelectedDescendants,
47
- highlighted,
48
- loading,
49
- node,
50
- onChange,
51
- onToggleOpen,
52
- open,
53
- rootId,
54
- selected,
55
- singleSelection
56
- } = _ref2;
57
- const onClick = (_ref3, event) => {
58
- let {
59
- checked
60
- } = _ref3;
37
+ const Label = ({
38
+ checked,
39
+ children,
40
+ dataTest,
41
+ disableSelection,
42
+ fullPath,
43
+ hasChildren,
44
+ hasSelectedDescendants,
45
+ highlighted,
46
+ loading,
47
+ node,
48
+ onChange,
49
+ onToggleOpen,
50
+ open,
51
+ rootId,
52
+ selected,
53
+ singleSelection
54
+ }) => {
55
+ const onClick = ({
56
+ checked
57
+ }, event) => {
61
58
  const newSelected = createNewSelected({
62
59
  path: fullPath,
63
60
  selected,
@@ -12,29 +12,26 @@ import React from 'react';
12
12
  * @param {Function} [props.onChange]
13
13
  * @returns {React.Component}
14
14
  */
15
- export const SingleSelectionLabel = _ref => {
16
- let {
15
+ export const SingleSelectionLabel = ({
16
+ checked,
17
+ children,
18
+ onChange,
19
+ loading
20
+ }) => /*#__PURE__*/React.createElement("span", {
21
+ onClick: event => {
22
+ const payload = {
23
+ checked: !checked
24
+ };
25
+ onChange(payload, event);
26
+ },
27
+ className: _JSXStyle.dynamic([["321503310", [colors.grey900, colors.teal700]]]) + " " + (cx({
17
28
  checked,
18
- children,
19
- onChange,
20
29
  loading
21
- } = _ref;
22
- return /*#__PURE__*/React.createElement("span", {
23
- onClick: event => {
24
- const payload = {
25
- checked: !checked
26
- };
27
- onChange(payload, event);
28
- },
29
- className: _JSXStyle.dynamic([["321503310", [colors.grey900, colors.teal700]]]) + " " + (cx({
30
- checked,
31
- loading
32
- }) || "")
33
- }, children, /*#__PURE__*/React.createElement(_JSXStyle, {
34
- id: "321503310",
35
- dynamic: [colors.grey900, colors.teal700]
36
- }, [`span.__jsx-style-dynamic-selector{background:transparent;border-radius:3px;color:${colors.grey900};cursor:pointer;display:inline-block;font-size:14px;line-height:24px;padding:0 5px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;white-space:nowrap;}`, `.checked.__jsx-style-dynamic-selector{background:${colors.teal700};color:white;}`, ".loading.__jsx-style-dynamic-selector{cursor:auto;}"]));
37
- };
30
+ }) || "")
31
+ }, children, /*#__PURE__*/React.createElement(_JSXStyle, {
32
+ id: "321503310",
33
+ dynamic: [colors.grey900, colors.teal700]
34
+ }, [`span.__jsx-style-dynamic-selector{background:transparent;border-radius:3px;color:${colors.grey900};cursor:pointer;display:inline-block;font-size:14px;line-height:24px;padding:0 5px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;white-space:nowrap;}`, `.checked.__jsx-style-dynamic-selector{background:${colors.teal700};color:white;}`, ".loading.__jsx-style-dynamic-selector{cursor:auto;}"]));
38
35
  SingleSelectionLabel.propTypes = {
39
36
  children: PropTypes.any.isRequired,
40
37
  checked: PropTypes.bool,
@@ -5,12 +5,11 @@ import i18n from '../locales/index.js';
5
5
  import { orgUnitPathPropType } from '../prop-types.js';
6
6
  import { LoadingSpinner } from './loading-spinner.js';
7
7
  import { useOrgChildren } from './use-org-children.js';
8
- const getFilteredChildren = _ref => {
9
- let {
10
- orgChildren,
11
- filter,
12
- node
13
- } = _ref;
8
+ const getFilteredChildren = ({
9
+ orgChildren,
10
+ filter,
11
+ node
12
+ }) => {
14
13
  if (!(filter !== null && filter !== void 0 && filter.length)) {
15
14
  return orgChildren;
16
15
  }
@@ -18,29 +17,28 @@ const getFilteredChildren = _ref => {
18
17
  return isPathIncluded(filter, `${node.path}/${child.id}`);
19
18
  });
20
19
  };
21
- export const OrganisationUnitNodeChildren = _ref2 => {
22
- let {
23
- node,
24
- autoExpandLoadingError,
25
- dataTest,
26
- disableSelection,
27
- displayProperty,
28
- expanded,
29
- filter,
30
- highlighted,
31
- isUserDataViewFallback,
32
- onChange,
33
- onChildrenLoaded,
34
- onCollapse,
35
- onExpand,
36
- parentPath,
37
- renderNodeLabel,
38
- rootId,
39
- selected,
40
- singleSelection,
41
- suppressAlphabeticalSorting,
42
- OrganisationUnitNode
43
- } = _ref2;
20
+ export const OrganisationUnitNodeChildren = ({
21
+ node,
22
+ autoExpandLoadingError,
23
+ dataTest,
24
+ disableSelection,
25
+ displayProperty,
26
+ expanded,
27
+ filter,
28
+ highlighted,
29
+ isUserDataViewFallback,
30
+ onChange,
31
+ onChildrenLoaded,
32
+ onCollapse,
33
+ onExpand,
34
+ parentPath,
35
+ renderNodeLabel,
36
+ rootId,
37
+ selected,
38
+ singleSelection,
39
+ suppressAlphabeticalSorting,
40
+ OrganisationUnitNode
41
+ }) => {
44
42
  const orgChildren = useOrgChildren({
45
43
  node,
46
44
  isUserDataViewFallback,
@@ -11,29 +11,28 @@ import { LoadingSpinner } from './loading-spinner.js';
11
11
  import { OrganisationUnitNodeChildren } from './organisation-unit-node-children.js';
12
12
  import { useOpenState } from './use-open-state.js';
13
13
  import { useOrgData } from './use-org-data/index.js';
14
- export const OrganisationUnitNode = _ref => {
15
- let {
16
- autoExpandLoadingError,
17
- dataTest,
18
- disableSelection,
19
- displayName,
20
- displayProperty,
21
- expanded,
22
- highlighted,
23
- id,
24
- isUserDataViewFallback,
25
- path,
26
- renderNodeLabel,
27
- rootId,
28
- selected,
29
- singleSelection,
30
- filter,
31
- suppressAlphabeticalSorting,
32
- onChange,
33
- onChildrenLoaded,
34
- onCollapse,
35
- onExpand
36
- } = _ref;
14
+ export const OrganisationUnitNode = ({
15
+ autoExpandLoadingError,
16
+ dataTest,
17
+ disableSelection,
18
+ displayName,
19
+ displayProperty,
20
+ expanded,
21
+ highlighted,
22
+ id,
23
+ isUserDataViewFallback,
24
+ path,
25
+ renderNodeLabel,
26
+ rootId,
27
+ selected,
28
+ singleSelection,
29
+ filter,
30
+ suppressAlphabeticalSorting,
31
+ onChange,
32
+ onChildrenLoaded,
33
+ onCollapse,
34
+ onExpand
35
+ }) => {
37
36
  const orgData = useOrgData(id, {
38
37
  isUserDataViewFallback,
39
38
  displayName
@@ -10,15 +10,14 @@ import { useEffect, useState } from 'react';
10
10
  * @param {Function} [args.onCollapse]
11
11
  * @returns {Object}
12
12
  */
13
- export const useOpenState = _ref => {
14
- let {
15
- path,
16
- expanded,
17
- onExpand,
18
- onCollapse,
19
- errorMessage,
20
- autoExpandLoadingError
21
- } = _ref;
13
+ export const useOpenState = ({
14
+ path,
15
+ expanded,
16
+ onExpand,
17
+ onCollapse,
18
+ errorMessage,
19
+ autoExpandLoadingError
20
+ }) => {
22
21
  const autoExpand = autoExpandLoadingError && !!errorMessage;
23
22
  const [openedOnceDueToError, setOpenedOnce] = useState(!!errorMessage);
24
23
  useEffect(() => {
@@ -4,20 +4,14 @@ import { sortNodeChildrenAlphabetically } from '../helpers/index.js';
4
4
  const ORG_DATA_QUERY = {
5
5
  orgUnit: {
6
6
  resource: `organisationUnits`,
7
- id: _ref => {
8
- let {
9
- id
10
- } = _ref;
11
- return id;
12
- },
13
- params: _ref2 => {
14
- let {
15
- displayProperty
16
- } = _ref2;
17
- return {
18
- fields: displayProperty === 'displayName' ? 'children[id,path,displayName]' : `children[id,path,${displayProperty}~rename(displayName)]`
19
- };
20
- }
7
+ id: ({
8
+ id
9
+ }) => id,
10
+ params: ({
11
+ displayProperty
12
+ }) => ({
13
+ fields: displayProperty === 'displayName' ? 'children[id,path,displayName]' : `children[id,path,${displayProperty}~rename(displayName)]`
14
+ })
21
15
  }
22
16
  };
23
17
 
@@ -29,13 +23,12 @@ const ORG_DATA_QUERY = {
29
23
  * @param {'displayName'|'displayShortName'} [options.displayProperty]
30
24
  * @returns {Object}
31
25
  */
32
- export const useOrgChildren = _ref3 => {
33
- let {
34
- node,
35
- suppressAlphabeticalSorting,
36
- onComplete,
37
- displayProperty = 'displayName'
38
- } = _ref3;
26
+ export const useOrgChildren = ({
27
+ node,
28
+ suppressAlphabeticalSorting,
29
+ onComplete,
30
+ displayProperty = 'displayName'
31
+ }) => {
39
32
  const onCompleteCalledRef = useRef(false);
40
33
  const {
41
34
  called,
@@ -4,10 +4,9 @@ import React from 'react';
4
4
  import { useOrgChildren } from './use-org-children.js';
5
5
  describe('OrganisationUnitTree - useOrgChildren', () => {
6
6
  const dataProviderData = {
7
- organisationUnits: jest.fn((type, _ref) => {
8
- let {
9
- id
10
- } = _ref;
7
+ organisationUnits: jest.fn((type, {
8
+ id
9
+ }) => {
11
10
  if (id === 'A0000000000') {
12
11
  return {
13
12
  children: [{
@@ -21,14 +20,11 @@ describe('OrganisationUnitTree - useOrgChildren', () => {
21
20
  return Promise.reject(`No org unit with id "${id}"`);
22
21
  })
23
22
  };
24
- const wrapper = _ref2 => {
25
- let {
26
- children
27
- } = _ref2;
28
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
29
- data: dataProviderData
30
- }, children);
31
- };
23
+ const wrapper = ({
24
+ children
25
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
26
+ data: dataProviderData
27
+ }, children);
32
28
  const node = {
33
29
  id: 'A0000000000',
34
30
  path: '/A0000000000',
@@ -78,18 +74,15 @@ describe('OrganisationUnitTree - useOrgChildren', () => {
78
74
  });
79
75
  });
80
76
  it('should provide the error', async () => {
81
- const errorWrapper = _ref3 => {
82
- let {
83
- children
84
- } = _ref3;
85
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
86
- data: {
87
- organisationUnits: async () => {
88
- throw new Error('Error message');
89
- }
77
+ const errorWrapper = ({
78
+ children
79
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
80
+ data: {
81
+ organisationUnits: async () => {
82
+ throw new Error('Error message');
90
83
  }
91
- }, children);
92
- };
84
+ }
85
+ }, children);
93
86
  const {
94
87
  result
95
88
  } = renderHook(() => useOrgChildren({
@@ -131,10 +124,9 @@ describe('OrganisationUnitTree - useOrgChildren', () => {
131
124
  });
132
125
  it("should sort the node's children alphabetically by default", async () => {
133
126
  const dataProviderDataWithUnsortedChildren = {
134
- organisationUnits: jest.fn((type, _ref4) => {
135
- let {
136
- id
137
- } = _ref4;
127
+ organisationUnits: jest.fn((type, {
128
+ id
129
+ }) => {
138
130
  if (id === 'A0000000000') {
139
131
  return {
140
132
  children: [{
@@ -153,14 +145,11 @@ describe('OrganisationUnitTree - useOrgChildren', () => {
153
145
  return Promise.reject(`No org unit with id "${id}"`);
154
146
  })
155
147
  };
156
- const wrapperWithUnsortedChildren = _ref5 => {
157
- let {
158
- children
159
- } = _ref5;
160
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
161
- data: dataProviderDataWithUnsortedChildren
162
- }, children);
163
- };
148
+ const wrapperWithUnsortedChildren = ({
149
+ children
150
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
151
+ data: dataProviderDataWithUnsortedChildren
152
+ }, children);
164
153
  const {
165
154
  result
166
155
  } = renderHook(() => useOrgChildren({
@@ -192,10 +181,9 @@ describe('OrganisationUnitTree - useOrgChildren', () => {
192
181
  });
193
182
  it(`should not sort the node's children alphabetically when "suppressAlphabeticalSorting" is true`, async () => {
194
183
  const dataProviderDataWithUnsortedChildren = {
195
- organisationUnits: jest.fn((type, _ref6) => {
196
- let {
197
- id
198
- } = _ref6;
184
+ organisationUnits: jest.fn((type, {
185
+ id
186
+ }) => {
199
187
  if (id === 'A0000000000') {
200
188
  return {
201
189
  children: [{
@@ -214,14 +202,11 @@ describe('OrganisationUnitTree - useOrgChildren', () => {
214
202
  return Promise.reject(`No org unit with id "${id}"`);
215
203
  })
216
204
  };
217
- const wrapperWithUnsortedChildren = _ref7 => {
218
- let {
219
- children
220
- } = _ref7;
221
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
222
- data: dataProviderDataWithUnsortedChildren
223
- }, children);
224
- };
205
+ const wrapperWithUnsortedChildren = ({
206
+ children
207
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
208
+ data: dataProviderDataWithUnsortedChildren
209
+ }, children);
225
210
  const options = {
226
211
  node: {
227
212
  ...node,
@@ -255,10 +240,9 @@ describe('OrganisationUnitTree - useOrgChildren', () => {
255
240
  });
256
241
  it(`should not sort the node's children alphabetically when "suppressAlphabeticalSorting" is true`, async () => {
257
242
  const dataProviderDataWithUnsortedChildren = {
258
- organisationUnits: jest.fn((type, _ref8) => {
259
- let {
260
- id
261
- } = _ref8;
243
+ organisationUnits: jest.fn((type, {
244
+ id
245
+ }) => {
262
246
  if (id === 'A0000000000') {
263
247
  return {
264
248
  children: [{
@@ -277,14 +261,11 @@ describe('OrganisationUnitTree - useOrgChildren', () => {
277
261
  return Promise.reject(`No org unit with id "${id}"`);
278
262
  })
279
263
  };
280
- const wrapperWithUnsortedChildren = _ref9 => {
281
- let {
282
- children
283
- } = _ref9;
284
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
285
- data: dataProviderDataWithUnsortedChildren
286
- }, children);
287
- };
264
+ const wrapperWithUnsortedChildren = ({
265
+ children
266
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
267
+ data: dataProviderDataWithUnsortedChildren
268
+ }, children);
288
269
  const options = {
289
270
  node: {
290
271
  ...node,
@@ -2,21 +2,15 @@ import { useDataQuery } from '@dhis2/app-runtime';
2
2
  const ORG_DATA_QUERY = {
3
3
  orgUnit: {
4
4
  resource: `organisationUnits`,
5
- id: _ref => {
6
- let {
7
- id
8
- } = _ref;
9
- return id;
10
- },
11
- params: _ref2 => {
12
- let {
13
- isUserDataViewFallback
14
- } = _ref2;
15
- return {
16
- isUserDataViewFallback,
17
- fields: ['path', 'children::size']
18
- };
19
- }
5
+ id: ({
6
+ id
7
+ }) => id,
8
+ params: ({
9
+ isUserDataViewFallback
10
+ }) => ({
11
+ isUserDataViewFallback,
12
+ fields: ['path', 'children::size']
13
+ })
20
14
  }
21
15
  };
22
16
 
@@ -27,11 +21,10 @@ const ORG_DATA_QUERY = {
27
21
  * @param {bool} options.isUserDataViewFallback
28
22
  * @returns {Object}
29
23
  */
30
- export const useOrgData = (id, _ref3) => {
31
- let {
32
- displayName,
33
- isUserDataViewFallback
34
- } = _ref3;
24
+ export const useOrgData = (id, {
25
+ displayName,
26
+ isUserDataViewFallback
27
+ }) => {
35
28
  if (!displayName) {
36
29
  throw new Error('"displayName" is required');
37
30
  }
@@ -5,10 +5,7 @@ import { useOrgData } from './use-org-data.js';
5
5
  describe('OrganisationUnitTree - useOrgData', () => {
6
6
  // @TODO: Figure out why this is necessary at all...
7
7
  const origError = console.error;
8
- jest.spyOn(console, 'error').mockImplementation(function () {
9
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
10
- args[_key] = arguments[_key];
11
- }
8
+ jest.spyOn(console, 'error').mockImplementation((...args) => {
12
9
  const [err] = args;
13
10
  if (!err.toString().match(/^Warning: An update to/)) {
14
11
  origError(...args);
@@ -18,10 +15,9 @@ describe('OrganisationUnitTree - useOrgData', () => {
18
15
  console.error.mockRestore();
19
16
  });
20
17
  const dataProviderData = {
21
- organisationUnits: jest.fn((type, _ref) => {
22
- let {
23
- id
24
- } = _ref;
18
+ organisationUnits: jest.fn((type, {
19
+ id
20
+ }) => {
25
21
  if (id === 'A0000000000') {
26
22
  return {
27
23
  id: 'A0000000000',
@@ -32,14 +28,11 @@ describe('OrganisationUnitTree - useOrgData', () => {
32
28
  return Promise.reject(`No org unit with id "${id}"`);
33
29
  })
34
30
  };
35
- const wrapper = _ref2 => {
36
- let {
37
- children
38
- } = _ref2;
39
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
40
- data: dataProviderData
41
- }, children);
42
- };
31
+ const wrapper = ({
32
+ children
33
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
34
+ data: dataProviderData
35
+ }, children);
43
36
  it('should respond with `loading: true`, `error: null` and `data: { displayName, id }` initially', () => {
44
37
  const {
45
38
  result
@@ -78,18 +71,15 @@ describe('OrganisationUnitTree - useOrgData', () => {
78
71
  });
79
72
  });
80
73
  it('should provide the error', async () => {
81
- const errorWrapper = _ref3 => {
82
- let {
83
- children
84
- } = _ref3;
85
- return /*#__PURE__*/React.createElement(CustomDataProvider, {
86
- data: {
87
- organisationUnits: async () => {
88
- throw new Error('Error message');
89
- }
74
+ const errorWrapper = ({
75
+ children
76
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
77
+ data: {
78
+ organisationUnits: async () => {
79
+ throw new Error('Error message');
90
80
  }
91
- }, children);
92
- };
81
+ }
82
+ }, children);
93
83
  const {
94
84
  result
95
85
  } = renderHook(() => useOrgData('A0000000000', {