Skip to content

Commit 1c8a1b1

Browse files
authored
Merge pull request #16 from b12io/the-last-update
Pull in the latest code from the closed-source repository
2 parents 13e6ce4 + 940260e commit 1c8a1b1

File tree

28 files changed

+501
-93
lines changed

28 files changed

+501
-93
lines changed

components/Icons.es6.js

Lines changed: 168 additions & 21 deletions
Large diffs are not rendered by default.

components/form/checkbox-multiple-select/CheckboxMultipleSelect.es6.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CheckboxMultipleSelect extends React.Component {
2626
})
2727
}
2828

29-
componentWillReceiveProps (nextProps) {
29+
UNSAFE_componentWillReceiveProps (nextProps) {
3030
this.overrideStateFromProps(nextProps)
3131
}
3232

components/form/datetime-picker/DatetimePicker.es6.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ class DatetimePicker extends React.Component<Props, State> {
3636
// event from firing.
3737
textInput: ?boolean
3838

39+
componentDidUpdate(prevProps: Props) {
40+
if(prevProps.value !== this.props.value) {
41+
this.setState({datetime: this.props.value});
42+
}
43+
}
44+
3945
handleChange = (datetime: moment$Moment): void => {
4046
const { dateOnly, timeOnly, updateDatetime } = this.props
4147

components/form/file-upload/FileUpload.es6.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class FileUpload extends React.Component<Props> {
118118
label={buttonLabel}
119119
icon={buttonIcon}
120120
small={buttonSmall}
121+
loading={loading}
121122
// $FlowFixMe: Not sure how to type this.dropzoneRef
122123
onClick={(e) => { e.preventDefault(); this.dropzoneRef.open(); } }
123124
/>}

components/form/filter-option/FilterOption.es6.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class FilterOption extends React.Component<Props, State> {
3535
filters: []
3636
}
3737

38-
componentWillReceiveProps ({ isOpened }: Props) {
38+
UNSAFE_componentWillReceiveProps ({ isOpened }: Props) {
3939
if (isOpened !== this.state.isOpened) {
4040
this.setState({ isOpened })
4141
}

components/form/radio/Radio.es6.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
3+
import classnames from 'classnames'
34

4-
function Radio ({disabled, label, name, value, checked, onChange}) {
5+
function Radio ({ className, disabled, label, name, value, checked, onChange, tabIndex }) {
56
return (
6-
<div className="ds-form-group">
7+
<div className={classnames('ds-form-group', className)}>
78
<label className="ds-form-control-radio">
89
<input type="checkbox"
910
value={value}
1011
name={name}
12+
tabIndex={tabIndex}
1113
disabled={disabled}
1214
checked={checked}
1315
onChange={() => {
@@ -21,20 +23,24 @@ function Radio ({disabled, label, name, value, checked, onChange}) {
2123
}
2224

2325
Radio.defaultProps = {
26+
className: '',
2427
label: '',
2528
value: '',
2629
name: '',
30+
tabIndex: 0,
2731
checked: false,
2832
disabled: false,
2933
onChange: () => {}
3034
}
3135

3236
Radio.propTypes = {
37+
className: PropTypes.string,
3338
label: PropTypes.oneOfType([
3439
PropTypes.string,
3540
PropTypes.element
3641
]),
3742
name: PropTypes.string,
43+
tabIndex: PropTypes.number,
3844
value: PropTypes.string,
3945
checked: PropTypes.bool,
4046
disabled: PropTypes.bool,

components/form/select/Select.es6.js

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
33
import classnames from 'classnames'
44
import { isEmpty } from 'lodash'
55

6-
import { Help, Search, Close } from '../../Icons.es6.js'
6+
import { Help, Search, Close, RemoveCircle } from '../../Icons.es6.js'
77
import Option from '../option/Option.es6.js'
88

99
class Select extends React.Component {
@@ -19,24 +19,31 @@ class Select extends React.Component {
1919
this.state = {
2020
isOpened: false,
2121
query: '',
22-
filteredOptions: props.search ? props.filter(this.options, '') : this.options
22+
filteredOptions: props.search ? props.filter(this.options, '') : this.options,
23+
initialPlaceholder: '',
24+
hasInitialPlaceholderChanged: false
2325
}
2426
}
2527

2628
componentDidMount () {
29+
this.setState({ initialPlaceholder: this.props.placeholder })
2730
document.addEventListener('click', this.handleDocumentClick, false)
2831
document.addEventListener('touchend', this.handleDocumentClick, false)
2932
}
3033

31-
componentWillReceiveProps (nextProps) {
34+
UNSAFE_componentWillReceiveProps (nextProps) {
3235
const {children, search, filter} = nextProps
3336
this.options = this.updateOptions(children)
3437
this.setState({
3538
filteredOptions: search ? filter(this.options, this.state.query) : this.options
3639
})
3740
}
3841

39-
componentDidUpdate () {
42+
componentDidUpdate (prevProps) {
43+
const { placeholder, search } = this.props
44+
if ((prevProps.placeholder !== placeholder) && (placeholder !== this.state.initialPlaceholder)) {
45+
this.setState({ hasInitialPlaceholderChanged: true })
46+
}
4047
if (this.props.search && this.state.isOpened && this.searchInput) {
4148
this.searchInput.focus()
4249
}
@@ -117,8 +124,43 @@ class Select extends React.Component {
117124
})
118125
}
119126

127+
renderCloseIcon = (query) => {
128+
return (
129+
<div
130+
className={classnames('ds-form-control-select__search-clear', {
131+
'is-hidden': !query
132+
})}
133+
onClick={this.handleClearSearch}
134+
>
135+
<Close color="#ddd" />
136+
</div>
137+
)
138+
}
139+
140+
resetHandler = () => {
141+
this.handleClearSearch()
142+
this.props.onResetClick()
143+
this.setState({ hasInitialPlaceholderChanged: false })
144+
}
145+
146+
renderResetIcon = () => {
147+
return (
148+
<div
149+
className={classnames('ds-form-control-select__reset', {
150+
'is-hidden': !this.state.hasInitialPlaceholderChanged
151+
})}
152+
onClick={this.resetHandler}
153+
>
154+
<RemoveCircle color="#ddd" />
155+
</div>
156+
)
157+
}
158+
120159
render () {
121-
const {error, disabled, className, label, preview, inlineSearch, placeholder, search, help} = this.props
160+
const {
161+
error, disabled, className, label, preview, showResetIcon,
162+
inlineSearch, placeholder, search, help
163+
} = this.props
122164
const {query, filteredOptions, isOpened} = this.state
123165
return (
124166
<div className={classnames({
@@ -146,6 +188,7 @@ class Select extends React.Component {
146188
{inlineSearch && <Search color="#ddd" />}
147189
{inlineSearch && query ? query : placeholder}
148190
{preview && <img src={preview} alt={placeholder} />}
191+
{showResetIcon && this.renderResetIcon()}
149192
</div>
150193

151194
{/* Options */}
@@ -159,16 +202,8 @@ class Select extends React.Component {
159202
ref={(node) => { this.searchInput = node }}
160203
onChange={(e) => this.onSearch(e.target.value)}
161204
/>
162-
{inlineSearch && <div
163-
className={classnames('ds-form-control-select__search-clear', {
164-
'is-hidden': !query
165-
})}
166-
onClick={this.handleClearSearch}
167-
>
168-
<Close color="#ddd" />
169-
</div>}
205+
{inlineSearch && this.renderCloseIcon(query)}
170206
</div>}
171-
172207
<div className="ds-form-control-select__dropdown-options">
173208
{filteredOptions}
174209
</div>
@@ -201,6 +236,7 @@ Select.defaultProps = {
201236
children: [],
202237
keepOpen: () => {},
203238
inlineSearch: false,
239+
showResetIcon: false,
204240
onSearchQueryClear: () => {},
205241
fillSelectedQuery: false
206242
}
@@ -226,8 +262,10 @@ Select.propTypes = {
226262
search: PropTypes.bool,
227263
preview: PropTypes.string,
228264
keepOpen: PropTypes.func,
265+
showResetIcon: PropTypes.bool,
229266
inlineSearch: PropTypes.bool,
230267
onSearchQueryClear: PropTypes.func,
268+
onResetClick: PropTypes.func,
231269
fillSelectedQuery: PropTypes.bool
232270
}
233271

components/form/switch/Switch.es6.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Switch extends React.Component {
1212
}
1313
}
1414

15-
componentWillReceiveProps (nextProps) {
15+
UNSAFE_componentWillReceiveProps (nextProps) {
1616
this.setState({
1717
selected: nextProps.selected,
1818
buttons: this.updateButtons(nextProps.children, nextProps.selected)

components/form/thumbnail-option/ThumbnailOption.es6.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type Props = {|
1111
key?: Key,
1212
label: string,
1313
onOptionClick: (event: SyntheticEvent<HTMLDivElement>, value: string) => *,
14+
onFocus: (event: SyntheticEvent<HTMLDivElement>, value: string) => *,
1415
selected: boolean,
1516
thumbnail: string,
1617
thumbnailCover: boolean,
@@ -22,7 +23,8 @@ type Props = {|
2223
text?: string,
2324
value: string,
2425
children?: Node,
25-
className?: string | Object
26+
className?: string | Object,
27+
tabIndex?: number
2628
|}
2729

2830
type ImageThumbnailType = {|
@@ -44,9 +46,9 @@ function ImageThumbnail ({ thumbnail, thumbnailCover, label }: ImageThumbnailTyp
4446
)
4547
}
4648

47-
function ThumbnailOption ({ label, onOptionClick, selected, thumbnail,
49+
function ThumbnailOption ({ label, onOptionClick, onFocus, selected, thumbnail,
4850
thumbnailCover, value, isVideo, videoType, videoUrl, rounded,
49-
shadowed, text, className, children }: Props) {
51+
shadowed, text, tabIndex, className, children }: Props) {
5052
return (
5153
<div className={classnames({
5254
'ds-thumbnail-option': true,
@@ -55,6 +57,8 @@ function ThumbnailOption ({ label, onOptionClick, selected, thumbnail,
5557
'ds-thumbnail-option--shadowed': shadowed
5658
}, className)}
5759
onClick={(event) => onOptionClick(event, value)}
60+
onFocus={(event) => onFocus(event, value)}
61+
tabIndex={tabIndex}
5862
>
5963
<div className="ds-thumbnail-option__thumbnail-container">
6064
{isVideo ? (
@@ -101,14 +105,16 @@ function ThumbnailOption ({ label, onOptionClick, selected, thumbnail,
101105
ThumbnailOption.defaultProps = {
102106
label: '',
103107
onOptionClick: () => {},
108+
onFocus: () => {},
104109
selected: false,
105110
thumbnail: '',
106111
thumbnailCover: false,
107112
isVideo: false,
108113
rounded: false,
109114
shadowed: false,
110115
text: '',
111-
value: ''
116+
value: '',
117+
tabIndex: 0
112118
}
113119

114120
export default ThumbnailOption

components/layout/breadcrumbs/Breadcrumbs.es6.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function Breadcrumbs ({ entries, onClick, maxEntryWidth = 90 }: Props) {
139139
<div className="ds-tabbed-nav__breadcrumbs-container ds-tabbed-nav__breadcrumbs-container--not-calculated">
140140
{entries.map((entry: Entry, index: number) => (
141141
<BreadcrumbEntry
142-
key={entry.label}
142+
key={`${entry.label}-${index}`}
143143
showSeparator={index !== 0}
144144
label={entry.label}
145145
ref={entriesRefs[index]}
@@ -178,11 +178,11 @@ function Breadcrumbs ({ entries, onClick, maxEntryWidth = 90 }: Props) {
178178
'ds-tabbed-nav__breadcrumbs-entry-menu': true,
179179
'ds-tabbed-nav__breadcrumbs-entry-menu--opened': isMenuOpened
180180
})}>
181-
{hiddenEntries.map((entry: IndexedEntry) => (
181+
{hiddenEntries.map((entry: IndexedEntry, index: number) => (
182182
<div
183183
className="ds-tabbed-nav__breadcrumbs-entry-menu-item"
184184
onClick={onClickEntryWithIndex(entry.index)}
185-
key={entry.entry.label}
185+
key={`${entry.entry.label}-${index}`}
186186
>
187187
{entry.entry.label}
188188
</div>
@@ -205,7 +205,7 @@ function Breadcrumbs ({ entries, onClick, maxEntryWidth = 90 }: Props) {
205205
width={maxEntryWidth}
206206
showTooltip={(maxEntryWidth < entry.width)}
207207
showSeparator={index !== 0}
208-
key={entry.entry.label}
208+
key={`${entry.entry.label}-${index}`}
209209
label={entry.entry.label}
210210
onClick={onClickEntryWithIndex(entry.index)}
211211
/>

0 commit comments

Comments
 (0)