shelving 1.282.2 → 1.284.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/package.json +2 -2
- package/ui/README.md +2 -1
- package/ui/block/Address.d.ts +7 -7
- package/ui/block/Address.js +6 -6
- package/ui/block/Address.tsx +10 -9
- package/ui/block/Block.d.ts +3 -3
- package/ui/block/Block.js +3 -2
- package/ui/block/Block.tsx +5 -4
- package/ui/block/Blockquote.d.ts +3 -3
- package/ui/block/Blockquote.js +2 -2
- package/ui/block/Blockquote.tsx +4 -3
- package/ui/block/Caption.d.ts +3 -3
- package/ui/block/Caption.js +3 -3
- package/ui/block/Caption.tsx +5 -4
- package/ui/block/Card.d.ts +3 -2
- package/ui/block/Card.js +2 -2
- package/ui/block/Card.tsx +4 -2
- package/ui/block/Column.d.ts +3 -3
- package/ui/block/Column.js +2 -2
- package/ui/block/Column.tsx +4 -3
- package/ui/block/Definitions.d.ts +3 -3
- package/ui/block/Definitions.js +2 -2
- package/ui/block/Definitions.tsx +4 -3
- package/ui/block/Details.d.ts +3 -2
- package/ui/block/Details.js +2 -2
- package/ui/block/Details.tsx +4 -3
- package/ui/block/Divider.d.ts +3 -2
- package/ui/block/Divider.js +2 -2
- package/ui/block/Divider.tsx +4 -2
- package/ui/block/Heading.d.ts +3 -3
- package/ui/block/Heading.js +2 -2
- package/ui/block/Heading.tsx +4 -3
- package/ui/block/Image.d.ts +3 -2
- package/ui/block/Image.js +2 -2
- package/ui/block/Image.tsx +4 -2
- package/ui/block/Label.d.ts +1 -1
- package/ui/block/Label.js +2 -2
- package/ui/block/Label.tsx +2 -1
- package/ui/block/List.d.ts +3 -2
- package/ui/block/List.js +4 -4
- package/ui/block/List.tsx +6 -4
- package/ui/block/Panel.d.ts +3 -3
- package/ui/block/Panel.js +2 -2
- package/ui/block/Panel.tsx +4 -3
- package/ui/block/Paragraph.d.ts +3 -3
- package/ui/block/Paragraph.js +2 -2
- package/ui/block/Paragraph.tsx +4 -3
- package/ui/block/Preformatted.d.ts +3 -3
- package/ui/block/Preformatted.js +2 -2
- package/ui/block/Preformatted.tsx +4 -3
- package/ui/block/Row.d.ts +3 -3
- package/ui/block/Row.js +2 -2
- package/ui/block/Row.tsx +4 -3
- package/ui/block/Section.js +1 -1
- package/ui/block/Section.tsx +1 -0
- package/ui/block/Subheading.d.ts +1 -1
- package/ui/block/Subheading.js +2 -2
- package/ui/block/Subheading.tsx +2 -1
- package/ui/block/Title.d.ts +1 -1
- package/ui/block/Title.js +2 -2
- package/ui/block/Title.tsx +2 -1
- package/ui/block/Video.d.ts +3 -3
- package/ui/block/Video.js +2 -2
- package/ui/block/Video.tsx +4 -3
- package/ui/button/Button.d.ts +3 -2
- package/ui/button/Button.js +2 -2
- package/ui/button/Button.md +28 -0
- package/ui/button/Button.module.css +23 -5
- package/ui/button/Button.tsx +4 -3
- package/ui/button/Clickable.d.ts +3 -3
- package/ui/button/Clickable.js +6 -4
- package/ui/button/Clickable.tsx +9 -9
- package/ui/button/FullscreenButton.d.ts +3 -5
- package/ui/button/FullscreenButton.tsx +3 -2
- package/ui/button/RetryButton.d.ts +2 -2
- package/ui/button/RetryButton.tsx +2 -2
- package/ui/button/SubmitButton.d.ts +3 -3
- package/ui/button/SubmitButton.js +3 -2
- package/ui/button/SubmitButton.tsx +5 -3
- package/ui/dialog/Dialog.d.ts +6 -4
- package/ui/dialog/Dialog.js +7 -4
- package/ui/dialog/Dialog.tsx +19 -7
- package/ui/dialog/Modal.d.ts +3 -3
- package/ui/dialog/Modal.js +3 -3
- package/ui/dialog/Modal.tsx +5 -5
- package/ui/docs/DocumentationButtons.d.ts +3 -2
- package/ui/docs/DocumentationButtons.js +2 -2
- package/ui/docs/DocumentationButtons.tsx +4 -1
- package/ui/form/Field.d.ts +3 -3
- package/ui/form/Field.js +2 -2
- package/ui/form/Field.tsx +4 -3
- package/ui/form/Form.d.ts +2 -2
- package/ui/form/Form.js +3 -2
- package/ui/form/Form.tsx +5 -3
- package/ui/form/FormFields.d.ts +1 -1
- package/ui/form/FormFields.js +2 -2
- package/ui/form/FormFields.tsx +2 -2
- package/ui/form/FormFooter.d.ts +3 -3
- package/ui/form/FormFooter.js +2 -2
- package/ui/form/FormFooter.tsx +4 -4
- package/ui/form/FormMessage.d.ts +2 -2
- package/ui/form/FormMessage.tsx +2 -3
- package/ui/form/Progress.d.ts +3 -2
- package/ui/form/Progress.js +2 -2
- package/ui/form/Progress.tsx +4 -2
- package/ui/inline/Code.d.ts +3 -3
- package/ui/inline/Code.js +2 -2
- package/ui/inline/Code.tsx +4 -3
- package/ui/inline/Deleted.d.ts +3 -3
- package/ui/inline/Deleted.js +2 -2
- package/ui/inline/Deleted.tsx +4 -3
- package/ui/inline/Emphasis.d.ts +3 -3
- package/ui/inline/Emphasis.js +2 -2
- package/ui/inline/Emphasis.tsx +4 -3
- package/ui/inline/Inserted.d.ts +3 -3
- package/ui/inline/Inserted.js +2 -2
- package/ui/inline/Inserted.tsx +4 -3
- package/ui/inline/Link.d.ts +3 -2
- package/ui/inline/Link.js +2 -2
- package/ui/inline/Link.tsx +4 -2
- package/ui/inline/Mark.d.ts +3 -3
- package/ui/inline/Mark.js +2 -2
- package/ui/inline/Mark.tsx +4 -3
- package/ui/inline/Small.d.ts +3 -3
- package/ui/inline/Small.js +2 -2
- package/ui/inline/Small.tsx +4 -3
- package/ui/inline/Span.d.ts +3 -3
- package/ui/inline/Span.js +3 -2
- package/ui/inline/Span.tsx +5 -4
- package/ui/inline/Strong.d.ts +3 -3
- package/ui/inline/Strong.js +2 -2
- package/ui/inline/Strong.tsx +4 -3
- package/ui/inline/Subscript.d.ts +3 -3
- package/ui/inline/Subscript.js +3 -3
- package/ui/inline/Subscript.tsx +5 -5
- package/ui/inline/Superscript.d.ts +3 -3
- package/ui/inline/Superscript.js +3 -3
- package/ui/inline/Superscript.tsx +5 -5
- package/ui/input/ArrayInput.js +2 -2
- package/ui/input/ArrayInput.tsx +2 -1
- package/ui/input/ArrayRadioInputs.d.ts +1 -1
- package/ui/input/ArrayRadioInputs.js +2 -2
- package/ui/input/ArrayRadioInputs.tsx +2 -1
- package/ui/input/ButtonInput.d.ts +1 -1
- package/ui/input/ButtonInput.js +2 -2
- package/ui/input/ButtonInput.tsx +2 -1
- package/ui/input/CheckboxInput.d.ts +1 -1
- package/ui/input/CheckboxInput.js +2 -2
- package/ui/input/CheckboxInput.tsx +2 -0
- package/ui/input/ChoiceRadioInputs.js +2 -2
- package/ui/input/ChoiceRadioInputs.tsx +2 -1
- package/ui/input/DataInput.js +2 -2
- package/ui/input/DataInput.tsx +2 -1
- package/ui/input/DateInput.d.ts +1 -1
- package/ui/input/DateInput.js +2 -2
- package/ui/input/DateInput.tsx +2 -1
- package/ui/input/DictionaryInput.js +2 -2
- package/ui/input/DictionaryInput.tsx +2 -1
- package/ui/input/FileInput.d.ts +1 -1
- package/ui/input/FileInput.js +3 -2
- package/ui/input/FileInput.tsx +3 -1
- package/ui/input/Input.d.ts +10 -3
- package/ui/input/Input.js +2 -2
- package/ui/input/Input.tsx +11 -4
- package/ui/input/NumberInput.d.ts +1 -1
- package/ui/input/NumberInput.js +2 -2
- package/ui/input/NumberInput.tsx +2 -1
- package/ui/input/OutputInput.d.ts +1 -1
- package/ui/input/OutputInput.js +2 -2
- package/ui/input/OutputInput.tsx +2 -2
- package/ui/input/Popover.d.ts +4 -2
- package/ui/input/Popover.js +4 -3
- package/ui/input/Popover.tsx +6 -3
- package/ui/input/PopoverButton.d.ts +28 -0
- package/ui/input/{ButtonPopover.js → PopoverButton.js} +10 -8
- package/ui/input/PopoverButton.tsx +44 -0
- package/ui/input/PopoverButtonInput.d.ts +27 -0
- package/ui/input/{ButtonInputPopover.js → PopoverButtonInput.js} +10 -8
- package/ui/input/PopoverButtonInput.tsx +44 -0
- package/ui/input/QueryInput.d.ts +1 -1
- package/ui/input/QueryInput.js +2 -2
- package/ui/input/QueryInput.tsx +2 -0
- package/ui/input/RadioInput.d.ts +1 -1
- package/ui/input/RadioInput.js +2 -2
- package/ui/input/RadioInput.tsx +2 -0
- package/ui/input/SchemaInput.d.ts +1 -1
- package/ui/input/SchemaInput.js +2 -2
- package/ui/input/SchemaInput.tsx +2 -2
- package/ui/input/SelectInput.js +2 -2
- package/ui/input/SelectInput.tsx +2 -1
- package/ui/input/TextInput.d.ts +1 -1
- package/ui/input/TextInput.js +3 -3
- package/ui/input/TextInput.tsx +3 -2
- package/ui/input/index.d.ts +2 -2
- package/ui/input/index.js +2 -2
- package/ui/input/index.ts +2 -2
- package/ui/menu/Menu.d.ts +5 -5
- package/ui/menu/Menu.js +4 -4
- package/ui/menu/Menu.tsx +7 -6
- package/ui/misc/Icon.d.ts +2 -1
- package/ui/misc/Icon.js +2 -1
- package/ui/misc/Icon.tsx +3 -1
- package/ui/misc/Loading.d.ts +2 -3
- package/ui/misc/Loading.js +2 -2
- package/ui/misc/Loading.tsx +10 -3
- package/ui/misc/Tag.d.ts +3 -2
- package/ui/misc/Tag.js +2 -2
- package/ui/misc/Tag.tsx +4 -3
- package/ui/notice/Message.d.ts +3 -3
- package/ui/notice/Message.js +2 -2
- package/ui/notice/Message.tsx +4 -3
- package/ui/notice/Notice.d.ts +3 -3
- package/ui/notice/Notice.js +2 -2
- package/ui/notice/Notice.tsx +4 -2
- package/ui/notice/Notices.d.ts +3 -2
- package/ui/notice/Notices.js +2 -2
- package/ui/notice/Notices.tsx +4 -3
- package/ui/table/Cell.d.ts +3 -3
- package/ui/table/Cell.js +2 -2
- package/ui/table/Cell.tsx +4 -3
- package/ui/table/Table.d.ts +3 -3
- package/ui/table/Table.js +2 -2
- package/ui/table/Table.tsx +4 -3
- package/ui/tree/TreeBreadcrumbs.d.ts +3 -2
- package/ui/tree/TreeBreadcrumbs.js +2 -2
- package/ui/tree/TreeBreadcrumbs.tsx +4 -2
- package/ui/tree/TreeButton.d.ts +2 -1
- package/ui/tree/TreeButton.tsx +2 -1
- package/ui/util/ClassProps.md +56 -0
- package/ui/util/css.d.ts +1 -1
- package/ui/util/css.js +2 -2
- package/ui/util/css.test.ts +29 -0
- package/ui/util/css.ts +2 -2
- package/ui/util/props.d.ts +12 -0
- package/ui/util/props.test.tsx +100 -0
- package/ui/util/props.ts +13 -0
- package/ui/input/ButtonInputPopover.d.ts +0 -25
- package/ui/input/ButtonInputPopover.tsx +0 -41
- package/ui/input/ButtonPopover.d.ts +0 -25
- package/ui/input/ButtonPopover.tsx +0 -40
package/ui/dialog/Dialog.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { XMarkIcon } from "@heroicons/react/24/solid";
|
|
3
3
|
import { memo, Suspense, useEffect, useRef } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { getButtonClass } from "../button/Button.js";
|
|
5
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
5
6
|
import styles from "./Dialog.module.css";
|
|
6
7
|
/**
|
|
7
8
|
* Modal `<dialog>` element that opens on mount and includes a close button.
|
|
@@ -17,7 +18,7 @@ export const Dialog = memo(({ children, onClose, ...props }) => {
|
|
|
17
18
|
useEffect(() => {
|
|
18
19
|
ref.current?.showModal();
|
|
19
20
|
}, []);
|
|
20
|
-
return (_jsx(Suspense, { fallback: null, children: _jsxs("dialog", { ref: ref, className: getModuleClass(styles, "dialog"), onClick: _closeOnBackdropClick, onClose: onClose, ...props, children: [children, _jsx("div", { className: getModuleClass(styles, "close"), children: _jsx(DialogCloseButton, {
|
|
21
|
+
return (_jsx(Suspense, { fallback: null, children: _jsxs("dialog", { ref: ref, className: getModuleClass(styles, "dialog"), onClick: _closeOnBackdropClick, onClose: onClose, ...props, children: [children, _jsx("div", { className: getModuleClass(styles, "close"), children: _jsx(DialogCloseButton, {}) })] }) }));
|
|
21
22
|
});
|
|
22
23
|
/** When the user clicks anywhere on a `<dialog>` element (and the click isn't on a link etc), then close the dialog. */
|
|
23
24
|
function _closeOnBackdropClick({ currentTarget, target }) {
|
|
@@ -30,12 +31,14 @@ function _closeOnBackdropClick({ currentTarget, target }) {
|
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
32
33
|
* Button that closes its wrapping `<dialog>`, showing an X icon by default.
|
|
34
|
+
* - Styled with the shared `Button` classes (positioning comes from the `<Dialog>`'s own `.close` wrapper rules).
|
|
35
|
+
* - `plain` by default so only the icon shows until hover or focus — pass `plain={false}` for a solid button.
|
|
33
36
|
*
|
|
34
37
|
* @kind component
|
|
35
38
|
* @see https://shelving.cc/ui/DialogCloseButton
|
|
36
39
|
*/
|
|
37
|
-
export function DialogCloseButton({ children = _jsx(XMarkIcon, {}), ...variants }) {
|
|
38
|
-
return (_jsx("button", { type: "button", title: "Close", className:
|
|
40
|
+
export function DialogCloseButton({ children = _jsx(XMarkIcon, {}), plain = true, className, ...variants }) {
|
|
41
|
+
return (_jsx("button", { type: "button", title: "Close", className: getClass(getButtonClass({ plain, ...variants }), className), onClick: _closeOnButtonClick, children: children }));
|
|
39
42
|
}
|
|
40
43
|
function _closeOnButtonClick({ currentTarget }) {
|
|
41
44
|
currentTarget.closest("dialog")?.close();
|
package/ui/dialog/Dialog.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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
|
|
5
|
-
import { getModuleClass } from "../util/css.js";
|
|
6
|
-
import type { OptionalChildProps } from "../util/props.js";
|
|
4
|
+
import { type ButtonVariants, getButtonClass } from "../button/Button.js";
|
|
5
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
6
|
+
import type { ClassProps, OptionalChildProps } from "../util/props.js";
|
|
7
7
|
import styles from "./Dialog.module.css";
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -37,7 +37,7 @@ export const Dialog = memo(({ children, onClose, ...props }: DialogProps) => {
|
|
|
37
37
|
<dialog ref={ref} className={getModuleClass(styles, "dialog")} onClick={_closeOnBackdropClick} onClose={onClose} {...props}>
|
|
38
38
|
{children}
|
|
39
39
|
<div className={getModuleClass(styles, "close")}>
|
|
40
|
-
<DialogCloseButton
|
|
40
|
+
<DialogCloseButton />
|
|
41
41
|
</div>
|
|
42
42
|
</dialog>
|
|
43
43
|
</Suspense>
|
|
@@ -58,17 +58,29 @@ function _closeOnBackdropClick({ currentTarget, target }: MouseEvent<HTMLDialogE
|
|
|
58
58
|
*
|
|
59
59
|
* @see https://shelving.cc/ui/DialogCloseButtonProps
|
|
60
60
|
*/
|
|
61
|
-
export interface DialogCloseButtonProps extends ButtonVariants, OptionalChildProps {}
|
|
61
|
+
export interface DialogCloseButtonProps extends ButtonVariants, OptionalChildProps, ClassProps {}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Button that closes its wrapping `<dialog>`, showing an X icon by default.
|
|
65
|
+
* - Styled with the shared `Button` classes (positioning comes from the `<Dialog>`'s own `.close` wrapper rules).
|
|
66
|
+
* - `plain` by default so only the icon shows until hover or focus — pass `plain={false}` for a solid button.
|
|
65
67
|
*
|
|
66
68
|
* @kind component
|
|
67
69
|
* @see https://shelving.cc/ui/DialogCloseButton
|
|
68
70
|
*/
|
|
69
|
-
export function DialogCloseButton({
|
|
71
|
+
export function DialogCloseButton({
|
|
72
|
+
children = <XMarkIcon />,
|
|
73
|
+
plain = true,
|
|
74
|
+
className,
|
|
75
|
+
...variants
|
|
76
|
+
}: DialogCloseButtonProps): ReactElement {
|
|
70
77
|
return (
|
|
71
|
-
<button
|
|
78
|
+
<button
|
|
79
|
+
type="button"
|
|
80
|
+
title="Close"
|
|
81
|
+
className={getClass(getButtonClass({ plain, ...variants }), className)}
|
|
82
|
+
onClick={_closeOnButtonClick}
|
|
83
|
+
>
|
|
72
84
|
{children}
|
|
73
85
|
</button>
|
|
74
86
|
);
|
package/ui/dialog/Modal.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
-
import type { OptionalChildProps } from "../util/props.js";
|
|
2
|
+
import type { ClassProps, OptionalChildProps } from "../util/props.js";
|
|
3
3
|
/**
|
|
4
4
|
* Props for `<Modal>` — optional `children` content.
|
|
5
5
|
*
|
|
6
6
|
* @see https://shelving.cc/ui/ModalProps
|
|
7
7
|
*/
|
|
8
|
-
export interface ModalProps extends OptionalChildProps {
|
|
8
|
+
export interface ModalProps extends OptionalChildProps, ClassProps {
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Styled `<aside>` overlay container for modal content.
|
|
@@ -13,4 +13,4 @@ export interface ModalProps extends OptionalChildProps {
|
|
|
13
13
|
* @kind component
|
|
14
14
|
* @see https://shelving.cc/ui/Modal
|
|
15
15
|
*/
|
|
16
|
-
export declare function Modal({ children }: ModalProps): ReactElement;
|
|
16
|
+
export declare function Modal({ children, className }: ModalProps): ReactElement;
|
package/ui/dialog/Modal.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { getModuleClass } from "../util/css.js";
|
|
2
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
3
3
|
import styles from "./Modal.module.css";
|
|
4
4
|
/**
|
|
5
5
|
* Styled `<aside>` overlay container for modal content.
|
|
@@ -7,6 +7,6 @@ import styles from "./Modal.module.css";
|
|
|
7
7
|
* @kind component
|
|
8
8
|
* @see https://shelving.cc/ui/Modal
|
|
9
9
|
*/
|
|
10
|
-
export function Modal({ children }) {
|
|
11
|
-
return _jsx("aside", { className: getModuleClass(styles, "modal"), children: children });
|
|
10
|
+
export function Modal({ children, className }) {
|
|
11
|
+
return _jsx("aside", { className: getClass(getModuleClass(styles, "modal"), className), children: children });
|
|
12
12
|
}
|
package/ui/dialog/Modal.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
-
import { getModuleClass } from "../util/css.js";
|
|
3
|
-
import type { OptionalChildProps } from "../util/props.js";
|
|
2
|
+
import { getClass, getModuleClass } from "../util/css.js";
|
|
3
|
+
import type { ClassProps, OptionalChildProps } from "../util/props.js";
|
|
4
4
|
import styles from "./Modal.module.css";
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -8,7 +8,7 @@ import styles from "./Modal.module.css";
|
|
|
8
8
|
*
|
|
9
9
|
* @see https://shelving.cc/ui/ModalProps
|
|
10
10
|
*/
|
|
11
|
-
export interface ModalProps extends OptionalChildProps {}
|
|
11
|
+
export interface ModalProps extends OptionalChildProps, ClassProps {}
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Styled `<aside>` overlay container for modal content.
|
|
@@ -16,6 +16,6 @@ export interface ModalProps extends OptionalChildProps {}
|
|
|
16
16
|
* @kind component
|
|
17
17
|
* @see https://shelving.cc/ui/Modal
|
|
18
18
|
*/
|
|
19
|
-
export function Modal({ children }: ModalProps): ReactElement {
|
|
20
|
-
return <aside className={getModuleClass(styles, "modal")}>{children}</aside>;
|
|
19
|
+
export function Modal({ children, className }: ModalProps): ReactElement {
|
|
20
|
+
return <aside className={getClass(getModuleClass(styles, "modal"), className)}>{children}</aside>;
|
|
21
21
|
}
|
|
@@ -2,12 +2,13 @@ import type { ReactElement } from "react";
|
|
|
2
2
|
import type { ImmutableArray } from "../../util/array.js";
|
|
3
3
|
import { type BlockVariants } from "../style/Block.js";
|
|
4
4
|
import { type FlexVariants } from "../style/Flex.js";
|
|
5
|
+
import type { ClassProps } from "../util/props.js";
|
|
5
6
|
/**
|
|
6
7
|
* Props for `DocumentationButtons` — the relational metadata of a documented symbol (`class`, `extends`, `implements`), plus block-space and flex overrides.
|
|
7
8
|
*
|
|
8
9
|
* @see https://shelving.cc/ui/DocumentationButtonsProps
|
|
9
10
|
*/
|
|
10
|
-
export interface DocumentationButtonsProps extends BlockVariants, FlexVariants {
|
|
11
|
+
export interface DocumentationButtonsProps extends BlockVariants, FlexVariants, ClassProps {
|
|
11
12
|
/** Name of the class/interface this member belongs to (e.g. `"Store"` for `Store.get()`). Set only on methods and properties. */
|
|
12
13
|
readonly class?: string | undefined;
|
|
13
14
|
/** Full type text of the class/interface this extends, including any generic arguments (e.g. `"AbstractStore<string>"`, `"Omit<StringSchemaOptions, 'value'>"`). Resolved to a link at render time, trimming generics to the bare name; builtins/wrappers that don't resolve stay as text. */
|
|
@@ -24,4 +25,4 @@ export interface DocumentationButtonsProps extends BlockVariants, FlexVariants {
|
|
|
24
25
|
*
|
|
25
26
|
* @kind component
|
|
26
27
|
*/
|
|
27
|
-
export declare function DocumentationButtons({ space, wrap, left, gap, ...props }: DocumentationButtonsProps): ReactElement | null;
|
|
28
|
+
export declare function DocumentationButtons({ space, wrap, left, gap, className, ...props }: DocumentationButtonsProps): ReactElement | null;
|
|
@@ -22,11 +22,11 @@ function* _relations({ class: className, extends: extendsName, implements: imple
|
|
|
22
22
|
*
|
|
23
23
|
* @kind component
|
|
24
24
|
*/
|
|
25
|
-
export function DocumentationButtons({ space = "paragraph", wrap = true, left = true, gap = "none", ...props }) {
|
|
25
|
+
export function DocumentationButtons({ space = "paragraph", wrap = true, left = true, gap = "none", className, ...props }) {
|
|
26
26
|
const relations = Array.from(_relations(props));
|
|
27
27
|
if (!relations.length)
|
|
28
28
|
return null;
|
|
29
29
|
const variants = { space, wrap, left, gap, ...props };
|
|
30
30
|
return (_jsx("nav", { className: getClass(getBlockClass(variants), //
|
|
31
|
-
getFlexClass(variants)), children: relations.map(([label, to]) => (_jsxs(TreeButton, { name: to, children: [label, " ", to] }, `${label}-${to}`))) }));
|
|
31
|
+
getFlexClass(variants), className), children: relations.map(([label, to]) => (_jsxs(TreeButton, { name: to, children: [label, " ", to] }, `${label}-${to}`))) }));
|
|
32
32
|
}
|
|
@@ -4,12 +4,13 @@ import { type BlockVariants, getBlockClass } from "../style/Block.js";
|
|
|
4
4
|
import { type FlexVariants, getFlexClass } from "../style/Flex.js";
|
|
5
5
|
import { TreeButton } from "../tree/TreeButton.js";
|
|
6
6
|
import { getClass } from "../util/css.js";
|
|
7
|
+
import type { ClassProps } from "../util/props.js";
|
|
7
8
|
/**
|
|
8
9
|
* Props for `DocumentationButtons` — the relational metadata of a documented symbol (`class`, `extends`, `implements`), plus block-space and flex overrides.
|
|
9
10
|
*
|
|
10
11
|
* @see https://shelving.cc/ui/DocumentationButtonsProps
|
|
11
12
|
*/
|
|
12
|
-
export interface DocumentationButtonsProps extends BlockVariants, FlexVariants {
|
|
13
|
+
export interface DocumentationButtonsProps extends BlockVariants, FlexVariants, ClassProps {
|
|
13
14
|
/** Name of the class/interface this member belongs to (e.g. `"Store"` for `Store.get()`). Set only on methods and properties. */
|
|
14
15
|
readonly class?: string | undefined;
|
|
15
16
|
/** Full type text of the class/interface this extends, including any generic arguments (e.g. `"AbstractStore<string>"`, `"Omit<StringSchemaOptions, 'value'>"`). Resolved to a link at render time, trimming generics to the bare name; builtins/wrappers that don't resolve stay as text. */
|
|
@@ -44,6 +45,7 @@ export function DocumentationButtons({
|
|
|
44
45
|
wrap = true,
|
|
45
46
|
left = true,
|
|
46
47
|
gap = "none",
|
|
48
|
+
className,
|
|
47
49
|
...props
|
|
48
50
|
}: DocumentationButtonsProps): ReactElement | null {
|
|
49
51
|
const relations = Array.from(_relations(props));
|
|
@@ -54,6 +56,7 @@ export function DocumentationButtons({
|
|
|
54
56
|
className={getClass(
|
|
55
57
|
getBlockClass(variants), //
|
|
56
58
|
getFlexClass(variants),
|
|
59
|
+
className,
|
|
57
60
|
)}
|
|
58
61
|
>
|
|
59
62
|
{relations.map(([label, to]) => (
|
package/ui/form/Field.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ReactElement, ReactNode } from "react";
|
|
2
2
|
import { type BlockVariants } from "../style/Block.js";
|
|
3
|
-
import type { ChildProps } from "../util/index.js";
|
|
3
|
+
import type { ChildProps, ClassProps } from "../util/index.js";
|
|
4
4
|
/**
|
|
5
5
|
* Props for `Field`, a labelled wrapper around a form control.
|
|
6
6
|
*
|
|
7
7
|
* @see https://shelving.cc/ui/FieldProps
|
|
8
8
|
*/
|
|
9
|
-
export interface FieldProps extends BlockVariants, ChildProps {
|
|
9
|
+
export interface FieldProps extends BlockVariants, ChildProps, ClassProps {
|
|
10
10
|
title?: ReactNode | undefined;
|
|
11
11
|
description?: ReactNode | undefined;
|
|
12
12
|
message?: ReactNode | undefined;
|
|
@@ -18,4 +18,4 @@ export interface FieldProps extends BlockVariants, ChildProps {
|
|
|
18
18
|
* @kind component
|
|
19
19
|
* @see https://shelving.cc/ui/Field
|
|
20
20
|
*/
|
|
21
|
-
export declare function Field({ title, description, message, children, ...props }: FieldProps): ReactElement;
|
|
21
|
+
export declare function Field({ title, description, message, children, className, ...props }: FieldProps): ReactElement;
|
package/ui/form/Field.js
CHANGED
|
@@ -12,7 +12,7 @@ const FIELD_DESCRIPTION_CLASS = getModuleClass(FIELD_CSS, "description");
|
|
|
12
12
|
* @kind component
|
|
13
13
|
* @see https://shelving.cc/ui/Field
|
|
14
14
|
*/
|
|
15
|
-
export function Field({ title, description, message, children, ...props }) {
|
|
15
|
+
export function Field({ title, description, message, children, className, ...props }) {
|
|
16
16
|
return (_jsxs("label", { className: getClass(FIELD_CLASS, //
|
|
17
|
-
getBlockClass(props)), children: [(title || description) && (_jsxs("div", { children: [title ? _jsx("div", { className: FIELD_TITLE_CLASS, children: title }) : null, description && _jsx("div", { className: FIELD_DESCRIPTION_CLASS, children: description })] })), children, message && (_jsx(Message, { status: "error", right: true, children: message }))] }));
|
|
17
|
+
getBlockClass(props), className), children: [(title || description) && (_jsxs("div", { children: [title ? _jsx("div", { className: FIELD_TITLE_CLASS, children: title }) : null, description && _jsx("div", { className: FIELD_DESCRIPTION_CLASS, children: description })] })), children, message && (_jsx(Message, { status: "error", right: true, children: message }))] }));
|
|
18
18
|
}
|
package/ui/form/Field.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import type { ReactElement, ReactNode } from "react";
|
|
|
2
2
|
import { Message } from "../notice/Message.js";
|
|
3
3
|
import { type BlockVariants, getBlockClass } from "../style/Block.js";
|
|
4
4
|
import { getClass, getModuleClass } from "../util/css.js";
|
|
5
|
-
import type { ChildProps } from "../util/index.js";
|
|
5
|
+
import type { ChildProps, ClassProps } from "../util/index.js";
|
|
6
6
|
import FIELD_CSS from "./Field.module.css";
|
|
7
7
|
|
|
8
8
|
const FIELD_CLASS = getModuleClass(FIELD_CSS, "field");
|
|
@@ -14,7 +14,7 @@ const FIELD_DESCRIPTION_CLASS = getModuleClass(FIELD_CSS, "description");
|
|
|
14
14
|
*
|
|
15
15
|
* @see https://shelving.cc/ui/FieldProps
|
|
16
16
|
*/
|
|
17
|
-
export interface FieldProps extends BlockVariants, ChildProps {
|
|
17
|
+
export interface FieldProps extends BlockVariants, ChildProps, ClassProps {
|
|
18
18
|
title?: ReactNode | undefined;
|
|
19
19
|
description?: ReactNode | undefined;
|
|
20
20
|
message?: ReactNode | undefined;
|
|
@@ -27,13 +27,14 @@ export interface FieldProps extends BlockVariants, ChildProps {
|
|
|
27
27
|
* @kind component
|
|
28
28
|
* @see https://shelving.cc/ui/Field
|
|
29
29
|
*/
|
|
30
|
-
export function Field({ title, description, message, children, ...props }: FieldProps): ReactElement {
|
|
30
|
+
export function Field({ title, description, message, children, className, ...props }: FieldProps): ReactElement {
|
|
31
31
|
return (
|
|
32
32
|
// biome-ignore lint/a11y/noLabelWithoutControl: Generally `children` will contain a field.
|
|
33
33
|
<label
|
|
34
34
|
className={getClass(
|
|
35
35
|
FIELD_CLASS, //
|
|
36
36
|
getBlockClass(props),
|
|
37
|
+
className,
|
|
37
38
|
)}
|
|
38
39
|
>
|
|
39
40
|
{(title || description) && (
|
package/ui/form/Form.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { ImmutableDictionary } from "../../util/dictionary.js";
|
|
|
5
5
|
import type { Arguments } from "../../util/function.js";
|
|
6
6
|
import { type BlockVariants } from "../style/Block.js";
|
|
7
7
|
import { type NoticeCallback } from "../util/notice.js";
|
|
8
|
-
import type { OptionalChildProps } from "../util/props.js";
|
|
8
|
+
import type { ClassProps, OptionalChildProps } from "../util/props.js";
|
|
9
9
|
import { FormStore } from "./FormStore.js";
|
|
10
10
|
/**
|
|
11
11
|
* Callback invoked when a `Form` is submitted with its validated data.
|
|
@@ -20,7 +20,7 @@ export type FormCallback<T extends Data> = (data: T, event: SubmitEvent<HTMLForm
|
|
|
20
20
|
*
|
|
21
21
|
* @see https://shelving.cc/ui/FormProps
|
|
22
22
|
*/
|
|
23
|
-
export interface FormProps<T extends Data> extends BlockVariants, OptionalChildProps {
|
|
23
|
+
export interface FormProps<T extends Data> extends BlockVariants, OptionalChildProps, ClassProps {
|
|
24
24
|
/** Schema for the form. */
|
|
25
25
|
schema: DataSchema<T>;
|
|
26
26
|
/** Initial data for the form. */
|
package/ui/form/Form.js
CHANGED
|
@@ -3,12 +3,13 @@ import { useInstance } from "../../react/useInstance.js";
|
|
|
3
3
|
import { useStore } from "../../react/useStore.js";
|
|
4
4
|
import { isAsync } from "../../util/async.js";
|
|
5
5
|
import { getBlockClass } from "../style/Block.js";
|
|
6
|
+
import { getClass } from "../util/css.js";
|
|
6
7
|
import { notifySuccess, notifyThrown } from "../util/notice.js";
|
|
7
8
|
import { FormContext } from "./FormContext.js";
|
|
8
9
|
import { FormFields } from "./FormFields.js";
|
|
9
10
|
import { FormFooter } from "./FormFooter.js";
|
|
10
11
|
import { FormStore } from "./FormStore.js";
|
|
11
|
-
export function Form({ schema, data: initialData, onSubmit, submit, messages, children = (_jsxs(_Fragment, { children: [_jsx(FormFields, {}), _jsx(FormFooter, { submit: submit })] })), ...props }) {
|
|
12
|
+
export function Form({ schema, data: initialData, onSubmit, submit, messages, className, children = (_jsxs(_Fragment, { children: [_jsx(FormFields, {}), _jsx(FormFooter, { submit: submit })] })), ...props }) {
|
|
12
13
|
// Create a form store instance and subscribe to changes in it.
|
|
13
14
|
const store = useStore(useInstance(FormStore, schema, initialData, messages));
|
|
14
15
|
const busy = useStore(store.busy).value;
|
|
@@ -23,7 +24,7 @@ export function Form({ schema, data: initialData, onSubmit, submit, messages, ch
|
|
|
23
24
|
// Close the parent dialog on successful submit.
|
|
24
25
|
if (result)
|
|
25
26
|
dialog?.close();
|
|
26
|
-
}, className: getBlockClass(props), noValidate: true, children: _jsx("fieldset", { className: getBlockClass({}), disabled: busy, children: _jsx(FormContext, { value: store, children: children }) }) }, store.key));
|
|
27
|
+
}, className: getClass(getBlockClass(props), className), noValidate: true, children: _jsx("fieldset", { className: getBlockClass({}), disabled: busy, children: _jsx(FormContext, { value: store, children: children }) }) }, store.key));
|
|
27
28
|
}
|
|
28
29
|
/**
|
|
29
30
|
* Run a form submit callback and publish success/error notices based on its return or thrown value.
|
package/ui/form/Form.tsx
CHANGED
|
@@ -7,8 +7,9 @@ import type { Data, PartialData } from "../../util/data.js";
|
|
|
7
7
|
import type { ImmutableDictionary } from "../../util/dictionary.js";
|
|
8
8
|
import type { Arguments } from "../../util/function.js";
|
|
9
9
|
import { type BlockVariants, getBlockClass } from "../style/Block.js";
|
|
10
|
+
import { getClass } from "../util/css.js";
|
|
10
11
|
import { type NoticeCallback, notifySuccess, notifyThrown } from "../util/notice.js";
|
|
11
|
-
import type { OptionalChildProps } from "../util/props.js";
|
|
12
|
+
import type { ClassProps, OptionalChildProps } from "../util/props.js";
|
|
12
13
|
import { FormContext } from "./FormContext.js";
|
|
13
14
|
import { FormFields } from "./FormFields.js";
|
|
14
15
|
import { FormFooter } from "./FormFooter.js";
|
|
@@ -31,7 +32,7 @@ export type FormCallback<T extends Data> = (
|
|
|
31
32
|
*
|
|
32
33
|
* @see https://shelving.cc/ui/FormProps
|
|
33
34
|
*/
|
|
34
|
-
export interface FormProps<T extends Data> extends BlockVariants, OptionalChildProps {
|
|
35
|
+
export interface FormProps<T extends Data> extends BlockVariants, OptionalChildProps, ClassProps {
|
|
35
36
|
/** Schema for the form. */
|
|
36
37
|
schema: DataSchema<T>;
|
|
37
38
|
/** Initial data for the form. */
|
|
@@ -60,6 +61,7 @@ export function Form({
|
|
|
60
61
|
onSubmit,
|
|
61
62
|
submit,
|
|
62
63
|
messages,
|
|
64
|
+
className,
|
|
63
65
|
children = (
|
|
64
66
|
<>
|
|
65
67
|
<FormFields />
|
|
@@ -90,7 +92,7 @@ export function Form({
|
|
|
90
92
|
// Close the parent dialog on successful submit.
|
|
91
93
|
if (result) dialog?.close();
|
|
92
94
|
}}
|
|
93
|
-
className={getBlockClass(props)}
|
|
95
|
+
className={getClass(getBlockClass(props), className)}
|
|
94
96
|
noValidate={true}
|
|
95
97
|
>
|
|
96
98
|
<fieldset className={getBlockClass({})} disabled={busy}>
|
package/ui/form/FormFields.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { InputProps } from "../input/Input.js";
|
|
|
8
8
|
* @example <FormField name="email" />
|
|
9
9
|
* @see https://shelving.cc/ui/FormField
|
|
10
10
|
*/
|
|
11
|
-
export declare function FormField({ name, ...props }: InputProps): ReactElement;
|
|
11
|
+
export declare function FormField({ name, className, ...props }: InputProps): ReactElement;
|
|
12
12
|
/**
|
|
13
13
|
* Show a `<Field>` for every property in the current form's schema.
|
|
14
14
|
*
|
package/ui/form/FormFields.js
CHANGED
|
@@ -11,10 +11,10 @@ import { requireForm, useField } from "./FormContext.js";
|
|
|
11
11
|
* @example <FormField name="email" />
|
|
12
12
|
* @see https://shelving.cc/ui/FormField
|
|
13
13
|
*/
|
|
14
|
-
export function FormField({ name, ...props }) {
|
|
14
|
+
export function FormField({ name, className, ...props }) {
|
|
15
15
|
const field = useField(name);
|
|
16
16
|
const { schema, message } = field;
|
|
17
|
-
return (_jsx(Field, { ...schema, message: message, required: props.required, children: _jsx(SchemaInput, { ...field, ...props }) }));
|
|
17
|
+
return (_jsx(Field, { ...schema, message: message, required: props.required, className: className, children: _jsx(SchemaInput, { ...field, ...props }) }));
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Show a `<Field>` for every property in the current form's schema.
|
package/ui/form/FormFields.tsx
CHANGED
|
@@ -13,12 +13,12 @@ import { requireForm, useField } from "./FormContext.js";
|
|
|
13
13
|
* @example <FormField name="email" />
|
|
14
14
|
* @see https://shelving.cc/ui/FormField
|
|
15
15
|
*/
|
|
16
|
-
export function FormField({ name, ...props }: InputProps): ReactElement {
|
|
16
|
+
export function FormField({ name, className, ...props }: InputProps): ReactElement {
|
|
17
17
|
const field = useField(name);
|
|
18
18
|
const { schema, message } = field;
|
|
19
19
|
|
|
20
20
|
return (
|
|
21
|
-
<Field {...schema} message={message} required={props.required}>
|
|
21
|
+
<Field {...schema} message={message} required={props.required} className={className}>
|
|
22
22
|
<SchemaInput {...field} {...props} />
|
|
23
23
|
</Field>
|
|
24
24
|
);
|
package/ui/form/FormFooter.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { ReactElement, ReactNode } from "react";
|
|
2
|
-
import type { OptionalChildProps } from "../util/props.js";
|
|
2
|
+
import type { ClassProps, OptionalChildProps } from "../util/props.js";
|
|
3
3
|
/**
|
|
4
4
|
* Props for `FormFooter`, the submit-button-and-message footer for a form.
|
|
5
5
|
*
|
|
6
6
|
* @see https://shelving.cc/ui/FormFooterProps
|
|
7
7
|
*/
|
|
8
|
-
export interface FormFooterProps extends OptionalChildProps {
|
|
8
|
+
export interface FormFooterProps extends OptionalChildProps, ClassProps {
|
|
9
9
|
submit?: ReactNode | undefined;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
@@ -18,4 +18,4 @@ export interface FormFooterProps extends OptionalChildProps {
|
|
|
18
18
|
* @example <FormFooter submit="Save" />
|
|
19
19
|
* @see https://shelving.cc/ui/FormFooter
|
|
20
20
|
*/
|
|
21
|
-
export declare function FormFooter({ children, submit }: FormFooterProps): ReactElement;
|
|
21
|
+
export declare function FormFooter({ children, submit, className }: FormFooterProps): ReactElement;
|
package/ui/form/FormFooter.js
CHANGED
|
@@ -13,6 +13,6 @@ import { FormMessage } from "./FormMessage.js";
|
|
|
13
13
|
* @example <FormFooter submit="Save" />
|
|
14
14
|
* @see https://shelving.cc/ui/FormFooter
|
|
15
15
|
*/
|
|
16
|
-
export function FormFooter({ children, submit }) {
|
|
17
|
-
return (_jsxs(Footer, { children: [_jsxs(Row, { reverse: true, children: [_jsx(SubmitButton, { children: submit }), children] }), _jsx(FormMessage, {})] }));
|
|
16
|
+
export function FormFooter({ children, submit, className }) {
|
|
17
|
+
return (_jsxs(Footer, { className: className, children: [_jsxs(Row, { reverse: true, children: [_jsx(SubmitButton, { children: submit }), children] }), _jsx(FormMessage, {})] }));
|
|
18
18
|
}
|
package/ui/form/FormFooter.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import type { ReactElement, ReactNode } from "react";
|
|
|
2
2
|
import { Row } from "../block/Row.js";
|
|
3
3
|
import { Footer } from "../block/Section.js";
|
|
4
4
|
import { SubmitButton } from "../button/SubmitButton.js";
|
|
5
|
-
import type { OptionalChildProps } from "../util/props.js";
|
|
5
|
+
import type { ClassProps, OptionalChildProps } from "../util/props.js";
|
|
6
6
|
import { FormMessage } from "./FormMessage.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -10,7 +10,7 @@ import { FormMessage } from "./FormMessage.js";
|
|
|
10
10
|
*
|
|
11
11
|
* @see https://shelving.cc/ui/FormFooterProps
|
|
12
12
|
*/
|
|
13
|
-
export interface FormFooterProps extends OptionalChildProps {
|
|
13
|
+
export interface FormFooterProps extends OptionalChildProps, ClassProps {
|
|
14
14
|
submit?: ReactNode | undefined;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -24,9 +24,9 @@ export interface FormFooterProps extends OptionalChildProps {
|
|
|
24
24
|
* @example <FormFooter submit="Save" />
|
|
25
25
|
* @see https://shelving.cc/ui/FormFooter
|
|
26
26
|
*/
|
|
27
|
-
export function FormFooter({ children, submit }: FormFooterProps): ReactElement {
|
|
27
|
+
export function FormFooter({ children, submit, className }: FormFooterProps): ReactElement {
|
|
28
28
|
return (
|
|
29
|
-
<Footer>
|
|
29
|
+
<Footer className={className}>
|
|
30
30
|
<Row reverse>
|
|
31
31
|
<SubmitButton>{submit}</SubmitButton>
|
|
32
32
|
{children}
|
package/ui/form/FormMessage.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
-
import type
|
|
2
|
+
import { type MessageProps } from "../notice/Message.js";
|
|
3
3
|
/**
|
|
4
4
|
* Show the current form's "main" (unnamed) message as a `<Message>`, or render nothing when there is no message.
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@ import type { BlockVariants } from "../style/Block.js";
|
|
|
8
8
|
* @example <FormMessage />
|
|
9
9
|
* @see https://shelving.cc/ui/FormMessage
|
|
10
10
|
*/
|
|
11
|
-
export declare function FormMessage(props:
|
|
11
|
+
export declare function FormMessage(props: Omit<MessageProps, "children">): ReactElement | null;
|
package/ui/form/FormMessage.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import { useStore } from "../../react/useStore.js";
|
|
3
|
-
import { Message } from "../notice/Message.js";
|
|
4
|
-
import type { BlockVariants } from "../style/Block.js";
|
|
3
|
+
import { Message, type MessageProps } from "../notice/Message.js";
|
|
5
4
|
import { requireForm } from "./FormContext.js";
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -12,7 +11,7 @@ import { requireForm } from "./FormContext.js";
|
|
|
12
11
|
* @example <FormMessage />
|
|
13
12
|
* @see https://shelving.cc/ui/FormMessage
|
|
14
13
|
*/
|
|
15
|
-
export function FormMessage(props:
|
|
14
|
+
export function FormMessage(props: Omit<MessageProps, "children">): ReactElement | null {
|
|
16
15
|
const message = useStore(requireForm().messages).get("");
|
|
17
16
|
if (!message) return null;
|
|
18
17
|
return (
|
package/ui/form/Progress.d.ts
CHANGED
|
@@ -2,13 +2,14 @@ import type { ReactElement } from "react";
|
|
|
2
2
|
import { type Nullish } from "../../util/null.js";
|
|
3
3
|
import { type ColorVariants } from "../style/Color.js";
|
|
4
4
|
import { type StatusVariants } from "../style/Status.js";
|
|
5
|
+
import type { ClassProps } from "../util/props.js";
|
|
5
6
|
import "./Progress.css";
|
|
6
7
|
/**
|
|
7
8
|
* Props for `Progress`, a continuous horizontal progress bar.
|
|
8
9
|
*
|
|
9
10
|
* @see https://shelving.cc/ui/ProgressProps
|
|
10
11
|
*/
|
|
11
|
-
export interface ProgressProps extends ColorVariants, StatusVariants {
|
|
12
|
+
export interface ProgressProps extends ColorVariants, StatusVariants, ClassProps {
|
|
12
13
|
/** Position within the `min`–`max` range, or `null`/`undefined`/omitted for an indeterminate bar. */
|
|
13
14
|
value?: Nullish<number>;
|
|
14
15
|
min?: number;
|
|
@@ -29,4 +30,4 @@ export interface ProgressProps extends ColorVariants, StatusVariants {
|
|
|
29
30
|
* @example <Progress />
|
|
30
31
|
* @see https://shelving.cc/ui/Progress
|
|
31
32
|
*/
|
|
32
|
-
export declare function Progress({ value, min, max, ...props }: ProgressProps): ReactElement;
|
|
33
|
+
export declare function Progress({ value, min, max, className, ...props }: ProgressProps): ReactElement;
|
package/ui/form/Progress.js
CHANGED
|
@@ -21,11 +21,11 @@ import styles from "./Progress.module.css";
|
|
|
21
21
|
* @example <Progress />
|
|
22
22
|
* @see https://shelving.cc/ui/Progress
|
|
23
23
|
*/
|
|
24
|
-
export function Progress({ value, min = 0, max = 100, ...props }) {
|
|
24
|
+
export function Progress({ value, min = 0, max = 100, className, ...props }) {
|
|
25
25
|
// `<progress>` has no `min`, so shift the range to a `0`-based one. A non-positive span would make `<progress>` indeterminate, so fall back to an empty determinate bar.
|
|
26
26
|
const span = max - min;
|
|
27
27
|
return (_jsx("progress", { className: getClass(getModuleClass(styles, "progress"), //
|
|
28
|
-
getColorClass(props), getStatusClass(props)),
|
|
28
|
+
getColorClass(props), getStatusClass(props), className),
|
|
29
29
|
// A nullish `value` drops the attribute (and its announced text) so the element is natively `:indeterminate` and the flowing animation styled off that pseudo-class takes over.
|
|
30
30
|
value: notNullish(value) ? (span > 0 ? value - min : 0) : undefined, max: span > 0 ? span : 1, "aria-valuetext": notNullish(value) ? formatPercent(value - min, max - min) : undefined }));
|
|
31
31
|
}
|
package/ui/form/Progress.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { type Nullish, notNullish } from "../../util/null.js";
|
|
|
4
4
|
import { type ColorVariants, getColorClass } from "../style/Color.js";
|
|
5
5
|
import { getStatusClass, type StatusVariants } from "../style/Status.js";
|
|
6
6
|
import { getClass, getModuleClass } from "../util/css.js";
|
|
7
|
+
import type { ClassProps } from "../util/props.js";
|
|
7
8
|
import "./Progress.css";
|
|
8
9
|
import styles from "./Progress.module.css";
|
|
9
10
|
|
|
@@ -12,7 +13,7 @@ import styles from "./Progress.module.css";
|
|
|
12
13
|
*
|
|
13
14
|
* @see https://shelving.cc/ui/ProgressProps
|
|
14
15
|
*/
|
|
15
|
-
export interface ProgressProps extends ColorVariants, StatusVariants {
|
|
16
|
+
export interface ProgressProps extends ColorVariants, StatusVariants, ClassProps {
|
|
16
17
|
/** Position within the `min`–`max` range, or `null`/`undefined`/omitted for an indeterminate bar. */
|
|
17
18
|
value?: Nullish<number>;
|
|
18
19
|
min?: number;
|
|
@@ -34,7 +35,7 @@ export interface ProgressProps extends ColorVariants, StatusVariants {
|
|
|
34
35
|
* @example <Progress />
|
|
35
36
|
* @see https://shelving.cc/ui/Progress
|
|
36
37
|
*/
|
|
37
|
-
export function Progress({ value, min = 0, max = 100, ...props }: ProgressProps): ReactElement {
|
|
38
|
+
export function Progress({ value, min = 0, max = 100, className, ...props }: ProgressProps): ReactElement {
|
|
38
39
|
// `<progress>` has no `min`, so shift the range to a `0`-based one. A non-positive span would make `<progress>` indeterminate, so fall back to an empty determinate bar.
|
|
39
40
|
const span = max - min;
|
|
40
41
|
|
|
@@ -44,6 +45,7 @@ export function Progress({ value, min = 0, max = 100, ...props }: ProgressProps)
|
|
|
44
45
|
getModuleClass(styles, "progress"), //
|
|
45
46
|
getColorClass(props),
|
|
46
47
|
getStatusClass(props),
|
|
48
|
+
className,
|
|
47
49
|
)}
|
|
48
50
|
// A nullish `value` drops the attribute (and its announced text) so the element is natively `:indeterminate` and the flowing animation styled off that pseudo-class takes over.
|
|
49
51
|
value={notNullish(value) ? (span > 0 ? value - min : 0) : undefined}
|
package/ui/inline/Code.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import { type TypographyVariants } from "../style/Typography.js";
|
|
3
|
-
import type { OptionalChildProps } from "../util/index.js";
|
|
3
|
+
import type { ClassProps, OptionalChildProps } from "../util/index.js";
|
|
4
4
|
/**
|
|
5
5
|
* Props for `Code` — colour and typography variants, optional `children`, plus a `plain` toggle.
|
|
6
6
|
*
|
|
7
7
|
* @see https://shelving.cc/ui/CodeProps
|
|
8
8
|
*/
|
|
9
|
-
export interface CodeProps extends TypographyVariants, OptionalChildProps {
|
|
9
|
+
export interface CodeProps extends TypographyVariants, OptionalChildProps, ClassProps {
|
|
10
10
|
plain?: boolean | undefined;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
@@ -16,4 +16,4 @@ export interface CodeProps extends TypographyVariants, OptionalChildProps {
|
|
|
16
16
|
* @kind component
|
|
17
17
|
* @see https://shelving.cc/ui/Code
|
|
18
18
|
*/
|
|
19
|
-
export declare function Code({ children, plain, ...props }: CodeProps): ReactElement;
|
|
19
|
+
export declare function Code({ children, plain, className, ...props }: CodeProps): ReactElement;
|
package/ui/inline/Code.js
CHANGED
|
@@ -11,7 +11,7 @@ const CODE_PLAIN_CLASS = getModuleClass(CODE_CSS, "plain");
|
|
|
11
11
|
* @kind component
|
|
12
12
|
* @see https://shelving.cc/ui/Code
|
|
13
13
|
*/
|
|
14
|
-
export function Code({ children, plain, ...props }) {
|
|
14
|
+
export function Code({ children, plain, className, ...props }) {
|
|
15
15
|
return (_jsx("code", { className: getClass(CODE_CLASS, //
|
|
16
|
-
plain && CODE_PLAIN_CLASS, getTypographyClass(props)), children: children }));
|
|
16
|
+
plain && CODE_PLAIN_CLASS, getTypographyClass(props), className), children: children }));
|
|
17
17
|
}
|