Skip to content

Commit 1913d8f

Browse files
Merge branch 'master' of github.com:salesforce/design-system-react into fieldLevelTooltipToCombobox
2 parents 167c2df + e0bcddd commit 1913d8f

File tree

122 files changed

+4360
-469
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+4360
-469
lines changed

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ module.exports = {
119119
//
120120
'prefer-object-spread/prefer-object-spread': [2, 'always'],
121121

122+
'max-lines': ['error', 500],
123+
122124
// Can't be used because it doesn't currently recognize props used in functions
123125
'react/no-unused-prop-types': 'off',
124126

CONTRIBUTING.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
First, on behalf of the core maintainers, I'd like to thank you for wanting to contribute and make the user experience for your end-users better and improve the developer experience of this library. :+1::tada: -- [@interactivellama](https://github.com/interactivellama/)
44

5+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
6+
7+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
8+
9+
* [Setup](#setup)
10+
* [Adding a new prop](#adding-a-new-prop)
11+
* [How to add a new component](#how-to-add-a-new-component)
12+
* [Contributing Guidelines](#contributing-guidelines)
13+
* [The review process](#the-review-process)
14+
* [Testing the documentation site (internal)](#testing-the-documentation-site-internal)
15+
16+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
17+
518
## Setup
619

720
1. Fork this repository (button in upper right). Install [git](https://git-scm.com/) and clone your fork locally with `git clone [email protected]:[YOUR-USER]/design-system-react.git`. This library only supports use of `git-bash` in Windows. The default command prompt may not work.
@@ -11,10 +24,11 @@ First, on behalf of the core maintainers, I'd like to thank you for wanting to c
1124
1. Read the [Codebase Overview](docs/codebase-overview.md) to learn concepts and best practices for the codebase and to confirm contribution is within project scope.
1225

1326
## Adding a new prop
27+
1428
1. This library is open to `data`, `ref`, `style`, and `className` on any element within reason, but especially open to it for the “primary part of a component” such as form elements such as `input` or a clickable elements such as `button`, since these are often used for testing purposes or form submission. This is probably a better way to write unit tests, anyway, since SLDS class changes are not considered breaking changes.
15-
1. `ref` callbacks should be within an `object` named refs with typically a key name of the HTML tag name. These should be tested with a Mocha callback.
16-
1. `style` props should be `style[SUFFIX]` and be tested with a Jest DOM snapshot by adding a Story to Storybook.
17-
1. `className` props should be `className[SUFFIX]` and be `PropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.string])` and be tested with a Jest DOM snapshot by adding a Story to Storybook.
29+
1. `ref` callbacks should be within an `object` named refs with typically a key name of the HTML tag name. These should be tested with a Mocha callback.
30+
1. `style` props should be `style[SUFFIX]` and be tested with a Jest DOM snapshot by adding a Story to Storybook.
31+
1. `className` props should be `className[SUFFIX]` and be `PropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.string])` and be tested with a Jest DOM snapshot by adding a Story to Storybook.
1832

1933
## How to add a new component
2034

RELEASENOTES.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ These are changes that have backwards-compatible solutions present and that comp
3131

3232
### Latest Release
3333

34+
## Release 0.9.2
35+
36+
**Bugfixes**
37+
38+
* `DataTable`: Adds event listeners to listen for window resize by default. This creates a behavior that truncates horizontal cells and is similar to how a `DataTable` on the Salesforce Platform works.
39+
40+
## Release 0.9.2
41+
42+
**Major Features**
43+
44+
* `DataTable` supports fixed headers and this allows the table headings to be visible while the table vertically scrolls.
45+
3446
## Release 0.9.1
3547

3648
**Notes**

components/app-launcher/__docs__/storybook-stories.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable max-lines */
12
import React from 'react';
23

34
import PropTypes from 'prop-types';

components/app-launcher/index.jsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ const defaultProps = {
3232
* The App Launcher allows the user to quickly access all the apps and functionality with their organization.
3333
* The App Launcher should generally only be used as a sub-component of the [Global Navigation Bar](/components/global-navigation-bar)
3434
*
35-
* Also note: App Launcher is not included in the standard component export. To import it, you must reference it directly via its path.
36-
* Example:
37-
* ```
38-
* import AppLauncher from 'design-system-react/components/app-launcher';
39-
* import AppLauncherTile from 'design-system-react/components/app-launcher/tile';
40-
* import AppLauncherSection from 'design-system-react/components/app-launcher/section';
41-
* ```
42-
*
4335
* USAGE EXAMPLE:
4436
* ```
4537
* <AppLauncher>

components/button/index.jsx

Lines changed: 53 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import checkProps from './check-props';
1313
import componentDoc from './docs.json';
1414
import Tooltip from '../tooltip';
1515

16+
import getAriaProps from '../../utilities/get-aria-props';
17+
1618
import { BUTTON } from '../../utilities/constants';
1719

1820
const defaultProps = {
@@ -27,29 +29,13 @@ const defaultProps = {
2729

2830
/**
2931
* The Button component is the Lightning Design System Button component. The Button should be used for label buttons, icon buttons, or buttons that have both labels and icons.
30-
* Either a <code>label</code> or <code>assistiveText.icon</code> is required; see the Prop Details table below.
31-
* For buttons that maintain selected/unselected states, use the <a href="#/button-stateful">ButtonStateful</a> component.
32+
* Either a <code>label</code> or <code>assistiveText.icon</code> is required; see the Prop Details table below. For buttons that maintain selected/unselected states, use the <a href="#/button-stateful">ButtonStateful</a> component.
33+
* Although not listed in the prop table, all `aria-*` props will be added to the `button` element if passed in.
3234
*/
3335
class Button extends React.Component {
3436
static displayName = BUTTON;
3537

3638
static propTypes = {
37-
/**
38-
* Used if the Button triggers a tooltip. The value should match the `id` of the element with `role="tooltip"`.
39-
*/
40-
'aria-describedby': PropTypes.string,
41-
/**
42-
* Establishes a relationship between an interactive parent element and a child element to indicate which child element a parent element affects. Frequently used in cases where buttons or tabs are associated with exposing expandable regions.
43-
*/
44-
'aria-controls': PropTypes.string,
45-
/**
46-
* Used if the Button triggers a menu or popup. Bool indicates if the menu or popup is open or closed.
47-
*/
48-
'aria-expanded': PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
49-
/**
50-
* True if Button triggers a menu or popup to open/close.
51-
*/
52-
'aria-haspopup': PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
5339
/**
5440
* **Assistive text for accessibility.**
5541
* This object is merged with the default props object on every render.
@@ -310,57 +296,57 @@ class Button extends React.Component {
310296
);
311297
};
312298

313-
renderButton = () => (
314-
<button
315-
aria-controls={this.props['aria-controls']}
316-
aria-describedby={this.props['aria-describedby']}
317-
aria-expanded={this.props['aria-expanded']}
318-
aria-haspopup={this.props['aria-haspopup']}
319-
className={this.getClassName()}
320-
disabled={this.props.disabled}
321-
id={this.props.id}
322-
onBlur={this.props.onBlur}
323-
onClick={this.handleClick}
324-
onFocus={this.props.onFocus}
325-
onKeyDown={this.props.onKeyDown}
326-
onKeyPress={this.props.onKeyPress}
327-
onKeyUp={this.props.onKeyUp}
328-
onMouseDown={this.props.onMouseDown}
329-
onMouseEnter={this.props.onMouseEnter}
330-
onMouseLeave={this.props.onMouseLeave}
331-
onMouseUp={this.props.onMouseUp}
332-
ref={(component) => {
333-
if (this.props.buttonRef) {
334-
this.props.buttonRef(component);
335-
}
336-
}}
337-
tabIndex={this.props.tabIndex}
338-
title={this.props.title}
339-
type={this.props.type}
340-
style={this.props.style}
341-
>
342-
{this.props.iconPosition === 'right' ? this.renderLabel() : null}
299+
renderButton = () => {
300+
const ariaProps = getAriaProps(this.props);
301+
return (
302+
<button
303+
className={this.getClassName()}
304+
disabled={this.props.disabled}
305+
id={this.props.id}
306+
onBlur={this.props.onBlur}
307+
onClick={this.handleClick}
308+
onFocus={this.props.onFocus}
309+
onKeyDown={this.props.onKeyDown}
310+
onKeyPress={this.props.onKeyPress}
311+
onKeyUp={this.props.onKeyUp}
312+
onMouseDown={this.props.onMouseDown}
313+
onMouseEnter={this.props.onMouseEnter}
314+
onMouseLeave={this.props.onMouseLeave}
315+
onMouseUp={this.props.onMouseUp}
316+
ref={(component) => {
317+
if (this.props.buttonRef) {
318+
this.props.buttonRef(component);
319+
}
320+
}}
321+
tabIndex={this.props.tabIndex}
322+
title={this.props.title}
323+
type={this.props.type}
324+
style={this.props.style}
325+
{...ariaProps}
326+
>
327+
{this.props.iconPosition === 'right' ? this.renderLabel() : null}
343328

344-
{this.props.iconName || this.props.iconPath
345-
? this.renderIcon(this.props.iconName)
346-
: null}
347-
{this.props.iconVariant === 'more' ? (
348-
<ButtonIcon
349-
category="utility"
350-
name="down"
351-
size="x-small"
352-
className={this.props.iconClassName}
353-
/>
354-
) : null}
329+
{this.props.iconName || this.props.iconPath
330+
? this.renderIcon(this.props.iconName)
331+
: null}
332+
{this.props.iconVariant === 'more' ? (
333+
<ButtonIcon
334+
category="utility"
335+
name="down"
336+
size="x-small"
337+
className={this.props.iconClassName}
338+
/>
339+
) : null}
355340

356-
{this.props.iconPosition === 'left' || !this.props.iconPosition
357-
? this.renderLabel()
358-
: null}
359-
{
360-
this.props.children // eslint-disable-line react/prop-types
361-
}
362-
</button>
363-
);
341+
{this.props.iconPosition === 'left' || !this.props.iconPosition
342+
? this.renderLabel()
343+
: null}
344+
{
345+
this.props.children // eslint-disable-line react/prop-types
346+
}
347+
</button>
348+
);
349+
};
364350

365351
// This is present for backwards compatibility and should be removed at a future breaking change release. Please wrap a `Button` in a `PopoverTooltip` to achieve the same result. There will be an extra trigger `div` wrapping the `Button` though.
366352
renderTooltip = () => (

components/card/__docs__/storybook-stories.jsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ import MediaObject from '../../media-object';
2020
import InlineEdit from '../../forms/input/inline';
2121

2222
const sampleItems = [
23-
{ name: 'Cloudhub' },
24-
{ name: 'Cloudhub + Anypoint Connectors' },
25-
{ name: 'Cloud City' },
23+
{ id: '0', name: 'Cloudhub' },
24+
{ id: '1', name: 'Cloudhub + Anypoint Connectors' },
25+
{ id: '2', name: 'Cloud City' },
2626
];
2727

28+
let currentId = 3;
29+
2830
class DemoCard extends React.Component {
2931
static displayName = 'DemoCard';
3032

@@ -63,7 +65,10 @@ class DemoCard extends React.Component {
6365
action('add')(...rest);
6466

6567
this.setState({
66-
items: [{ name: `New item #${shortid.generate()}` }, ...this.state.items],
68+
items: [
69+
{ id: currentId++, name: `New item #${shortid.generate()}` },
70+
...this.state.items,
71+
],
6772
});
6873
};
6974

@@ -107,7 +112,7 @@ class DemoCard extends React.Component {
107112
icon={<Icon category="standard" name="document" size="small" />}
108113
empty={isEmpty ? <CardEmpty heading="No Related Items" /> : null}
109114
>
110-
<DataTable id="SLDSDataTableExample-1" items={items} bordered>
115+
<DataTable id="SLDSDataTableExample-1" items={items}>
111116
<DataTableColumn label="Opportunity Name" property="name" truncate>
112117
<DataTableHighlightCell search={this.state.filter} />
113118
</DataTableColumn>

components/color-picker/__tests__/color-picker.browser-test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable max-lines */
12
import React from 'react';
23
import createReactClass from 'create-react-class';
34
import PropTypes from 'prop-types';

components/color-picker/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable max-lines */
12
import classNames from 'classnames';
23
import PropTypes from 'prop-types';
34
import React from 'react';

components/combobox/__tests__/combobox.browser-test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Import your external dependencies
1+
/* eslint-disable max-lines */
22
import React from 'react';
33
import PropTypes from 'prop-types';
44
import chai, { expect } from 'chai';

components/combobox/combobox.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
/* eslint-disable max-lines */
12
/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */
23
/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
34

45
/* eslint-disable jsx-a11y/role-has-required-aria-props */
6+
/* eslint-disable max-lines */
57

68
import React from 'react';
79
import PropTypes from 'prop-types';

components/component-docs.json

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3942,6 +3942,30 @@
39423942
}
39433943
],
39443944
"returns": null
3945+
},
3946+
{
3947+
"name": "resizeFixedHeaders",
3948+
"docblock": null,
3949+
"modifiers": [],
3950+
"params": [
3951+
{
3952+
"name": "event",
3953+
"type": null
3954+
}
3955+
],
3956+
"returns": null
3957+
},
3958+
{
3959+
"name": "toggleFixedHeaderListeners",
3960+
"docblock": null,
3961+
"modifiers": [],
3962+
"params": [
3963+
{
3964+
"name": "attach",
3965+
"type": null
3966+
}
3967+
],
3968+
"returns": null
39453969
}
39463970
],
39473971
"props": {
@@ -4014,19 +4038,26 @@
40144038
"required": false,
40154039
"description": "A variant which adds border to the vertical columns."
40164040
},
4017-
"id": {
4041+
"fixedHeader": {
40184042
"type": {
4019-
"name": "string"
4043+
"name": "bool"
40204044
},
40214045
"required": false,
4022-
"description": "A unique ID is needed in order to support keyboard navigation and ARIA support."
4046+
"description": "Use this to enable fixed headers and scrolling columns / rows. Appearance / behavior is consistent only if used in combination with `fixedLayout`. Since scrolling is enabled, columns are not truncated unless a width is set. Due to `overflow:hidden` elements, any dialog components will need a separate render tree (portal) such as with `menuPosition: overflowBoundaryElement` in order to break out of the container."
40234047
},
40244048
"fixedLayout": {
40254049
"type": {
40264050
"name": "bool"
40274051
},
40284052
"required": false,
4029-
"description": "Use this if you are creating an advanced table (selectable, sortable, or resizable rows)"
4053+
"description": "Use this if you are creating an advanced table (selectable, sortable, or resizable rows). Columns widths will be truncate based on width and DOM ancestors. See `fixedHeader` to enable horizontal and vertical scrolling."
4054+
},
4055+
"id": {
4056+
"type": {
4057+
"name": "string"
4058+
},
4059+
"required": false,
4060+
"description": "A unique ID is needed in order to support keyboard navigation and ARIA support."
40304061
},
40314062
"items": {
40324063
"type": {
@@ -4051,6 +4082,13 @@
40514082
"required": false,
40524083
"description": "A variant which removes hover style on rows"
40534084
},
4085+
"onFixedHeaderResize": {
4086+
"type": {
4087+
"name": "func"
4088+
},
4089+
"required": false,
4090+
"description": "By default this function resizes the display headers when fixedHeader is `true`, but this behavior can be overridden. Passes an event and a data object with properties `headerRefs`, an array of DOM nodes referencing the `thead th` elements and `scrollerRef`, a DOM node referencing `.slds-table_header-fixed_scroller`"
4091+
},
40544092
"onRowChange": {
40554093
"type": {
40564094
"name": "func"
@@ -4065,6 +4103,13 @@
40654103
"required": false,
40664104
"description": "This function fires when the table should be sorted."
40674105
},
4106+
"onToggleFixedHeaderListeners": {
4107+
"type": {
4108+
"name": "func"
4109+
},
4110+
"required": false,
4111+
"description": "By default this function attaches/detaches listeners for window resize and tbody scrolling when fixedHeader is `true`, but this behavior can be overridden. Passes an event and a data object with an `attach` boolean property to determine whether listeners should be attached, a `resizeHandler` function property that can be called as-needed, and a `scrollerRef` DOM node property that serves as a reference to `.slds-table_header-fixed_scroller`"
4112+
},
40684113
"selection": {
40694114
"type": {
40704115
"name": "array"

components/data-table/__docs__/site-stories.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const siteStories = [
88
require('raw-loader!@salesforce/design-system-react/components/data-table/__examples__/basic-fixed-layout.jsx'),
99
require('raw-loader!@salesforce/design-system-react/components/data-table/__examples__/advanced.jsx'),
1010
require('raw-loader!@salesforce/design-system-react/components/data-table/__examples__/advanced-single-select.jsx'),
11+
require('raw-loader!@salesforce/design-system-react/components/data-table/__examples__/fixed-header.jsx'),
1112
];
1213

1314
module.exports = siteStories;

0 commit comments

Comments
 (0)