@jobber/components 4.20.4 → 4.20.5-JOB-70296.10
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/AnimatedSwitcher.d.ts +1 -0
- package/AnimatedSwitcher.js +17 -0
- package/dist/AnimatedSwitcher/AnimatedSwitcher.d.ts +31 -0
- package/dist/AnimatedSwitcher/index.d.ts +1 -0
- package/dist/AnimatedSwitcher/index.js +99 -0
- package/dist/AnimatedSwitcher/transitions.d.ts +8 -0
- package/dist/InputText/InputText.d.ts +6 -6
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./dist/AnimatedSwitcher";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true,
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var AnimatedSwitcher = require("./dist/AnimatedSwitcher");
|
|
8
|
+
|
|
9
|
+
Object.keys(AnimatedSwitcher).forEach(function(key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
Object.defineProperty(exports, key, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function get() {
|
|
14
|
+
return AnimatedSwitcher[key];
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
import { IconNames } from "@jobber/design";
|
|
3
|
+
export interface AnimatedSwitcherProps {
|
|
4
|
+
/**
|
|
5
|
+
* Determines when to switch the component to the `switchTo` prop.
|
|
6
|
+
*
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
readonly switched: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The component that shows up when the `switched` prop is `false`
|
|
12
|
+
*/
|
|
13
|
+
readonly initialChild: ReactElement;
|
|
14
|
+
/**
|
|
15
|
+
* The component that shows up when the `switched` prop is `true`
|
|
16
|
+
*/
|
|
17
|
+
readonly switchTo: ReactElement;
|
|
18
|
+
/**
|
|
19
|
+
* Change the transition between 2 elements.
|
|
20
|
+
*/
|
|
21
|
+
readonly type?: "slideFromBottom" | "fade";
|
|
22
|
+
}
|
|
23
|
+
export declare function AnimatedSwitcher({ initialChild, switched, switchTo, type, }: AnimatedSwitcherProps): JSX.Element;
|
|
24
|
+
export declare namespace AnimatedSwitcher {
|
|
25
|
+
var Icon: ({ switchToIcon, switched, initialIcon, }: AnimatedSwitcherIconProps) => JSX.Element;
|
|
26
|
+
}
|
|
27
|
+
interface AnimatedSwitcherIconProps extends Pick<AnimatedSwitcherProps, "switched"> {
|
|
28
|
+
readonly initialIcon: IconNames;
|
|
29
|
+
readonly switchToIcon: IconNames;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AnimatedSwitcher";
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var framerMotion = require('framer-motion');
|
|
7
|
+
var Icon = require('../Icon-405a216c.js');
|
|
8
|
+
require('@jobber/design');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
13
|
+
|
|
14
|
+
const DURATION_SIMPLE = 0.1;
|
|
15
|
+
const DURATION_AVERAGE = 0.2;
|
|
16
|
+
const FADE = {
|
|
17
|
+
visible: { opacity: 1 },
|
|
18
|
+
hidden: { opacity: 0 },
|
|
19
|
+
};
|
|
20
|
+
const SLIDE_IN_UP = {
|
|
21
|
+
visible: { y: 0, opacity: 1 },
|
|
22
|
+
hidden: { y: "10%", opacity: 0 },
|
|
23
|
+
};
|
|
24
|
+
const SLIDE_IN_DOWN = {
|
|
25
|
+
visible: { y: 0, opacity: 1 },
|
|
26
|
+
hidden: { y: "-10%", opacity: 0 },
|
|
27
|
+
};
|
|
28
|
+
const SPIN_COUNTER_CLOCK_WISE = {
|
|
29
|
+
visible: {
|
|
30
|
+
rotate: 0,
|
|
31
|
+
scale: 1,
|
|
32
|
+
transition: { duration: DURATION_AVERAGE, ease: "easeOut" },
|
|
33
|
+
},
|
|
34
|
+
hidden: {
|
|
35
|
+
rotate: 180,
|
|
36
|
+
scale: 0.6,
|
|
37
|
+
transition: { duration: DURATION_AVERAGE, ease: "easeIn" },
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
const SPIN_CLOCK_WISE = {
|
|
41
|
+
visible: {
|
|
42
|
+
rotate: 0,
|
|
43
|
+
scale: 1,
|
|
44
|
+
transition: { duration: DURATION_AVERAGE, ease: "easeOut" },
|
|
45
|
+
},
|
|
46
|
+
hidden: {
|
|
47
|
+
rotate: -180,
|
|
48
|
+
scale: 0.6,
|
|
49
|
+
transition: { duration: DURATION_AVERAGE, ease: "easeIn" },
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function AnimatedSwitcher({ initialChild, switched, switchTo, type = "slideFromBottom", }) {
|
|
54
|
+
const [ref, setRef] = React.useState(null);
|
|
55
|
+
const isSwitchingBetweenIcons = initialChild.type === Icon.Icon && switchTo.type === Icon.Icon;
|
|
56
|
+
const { key, transition, child, duration } = getChildData();
|
|
57
|
+
return (React__default["default"].createElement(framerMotion.AnimatePresence, { exitBeforeEnter: true, initial: false },
|
|
58
|
+
React__default["default"].createElement(framerMotion.motion.div, { ref: setRef, key: key, variants: transition, initial: "hidden", animate: "visible", exit: "hidden", transition: { duration }, style: { display: getDisplayValue() } }, child)));
|
|
59
|
+
function getDisplayValue() {
|
|
60
|
+
if (ref === null || ref === void 0 ? void 0 : ref.firstElementChild) {
|
|
61
|
+
return window.getComputedStyle(ref.firstElementChild).display;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function getChildData() {
|
|
65
|
+
let data = { key: `${initialChild.type}_1`, child: initialChild };
|
|
66
|
+
if (switched) {
|
|
67
|
+
data = { key: `${switchTo.type}_2`, child: switchTo };
|
|
68
|
+
}
|
|
69
|
+
return Object.assign(Object.assign({}, data), { transition: getTransitionType(), duration: getTransitionDuration() });
|
|
70
|
+
}
|
|
71
|
+
function getTransitionType() {
|
|
72
|
+
if (isSwitchingBetweenIcons) {
|
|
73
|
+
if (switched)
|
|
74
|
+
return SPIN_COUNTER_CLOCK_WISE;
|
|
75
|
+
return SPIN_CLOCK_WISE;
|
|
76
|
+
}
|
|
77
|
+
else if (type === "fade") {
|
|
78
|
+
return FADE;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
if (switched)
|
|
82
|
+
return SLIDE_IN_UP;
|
|
83
|
+
return SLIDE_IN_DOWN;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function getTransitionDuration() {
|
|
87
|
+
switch (type) {
|
|
88
|
+
case "fade":
|
|
89
|
+
return DURATION_AVERAGE;
|
|
90
|
+
default:
|
|
91
|
+
return DURATION_SIMPLE;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
AnimatedSwitcher.Icon = function AnimatedSwitcherIcon({ switchToIcon, switched, initialIcon, }) {
|
|
96
|
+
return (React__default["default"].createElement(AnimatedSwitcher, { switched: switched, initialChild: React__default["default"].createElement(Icon.Icon, { name: initialIcon }), switchTo: React__default["default"].createElement(Icon.Icon, { name: switchToIcon }) }));
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
exports.AnimatedSwitcher = AnimatedSwitcher;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Variants } from "framer-motion";
|
|
2
|
+
export declare const DURATION_SIMPLE = 0.1;
|
|
3
|
+
export declare const DURATION_AVERAGE = 0.2;
|
|
4
|
+
export declare const FADE: Variants;
|
|
5
|
+
export declare const SLIDE_IN_UP: Variants;
|
|
6
|
+
export declare const SLIDE_IN_DOWN: Variants;
|
|
7
|
+
export declare const SPIN_COUNTER_CLOCK_WISE: Variants;
|
|
8
|
+
export declare const SPIN_CLOCK_WISE: Variants;
|
|
@@ -11,7 +11,7 @@ export interface InputTextRef {
|
|
|
11
11
|
export declare const InputText: React.ForwardRefExoticComponent<({
|
|
12
12
|
readonly multiline: true;
|
|
13
13
|
readonly rows?: number | RowRange | undefined;
|
|
14
|
-
readonly align?: "
|
|
14
|
+
readonly align?: "right" | "center" | undefined;
|
|
15
15
|
readonly description?: string | undefined;
|
|
16
16
|
readonly disabled?: boolean | undefined;
|
|
17
17
|
readonly invalid?: boolean | undefined;
|
|
@@ -23,10 +23,10 @@ export declare const InputText: React.ForwardRefExoticComponent<({
|
|
|
23
23
|
readonly placeholder?: string | undefined;
|
|
24
24
|
readonly size?: "large" | "small" | undefined;
|
|
25
25
|
readonly value?: string | number | Date | undefined;
|
|
26
|
-
readonly defaultValue?: string | Date | undefined;
|
|
27
|
-
readonly prefix?: import("../FormField").Affix | undefined;
|
|
28
26
|
onFocus?: (() => void) | undefined;
|
|
29
27
|
onBlur?: (() => void) | undefined;
|
|
28
|
+
readonly defaultValue?: string | Date | undefined;
|
|
29
|
+
readonly prefix?: import("../FormField").Affix | undefined;
|
|
30
30
|
readonly autocomplete?: boolean | import("../FormField").AutocompleteTypes | undefined;
|
|
31
31
|
inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement> | undefined;
|
|
32
32
|
readonly keyboard?: "numeric" | "decimal" | undefined;
|
|
@@ -48,7 +48,7 @@ export declare const InputText: React.ForwardRefExoticComponent<({
|
|
|
48
48
|
} | {
|
|
49
49
|
rows?: undefined;
|
|
50
50
|
multiline?: boolean | undefined;
|
|
51
|
-
readonly align?: "
|
|
51
|
+
readonly align?: "right" | "center" | undefined;
|
|
52
52
|
readonly description?: string | undefined;
|
|
53
53
|
readonly disabled?: boolean | undefined;
|
|
54
54
|
readonly invalid?: boolean | undefined;
|
|
@@ -60,10 +60,10 @@ export declare const InputText: React.ForwardRefExoticComponent<({
|
|
|
60
60
|
readonly placeholder?: string | undefined;
|
|
61
61
|
readonly size?: "large" | "small" | undefined;
|
|
62
62
|
readonly value?: string | number | Date | undefined;
|
|
63
|
-
readonly defaultValue?: string | Date | undefined;
|
|
64
|
-
readonly prefix?: import("../FormField").Affix | undefined;
|
|
65
63
|
onFocus?: (() => void) | undefined;
|
|
66
64
|
onBlur?: (() => void) | undefined;
|
|
65
|
+
readonly defaultValue?: string | Date | undefined;
|
|
66
|
+
readonly prefix?: import("../FormField").Affix | undefined;
|
|
67
67
|
readonly autocomplete?: boolean | import("../FormField").AutocompleteTypes | undefined;
|
|
68
68
|
inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement> | undefined;
|
|
69
69
|
readonly keyboard?: "numeric" | "decimal" | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components",
|
|
3
|
-
"version": "4.20.
|
|
3
|
+
"version": "4.20.5-JOB-70296.10+1855d88a",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@jobber/design": "^0.42.0",
|
|
23
|
-
"@jobber/formatters": "
|
|
23
|
+
"@jobber/formatters": "^0.2.2",
|
|
24
24
|
"@jobber/hooks": "^2.1.4",
|
|
25
25
|
"@popperjs/core": "^2.0.6",
|
|
26
26
|
"@std-proposal/temporal": "0.0.1",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"> 1%",
|
|
84
84
|
"IE 10"
|
|
85
85
|
],
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "1855d88a1d48436ff054e3292de099a7a1e98467"
|
|
87
87
|
}
|