shelving 1.264.0 → 1.264.2

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 (210) hide show
  1. package/package.json +1 -1
  2. package/ui/README.md +2 -2
  3. package/ui/block/Blockquote.module.css +0 -3
  4. package/ui/block/Card.d.ts +1 -1
  5. package/ui/block/Card.js +1 -1
  6. package/ui/block/Card.md +3 -7
  7. package/ui/block/Card.module.css +0 -3
  8. package/ui/block/Card.tsx +1 -1
  9. package/ui/block/Heading.md +0 -1
  10. package/ui/block/Heading.module.css +0 -3
  11. package/ui/block/Image.d.ts +3 -3
  12. package/ui/block/Image.js +4 -4
  13. package/ui/block/Image.module.css +4 -1
  14. package/ui/block/Image.tsx +14 -4
  15. package/ui/block/Label.module.css +0 -3
  16. package/ui/block/List.md +1 -2
  17. package/ui/block/List.module.css +0 -3
  18. package/ui/block/Panel.md +1 -2
  19. package/ui/block/Panel.module.css +0 -3
  20. package/ui/block/Paragraph.md +1 -2
  21. package/ui/block/Paragraph.module.css +0 -3
  22. package/ui/block/Preformatted.module.css +0 -3
  23. package/ui/block/Subheading.md +0 -1
  24. package/ui/block/Subheading.module.css +0 -3
  25. package/ui/block/Title.md +0 -1
  26. package/ui/block/Title.module.css +0 -3
  27. package/ui/block/Video.d.ts +3 -58
  28. package/ui/block/Video.js +2 -52
  29. package/ui/block/Video.module.css +1 -51
  30. package/ui/block/Video.tsx +3 -99
  31. package/ui/{form → button}/Button.d.ts +6 -2
  32. package/ui/{form → button}/Button.md +1 -2
  33. package/ui/{form → button}/Button.module.css +0 -3
  34. package/ui/{form → button}/Button.tsx +6 -1
  35. package/ui/button/FullscreenButton.d.ts +31 -0
  36. package/ui/button/FullscreenButton.js +37 -0
  37. package/ui/button/FullscreenButton.tsx +58 -0
  38. package/ui/button/RetryButton.d.ts +29 -0
  39. package/ui/button/RetryButton.js +27 -0
  40. package/ui/button/RetryButton.tsx +48 -0
  41. package/ui/{form → button}/SubmitButton.d.ts +12 -8
  42. package/ui/{form → button}/SubmitButton.js +4 -4
  43. package/ui/{form → button}/SubmitButton.tsx +22 -18
  44. package/ui/button/index.d.ts +5 -0
  45. package/ui/button/index.js +5 -0
  46. package/ui/button/index.ts +5 -0
  47. package/ui/dialog/Dialog.d.ts +1 -1
  48. package/ui/dialog/Dialog.tsx +1 -1
  49. package/ui/docs/DocumentationPage.test.tsx +2 -4
  50. package/ui/docs/DocumentationParams.js +1 -1
  51. package/ui/docs/DocumentationParams.tsx +1 -1
  52. package/ui/docs/DocumentationProperties.js +1 -1
  53. package/ui/docs/DocumentationProperties.tsx +1 -1
  54. package/ui/docs/DocumentationReferences.js +1 -1
  55. package/ui/docs/DocumentationReferences.tsx +1 -1
  56. package/ui/docs/DocumentationReturns.js +1 -1
  57. package/ui/docs/DocumentationReturns.tsx +1 -1
  58. package/ui/docs/DocumentationSearchPage.js +2 -2
  59. package/ui/docs/DocumentationSearchPage.tsx +2 -2
  60. package/ui/docs/DocumentationThrows.js +1 -1
  61. package/ui/docs/DocumentationThrows.tsx +1 -1
  62. package/ui/form/Field.test.tsx +1 -1
  63. package/ui/form/FormContext.d.ts +1 -1
  64. package/ui/form/FormContext.js +1 -1
  65. package/ui/form/FormContext.tsx +1 -1
  66. package/ui/form/FormFields.d.ts +1 -1
  67. package/ui/form/FormFields.js +1 -1
  68. package/ui/form/FormFields.tsx +2 -2
  69. package/ui/form/FormFooter.js +1 -1
  70. package/ui/form/FormFooter.tsx +1 -1
  71. package/ui/form/FormInput.d.ts +1 -1
  72. package/ui/form/FormInput.js +1 -1
  73. package/ui/form/FormInput.tsx +2 -2
  74. package/ui/form/Progress.d.ts +6 -24
  75. package/ui/form/Progress.js +9 -20
  76. package/ui/form/Progress.module.css +13 -32
  77. package/ui/form/Progress.tsx +18 -51
  78. package/ui/form/index.d.ts +0 -23
  79. package/ui/form/index.js +0 -23
  80. package/ui/form/index.ts +0 -23
  81. package/ui/index.d.ts +2 -0
  82. package/ui/index.js +2 -0
  83. package/ui/index.ts +2 -0
  84. package/ui/inline/Deleted.md +4 -5
  85. package/ui/inline/Deleted.module.css +1 -3
  86. package/ui/inline/Inserted.md +4 -5
  87. package/ui/inline/Inserted.module.css +1 -3
  88. package/ui/inline/Link.d.ts +1 -1
  89. package/ui/inline/Link.js +1 -1
  90. package/ui/inline/Link.md +2 -3
  91. package/ui/inline/Link.module.css +1 -3
  92. package/ui/inline/Link.tsx +1 -1
  93. package/ui/inline/Mark.js +1 -2
  94. package/ui/inline/Mark.md +5 -5
  95. package/ui/inline/Mark.module.css +2 -3
  96. package/ui/inline/Mark.tsx +0 -2
  97. package/ui/{form → input}/ArrayInput.js +1 -1
  98. package/ui/{form → input}/ArrayInput.tsx +1 -1
  99. package/ui/{form → input}/ButtonInput.d.ts +1 -1
  100. package/ui/{form → input}/ButtonInput.js +1 -1
  101. package/ui/{form → input}/ButtonInput.tsx +1 -1
  102. package/ui/{form → input}/ButtonPopover.d.ts +1 -1
  103. package/ui/{form → input}/ButtonPopover.js +1 -1
  104. package/ui/{form → input}/ButtonPopover.tsx +1 -1
  105. package/ui/{form → input}/DictionaryInput.js +1 -1
  106. package/ui/{form → input}/DictionaryInput.tsx +1 -1
  107. package/ui/{form → input}/SchemaInput.js +1 -1
  108. package/ui/{form → input}/SchemaInput.test.tsx +3 -3
  109. package/ui/{form → input}/SchemaInput.tsx +1 -1
  110. package/ui/{form → input}/TextInput.d.ts +1 -1
  111. package/ui/{form → input}/TextInput.js +1 -1
  112. package/ui/{form → input}/TextInput.tsx +1 -1
  113. package/ui/input/index.d.ts +20 -0
  114. package/ui/input/index.js +20 -0
  115. package/ui/input/index.ts +20 -0
  116. package/ui/layout/CenteredLayout.d.ts +5 -7
  117. package/ui/layout/CenteredLayout.js +8 -4
  118. package/ui/layout/CenteredLayout.md +9 -2
  119. package/ui/layout/CenteredLayout.module.css +16 -22
  120. package/ui/layout/CenteredLayout.tsx +18 -12
  121. package/ui/layout/Layout.d.ts +1 -1
  122. package/ui/layout/Layout.js +4 -0
  123. package/ui/layout/Layout.ts +6 -0
  124. package/ui/layout/SidebarLayout.js +13 -6
  125. package/ui/layout/SidebarLayout.md +4 -4
  126. package/ui/layout/SidebarLayout.module.css +6 -9
  127. package/ui/layout/SidebarLayout.tsx +21 -18
  128. package/ui/menu/Menu.d.ts +1 -1
  129. package/ui/menu/Menu.js +1 -1
  130. package/ui/menu/Menu.tsx +1 -1
  131. package/ui/misc/Catcher.d.ts +2 -19
  132. package/ui/misc/Catcher.js +3 -22
  133. package/ui/misc/Catcher.tsx +4 -40
  134. package/ui/misc/MetaContext.test.tsx +2 -3
  135. package/ui/misc/Tag.d.ts +1 -1
  136. package/ui/misc/Tag.js +1 -1
  137. package/ui/misc/Tag.md +1 -2
  138. package/ui/misc/Tag.module.css +0 -3
  139. package/ui/misc/Tag.tsx +1 -1
  140. package/ui/notice/Message.module.css +0 -3
  141. package/ui/notice/Notice.md +1 -2
  142. package/ui/notice/Notice.module.css +0 -3
  143. package/ui/router/Router.test.tsx +1 -4
  144. package/ui/style/TINT_CLASS.md +1 -1
  145. package/ui/style/Width.d.ts +2 -1
  146. package/ui/style/Width.module.css +47 -17
  147. package/ui/style/Width.tsx +22 -1
  148. package/ui/style/getWidthClass.md +5 -9
  149. package/ui/table/Table.md +1 -1
  150. package/ui/tree/TreeButton.d.ts +1 -1
  151. package/ui/tree/TreeButton.js +1 -1
  152. package/ui/tree/TreeButton.test.tsx +2 -5
  153. package/ui/tree/TreeButton.tsx +1 -1
  154. package/ui/tree/TreeContext.test.tsx +2 -3
  155. package/ui/tree/TreeMarkup.test.tsx +2 -5
  156. package/ui/tree/TreeRouter.test.tsx +2 -5
  157. package/ui/tree/TreeSidebar.js +1 -1
  158. package/ui/tree/TreeSidebar.tsx +1 -1
  159. /package/ui/{form → button}/Button.js +0 -0
  160. /package/ui/{form → button}/Clickable.d.ts +0 -0
  161. /package/ui/{form → button}/Clickable.js +0 -0
  162. /package/ui/{form → button}/Clickable.tsx +0 -0
  163. /package/ui/{form → input}/ArrayInput.d.ts +0 -0
  164. /package/ui/{form → input}/ArrayRadioInputs.d.ts +0 -0
  165. /package/ui/{form → input}/ArrayRadioInputs.js +0 -0
  166. /package/ui/{form → input}/ArrayRadioInputs.tsx +0 -0
  167. /package/ui/{form → input}/ButtonInputPopover.d.ts +0 -0
  168. /package/ui/{form → input}/ButtonInputPopover.js +0 -0
  169. /package/ui/{form → input}/ButtonInputPopover.tsx +0 -0
  170. /package/ui/{form → input}/CheckboxInput.d.ts +0 -0
  171. /package/ui/{form → input}/CheckboxInput.js +0 -0
  172. /package/ui/{form → input}/CheckboxInput.tsx +0 -0
  173. /package/ui/{form → input}/ChoiceRadioInputs.d.ts +0 -0
  174. /package/ui/{form → input}/ChoiceRadioInputs.js +0 -0
  175. /package/ui/{form → input}/ChoiceRadioInputs.tsx +0 -0
  176. /package/ui/{form → input}/DataInput.d.ts +0 -0
  177. /package/ui/{form → input}/DataInput.js +0 -0
  178. /package/ui/{form → input}/DataInput.tsx +0 -0
  179. /package/ui/{form → input}/DateInput.d.ts +0 -0
  180. /package/ui/{form → input}/DateInput.js +0 -0
  181. /package/ui/{form → input}/DateInput.tsx +0 -0
  182. /package/ui/{form → input}/DictionaryInput.d.ts +0 -0
  183. /package/ui/{form → input}/FileInput.d.ts +0 -0
  184. /package/ui/{form → input}/FileInput.js +0 -0
  185. /package/ui/{form → input}/FileInput.tsx +0 -0
  186. /package/ui/{form → input}/Input.d.ts +0 -0
  187. /package/ui/{form → input}/Input.js +0 -0
  188. /package/ui/{form → input}/Input.module.css +0 -0
  189. /package/ui/{form → input}/Input.tsx +0 -0
  190. /package/ui/{form → input}/NumberInput.d.ts +0 -0
  191. /package/ui/{form → input}/NumberInput.js +0 -0
  192. /package/ui/{form → input}/NumberInput.tsx +0 -0
  193. /package/ui/{form → input}/OutputInput.d.ts +0 -0
  194. /package/ui/{form → input}/OutputInput.js +0 -0
  195. /package/ui/{form → input}/OutputInput.tsx +0 -0
  196. /package/ui/{form → input}/Popover.d.ts +0 -0
  197. /package/ui/{form → input}/Popover.js +0 -0
  198. /package/ui/{form → input}/Popover.module.css +0 -0
  199. /package/ui/{form → input}/Popover.tsx +0 -0
  200. /package/ui/{form → input}/QueryInput.d.ts +0 -0
  201. /package/ui/{form → input}/QueryInput.js +0 -0
  202. /package/ui/{form → input}/QueryInput.tsx +0 -0
  203. /package/ui/{form → input}/RadioInput.d.ts +0 -0
  204. /package/ui/{form → input}/RadioInput.js +0 -0
  205. /package/ui/{form → input}/RadioInput.tsx +0 -0
  206. /package/ui/{form → input}/SchemaInput.d.ts +0 -0
  207. /package/ui/{form → input}/SchemaInput.md +0 -0
  208. /package/ui/{form → input}/SelectInput.d.ts +0 -0
  209. /package/ui/{form → input}/SelectInput.js +0 -0
  210. /package/ui/{form → input}/SelectInput.tsx +0 -0
