@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,5 +1,16 @@
|
|
|
1
1
|
import { MenuBarContextName, type MenuBarContext, type ItemState } from "./MenuBarTypes";
|
|
2
2
|
|
|
3
|
+
interface MenuBarProps {
|
|
4
|
+
/** An ID for the root element */
|
|
5
|
+
id?: string;
|
|
6
|
+
/** Class name(s) for the root element */
|
|
7
|
+
class?: string,
|
|
8
|
+
/** An ARIA label for describing the menu to screen readers */
|
|
9
|
+
ariaLabel?: string,
|
|
10
|
+
/** The orientation of the menu, which affects keyboard navigation */
|
|
11
|
+
orientation?: "horizontal" | "vertical",
|
|
12
|
+
}
|
|
13
|
+
|
|
3
14
|
/**
|
|
4
15
|
* A menu bar, similar to that shown at the top of Windows applications or at the top of the screen on Macs.
|
|
5
16
|
*
|
|
@@ -17,11 +28,9 @@ import { MenuBarContextName, type MenuBarContext, type ItemState } from "./MenuB
|
|
|
17
28
|
* </MenuBarItem>
|
|
18
29
|
* </MenuBar>
|
|
19
30
|
* ```
|
|
20
|
-
*
|
|
21
|
-
* @prop {string} ariaLabel -- An ARIA label for describing the menu to screen readers
|
|
22
|
-
* @prop {"horizontal" | "vertical"} orientation -- The orientation of the menu, which affects keyboard navigation
|
|
23
31
|
*/
|
|
24
|
-
export default function MenuBar() {
|
|
32
|
+
export default function MenuBar($props: MenuBarProps) {
|
|
33
|
+
$props ??= $watch({});
|
|
25
34
|
$props.orientation ??= "horizontal";
|
|
26
35
|
|
|
27
36
|
let $state = $watch({
|
|
@@ -6,6 +6,21 @@ import {
|
|
|
6
6
|
} from "./MenuBarTypes";
|
|
7
7
|
import { PopoverContextName, type PopoverContext } from "../Popover/PopoverTypes";
|
|
8
8
|
|
|
9
|
+
interface MenuBarItemProps {
|
|
10
|
+
/** An ID for the root element */
|
|
11
|
+
id?: string;
|
|
12
|
+
/** Class name(s) for the root element */
|
|
13
|
+
class?: string,
|
|
14
|
+
/** Whether the item is visible */
|
|
15
|
+
visible?: boolean,
|
|
16
|
+
/** Called when the item is opened or closed */
|
|
17
|
+
ontoggle?: (visible: boolean) => void,
|
|
18
|
+
/** Called when the item has opened */
|
|
19
|
+
onopen?: () => void,
|
|
20
|
+
/** Called when the item has closed */
|
|
21
|
+
onclose?: () => void,
|
|
22
|
+
}
|
|
23
|
+
|
|
9
24
|
/**
|
|
10
25
|
* A popout that is attached to a menubar button and can be used to show a submenu.
|
|
11
26
|
*
|
|
@@ -17,13 +32,9 @@ import { PopoverContextName, type PopoverContext } from "../Popover/PopoverTypes
|
|
|
17
32
|
* <MenuBarItemContent />
|
|
18
33
|
* </MenuBarItem>
|
|
19
34
|
* ```
|
|
20
|
-
*
|
|
21
|
-
* @prop {boolean} visible -- Whether the item is visible
|
|
22
|
-
* @prop {(boolean) => void} ontoggle -- Called when the item is opened or closed
|
|
23
|
-
* @prop {() => void} onopen -- Called when the item has opened
|
|
24
|
-
* @prop {() => void} onclose -- Called when the item has closed
|
|
25
35
|
*/
|
|
26
|
-
export default function MenuBarItem() {
|
|
36
|
+
export default function MenuBarItem($props: MenuBarItemProps) {
|
|
37
|
+
$props ??= $watch({});
|
|
27
38
|
$props.visible ??= false;
|
|
28
39
|
|
|
29
40
|
let $state = $watch({
|
|
@@ -7,13 +7,22 @@ import {
|
|
|
7
7
|
type MenuBarItemContext
|
|
8
8
|
} from "./MenuBarTypes";
|
|
9
9
|
|
|
10
|
+
interface MenuBarItemContentProps {
|
|
11
|
+
/** An ID for the root element */
|
|
12
|
+
id?: string;
|
|
13
|
+
/** Class name(s) for the root element */
|
|
14
|
+
class?: string,
|
|
15
|
+
/** Where the popout will be shown, relative to the popout button */
|
|
16
|
+
side?: "top" | "right" | "bottom" | "left",
|
|
17
|
+
/** How the popout will be aligned, relative to the popout button */
|
|
18
|
+
alignment?: "start" | "center" | "end",
|
|
19
|
+
}
|
|
20
|
+
|
|
10
21
|
/**
|
|
11
22
|
* The content that is displayed for a MenuBarItem when it is open.
|
|
12
|
-
*
|
|
13
|
-
* @prop {"top" | "right" | "bottom" | "left"} side -- Where the popout will be shown, relative to the popout button
|
|
14
|
-
* @prop {"start" | "center" | "end"} alignment -- How the popout will be aligned, relative to the popout button
|
|
15
23
|
*/
|
|
16
|
-
export default function MenuBarItemContent() {
|
|
24
|
+
export default function MenuBarItemContent($props: MenuBarItemContentProps) {
|
|
25
|
+
$props ??= $watch({});
|
|
17
26
|
$props.side ??= "bottom";
|
|
18
27
|
$props.alignment ??= "start";
|
|
19
28
|
|
|
@@ -5,12 +5,21 @@ import {
|
|
|
5
5
|
type MenuBarItemContext
|
|
6
6
|
} from "./MenuBarTypes";
|
|
7
7
|
|
|
8
|
+
interface MenuBarItemTriggerProps {
|
|
9
|
+
/** An ID for the root element */
|
|
10
|
+
id?: string;
|
|
11
|
+
/** Class name(s) for the root element */
|
|
12
|
+
class?: string,
|
|
13
|
+
/** Whether this button is disabled */
|
|
14
|
+
disabled?: boolean,
|
|
15
|
+
}
|
|
16
|
+
|
|
8
17
|
/**
|
|
9
18
|
* A button that is placed in a MenuBar and opens a submenu.
|
|
10
19
|
*
|
|
11
|
-
* @prop {boolean} disabled -- Whether this button is disabled
|
|
12
20
|
*/
|
|
13
|
-
export default function MenuBarItemTrigger() {
|
|
21
|
+
export default function MenuBarItemTrigger($props: MenuBarItemTriggerProps) {
|
|
22
|
+
$props ??= $watch({});
|
|
14
23
|
$props.disabled ??= false;
|
|
15
24
|
|
|
16
25
|
let button: HTMLButtonElement;
|
package/dist/MenuBar/index.d.ts
CHANGED
|
@@ -1,72 +1,123 @@
|
|
|
1
1
|
import { type SlotRender } from "@torpor/view";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
interface MenuBarProps {
|
|
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 menu to screen readers */
|
|
10
|
+
ariaLabel?: string,
|
|
11
|
+
/** The orientation of the menu, which affects keyboard navigation */
|
|
12
|
+
orientation?: "horizontal" | "vertical",
|
|
13
|
+
}
|
|
14
|
+
|
|
4
15
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
16
|
+
* A menu bar, similar to that shown at the top of Windows applications or at the top of the screen on Macs.
|
|
17
|
+
*
|
|
18
|
+
* See [the WAI ARIA guidelines for Menus](https://www.w3.org/WAI/ARIA/apg/patterns/menu/).
|
|
19
|
+
*
|
|
20
|
+
* The structure of a MenuBar is:
|
|
21
|
+
*
|
|
22
|
+
* ```
|
|
23
|
+
* <MenuBar>
|
|
24
|
+
* <MenuBarItem>
|
|
25
|
+
* <MenuBarItemTrigger />
|
|
26
|
+
* <MenuBarItemContent>
|
|
27
|
+
* <Menu />
|
|
28
|
+
* </MenuBarItemContent>
|
|
29
|
+
* </MenuBarItem>
|
|
30
|
+
* </MenuBar>
|
|
31
|
+
* ```
|
|
11
32
|
*/
|
|
12
33
|
declare function MenuBar(
|
|
13
34
|
$parent: ParentNode,
|
|
14
35
|
$anchor: Node | null,
|
|
15
|
-
$props
|
|
36
|
+
$props: MenuBarProps,
|
|
16
37
|
$context?: Record<PropertyKey, any>,
|
|
17
38
|
$slots?: Record<string, SlotRender>,
|
|
18
39
|
): void;
|
|
19
40
|
|
|
20
41
|
|
|
21
42
|
|
|
43
|
+
interface MenuBarItemProps {
|
|
44
|
+
/** An ID for the root element */
|
|
45
|
+
id?: string;
|
|
46
|
+
/** Class name(s) for the root element */
|
|
47
|
+
class?: string,
|
|
48
|
+
/** Whether the item is visible */
|
|
49
|
+
visible?: boolean,
|
|
50
|
+
/** Called when the item is opened or closed */
|
|
51
|
+
ontoggle?: (visible: boolean) => void,
|
|
52
|
+
/** Called when the item has opened */
|
|
53
|
+
onopen?: () => void,
|
|
54
|
+
/** Called when the item has closed */
|
|
55
|
+
onclose?: () => void,
|
|
56
|
+
}
|
|
57
|
+
|
|
22
58
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
59
|
+
* A popout that is attached to a menubar button and can be used to show a submenu.
|
|
60
|
+
*
|
|
61
|
+
* The structure of a MenuBarItem is:
|
|
62
|
+
*
|
|
63
|
+
* ```
|
|
64
|
+
* <MenuBarItem>
|
|
65
|
+
* <MenuBarItemTrigger /> (optional)
|
|
66
|
+
* <MenuBarItemContent />
|
|
67
|
+
* </MenuBarItem>
|
|
68
|
+
* ```
|
|
29
69
|
*/
|
|
30
70
|
declare function MenuBarItem(
|
|
31
71
|
$parent: ParentNode,
|
|
32
72
|
$anchor: Node | null,
|
|
33
|
-
$props
|
|
73
|
+
$props: MenuBarItemProps,
|
|
34
74
|
$context?: Record<PropertyKey, any>,
|
|
35
75
|
$slots?: Record<string, SlotRender>,
|
|
36
76
|
): void;
|
|
37
77
|
|
|
38
78
|
|
|
39
79
|
|
|
80
|
+
interface MenuBarItemContentProps {
|
|
81
|
+
/** An ID for the root element */
|
|
82
|
+
id?: string;
|
|
83
|
+
/** Class name(s) for the root element */
|
|
84
|
+
class?: string,
|
|
85
|
+
/** Where the popout will be shown, relative to the popout button */
|
|
86
|
+
side?: "top" | "right" | "bottom" | "left",
|
|
87
|
+
/** How the popout will be aligned, relative to the popout button */
|
|
88
|
+
alignment?: "start" | "center" | "end",
|
|
89
|
+
}
|
|
90
|
+
|
|
40
91
|
/**
|
|
41
|
-
*
|
|
42
|
-
* @param $parent -- The parent node.
|
|
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.
|
|
92
|
+
* The content that is displayed for a MenuBarItem when it is open.
|
|
47
93
|
*/
|
|
48
94
|
declare function MenuBarItemContent(
|
|
49
95
|
$parent: ParentNode,
|
|
50
96
|
$anchor: Node | null,
|
|
51
|
-
$props
|
|
97
|
+
$props: MenuBarItemContentProps,
|
|
52
98
|
$context?: Record<PropertyKey, any>,
|
|
53
99
|
$slots?: Record<string, SlotRender>,
|
|
54
100
|
): void;
|
|
55
101
|
|
|
56
102
|
|
|
57
103
|
|
|
104
|
+
interface MenuBarItemTriggerProps {
|
|
105
|
+
/** An ID for the root element */
|
|
106
|
+
id?: string;
|
|
107
|
+
/** Class name(s) for the root element */
|
|
108
|
+
class?: string,
|
|
109
|
+
/** Whether this button is disabled */
|
|
110
|
+
disabled?: boolean,
|
|
111
|
+
}
|
|
112
|
+
|
|
58
113
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
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.
|
|
114
|
+
* A button that is placed in a MenuBar and opens a submenu.
|
|
115
|
+
*
|
|
65
116
|
*/
|
|
66
117
|
declare function MenuBarItemTrigger(
|
|
67
118
|
$parent: ParentNode,
|
|
68
119
|
$anchor: Node | null,
|
|
69
|
-
$props
|
|
120
|
+
$props: MenuBarItemTriggerProps,
|
|
70
121
|
$context?: Record<PropertyKey, any>,
|
|
71
122
|
$slots?: Record<string, SlotRender>,
|
|
72
123
|
): void;
|
|
@@ -6,6 +6,17 @@ import {
|
|
|
6
6
|
type NavMenuPopoutContext
|
|
7
7
|
} from "./NavMenuTypes";
|
|
8
8
|
|
|
9
|
+
interface NavMenuProps {
|
|
10
|
+
/** An ID for the root element */
|
|
11
|
+
id?: string;
|
|
12
|
+
/** Class name(s) for the root element */
|
|
13
|
+
class?: string,
|
|
14
|
+
/** An ARIA label for describing the menu to screen readers */
|
|
15
|
+
ariaLabel?: string | undefined,
|
|
16
|
+
/** The orientation of the menu, which affects keyboard navigation */
|
|
17
|
+
orientation?: "horizontal" | "vertical",
|
|
18
|
+
}
|
|
19
|
+
|
|
9
20
|
/**
|
|
10
21
|
* A list of links for navigating a website.
|
|
11
22
|
*
|
|
@@ -21,11 +32,9 @@ import {
|
|
|
21
32
|
* ...
|
|
22
33
|
* </NavMenu>
|
|
23
34
|
* ```
|
|
24
|
-
*
|
|
25
|
-
* @prop {string | undefined} ariaLabel -- An ARIA label for describing the menu to screen readers
|
|
26
|
-
* @prop {"horizontal" | "vertical"} orientation -- The orientation of the menu, which affects keyboard navigation
|
|
27
35
|
*/
|
|
28
|
-
export default function NavMenu($props:
|
|
36
|
+
export default function NavMenu($props: NavMenuProps) {
|
|
37
|
+
$props ??= $watch({});
|
|
29
38
|
$props.orientation ||= "horizontal";
|
|
30
39
|
|
|
31
40
|
// A collection containing the state and some functions for each item
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { NavMenuContextName, type NavMenuContext } from "./NavMenuTypes";
|
|
2
2
|
|
|
3
|
+
interface NavMenuButtonProps {
|
|
4
|
+
/** An ID for the root element */
|
|
5
|
+
id?: string;
|
|
6
|
+
/** Class name(s) for the root element */
|
|
7
|
+
class?: string,
|
|
8
|
+
/** Whether this button is disabled */
|
|
9
|
+
disabled?: boolean,
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
/**
|
|
4
13
|
* A button that is placed in a NavMenu to carry out a non-navigation action such as logging out.
|
|
5
14
|
*
|
|
6
|
-
* @prop {boolean} disabled -- Whether this button is disabled
|
|
7
15
|
*/
|
|
8
|
-
export default function NavMenuButton($props:
|
|
9
|
-
|
|
10
|
-
let dataDisabled = $props.disabled || undefined;
|
|
16
|
+
export default function NavMenuButton($props: NavMenuButtonProps) {
|
|
17
|
+
$props ??= $watch({});
|
|
11
18
|
|
|
12
19
|
let button: HTMLButtonElement;
|
|
13
20
|
|
|
@@ -33,7 +40,7 @@ export default function NavMenuButton($props: any) {
|
|
|
33
40
|
{$props.disabled}
|
|
34
41
|
role="menuitem"
|
|
35
42
|
aria-disabled={$props.disabled ? "true" : undefined}
|
|
36
|
-
data-disabled={
|
|
43
|
+
data-disabled={$props.disabled ? "true" : undefined}
|
|
37
44
|
onkeydown
|
|
38
45
|
onkeydown={handleItemKey}
|
|
39
46
|
onclick
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { NavMenuContextName, type NavMenuContext } from "./NavMenuTypes";
|
|
2
2
|
|
|
3
|
+
interface NavMenuElementProps {
|
|
4
|
+
/** An ID for the root element */
|
|
5
|
+
id?: string;
|
|
6
|
+
/** Class name(s) for the root element */
|
|
7
|
+
class?: string,
|
|
8
|
+
/** Whether this button is disabled */
|
|
9
|
+
disabled?: boolean,
|
|
10
|
+
/** An element that can be focused via keyboard navigation */
|
|
11
|
+
element?: HTMLElement,
|
|
12
|
+
}
|
|
13
|
+
|
|
3
14
|
/**
|
|
4
15
|
* An element of any type that can be placed in a NavMenu.
|
|
5
16
|
*
|
|
6
|
-
* @prop {boolean} disabled -- Whether this button is disabled
|
|
7
|
-
* @prop {HTMLElement} element -- An element that can be focused via keyboard navigation
|
|
8
17
|
*/
|
|
9
|
-
export default function NavMenuElement($props:
|
|
10
|
-
|
|
11
|
-
let dataDisabled = $props.disabled || undefined;
|
|
18
|
+
export default function NavMenuElement($props: NavMenuElementProps) {
|
|
19
|
+
$props ??= $watch({});
|
|
12
20
|
|
|
13
21
|
// Get stuff out of the NavMenuContext
|
|
14
22
|
const menuContext = $context[NavMenuContextName] as NavMenuContext;
|
|
@@ -31,7 +39,7 @@ export default function NavMenuElement($props: any) {
|
|
|
31
39
|
type="div"
|
|
32
40
|
role="menuitem"
|
|
33
41
|
aria-disabled={$props.disabled ? "true" : undefined}
|
|
34
|
-
data-disabled={
|
|
42
|
+
data-disabled={$props.disabled ? "true" : undefined}
|
|
35
43
|
onkeydown
|
|
36
44
|
onkeydown={handleItemKey}
|
|
37
45
|
onclick
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { NavMenuGroupContextName, type NavMenuGroupContext } from "./NavMenuTypes";
|
|
2
2
|
|
|
3
|
+
interface NavMenuGroupProps {
|
|
4
|
+
/** An ID for the root element */
|
|
5
|
+
id?: string;
|
|
6
|
+
/** Class name(s) for the root element */
|
|
7
|
+
class?: string,
|
|
8
|
+
/** An ARIA label for describing the group to screen readers */
|
|
9
|
+
ariaLabel?: string,
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
/**
|
|
4
13
|
* A container for a logical group of navigation menu items.
|
|
5
|
-
*
|
|
6
|
-
* @prop {string | undefined} ariaLabel -- An ARIA label for describing the group to screen readers
|
|
7
14
|
*/
|
|
8
|
-
export default function NavMenuGroup($props:
|
|
15
|
+
export default function NavMenuGroup($props: NavMenuGroupProps) {
|
|
16
|
+
$props ??= $watch({});
|
|
17
|
+
|
|
9
18
|
let $state = $watch({
|
|
10
19
|
headerId: ""
|
|
11
20
|
});
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import getId from "../utils/getId";
|
|
2
2
|
import { NavMenuGroupContextName, type NavMenuGroupContext } from "./NavMenuTypes";
|
|
3
3
|
|
|
4
|
+
interface NavMenuGroupHeaderProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Class name(s) for the root element */
|
|
8
|
+
class?: string,
|
|
9
|
+
/** The type of HTML header to use */
|
|
10
|
+
as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6",
|
|
11
|
+
}
|
|
12
|
+
|
|
4
13
|
/**
|
|
5
14
|
* The header for a NavMenuGroup.
|
|
6
|
-
*
|
|
7
|
-
* @prop {"h1" | "h2" | "h3" | "h4" | "h5" | "h6"} as -- The type of HTML header to use
|
|
8
15
|
*/
|
|
9
|
-
export default function NavMenuGroupHeader($props:
|
|
16
|
+
export default function NavMenuGroupHeader($props: NavMenuGroupHeaderProps) {
|
|
17
|
+
$props ??= $watch({});
|
|
10
18
|
$props.id ??= getId();
|
|
11
19
|
|
|
12
20
|
const context = $context[NavMenuGroupContextName] as NavMenuGroupContext;
|
|
@@ -19,8 +27,8 @@ export default function NavMenuGroupHeader($props: any) {
|
|
|
19
27
|
$state.headerId = $props.id;
|
|
20
28
|
|
|
21
29
|
@render {
|
|
30
|
+
@// TODO: self={$props.as}
|
|
22
31
|
<h4
|
|
23
|
-
@// TODO: self={$props.as}
|
|
24
32
|
{$props.id}
|
|
25
33
|
class={`torp-nav-menu-group-header ${$props.class ?? ""}`.trim()}
|
|
26
34
|
>
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
|
|
2
2
|
import { NavMenuContextName, type NavMenuContext } from "./NavMenuTypes";
|
|
3
3
|
|
|
4
|
+
interface NavMenuLinkProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Class name(s) for the root element */
|
|
8
|
+
class?: string,
|
|
9
|
+
/** The URL for the menu link */
|
|
10
|
+
href: string,
|
|
11
|
+
/** Whether the menu link should open in a new tab/window */
|
|
12
|
+
newWindow?: boolean,
|
|
13
|
+
/** Whether this link is disabled */
|
|
14
|
+
disabled?: boolean,
|
|
15
|
+
}
|
|
16
|
+
|
|
4
17
|
/**
|
|
5
18
|
* A link that is placed in a NavMenu and signals a response by a user.
|
|
6
19
|
*
|
|
7
|
-
* @prop {string} href -- The URL for the menu link
|
|
8
|
-
* @prop {newWindow} boolean -- Whether the menu link should open in a new tab/window
|
|
9
|
-
* @prop {boolean} disabled -- Whether this link is disabled
|
|
10
20
|
*/
|
|
11
|
-
export default function NavMenuLink($props:
|
|
21
|
+
export default function NavMenuLink($props: NavMenuLinkProps) {
|
|
22
|
+
$props ??= $watch({ href: "#" });
|
|
12
23
|
$props.newWindow ??= false;
|
|
13
24
|
|
|
14
|
-
/** Set when the item is disabled */
|
|
15
|
-
let dataDisabled = $props.disabled || undefined;
|
|
16
|
-
|
|
17
25
|
let link: HTMLAnchorElement;
|
|
18
26
|
|
|
19
27
|
// Get stuff out of the NavMenuContext
|
|
@@ -39,7 +47,7 @@ export default function NavMenuLink($props: any) {
|
|
|
39
47
|
target={$props.newWindow ? "_blank" : undefined}
|
|
40
48
|
role="menuitem"
|
|
41
49
|
aria-disabled={$props.disabled ? "true" : undefined}
|
|
42
|
-
data-disabled={
|
|
50
|
+
data-disabled={$props.disabled ? "true" : undefined}
|
|
43
51
|
onkeydown
|
|
44
52
|
onkeydown={handleItemKey}
|
|
45
53
|
onclick
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { NavMenuPopoutContextName, type NavMenuPopoutContext } from "./NavMenuTypes";
|
|
2
2
|
|
|
3
|
+
interface NavMenuPopoutProps {
|
|
4
|
+
/** An ID for the root element */
|
|
5
|
+
id?: string;
|
|
6
|
+
/** Class name(s) for the root element */
|
|
7
|
+
class?: string,
|
|
8
|
+
/** Whether the popout is visible */
|
|
9
|
+
visible?: boolean,
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
/**
|
|
4
13
|
* A popout that is attached to a menu button and can be used to show a submenu.
|
|
5
14
|
*
|
|
@@ -11,10 +20,9 @@ import { NavMenuPopoutContextName, type NavMenuPopoutContext } from "./NavMenuTy
|
|
|
11
20
|
* <NavMenuPopoutContent />
|
|
12
21
|
* </NavMenuPopout>
|
|
13
22
|
* ```
|
|
14
|
-
*
|
|
15
|
-
* @prop {boolean} visible -- Whether the popout is visible
|
|
16
23
|
*/
|
|
17
|
-
export default function NavMenuPopout($props:
|
|
24
|
+
export default function NavMenuPopout($props: NavMenuPopoutProps) {
|
|
25
|
+
$props ??= $watch({});
|
|
18
26
|
$props.visible ??= false;
|
|
19
27
|
|
|
20
28
|
let $state = $watch({
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import {
|
|
3
2
|
NavMenuContextName,
|
|
4
3
|
NavMenuPopoutContextName,
|
|
@@ -6,18 +5,25 @@ import {
|
|
|
6
5
|
type NavMenuPopoutContext,
|
|
7
6
|
} from "./NavMenuTypes";
|
|
8
7
|
|
|
8
|
+
interface NavMenuPopoutButtonProps {
|
|
9
|
+
/** An ID for the root element */
|
|
10
|
+
id?: string;
|
|
11
|
+
/** Class name(s) for the root element */
|
|
12
|
+
class?: string,
|
|
13
|
+
/** The delay before showing the popout, in milliseconds */
|
|
14
|
+
hoverDelay?: number,
|
|
15
|
+
/** Whether this button is disabled */
|
|
16
|
+
disabled?: boolean,
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
/**
|
|
10
20
|
* A button that is placed in a NavMenu and signals a response by a user.
|
|
11
21
|
*
|
|
12
|
-
* @prop {number} hoverDelay -- The delay before showing the popout, in milliseconds
|
|
13
|
-
* @prop {boolean} disabled -- Whether this button is disabled
|
|
14
22
|
*/
|
|
15
|
-
export default function NavMenuPopoutButton($props:
|
|
23
|
+
export default function NavMenuPopoutButton($props: NavMenuPopoutButtonProps) {
|
|
24
|
+
$props ??= $watch({});
|
|
16
25
|
$props.hoverDelay ??= 500;
|
|
17
26
|
|
|
18
|
-
/** Set when the item is disabled */
|
|
19
|
-
let dataDisabled = $props.disabled || undefined;
|
|
20
|
-
|
|
21
27
|
let button: HTMLButtonElement;
|
|
22
28
|
let interval: NodeJS.Timeout | undefined;
|
|
23
29
|
|
|
@@ -104,7 +110,7 @@ export default function NavMenuPopoutButton($props: any) {
|
|
|
104
110
|
aria-haspopup="true"
|
|
105
111
|
aria-expanded={$state.visible.toString()}
|
|
106
112
|
aria-disabled={$props.disabled ? "true" : undefined}
|
|
107
|
-
data-disabled={
|
|
113
|
+
data-disabled={$state.disabled ? "true" : undefined}
|
|
108
114
|
onkeydown={handlePopoutKey}
|
|
109
115
|
onclick={handleClick}
|
|
110
116
|
onfocus={() => handleItemFocus(index)}
|
|
@@ -3,13 +3,23 @@ import getScrollParent from "../utils/getScrollParent";
|
|
|
3
3
|
import setPopoverPosition from "../utils/setPopoverPosition";
|
|
4
4
|
import { NavMenuPopoutContextName, type NavMenuPopoutContext } from "./NavMenuTypes";
|
|
5
5
|
|
|
6
|
+
interface NavMenuPopoutContentProps {
|
|
7
|
+
/** An ID for the root element */
|
|
8
|
+
id?: string;
|
|
9
|
+
/** Class name(s) for the root element */
|
|
10
|
+
class?: string,
|
|
11
|
+
/** Where the popout will be shown, relative to the popout button */
|
|
12
|
+
side?: "top" | "right" | "bottom" | "left",
|
|
13
|
+
/** How the popout will be aligned, relative to the popout button */
|
|
14
|
+
alignment?: "start" | "center" | "end",
|
|
15
|
+
}
|
|
16
|
+
|
|
6
17
|
/**
|
|
7
18
|
* The content that is displayed for a NavMenuPopout when it is open.
|
|
8
19
|
*
|
|
9
|
-
* @prop {"top" | "right" | "bottom" | "left"} side -- Where the popout will be shown, relative to the popout button
|
|
10
|
-
* @prop {"start" | "center" | "end"} alignment -- How the popout will be aligned, relative to the popout button
|
|
11
20
|
*/
|
|
12
|
-
export default function NavMenuPopoutContent($props:
|
|
21
|
+
export default function NavMenuPopoutContent($props: NavMenuPopoutContentProps) {
|
|
22
|
+
$props ??= $watch({});
|
|
13
23
|
$props.side ??= "bottom";
|
|
14
24
|
$props.alignment ??= "start";
|
|
15
25
|
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
|
|
2
|
+
interface NavMenuSeparatorProps {
|
|
3
|
+
/** An ID for the root element */
|
|
4
|
+
id?: string;
|
|
5
|
+
/** Class name(s) for the root element */
|
|
6
|
+
class?: string,
|
|
7
|
+
}
|
|
8
|
+
|
|
2
9
|
/**
|
|
3
10
|
* An element in a menu that separates logical sets of menu items.
|
|
4
11
|
*/
|
|
5
|
-
export default function NavMenuSeparator($props:
|
|
12
|
+
export default function NavMenuSeparator($props: NavMenuSeparatorProps) {
|
|
13
|
+
$props ??= $watch({});
|
|
14
|
+
|
|
6
15
|
@render {
|
|
7
16
|
<div
|
|
8
17
|
{$props.id}
|