@progress/kendo-themes-html 4.43.1-dev.4 → 4.43.1-dev.8

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.
@@ -0,0 +1,142 @@
1
+ import { Component, globalDefaultProps } from '../component/index';
2
+ import { TreeviewGroupStatic } from './treeview-group.jsx';
3
+ import { TreeviewLeafStatic } from './treeview-leaf.jsx';
4
+ import { IconStatic } from '../icon/index';
5
+ import { CheckboxStatic } from '../checkbox/index';
6
+
7
+ class TreeviewItem extends Component {
8
+ render() {
9
+ return <TreeviewItemStatic {...this.props} />;
10
+ }
11
+ }
12
+
13
+ function TreeviewItemStatic(props) {
14
+ const {
15
+ className: ownClassName,
16
+ leafClassName,
17
+
18
+ items,
19
+ expanded,
20
+ hasChildren: _hasChildren,
21
+
22
+ text,
23
+
24
+ showIcon,
25
+ iconName,
26
+ showCheckbox,
27
+ checked,
28
+
29
+ hover,
30
+ focus,
31
+ selected,
32
+ disabled,
33
+
34
+ aria,
35
+ legacy,
36
+
37
+ ...htmlAttributes
38
+ } = props;
39
+
40
+ const leafProps = {
41
+ className: leafClassName,
42
+ text,
43
+ showIcon,
44
+ iconName,
45
+ hover,
46
+ focus,
47
+ selected
48
+ };
49
+
50
+ const hasChildren = _hasChildren || items.length > 0;
51
+
52
+ let treeviewItemClasses = [
53
+ ownClassName,
54
+ 'k-treeview-item',
55
+ {
56
+ 'k-disabled': disabled === true
57
+ }
58
+ ];
59
+
60
+ let ariaAttr = aria
61
+ ? {}
62
+ : {};
63
+
64
+ if (legacy) {
65
+
66
+ let legacyTreeviewItemClasses = [
67
+ ownClassName,
68
+ 'k-item',
69
+ {
70
+ 'k-state-disabled': disabled === true
71
+ }
72
+ ];
73
+
74
+ return (
75
+ <li className={legacyTreeviewItemClasses} {...ariaAttr} {...htmlAttributes}>
76
+ <span className="k-mid">
77
+ {hasChildren && <span className="k-treeview-toggle"><IconStatic name={expanded ? 'collapse' : 'expand'} /></span>}
78
+ {showCheckbox && <CheckboxStatic checked={checked} />}
79
+ <TreeviewLeafStatic {...leafProps} />
80
+ </span>
81
+ {expanded && hasChildren && <TreeviewGroupStatic items={items} />}
82
+ </li>
83
+ );
84
+ }
85
+
86
+ return (
87
+ <li className={treeviewItemClasses} {...ariaAttr} {...htmlAttributes}>
88
+ <span className="k-treeview-mid">
89
+ {hasChildren && <span className="k-treeview-toggle"><IconStatic name={expanded ? 'collapse' : 'expand'} /></span>}
90
+ {showCheckbox && <CheckboxStatic checked={checked} />}
91
+ <TreeviewLeafStatic {...leafProps} />
92
+ </span>
93
+ {expanded && hasChildren && <TreeviewGroupStatic items={items} />}
94
+ </li>
95
+ );
96
+ }
97
+
98
+ TreeviewItemStatic.defaultProps = {
99
+ ...globalDefaultProps,
100
+
101
+ leafClassName: '',
102
+
103
+ text: '',
104
+
105
+ items: [],
106
+ expanded: false,
107
+ hasChildren: false,
108
+
109
+ showIcon: false,
110
+ iconName: '',
111
+ showCheckbox: false,
112
+ checked: false,
113
+ };
114
+
115
+ TreeviewItemStatic.propTypes = {
116
+ children: typeof [],
117
+ className: typeof '',
118
+ leafClassName: typeof '',
119
+
120
+ text: typeof '',
121
+
122
+ items: [],
123
+ expanded: typeof false,
124
+ hasChildren: typeof false,
125
+
126
+ showIcon: typeof false,
127
+ iconName: typeof '',
128
+ showCheckbox: typeof false,
129
+ checked: typeof false,
130
+
131
+ hover: typeof false,
132
+ focus: typeof false,
133
+ selected: typeof false,
134
+ disabled: typeof false,
135
+
136
+ aria: typeof false,
137
+ legacy: typeof false,
138
+
139
+ htmlAttributes: typeof []
140
+ };
141
+
142
+ export { TreeviewItem, TreeviewItemStatic };
@@ -0,0 +1,99 @@
1
+ import { Component, globalDefaultProps } from '../component/index';
2
+ import { IconStatic } from '../icon/index';
3
+
4
+ class TreeviewLeaf extends Component {
5
+ render() {
6
+ return <TreeviewLeafStatic {...this.props} />;
7
+ }
8
+ }
9
+
10
+ function TreeviewLeafStatic(props) {
11
+ const {
12
+ className: ownClassName,
13
+
14
+ text,
15
+
16
+ showIcon,
17
+ iconName,
18
+
19
+ hover,
20
+ focus,
21
+ selected,
22
+
23
+ aria,
24
+ legacy,
25
+
26
+ ...htmlAttributes
27
+ } = props;
28
+
29
+ let treeviewLeafClasses = [
30
+ ownClassName,
31
+ 'k-treeview-leaf',
32
+ {
33
+ 'k-hover': hover === true,
34
+ 'k-focus': focus === true,
35
+ 'k-selected': selected === true
36
+ }
37
+ ];
38
+
39
+ let ariaAttr = aria
40
+ ? {}
41
+ : {};
42
+
43
+ if (legacy) {
44
+
45
+ let legacyTreeviewLeafClasses = [
46
+ ownClassName,
47
+ 'k-in',
48
+ {
49
+ 'k-state-hover': hover === true,
50
+ 'k-state-focus': focus === true,
51
+ 'k-state-selected': selected === true
52
+ }
53
+ ];
54
+
55
+ return (
56
+ <span className={legacyTreeviewLeafClasses} {...ariaAttr} {...htmlAttributes}>
57
+ {showIcon && <IconStatic name={iconName} />}
58
+ <span className="k-treeview-leaf-text">{text}</span>
59
+ </span>
60
+ );
61
+ }
62
+
63
+ return (
64
+ <span className={treeviewLeafClasses} {...ariaAttr} {...htmlAttributes}>
65
+ {showIcon && <IconStatic name={iconName} />}
66
+ <span className="k-treeview-leaf-text">{text}</span>
67
+ </span>
68
+ );
69
+ }
70
+
71
+ TreeviewLeafStatic.defaultProps = {
72
+ ...globalDefaultProps,
73
+
74
+ text: '',
75
+
76
+ showIcon: false,
77
+ iconName: ''
78
+ };
79
+
80
+ TreeviewLeafStatic.propTypes = {
81
+ children: typeof [],
82
+ className: typeof '',
83
+
84
+ text: typeof '',
85
+
86
+ showIcon: typeof false,
87
+ iconName: typeof '',
88
+
89
+ hover: typeof false,
90
+ focus: typeof false,
91
+ selected: typeof false,
92
+
93
+ aria: typeof false,
94
+ legacy: typeof false,
95
+
96
+ htmlAttributes: typeof []
97
+ };
98
+
99
+ export { TreeviewLeaf, TreeviewLeafStatic };
@@ -0,0 +1,125 @@
1
+ import * as styles from '../../utils/styles';
2
+ import { Component, globalDefaultProps } from '../component/index';
3
+ import { TreeviewGroupStatic } from './treeview-group.jsx';
4
+ import { TreeviewItemStatic } from './treeview-item.jsx';
5
+
6
+ class Treeview extends Component {
7
+
8
+ static transformUL( ul ) {
9
+ let children = ul.props.children;
10
+ let items = [];
11
+
12
+ children.filter( child => child.type === 'LI' ).forEach( li => {
13
+ items.push( Treeview.transformLI( li ) );
14
+ });
15
+
16
+ return items;
17
+ }
18
+
19
+ static transformLI( li ) {
20
+ let children = li.props.children;
21
+ let text = li.props.text || '';
22
+ let items = [];
23
+
24
+ children.forEach( child => {
25
+ if (text === '' && child.type === '#text') {
26
+ text = child.props.text;
27
+ }
28
+ if (child.type === 'UL') {
29
+ items.push( ...Treeview.transformUL( child ) );
30
+ }
31
+ });
32
+
33
+ li.props.children = [];
34
+ li.props.text = text;
35
+ li.props.items = items;
36
+
37
+ return <TreeviewItemStatic {...li.props} />;
38
+ }
39
+
40
+ init() {
41
+ let children = this._props.children;
42
+ let items = [];
43
+
44
+ children.filter( child => child.type === 'LI' ).forEach( li => {
45
+ items.push( Treeview.transformLI( li ) );
46
+ });
47
+
48
+ this._props.children = [];
49
+ this._props.items = items;
50
+ }
51
+
52
+ render() {
53
+ return <TreeviewStatic {...this.props} />;
54
+ }
55
+ }
56
+
57
+ function TreeviewStatic(props) {
58
+ const {
59
+ className: ownClassName,
60
+
61
+ items,
62
+
63
+ size,
64
+
65
+ aria,
66
+ legacy,
67
+
68
+ ...htmlAttributes
69
+ } = props;
70
+
71
+ let treeviewClasses = [
72
+ ownClassName,
73
+ 'k-treeview',
74
+ styles.sizeClass( size, 'k-treeview' )
75
+ ];
76
+
77
+ let ariaAttr = aria
78
+ ? {}
79
+ : {};
80
+
81
+ if (legacy) {
82
+
83
+ let legacyTreeviewClasses = [
84
+ ownClassName,
85
+ 'k-treeview'
86
+ ];
87
+
88
+ return (
89
+ <div className={legacyTreeviewClasses} {...ariaAttr} {...htmlAttributes}>
90
+ <TreeviewGroupStatic className="k-treeview-lines" items={items} />
91
+ </div>
92
+ );
93
+ }
94
+
95
+ return (
96
+ <div className={treeviewClasses} {...ariaAttr} {...htmlAttributes}>
97
+ <TreeviewGroupStatic className="k-treeview-lines" items={items} />
98
+ </div>
99
+ );
100
+ }
101
+
102
+ TreeviewStatic.defaultProps = {
103
+ ...globalDefaultProps,
104
+
105
+ children: [],
106
+ items: [],
107
+
108
+ size: 'medium'
109
+ };
110
+
111
+ TreeviewStatic.propTypes = {
112
+ children: typeof [],
113
+ className: typeof '',
114
+
115
+ items: typeof [],
116
+
117
+ size: typeof [ null, 'small', 'medium', 'large' ],
118
+
119
+ aria: typeof false,
120
+ legacy: typeof false,
121
+
122
+ htmlAttributes: typeof []
123
+ };
124
+
125
+ export { Treeview, TreeviewStatic };