superdesk-ui-framework 3.0.1-beta.3 → 3.0.1-beta.30

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.
Files changed (262) hide show
  1. package/app/fonts/sd_icons.eot +0 -0
  2. package/app/fonts/sd_icons.svg +14 -7
  3. package/app/fonts/sd_icons.ttf +0 -0
  4. package/app/fonts/sd_icons.woff +0 -0
  5. package/app/scripts/toggleBoxNext.js +1 -1
  6. package/app/styles/_big-icon-font.scss +1 -1
  7. package/app/styles/_buttons.scss +11 -6
  8. package/app/styles/_content-divider.scss +63 -8
  9. package/app/styles/_helpers.scss +24 -1
  10. package/app/styles/_icon-font.scss +17 -10
  11. package/app/styles/_labels.scss +0 -1
  12. package/app/styles/_master-desk.scss +3 -2
  13. package/app/styles/_modals.scss +6 -3
  14. package/app/styles/_normalize.scss +4 -0
  15. package/app/styles/_sd-tag-input.scss +256 -296
  16. package/app/styles/_simple-list.scss +0 -2
  17. package/app/styles/_table-list.scss +116 -12
  18. package/app/styles/app.scss +1 -0
  19. package/app/styles/components/_list-item.scss +36 -17
  20. package/app/styles/components/_sd-collapse-box.scss +6 -6
  21. package/app/styles/components/_sd-comment-box.scss +8 -4
  22. package/app/styles/components/_sd-editor-popup.scss +4 -4
  23. package/app/styles/components/_sd-grid-item.scss +30 -16
  24. package/app/styles/components/_sd-media-carousel.scss +37 -2
  25. package/app/styles/components/_sd-photo-preview.scss +3 -3
  26. package/app/styles/components/_sd-searchbar.scss +7 -0
  27. package/app/styles/components/_subnav.scss +470 -470
  28. package/app/styles/design-tokens/_design-tokens-general.scss +1 -1
  29. package/app/styles/design-tokens/_new-colors.scss +30 -13
  30. package/app/styles/dropdowns/_basic-dropdown.scss +6 -0
  31. package/app/styles/form-elements/_forms-general.scss +81 -7
  32. package/app/styles/form-elements/_input-wrap.scss +138 -0
  33. package/app/styles/form-elements/_inputs.scss +368 -110
  34. package/app/styles/grids/_grid-layout.scss +34 -1
  35. package/app/styles/interface-elements/_side-panel.scss +1 -1
  36. package/app/styles/layout/_basic-layout.scss +2 -2
  37. package/app/styles/layout/_editor.scss +10 -4
  38. package/app/styles/primereact/_pr-datepicker.scss +4 -2
  39. package/app/styles/primereact/_pr-dialog.scss +5 -0
  40. package/app/styles/primereact/_pr-dropdown.scss +17 -1
  41. package/app/styles/primereact/_pr-menu.scss +6 -5
  42. package/app/styles/variables/_colors.scss +21 -21
  43. package/app-typescript/components/Badge.tsx +3 -2
  44. package/app-typescript/components/ContentDivider.tsx +3 -0
  45. package/app-typescript/components/DatePicker.tsx +40 -52
  46. package/app-typescript/components/Dropdown.tsx +127 -82
  47. package/app-typescript/components/DurationInput.tsx +400 -0
  48. package/app-typescript/components/EmptyState.tsx +2 -1
  49. package/app-typescript/components/Form/FormLabel.tsx +8 -1
  50. package/app-typescript/components/Form/FormRowNew.tsx +41 -0
  51. package/app-typescript/components/Form/InputBase.tsx +95 -0
  52. package/app-typescript/components/Form/InputNew.tsx +107 -0
  53. package/app-typescript/components/Form/InputWrapper.tsx +79 -0
  54. package/app-typescript/components/Form/index.tsx +4 -0
  55. package/app-typescript/components/Input.tsx +28 -45
  56. package/app-typescript/components/Label.tsx +65 -10
  57. package/app-typescript/components/Layouts/AuthoringContainer.tsx +2 -1
  58. package/app-typescript/components/Layouts/AuthoringFrame.tsx +2 -1
  59. package/app-typescript/components/Layouts/AuthoringFrameRightBar.tsx +21 -2
  60. package/app-typescript/components/Layouts/AuthoringInnerHeader.tsx +1 -1
  61. package/app-typescript/components/Layouts/AuthoringMain.tsx +4 -2
  62. package/app-typescript/components/Layouts/CoreLayout.tsx +2 -1
  63. package/app-typescript/components/Layouts/CoreLayoutMain.tsx +7 -1
  64. package/app-typescript/components/Layouts/Layout.tsx +1 -1
  65. package/app-typescript/components/LeftMenu.tsx +127 -122
  66. package/app-typescript/components/Lists/ContentList.tsx +66 -33
  67. package/app-typescript/components/Lists/TableList.tsx +348 -151
  68. package/app-typescript/components/Menu.tsx +2 -2
  69. package/app-typescript/components/MultiSelect.tsx +37 -50
  70. package/app-typescript/components/NavButton.tsx +2 -1
  71. package/app-typescript/components/Navigation/BottomNav.tsx +3 -2
  72. package/app-typescript/components/SearchBar.tsx +39 -12
  73. package/app-typescript/components/Select.tsx +23 -41
  74. package/app-typescript/components/SelectWithTemplate.tsx +32 -7
  75. package/app-typescript/components/Spacer.tsx +87 -0
  76. package/app-typescript/components/TimePicker.tsx +38 -15
  77. package/app-typescript/components/TreeSelect.tsx +546 -212
  78. package/app-typescript/index.ts +6 -1
  79. package/dist/examples.bundle.css +344 -71
  80. package/dist/examples.bundle.js +48203 -45174
  81. package/dist/playgrounds/react-playgrounds/CoreLayout.tsx +65 -54
  82. package/dist/playgrounds/react-playgrounds/Index.tsx +1 -0
  83. package/dist/playgrounds/react-playgrounds/Multiedit.tsx +321 -0
  84. package/dist/playgrounds/react-playgrounds/RundownEditor.tsx +26 -23
  85. package/dist/playgrounds/react-playgrounds/Rundowns.tsx +20 -21
  86. package/dist/playgrounds/react-playgrounds/SamsPlayground.tsx +12 -3
  87. package/dist/playgrounds/react-playgrounds/TestGround.tsx +379 -25
  88. package/dist/playgrounds/react-playgrounds/components/Layout.tsx +1 -1
  89. package/dist/react/Badges.tsx +18 -0
  90. package/dist/react/ContentDivider.tsx +22 -18
  91. package/dist/react/ContentList.tsx +200 -18
  92. package/dist/react/DatePicker.tsx +21 -1
  93. package/dist/react/Dropdowns.tsx +580 -48
  94. package/dist/react/DurationInput.tsx +108 -0
  95. package/dist/react/Index.tsx +5 -0
  96. package/dist/react/Inputs.tsx +147 -2
  97. package/dist/react/Labels.tsx +51 -1
  98. package/dist/react/LeftNavigations.tsx +71 -44
  99. package/dist/react/MultiSelect.tsx +10 -7
  100. package/dist/react/NavButtons.tsx +31 -1
  101. package/dist/react/SelectWithTemplate.tsx +6 -1
  102. package/dist/react/TableList.tsx +79 -186
  103. package/dist/react/TimePicker.tsx +22 -12
  104. package/dist/react/Togglebox.tsx +1 -1
  105. package/dist/react/TreeSelect.tsx +295 -51
  106. package/dist/react/tree-select/TreeSelect.tsx +273 -0
  107. package/dist/react/tree-select/example-1.tsx +71 -0
  108. package/dist/react/tree-select/example-2.tsx +59 -0
  109. package/dist/sd_icons.eot +0 -0
  110. package/dist/sd_icons.svg +14 -7
  111. package/dist/sd_icons.ttf +0 -0
  112. package/dist/sd_icons.woff +0 -0
  113. package/dist/superdesk-ui.bundle.css +2282 -782
  114. package/dist/superdesk-ui.bundle.js +37312 -21800
  115. package/dist/vendor.bundle.js +27 -27
  116. package/examples/css/docs-page.css +4 -4
  117. package/examples/index.js +4 -0
  118. package/examples/pages/playgrounds/react-playgrounds/CoreLayout.tsx +65 -54
  119. package/examples/pages/playgrounds/react-playgrounds/Index.tsx +1 -0
  120. package/examples/pages/playgrounds/react-playgrounds/Multiedit.tsx +321 -0
  121. package/examples/pages/playgrounds/react-playgrounds/RundownEditor.tsx +26 -23
  122. package/examples/pages/playgrounds/react-playgrounds/Rundowns.tsx +20 -21
  123. package/examples/pages/playgrounds/react-playgrounds/SamsPlayground.tsx +12 -3
  124. package/examples/pages/playgrounds/react-playgrounds/TestGround.tsx +379 -25
  125. package/examples/pages/playgrounds/react-playgrounds/components/Layout.tsx +1 -1
  126. package/examples/pages/react/Badges.tsx +18 -0
  127. package/examples/pages/react/ContentDivider.tsx +22 -18
  128. package/examples/pages/react/ContentList.tsx +200 -18
  129. package/examples/pages/react/DatePicker.tsx +21 -1
  130. package/examples/pages/react/Dropdowns.tsx +580 -48
  131. package/examples/pages/react/DurationInput.tsx +108 -0
  132. package/examples/pages/react/Index.tsx +5 -0
  133. package/examples/pages/react/Inputs.tsx +147 -2
  134. package/examples/pages/react/Labels.tsx +51 -1
  135. package/examples/pages/react/LeftNavigations.tsx +71 -44
  136. package/examples/pages/react/MultiSelect.tsx +10 -7
  137. package/examples/pages/react/NavButtons.tsx +31 -1
  138. package/examples/pages/react/SelectWithTemplate.tsx +6 -1
  139. package/examples/pages/react/TableList.tsx +79 -186
  140. package/examples/pages/react/TimePicker.tsx +22 -12
  141. package/examples/pages/react/Togglebox.tsx +1 -1
  142. package/examples/pages/react/TreeSelect.tsx +295 -51
  143. package/examples/pages/react/tree-select/TreeSelect.tsx +273 -0
  144. package/examples/pages/react/tree-select/example-1.tsx +71 -0
  145. package/examples/pages/react/tree-select/example-2.tsx +59 -0
  146. package/package.json +5 -5
  147. package/react/components/Badge.d.ts +1 -0
  148. package/react/components/Badge.js +2 -2
  149. package/react/components/ContentDivider.d.ts +1 -0
  150. package/react/components/ContentDivider.js +2 -0
  151. package/react/components/DatePicker.d.ts +1 -0
  152. package/react/components/DatePicker.js +6 -22
  153. package/react/components/Dropdown.d.ts +6 -5
  154. package/react/components/Dropdown.js +57 -30
  155. package/react/components/DurationInput.d.ts +42 -0
  156. package/react/components/DurationInput.js +364 -0
  157. package/react/components/EmptyState.d.ts +1 -0
  158. package/react/components/EmptyState.js +1 -1
  159. package/react/components/Form/FormLabel.d.ts +4 -1
  160. package/react/components/Form/FormLabel.js +9 -3
  161. package/react/components/Form/FormRowNew.d.ts +12 -0
  162. package/react/components/Form/FormRowNew.js +67 -0
  163. package/react/components/Form/InputBase.d.ts +41 -0
  164. package/react/components/Form/InputBase.js +86 -0
  165. package/react/components/Form/InputNew.d.ts +45 -0
  166. package/react/components/Form/InputNew.js +75 -0
  167. package/react/components/Form/InputWrapper.d.ts +28 -0
  168. package/react/components/Form/InputWrapper.js +91 -0
  169. package/react/components/Form/index.d.ts +4 -0
  170. package/react/components/Form/index.js +9 -1
  171. package/react/components/Input.js +5 -34
  172. package/react/components/Label.d.ts +2 -0
  173. package/react/components/Label.js +34 -3
  174. package/react/components/Layouts/AuthoringContainer.d.ts +1 -0
  175. package/react/components/Layouts/AuthoringContainer.js +1 -1
  176. package/react/components/Layouts/AuthoringFrame.d.ts +1 -0
  177. package/react/components/Layouts/AuthoringFrame.js +1 -1
  178. package/react/components/Layouts/AuthoringFrameRightBar.d.ts +9 -2
  179. package/react/components/Layouts/AuthoringFrameRightBar.js +14 -3
  180. package/react/components/Layouts/AuthoringInnerHeader.js +1 -1
  181. package/react/components/Layouts/AuthoringMain.js +1 -1
  182. package/react/components/Layouts/CoreLayout.d.ts +1 -0
  183. package/react/components/Layouts/CoreLayout.js +1 -1
  184. package/react/components/Layouts/CoreLayoutMain.d.ts +1 -0
  185. package/react/components/Layouts/CoreLayoutMain.js +8 -1
  186. package/react/components/Layouts/Layout.js +1 -1
  187. package/react/components/LeftMenu.d.ts +3 -1
  188. package/react/components/LeftMenu.js +8 -1
  189. package/react/components/Lists/ContentList.d.ts +51 -0
  190. package/react/components/Lists/ContentList.js +110 -0
  191. package/react/components/Lists/TableList.d.ts +64 -0
  192. package/react/components/Lists/TableList.js +240 -0
  193. package/react/components/Menu.js +1 -1
  194. package/react/components/MultiSelect.d.ts +40 -0
  195. package/react/components/MultiSelect.js +70 -0
  196. package/react/components/NavButton.d.ts +1 -1
  197. package/react/components/Navigation/BottomNav.d.ts +1 -0
  198. package/react/components/Navigation/BottomNav.js +2 -2
  199. package/react/components/SearchBar.d.ts +3 -2
  200. package/react/components/SearchBar.js +28 -4
  201. package/react/components/Select.d.ts +1 -1
  202. package/react/components/Select.js +4 -26
  203. package/react/components/SelectWithTemplate.d.ts +11 -1
  204. package/react/components/SelectWithTemplate.js +19 -10
  205. package/react/components/TimePicker.d.ts +11 -1
  206. package/react/components/TimePicker.js +10 -3
  207. package/react/components/TreeSelect.d.ts +82 -0
  208. package/react/components/TreeSelect.js +521 -0
  209. package/react/index.d.ts +6 -0
  210. package/react/index.js +16 -3
  211. package/.vscode/settings.json +0 -5
  212. package/app-typescript/dist/components/Alert.d.ts +0 -16
  213. package/app-typescript/dist/components/Autocomplete.d.ts +0 -48
  214. package/app-typescript/dist/components/Avatar.d.ts +0 -33
  215. package/app-typescript/dist/components/Badge.d.ts +0 -13
  216. package/app-typescript/dist/components/Button.d.ts +0 -23
  217. package/app-typescript/dist/components/ButtonGroup.d.ts +0 -12
  218. package/app-typescript/dist/components/CheckButtonGroup.d.ts +0 -11
  219. package/app-typescript/dist/components/CheckGroup.d.ts +0 -9
  220. package/app-typescript/dist/components/Checkbox.d.ts +0 -19
  221. package/app-typescript/dist/components/CheckboxButton.d.ts +0 -19
  222. package/app-typescript/dist/components/DatePicker.d.ts +0 -37
  223. package/app-typescript/dist/components/Divider.d.ts +0 -9
  224. package/app-typescript/dist/components/DonutChart.d.ts +0 -12
  225. package/app-typescript/dist/components/Dropdown.d.ts +0 -28
  226. package/app-typescript/dist/components/DropdownFirst.d.ts +0 -42
  227. package/app-typescript/dist/components/EmptyState.d.ts +0 -11
  228. package/app-typescript/dist/components/FormLabel.d.ts +0 -9
  229. package/app-typescript/dist/components/Genie.d.ts +0 -13
  230. package/app-typescript/dist/components/GridItem.d.ts +0 -69
  231. package/app-typescript/dist/components/GridList.d.ts +0 -14
  232. package/app-typescript/dist/components/HeadingText.d.ts +0 -10
  233. package/app-typescript/dist/components/HelloWorld.d.ts +0 -8
  234. package/app-typescript/dist/components/Icon.d.ts +0 -12
  235. package/app-typescript/dist/components/IconButton.d.ts +0 -12
  236. package/app-typescript/dist/components/IconLabel.d.ts +0 -11
  237. package/app-typescript/dist/components/Input.d.ts +0 -24
  238. package/app-typescript/dist/components/Label.d.ts +0 -15
  239. package/app-typescript/dist/components/LeftMenu.d.ts +0 -26
  240. package/app-typescript/dist/components/Loader.d.ts +0 -8
  241. package/app-typescript/dist/components/NavButton.d.ts +0 -15
  242. package/app-typescript/dist/components/Popover.d.ts +0 -13
  243. package/app-typescript/dist/components/PropsList.d.ts +0 -15
  244. package/app-typescript/dist/components/Radio.d.ts +0 -19
  245. package/app-typescript/dist/components/RadioButton.d.ts +0 -20
  246. package/app-typescript/dist/components/Select.d.ts +0 -29
  247. package/app-typescript/dist/components/SelectWithTemplate.d.ts +0 -32
  248. package/app-typescript/dist/components/SlidingToolbar.d.ts +0 -8
  249. package/app-typescript/dist/components/StrechBar.d.ts +0 -4
  250. package/app-typescript/dist/components/SubNav.d.ts +0 -10
  251. package/app-typescript/dist/components/Switch.d.ts +0 -12
  252. package/app-typescript/dist/components/TabCustom.d.ts +0 -25
  253. package/app-typescript/dist/components/TabList.d.ts +0 -22
  254. package/app-typescript/dist/components/Tag.d.ts +0 -9
  255. package/app-typescript/dist/components/TagInput.d.ts +0 -7
  256. package/app-typescript/dist/components/TagInputTest.d.ts +0 -18
  257. package/app-typescript/dist/components/TimePicker.d.ts +0 -11
  258. package/app-typescript/dist/components/Tooltip.d.ts +0 -11
  259. package/app-typescript/dist/components/_Positioner.d.ts +0 -27
  260. package/app-typescript/dist/index.d.ts +0 -56
  261. package/patches/@superdesk+primereact+5.0.2-4.patch +0 -57
  262. package/yarn-error.log +0 -111
