pebble-web 2.26.1 → 3.0.0-alpha.1
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/dist/components/shared/MountTransition.d.ts +4 -4
- package/dist/pebble-web.dev.js +37 -35
- package/dist/pebble-web.dev.js.map +1 -1
- package/dist/pebble-web.es.dev.js +21 -16
- package/dist/pebble-web.es.dev.js.map +1 -1
- package/dist/pebble-web.es.js +20 -15
- package/dist/pebble-web.es.js.map +1 -1
- package/dist/pebble-web.js +36 -34
- package/dist/pebble-web.js.map +1 -1
- package/dist/pebble-web.module.dev.js +31 -29
- package/dist/pebble-web.module.dev.js.map +1 -1
- package/dist/pebble-web.module.js +30 -28
- package/dist/pebble-web.module.js.map +1 -1
- package/dist/pebble-web.umd.dev.js +3329 -1832
- package/dist/pebble-web.umd.dev.js.map +1 -1
- package/dist/pebble-web.umd.js +3340 -1843
- package/dist/pebble-web.umd.js.map +1 -1
- package/dist/utils/animation.d.ts +6 -18
- package/package.json +2 -2
- package/src/components/DropDown.tsx +6 -6
- package/src/components/Modal.tsx +10 -11
- package/src/components/Popper.tsx +6 -5
- package/src/components/Sidebar.tsx +1 -1
- package/src/components/Toast.tsx +4 -5
- package/src/components/TypeAhead.tsx +2 -2
- package/src/components/__tests__/__snapshots__/popper.test.tsx.snap +1 -1
- package/src/components/shared/MountTransition.tsx +25 -14
- package/src/utils/animation.ts +13 -4
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
enter: {
|
|
8
|
-
opacity: number;
|
|
9
|
-
transform: string;
|
|
10
|
-
};
|
|
11
|
-
leave: {
|
|
12
|
-
opacity: number;
|
|
13
|
-
transform: string;
|
|
14
|
-
pointerEvents: string;
|
|
15
|
-
};
|
|
16
|
-
config: (_a: boolean, motion: State) => {
|
|
17
|
-
duration: number;
|
|
18
|
-
};
|
|
1
|
+
import { TransitionState, UseTransitionProps } from "react-spring";
|
|
2
|
+
export declare type TransitionPhase = TransitionState["phase"];
|
|
3
|
+
export declare const animationConfig: UseTransitionProps<boolean>;
|
|
4
|
+
export declare type AnimationStyle = {
|
|
5
|
+
opacity: number;
|
|
6
|
+
transform: string;
|
|
19
7
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pebble-web",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.1",
|
|
4
4
|
"author": "ritz078 <rkritesh078@gmail.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/pebble-web.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"react-calendar": "^2.19.2",
|
|
38
38
|
"react-ink": "^6.4.0",
|
|
39
39
|
"react-popper": "^1.3.6",
|
|
40
|
-
"react-spring": "^
|
|
40
|
+
"react-spring": "^9.7.4",
|
|
41
41
|
"rheostat": "2.2.0",
|
|
42
42
|
"rifm": "^0.12.0",
|
|
43
43
|
"scroll-into-view-if-needed": "^2.2.25",
|
|
@@ -4,7 +4,7 @@ import { DropDownButton } from "./Button";
|
|
|
4
4
|
import { dropDownStyle, wrapperStyle } from "./styles/Dropdown.styles";
|
|
5
5
|
import { cx } from "emotion";
|
|
6
6
|
import OutsideClick from "./OutsideClick";
|
|
7
|
-
import { animated } from "react-spring
|
|
7
|
+
import { animated } from "react-spring";
|
|
8
8
|
import MountTransition from "./shared/MountTransition";
|
|
9
9
|
import { Manager, Reference, Popper } from "react-popper";
|
|
10
10
|
import { colors } from "pebble-shared";
|
|
@@ -105,9 +105,9 @@ class DropDown extends React.PureComponent<DropdownProps, DropdownState> {
|
|
|
105
105
|
...style,
|
|
106
106
|
...transitionStyles,
|
|
107
107
|
backgroundColor: colors.white.base,
|
|
108
|
-
transform:
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
transform: transitionStyles.transform.to(
|
|
109
|
+
t => `${style.transform || ""} ${t || ""}`
|
|
110
|
+
),
|
|
111
111
|
transformOrigin: `${arrowProps.style.left || 0}px ${
|
|
112
112
|
arrowProps.style.top || 0
|
|
113
113
|
}px`,
|
|
@@ -115,7 +115,7 @@ class DropDown extends React.PureComponent<DropdownProps, DropdownState> {
|
|
|
115
115
|
};
|
|
116
116
|
|
|
117
117
|
return (
|
|
118
|
-
<div
|
|
118
|
+
<animated.div
|
|
119
119
|
className={cx(dropDownStyle, dropDownClassName)}
|
|
120
120
|
ref={ref}
|
|
121
121
|
style={popperWrapperStyle}
|
|
@@ -125,7 +125,7 @@ class DropDown extends React.PureComponent<DropdownProps, DropdownState> {
|
|
|
125
125
|
toggle: this.toggleDropdown,
|
|
126
126
|
isOpen: _isDropDownOpen
|
|
127
127
|
})}
|
|
128
|
-
</div>
|
|
128
|
+
</animated.div>
|
|
129
129
|
);
|
|
130
130
|
}}
|
|
131
131
|
</Popper>
|
package/src/components/Modal.tsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { ModalProps } from "./typings/Modal";
|
|
3
3
|
import { modalContainer } from "./styles/Modal.styles";
|
|
4
|
-
import { cx
|
|
4
|
+
import { cx } from "emotion";
|
|
5
5
|
import isBrowser from "is-in-browser";
|
|
6
6
|
import * as ReactDOM from "react-dom";
|
|
7
7
|
import MountTransition from "./shared/MountTransition";
|
|
8
|
+
import { animated } from "react-spring";
|
|
8
9
|
|
|
9
10
|
class Modal extends React.PureComponent<ModalProps> {
|
|
10
11
|
private node = isBrowser ? document.createElement("div") : null;
|
|
@@ -41,23 +42,21 @@ class Modal extends React.PureComponent<ModalProps> {
|
|
|
41
42
|
// tslint:disable-next-line:jsx-wrap-multiline
|
|
42
43
|
<MountTransition visible={visible}>
|
|
43
44
|
{transitionStyles => (
|
|
44
|
-
<div
|
|
45
|
+
<animated.div
|
|
45
46
|
style={{
|
|
46
47
|
opacity: transitionStyles.opacity
|
|
47
48
|
}}
|
|
48
49
|
className={cx(modalContainer, backDropClassName)}
|
|
49
50
|
>
|
|
50
|
-
<div
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
modalClassName
|
|
56
|
-
)}
|
|
51
|
+
<animated.div
|
|
52
|
+
style={{
|
|
53
|
+
transform: transitionStyles.transform
|
|
54
|
+
}}
|
|
55
|
+
className={modalClassName}
|
|
57
56
|
>
|
|
58
57
|
{children}
|
|
59
|
-
</div>
|
|
60
|
-
</div>
|
|
58
|
+
</animated.div>
|
|
59
|
+
</animated.div>
|
|
61
60
|
)}
|
|
62
61
|
</MountTransition>,
|
|
63
62
|
node as NonNullable<typeof node>
|
|
@@ -6,6 +6,7 @@ import { colors } from "pebble-shared";
|
|
|
6
6
|
import { cx } from "emotion";
|
|
7
7
|
import OutsideClick from "./OutsideClick";
|
|
8
8
|
import MountTransition from "./shared/MountTransition";
|
|
9
|
+
import { animated } from "react-spring";
|
|
9
10
|
|
|
10
11
|
export default class PebblePopper extends React.PureComponent<
|
|
11
12
|
PopperProps,
|
|
@@ -71,16 +72,16 @@ export default class PebblePopper extends React.PureComponent<
|
|
|
71
72
|
...style,
|
|
72
73
|
...transitionStyles,
|
|
73
74
|
backgroundColor: popperBackgroundColor,
|
|
74
|
-
transform:
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
transform: transitionStyles.transform.to(
|
|
76
|
+
t => `${style.transform || ""} ${t || ""}`
|
|
77
|
+
),
|
|
77
78
|
transformOrigin: `${arrowProps.style.left || 0}px ${
|
|
78
79
|
arrowProps.style.top || 0
|
|
79
80
|
}px`
|
|
80
81
|
};
|
|
81
82
|
|
|
82
83
|
return (
|
|
83
|
-
<div
|
|
84
|
+
<animated.div
|
|
84
85
|
className={cx(popperStyle, popperClassName)}
|
|
85
86
|
ref={ref}
|
|
86
87
|
style={wrapperStyle}
|
|
@@ -101,7 +102,7 @@ export default class PebblePopper extends React.PureComponent<
|
|
|
101
102
|
>
|
|
102
103
|
▶
|
|
103
104
|
</div>
|
|
104
|
-
</div>
|
|
105
|
+
</animated.div>
|
|
105
106
|
);
|
|
106
107
|
}}
|
|
107
108
|
</Popper>
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
sidebarWrapperStyle
|
|
6
6
|
} from "./styles/Sidebar.styles";
|
|
7
7
|
import { SidebarProps } from "./typings/Sidebar";
|
|
8
|
-
import { animated } from "react-spring
|
|
8
|
+
import { animated } from "react-spring";
|
|
9
9
|
import Ink from "react-ink";
|
|
10
10
|
import { css, cx } from "emotion";
|
|
11
11
|
import { disableScrollY } from "../theme/styles";
|
package/src/components/Toast.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
ToastType,
|
|
8
8
|
ToastPosition
|
|
9
9
|
} from "./typings/Toast";
|
|
10
|
-
import { Transition, animated } from "react-spring
|
|
10
|
+
import { Transition, animated } from "react-spring";
|
|
11
11
|
import { cx } from "emotion";
|
|
12
12
|
import mitt from "mitt";
|
|
13
13
|
import { animationConfig } from "../utils/animation";
|
|
@@ -188,9 +188,8 @@ class Toast extends React.PureComponent<ToastProps, ToastState> {
|
|
|
188
188
|
}}
|
|
189
189
|
config={animationConfig.config}
|
|
190
190
|
>
|
|
191
|
-
{show =>
|
|
192
|
-
show &&
|
|
193
|
-
(styles => (
|
|
191
|
+
{(styles, show) =>
|
|
192
|
+
show && (
|
|
194
193
|
<animated.div
|
|
195
194
|
className={cx(toastWrapper, this.props.className)}
|
|
196
195
|
style={{
|
|
@@ -202,7 +201,7 @@ class Toast extends React.PureComponent<ToastProps, ToastState> {
|
|
|
202
201
|
<i className={iconClass} />
|
|
203
202
|
{this.state.text}
|
|
204
203
|
</animated.div>
|
|
205
|
-
)
|
|
204
|
+
)
|
|
206
205
|
}
|
|
207
206
|
</Transition>
|
|
208
207
|
);
|
|
@@ -10,7 +10,7 @@ import Input from "./Input";
|
|
|
10
10
|
import { optionsWrapper, wrapper } from "./styles/TypeAhead.styles";
|
|
11
11
|
import OutsideClick from "./OutsideClick";
|
|
12
12
|
import OptionGroupRadio from "./OptionGroupRadio";
|
|
13
|
-
import { animated } from "react-spring
|
|
13
|
+
import { animated } from "react-spring";
|
|
14
14
|
import MountTransition from "./shared/MountTransition";
|
|
15
15
|
import { getTestIds, getTypeaheadTestIds } from "../utils/testIds";
|
|
16
16
|
|
|
@@ -129,7 +129,7 @@ export default class TypeAhead<OptionType> extends React.PureComponent<
|
|
|
129
129
|
}
|
|
130
130
|
)}
|
|
131
131
|
|
|
132
|
-
<MountTransition visible={showSuggestions}
|
|
132
|
+
<MountTransition visible={showSuggestions}>
|
|
133
133
|
{transitionStyles => (
|
|
134
134
|
<animated.div
|
|
135
135
|
style={transitionStyles}
|
|
@@ -1,29 +1,40 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import {
|
|
3
|
-
State,
|
|
4
3
|
Transition,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
UseTransitionProps,
|
|
5
|
+
SpringValues,
|
|
6
|
+
TransitionComponentProps
|
|
7
|
+
} from "react-spring";
|
|
8
|
+
import {
|
|
9
|
+
animationConfig,
|
|
10
|
+
TransitionPhase,
|
|
11
|
+
AnimationStyle
|
|
12
|
+
} from "../../utils/animation";
|
|
9
13
|
|
|
10
|
-
interface MountTransitionProps
|
|
11
|
-
extends Omit<Omit<TransitionProps<boolean>, "items">, "children"> {
|
|
14
|
+
interface MountTransitionProps extends UseTransitionProps<boolean> {
|
|
12
15
|
visible: boolean;
|
|
13
16
|
children: (
|
|
14
|
-
params:
|
|
15
|
-
state:
|
|
17
|
+
params: SpringValues<AnimationStyle>,
|
|
18
|
+
state: TransitionPhase,
|
|
16
19
|
index: number
|
|
17
20
|
) => React.ReactNode;
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
const MountTransition: React.FunctionComponent<MountTransitionProps> = props => {
|
|
21
24
|
return (
|
|
22
|
-
<Transition
|
|
23
|
-
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
<Transition<boolean, TransitionComponentProps<boolean>>
|
|
26
|
+
items={props.visible}
|
|
27
|
+
{...animationConfig}
|
|
28
|
+
{...props}
|
|
29
|
+
>
|
|
30
|
+
{(styles, show, { phase }, index) => {
|
|
31
|
+
if (!show) return null;
|
|
32
|
+
return props.children(
|
|
33
|
+
styles as SpringValues<AnimationStyle>,
|
|
34
|
+
phase,
|
|
35
|
+
index
|
|
36
|
+
);
|
|
37
|
+
}}
|
|
27
38
|
</Transition>
|
|
28
39
|
);
|
|
29
40
|
};
|
package/src/utils/animation.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TransitionState, UseTransitionProps } from "react-spring";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// TransitionPhase enum is not exported by react-spring package
|
|
4
|
+
// so we alias it as a type here
|
|
5
|
+
export type TransitionPhase = TransitionState["phase"];
|
|
6
|
+
|
|
7
|
+
export const animationConfig: UseTransitionProps<boolean> = {
|
|
4
8
|
from: { opacity: 0, transform: "scale(0.95)" },
|
|
5
9
|
enter: { opacity: 1, transform: "scale(1)" },
|
|
6
10
|
leave: { opacity: 0, transform: "scale(0.95)", pointerEvents: "none" },
|
|
7
|
-
config: (
|
|
8
|
-
|
|
11
|
+
config: (_show, _index, state) =>
|
|
12
|
+
state === "leave" ? { duration: 80 } : { duration: 200 }
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type AnimationStyle = {
|
|
16
|
+
opacity: number;
|
|
17
|
+
transform: string;
|
|
9
18
|
};
|