superdesk-ui-framework 3.0.56 → 3.0.57
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/app/styles/_sd-tag-input.scss +7 -2
- package/app-typescript/components/Button.tsx +1 -1
- package/app-typescript/components/TreeMenu.tsx +460 -0
- package/app-typescript/components/TreeSelect/KeyboardNavigation.tsx +63 -0
- package/app-typescript/components/TreeSelect/TreeSelect.tsx +2 -65
- package/app-typescript/components/TreeSelect/TreeSelectItem.tsx +15 -7
- package/dist/examples.bundle.js +1901 -1283
- package/dist/react/Index.tsx +5 -0
- package/dist/react/TreeMenu.tsx +277 -0
- package/dist/superdesk-ui.bundle.css +6 -3
- package/dist/superdesk-ui.bundle.js +859 -833
- package/dist/vendor.bundle.js +18 -18
- package/examples/pages/react/Index.tsx +5 -0
- package/examples/pages/react/TreeMenu.tsx +277 -0
- package/package.json +1 -1
- package/react/components/Button.js +1 -1
- package/react/components/TreeSelect/KeyboardNavigation.d.ts +1 -0
- package/react/components/TreeSelect/KeyboardNavigation.js +64 -0
- package/react/components/TreeSelect/TreeSelect.js +3 -53
- package/react/components/TreeSelect/TreeSelectItem.d.ts +2 -1
- package/react/components/TreeSelect/TreeSelectItem.js +10 -7
package/dist/vendor.bundle.js
CHANGED
@@ -70,7 +70,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
70
70
|
/******/ __webpack_require__.p = "";
|
71
71
|
/******/
|
72
72
|
/******/ // Load entry module and return exports
|
73
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
73
|
+
/******/ return __webpack_require__(__webpack_require__.s = 573);
|
74
74
|
/******/ })
|
75
75
|
/************************************************************************/
|
76
76
|
/******/ ({
|
@@ -17328,7 +17328,7 @@ module.exports = g;
|
|
17328
17328
|
|
17329
17329
|
/***/ }),
|
17330
17330
|
|
17331
|
-
/***/
|
17331
|
+
/***/ 44:
|
17332
17332
|
/***/ (function(module, exports, __webpack_require__) {
|
17333
17333
|
|
17334
17334
|
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
@@ -28246,7 +28246,7 @@ module.exports = function(module) {
|
|
28246
28246
|
|
28247
28247
|
/***/ }),
|
28248
28248
|
|
28249
|
-
/***/
|
28249
|
+
/***/ 573:
|
28250
28250
|
/***/ (function(module, exports, __webpack_require__) {
|
28251
28251
|
|
28252
28252
|
"use strict";
|
@@ -28254,13 +28254,13 @@ module.exports = function(module) {
|
|
28254
28254
|
|
28255
28255
|
__webpack_require__(21);
|
28256
28256
|
|
28257
|
-
__webpack_require__(
|
28257
|
+
__webpack_require__(44);
|
28258
28258
|
|
28259
|
-
__webpack_require__(
|
28259
|
+
__webpack_require__(574);
|
28260
28260
|
|
28261
|
-
__webpack_require__(
|
28261
|
+
__webpack_require__(576);
|
28262
28262
|
|
28263
|
-
__webpack_require__(
|
28263
|
+
__webpack_require__(578);
|
28264
28264
|
|
28265
28265
|
__webpack_require__(0);
|
28266
28266
|
|
@@ -28268,7 +28268,7 @@ __webpack_require__(8);
|
|
28268
28268
|
|
28269
28269
|
/***/ }),
|
28270
28270
|
|
28271
|
-
/***/
|
28271
|
+
/***/ 574:
|
28272
28272
|
/***/ (function(module, exports, __webpack_require__) {
|
28273
28273
|
|
28274
28274
|
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
|
@@ -28292,7 +28292,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
28292
28292
|
if ( true ) {
|
28293
28293
|
|
28294
28294
|
// AMD. Register as an anonymous module.
|
28295
|
-
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(
|
28295
|
+
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(44), __webpack_require__(575) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
|
28296
28296
|
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
|
28297
28297
|
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
|
28298
28298
|
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
@@ -29030,7 +29030,7 @@ return $.widget;
|
|
29030
29030
|
|
29031
29031
|
/***/ }),
|
29032
29032
|
|
29033
|
-
/***/
|
29033
|
+
/***/ 575:
|
29034
29034
|
/***/ (function(module, exports, __webpack_require__) {
|
29035
29035
|
|
29036
29036
|
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;( function( factory ) {
|
@@ -29039,7 +29039,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
29039
29039
|
if ( true ) {
|
29040
29040
|
|
29041
29041
|
// AMD. Register as an anonymous module.
|
29042
|
-
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(
|
29042
|
+
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(44) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
|
29043
29043
|
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
|
29044
29044
|
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
|
29045
29045
|
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
@@ -29060,16 +29060,16 @@ return $.ui.version = "1.13.0";
|
|
29060
29060
|
|
29061
29061
|
/***/ }),
|
29062
29062
|
|
29063
|
-
/***/
|
29063
|
+
/***/ 576:
|
29064
29064
|
/***/ (function(module, exports, __webpack_require__) {
|
29065
29065
|
|
29066
|
-
__webpack_require__(
|
29066
|
+
__webpack_require__(577);
|
29067
29067
|
module.exports = angular;
|
29068
29068
|
|
29069
29069
|
|
29070
29070
|
/***/ }),
|
29071
29071
|
|
29072
|
-
/***/
|
29072
|
+
/***/ 577:
|
29073
29073
|
/***/ (function(module, exports, __webpack_require__) {
|
29074
29074
|
|
29075
29075
|
/* WEBPACK VAR INJECTION */(function(__webpack_provided_window_dot_jQuery) {/**
|
@@ -65672,20 +65672,20 @@ $provide.value("$locale", {
|
|
65672
65672
|
})(window);
|
65673
65673
|
|
65674
65674
|
!window.angular.$$csp().noInlineStyle && window.angular.element(document.head).prepend(window.angular.element('<style>').text('@charset "UTF-8";[ng\\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide:not(.ng-hide-animate){display:none !important;}ng\\:form{display:block;}.ng-animate-shim{visibility:hidden;}.ng-anchor{position:absolute;}'));
|
65675
|
-
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(
|
65675
|
+
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(44)))
|
65676
65676
|
|
65677
65677
|
/***/ }),
|
65678
65678
|
|
65679
|
-
/***/
|
65679
|
+
/***/ 578:
|
65680
65680
|
/***/ (function(module, exports, __webpack_require__) {
|
65681
65681
|
|
65682
|
-
__webpack_require__(
|
65682
|
+
__webpack_require__(579);
|
65683
65683
|
module.exports = 'ngAnimate';
|
65684
65684
|
|
65685
65685
|
|
65686
65686
|
/***/ }),
|
65687
65687
|
|
65688
|
-
/***/
|
65688
|
+
/***/ 579:
|
65689
65689
|
/***/ (function(module, exports) {
|
65690
65690
|
|
65691
65691
|
/**
|
@@ -62,6 +62,7 @@ import * as Playgrounds from '../playgrounds/react-playgrounds/Index';
|
|
62
62
|
import { SelectWithTemplateDocs } from './SelectWithTemplate';
|
63
63
|
import { MultiselectDocs } from './MultiSelect';
|
64
64
|
import { TreeSelectDocs } from './TreeSelect';
|
65
|
+
import { TreeMenuDocs } from './TreeMenu';
|
65
66
|
import DurationInputDoc from './DurationInput';
|
66
67
|
import {WithPaginationDocs} from './WithPaginationDocs';
|
67
68
|
import { PopoverDoc } from './Popover';
|
@@ -124,6 +125,9 @@ const pages = {
|
|
124
125
|
'menu': {
|
125
126
|
name: 'Menu',
|
126
127
|
},
|
128
|
+
'treemenu': {
|
129
|
+
name: 'TreeMenu',
|
130
|
+
},
|
127
131
|
"drag-handle": {
|
128
132
|
name: 'Drag handle'
|
129
133
|
}
|
@@ -353,6 +357,7 @@ class ReactDoc extends React.Component<IProps, IState> {
|
|
353
357
|
<Route path="/react/with-size-observer" component={WithSizeObserverDocs} />
|
354
358
|
<Route path="/react/multiselect" component={MultiselectDocs} />
|
355
359
|
<Route path="/react/treeselect" component={TreeSelectDocs} />
|
360
|
+
<Route path="/react/treemenu" component={TreeMenuDocs} />
|
356
361
|
<Route path="/react/duration-input" component={DurationInputDoc} />
|
357
362
|
<Route path="/react/with-pagination" component={WithPaginationDocs} />
|
358
363
|
<Route path="/react/popover" component={PopoverDoc} />
|
@@ -0,0 +1,277 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import * as Markup from '../../js/react';
|
3
|
+
import { PropsList, Prop, Button, Icon } from '../../../app-typescript';
|
4
|
+
import {ITreeMenuNode, TreeMenu} from '../../../app-typescript/components/TreeMenu';
|
5
|
+
|
6
|
+
let options: Array<ITreeMenuNode<{name: string, bgColor?: string}>> = [
|
7
|
+
{
|
8
|
+
value: {name: 'Category1'},
|
9
|
+
children: [
|
10
|
+
{
|
11
|
+
value: {name: 'Sub-category1'},
|
12
|
+
children: [
|
13
|
+
{value: {name: 'Item5'}, onSelect: () => false},
|
14
|
+
{value: {name: 'Item6'}, onSelect: () => false},
|
15
|
+
{value: {name: 'Item7'}, onSelect: () => false},
|
16
|
+
{value: {name: 'Item8'}, onSelect: () => false},
|
17
|
+
|
18
|
+
]
|
19
|
+
},
|
20
|
+
{
|
21
|
+
value: {name: 'Sub-category2'},
|
22
|
+
children: [
|
23
|
+
{value: {name: 'Item9'}, onSelect: () => false},
|
24
|
+
{value: {name: 'Item10'}, onSelect: () => false},
|
25
|
+
{value: {name: 'Item11'}, onSelect: () => false},
|
26
|
+
{value: {name: 'Item12'}, onSelect: () => false},
|
27
|
+
]
|
28
|
+
},
|
29
|
+
{
|
30
|
+
value: {name: 'Sub-category3'},
|
31
|
+
children: [
|
32
|
+
{value: {name: 'Item13'}, onSelect: () => false},
|
33
|
+
{value: {name: 'Item14'}, onSelect: () => false},
|
34
|
+
]
|
35
|
+
},
|
36
|
+
{
|
37
|
+
value: {name: 'Sub-category4'},
|
38
|
+
children: [
|
39
|
+
{value: {name: 'Item15'}, onSelect: () => false},
|
40
|
+
{value: {name: 'Item16'}, onSelect: () => false},
|
41
|
+
]
|
42
|
+
},
|
43
|
+
{
|
44
|
+
value: {name: 'Sub-category5'},
|
45
|
+
children: [
|
46
|
+
{value: {name: 'Item17'}, onSelect: () => false},
|
47
|
+
{value: {name: 'Item18'}, onSelect: () => false},
|
48
|
+
{value: {name: 'Item19'}, onSelect: () => false},
|
49
|
+
{value: {name: 'Item20'}, onSelect: () => false},
|
50
|
+
]
|
51
|
+
},
|
52
|
+
{
|
53
|
+
value: {name: 'Sub-category6'},
|
54
|
+
children: [
|
55
|
+
{value: {name: 'Item21'}, onSelect: () => false},
|
56
|
+
{value: {name: 'Item22'}, onSelect: () => false},
|
57
|
+
{value: {name: 'Item23'}, onSelect: () => false},
|
58
|
+
{value: {name: 'Item24'}, onSelect: () => false},
|
59
|
+
]
|
60
|
+
}
|
61
|
+
]
|
62
|
+
},
|
63
|
+
{
|
64
|
+
value: {name: 'Category2'},
|
65
|
+
children: [
|
66
|
+
{value: {name: 'Item1'}, onSelect: () => false},
|
67
|
+
{value: {name: 'Item2'}, onSelect: () => false},
|
68
|
+
]
|
69
|
+
},
|
70
|
+
{
|
71
|
+
value: {name: 'Category3', bgColor: 'red'},
|
72
|
+
children: [
|
73
|
+
{value: {name: 'Item3'}, onSelect: () => false},
|
74
|
+
{value: {name: 'Item4'}, onSelect: () => false},
|
75
|
+
]
|
76
|
+
},
|
77
|
+
]
|
78
|
+
|
79
|
+
let options2: Array<ITreeMenuNode<{name: string, icon?: any}>>= [
|
80
|
+
{
|
81
|
+
value: {name: 'Category1', icon: <Icon name='text' />},
|
82
|
+
children: [
|
83
|
+
{
|
84
|
+
value: {name: 'Sub-category1'},
|
85
|
+
children: [
|
86
|
+
{value: {name: 'Item5'}, onSelect: () => false},
|
87
|
+
{value: {name: 'Item6'}, onSelect: () => false},
|
88
|
+
]
|
89
|
+
},
|
90
|
+
{
|
91
|
+
value: {name: 'Sub-category2'},
|
92
|
+
children: [
|
93
|
+
{value: {name: 'Item7'}, onSelect: () => false},
|
94
|
+
{value: {name: 'Item8'}, onSelect: () => false},
|
95
|
+
]
|
96
|
+
},
|
97
|
+
{
|
98
|
+
value: {name: 'Sub-category3'},
|
99
|
+
children: [
|
100
|
+
{value: {name: 'Item9'}, onSelect: () => false},
|
101
|
+
{value: {name: 'Item10'}, onSelect: () => false},
|
102
|
+
]
|
103
|
+
},
|
104
|
+
{
|
105
|
+
value: {name: 'Sub-category4'},
|
106
|
+
children: [
|
107
|
+
{value: {name: 'Item11'}, onSelect: () => false},
|
108
|
+
{value: {name: 'Item12'}, onSelect: () => false},
|
109
|
+
]
|
110
|
+
},
|
111
|
+
{
|
112
|
+
value: {name: 'Sub-category5'},
|
113
|
+
children: [
|
114
|
+
{value: {name: 'Item13'}, onSelect: () => false},
|
115
|
+
{value: {name: 'Item14'}, onSelect: () => false},
|
116
|
+
]
|
117
|
+
},
|
118
|
+
{
|
119
|
+
value: {name: 'Sub-category6'},
|
120
|
+
children: [
|
121
|
+
{value: {name: 'Item15'}, onSelect: () => false},
|
122
|
+
{value: {name: 'Item16'}, onSelect: () => false},
|
123
|
+
]
|
124
|
+
}
|
125
|
+
]
|
126
|
+
},
|
127
|
+
{
|
128
|
+
value: {name: 'Category2', icon: <Icon name='photo' />},
|
129
|
+
children: [
|
130
|
+
{value: {name: 'Item1'}, onSelect: () => false},
|
131
|
+
{value: {name: 'Item2'}, onSelect: () => false},
|
132
|
+
]
|
133
|
+
},
|
134
|
+
{
|
135
|
+
value: {name: 'Category3', icon: <Icon name='video' />},
|
136
|
+
children: [
|
137
|
+
{value: {name: 'Item3'}, onSelect: () => false},
|
138
|
+
{value: {name: 'Item4'}, onSelect: () => false},
|
139
|
+
]
|
140
|
+
},
|
141
|
+
]
|
142
|
+
|
143
|
+
export class TreeMenuDocs extends React.Component<{}, {}> {
|
144
|
+
constructor(props) {
|
145
|
+
super(props);
|
146
|
+
|
147
|
+
this.handleChange = this.handleChange.bind(this);
|
148
|
+
}
|
149
|
+
|
150
|
+
handleChange(e, option) {
|
151
|
+
if(option.item) {
|
152
|
+
e.stopPropagation();
|
153
|
+
e.preventDefault();
|
154
|
+
|
155
|
+
this.setState({
|
156
|
+
options: option.item
|
157
|
+
})
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
render() {
|
162
|
+
return (
|
163
|
+
<section className='docs-page__container'>
|
164
|
+
<h2 className='docs-page__h2'>TreeMenu</h2>
|
165
|
+
|
166
|
+
<Markup.ReactMarkupCodePreview>{`
|
167
|
+
<TreeSelect
|
168
|
+
getOptions={() => this.state.options}
|
169
|
+
getId={(item) => item.name}
|
170
|
+
getLabel={(item) => item.name}
|
171
|
+
/>
|
172
|
+
`}
|
173
|
+
</Markup.ReactMarkupCodePreview>
|
174
|
+
|
175
|
+
<Markup.ReactMarkup>
|
176
|
+
<Markup.ReactMarkupPreview>
|
177
|
+
<div className='docs-page__content-row docs-page__content-row--no-margin'>
|
178
|
+
<TreeMenu
|
179
|
+
getOptions={() => options}
|
180
|
+
getId={(item) => item.name}
|
181
|
+
getLabel={(item) => item.name}
|
182
|
+
getBackgroundColor={(item: any) => item.bgColor}
|
183
|
+
>
|
184
|
+
{(toggle) => (
|
185
|
+
<Button text="Open TreeMenu" onClick={toggle} />
|
186
|
+
)}
|
187
|
+
</TreeMenu>
|
188
|
+
</div>
|
189
|
+
</Markup.ReactMarkupPreview>
|
190
|
+
|
191
|
+
<Markup.ReactMarkupCode>{`
|
192
|
+
<TreeMenu
|
193
|
+
getOptions={() => options}
|
194
|
+
getId={(item) => item.name}
|
195
|
+
getLabel={(item) => item.name}
|
196
|
+
getBackgroundColor={(item: any) => item.bgColor}
|
197
|
+
>
|
198
|
+
{(toggle) => (
|
199
|
+
<Button text="Open TreeMenu" onClick={toggle} />
|
200
|
+
)}
|
201
|
+
</TreeMenu>
|
202
|
+
`}</Markup.ReactMarkupCode>
|
203
|
+
|
204
|
+
</Markup.ReactMarkup>
|
205
|
+
|
206
|
+
<p className='docs-page__paragraph'>TreeMenu with custom template:</p>
|
207
|
+
<Markup.ReactMarkup>
|
208
|
+
<Markup.ReactMarkupPreview>
|
209
|
+
<div className='docs-page__content-row docs-page__content-row--no-margin'>
|
210
|
+
<TreeMenu
|
211
|
+
getOptions={() => options2}
|
212
|
+
getId={(item) => item.name}
|
213
|
+
getLabel={(item) => item.name}
|
214
|
+
optionTemplate={(item: any) => {
|
215
|
+
return (
|
216
|
+
<div
|
217
|
+
style={{
|
218
|
+
display: 'flex',
|
219
|
+
alignItems: 'center',
|
220
|
+
gap: '4px'
|
221
|
+
}}
|
222
|
+
>
|
223
|
+
{item.icon}
|
224
|
+
{item.name}
|
225
|
+
</div>
|
226
|
+
)
|
227
|
+
}}
|
228
|
+
>
|
229
|
+
{(toggle) => (
|
230
|
+
<Button text="Open TreeMenu" onClick={toggle} />
|
231
|
+
)}
|
232
|
+
</TreeMenu>
|
233
|
+
</div>
|
234
|
+
</Markup.ReactMarkupPreview>
|
235
|
+
|
236
|
+
<Markup.ReactMarkupCode>{`
|
237
|
+
<TreeMenu
|
238
|
+
getOptions={() => options2}
|
239
|
+
getId={(item) => item.name}
|
240
|
+
getLabel={(item) => item.name}
|
241
|
+
optionTemplate={(item: any) => {
|
242
|
+
return (
|
243
|
+
<div
|
244
|
+
style={{
|
245
|
+
display: 'flex',
|
246
|
+
alignItems: 'center',
|
247
|
+
gap: '4px'
|
248
|
+
}}
|
249
|
+
>
|
250
|
+
{item.icon}
|
251
|
+
{item.name}
|
252
|
+
</div>
|
253
|
+
)
|
254
|
+
}}
|
255
|
+
>
|
256
|
+
{(toggle) => (
|
257
|
+
<Button text="Open TreeMenu" onClick={toggle} />
|
258
|
+
)}
|
259
|
+
</TreeMenu>
|
260
|
+
`}</Markup.ReactMarkupCode>
|
261
|
+
|
262
|
+
</Markup.ReactMarkup>
|
263
|
+
|
264
|
+
<h3 className="docs-page__h3">Props</h3>
|
265
|
+
<PropsList>
|
266
|
+
<Prop name='getOptions' isRequired={true} type='Function' default='/' description='An array of selectitems to display as the available options.'/>
|
267
|
+
<Prop name='width' isRequired={false} type='medium | full-width (100%)' default='100%' description='Dropdown width.'/>
|
268
|
+
<Prop name='getLabel' isRequired={true} type='Function' default='/' description='Callback to invoke when value changes.'/>
|
269
|
+
<Prop name='getId' isRequired={true} type='Function' default='/' description='Callback to invoke when value changes.'/>
|
270
|
+
<Prop name='getBackgroundColor' isRequired={true} type='Function' default='/' description='Function to return background color of individual item in options.'/>
|
271
|
+
<Prop name='getBorderColor' isRequired={true} type='Function' default='/' description='Function to return border color of individual item in options in single-select mode.'/>
|
272
|
+
<Prop name='optionTemplate' isRequired={false} type='Function(item)' default='/' description='Function that gets the option and returns the content for it.'/>
|
273
|
+
</PropsList>
|
274
|
+
</section>
|
275
|
+
)
|
276
|
+
}
|
277
|
+
}
|
package/package.json
CHANGED
@@ -65,7 +65,7 @@ var Button = /** @class */ (function (_super) {
|
|
65
65
|
_a['btn--ui-dark'] = this.props.theme === 'dark',
|
66
66
|
_a['btn--icon-only-circle'] = this.props.shape === 'round' && this.props.iconOnly,
|
67
67
|
_a));
|
68
|
-
return (React.createElement("button", { id: this.props.id, className: classes, tabIndex: 0, disabled: this.props.isLoading, "data-loading": this.props.isLoading, onClick: this.props.disabled ? function () { return false; } : function (event) { return _this.props.onClick(event); }, "aria-label": this.props.iconOnly ? this.props.text : '', "data-test-id": this.props['data-test-id'], title: this.props.tooltip },
|
68
|
+
return (React.createElement("button", { id: this.props.id, className: classes, tabIndex: 0, disabled: this.props.disabled || this.props.isLoading, "data-loading": this.props.isLoading, onClick: this.props.disabled ? function () { return false; } : function (event) { return _this.props.onClick(event); }, "aria-label": this.props.iconOnly ? this.props.text : '', "data-test-id": this.props['data-test-id'], title: this.props.tooltip },
|
69
69
|
this.props.isLoading ? React.createElement(Spinner_1.Spinner, { size: "mini" }) : null,
|
70
70
|
this.props.icon && !this.props.isLoading ? React.createElement(Icon_1.Icon, { name: this.props.icon }) : null,
|
71
71
|
this.props.iconOnly ? null : this.props.text));
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const keyboardNavigation: (e?: KeyboardEvent, menuRef?: HTMLUListElement, ref?: () => void) => void;
|
@@ -0,0 +1,64 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
4
|
+
if (ar || !(i in from)) {
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
6
|
+
ar[i] = from[i];
|
7
|
+
}
|
8
|
+
}
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.keyboardNavigation = void 0;
|
13
|
+
var getButtonList = function (menuRef) {
|
14
|
+
var _a;
|
15
|
+
var list = Array.from((_a = menuRef === null || menuRef === void 0 ? void 0 : menuRef.querySelectorAll(':scope > li')) !== null && _a !== void 0 ? _a : []);
|
16
|
+
var buttons = [];
|
17
|
+
if (list != null) {
|
18
|
+
__spreadArray([], list, true).filter(function (item) {
|
19
|
+
if (item.querySelectorAll('.suggestion-item--btn:not([disabled])').length > 0) {
|
20
|
+
buttons.push(item.querySelector('.suggestion-item--btn'));
|
21
|
+
}
|
22
|
+
});
|
23
|
+
}
|
24
|
+
return buttons;
|
25
|
+
};
|
26
|
+
var nextElement = function (buttons, currentIndex, e) {
|
27
|
+
e.preventDefault();
|
28
|
+
e.stopPropagation();
|
29
|
+
if (buttons[currentIndex + 1]) {
|
30
|
+
buttons[currentIndex + 1].focus();
|
31
|
+
}
|
32
|
+
else {
|
33
|
+
buttons[0].focus();
|
34
|
+
}
|
35
|
+
};
|
36
|
+
var prevElement = function (buttons, currentIndex, e, ref) {
|
37
|
+
e.preventDefault();
|
38
|
+
e.stopPropagation();
|
39
|
+
if (buttons[currentIndex - 1]) {
|
40
|
+
buttons[currentIndex - 1].focus();
|
41
|
+
}
|
42
|
+
else if (currentIndex === 0) {
|
43
|
+
if (ref) {
|
44
|
+
ref();
|
45
|
+
}
|
46
|
+
}
|
47
|
+
else {
|
48
|
+
buttons[buttons.length - 1].focus();
|
49
|
+
}
|
50
|
+
};
|
51
|
+
var keyboardNavigation = function (e, menuRef, ref) {
|
52
|
+
var buttons = getButtonList(menuRef);
|
53
|
+
var currentElement = document.activeElement;
|
54
|
+
var currentIndex = Array.prototype.indexOf.call(buttons, currentElement);
|
55
|
+
if (document.activeElement != null && buttons.includes(document.activeElement)) {
|
56
|
+
if ((e === null || e === void 0 ? void 0 : e.key) === 'ArrowDown') {
|
57
|
+
nextElement(buttons, currentIndex, e);
|
58
|
+
}
|
59
|
+
else if ((e === null || e === void 0 ? void 0 : e.key) === 'ArrowUp') {
|
60
|
+
prevElement(buttons, currentIndex, e, ref);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
};
|
64
|
+
exports.keyboardNavigation = keyboardNavigation;
|
@@ -63,6 +63,7 @@ var Label_1 = require("../Label");
|
|
63
63
|
var SelectPreview_1 = require("../SelectPreview");
|
64
64
|
var TreeSelectPill_1 = require("./TreeSelectPill");
|
65
65
|
var TreeSelectItem_1 = require("./TreeSelectItem");
|
66
|
+
var KeyboardNavigation_1 = require("./KeyboardNavigation");
|
66
67
|
var react_dom_1 = require("react-dom");
|
67
68
|
var TreeSelect = /** @class */ (function (_super) {
|
68
69
|
__extends(TreeSelect, _super);
|
@@ -91,7 +92,7 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
91
92
|
};
|
92
93
|
_this.onKeyDown = function (e) {
|
93
94
|
if (_this.state.openDropdown && _this.ref.current) {
|
94
|
-
keyboardNavigation(e, _this.ref.current, _this.categoryButtonRef.current ? _this.buttonFocus : _this.inputFocus);
|
95
|
+
(0, KeyboardNavigation_1.keyboardNavigation)(e, _this.ref.current, _this.categoryButtonRef.current ? _this.buttonFocus : _this.inputFocus);
|
95
96
|
if (e.key === 'Backspace' && _this.state.activeTree.length > 0) {
|
96
97
|
_this.backButton();
|
97
98
|
var lastElement = _this.state.buttonTarget.pop();
|
@@ -431,7 +432,7 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
431
432
|
} },
|
432
433
|
React.createElement("button", { className: "suggestion-item--btn" }, _this.props.optionTemplate
|
433
434
|
? _this.props.optionTemplate(item.value)
|
434
|
-
: (React.createElement("span", { className: selectedItem ? 'suggestion-item--
|
435
|
+
: (React.createElement("span", { className: selectedItem ? 'suggestion-item--selected' : undefined }, _this.props.getLabel(item.value))))));
|
435
436
|
});
|
436
437
|
}
|
437
438
|
else {
|
@@ -623,54 +624,3 @@ var TreeSelect = /** @class */ (function (_super) {
|
|
623
624
|
return TreeSelect;
|
624
625
|
}(React.Component));
|
625
626
|
exports.TreeSelect = TreeSelect;
|
626
|
-
var getButtonList = function (menuRef) {
|
627
|
-
var _a;
|
628
|
-
var list = Array.from((_a = menuRef === null || menuRef === void 0 ? void 0 : menuRef.querySelectorAll(':scope > li')) !== null && _a !== void 0 ? _a : []);
|
629
|
-
var buttons = [];
|
630
|
-
if (list != null) {
|
631
|
-
__spreadArray([], list, true).filter(function (item) {
|
632
|
-
if (item.querySelectorAll('.suggestion-item--btn').length > 0) {
|
633
|
-
buttons.push(item.querySelector('.suggestion-item--btn'));
|
634
|
-
}
|
635
|
-
});
|
636
|
-
}
|
637
|
-
return buttons;
|
638
|
-
};
|
639
|
-
var keyboardNavigation = function (e, menuRef, ref) {
|
640
|
-
var buttons = getButtonList(menuRef);
|
641
|
-
var currentElement = document.activeElement;
|
642
|
-
var currentIndex = Array.prototype.indexOf.call(buttons, currentElement);
|
643
|
-
if (document.activeElement != null && buttons.includes(document.activeElement)) {
|
644
|
-
if ((e === null || e === void 0 ? void 0 : e.key) === 'ArrowDown') {
|
645
|
-
nextElement(buttons, currentIndex, e);
|
646
|
-
}
|
647
|
-
else if ((e === null || e === void 0 ? void 0 : e.key) === 'ArrowUp') {
|
648
|
-
prevElement(buttons, currentIndex, e, ref);
|
649
|
-
}
|
650
|
-
}
|
651
|
-
};
|
652
|
-
var nextElement = function (buttons, currentIndex, e) {
|
653
|
-
e.preventDefault();
|
654
|
-
e.stopPropagation();
|
655
|
-
if (buttons[currentIndex + 1]) {
|
656
|
-
buttons[currentIndex + 1].focus();
|
657
|
-
}
|
658
|
-
else {
|
659
|
-
buttons[0].focus();
|
660
|
-
}
|
661
|
-
};
|
662
|
-
var prevElement = function (buttons, currentIndex, e, ref) {
|
663
|
-
e.preventDefault();
|
664
|
-
e.stopPropagation();
|
665
|
-
if (buttons[currentIndex - 1]) {
|
666
|
-
buttons[currentIndex - 1].focus();
|
667
|
-
}
|
668
|
-
else if (currentIndex === 0) {
|
669
|
-
if (ref) {
|
670
|
-
ref();
|
671
|
-
}
|
672
|
-
}
|
673
|
-
else {
|
674
|
-
buttons[buttons.length - 1].focus();
|
675
|
-
}
|
676
|
-
};
|
@@ -3,7 +3,8 @@ import { ITreeNode } from './TreeSelect';
|
|
3
3
|
export declare function getPrefixedItemId(id: string): string;
|
4
4
|
interface IProps<T> {
|
5
5
|
option: ITreeNode<T>;
|
6
|
-
selectedItem
|
6
|
+
selectedItem?: boolean;
|
7
|
+
disabledItem?: boolean;
|
7
8
|
allowMultiple?: boolean;
|
8
9
|
handleTree(event: React.MouseEvent<HTMLLIElement, MouseEvent>, option: ITreeNode<T>): any;
|
9
10
|
getLabel(item: T): string;
|
@@ -55,25 +55,28 @@ var TreeSelectItem = /** @class */ (function (_super) {
|
|
55
55
|
var _this = this;
|
56
56
|
return (React.createElement("li", { className: 'suggestion-item suggestion-item--multi-select', onClick: function (event) {
|
57
57
|
var _a, _b;
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
if (!_this.props.disabledItem) {
|
59
|
+
(_b = (_a = _this.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a);
|
60
|
+
event.preventDefault();
|
61
|
+
event.stopPropagation();
|
62
|
+
_this.props.handleTree(event, _this.props.option);
|
63
|
+
}
|
62
64
|
} },
|
63
65
|
React.createElement("button", {
|
64
66
|
// the className is generated in order to focus the element later
|
65
|
-
className: "suggestion-item--btn ".concat(getPrefixedItemId(this.props.getId(this.props.option.value)))
|
67
|
+
className: "suggestion-item--btn ".concat(getPrefixedItemId(this.props.getId(this.props.option.value)))
|
68
|
+
+ (this.props.disabledItem ? ' suggestion-item--disabled' : ''), onKeyDown: function (event) {
|
66
69
|
var _a, _b;
|
67
70
|
if (event.key === 'Enter' && _this.props.option.children) {
|
68
71
|
(_b = (_a = _this.props).onKeyDown) === null || _b === void 0 ? void 0 : _b.call(_a);
|
69
72
|
}
|
70
|
-
} },
|
73
|
+
}, disabled: this.props.disabledItem },
|
71
74
|
(this.props.getBorderColor && !this.props.allowMultiple)
|
72
75
|
&& React.createElement("div", { className: "item-border", style: {
|
73
76
|
backgroundColor: this.props.getBorderColor(this.props.option.value),
|
74
77
|
} }),
|
75
78
|
React.createElement("span", { className: 'suggestion-item--bgcolor'
|
76
|
-
+ (this.props.selectedItem ? ' suggestion-item--
|
79
|
+
+ (this.props.selectedItem ? ' suggestion-item--selected' : ''), style: (this.props.getBackgroundColor && this.props.option.value)
|
77
80
|
? {
|
78
81
|
backgroundColor: this.props.getBackgroundColor(this.props.option.value),
|
79
82
|
color: (0, Label_1.getTextColor)(this.props.getBackgroundColor(this.props.option.value)),
|