Skip to content

Commit

Permalink
Merge pull request #254 from dnbexperience/develop
Browse files Browse the repository at this point in the history
release of v4.8.1
  • Loading branch information
tujoworker authored Aug 12, 2019
2 parents 5842e87 + 696451c commit d686d25
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/dnb-ui-lib/src/components/date-picker/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const renderProps = {

export const propTypes = {
id: PropTypes.string,
title: PropTypes.string,
date: PropTypes.oneOfType([
PropTypes.instanceOf(Date),
PropTypes.string
Expand Down Expand Up @@ -134,6 +135,7 @@ export const propTypes = {

export const defaultProps = {
id: null,
title: null,
date: null,
start_date: null,
end_date: null,
Expand Down Expand Up @@ -547,6 +549,7 @@ export default class DatePicker extends PureComponent {

const {
label,
title,
label_direction,
only_month,
hide_navigation_buttons,
Expand Down Expand Up @@ -661,6 +664,7 @@ export default class DatePicker extends PureComponent {
<span className="dnb-date-picker__shell">
<DatePickerInput
id={id}
title={title}
disabled={isTrue(disabled)}
maskOrder={mask_order}
maskPlaceholder={mask_placeholder}
Expand Down
22 changes: 18 additions & 4 deletions packages/dnb-ui-lib/src/components/date-picker/DatePickerInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { isDisabled } from './DatePickerCalc'

export const propTypes = {
id: PropTypes.string,
title: PropTypes.string,
maskOrder: PropTypes.string,
maskPlaceholder: PropTypes.string,
separatorRexExp: PropTypes.instanceOf(RegExp),
Expand All @@ -39,6 +40,11 @@ export const propTypes = {
]),
status_state: PropTypes.string,
status_animation: PropTypes.string,
inputElement: PropTypes.oneOfType([
PropTypes.string,
PropTypes.func,
PropTypes.node
]),
disabled: PropTypes.bool,
opened: PropTypes.bool,
showInput: PropTypes.bool,
Expand All @@ -50,6 +56,7 @@ export const propTypes = {

export const defaultProps = {
id: null,
title: null,
maskOrder: 'dd/mm/yyyy',
maskPlaceholder: 'dd/mm/åååå',
separatorRexExp: /[-/ ]/g,
Expand All @@ -60,6 +67,7 @@ export const defaultProps = {
status_animation: null,
minDate: null,
maxDate: null,
inputElement: null,
disabled: null,
opened: false,
showInput: null,
Expand Down Expand Up @@ -418,12 +426,16 @@ export default class DatePickerInput extends PureComponent {
},
placeholderChar
}

// this makes it possible to use a vanilla <input /> like: inputElement="input"
const Input = this.props.inputElement || InputElement

switch (state) {
case 'd':
this.refList.push(this[`_${mode}DayRef`])

return (
<InputElement
<Input
{...params}
id={`${this.props.id}-${mode}-day`}
key={'d' + i}
Expand All @@ -443,7 +455,7 @@ export default class DatePickerInput extends PureComponent {
this.refList.push(this[`_${mode}MonthRef`])

return (
<InputElement
<Input
{...params}
id={`${this.props.id}-${mode}-month`}
key={'m' + i}
Expand All @@ -463,7 +475,7 @@ export default class DatePickerInput extends PureComponent {
this.refList.push(this[`_${mode}YearRef`])

return (
<InputElement
<Input
{...params}
id={`${this.props.id}-${mode}-year`}
key={'y' + i}
Expand Down Expand Up @@ -496,6 +508,7 @@ export default class DatePickerInput extends PureComponent {
render() {
const {
id,
title,

submitAttributes,
range /* eslint-disable-line */,
Expand All @@ -512,6 +525,7 @@ export default class DatePickerInput extends PureComponent {
onSubmit /* eslint-disable-line */,
onSubmitButtonFocus /* eslint-disable-line */,
showInput /* eslint-disable-line */,
inputElement /* eslint-disable-line */,
disabled,
opened,
status,
Expand Down Expand Up @@ -540,7 +554,7 @@ export default class DatePickerInput extends PureComponent {
id={id}
disabled={disabled}
className={opened ? 'dnb-button--active' : null}
// title={submit_button_title} // Not implemented yet
title={title}
type="button"
icon="calendar"
variant="secondary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ exports[`DatePicker component have to match snapshot 1`] = `
status_state="error"
submit_button_text="Ok"
sync={true}
title={null}
>
<span
className="dnb-date-picker dnb-date-picker__status--error dnb-date-picker--hidden dnb-date-picker--show-input dnb-date-picker--show-footer"
Expand All @@ -98,6 +99,7 @@ exports[`DatePicker component have to match snapshot 1`] = `
disabled={false}
endDate={2019-02-15T00:00:00.000Z}
id="date-picker-id"
inputElement={null}
maskOrder="dd/mm/yyyy"
maskPlaceholder="dd/mm/åååå"
maxDate={null}
Expand All @@ -119,6 +121,7 @@ exports[`DatePicker component have to match snapshot 1`] = `
"aria-expanded": false,
}
}
title={null}
>
<Input
align={null}
Expand Down
2 changes: 2 additions & 0 deletions packages/dnb-ui-lib/stories/components/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default [
label="Date Picker 1:"
right="small"
date="1981-01-15"
title="My Button"
/>
<DatePicker
label="Date Picker 2:"
Expand All @@ -33,6 +34,7 @@ export default [
align_picker="right"
mask_placeholder="dd/mm/yyyy"
locale={enLocale}
inputElement="input"
first_day="sunday"
return_format="DD/MM/YYYY"
date="1981-01-15"
Expand Down

0 comments on commit d686d25

Please sign in to comment.