@progress/kendo-themes-html 4.43.1-dev.4 → 4.43.1-dev.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.
@@ -40,7 +40,16 @@ const attrMap = {
40
40
  thumbrounded: 'thumbRounded',
41
41
 
42
42
  // Chip
43
- showavatar: 'showAvatar'
43
+ showavatar: 'showAvatar',
44
+
45
+ // Hierarchy
46
+ haschildren: 'hasChildren',
47
+
48
+ // Treeview
49
+ leafclassname: 'leafClassName',
50
+
51
+ // Template
52
+ contenttemplate: 'contentTemplate'
44
53
  };
45
54
 
46
55
  const booleanAttr = new Set([
@@ -73,6 +82,12 @@ const booleanAttr = new Set([
73
82
  'virtualization',
74
83
  'root',
75
84
 
85
+ 'open',
86
+ 'expanded',
87
+ 'hasChildren',
88
+
89
+ 'showArrow',
90
+
76
91
  'showAvatar',
77
92
 
78
93
  'aria'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@progress/kendo-themes-html",
3
3
  "description": "A collection of HTML helpers used for developing Kendo UI themes",
4
- "version": "4.43.1-dev.4",
4
+ "version": "4.43.1-dev.5",
5
5
  "author": "Progress",
6
6
  "license": "Apache-2.0",
7
7
  "keywords": [
@@ -34,13 +34,13 @@
34
34
  "dev": "rollup -cw"
35
35
  },
36
36
  "devDependencies": {
37
- "@babel/core": "^7.16.0",
38
- "@babel/preset-env": "^7.16.0",
39
- "@babel/preset-react": "^7.16.0",
37
+ "@babel/core": "^7.16.7",
38
+ "@babel/preset-env": "^7.16.7",
39
+ "@babel/preset-react": "^7.16.7",
40
40
  "@rollup/plugin-babel": "^5.3.0",
41
41
  "@rollup/plugin-commonjs": "^21.0.1",
42
- "@rollup/plugin-node-resolve": "^13.0.6",
43
- "rollup": "^2.59.0"
42
+ "@rollup/plugin-node-resolve": "^13.1.2",
43
+ "rollup": "^2.62.0"
44
44
  },
45
- "gitHead": "f0dfb6acb8fcf7694986e41e4b08d242c4b47add"
45
+ "gitHead": "ac48eb1c0df9b906d3bef3e7881332555f14a232"
46
46
  }
@@ -75,7 +75,7 @@ function AutocompleteStatic(props) {
75
75
  'k-autocomplete',
76
76
  {
77
77
  'k-state-hover': hover === true,
78
- 'k-state-focused': focus === true,
78
+ 'k-state-focus': focus === true,
79
79
  'k-state-invalid': invalid === true,
80
80
  'k-state-required': required === true,
81
81
  'k-state-disabled': disabled === true
@@ -2,7 +2,7 @@
2
2
  <!-- default rendering -->
3
3
  <div class="k-avatar k-avatar-md k-rounded-circle k-avatar-solid k-avatar-solid-primary">
4
4
  <span class="k-avatar-image">
5
- <img src="../../assets/avatar.jpg" class="">
5
+ <img src="../../assets/avatar.jpg" />
6
6
  </span>
7
7
  </div>
8
8
 
@@ -87,7 +87,7 @@ function ButtonStatic(props) {
87
87
  if (legacy) {
88
88
  return (
89
89
  <button type={type} className={legacyClasses} {...ariaAttr} {...htmlAttributes}>
90
- <IconStatic name={icon} />
90
+ <IconStatic className="k-button-icon" name={icon} />
91
91
  { text }
92
92
  </button>
93
93
  );
@@ -74,12 +74,12 @@ function CheckboxStatic(props) {
74
74
  ];
75
75
 
76
76
  return (
77
- <input type="checkbox" className={legacyClasses} {...ariaAttr} {...htmlAttributes} />
77
+ <span className="k-checkbox-wrap"><input type="checkbox" className={legacyClasses} {...ariaAttr} {...htmlAttributes} /></span>
78
78
  );
79
79
  }
80
80
 
81
81
  return (
82
- <input type="checkbox" className={checkboxClasses} {...ariaAttr} {...htmlAttributes} />
82
+ <span className="k-checkbox-wrap"><input type="checkbox" className={checkboxClasses} {...ariaAttr} {...htmlAttributes} /></span>
83
83
  );
84
84
  }
85
85
 
@@ -4,7 +4,7 @@ function ChipAvatarStatic() {
4
4
 
5
5
  return (
6
6
  <AvatarStatic className="k-chip-avatar" type="image">
7
- <img src="../../assets/avatar.jpg"/>
7
+ <img src="../../assets/avatar.jpg" />
8
8
  </AvatarStatic>
9
9
  );
10
10
 
package/src/index.js CHANGED
@@ -70,7 +70,7 @@ export * from './switch/index';
70
70
  // Command interfaces
71
71
  // export * from './action-buttons/index';
72
72
  export * from './fab/index';
73
- // export * from './menu/index';
73
+ export * from './menu/index';
74
74
  // export * from './toolbar/index';
75
75
 
76
76
  // Popups and modals
@@ -89,6 +89,7 @@ export * from './fab/index';
89
89
  // export * from './pager/index';
90
90
  // export * from './stepper/index';
91
91
  // export * from './tabstrip/index';
92
+ export * from './treeview/index';
92
93
  // export * from './wizard/index';
93
94
 
94
95
  // Layout & containers
@@ -0,0 +1,40 @@
1
+ ```html
2
+ <!-- default rendering -->
3
+ <ul class="k-group k-menu-group k-reset"></ul>
4
+
5
+ <!-- canonical rendering -->
6
+ <ul class="
7
+ k-group k-menu-group k-reset
8
+ k-menulist-{size}
9
+ "
10
+ ></ul>
11
+ ```
12
+
13
+ ```html
14
+ <!-- default rendering -->
15
+ <li class="k-item k-menu-item">
16
+ <span class="k-link k-menu-link">
17
+ {icon !== '' && <span class="k-icon k-i-{icon}"></span>}
18
+ {text !== '' && <span class="k-menu-link-text">Text</span>}
19
+ <span className="k-menu-expand-arrow k-icon k-i-{arrowIconName || 'none'}"></span>
20
+ </span>
21
+ </li>
22
+
23
+ <!-- canonical rendering -->
24
+ <li class="
25
+ k-item
26
+ k-menu-item
27
+ {hover && 'k-hover'}
28
+ {focus && 'k-focus'}
29
+ {active && 'k-active'}
30
+ {disabled && 'k-disabled'}
31
+ " disabled={disabled}>
32
+ <span class="k-link k-menu-link">
33
+ {icon !== '' && <span class="k-icon k-i-{icon}"></span>}
34
+ {text !== '' && <span class="k-menu-link-text">Text</span>}
35
+ {showArrow && <span className="k-menu-expand-arrow">
36
+ <span className="k-icon k-i-{arrowIconName || 'none'}"></span>
37
+ </span>}
38
+ </span>
39
+ </li>
40
+ ```
@@ -0,0 +1,3 @@
1
+ export * from './menu-list.jsx';
2
+ export * from './menu-item.jsx';
3
+ export * from './menu-item-content.jsx';
@@ -0,0 +1,48 @@
1
+ import { Component, globalDefaultProps } from '../component/index';
2
+
3
+ class MenuItemContent extends Component {
4
+ render() {
5
+ return <MenuItemContentStatic {...this.props} />;
6
+ }
7
+ }
8
+
9
+ function MenuItemContentStatic(props) {
10
+
11
+ const {
12
+ className: ownClassName,
13
+
14
+ children,
15
+
16
+ ...htmlAttributes
17
+ } = props;
18
+
19
+ let menuItemContentClasses = [
20
+ ownClassName,
21
+ 'k-menu-item-content'
22
+ ];
23
+
24
+ if (children.length === 0) {
25
+ return <></>;
26
+ }
27
+
28
+ return (
29
+ <span className={menuItemContentClasses} {...htmlAttributes}>
30
+ {children}
31
+ </span>
32
+ );
33
+ }
34
+
35
+ MenuItemContentStatic.defaultProps = {
36
+ ...globalDefaultProps,
37
+
38
+ children: []
39
+ };
40
+
41
+ MenuItemContentStatic.propTypes = {
42
+ children: typeof [],
43
+ className: typeof '',
44
+
45
+ htmlAttributes: typeof []
46
+ };
47
+
48
+ export { MenuItemContent, MenuItemContentStatic };
@@ -0,0 +1,174 @@
1
+ import { Component, globalDefaultProps } from '../component/index';
2
+ import { IconStatic } from '../icon/index';
3
+
4
+ class MenuItem extends Component {
5
+ init() {
6
+ let subItem = <></>;
7
+ let contentTemplate = <></>;
8
+ let children = this._props.children;
9
+ let newChildren = [];
10
+
11
+ children.forEach( child => {
12
+ let component = child._component;
13
+
14
+ if (component === 'MenuItem') {
15
+ subItem.props.children.push( child );
16
+ return;
17
+ }
18
+
19
+ if (component === 'MenuItemContent') {
20
+ contentTemplate.props.children.push( child );
21
+ return;
22
+ }
23
+
24
+ newChildren.push( child );
25
+ });
26
+
27
+ this._props.subItem = subItem;
28
+ this._props.contentTemplate = contentTemplate;
29
+ this._props.children = newChildren;
30
+ }
31
+ render() {
32
+ return <MenuItemStatic {...this.props} />;
33
+ }
34
+ }
35
+
36
+ function MenuItemStatic(props) {
37
+ const {
38
+ className: ownClassName,
39
+
40
+ text,
41
+
42
+ icon,
43
+
44
+ showArrow,
45
+ arrowIconName,
46
+
47
+ contentTemplate,
48
+
49
+ hover,
50
+ focus,
51
+ active,
52
+ selected,
53
+ disabled,
54
+
55
+ dir,
56
+
57
+ aria,
58
+ legacy,
59
+
60
+ ...htmlAttributes
61
+ } = props;
62
+
63
+ let menuItemClasses = [
64
+ ownClassName,
65
+ 'k-item k-menu-item',
66
+ {
67
+ 'k-disabled': disabled === true
68
+ }
69
+ ];
70
+
71
+ let menuItemLinkClasses = [
72
+ 'k-link k-menu-link',
73
+ {
74
+ 'k-hover': hover === true,
75
+ 'k-focus': focus === true,
76
+ 'k-active': active === true,
77
+ 'k-selected': selected === true,
78
+ 'k-disabled': disabled === true
79
+ }
80
+ ];
81
+
82
+ let expandArrowName = arrowIconName;
83
+
84
+ if ( expandArrowName === '' ) {
85
+ expandArrowName = dir === 'rtl'
86
+ ? 'arrow-w'
87
+ : 'arrow-e';
88
+ }
89
+
90
+ // Augment attributes
91
+ htmlAttributes.disabled = disabled;
92
+
93
+ let ariaAttr = aria
94
+ ? {}
95
+ : {};
96
+
97
+ if (legacy) {
98
+
99
+ let legacyMenuItemClasses = [
100
+ ownClassName,
101
+ 'k-item k-menu-item',
102
+ {
103
+ 'k-state-hover': hover === true,
104
+ 'k-state-focus': focus === true,
105
+ 'k-state-selected': selected === true,
106
+ 'k-state-disabled': disabled === true,
107
+ }
108
+ ];
109
+
110
+ return (
111
+ <li className={legacyMenuItemClasses} {...ariaAttr} {...htmlAttributes}>
112
+ <span className={`k-link k-menu-link ${active === true ? 'k-state-active' : ''}`}>
113
+ {icon && <IconStatic className="k-menu-link-icon" name={icon} />}
114
+ <span className="k-menu-link-text">{text}</span>
115
+ {showArrow && <span className="k-menu-expand-arrow"><IconStatic name={expandArrowName} /></span>}
116
+ </span>
117
+ {contentTemplate}
118
+ </li>
119
+ );
120
+ }
121
+
122
+ return (
123
+ <li className={menuItemClasses} {...ariaAttr} {...htmlAttributes}>
124
+ <span className={menuItemLinkClasses}>
125
+ {icon && <IconStatic className="k-menu-link-icon" name={icon} />}
126
+ <span className="k-menu-link-text">{text}</span>
127
+ {showArrow && <span className="k-menu-expand-arrow"><IconStatic name={expandArrowName} /></span>}
128
+ </span>
129
+ {contentTemplate}
130
+ </li>
131
+ );
132
+ }
133
+
134
+ MenuItemStatic.defaultProps = {
135
+ ...globalDefaultProps,
136
+
137
+ text: '',
138
+ icon: '',
139
+
140
+ className: '',
141
+ arrowIconName: '',
142
+
143
+ size: 'medium',
144
+
145
+ dir: 'ltr'
146
+ };
147
+
148
+ MenuItemStatic.propTypes = {
149
+ text: typeof '',
150
+ icon: typeof '',
151
+
152
+ showArrow: typeof false,
153
+ arrowIconName: typeof '',
154
+
155
+ contentTemplate: typeof '#fragment',
156
+
157
+ size: typeof [ null, 'small', 'medium', 'large' ],
158
+
159
+ hover: typeof false,
160
+ focus: typeof false,
161
+ active: typeof false,
162
+ selected: typeof false,
163
+ disabled: typeof false,
164
+
165
+ aria: typeof false,
166
+ legacy: typeof false,
167
+
168
+ dir: typeof '',
169
+
170
+ className: typeof '',
171
+ htmlAttributes: typeof []
172
+ };
173
+
174
+ export { MenuItem, MenuItemStatic };
@@ -0,0 +1,74 @@
1
+ import * as styles from '../../utils/styles';
2
+ import { Component, globalDefaultProps } from '../component/index';
3
+
4
+ class MenuList extends Component {
5
+ render() {
6
+ return <MenuListStatic {...this.props} />;
7
+ }
8
+ }
9
+
10
+ function MenuListStatic(props) {
11
+ const {
12
+ className: ownClassName,
13
+ children,
14
+
15
+ size,
16
+
17
+ aria,
18
+ legacy,
19
+
20
+ ...htmlAttributes
21
+ } = props;
22
+
23
+ let menuListClasses = [
24
+ ownClassName,
25
+ 'k-menu-group',
26
+ styles.sizeClass( size, 'k-menu-group' ),
27
+ ];
28
+
29
+ let ariaAttr = aria
30
+ ? {}
31
+ : {};
32
+
33
+ if (legacy) {
34
+
35
+ let legacyMenuListClasses = [
36
+ ownClassName,
37
+ 'k-group k-menu-group k-reset',
38
+ ];
39
+
40
+ return (
41
+ <ul className={legacyMenuListClasses} {...ariaAttr} {...htmlAttributes}>
42
+ {children}
43
+ </ul>
44
+ );
45
+ }
46
+
47
+ return (
48
+ <ul className={menuListClasses} {...ariaAttr} {...htmlAttributes}>
49
+ {children}
50
+ </ul>
51
+ );
52
+ }
53
+
54
+ MenuListStatic.defaultProps = {
55
+ ...globalDefaultProps,
56
+
57
+ className: '',
58
+
59
+ size: 'medium'
60
+ };
61
+
62
+ MenuListStatic.propTypes = {
63
+ size: typeof [ null, 'small', 'medium', 'large' ],
64
+
65
+ children: typeof [],
66
+
67
+ aria: typeof false,
68
+ legacy: typeof false,
69
+
70
+ className: typeof '',
71
+ htmlAttributes: typeof []
72
+ };
73
+
74
+ export { MenuList, MenuListStatic };
@@ -75,17 +75,15 @@ function NumericTextboxStatic(props) {
75
75
  'k-widget',
76
76
  'k-numerictextbox',
77
77
  {
78
+ 'k-state-hover': hover === true,
79
+ 'k-state-focus': focus === true,
80
+ 'k-state-invalid': invalid === true,
78
81
  'k-state-disabled': disabled === true
79
82
  }
80
83
  ];
81
84
 
82
85
  let legacyWrapClasses = [
83
- 'k-numeric-wrap',
84
- {
85
- 'k-state-hover': hover === true,
86
- 'k-state-focused': focus === true,
87
- 'k-state-invalid': invalid === true
88
- }
86
+ 'k-numeric-wrap'
89
87
  ];
90
88
 
91
89
  let legacyInputClasses = [
@@ -62,10 +62,14 @@ function RadioStatic(props) {
62
62
  }
63
63
  ];
64
64
 
65
- return <input type="radio" className={legacyClasses} {...ariaAttr} {...htmlAttributes}/>;
65
+ return (
66
+ <span className="k-radio-wrap"><input type="radio" className={legacyClasses} {...ariaAttr} {...htmlAttributes}/></span>
67
+ );
66
68
  }
67
69
 
68
- return <input type="radio" className={radioClasses} {...ariaAttr} {...htmlAttributes}/>;
70
+ return (
71
+ <span className="k-radio-wrap"><input type="radio" className={radioClasses} {...ariaAttr} {...htmlAttributes}/></span>
72
+ );
69
73
  }
70
74
 
71
75
  RadioStatic.defaultProps = {
@@ -1,12 +1,12 @@
1
1
  ```html
2
2
  <!-- default rendering -->
3
- <span class="k-switch k-switch-on k-switch-md k-rounded-pill">
4
- <span class="k-switch-track k-rounded-pill">
3
+ <span class="k-switch k-switch-on k-switch-md k-rounded-full">
4
+ <span class="k-switch-track k-rounded-full">
5
5
  <span class="k-switch-label-on">On</span>
6
6
  <span class="k-switch-label-off">Off</span>
7
7
  </span>
8
8
  <span class="k-switch-thumb-wrap">
9
- <span class="k-switch-thumb k-rounded-pill"></span>
9
+ <span class="k-switch-thumb k-rounded-full"></span>
10
10
  </span>
11
11
  </span>
12
12
 
File without changes
@@ -0,0 +1,4 @@
1
+ export * from './treeview.jsx';
2
+ export * from './treeview-group.jsx';
3
+ export * from './treeview-item.jsx';
4
+ export * from './treeview-leaf.jsx';
@@ -0,0 +1,70 @@
1
+ import { Component, globalDefaultProps } from '../component/index';
2
+
3
+ class TreeviewGroup extends Component {
4
+ render() {
5
+ return <TreeviewGroupStatic {...this.props} />;
6
+ }
7
+ }
8
+
9
+ function TreeviewGroupStatic(props) {
10
+ const {
11
+ className: ownClassName,
12
+
13
+ items,
14
+
15
+ aria,
16
+ legacy,
17
+
18
+ ...htmlAttributes
19
+ } = props;
20
+
21
+ let treeviewULClasses = [
22
+ ownClassName,
23
+ 'k-treeview-group'
24
+ ];
25
+
26
+ let ariaAttr = aria
27
+ ? {}
28
+ : {};
29
+
30
+ if (legacy) {
31
+
32
+ let legacyTreeviewULClasses = [
33
+ ownClassName,
34
+ 'k-group',
35
+ ];
36
+
37
+ return (
38
+ <ul className={legacyTreeviewULClasses} {...ariaAttr} {...htmlAttributes}>
39
+ {items}
40
+ </ul>
41
+ );
42
+ }
43
+
44
+ return (
45
+ <ul className={treeviewULClasses} {...ariaAttr} {...htmlAttributes}>
46
+ {items}
47
+ </ul>
48
+ );
49
+ }
50
+
51
+ TreeviewGroupStatic.defaultProps = {
52
+ ...globalDefaultProps,
53
+
54
+ children: [],
55
+ items: []
56
+ };
57
+
58
+ TreeviewGroupStatic.propTypes = {
59
+ children: typeof [],
60
+ className: typeof '',
61
+
62
+ items: typeof [],
63
+
64
+ aria: typeof false,
65
+ legacy: typeof false,
66
+
67
+ htmlAttributes: typeof []
68
+ };
69
+
70
+ export { TreeviewGroup, TreeviewGroupStatic };
@@ -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 };