@jobber/components 4.77.5 → 4.78.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.
@@ -0,0 +1 @@
1
+ export * from "./dist/AnimatedPresence";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+
7
+ var AnimatedPresence = require("./dist/AnimatedPresence");
8
+
9
+ Object.keys(AnimatedPresence).forEach(function(key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ Object.defineProperty(exports, key, {
12
+ enumerable: true,
13
+ get: function get() {
14
+ return AnimatedPresence[key];
15
+ },
16
+ });
17
+ });
@@ -0,0 +1,24 @@
1
+ import { PropsWithChildren } from "react";
2
+ declare const transitions: {
3
+ fromBottom: import("framer-motion").Variants;
4
+ fromTop: import("framer-motion").Variants;
5
+ fromLeft: import("framer-motion").Variants;
6
+ fromRight: import("framer-motion").Variants;
7
+ popIn: import("framer-motion").Variants;
8
+ fromLeftToRight: import("framer-motion").Variants;
9
+ fromRightToLeft: import("framer-motion").Variants;
10
+ fade: import("framer-motion").Variants;
11
+ };
12
+ export type AnimatedPresenceTransitions = keyof typeof transitions;
13
+ interface AnimatedPresenceProps extends Required<PropsWithChildren> {
14
+ /**
15
+ * The type of transition you can use.
16
+ */
17
+ readonly transition?: AnimatedPresenceTransitions;
18
+ /**
19
+ * Whether or not to animate the children on mount. By default it's set to false.
20
+ */
21
+ readonly initial?: boolean;
22
+ }
23
+ export declare function AnimatedPresence(props: AnimatedPresenceProps): JSX.Element;
24
+ export {};
@@ -0,0 +1,11 @@
1
+ import { Variants } from "framer-motion";
2
+ export declare const TIMING_QUICK: number;
3
+ export declare const TIMING_BASE: number;
4
+ export declare const fade: Variants;
5
+ export declare const popIn: Variants;
6
+ export declare const fromTop: Variants;
7
+ export declare const fromBottom: Variants;
8
+ export declare const fromLeft: Variants;
9
+ export declare const fromRight: Variants;
10
+ export declare const fromLeftToRight: Variants;
11
+ export declare const fromRightToLeft: Variants;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function usePreviousValue<T>(value: T): readonly [T, import("react").Dispatch<import("react").SetStateAction<T>>];
@@ -0,0 +1 @@
1
+ export * from "./AnimatedPresence";
@@ -0,0 +1,106 @@
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 design = require('@jobber/design');
8
+
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
+
11
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
12
+
13
+ const TIMING_QUICK = toSeconds(design.tokens["timing-quick"]);
14
+ const TIMING_BASE = toSeconds(design.tokens["timing-base"]);
15
+ const baseTransition = {
16
+ visible: { opacity: 1 },
17
+ hidden: { opacity: 0 },
18
+ };
19
+ const fade = {
20
+ visible: { opacity: 1 },
21
+ hidden: { opacity: 0 },
22
+ };
23
+ const popIn = {
24
+ visible: Object.assign({ scale: 1 }, baseTransition.visible),
25
+ hidden: Object.assign({ scale: 0.95 }, baseTransition.hidden),
26
+ };
27
+ const fromTop = {
28
+ visible: Object.assign({ y: 0 }, baseTransition.visible),
29
+ hidden: Object.assign({ y: -design.tokens["space-base"] }, baseTransition.hidden),
30
+ };
31
+ const fromBottom = {
32
+ visible: Object.assign({ y: 0 }, baseTransition.visible),
33
+ hidden: Object.assign({ y: design.tokens["space-base"] }, baseTransition.hidden),
34
+ };
35
+ const fromLeft = {
36
+ visible: Object.assign({ x: 0 }, baseTransition.visible),
37
+ hidden: Object.assign({ x: -design.tokens["space-base"] }, baseTransition.hidden),
38
+ };
39
+ const fromRight = {
40
+ visible: Object.assign({ x: 0 }, baseTransition.visible),
41
+ hidden: Object.assign({ x: design.tokens["space-base"] }, baseTransition.hidden),
42
+ };
43
+ const fromLeftToRight = {
44
+ initial: Object.assign({ x: -design.tokens["space-base"] }, baseTransition.hidden),
45
+ visible: Object.assign({ x: 0 }, baseTransition.visible),
46
+ hidden: Object.assign({ x: design.tokens["space-base"] }, baseTransition.hidden),
47
+ };
48
+ const fromRightToLeft = {
49
+ initial: Object.assign({ x: design.tokens["space-base"] }, baseTransition.hidden),
50
+ visible: Object.assign({ x: 0 }, baseTransition.visible),
51
+ hidden: Object.assign({ x: -design.tokens["space-base"] }, baseTransition.hidden),
52
+ };
53
+ function toSeconds(ms) {
54
+ return ms / 1000;
55
+ }
56
+
57
+ function usePreviousValue(value) {
58
+ const [previousValue, setPreviousValue] = React.useState(value);
59
+ React.useEffect(() => {
60
+ setPreviousValue(value);
61
+ }, [value]);
62
+ return [previousValue, setPreviousValue];
63
+ }
64
+
65
+ const transitions = {
66
+ fromBottom,
67
+ fromTop,
68
+ fromLeft,
69
+ fromRight,
70
+ popIn,
71
+ fromLeftToRight,
72
+ fromRightToLeft,
73
+ fade,
74
+ };
75
+ function AnimatedPresence(props) {
76
+ const shouldReduceMotion = framerMotion.useReducedMotion();
77
+ if (shouldReduceMotion) {
78
+ return React__default["default"].createElement(React__default["default"].Fragment, null, props.children);
79
+ }
80
+ return React__default["default"].createElement(InternalAnimatedPresence, Object.assign({}, props));
81
+ }
82
+ function InternalAnimatedPresence({ transition = "fromTop", initial = false, children, }) {
83
+ const transitionVariation = transitions[transition];
84
+ const hasInitialTransition = "initial" in transitionVariation;
85
+ const childCount = React.Children.count(children);
86
+ // Set the initial value to 0 so it staggers the animation on mount when
87
+ // initial is true.
88
+ const [lastChildIndex, setLastChildIndex] = usePreviousValue(0);
89
+ // Whenever the children count changes, update the last index.
90
+ React.useEffect(() => {
91
+ setLastChildIndex(childCount - 1);
92
+ }, [childCount]);
93
+ return (React__default["default"].createElement(framerMotion.AnimatePresence, { initial: initial, mode: "popLayout" }, React.Children.map(children, (child, i) => child && (React__default["default"].createElement(framerMotion.motion.div, { layout: true, variants: transitionVariation, initial: hasInitialTransition ? "initial" : "hidden", animate: "visible", exit: "hidden", transition: {
94
+ duration: TIMING_BASE,
95
+ delay: generateDelayTime(i),
96
+ } }, child)))));
97
+ function generateDelayTime(index) {
98
+ // Don't add a delay if it's already rendered.
99
+ if (lastChildIndex > index)
100
+ return 0;
101
+ // Stagger the animation starting after the previous last child index.
102
+ return (index - lastChildIndex) * TIMING_QUICK;
103
+ }
104
+ }
105
+
106
+ exports.AnimatedPresence = AnimatedPresence;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var Combobox = require('../Combobox-237caf42.js');
5
+ var Combobox = require('../Combobox-1c91da1f.js');
6
6
  require('react');
