@dhis2-ui/organisation-unit-tree 10.16.3 → 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
@@ -7,14 +7,11 @@ export default {
7
7
  };
8
8
  export const ClosedWithChildren = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
9
9
  data: dataProviderData
10
- }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, _ref => {
11
- let {
12
- selected,
13
- onChange
14
- } = _ref;
15
- return /*#__PURE__*/React.createElement(OrganisationUnitTree, {
16
- roots: "A0000000000",
17
- onChange: onChange,
18
- selected: selected
19
- });
20
- }));
10
+ }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
11
+ selected,
12
+ onChange
13
+ }) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
14
+ roots: "A0000000000",
15
+ onChange: onChange,
16
+ selected: selected
17
+ })));
@@ -7,11 +7,10 @@ export { getOrganisationUnitData } from './get-organisation-unit-data.js';
7
7
  export { namespace } from './namespace.js';
8
8
  export const delayResponse = (delay, response) => () => new Promise(resolve => setTimeout(() => resolve(response), delay));
9
9
  export const dataProviderData = {
10
- organisationUnits: (_, _ref) => {
11
- let {
12
- id,
13
- params = {}
14
- } = _ref;
10
+ organisationUnits: (_, {
11
+ id,
12
+ params = {}
13
+ }) => {
15
14
  console.log('id, params', id, params);
16
15
  const data = getOrganisationUnitData(id, params);
17
16
  if (!data) {
@@ -20,18 +19,16 @@ export const dataProviderData = {
20
19
  return Promise.resolve(data);
21
20
  }
22
21
  };
23
- export const StatefulMultiSelectionWrapper = _ref2 => {
24
- let {
25
- children,
26
- onSelectionChange = () => null
27
- } = _ref2;
22
+ export const StatefulMultiSelectionWrapper = ({
23
+ children,
24
+ onSelectionChange = () => null
25
+ }) => {
28
26
  const [selected, setSelected] = useState([]);
29
27
  return children({
30
28
  selected,
31
- onChange: _ref3 => {
32
- let {
33
- selected: newSelected
34
- } = _ref3;
29
+ onChange: ({
30
+ selected: newSelected
31
+ }) => {
35
32
  setSelected(newSelected);
36
33
  onSelectionChange(newSelected);
37
34
  }
@@ -44,16 +41,13 @@ StatefulMultiSelectionWrapper.propTypes = {
44
41
  export const createDecoratorStatefulMultiSelection = args => {
45
42
  return Story => /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, {
46
43
  onSelectionChange: args === null || args === void 0 ? void 0 : args.onSelectionChange
47
- }, _ref4 => {
48
- let {
49
- selected,
50
- onChange
51
- } = _ref4;
52
- return /*#__PURE__*/React.createElement(Story, {
53
- selected: selected,
54
- onChange: onChange
55
- });
56
- });
44
+ }, ({
45
+ selected,
46
+ onChange
47
+ }) => /*#__PURE__*/React.createElement(Story, {
48
+ selected: selected,
49
+ onChange: onChange
50
+ }));
57
51
  };
58
52
  export const createDecoratorCustomDataProvider = args => {
59
53
  const data = (args === null || args === void 0 ? void 0 : args.data) || dataProviderData;
@@ -7,18 +7,16 @@ window.orgUnitPathToExpand = '/A0000000000/A0000000001';
7
7
  export const Controlled = () => {
8
8
  const initiallyExpanded = getAllExpandedOrgUnitPaths(window.initiallyExpandedPaths);
9
9
  const [expanded, setExpanded] = useState(initiallyExpanded);
10
- const handleExpand = _ref => {
11
- let {
12
- path
13
- } = _ref;
10
+ const handleExpand = ({
11
+ path
12
+ }) => {
14
13
  if (!expanded.includes(path)) {
15
14
  setExpanded([...expanded, path]);
16
15
  }
17
16
  };
18
- const handleCollapse = _ref2 => {
19
- let {
20
- path
21
- } = _ref2;
17
+ const handleCollapse = ({
18
+ path
19
+ }) => {
22
20
  const pathIndex = expanded.indexOf(path);
23
21
  if (pathIndex !== -1) {
24
22
  const updatedExpanded = pathIndex === 0 ? expanded.slice(1) : [...expanded.slice(0, pathIndex), ...expanded.slice(pathIndex + 1)];
@@ -3,10 +3,7 @@ import React from 'react';
3
3
  import { OrganisationUnitTree } from '../index.js';
4
4
  import { StatefulMultiSelectionWrapper, dataProviderData } from './common.js';
5
5
  const dataProviderDataWithError = {
6
- organisationUnits: function () {
7
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8
- args[_key] = arguments[_key];
9
- }
6
+ organisationUnits: (...args) => {
10
7
  const [, {
11
8
  id
12
9
  }] = args;
@@ -2,40 +2,31 @@ import React from 'react';
2
2
  import { OrganisationUnitTree } from '../index.js';
3
3
  import { createDecoratorCustomDataProvider, createDecoratorStatefulMultiSelection } from './common.js';
4
4
  const decorators = [createDecoratorStatefulMultiSelection(), createDecoratorCustomDataProvider()];
5
- export const NoInitiallyExpandedPaths = (_, _ref) => {
6
- let {
7
- onChange,
8
- selected
9
- } = _ref;
10
- return /*#__PURE__*/React.createElement(OrganisationUnitTree, {
11
- roots: "A0000000000",
12
- selected: selected,
13
- onChange: onChange
14
- });
15
- };
5
+ export const NoInitiallyExpandedPaths = (_, {
6
+ onChange,
7
+ selected
8
+ }) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
9
+ roots: "A0000000000",
10
+ selected: selected,
11
+ onChange: onChange
12
+ });
16
13
  NoInitiallyExpandedPaths.decorators = decorators;
17
- export const InitiallyExpandedPaths = (_, _ref2) => {
18
- let {
19
- onChange,
20
- selected
21
- } = _ref2;
22
- return /*#__PURE__*/React.createElement(OrganisationUnitTree, {
23
- roots: "A0000000000",
24
- selected: selected,
25
- onChange: onChange,
26
- initiallyExpanded: ['/A0000000000']
27
- });
28
- };
14
+ export const InitiallyExpandedPaths = (_, {
15
+ onChange,
16
+ selected
17
+ }) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
18
+ roots: "A0000000000",
19
+ selected: selected,
20
+ onChange: onChange,
21
+ initiallyExpanded: ['/A0000000000']
22
+ });
29
23
  InitiallyExpandedPaths.decorators = decorators;
30
- export const WithRootMainAndRootSubOrgUnit = (_, _ref3) => {
31
- let {
32
- onChange,
33
- selected
34
- } = _ref3;
35
- return /*#__PURE__*/React.createElement(OrganisationUnitTree, {
36
- roots: ['A0000000000', 'A0000000001'],
37
- selected: selected,
38
- onChange: onChange
39
- });
40
- };
24
+ export const WithRootMainAndRootSubOrgUnit = (_, {
25
+ onChange,
26
+ selected
27
+ }) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
28
+ roots: ['A0000000000', 'A0000000001'],
29
+ selected: selected,
30
+ onChange: onChange
31
+ });
41
32
  WithRootMainAndRootSubOrgUnit.decorators = decorators;
@@ -3,10 +3,7 @@ import React, { useState } from 'react';
3
3
  import { OrganisationUnitTree } from '../index.js';
4
4
  import { StatefulMultiSelectionWrapper, dataProviderData, delayResponse, namespace } from './common.js';
5
5
  const afterReloadData = {
6
- organisationUnits: function () {
7
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8
- args[_key] = arguments[_key];
9
- }
6
+ organisationUnits: (...args) => {
10
7
  const [, {
11
8
  id
12
9
  }] = args;
@@ -27,23 +24,20 @@ const ForceReloading_ = () => {
27
24
  disabled: forceReload,
28
25
  "data-test": "reload-all",
29
26
  onClick: () => setForceReload(true)
30
- }, "Force reload tree"), /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, _ref => {
31
- let {
32
- selected,
33
- onChange
34
- } = _ref;
35
- return /*#__PURE__*/React.createElement(OrganisationUnitTree, {
36
- roots: "A0000000000",
37
- onChange: onChange,
38
- selected: selected,
39
- forceReload: forceReload,
40
- onChildrenLoaded: data => {
41
- if (data.A0000000000) {
42
- setForceReload(false);
43
- }
27
+ }, "Force reload tree"), /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
28
+ selected,
29
+ onChange
30
+ }) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
31
+ roots: "A0000000000",
32
+ onChange: onChange,
33
+ selected: selected,
34
+ forceReload: forceReload,
35
+ onChildrenLoaded: data => {
36
+ if (data.A0000000000) {
37
+ setForceReload(false);
44
38
  }
45
- });
46
- }));
39
+ }
40
+ })));
47
41
  };
