@jobber/components 8.12.2 → 8.13.1-addeditor-cab44cf.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/dist/Combobox/components/ComboboxContent/ComboboxContentList/index.cjs +11 -2
- package/dist/Combobox/components/ComboboxContent/ComboboxContentList/index.mjs +11 -2
- package/dist/Combobox/components/ComboboxContent/index.cjs +11 -2
- package/dist/Combobox/components/ComboboxContent/index.mjs +11 -2
- package/dist/Combobox/index.cjs +11 -3
- package/dist/Combobox/index.mjs +11 -3
- package/dist/ComboboxContentList-cjs.js +5 -2
- package/dist/ComboboxContentList-es.js +5 -2
- package/dist/DataList/components/DataListFilters/components/DataListSort/index.cjs +10 -2
- package/dist/DataList/components/DataListFilters/components/DataListSort/index.mjs +10 -2
- package/dist/DataList/components/DataListFilters/index.cjs +10 -4
- package/dist/DataList/components/DataListFilters/index.mjs +10 -4
- package/dist/DataList/index.cjs +7 -1
- package/dist/DataList/index.mjs +7 -1
- package/dist/docs/Combobox/Combobox.md +1 -1
- package/dist/docs/InputText/InputText.md +1 -1
- package/dist/docs/Toast/Toast.md +2 -2
- package/dist/docs/errors/errors.md +2 -2
- package/dist/docs/formatting/formatting.md +245 -0
- package/dist/docs/index.md +3 -1
- package/dist/docs/product-vocabulary/product-vocabulary.md +524 -0
- package/dist/docs/voice-and-tone/voice-and-tone.md +385 -0
- package/dist/index.cjs +0 -2
- package/dist/index.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +0 -1
- package/dist/utils/meta/meta.json +0 -1
- package/package.json +3 -8
- package/AnimatedPresence.d.ts +0 -1
- package/AnimatedPresence.js +0 -17
- package/dist/AnimatedPresence/AnimatedPresence.d.ts +0 -25
- package/dist/AnimatedPresence/AnimatedPresence.transitions.d.ts +0 -11
- package/dist/AnimatedPresence/hooks/usePreviousValue.d.ts +0 -1
- package/dist/AnimatedPresence/index.cjs +0 -10
- package/dist/AnimatedPresence/index.d.ts +0 -1
- package/dist/AnimatedPresence/index.mjs +0 -4
- package/dist/AnimatedPresence-cjs.js +0 -100
- package/dist/AnimatedPresence-es.js +0 -98
- package/dist/docs/AnimatedPresence/AnimatedPresence.md +0 -74
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import React__default, { useState, useEffect, Children } from 'react';
|
|
2
|
-
import { useReducedMotion, AnimatePresence, motion } from 'framer-motion';
|
|
3
|
-
import { tokens } from '@jobber/design';
|
|
4
|
-
|
|
5
|
-
const TIMING_QUICK = toSeconds(tokens["timing-quick"]);
|
|
6
|
-
const TIMING_BASE = toSeconds(tokens["timing-base"]);
|
|
7
|
-
const baseTransition = {
|
|
8
|
-
visible: { opacity: 1 },
|
|
9
|
-
hidden: { opacity: 0 },
|
|
10
|
-
};
|
|
11
|
-
const fade = {
|
|
12
|
-
visible: { opacity: 1 },
|
|
13
|
-
hidden: { opacity: 0 },
|
|
14
|
-
};
|
|
15
|
-
const popIn = {
|
|
16
|
-
visible: Object.assign({ scale: 1 }, baseTransition.visible),
|
|
17
|
-
hidden: Object.assign({ scale: 0.95 }, baseTransition.hidden),
|
|
18
|
-
};
|
|
19
|
-
const fromTop = {
|
|
20
|
-
visible: Object.assign({ y: 0 }, baseTransition.visible),
|
|
21
|
-
hidden: Object.assign({ y: -tokens["space-base"] }, baseTransition.hidden),
|
|
22
|
-
};
|
|
23
|
-
const fromBottom = {
|
|
24
|
-
visible: Object.assign({ y: 0 }, baseTransition.visible),
|
|
25
|
-
hidden: Object.assign({ y: tokens["space-base"] }, baseTransition.hidden),
|
|
26
|
-
};
|
|
27
|
-
const fromLeft = {
|
|
28
|
-
visible: Object.assign({ x: 0 }, baseTransition.visible),
|
|
29
|
-
hidden: Object.assign({ x: -tokens["space-base"] }, baseTransition.hidden),
|
|
30
|
-
};
|
|
31
|
-
const fromRight = {
|
|
32
|
-
visible: Object.assign({ x: 0 }, baseTransition.visible),
|
|
33
|
-
hidden: Object.assign({ x: tokens["space-base"] }, baseTransition.hidden),
|
|
34
|
-
};
|
|
35
|
-
const fromLeftToRight = {
|
|
36
|
-
initial: Object.assign({ x: -tokens["space-base"] }, baseTransition.hidden),
|
|
37
|
-
visible: Object.assign({ x: 0 }, baseTransition.visible),
|
|
38
|
-
hidden: Object.assign({ x: tokens["space-base"] }, baseTransition.hidden),
|
|
39
|
-
};
|
|
40
|
-
const fromRightToLeft = {
|
|
41
|
-
initial: Object.assign({ x: tokens["space-base"] }, baseTransition.hidden),
|
|
42
|
-
visible: Object.assign({ x: 0 }, baseTransition.visible),
|
|
43
|
-
hidden: Object.assign({ x: -tokens["space-base"] }, baseTransition.hidden),
|
|
44
|
-
};
|
|
45
|
-
function toSeconds(ms) {
|
|
46
|
-
return ms / 1000;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function usePreviousValue(value) {
|
|
50
|
-
const [previousValue, setPreviousValue] = useState(value);
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
setPreviousValue(value);
|
|
53
|
-
}, [value]);
|
|
54
|
-
return [previousValue, setPreviousValue];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const transitions = {
|
|
58
|
-
fromBottom,
|
|
59
|
-
fromTop,
|
|
60
|
-
fromLeft,
|
|
61
|
-
fromRight,
|
|
62
|
-
popIn,
|
|
63
|
-
fromLeftToRight,
|
|
64
|
-
fromRightToLeft,
|
|
65
|
-
fade,
|
|
66
|
-
};
|
|
67
|
-
function AnimatedPresence(props) {
|
|
68
|
-
const shouldReduceMotion = useReducedMotion();
|
|
69
|
-
if (shouldReduceMotion) {
|
|
70
|
-
return React__default.createElement(React__default.Fragment, null, props.children);
|
|
71
|
-
}
|
|
72
|
-
return React__default.createElement(InternalAnimatedPresence, Object.assign({}, props));
|
|
73
|
-
}
|
|
74
|
-
function InternalAnimatedPresence({ transition = "fromTop", initial = false, children, }) {
|
|
75
|
-
const transitionVariation = transitions[transition];
|
|
76
|
-
const hasInitialTransition = "initial" in transitionVariation;
|
|
77
|
-
const childCount = Children.count(children);
|
|
78
|
-
// Set the initial value to 0 so it staggers the animation on mount when
|
|
79
|
-
// initial is true.
|
|
80
|
-
const [lastChildIndex, setLastChildIndex] = usePreviousValue(0);
|
|
81
|
-
// Whenever the children count changes, update the last index.
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
setLastChildIndex(childCount - 1);
|
|
84
|
-
}, [childCount]);
|
|
85
|
-
return (React__default.createElement(AnimatePresence, { initial: initial, mode: "popLayout" }, Children.map(children, (child, i) => child && (React__default.createElement(motion.div, { layout: true, variants: transitionVariation, initial: hasInitialTransition ? "initial" : "hidden", animate: "visible", exit: "hidden", transition: {
|
|
86
|
-
duration: TIMING_BASE,
|
|
87
|
-
delay: generateDelayTime(i),
|
|
88
|
-
} }, child)))));
|
|
89
|
-
function generateDelayTime(index) {
|
|
90
|
-
// Don't add a delay if it's already rendered.
|
|
91
|
-
if (lastChildIndex > index)
|
|
92
|
-
return 0;
|
|
93
|
-
// Stagger the animation starting after the previous last child index.
|
|
94
|
-
return (index - lastChildIndex) * TIMING_QUICK;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export { AnimatedPresence as A };
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# AnimatedPresence
|
|
2
|
-
|
|
3
|
-
Just like in real life, nothing appears out of nowhere. Animate elements that
|
|
4
|
-
get added or removed from the React tree with AnimatedPresence. If more than 1
|
|
5
|
-
element gets added, there will be a delay between each new element.
|
|
6
|
-
|
|
7
|
-
## Accessibility
|
|
8
|
-
|
|
9
|
-
AnimatedPresence respects the
|
|
10
|
-
[`prefers-reduced-motion`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion)
|
|
11
|
-
setting. If the user has this enabled, the animations will be disabled and the
|
|
12
|
-
elements will show/hide instantly.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## Configuration
|
|
16
|
-
|
|
17
|
-
### Conditional rendering
|
|
18
|
-
|
|
19
|
-
Hide and show elements with a transition to add emphasis on the change. This is
|
|
20
|
-
useful for UX which has a different part of the UI hidden until the user takes
|
|
21
|
-
an action to show them.
|
|
22
|
-
|
|
23
|
-
```tsx
|
|
24
|
-
<AnimatedPresence>{show && <div>Item</div>}</AnimatedPresence>
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
See the
|
|
28
|
-
[Basic](/storybook/web/?path=/story/components-utilities-animatedpresence--basic)
|
|
29
|
-
example for a live demo.
|
|
30
|
-
|
|
31
|
-
> **WARNING:** When using AnimatedPresence with conditional rendering, elements will be added
|
|
32
|
-
> and removed from the DOM causing shifts in the layout, with the potential for frames where neither the entering nor exiting element is yet present.
|
|
33
|
-
>
|
|
34
|
-
> This can create undesirable visual jumps in some scenarios, such as when the
|
|
35
|
-
> element's height is what creates enough vertical space to require scrolling. The
|
|
36
|
-
> layout will have to be stabilized with something such as a min-height to avoid
|
|
37
|
-
> this.
|
|
38
|
-
|
|
39
|
-
### List rendering
|
|
40
|
-
|
|
41
|
-
Animate items in a list as they are added or removed.
|
|
42
|
-
|
|
43
|
-
```tsx
|
|
44
|
-
<AnimatedPresence>
|
|
45
|
-
{items.map(item => (
|
|
46
|
-
<div key={item.id}>{item.name}</div>
|
|
47
|
-
))}
|
|
48
|
-
</AnimatedPresence>
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
See the
|
|
52
|
-
[List](/storybook/web/?path=/story/components-utilities-animatedpresence--list)
|
|
53
|
-
example for a live demo.
|
|
54
|
-
|
|
55
|
-
### Animate on mount
|
|
56
|
-
|
|
57
|
-
Set the `initial` prop to `true` to animate the element whenever it initially
|
|
58
|
-
renders on the screen. See this in action on the
|
|
59
|
-
[List](/storybook/web/?path=/story/components-utilities-animatedpresence--list)
|
|
60
|
-
example.
|
|
61
|
-
|
|
62
|
-
```tsx
|
|
63
|
-
<AnimatedPresence initial={true}>...</AnimatedPresence>
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
## Props
|
|
68
|
-
|
|
69
|
-
### Web
|
|
70
|
-
|
|
71
|
-
| Prop | Type | Required | Default | Description |
|
|
72
|
-
|------|------|----------|---------|-------------|
|
|
73
|
-
| `initial` | `boolean` | No | — | Whether or not to animate the children on mount. By default it's set to false. |
|
|
74
|
-
| `transition` | `"fade" | "fromBottom" | "fromLeft" | "fromLeftToRight" | "fromRight" | "fromRightToLeft" | "fromTop" | "popIn"` | No | — | The type of transition you can use. |
|