7
7
  require('classnames');
8
8
  require('react-dom');
@@ -66,7 +66,7 @@ var css_248z$4 = ".SgMzjOcdE-E- {\n position: relative;\n padding: calc(16px /
66
66
  var styles$4 = {"container":"SgMzjOcdE-E-","optionsList":"TwoTCjgcssc-","filterMessage":"_8T5M7MGwCRE-","emptyStateMessage":"_4y5NXkNeIQM-","scrollTop":"T6E3VwBGoQM-","scrollNone":"_6HQzxMQkXnE-","scrollBottom":"_5YsJZyMDkbA-","loadingContainer":"A6z4OI58xoE-"};
67
67
  styleInject_es.styleInject(css_248z$4);
68
68
 
69
- var css_248z$3 = "._5QdRGmaNHvc- {\n display: -ms-flexbox;\n display: flex;\n min-height: calc((calc(16px * 3) - calc(16px / 4)));\n min-height: calc((var(--space-largest) - var(--space-smaller)));\n box-sizing: border-box;\n margin: 0 calc(16px / 2);\n margin: 0 var(--space-small);\n padding: calc(16px / 2);\n padding: var(--space-small);\n border-radius: calc(16px / 4);\n border-radius: var(--radius-large);\n color: rgb(1, 41, 57);\n color: var(--color-heading);\n font-weight: 500;\n cursor: pointer;\n transition: all 200ms;\n transition: all var(--timing-base);\n -ms-flex-pack: justify;\n justify-content: space-between;\n -ms-flex-align: center;\n align-items: center;\n}\n\n.jobber-retheme ._5QdRGmaNHvc- {\n border-radius: calc(16px / 8);\n border-radius: var(--radius-base);\n}\n\n._5QdRGmaNHvc-:hover,\n._5QdRGmaNHvc-:focus-visible {\n background-color: rgb(244, 246, 250);\n background-color: var(--color-surface--hover);\n}\n\n._5QdRGmaNHvc-:focus,\n._5QdRGmaNHvc-:focus-visible {\n outline: none;\n}\n\n._5QdRGmaNHvc-:focus-visible {\n box-shadow: 0px 0px 0px calc(16px / 8) rgba(255, 255, 255, 1),\n 0px 0px 0px calc(16px / 4) rgb(147, 161, 169);\n box-shadow: var(--shadow-focus);\n}\n";
69
+ var css_248z$3 = "._5QdRGmaNHvc- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-negative: 0;\n flex-shrink: 0;\n min-height: calc((calc(16px * 3) - calc(16px / 4)));\n min-height: calc((var(--space-largest) - var(--space-smaller)));\n box-sizing: border-box;\n margin: 0 calc(16px / 2);\n margin: 0 var(--space-small);\n padding: calc(16px / 2);\n padding: var(--space-small);\n border-radius: calc(16px / 4);\n border-radius: var(--radius-large);\n color: rgb(1, 41, 57);\n color: var(--color-heading);\n font-weight: 500;\n cursor: pointer;\n transition: all 200ms;\n transition: all var(--timing-base);\n -ms-flex-pack: justify;\n justify-content: space-between;\n -ms-flex-align: center;\n align-items: center;\n}\n\n.jobber-retheme ._5QdRGmaNHvc- {\n border-radius: calc(16px / 8);\n border-radius: var(--radius-base);\n}\n\n._5QdRGmaNHvc-:hover,\n._5QdRGmaNHvc-:focus-visible {\n background-color: rgb(244, 246, 250);\n background-color: var(--color-surface--hover);\n}\n\n._5QdRGmaNHvc-:focus,\n._5QdRGmaNHvc-:focus-visible {\n outline: none;\n}\n\n._5QdRGmaNHvc-:focus-visible {\n box-shadow: 0px 0px 0px calc(16px / 8) rgba(255, 255, 255, 1),\n 0px 0px 0px calc(16px / 4) rgb(147, 161, 169);\n box-shadow: var(--shadow-focus);\n}\n";
70
70
  var styles$3 = {"option":"_5QdRGmaNHvc-"};
