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.
- package/app/fonts/sd_icons.eot +0 -0
- package/app/fonts/sd_icons.svg +14 -7
- package/app/fonts/sd_icons.ttf +0 -0
- package/app/fonts/sd_icons.woff +0 -0
- package/app/scripts/toggleBoxNext.js +1 -1
- package/app/styles/_big-icon-font.scss +1 -1
- package/app/styles/_buttons.scss +11 -6
- package/app/styles/_content-divider.scss +63 -8
- package/app/styles/_helpers.scss +24 -1
- package/app/styles/_icon-font.scss +17 -10
- package/app/styles/_labels.scss +0 -1
- package/app/styles/_master-desk.scss +3 -2
- package/app/styles/_modals.scss +6 -3
- package/app/styles/_normalize.scss +4 -0
- package/app/styles/_sd-tag-input.scss +256 -296
- package/app/styles/_simple-list.scss +0 -2
- package/app/styles/_table-list.scss +116 -12
- package/app/styles/app.scss +1 -0
- package/app/styles/components/_list-item.scss +36 -17
- package/app/styles/components/_sd-collapse-box.scss +6 -6
- package/app/styles/components/_sd-comment-box.scss +8 -4
- package/app/styles/components/_sd-editor-popup.scss +4 -4
- package/app/styles/components/_sd-grid-item.scss +30 -16
- package/app/styles/components/_sd-media-carousel.scss +37 -2
- package/app/styles/components/_sd-photo-preview.scss +3 -3
- package/app/styles/components/_sd-searchbar.scss +7 -0
- package/app/styles/components/_subnav.scss +470 -470
- package/app/styles/design-tokens/_design-tokens-general.scss +1 -1
- package/app/styles/design-tokens/_new-colors.scss +30 -13
- package/app/styles/dropdowns/_basic-dropdown.scss +6 -0
- package/app/styles/form-elements/_forms-general.scss +81 -7
- package/app/styles/form-elements/_input-wrap.scss +138 -0
- package/app/styles/form-elements/_inputs.scss +368 -110
- package/app/styles/grids/_grid-layout.scss +34 -1
- package/app/styles/interface-elements/_side-panel.scss +1 -1
- package/app/styles/layout/_basic-layout.scss +2 -2
- package/app/styles/layout/_editor.scss +10 -4
- package/app/styles/primereact/_pr-datepicker.scss +4 -2
- package/app/styles/primereact/_pr-dialog.scss +5 -0
- package/app/styles/primereact/_pr-dropdown.scss +17 -1
- package/app/styles/primereact/_pr-menu.scss +6 -5
- package/app/styles/variables/_colors.scss +21 -21
- package/app-typescript/components/Badge.tsx +3 -2
- package/app-typescript/components/ContentDivider.tsx +3 -0
- package/app-typescript/components/DatePicker.tsx +40 -52
- package/app-typescript/components/Dropdown.tsx +127 -82
- package/app-typescript/components/DurationInput.tsx +400 -0
- package/app-typescript/components/EmptyState.tsx +2 -1
- package/app-typescript/components/Form/FormLabel.tsx +8 -1
- package/app-typescript/components/Form/FormRowNew.tsx +41 -0
- package/app-typescript/components/Form/InputBase.tsx +95 -0
- package/app-typescript/components/Form/InputNew.tsx +107 -0
- package/app-typescript/components/Form/InputWrapper.tsx +79 -0
- package/app-typescript/components/Form/index.tsx +4 -0
- package/app-typescript/components/Input.tsx +28 -45
- package/app-typescript/components/Label.tsx +65 -10
- package/app-typescript/components/Layouts/AuthoringContainer.tsx +2 -1
- package/app-typescript/components/Layouts/AuthoringFrame.tsx +2 -1
- package/app-typescript/components/Layouts/AuthoringFrameRightBar.tsx +21 -2
- package/app-typescript/components/Layouts/AuthoringInnerHeader.tsx +1 -1
- package/app-typescript/components/Layouts/AuthoringMain.tsx +4 -2
- package/app-typescript/components/Layouts/CoreLayout.tsx +2 -1
- package/app-typescript/components/Layouts/CoreLayoutMain.tsx +7 -1
- package/app-typescript/components/Layouts/Layout.tsx +1 -1
- package/app-typescript/components/LeftMenu.tsx +127 -122
- package/app-typescript/components/Lists/ContentList.tsx +66 -33
- package/app-typescript/components/Lists/TableList.tsx +348 -151
- package/app-typescript/components/Menu.tsx +2 -2
- package/app-typescript/components/MultiSelect.tsx +37 -50
- package/app-typescript/components/NavButton.tsx +2 -1
- package/app-typescript/components/Navigation/BottomNav.tsx +3 -2
- package/app-typescript/components/SearchBar.tsx +39 -12
- package/app-typescript/components/Select.tsx +23 -41
- package/app-typescript/components/SelectWithTemplate.tsx +32 -7
- package/app-typescript/components/Spacer.tsx +87 -0
- package/app-typescript/components/TimePicker.tsx +38 -15
- package/app-typescript/components/TreeSelect.tsx +546 -212
- package/app-typescript/index.ts +6 -1
- package/dist/examples.bundle.css +344 -71
- package/dist/examples.bundle.js +48203 -45174
- package/dist/playgrounds/react-playgrounds/CoreLayout.tsx +65 -54
- package/dist/playgrounds/react-playgrounds/Index.tsx +1 -0
- package/dist/playgrounds/react-playgrounds/Multiedit.tsx +321 -0
- package/dist/playgrounds/react-playgrounds/RundownEditor.tsx +26 -23
- package/dist/playgrounds/react-playgrounds/Rundowns.tsx +20 -21
- package/dist/playgrounds/react-playgrounds/SamsPlayground.tsx +12 -3
- package/dist/playgrounds/react-playgrounds/TestGround.tsx +379 -25
- package/dist/playgrounds/react-playgrounds/components/Layout.tsx +1 -1
- package/dist/react/Badges.tsx +18 -0
- package/dist/react/ContentDivider.tsx +22 -18
- package/dist/react/ContentList.tsx +200 -18
- package/dist/react/DatePicker.tsx +21 -1
- package/dist/react/Dropdowns.tsx +580 -48
- package/dist/react/DurationInput.tsx +108 -0
- package/dist/react/Index.tsx +5 -0
- package/dist/react/Inputs.tsx +147 -2
- package/dist/react/Labels.tsx +51 -1
- package/dist/react/LeftNavigations.tsx +71 -44
- package/dist/react/MultiSelect.tsx +10 -7
- package/dist/react/NavButtons.tsx +31 -1
- package/dist/react/SelectWithTemplate.tsx +6 -1
- package/dist/react/TableList.tsx +79 -186
- package/dist/react/TimePicker.tsx +22 -12
- package/dist/react/Togglebox.tsx +1 -1
- package/dist/react/TreeSelect.tsx +295 -51
- package/dist/react/tree-select/TreeSelect.tsx +273 -0
- package/dist/react/tree-select/example-1.tsx +71 -0
- package/dist/react/tree-select/example-2.tsx +59 -0
- package/dist/sd_icons.eot +0 -0
- package/dist/sd_icons.svg +14 -7
- package/dist/sd_icons.ttf +0 -0
- package/dist/sd_icons.woff +0 -0
- package/dist/superdesk-ui.bundle.css +2282 -782
- package/dist/superdesk-ui.bundle.js +37312 -21800
- package/dist/vendor.bundle.js +27 -27
- package/examples/css/docs-page.css +4 -4
- package/examples/index.js +4 -0
- package/examples/pages/playgrounds/react-playgrounds/CoreLayout.tsx +65 -54
- package/examples/pages/playgrounds/react-playgrounds/Index.tsx +1 -0
- package/examples/pages/playgrounds/react-playgrounds/Multiedit.tsx +321 -0
- package/examples/pages/playgrounds/react-playgrounds/RundownEditor.tsx +26 -23
- package/examples/pages/playgrounds/react-playgrounds/Rundowns.tsx +20 -21
- package/examples/pages/playgrounds/react-playgrounds/SamsPlayground.tsx +12 -3
- package/examples/pages/playgrounds/react-playgrounds/TestGround.tsx +379 -25
- package/examples/pages/playgrounds/react-playgrounds/components/Layout.tsx +1 -1
- package/examples/pages/react/Badges.tsx +18 -0
- package/examples/pages/react/ContentDivider.tsx +22 -18
- package/examples/pages/react/ContentList.tsx +200 -18
- package/examples/pages/react/DatePicker.tsx +21 -1
- package/examples/pages/react/Dropdowns.tsx +580 -48
- package/examples/pages/react/DurationInput.tsx +108 -0
- package/examples/pages/react/Index.tsx +5 -0
- package/examples/pages/react/Inputs.tsx +147 -2
- package/examples/pages/react/Labels.tsx +51 -1
- package/examples/pages/react/LeftNavigations.tsx +71 -44
- package/examples/pages/react/MultiSelect.tsx +10 -7
- package/examples/pages/react/NavButtons.tsx +31 -1
- package/examples/pages/react/SelectWithTemplate.tsx +6 -1
- package/examples/pages/react/TableList.tsx +79 -186
- package/examples/pages/react/TimePicker.tsx +22 -12
- package/examples/pages/react/Togglebox.tsx +1 -1
- package/examples/pages/react/TreeSelect.tsx +295 -51
- package/examples/pages/react/tree-select/TreeSelect.tsx +273 -0
- package/examples/pages/react/tree-select/example-1.tsx +71 -0
- package/examples/pages/react/tree-select/example-2.tsx +59 -0
- package/package.json +5 -5
- package/react/components/Badge.d.ts +1 -0
- package/react/components/Badge.js +2 -2
- package/react/components/ContentDivider.d.ts +1 -0
- package/react/components/ContentDivider.js +2 -0
- package/react/components/DatePicker.d.ts +1 -0
- package/react/components/DatePicker.js +6 -22
- package/react/components/Dropdown.d.ts +6 -5
- package/react/components/Dropdown.js +57 -30
- package/react/components/DurationInput.d.ts +42 -0
- package/react/components/DurationInput.js +364 -0
- package/react/components/EmptyState.d.ts +1 -0
- package/react/components/EmptyState.js +1 -1
- package/react/components/Form/FormLabel.d.ts +4 -1
- package/react/components/Form/FormLabel.js +9 -3
- package/react/components/Form/FormRowNew.d.ts +12 -0
- package/react/components/Form/FormRowNew.js +67 -0
- package/react/components/Form/InputBase.d.ts +41 -0
- package/react/components/Form/InputBase.js +86 -0
- package/react/components/Form/InputNew.d.ts +45 -0
- package/react/components/Form/InputNew.js +75 -0
- package/react/components/Form/InputWrapper.d.ts +28 -0
- package/react/components/Form/InputWrapper.js +91 -0
- package/react/components/Form/index.d.ts +4 -0
- package/react/components/Form/index.js +9 -1
- package/react/components/Input.js +5 -34
- package/react/components/Label.d.ts +2 -0
- package/react/components/Label.js +34 -3
- package/react/components/Layouts/AuthoringContainer.d.ts +1 -0
- package/react/components/Layouts/AuthoringContainer.js +1 -1
- package/react/components/Layouts/AuthoringFrame.d.ts +1 -0
- package/react/components/Layouts/AuthoringFrame.js +1 -1
- package/react/components/Layouts/AuthoringFrameRightBar.d.ts +9 -2
- package/react/components/Layouts/AuthoringFrameRightBar.js +14 -3
- package/react/components/Layouts/AuthoringInnerHeader.js +1 -1
- package/react/components/Layouts/AuthoringMain.js +1 -1
- package/react/components/Layouts/CoreLayout.d.ts +1 -0
- package/react/components/Layouts/CoreLayout.js +1 -1
- package/react/components/Layouts/CoreLayoutMain.d.ts +1 -0
- package/react/components/Layouts/CoreLayoutMain.js +8 -1
- package/react/components/Layouts/Layout.js +1 -1
- package/react/components/LeftMenu.d.ts +3 -1
- package/react/components/LeftMenu.js +8 -1
- package/react/components/Lists/ContentList.d.ts +51 -0
- package/react/components/Lists/ContentList.js +110 -0
- package/react/components/Lists/TableList.d.ts +64 -0
- package/react/components/Lists/TableList.js +240 -0
- package/react/components/Menu.js +1 -1
- package/react/components/MultiSelect.d.ts +40 -0
- package/react/components/MultiSelect.js +70 -0
- package/react/components/NavButton.d.ts +1 -1
- package/react/components/Navigation/BottomNav.d.ts +1 -0
- package/react/components/Navigation/BottomNav.js +2 -2
- package/react/components/SearchBar.d.ts +3 -2
- package/react/components/SearchBar.js +28 -4
- package/react/components/Select.d.ts +1 -1
- package/react/components/Select.js +4 -26
- package/react/components/SelectWithTemplate.d.ts +11 -1
- package/react/components/SelectWithTemplate.js +19 -10
- package/react/components/TimePicker.d.ts +11 -1
- package/react/components/TimePicker.js +10 -3
- package/react/components/TreeSelect.d.ts +82 -0
- package/react/components/TreeSelect.js +521 -0
- package/react/index.d.ts +6 -0
- package/react/index.js +16 -3
- package/.vscode/settings.json +0 -5
- package/app-typescript/dist/components/Alert.d.ts +0 -16
- package/app-typescript/dist/components/Autocomplete.d.ts +0 -48
- package/app-typescript/dist/components/Avatar.d.ts +0 -33
- package/app-typescript/dist/components/Badge.d.ts +0 -13
- package/app-typescript/dist/components/Button.d.ts +0 -23
- package/app-typescript/dist/components/ButtonGroup.d.ts +0 -12
- package/app-typescript/dist/components/CheckButtonGroup.d.ts +0 -11
- package/app-typescript/dist/components/CheckGroup.d.ts +0 -9
- package/app-typescript/dist/components/Checkbox.d.ts +0 -19
- package/app-typescript/dist/components/CheckboxButton.d.ts +0 -19
- package/app-typescript/dist/components/DatePicker.d.ts +0 -37
- package/app-typescript/dist/components/Divider.d.ts +0 -9
- package/app-typescript/dist/components/DonutChart.d.ts +0 -12
- package/app-typescript/dist/components/Dropdown.d.ts +0 -28
- package/app-typescript/dist/components/DropdownFirst.d.ts +0 -42
- package/app-typescript/dist/components/EmptyState.d.ts +0 -11
- package/app-typescript/dist/components/FormLabel.d.ts +0 -9
- package/app-typescript/dist/components/Genie.d.ts +0 -13
- package/app-typescript/dist/components/GridItem.d.ts +0 -69
- package/app-typescript/dist/components/GridList.d.ts +0 -14
- package/app-typescript/dist/components/HeadingText.d.ts +0 -10
- package/app-typescript/dist/components/HelloWorld.d.ts +0 -8
- package/app-typescript/dist/components/Icon.d.ts +0 -12
- package/app-typescript/dist/components/IconButton.d.ts +0 -12
- package/app-typescript/dist/components/IconLabel.d.ts +0 -11
- package/app-typescript/dist/components/Input.d.ts +0 -24
- package/app-typescript/dist/components/Label.d.ts +0 -15
- package/app-typescript/dist/components/LeftMenu.d.ts +0 -26
- package/app-typescript/dist/components/Loader.d.ts +0 -8
- package/app-typescript/dist/components/NavButton.d.ts +0 -15
- package/app-typescript/dist/components/Popover.d.ts +0 -13
- package/app-typescript/dist/components/PropsList.d.ts +0 -15
- package/app-typescript/dist/components/Radio.d.ts +0 -19
- package/app-typescript/dist/components/RadioButton.d.ts +0 -20
- package/app-typescript/dist/components/Select.d.ts +0 -29
- package/app-typescript/dist/components/SelectWithTemplate.d.ts +0 -32
- package/app-typescript/dist/components/SlidingToolbar.d.ts +0 -8
- package/app-typescript/dist/components/StrechBar.d.ts +0 -4
- package/app-typescript/dist/components/SubNav.d.ts +0 -10
- package/app-typescript/dist/components/Switch.d.ts +0 -12
- package/app-typescript/dist/components/TabCustom.d.ts +0 -25
- package/app-typescript/dist/components/TabList.d.ts +0 -22
- package/app-typescript/dist/components/Tag.d.ts +0 -9
- package/app-typescript/dist/components/TagInput.d.ts +0 -7
- package/app-typescript/dist/components/TagInputTest.d.ts +0 -18
- package/app-typescript/dist/components/TimePicker.d.ts +0 -11
- package/app-typescript/dist/components/Tooltip.d.ts +0 -11
- package/app-typescript/dist/components/_Positioner.d.ts +0 -27
- package/app-typescript/dist/index.d.ts +0 -56
- package/patches/@superdesk+primereact+5.0.2-4.patch +0 -57
- 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
|
9
|
-
|
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
|
-
|
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
|
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
|
-
|
101
|
-
|
102
|
-
|
103
|
-
result.splice(endIndex, 0, removed);
|
34
|
+
interface IState {
|
35
|
+
items: Array<IPropsArrayItem>;
|
36
|
+
}
|
104
37
|
|
105
|
-
|
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,
|
109
|
-
constructor(props) {
|
46
|
+
class TableList extends React.PureComponent<IProps, IState> {
|
47
|
+
constructor(props: IProps) {
|
110
48
|
super(props);
|
111
49
|
this.state = {
|
112
|
-
|
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
|
-
|
58
|
+
if (this.props.array) {
|
59
|
+
this.setState({ items: this.props.array });
|
60
|
+
}
|
120
61
|
}
|
121
62
|
|
122
|
-
componentDidUpdate(prevProps:
|
123
|
-
if (
|
124
|
-
this.
|
125
|
-
|
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'
|
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.
|
152
|
-
this.props.dragAndDrop
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
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
|
-
</
|
179
|
-
)
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
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
|
-
<
|
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
|
-
</
|
170
|
+
</React.Fragment>
|
171
171
|
);
|
172
172
|
}
|
173
173
|
}
|