@progress/kendo-themes-html 4.43.1-dev.2 → 4.43.1-dev.6

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,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 };
package/utils/styles.js CHANGED
@@ -72,6 +72,14 @@ function borderedClass( bordered, prefix ) {
72
72
  return `${prefix}-bordered`;
73
73
  }
74
74
 
75
+ function positionClass( position, prefix ) {
76
+ if ( position === null ) {
77
+ return '';
78
+ }
79
+
80
+ return `k-pos-absolute ${prefix}-${position}`;
81
+ }
82
+
75
83
  function classNames( ...args ) {
76
84
 
77
85
  /* eslint-disable arrow-body-style, no-nested-ternary */
@@ -131,6 +139,7 @@ export {
131
139
  fillModeClass,
132
140
  themeColorClass,
133
141
  borderedClass,
142
+ positionClass,
134
143
 
135
144
  classNames,
136
145
  cssStyle,