71
71
  styleInject_es.styleInject(css_248z$3);
72
72
 
@@ -82,7 +82,7 @@ function ComboboxOption(props) {
82
82
  return (React__default["default"].createElement("li", { key: props.id, tabIndex: -1, "data-selected": isSelected, role: "option", "aria-selected": isSelected, onClick: () => selectionHandler &&
83
83
  selectionHandler({ id: props.id, label: props.label }), className: classnames__default["default"](styles$3.option) },
84
84
  props.label,
85
- isSelected && React__default["default"].createElement(Icon.Icon, { name: "checkmark", color: "blue" })));
85
+ React__default["default"].createElement("div", null, isSelected && React__default["default"].createElement(Icon.Icon, { name: "checkmark", color: "blue" }))));
86
86
  }
87
87
 
88
88
  function ComboboxContentList(props) {
@@ -123,7 +123,7 @@ function useScrollState(optionsListRef, options) {
123
123
  else if (scrollTop === 0) {
124
124
  setlistScrollState("scrollTop");
125
125
  }
126
- else if (scrollTop + clientHeight === scrollHeight) {
126
+ else if (scrollTop + clientHeight >= scrollHeight) {
127
127
  setlistScrollState("scrollBottom");
128
128
  }
129
129
  else {
@@ -26,7 +26,7 @@ var ReactDOM = require('react-dom');
26
26
  var Checkbox = require('../Checkbox-99f6297f.js');
27
27
  var reactRouterDom = require('react-router-dom');
28
28
  var AnimatedSwitcher = require('../AnimatedSwitcher-3d45ec5d.js');
29
- var Combobox = require('../Combobox-237caf42.js');
29
+ var Combobox = require('../Combobox-1c91da1f.js');
30
30
  var Chip = require('../Chip-c91fd6c8.js');
31
31
  var debounce = require('lodash/debounce');
32
32
  var InputText = require('../InputText-6e356985.js');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "4.77.5",
3
+ "version": "4.78.1",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -84,5 +84,5 @@
84
84
  "> 1%",
85
85
  "IE 10"
86
86
  ],
87
- "gitHead": "3f1d6b70deb0ca76a8d1b818cb857151b371a598"
87
+ "gitHead": "5dfbb5b8c8fe61a7c70e64ef7e7f4f0c90a2a34c"
88
88
  }