@@ -1,10 +1,9 @@
1
- import { ArrowsPointingInIcon, ArrowsPointingOutIcon } from "@heroicons/react/24/solid";
2
- import { type MouseEvent, type ReactElement, useEffect, useRef, useState } from "react";
1
+ import { type ReactElement, useRef } from "react";
3
2
  import { getBlockClass } from "../style/Block.js";
4
3
  import type { SpaceVariants } from "../style/Space.js";
5
4
  import type { WidthVariants } from "../style/Width.js";
6
5
  import { getClass, getModuleClass } from "../util/css.js";
7
- import type { ChildProps, OptionalChildProps } from "../util/props.js";
6
+ import type { OptionalChildProps } from "../util/props.js";
8
7
  import VIDEO_CSS from "./Video.module.css";
9
8
 
10
9
  const VIDEO_CLASS = getModuleClass(VIDEO_CSS, "video");
@@ -16,31 +15,10 @@ const VIDEO_CLASS = getModuleClass(VIDEO_CSS, "video");
16
15
  */
17
16
  export interface VideoProps extends SpaceVariants, WidthVariants, OptionalChildProps {}
18
17
 
19
- /**
20
- * Props for `VideoButtons` — `children` plus an optional `left` alignment flag.
21
- *
22
- * @see https://shelving.cc/ui/VideoButtonsProps
23
- */
24
- export interface VideoButtonsProps extends ChildProps {
25
- left?: boolean;
26
- }
27
-
28
- /**
29
- * Props for `VideoButton` — `children` plus optional `title`, `onClick`, `danger`, and `disabled`.
30
- *
31
- * @see https://shelving.cc/ui/VideoButtonProps
32
- */
33
- export interface VideoButtonProps extends ChildProps {
34
- title?: string | undefined;
35
- onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
36
- danger?: boolean;
37
- disabled?: boolean;
38
- }
39
-
40
18
  /**
41
19
  * Video container element.
42
20
  * - Has a black background and a 16:9 aspect ratio.
43
- * - Shows its contents (i.e. a `<video>` element or a `<TwilioRoom>`.
21
+ * - Shows its contents (i.e. a `<video>` element or a `<TwilioRoom>`).
44
22
  *
45
23
  * @kind component
46
24
  * @example <Video><video src="/clip.mp4" /></Video>
@@ -61,77 +39,3 @@ export function Video({ children, ...props }: VideoProps): ReactElement {
61
39
  </figure>
62
40
  );
63
41
  }
64
-
65
- /**
66
- * Set of video buttons floating over a video.
67
- *
68
- * @example <VideoButtons><FullscreenVideoButton /></VideoButtons>
69
- * @see https://shelving.cc/ui/VideoButtons
70
- */
71
- export function VideoButtons({ children, ...variants }: VideoButtonsProps) {
72
- return <div className={getModuleClass(VIDEO_CSS, "buttons", variants)}>{children}</div>;
73
- }
74
-
75
- /**
76
- * Individual video button over a video — renders a `<button>`.
77
- *
78
- * @kind component
79
- * @example <VideoButton title="Play" onClick={play}><PlayIcon /></VideoButton>
80
- * @see https://shelving.cc/ui/VideoButton
81
- */
82
- export function VideoButton({ children, title, onClick, disabled, ...variants }: VideoButtonProps): ReactElement {
83
- return (
84
- <button type="button" onClick={onClick} className={getModuleClass(VIDEO_CSS, "button", variants)} title={title} disabled={disabled}>
85
- {children}
86
- </button>
87
- );
88
- }
89
-
90
- declare const _fullscreenVideoButtonProps: unique symbol;
91
-
92
- /**
93
- * Props for `FullscreenVideoButton` — an empty marker interface (the component takes no props).
94
- *
95
- * @see https://shelving.cc/ui/FullscreenVideoButtonProps
96
- */
97
- export interface FullscreenVideoButtonProps {
98
- readonly [_fullscreenVideoButtonProps]?: never;
99
- }
100
-
101
- /**
102
- * Button to toggle the surrounding video element in and out of fullscreen.
103
- * - Renders `null` when the browser does not support the Fullscreen API.
104
- * - Tracks fullscreen state so the icon and title flip between enter/exit.
105
- *
106
- * @returns Rendered fullscreen toggle button, or `null` when fullscreen is unavailable.
107
- * @kind component
108
- * @example <Video><video src="/clip.mp4" /><VideoButtons><FullscreenVideoButton /></VideoButtons></Video>
109
- * @see https://shelving.cc/ui/FullscreenVideoButton
110
- */
111
- export function FullscreenVideoButton(): ReactElement | null {
112
- const [isFull, setFull] = useState(() => typeof document !== "undefined" && !!document.fullscreenElement);
113
-
114
- useEffect(() => {
115
- const onChange = () => setFull(!!document.fullscreenElement);
116
- document.addEventListener("fullscreenchange", onChange);
117
- return () => document.removeEventListener("fullscreenchange", onChange);
118
- });
119
-
120
- if (!document.fullscreenEnabled) return null;
121
-
122
- return (
123
- <VideoButton
124
- title={isFull ? "Exit full screen mode" : "Enter full screen mode"}
125
- onClick={({ currentTarget }) => {
126
- if (document.fullscreenElement) {
127
- document.exitFullscreen();
128
- } else {
129
- const parent = currentTarget.closest("figure, video");
130
- if (parent) parent.requestFullscreen();
131
- }
132
- }}
133
- >
134
- {isFull ? <ArrowsPointingInIcon /> : <ArrowsPointingOutIcon />}
135
- </VideoButton>
136
- );
137
- }
@@ -28,7 +28,12 @@ export interface ButtonVariants extends FlexVariants, StatusVariants, Typography
28
28
  * @see https://shelving.cc/ui/getButtonClass
