@dhis2-ui/organisation-unit-tree 8.16.0-alpha.2 → 8.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.js +2 -2
- package/build/cjs/organisation-unit-tree/index.js +6 -6
- package/build/cjs/organisation-unit-tree/organisation-unit-tree.js +3 -3
- package/build/cjs/organisation-unit-tree/{organisation-unit-tree-root-error.js → root-error.js} +5 -5
- package/build/cjs/organisation-unit-tree/{organisation-unit-tree-root-loading.js → root-loading.js} +5 -5
- package/build/es/index.js +1 -1
- package/build/es/organisation-unit-tree/index.js +2 -2
- package/build/es/organisation-unit-tree/organisation-unit-tree.js +3 -3
- package/build/es/organisation-unit-tree/{organisation-unit-tree-root-error.js → root-error.js} +3 -3
- package/build/es/organisation-unit-tree/{organisation-unit-tree-root-loading.js → root-loading.js} +3 -3
- package/package.json +7 -10
- package/types/index.d.ts +0 -165
package/build/cjs/index.js
CHANGED
|
@@ -12,13 +12,13 @@ Object.defineProperty(exports, "OrganisationUnitTree", {
|
|
|
12
12
|
Object.defineProperty(exports, "OrganisationUnitTreeRootError", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return _index.
|
|
15
|
+
return _index.RootError;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "OrganisationUnitTreeRootLoading", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function () {
|
|
21
|
-
return _index.
|
|
21
|
+
return _index.RootLoading;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "getAllExpandedOrgUnitPaths", {
|
|
@@ -9,21 +9,21 @@ Object.defineProperty(exports, "OrganisationUnitTree", {
|
|
|
9
9
|
return _organisationUnitTree.OrganisationUnitTree;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "RootError", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return
|
|
15
|
+
return _rootError.RootError;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
Object.defineProperty(exports, "
|
|
18
|
+
Object.defineProperty(exports, "RootLoading", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function () {
|
|
21
|
-
return
|
|
21
|
+
return _rootLoading.RootLoading;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
var _organisationUnitTree = require("./organisation-unit-tree.js");
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _rootError = require("./root-error.js");
|
|
28
28
|
|
|
29
|
-
var
|
|
29
|
+
var _rootLoading = require("./root-loading.js");
|
|
@@ -19,9 +19,9 @@ var _index2 = require("./default-render-node-label/index.js");
|
|
|
19
19
|
|
|
20
20
|
var _filterRootIds = require("./filter-root-ids.js");
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _rootError = require("./root-error.js");
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var _rootLoading = require("./root-loading.js");
|
|
25
25
|
|
|
26
26
|
var _index3 = require("./use-expanded/index.js");
|
|
27
27
|
|
|
@@ -95,7 +95,7 @@ const OrganisationUnitTree = _ref => {
|
|
|
95
95
|
const isLoading = !called || loading;
|
|
96
96
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
97
97
|
"data-test": dataTest
|
|
98
|
-
}, isLoading && /*#__PURE__*/_react.default.createElement(
|
|
98
|
+
}, isLoading && /*#__PURE__*/_react.default.createElement(_rootLoading.RootLoading, null), error && /*#__PURE__*/_react.default.createElement(_rootError.RootError, {
|
|
99
99
|
error: error
|
|
100
100
|
}), !error && !isLoading && rootIds.map(rootId => {
|
|
101
101
|
const rootNode = data[rootId];
|
package/build/cjs/organisation-unit-tree/{organisation-unit-tree-root-error.js → root-error.js}
RENAMED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.RootError = void 0;
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
|
@@ -13,7 +13,7 @@ var _index = _interopRequireDefault(require("../locales/index.js"));
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const RootError = _ref => {
|
|
17
17
|
let {
|
|
18
18
|
dataTest,
|
|
19
19
|
error
|
|
@@ -26,11 +26,11 @@ const OrganisationUnitTreeRootError = _ref => {
|
|
|
26
26
|
}));
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
exports.
|
|
30
|
-
|
|
29
|
+
exports.RootError = RootError;
|
|
30
|
+
RootError.defaultProps = {
|
|
31
31
|
dataTest: 'dhis2-uiwidgets-orgunittree-error'
|
|
32
32
|
};
|
|
33
|
-
|
|
33
|
+
RootError.propTypes = {
|
|
34
34
|
error: _propTypes.default.string.isRequired,
|
|
35
35
|
dataTest: _propTypes.default.string
|
|
36
36
|
};
|
package/build/cjs/organisation-unit-tree/{organisation-unit-tree-root-loading.js → root-loading.js}
RENAMED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.RootLoading = void 0;
|
|
7
7
|
|
|
8
8
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
9
|
|
|
@@ -15,7 +15,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const RootLoading = _ref => {
|
|
19
19
|
let {
|
|
20
20
|
dataTest
|
|
21
21
|
} = _ref;
|
|
@@ -29,10 +29,10 @@ const OrganisationUnitTreeRootLoading = _ref => {
|
|
|
29
29
|
}, ["div.jsx-814846266{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}"]));
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
exports.
|
|
33
|
-
|
|
32
|
+
exports.RootLoading = RootLoading;
|
|
33
|
+
RootLoading.defaultProps = {
|
|
34
34
|
dataTest: 'dhis2-uiwidgets-orgunittree-loading'
|
|
35
35
|
};
|
|
36
|
-
|
|
36
|
+
RootLoading.propTypes = {
|
|
37
37
|
dataTest: _propTypes.default.string
|
|
38
38
|
};
|
package/build/es/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { OrganisationUnitTree, OrganisationUnitTreeRootError, OrganisationUnitTreeRootLoading } from './organisation-unit-tree/index.js';
|
|
1
|
+
export { OrganisationUnitTree, RootError as OrganisationUnitTreeRootError, RootLoading as OrganisationUnitTreeRootLoading } from './organisation-unit-tree/index.js';
|
|
2
2
|
export { getAllExpandedPaths as getAllExpandedOrgUnitPaths } from './get-all-expanded-paths/index.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { OrganisationUnitTree } from './organisation-unit-tree.js';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
2
|
+
export { RootError } from './root-error.js';
|
|
3
|
+
export { RootLoading } from './root-loading.js';
|
|
@@ -5,8 +5,8 @@ import { OrganisationUnitNode } from '../organisation-unit-node/index.js';
|
|
|
5
5
|
import { orgUnitPathPropType } from '../prop-types.js';
|
|
6
6
|
import { defaultRenderNodeLabel } from './default-render-node-label/index.js';
|
|
7
7
|
import { filterRootIds } from './filter-root-ids.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { RootError } from './root-error.js';
|
|
9
|
+
import { RootLoading } from './root-loading.js';
|
|
10
10
|
import { useExpanded } from './use-expanded/index.js';
|
|
11
11
|
import { useForceReload } from './use-force-reload.js';
|
|
12
12
|
import { useRootOrgData } from './use-root-org-data/index.js';
|
|
@@ -71,7 +71,7 @@ const OrganisationUnitTree = _ref => {
|
|
|
71
71
|
const isLoading = !called || loading;
|
|
72
72
|
return /*#__PURE__*/React.createElement("div", {
|
|
73
73
|
"data-test": dataTest
|
|
74
|
-
}, isLoading && /*#__PURE__*/React.createElement(
|
|
74
|
+
}, isLoading && /*#__PURE__*/React.createElement(RootLoading, null), error && /*#__PURE__*/React.createElement(RootError, {
|
|
75
75
|
error: error
|
|
76
76
|
}), !error && !isLoading && rootIds.map(rootId => {
|
|
77
77
|
const rootNode = data[rootId];
|
package/build/es/organisation-unit-tree/{organisation-unit-tree-root-error.js → root-error.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import i18n from '../locales/index.js';
|
|
4
|
-
export const
|
|
4
|
+
export const RootError = _ref => {
|
|
5
5
|
let {
|
|
6
6
|
dataTest,
|
|
7
7
|
error
|
|
@@ -13,10 +13,10 @@ export const OrganisationUnitTreeRootError = _ref => {
|
|
|
13
13
|
nsSeparator: '>'
|
|
14
14
|
}));
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
RootError.defaultProps = {
|
|
17
17
|
dataTest: 'dhis2-uiwidgets-orgunittree-error'
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
RootError.propTypes = {
|
|
20
20
|
error: PropTypes.string.isRequired,
|
|
21
21
|
dataTest: PropTypes.string
|
|
22
22
|
};
|
package/build/es/organisation-unit-tree/{organisation-unit-tree-root-loading.js → root-loading.js}
RENAMED
|
@@ -2,7 +2,7 @@ import _JSXStyle from "styled-jsx/style";
|
|
|
2
2
|
import { CircularLoader } from '@dhis2-ui/loader';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
export const
|
|
5
|
+
export const RootLoading = _ref => {
|
|
6
6
|
let {
|
|
7
7
|
dataTest
|
|
8
8
|
} = _ref;
|
|
@@ -15,9 +15,9 @@ export const OrganisationUnitTreeRootLoading = _ref => {
|
|
|
15
15
|
id: "814846266"
|
|
16
16
|
}, ["div.jsx-814846266{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}"]));
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
RootLoading.defaultProps = {
|
|
19
19
|
dataTest: 'dhis2-uiwidgets-orgunittree-loading'
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
RootLoading.propTypes = {
|
|
22
22
|
dataTest: PropTypes.string
|
|
23
23
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/organisation-unit-tree",
|
|
3
|
-
"version": "8.16.0
|
|
3
|
+
"version": "8.16.0",
|
|
4
4
|
"description": "UI OrganisationUnitTree",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
"main": "./build/cjs/index.js",
|
|
14
14
|
"module": "./build/es/index.js",
|
|
15
15
|
"exports": {
|
|
16
|
-
"types": "./types/index.d.ts",
|
|
17
16
|
"import": "./build/es/index.js",
|
|
18
17
|
"require": "./build/cjs/index.js"
|
|
19
18
|
},
|
|
@@ -35,16 +34,15 @@
|
|
|
35
34
|
},
|
|
36
35
|
"dependencies": {
|
|
37
36
|
"@dhis2/prop-types": "^3.1.2",
|
|
38
|
-
"@dhis2-ui/checkbox": "8.16.0
|
|
39
|
-
"@dhis2-ui/loader": "8.16.0
|
|
40
|
-
"@dhis2-ui/node": "8.16.0
|
|
41
|
-
"@dhis2/ui-constants": "8.16.0
|
|
37
|
+
"@dhis2-ui/checkbox": "8.16.0",
|
|
38
|
+
"@dhis2-ui/loader": "8.16.0",
|
|
39
|
+
"@dhis2-ui/node": "8.16.0",
|
|
40
|
+
"@dhis2/ui-constants": "8.16.0",
|
|
42
41
|
"classnames": "^2.3.1",
|
|
43
42
|
"prop-types": "^15.7.2"
|
|
44
43
|
},
|
|
45
44
|
"files": [
|
|
46
|
-
"build"
|
|
47
|
-
"types"
|
|
45
|
+
"build"
|
|
48
46
|
],
|
|
49
47
|
"devDependencies": {
|
|
50
48
|
"@dhis2/app-runtime": "^3.9.0",
|
|
@@ -52,6 +50,5 @@
|
|
|
52
50
|
"react": "16.13",
|
|
53
51
|
"react-dom": "16.13",
|
|
54
52
|
"styled-jsx": "^4.0.1"
|
|
55
|
-
}
|
|
56
|
-
"types": "types"
|
|
53
|
+
}
|
|
57
54
|
}
|
package/types/index.d.ts
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
|
|
3
|
-
export type OrganisationUnitTreeRoots = string | string[]
|
|
4
|
-
|
|
5
|
-
export interface OrganisationUnitNode {
|
|
6
|
-
id: string
|
|
7
|
-
displayName: string
|
|
8
|
-
children?: number
|
|
9
|
-
path: string
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface OrganisationUnitEventPayload extends OrganisationUnitNode {
|
|
13
|
-
checked: boolean
|
|
14
|
-
selected: string[]
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface NodeLabelProps {
|
|
18
|
-
disableSelection: boolean
|
|
19
|
-
hasChildren: boolean
|
|
20
|
-
hasSelectedDescendants: boolean
|
|
21
|
-
loading: boolean
|
|
22
|
-
selected: string[]
|
|
23
|
-
open: boolean
|
|
24
|
-
path: string[]
|
|
25
|
-
singleSelection: boolean
|
|
26
|
-
node: OrganisationUnitNode
|
|
27
|
-
label: string
|
|
28
|
-
checked: boolean
|
|
29
|
-
highlighted: boolean
|
|
30
|
-
error?: Error
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface OrganisationUnitTreeProps {
|
|
34
|
-
/**
|
|
35
|
-
* Root org unit ID(s)
|
|
36
|
-
*/
|
|
37
|
-
roots: OrganisationUnitTreeRoots
|
|
38
|
-
/**
|
|
39
|
-
* Will be called with the following object:
|
|
40
|
-
* `{ id: string, displayName: string, path: string, checked: boolean, selected: string[] }`
|
|
41
|
-
*/
|
|
42
|
-
onChange: (
|
|
43
|
-
payload: OrganisationUnitEventPayload,
|
|
44
|
-
event: React.MouseEvent<HTMLSpanElement | HTMLInputElement>
|
|
45
|
-
) => void
|
|
46
|
-
/**
|
|
47
|
-
* When set, the error when loading children fails will be shown automatically
|
|
48
|
-
*/
|
|
49
|
-
autoExpandLoadingError?: boolean
|
|
50
|
-
dataTest?: string
|
|
51
|
-
/**
|
|
52
|
-
* When set to true, no unit can be selected
|
|
53
|
-
*/
|
|
54
|
-
disableSelection?: boolean
|
|
55
|
-
expanded?: boolean
|
|
56
|
-
/**
|
|
57
|
-
* All organisation units with a path that includes the provided paths will be shown.
|
|
58
|
-
* All others will not be rendered. When not provided, all org units will be shown.
|
|
59
|
-
*/
|
|
60
|
-
filter?: string[]
|
|
61
|
-
/**
|
|
62
|
-
* When true, everything will be reloaded. In order to load it again after reloading, `forceReload` has to be set to `false` and then to `true` again
|
|
63
|
-
*/
|
|
64
|
-
forceReload?: boolean
|
|
65
|
-
handleCollapse?: ({ path: string }) => void
|
|
66
|
-
handleExpand?: ({ path: string }) => void
|
|
67
|
-
/**
|
|
68
|
-
* All units provided to "highlighted" as path will be visually
|
|
69
|
-
* highlighted.
|
|
70
|
-
* Note:
|
|
71
|
-
* The d2-ui component used two props for this:
|
|
72
|
-
* * searchResults
|
|
73
|
-
* * highlightSearchResults
|
|
74
|
-
*/
|
|
75
|
-
highlighted?: string[]
|
|
76
|
-
/**
|
|
77
|
-
* An array of OU paths that will be expanded automatically
|
|
78
|
-
* as soon as they are encountered.
|
|
79
|
-
* The path of an OU is the UIDs of the OU
|
|
80
|
-
* and all its parent OUs separated by slashes (/)
|
|
81
|
-
* Note: This replaces "openFirstLevel" as that's redundant
|
|
82
|
-
*/
|
|
83
|
-
initiallyExpanded?: string[]
|
|
84
|
-
/**
|
|
85
|
-
* When provided, the 'isUserDataViewFallback' option will be sent when requesting the org units
|
|
86
|
-
*/
|
|
87
|
-
isUserDataViewFallback?: boolean
|
|
88
|
-
/**
|
|
89
|
-
* Renders the actual node component for each leaf, can be used to
|
|
90
|
-
* customize the node. The default function just returns the node's
|
|
91
|
-
* displayName
|
|
92
|
-
* Shape of the object passed to the callback:
|
|
93
|
-
* ```
|
|
94
|
-
* {
|
|
95
|
-
* label: string,
|
|
96
|
-
* node: {
|
|
97
|
-
* displayName: string,
|
|
98
|
-
* id: string,
|
|
99
|
-
* // Only provided once `loading` is false
|
|
100
|
-
* path?: string,
|
|
101
|
-
* // Only provided once `loading` is false
|
|
102
|
-
* children?: Array.<{
|
|
103
|
-
* id: string,
|
|
104
|
-
* path: string,
|
|
105
|
-
* displayName: string
|
|
106
|
-
* }>
|
|
107
|
-
* },
|
|
108
|
-
* loading: boolean,
|
|
109
|
-
* error: string,
|
|
110
|
-
* open: boolean,
|
|
111
|
-
* selected: string[],
|
|
112
|
-
* singleSelection: boolean,
|
|
113
|
-
* disableSelection: boolean,
|
|
114
|
-
* }
|
|
115
|
-
* ```
|
|
116
|
-
*/
|
|
117
|
-
renderNodeLabel?: (props: NodeLabelProps) => React.ReactNode
|
|
118
|
-
/**
|
|
119
|
-
* An array of paths of selected OUs. The path of an OU is the UIDs of the OU and all its parent OUs separated by slashes (`/`)
|
|
120
|
-
*/
|
|
121
|
-
selected?: string[]
|
|
122
|
-
/**
|
|
123
|
-
* When set, no checkboxes will be displayed and only the first selected path in `selected` will be highlighted
|
|
124
|
-
*/
|
|
125
|
-
singleSelection?: boolean
|
|
126
|
-
/**
|
|
127
|
-
* Turns off alphabetical sorting of units
|
|
128
|
-
*/
|
|
129
|
-
suppressAlphabeticalSorting?: boolean
|
|
130
|
-
/**
|
|
131
|
-
* Called with the children's data that was loaded
|
|
132
|
-
*/
|
|
133
|
-
onChildrenLoaded?: (
|
|
134
|
-
data: OrganisationUnitNode & {
|
|
135
|
-
children: Array<Omit<OrganisationUnitNode, 'children'>>
|
|
136
|
-
}
|
|
137
|
-
) => void
|
|
138
|
-
/**
|
|
139
|
-
* Called with `{ path: string }` with the path of the parent of the level closed
|
|
140
|
-
*/
|
|
141
|
-
onCollapse?: ({ path: string }) => void
|
|
142
|
-
/**
|
|
143
|
-
* Called with `{ path: string }` with the path of the parent of the level opened
|
|
144
|
-
*/
|
|
145
|
-
onExpand?: ({ path: string }) => void
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export const OrganisationUnitTree: React.FC<OrganisationUnitTreeProps>
|
|
149
|
-
|
|
150
|
-
export interface OrganisationUnitTreeRootErrorProps {
|
|
151
|
-
error: string
|
|
152
|
-
dataTest?: string
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export const OrganisationUnitTreeRootError: React.FC<OrganisationUnitTreeRootErrorProps>
|
|
156
|
-
|
|
157
|
-
export interface OrganisationUnitTreeRootLoadingProps {
|
|
158
|
-
dataTest?: string
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export const OrganisationUnitTreeRootLoading: React.FC<OrganisationUnitTreeRootLoadingProps>
|
|
162
|
-
|
|
163
|
-
export const getAllExpandedOrgUnitPaths: (
|
|
164
|
-
initiallyExpanded: string[]
|
|
165
|
-
) => string[]
|