@@ -1,46 +1,87 @@
1
- import { any } from "prop-types";
2
1
  import * as React from "react";
3
2
  import { Icon } from "./Icon";
3
+ import { Loader } from "./Loader";
4
+ import nextId from "react-id-generator";
5
+ import _debounce from 'lodash/debounce';
6
+ import { InputWrapper } from "./Form";
7
+ import { createPopper } from '@popperjs/core';
8
+ import {isEqual} from 'lodash';
9
+ import {getTextColor} from './Label';
4
10
 
5
11
  interface IState<T> {
6
- value?: Array<T>;
7
- options?: Array<T>;
8
- firstBranchOptions?: Array<T>; // to return on first branch in dropdown
9
- getLabel?: string; // label from props
10
- getMultilevelArray?: string; // array from props
11
- openDropdown?: boolean; // open/close dropdown
12
- activeTree?: Array<any>; // for filtered array
13
- filterArr?: Array<T>; // for filtered array
14
- searchFieldValue?: string; // filter value of input
15
- buttonTree?: Array<any>; // array of button (for backButton)
16
- buttonValue?: Array<any>; // button for name of category
17
- buttonMouseEvent?: boolean; // valueButton hover
18
- selectBranchWithChildren?: boolean;
12
+ value: Array<T>;
13
+ options: Array<ITreeNode<T>>;
14
+ firstBranchOptions: Array<any>;
15
+ openDropdown: boolean;
16
+ activeTree: Array<any>;
17
+ filterArr: Array<any>;
18
+ searchFieldValue: string;
19
+ buttonTree: Array<any>;
20
+ buttonValue: any;
21
+ buttonMouseEvent: boolean;
22
+ loading: boolean;
23
+ // provera: boolean;
19
24
  }