48
42
  export default {
49
43
  title: namespace
@@ -1,33 +1,29 @@
1
- const createResponse = _ref => {
2
- let {
3
- fields,
4
- id,
5
- path,
6
- displayName,
1
+ const createResponse = ({
2
+ fields,
3
+ id,
4
+ path,
5
+ displayName,
6
+ children
7
+ }) => ({
8
+ ...(fields.includes('id') ? {
9
+ id
10
+ } : {}),
11
+ ...(fields.includes('path') ? {
12
+ path
13
+ } : {}),
14
+ ...(fields.includes('displayName') ? {
15
+ displayName
16
+ } : {}),
17
+ ...(fields.includes('children::size') ? {
18
+ children: children.length
19
+ } : {}),
20
+ ...(fields.includes('children[id,path,displayName]') ? {
7
21
  children
8
- } = _ref;
9
- return {
10
- ...(fields.includes('id') ? {
11
- id
12
- } : {}),
13
- ...(fields.includes('path') ? {
14
- path
15
- } : {}),
16
- ...(fields.includes('displayName') ? {
17
- displayName
18
- } : {}),
19
- ...(fields.includes('children::size') ? {
20
- children: children.length
21
- } : {}),
22
- ...(fields.includes('children[id,path,displayName]') ? {
23
- children
24
- } : {})
25
- };
26
- };
27
- export const getOrganisationUnitData = (id, _ref2) => {
28
- let {
29
- fields
30
- } = _ref2;
22
+ } : {})
23
+ });
24
+ export const getOrganisationUnitData = (id, {
25
+ fields
26
+ }) => {
31
27
  let data;
32
28
  if (id === 'A0000000000') {
33
29
  data = createResponse({
@@ -7,13 +7,10 @@ export default {
7
7
  };
8
8
  export const RootHighlighted = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
9
9
  data: dataProviderData
10
- }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, _ref => {
11
- let {
12
- onChange
13
- } = _ref;
14
- return /*#__PURE__*/React.createElement(OrganisationUnitTree, {
15
- roots: "A0000000000",
16
- onChange: onChange,
17
- highlighted: ['/A0000000000']
18
- });
19
- }));
10
+ }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
11
+ onChange
12
+ }) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
13
+ roots: "A0000000000",
14
+ onChange: onChange,
15
+ highlighted: ['/A0000000000']
16
+ })));
@@ -3,10 +3,7 @@ import React from 'react';
3
3
  import { OrganisationUnitTree } from '../index.js';
