@imposium-hub/components 1.42.0 → 1.42.2
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.
|
@@ -5,6 +5,7 @@ interface IButtonMenuProps {
|
|
|
5
5
|
items : any;
|
|
6
6
|
position : string;
|
|
7
7
|
isOpen ? : boolean;
|
|
8
|
+
onClick ? : (e) => string | void;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
interface IButtonMenuState {
|
|
@@ -15,27 +16,35 @@ class ButtonMenu extends React.PureComponent<IButtonMenuProps, IButtonMenuState>
|
|
|
15
16
|
|
|
16
17
|
private evtHandlers : any;
|
|
17
18
|
private toggleRef : any;
|
|
19
|
+
private menuRef : any;
|
|
18
20
|
|
|
19
21
|
constructor(props) {
|
|
20
22
|
|
|
21
23
|
super(props);
|
|
22
24
|
this.state = {
|
|
23
|
-
open :
|
|
25
|
+
open : false
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
this.evtHandlers = {
|
|
27
29
|
toggleMenu: (e) => this.toggleMenu(e),
|
|
28
|
-
clickOutside: (e) => this.handleClickOutside(e)
|
|
30
|
+
clickOutside: (e, isSelect ? : boolean) => this.handleClickOutside(e, isSelect)
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
this.toggleRef = React.createRef();
|
|
34
|
+
this.menuRef = React.createRef();
|
|
32
35
|
}
|
|
33
36
|
|
|
34
|
-
private handleClickOutside(e) {
|
|
35
|
-
|
|
37
|
+
private handleClickOutside(e, isSelect ? : boolean) {
|
|
36
38
|
const clickOnToggle = (this.toggleRef && this.toggleRef.current && this.toggleRef.current.contains(e.target)) ? true : false;
|
|
39
|
+
const menus = (this.menuRef && this.menuRef.current && this.menuRef.current.contains(e.target)) ? true : false;
|
|
40
|
+
if (!clickOnToggle && !isSelect) {
|
|
41
|
+
document.removeEventListener('click', this.evtHandlers.clickOutside);
|
|
42
|
+
this.setState({
|
|
43
|
+
open: false
|
|
44
|
+
});
|
|
45
|
+
}
|
|
37
46
|
|
|
38
|
-
if (!
|
|
47
|
+
if (isSelect && !menus) {
|
|
39
48
|
document.removeEventListener('click', this.evtHandlers.clickOutside);
|
|
40
49
|
this.setState({
|
|
41
50
|
open: false
|
|
@@ -49,37 +58,39 @@ class ButtonMenu extends React.PureComponent<IButtonMenuProps, IButtonMenuState>
|
|
|
49
58
|
}
|
|
50
59
|
|
|
51
60
|
public toggleMenu(e) {
|
|
52
|
-
|
|
61
|
+
const {onClick} = this.props;
|
|
53
62
|
const newState = !this.state.open;
|
|
54
|
-
|
|
63
|
+
if (onClick) {
|
|
64
|
+
onClick(newState);
|
|
65
|
+
}
|
|
55
66
|
this.setState({
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
open : newState
|
|
68
|
+
}, () => {
|
|
69
|
+
if (this.state.open) {
|
|
70
|
+
document.addEventListener('click',
|
|
71
|
+
(evt) => this.evtHandlers.clickOutside(evt, onClick ? true : undefined)
|
|
72
|
+
);
|
|
73
|
+
} else {
|
|
74
|
+
document.removeEventListener('click', this.evtHandlers.clickOutside);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
64
77
|
}
|
|
65
78
|
|
|
66
79
|
public renderItems() {
|
|
67
80
|
|
|
68
|
-
const {items} = this.props;
|
|
81
|
+
const {items, isOpen} = this.props;
|
|
69
82
|
const newItems = [];
|
|
70
83
|
for (const item of items) {
|
|
71
84
|
|
|
72
85
|
// clone the menu items passed in, close the modal before calling onClick on each item
|
|
73
86
|
const newItem = React.cloneElement(item, {
|
|
74
87
|
onClick: (e) => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
document.removeEventListener('click', this.evtHandlers.clickOutside);
|
|
88
|
+
if (!this.props.isOpen) {
|
|
89
|
+
document.removeEventListener('click', this.evtHandlers.clickOutside);
|
|
90
|
+
}
|
|
80
91
|
|
|
81
92
|
this.setState({
|
|
82
|
-
open: false
|
|
93
|
+
open: isOpen ? isOpen : false
|
|
83
94
|
}, () => {
|
|
84
95
|
item.props.onClick(e);
|
|
85
96
|
});
|
|
@@ -114,7 +125,7 @@ class ButtonMenu extends React.PureComponent<IButtonMenuProps, IButtonMenuState>
|
|
|
114
125
|
active: open
|
|
115
126
|
});
|
|
116
127
|
|
|
117
|
-
return <div className = 'button-menu'>
|
|
128
|
+
return <div ref={this.menuRef} className = 'button-menu'>
|
|
118
129
|
{ trigger }
|
|
119
130
|
{ this.renderMenu() }
|
|
120
131
|
</div>;
|
|
@@ -103,20 +103,11 @@ class PublishWizard extends React.PureComponent<IPublishWizardProps, IPublishWiz
|
|
|
103
103
|
// Pull in all of the access creds for the composition dropdown
|
|
104
104
|
api.getAssets({type: ASSET_TYPES.VIDEO_COMPOSITION}, story.id).then((res) => {
|
|
105
105
|
const firstCompId = (res.assets[0]) ? res.assets[0].id : null;
|
|
106
|
+
const compId = (activeComposition) ? activeComposition : firstCompId;
|
|
106
107
|
this.setState({
|
|
107
108
|
compositions: res.assets,
|
|
108
|
-
selectedComposition:
|
|
109
|
+
selectedComposition: compId
|
|
109
110
|
});
|
|
110
|
-
if (res.assets.length > 0) {
|
|
111
|
-
const comp = res.assets[0];
|
|
112
|
-
const composition = {
|
|
113
|
-
value: comp.id,
|
|
114
|
-
label: comp.name
|
|
115
|
-
};
|
|
116
|
-
this.setState({
|
|
117
|
-
selectedComposition: composition
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
111
|
}).catch((credsError) => {
|
|
121
112
|
handleError(copy.integration.errorPullingComps);
|
|
122
113
|
});
|
package/components/tabs/Tabs.tsx
CHANGED
|
@@ -13,6 +13,7 @@ interface ITab {
|
|
|
13
13
|
canClose? : boolean;
|
|
14
14
|
resize? : boolean;
|
|
15
15
|
label : any;
|
|
16
|
+
menuButtons : JSX.Element;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
interface ITabsProps {
|
|
@@ -28,6 +29,7 @@ interface ITabsProps {
|
|
|
28
29
|
|
|
29
30
|
interface ITabsState {
|
|
30
31
|
allowableTabsInView : number | null;
|
|
32
|
+
isMenuOpen : boolean;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
class Tabs extends React.PureComponent<ITabsProps, ITabsState> {
|
|
@@ -41,7 +43,8 @@ class Tabs extends React.PureComponent<ITabsProps, ITabsState> {
|
|
|
41
43
|
this.headerRef = React.createRef();
|
|
42
44
|
|
|
43
45
|
this.state = {
|
|
44
|
-
allowableTabsInView: 0
|
|
46
|
+
allowableTabsInView: 0,
|
|
47
|
+
isMenuOpen: false,
|
|
45
48
|
};
|
|
46
49
|
|
|
47
50
|
}
|
|
@@ -72,18 +75,10 @@ class Tabs extends React.PureComponent<ITabsProps, ITabsState> {
|
|
|
72
75
|
for (let i = 0; i < options.length; i++) {
|
|
73
76
|
|
|
74
77
|
const option = options[i];
|
|
75
|
-
|
|
78
|
+
const buttonWidth = option.canClose || option.menuButtons ? 20 : 0;
|
|
76
79
|
let div = document.createElement('div');
|
|
77
80
|
div.className = 'tab-header-option';
|
|
78
|
-
|
|
79
|
-
// check typeof label
|
|
80
|
-
if (typeof option.label !== 'string') {
|
|
81
|
-
// set label
|
|
82
|
-
div.innerHTML = option.label.props.children[0];
|
|
83
|
-
buttonWidth = 20;
|
|
84
|
-
} else {
|
|
85
|
-
div.innerHTML = option.label;
|
|
86
|
-
}
|
|
81
|
+
div.innerHTML = option.label;
|
|
87
82
|
container.appendChild(div);
|
|
88
83
|
totalTabWidths += div.offsetWidth + buttonWidth;
|
|
89
84
|
container.removeChild(div);
|
|
@@ -144,7 +139,7 @@ class Tabs extends React.PureComponent<ITabsProps, ITabsState> {
|
|
|
144
139
|
|
|
145
140
|
for (let i = 0; i < options.length; i++) {
|
|
146
141
|
|
|
147
|
-
const {canClose, key, label} = options[i];
|
|
142
|
+
const {canClose, key, label, menuButtons} = options[i];
|
|
148
143
|
const btnClose = (canClose) ?
|
|
149
144
|
<Button
|
|
150
145
|
style = 'subtle'
|
|
@@ -155,24 +150,30 @@ class Tabs extends React.PureComponent<ITabsProps, ITabsState> {
|
|
|
155
150
|
this.props.onClose(key); }}>
|
|
156
151
|
{ICON_TIMES}</Button> : null;
|
|
157
152
|
|
|
153
|
+
const buttonMenus = menuButtons ?
|
|
154
|
+
menuButtons
|
|
155
|
+
:
|
|
156
|
+
null;
|
|
157
|
+
|
|
158
158
|
const activeClass = (key === activeTab) ? 'active' : '';
|
|
159
159
|
|
|
160
160
|
if (i < this.state.allowableTabsInView ) {
|
|
161
161
|
headerOptions.push(
|
|
162
162
|
<div className = {`tab-header-option ${activeClass}`}
|
|
163
163
|
onClick = {() => this.props.onChange(key)}
|
|
164
|
-
key = {key}>{label}{btnClose}</div>
|
|
164
|
+
key = {key}>{label}{btnClose}{buttonMenus}</div>
|
|
165
165
|
);
|
|
166
166
|
} else {
|
|
167
167
|
if (activeTab === key && !activeTabInMenu) {
|
|
168
168
|
activeTabInMenu = true;
|
|
169
169
|
}
|
|
170
|
-
|
|
171
170
|
menuOptions.push(
|
|
172
171
|
<ButtonMenuItem
|
|
173
172
|
key = {key}
|
|
174
|
-
label = {<span>{label}{btnClose}</span>}
|
|
175
|
-
onClick = {() =>
|
|
173
|
+
label = {<span>{label}{btnClose}{buttonMenus}</span>}
|
|
174
|
+
onClick = {(e) => {
|
|
175
|
+
this.props.onChange(key);
|
|
176
|
+
}}
|
|
176
177
|
active = {activeTab === key}
|
|
177
178
|
/>
|
|
178
179
|
);
|
|
@@ -189,6 +190,12 @@ class Tabs extends React.PureComponent<ITabsProps, ITabsState> {
|
|
|
189
190
|
<ButtonMenu
|
|
190
191
|
position = 'left'
|
|
191
192
|
items = {menuOptions}
|
|
193
|
+
onClick={(open) => {
|
|
194
|
+
this.setState(
|
|
195
|
+
{isMenuOpen: open}
|
|
196
|
+
);
|
|
197
|
+
}}
|
|
198
|
+
isOpen={this.state.isMenuOpen}
|
|
192
199
|
button = {btnOpenMenu}
|
|
193
200
|
/>
|
|
194
201
|
</span>
|