+ The passed icon needs to come from our list of svg icons. Can be flipped {
+ // eslint-disable-next-line react/no-unescaped-entities
+ } to the other side by passing iconSide="right".
+
+ ),
+ demo: ,
}],
};
diff --git a/src-docs/src/views/date_picker/inline.js b/src-docs/src/views/date_picker/inline.js
new file mode 100644
index 00000000000..fca1cccd473
--- /dev/null
+++ b/src-docs/src/views/date_picker/inline.js
@@ -0,0 +1,24 @@
+import React from 'react';
+
+import moment from 'moment';
+
+import {
+ EuiDatePicker,
+ EuiFormRow,
+} from '../../../../src/components';
+
+export default () => (
+
+ The passed icon needs to come from our list of svg icons. Can be flipped {
+ // eslint-disable-next-line react/no-unescaped-entities
+ } to the other side by passing iconSide="right".
+
+ ),
+ demo: ,
}, {
title: 'Datepicker inline',
source: [{
diff --git a/src-docs/src/views/date_picker/inline.js b/src-docs/src/views/date_picker/inline.js
index fca1cccd473..3aed41b7c87 100644
--- a/src-docs/src/views/date_picker/inline.js
+++ b/src-docs/src/views/date_picker/inline.js
@@ -1,24 +1,50 @@
-import React from 'react';
+
+import React, {
+ Component,
+} from 'react';
import moment from 'moment';
import {
EuiDatePicker,
- EuiFormRow,
} from '../../../../src/components';
-export default () => (
-
+ The passed icon needs to come from our list of svg icons. Can be flipped {
+ // eslint-disable-next-line react/no-unescaped-entities
+ } to the other side by passing iconSide="right".
+
+ Locale formatting is achieved by using the locale,
+ timeFormat and dateFormat props.
+ The later will take any moment() notation. Check
+ Date format by country
+ for formatting examples.
+
+ Two props control time selction. showTimeSelect will make
+ time selection appear next to the calendar
+ and showTimeSelectOnly will exclude the calendar and
+ make the time selection the only thing you see. Make sure to adjust
+ your dateFormat and timeFormat values
+ to match.
+
Locale formatting is achieved by using the locale,
timeFormat and dateFormat props.
- The later will take any moment() notation. Check
+ The later will take any moment() notation. Check{' '}
Date format by country
- for formatting examples.
+ {' '}for formatting examples.
- The passed icon needs to come from our list of svg icons. Can be flipped {
- // eslint-disable-next-line react/no-unescaped-entities
- } to the other side by passing iconSide="right".
+ Use the inline prop to display the date picker directly
+ in the page. If you do not need the shadows / popover effect to the date picker
+ then also apply the shadow=false prop as shown in the second
+ example.
- Description needed: how to use the EuiDatePicker component.
+ At its most bare the EuiDatePicker only requires
+ props for selected and onChange.
+ It depends on moment for
+ all of its formatting.
),
components: { EuiDatePicker },
diff --git a/src-docs/src/views/date_picker/states.js b/src-docs/src/views/date_picker/states.js
index db1d456f934..c1b6e5bf39c 100644
--- a/src-docs/src/views/date_picker/states.js
+++ b/src-docs/src/views/date_picker/states.js
@@ -5,6 +5,7 @@ import React, {
import {
EuiDatePicker,
EuiSpacer,
+ EuiFormRow,
} from '../../../../src/components';
export default class extends Component {
@@ -26,6 +27,11 @@ export default class extends Component {
}
render() {
+ const errors = [
+ 'Here\'s an example of an error',
+ 'You might have more than one error, so pass an array.',
+ ];
+
return (
);
}
diff --git a/src-docs/src/views/date_picker/range.js b/src-docs/src/views/date_picker/range.js
index fa2b6ee40ae..6226ef56084 100644
--- a/src-docs/src/views/date_picker/range.js
+++ b/src-docs/src/views/date_picker/range.js
@@ -7,6 +7,9 @@ import moment from 'moment';
import {
EuiDatePicker,
+ EuiFlexGroup,
+ EuiFlexItem,
+ EuiFormRow,
} from '../../../../src/components';
export default class extends Component {
@@ -36,22 +39,30 @@ export default class extends Component {
render() {
return (
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
);
}
}
diff --git a/src/components/date_picker/_date_picker.scss b/src/components/date_picker/_date_picker.scss
index 8cf1dd66a26..16dce58722b 100644
--- a/src/components/date_picker/_date_picker.scss
+++ b/src/components/date_picker/_date_picker.scss
@@ -166,7 +166,7 @@
&:hover {
background-color: $euiColorLightestShade;
border-radius: $euiBorderRadius;
- outline: solid 2px $euiColorLightestShade;
+ outline: solid ($euiSizeXS / 2) $euiColorLightestShade;
transform: scale(1.2) rotate(90deg);
}
@@ -195,7 +195,7 @@
transform: scale(1.2) rotate(-90deg);
background-color: $euiColorLightestShade;
border-radius: $euiBorderRadius;
- outline: solid ($euiSize / 2) $euiColorLightestShade;
+ outline: solid ($euiSizeXS / 2) $euiColorLightestShade;
}
&--disabled,
diff --git a/src/components/date_picker/date_picker.js b/src/components/date_picker/date_picker.js
index 0cd80ecfb23..fc7c47d597d 100644
--- a/src/components/date_picker/date_picker.js
+++ b/src/components/date_picker/date_picker.js
@@ -67,6 +67,7 @@ export class EuiDatePicker extends Component {
openToDate,
disabled,
utcOffset,
+ filterDates,
...rest
} = this.props;
@@ -133,6 +134,7 @@ export class EuiDatePicker extends Component {
openToDate={openToDate}
disabled={disabled}
utcOffset={utcOffset}
+ filterDates={filterDates}
{...rest}
/>
From a85b32e35f93e921fcd57a606303d9d54665f891 Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Wed, 11 Apr 2018 15:07:48 -0700
Subject: [PATCH 24/42] clean up date range
---
src/components/date_picker/_date_picker.scss | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/components/date_picker/_date_picker.scss b/src/components/date_picker/_date_picker.scss
index 16dce58722b..2282cda3a48 100644
--- a/src/components/date_picker/_date_picker.scss
+++ b/src/components/date_picker/_date_picker.scss
@@ -383,8 +383,6 @@
}
&--selected,
- &--range-start,
- &--range-end,
&--in-selecting-range {
height: $euiSizeXL;
margin: 0 $euiSizeXS / 2;
From 194d9cea729c663e898817fc6d450b429e7b4df8 Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Wed, 11 Apr 2018 15:35:15 -0700
Subject: [PATCH 25/42] alphabatize props
---
src/components/date_picker/date_picker.js | 113 +++++++++++-----------
1 file changed, 57 insertions(+), 56 deletions(-)
diff --git a/src/components/date_picker/date_picker.js b/src/components/date_picker/date_picker.js
index fc7c47d597d..013fa747149 100644
--- a/src/components/date_picker/date_picker.js
+++ b/src/components/date_picker/date_picker.js
@@ -38,36 +38,36 @@ export class EuiDatePicker extends Component {
render() {
const {
+ calendarClassName,
className,
- isInvalid,
- inputRef,
- fullWidth,
- isLoading,
customInput,
- placeholder,
- inline,
- shadow,
dateFormat,
+ dayClassName,
+ disabled,
excludeDates,
+ filterDates,
+ fullWidth,
+ injectTimes,
+ inline,
+ inputRef,
+ isInvalid,
+ isLoading,
locale,
- minDate,
maxDate,
- minTime,
maxTime,
- timeFormat,
- showTimeSelect,
- showTimeSelectOnly,
+ minDate,
+ minTime,
onChange,
- selected,
- injectTimes,
- calendarClassName,
- dayClassName,
+ openToDate,
+ placeholder,
popperClassName,
+ selected,
+ shadow,
shouldCloseOnSelect,
- openToDate,
- disabled,
+ showTimeSelect,
+ showTimeSelectOnly,
+ timeFormat,
utcOffset,
- filterDates,
...rest
} = this.props;
@@ -106,35 +106,35 @@ export class EuiDatePicker extends Component {
isInvalid={isInvalid}
>
@@ -187,37 +187,38 @@ export class EuiDatePicker extends Component {
}
EuiDatePicker.propTypes = {
- className: PropTypes.string,
calendarClassName: PropTypes.string,
+ className: PropTypes.string,
+ customInput: PropTypes.node,
+ dateFormat: PropTypes.string,
dayClassName: PropTypes.func,
- popperClassName: PropTypes.string,
- placeholder: PropTypes.string,
+ filterDates: PropTypes.array,
+ fullWidth: PropTypes.bool,
icon: PropTypes.string,
- customInput: PropTypes.node,
- locale: PropTypes.string,
- isInvalid: PropTypes.bool,
+ injectTimes: PropTypes.array,
inputRef: PropTypes.func,
- fullWidth: PropTypes.bool,
+ isInvalid: PropTypes.bool,
isLoading: PropTypes.bool,
+ locale: PropTypes.string,
+ maxDate: PropTypes.instanceOf(moment),
+ maxTime: PropTypes.instanceOf(moment),
+ minDate: PropTypes.instanceOf(moment),
+ minTime: PropTypes.instanceOf(moment),
onChange: PropTypes.func,
+ openToDate: PropTypes.instanceOf(moment),
+ placeholder: PropTypes.string,
+ popperClassName: PropTypes.string,
+ selected: PropTypes.instanceOf(moment),
showTimeSelect: PropTypes.bool,
showTimeSelectOnly: PropTypes.bool,
timeFormat: PropTypes.string,
- dateFormat: PropTypes.string,
- injectTimes: PropTypes.array,
- selected: PropTypes.instanceOf(moment),
- minDate: PropTypes.instanceOf(moment),
- maxDate: PropTypes.instanceOf(moment),
- minTime: PropTypes.instanceOf(moment),
- maxTime: PropTypes.instanceOf(moment),
- openToDate: PropTypes.instanceOf(moment),
};
EuiDatePicker.defaultProps = {
+ dateFormat:"MM/DD/YYYY hh:mm A",
fullWidth: false,
isLoading: false,
- shouldCloseOnSelect: true,
shadow: true,
- dateFormat:"MM/DD/YYYY hh:mm A",
+ shouldCloseOnSelect: true,
timeFormat:"hh:mm A",
};
From 86944e1ff8ff5bc2d01f352fac55394d26af8fcb Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Wed, 11 Apr 2018 21:21:11 -0700
Subject: [PATCH 26/42] fix stupid selector bug
---
src/components/date_picker/_date_picker.scss | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/components/date_picker/_date_picker.scss b/src/components/date_picker/_date_picker.scss
index 2282cda3a48..afdf4d44242 100644
--- a/src/components/date_picker/_date_picker.scss
+++ b/src/components/date_picker/_date_picker.scss
@@ -541,20 +541,21 @@
}
}
- // These selectors are not a typo. Likely a bug in their rendering.
- &.--selected_year, &.--selected_month {
+ &--selected {
+ display: none;
+ }
+}
+
+// These selectors are not a typo. Likely a bug in their rendering.
+.react-datepicker__year-option {
+ &[class*="selected"] {
background: $euiColorPrimary;
color: $euiColorEmptyShade;
font-weight: $euiFontWeightBold;
border-radius: $euiBorderRadius;
}
-
- &--selected {
- display: none;
- }
}
-
@include screenXSmall {
.react-datepicker__time-container {
display: none;
From aab86a4f0df25cc8dbeec25189aed100215424be Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Wed, 11 Apr 2018 21:21:42 -0700
Subject: [PATCH 27/42] remove form mixins
---
src/components/date_picker/_index.scss | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/components/date_picker/_index.scss b/src/components/date_picker/_index.scss
index e3e05110e32..f44d6770ed1 100644
--- a/src/components/date_picker/_index.scss
+++ b/src/components/date_picker/_index.scss
@@ -1,5 +1,2 @@
// Uses some form mixins
-@import '../form/_variables';
-@import '../form/_mixins';
-
@import 'date_picker';
From a0729625347888ccd9d77b833945bc15578ea426 Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Wed, 11 Apr 2018 21:28:30 -0700
Subject: [PATCH 28/42] comments
---
src/components/date_picker/_date_picker.scss | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/components/date_picker/_date_picker.scss b/src/components/date_picker/_date_picker.scss
index afdf4d44242..c80c8ece706 100644
--- a/src/components/date_picker/_date_picker.scss
+++ b/src/components/date_picker/_date_picker.scss
@@ -546,8 +546,11 @@
}
}
-// These selectors are not a typo. Likely a bug in their rendering.
-.react-datepicker__year-option {
+// These selectors are not a typo. react-datepicker has a bug where these selectors
+// output as "--selected_year". Sass has trouble compiling .--selected_year, so instead
+// we use this generic selector get around it.
+.react-datepicker__year-option,
+.react-datepicker__month-option {
&[class*="selected"] {
background: $euiColorPrimary;
color: $euiColorEmptyShade;
@@ -556,6 +559,7 @@
}
}
+// We drop the time picker on mobile. They can still type in the time directly.
@include screenXSmall {
.react-datepicker__time-container {
display: none;
From 1740893576f6905eb3f7281b853ddf6ee52b18cb Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Thu, 12 Apr 2018 13:58:32 -0700
Subject: [PATCH 29/42] address design feedback
---
src-docs/src/views/date_picker/states.js | 1 +
src/components/date_picker/_date_picker.scss | 1 +
src/components/date_picker/date_picker.js | 1 +
src/components/form/field_text/_field_text.scss | 4 ++++
4 files changed, 7 insertions(+)
diff --git a/src-docs/src/views/date_picker/states.js b/src-docs/src/views/date_picker/states.js
index c1b6e5bf39c..cc7db3b800e 100644
--- a/src-docs/src/views/date_picker/states.js
+++ b/src-docs/src/views/date_picker/states.js
@@ -81,6 +81,7 @@ export default class extends Component {
>
Date: Thu, 12 Apr 2018 14:06:25 -0700
Subject: [PATCH 30/42] fix goofy border with a box shadow
---
src/components/date_picker/_date_picker.scss | 2 +-
src/components/form/field_text/_field_text.scss | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/components/date_picker/_date_picker.scss b/src/components/date_picker/_date_picker.scss
index a4c9a2b156f..c9fdf303b3d 100644
--- a/src/components/date_picker/_date_picker.scss
+++ b/src/components/date_picker/_date_picker.scss
@@ -195,7 +195,7 @@
transform: scale(1.2) rotate(-90deg);
background-color: $euiColorLightestShade;
border-radius: $euiBorderRadius;
- outline: solid ($euiSizeXS / 2) $euiColorLightestShade;
+ box-shadow: 0 0 0 ($euiSizeXS / 2) $euiColorLightestShade;
}
&--disabled,
diff --git a/src/components/form/field_text/_field_text.scss b/src/components/form/field_text/_field_text.scss
index a7120c7f315..fc84e45e4dd 100644
--- a/src/components/form/field_text/_field_text.scss
+++ b/src/components/form/field_text/_field_text.scss
@@ -3,6 +3,9 @@
@include euiFormControlWithIcon($isIconOptional: true);
@include euiFormControlIsLoading;
+ /* Invalid state normally comes from :invalid, but several components
+ /* like EuiDatePicker need it toggled through an extra class.
+ */
&.euiFieldText-isInvalid {
@include euiFormControlInvalidStyle;
}
From 19e67ba68ee711291fcdc7842057dd1373ec813e Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Thu, 12 Apr 2018 14:15:48 -0700
Subject: [PATCH 31/42] use clock icon if only time select, format date
properly
---
src-docs/src/views/date_picker/time_select.js | 1 +
src/components/date_picker/date_picker.js | 10 +++++++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src-docs/src/views/date_picker/time_select.js b/src-docs/src/views/date_picker/time_select.js
index 2b8fd4dd4f8..1e8192f349e 100644
--- a/src-docs/src/views/date_picker/time_select.js
+++ b/src-docs/src/views/date_picker/time_select.js
@@ -45,6 +45,7 @@ export default class extends Component {
diff --git a/src/components/date_picker/date_picker.js b/src/components/date_picker/date_picker.js
index ae9b7f68df0..7fd2a73ba1e 100644
--- a/src/components/date_picker/date_picker.js
+++ b/src/components/date_picker/date_picker.js
@@ -91,15 +91,19 @@ export class EuiDatePicker extends Component {
className
);
- let showIcon = true;
+ let optionalIcon;
if (inline || customInput) {
- showIcon = false;
+ optionalIcon = null;
+ } else if (showTimeSelectOnly) {
+ optionalIcon = "clock";
+ } else {
+ optionalIcon = "calendar";
}
let datePickerOrError = (
From 968e1b6569fa1d23da8b377e7644d1e39987d38e Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Thu, 12 Apr 2018 14:25:27 -0700
Subject: [PATCH 32/42] clean up some more styling, address feedback
---
src/components/date_picker/_date_picker.scss | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/components/date_picker/_date_picker.scss b/src/components/date_picker/_date_picker.scss
index c9fdf303b3d..55e966d27ae 100644
--- a/src/components/date_picker/_date_picker.scss
+++ b/src/components/date_picker/_date_picker.scss
@@ -123,7 +123,7 @@
}
.react-datepicker__header__dropdown {
- padding: $euiSizeS 0;
+ padding: $euiSize 0 $euiSizeS 0;
}
.react-datepicker__year-dropdown-container--select,
@@ -150,7 +150,8 @@
.react-datepicker__navigation {
cursor: pointer;
position: absolute;
- top: $euiSizeS + $euiSizeXS;
+ // Pixel pushing because these are icons against text
+ top: $euiSize + ($euiSizeXS / 2);
width: 0;
padding: 0;
z-index: 1;
@@ -274,7 +275,6 @@
padding: $euiSizeXS $euiSizeS;
margin-bottom: $euiSizeXS;
text-align: right;
- font-family: $euiCodeFontFamily;
color: $euiColorDarkShade;
white-space: nowrap;
From 96fd0630163cc9f714362c1c0da93b6f394aa5f6 Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Thu, 12 Apr 2018 14:41:36 -0700
Subject: [PATCH 33/42] make time picker dropdown look similar to combo box
---
src/components/date_picker/_date_picker.scss | 21 ++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/components/date_picker/_date_picker.scss b/src/components/date_picker/_date_picker.scss
index 55e966d27ae..f1b19699b4b 100644
--- a/src/components/date_picker/_date_picker.scss
+++ b/src/components/date_picker/_date_picker.scss
@@ -59,7 +59,28 @@
}
+// When in time only mode we make the dropdown look more like the combo box styling
.react-datepicker--time-only {
+ min-width: 150px;
+
+ .react-datepicker__time-container {
+ background: $euiColorEmptyShade !important;
+
+ .react-datepicker__time {
+ // padding-left:
+
+ .react-datepicker__time-box {
+ width: 100%;
+
+ .react-datepicker__time-list li.react-datepicker__time-list-item {
+ font-size: $euiFontSizeS;
+ text-align: left;
+ color: $euiTextColor;
+ }
+ }
+ }
+ }
+
.react-datepicker__time-container {
border-left: 0;
From aef7b8daa27912b2caab9355aef4316255348756 Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Thu, 12 Apr 2018 14:52:46 -0700
Subject: [PATCH 34/42] more time only styling
---
src/components/date_picker/_date_picker.scss | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/components/date_picker/_date_picker.scss b/src/components/date_picker/_date_picker.scss
index f1b19699b4b..5db67e3c186 100644
--- a/src/components/date_picker/_date_picker.scss
+++ b/src/components/date_picker/_date_picker.scss
@@ -59,15 +59,13 @@
}
-// When in time only mode we make the dropdown look more like the combo box styling
+// When in time only mode we make the dropdown look more like the combo box styling.
.react-datepicker--time-only {
- min-width: 150px;
.react-datepicker__time-container {
background: $euiColorEmptyShade !important;
.react-datepicker__time {
- // padding-left:
.react-datepicker__time-box {
width: 100%;
@@ -75,7 +73,13 @@
.react-datepicker__time-list li.react-datepicker__time-list-item {
font-size: $euiFontSizeS;
text-align: left;
+ padding-left: $euiSizeXL + $euiSizeXS;
+ padding-right: $euiSizeXL + $euiSizeXS;
color: $euiTextColor;
+
+ &.react-datepicker__time-list-item--selected {
+ color: $euiColorGhost;
+ }
}
}
}
From 1e53815ac4e05a67a5d6379932b2a4efb4f836df Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Thu, 12 Apr 2018 15:25:43 -0700
Subject: [PATCH 35/42] update to react-datepicker@1.4.1
---
package.json | 2 +-
yarn.lock | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/package.json b/package.json
index 6f01218eed1..45d3e395773 100644
--- a/package.json
+++ b/package.json
@@ -42,7 +42,7 @@
"prop-types": "^15.6.0",
"react-ace": "^5.5.0",
"react-color": "^2.13.8",
- "react-datepicker": "v1.4.0",
+ "react-datepicker": "v1.4.1",
"react-input-autosize": "^2.2.1",
"serve": "^6.3.1",
"tabbable": "^1.1.0",
diff --git a/yarn.lock b/yarn.lock
index bee4c7e29a7..b2615d89593 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -7194,9 +7194,9 @@ react-color@^2.13.8:
reactcss "^1.2.0"
tinycolor2 "^1.4.1"
-react-datepicker@v1.4.0:
- version "1.4.0"
- resolved "https://registry.yarnpkg.com/react-datepicker/-/react-datepicker-1.4.0.tgz#3043afe7c1b65640e75c86d67fe3d5fbe844e413"
+react-datepicker@v1.4.1:
+ version "1.4.1"
+ resolved "https://registry.yarnpkg.com/react-datepicker/-/react-datepicker-1.4.1.tgz#ee171b71d9853e56f9eece5fc3186402f4648683"
dependencies:
classnames "^2.2.5"
prop-types "^15.6.0"
From cab7fb4ba6f30bda33f6a6ae22b9597e840c17cc Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Thu, 12 Apr 2018 15:26:55 -0700
Subject: [PATCH 36/42] remove constructor, address feedback
---
src/components/date_picker/date_picker.js | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/src/components/date_picker/date_picker.js b/src/components/date_picker/date_picker.js
index 7fd2a73ba1e..2c73f198103 100644
--- a/src/components/date_picker/date_picker.js
+++ b/src/components/date_picker/date_picker.js
@@ -20,21 +20,6 @@ import {
} from '../error_boundary';
export class EuiDatePicker extends Component {
- constructor(props) {
- super(props);
-
- this.state = {
- startDate: moment()
- };
-
- this.handleChange = this.handleChange.bind(this);
- }
-
- handleChange(date) {
- this.setState({
- startDate: date
- });
- }
render() {
const {
From 1ec01ac7b8eb2ec117d6b39c636f2f41eedf9805 Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Thu, 12 Apr 2018 15:30:25 -0700
Subject: [PATCH 37/42] clean up the way errors are returned
---
src/components/date_picker/date_picker.js | 95 +++++++++++------------
1 file changed, 46 insertions(+), 49 deletions(-)
diff --git a/src/components/date_picker/date_picker.js b/src/components/date_picker/date_picker.js
index 2c73f198103..ee792ac7fe2 100644
--- a/src/components/date_picker/date_picker.js
+++ b/src/components/date_picker/date_picker.js
@@ -85,53 +85,6 @@ export class EuiDatePicker extends Component {
optionalIcon = "calendar";
}
- let datePickerOrError = (
-
-
-
-
-
-
-
- );
-
// EuiDatePicker only supports a subset of props from react-datepicker. Using any of
// the unsupported props below will spit out an error.
const PropNotSupported = () => {
@@ -161,16 +114,60 @@ export class EuiDatePicker extends Component {
// There is no reason to launch the datepicker in its own modal. Can always build these ourselves
this.props.withPortal
) {
- datePickerOrError = (
+ return (
+
);
}
return (
- {datePickerOrError}
+
+
+
+
+
+
+
);
}
From 3ffc72bedd1d42e84ded7e6a9c331af145e19a5a Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Thu, 12 Apr 2018 15:48:20 -0700
Subject: [PATCH 38/42] fix props doc error, add props docs
---
src/components/date_picker/date_picker.js | 83 ++++++++++++++++++++++-
1 file changed, 82 insertions(+), 1 deletion(-)
diff --git a/src/components/date_picker/date_picker.js b/src/components/date_picker/date_picker.js
index ee792ac7fe2..a9d158aa916 100644
--- a/src/components/date_picker/date_picker.js
+++ b/src/components/date_picker/date_picker.js
@@ -174,30 +174,111 @@ export class EuiDatePicker extends Component {
}
EuiDatePicker.propTypes = {
+ /**
+ * Optional class added to the calendar portion of datepicker
+ */
calendarClassName: PropTypes.string,
+
+ /**
+ * Added to the actual input of the calendar
+ */
className: PropTypes.string,
+ /**
+ * Replaces the input with any node, like a button
+ */
customInput: PropTypes.node,
+ /**
+ * Accepts any moment format string
+ */
dateFormat: PropTypes.string,
+ /**
+ * Applies classes to the numbered days provided. Check docs for example.
+ */
dayClassName: PropTypes.func,
+
+ /**
+ * Array of dates allowed. Check docs for example.
+ */
filterDates: PropTypes.array,
+ /**
+ * Makes the input full width
+ */
fullWidth: PropTypes.bool,
- icon: PropTypes.string,
+ /**
+ * Adds additional times to the time selector other then :30 increments
+ */
injectTimes: PropTypes.array,
+ /**
+ * Applies ref to the input
+ */
inputRef: PropTypes.func,
+ /**
+ * Provides styling to the input when invalid
+ */
isInvalid: PropTypes.bool,
+ /**
+ * Provides styling to the input when loading
+ */
isLoading: PropTypes.bool,
+ /**
+ * Switches the locale / display. "en-us", "zn-ch"...etc
+ */
locale: PropTypes.string,
+ /**
+ * The max date accepted (in moment format) as a selection
+ */
maxDate: PropTypes.instanceOf(moment),
+ /**
+ * The max time accepted (in moment format) as a selection
+ */
maxTime: PropTypes.instanceOf(moment),
+ /**
+ * The min date accepted (in moment format) as a selection
+ */
minDate: PropTypes.instanceOf(moment),
+ /**
+ * The min time accepted (in moment format) as a selection
+ */
minTime: PropTypes.instanceOf(moment),
+ /**
+ * What to do when the input changes
+ */
onChange: PropTypes.func,
+ /**
+ * Opens to this date (in moment format) on first press, regardless of selection
+ */
openToDate: PropTypes.instanceOf(moment),
+ /**
+ * Shows only when no date is selected
+ */
placeholder: PropTypes.string,
+ /**
+ * Class applied to the popup, when inline is false
+ */
popperClassName: PropTypes.string,
+ /**
+ * The selected datetime (in moment format)
+ */
selected: PropTypes.instanceOf(moment),
+ /**
+ * Can turn the shadow off if using the inline prop
+ */
+ shadow: PropTypes.bool,
+ /**
+ * Will close the popup on selection
+ */
+ shouldCloseOnSelect: PropTypes.bool,
+ /**
+ * Show the time selection alongside the calendar
+ */
showTimeSelect: PropTypes.bool,
+ /**
+ * Only show the time selector, not the calendar
+ */
showTimeSelectOnly: PropTypes.bool,
+ /**
+ * The format of the time within the selector, in moment notation
+ */
timeFormat: PropTypes.string,
};
From d68e2f668aa795c5b389571261c1e09167ac7d79 Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Thu, 12 Apr 2018 16:08:54 -0700
Subject: [PATCH 39/42] changelog
---
CHANGELOG.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 73fbc2519e5..75b53f1b2a1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)
-No public interface changes since `0.0.41`.
+- Added `euiDatePicker` component for date/time input ([#644](https://github.com/elastic/eui/pull/644))
## [`0.0.41`](https://github.com/elastic/eui/tree/v0.0.41)
From 43826fc80d7fe8dc792b8b5979fcacf7707a33e2 Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Thu, 12 Apr 2018 16:25:07 -0700
Subject: [PATCH 40/42] address feedback
---
.../views/date_picker/date_picker_example.js | 5 ++-
src/components/date_picker/_date_picker.scss | 33 ++++++++++---------
src/global_styling/mixins/_shadow.scss | 9 +++++
3 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/src-docs/src/views/date_picker/date_picker_example.js b/src-docs/src/views/date_picker/date_picker_example.js
index cd52abed2c0..85dd303289d 100644
--- a/src-docs/src/views/date_picker/date_picker_example.js
+++ b/src-docs/src/views/date_picker/date_picker_example.js
@@ -144,9 +144,8 @@ export const DatePickerExample = {
}],
text: (
- The passed icon needs to come from our list of svg icons. Can be flipped {
- // eslint-disable-next-line react/no-unescaped-entities
- } to the other side by passing iconSide="right".
+ By passing startDate and endDate props
+ you can provide styling the range in between two dates.
),
demo: ,
diff --git a/src/components/date_picker/_date_picker.scss b/src/components/date_picker/_date_picker.scss
index 5db67e3c186..b7932fdb620 100644
--- a/src/components/date_picker/_date_picker.scss
+++ b/src/components/date_picker/_date_picker.scss
@@ -3,10 +3,18 @@
**
** In places where features were disabled, I've commented out the original Sass
** selectors rather than removing it so we can better understand what's changed.
+** Commented out selectors that don't have properties indicate that we are not
+** using those dom elements for styling of any kind. For example, react-datepicker
+** has lots of pointer arrows attached to its popovers, but we choose not to render
+** then in any way.
+**
+** Similarly, you will also find several times where we use display: none to
+** completely remove extranous UI (they had some overly obvious legends for example).
*/
-// We use SVG URIs for the navigation arrows. There is one for light and dark.
+// Because we don't have control over react-datepicker's dom we use SVG URIs for the navigation arrows.
+// There is one for light and dark.
@mixin datePicker__arrow {
@if (lightness($euiColorEmptyShade) > 50) {
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiI+ICA8ZGVmcz4gICAgPHBhdGggaWQ9ImFycm93X2Rvd24tYSIgZD0iTTEzLjA2ODg1MDgsNS4xNTcyNTAzOCBMOC4zODQyMzk3NSw5Ljc2ODI3NDI4IEM4LjE3MDU0NDE1LDkuOTc4NjEzMDggNy44Mjk5OTIxNCw5Ljk3OTE0MDk1IDcuNjE1NzYwMjUsOS43NjgyNzQyOCBMMi45MzExNDkxNSw1LjE1NzI1MDM4IEMyLjcxODEzNTksNC45NDc1ODMyMSAyLjM3Mjc3MzE5LDQuOTQ3NTgzMjEgMi4xNTk3NTk5NCw1LjE1NzI1MDM4IEMxLjk0Njc0NjY5LDUuMzY2OTE3NTYgMS45NDY3NDY2OSw1LjcwNjg1NTIyIDIuMTU5NzU5OTQsNS45MTY1MjI0IEw2Ljg0NDM3MTA0LDEwLjUyNzU0NjMgQzcuNDg1MTc0MjQsMTEuMTU4MjgzNiA4LjUxNjQ0OTc5LDExLjE1NjY4NTEgOS4xNTU2Mjg5NiwxMC41Mjc1NDYzIEwxMy44NDAyNDAxLDUuOTE2NTIyNCBDMTQuMDUzMjUzMyw1LjcwNjg1NTIyIDE0LjA1MzI1MzMsNS4zNjY5MTc1NiAxMy44NDAyNDAxLDUuMTU3MjUwMzggQzEzLjYyNzIyNjgsNC45NDc1ODMyMSAxMy4yODE4NjQxLDQuOTQ3NTgzMjEgMTMuMDY4ODUwOCw1LjE1NzI1MDM4IFoiLz4gIDwvZGVmcz4gIDxnIGZpbGwtcnVsZT0iZXZlbm9kZCI+ICAgIDx1c2UgZmlsbC1ydWxlPSJub256ZXJvIiB4bGluazpocmVmPSIjYXJyb3dfZG93bi1hIi8+ICA8L2c+PC9zdmc+);
@@ -32,13 +40,13 @@
background: $euiColorLightestShade;
}
- // If the shadow is on, and it is inline, we need to put the shadow on the datepciker
+ // If the shadow is on, and it is inline, we need to put the shadow on the datepicker
// itself rather than the popper.
&.euiDatePicker--inline {
.react-datepicker {
@include euiBottomShadowMedium;
- border: 1px solid $euiBorderColor;
+ border: $euiBorderThin;
background-color: $euiColorEmptyShade;
border-radius: $euiBorderRadius;
}
@@ -101,7 +109,7 @@
// .react-datepicker__triangle {
// }
-.react-datepicker-popper {
+.euiDatePicker.euiDatePicker--shadow .react-datepicker-popper {
z-index: 1;
animation: euiAnimFadeIn $euiAnimSpeedFast ease-in;
@@ -112,11 +120,9 @@
}
&[data-placement^="top"] {
- box-shadow:
- 0 0px 12px -1px rgba($euiShadowColor, .2),
- 0 0px 4px -1px rgba($euiShadowColor, .2),
- 0 0px 2px 0 rgba($euiShadowColor, .2) !important;
- border-radius: $euiBorderRadius $euiBorderRadius 0 0 !important;
+ @include euiBottomShadowFlat;
+
+ border-radius: $euiBorderRadius $euiBorderRadius 0 0 !important;
// .react-datepicker__triangle {
// }
@@ -275,12 +281,6 @@
flex-grow: 1;
// &--with-today-button {
- // display: inline;
- // border: 1px solid #aeaeae;
- // border-radius: 0.3rem;
- // position: absolute;
- // right: auto;
- // top: 0;
// }
.react-datepicker__time {
@@ -592,6 +592,9 @@
}
}
+// The below is for the portal version of react-datepicker which we do not use.
+// It is shown here just to know what their baseline includes.
+
// .react-datepicker__close-icon {
// background-color: transparent;
// border: 0;
diff --git a/src/global_styling/mixins/_shadow.scss b/src/global_styling/mixins/_shadow.scss
index ad04dde0e2e..3470e4816ee 100644
--- a/src/global_styling/mixins/_shadow.scss
+++ b/src/global_styling/mixins/_shadow.scss
@@ -19,6 +19,15 @@ $euiShadowColorLarge: $euiColorSlightHue !default;
0 2px 2px 0 rgba($color, $opacity);
}
+// Similar to shadow medium but wihtout the bottom depth. Useful for popovers
+// that drop UP rather than DOWN.
+@mixin euiBottomShadowFlat($color: $euiShadowColor, $opacity: .2) {
+ box-shadow:
+ 0 0px 12px -1px rgba($color, $opacity),
+ 0 0px 4px -1px rgba($color, $opacity),
+ 0 0px 2px 0 rgba($color, $opacity);
+}
+
@mixin euiBottomShadow($color: $euiShadowColor, $opacity: .2) {
box-shadow:
0 12px 24px 0 rgba($color, $opacity),
From ca034806cf9826ef398bc61251a339141408b132 Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Thu, 12 Apr 2018 16:26:26 -0700
Subject: [PATCH 41/42] pesky outline
---
src/components/date_picker/_date_picker.scss | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/date_picker/_date_picker.scss b/src/components/date_picker/_date_picker.scss
index b7932fdb620..2ecd79b7fd3 100644
--- a/src/components/date_picker/_date_picker.scss
+++ b/src/components/date_picker/_date_picker.scss
@@ -198,7 +198,7 @@
&:hover {
background-color: $euiColorLightestShade;
border-radius: $euiBorderRadius;
- outline: solid ($euiSizeXS / 2) $euiColorLightestShade;
+ box-shadow: 0 0 0 ($euiSizeXS / 2) $euiColorLightestShade;
transform: scale(1.2) rotate(90deg);
}
From 9d22f332cb5c462ebd9d2d0961eff581dc0b0d88 Mon Sep 17 00:00:00 2001
From: Dave Snider
Date: Thu, 12 Apr 2018 16:28:42 -0700
Subject: [PATCH 42/42] docs and borders
---
src-docs/src/views/date_picker/date_picker_example.js | 5 ++---
src/components/date_picker/_date_picker.scss | 4 ++--
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/src-docs/src/views/date_picker/date_picker_example.js b/src-docs/src/views/date_picker/date_picker_example.js
index 85dd303289d..4bd9ca9ecd2 100644
--- a/src-docs/src/views/date_picker/date_picker_example.js
+++ b/src-docs/src/views/date_picker/date_picker_example.js
@@ -88,9 +88,8 @@ export const DatePickerExample = {
}],
text: (
- The passed icon needs to come from our list of svg icons. Can be flipped {
- // eslint-disable-next-line react/no-unescaped-entities
- } to the other side by passing iconSide="right".
+ Examples of how the input can appear within a form. This should match our
+ other form styles.