pebble-web 2.4.2 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pebble-web",
3
- "version": "2.4.2",
3
+ "version": "2.6.0",
4
4
  "author": "ritz078 <rkritesh078@gmail.com>",
5
5
  "license": "MIT",
6
6
  "main": "dist/pebble-web.js",
@@ -44,11 +44,12 @@
44
44
  "utility-types": "^3.10.0"
45
45
  },
46
46
  "devDependencies": {
47
- "pebble-shared": "^2.3.2"
47
+ "pebble-shared": "^2.5.0"
48
48
  },
49
49
  "greenkeeper": {
50
50
  "ignore": [
51
51
  "rheostat"
52
52
  ]
53
- }
53
+ },
54
+ "gitHead": "10642c163578a97858d3df92ec9532d01c2cbc52"
54
55
  }
@@ -5,7 +5,8 @@ import {
5
5
  dateClass,
6
6
  dropDownClassName,
7
7
  inputStyle,
8
- wrapperStyle
8
+ wrapperStyle,
9
+ errorStyle
9
10
  } from "./styles/Date.styles";
10
11
  import Calendar from "./Calendar";
11
12
  import Input from "./Input";
@@ -83,7 +84,8 @@ export default class DateInput extends React.PureComponent<
83
84
  inputProps,
84
85
  placeholder,
85
86
  value: propsValue,
86
- disabled
87
+ disabled,
88
+ errorMessage
87
89
  } = this.props;
88
90
 
89
91
  return (
@@ -100,7 +102,7 @@ export default class DateInput extends React.PureComponent<
100
102
  onChange={noop}
101
103
  type={"tel"}
102
104
  value={value}
103
- placeholder={`${placeholder} DD/MM/YYYY`}
105
+ placeholder={placeholder}
104
106
  onClick={() => {
105
107
  if (disabled) return;
106
108
  toggleDropdown();
@@ -123,17 +125,20 @@ export default class DateInput extends React.PureComponent<
123
125
  modifiers={modifiers}
124
126
  >
125
127
  {({ toggle }) => (
126
- <Calendar
127
- hideShadow
128
- className={dateClass}
129
- selected={propsValue ? new Date(propsValue) : undefined}
130
- {...calendarProps}
131
- range={false}
132
- onChange={date => {
133
- this.onCalendarDateChange(date);
134
- toggle();
135
- }}
136
- />
128
+ <>
129
+ <Calendar
130
+ hideShadow
131
+ className={dateClass}
132
+ selected={propsValue ? new Date(propsValue) : undefined}
133
+ {...calendarProps}
134
+ range={false}
135
+ onChange={date => {
136
+ this.onCalendarDateChange(date);
137
+ toggle();
138
+ }}
139
+ />
140
+ {errorMessage && <div className={errorStyle}>{errorMessage}</div>}
141
+ </>
137
142
  )}
138
143
  </DropDown>
139
144
  );
@@ -12,14 +12,15 @@ describe("DateInput", () => {
12
12
  const changeSpy = sinon.spy();
13
13
 
14
14
  const dateInput = mount(
15
- <DateInput placeholder="Select Date" onChange={changeSpy} value={date} />
15
+ <DateInput
16
+ placeholder="Select Date DD/MM/YYYY"
17
+ onChange={changeSpy}
18
+ value={date}
19
+ />
16
20
  );
17
21
  dateInput.find(Input).simulate("click");
18
22
 
19
- dateInput
20
- .find(".react-calendar__tile")
21
- .at(0)
22
- .simulate("click");
23
+ dateInput.find(".react-calendar__tile").at(0).simulate("click");
23
24
 
24
25
  expect(changeSpy.calledOnce).toBeTruthy();
25
26
 
@@ -1,4 +1,6 @@
1
1
  import { css } from "emotion";
2
+ import { colors } from "pebble-shared";
3
+ import { typography } from "../../theme";
2
4
  import { inputMarginBottom } from "./Input.styles";
3
5
 
4
6
  export const dateClass = css({
@@ -17,3 +19,11 @@ export const inputStyle = css({
17
19
  export const wrapperStyle = css({
18
20
  marginBottom: 20
19
21
  });
22
+
23
+ export const errorStyle = css({
24
+ ...typography.s.bold,
25
+ backgroundColor: colors.red.lightest,
26
+ color: colors.red.darker,
27
+ textAlign: "left",
28
+ padding: "11px 30px",
29
+ })
@@ -9,6 +9,7 @@ export interface DateInputProps {
9
9
  inputProps?: Omit<SimpleInputProps, "value" | "onChange" | "placeholder">;
10
10
  calendarProps?: DateSingle;
11
11
  disabled?: boolean;
12
+ errorMessage?: string;
12
13
  }
13
14
 
14
15
  export interface DateInputState {