@dhis2-ui/organisation-unit-tree 10.16.3 → 10.16.5

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 (114) 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 +41 -35
  50. package/build/cjs/organisation-unit-tree/organisation-unit-tree.test.js +78 -7
  51. package/build/cjs/organisation-unit-tree/use-expanded/create-expand-handlers.js +14 -17
  52. package/build/cjs/organisation-unit-tree/use-expanded/use-expanded.js +8 -9
  53. package/build/cjs/organisation-unit-tree/use-root-org-data/patch-missing-display-name.js +1 -2
  54. package/build/cjs/organisation-unit-tree/use-root-org-data/use-root-org-data.js +10 -14
  55. package/build/cjs/organisation-unit-tree/use-root-org-data/use-root-org-unit.test.js +32 -46
  56. package/build/es/__e2e__/children_as_child_nodes.js +8 -11
  57. package/build/es/__e2e__/common.js +18 -24
  58. package/build/es/__e2e__/controlled_expanded.js +6 -8
  59. package/build/es/__e2e__/displaying_loading_error.js +1 -4
  60. package/build/es/__e2e__/expanded.js +25 -34
  61. package/build/es/__e2e__/force_reload.js +14 -20
  62. package/build/es/__e2e__/get-organisation-unit-data.js +25 -29
  63. package/build/es/__e2e__/highlight.js +7 -10
  64. package/build/es/__e2e__/loading_state.js +7 -13
  65. package/build/es/__e2e__/multi_selection.js +8 -11
  66. package/build/es/__e2e__/no_selection.js +15 -21
  67. package/build/es/__e2e__/path_based_filtering.js +16 -22
  68. package/build/es/__e2e__/single_selection.js +10 -16
  69. package/build/es/__e2e__/sub_unit_as_root.js +4 -5
  70. package/build/es/__e2e__/tree_api.js +15 -21
  71. package/build/es/__stories__/custom-expanded-imperative-open.js +6 -8
  72. package/build/es/__stories__/custom-node-label.js +4 -5
  73. package/build/es/__stories__/development-stories.js +5 -6
  74. package/build/es/__stories__/loading-error-grandchild.js +1 -4
  75. package/build/es/__stories__/loading.js +1 -4
  76. package/build/es/__stories__/multiple-roots.js +9 -12
  77. package/build/es/__stories__/root-error.js +1 -4
  78. package/build/es/__stories__/root-loading.js +1 -4
  79. package/build/es/__stories__/shared.js +45 -77
  80. package/build/es/features/controlled_expanded/index.js +3 -6
  81. package/build/es/locales/index.js +40 -18
  82. package/build/es/organisation-unit-node/error-message.js +10 -13
  83. package/build/es/organisation-unit-node/label/disabled-selection-label.js +9 -12
  84. package/build/es/organisation-unit-node/label/icon-empty.js +19 -22
  85. package/build/es/organisation-unit-node/label/icon-folder-closed.js +25 -28
  86. package/build/es/organisation-unit-node/label/icon-folder-open.js +34 -37
  87. package/build/es/organisation-unit-node/label/icon-single.js +28 -31
  88. package/build/es/organisation-unit-node/label/icon.js +6 -7
  89. package/build/es/organisation-unit-node/label/iconized-checkbox.js +12 -13
  90. package/build/es/organisation-unit-node/label/label-container.js +13 -16
  91. package/build/es/organisation-unit-node/label/label.js +27 -30
  92. package/build/es/organisation-unit-node/label/single-selection-label.js +18 -21
  93. package/build/es/organisation-unit-node/organisation-unit-node-children.js +27 -29
  94. package/build/es/organisation-unit-node/organisation-unit-node.js +22 -23
  95. package/build/es/organisation-unit-node/use-open-state.js +8 -9
  96. package/build/es/organisation-unit-node/use-org-children.js +14 -21
  97. package/build/es/organisation-unit-node/use-org-children.test.js +40 -59
  98. package/build/es/organisation-unit-node/use-org-data/use-org-data.js +13 -20
  99. package/build/es/organisation-unit-node/use-org-data/use-org-data.test.js +17 -27
  100. package/build/es/organisation-unit-tree/default-render-node-label/default-render-node-label.js +3 -6
  101. package/build/es/organisation-unit-tree/organisation-unit-tree-root-error.js +9 -12
  102. package/build/es/organisation-unit-tree/organisation-unit-tree-root-loading.js +10 -13
  103. package/build/es/organisation-unit-tree/organisation-unit-tree.js +34 -27
  104. package/build/es/organisation-unit-tree/organisation-unit-tree.test.js +71 -0
  105. package/build/es/organisation-unit-tree/use-expanded/create-expand-handlers.js +14 -17
  106. package/build/es/organisation-unit-tree/use-expanded/use-expanded.js +8 -9
  107. package/build/es/organisation-unit-tree/use-root-org-data/patch-missing-display-name.js +1 -2
  108. package/build/es/organisation-unit-tree/use-root-org-data/use-root-org-data.js +10 -14
  109. package/build/es/organisation-unit-tree/use-root-org-data/use-root-org-unit.test.js +32 -46
  110. package/package.json +6 -6
  111. package/src/locales/index.js +57 -18
  112. package/src/organisation-unit-tree/organisation-unit-tree.js +14 -3
  113. package/src/organisation-unit-tree/organisation-unit-tree.test.js +64 -0
  114. package/src/organisation-unit-tree/use-root-org-data/use-root-org-unit.test.js +14 -14