20
25
 
21
- interface IProps<T> {
26
+ interface IPropsBase<T> {
22
27
  value?: Array<T>;
23
- options: Array<T>;
24
- getLabel: string;
25
- getMultilevelArray: string;
26
28
  selectBranchWithChildren?: boolean;
27
- readonly?: boolean;
29
+ readOnly?: boolean;
28
30
  width?: string;
31
+ allowMultiple?: boolean;
32
+ loading?: boolean;
33
+ singleLevelSearch?: boolean;
34
+ placeholder?: string;
35
+ 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
+ getLabel(item: T): string;
47
+ getId(item: T): string;
48
+ getBackgroundColor?(item: T): string;
49
+ getBorderColor?(item: T): string;
29
50
  optionTemplate?(item: T): React.ComponentType<T> | JSX.Element;
30
- valueTemplate?(item: T): React.ComponentType<T> | JSX.Element;
31
- onChange(): void;
51
+ valueTemplate?(item: T, Wrapper: any): React.ComponentType<T> | JSX.Element;
52
+ onChange(e: Array<T>): void;
53
+ }
54
+
55
+ interface IPropsSync<T> extends IPropsBase<T> {
56
+ kind: 'synchronous';
57
+ getOptions(): Array<ITreeNode<T>>;
58
+ }
59
+
60
+ interface IPropsAsync<T> extends IPropsBase<T> {
61
+ kind: 'asynchronous';
62
+ getOptions?(): Array<ITreeNode<T>>;
63
+ searchOptions(term: string, callback?: (options: Array<ITreeNode<T>>) => void): any;
64
+ }
65
+
66
+ type IProps<T> = IPropsSync<T> | IPropsAsync<T>;
67
+
68
+ export interface ITreeNode<T> {
69
+ value: T;
70
+ children?: Array<ITreeNode<T>>;
32
71
  }
33
72
 
34
73
  export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
35
- private dropdownRef: any;
36
- private openDropdownRef: any;
74
+ private dropdownRef: React.RefObject<HTMLInputElement>;
75
+ private openDropdownRef: React.RefObject<HTMLButtonElement>;
76
+ private htmlId: string = nextId();
77
+ private popperInstance: any;
37
78
 
38
79
  constructor(props: IProps<T>) {
39
80
  super(props);
40
81
  this.state = {
41
82
  value: this.props.value ? this.props.value : [],
42
- options: this.props.options ? this.props.options : [],
43
- firstBranchOptions: this.props.options ? this.props.options : [],
83
+ options: this.props.getOptions ? this.props.getOptions() : [],
84
+ firstBranchOptions: this.props.getOptions ? this.props.getOptions() : [],
44
85
  activeTree: [],
45
86
  filterArr: [],
46
87
  searchFieldValue: '',
@@ -48,6 +89,8 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
48
89
  buttonValue: [],
49
90
  buttonMouseEvent: false,
50
91
  openDropdown: false,
92
+ loading: false,
93
+ // provera: false
51
94
  };
52
95
 
53
96
  this.removeClick = this.removeClick.bind(this);
@@ -55,62 +98,110 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
55
98
  this.backButton = this.backButton.bind(this);
56
99
  this.handleButton = this.handleButton.bind(this);
57
100
  this.backButtonValue = this.backButtonValue.bind(this);
101
+ this.handleTree = this.handleTree.bind(this);
102
+ this.filteredItem = this.filteredItem.bind(this);
103
+ this.banchButton = this.banchButton.bind(this);
104
+ this.handleDebounce = this.handleDebounce.bind(this);
105
+ this.toggleMenu = this.toggleMenu.bind(this);
58
106
  this.dropdownRef = React.createRef();
59
107
  this.openDropdownRef = React.createRef();
60
108
  }
61
109
 
110
+ componentDidMount = () => {
111
+ this.recursion(this.state.options);
112
+ document.addEventListener("mousedown", (event: any) => {
113
+ if ((this.dropdownRef.current && !this.dropdownRef.current.contains(event.target))
114
+ && (this.openDropdownRef.current && !this.openDropdownRef.current.contains(event.target))) {
115
+ this.setState({openDropdown: false});
116
+ }
117
+ });
118
+ }
119
+
120
+ componentDidUpdate(prevProps: Readonly<IProps<T>>, prevState: Readonly<IState<T>>): void {
121
+ if (!isEqual(prevState.value, this.state.value)) {
122
+ this.props.onChange(this.state.value);
123
+ } else if (!isEqual(prevProps.value, this.props.value)) {
124
+ this.props.onChange(this.state.value);
125
+ }
126
+ if (prevState.openDropdown !== this.state.openDropdown) {
127
+ this.toggleMenu();
128
+ }
129
+ if (this.props.kind === 'synchronous') {
130
+ if ((prevState.activeTree !== this.state.activeTree)
131
+ || (prevState.filterArr !== this.state.filterArr)
132
+ || (prevState.options !== this.state.options)) {
133
+ this.popperInstance.update();
134
+ }
135
+ }
136
+ }
137
+
138
+ toggleMenu() {
139
+ if (this.state.openDropdown) {
140
+ if (this.openDropdownRef.current && this.dropdownRef.current) {
141
+ this.popperInstance = createPopper(this.openDropdownRef.current, this.dropdownRef.current, {
142
+ placement: 'bottom-start',
143
+ modifiers: [
144
+ {
145
+ name: 'offset',
146
+ options: {
147
+ offset: [-4, 4],
148
+ },
149
+ },
150
+ ],
151
+ });
152
+ }
153
+ }
154
+ }
155
+
62
156
  removeClick(i: number) {
63
157
  let newTags = this.state.value;
64
- newTags.splice(i, 1);
158
+ newTags?.splice(i, 1);
65
159
 
66
160
  this.setState({
67
161
  value: newTags,
68
162
  });
69
- this.props.onChange();
163
+ this.props.onChange(this.state.value);
70
164
  }
71
165
 
72
- handleMultiLevel(event, item) {
73
- if (item[this.props.getMultilevelArray]) {
166
+ handleMultiLevel(item: ITreeNode<T>) {
167
+ if (item.children) {
74
168
  this.setState({
75
169
  activeTree: [...this.state.activeTree, this.state.options],
76
- options: item[this.props.getMultilevelArray],
170
+ options: item.children,
77
171
  });
78
172
  }
79
173
  }
80
174
 
81
- handleButton(event, item) {
175
+ handleButton(item: ITreeNode<T>) {
82
176
  this.setState({
83
177
  buttonTree: [...this.state.buttonTree, this.state.buttonValue],
84
178
  buttonValue: item,
85
179
  });
86
180
  }
87
181
 
88
- handleValue(event, item) {
89
- let checkItem = this.state.value.find((valueItem: any) => {
90
- return valueItem === item;
182
+ handleValue(event: React.MouseEvent<HTMLLIElement, MouseEvent>, item: ITreeNode<T>) {
183
+ if (this.props.allowMultiple) {
184
+ let checkItem = this.state.value.find((valueItem: T) => {
185
+ return this.props.getId(valueItem) === this.props.getId(item.value);
91
186
  });
92
-
93
187
  if (!checkItem) {
94
- this.setState({value: [...this.state.value, item]});
188
+ this.setState({value: [...this.state.value, item.value]});
95
189
  }
96
-
97
190
  if (!event.ctrlKey) {
98
- this.setState({options: this.state.firstBranchOptions, activeTree: [], openDropdown: false});
191
+ if (this.props.getOptions) {
192
+ this.setState({options: this.state.firstBranchOptions, activeTree: [], openDropdown: false});
193
+ } else {
194
+ this.setState({activeTree: [], openDropdown: false});
195
+ }
99
196
  }
100
197
  this.setState({buttonMouseEvent: false});
101
- }
102
-
103
- handleBranchValue(event, item) {
104
- if (this.props.selectBranchWithChildren) {
105
-
106
- let checkItem = this.state.value.find((valueItem: any) => {
107
- return valueItem === item;
198
+ } else {
199
+ let checkItem = this.state.value.find((valueItem: T) => {
200
+ return this.props.getId(valueItem) === this.props.getId(item.value);
108
201
  });
109
-
110
202
  if (!checkItem) {
111
- this.setState({value: [...this.state.value, item]});
203
+ this.setState({value: [item.value]});
112
204
  }
113
-
114
205
  if (!event.ctrlKey) {
115
206
  this.setState({options: this.state.firstBranchOptions, activeTree: [], openDropdown: false});
116
207
  }
@@ -118,11 +209,86 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
118
209
  }
119
210
  }
120
211
 
212
+ handleBranchValue(event: React.MouseEvent<HTMLButtonElement, MouseEvent>, item: ITreeNode<T>) {
213
+ if (this.props.allowMultiple) {
214
+ if (this.props.selectBranchWithChildren) {
215
+ let checkItem = this.state.value.find((valueItem: T) => {
216
+ return this.props.getId(valueItem) === this.props.getId(item.value);
217
+ });
218
+ if (!checkItem) {
219
+ this.setState({value: [...this.state.value, item.value]});
220
+ }
221
+ if (!event.ctrlKey) {
222
+ this.setState({options: this.state.firstBranchOptions, activeTree: [], openDropdown: false});
223
+ }
224
+ this.setState({buttonMouseEvent: false});
225
+ }
226
+ } else {
227
+ if (this.props.selectBranchWithChildren) {
228
+ let checkItem = this.state.value.find((valueItem: T) => {
229
+ return this.props.getId(valueItem) === this.props.getId(item.value);
230
+ });
231
+ if (!checkItem) {
232
+ this.setState({value: [item.value]});
233
+ }
234
+ if (!event.ctrlKey) {
235
+ this.setState({options: this.state.firstBranchOptions, activeTree: [], openDropdown: false});
236
+ }
237
+ this.setState({buttonMouseEvent: false});
238
+ }
239
+ }
240
+ }
241
+
242
+ handleTree(event: React.MouseEvent<HTMLLIElement, MouseEvent>, option: ITreeNode<T>) {
243
+ if (option.children) {
244
+ this.handleButton(option);
245
+ this.handleMultiLevel(option);
246
+ if (event.altKey && this.props.allowMultiple) {
247
+ if (this.props.selectBranchWithChildren) {
248
+ let filteredItems: Array<T> = [];
249
+ option.children.forEach((item: { value: T; }) => {
250
+ if (!this.state.value.includes(item.value)) {
251
+ filteredItems.push(item.value);
252
+ }
253
+ });
254
+ this.setState({
255
+ value: [...this.state.value, ...filteredItems],
256
+ options: this.state.firstBranchOptions,
257
+ openDropdown: false,
258
+ activeTree: [],
259
+ });
260
+ } else {
261
+ let filteredItems: Array<T> = [];
262
+ option.children.forEach((item: ITreeNode<T>) => {
263
+ if (!this.state.value.includes(item.value)
264
+ && !item.children) {
265
+ filteredItems.push(item.value);
266
+ }
267
+ });
268
+ if (filteredItems.length > 0) {
269
+ this.setState({
270
+ value: [...this.state.value, ...filteredItems],
271
+ options: this.state.firstBranchOptions,
272
+ openDropdown: false,
273
+ activeTree: [],
274
+ });
275
+ }
276
+ }
277
+ }
278
+ } else {
279
+ this.handleValue(event, option);
280
+ if (!event.ctrlKey) {
281
+ this.setState({openDropdown: false});
282
+ }
283
+ }
284
+ }
285
+
121
286
  backButton = () => {
122
287
  if (this.state.activeTree.length > 0) {
123
288
  this.setState({
124
289
  options: this.state.activeTree.pop(),
125
290
  });
291
+ return;
126
292
  } else {
127
293
  return false;
128
294
  }
@@ -134,197 +300,365 @@ export class TreeSelect<T> extends React.Component<IProps<T>, IState<T>> {
134
300
  });
135
301
  }
136
302
 
137
- recursion(arr) {
138
- if (this.props.selectBranchWithChildren) {
139
- arr.map((item: any) => {
140
- this.state.filterArr.push(item);
141
- if (item[this.props.getMultilevelArray]) {
142
- this.recursion(item[this.props.getMultilevelArray]);
143
- }
144
- });
145
- } else {
146
- arr.map((item: any) => {
147
- if (!item[this.props.getMultilevelArray]) {
148
- this.state.filterArr.push(item);
303
+ recursion(arr: Array<ITreeNode<T>>) {
304
+ arr.map((item) => {
305
+ this.state.filterArr.push(item);
306
+ if (item.children) {
307
+ this.recursion(item.children);
308
+ }
309
+ });
310
+ }
311
+
312
+ filteredItem(arr: Array<ITreeNode<T>>) {
313
+ if (this.props.kind === 'synchronous') {
314
+ let filteredArr = arr.filter((item) => {
315
+ if (this.state.searchFieldValue) {
316
+ if (this.props.getLabel(item.value)
317
+ .toLowerCase().includes(this.state.searchFieldValue.toLowerCase())) {
318
+ return item.value;
319
+ } else {
320
+ return;
321
+ }
149
322
  } else {
150
- this.recursion(item[this.props.getMultilevelArray]);
323
+ return item.value;
151
324
  }
152
325
  });
326
+
327
+ if (filteredArr.length === 0) {
328
+ return <li className="suggestion-item--nothing-found">Nothing fonud</li>;
329
+ } else {
330
+ return filteredArr.map((option, i) => {
331
+ let selectedItem = this.state.value.some((obj) =>
332
+ this.props.getId(obj) === this.props.getId(option.value),
333
+ );
334
+ return <li key={i}
335
+ className={`suggestion-item suggestion-item--multi-select`}
336
+ onClick={(event) => {
337
+ this.setState({
338
+ searchFieldValue: '',
339
+ }),
340
+ event.preventDefault();
341
+ event.stopPropagation();
342
+ this.handleTree(event, option);
343
+ }}>
344
+ {this.props.getBorderColor
345
+ && <div className="item-border"
346
+ style={{backgroundColor: this.props.getBorderColor(option.value)}}></div>}
347
+ <span
348
+ style={this.props.getBackgroundColor
349
+ ? {backgroundColor: this.props.getBackgroundColor(option.value),
350
+ color: getTextColor(this.props.getBackgroundColor(option.value))}
351
+ : undefined}
352
+ className={'suggestion-item--bgcolor'
353
+ + (selectedItem ? ' suggestion-item--disabled' : '')}
354
+ >
355
+ {this.props.optionTemplate
356
+ ? this.props.optionTemplate(option.value)
357
+ : this.props.getLabel(option.value)}
358
+ </span>
359
+ {option.children && <span className="suggestion-item__icon">
360
+ <Icon name="chevron-right-thin"></Icon>
361
+ </span>}
362
+ </li>;
363
+ });
364
+ }
365
+ } else if (this.props.kind === 'asynchronous') {
366
+ return this.state.options.map((item, i) => {
367
+ let selectedItem = this.state.value.some((obj) =>
368
+ this.props.getId(obj) === this.props.getId(item.value),
369
+ );
370
+ return (
371
+ <li key={i}
372
+ className={`suggestion-item suggestion-item--multi-select`}
373
+ onClick={(event) => {
374
+ this.handleValue(event, item);
375
+ }}>
376
+ {this.props.optionTemplate
377
+ ? this.props.optionTemplate(item.value)
378
+ : <span
379
+ className={selectedItem
380
+ ? 'suggestion-item--disabled' : undefined}
381
+ >
382
+ {this.props.getLabel(item.value)}
383
+ </span>}
384
+ </li>
385
+ );
386
+ });
387
+ } else {
388
+ return;
153
389
  }
154
390
  }
155
391
 
156
- componentDidMount = () => {
157
- this.recursion(this.state.options);
158
- document.addEventListener("mousedown", (event) => {
159
- if ((this.dropdownRef.current && !this.dropdownRef.current.contains(event.target))
160
- && (this.openDropdownRef.current && !this.openDropdownRef.current.contains(event.target))) {
161
- this.setState({openDropdown: false});
162
- }
163
- });
392
+ banchButton() {
393
+ let selectedButton = this.state.value.some((obj) =>
394
+ this.props.getId(obj) === this.props.getId(this.state.buttonValue.value),
395
+ );
396
+
397
+ if (!selectedButton) {
398
+ return <button
399
+ className={'autocomplete__button' + (this.props.selectBranchWithChildren ? ' autocomplete__button--multi-select' : '')}
400
+ onMouseOver={() => this.setState({buttonMouseEvent: true})}
401
+ onMouseOut={() => this.setState({buttonMouseEvent: false})}
402
+ value={this.state.buttonValue}
403
+ onClick={(event) => this.handleBranchValue(event, this.state.buttonValue)}>
404
+ Choose entire category
405
+ </button>;
406
+ } else {
407
+ return <button
408
+ className={'autocomplete__button' + (this.props.selectBranchWithChildren ? ' autocomplete__button--multi-select' : '') + ' autocomplete__button--disabled'}
409
+ value={this.state.buttonValue}>
410
+ Category selected
411
+ </button>;
412
+ }
164
413
  }
165
414
 
166
- componentDidUpdate(prevProps: Readonly<IProps<T>>, prevState: Readonly<IState<T>>): void {
167
- if (prevState.value !== this.state.value) {
168
- this.props.onChange();
169
- } else if (prevProps.value !== this.props.value) {
170
- this.props.onChange();
415
+ private debounceFn = _debounce(this.handleDebounce, 500);
416
+ private ICancelFn: any;
417
+
418
+ handleDebounce() {
419
+ this.setState({options: []});
420
+ if (this.props.kind === 'asynchronous') {
421
+ if (this.state.searchFieldValue) {
422
+ this.setState({
423
+ loading: true,
424
+ // provera: false
425
+ });
426
+ this.ICancelFn = this.props.searchOptions(this.state.searchFieldValue, (items) => {
427
+ // if (items.length === 0) {
428
+ // this.setState({provera: true, loading: false})
429
+ // } else {
430
+ this.setState({options: items, loading: false});
431
+ this.popperInstance.update();
432
+ // }
433
+ });
434
+ }
171
435
  }
172
436
  }
173
437
 
174
438
  render() {
175
-
176
439
  return (
177
- <div className="tags-input tags-input--multiselect">
178
- <div className="tags-input__tags">
179
- {this.props.readonly
180
- || <button ref={this.openDropdownRef}
181
- className="tags-input__add-button"
182
- onClick={() => this.setState({openDropdown: !this.state.openDropdown})}>
183
- <i className="icon-plus-large"></i>
184
- </button>}
185
- <ul className="tags-input__tag-list">
186
- {this.state.value.map((item, i) => {
187
- return <React.Fragment key={i}>
188
- <li
189
- className={"tags-input__tag-item tags-input__tag-item-multiselect"
190
- + (this.props.readonly ? ' tags-input__tag-item-readonly' : '')}
191
- onClick={(event) => this.props.readonly || this.removeClick(i)}>
192
- <span className="tags-input__helper-box">
440
+ <InputWrapper
441
+ label={this.props.label}
442
+ error={this.props.error}
443
+ required={this.props.required}
444
+ disabled={this.props.disabled}
445
+ invalid={this.props.invalid}
446
+ info={this.props.info}
447
+ inlineLabel={this.props.inlineLabel}
448
+ labelHidden={this.props.labelHidden}
449
+ fullWidth={this.props.fullWidth}
450
+ htmlId={this.htmlId}
451
+ tabindex={this.props.tabindex}>
452
+ <div className={`tags-input tags-input--${this.props.allowMultiple ? 'multi-select' : 'single-select'} sd-input__input`}>
453
+ {this.props.allowMultiple
454
+ ? <div className="tags-input__tags">
455
+ {this.props.readOnly
456
+ || <button ref={this.openDropdownRef}
457
+ className="tags-input__add-button"
458
+ onClick={() => this.setState({openDropdown: !this.state.openDropdown})}>
459
+ <i className="icon-plus-large"></i>
460
+ </button>}
461
+ <ul className="tags-input__tag-list">
462
+ {this.state.value.map((item, i: number) => {
463
+ const Wrapper: React.ComponentType<{backgroundColor?: string}>
464
+ = ({backgroundColor, children}) => (
465
+ <li
466
+ className={"tags-input__tag-item tags-input__tag-item--multi-select"
467
+ + (this.props.readOnly ? ' tags-input__tag-item--readonly' : '')}
468
+ onClick={() => !this.props.readOnly && this.removeClick(i)}
469
+ style={this.props.valueTemplate
470
+ ? {backgroundColor}
471
+ : this.props.getBackgroundColor
472
+ && {backgroundColor: this.props.getBackgroundColor(item)}}>
473
+ <span
474
+ style={{color: backgroundColor
475
+ ? getTextColor(backgroundColor)
476
+ : this.props.getBackgroundColor
477
+ && getTextColor(this.props.getBackgroundColor(item))}}
478
+ className="tags-input__helper-box">
479
+ {children}
480
+ {!this.props.readOnly && <span className="tags-input__remove-button">
481
+ <Icon name="close-small"></Icon>
482
+ </span>}
483
+ </span>
484
+ </li>
485
+ );
486
+
487
+ return (
488
+ <React.Fragment key={i}>
193
489
  {this.props.valueTemplate
194
- ? this.props.valueTemplate(item)
195
- : <span>{item[this.props.getLabel]}</span>}
196
- {this.props.readonly
490
+ ? this.props.valueTemplate(item, Wrapper)
491
+ : <Wrapper>
492
+ <span>{this.props.getLabel(item)}</span>
493
+ </Wrapper>
494
+ }
495
+ </React.Fragment>
496
+ );
497
+ })}
498
+ </ul>
499
+ {this.state.value.length > 0
500
+ ? this.props.readOnly
501
+ || <button className="tags-input__remove-value"
502
+ style={{position: 'relative', bottom: '2px'}}
503
+ onClick={() => this.setState({value: []})}>
504
+ <Icon name='remove-sign'></Icon>
505
+ </button> : null}
506
+ </div>
507
+ : <div className="tags-input__tags">
508
+ {this.props.readOnly
509
+ || <button
510
+ className="tags-input__overlay-button"
511
+ ref={this.openDropdownRef}
512
+ onClick={() => this.setState({openDropdown: !this.state.openDropdown})}>
513
+ </button>}
514
+ {this.state.value.length < 1 && <span className={ 'tags-input__single-item'
515
+ + (this.props.readOnly ? ' tags-input__tag-item--readonly' : '')}>
516
+ <span className="tags-input__placeholder">
517
+ {this.props.placeholder}
518
+ </span>
519
+ </span>}
520
+ {this.state.value.map((item, i: number) => {
521
+ const Wrapper: React.ComponentType<{backgroundColor?: string, borderColor?: string}>
522
+ = ({backgroundColor, borderColor, children}) => (
523
+ <span
524
+ className={ 'tags-input__single-item'
525
+ + (this.props.readOnly ? ' tags-input__tag-item--readonly' : '')}
526
+ onClick={() => this.props.readOnly || this.removeClick(i)}>
527
+ {this.props.getBorderColor
528
+ && <div className="item-border item-border-selected"
529
+ style={borderColor
530
+ ? {backgroundColor: borderColor}
531
+ : {backgroundColor: this.props.getBorderColor(item)}}></div>}
532
+ <span
533
+ style={{color: backgroundColor && getTextColor(backgroundColor)}}
534
+ className="tags-input__helper-box">
535
+ <span
536
+ className={backgroundColor && `tags-input__tag-item`}
537
+ style={{backgroundColor, margin: 0}}>
538
+ {children}
539
+ </span>
540
+ {this.props.readOnly
197
541
  || <span className="tags-input__remove-button">
198
- <i className="icon-close-small"></i>
542
+ <Icon name='remove-sign'></Icon>
199
543
  </span>}
200
544
  </span>
201
- </li>
545
+ </span>
546
+ );
547
+
548
+ return <React.Fragment key={i}>
549
+ {this.props.valueTemplate
550
+ ? this.props.valueTemplate(item, Wrapper)
551
+ : <Wrapper>
552
+ <span>{this.props.getLabel(item)}</span>
553
+ </Wrapper>
554
+ }
202
555
  </React.Fragment>;
203
556
  })}
204
- </ul>
205
- </div>
557
+ </div>
558
+ }
206
559
 
207
- {this.state.openDropdown &&
208
- <div className={"autocomplete autocomplete-multiselect" + (this.props.width === 'medium' ? ' autocomplete-multiselect-width' : '')} ref={this.dropdownRef}>
209
- <div className='autocomplete__header'>
210
- <div className="autocomplete__icon" onClick={() => {
211
- this.backButtonValue();
212
- this.backButton();
213
- }}>
214
- {this.state.activeTree.length > 0
215
- ? <Icon name="arrow-left" className="arrow-left"></Icon>
216
- : <Icon name="search" className="search"></Icon>}
217
- </div>
218
- <div className='autocomplete__filter'>
219
- {this.state.activeTree.length > 0
220
- ? <button
221
- className={'autocomplete__button' + (this.props.selectBranchWithChildren ? ' autocomplete__button--multiselect' : '')}
222
- onMouseOver={() => this.setState({buttonMouseEvent: true})}
223
- onMouseOut={() => this.setState({buttonMouseEvent: false})}
224
- value={this.state.buttonValue}
225
- onClick={(event) => this.handleBranchValue(event, this.state.buttonValue)}>
226
- {this.state.buttonMouseEvent && this.props.selectBranchWithChildren ? 'Choose entire category' : this.state.buttonValue[this.props.getLabel]}
227
- </button>
228
- : <input
560
+ {this.state.openDropdown
561
+ && <div className={"autocomplete autocomplete--multi-select" + (this.props.width === 'medium' ? ' autocomplete--fixed-width' : '')} ref={this.dropdownRef}>
562
+ <div className='autocomplete__header'>
563
+ <div className="autocomplete__icon" onClick={() => {
564
+ this.backButtonValue();
565
+ this.backButton();
566
+ }}>
567
+ <Icon name="search" className="search"></Icon>
568
+ </div>
569
+ <div className='autocomplete__filter'>
570
+ <input
571
+ placeholder={this.props.searchPlaceholder}
229
572
  type="text"
230
573
  className="autocomplete__input"
231
- ref={(input: any) => input && input.focus()}
574
+ ref={(input) => input && input.focus()}
232
575
  value={this.state.searchFieldValue}
233
576
  onChange={(event) => {
234
- this.setState({searchFieldValue: event.target.value});
235
- }}
236
- />
237
- }
238
- </div>
239
- </div>
240
- <ul className="suggestion-list suggestion-list--multi-select">
241
- {this.state.searchFieldValue === ''
242
- ? this.state.options.map((option, i) => {
243
- return (
244
- <li key={i}
245
- className={`suggestion-item suggestion-item--multi-select`}
246
- onClick={(event) => {
247
- event.preventDefault();
248
- event.stopPropagation();
249
- if (option[this.props.getMultilevelArray]) {
250
- this.handleButton(event, option);
251
- this.handleMultiLevel(event, option);
252
- if (event.altKey) {
253
- if (this.props.selectBranchWithChildren) {
254
- let filteredItems = option[this.props.getMultilevelArray]
255
- .filter((item) => {
256
- if (!this.state.value.includes(item)) {
257
- return item;
258
- }
259
- });
260
- this.setState({
261
- value: [...this.state.value, ...filteredItems],
262
- options: this.state.firstBranchOptions,
263
- openDropdown: false,
264
- activeTree: [],
265
- });
266
- } else {
267
- let filteredItems = option[this.props.getMultilevelArray]
268
- .filter((item) => {
269
- if (!this.state.value.includes(item)
270
- && !item[this.props.getMultilevelArray]) {
271
- return item;
272
- }
273
- });
274
- if (filteredItems.length > 0) {
275
- this.setState({
276
- value: [...this.state.value, ...filteredItems],
277
- options: this.state.firstBranchOptions,
278
- openDropdown: false,
279
- activeTree: [],
280
- });
281
- }
282
- }
283
- }
284
- } else {
285
- this.handleValue(event, option);
286
- if (!event.ctrlKey) {
287
- this.setState({openDropdown: false});
288
- }
577
+ if (this.props.kind === 'synchronous') {
578
+ this.setState({searchFieldValue: event.target.value});
579
+ this.popperInstance.update();
580
+ } else if (this.props.kind === 'asynchronous') {
581
+ if (this.ICancelFn) {
582
+ this.ICancelFn();
289
583
  }
290
- }}>
291
- {this.props.optionTemplate
292
- ? this.props.optionTemplate(option)
293
- : <span className={this.state.value.includes(option) ? 'suggestion-item--disabled' : null}>
294
- {option[this.props.getLabel]}
295
- </span>}
296
- {option[this.props.getMultilevelArray] && <span className="suggestion-item__icon">
297
- <Icon name="chevron-right-thin"></Icon>
298
- </span>}
299
- </li>
300
- );
301
- })
302
- : this.state.filterArr.filter((item: any) => {
303
- if (this.state.searchFieldValue) {
304
- if (item[this.props.getLabel]
305
- .toLowerCase().includes(this.state.searchFieldValue.toLowerCase())) {
306
- return item;
584
+ this.setState({searchFieldValue: event.target.value, options: []});
585
+ this.popperInstance.update();
586
+ this.debounceFn();
587
+ } else {
588
+ return;
307
589
  }
308
- } else {
309
- return item;
310
- }
311
- }).map((item, i) => {
312
- return <li key={i}
313
- className={`suggestion-item suggestion-item--multi-select`}
314
- onClick={(event) => {
315
- this.handleValue(event, item);
316
- }}>
317
- <span
318
- className={this.state.value.includes(item)
319
- ? 'suggestion-item--disabled' : null}>
320
- {item[this.props.getLabel]}
321
- </span>
322
- </li>;
323
- })
590
+ // if(!this.state.searchFieldValue) {
591
+ // this.setState({provera: false});
592
+ // }
593
+ }} />
594
+ </div>
595
+ </div>
596
+ {this.state.activeTree.length > 0
597
+ && <div className='autocomplete__category-header'>
598
+ <div className="autocomplete__icon" onClick={() => {
599
+ this.backButtonValue();
600
+ this.backButton();
601
+ }}>
602
+ <Icon name="arrow-left" className="arrow-left"></Icon>
603
+ </div>
604
+ <div className='autocomplete__filter'>
605
+ <button
606
+ className={'autocomplete__category-title'}
607
+ value={this.state.buttonValue}>
608
+ {this.props.optionTemplate
609
+ ? this.props.optionTemplate(this.state.buttonValue.value)
610
+ : this.props.getLabel(this.state.buttonValue.value)}
611
+ </button>
612
+ {this.props.selectBranchWithChildren && this.banchButton()}
613
+ </div>
614
+ </div>}
615
+ {this.state.loading
616
+ ? <ul className="suggestion-list--loader"><Loader overlay={true}></Loader></ul>
617
+ : this.state.searchFieldValue === ''
618
+ ? this.props.getOptions
619
+ ? <ul className="suggestion-list suggestion-list--multi-select">
620
+ {this.state.options
621
+ .map((option, i: React.Key | undefined) => {
622
+ let selectedItem = this.state.value.some((obj) =>
623
+ this.props.getId(obj) === this.props.getLabel(option.value),
624
+ );
625
+ return (
626
+ <li key={i}
627
+ className={`suggestion-item suggestion-item--multi-select`}
628
+ onClick={(event) => {
629
+ event.preventDefault();
630
+ event.stopPropagation();
631
+ this.handleTree(event, option);
632
+ }}>
633
+ {(this.props.getBorderColor && !this.props.allowMultiple) && <div className="item-border" style={{backgroundColor: this.props.getBorderColor(option.value)}}></div>}
634
+ <span
635
+ style={(this.props.getBackgroundColor && option.value)
636
+ ? {backgroundColor: this.props.getBackgroundColor(option.value),
637
+ color: getTextColor(this.props.getBackgroundColor(option.value))}
638
+ : undefined}
639
+ className={'suggestion-item--bgcolor'
640
+ + (selectedItem ? ' suggestion-item--disabled' : '')}
641
+ >
642
+ {this.props.optionTemplate
643
+ ? this.props.optionTemplate(option.value)
644
+ : this.props.getLabel(option.value)}
645
+ </span>
646
+ {option.children && <span className="suggestion-item__icon">
647
+ <Icon name="chevron-right-thin"></Icon>
648
+ </span>}
649
+ </li>
650
+ );
651
+ })}</ul> : null
652
+ : <ul className="suggestion-list suggestion-list--multi-select">
653
+ {this.filteredItem(this.props.singleLevelSearch
654
+ ? this.state.options : this.state.filterArr)}
655
+ {/* {this.state.provera
656
+ && <li className="suggestion-item--nothing-found">Nothing fonud</li>} */}
657
+ </ul>
324
658
  }
325
- </ul>
326
- </div>}
327
- </div>
659
+ </div>}
660
+ </div>
661
+ </InputWrapper>
328
662
  );
329
663
  }
330
664
  }