shelving 1.319.0 → 1.320.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.
Files changed (42) hide show
  1. package/docs/llms-full.txt +171 -20
  2. package/docs/ui/Dialog.md +11 -8
  3. package/docs/ui/DialogProps.md +1 -1
  4. package/docs/ui/FADE_TRANSITION_CLASS.md +9 -0
  5. package/docs/ui/FadeTransition.md +13 -0
  6. package/docs/ui/Form.md +1 -1
  7. package/docs/ui/HorizontalTransition.md +20 -4
  8. package/docs/ui/Modal.md +1 -1
  9. package/docs/ui/Notices.md +1 -1
  10. package/docs/ui/SLIDE_DOWN_TRANSITION_CLASS.md +9 -0
  11. package/docs/ui/SLIDE_LEFT_TRANSITION_CLASS.md +9 -0
  12. package/docs/ui/SLIDE_RIGHT_TRANSITION_CLASS.md +9 -0
  13. package/docs/ui/SLIDE_UP_TRANSITION_CLASS.md +9 -0
  14. package/docs/ui/VerticalTransition.md +20 -4
  15. package/docs/ui/requestDialogClose.md +28 -0
  16. package/docs/ui.md +6 -0
  17. package/package.json +1 -1
  18. package/ui/dialog/Dialog.d.ts +15 -4
  19. package/ui/dialog/Dialog.js +19 -12
  20. package/ui/dialog/Dialog.md +9 -6
  21. package/ui/dialog/Dialog.tsx +20 -13
  22. package/ui/dialog/Modal.md +1 -1
  23. package/ui/form/Form.js +4 -3
  24. package/ui/form/Form.md +1 -1
  25. package/ui/form/Form.tsx +3 -2
  26. package/ui/notice/Notices.md +1 -1
  27. package/ui/notice/NoticesTransition.module.css +1 -1
  28. package/ui/transition/FadeTransition.d.ts +9 -1
  29. package/ui/transition/FadeTransition.js +12 -2
  30. package/ui/transition/FadeTransition.md +13 -0
  31. package/ui/transition/{FadeTransition.css → FadeTransition.module.css} +9 -2
  32. package/ui/transition/FadeTransition.tsx +13 -2
  33. package/ui/transition/HorizontalTransition.d.ts +18 -1
  34. package/ui/transition/HorizontalTransition.js +21 -2
  35. package/ui/transition/HorizontalTransition.md +20 -4
  36. package/ui/transition/{HorizontalTransition.css → HorizontalTransition.module.css} +17 -5
  37. package/ui/transition/HorizontalTransition.tsx +30 -2
  38. package/ui/transition/VerticalTransition.d.ts +18 -1
  39. package/ui/transition/VerticalTransition.js +21 -2
  40. package/ui/transition/VerticalTransition.md +20 -4
  41. package/ui/transition/{VerticalTransition.css → VerticalTransition.module.css} +17 -5
  42. package/ui/transition/VerticalTransition.tsx +25 -2
@@ -1,7 +1,6 @@
1
1
  @import url("../style/layers.css");
2
2
  @import url("../style/Duration.module.css");
3
3
 