4
4
  import { StatefulMultiSelectionWrapper, dataProviderData, delayResponse } from './common.js';
5
5
  const data = {
6
- organisationUnits: function () {
7
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8
- args[_key] = arguments[_key];
9
- }
6
+ organisationUnits: (...args) => {
10
7
  const [, {
11
8
  id
12
9
  }] = args;
@@ -21,12 +18,9 @@ const data = {
21
18
  };
22
19
  export const A0000000001Loading = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
23
20
  data: data
24
- }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, _ref => {
25
- let {
26
- onChange
27
- } = _ref;
28
- return /*#__PURE__*/React.createElement(OrganisationUnitTree, {
29
- roots: "A0000000000",
30
- onChange: onChange
31
- });
32
- }));
21
+ }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
22
+ onChange
23
+ }) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
24
+ roots: "A0000000000",
25
+ onChange: onChange
26
+ })));
@@ -7,14 +7,11 @@ export const MultipleSelection = () => /*#__PURE__*/React.createElement(CustomDa
7
7
  data: dataProviderData
8
8
  }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, {
9
9
  onSelectionChange: newSelection => window.selection = newSelection
10
- }, _ref => {
11
- let {
12
- selected,
13
- onChange
14
- } = _ref;
15
- return /*#__PURE__*/React.createElement(OrganisationUnitTree, {
16
- roots: "A0000000000",
17
- onChange: onChange,
18
- selected: selected
19
- });
20
- }));
10
+ }, ({
11
+ selected,
12
+ onChange
13
+ }) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
14
+ roots: "A0000000000",
15
+ onChange: onChange,
16
+ selected: selected
17
+ })));
@@ -4,26 +4,20 @@ import { OrganisationUnitTree } from '../index.js';
4
4
  import { StatefulMultiSelectionWrapper, dataProviderData } from './common.js';
5
5
  export const NoSelectionClosed = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
6
6
  data: dataProviderData
7
- }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, _ref => {
8
- let {
9
- onChange
10
- } = _ref;
11
- return /*#__PURE__*/React.createElement(OrganisationUnitTree, {
12
- disableSelection: true,
13
- roots: "A0000000000",
14
- onChange: onChange
15
- });
16
- }));
7
+ }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
8
+ onChange
9
+ }) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
10
+ disableSelection: true,
11
+ roots: "A0000000000",
12
+ onChange: onChange
13
+ })));
17
14
  export const NoSelectionRootOpened = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
