pebble-web 2.5.0 → 2.7.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.5.0",
3
+ "version": "2.7.0",
4
4
  "author": "ritz078 <rkritesh078@gmail.com>",
5
5
  "license": "MIT",
6
6
  "main": "dist/pebble-web.js",
@@ -44,12 +44,12 @@
44
44
  "utility-types": "^3.10.0"
45
45
  },
46
46
  "devDependencies": {
47
- "pebble-shared": "^2.4.0"
47
+ "pebble-shared": "^2.6.0"
48
48
  },
49
49
  "greenkeeper": {
50
50
  "ignore": [
51
51
  "rheostat"
52
52
  ]
53
53
  },
54
- "gitHead": "caa00f9df1eadf04e33d85e4e7e40ab0386ed5b2"
54
+ "gitHead": "17ffd0408f8ba57c3d4ef1342da8c696924bd5db"
55
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
  );
@@ -5,16 +5,16 @@ import {
5
5
  sidebarWrapperStyle
6
6
  } from "./styles/Sidebar.styles";
7
7
  import { SidebarProps } from "./typings/Sidebar";
8
- import { Transition, animated } from "react-spring/renderprops.cjs";
8
+ import { animated } from "react-spring/renderprops.cjs";
9
9
  import Ink from "react-ink";
10
10
  import { css, cx } from "emotion";
11
11
  import { disableScrollY } from "../theme/styles";
12
- import { animationConfig } from "../utils/animation";
12
+ import MountTransition from "./shared/MountTransition";
13
13
 
14
14
  const transitionProps = {
15
- from: { opacity: 0 },
16
- enter: { opacity: 1 },
17
- leave: { opacity: 0 }
15
+ from: { opacity: 0, transform: "translateX(100%)" },
16
+ enter: { opacity: 1, transform: "translateX(0)" },
17
+ leave: { opacity: 0, transform: "translateX(100%)", pointerEvents: "none" }
18
18
  };
19
19
 
20
20
  class SideBar extends React.PureComponent<SidebarProps> {
@@ -57,65 +57,36 @@ class SideBar extends React.PureComponent<SidebarProps> {
57
57
  onOutsideClick,
58
58
  closeOnOutsideClick
59
59
  } = this.props;
60
- const _sidebarOverride = css({
61
- width,
62
- transform: isOpen ? `translateX(0)` : `translateX(${width}px)`
63
- });
64
- const _sidebarStyle = cx(
65
- _sidebarOverride,
66
- sidebarStyle,
67
- css({
68
- transform: isOpen ? `translateX(0)` : `translateX(100%)`
69
- })
70
- );
60
+ const _sidebarStyle = cx(sidebarStyle, css({ width }));
71
61
 
72
62
  return (
73
- <React.Fragment>
74
- <Transition
75
- items={isOpen}
76
- {...transitionProps}
77
- config={animationConfig.config}
78
- >
79
- {show =>
80
- show &&
81
- (styles => (
82
- <animated.div
83
- style={styles}
84
- className={sidebarWrapperStyle}
85
- onClick={
86
- onOutsideClick || closeOnOutsideClick
87
- ? this.onOutsideClick
88
- : undefined
89
- }
90
- data-testid="shadowArea"
91
- />
92
- ))
93
- }
94
- </Transition>
63
+ <MountTransition visible={isOpen} {...transitionProps}>
64
+ {styles => (
65
+ <>
66
+ <animated.div
67
+ style={{ opacity: styles.opacity }}
68
+ className={sidebarWrapperStyle}
69
+ onClick={
70
+ onOutsideClick || closeOnOutsideClick
71
+ ? this.onOutsideClick
72
+ : undefined
73
+ }
74
+ data-testid="shadowArea"
75
+ />
76
+
77
+ <animated.div className={_sidebarStyle} style={styles}>
78
+ <div className={closeStyle} onClick={onClose}>
79
+ <i className="pi pi-close" />
80
+ <Ink />
81
+ </div>
95
82
 
96
- <div className={_sidebarStyle}>
97
- <Transition items={isOpen} {...transitionProps}>
98
- {show =>
99
- show &&
100
- (styles => (
101
- <animated.div
102
- style={styles}
103
- className={closeStyle}
104
- onClick={onClose}
105
- >
106
- <i className="pi pi-close" />
107
- <Ink />
108
- </animated.div>
109
- ))
110
- }
111
- </Transition>
112
- {isOpen && (
113
- <div style={{ overflowY: "scroll", height: "100vh" }}>
114
- {children}
115
- </div>
116
- )}
117
- </div>
118
- </React.Fragment>
83
+ <div style={{ overflowY: "scroll", height: "100vh" }}>
84
+ {children}
85
+ </div>
86
+ </animated.div>
87
+ </>
88
+ )}
89
+ </MountTransition>
119
90
  );
120
91
  }
121
92
  }
@@ -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
+ })
@@ -44,7 +44,6 @@ export const closeStyle = css({
44
44
  });
45
45
 
46
46
  export const sidebarStyle = css({
47
- transition: `transform 200ms ${constants.animationCurve}`,
48
47
  backgroundColor: colors.white.base,
49
48
  position: "fixed",
50
49
  top: 0,
@@ -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 {
@@ -5,5 +5,5 @@ export const animationConfig = {
5
5
  enter: { opacity: 1, transform: "scale(1)" },
6
6
  leave: { opacity: 0, transform: "scale(0.95)", pointerEvents: "none" },
7
7
  config: (_a: boolean, motion: State) =>
8
- motion === "leave" ? { duration: 0.1 } : { duration: 200 }
8
+ motion === "leave" ? { duration: 80 } : { duration: 200 }
9
9
  };