4
- /* Global CSS, not a CSS module yet — see dhoulb/shelving#259. */
5
4
  @layer defaults {
6
5
  :root {
7
6
  /* A percentage is of the snapshot's own size, so the old and new content sit edge to edge and never overlap. */
@@ -64,20 +63,33 @@
64
63
  overflow: clip;
65
64
  }
66
65
 
66
+ /* Longhands, not the `animation` shorthand: Bun rewrites `animation-name` to the hashed keyframes name but leaves a shorthand that holds a `var()` untouched. */
67
67
  ::view-transition-new(.slide-right) {
68
- animation: slide-in-from-right var(--horizontal-transition-duration) ease-in-out both;
68
+ animation-name: slide-in-from-right;
69
+ animation-duration: var(--horizontal-transition-duration);
70
+ animation-timing-function: ease-in-out;
71
+ animation-fill-mode: both;
69
72
  }
70
73
 
71
74
  ::view-transition-old(.slide-right) {
72
- animation: slide-out-to-left var(--horizontal-transition-duration) ease-in-out both;
75
+ animation-name: slide-out-to-left;
76
+ animation-duration: var(--horizontal-transition-duration);
77
+ animation-timing-function: ease-in-out;
78
+ animation-fill-mode: both;
73
79
  }
74
80
 
75
81
  ::view-transition-new(.slide-left) {
76
- animation: slide-in-from-left var(--horizontal-transition-duration) ease-in-out both;
82
+ animation-name: slide-in-from-left;
83
+ animation-duration: var(--horizontal-transition-duration);
84
+ animation-timing-function: ease-in-out;
85
+ animation-fill-mode: both;
77
86
  }
78
87
 
79
88
  ::view-transition-old(.slide-left) {
80
- animation: slide-out-to-right var(--horizontal-transition-duration) ease-in-out both;
89
+ animation-name: slide-out-to-right;
90
+ animation-duration: var(--horizontal-transition-duration);
91
+ animation-timing-function: ease-in-out;
92
+ animation-fill-mode: both;
81
93
  }
82
94
 
83
95
  /* Reduced motion: null the slide distance so the keyframes above degrade to an opacity-only crossfade (reduced-motion-safe), and disable the group's default positional morph. Unlayered so it wins over app-level overrides of the distance hook. */
@@ -1,7 +1,28 @@
1
1
  import type { ReactElement } from "react";
2
- import "./HorizontalTransition.css";
2
+ import { getClass, getModuleClass } from "../util/css.js";
3
+ import HORIZONTAL_TRANSITION_CSS from "./HorizontalTransition.module.css";
3
4
  import { Transition, type TransitionProps } from "./Transition.js";
4
5
 
6
+ /**
7
+ * View transition class that slides content right: the new content comes in from the right and the old content leaves to the left.
8
+ *
9
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
10
+ * - Also adds the plain global `slide-right` class, so app CSS can target it with `::view-transition-group(.slide-right)`.
11
+ *
12
+ * @see https://shelving.cc/ui/SLIDE_RIGHT_TRANSITION_CLASS
13
+ */
14
+ export const SLIDE_RIGHT_TRANSITION_CLASS = getClass("slide-right", getModuleClass(HORIZONTAL_TRANSITION_CSS, "slide-right"));
15
+
16
+ /**
17
+ * View transition class that slides content left: the new content comes in from the left and the old content leaves to the right.
18
+ *
19
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
20
+ * - Also adds the plain global `slide-left` class, so app CSS can target it with `::view-transition-group(.slide-left)`.
21
+ *
22
+ * @see https://shelving.cc/ui/SLIDE_LEFT_TRANSITION_CLASS
23
+ */
24
+ export const SLIDE_LEFT_TRANSITION_CLASS = getClass("slide-left", getModuleClass(HORIZONTAL_TRANSITION_CSS, "slide-left"));
25
+
5
26
  /**
6
27
  * Props for the `HorizontalTransition` component — the shared transition variant props.
7
28
  *
@@ -16,5 +37,12 @@ export interface HorizontalTransitionProps extends TransitionProps {}
16
37
  * @see https://shelving.cc/ui/HorizontalTransition
17
38
  */
18
39
  export function HorizontalTransition(props: HorizontalTransitionProps): ReactElement {
19
- return <Transition default="slide-right" forward="slide-right" back="slide-left" {...props} />;
40
+ return (
41
+ <Transition
42
+ default={SLIDE_RIGHT_TRANSITION_CLASS}
43
+ forward={SLIDE_RIGHT_TRANSITION_CLASS}
44
+ back={SLIDE_LEFT_TRANSITION_CLASS}
45
+ {...props}
46
+ />
47
+ );
20
48
  }
@@ -1,6 +1,23 @@
1
1
  import type { ReactElement } from "react";
2
- import "./VerticalTransition.css";
3
2
  import { type TransitionProps } from "./Transition.js";
3
+ /**
4
+ * View transition class that slides content down: the new content comes in from the top and the old content leaves to the bottom.
5
+ *
6
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
7
+ * - Also adds the plain global `slide-down` class, so app CSS can target it with `::view-transition-group(.slide-down)`.
8
+ *
9
+ * @see https://shelving.cc/ui/SLIDE_DOWN_TRANSITION_CLASS
10
+ */
11
+ export declare const SLIDE_DOWN_TRANSITION_CLASS: string;
12
+ /**
13
+ * View transition class that slides content up: the new content comes in from the bottom and the old content leaves to the top.
14
+ *
15
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
16
+ * - Also adds the plain global `slide-up` class, so app CSS can target it with `::view-transition-group(.slide-up)`.
17
+ *
18
+ * @see https://shelving.cc/ui/SLIDE_UP_TRANSITION_CLASS
19
+ */
20
+ export declare const SLIDE_UP_TRANSITION_CLASS: string;
4
21
  /**
5
22
  * Props for the `VerticalTransition` component — the shared transition variant props.
6
23
  *
@@ -1,6 +1,25 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import "./VerticalTransition.css";
2
+ import { getClass, getModuleClass } from "../util/css.js";
3
3
  import { Transition } from "./Transition.js";
4
+ import VERTICAL_TRANSITION_CSS from "./VerticalTransition.module.css";
5
+ /**
6
+ * View transition class that slides content down: the new content comes in from the top and the old content leaves to the bottom.
7
+ *
8
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
9
+ * - Also adds the plain global `slide-down` class, so app CSS can target it with `::view-transition-group(.slide-down)`.
10
+ *
11
+ * @see https://shelving.cc/ui/SLIDE_DOWN_TRANSITION_CLASS
12
+ */
13
+ export const SLIDE_DOWN_TRANSITION_CLASS = getClass("slide-down", getModuleClass(VERTICAL_TRANSITION_CSS, "slide-down"));
14
+ /**
15
+ * View transition class that slides content up: the new content comes in from the bottom and the old content leaves to the top.
16
+ *
17
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
18
+ * - Also adds the plain global `slide-up` class, so app CSS can target it with `::view-transition-group(.slide-up)`.
19
+ *
20
+ * @see https://shelving.cc/ui/SLIDE_UP_TRANSITION_CLASS
21
+ */
22
+ export const SLIDE_UP_TRANSITION_CLASS = getClass("slide-up", getModuleClass(VERTICAL_TRANSITION_CSS, "slide-up"));
4
23
  /**
5
24
  * Transition that slides its children vertically — down when moving forward, up when moving back.
6
25
  *
@@ -8,5 +27,5 @@ import { Transition } from "./Transition.js";
8
27
  * @see https://shelving.cc/ui/VerticalTransition
9
28
  */
10
29
  export function VerticalTransition(props) {
11
- return _jsx(Transition, { default: "slide-down", forward: "slide-down", back: "slide-up", ...props });
30
+ return (_jsx(Transition, { default: SLIDE_DOWN_TRANSITION_CLASS, forward: SLIDE_DOWN_TRANSITION_CLASS, back: SLIDE_UP_TRANSITION_CLASS, ...props }));
12
31
  }
@@ -9,12 +9,15 @@ A direction-aware `<Transition>` preset that slides its children vertically —
9
9
  - Pass `overlay` to raise the transition group above surrounding content during the animation (`z-index: 100`).
10
10
  - The old and new content slide a full height apart, so they sit edge to edge and never overlap.
11
11
  - The slide is clipped to the element's own box (`overflow: clip` on the group), so it does not paint over the content around it.
12
- - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and put the slide groups below it:
12
+ - During the slide, the snapshots paint above fixed elements such as a bottom bar. To keep a fixed element on top, give it its own `view-transition-name` and raise its group:
13
13
 
14
14
  ```css
15
- ::view-transition-group(.slide-up),
16
- ::view-transition-group(.slide-down) {
17
- z-index: -1;
15
+ .bottom-bar {
16
+ view-transition-name: bottom-bar;
17
+ }
18
+
19
+ ::view-transition-group(bottom-bar) {
20
+ z-index: 1;
18
21
  }
19
22
  ```
20
23
 
@@ -30,6 +33,19 @@ import { VerticalTransition } from "shelving/ui";
30
33
  </VerticalTransition>
31
34
  ```
32
35
 
36
+ ## Use the class without the component
37
+
38
+ The CSS is a CSS module, so its class names are hashed. To use the same animation on your own `<ViewTransition>`, import `SLIDE_DOWN_TRANSITION_CLASS` and `SLIDE_UP_TRANSITION_CLASS`. Each one also holds a plain global class name, so your CSS can still target it.
39
+
40
+ ```tsx
41
+ import { ViewTransition } from "react";
42
+ import { SLIDE_DOWN_TRANSITION_CLASS } from "shelving/ui";
43
+
44
+ <ViewTransition enter={SLIDE_DOWN_TRANSITION_CLASS} exit={SLIDE_DOWN_TRANSITION_CLASS}>
45
+ <div className="panel">…</div>
46
+ </ViewTransition>
47
+ ```
48
+
33
49
  ## Styling
34
50
 
35
51
  | Variable | Styles | Default |
@@ -1,7 +1,6 @@
1
1
  @import url("../style/layers.css");
2
2
  @import url("../style/Duration.module.css");
3
3
 
4
- /* Global CSS, not a CSS module yet — see dhoulb/shelving#259. */
5
4
  @layer defaults {
6
5
  :root {
7
6
  /* A percentage is of the snapshot's own size, so the old and new content sit edge to edge and never overlap. */
@@ -64,20 +63,33 @@
64
63
  overflow: clip;
65
64
  }
66
65
 
66
+ /* Longhands, not the `animation` shorthand: Bun rewrites `animation-name` to the hashed keyframes name but leaves a shorthand that holds a `var()` untouched. */
67
67
  ::view-transition-new(.slide-up) {
68
- animation: slide-in-from-bottom var(--vertical-transition-duration) ease-in-out both;
68
+ animation-name: slide-in-from-bottom;
69
+ animation-duration: var(--vertical-transition-duration);
70
+ animation-timing-function: ease-in-out;
71
+ animation-fill-mode: both;
69
72
  }
70
73
 
71
74
  ::view-transition-old(.slide-up) {
72
- animation: slide-out-to-top var(--vertical-transition-duration) ease-in-out both;
75
+ animation-name: slide-out-to-top;
76
+ animation-duration: var(--vertical-transition-duration);
77
+ animation-timing-function: ease-in-out;
78
+ animation-fill-mode: both;
73
79
  }
74
80
 
75
81
  ::view-transition-new(.slide-down) {
76
- animation: slide-in-from-top var(--vertical-transition-duration) ease-in-out both;
82
+ animation-name: slide-in-from-top;
83
+ animation-duration: var(--vertical-transition-duration);
84
+ animation-timing-function: ease-in-out;
85
+ animation-fill-mode: both;
77
86
  }
78
87
 
79
88
  ::view-transition-old(.slide-down) {
80
- animation: slide-out-to-bottom var(--vertical-transition-duration) ease-in-out both;
89
+ animation-name: slide-out-to-bottom;
90
+ animation-duration: var(--vertical-transition-duration);
91
+ animation-timing-function: ease-in-out;
92
+ animation-fill-mode: both;
81
93
  }
82
94
 
83
95
  /* Reduced motion: null the slide distance so the keyframes above degrade to an opacity-only crossfade (reduced-motion-safe), and disable the group's default positional morph. Unlayered so it wins over app-level overrides of the distance hook. */
@@ -1,6 +1,27 @@
1
1
  import type { ReactElement } from "react";
2
- import "./VerticalTransition.css";
2
+ import { getClass, getModuleClass } from "../util/css.js";
3
3
  import { Transition, type TransitionProps } from "./Transition.js";
4
+ import VERTICAL_TRANSITION_CSS from "./VerticalTransition.module.css";
5
+
6
+ /**
7
+ * View transition class that slides content down: the new content comes in from the top and the old content leaves to the bottom.
8
+ *
9
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
10
+ * - Also adds the plain global `slide-down` class, so app CSS can target it with `::view-transition-group(.slide-down)`.
11
+ *
12
+ * @see https://shelving.cc/ui/SLIDE_DOWN_TRANSITION_CLASS
13
+ */
14
+ export const SLIDE_DOWN_TRANSITION_CLASS = getClass("slide-down", getModuleClass(VERTICAL_TRANSITION_CSS, "slide-down"));
15
+
16
+ /**
17
+ * View transition class that slides content up: the new content comes in from the bottom and the old content leaves to the top.
18
+ *
19
+ * - Pass it to React's `<ViewTransition>` (for example `enter` or `exit`) to use this animation without the component.
20
+ * - Also adds the plain global `slide-up` class, so app CSS can target it with `::view-transition-group(.slide-up)`.
21
+ *
22
+ * @see https://shelving.cc/ui/SLIDE_UP_TRANSITION_CLASS
23
+ */
24
+ export const SLIDE_UP_TRANSITION_CLASS = getClass("slide-up", getModuleClass(VERTICAL_TRANSITION_CSS, "slide-up"));
4
25
 
5
26
  /**
6
27
  * Props for the `VerticalTransition` component — the shared transition variant props.
@@ -16,5 +37,7 @@ export interface VerticalTransitionProps extends TransitionProps {}
16
37
  * @see https://shelving.cc/ui/VerticalTransition
17
38
  */
18
39
  export function VerticalTransition(props: VerticalTransitionProps): ReactElement {
19
- return <Transition default="slide-down" forward="slide-down" back="slide-up" {...props} />;
40
+ return (
41
+ <Transition default={SLIDE_DOWN_TRANSITION_CLASS} forward={SLIDE_DOWN_TRANSITION_CLASS} back={SLIDE_UP_TRANSITION_CLASS} {...props} />
42
+ );
20
43
  }