@progress/kendo-react-orgchart 5.20.0-dev.202310061256
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/LICENSE.md +11 -0
- package/NOTICE.txt +117 -0
- package/README.md +50 -0
- package/about.md +3 -0
- package/dist/cdn/js/kendo-react-orgchart.js +1 -0
- package/dist/es/OrgChart.d.ts +6 -0
- package/dist/es/OrgChart.js +67 -0
- package/dist/es/OrgChartOperationDescriptors.d.ts +76 -0
- package/dist/es/OrgChartOperationDescriptors.js +2 -0
- package/dist/es/client/ClientOrgChart.d.ts +94 -0
- package/dist/es/client/ClientOrgChart.js +287 -0
- package/dist/es/client/ExpandButton.d.ts +13 -0
- package/dist/es/client/ExpandButton.js +23 -0
- package/dist/es/client/OrgChartCard.d.ts +19 -0
- package/dist/es/client/OrgChartCard.js +68 -0
- package/dist/es/client/OrgChartCardBody.d.ts +12 -0
- package/dist/es/client/OrgChartCardBody.js +13 -0
- package/dist/es/client/OrgChartGroupContainer.d.ts +19 -0
- package/dist/es/client/OrgChartGroupContainer.js +71 -0
- package/dist/es/interfaces/ChildGroup.d.ts +16 -0
- package/dist/es/interfaces/ChildGroup.js +1 -0
- package/dist/es/interfaces/OrgChartActionEvent.d.ts +22 -0
- package/dist/es/interfaces/OrgChartActionEvent.js +1 -0
- package/dist/es/interfaces/OrgChartExpandChangeEvent.d.ts +22 -0
- package/dist/es/interfaces/OrgChartExpandChangeEvent.js +1 -0
- package/dist/es/interfaces/SeverOrgChartProps.d.ts +106 -0
- package/dist/es/interfaces/SeverOrgChartProps.js +1 -0
- package/dist/es/main.d.ts +6 -0
- package/dist/es/main.js +3 -0
- package/dist/es/package-metadata.d.ts +5 -0
- package/dist/es/package-metadata.js +11 -0
- package/dist/es/processOrgChartItems.d.ts +51 -0
- package/dist/es/processOrgChartItems.js +163 -0
- package/dist/es/server/ServerGroupedOrgChart.d.ts +9 -0
- package/dist/es/server/ServerGroupedOrgChart.js +235 -0
- package/dist/es/server/ServerOrgChart.d.ts +9 -0
- package/dist/es/server/ServerOrgChart.js +192 -0
- package/dist/es/server/ServerOrgChartGroup.d.ts +96 -0
- package/dist/es/server/ServerOrgChartGroup.js +59 -0
- package/dist/es/server/ServerOrgChartNode.d.ts +75 -0
- package/dist/es/server/ServerOrgChartNode.js +57 -0
- package/dist/es/theming/theme-service.d.ts +5 -0
- package/dist/es/theming/theme-service.js +62 -0
- package/dist/es/utils/consts.d.ts +72 -0
- package/dist/es/utils/consts.js +72 -0
- package/dist/npm/OrgChart.d.ts +6 -0
- package/dist/npm/OrgChart.js +71 -0
- package/dist/npm/OrgChartOperationDescriptors.d.ts +76 -0
- package/dist/npm/OrgChartOperationDescriptors.js +3 -0
- package/dist/npm/client/ClientOrgChart.d.ts +94 -0
- package/dist/npm/client/ClientOrgChart.js +291 -0
- package/dist/npm/client/ExpandButton.d.ts +13 -0
- package/dist/npm/client/ExpandButton.js +27 -0
- package/dist/npm/client/OrgChartCard.d.ts +19 -0
- package/dist/npm/client/OrgChartCard.js +72 -0
- package/dist/npm/client/OrgChartCardBody.d.ts +12 -0
- package/dist/npm/client/OrgChartCardBody.js +17 -0
- package/dist/npm/client/OrgChartGroupContainer.d.ts +19 -0
- package/dist/npm/client/OrgChartGroupContainer.js +75 -0
- package/dist/npm/interfaces/ChildGroup.d.ts +16 -0
- package/dist/npm/interfaces/ChildGroup.js +2 -0
- package/dist/npm/interfaces/OrgChartActionEvent.d.ts +22 -0
- package/dist/npm/interfaces/OrgChartActionEvent.js +2 -0
- package/dist/npm/interfaces/OrgChartExpandChangeEvent.d.ts +22 -0
- package/dist/npm/interfaces/OrgChartExpandChangeEvent.js +2 -0
- package/dist/npm/interfaces/SeverOrgChartProps.d.ts +106 -0
- package/dist/npm/interfaces/SeverOrgChartProps.js +2 -0
- package/dist/npm/main.d.ts +6 -0
- package/dist/npm/main.js +21 -0
- package/dist/npm/package-metadata.d.ts +5 -0
- package/dist/npm/package-metadata.js +14 -0
- package/dist/npm/processOrgChartItems.d.ts +51 -0
- package/dist/npm/processOrgChartItems.js +167 -0
- package/dist/npm/server/ServerGroupedOrgChart.d.ts +9 -0
- package/dist/npm/server/ServerGroupedOrgChart.js +239 -0
- package/dist/npm/server/ServerOrgChart.d.ts +9 -0
- package/dist/npm/server/ServerOrgChart.js +196 -0
- package/dist/npm/server/ServerOrgChartGroup.d.ts +96 -0
- package/dist/npm/server/ServerOrgChartGroup.js +63 -0
- package/dist/npm/server/ServerOrgChartNode.d.ts +75 -0
- package/dist/npm/server/ServerOrgChartNode.js +61 -0
- package/dist/npm/theming/theme-service.d.ts +5 -0
- package/dist/npm/theming/theme-service.js +65 -0
- package/dist/npm/utils/consts.d.ts +72 -0
- package/dist/npm/utils/consts.js +75 -0
- package/dist/systemjs/kendo-react-orgchart.js +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import * as React from 'react';
|
|
24
|
+
import * as PropTypes from 'prop-types';
|
|
25
|
+
import { packageMetadata } from './package-metadata';
|
|
26
|
+
import { ServerOrgChart } from './server/ServerOrgChart';
|
|
27
|
+
import { guid, validatePackage } from '@progress/kendo-react-common';
|
|
28
|
+
import { ServerGroupedOrgChart } from './server/ServerGroupedOrgChart';
|
|
29
|
+
import { ClientOrgChart } from './client/ClientOrgChart';
|
|
30
|
+
/**
|
|
31
|
+
* Represents the OrgChart component.
|
|
32
|
+
*/
|
|
33
|
+
export var OrgChart = function (props) {
|
|
34
|
+
var combinedProps = __assign({ tabIndex: 0, navigatable: true, expandField: 'expanded', ariaLabel: 'Org Chart', idField: 'id', childrenField: 'items', avatarField: 'avatar', titleField: 'title', subTitleField: 'subtitle' }, props);
|
|
35
|
+
var cardsColors = combinedProps.cardsColors, onExpandChange = combinedProps.onExpandChange, onKeyDown = combinedProps.onKeyDown, onItemAction = combinedProps.onItemAction, onGroupAction = combinedProps.onGroupAction, onGroupBlur = combinedProps.onGroupBlur, onGroupFocus = combinedProps.onGroupFocus, id = combinedProps.id, other = __rest(combinedProps, ["cardsColors", "onExpandChange", "onKeyDown", "onItemAction", "onGroupAction", "onGroupBlur", "onGroupFocus", "id"]);
|
|
36
|
+
var generateId = React.useRef(guid());
|
|
37
|
+
validatePackage(packageMetadata);
|
|
38
|
+
return (React.createElement(ClientOrgChart, __assign({}, combinedProps), props.groupField
|
|
39
|
+
? React.createElement(ServerGroupedOrgChart, __assign({ id: id || generateId.current }, other), props.children)
|
|
40
|
+
: React.createElement(ServerOrgChart, __assign({ id: id || generateId.current }, other), props.children)));
|
|
41
|
+
};
|
|
42
|
+
OrgChart.propTypes = {
|
|
43
|
+
className: PropTypes.string,
|
|
44
|
+
style: PropTypes.object,
|
|
45
|
+
id: PropTypes.string,
|
|
46
|
+
ariaLabel: PropTypes.string,
|
|
47
|
+
idField: PropTypes.string,
|
|
48
|
+
childrenField: PropTypes.string,
|
|
49
|
+
expandField: PropTypes.string,
|
|
50
|
+
titleField: PropTypes.string,
|
|
51
|
+
hasChildrenField: PropTypes.string,
|
|
52
|
+
subTitleField: PropTypes.string,
|
|
53
|
+
avatarField: PropTypes.string,
|
|
54
|
+
cardsColors: PropTypes.array,
|
|
55
|
+
data: PropTypes.array,
|
|
56
|
+
groupField: PropTypes.string,
|
|
57
|
+
cardHeight: PropTypes.number,
|
|
58
|
+
cardWidth: PropTypes.number,
|
|
59
|
+
groupTitleHeight: PropTypes.number,
|
|
60
|
+
groupSubtitleHeight: PropTypes.number,
|
|
61
|
+
verticalLine: PropTypes.number,
|
|
62
|
+
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
63
|
+
onExpandChange: PropTypes.func,
|
|
64
|
+
onItemAction: PropTypes.func,
|
|
65
|
+
onGroupAction: PropTypes.func
|
|
66
|
+
};
|
|
67
|
+
OrgChart.displayName = 'KendoOrgChart';
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The descriptors of the data operations which are applied to the OrgChart component.
|
|
3
|
+
*/
|
|
4
|
+
export interface OrgChartOperationDescriptors {
|
|
5
|
+
/**
|
|
6
|
+
* The hierarchical indices of the items to which the expand operation will be applied, or the descriptor of the operation.
|
|
7
|
+
*/
|
|
8
|
+
expand?: string[] | OrgChartOperationDescriptor;
|
|
9
|
+
/**
|
|
10
|
+
* The hierarchical indices of the items to which the select operation will be applied, or the descriptor of the operation.
|
|
11
|
+
*/
|
|
12
|
+
select?: string[] | OrgChartOperationDescriptor;
|
|
13
|
+
/**
|
|
14
|
+
* The hierarchical indices of the items to which the check operation will be applied, or the descriptor of the operation.
|
|
15
|
+
*/
|
|
16
|
+
check?: string[] | OrgChartCheckDescriptor;
|
|
17
|
+
/**
|
|
18
|
+
* When the operations are applied, the corresponding items and their parents are cloned.
|
|
19
|
+
* For performance reasons, OrgChart items are cloned only once.
|
|
20
|
+
* The name of the field which provides a Boolean representation of whether an item is already cloned.
|
|
21
|
+
* Defaults to `cloned`.
|
|
22
|
+
*/
|
|
23
|
+
cloneField?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The expand field of the item.
|
|
26
|
+
*/
|
|
27
|
+
expandField?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The select field of the item.
|
|
30
|
+
*/
|
|
31
|
+
selectField?: string;
|
|
32
|
+
/**
|
|
33
|
+
* The check field of the item.
|
|
34
|
+
*/
|
|
35
|
+
checkField?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The children field of the item.
|
|
38
|
+
*/
|
|
39
|
+
childrenField?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The descriptor which is used for expanding, selecting, and checking.
|
|
43
|
+
*/
|
|
44
|
+
export interface OrgChartOperationDescriptor {
|
|
45
|
+
/**
|
|
46
|
+
* The IDs of the items to which the operation will be applied. By default, the OrgChart applies the hierarchical indices of the items. These indices are zero-based. The first root item has a `0` (zero) index. If the first root item has children, the first child acquires a `0_0` index and the second acquires a `0_1` index.
|
|
47
|
+
*/
|
|
48
|
+
ids?: any[];
|
|
49
|
+
/**
|
|
50
|
+
* The name of the field which will provide a Boolean representation for the operation state of the item.
|
|
51
|
+
*
|
|
52
|
+
* The default fields are:
|
|
53
|
+
* * `expanded`—Indicates that an item is expanded.
|
|
54
|
+
* * `selected`—Indicates that an item is selected.
|
|
55
|
+
* * `checked`—Indicates that an item is checked.
|
|
56
|
+
*/
|
|
57
|
+
operationField?: string;
|
|
58
|
+
/**
|
|
59
|
+
* The name of the field which will uniquely describe an item as an alternative to its hierarchical index.
|
|
60
|
+
*/
|
|
61
|
+
idField?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The descriptor which is used for checking.
|
|
65
|
+
*/
|
|
66
|
+
export interface OrgChartCheckDescriptor extends OrgChartOperationDescriptor {
|
|
67
|
+
/**
|
|
68
|
+
* Determines if a parent item will have an indeterminate state when not all its children are checked.
|
|
69
|
+
*/
|
|
70
|
+
applyCheckIndeterminate?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* The name of the field which will provide a Boolean representation for the indeterminate state of a parent item.
|
|
73
|
+
* Defaults to `checkIndeterminate`.
|
|
74
|
+
*/
|
|
75
|
+
checkIndeterminateField?: string;
|
|
76
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as PropTypes from 'prop-types';
|
|
3
|
+
import { ServerOrgChartProps } from '../interfaces/SeverOrgChartProps';
|
|
4
|
+
import { OrgChartActionEvent } from '../interfaces/OrgChartActionEvent';
|
|
5
|
+
import { OrgChartExpandChangeEvent } from '../main';
|
|
6
|
+
/**
|
|
7
|
+
* Represents the props of the [KendoReact OrgChart component]({% slug overview_orgchart %}).
|
|
8
|
+
*/
|
|
9
|
+
export interface OrgChartProps extends ServerOrgChartProps {
|
|
10
|
+
/**
|
|
11
|
+
* Specifies if the OrgChart can be navigatable with keyboard.
|
|
12
|
+
* Defaults to `true`.
|
|
13
|
+
*/
|
|
14
|
+
navigatable?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Fires when a node or group is expanded.
|
|
17
|
+
*/
|
|
18
|
+
onExpandChange?: (ev: OrgChartExpandChangeEvent) => void;
|
|
19
|
+
/**
|
|
20
|
+
* @hidden
|
|
21
|
+
*/
|
|
22
|
+
onKeyDown?: (ev: OrgChartActionEvent) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Triggers the item action event.
|
|
25
|
+
*/
|
|
26
|
+
onItemAction?: (ev: OrgChartActionEvent) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Triggers the item double click action event.
|
|
29
|
+
*/
|
|
30
|
+
onItemDoubleClick?: (ev: OrgChartActionEvent) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Triggers the item contextmenu action event.
|
|
33
|
+
*/
|
|
34
|
+
onItemContextMenu?: (ev: OrgChartActionEvent) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Triggers the group action event.
|
|
37
|
+
*/
|
|
38
|
+
onGroupAction?: (ev: OrgChartActionEvent) => void;
|
|
39
|
+
/**
|
|
40
|
+
* @hidden
|
|
41
|
+
*/
|
|
42
|
+
onGroupBlur?: (ev: OrgChartActionEvent) => void;
|
|
43
|
+
/**
|
|
44
|
+
* @hidden
|
|
45
|
+
*/
|
|
46
|
+
onGroupFocus?: (ev: OrgChartActionEvent) => void;
|
|
47
|
+
}
|
|
48
|
+
declare type OrgChartEventsContextType = {
|
|
49
|
+
cardColors?: string[];
|
|
50
|
+
onExpandChange?: (ev: OrgChartExpandChangeEvent) => void;
|
|
51
|
+
onKeyDown?: (ev: OrgChartActionEvent) => void;
|
|
52
|
+
onItemAction?: (ev: OrgChartActionEvent) => void;
|
|
53
|
+
onItemContextMenu?: (ev: OrgChartActionEvent) => void;
|
|
54
|
+
onItemDoubleClick?: (ev: OrgChartActionEvent) => void;
|
|
55
|
+
onGroupAction?: (ev: OrgChartActionEvent) => void;
|
|
56
|
+
onGroupBlur?: (ev: OrgChartActionEvent) => void;
|
|
57
|
+
onGroupFocus?: (ev: OrgChartActionEvent) => void;
|
|
58
|
+
};
|
|
59
|
+
export declare const OrgChartEventsContextContext: React.Context<OrgChartEventsContextType>;
|
|
60
|
+
/**
|
|
61
|
+
* @hidden
|
|
62
|
+
*/
|
|
63
|
+
export declare const ClientOrgChart: {
|
|
64
|
+
(props: OrgChartProps): JSX.Element;
|
|
65
|
+
propTypes: {
|
|
66
|
+
className: PropTypes.Requireable<string>;
|
|
67
|
+
style: PropTypes.Requireable<object>;
|
|
68
|
+
id: PropTypes.Requireable<string>;
|
|
69
|
+
ariaLabel: PropTypes.Requireable<string>;
|
|
70
|
+
idField: PropTypes.Requireable<string>;
|
|
71
|
+
childrenField: PropTypes.Requireable<string>;
|
|
72
|
+
expandField: PropTypes.Requireable<string>;
|
|
73
|
+
titleField: PropTypes.Requireable<string>;
|
|
74
|
+
hasChildrenField: PropTypes.Requireable<string>;
|
|
75
|
+
subTitleField: PropTypes.Requireable<string>;
|
|
76
|
+
avatarField: PropTypes.Requireable<string>;
|
|
77
|
+
cardsColors: PropTypes.Requireable<any[]>;
|
|
78
|
+
data: PropTypes.Requireable<any[]>;
|
|
79
|
+
groupField: PropTypes.Requireable<string>;
|
|
80
|
+
cardHeight: PropTypes.Requireable<number>;
|
|
81
|
+
cardWidth: PropTypes.Requireable<number>;
|
|
82
|
+
groupTitleHeight: PropTypes.Requireable<number>;
|
|
83
|
+
groupSubtitleHeight: PropTypes.Requireable<number>;
|
|
84
|
+
verticalLine: PropTypes.Requireable<number>;
|
|
85
|
+
height: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
86
|
+
onExpandChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
87
|
+
onItemAction: PropTypes.Requireable<(...args: any[]) => any>;
|
|
88
|
+
onItemDoubleClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
89
|
+
onItemContextMenu: PropTypes.Requireable<(...args: any[]) => any>;
|
|
90
|
+
onGroupAction: PropTypes.Requireable<(...args: any[]) => any>;
|
|
91
|
+
};
|
|
92
|
+
displayName: string;
|
|
93
|
+
};
|
|
94
|
+
export {};
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
import * as React from 'react';
|
|
25
|
+
import * as PropTypes from 'prop-types';
|
|
26
|
+
import { Navigation, classNames } from '@progress/kendo-react-common';
|
|
27
|
+
import { loadTheme } from '../theming/theme-service';
|
|
28
|
+
import { ORGCHART_CLASSNAME } from '../utils/consts';
|
|
29
|
+
export var OrgChartEventsContextContext = React.createContext({
|
|
30
|
+
cardColors: undefined,
|
|
31
|
+
onExpandChange: undefined,
|
|
32
|
+
onKeyDown: undefined,
|
|
33
|
+
onItemAction: undefined,
|
|
34
|
+
onItemContextMenu: undefined,
|
|
35
|
+
onItemDoubleClick: undefined,
|
|
36
|
+
onGroupAction: undefined,
|
|
37
|
+
onGroupBlur: undefined,
|
|
38
|
+
onGroupFocus: undefined
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* @hidden
|
|
42
|
+
*/
|
|
43
|
+
export var ClientOrgChart = function (props) {
|
|
44
|
+
var combinedProps = __assign({ tabIndex: 0, navigatable: true, expandField: 'expanded', ariaLabel: 'Org Chart', idField: 'id', childrenField: 'items', avatarField: 'avatar', titleField: 'title', subTitleField: 'subtitle' }, props);
|
|
45
|
+
var navigatable = combinedProps.navigatable, id = combinedProps.id, tabIndex = combinedProps.tabIndex, className = combinedProps.className, style = combinedProps.style, data = combinedProps.data, groupField = combinedProps.groupField, cardWidth = combinedProps.cardWidth, cardHeight = combinedProps.cardHeight, groupTitleHeight = combinedProps.groupTitleHeight, groupSubtitleHeight = combinedProps.groupSubtitleHeight, verticalLine = combinedProps.verticalLine, idField = combinedProps.idField, childrenField = combinedProps.childrenField, expandField = combinedProps.expandField, hasChildrenField = combinedProps.hasChildrenField, avatarField = combinedProps.avatarField, titleField = combinedProps.titleField, subTitleField = combinedProps.subTitleField, onExpandChange = combinedProps.onExpandChange, onItemAction = combinedProps.onItemAction, onItemDoubleClick = combinedProps.onItemDoubleClick, onItemContextMenu = combinedProps.onItemContextMenu, onKeyDown = combinedProps.onKeyDown, onGroupAction = combinedProps.onGroupAction, onGroupBlur = combinedProps.onGroupBlur, onGroupFocus = combinedProps.onGroupFocus, cardsColors = combinedProps.cardsColors, ariaLabel = combinedProps.ariaLabel, itemRender = combinedProps.itemRender, groupTitleRender = combinedProps.groupTitleRender, groupSubtitleRender = combinedProps.groupSubtitleRender, height = combinedProps.height, children = combinedProps.children, other = __rest(combinedProps, ["navigatable", "id", "tabIndex", "className", "style", "data", "groupField", "cardWidth", "cardHeight", "groupTitleHeight", "groupSubtitleHeight", "verticalLine", "idField", "childrenField", "expandField", "hasChildrenField", "avatarField", "titleField", "subTitleField", "onExpandChange", "onItemAction", "onItemDoubleClick", "onItemContextMenu", "onKeyDown", "onGroupAction", "onGroupBlur", "onGroupFocus", "cardsColors", "ariaLabel", "itemRender", "groupTitleRender", "groupSubtitleRender", "height", "children"]);
|
|
46
|
+
var orgChartRef = React.useRef(null);
|
|
47
|
+
var navigation = React.useRef(new Navigation({
|
|
48
|
+
tabIndex: tabIndex,
|
|
49
|
+
root: orgChartRef,
|
|
50
|
+
selectors: [combinedProps.groupField ? '.k-orgchart-node-group-container' : '.k-orgchart-card'],
|
|
51
|
+
focusOptions: {}
|
|
52
|
+
}));
|
|
53
|
+
var _a = React.useState([]), cardColorsFromTheme = _a[0], setCardColorsFromTheme = _a[1];
|
|
54
|
+
var innerNavigation = React.useRef(null);
|
|
55
|
+
var onRight = function (target, nav, ev) {
|
|
56
|
+
ev.preventDefault();
|
|
57
|
+
nav.focusNext(target);
|
|
58
|
+
};
|
|
59
|
+
var onLeft = function (target, nav, ev) {
|
|
60
|
+
ev.preventDefault();
|
|
61
|
+
nav.focusPrevious(target);
|
|
62
|
+
};
|
|
63
|
+
var onUp = function (target, nav, ev, options) {
|
|
64
|
+
var _a;
|
|
65
|
+
ev.preventDefault();
|
|
66
|
+
var expanded = combinedProps.groupField
|
|
67
|
+
? options.items.some(function (i) { return i[combinedProps.expandField]; })
|
|
68
|
+
: options.item[combinedProps.expandField];
|
|
69
|
+
if (expanded && combinedProps.onExpandChange) {
|
|
70
|
+
combinedProps.onExpandChange.call(undefined, options);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
var parentSelector = '.k-orgchart-group';
|
|
74
|
+
var current = (_a = target.closest(parentSelector)) === null || _a === void 0 ? void 0 : _a.getAttribute('id');
|
|
75
|
+
var next = document.querySelector("[aria-owns=\"".concat(current, "\"]"));
|
|
76
|
+
if (next) {
|
|
77
|
+
nav.focusElement(next, target);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
nav.focusPrevious(target);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var onDown = function (target, nav, ev, options) {
|
|
85
|
+
var _a;
|
|
86
|
+
ev.preventDefault();
|
|
87
|
+
var expanded = combinedProps.groupField
|
|
88
|
+
? options.items.some(function (i) { return i[combinedProps.expandField]; })
|
|
89
|
+
: options.item[combinedProps.expandField];
|
|
90
|
+
var subItems = combinedProps.groupField
|
|
91
|
+
? options.items.find(function (i) { return i[combinedProps.childrenField]; })
|
|
92
|
+
: options.item[combinedProps.childrenField];
|
|
93
|
+
var hasChildren = combinedProps.groupField
|
|
94
|
+
? options.items.some(function (i) { return combinedProps.hasChildrenField && i[combinedProps.hasChildrenField]; })
|
|
95
|
+
: combinedProps.hasChildrenField && options.item[combinedProps.hasChildrenField];
|
|
96
|
+
var hasSubItems = combinedProps.groupField
|
|
97
|
+
? subItems && subItems[combinedProps.childrenField] && subItems[combinedProps.childrenField].length
|
|
98
|
+
: subItems && subItems.length;
|
|
99
|
+
if ((hasChildren || hasSubItems) && !expanded && combinedProps.onExpandChange) {
|
|
100
|
+
combinedProps.onExpandChange.call(undefined, options);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
var selector = combinedProps.groupField ? '.k-orgchart-node-group-container' : '.k-orgchart-card';
|
|
104
|
+
var current = target.getAttribute('aria-owns');
|
|
105
|
+
var next = (_a = document.getElementById(current)) === null || _a === void 0 ? void 0 : _a.querySelector(selector);
|
|
106
|
+
if (next) {
|
|
107
|
+
nav.focusElement(next, target);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
nav.focusNext(target);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
var onHome = function (_target, nav, ev) {
|
|
115
|
+
ev.preventDefault();
|
|
116
|
+
nav.focusElement(nav.first, null);
|
|
117
|
+
};
|
|
118
|
+
var onEnd = function (_target, nav, ev) {
|
|
119
|
+
ev.preventDefault();
|
|
120
|
+
nav.focusElement(nav.last, null);
|
|
121
|
+
};
|
|
122
|
+
var onEnter = function (target, _nav, ev, options) {
|
|
123
|
+
ev.stopPropagation();
|
|
124
|
+
var isGroupFocused = target.className.indexOf('k-orgchart-node-group-container') !== -1;
|
|
125
|
+
if (props.groupField && isGroupFocused) {
|
|
126
|
+
if (innerNavigation.current && innerNavigation.current.first) {
|
|
127
|
+
innerNavigation.current.focusElement(innerNavigation.current.first, null);
|
|
128
|
+
}
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (combinedProps.onItemAction) {
|
|
132
|
+
combinedProps.onItemAction({
|
|
133
|
+
event: ev,
|
|
134
|
+
item: options.item
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
var onEscape = function (target) {
|
|
139
|
+
if (props.groupField) {
|
|
140
|
+
var parentGroup = target.closest('.k-orgchart-node-group-container');
|
|
141
|
+
if (parentGroup) {
|
|
142
|
+
navigation.current.focusElement(parentGroup, null);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
React.useEffect(function () {
|
|
147
|
+
if (navigatable) {
|
|
148
|
+
if (navigation.current.first) {
|
|
149
|
+
navigation.current.first.setAttribute('tabindex', String(tabIndex));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (!cardsColors) {
|
|
153
|
+
var doc = orgChartRef.current.ownerDocument || document;
|
|
154
|
+
loadTheme(function (groupsColors) {
|
|
155
|
+
setCardColorsFromTheme(groupsColors);
|
|
156
|
+
}, doc);
|
|
157
|
+
}
|
|
158
|
+
}, [navigatable, tabIndex]);
|
|
159
|
+
var handleKeyDown = function (e) {
|
|
160
|
+
if (combinedProps.navigatable) {
|
|
161
|
+
// defaulted to this one but oddly didn't work in some cases
|
|
162
|
+
// navigation.current.triggerKeyboardEvent(e.event, e);
|
|
163
|
+
var event_1 = e.event;
|
|
164
|
+
var key = event_1.key === ' ' ? 'Space' : event_1.key;
|
|
165
|
+
var currentNavigation = props.groupField
|
|
166
|
+
? event_1.target.className.indexOf('k-orgchart-card') !== -1
|
|
167
|
+
? innerNavigation.current || navigation.current
|
|
168
|
+
: navigation.current
|
|
169
|
+
: navigation.current;
|
|
170
|
+
var target = event_1.target.closest(currentNavigation.selectors.join(','));
|
|
171
|
+
switch (key) {
|
|
172
|
+
case 'ArrowUp':
|
|
173
|
+
onUp(target, currentNavigation, event_1, e);
|
|
174
|
+
break;
|
|
175
|
+
case 'ArrowDown':
|
|
176
|
+
onDown(target, currentNavigation, event_1, e);
|
|
177
|
+
break;
|
|
178
|
+
case 'ArrowLeft':
|
|
179
|
+
onLeft(target, currentNavigation, event_1);
|
|
180
|
+
break;
|
|
181
|
+
case 'ArrowRight':
|
|
182
|
+
onRight(target, currentNavigation, event_1);
|
|
183
|
+
break;
|
|
184
|
+
case 'End':
|
|
185
|
+
onEnd(target, currentNavigation, event_1);
|
|
186
|
+
break;
|
|
187
|
+
case 'Home':
|
|
188
|
+
onHome(target, currentNavigation, event_1);
|
|
189
|
+
break;
|
|
190
|
+
case 'Enter':
|
|
191
|
+
onEnter(target, currentNavigation, event_1, e);
|
|
192
|
+
break;
|
|
193
|
+
case 'Escape':
|
|
194
|
+
onEscape(target);
|
|
195
|
+
break;
|
|
196
|
+
default:
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
var handleItemAction = function (e) {
|
|
202
|
+
e.event.stopPropagation();
|
|
203
|
+
if (onItemAction) {
|
|
204
|
+
onItemAction.call(undefined, e);
|
|
205
|
+
}
|
|
206
|
+
if (combinedProps.navigatable) {
|
|
207
|
+
var closestOrgChartCard = e.event.target.closest('.k-orgchart-card');
|
|
208
|
+
if (closestOrgChartCard) {
|
|
209
|
+
navigation.current.focusElement(closestOrgChartCard, null);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
var handleContextMenu = function (e) {
|
|
214
|
+
e.event.stopPropagation();
|
|
215
|
+
if (onItemAction) {
|
|
216
|
+
onItemAction.call(undefined, e);
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
var handleDoubleClick = function (e) {
|
|
220
|
+
e.event.stopPropagation();
|
|
221
|
+
if (onItemAction) {
|
|
222
|
+
onItemAction.call(undefined, e);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
var handleGroupAction = function (e) {
|
|
226
|
+
if (onGroupAction) {
|
|
227
|
+
onGroupAction.call(undefined, e);
|
|
228
|
+
}
|
|
229
|
+
if (combinedProps.navigatable) {
|
|
230
|
+
var closestOrgChartCard = e.event.target.closest('.k-orgchart-node-group-container');
|
|
231
|
+
if (closestOrgChartCard) {
|
|
232
|
+
navigation.current.focusElement(closestOrgChartCard, null);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
var handleGroupBlur = function (_e) {
|
|
237
|
+
innerNavigation.current = null;
|
|
238
|
+
};
|
|
239
|
+
var handleGroupFocus = function (e) {
|
|
240
|
+
innerNavigation.current = new Navigation({
|
|
241
|
+
tabIndex: 0,
|
|
242
|
+
root: e.containerRef,
|
|
243
|
+
selectors: ['.k-orgchart-card'],
|
|
244
|
+
focusOptions: {}
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
return (React.createElement("div", { style: style, ref: orgChartRef, className: classNames(className, ORGCHART_CLASSNAME) },
|
|
248
|
+
React.createElement(OrgChartEventsContextContext.Provider, __assign({ value: {
|
|
249
|
+
cardColors: cardsColors || cardColorsFromTheme,
|
|
250
|
+
onExpandChange: props.onExpandChange,
|
|
251
|
+
onKeyDown: handleKeyDown,
|
|
252
|
+
onItemAction: handleItemAction,
|
|
253
|
+
onItemDoubleClick: handleDoubleClick,
|
|
254
|
+
onItemContextMenu: handleContextMenu,
|
|
255
|
+
onGroupAction: handleGroupAction,
|
|
256
|
+
onGroupBlur: handleGroupBlur,
|
|
257
|
+
onGroupFocus: handleGroupFocus
|
|
258
|
+
} }, other), props.children)));
|
|
259
|
+
};
|
|
260
|
+
ClientOrgChart.propTypes = {
|
|
261
|
+
className: PropTypes.string,
|
|
262
|
+
style: PropTypes.object,
|
|
263
|
+
id: PropTypes.string,
|
|
264
|
+
ariaLabel: PropTypes.string,
|
|
265
|
+
idField: PropTypes.string,
|
|
266
|
+
childrenField: PropTypes.string,
|
|
267
|
+
expandField: PropTypes.string,
|
|
268
|
+
titleField: PropTypes.string,
|
|
269
|
+
hasChildrenField: PropTypes.string,
|
|
270
|
+
subTitleField: PropTypes.string,
|
|
271
|
+
avatarField: PropTypes.string,
|
|
272
|
+
cardsColors: PropTypes.array,
|
|
273
|
+
data: PropTypes.array,
|
|
274
|
+
groupField: PropTypes.string,
|
|
275
|
+
cardHeight: PropTypes.number,
|
|
276
|
+
cardWidth: PropTypes.number,
|
|
277
|
+
groupTitleHeight: PropTypes.number,
|
|
278
|
+
groupSubtitleHeight: PropTypes.number,
|
|
279
|
+
verticalLine: PropTypes.number,
|
|
280
|
+
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
281
|
+
onExpandChange: PropTypes.func,
|
|
282
|
+
onItemAction: PropTypes.func,
|
|
283
|
+
onItemDoubleClick: PropTypes.func,
|
|
284
|
+
onItemContextMenu: PropTypes.func,
|
|
285
|
+
onGroupAction: PropTypes.func
|
|
286
|
+
};
|
|
287
|
+
ClientOrgChart.displayName = 'KendoClientOrgChart';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @hidden
|
|
4
|
+
*/
|
|
5
|
+
export interface ExpandButtonProps {
|
|
6
|
+
node?: any;
|
|
7
|
+
nodes?: any[];
|
|
8
|
+
expanded?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @hidden
|
|
12
|
+
*/
|
|
13
|
+
export declare const ExpandButton: React.FunctionComponent<ExpandButtonProps>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Button } from '@progress/kendo-react-buttons';
|
|
4
|
+
import { minusIcon, plusIcon } from '@progress/kendo-svg-icons';
|
|
5
|
+
import { OrgChartEventsContextContext } from './ClientOrgChart';
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
9
|
+
export var ExpandButton = function (props) {
|
|
10
|
+
var expanded = props.expanded, node = props.node, nodes = props.nodes;
|
|
11
|
+
var context = React.useContext(OrgChartEventsContextContext);
|
|
12
|
+
var onClick = function (event) {
|
|
13
|
+
if (context.onExpandChange) {
|
|
14
|
+
context.onExpandChange.call(undefined, {
|
|
15
|
+
event: event,
|
|
16
|
+
expand: !expanded,
|
|
17
|
+
item: node,
|
|
18
|
+
items: nodes
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return (React.createElement(Button, { className: "k-orgchart-button", icon: expanded ? 'minus' : 'plus', tabIndex: -1, svgIcon: expanded ? minusIcon : plusIcon, "aria-label": expanded ? 'collapse' : 'expand', onClick: onClick }));
|
|
23
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @hidden
|
|
4
|
+
*/
|
|
5
|
+
export interface OrgChartCardProps {
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* The styles that are applied to the OrgChart.
|
|
12
|
+
*/
|
|
13
|
+
style?: React.CSSProperties;
|
|
14
|
+
node?: any;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @hidden
|
|
18
|
+
*/
|
|
19
|
+
export declare const OrgChartCard: React.FunctionComponent<OrgChartCardProps>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
import * as React from 'react';
|
|
25
|
+
import { Card } from '@progress/kendo-react-layout';
|
|
26
|
+
import { classNames } from '@progress/kendo-react-common';
|
|
27
|
+
import { OrgChartEventsContextContext } from './ClientOrgChart';
|
|
28
|
+
/**
|
|
29
|
+
* @hidden
|
|
30
|
+
*/
|
|
31
|
+
export var OrgChartCard = function (props) {
|
|
32
|
+
var node = props.node, children = props.children, style = props.style, others = __rest(props, ["node", "children", "style"]);
|
|
33
|
+
var _a = React.useState(false), selected = _a[0], setSelected = _a[1];
|
|
34
|
+
var context = React.useContext(OrgChartEventsContextContext);
|
|
35
|
+
var handleKeyDown = function (event) {
|
|
36
|
+
if (context.onKeyDown) {
|
|
37
|
+
context.onKeyDown.call(undefined, {
|
|
38
|
+
event: event,
|
|
39
|
+
item: node
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var handleClick = function (event) {
|
|
44
|
+
if (context.onItemAction) {
|
|
45
|
+
context.onItemAction.call(undefined, {
|
|
46
|
+
event: event,
|
|
47
|
+
item: node
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var handleContextMenu = function (event) {
|
|
52
|
+
if (context.onItemContextMenu) {
|
|
53
|
+
context.onItemContextMenu.call(undefined, {
|
|
54
|
+
event: event,
|
|
55
|
+
item: node
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var handleDoubleClick = function (event) {
|
|
60
|
+
if (context.onItemDoubleClick) {
|
|
61
|
+
context.onItemDoubleClick.call(undefined, {
|
|
62
|
+
event: event,
|
|
63
|
+
item: node
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
return (React.createElement(Card, __assign({ role: "treeitem", className: classNames('k-orgchart-card', { 'k-focus': selected }), onClick: handleClick, onKeyDown: handleKeyDown, onContextMenu: handleContextMenu, onDoubleClick: handleDoubleClick, style: style, "aria-selected": selected, "aria-keyshortcuts": "Enter", onFocus: function () { return setSelected(true); }, onBlur: function () { return setSelected(false); } }, others), children));
|
|
68
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* @hidden
|
|
4
|
+
*/
|
|
5
|
+
export interface OrgChartCardBodyProps {
|
|
6
|
+
level: number;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @hidden
|
|
11
|
+
*/
|
|
12
|
+
export declare const OrgChartCardBody: React.FunctionComponent<OrgChartCardBodyProps>;
|