@torpor/ui 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/Accordion/Accordion.torp +23 -11
- package/dist/Accordion/AccordionContent.torp +13 -6
- package/dist/Accordion/AccordionHeader.torp +14 -5
- package/dist/Accordion/AccordionItem.torp +22 -8
- package/dist/Accordion/AccordionTrigger.torp +14 -6
- package/dist/Accordion/AccordionTypes.ts +2 -0
- package/dist/Accordion/index.d.ts +100 -35
- package/dist/Breadcrumb/Breadcrumb.torp +12 -3
- package/dist/Breadcrumb/BreadcrumbItem.torp +12 -3
- package/dist/Breadcrumb/BreadcrumbSeparator.torp +10 -1
- package/dist/Breadcrumb/index.d.ts +49 -21
- package/dist/Calendar/Calendar.torp +9 -1
- package/dist/Calendar/CalendarDay.torp +9 -1
- package/dist/Calendar/index.d.ts +16 -18
- package/dist/Dialog/Dialog.torp +13 -3
- package/dist/Dialog/DialogBody.torp +11 -3
- package/dist/Dialog/DialogButton.torp +16 -4
- package/dist/Dialog/DialogFooter.torp +11 -1
- package/dist/Dialog/DialogHeader.torp +11 -2
- package/dist/Dialog/index.d.ts +78 -35
- package/dist/Disclosure/Disclosure.torp +17 -7
- package/dist/Disclosure/DisclosureContent.torp +13 -6
- package/dist/Disclosure/DisclosureHeader.torp +14 -5
- package/dist/Disclosure/DisclosureTrigger.torp +10 -2
- package/dist/Disclosure/index.d.ts +67 -28
- package/dist/Drawer/Drawer.torp +11 -1
- package/dist/Drawer/index.d.ts +10 -9
- package/dist/Form/Field.torp +93 -0
- package/dist/Form/Form.torp +131 -0
- package/dist/Form/FormTypes.ts +30 -0
- package/dist/Form/Input.torp +94 -0
- package/dist/Form/Label.torp +31 -0
- package/dist/Form/Message.torp +35 -0
- package/dist/Form/StandardSchemaV1.ts +70 -0
- package/dist/Form/index.d.ts +117 -0
- package/dist/Form/index.js +22 -0
- package/dist/Form/index.js.map +1 -0
- package/dist/Menu/Menu.torp +12 -3
- package/dist/Menu/MenuButton.torp +14 -3
- package/dist/Menu/MenuCheck.torp +14 -3
- package/dist/Menu/MenuGroup.torp +13 -3
- package/dist/Menu/MenuIndicator.torp +12 -3
- package/dist/Menu/MenuPopout.torp +17 -6
- package/dist/Menu/MenuPopoutContent.torp +13 -4
- package/dist/Menu/MenuPopoutTrigger.torp +13 -4
- package/dist/Menu/MenuRadio.torp +16 -5
- package/dist/Menu/MenuRadioGroup.torp +16 -5
- package/dist/Menu/MenuSeparator.torp +11 -1
- package/dist/Menu/index.d.ts +170 -77
- package/dist/MenuBar/MenuBar.torp +13 -4
- package/dist/MenuBar/MenuBarItem.torp +17 -6
- package/dist/MenuBar/MenuBarItemContent.torp +13 -4
- package/dist/MenuBar/MenuBarItemTrigger.torp +11 -2
- package/dist/MenuBar/index.d.ts +79 -28
- package/dist/NavMenu/NavMenu.torp +13 -4
- package/dist/NavMenu/NavMenuButton.torp +12 -5
- package/dist/NavMenu/NavMenuElement.torp +14 -6
- package/dist/NavMenu/NavMenuGroup.torp +12 -3
- package/dist/NavMenu/NavMenuGroupHeader.torp +12 -4
- package/dist/NavMenu/NavMenuLink.torp +16 -8
- package/dist/NavMenu/NavMenuPopout.torp +11 -3
- package/dist/NavMenu/NavMenuPopoutButton.torp +14 -8
- package/dist/NavMenu/NavMenuPopoutContent.torp +13 -3
- package/dist/NavMenu/NavMenuSeparator.torp +10 -1
- package/dist/NavMenu/index.d.ts +147 -70
- package/dist/Notification/Notification.torp +15 -5
- package/dist/Notification/NotificationClose.torp +10 -1
- package/dist/Notification/NotificationContainer.torp +11 -1
- package/dist/Notification/NotificationContent.torp +11 -1
- package/dist/Notification/index.d.ts +46 -28
- package/dist/Popover/Popover.torp +20 -6
- package/dist/Popover/PopoverContent.torp +10 -1
- package/dist/Popover/PopoverContentAnchored.torp +13 -6
- package/dist/Popover/PopoverContentContextual.torp +10 -1
- package/dist/Popover/PopoverOverlay.torp +10 -1
- package/dist/Popover/PopoverTrigger.torp +10 -1
- package/dist/Popover/PopoverTriggerContextual.torp +10 -1
- package/dist/Popover/PopoverTriggerHover.torp +11 -2
- package/dist/Popover/index.d.ts +101 -56
- package/dist/TabGroup/TabContent.torp +11 -5
- package/dist/TabGroup/TabGroup.torp +21 -9
- package/dist/TabGroup/TabHeader.torp +14 -5
- package/dist/TabGroup/TabList.torp +13 -4
- package/dist/TabGroup/TabTrigger.torp +12 -4
- package/dist/TabGroup/index.d.ts +93 -35
- package/dist/icons/ArrowDown.torp +3 -3
- package/dist/icons/ArrowLeft.torp +3 -3
- package/dist/icons/ArrowRight.torp +3 -3
- package/dist/icons/ArrowUp.torp +3 -3
- package/dist/icons/Bars.torp +3 -3
- package/dist/icons/Check.torp +3 -3
- package/dist/icons/ChevronDown.torp +3 -3
- package/dist/icons/ChevronLeft.torp +3 -3
- package/dist/icons/ChevronRight.torp +3 -3
- package/dist/icons/ChevronUp.torp +3 -3
- package/dist/icons/Cross.torp +3 -3
- package/dist/icons/Loading.torp +3 -3
- package/dist/icons/Minus.torp +3 -3
- package/dist/icons/Plus.torp +3 -3
- package/dist/icons/index.d.ts +14 -126
- package/dist/metafile-esm.json +1 -1
- package/package.json +13 -4
- package/src/Accordion/Accordion.torp +23 -11
- package/src/Accordion/AccordionContent.torp +13 -6
- package/src/Accordion/AccordionHeader.torp +14 -5
- package/src/Accordion/AccordionItem.torp +22 -8
- package/src/Accordion/AccordionTrigger.torp +14 -6
- package/src/Accordion/AccordionTypes.ts +2 -0
- package/src/Breadcrumb/Breadcrumb.torp +12 -3
- package/src/Breadcrumb/BreadcrumbItem.torp +12 -3
- package/src/Breadcrumb/BreadcrumbSeparator.torp +10 -1
- package/src/Calendar/Calendar.torp +9 -1
- package/src/Calendar/CalendarDay.torp +9 -1
- package/src/Dialog/Dialog.torp +13 -3
- package/src/Dialog/DialogBody.torp +11 -3
- package/src/Dialog/DialogButton.torp +16 -4
- package/src/Dialog/DialogFooter.torp +11 -1
- package/src/Dialog/DialogHeader.torp +11 -2
- package/src/Disclosure/Disclosure.torp +17 -7
- package/src/Disclosure/DisclosureContent.torp +13 -6
- package/src/Disclosure/DisclosureHeader.torp +14 -5
- package/src/Disclosure/DisclosureTrigger.torp +10 -2
- package/src/Drawer/Drawer.torp +11 -1
- package/src/Form/Field.torp +93 -0
- package/src/Form/Form.torp +131 -0
- package/src/Form/FormTypes.ts +30 -0
- package/src/Form/Input.torp +94 -0
- package/src/Form/Label.torp +31 -0
- package/src/Form/Message.torp +35 -0
- package/src/Form/StandardSchemaV1.ts +70 -0
- package/src/Form/index.ts +7 -0
- package/src/Menu/Menu.torp +12 -3
- package/src/Menu/MenuButton.torp +14 -3
- package/src/Menu/MenuCheck.torp +14 -3
- package/src/Menu/MenuGroup.torp +13 -3
- package/src/Menu/MenuIndicator.torp +12 -3
- package/src/Menu/MenuPopout.torp +17 -6
- package/src/Menu/MenuPopoutContent.torp +13 -4
- package/src/Menu/MenuPopoutTrigger.torp +13 -4
- package/src/Menu/MenuRadio.torp +16 -5
- package/src/Menu/MenuRadioGroup.torp +16 -5
- package/src/Menu/MenuSeparator.torp +11 -1
- package/src/MenuBar/MenuBar.torp +13 -4
- package/src/MenuBar/MenuBarItem.torp +17 -6
- package/src/MenuBar/MenuBarItemContent.torp +13 -4
- package/src/MenuBar/MenuBarItemTrigger.torp +11 -2
- package/src/NavMenu/NavMenu.torp +13 -4
- package/src/NavMenu/NavMenuButton.torp +12 -5
- package/src/NavMenu/NavMenuElement.torp +14 -6
- package/src/NavMenu/NavMenuGroup.torp +12 -3
- package/src/NavMenu/NavMenuGroupHeader.torp +12 -4
- package/src/NavMenu/NavMenuLink.torp +16 -8
- package/src/NavMenu/NavMenuPopout.torp +11 -3
- package/src/NavMenu/NavMenuPopoutButton.torp +14 -8
- package/src/NavMenu/NavMenuPopoutContent.torp +13 -3
- package/src/NavMenu/NavMenuSeparator.torp +10 -1
- package/src/Notification/Notification.torp +15 -5
- package/src/Notification/NotificationClose.torp +10 -1
- package/src/Notification/NotificationContainer.torp +11 -1
- package/src/Notification/NotificationContent.torp +11 -1
- package/src/Popover/Popover.torp +20 -6
- package/src/Popover/PopoverContent.torp +10 -1
- package/src/Popover/PopoverContentAnchored.torp +13 -6
- package/src/Popover/PopoverContentContextual.torp +10 -1
- package/src/Popover/PopoverOverlay.torp +10 -1
- package/src/Popover/PopoverTrigger.torp +10 -1
- package/src/Popover/PopoverTriggerContextual.torp +10 -1
- package/src/Popover/PopoverTriggerHover.torp +11 -2
- package/src/TabGroup/TabContent.torp +11 -5
- package/src/TabGroup/TabGroup.torp +21 -9
- package/src/TabGroup/TabHeader.torp +14 -5
- package/src/TabGroup/TabList.torp +13 -4
- package/src/TabGroup/TabTrigger.torp +12 -4
- package/src/icons/ArrowDown.torp +3 -3
- package/src/icons/ArrowLeft.torp +3 -3
- package/src/icons/ArrowRight.torp +3 -3
- package/src/icons/ArrowUp.torp +3 -3
- package/src/icons/Bars.torp +3 -3
- package/src/icons/Check.torp +3 -3
- package/src/icons/ChevronDown.torp +3 -3
- package/src/icons/ChevronLeft.torp +3 -3
- package/src/icons/ChevronRight.torp +3 -3
- package/src/icons/ChevronUp.torp +3 -3
- package/src/icons/Cross.torp +3 -3
- package/src/icons/Loading.torp +3 -3
- package/src/icons/Minus.torp +3 -3
- package/src/icons/Plus.torp +3 -3
- package/test/Accordion/components/AccordionAccessibility.torp +2 -0
- package/test/Accordion/components/AccordionKeyboard.torp +2 -0
- package/test/Accordion/components/AccordionList.torp +2 -0
- package/test/Accordion/components/AccordionMultiple.torp +2 -0
- package/test/Accordion/components/AccordionSingle.torp +2 -0
- package/test/Disclosure/accessibility.test.ts +3 -2
- package/test/Disclosure/components/DisclosureTest.torp +2 -0
- package/test/Disclosure/toggle.test.ts +3 -2
- package/test/Form/components/FieldTest.torp +25 -0
- package/test/Form/components/FormTest.torp +31 -0
- package/test/Form/components/InputTest.torp +9 -0
- package/test/Form/field.test.ts +34 -0
- package/test/Form/form.test.ts +34 -0
- package/test/Form/input.test.ts +19 -0
- package/test/Menu/accessibility.test.ts +3 -2
- package/test/Menu/basic.test.ts +11 -10
- package/test/MenuBar/accessibility.test.ts +3 -2
- package/test/MenuBar/basic.test.ts +3 -2
- package/test/NavMenu/basic.test.ts +1 -1
- package/test/NavMenu/components/{NavMenu.torp → NavMenuBasic.torp} +1 -1
- package/test/TabGroup/components/TabGroupAccessibility.torp +2 -0
- package/test/TabGroup/components/TabGroupKeyboard.torp +2 -0
- package/test/TabGroup/components/TabGroupList.torp +2 -0
- package/test/TabGroup/components/TabGroupTrigger.torp +2 -0
- package/tsup.config.ts +1 -1
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { areDatesEqual } from "../utils/dateUtils";
|
|
2
2
|
import { type CalendarContext, type CalendarEvent, CalendarContextName } from "./CalendarTypes";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface CalendarDayProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Class name(s) for the root element */
|
|
8
|
+
class?: string,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default function CalendarDay($props: CalendarDayProps) {
|
|
12
|
+
$props ??= $watch({});
|
|
5
13
|
$props.date ??= new Date();
|
|
6
14
|
$props.selectable ??= false;
|
|
7
15
|
$props.muted ??= false;
|
package/dist/Calendar/index.d.ts
CHANGED
|
@@ -1,36 +1,34 @@
|
|
|
1
1
|
import { type SlotRender } from "@torpor/view";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
4
|
+
interface CalendarProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Class name(s) for the root element */
|
|
8
|
+
class?: string,
|
|
9
|
+
}
|
|
10
|
+
|
|
12
11
|
declare function Calendar(
|
|
13
12
|
$parent: ParentNode,
|
|
14
13
|
$anchor: Node | null,
|
|
15
|
-
$props
|
|
14
|
+
$props: CalendarProps,
|
|
16
15
|
$context?: Record<PropertyKey, any>,
|
|
17
16
|
$slots?: Record<string, SlotRender>,
|
|
18
17
|
): void;
|
|
19
18
|
|
|
20
19
|
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
21
|
+
interface CalendarDayProps {
|
|
22
|
+
/** An ID for the root element */
|
|
23
|
+
id?: string;
|
|
24
|
+
/** Class name(s) for the root element */
|
|
25
|
+
class?: string,
|
|
26
|
+
}
|
|
27
|
+
|
|
30
28
|
declare function CalendarDay(
|
|
31
29
|
$parent: ParentNode,
|
|
32
30
|
$anchor: Node | null,
|
|
33
|
-
$props
|
|
31
|
+
$props: CalendarDayProps,
|
|
34
32
|
$context?: Record<PropertyKey, any>,
|
|
35
33
|
$slots?: Record<string, SlotRender>,
|
|
36
34
|
): void;
|
package/dist/Dialog/Dialog.torp
CHANGED
|
@@ -4,6 +4,17 @@ import { trapFocus, type TrapFocusOptions } from "../mount/trapFocus";
|
|
|
4
4
|
import { PopoverContextName, type PopoverContext } from "../Popover/PopoverTypes";
|
|
5
5
|
import { DialogContextName, type DialogContext, type DialogState } from "./DialogTypes";
|
|
6
6
|
|
|
7
|
+
interface DialogProps {
|
|
8
|
+
/** An ID for the root element */
|
|
9
|
+
id?: string;
|
|
10
|
+
/** Class name(s) for the root element */
|
|
11
|
+
class?: string,
|
|
12
|
+
/** An ARIA label for describing the popover to screen readers */
|
|
13
|
+
ariaLabel?: string,
|
|
14
|
+
/** Whether the dialog should alert the user via the screen reader */
|
|
15
|
+
alert?: boolean,
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
/**
|
|
8
19
|
* Content for a window displayed in a Popover.
|
|
9
20
|
*
|
|
@@ -21,10 +32,9 @@ import { DialogContextName, type DialogContext, type DialogState } from "./Dialo
|
|
|
21
32
|
* </Dialog>
|
|
22
33
|
* ```
|
|
23
34
|
*
|
|
24
|
-
* @prop {string | undefined} ariaLabel -- An ARIA label for describing the popover to screen readers
|
|
25
|
-
* @prop {boolean} alert -- Whether the dialog should alert the user via the screen reader
|
|
26
35
|
*/
|
|
27
|
-
export default function Dialog($props:
|
|
36
|
+
export default function Dialog($props: DialogProps) {
|
|
37
|
+
$props ??= $watch({});
|
|
28
38
|
$props.id ??= getId();
|
|
29
39
|
$props.dialog ??= false;
|
|
30
40
|
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import getId from "../utils/getId";
|
|
2
2
|
import { DialogContextName, type DialogContext } from "./DialogTypes";
|
|
3
3
|
|
|
4
|
+
interface DialogBodyProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Class name(s) for the root element */
|
|
8
|
+
class?: string,
|
|
9
|
+
/** Whether the body content will be announced by screen readers when the Dialog is opened */
|
|
10
|
+
ariaAnnounce?: boolean,
|
|
11
|
+
}
|
|
12
|
+
|
|
4
13
|
/**
|
|
5
14
|
* The body information for a Dialog. Content in the body will be announced by
|
|
6
15
|
* screen readers when the Dialog is opened, unless ariaAnnounce is false.
|
|
7
|
-
*
|
|
8
|
-
* @prop {boolean} ariaAnnounce -- Whether the body content will be announced by screen readers when the Dialog is opened
|
|
9
16
|
*/
|
|
10
|
-
export default function DialogBody($props:
|
|
17
|
+
export default function DialogBody($props: DialogBodyProps) {
|
|
18
|
+
$props ??= $watch({});
|
|
11
19
|
$props.id ??= getId();
|
|
12
20
|
$props.ariaAnnounce ??= true;
|
|
13
21
|
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
import { DialogContextName, type DialogContext } from "./DialogTypes";
|
|
2
2
|
|
|
3
|
+
interface DialogButtonProps {
|
|
4
|
+
/** An ID for the root element */
|
|
5
|
+
id?: string;
|
|
6
|
+
/** Class name(s) for the root element */
|
|
7
|
+
class?: string,
|
|
8
|
+
/** The value that should be returned when this button is pressed and the Dialog was invoked by calling showContextual, showPrompt or showPopover */
|
|
9
|
+
value?: any,
|
|
10
|
+
/** "confirm" if the button should respond to the Enter key or "cancel" if the button should respond to the Escape key */
|
|
11
|
+
type?: "confirm" | "cancel",
|
|
12
|
+
/** Whether this button is disabled */
|
|
13
|
+
disabled?: boolean,
|
|
14
|
+
}
|
|
15
|
+
|
|
3
16
|
/**
|
|
4
17
|
* A button that is placed in a DialogFooter and signals a response by a user.
|
|
5
18
|
*
|
|
6
|
-
* @prop {any | undefined} value -- The value that should be returned when this button is pressed and the Dialog was invoked by calling showContextual, showPrompt or showPopover
|
|
7
|
-
* @prop {"confirm" | "cancel" | undefined} type -- "confirm" if the button should respond to the Enter key or "cancel" if the button should respond to the Escape key
|
|
8
|
-
* @prop {boolean} disabled -- Whether this button is disabled
|
|
9
19
|
*/
|
|
10
|
-
export default function DialogButton($props:
|
|
20
|
+
export default function DialogButton($props: DialogButtonProps) {
|
|
21
|
+
$props ??= $watch({});
|
|
22
|
+
|
|
11
23
|
let button: HTMLButtonElement;
|
|
12
24
|
|
|
13
25
|
// Get stuff out of the DialogContext
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
interface DialogFooterProps {
|
|
3
|
+
/** An ID for the root element */
|
|
4
|
+
id?: string;
|
|
5
|
+
/** Class name(s) for the root element */
|
|
6
|
+
class?: string,
|
|
7
|
+
}
|
|
8
|
+
|
|
1
9
|
/**
|
|
2
10
|
* The footer for a Dialog, which may contain one or more DialogButtons.
|
|
3
11
|
*/
|
|
4
|
-
export default function DialogFooter($props:
|
|
12
|
+
export default function DialogFooter($props: DialogFooterProps) {
|
|
13
|
+
$props ??= $watch({});
|
|
14
|
+
|
|
5
15
|
@render {
|
|
6
16
|
<div
|
|
7
17
|
{$props.id}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import getId from "../utils/getId";
|
|
2
2
|
import { DialogContextName, type DialogContext } from "./DialogTypes";
|
|
3
3
|
|
|
4
|
+
interface DialogHeaderProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Class name(s) for the root element */
|
|
8
|
+
class?: string,
|
|
9
|
+
/** Whether the header will be announced by screen readers when the Dialog is opened */
|
|
10
|
+
ariaAnnounce?: boolean,
|
|
11
|
+
}
|
|
12
|
+
|
|
4
13
|
/**
|
|
5
14
|
* The header for a Dialog. Content in the header will be announced by screen
|
|
6
15
|
* readers when the Dialog is opened, unless ariaAnnounce is false.
|
|
7
16
|
*
|
|
8
|
-
* @prop {boolean} ariaAnnounce -- Whether the header will be announced by screen readers when the Dialog is opened
|
|
9
17
|
*/
|
|
10
|
-
export default function DialogHeader($props:
|
|
18
|
+
export default function DialogHeader($props: DialogHeaderProps) {
|
|
19
|
+
$props ??= $watch({});
|
|
11
20
|
$props.id ??= getId();
|
|
12
21
|
$props.ariaAnnounce ??= true;
|
|
13
22
|
|
package/dist/Dialog/index.d.ts
CHANGED
|
@@ -1,90 +1,133 @@
|
|
|
1
1
|
import { type SlotRender } from "@torpor/view";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
interface DialogProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Class name(s) for the root element */
|
|
8
|
+
class?: string,
|
|
9
|
+
/** An ARIA label for describing the popover to screen readers */
|
|
10
|
+
ariaLabel?: string,
|
|
11
|
+
/** Whether the dialog should alert the user via the screen reader */
|
|
12
|
+
alert?: boolean,
|
|
13
|
+
}
|
|
14
|
+
|
|
4
15
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
16
|
+
* Content for a window displayed in a Popover.
|
|
17
|
+
*
|
|
18
|
+
* See [the WAI ARIA guidelines for Dialogs](https://www.w3.org/WAI/ARIA/apg/patterns/dialogmodal/).
|
|
19
|
+
*
|
|
20
|
+
* The structure of a Dialog is:
|
|
21
|
+
*
|
|
22
|
+
* ```
|
|
23
|
+
* <Dialog>
|
|
24
|
+
* <DialogHeader /> (optional)
|
|
25
|
+
* <DialogBody /> (optional)
|
|
26
|
+
* <DialogFooter> (optional)
|
|
27
|
+
* <DialogButton /> (optional)
|
|
28
|
+
* </DialogFooter>
|
|
29
|
+
* </Dialog>
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
11
32
|
*/
|
|
12
33
|
declare function Dialog(
|
|
13
34
|
$parent: ParentNode,
|
|
14
35
|
$anchor: Node | null,
|
|
15
|
-
$props:
|
|
36
|
+
$props: DialogProps,
|
|
16
37
|
$context?: Record<PropertyKey, any>,
|
|
17
38
|
$slots?: Record<string, SlotRender>,
|
|
18
39
|
): void;
|
|
19
40
|
|
|
20
41
|
|
|
21
42
|
|
|
43
|
+
interface DialogBodyProps {
|
|
44
|
+
/** An ID for the root element */
|
|
45
|
+
id?: string;
|
|
46
|
+
/** Class name(s) for the root element */
|
|
47
|
+
class?: string,
|
|
48
|
+
/** Whether the body content will be announced by screen readers when the Dialog is opened */
|
|
49
|
+
ariaAnnounce?: boolean,
|
|
50
|
+
}
|
|
51
|
+
|
|
22
52
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @param $anchor -- The node to mount the component before.
|
|
26
|
-
* @param $props -- The values that have been passed into the component as properties.
|
|
27
|
-
* @param $context -- Values that have been passed into the component from its ancestors.
|
|
28
|
-
* @param $slots -- Functions for rendering children into slot nodes within the component.
|
|
53
|
+
* The body information for a Dialog. Content in the body will be announced by
|
|
54
|
+
* screen readers when the Dialog is opened, unless ariaAnnounce is false.
|
|
29
55
|
*/
|
|
30
56
|
declare function DialogBody(
|
|
31
57
|
$parent: ParentNode,
|
|
32
58
|
$anchor: Node | null,
|
|
33
|
-
$props:
|
|
59
|
+
$props: DialogBodyProps,
|
|
34
60
|
$context?: Record<PropertyKey, any>,
|
|
35
61
|
$slots?: Record<string, SlotRender>,
|
|
36
62
|
): void;
|
|
37
63
|
|
|
38
64
|
|
|
39
65
|
|
|
66
|
+
interface DialogButtonProps {
|
|
67
|
+
/** An ID for the root element */
|
|
68
|
+
id?: string;
|
|
69
|
+
/** Class name(s) for the root element */
|
|
70
|
+
class?: string,
|
|
71
|
+
/** The value that should be returned when this button is pressed and the Dialog was invoked by calling showContextual, showPrompt or showPopover */
|
|
72
|
+
value?: any,
|
|
73
|
+
/** "confirm" if the button should respond to the Enter key or "cancel" if the button should respond to the Escape key */
|
|
74
|
+
type?: "confirm" | "cancel",
|
|
75
|
+
/** Whether this button is disabled */
|
|
76
|
+
disabled?: boolean,
|
|
77
|
+
}
|
|
78
|
+
|
|
40
79
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* @param $anchor -- The node to mount the component before.
|
|
44
|
-
* @param $props -- The values that have been passed into the component as properties.
|
|
45
|
-
* @param $context -- Values that have been passed into the component from its ancestors.
|
|
46
|
-
* @param $slots -- Functions for rendering children into slot nodes within the component.
|
|
80
|
+
* A button that is placed in a DialogFooter and signals a response by a user.
|
|
81
|
+
*
|
|
47
82
|
*/
|
|
48
83
|
declare function DialogButton(
|
|
49
84
|
$parent: ParentNode,
|
|
50
85
|
$anchor: Node | null,
|
|
51
|
-
$props:
|
|
86
|
+
$props: DialogButtonProps,
|
|
52
87
|
$context?: Record<PropertyKey, any>,
|
|
53
88
|
$slots?: Record<string, SlotRender>,
|
|
54
89
|
): void;
|
|
55
90
|
|
|
56
91
|
|
|
57
92
|
|
|
93
|
+
interface DialogFooterProps {
|
|
94
|
+
/** An ID for the root element */
|
|
95
|
+
id?: string;
|
|
96
|
+
/** Class name(s) for the root element */
|
|
97
|
+
class?: string,
|
|
98
|
+
}
|
|
99
|
+
|
|
58
100
|
/**
|
|
59
|
-
*
|
|
60
|
-
* @param $parent -- The parent node.
|
|
61
|
-
* @param $anchor -- The node to mount the component before.
|
|
62
|
-
* @param $props -- The values that have been passed into the component as properties.
|
|
63
|
-
* @param $context -- Values that have been passed into the component from its ancestors.
|
|
64
|
-
* @param $slots -- Functions for rendering children into slot nodes within the component.
|
|
101
|
+
* The footer for a Dialog, which may contain one or more DialogButtons.
|
|
65
102
|
*/
|
|
66
103
|
declare function DialogFooter(
|
|
67
104
|
$parent: ParentNode,
|
|
68
105
|
$anchor: Node | null,
|
|
69
|
-
$props:
|
|
106
|
+
$props: DialogFooterProps,
|
|
70
107
|
$context?: Record<PropertyKey, any>,
|
|
71
108
|
$slots?: Record<string, SlotRender>,
|
|
72
109
|
): void;
|
|
73
110
|
|
|
74
111
|
|
|
75
112
|
|
|
113
|
+
interface DialogHeaderProps {
|
|
114
|
+
/** An ID for the root element */
|
|
115
|
+
id?: string;
|
|
116
|
+
/** Class name(s) for the root element */
|
|
117
|
+
class?: string,
|
|
118
|
+
/** Whether the header will be announced by screen readers when the Dialog is opened */
|
|
119
|
+
ariaAnnounce?: boolean,
|
|
120
|
+
}
|
|
121
|
+
|
|
76
122
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* @param $props -- The values that have been passed into the component as properties.
|
|
81
|
-
* @param $context -- Values that have been passed into the component from its ancestors.
|
|
82
|
-
* @param $slots -- Functions for rendering children into slot nodes within the component.
|
|
123
|
+
* The header for a Dialog. Content in the header will be announced by screen
|
|
124
|
+
* readers when the Dialog is opened, unless ariaAnnounce is false.
|
|
125
|
+
*
|
|
83
126
|
*/
|
|
84
127
|
declare function DialogHeader(
|
|
85
128
|
$parent: ParentNode,
|
|
86
129
|
$anchor: Node | null,
|
|
87
|
-
$props:
|
|
130
|
+
$props: DialogHeaderProps,
|
|
88
131
|
$context?: Record<PropertyKey, any>,
|
|
89
132
|
$slots?: Record<string, SlotRender>,
|
|
90
133
|
): void;
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
import { DisclosureContextName, type DisclosureContext } from "./DisclosureTypes";
|
|
1
|
+
import { DisclosureContextName, type DisclosureContext, type DisclosureState } from "./DisclosureTypes";
|
|
2
|
+
|
|
3
|
+
interface DisclosureProps {
|
|
4
|
+
/** An ID for the root element */
|
|
5
|
+
id?: string;
|
|
6
|
+
/** Class name(s) for the root element */
|
|
7
|
+
class?: string,
|
|
8
|
+
/** Whether the Disclosure is expanded and its content visible */
|
|
9
|
+
expanded?: boolean,
|
|
10
|
+
/** If set to true, the user cannot interact with this Disclosure */
|
|
11
|
+
disabled?: boolean,
|
|
12
|
+
/** Raised when this item is opened or closed */
|
|
13
|
+
ontoggle?: (open: boolean) => void,
|
|
14
|
+
}
|
|
2
15
|
|
|
3
16
|
/**
|
|
4
17
|
* An interactive header that enables users to reveal or hide an associated section of content.
|
|
@@ -15,12 +28,9 @@ import { DisclosureContextName, type DisclosureContext } from "./DisclosureTypes
|
|
|
15
28
|
* <DisclosureContent />
|
|
16
29
|
* </Disclosure>
|
|
17
30
|
* ```
|
|
18
|
-
*
|
|
19
|
-
* @prop {boolean} [expanded] -- Whether the Disclosure is expanded and its content visible
|
|
20
|
-
* @prop {boolean} [disabled] -- If set to true, the user cannot interact with this Disclosure
|
|
21
|
-
* @prop {(boolean) => void} [ontoggle] -- Raised when this item is opened or closed
|
|
22
31
|
*/
|
|
23
|
-
export default function Disclosure($props:
|
|
32
|
+
export default function Disclosure($props: DisclosureProps) {
|
|
33
|
+
$props ??= $watch({});
|
|
24
34
|
$props.expanded ??= false;
|
|
25
35
|
$props.disabled ??= false;
|
|
26
36
|
|
|
@@ -61,7 +71,7 @@ export default function Disclosure($props: any) {
|
|
|
61
71
|
{$props.id}
|
|
62
72
|
class={`torp-disclosure-item ${$props.class ?? ""}`.trim()}
|
|
63
73
|
data-state={$state.dataState}
|
|
64
|
-
data-disabled={$state.
|
|
74
|
+
data-disabled={$state.disabled ? "true" : undefined}
|
|
65
75
|
>
|
|
66
76
|
<slot />
|
|
67
77
|
</div>
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import getId from "../utils/getId";
|
|
2
2
|
import { DisclosureContextName, type DisclosureContext } from "./DisclosureTypes";
|
|
3
3
|
|
|
4
|
+
interface DisclosureContentProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Class name(s) for the root element */
|
|
8
|
+
class?: string,
|
|
9
|
+
/** Whether this content should act as a region. Set this when the content contains heading elements or a nested Disclosure */
|
|
10
|
+
ariaRegion?: boolean,
|
|
11
|
+
}
|
|
12
|
+
|
|
4
13
|
/**
|
|
5
14
|
* Content for a Disclosure, which can be revealed or hidden by an associated DisclosureTrigger.
|
|
6
|
-
*
|
|
7
|
-
* @prop {string} [id] -- An ID for the DisclosureContent's div container
|
|
8
|
-
* @prop {boolean} [ariaRegion] -- Whether this content should act as a region. Set this when the content contains heading elements or a nested Disclosure
|
|
9
15
|
*/
|
|
10
|
-
export default function DisclosureContent($props:
|
|
16
|
+
export default function DisclosureContent($props: DisclosureContentProps) {
|
|
17
|
+
$props ??= $watch({});
|
|
11
18
|
$props.id ||= getId();
|
|
12
19
|
|
|
13
20
|
const context = $context[DisclosureContextName] as DisclosureContext;
|
|
14
21
|
if (!context) {
|
|
15
22
|
throw new Error("DisclosureContent must be contained within a Disclosure");
|
|
16
23
|
}
|
|
17
|
-
let $state =
|
|
24
|
+
let $state = context.state
|
|
18
25
|
|
|
19
26
|
// Set the content ID so that it can be used with aria-controls in DisclosureTrigger
|
|
20
27
|
$state.contentId = $props.id;
|
|
@@ -26,7 +33,7 @@ export default function DisclosureContent($props: any) {
|
|
|
26
33
|
role={$props.ariaRegion ? "region" : undefined}
|
|
27
34
|
aria-labelledby={$state.headerId}
|
|
28
35
|
data-state={$state.dataState}
|
|
29
|
-
data-disabled={$state.
|
|
36
|
+
data-disabled={$state.disabled ? "true" : undefined}
|
|
30
37
|
>
|
|
31
38
|
@if ($state.expanded) {
|
|
32
39
|
<slot />
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { DisclosureContextName, type DisclosureContext } from "./DisclosureTypes";
|
|
2
2
|
|
|
3
|
+
interface DisclosureHeaderProps {
|
|
4
|
+
/** An ID for the root element */
|
|
5
|
+
id?: string;
|
|
6
|
+
/** Class name(s) for the root element */
|
|
7
|
+
class?: string,
|
|
8
|
+
/** The type of HTML header to use */
|
|
9
|
+
as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6",
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
/**
|
|
4
13
|
* The header for a Disclosure, which contains the DisclosureTrigger.
|
|
5
14
|
*
|
|
@@ -10,15 +19,15 @@ import { DisclosureContextName, type DisclosureContext } from "./DisclosureTypes
|
|
|
10
19
|
* <DisclosureTrigger />
|
|
11
20
|
* </DisclosureHeader>
|
|
12
21
|
* ```
|
|
13
|
-
*
|
|
14
|
-
* @prop {"h1" | "h2" | "h3" | "h4" | "h5" | "h6"} as -- The type of HTML header to use
|
|
15
22
|
*/
|
|
16
|
-
export default function DisclosureHeader($props:
|
|
23
|
+
export default function DisclosureHeader($props: DisclosureHeaderProps) {
|
|
24
|
+
$props ??= $watch({});
|
|
25
|
+
|
|
17
26
|
const context = $context[DisclosureContextName] as DisclosureContext;
|
|
18
27
|
if (!context) {
|
|
19
28
|
throw new Error("DisclosureHeader must be contained within a Disclosure");
|
|
20
29
|
}
|
|
21
|
-
let $state =
|
|
30
|
+
let $state = context.state
|
|
22
31
|
|
|
23
32
|
@render {
|
|
24
33
|
@// TODO: $props.as
|
|
@@ -26,7 +35,7 @@ export default function DisclosureHeader($props: any) {
|
|
|
26
35
|
{$props.id}
|
|
27
36
|
class={`torp-disclosure-header ${$props.class ?? ""}`.trim()}
|
|
28
37
|
data-state={$state.dataState}
|
|
29
|
-
data-disabled={$state.
|
|
38
|
+
data-disabled={$state.disabled ? "true" : undefined}
|
|
30
39
|
>
|
|
31
40
|
<slot />
|
|
32
41
|
</h4>
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import getId from "../utils/getId";
|
|
2
2
|
import { DisclosureContextName, type DisclosureContext } from "./DisclosureTypes";
|
|
3
3
|
|
|
4
|
+
interface DisclosureTriggerProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Class name(s) for the root element */
|
|
8
|
+
class?: string,
|
|
9
|
+
}
|
|
10
|
+
|
|
4
11
|
/**
|
|
5
12
|
* A header button for a Disclosure, which can be used to reveal or hide an associated DisclosureContent.
|
|
6
13
|
*/
|
|
7
|
-
export default function DisclosureTrigger() {
|
|
14
|
+
export default function DisclosureTrigger($props: DisclosureTriggerProps) {
|
|
15
|
+
$props ??= $watch({});
|
|
8
16
|
$props.id ||= getId();
|
|
9
17
|
|
|
10
18
|
// Get stuff out of the DisclosureContext
|
|
@@ -12,7 +20,7 @@ export default function DisclosureTrigger() {
|
|
|
12
20
|
if (!context) {
|
|
13
21
|
throw new Error("DisclosureTrigger must be contained within a Disclosure");
|
|
14
22
|
}
|
|
15
|
-
let $state =
|
|
23
|
+
let $state = context.state;
|
|
16
24
|
|
|
17
25
|
// Set the header ID so that it can be used with aria-labelledby in DisclosureContent
|
|
18
26
|
$state.headerId = $props.id;
|
|
@@ -1,72 +1,111 @@
|
|
|
1
1
|
import { type SlotRender } from "@torpor/view";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
interface DisclosureProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Class name(s) for the root element */
|
|
8
|
+
class?: string,
|
|
9
|
+
/** Whether the Disclosure is expanded and its content visible */
|
|
10
|
+
expanded?: boolean,
|
|
11
|
+
/** If set to true, the user cannot interact with this Disclosure */
|
|
12
|
+
disabled?: boolean,
|
|
13
|
+
/** Raised when this item is opened or closed */
|
|
14
|
+
ontoggle?: (open: boolean) => void,
|
|
15
|
+
}
|
|
16
|
+
|
|
4
17
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
18
|
+
* An interactive header that enables users to reveal or hide an associated section of content.
|
|
19
|
+
*
|
|
20
|
+
* See [the WAI ARIA guidelines for Disclosures](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/).
|
|
21
|
+
*
|
|
22
|
+
* The structure of a Disclosure is:
|
|
23
|
+
*
|
|
24
|
+
* ```
|
|
25
|
+
* <Disclosure>
|
|
26
|
+
* <DisclosureHeader>
|
|
27
|
+
* <DisclosureTrigger />
|
|
28
|
+
* </DisclosureHeader>
|
|
29
|
+
* <DisclosureContent />
|
|
30
|
+
* </Disclosure>
|
|
31
|
+
* ```
|
|
11
32
|
*/
|
|
12
33
|
declare function Disclosure(
|
|
13
34
|
$parent: ParentNode,
|
|
14
35
|
$anchor: Node | null,
|
|
15
|
-
$props:
|
|
36
|
+
$props: DisclosureProps,
|
|
16
37
|
$context?: Record<PropertyKey, any>,
|
|
17
38
|
$slots?: Record<string, SlotRender>,
|
|
18
39
|
): void;
|
|
19
40
|
|
|
20
41
|
|
|
21
42
|
|
|
43
|
+
interface DisclosureContentProps {
|
|
44
|
+
/** An ID for the root element */
|
|
45
|
+
id?: string;
|
|
46
|
+
/** Class name(s) for the root element */
|
|
47
|
+
class?: string,
|
|
48
|
+
/** Whether this content should act as a region. Set this when the content contains heading elements or a nested Disclosure */
|
|
49
|
+
ariaRegion?: boolean,
|
|
50
|
+
}
|
|
51
|
+
|
|
22
52
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @param $parent -- The parent node.
|
|
25
|
-
* @param $anchor -- The node to mount the component before.
|
|
26
|
-
* @param $props -- The values that have been passed into the component as properties.
|
|
27
|
-
* @param $context -- Values that have been passed into the component from its ancestors.
|
|
28
|
-
* @param $slots -- Functions for rendering children into slot nodes within the component.
|
|
53
|
+
* Content for a Disclosure, which can be revealed or hidden by an associated DisclosureTrigger.
|
|
29
54
|
*/
|
|
30
55
|
declare function DisclosureContent(
|
|
31
56
|
$parent: ParentNode,
|
|
32
57
|
$anchor: Node | null,
|
|
33
|
-
$props:
|
|
58
|
+
$props: DisclosureContentProps,
|
|
34
59
|
$context?: Record<PropertyKey, any>,
|
|
35
60
|
$slots?: Record<string, SlotRender>,
|
|
36
61
|
): void;
|
|
37
62
|
|
|
38
63
|
|
|
39
64
|
|
|
65
|
+
interface DisclosureHeaderProps {
|
|
66
|
+
/** An ID for the root element */
|
|
67
|
+
id?: string;
|
|
68
|
+
/** Class name(s) for the root element */
|
|
69
|
+
class?: string,
|
|
70
|
+
/** The type of HTML header to use */
|
|
71
|
+
as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6",
|
|
72
|
+
}
|
|
73
|
+
|
|
40
74
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
75
|
+
* The header for a Disclosure, which contains the DisclosureTrigger.
|
|
76
|
+
*
|
|
77
|
+
* The structure of a DisclosureHeader is:
|
|
78
|
+
*
|
|
79
|
+
* ```
|
|
80
|
+
* <DisclosureHeader>
|
|
81
|
+
* <DisclosureTrigger />
|
|
82
|
+
* </DisclosureHeader>
|
|
83
|
+
* ```
|
|
47
84
|
*/
|
|
48
85
|
declare function DisclosureHeader(
|
|
49
86
|
$parent: ParentNode,
|
|
50
87
|
$anchor: Node | null,
|
|
51
|
-
$props:
|
|
88
|
+
$props: DisclosureHeaderProps,
|
|
52
89
|
$context?: Record<PropertyKey, any>,
|
|
53
90
|
$slots?: Record<string, SlotRender>,
|
|
54
91
|
): void;
|
|
55
92
|
|
|
56
93
|
|
|
57
94
|
|
|
95
|
+
interface DisclosureTriggerProps {
|
|
96
|
+
/** An ID for the root element */
|
|
97
|
+
id?: string;
|
|
98
|
+
/** Class name(s) for the root element */
|
|
99
|
+
class?: string,
|
|
100
|
+
}
|
|
101
|
+
|
|
58
102
|
/**
|
|
59
|
-
*
|
|
60
|
-
* @param $parent -- The parent node.
|
|
61
|
-
* @param $anchor -- The node to mount the component before.
|
|
62
|
-
* @param $props -- The values that have been passed into the component as properties.
|
|
63
|
-
* @param $context -- Values that have been passed into the component from its ancestors.
|
|
64
|
-
* @param $slots -- Functions for rendering children into slot nodes within the component.
|
|
103
|
+
* A header button for a Disclosure, which can be used to reveal or hide an associated DisclosureContent.
|
|
65
104
|
*/
|
|
66
105
|
declare function DisclosureTrigger(
|
|
67
106
|
$parent: ParentNode,
|
|
68
107
|
$anchor: Node | null,
|
|
69
|
-
$props
|
|
108
|
+
$props: DisclosureTriggerProps,
|
|
70
109
|
$context?: Record<PropertyKey, any>,
|
|
71
110
|
$slots?: Record<string, SlotRender>,
|
|
72
111
|
): void;
|