29
29
  */
30
30
  export declare function getButtonClass(variants: ButtonVariants): string;
31
- interface ButtonProps extends ButtonVariants, ClickableProps {
31
+ /**
32
+ * Component props for a `<Button>` component.
33
+ *
34
+ * @see https://shelving.cc/ui/ButtonProps
35
+ */
36
+ export interface ButtonProps extends ButtonVariants, ClickableProps {
32
37
  }
33
38
  /**
34
39
  * Render either a `<button>` or an `<a href="">` styled as a button, based on whether an `onClick` or `href` prop is provided.
@@ -39,4 +44,3 @@ interface ButtonProps extends ButtonVariants, ClickableProps {
39
44
  * @see https://shelving.cc/ui/Button
40
45
  */
41
46
  export declare function Button(props: ButtonProps): ReactElement;
42
- export {};
@@ -46,11 +46,10 @@ import { getButtonClass } from "shelving/ui";
46
46
 
47
47
  ## Styling
48
48
 
49
- `Button` paints from the [tint ladder](/ui/TINT_CLASS). Override these hooks at `:root` or any ancestor scope; move `--button-tint` to recolour the whole button, or use a per-property hook for one change.
49
+ `Button` paints from the [tint ladder](/ui/TINT_CLASS). Override these hooks at `:root` or any ancestor scope; apply `color=` / `status=` (on the button or an ancestor scope) to recolour the whole button, or use a per-property hook for one change.
50
50
 
51
51
  | Variable | Styles | Default |
52
52
  |---|---|---|
53
- | `--button-tint` | Tint anchor for the button scope | `inherit` (flows from `color=` / `status=` / parent) |
54
53
  | `--button-background` | Surface fill | `var(--tint-90)` |
55
54
  | `--button-hover-background` | Surface fill on hover / focus | `var(--tint-95)` |
56
55
  | `--button-hover-border` | Border on hover / focus | `var(--button-stroke) solid var(--tint-90)` |
@@ -9,9 +9,6 @@
9
9
 
10
10
  @layer components {
11
11
  .button {
12
- /* Theme */
13
- --tint-50: var(--button-tint, inherit);
14
-
15
12
  /* Box */
16
13
  display: block;
17
14
  box-sizing: border-box;
@@ -40,7 +40,12 @@ export function getButtonClass(variants: ButtonVariants): string {
40
40
  );
41
41
  }
42
42
 
43
- interface ButtonProps extends ButtonVariants, ClickableProps {}
43
+ /**
44
+ * Component props for a `<Button>` component.
45
+ *
46
+ * @see https://shelving.cc/ui/ButtonProps
47
+ */
48
+ export interface ButtonProps extends ButtonVariants, ClickableProps {}
44
49
 
45
50
  /**
46
51
  * Render either a `<button>` or an `<a href="">` styled as a button, based on whether an `onClick` or `href` prop is provided.
@@ -0,0 +1,31 @@
1
+ import { type ReactElement } from "react";
2
+ import { type ButtonVariants } from "./Button.js";
3
+ /**
4
+ * Component props for a `<FullscreenButton>`
5
+ *
6
+ * @see https://shelving.cc/ui/FullscreenButtonProps
7
+ */
8
+ export interface FullscreenButtonProps extends ButtonVariants {
9
+ /**
10
+ * CSS selector to identify the parent element to toggle fullscreen status on.
11
+ * @default "body, figure"
12
+ */
13
+ target?: string;
14
+ }
15
+ /**
16
+ * Button to toggle the surrounding `<figure>` element or `<body>` element in/out of fullscreen mode.
17
+ * - Renders `null` when the browser does not support the Fullscreen API.
18
+ * - Tracks fullscreen state so the icon and title toggle between enter/exit.
19
+ * - Parent can be identified by `props.target`, but defaults to `figure, body` does not exist, the button will do nothing when clicked.
20
+ * - The `<Figure>` and `<Video>` components are rendered as `<figure>` so this works out the box with both of these.
21
+ * - If not contained in a `<figure>` by default the
22
+ *
23
+ * @returns Rendered fullscreen toggle button, or `null` when fullscreen is unavailable.
24
+ * @kind component
25
+ * @example <Video><video src="/clip.mp4" /><FullscreenButton /></Video>
26
+ * @see https://shelving.cc/ui/FullscreenButton
27
+ */
28
+ export declare function FullscreenButton({ target, ...props }: {
29
+ [x: string]: any;
30
+ target?: string | undefined;
31
+ }): ReactElement | null;
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ArrowsPointingInIcon, ArrowsPointingOutIcon } from "@heroicons/react/16/solid";
3
+ import { useEffect, useState } from "react";
4
+ import { Button } from "./Button.js";
5
+ /**
6
+ * Button to toggle the surrounding `<figure>` element or `<body>` element in/out of fullscreen mode.
7
+ * - Renders `null` when the browser does not support the Fullscreen API.
8
+ * - Tracks fullscreen state so the icon and title toggle between enter/exit.
9
+ * - Parent can be identified by `props.target`, but defaults to `figure, body` does not exist, the button will do nothing when clicked.
10
+ * - The `<Figure>` and `<Video>` components are rendered as `<figure>` so this works out the box with both of these.
11
+ * - If not contained in a `<figure>` by default the
12
+ *
13
+ * @returns Rendered fullscreen toggle button, or `null` when fullscreen is unavailable.
14
+ * @kind component
15
+ * @example <Video><video src="/clip.mp4" /><FullscreenButton /></Video>
16
+ * @see https://shelving.cc/ui/FullscreenButton
17
+ */
18
+ export function FullscreenButton({ target = "body, figure", ...props }) {
19
+ const [isFull, setFull] = useState(() => typeof document !== "undefined" && !!document.fullscreenElement);
20
+ useEffect(() => {
21
+ const onChange = () => setFull(!!document.fullscreenElement);
22
+ document.addEventListener("fullscreenchange", onChange);
23
+ return () => document.removeEventListener("fullscreenchange", onChange);
24
+ });
25
+ if (!document.fullscreenEnabled)
26
+ return null;
27
+ return (_jsx(Button, { title: isFull ? "Exit full screen mode" : "Enter full screen mode", onClick: ({ currentTarget }) => {
28
+ if (document.fullscreenElement) {
29
+ document.exitFullscreen();
30
+ }
31
+ else {
32
+ const parent = currentTarget.closest(target);
33
+ if (parent)
34
+ parent.requestFullscreen();
35
+ }
36
+ }, ...props, children: isFull ? _jsx(ArrowsPointingInIcon, {}) : _jsx(ArrowsPointingOutIcon, {}) }));
37
+ }
@@ -0,0 +1,58 @@
1
+ import { ArrowsPointingInIcon, ArrowsPointingOutIcon } from "@heroicons/react/16/solid";
2
+ import { type ReactElement, useEffect, useState } from "react";
3
+ import { Button, type ButtonVariants } from "./Button.js";
4
+
5
+ /**
6
+ * Component props for a `<FullscreenButton>`
7
+ *
8
+ * @see https://shelving.cc/ui/FullscreenButtonProps
9
+ */
10
+ export interface FullscreenButtonProps extends ButtonVariants {
11
+ /**
12
+ * CSS selector to identify the parent element to toggle fullscreen status on.
13
+ * @default "body, figure"
14
+ */
15
+ target?: string;
16
+ }
17
+
18
+ /**
19
+ * Button to toggle the surrounding `<figure>` element or `<body>` element in/out of fullscreen mode.
20
+ * - Renders `null` when the browser does not support the Fullscreen API.
21
+ * - Tracks fullscreen state so the icon and title toggle between enter/exit.
22
+ * - Parent can be identified by `props.target`, but defaults to `figure, body` does not exist, the button will do nothing when clicked.
23
+ * - The `<Figure>` and `<Video>` components are rendered as `<figure>` so this works out the box with both of these.
24
+ * - If not contained in a `<figure>` by default the
25
+ *
26
+ * @returns Rendered fullscreen toggle button, or `null` when fullscreen is unavailable.
27
+ * @kind component
28
+ * @example <Video><video src="/clip.mp4" /><FullscreenButton /></Video>
29
+ * @see https://shelving.cc/ui/FullscreenButton
30
+ */
31
+ export function FullscreenButton({ target = "body, figure", ...props }): ReactElement | null {
32
+ const [isFull, setFull] = useState(() => typeof document !== "undefined" && !!document.fullscreenElement);
33
+
34
+ useEffect(() => {
35
+ const onChange = () => setFull(!!document.fullscreenElement);
36
+ document.addEventListener("fullscreenchange", onChange);
37
+ return () => document.removeEventListener("fullscreenchange", onChange);
38
+ });
39
+
40
+ if (!document.fullscreenEnabled) return null;
41
+
42
+ return (
43
+ <Button
44
+ title={isFull ? "Exit full screen mode" : "Enter full screen mode"}
45
+ onClick={({ currentTarget }) => {
46
+ if (document.fullscreenElement) {
47
+ document.exitFullscreen();
48
+ } else {
49
+ const parent = currentTarget.closest(target);
50
+ if (parent) parent.requestFullscreen();
51
+ }
52
+ }}
53
+ {...props}
54
+ >
55
+ {isFull ? <ArrowsPointingInIcon /> : <ArrowsPointingOutIcon />}
56
+ </Button>
57
+ );
58
+ }
@@ -0,0 +1,29 @@
1
+ import { type ReactElement } from "react";
2
+ import type { Callback } from "../../util/function.js";
3
+ import type { OptionalChildProps } from "../util/index.js";
4
+ import { type ButtonVariants } from "./Button.js";
5
+ /**
6
+ * Context for providing a "retry" callback to descendant `<RetryButton>` elements.
7
+ * - Used by `<Catcher>` to provide a retry callback to its children.
8
+ * - Default `<ErrorNotice>` and `<ErrorPage>` elements include `<RetryButton>` to trigger a retry on their parent `<Catcher>`
9
+ */
10
+ export declare const RetryContext: import("react").Context<Callback | undefined>;
11
+ /**
12
+ * Component props for `<RetryButton>`
13
+ *
14
+ * @property children - The content of the button. Defaults to a refresh icon and `"Retry"`
15
+ *
16
+ * @see https://shelving.cc/ui/RetryButtonProps
17
+ */
18
+ export interface RetryButtonProps extends ButtonVariants, OptionalChildProps {
19
+ }
20
+ /**
21
+ * Button that retries the nearest `<Catcher>` error boundary when clicked.
22
+ *
23
+ * - Reads the retry callback from `<Catcher>`'s private context, so it renders `null` when there is no boundary above it to retry.
24
+ * - Defaults to an "Retry" label with a refresh icon; pass `children` to override.
25
+ *
26
+ * @kind component
27
+ * @see https://shelving.cc/ui/RetryButton
28
+ */
29
+ export declare function RetryButton({ children, ...props }: RetryButtonProps): ReactElement | null;
@@ -0,0 +1,27 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ArrowPathIcon } from "@heroicons/react/16/solid";
3
+ import { createContext, use } from "react";
4
+ import { Button } from "./Button.js";
5
+ /**
6
+ * Context for providing a "retry" callback to descendant `<RetryButton>` elements.
7
+ * - Used by `<Catcher>` to provide a retry callback to its children.
8
+ * - Default `<ErrorNotice>` and `<ErrorPage>` elements include `<RetryButton>` to trigger a retry on their parent `<Catcher>`
9
+ */
10
+ export const RetryContext = createContext(undefined);
11
+ RetryContext.displayName = "RetryContext";
12
+ const _RETRY_CHILDREN = (_jsxs(_Fragment, { children: [_jsx(ArrowPathIcon, {}), "Retry"] }));
13
+ /**
14
+ * Button that retries the nearest `<Catcher>` error boundary when clicked.
15
+ *
16
+ * - Reads the retry callback from `<Catcher>`'s private context, so it renders `null` when there is no boundary above it to retry.
17
+ * - Defaults to an "Retry" label with a refresh icon; pass `children` to override.
18
+ *
19
+ * @kind component
20
+ * @see https://shelving.cc/ui/RetryButton
21
+ */
22
+ export function RetryButton({ children = _RETRY_CHILDREN, ...props }) {
23
+ const retry = use(RetryContext);
24
+ if (!retry)
25
+ return null;
26
+ return (_jsx(Button, { onClick: retry, ...props, children: children }));
27
+ }
@@ -0,0 +1,48 @@
1
+ import { ArrowPathIcon } from "@heroicons/react/16/solid";
2
+ import { createContext, type ReactElement, use } from "react";
3
+ import type { Callback } from "../../util/function.js";
4
+ import type { OptionalChildProps } from "../util/index.js";
5
+ import { Button, type ButtonVariants } from "./Button.js";
6
+
7
+ /**
8
+ * Context for providing a "retry" callback to descendant `<RetryButton>` elements.
9
+ * - Used by `<Catcher>` to provide a retry callback to its children.
10
+ * - Default `<ErrorNotice>` and `<ErrorPage>` elements include `<RetryButton>` to trigger a retry on their parent `<Catcher>`
11
+ */
12
+ export const RetryContext = createContext<Callback | undefined>(undefined);
13
+ RetryContext.displayName = "RetryContext";
14
+
15
+ /**
16
+ * Component props for `<RetryButton>`
17
+ *
18
+ * @property children - The content of the button. Defaults to a refresh icon and `"Retry"`
19
+ *
20
+ * @see https://shelving.cc/ui/RetryButtonProps
21
+ */
22
+ export interface RetryButtonProps extends ButtonVariants, OptionalChildProps {}
23
+
24
+ const _RETRY_CHILDREN = (
25
+ <>
26
+ <ArrowPathIcon />
27
+ Retry
28
+ </>
29
+ );
30
+
31
+ /**
32
+ * Button that retries the nearest `<Catcher>` error boundary when clicked.
33
+ *
34
+ * - Reads the retry callback from `<Catcher>`'s private context, so it renders `null` when there is no boundary above it to retry.
35
+ * - Defaults to an "Retry" label with a refresh icon; pass `children` to override.
36
+ *
37
+ * @kind component
38
+ * @see https://shelving.cc/ui/RetryButton
39
+ */
40
+ export function RetryButton({ children = _RETRY_CHILDREN, ...props }: RetryButtonProps): ReactElement | null {
41
+ const retry = use(RetryContext);
42
+ if (!retry) return null;
43
+ return (
44
+ <Button onClick={retry} {...props}>
45
+ {children}
46
+ </Button>
47
+ );
48
+ }
@@ -1,6 +1,17 @@
1
1
  import type { ReactElement } from "react";