@@ -1,34 +1,31 @@
1
1
  import _JSXStyle from "styled-jsx/style";
2
2
  import PropTypes from 'prop-types';
3
3
  import React from 'react';
4
- export const IconFolderClosed = _ref => {
5
- let {
6
- dataTest
7
- } = _ref;
8
- return /*#__PURE__*/React.createElement("svg", {
9
- width: "18px",
10
- height: "18px",
11
- viewBox: "0 0 18 18",
12
- version: "1.1",
13
- "data-test": `${dataTest}-iconfolderclosed`,
14
- className: "jsx-3201893673"
15
- }, /*#__PURE__*/React.createElement("g", {
16
- id: "icon/folder/closed",
17
- stroke: "none",
18
- strokeWidth: "1",
19
- fill: "none",
20
- fillRule: "evenodd",
21
- className: "jsx-3201893673"
22
- }, /*#__PURE__*/React.createElement("path", {
23
- d: "M2,3.5 C1.17157288,3.5 0.5,4.17157288 0.5,5 L0.5,13 C0.5,13.8284271 1.17157288,14.5 2,14.5 L12,14.5 C12.8284271,14.5 13.5,13.8284271 13.5,13 L13.5,7 C13.5,6.17157288 12.8284271,5.5 12,5.5 L6.69098301,5.5 L5.82917961,3.7763932 C5.7444836,3.60700119 5.57135204,3.5 5.38196601,3.5 L2,3.5 Z",
24
- id: "Path-2",
25
- stroke: "#6C7787",
26
- fill: "#D5DDE5",
27
- className: "jsx-3201893673"
28
- })), /*#__PURE__*/React.createElement(_JSXStyle, {
29
- id: "3201893673"
30
- }, ["svg.jsx-3201893673{display:block;margin:3px 0;}"]));
31
- };
4
+ export const IconFolderClosed = ({
5
+ dataTest
6
+ }) => /*#__PURE__*/React.createElement("svg", {
7
+ width: "18px",
8
+ height: "18px",
9
+ viewBox: "0 0 18 18",
10
+ version: "1.1",
11
+ "data-test": `${dataTest}-iconfolderclosed`,
12
+ className: "jsx-3201893673"
13
+ }, /*#__PURE__*/React.createElement("g", {
14
+ id: "icon/folder/closed",
15
+ stroke: "none",
16
+ strokeWidth: "1",
17
+ fill: "none",
18
+ fillRule: "evenodd",
19
+ className: "jsx-3201893673"
20
+ }, /*#__PURE__*/React.createElement("path", {
21
+ d: "M2,3.5 C1.17157288,3.5 0.5,4.17157288 0.5,5 L0.5,13 C0.5,13.8284271 1.17157288,14.5 2,14.5 L12,14.5 C12.8284271,14.5 13.5,13.8284271 13.5,13 L13.5,7 C13.5,6.17157288 12.8284271,5.5 12,5.5 L6.69098301,5.5 L5.82917961,3.7763932 C5.7444836,3.60700119 5.57135204,3.5 5.38196601,3.5 L2,3.5 Z",
22
+ id: "Path-2",
23
+ stroke: "#6C7787",
24
+ fill: "#D5DDE5",
25
+ className: "jsx-3201893673"
26
+ })), /*#__PURE__*/React.createElement(_JSXStyle, {
27
+ id: "3201893673"
28
+ }, ["svg.jsx-3201893673{display:block;margin:3px 0;}"]));
32
29
  IconFolderClosed.propTypes = {
33
30
  dataTest: PropTypes.string.isRequired
34
31
  };
