@talogic/react 0.14.0 → 0.15.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,24 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { PresenceAnimation } from './presence.recipe';
3
+ /** Props of {@link PresenceGroup}. */
4
+ export interface PresenceGroupProps {
5
+ /** The items. Give each one a stable `key`: the key tells an added or removed item from one that stays. */
6
+ children: ReactNode;
7
+ /** The motion of each item: `expand` (default), `fade`, `scale` or `drop`. */
8
+ animation?: PresenceAnimation;
9
+ /** Animates the items that are there on the first render too. Default false: only later changes animate. */
10
+ initial?: boolean;
11
+ /** The class of the box around each item. */
12
+ className?: string;
13
+ }
14
+ /**
15
+ * Animates the items of a list as they are added and removed, like React's Suspense wraps content: put it around
16
+ * the list's children, and give each child a `key`. An added child enters with the animation (by default it grows
17
+ * to its height, so the items under it slide down). A removed child stays until its exit animation ends. The items
18
+ * of the first render do not animate, unless `initial` is set. Each item is wrapped in a {@link Presence} box, so
19
+ * the group adds no element of its own: the parent's layout (flex, grid, gap) applies to the boxes.
20
+ *
21
+ * @param props - The keyed `children`, `animation`, `initial` and the `className` of each box.
22
+ * @returns The items, each in its animated box.
23
+ */
24
+ export declare function PresenceGroup({ children, animation, initial, className }: PresenceGroupProps): import("react").JSX.Element[];
@@ -4,18 +4,26 @@ import { type PresenceAnimation } from './presence.recipe';
4
4
  export interface PresenceProps extends ComponentProps<'div'> {
5
5
  /** Shows the content when true. When it turns false, the exit animation plays before the content goes. */
6
6
  present: boolean;
7
- /** The motion: `fade` (default), `scale` or `drop`. */
7
+ /** The motion: `fade` (default), `scale`, `drop` or `expand`. */
8
8
  animation?: PresenceAnimation;
9
9
  /** Removes the content from the DOM after the exit animation. Default true. When false, it is hidden instead. */
10
10
  unmountOnExit?: boolean;
11
+ /**
12
+ * Plays the enter animation when the box is present on its first render. Default true. Set false for content that
13
+ * was there before the user acted, such as the rows of a list when the page loads: only a later enter animates.
14
+ */
15
+ initial?: boolean;
16
+ /** Called when the box has left: after its exit animation, or at once when it has none. */
17
+ onExitComplete?: () => void;
11
18
  }
12
19
  /**
13
20
  * Shows and hides a box with an enter and an exit animation, like Chakra's Presence. When `present` turns true the
14
21
  * box mounts and plays its enter animation. When `present` turns false it plays the exit animation, and only then
15
22
  * leaves the DOM (or hides, with `unmountOnExit={false}`). Use it for content that appears in place, such as a
16
- * notice, a details panel or a filter row. Overlays (dialogs, popovers, menus) already animate themselves.
23
+ * notice, a details panel or a filter row. For the items of a list, use {@link PresenceGroup}. Overlays (dialogs,
24
+ * popovers, menus) already animate themselves.
17
25
  *
18
- * @param props - `present`, `animation`, `unmountOnExit` and any `div` props.
26
+ * @param props - `present`, `animation`, `unmountOnExit`, `initial`, `onExitComplete` and any `div` props.
19
27
  * @returns The animated box, or nothing once it has left.
20
28
  */
21
- export declare function Presence({ present, animation, unmountOnExit, className, onAnimationEnd, ...props }: PresenceProps): import("react").JSX.Element | null;
29
+ export declare function Presence({ present, animation, unmountOnExit, initial, onExitComplete, className, style, onAnimationEnd, ...props }: PresenceProps): import("react").JSX.Element | null;
@@ -1,8 +1,9 @@
1
1
  /** The motion of a {@link Presence}. */
2
- export type PresenceAnimation = 'fade' | 'scale' | 'drop';
2
+ export type PresenceAnimation = 'fade' | 'scale' | 'drop' | 'expand';
3
3
  /**
4
4
  * The enter and exit classes of each {@link PresenceAnimation}: `fade` fades, `scale` grows from 96 % while it
5
- * fades (like popovers), `drop` falls 6 px into place while it fades (like the navigation menu). Reduced motion
6
- * keeps only the fade.
5
+ * fades (like popovers), `drop` falls 6 px into place while it fades (like the navigation menu), `expand` grows to
6
+ * its own height while it fades, so the content under it slides (like a field added to a form). Reduced motion keeps
7
+ * only the fade.
7
8
  */
8
9
  export declare const presenceClassName: Record<PresenceAnimation, string>;