2
2
  import type { OptionalChildProps } from "../util/props.js";
3
3
  import { type ButtonVariants } from "./Button.js";
4
+ /**
5
+ * Component props for `<SubmitButton>`, a form submit button.
6
+ *
7
+ * @property children - The content of the button. Defaults to `"Save"` with a right-pointing arrow icon.
8
+ * @property strong - Whether the button should have strong styling. Defaults to `true`
9
+ * @property color - The color variant of the button. Defaults to `"primary"`
10
+ *
11
+ * @see https://shelving.cc/ui/SubmitButtonProps
12
+ */
13
+ export interface SubmitButtonProps extends ButtonVariants, OptionalChildProps {
14
+ }
4
15
  /**
5
16
  * Submit button for a form that disables itself and shows a spinner while the form is busy.
6
17
  * - Defaults to strong, full-width, primary styling and a "Save" label.
@@ -9,11 +20,4 @@ import { type ButtonVariants } from "./Button.js";
9
20
  * @example <SubmitButton>Save changes</SubmitButton>
10
21
  * @see https://shelving.cc/ui/SubmitButton
11
22
  */
12
- export declare function SubmitButton({ children, strong, color, full, ...variants }: SubmitButtonProps): ReactElement;
13
- /**
14
- * Props for `SubmitButton`, a form submit button.
15
- *
16
- * @see https://shelving.cc/ui/SubmitButtonProps
17
- */
18
- export interface SubmitButtonProps extends ButtonVariants, OptionalChildProps {
19
- }
23
+ export declare function SubmitButton({ children, strong, color, full, ...props }: SubmitButtonProps): ReactElement;
@@ -1,9 +1,10 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { ArrowRightIcon } from "@heroicons/react/24/solid";
3
3
  import { useStore } from "../../react/useStore.js";