@@ -1,43 +1,40 @@
1
1
  import _JSXStyle from "styled-jsx/style";
2
2
  import PropTypes from 'prop-types';
3
3
  import React from 'react';
4
- export const IconFolderOpen = _ref => {
5
- let {
6
- dataTest
7
- } = _ref;
8
- return /*#__PURE__*/React.createElement("svg", {
9
- width: "18px",
10
- height: "18px",
11
- viewBox: "0 0 18 18",
12
- version: "1.1",
13
- "data-test": `${dataTest}-iconfolderopen`,
14
- className: "jsx-2091325045"
15
- }, /*#__PURE__*/React.createElement("g", {
16
- id: "icon/folder/open",
17
- stroke: "none",
18
- strokeWidth: "1",
19
- fill: "none",
20
- fillRule: "evenodd",
21
- className: "jsx-2091325045"
22
- }, /*#__PURE__*/React.createElement("g", {
23
- id: "Group",
24
- transform: "translate(0.000000, 3.000000)",
25
- stroke: "#6C7787",
26
- className: "jsx-2091325045"
27
- }, /*#__PURE__*/React.createElement("path", {
28
- d: "M2,0.5 C1.17157288,0.5 0.5,1.17157288 0.5,2 L0.5,10 C0.5,10.8284271 1.17157288,11.5 2,11.5 L12,11.5 C12.8284271,11.5 13.5,10.8284271 13.5,10 L13.5,4 C13.5,3.17157288 12.8284271,2.5 12,2.5 L6.69098301,2.5 L5.82917961,0.776393202 C5.7444836,0.607001188 5.57135204,0.5 5.38196601,0.5 L2,0.5 Z",
29
- id: "Path-2",
30
- fill: "#A0ADBA",
31
- className: "jsx-2091325045"
32
- }), /*#__PURE__*/React.createElement("path", {
33
- d: "M1.53632259,10.7093809 C1.47575089,10.7941813 1.44318932,10.8957885 1.44318932,11 C1.44318932,11.2761424 1.66704695,11.5 1.94318932,11.5 L12.4853821,11.5 C12.6468577,11.5 12.7983931,11.4220172 12.8922488,11.2906191 L16.4636774,6.2906191 C16.5242491,6.20581872 16.5568107,6.10421149 16.5568107,6 C16.5568107,5.72385763 16.3329531,5.5 16.0568107,5.5 L5.5146179,5.5 C5.35314234,5.5 5.20160692,5.57798284 5.10775116,5.7093809 L1.53632259,10.7093809 Z",
34
- id: "Path-3",
35
- fill: "#FBFCFD",
36
- className: "jsx-2091325045"
37
- }))), /*#__PURE__*/React.createElement(_JSXStyle, {
38
- id: "2091325045"
39
- }, ["svg.jsx-2091325045{margin:3px 0;display:block;}"]));
40
- };
4
+ export const IconFolderOpen = ({
5
+ dataTest
6
+ }) => /*#__PURE__*/React.createElement("svg", {
7
+ width: "18px",
8
+ height: "18px",
9
+ viewBox: "0 0 18 18",
10
+ version: "1.1",
11
+ "data-test": `${dataTest}-iconfolderopen`,
12
+ className: "jsx-2091325045"
13
+ }, /*#__PURE__*/React.createElement("g", {
14
+ id: "icon/folder/open",
15
+ stroke: "none",
16
+ strokeWidth: "1",
17
+ fill: "none",
18
+ fillRule: "evenodd",
19
+ className: "jsx-2091325045"
20
+ }, /*#__PURE__*/React.createElement("g", {
21
+ id: "Group",
22
+ transform: "translate(0.000000, 3.000000)",
23
+ stroke: "#6C7787",
24
+ className: "jsx-2091325045"
25
+ }, /*#__PURE__*/React.createElement("path", {
26
+ d: "M2,0.5 C1.17157288,0.5 0.5,1.17157288 0.5,2 L0.5,10 C0.5,10.8284271 1.17157288,11.5 2,11.5 L12,11.5 C12.8284271,11.5 13.5,10.8284271 13.5,10 L13.5,4 C13.5,3.17157288 12.8284271,2.5 12,2.5 L6.69098301,2.5 L5.82917961,0.776393202 C5.7444836,0.607001188 5.57135204,0.5 5.38196601,0.5 L2,0.5 Z",
27
+ id: "Path-2",
28
+ fill: "#A0ADBA",
29
+ className: "jsx-2091325045"
30
+ }), /*#__PURE__*/React.createElement("path", {
31
+ d: "M1.53632259,10.7093809 C1.47575089,10.7941813 1.44318932,10.8957885 1.44318932,11 C1.44318932,11.2761424 1.66704695,11.5 1.94318932,11.5 L12.4853821,11.5 C12.6468577,11.5 12.7983931,11.4220172 12.8922488,11.2906191 L16.4636774,6.2906191 C16.5242491,6.20581872 16.5568107,6.10421149 16.5568107,6 C16.5568107,5.72385763 16.3329531,5.5 16.0568107,5.5 L5.5146179,5.5 C5.35314234,5.5 5.20160692,5.57798284 5.10775116,5.7093809 L1.53632259,10.7093809 Z",
32
+ id: "Path-3",
33
+ fill: "#FBFCFD",
34
+ className: "jsx-2091325045"
35
+ }))), /*#__PURE__*/React.createElement(_JSXStyle, {
36
+ id: "2091325045"
37
+ }, ["svg.jsx-2091325045{margin:3px 0;display:block;}"]));
41
38
  IconFolderOpen.propTypes = {
42
39
  dataTest: PropTypes.string.isRequired
43
40
  };
