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,133 +1,76 @@
1
1
  import * as React from 'react';
2
2
  import classNames from 'classnames';
3
- import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd";
3
+ import { DragDropContext, Droppable, Draggable, DropResult } from "react-beautiful-dnd";
4
4
  import { Tooltip } from '../Tooltip';
5
5
  import { Button } from '../Button';
6
- import { Dropdown } from '../Dropdown';
6
+ import { Dropdown, IMenuItem, ISubmenu, IMenuGroup } from '../Dropdown';
7
+ import ReactDOM from 'react-dom';
7
8
 
8
- interface IPropsItem {
9
- start?: React.ReactNode;
10
- center?: React.ReactNode;
11
- end?: React.ReactNode;
12
- action?: React.ReactNode;
9
+ export interface IProps {
10
+ array: Array<IPropsArrayItem>;
13
11
  addItem?: boolean;
14
- itemsDropdown?: any;
15
12
  dragAndDrop?: boolean;
16
- onClick?(): void;
17
- }
18
-
19
- class TableListItem extends React.PureComponent<IPropsItem> {
20
- render() {
21
- return (
22
- this.props.addItem ?
23
- <li className='table-list__item-container'>
24
- <div
25
- onClick={this.props.onClick}
26
- className={`table-list__item ${this.props.onClick && 'table-list__item--clickable'} ${this.props.dragAndDrop && 'table-list__item--draggable'}`}>
27
- <div className='table-list__item-content'>
28
- <div className='table-list__item-content-block'>
29
- {this.props.start && this.props.start}
30
- </div>
31
- <div className='table-list__item-content-block table-list__item-content-block--center'>
32
- {this.props.center && this.props.center}
33
- </div>
34
- <div className='table-list__item-content-block'>
35
- {this.props.end && this.props.end}
36
- </div>
37
- </div>
38
- {this.props.action && <div className='table-list__slide-in-actions'>
39
- {this.props.action}
40
- </div>}
41
- </div>
42
- <div className='table-list__add-bar-container'>
43
- <Tooltip text='Add item' flow='top' appendToBody={true}>
44
- <div className='table-list__add-bar'>
45
- <Dropdown
46
- items={this.props.itemsDropdown}>
47
- <Button
48
- type="primary"
49
- icon="plus-large"
50
- text="Add item"
51
- size="small"
52
- shape="round"
53
- iconOnly={true}
54
- onClick={() => false}
55
- />
56
- </Dropdown>
57
- </div>
58
- </Tooltip>
59
- </div>
60
- </li>
61
- : <li
62
- className={`table-list__item ${this.props.onClick && 'table-list__item--clickable'} ${this.props.dragAndDrop && 'table-list__item--draggable'} table-list__item--margin`}
63
- onClick={this.props.onClick}>
64
- <div className='table-list__item-content'>
65
- <div className='table-list__item-content-block'>
66
- {this.props.start && this.props.start}
67
- </div>
68
- <div className='table-list__item-content-block table-list__item-content-block--center'>
69
- {this.props.center && this.props.center}
70
- </div>
71
- <div className='table-list__item-content-block'>
72
- {this.props.end && this.props.end}
73
- </div>
74
- </div>
75
- {this.props.action && <div className='table-list__slide-in-actions'>
76
- {this.props.action}
77
- </div>}
78
- </li>
79
- );
80
- }
81
- }
82
-
83
- interface IProps {
84
- children?: React.ReactNode;
85
- array?: Array<IPropsArray>;
86
- addItem?: boolean;
87
- dragAndDrop?: boolean;
88
- itemsDropdown?: any;
89
13
  className?: string;
90
- onClick?(): void;
14
+ readOnly?: boolean;
15
+ showDragHandle?: 'always' | 'onHover' | 'none'; // always default
16
+ append?: boolean;
17
+ onDrag?(start: number, end: number): void;
18
+ onAddItem?(index: number, item?: IPropsArrayItem): void;
19
+ itemsDropdown?(index?: number): Array<IMenuItem | ISubmenu | IMenuGroup | 'divider'>;
91
20
  }
92
21
 
93
- interface IPropsArray {
22
+ export interface IPropsArrayItem {
94
23
  start?: React.ReactNode;
95
24
  center?: React.ReactNode;
96
25
  end?: React.ReactNode;
97
26
  action?: React.ReactNode;
27
+ hexColor?: string;
28
+ onClick?(): void;
29
+ onDoubleClick?(): void;
30
+ locked?: boolean;
31
+ positionLocked?: boolean;
98
32
  }
99
33
 
100
- const reorder = (list, startIndex, endIndex) => {
101
- const result = Array.from(list);
102
- const [removed] = result.splice(startIndex, 1);
103
- result.splice(endIndex, 0, removed);
34
+ interface IState {
35
+ items: Array<IPropsArrayItem>;
36
+ }
104
37
 
105
- return result;
38
+ const reorder = (list: Array<IPropsArrayItem>, startIndex: number, endIndex: number) => {
39
+ const result = Array.from(list);
40
+ const [removed] = result.splice(startIndex, 1);
41
+ result.splice(endIndex, 0, removed);
42
+
43
+ return result;
106
44
  };
107
45
 
108
- class TableList extends React.PureComponent<IProps, {items: any}> {
109
- constructor(props) {
46
+ class TableList extends React.PureComponent<IProps, IState> {
47
+ constructor(props: IProps) {
110
48
  super(props);
111
49
  this.state = {
112
- items: [],
50
+ items: [],
113
51
  };
114
52
 
115
53
  this.onDragEnd = this.onDragEnd.bind(this);
54
+ this.dropDown = this.dropDown.bind(this);
116
55
  }
117
56
 
118
57
  componentDidMount(): void {
119
- this.setState({items: this.props.array});
58
+ if (this.props.array) {
59
+ this.setState({ items: this.props.array });
60
+ }
120
61
  }
121
62
 
122
- componentDidUpdate(prevProps: Readonly<IProps>, prevState: Readonly<{ items: any; }>, snapshot?: any): void {
123
- if (prevProps.array !== this.props.array) {
124
- this.setState({
125
- items: this.props.array,
126
- });
63
+ componentDidUpdate(prevProps: IProps): void {
64
+ if (this.props.array) {
65
+ if (prevProps.array !== this.props.array) {
66
+ this.setState({
67
+ items: this.props.array,
68
+ });
69
+ }
127
70
  }
128
71
  }
129
72
 
130
- onDragEnd(result) {
73
+ onDragEnd(result: DropResult) {
131
74
  if (!result.destination) {
132
75
  return;
133
76
  }
@@ -137,72 +80,326 @@ class TableList extends React.PureComponent<IProps, {items: any}> {
137
80
  result.destination.index,
138
81
  );
139
82
  this.setState({
140
- items,
83
+ items: items,
141
84
  });
85
+
86
+ return this.props.onDrag ?
87
+ this.props.onDrag(result.source.index, result.destination.index) : null;
88
+ }
89
+
90
+ dropDown() {
91
+ return (
92
+ <Dropdown
93
+ items={this.props.itemsDropdown ? this.props.itemsDropdown() : []}>
94
+ <Button
95
+ type="primary"
96
+ icon="plus-large"
97
+ text="Add item"
98
+ size="small"
99
+ shape="round"
100
+ iconOnly={true}
101
+ onClick={() => false}
102
+ />
103
+ </Dropdown>
104
+ );
142
105
  }
143
106
 
144
107
  render() {
145
- let classes = classNames({
146
- 'table-list' : !this.props.addItem,
108
+ let classes = classNames('', {
109
+ 'table-list': !this.props.addItem,
110
+ 'table-list--read-only': this.props.readOnly,
147
111
  [`${this.props.className}`]: this.props.className,
148
112
  });
149
113
 
150
114
  return (
151
- this.props.array ?
152
- this.props.dragAndDrop ?
153
- <DragDropContext onDragEnd={this.onDragEnd}>
154
- <Droppable droppableId="droppable">
155
- {(provided, snapshot) => (
156
- <ul
157
- className={classes}
158
- ref={provided.innerRef}
159
- {...provided.droppableProps} >
160
- {this.state.items.map((item, index) => (
161
- <Draggable key={index} draggableId={`${index}`} index={index}>
162
- {(provided2, snapshot2) => (
163
- <div
164
- ref={provided2.innerRef}
165
- {...provided2.draggableProps}
166
- {...provided2.dragHandleProps} >
167
- <TableListItem
168
- dragAndDrop={this.props.dragAndDrop}
169
- start={item.start}
170
- center={item.center}
171
- end={item.end}
172
- action={item.action}
173
- onClick={item.onClick ? item.onClick : false}
174
- addItem={this.props.addItem}
175
- itemsDropdown={this.props.itemsDropdown} />
115
+ this.state.items.length > 0
116
+ ? this.props.dragAndDrop
117
+ ? <DragDropContext onDragEnd={this.onDragEnd}>
118
+ <Droppable droppableId="droppable">
119
+ {(provided, _snapshot) => (
120
+ <div
121
+ role='list'
122
+ className={classes}
123
+ ref={provided.innerRef}
124
+ {...provided.droppableProps} >
125
+ {this.state.items.map((item: IPropsArrayItem, index: number) => (
126
+ <Draggable key={index} draggableId={`${index}`} index={index}>
127
+ {(provided2, snapshot) => (
128
+ this.props.append
129
+ ? <PortalItem
130
+ provided={provided2}
131
+ snapshot={snapshot}
132
+ item={item}
133
+ index={index}
134
+ dragAndDrop={this.props.dragAndDrop}
135
+ showDragHandle={this.props.showDragHandle}
136
+ addItem={this.props.addItem}
137
+ onAddItem={() => this.props.onAddItem
138
+ && this.props.onAddItem(index, item)}
139
+ itemsDropdown={() => this.props.itemsDropdown
140
+ ? this.props.itemsDropdown(index)
141
+ : []}
142
+ />
143
+ : <div
144
+ ref={provided2.innerRef}
145
+ {...provided2.draggableProps}
146
+ {...provided2.dragHandleProps} >
147
+ <TableListItem
148
+ dragAndDrop={this.props.dragAndDrop}
149
+ start={item.start}
150
+ center={item.center}
151
+ end={item.end}
152
+ action={item.action}
153
+ onClick={item.onClick ? item.onClick : undefined}
154
+ onDoubleClick={item.onDoubleClick
155
+ ? item.onDoubleClick
156
+ : undefined}
157
+ addItem={this.props.addItem}
158
+ itemsDropdown={() => this.props.itemsDropdown
159
+ ? this.props.itemsDropdown(index)
160
+ : []}
161
+ hexColor={item.hexColor}
162
+ locked={item.locked}
163
+ positionLocked={item.positionLocked}
164
+ onAddItem={() => this.props.onAddItem
165
+ && this.props.onAddItem(index, item)}
166
+ showDragHandle={this.props.showDragHandle}
167
+ />
168
+ </div>
169
+ )}
170
+ </Draggable>
171
+ ))}
172
+ {provided.placeholder}
173
+ {(this.props.addItem && !this.props.readOnly) &&
174
+ <div className={`table-list__add-item table-list__item--margin`}>
175
+ <Tooltip text='Add item' flow='top' appendToBody={true}>
176
+ <div className='table-list__add-item--container sd-margin-x--auto'>
177
+ {this.dropDown()}
178
+ </div>
179
+ </Tooltip>
176
180
  </div>
177
- )}
178
- </Draggable>
179
- ))}
180
- {provided.placeholder}
181
- </ul>
182
- )}
183
- </Droppable>
184
- </DragDropContext>
185
- : <ul className={classes}>
186
- {this.state.items.map((item, index) => (
187
- <TableListItem
188
- key={index}
189
- start={item.start}
190
- center={item.center}
191
- end={item.end}
192
- action={item.action}
193
- onClick={item.onClick ? item.onClick : false}
194
- addItem={this.props.addItem}
195
- itemsDropdown={this.props.itemsDropdown} />
196
- ))}
197
- </ul>
198
- : this.props.children &&
199
- <ul className={classes}>
200
- {this.props.children}
201
- </ul>
181
+ }
182
+ </div>
183
+ )}
184
+ </Droppable>
185
+ </DragDropContext>
186
+ : <div role='list' className={classes}>
187
+ {this.state.items.map((item: IPropsArrayItem, index: number) => (
188
+ <TableListItem
189
+ key={index}
190
+ start={item.start}
191
+ center={item.center}
192
+ end={item.end}
193
+ action={item.action}
194
+ onClick={item.onClick ? item.onClick : undefined}
195
+ onDoubleClick={item.onDoubleClick
196
+ ? item.onDoubleClick
197
+ : undefined}
198
+ addItem={this.props.addItem}
199
+ itemsDropdown={() => this.props.itemsDropdown ? this.props.itemsDropdown(index) : []}
200
+ hexColor={item.hexColor}
201
+ locked={item.locked}
202
+ positionLocked={item.positionLocked}
203
+ onAddItem={() => this.props.onAddItem
204
+ && this.props.onAddItem(index, item)}
205
+ />
206
+ ))}
207
+ {(this.props.addItem && !this.props.readOnly) &&
208
+ <div className={`table-list__add-item table-list__item--margin`}>
209
+ <Tooltip text='Add item' flow='top' appendToBody={true}>
210
+ <div className='table-list__add-item--container sd-margin-x--auto'>
211
+ {this.dropDown()}
212
+ </div>
213
+ </Tooltip>
214
+ </div>
215
+ }
216
+ </div>
217
+ : (this.props.addItem && !this.props.readOnly) ? <div role='list' className={classes}>
218
+ <div className={`table-list__add-item table-list__item--margin`}>
219
+ <Tooltip text='Add item' flow='top' appendToBody={true}>
220
+ <div className='table-list__add-item--container sd-margin-x--auto'>
221
+ {this.dropDown()}
222
+ </div>
223
+ </Tooltip>
224
+ </div>
225
+ </div>
226
+ : null
227
+ );
228
+ }
229
+ }
230
+
231
+ export interface IPropsItem {
232
+ start?: React.ReactNode;
233
+ center?: React.ReactNode;
234
+ end?: React.ReactNode;
235
+ action?: React.ReactNode;
236
+ addItem?: boolean;
237
+ dragAndDrop?: boolean;
238
+ hexColor?: string;
239
+ showDragHandle?: 'always' | 'onHover' | 'none';
240
+ locked?: boolean;
241
+ positionLocked?: boolean;
242
+ onClick?(): void;
243
+ onDoubleClick?(): void;
244
+ onSelect?(): void;
245
+ onAddItem?(e: number): void;
246
+ itemsDropdown?(index?: number): Array<IMenuItem | ISubmenu | IMenuGroup | 'divider'>;
247
+ }
248
+
249
+ class TableListItem extends React.PureComponent<IPropsItem> {
250
+ private timer: any;
251
+ private delay = 200;
252
+ private prevent = false;
253
+
254
+ onSingleClick = () => {
255
+ this.timer = setTimeout(() => {
256
+ if (!this.prevent) {
257
+ if (this.props.onClick) {
258
+ this.props.onClick();
259
+ }
260
+ }
261
+ }, this.delay);
262
+ }
263
+
264
+ onDoubleClick = () => {
265
+ clearTimeout(this.timer);
266
+ this.prevent = true;
267
+ if (this.props.onDoubleClick) {
268
+ this.props.onDoubleClick();
269
+ }
270
+ setTimeout(() => {
271
+ this.prevent = false;
272
+ }, this.delay);
273
+ }
274
+
275
+ onActionMenuClick = (event: React.MouseEvent<HTMLElement>) => {
276
+ event.preventDefault();
277
+ event.stopPropagation();
278
+ }
279
+
280
+ render() {
281
+
282
+ let classes = classNames('table-list__item', {
283
+ 'table-list__item--clickable': this.props.onClick,
284
+ 'table-list__item--draggable': this.props.dragAndDrop,
285
+ 'table-list__item--locked': this.props.locked,
286
+ 'table-list__item--position-locked': this.props.positionLocked,
287
+ 'table-list__item--drag-handles-always': !this.props.showDragHandle,
288
+ 'table-list__item--drag-handles-none': this.props.showDragHandle === 'none',
289
+ });
290
+
291
+ return (
292
+ this.props.addItem ?
293
+ <div className='table-list__item-container'>
294
+ <div
295
+ role='listitem'
296
+ onClick={() => this.onSingleClick()}
297
+ onDoubleClick={() => this.onDoubleClick()}
298
+ className={classes}>
299
+ <div className='table-list__item-border' style={{ backgroundColor: this.props.hexColor }}></div>
300
+ <div className='table-list__item-content'>
301
+ <div className='table-list__item-content-block'>
302
+ {this.props.start && this.props.start}
303
+ </div>
304
+ <div className='table-list__item-content-block table-list__item-content-block--center'>
305
+ {this.props.center && this.props.center}
306
+ </div>
307
+ <div className='table-list__item-content-block'>
308
+ {this.props.end && this.props.end}
309
+ </div>
310
+ </div>
311
+ {this.props.action && <div className='table-list__slide-in-actions' onClick={this.onActionMenuClick}>
312
+ {this.props.action}
313
+ </div>}
314
+ </div>
315
+ <div className='table-list__add-bar-container'>
316
+ <Tooltip text='Add item' flow='top' appendToBody={true}>
317
+ <div className='table-list__add-bar'>
318
+ <Dropdown
319
+ onChange={this.props.onAddItem}
320
+ items={this.props.itemsDropdown ? this.props.itemsDropdown() : []}>
321
+ <Button
322
+ type="primary"
323
+ icon="plus-large"
324
+ text="Add item"
325
+ size="small"
326
+ shape="round"
327
+ iconOnly={true}
328
+ onClick={() => false}
329
+ />
330
+ </Dropdown>
331
+ </div>
332
+ </Tooltip>
333
+ </div>
334
+ </div>
335
+ : <div
336
+ role='listitem'
337
+ className={`${classes} table-list__item--margin`}
338
+ onClick={() => this.onSingleClick()}
339
+ onDoubleClick={() => this.onDoubleClick()}>
340
+ <div className='table-list__item-border' style={{ backgroundColor: this.props.hexColor }}></div>
341
+ <div className='table-list__item-content'>
342
+ <div className='table-list__item-content-block'>
343
+ {this.props.start && this.props.start}
344
+ </div>
345
+ <div className='table-list__item-content-block table-list__item-content-block--center'>
346
+ {this.props.center && this.props.center}
347
+ </div>
348
+ <div className='table-list__item-content-block'>
349
+ {this.props.end && this.props.end}
350
+ </div>
351
+ </div>
352
+ {this.props.action && <div className='table-list__slide-in-actions' onClick={this.onActionMenuClick}>
353
+ {this.props.action}
354
+ </div>}
355
+ </div>
202
356
  );
203
357
  }
204
358
  }
205
359
 
360
+ class PortalItem extends React.PureComponent {
361
+ props: any;
362
+ render() {
363
+ const provided = this.props.provided;
364
+ const snapshot = this.props.snapshot;
365
+
366
+ const usePortal: boolean = snapshot.isDragging;
367
+
368
+ const child = (
369
+ <div
370
+ ref={provided.innerRef}
371
+ {...provided.draggableProps}
372
+ {...provided.dragHandleProps}>
373
+ <TableListItem
374
+ dragAndDrop={this.props.dragAndDrop}
375
+ start={this.props.item.start}
376
+ center={this.props.item.center}
377
+ end={this.props.item.end}
378
+ action={this.props.item.action}
379
+ onClick={this.props.item.onClick ? this.props.item.onClick : undefined}
380
+ onDoubleClick={this.props.item.onDoubleClick
381
+ ? this.props.item.onDoubleClick
382
+ : undefined}
383
+ addItem={this.props.addItem}
384
+ itemsDropdown={this.props.itemsDropdown}
385
+ hexColor={this.props.item.hexColor}
386
+ locked={this.props.item.locked}
387
+ positionLocked={this.props.item.positionLocked}
388
+ onAddItem={() => this.props.onAddItem}
389
+ showDragHandle={this.props.showDragHandle}
390
+ />
391
+ </div>
392
+ );
393
+
394
+ if (!usePortal) {
395
+ return child;
396
+ }
397
+
398
+ // if dragging - put the item in a portal
399
+ return ReactDOM.createPortal(child, document.body);
400
+ }
401
+ }
402
+
206
403
  export {
207
404
  TableList, TableListItem
208
405
  };
@@ -131,7 +131,7 @@ export class Menu extends React.Component<IProps, {}> {
131
131
 
132
132
  render() {
133
133
  return (
134
- <div>
134
+ <React.Fragment>
135
135
  {
136
136
  this.props.children(this.toggle)
137
137
  }
@@ -167,7 +167,7 @@ export class Menu extends React.Component<IProps, {}> {
167
167
  baseZIndex={this.props.zIndex ?? superdeskTopBarZIndex}
168
168
  />
169
169
  </div>
170
- </div>
170
+ </React.Fragment>
171
171
  );
172
172
  }
173
173
  }