superdesk-ui-framework 3.0.6 → 3.0.7
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 +29 -10
- package/app-typescript/components/MultiSelect.tsx +2 -3
- package/app-typescript/components/TreeSelect.tsx +506 -243
- package/dist/examples.bundle.js +385 -143
- package/dist/react/Dropdowns.tsx +134 -85
- package/dist/react/MultiSelect.tsx +2 -2
- package/dist/react/TreeSelect.tsx +39 -27
- package/dist/superdesk-ui.bundle.css +26 -9
- package/dist/superdesk-ui.bundle.js +283 -104
- package/examples/pages/react/Dropdowns.tsx +134 -85
- package/examples/pages/react/MultiSelect.tsx +2 -2
- package/examples/pages/react/TreeSelect.tsx +39 -27
- package/package.json +2 -2
- package/react/components/MultiSelect.d.ts +1 -1
- package/react/components/MultiSelect.js +1 -1
- package/react/components/TreeSelect.d.ts +17 -9
- package/react/components/TreeSelect.js +249 -74
@@ -69,7 +69,7 @@ export class MultiselectDocs extends React.Component<{}, IState> {
|
|
69
69
|
showSelectAll
|
70
70
|
zIndex={2000}
|
71
71
|
placeholder='Select a color'
|
72
|
-
optionLabel=
|
72
|
+
optionLabel={(option) => `${option.name} :: ${option.colorCode}`}
|
73
73
|
required
|
74
74
|
tabindex={1}
|
75
75
|
label={'This is Label'}
|
@@ -106,10 +106,10 @@ export class MultiselectDocs extends React.Component<{}, IState> {
|
|
106
106
|
<MultiSelect
|
107
107
|
value={this.state.value2}
|
108
108
|
options={ItemArr}
|
109
|
+
optionLabel={(option) => `${option.name} :: ${option.colorCode}`}
|
109
110
|
onChange={(e: any) => this.setState({value2: e})}
|
110
111
|
filter
|
111
112
|
showSelectAll
|
112
|
-
optionLabel='name'
|
113
113
|
itemTemplate={(option) => {
|
114
114
|
if (option) {
|
115
115
|
return (
|
@@ -20,41 +20,53 @@ let options = [
|
|
20
20
|
{
|
21
21
|
value: {name: 'Sub-category1'},
|
22
22
|
children: [
|
23
|
-
{value: {name: '
|
23
|
+
{value: {name: 'Item31'}},
|
24
|
+
// {value: {name: 'Item32'}},
|
25
|
+
// {value: {name: 'Item33'}},
|
26
|
+
// {value: {name: 'Item34'}},
|
27
|
+
|
24
28
|
]
|
25
29
|
},
|
26
30
|
{
|
27
31
|
value: {name: 'Sub-category2'},
|
28
32
|
children: [
|
29
|
-
{value: {name: '
|
33
|
+
{value: {name: 'Item41'}},
|
34
|
+
{value: {name: 'Item42'}},
|
35
|
+
{value: {name: 'Item43'}}
|
30
36
|
]
|
31
|
-
}
|
32
|
-
,
|
37
|
+
},
|
33
38
|
{
|
34
39
|
value: {name: 'Sub-category3'},
|
35
40
|
children: [
|
36
|
-
{value: {name: '
|
41
|
+
{value: {name: 'Item50'}},
|
42
|
+
{value: {name: 'Item51'}},
|
43
|
+
{value: {name: 'Item53'}}
|
37
44
|
]
|
38
|
-
}
|
39
|
-
,
|
45
|
+
},
|
40
46
|
{
|
41
47
|
value: {name: 'Sub-category4'},
|
42
48
|
children: [
|
43
|
-
{value: {name: 'Item23'}}
|
49
|
+
{value: {name: 'Item23'}},
|
50
|
+
{value: {name: 'Item41'}},
|
51
|
+
{value: {name: 'Item42'}},
|
52
|
+
{value: {name: 'Item43'}}
|
44
53
|
]
|
45
|
-
}
|
46
|
-
,
|
54
|
+
},
|
47
55
|
{
|
48
56
|
value: {name: 'Sub-category5'},
|
49
57
|
children: [
|
50
|
-
{value: {name: 'Item24'}}
|
58
|
+
{value: {name: 'Item24'}},
|
59
|
+
{value: {name: 'Item41'}},
|
60
|
+
{value: {name: 'Item42'}},
|
61
|
+
{value: {name: 'Item43'}}
|
51
62
|
]
|
52
|
-
}
|
53
|
-
,
|
63
|
+
},
|
54
64
|
{
|
55
65
|
value: {name: 'Sub-category6'},
|
56
66
|
children: [
|
57
|
-
{value: {name: '
|
67
|
+
{value: {name: 'Item50'}},
|
68
|
+
{value: {name: 'Item51'}},
|
69
|
+
{value: {name: 'Item52'}}
|
58
70
|
]
|
59
71
|
}
|
60
72
|
]
|
@@ -65,9 +77,9 @@ let options = [
|
|
65
77
|
{
|
66
78
|
value: {name: 'Item8'}
|
67
79
|
},
|
68
|
-
{
|
69
|
-
|
70
|
-
}
|
80
|
+
// {
|
81
|
+
// value: {name: 'Item9'}
|
82
|
+
// }
|
71
83
|
]
|
72
84
|
},
|
73
85
|
{
|
@@ -164,7 +176,7 @@ function searchOptions(
|
|
164
176
|
callback: (res: any) => void,
|
165
177
|
): ICancelFn {
|
166
178
|
let timeout = setTimeout(() => {
|
167
|
-
|
179
|
+
|
168
180
|
callback(
|
169
181
|
fetchedArr
|
170
182
|
.filter((item: any) => item.display_name.toLocaleLowerCase().includes(term.toLocaleLowerCase()))
|
@@ -188,7 +200,7 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
|
|
188
200
|
inputValue: '',
|
189
201
|
arr: []
|
190
202
|
}
|
191
|
-
|
203
|
+
|
192
204
|
|
193
205
|
this.handleChange = this.handleChange.bind(this);
|
194
206
|
}
|
@@ -197,7 +209,7 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
|
|
197
209
|
if(option.item) {
|
198
210
|
e.stopPropagation();
|
199
211
|
e.preventDefault();
|
200
|
-
|
212
|
+
|
201
213
|
this.setState({
|
202
214
|
options: option.item
|
203
215
|
})
|
@@ -219,7 +231,7 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
|
|
219
231
|
/>
|
220
232
|
`}
|
221
233
|
</Markup.ReactMarkupCodePreview>
|
222
|
-
|
234
|
+
|
223
235
|
<Markup.ReactMarkup>
|
224
236
|
<Markup.ReactMarkupPreview>
|
225
237
|
<div className='docs-page__content-row docs-page__content-row--no-margin'>
|
@@ -234,7 +246,7 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
|
|
234
246
|
selectBranchWithChildren={true}
|
235
247
|
allowMultiple
|
236
248
|
fullWidth
|
237
|
-
singleLevelSearch
|
249
|
+
//singleLevelSearch
|
238
250
|
required
|
239
251
|
info={'Info Message'}
|
240
252
|
error={'Error Message'}
|
@@ -247,7 +259,7 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
|
|
247
259
|
<span>{item.name}</span>
|
248
260
|
</Wrapper>
|
249
261
|
);
|
250
|
-
}}
|
262
|
+
}}
|
251
263
|
/>
|
252
264
|
</div>
|
253
265
|
</div>
|
@@ -277,10 +289,10 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
|
|
277
289
|
<span>{item.name}</span>
|
278
290
|
</Wrapper>
|
279
291
|
);
|
280
|
-
}}
|
292
|
+
}}
|
281
293
|
/>
|
282
294
|
`}</Markup.ReactMarkupCode>
|
283
|
-
|
295
|
+
|
284
296
|
</Markup.ReactMarkup>
|
285
297
|
|
286
298
|
<p className='docs-page__paragraph'>Asynchronous mode in TreeSelect component.</p>
|
@@ -320,7 +332,7 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
|
|
320
332
|
allowMultiple={true}
|
321
333
|
/>
|
322
334
|
`}</Markup.ReactMarkupCode>
|
323
|
-
|
335
|
+
|
324
336
|
</Markup.ReactMarkup>
|
325
337
|
|
326
338
|
<p className='docs-page__paragraph'>TreeSelect with custom template.</p>
|
@@ -415,7 +427,7 @@ export class TreeSelectDocs extends React.Component<{}, IState> {
|
|
415
427
|
<Prop name='getOptions' isRequired={false} type='Function' default='/' description='An array of selectitems to display as the available options.'/>
|
416
428
|
<Prop name='searchOptions' isRequired={false} type='Function' default='/' description='function will be called when a search is initiated from UI.'/>
|
417
429
|
</PropsList>
|
418
|
-
|
430
|
+
|
419
431
|
</section>
|
420
432
|
)
|
421
433
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "superdesk-ui-framework",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.7",
|
4
4
|
"license": "AGPL-3.0",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -84,7 +84,7 @@
|
|
84
84
|
"dependencies": {
|
85
85
|
"@material-ui/lab": "^4.0.0-alpha.56",
|
86
86
|
"@popperjs/core": "^2.4.0",
|
87
|
-
"@superdesk/primereact": "^5.0.2-
|
87
|
+
"@superdesk/primereact": "^5.0.2-10",
|
88
88
|
"@types/node": "^14.10.2",
|
89
89
|
"chart.js": "^2.9.3",
|
90
90
|
"date-fns": "2.7.0",
|
@@ -3,7 +3,6 @@ interface IProps<T> {
|
|
3
3
|
value: Array<T>;
|
4
4
|
options: Array<T>;
|
5
5
|
placeholder?: string;
|
6
|
-
optionLabel: string;
|
7
6
|
emptyFilterMessage?: string;
|
8
7
|
filterPlaceholder?: string;
|
9
8
|
maxSelectedLabels?: number;
|
@@ -14,6 +13,7 @@ interface IProps<T> {
|
|
14
13
|
showClear?: boolean;
|
15
14
|
showSelectAll?: boolean;
|
16
15
|
zIndex?: number;
|
16
|
+
optionLabel: (option: T) => string;
|
17
17
|
itemTemplate?(item: any): JSX.Element | undefined;
|
18
18
|
selectedItemTemplate?(value: any): JSX.Element | undefined;
|
19
19
|
onChange(newValue: Array<T>): void;
|
@@ -66,7 +66,7 @@ var MultiSelect = /** @class */ (function (_super) {
|
|
66
66
|
React.createElement(multiselect_1.MultiSelect, { panelClassName: classes, value: this.props.value, options: this.props.options, onChange: function (_a) {
|
67
67
|
var value = _a.value;
|
68
68
|
return _this.props.onChange(value);
|
69
|
-
}, display: "chip", zIndex: this.props.zIndex, filter: this.props.filter,
|
69
|
+
}, display: "chip", zIndex: this.props.zIndex, filter: this.props.filter, appendTo: document.body, placeholder: this.props.placeholder, optionLabel: function (option) { return _this.props.optionLabel(option); }, emptyFilterMessage: this.props.emptyFilterMessage, filterPlaceholder: this.props.filterPlaceholder, itemTemplate: this.props.itemTemplate, selectedItemTemplate: this.props.selectedItemTemplate, maxSelectedLabels: (_a = this.props.maxSelectedLabels) !== null && _a !== void 0 ? _a : 4, selectedItemsLabel: this.props.selectedItemsLabel, ariaLabelledBy: this.htmlId + 'label', tabIndex: this.props.tabIndex ? this.props.tabIndex : '0', showClear: this.props.showClear, disabled: this.props.disabled, inputId: this.htmlId })));
|
70
70
|
};
|
71
71
|
return MultiSelect;
|
72
72
|
}(React.Component));
|
@@ -2,15 +2,16 @@ import * as React from "react";
|
|
2
2
|
interface IState<T> {
|
3
3
|
value: Array<T>;
|
4
4
|
options: Array<ITreeNode<T>>;
|
5
|
-
firstBranchOptions: Array<
|
5
|
+
firstBranchOptions: Array<ITreeNode<T>>;
|
6
6
|
openDropdown: boolean;
|
7
|
-
activeTree: Array<
|
8
|
-
filterArr: Array<
|
7
|
+
activeTree: Array<Array<ITreeNode<T>>>;
|
8
|
+
filterArr: Array<ITreeNode<T>>;
|
9
9
|
searchFieldValue: string;
|
10
|
-
buttonTree: Array<
|
11
|
-
buttonValue:
|
10
|
+
buttonTree: Array<ITreeNode<T>>;
|
11
|
+
buttonValue: ITreeNode<T> | null;
|
12
12
|
buttonMouseEvent: boolean;
|
13
13
|
loading: boolean;
|
14
|
+
buttonTarget: Array<string>;
|
14
15
|
}
|
15
16
|
interface IPropsBase<T> {
|
16
17
|
value?: Array<T>;
|
@@ -37,17 +38,18 @@ interface IPropsBase<T> {
|
|
37
38
|
getBackgroundColor?(item: T): string;
|
38
39
|
getBorderColor?(item: T): string;
|
39
40
|
optionTemplate?(item: T): React.ComponentType<T> | JSX.Element;
|
40
|
-
valueTemplate?(item: T, Wrapper:
|
41
|
+
valueTemplate?(item: T, Wrapper: React.ElementType): React.ComponentType<T> | JSX.Element;
|
41
42
|
onChange(e: Array<T>): void;
|
42
43
|
}
|
43
44
|
interface IPropsSync<T> extends IPropsBase<T> {
|
44
45
|
kind: 'synchronous';
|
45
46
|
getOptions(): Array<ITreeNode<T>>;
|
46
47
|
}
|
48
|
+
declare type ICancelFn = () => void;
|
47
49
|
interface IPropsAsync<T> extends IPropsBase<T> {
|
48
50
|
kind: 'asynchronous';
|
49
51
|
getOptions?(): Array<ITreeNode<T>>;
|
50
|
-
searchOptions(term: string, callback?: (options: Array<ITreeNode<T>>) => void):
|
52
|
+
searchOptions(term: string, callback?: (options: Array<ITreeNode<T>>) => void): ICancelFn;
|
51
53
|
}
|
52
54
|
declare type IProps<T> = IPropsSync<T> | IPropsAsync<T>;
|
53
55
|
export interface ITreeNode<T> {
|
@@ -56,10 +58,16 @@ export interface ITreeNode<T> {
|
|
56
58
|
}
|
57
59
|
export declare class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
58
60
|
private dropdownRef;
|
61
|
+
private ref;
|
62
|
+
private inputRef;
|
63
|
+
private categoryButtonRef;
|
59
64
|
private openDropdownRef;
|
60
65
|
private htmlId;
|
61
66
|
private popperInstance;
|
62
67
|
constructor(props: IProps<T>);
|
68
|
+
inputFocus: () => void;
|
69
|
+
listNavigation: () => void;
|
70
|
+
buttonFocus: () => void;
|
63
71
|
componentDidMount: () => void;
|
64
72
|
componentDidUpdate(prevProps: Readonly<IProps<T>>, prevState: Readonly<IState<T>>): void;
|
65
73
|
toggleMenu(): void;
|
@@ -69,11 +77,11 @@ export declare class TreeSelect<T> extends React.Component<IProps<T>, IState<T>>
|
|
69
77
|
handleValue(event: React.MouseEvent<HTMLLIElement, MouseEvent>, item: ITreeNode<T>): void;
|
70
78
|
handleBranchValue(event: React.MouseEvent<HTMLButtonElement, MouseEvent>, item: ITreeNode<T>): void;
|
71
79
|
handleTree(event: React.MouseEvent<HTMLLIElement, MouseEvent>, option: ITreeNode<T>): void;
|
72
|
-
backButton
|
80
|
+
backButton(): void;
|
73
81
|
backButtonValue: () => void;
|
74
82
|
recursion(arr: Array<ITreeNode<T>>): void;
|
75
83
|
filteredItem(arr: Array<ITreeNode<T>>): JSX.Element | JSX.Element[] | undefined;
|
76
|
-
|
84
|
+
branchButton(buttonValue: ITreeNode<T>): JSX.Element;
|
77
85
|
private debounceFn;
|
78
86
|
private ICancelFn;
|
79
87
|
handleDebounce(): void;
|