Skip to content

Commit 8f1b35e

Browse files
Merge branch 'master' of github.com:salesforce-ux/design-system-react
# Conflicts: # package.json
2 parents 8688d9a + 0c85068 commit 8f1b35e

File tree

19 files changed

+387
-101
lines changed

19 files changed

+387
-101
lines changed

components/date-picker/index.jsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1111

1212
import React from 'react';
1313
import ReactDOM from 'react-dom';
14-
import Popover from '../popover';
14+
import Dialog from '../utilities/dialog';
1515
import DatePicker from './date-picker-base/index';
1616
import InputIcon from '../icon/input-icon';
1717

1818
// This component's `checkProps` which issues warnings to developers about properties
1919
// when in development mode (similar to React's built in development tools)
2020
import checkProps from './check-props';
2121

22-
import {KEYS,EventUtil} from '../../utilities';
22+
import EventUtil from '../../utilities/EventUtil';
23+
import KEYS from '../../utilities/KEYS';
2324

2425
import { DATEPICKER } from '../../utilities/constants';
2526

@@ -173,18 +174,18 @@ module.exports = React.createClass({
173174
);
174175
},
175176

176-
getSeparateMenu() {
177+
getDialog() {
177178
return (
178179
!this.props.disabled && this.state.isOpen?
179-
<Popover
180+
<Dialog
180181
closeOnTabKey={true}
181182
constrainToScrollParent={this.props.constrainToScrollParent}
182183
inheritTargetWidth={this.props.inheritTargetWidth}
183184
flippable={true}
184185
onClose={this.handleClose}
185186
targetElement={this.refs.date}>
186187
{this.getDatePicker()}
187-
</Popover>:null
188+
</Dialog>:null
188189
);
189190
},
190191

@@ -282,7 +283,7 @@ module.exports = React.createClass({
282283
/>
283284
</div>
284285
</div>
285-
{isInline ? this.getInlineMenu() : this.getSeparateMenu()}
286+
{isInline ? this.getInlineMenu() : this.getDialog()}
286287
</div>
287288
);
288289
}

components/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ export InputIcon from './icon/input-icon';
9696
export SLDSLookup from './lookup';
9797
export Lookup from './lookup';
9898

99+
export SLDSMediaObject from './media-object';
100+
export MediaObject from './media-object';
101+
99102
export SLDSMenuDropdown from './menu-dropdown';
100103
export Dropdown from './menu-dropdown';
101104

components/lookup/index.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ import escapeRegExp from 'lodash.escaperegexp';
2525
import checkProps from './check-props';
2626

2727
// Children
28-
import Popover from '../popover';
28+
import Dialog from '../utilities/dialog';
2929
import Button from '../button';
3030
import Icon from '../icon';
3131
import InputIcon from '../icon/input-icon';
3232
import Input from '../forms/input';
3333

3434
// ### Event Helpers
35-
import { KEYS, EventUtil } from '../../utilities';
35+
import EventUtil from '../../utilities/EventUtil';
36+
import KEYS from '../../utilities/KEYS';
3637

3738
import Menu from './menu';
3839
import DefaultFooter from './menu/default-footer';
@@ -473,9 +474,10 @@ class Lookup extends React.Component {
473474
renderSeparateMenu() {
474475
return (
475476
this.state.isOpen ?
476-
<Popover
477+
<Dialog
477478
className="slds-lookup__menu slds-show"
478479
closeOnTabKey={true}
480+
contentsClassName='slds-lookup__menu slds-show'
479481
inheritTargetWidth={true}
480482
onClose={this.handleCancel.bind(this)}
481483
flippable={this.props.flippable}
@@ -484,7 +486,7 @@ class Lookup extends React.Component {
484486
verticalAlign="bottom"
485487
>
486488
{this.renderMenuContent()}
487-
</Popover> : null
489+
</Dialog> : null
488490
);
489491
}
490492

components/media-object/index.jsx

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Neither the name of salesforce.com, inc. nor the names of its contributors may b
88
99
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1010
*/
11-
/* eslint-disable indent */
1211

1312
// ### React
1413
// React is an external dependency of the project.
@@ -33,7 +32,7 @@ export const cssClasses = {
3332
};
3433

3534
/**
36-
* A media object should be used when text and a figure next to each other is needed.
35+
* When you need text and a figure next to each other, use a media object.
3736
*/
3837
const MediaObject = React.createClass({
3938
// ### Display Name
@@ -42,11 +41,11 @@ const MediaObject = React.createClass({
4241
// ### Prop Types
4342
propTypes: {
4443
/**
45-
* Allows truncation in nested flexbox containers. Often the body may need to be truncated.
44+
* Often the body may need to be truncated for correct layout. This is only applicable if using the component within a flexbox container.
4645
*/
4746
canTruncate: PropTypes.bool,
4847
/**
49-
* Class names to be added to the Media Object.
48+
* Class names to be added to the component's HTML tag with `slds-media` class.
5049
*/
5150
className: PropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.string]),
5251
/**
@@ -63,35 +62,24 @@ const MediaObject = React.createClass({
6362
verticalCenter: PropTypes.bool
6463
},
6564

66-
_renderMediaFigure () {
67-
// icon should be size small
68-
return (
69-
<div className={cssClasses.figure}>
70-
{this.props.figure}
71-
</div>
72-
);
73-
},
74-
7565
render () {
76-
let mediaFigure = null;
77-
if (this.props.figure) {
78-
mediaFigure = this._renderMediaFigure();
79-
}
80-
8166
return (
82-
<div className={
67+
<div
68+
className={
8369
classnames(
8470
cssClasses.base,
8571
{
8672
'slds-media--center': this.props.verticalCenter,
8773
'slds-has-flexi-truncate': this.props.canTruncate
88-
}, this.props.className)}>
89-
{mediaFigure}
74+
}, this.props.className)}
75+
>
76+
{this.props.figure ? <div className={cssClasses.figure}>
77+
{this.props.figure} </div> : null}
9078
<div className={cssClasses.body}>
9179
{this.props.body}
9280
</div>
9381
</div>
94-
)
82+
);
9583
}
9684
});
9785

components/menu-dropdown/button-trigger.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const Trigger = React.createClass({
6464
*/
6565
isOpen: PropTypes.bool,
6666
/**
67-
* The dropdown menu which is typically a `Popover` component.
67+
* By Default the dropdown menu is inside a `Dialog` component.
6868
*/
6969
menu: PropTypes.node,
7070
/**

components/menu-dropdown/menu-dropdown.jsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import isFunction from 'lodash.isfunction';
3434
import shortid from 'shortid';
3535

3636
// ### Children
37-
import Popover from '../popover';
37+
import Dialog from '../utilities/dialog';
3838
import List from '../menu-list/list';
3939
import ListItem from '../menu-list/list-item';
4040
import ListItemLabel from '../menu-list/list-item-label';
@@ -51,7 +51,8 @@ import checkProps from './check-props';
5151
// #### KeyboardNavigable
5252
import KeyboardNavigable from '../../utilities/keyboard-navigable';
5353

54-
import { KEYS, EventUtil } from '../../utilities';
54+
import EventUtil from '../../utilities/EventUtil';
55+
import KEYS from '../../utilities/KEYS';
5556
import { MENU_DROPDOWN, MENU_DROPDOWN_TRIGGER, LIST } from '../../utilities/constants';
5657

5758
// The overlay is an optional way to allow the dropdown to close on outside
@@ -128,9 +129,13 @@ const MenuDropdown = React.createClass({
128129
*/
129130
children: PropTypes.node,
130131
/**
131-
* CSS classes to be added to dropdown menu container. By default, It will be added to the `Popover` component.
132+
* CSS classes to be added to dropdown menu.
132133
*/
133134
className: PropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.string]),
135+
/**
136+
* By default, these class names will be added to the absolutely-positioned `Dialog` component.
137+
*/
138+
containerClassName: PropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.string]),
134139
/**
135140
* This prop is passed onto the triggering `Button`. Prevent dropdown menu from opening. Also applies disabled styling to trigger button.
136141
*/
@@ -310,6 +315,9 @@ const MenuDropdown = React.createClass({
310315
},
311316

312317
componentWillUnmount () {
318+
if (currentOpenDropdown === this) {
319+
currentOpenDropdown = undefined;
320+
}
313321
this.isUnmounting = true;
314322
this.renderOverlay(false);
315323
},
@@ -631,7 +639,7 @@ const MenuDropdown = React.createClass({
631639
);
632640
},
633641

634-
renderSeparatedMenu (customContent, isOpen, outsideClickIgnoreClass) {
642+
renderDialog (customContent, isOpen, outsideClickIgnoreClass) {
635643
let positionClassName;
636644
let marginTop;
637645
let offset = this.props.offset;
@@ -653,13 +661,14 @@ const MenuDropdown = React.createClass({
653661

654662
return (
655663
isOpen ?
656-
<Popover
657-
className={classNames('slds-dropdown',
664+
<Dialog
665+
className={classNames(this.props.containerClassName)}
666+
closeOnTabKey
667+
constrainToScrollParent={this.props.constrainToScrollParent}
668+
contentsClassName={classNames('slds-dropdown',
658669
'ignore-react-onclickoutside',
659670
positionClassName,
660671
this.props.className)}
661-
closeOnTabKey
662-
constrainToScrollParent={this.props.constrainToScrollParent}
663672
flippable={!this.props.hasStaticAlignment}
664673
horizontalAlign={this.props.align}
665674
inheritTargetWidth={this.props.inheritTargetWidth}
@@ -674,8 +683,7 @@ const MenuDropdown = React.createClass({
674683
targetElement={this.triggerContainer}
675684
>
676685
{this.renderMenuContent(customContent)}
677-
</Popover> : null
678-
);
686+
</Dialog> : null );
679687
},
680688

681689
renderOverlay (isOpen) {
@@ -778,7 +786,7 @@ const MenuDropdown = React.createClass({
778786
triggerRef={this.saveRefToTrigger}
779787
menu={isInline ?
780788
this.renderInlineMenu(customContent, isOpen) :
781-
this.renderSeparatedMenu(customContent, isOpen, outsideClickIgnoreClass)
789+
this.renderDialog(customContent, isOpen, outsideClickIgnoreClass)
782790
}
783791
/>
784792
);

components/menu-list/list-item.jsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,23 +147,18 @@ const ListItem = React.createClass({
147147
{
148148
'slds-has-divider--top-space': this.props.divider === 'top',
149149
'slds-has-divider--bottom-space': this.props.divider === 'bottom'
150-
},
151-
this.props.className
150+
}
152151
)}
153152
onMouseDown={this.handleMouseDown}
154153
role="separator"
155154
>
156-
<span className="slds-text-title--caps">{this.props.label}</span>
155+
<span className={classNames('slds-text-title--caps', this.props.className)}>{this.props.label}</span>
157156
</li>
158157
);
159158
}
160159
case 'divider': {
161160
return (
162-
<li
163-
className={classNames('slds-has-divider', this.props.className)}
164-
onMouseDown={this.handleMouseDown}
165-
role="separator"
166-
></li>
161+
<li className="slds-has-divider" onMouseDown={this.handleMouseDown} role="separator"></li>
167162
);
168163
}
169164
case 'link':
@@ -172,12 +167,13 @@ const ListItem = React.createClass({
172167
return (
173168
<li
174169
aria-selected={this.props.isSelected}
175-
className={classNames('slds-dropdown__item', { 'slds-is-selected': this.props.isSelected }, this.props.className)}
170+
className={classNames('slds-dropdown__item', { 'slds-is-selected': this.props.isSelected })}
176171
id={this.props.id}
177172
onMouseDown={this.handleMouseDown}
178173
role="presentation"
179174
>
180175
<a
176+
className={this.props.className}
181177
href={this.props.href}
182178
ref="link"
183179
data-index={this.props.index}

components/menu-picklist/index.jsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import classNames from 'classnames';
3232
import shortid from 'shortid';
3333

3434
// ### Children
35-
import Popover from '../popover';
35+
import Dialog from '../utilities/dialog';
3636
import Icon from '../icon';
3737
import List from '../menu-list/list';
3838
import ListItemLabel from '../menu-list/list-item-label';
@@ -42,7 +42,8 @@ import ListItemLabel from '../menu-list/list-item-label';
4242
// #### KeyboardNavigable
4343
import KeyboardNavigable from '../../utilities/keyboard-navigable';
4444

45-
import { KEYS, EventUtil } from '../../utilities';
45+
import EventUtil from '../../utilities/EventUtil';
46+
import KEYS from '../../utilities/KEYS';
4647
import { MENU_PICKLIST } from '../../utilities/constants';
4748

4849
/**
@@ -314,21 +315,21 @@ const MenuPicklist = React.createClass({
314315
);
315316
},
316317

317-
renderSeparateMenu () {
318+
renderDialog () {
318319
return (
319320
!this.props.disabled && this.state.isOpen && this.button
320-
? <Popover
321-
className="slds-dropdown slds-dropdown--left"
321+
? <Dialog
322322
closeOnTabKey
323323
constrainToScrollParent={this.props.constrainToScrollParent}
324+
contentsClassName="slds-dropdown slds-dropdown--left"
324325
flippable
325326
onClose={this.handleCancel}
326327
onKeyDown={this.handleKeyDown}
327328
targetElement={this.button}
328329
inheritTargetWidth={this.props.inheritTargetWidth}
329330
>
330331
{this.renderMenuContent()}
331-
</Popover>
332+
</Dialog>
332333
: null
333334
);
334335
},
@@ -372,7 +373,7 @@ const MenuPicklist = React.createClass({
372373
<span className="slds-truncate">{this.renderPlaceholder()}</span>
373374
<Icon name="down" category="utility" />
374375
</button>
375-
{isInline ? this.renderInlineMenu() : this.renderSeparateMenu()}
376+
{isInline ? this.renderInlineMenu() : this.renderDialog()}
376377
</div>
377378
);
378379
},

0 commit comments

Comments
 (0)