@@ -1,37 +1,34 @@
1
1
  import _JSXStyle from "styled-jsx/style";
2
2
  import PropTypes from 'prop-types';
3
3
  import React from 'react';
4
- export const IconSingle = _ref => {
5
- let {
6
- dataTest
7
- } = _ref;
8
- return /*#__PURE__*/React.createElement("svg", {
9
- height: "18px",
10
- version: "1.1",
11
- viewBox: "0 0 18 18",
12
- width: "18px",
13
- "data-test": `${dataTest}-iconsingle`,
14
- className: "jsx-3201893673"
15
- }, /*#__PURE__*/React.createElement("g", {
16
- fill: "none",
17
- fillRule: "evenodd",
18
- id: "icon/single",
19
- stroke: "none",
20
- strokeWidth: "1",
21
- className: "jsx-3201893673"
22
- }, /*#__PURE__*/React.createElement("rect", {
23
- fill: "#A0ADBA",
24
- height: "4",
25
- id: "Rectangle",
26
- rx: "1",
27
- width: "4",
28
- x: "7",
29
- y: "7",
30
- className: "jsx-3201893673"
31
- })), /*#__PURE__*/React.createElement(_JSXStyle, {
32
- id: "3201893673"
33
- }, ["svg.jsx-3201893673{display:block;margin:3px 0;}"]));
34
- };
4
+ export const IconSingle = ({
5
+ dataTest
6
+ }) => /*#__PURE__*/React.createElement("svg", {
7
+ height: "18px",
8
+ version: "1.1",
9
+ viewBox: "0 0 18 18",
10
+ width: "18px",
11
+ "data-test": `${dataTest}-iconsingle`,
12
+ className: "jsx-3201893673"
13
+ }, /*#__PURE__*/React.createElement("g", {
14
+ fill: "none",
15
+ fillRule: "evenodd",
16
+ id: "icon/single",
17
+ stroke: "none",
18
+ strokeWidth: "1",
19
+ className: "jsx-3201893673"
20
+ }, /*#__PURE__*/React.createElement("rect", {
21
+ fill: "#A0ADBA",
22
+ height: "4",
23
+ id: "Rectangle",
24
+ rx: "1",
25
+ width: "4",
26
+ x: "7",
27
+ y: "7",
28
+ className: "jsx-3201893673"
29
+ })), /*#__PURE__*/React.createElement(_JSXStyle, {
30
+ id: "3201893673"
31
+ }, ["svg.jsx-3201893673{display:block;margin:3px 0;}"]));
35
32
  IconSingle.propTypes = {
36
33
  dataTest: PropTypes.string.isRequired
37
34
  };
@@ -11,13 +11,12 @@ import { IconSingle } from './icon-single.js';
11
11
  * @param {bool} props.open
12
12
  * @returns {React.Component}
13
13
  */
14
- export const Icon = _ref => {
15
- let {
16
- loading,
17
- hasChildren,
18
- open,
19
- dataTest
20
- } = _ref;
14
+ export const Icon = ({
15
+ loading,
16
+ hasChildren,
17
+ open,
18
+ dataTest
19
+ }) => {
21
20
  if (loading) {
22
21
  return /*#__PURE__*/React.createElement(IconEmpty, {
23
22
  dataTest: dataTest
@@ -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,