4
+ import { requireForm } from "../form/FormContext.js";
4
5
  import { LOADING } from "../misc/Loading.js";
5
6
  import { getButtonClass } from "./Button.js";
6
- import { requireForm } from "./FormContext.js";
7
+ const _SUBMIT_CHILDREN = (_jsxs(_Fragment, { children: ["Save", _jsx(ArrowRightIcon, {})] }));
7
8
  /**
8
9
  * Submit button for a form that disables itself and shows a spinner while the form is busy.
9
10
  * - Defaults to strong, full-width, primary styling and a "Save" label.
@@ -12,9 +13,8 @@ import { requireForm } from "./FormContext.js";
12
13
  * @example <SubmitButton>Save changes</SubmitButton>
13
14
  * @see https://shelving.cc/ui/SubmitButton
14
15
  */
15
- export function SubmitButton({ children = SUBMIT_CHILDREN, strong = true, color = "primary", full = true, ...variants }) {
16
+ export function SubmitButton({ children = _SUBMIT_CHILDREN, strong = true, color = "primary", full = true, ...props }) {
16
17
  const form = requireForm();
17
18
  const busy = useStore(form.busy).value;
18
- return (_jsx("button", { type: "submit", disabled: busy, className: getButtonClass({ strong, color, full, ...variants }), children: busy ? LOADING : children }));
19
+ return (_jsx("button", { type: "submit", disabled: busy, className: getButtonClass({ strong, color, full, ...props }), children: busy ? LOADING : children }));
19
20
  }
20
- const SUBMIT_CHILDREN = (_jsxs(_Fragment, { children: ["Save", _jsx(ArrowRightIcon, {})] }));
@@ -1,10 +1,28 @@
1
1
  import { ArrowRightIcon } from "@heroicons/react/24/solid";
2
2
  import type { ReactElement } from "react";
3
3
  import { useStore } from "../../react/useStore.js";
4
+ import { requireForm } from "../form/FormContext.js";
4
5
  import { LOADING } from "../misc/Loading.js";
5
6
  import type { OptionalChildProps } from "../util/props.js";
6
7
  import { type ButtonVariants, getButtonClass } from "./Button.js";
7
- import { requireForm } from "./FormContext.js";
8
+
9
+ /**
10
+ * Component props for `<SubmitButton>`, a form submit button.
11
+ *
12
+ * @property children - The content of the button. Defaults to `"Save"` with a right-pointing arrow icon.
13
+ * @property strong - Whether the button should have strong styling. Defaults to `true`
14
+ * @property color - The color variant of the button. Defaults to `"primary"`
15
+ *
16
+ * @see https://shelving.cc/ui/SubmitButtonProps
17
+ */
18
+ export interface SubmitButtonProps extends ButtonVariants, OptionalChildProps {}
19
+
20
+ const _SUBMIT_CHILDREN = (
21
+ <>
22
+ Save
23
+ <ArrowRightIcon />
24
+ </>
25
+ );
8
26
 
9
27
  /**
10
28
  * Submit button for a form that disables itself and shows a spinner while the form is busy.
@@ -15,31 +33,17 @@ import { requireForm } from "./FormContext.js";
15
33
  * @see https://shelving.cc/ui/SubmitButton
16
34
  */
17
35
  export function SubmitButton({
18
- children = SUBMIT_CHILDREN,
36
+ children = _SUBMIT_CHILDREN,
19
37
  strong = true,
20
38
  color = "primary",
21
39
  full = true,
22
- ...variants
40
+ ...props
23
41
  }: SubmitButtonProps): ReactElement {
24
42
  const form = requireForm();
25
43
  const busy = useStore(form.busy).value;
26
44
  return (
27
- <button type="submit" disabled={busy} className={getButtonClass({ strong, color, full, ...variants })}>
45
+ <button type="submit" disabled={busy} className={getButtonClass({ strong, color, full, ...props })}>
28
46
  {busy ? LOADING : children}
29
47
  </button>
30
48
  );
31
49
  }
32
-
33
- /**
34
- * Props for `SubmitButton`, a form submit button.
35
- *
36
- * @see https://shelving.cc/ui/SubmitButtonProps
37
- */
38
- export interface SubmitButtonProps extends ButtonVariants, OptionalChildProps {}
39
-
40
- const SUBMIT_CHILDREN = (
41
- <>
42
- Save
43
- <ArrowRightIcon />
44
- </>
45
- );
@@ -0,0 +1,5 @@
1
+ export * from "../button/Button.js";
2
+ export * from "../button/Clickable.js";
3
+ export * from "../button/FullscreenButton.js";
4
+ export * from "../button/RetryButton.js";
5
+ export * from "../button/SubmitButton.js";
@@ -0,0 +1,5 @@
1
+ export * from "../button/Button.js";
2
+ export * from "../button/Clickable.js";
3
+ export * from "../button/FullscreenButton.js";
4
+ export * from "../button/RetryButton.js";
5
+ export * from "../button/SubmitButton.js";
@@ -0,0 +1,5 @@
1
+ export * from "../button/Button.js";
2
+ export * from "../button/Clickable.js";
3
+ export * from "../button/FullscreenButton.js";
4
+ export * from "../button/RetryButton.js";
5
+ export * from "../button/SubmitButton.js";
@@ -1,6 +1,6 @@
1
1
  import { type ReactElement } from "react";
2
2
  import type { Callback } from "../../util/function.js";
3
- import type { ButtonVariants } from "../form/Button.js";
3
+ import type { ButtonVariants } from "../button/Button.js";
4
4
  import type { OptionalChildProps } from "../util/props.js";
5
5
  /**
6
6
  * Props for `<Dialog>` — optional `children` content and an `onClose` callback.
@@ -1,7 +1,7 @@
1
1
  import { XMarkIcon } from "@heroicons/react/24/solid";
2
2
  import { type MouseEvent, memo, type ReactElement, Suspense, useEffect, useRef } from "react";
3
3
  import type { Callback } from "../../util/function.js";
4
- import type { ButtonVariants } from "../form/Button.js";
4
+ import type { ButtonVariants } from "../button/Button.js";
5
5
  import { getModuleClass } from "../util/css.js";
6
6
  import type { OptionalChildProps } from "../util/props.js";
7
7
  import styles from "./Dialog.module.css";
@@ -1,10 +1,8 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import type { ReactNode } from "react";
3
3
  import { renderToStaticMarkup } from "react-dom/server";
4
- import type { DocumentationElement } from "../../util/tree.js";
5
- import { MetaContext } from "../misc/MetaContext.js";
6
- import { createMeta } from "../util/meta.js";
7
- import { DocumentationPage } from "./DocumentationPage.js";
4
+ import { createMeta, DocumentationPage, MetaContext } from "shelving/ui";
5
+ import type { DocumentationElement } from "shelving/util/tree";
8
6
 
9
7
  /** Make a minimal `tree-documentation` child element of a given kind. */
10
8
  function doc(name: string, kind: string): DocumentationElement {
@@ -29,7 +29,7 @@ export function DocumentationParams({ params }) {
29
29
  const map = useTreeMap();
30
30
  if (!params?.length)
31
31
  return null;
32
- return (_jsx(Section, { children: _jsx(Scroll, { horizontal: true, children: _jsxs(Table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx(Cell, { header: true, width: "fit", children: "Param" }), _jsx(Cell, { header: true, width: "fit", children: "Type" }), _jsx(Cell, { header: true, width: "xxnarrow", grow: true })] }) }), _jsx("tbody", { children: params.map(({ name, type = DEFAULT_TYPE, description, default: def, optional }) => {
32
+ return (_jsx(Section, { children: _jsx(Scroll, { horizontal: true, children: _jsxs(Table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx(Cell, { header: true, width: "fit", children: "Param" }), _jsx(Cell, { header: true, width: "fit", children: "Type" }), _jsx(Cell, { header: true, width: "16x", grow: true })] }) }), _jsx("tbody", { children: params.map(({ name, type = DEFAULT_TYPE, description, default: def, optional }) => {
33
33
  const { members, optional: typeOptional } = splitType(type);
34
34
  // An options-bag param whose (single, concrete) type resolves to a documented interface/object type is flattened into its individual fields as indented child rows.
35
35
  const single = members.length === 1 ? members[0] : undefined;
@@ -55,7 +55,7 @@ export function DocumentationParams({ params }: DocumentationParamsProps): React
55
55
  <Cell header width="fit">
56
56
  Type
57
57
  </Cell>
58
- <Cell header width="xxnarrow" grow />
58
+ <Cell header width="16x" grow />
59
59
  </tr>
60
60
  </thead>
61
61
  <tbody>
@@ -24,7 +24,7 @@ export function DocumentationProperties({ properties }) {
24
24
  const map = useTreeMap();
25
25
  if (!properties?.length)
26
26
  return null;
27
- return (_jsx(Section, { children: _jsx(Scroll, { horizontal: true, children: _jsxs(Table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx(Cell, { header: true, width: "fit", children: "Property" }), _jsx(Cell, { header: true, width: "fit", children: "Type" }), _jsx(Cell, { header: true, width: "xxnarrow", grow: true })] }) }), _jsx("tbody", { children: properties.map(({ name, type = DEFAULT_TYPE, description, default: def, optional, readonly }) => {
27
+ return (_jsx(Section, { children: _jsx(Scroll, { horizontal: true, children: _jsxs(Table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx(Cell, { header: true, width: "fit", children: "Property" }), _jsx(Cell, { header: true, width: "fit", children: "Type" }), _jsx(Cell, { header: true, width: "16x", grow: true })] }) }), _jsx("tbody", { children: properties.map(({ name, type = DEFAULT_TYPE, description, default: def, optional, readonly }) => {
28
28
  const { members, optional: typeOptional } = splitType(type);
29
29
  return (_jsxs("tr", { children: [_jsx(Cell, { nowrap: true, children: _jsx(Code, { nowrap: true, children: `.${name}` }) }), _jsx("td", { children: _jsx(DocumentationType, { members: members }) }), _jsx("td", { children: _jsx(DocumentationDescription, { description: description || getTreeElement(map, members[0] ?? DEFAULT_TYPE)?.props.description, default: def, optional: !!optional || typeOptional, readonly: readonly }) })] }, `${name}-${type}`));
30
30
  }) })] }) }) }));
@@ -49,7 +49,7 @@ export function DocumentationProperties({ properties }: DocumentationPropertiesP
49
49
  <Cell header width="fit">
50
50
  Type
51
51
  </Cell>
52
- <Cell header width="xxnarrow" grow />
52
+ <Cell header width="16x" grow />
53
53
  </tr>
54
54
  </thead>
55
55
  <tbody>
@@ -19,5 +19,5 @@ export function DocumentationReferences({ types }) {
19
19
  const map = useTreeMap();
20
20
  if (!types?.length)
21
21
  return null;
22
- return (_jsx(Section, { children: _jsx(Scroll, { horizontal: true, children: _jsxs(Table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx(Cell, { header: true, width: "fit", children: "Type" }), _jsx(Cell, { header: true, width: "xxnarrow", grow: true })] }) }), _jsx("tbody", { children: types.map(type => (_jsxs("tr", { children: [_jsx("td", { children: _jsx(TreeLink, { name: type }) }), _jsx("td", { children: _jsx(DocumentationDescription, { description: getTreeElement(map, type)?.props.description }) })] }, type))) })] }) }) }));
22
+ return (_jsx(Section, { children: _jsx(Scroll, { horizontal: true, children: _jsxs(Table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx(Cell, { header: true, width: "fit", children: "Type" }), _jsx(Cell, { header: true, width: "16x", grow: true })] }) }), _jsx("tbody", { children: types.map(type => (_jsxs("tr", { children: [_jsx("td", { children: _jsx(TreeLink, { name: type }) }), _jsx("td", { children: _jsx(DocumentationDescription, { description: getTreeElement(map, type)?.props.description }) })] }, type))) })] }) }) }));
23
23
  }