18
15
  data: dataProviderData
19
- }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, _ref2 => {
20
- let {
21
- onChange
22
- } = _ref2;
23
- return /*#__PURE__*/React.createElement(OrganisationUnitTree, {
24
- disableSelection: true,
25
- roots: "A0000000000",
26
- onChange: onChange,
27
- initiallyExpanded: ['/A0000000000']
28
- });
29
- }));
16
+ }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
17
+ onChange
18
+ }) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
19
+ disableSelection: true,
20
+ roots: "A0000000000",
21
+ onChange: onChange,
22
+ initiallyExpanded: ['/A0000000000']
23
+ })));
@@ -8,27 +8,21 @@ for (let i = 0; i < 7; ++i) {
8
8
  }
9
9
  export const FilteredBy3LevelPath = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
10
10
  data: dataProviderData
11
- }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, _ref => {
12
- let {
13
- onChange
14
- } = _ref;
15
- return /*#__PURE__*/React.createElement(OrganisationUnitTree, {
16
- roots: "A0000000000",
17
- onChange: onChange,
18
- initiallyExpanded: ['/A0000000000', '/A0000000000/A0000000001', '/A0000000000/A0000000002'],
19
- filter: ['/A0000000000/A0000000001/A0000000003']
20
- });
21
- }));
11
+ }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
12
+ onChange
13
+ }) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
14
+ roots: "A0000000000",
15
+ onChange: onChange,
16
+ initiallyExpanded: ['/A0000000000', '/A0000000000/A0000000001', '/A0000000000/A0000000002'],
17
+ filter: ['/A0000000000/A0000000001/A0000000003']
18
+ })));
22
19
  export const FilteredBy3LevelPathAnd2LevelPath = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
23
20
  data: dataProviderData
24
- }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, _ref2 => {
25
- let {
26
- onChange
27
- } = _ref2;
28
- return /*#__PURE__*/React.createElement(OrganisationUnitTree, {
29
- roots: "A0000000000",
30
- onChange: onChange,
31
- initiallyExpanded: ['/A0000000000', '/A0000000000/A0000000001', '/A0000000000/A0000000002'],
32
- filter: ['/A0000000000/A0000000001/A0000000003', '/A0000000000/A0000000002']
33
- });
34
- }));
21
+ }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
22
+ onChange
23
+ }) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
24
+ roots: "A0000000000",
25
+ onChange: onChange,
26
+ initiallyExpanded: ['/A0000000000', '/A0000000000/A0000000001', '/A0000000000/A0000000002'],
27
+ filter: ['/A0000000000/A0000000001/A0000000003', '/A0000000000/A0000000002']
28
+ })));
@@ -3,10 +3,7 @@ import React from 'react';
3
3
  import { OrganisationUnitTree } from '../index.js';
4
4
  import { StatefulMultiSelectionWrapper, dataProviderData } from './common.js';
5
5
  const data = {
6
- organisationUnits: function () {
7
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8
- args[_key] = arguments[_key];
9
- }
6
+ organisationUnits: (...args) => {
10
7
  const [, {
11
8
  id
12
9
  }] = args;
@@ -28,15 +25,12 @@ const data = {
28
25
  };
29
26
  export const SingleSelection = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
30
27
  data: data
31
- }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, _ref => {
32
- let {
33
- selected,
34
- onChange
35
- } = _ref;
36
- return /*#__PURE__*/React.createElement(OrganisationUnitTree, {
37
- singleSelection: true,
38
- roots: ['A0000000000', 'A0000000001'],
39
- onChange: onChange,
40
- selected: selected
41
- });
42
- }));
28
+ }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
29
+ selected,
30
+ onChange
31
+ }) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
32
+ singleSelection: true,
33
+ roots: ['A0000000000', 'A0000000001'],
34
+ onChange: onChange,
35
+ selected: selected
36
+ })));
@@ -1,11 +1,10 @@
1
1
  import React, { useState } from 'react';
2
2
  import { OrganisationUnitTree } from '../index.js';
3
3
  import { createDecoratorCustomDataProvider, createDecoratorStatefulMultiSelection } from './common.js';
