Skip to content

Commit 09b7faf

Browse files
Merge branch 'master' of github.com:salesforce-ux/design-system-react
2 parents afdf90f + 31088c4 commit 09b7faf

File tree

34 files changed

+627
-434
lines changed

34 files changed

+627
-434
lines changed

RELEASENOTES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ These are changes that have backwards-compatible solutions present and that comp
1414

1515
---
1616

17+
## Release 0.4.9
18+
- Removed {...props} from DOM nodes in components to prevent non-valid ones from being passed on (ie. `<input myFunkyprop .. />`)
19+
- If users need specific props passed onto DOM nodes, please submit a github issue.
20+
1721
## Release 0.4.7
1822

1923
**MINOR FEATURES**

components/button-stateful/index.jsx

Lines changed: 79 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import TooltipTrigger from '../popover-tooltip/trigger';
3232

3333
import { BUTTON_STATEFUL } from '../../utilities/constants';
3434

35-
const blurElement = e => e.currentTarget.blur();
3635

3736
const propTypes = {
3837
/**
@@ -54,15 +53,19 @@ const propTypes = {
5453
* If true, button/icon is white. Meant for buttons or utility icons on dark backgrounds.
5554
*/
5655
inverse: PropTypes.bool,
56+
onBlur: PropTypes.func,
5757
onClick: PropTypes.func,
58+
onFocus: PropTypes.func,
59+
onKeyDown: PropTypes.func,
60+
onKeyPress: PropTypes.func,
61+
onKeyUp: PropTypes.func,
62+
onMouseDown: PropTypes.func,
63+
onMouseEnter: PropTypes.func,
64+
onMouseLeave: PropTypes.func,
5865
/**
5966
* If true, button scales to 100% width on small form factors.
6067
*/
6168
responsive: PropTypes.bool,
62-
/**
63-
* Write <code>'-1'</code> if you don't want the user to tab to the button.
64-
*/
65-
tabIndex: PropTypes.string,
6669
/**
6770
* Initial label and icon (optional) of button.
6871
*/
@@ -75,6 +78,10 @@ const propTypes = {
7578
* Deselect label and icon (optional) of button.
7679
*/
7780
stateThree: PropTypes.object,
81+
/**
82+
* Write "-1" if you don't want the user to tab to the button.
83+
*/
84+
tabIndex: PropTypes.string,
7885
tooltip: PropTypes.node,
7986
variant: PropTypes.oneOf(['base', 'neutral', 'brand', 'destructive', 'icon'])
8087
};
@@ -112,6 +119,11 @@ class ButtonStateful extends TooltipTrigger {
112119
if (!isBoolean(this.props.active)) this.setState({ active: !this.state.active });
113120
}
114121

122+
handleBlur(e) {
123+
if(this.props.onBlur) this.props.onBlur(e);
124+
e.currentTarget.blur();
125+
}
126+
115127
getClassName (active) {
116128
return classNames(this.props.className, 'slds-button', {
117129
'slds-button--neutral': this.props.variant !== 'icon',
@@ -124,67 +136,104 @@ class ButtonStateful extends TooltipTrigger {
124136
}
125137

126138
render () {
127-
const props = omit(this.props, ['className', 'label', 'onClick', 'type', 'active']);
128-
const active = isBoolean(this.props.active) ? this.props.active : this.state.active;
129-
130-
if (this.props.variant === 'icon') {
139+
const {
140+
active,
141+
assistiveText,
142+
disabled,
143+
iconName,
144+
iconSize,
145+
id,
146+
onFocus,
147+
onKeyDown,
148+
onKeyPress,
149+
onKeyUp,
150+
onMouseDown,
151+
onMouseEnter,
152+
onMouseLeave,
153+
stateOne,
154+
stateTwo,
155+
stateThree,
156+
tabIndex,
157+
variant
158+
} = this.props;
159+
160+
const isActive = isBoolean(active) ? active : this.state.active;
161+
162+
if (variant === 'icon') {
131163
return (
132164
<button
133-
onMouseLeave={blurElement}
134-
className={this.getClassName(active)}
135-
onClick={this.handleClick.bind(this)}
136-
{...props}
137165
aria-live="polite"
166+
className={this.getClassName(isActive)}
167+
disabled={disabled}
168+
id={id}
169+
onBlur={this.handleBlur.bind(this)}
170+
onClick={this.handleClick.bind(this)}
171+
onFocus={onFocus}
172+
onKeyDown={onKeyDown}
173+
onKeyPress={onKeyPress}
174+
onKeyUp={onKeyUp}
175+
onMouseDown={onMouseDown}
176+
onMouseEnter={onMouseEnter}
177+
onMouseLeave={this.handleBlur.bind(this)}
178+
tabIndex={tabIndex}
138179
>
139180
<ButtonIcon
140-
assistiveText={active ? `${this.props.assistiveText} selected` : this.props.assistiveText}
141-
disabled={this.props.disabled}
142-
name={this.props.iconName}
143-
size={this.props.iconSize}
181+
assistiveText={isActive ? `${assistiveText} selected` : assistiveText}
182+
disabled={disabled}
183+
name={iconName}
184+
size={iconSize}
144185
className="slds-button__icon--stateful"
145186
/>
146187
{this.getTooltip()}
147188
</button>
148189
);
149190
}
150-
191+
151192
return (
152193
<button
153-
onMouseLeave={blurElement}
154-
className={this.getClassName(active)}
155194
aria-live="assertive"
195+
className={this.getClassName(isActive)}
196+
disabled={disabled}
197+
id={id}
198+
onBlur={this.handleBlur.bind(this)}
156199
onClick={this.handleClick.bind(this)}
157-
{...props}
200+
onFocus={onFocus}
201+
onKeyDown={onKeyDown}
202+
onKeyPress={onKeyPress}
203+
onKeyUp={onKeyUp}
204+
onMouseEnter={onMouseEnter}
205+
onMouseLeave={this.handleBlur.bind(this)}
206+
tabIndex={tabIndex}
158207
>
159208
<span className="slds-text-not-selected">
160209
<ButtonIcon
161-
disabled={this.props.disabled}
162-
name={this.props.stateOne.iconName}
210+
disabled={disabled}
211+
name={stateOne.iconName}
163212
size="small"
164213
position="left"
165214
className="slds-button__icon--stateful"
166215
/>
167-
{this.props.stateOne.label}
216+
{stateOne.label}
168217
</span>
169218
<span className="slds-text-selected">
170219
<ButtonIcon
171-
disabled={this.props.disabled}
172-
name={this.props.stateTwo.iconName}
220+
disabled={disabled}
221+
name={stateTwo.iconName}
173222
size="small"
174223
position="left"
175224
className="slds-button__icon--stateful"
176225
/>
177-
{this.props.stateTwo.label}
226+
{stateTwo.label}
178227
</span>
179228
<span className="slds-text-selected-focus">
180229
<ButtonIcon
181-
disabled={this.props.disabled}
182-
name={this.props.stateThree.iconName}
230+
disabled={disabled}
231+
name={stateThree.iconName}
183232
size="small"
184233
position="left"
185234
className="slds-button__icon--stateful"
186235
/>
187-
{this.props.stateThree.label}
236+
{stateThree.label}
188237
</span>
189238
{this.getTooltip()}
190239
</button>

components/button/index.jsx

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ import { BUTTON } from '../../utilities/constants';
1919

2020
const displayName = BUTTON;
2121
const propTypes = {
22+
/**
23+
* Used if the Button triggers a menu or popup. Bool indicates if the menu or popup is open or closed.
24+
*/
25+
ariaExpanded: PropTypes.bool,
26+
/**
27+
* True if Button triggers a menu or popup to open/close.
28+
*/
29+
ariaHaspopup: PropTypes.bool,
2230
/**
2331
* Text that is visually hidden but read aloud by screenreaders to tell the user what the icon means.
2432
* If the button has an icon and a visible label, you can omit the <code>assistiveText</code> prop and use the <code>label</code> prop.
@@ -57,7 +65,7 @@ const propTypes = {
5765
*/
5866
iconVariant: PropTypes.oneOf(['bare', 'container', 'border', 'border-filled', 'more', 'global-header']),
5967
/**
60-
* For icon variants, please reference <a href="http://www.lightningdesignsystem.com/components/buttons/#icon">Lightning Design System Icons</a>.
68+
* Id string applied to button node.
6169
*/
6270
id: PropTypes.string,
6371
/**
@@ -68,10 +76,18 @@ const propTypes = {
6876
* Visible label on the button. If the button is an icon button with no label, you must use the <code>assistiveText</code> prop.
6977
*/
7078
label: PropTypes.string,
79+
onBlur: PropTypes.func,
7180
/**
7281
* Triggered when the button is clicked.
7382
*/
7483
onClick: PropTypes.func,
84+
onFocus: PropTypes.func,
85+
onKeyDown: PropTypes.func,
86+
onKeyPress: PropTypes.func,
87+
onKeyUp: PropTypes.func,
88+
onMouseDown: PropTypes.func,
89+
onMouseEnter: PropTypes.func,
90+
onMouseLeave: PropTypes.func,
7591
/**
7692
* If true, button scales to 100% width on small form factors.
7793
*/
@@ -185,38 +201,53 @@ class Button extends TooltipTrigger {
185201
}
186202

187203
render () {
188-
const props = omit(this.props, [
189-
'assistiveText',
190-
'className',
191-
'hint',
192-
'iconCategory',
193-
'iconName',
194-
'iconPosition',
195-
'iconSize',
196-
'iconVariant',
197-
'inverse',
198-
'label',
199-
'onClick',
200-
'responsive',
201-
'tooltip',
202-
'variant'
203-
]);
204+
const {
205+
ariaExpanded,
206+
ariaHaspopup,
207+
children,
208+
disabled,
209+
iconName,
210+
iconPosition,
211+
iconVariant,
212+
id,
213+
onBlur,
214+
onFocus,
215+
onKeyDown,
216+
onKeyPress,
217+
onKeyUp,
218+
onMouseDown,
219+
onMouseEnter,
220+
onMouseLeave,
221+
tabIndex
222+
} = this.props;
204223

205224
return (
206225
<button
226+
aria-expanded={ariaExpanded}
227+
aria-haspopup={ariaHaspopup}
207228
className={this.getClassName()}
208-
{...props}
229+
disabled={disabled}
230+
id={id}
231+
onBlur={onBlur}
209232
onClick={this.handleClick}
233+
onFocus={onFocus}
234+
onKeyDown={onKeyDown}
235+
onKeyPress={onKeyPress}
236+
onKeyUp={onKeyUp}
237+
onMouseDown={onMouseDown}
238+
onMouseEnter={onMouseEnter}
239+
onMouseLeave={onMouseLeave}
240+
tabIndex={tabIndex}
210241
>
211-
{this.props.iconPosition === 'right' ? this.renderLabel() : null}
242+
{iconPosition === 'right' ? this.renderLabel() : null}
212243

213-
{this.props.iconName ? this.renderIcon(this.props.iconName) : null}
214-
{this.props.iconVariant === 'more'
244+
{iconName ? this.renderIcon(this.props.iconName) : null}
245+
{iconVariant === 'more'
215246
? <ButtonIcon category="utility" name="down" size="x-small" />
216247
: null}
217248

218-
{(this.props.iconPosition === 'left' || !this.props.iconPosition) ? this.renderLabel() : null}
219-
{this.props.children}
249+
{(iconPosition === 'left' || !iconPosition) ? this.renderLabel() : null}
250+
{children}
220251
{this.getTooltip()}
221252
</button>
222253
);

components/card/filter/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1414
import React from 'react';
1515

1616
import Input from '../../forms/input';
17+
import InputIcon from '../../icon/input-icon';
1718

1819
// Removes the need for `PropTypes`.
1920
const { PropTypes } = React;
@@ -35,8 +36,7 @@ const Filter = (props) => {
3536
<Input
3637
{...rest}
3738
assistiveText={placeholder}
38-
iconCategory="utility"
39-
iconName="search"
39+
iconLeft={<InputIcon name="search" category="utility" />}
4040
id={id}
4141
onChange={onChange}
4242
placeholder={placeholder}

0 commit comments

Comments
 (0)