superdesk-ui-framework 3.0.35 → 3.0.38
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 +3 -5
- package/app/styles/_tag-labels.scss +0 -2
- package/app/styles/app.scss +1 -0
- package/app/styles/form-elements/_checkbox.scss +3 -0
- package/app/styles/form-elements/_input-preview.scss +70 -0
- package/app/styles/form-elements/_inputs.scss +10 -14
- package/app/styles/primereact/_pr-tag-input.scss +1 -1
- package/app-typescript/components/DatePicker.tsx +101 -101
- package/app-typescript/components/DurationInput.tsx +76 -76
- package/app-typescript/components/Form/InputNew.tsx +1 -1
- package/app-typescript/components/Form/InputWrapper.tsx +34 -18
- package/app-typescript/components/Input.tsx +38 -62
- package/app-typescript/components/MultiSelect.tsx +49 -47
- package/app-typescript/components/Select.tsx +13 -22
- package/app-typescript/components/SelectPreview.tsx +100 -0
- package/app-typescript/components/SelectWithTemplate.tsx +2 -12
- package/app-typescript/components/TagInput.tsx +25 -24
- package/app-typescript/components/TimePicker.tsx +13 -16
- package/app-typescript/components/TreeSelect.tsx +218 -158
- package/dist/examples.bundle.js +2400 -2258
- package/dist/react/Autocomplete.tsx +32 -31
- package/dist/react/DatePicker.tsx +56 -73
- package/dist/react/DurationInput.tsx +36 -47
- package/dist/react/Inputs.tsx +86 -248
- package/dist/react/MultiSelect.tsx +30 -23
- package/dist/react/Selects.tsx +12 -44
- package/dist/react/TagInputDocs.tsx +15 -21
- package/dist/react/TimePicker.tsx +25 -32
- package/dist/react/TreeSelect.tsx +97 -90
- package/dist/superdesk-ui.bundle.css +85 -18
- package/dist/superdesk-ui.bundle.js +1973 -1816
- package/dist/vendor.bundle.js +14 -14
- package/examples/pages/react/Autocomplete.tsx +32 -31
- package/examples/pages/react/DatePicker.tsx +56 -73
- package/examples/pages/react/DurationInput.tsx +36 -47
- package/examples/pages/react/Inputs.tsx +86 -248
- package/examples/pages/react/MultiSelect.tsx +30 -23
- package/examples/pages/react/Selects.tsx +12 -44
- package/examples/pages/react/TagInputDocs.tsx +15 -21
- package/examples/pages/react/TimePicker.tsx +25 -32
- package/examples/pages/react/TreeSelect.tsx +97 -90
- package/package.json +1 -1
- package/react/components/DatePicker.d.ts +2 -12
- package/react/components/DatePicker.js +14 -8
- package/react/components/DurationInput.d.ts +2 -11
- package/react/components/DurationInput.js +14 -4
- package/react/components/Form/InputNew.d.ts +1 -1
- package/react/components/Form/InputWrapper.d.ts +11 -5
- package/react/components/Form/InputWrapper.js +6 -9
- package/react/components/Input.d.ts +3 -19
- package/react/components/Input.js +8 -21
- package/react/components/MultiSelect.d.ts +4 -13
- package/react/components/MultiSelect.js +6 -2
- package/react/components/Select.d.ts +3 -15
- package/react/components/Select.js +7 -8
- package/react/components/SelectPreview.d.ts +17 -0
- package/react/components/SelectPreview.js +109 -0
- package/react/components/SelectWithTemplate.d.ts +2 -11
- package/react/components/SelectWithTemplate.js +0 -1
- package/react/components/TagInput.d.ts +3 -12
- package/react/components/TagInput.js +6 -2
- package/react/components/TimePicker.d.ts +2 -11
- package/react/components/TimePicker.js +6 -2
- package/react/components/TreeSelect.d.ts +5 -11
- package/react/components/TreeSelect.js +78 -47
@@ -1,48 +1,45 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import nextId from "react-id-generator";
|
3
3
|
import { InputWrapper } from './Form';
|
4
|
+
import {IInputWrapper} from './Form/InputWrapper';
|
4
5
|
|
5
|
-
interface IProps {
|
6
|
+
interface IProps extends IInputWrapper {
|
6
7
|
value: string; // will output time as ISO8601 time string(e.g. 16:55) or an empty string if there's no value
|
7
8
|
onChange(valueNext: string): void;
|
8
9
|
allowSeconds?: boolean;
|
9
|
-
disabled?: boolean;
|
10
|
-
inlineLabel?: boolean;
|
11
|
-
required?: boolean;
|
12
|
-
fullWidth?: boolean;
|
13
|
-
invalid?: boolean;
|
14
|
-
labelHidden?: boolean;
|
15
|
-
tabindex?: number;
|
16
|
-
label?: string;
|
17
|
-
info?: string;
|
18
|
-
error?: string;
|
19
10
|
}
|
20
11
|
|
21
12
|
export class TimePicker extends React.PureComponent<IProps> {
|
22
13
|
private htmlId = nextId();
|
23
14
|
|
24
15
|
render() {
|
16
|
+
if (this.props.preview) {
|
17
|
+
return (
|
18
|
+
<div>
|
19
|
+
<span>{this.props.value}</span>
|
20
|
+
</div>
|
21
|
+
);
|
22
|
+
}
|
23
|
+
|
25
24
|
return (
|
26
25
|
<InputWrapper
|
27
26
|
label={this.props.label}
|
28
27
|
error={this.props.error}
|
29
28
|
required={this.props.required}
|
30
29
|
disabled={this.props.disabled}
|
31
|
-
invalid={this.props.invalid}
|
32
30
|
info={this.props.info}
|
33
31
|
inlineLabel={this.props.inlineLabel}
|
34
32
|
labelHidden={this.props.labelHidden}
|
35
|
-
fullWidth={this.props.fullWidth}
|
36
33
|
htmlId={this.htmlId}
|
37
34
|
tabindex={this.props.tabindex}
|
38
35
|
>
|
39
36
|
<input
|
37
|
+
value={this.props.value}
|
38
|
+
type="time"
|
39
|
+
className="sd-input__input"
|
40
40
|
id={this.htmlId}
|
41
41
|
aria-labelledby={this.htmlId + 'label'}
|
42
|
-
type="time"
|
43
42
|
step={this.props.allowSeconds ? 1 : undefined}
|
44
|
-
className="sd-input__input"
|
45
|
-
value={this.props.value}
|
46
43
|
required={this.props.required}
|
47
44
|
disabled={this.props.disabled}
|
48
45
|
onChange={(event) => {
|
@@ -7,6 +7,8 @@ import { InputWrapper } from "./Form";
|
|
7
7
|
import { createPopper, Instance } from '@popperjs/core';
|
8
8
|
import {isEqual} from 'lodash';
|
9
9
|
import {getTextColor} from './Label';
|
10
|
+
import {IInputWrapper} from './Form/InputWrapper';
|
11
|
+
import {SelectPreview} from './SelectPreview';
|
10
12
|
|
11
13
|
interface IState<T> {
|
12
14
|
value: Array<T>;
|
@@ -23,7 +25,7 @@ interface IState<T> {
|
|
23
25
|
buttonTarget: Array<string>; // array of class names
|
24
26
|
}
|
25
27
|
|
26
|
-
interface IPropsBase<T> {
|
28
|
+
interface IPropsBase<T> extends IInputWrapper {
|
27
29
|
value?: Array<T>;
|
28
30
|
selectBranchWithChildren?: boolean;
|
29
31
|
readOnly?: boolean;
|
@@ -33,16 +35,6 @@ interface IPropsBase<T> {
|
|
33
35
|
singleLevelSearch?: boolean;
|
34
36
|
placeholder?: string;
|
35
37
|
searchPlaceholder?: string;
|
36
|
-
invalid?: boolean;
|
37
|
-
inlineLabel?: boolean;
|
38
|
-
labelHidden?: boolean;
|
39
|
-
tabindex?: number;
|
40
|
-
fullWidth?: boolean;
|
41
|
-
info?: string;
|
42
|
-
error?: string;
|
43
|
-
required?: boolean;
|
44
|
-
label?: string;
|
45
|
-
disabled?: boolean;
|
46
38
|
zIndex?: number;
|
47
39
|
getLabel(item: T): string;
|
48
40
|
getId(item: T): string;
|
@@ -109,12 +101,13 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
109
101
|
this.branchButton = this.branchButton.bind(this);
|
110
102
|
this.handleDebounce = this.handleDebounce.bind(this);
|
111
103
|
this.toggleMenu = this.toggleMenu.bind(this);
|
104
|
+
this.onMouseDown = this.onMouseDown.bind(this);
|
105
|
+
this.onKeyDown = this.onKeyDown.bind(this);
|
112
106
|
this.dropdownRef = React.createRef();
|
113
107
|
this.ref = React.createRef();
|
114
108
|
this.inputRef = React.createRef();
|
115
109
|
this.categoryButtonRef = React.createRef();
|
116
110
|
this.openDropdownRef = React.createRef();
|
117
|
-
|
118
111
|
this.popperInstance = null;
|
119
112
|
}
|
120
113
|
|
@@ -129,38 +122,47 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
129
122
|
this.categoryButtonRef.current?.focus();
|
130
123
|
}
|
131
124
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
125
|
+
onMouseDown = (event: MouseEvent) => {
|
126
|
+
if (
|
127
|
+
(this.dropdownRef.current?.contains(event.target as HTMLElement) !== true)
|
128
|
+
&& (this.openDropdownRef.current?.contains(event.target as HTMLElement) !== true)
|
129
|
+
) {
|
130
|
+
this.setState({openDropdown: false});
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
onKeyDown = (e: KeyboardEvent) => {
|
135
|
+
if (this.state.openDropdown && this.ref.current) {
|
136
|
+
keyboardNavigation(
|
137
|
+
e,
|
138
|
+
this.ref.current,
|
139
|
+
this.categoryButtonRef.current ? this.buttonFocus : this.inputFocus,
|
140
|
+
);
|
141
|
+
if (e.key === 'Backspace') {
|
142
|
+
this.backButton();
|
143
|
+
this.backButtonValue();
|
144
|
+
|
145
|
+
const {buttonTarget} = this.state;
|
146
|
+
const className = `${buttonTarget.pop()}-focus`;
|
147
|
+
|
148
|
+
if (className != null) {
|
149
|
+
const element: HTMLElement = document.getElementsByClassName(className)[0] as HTMLElement;
|
150
|
+
element.focus();
|
151
|
+
}
|
140
152
|
}
|
141
|
-
}
|
153
|
+
}
|
154
|
+
}
|
142
155
|
|
143
|
-
|
144
|
-
|
145
|
-
keyboardNavigation(
|
146
|
-
e,
|
147
|
-
this.ref.current,
|
148
|
-
this.categoryButtonRef.current ? this.buttonFocus : this.inputFocus,
|
149
|
-
);
|
150
|
-
if (e.key === 'Backspace') {
|
151
|
-
this.backButton();
|
152
|
-
this.backButtonValue();
|
156
|
+
componentDidMount = () => {
|
157
|
+
this.recursion(this.state.options);
|
153
158
|
|
154
|
-
|
155
|
-
|
159
|
+
document.addEventListener("mousedown", this.onMouseDown);
|
160
|
+
document.addEventListener("keydown", this.onKeyDown);
|
161
|
+
}
|
156
162
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
}
|
161
|
-
}
|
162
|
-
}
|
163
|
-
});
|
163
|
+
componentWillUnmount(): void {
|
164
|
+
document.removeEventListener("mousedown", this.onMouseDown);
|
165
|
+
document.removeEventListener("keydown", this.onKeyDown);
|
164
166
|
}
|
165
167
|
|
166
168
|
componentDidUpdate(prevProps: Readonly<IProps<T>>, prevState: Readonly<IState<T>>): void {
|
@@ -449,21 +451,30 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
449
451
|
>
|
450
452
|
<button className="suggestion-item--btn">
|
451
453
|
{this.props.getBorderColor
|
452
|
-
&& <div
|
453
|
-
|
454
|
+
&& <div
|
455
|
+
className="item-border"
|
456
|
+
style={{
|
457
|
+
backgroundColor: this.props.getBorderColor(option.value),
|
458
|
+
}}
|
459
|
+
>
|
454
460
|
</div>
|
455
461
|
}
|
456
462
|
<span
|
457
|
-
style={this.props.getBackgroundColor
|
458
|
-
? {backgroundColor: this.props.getBackgroundColor(option.value),
|
459
|
-
color: getTextColor(this.props.getBackgroundColor(option.value))}
|
460
|
-
: undefined}
|
461
463
|
className={'suggestion-item--bgcolor'
|
462
|
-
+ (selectedItem ? ' suggestion-item--disabled' : '')
|
464
|
+
+ (selectedItem ? ' suggestion-item--disabled' : '')
|
465
|
+
}
|
466
|
+
style={this.props.getBackgroundColor
|
467
|
+
? {
|
468
|
+
backgroundColor: this.props.getBackgroundColor(option.value),
|
469
|
+
color: getTextColor(this.props.getBackgroundColor(option.value)),
|
470
|
+
}
|
471
|
+
: undefined
|
472
|
+
}
|
463
473
|
>
|
464
474
|
{this.props.optionTemplate
|
465
475
|
? this.props.optionTemplate(option.value)
|
466
|
-
: this.props.getLabel(option.value)
|
476
|
+
: this.props.getLabel(option.value)
|
477
|
+
}
|
467
478
|
</span>
|
468
479
|
{option.children
|
469
480
|
&& <span className="suggestion-item__icon">
|
@@ -481,7 +492,8 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
481
492
|
this.props.getId(obj) === this.props.getId(item.value),
|
482
493
|
);
|
483
494
|
return (
|
484
|
-
<li
|
495
|
+
<li
|
496
|
+
key={i}
|
485
497
|
className={`suggestion-item suggestion-item--multi-select`}
|
486
498
|
onClick={(event) => {
|
487
499
|
this.handleValue(event, item);
|
@@ -495,7 +507,8 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
495
507
|
? 'suggestion-item--disabled' : undefined}
|
496
508
|
>
|
497
509
|
{this.props.getLabel(item.value)}
|
498
|
-
</span>
|
510
|
+
</span>
|
511
|
+
}
|
499
512
|
</button>
|
500
513
|
</li>
|
501
514
|
);
|
@@ -531,8 +544,8 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
531
544
|
|
532
545
|
if (!selectedButton) {
|
533
546
|
return <button
|
534
|
-
ref={this.categoryButtonRef}
|
535
547
|
className={'autocomplete__button' + (this.props.selectBranchWithChildren ? ' autocomplete__button--multi-select' : '')}
|
548
|
+
ref={this.categoryButtonRef}
|
536
549
|
onMouseOver={() => this.setState({buttonMouseEvent: true})}
|
537
550
|
onMouseOut={() => this.setState({buttonMouseEvent: false})}
|
538
551
|
onClick={(event) => this.handleBranchValue(event, buttonValue)}
|
@@ -542,7 +555,7 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
542
555
|
} else {
|
543
556
|
return <button
|
544
557
|
className={'autocomplete__button'
|
545
|
-
|
558
|
+
+ (this.props.selectBranchWithChildren ? ' autocomplete__button--multi-select' : '') + ' autocomplete__button--disabled'}
|
546
559
|
>
|
547
560
|
Category selected
|
548
561
|
</button>;
|
@@ -568,29 +581,53 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
568
581
|
}
|
569
582
|
|
570
583
|
render() {
|
584
|
+
if (this.props.preview) {
|
585
|
+
return (
|
586
|
+
<SelectPreview
|
587
|
+
kind={this.props.allowMultiple
|
588
|
+
? {
|
589
|
+
mode: 'multi-select',
|
590
|
+
getBackgroundColor: this.props.getBackgroundColor,
|
591
|
+
}
|
592
|
+
: {
|
593
|
+
mode: 'single-select',
|
594
|
+
getBorderColor: this.props.getBorderColor,
|
595
|
+
}
|
596
|
+
}
|
597
|
+
items={this.state.value}
|
598
|
+
valueTemplate={this.props.valueTemplate}
|
599
|
+
getLabel={this.props.getLabel}
|
600
|
+
/>
|
601
|
+
);
|
602
|
+
}
|
603
|
+
|
571
604
|
return (
|
572
605
|
<InputWrapper
|
573
606
|
label={this.props.label}
|
574
607
|
error={this.props.error}
|
575
608
|
required={this.props.required}
|
576
609
|
disabled={this.props.disabled}
|
577
|
-
invalid={this.props.invalid}
|
578
610
|
info={this.props.info}
|
579
611
|
inlineLabel={this.props.inlineLabel}
|
580
612
|
labelHidden={this.props.labelHidden}
|
581
|
-
fullWidth={this.props.fullWidth}
|
582
613
|
htmlId={this.htmlId}
|
583
|
-
tabindex={this.props.tabindex}
|
584
|
-
|
614
|
+
tabindex={this.props.tabindex}
|
615
|
+
>
|
616
|
+
<div className={`tags-input sd-input__input tags-input--${this.props.allowMultiple ? 'multi-select' : 'single-select'}`}>
|
585
617
|
{this.props.allowMultiple
|
586
618
|
? <div className="tags-input__tags">
|
587
619
|
{this.props.readOnly
|
588
620
|
|| <button ref={this.openDropdownRef}
|
589
|
-
className=
|
590
|
-
onClick={() =>
|
621
|
+
className={`tags-input__add-button ${this.props.disabled ? 'tags-input__add-button--disabled' : ''}`}
|
622
|
+
onClick={() => {
|
623
|
+
if (!this.props.disabled) {
|
624
|
+
this.setState({openDropdown: !this.state.openDropdown});
|
625
|
+
}
|
626
|
+
}}
|
591
627
|
>
|
592
628
|
<i className="icon-plus-large"></i>
|
593
|
-
</button>
|
629
|
+
</button>
|
630
|
+
}
|
594
631
|
<ul className="tags-input__tag-list">
|
595
632
|
{this.state.value.map((item, i: number) => {
|
596
633
|
const Wrapper: React.ComponentType<{backgroundColor?: string}>
|
@@ -598,22 +635,30 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
598
635
|
<li
|
599
636
|
className={"tags-input__tag-item tags-input__tag-item--multi-select"
|
600
637
|
+ (this.props.readOnly ? ' tags-input__tag-item--readonly' : '')}
|
601
|
-
onClick={() => !this.props.readOnly && this.
|
638
|
+
onClick={() => (!this.props.readOnly && !this.props.disabled)
|
639
|
+
&& this.removeClick(i)
|
640
|
+
}
|
602
641
|
style={this.props.valueTemplate
|
603
642
|
? {backgroundColor}
|
604
643
|
: this.props.getBackgroundColor
|
605
644
|
&& {backgroundColor: this.props.getBackgroundColor(item)}}
|
606
645
|
>
|
607
646
|
<span
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
647
|
+
className="tags-input__helper-box"
|
648
|
+
style={
|
649
|
+
{color: backgroundColor
|
650
|
+
? getTextColor(backgroundColor)
|
651
|
+
: this.props.getBackgroundColor
|
652
|
+
&& getTextColor(this.props.getBackgroundColor(item)),
|
653
|
+
}
|
654
|
+
}
|
655
|
+
>
|
613
656
|
{children}
|
614
|
-
{!this.props.readOnly
|
615
|
-
<
|
616
|
-
|
657
|
+
{!this.props.readOnly
|
658
|
+
&& <span className="tags-input__remove-button">
|
659
|
+
<Icon name="close-small"></Icon>
|
660
|
+
</span>
|
661
|
+
}
|
617
662
|
</span>
|
618
663
|
</li>
|
619
664
|
);
|
@@ -631,10 +676,12 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
631
676
|
})}
|
632
677
|
</ul>
|
633
678
|
{this.state.value.length > 0
|
634
|
-
? this.props.readOnly
|
635
|
-
|| <button
|
636
|
-
|
637
|
-
|
679
|
+
? (this.props.readOnly || this.props.disabled)
|
680
|
+
|| <button
|
681
|
+
className="tags-input__remove-value"
|
682
|
+
style={{position: 'relative', bottom: '2px'}}
|
683
|
+
onClick={() => this.setState({value: []})}
|
684
|
+
>
|
638
685
|
<Icon name='remove-sign'></Icon>
|
639
686
|
</button>
|
640
687
|
: null
|
@@ -650,8 +697,11 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
650
697
|
</button>
|
651
698
|
}
|
652
699
|
{this.state.value.length < 1
|
653
|
-
&& <span
|
654
|
-
|
700
|
+
&& <span
|
701
|
+
className={ 'tags-input__single-item'
|
702
|
+
+ (this.props.readOnly ? ' tags-input__tag-item--readonly' : '')
|
703
|
+
}
|
704
|
+
>
|
655
705
|
<span className="tags-input__placeholder">
|
656
706
|
{this.props.placeholder}
|
657
707
|
</span>
|
@@ -662,23 +712,29 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
662
712
|
= ({backgroundColor, borderColor, children}) => (
|
663
713
|
<span
|
664
714
|
className={ 'tags-input__single-item'
|
665
|
-
|
666
|
-
|
715
|
+
+ (this.props.readOnly ? ' tags-input__tag-item--readonly' : '')
|
716
|
+
}
|
717
|
+
onClick={() => !this.props.readOnly && this.removeClick(i)
|
718
|
+
}
|
667
719
|
>
|
668
720
|
{this.props.getBorderColor
|
669
|
-
&& <div
|
721
|
+
&& <div
|
722
|
+
className="item-border item-border-selected"
|
670
723
|
style={borderColor
|
671
|
-
|
672
|
-
|
724
|
+
? {backgroundColor: borderColor}
|
725
|
+
: {backgroundColor: this.props.getBorderColor(item)}
|
726
|
+
}
|
673
727
|
>
|
674
728
|
</div>
|
675
729
|
}
|
676
730
|
<span
|
677
731
|
style={{color: backgroundColor && getTextColor(backgroundColor)}}
|
678
|
-
className="tags-input__helper-box"
|
732
|
+
className="tags-input__helper-box"
|
733
|
+
>
|
679
734
|
<span
|
680
735
|
className={backgroundColor && `tags-input__tag-item`}
|
681
|
-
style={{backgroundColor, margin: 0}}
|
736
|
+
style={{backgroundColor, margin: 0}}
|
737
|
+
>
|
682
738
|
{children}
|
683
739
|
</span>
|
684
740
|
{this.props.readOnly
|
@@ -699,14 +755,16 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
699
755
|
}
|
700
756
|
</React.Fragment>;
|
701
757
|
})}
|
702
|
-
|
758
|
+
</div>
|
703
759
|
}
|
704
760
|
|
705
761
|
{this.state.openDropdown
|
706
762
|
&& <div
|
707
|
-
className={"autocomplete autocomplete--multi-select"
|
708
|
-
|
763
|
+
className={"autocomplete autocomplete--multi-select"
|
764
|
+
+ (this.props.width === 'medium' ? ' autocomplete--fixed-width' : '')
|
765
|
+
}
|
709
766
|
style={{zIndex: this.props.zIndex}}
|
767
|
+
ref={this.dropdownRef}
|
710
768
|
>
|
711
769
|
<div className='autocomplete__header'>
|
712
770
|
<div
|
@@ -720,9 +778,9 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
720
778
|
</div>
|
721
779
|
<div className='autocomplete__filter'>
|
722
780
|
<input
|
723
|
-
placeholder={this.props.searchPlaceholder}
|
724
|
-
type="text"
|
725
781
|
className="autocomplete__input"
|
782
|
+
type="text"
|
783
|
+
placeholder={this.props.searchPlaceholder}
|
726
784
|
ref={this.inputRef}
|
727
785
|
value={this.state.searchFieldValue}
|
728
786
|
onChange={(event) => {
|
@@ -756,10 +814,9 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
756
814
|
</div>
|
757
815
|
<div className='autocomplete__filter'>
|
758
816
|
<button className={'autocomplete__category-title'}>
|
759
|
-
{
|
760
|
-
this.props.optionTemplate
|
761
|
-
|
762
|
-
: this.props.getLabel(this.state.buttonValue.value)
|
817
|
+
{this.props.optionTemplate
|
818
|
+
? this.props.optionTemplate(this.state.buttonValue.value)
|
819
|
+
: this.props.getLabel(this.state.buttonValue.value)
|
763
820
|
}
|
764
821
|
</button>
|
765
822
|
|
@@ -777,83 +834,86 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
|
|
777
834
|
className="suggestion-list suggestion-list--multi-select"
|
778
835
|
ref={this.ref}
|
779
836
|
>
|
780
|
-
{this.state.options
|
781
|
-
.
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
837
|
+
{this.state.options.map((option, i: React.Key | undefined) => {
|
838
|
+
let selectedItem = this.state.value.some((obj) =>
|
839
|
+
this.props.getId(obj) === this.props.getId(option.value),
|
840
|
+
);
|
841
|
+
return (
|
842
|
+
<li
|
843
|
+
key={i}
|
844
|
+
className={`suggestion-item suggestion-item--multi-select`}
|
845
|
+
onClick={(event) => {
|
846
|
+
event.preventDefault();
|
847
|
+
event.stopPropagation();
|
848
|
+
this.handleTree(event, option);
|
849
|
+
}}
|
850
|
+
>
|
851
|
+
<button
|
852
|
+
className={`suggestion-item--btn ${this.props.getId(option.value)}-focus`}
|
853
|
+
onKeyDown={(event) => {
|
854
|
+
if (event.key === 'Enter' && option.children) {
|
855
|
+
this.setState({
|
856
|
+
buttonTarget: [
|
857
|
+
...this.state.buttonTarget,
|
858
|
+
this.props.getId(option.value),
|
859
|
+
],
|
860
|
+
});
|
861
|
+
}
|
793
862
|
}}
|
794
863
|
>
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
this.
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
864
|
+
{(this.props.getBorderColor && !this.props.allowMultiple)
|
865
|
+
&& <div
|
866
|
+
className="item-border"
|
867
|
+
style={{
|
868
|
+
backgroundColor: this.props.getBorderColor(
|
869
|
+
option.value,
|
870
|
+
),
|
871
|
+
}}
|
872
|
+
>
|
873
|
+
</div>
|
874
|
+
}
|
875
|
+
<span
|
876
|
+
className={
|
877
|
+
'suggestion-item--bgcolor'
|
878
|
+
+ (selectedItem ? ' suggestion-item--disabled' : '')
|
879
|
+
}
|
880
|
+
style={
|
881
|
+
(this.props.getBackgroundColor && option.value)
|
882
|
+
? {
|
883
|
+
backgroundColor:
|
884
|
+
this.props.getBackgroundColor(option.value),
|
885
|
+
color:
|
886
|
+
getTextColor(this.props.getBackgroundColor(
|
813
887
|
option.value,
|
888
|
+
),
|
814
889
|
),
|
815
|
-
}
|
816
|
-
|
817
|
-
</div>
|
890
|
+
}
|
891
|
+
: undefined
|
818
892
|
}
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
backgroundColor:
|
824
|
-
this.props.getBackgroundColor(option.value),
|
825
|
-
color:
|
826
|
-
getTextColor(this.props.getBackgroundColor(
|
827
|
-
option.value,
|
828
|
-
),
|
829
|
-
),
|
830
|
-
}
|
831
|
-
: undefined
|
832
|
-
}
|
833
|
-
className={
|
834
|
-
'suggestion-item--bgcolor'
|
835
|
-
+ (selectedItem ? ' suggestion-item--disabled' : '')
|
836
|
-
}
|
837
|
-
>
|
838
|
-
{this.props.optionTemplate
|
839
|
-
? this.props.optionTemplate(option.value)
|
840
|
-
: this.props.getLabel(option.value)}
|
841
|
-
</span>
|
842
|
-
{option.children
|
843
|
-
&& <span className="suggestion-item__icon">
|
844
|
-
<Icon name="chevron-right-thin"></Icon>
|
845
|
-
</span>
|
893
|
+
>
|
894
|
+
{this.props.optionTemplate
|
895
|
+
? this.props.optionTemplate(option.value)
|
896
|
+
: this.props.getLabel(option.value)
|
846
897
|
}
|
847
|
-
</
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
898
|
+
</span>
|
899
|
+
{option.children
|
900
|
+
&& <span className="suggestion-item__icon">
|
901
|
+
<Icon name="chevron-right-thin"></Icon>
|
902
|
+
</span>
|
903
|
+
}
|
904
|
+
</button>
|
905
|
+
</li>
|
906
|
+
);
|
907
|
+
})}
|
852
908
|
</ul>
|
853
909
|
: null
|
854
|
-
: <ul
|
910
|
+
: <ul
|
911
|
+
className="suggestion-list suggestion-list--multi-select"
|
912
|
+
ref={this.ref}
|
913
|
+
>
|
855
914
|
{this.filteredItem(this.props.singleLevelSearch
|
856
|
-
? this.state.options : this.state.filterArr)
|
915
|
+
? this.state.options : this.state.filterArr)
|
916
|
+
}
|
857
917
|
</ul>
|
858
918
|
}
|
859
919
|
</div>
|