4
- export const MultipleRootSubAndOneMainOrgUnit = (_, _ref) => {
5
- let {
6
- selected,
7
- onChange
8
- } = _ref;
4
+ export const MultipleRootSubAndOneMainOrgUnit = (_, {
5
+ selected,
6
+ onChange
7
+ }) => {
9
8
  const [filter, setFilter] = useState('');
10
9
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("input", {
11
10
  type: "input",
@@ -3,10 +3,7 @@ import React from 'react';
3
3
  import { OrganisationUnitTree } from '../index.js';
4
4
  import { StatefulMultiSelectionWrapper, dataProviderData } from './common.js';
5
5
  const customizedDataProviderData = {
6
- organisationUnits: function () {
7
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8
- args[_key] = arguments[_key];
9
- }
6
+ organisationUnits: (...args) => {
10
7
  const [, {
11
8
  id,
12
9
  params
@@ -39,20 +36,17 @@ window.onExpand = window.Cypress && window.Cypress.cy.stub();
39
36
  window.onChildrenLoaded = window.Cypress && window.Cypress.cy.stub();
40
37
  export const Events = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
41
38
  data: customizedDataProviderData
42
- }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, _ref => {
43
- let {
44
- selected,
45
- onChange
46
- } = _ref;
47
- return /*#__PURE__*/React.createElement(OrganisationUnitTree, {
48
- roots: "A0000000000",
49
- selected: selected,
50
- onChange: function () {
51
- onChange(...arguments);
52
- window.onChange(...arguments);
53
- },
54
- onExpand: window.onExpand,
55
- onCollapse: window.onCollapse,
56
- onChildrenLoaded: window.onChildrenLoaded
57
- });
58
- }));
39
+ }, /*#__PURE__*/React.createElement(StatefulMultiSelectionWrapper, null, ({
40
+ selected,
41
+ onChange
42
+ }) => /*#__PURE__*/React.createElement(OrganisationUnitTree, {
43
+ roots: "A0000000000",
44
+ selected: selected,
45
+ onChange: (...args) => {
46
+ onChange(...args);
47
+ window.onChange(...args);
48
+ },
49
+ onExpand: window.onExpand,
50
+ onCollapse: window.onCollapse,
51
+ onChildrenLoaded: window.onChildrenLoaded
52
+ })));
@@ -6,18 +6,16 @@ export const CustomExpandedImperativeOpen = () => {
6
6
  const orgUnit2Path = '/A0000000000/A0000000001';
7
7
  const initiallyExpanded = getAllExpandedOrgUnitPaths([]);
8
8
  const [expanded, setExpanded] = useState(initiallyExpanded);
9
- const handleExpand = _ref => {
10
- let {
11
- path
12
- } = _ref;
9
+ const handleExpand = ({
10
+ path
11
+ }) => {
13
12
  if (!expanded.includes(path)) {
14
13
  setExpanded([...expanded, path]);
15
14
  }
16
15
  };
17
- const handleCollapse = _ref2 => {
18
- let {
19
- path
20
- } = _ref2;
16
+ const handleCollapse = ({
17
+ path
18
+ }) => {
21
19
  const pathIndex = expanded.indexOf(path);
22
20
  if (pathIndex !== -1) {
23
21
  const updatedExpanded = pathIndex === 0 ? expanded.slice(1) : [...expanded.slice(0, pathIndex), ...expanded.slice(pathIndex + 1)];
@@ -5,11 +5,10 @@ export const CustomNodeLabel = () => /*#__PURE__*/React.createElement(Organisati
5
5
  name: "Root org unit",
6
6
  roots: "A0000000000",
7
7
  initiallyExpanded: ['/A0000000000/A0000000001'],
8
- renderNodeLabel: _ref => {
9
- let {
10
- label,
11
- node
12
- } = _ref;
8
+ renderNodeLabel: ({
9
+ label,
10
+ node
11
+ }) => {
13
12
  if (node.path !== '/A0000000000/A0000000001') {
14
13
  return label;
15
14
  }
@@ -2,12 +2,11 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
2
2
  import { DataProvider } from '@dhis2/app-runtime';
3
3
  import React, { useState } from 'react';
4
4
  import { OrganisationUnitTree } from '../index.js';
5
- const DX_onChange = (selected, setSelected, singleSelection) => _ref => {
6
- let {
7
- id,
8
- path,
9
- checked
10
- } = _ref;
5
+ const DX_onChange = (selected, setSelected, singleSelection) => ({
6
+ id,
7
+ path,
8
+ checked
9
+ }) => {
11
10
  console.log('onChange', {
12
11
  path,
13
12
  id,
@@ -5,10 +5,7 @@ import { customData, onChange, onExpand, onCollapse, onChildrenLoaded } from './
5
5
  export const LoadingErrorGrandchild = () => /*#__PURE__*/React.createElement(CustomDataProvider, {
6
6
  data: {
7
7
  ...customData,
8
- organisationUnits: function () {
9
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
10
- args[_key] = arguments[_key];
11
- }
8
+ organisationUnits: (...args) => {
12
9
  const [, {
13
10
  id
14
11
  }] = args;