@torpor/ui 0.3.5 → 0.3.6
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/dist/metafile-esm.json +1 -1
- package/package.json +5 -2
- package/CHANGELOG.md +0 -344
- package/scripts/postbuild.ts +0 -127
- package/src/Accordion/Accordion.torp +0 -230
- package/src/Accordion/AccordionContent.torp +0 -46
- package/src/Accordion/AccordionHeader.torp +0 -45
- package/src/Accordion/AccordionItem.torp +0 -101
- package/src/Accordion/AccordionTrigger.torp +0 -70
- package/src/Accordion/AccordionTypes.ts +0 -36
- package/src/Accordion/index.ts +0 -7
- package/src/Breadcrumb/Breadcrumb.torp +0 -45
- package/src/Breadcrumb/BreadcrumbItem.torp +0 -30
- package/src/Breadcrumb/BreadcrumbSeparator.torp +0 -27
- package/src/Breadcrumb/index.ts +0 -5
- package/src/Calendar/Calendar.torp +0 -277
- package/src/Calendar/CalendarDay.torp +0 -78
- package/src/Calendar/CalendarTypes.ts +0 -22
- package/src/Calendar/index.ts +0 -4
- package/src/Contextual/Contextual.torp +0 -129
- package/src/Contextual/ContextualContent.torp +0 -112
- package/src/Contextual/ContextualTrigger.torp +0 -70
- package/src/Contextual/ContextualTypes.ts +0 -30
- package/src/Contextual/index.ts +0 -5
- package/src/Dialog/Dialog.torp +0 -136
- package/src/Dialog/DialogBody.torp +0 -44
- package/src/Dialog/DialogButton.torp +0 -66
- package/src/Dialog/DialogFooter.torp +0 -25
- package/src/Dialog/DialogHeader.torp +0 -45
- package/src/Dialog/DialogTypes.ts +0 -17
- package/src/Dialog/index.ts +0 -7
- package/src/Disclosure/Disclosure.torp +0 -82
- package/src/Disclosure/DisclosureContent.torp +0 -46
- package/src/Disclosure/DisclosureHeader.torp +0 -45
- package/src/Disclosure/DisclosureTrigger.torp +0 -47
- package/src/Disclosure/DisclosureTypes.ts +0 -13
- package/src/Disclosure/index.ts +0 -6
- package/src/Drawer/Drawer.torp +0 -127
- package/src/Drawer/DrawerContent.torp +0 -83
- package/src/Drawer/DrawerOverlay.torp +0 -42
- package/src/Drawer/DrawerTrigger.torp +0 -39
- package/src/Drawer/DrawerTypes.ts +0 -24
- package/src/Drawer/index.ts +0 -6
- package/src/Form/CheckBox.torp +0 -94
- package/src/Form/Field.torp +0 -95
- package/src/Form/File.torp +0 -102
- package/src/Form/Form.torp +0 -147
- package/src/Form/FormTypes.ts +0 -35
- package/src/Form/Hidden.torp +0 -25
- package/src/Form/Input.torp +0 -112
- package/src/Form/Label.torp +0 -35
- package/src/Form/Message.torp +0 -39
- package/src/Form/Option.torp +0 -28
- package/src/Form/Select.torp +0 -101
- package/src/Form/StandardSchemaV1.ts +0 -70
- package/src/Form/TextArea.torp +0 -105
- package/src/Form/index.ts +0 -13
- package/src/Menu/Menu.torp +0 -174
- package/src/Menu/MenuButton.torp +0 -74
- package/src/Menu/MenuCheck.torp +0 -89
- package/src/Menu/MenuGroup.torp +0 -31
- package/src/Menu/MenuIndicator.torp +0 -40
- package/src/Menu/MenuPopout.torp +0 -83
- package/src/Menu/MenuPopoutContent.torp +0 -84
- package/src/Menu/MenuPopoutTrigger.torp +0 -128
- package/src/Menu/MenuRadio.torp +0 -103
- package/src/Menu/MenuRadioGroup.torp +0 -109
- package/src/Menu/MenuSeparator.torp +0 -26
- package/src/Menu/MenuTypes.ts +0 -60
- package/src/Menu/index.ts +0 -25
- package/src/MenuBar/MenuBar.torp +0 -162
- package/src/MenuBar/MenuBarItem.torp +0 -116
- package/src/MenuBar/MenuBarItemContent.torp +0 -119
- package/src/MenuBar/MenuBarItemTrigger.torp +0 -99
- package/src/MenuBar/MenuBarTypes.ts +0 -36
- package/src/MenuBar/index.ts +0 -6
- package/src/Modal/Modal.torp +0 -122
- package/src/Modal/ModalContent.torp +0 -81
- package/src/Modal/ModalOverlay.torp +0 -42
- package/src/Modal/ModalTrigger.torp +0 -54
- package/src/Modal/ModalTypes.ts +0 -22
- package/src/Modal/index.ts +0 -10
- package/src/Modal/showModal.ts +0 -19
- package/src/Modal/showPrompt.ts +0 -23
- package/src/NavMenu/NavMenu.torp +0 -190
- package/src/NavMenu/NavMenuButton.torp +0 -55
- package/src/NavMenu/NavMenuElement.torp +0 -55
- package/src/NavMenu/NavMenuGroup.torp +0 -41
- package/src/NavMenu/NavMenuGroupHeader.torp +0 -41
- package/src/NavMenu/NavMenuLink.torp +0 -60
- package/src/NavMenu/NavMenuPopout.torp +0 -89
- package/src/NavMenu/NavMenuPopoutButton.torp +0 -129
- package/src/NavMenu/NavMenuPopoutContent.torp +0 -92
- package/src/NavMenu/NavMenuSeparator.torp +0 -24
- package/src/NavMenu/NavMenuTypes.ts +0 -32
- package/src/NavMenu/index.ts +0 -23
- package/src/Notification/Notification.torp +0 -71
- package/src/Notification/NotificationClose.torp +0 -39
- package/src/Notification/NotificationContainer.torp +0 -26
- package/src/Notification/NotificationContent.torp +0 -25
- package/src/Notification/NotificationTypes.ts +0 -5
- package/src/Notification/index.ts +0 -13
- package/src/Notification/showNotification.ts +0 -30
- package/src/Popover/Popover.torp +0 -129
- package/src/Popover/PopoverContent.torp +0 -117
- package/src/Popover/PopoverTrigger.torp +0 -62
- package/src/Popover/PopoverTypes.ts +0 -30
- package/src/Popover/index.ts +0 -6
- package/src/Popover/showPopover.ts +0 -24
- package/src/Slider/Slider.torp +0 -84
- package/src/Slider/index.ts +0 -3
- package/src/TabGroup/TabContent.torp +0 -49
- package/src/TabGroup/TabGroup.torp +0 -250
- package/src/TabGroup/TabGroupTypes.ts +0 -44
- package/src/TabGroup/TabHeader.torp +0 -81
- package/src/TabGroup/TabList.torp +0 -61
- package/src/TabGroup/TabTrigger.torp +0 -76
- package/src/TabGroup/index.ts +0 -7
- package/src/ambient.d.ts +0 -7
- package/src/icons/ArrowDown.torp +0 -18
- package/src/icons/ArrowLeft.torp +0 -18
- package/src/icons/ArrowRight.torp +0 -18
- package/src/icons/ArrowUp.torp +0 -18
- package/src/icons/Bars.torp +0 -20
- package/src/icons/Check.torp +0 -18
- package/src/icons/ChevronDown.torp +0 -18
- package/src/icons/ChevronLeft.torp +0 -18
- package/src/icons/ChevronRight.torp +0 -18
- package/src/icons/ChevronUp.torp +0 -18
- package/src/icons/Cross.torp +0 -19
- package/src/icons/IconTypes.ts +0 -10
- package/src/icons/Loading.torp +0 -19
- package/src/icons/Minus.torp +0 -18
- package/src/icons/Plus.torp +0 -19
- package/src/icons/index.ts +0 -31
- package/src/motion/fade.ts +0 -16
- package/src/motion/grow.ts +0 -23
- package/src/motion/index.ts +0 -6
- package/src/motion/measure.ts +0 -28
- package/src/motion/slide.ts +0 -45
- package/src/mount/clickPopover.ts +0 -51
- package/src/mount/contextPopover.ts +0 -51
- package/src/mount/disableScroll.ts +0 -28
- package/src/mount/hoverPopover.ts +0 -58
- package/src/mount/hoverTrigger.ts +0 -59
- package/src/mount/trapFocus.ts +0 -58
- package/src/utils/dateUtils.ts +0 -244
- package/src/utils/documentEvents.ts +0 -17
- package/src/utils/getId.ts +0 -6
- package/src/utils/getScrollParent.ts +0 -22
- package/src/utils/setContextPosition.ts +0 -31
- package/src/utils/setPopoverPosition.ts +0 -142
- package/test/Accordion/accessibility.test.ts +0 -59
- package/test/Accordion/components/AccordionAccessibility.torp +0 -44
- package/test/Accordion/components/AccordionKeyboard.torp +0 -32
- package/test/Accordion/components/AccordionList.torp +0 -23
- package/test/Accordion/components/AccordionMultiple.torp +0 -32
- package/test/Accordion/components/AccordionSingle.torp +0 -32
- package/test/Accordion/for-items.test.ts +0 -52
- package/test/Accordion/keyboard.test.ts +0 -64
- package/test/Accordion/multiple-item-toggle.test.ts +0 -32
- package/test/Accordion/multiple-item-value.test.ts +0 -17
- package/test/Accordion/single-item-toggle.test.ts +0 -31
- package/test/Accordion/single-item-value.test.ts +0 -17
- package/test/Breadcrumb/accessibility.test.ts +0 -29
- package/test/Breadcrumb/basic.test.ts +0 -17
- package/test/Breadcrumb/components/BreadcrumbTest.torp +0 -15
- package/test/Calendar/components/CalendarTest.torp +0 -9
- package/test/Calendar/default.test.ts +0 -18
- package/test/Dialog/accessibility-alert.test.ts +0 -40
- package/test/Dialog/accessibility-modal.test.ts +0 -52
- package/test/Dialog/components/DialogAccessibility.torp +0 -25
- package/test/Dialog/components/DialogFunction.torp +0 -36
- package/test/Dialog/components/DialogModal.torp +0 -30
- package/test/Dialog/components/DialogVariable.torp +0 -33
- package/test/Dialog/function.test.ts +0 -26
- package/test/Dialog/variable.test.ts +0 -27
- package/test/Disclosure/accessibility.test.ts +0 -31
- package/test/Disclosure/components/DisclosureTest.torp +0 -17
- package/test/Disclosure/default.test.ts +0 -15
- package/test/Disclosure/toggle.test.ts +0 -20
- package/test/Form/components/FieldTest.torp +0 -25
- package/test/Form/components/FormTest.torp +0 -31
- package/test/Form/components/InputTest.torp +0 -9
- package/test/Form/field.test.ts +0 -34
- package/test/Form/form.test.ts +0 -34
- package/test/Form/input.test.ts +0 -19
- package/test/Menu/accessibility.test.ts +0 -83
- package/test/Menu/basic.test.ts +0 -58
- package/test/Menu/components/MenuAccessibility.torp +0 -59
- package/test/Menu/components/MenuBasic.torp +0 -58
- package/test/MenuBar/accessibility.test.ts +0 -87
- package/test/MenuBar/basic.test.ts +0 -22
- package/test/MenuBar/components/MenuBarAccessibility.torp +0 -34
- package/test/MenuBar/components/MenuBarBasic.torp +0 -25
- package/test/NavMenu/accessibility.test.ts +0 -97
- package/test/NavMenu/basic.test.ts +0 -22
- package/test/NavMenu/components/NavMenuAccessibility.torp +0 -35
- package/test/NavMenu/components/NavMenuBasic.torp +0 -28
- package/test/Notification/accessibility.test.ts +0 -21
- package/test/Notification/components/CustomNotification.torp +0 -14
- package/test/Notification/components/NotificationAccessibility.torp +0 -14
- package/test/Notification/components/NotificationFunction.torp +0 -17
- package/test/Notification/components/NotificationVariable.torp +0 -22
- package/test/Notification/function.test.ts +0 -25
- package/test/Notification/variable.test.ts +0 -25
- package/test/Popover/components/CustomDialog.torp +0 -25
- package/test/Popover/components/PopoverFunction.torp +0 -37
- package/test/Popover/components/PopoverTrigger.torp +0 -36
- package/test/Popover/components/PopoverVariable.torp +0 -40
- package/test/Popover/function.test.ts +0 -21
- package/test/Popover/trigger.test.ts +0 -27
- package/test/Popover/variable.test.ts +0 -27
- package/test/TabGroup/accessibility.test.ts +0 -67
- package/test/TabGroup/components/TabGroupAccessibility.torp +0 -28
- package/test/TabGroup/components/TabGroupKeyboard.torp +0 -28
- package/test/TabGroup/components/TabGroupList.torp +0 -26
- package/test/TabGroup/components/TabGroupTrigger.torp +0 -28
- package/test/TabGroup/for-items.test.ts +0 -52
- package/test/TabGroup/item-trigger.test.ts +0 -33
- package/test/TabGroup/item-value.test.ts +0 -17
- package/test/TabGroup/keyboard.test.ts +0 -72
- package/tsconfig.json +0 -4
- package/tsup.config.ts +0 -37
- package/vitest.config.ts +0 -12
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { ClassValue, StyleValue } from "@torpor/view";
|
|
2
|
-
import { NavMenuGroupContextName, type NavMenuGroupContext } from "./NavMenuTypes";
|
|
3
|
-
|
|
4
|
-
interface NavMenuGroupProps {
|
|
5
|
-
/** An ID for the root element */
|
|
6
|
-
id?: string;
|
|
7
|
-
/** Classes for the root element */
|
|
8
|
-
class?: ClassValue,
|
|
9
|
-
/** Styles for the root element */
|
|
10
|
-
style?: StyleValue,
|
|
11
|
-
/** An ARIA label for describing the group to screen readers */
|
|
12
|
-
ariaLabel?: string,
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* A container for a logical group of navigation menu items.
|
|
17
|
-
*/
|
|
18
|
-
export default function NavMenuGroup($props: NavMenuGroupProps | undefined) {
|
|
19
|
-
let $state = $watch({
|
|
20
|
-
headerId: ""
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// Set the context to pass down to items
|
|
24
|
-
let context: NavMenuGroupContext = {
|
|
25
|
-
state: $state,
|
|
26
|
-
};
|
|
27
|
-
$context[NavMenuGroupContextName] = context;
|
|
28
|
-
|
|
29
|
-
@render {
|
|
30
|
-
<div
|
|
31
|
-
{$props?.id}
|
|
32
|
-
class={["torp-nav-menu-group", $props?.class]}
|
|
33
|
-
{$props?.style}
|
|
34
|
-
role="group"
|
|
35
|
-
aria-label={$props?.ariaLabel}
|
|
36
|
-
aria-labelledby={$state.headerId}
|
|
37
|
-
>
|
|
38
|
-
<slot />
|
|
39
|
-
</div>
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { ClassValue, StyleValue } from "@torpor/view";
|
|
2
|
-
import getId from "../utils/getId";
|
|
3
|
-
import { NavMenuGroupContextName, type NavMenuGroupContext } from "./NavMenuTypes";
|
|
4
|
-
|
|
5
|
-
interface NavMenuGroupHeaderProps {
|
|
6
|
-
/** An ID for the root element */
|
|
7
|
-
id?: string;
|
|
8
|
-
/** Classes for the root element */
|
|
9
|
-
class?: ClassValue,
|
|
10
|
-
/** Styles for the root element */
|
|
11
|
-
style?: StyleValue,
|
|
12
|
-
/** The type of HTML header to use */
|
|
13
|
-
as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6",
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The header for a NavMenuGroup.
|
|
18
|
-
*/
|
|
19
|
-
export default function NavMenuGroupHeader($props: NavMenuGroupHeaderProps | undefined) {
|
|
20
|
-
let defaultId = getId();
|
|
21
|
-
|
|
22
|
-
const context = $context[NavMenuGroupContextName] as NavMenuGroupContext;
|
|
23
|
-
if (!context) {
|
|
24
|
-
throw new Error("NavMenuGroupHeader must be contained within a NavMenuGroup");
|
|
25
|
-
}
|
|
26
|
-
let $state = context.state;
|
|
27
|
-
|
|
28
|
-
// Set the header ID now that we know what it is
|
|
29
|
-
$state.headerId = $props?.id ?? defaultId;
|
|
30
|
-
|
|
31
|
-
@render {
|
|
32
|
-
@// TODO: self={$props.as}
|
|
33
|
-
<h4
|
|
34
|
-
id={$props?.id ?? defaultId}
|
|
35
|
-
class={["torp-nav-menu-group-header", $props?.class]}
|
|
36
|
-
{$props?.style}
|
|
37
|
-
>
|
|
38
|
-
<slot />
|
|
39
|
-
</h4>
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import type { ClassValue, StyleValue } from "@torpor/view";
|
|
2
|
-
import { NavMenuContextName, type NavMenuContext } from "./NavMenuTypes";
|
|
3
|
-
|
|
4
|
-
interface NavMenuLinkProps {
|
|
5
|
-
/** An ID for the root element */
|
|
6
|
-
id?: string;
|
|
7
|
-
/** Classes for the root element */
|
|
8
|
-
class?: ClassValue,
|
|
9
|
-
/** Styles for the root element */
|
|
10
|
-
style?: StyleValue,
|
|
11
|
-
/** The URL for the menu link */
|
|
12
|
-
href: string,
|
|
13
|
-
/** Whether the menu link should open in a new tab/window */
|
|
14
|
-
newWindow?: boolean,
|
|
15
|
-
/** Whether this link is disabled */
|
|
16
|
-
disabled?: boolean,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* A link that is placed in a NavMenu and signals a response by a user.
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
export default function NavMenuLink($props: NavMenuLinkProps | undefined) {
|
|
24
|
-
let link: HTMLAnchorElement;
|
|
25
|
-
|
|
26
|
-
// Get stuff out of the NavMenuContext
|
|
27
|
-
const menuContext = $context[NavMenuContextName] as NavMenuContext;
|
|
28
|
-
if (!menuContext) {
|
|
29
|
-
throw new Error("NavMenuLink must be contained within a NavMenu");
|
|
30
|
-
}
|
|
31
|
-
const { registerItem, handleItemKey, handleItemFocus } = menuContext;
|
|
32
|
-
|
|
33
|
-
// Register this item with the parent NavMenu and store the index
|
|
34
|
-
const { index } = registerItem(setFocused);
|
|
35
|
-
|
|
36
|
-
function setFocused() {
|
|
37
|
-
link.focus();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@render {
|
|
41
|
-
<a
|
|
42
|
-
{$props?.id}
|
|
43
|
-
class={["torp-nav-menu-link", $props?.class]}
|
|
44
|
-
{$props?.style}
|
|
45
|
-
{$props?.href}
|
|
46
|
-
{$props?.disabled}
|
|
47
|
-
target={$props?.newWindow ? "_blank" : undefined}
|
|
48
|
-
role="menuitem"
|
|
49
|
-
aria-disabled={$props?.disabled ? "true" : undefined}
|
|
50
|
-
data-disabled={$props?.disabled ? "true" : undefined}
|
|
51
|
-
onkeydown
|
|
52
|
-
onkeydown={handleItemKey}
|
|
53
|
-
onclick
|
|
54
|
-
onfocus={() => handleItemFocus(index)}
|
|
55
|
-
&ref={link}
|
|
56
|
-
>
|
|
57
|
-
<slot />
|
|
58
|
-
</a>
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import type { ClassValue, StyleValue } from "@torpor/view";
|
|
2
|
-
import { NavMenuPopoutContextName, type NavMenuPopoutContext } from "./NavMenuTypes";
|
|
3
|
-
|
|
4
|
-
interface NavMenuPopoutProps {
|
|
5
|
-
/** An ID for the root element */
|
|
6
|
-
id?: string;
|
|
7
|
-
/** Classes for the root element */
|
|
8
|
-
class?: ClassValue,
|
|
9
|
-
/** Styles for the root element */
|
|
10
|
-
style?: StyleValue,
|
|
11
|
-
/** Whether the popout is visible */
|
|
12
|
-
visible?: boolean,
|
|
13
|
-
/** Raised when the popout is opened or closed */
|
|
14
|
-
ontoggle?: (open: boolean) => void,
|
|
15
|
-
/** Raised when the popout has opened */
|
|
16
|
-
onopen?: () => void,
|
|
17
|
-
/** Raised when the popout has closed */
|
|
18
|
-
onclose?: (result: any) => void,
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* A popout that is attached to a menu button and can be used to show a submenu.
|
|
23
|
-
*
|
|
24
|
-
* The structure of a NavMenuPopout is:
|
|
25
|
-
*
|
|
26
|
-
* ```
|
|
27
|
-
* <NavMenuPopout>
|
|
28
|
-
* <NavMenuPopoutButton />
|
|
29
|
-
* <NavMenuPopoutContent />
|
|
30
|
-
* </NavMenuPopout>
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
export default function NavMenuPopout($props: NavMenuPopoutProps | undefined) {
|
|
34
|
-
let $state = $watch({
|
|
35
|
-
visible: false
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Sync props and state
|
|
39
|
-
$run(() => {
|
|
40
|
-
$state.visible = $props?.visible ?? false;
|
|
41
|
-
});
|
|
42
|
-
$run(() => {
|
|
43
|
-
if ($props !== undefined) {
|
|
44
|
-
$props.visible = $state.visible;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
let result: any;
|
|
49
|
-
|
|
50
|
-
// Set the context to pass down to items
|
|
51
|
-
let context: NavMenuPopoutContext = {
|
|
52
|
-
state: $state,
|
|
53
|
-
};
|
|
54
|
-
$context[NavMenuPopoutContextName] = context;
|
|
55
|
-
|
|
56
|
-
// Dispatch the toggle event when the popout is opened or closed
|
|
57
|
-
let firstToggle = true;
|
|
58
|
-
$run(() => {
|
|
59
|
-
const ontoggle = $props?.ontoggle;
|
|
60
|
-
const onopen = $props?.onopen;
|
|
61
|
-
const onclose = $props?.onclose;
|
|
62
|
-
const visible = $state.visible;
|
|
63
|
-
if (firstToggle) {
|
|
64
|
-
firstToggle = false;
|
|
65
|
-
} else {
|
|
66
|
-
if (ontoggle) ontoggle(visible);
|
|
67
|
-
if (visible) {
|
|
68
|
-
if (onopen) onopen()
|
|
69
|
-
} else {
|
|
70
|
-
if (onclose) onclose(result);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
function handleMouseLeave() {
|
|
76
|
-
$state.visible = false;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
@render {
|
|
80
|
-
<div
|
|
81
|
-
{$props?.id}
|
|
82
|
-
class={["torp-nav-menu-popout", $props?.class]}
|
|
83
|
-
{$props?.style}
|
|
84
|
-
onmouseleave={handleMouseLeave}
|
|
85
|
-
>
|
|
86
|
-
<slot />
|
|
87
|
-
</div>
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import type { ClassValue, StyleValue } from "@torpor/view";
|
|
2
|
-
import {
|
|
3
|
-
NavMenuContextName,
|
|
4
|
-
NavMenuPopoutContextName,
|
|
5
|
-
type NavMenuContext,
|
|
6
|
-
type NavMenuPopoutContext,
|
|
7
|
-
} from "./NavMenuTypes";
|
|
8
|
-
|
|
9
|
-
interface NavMenuPopoutButtonProps {
|
|
10
|
-
/** An ID for the root element */
|
|
11
|
-
id?: string;
|
|
12
|
-
/** Classes for the root element */
|
|
13
|
-
class?: ClassValue,
|
|
14
|
-
/** Styles for the root element */
|
|
15
|
-
style?: StyleValue,
|
|
16
|
-
/** The delay before showing the popout, in milliseconds */
|
|
17
|
-
hoverDelay?: number,
|
|
18
|
-
/** Whether this button is disabled */
|
|
19
|
-
disabled?: boolean,
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* A button that is placed in a NavMenu and signals a response by a user.
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
export default function NavMenuPopoutButton($props: NavMenuPopoutButtonProps | undefined) {
|
|
27
|
-
let defaultHoverDelay = 500;
|
|
28
|
-
|
|
29
|
-
let button: HTMLButtonElement;
|
|
30
|
-
let interval: NodeJS.Timeout | undefined;
|
|
31
|
-
|
|
32
|
-
// Get stuff out of the NavMenuContext
|
|
33
|
-
const menuContext = $context[NavMenuContextName] as NavMenuContext;
|
|
34
|
-
if (!menuContext) {
|
|
35
|
-
throw new Error("NavMenuPopoutButton must be contained within a NavMenu");
|
|
36
|
-
}
|
|
37
|
-
const { registerItem, handleItemKey, handleItemFocus } = menuContext;
|
|
38
|
-
|
|
39
|
-
// Get stuff out of the NavMenuPopoutContext
|
|
40
|
-
const popoutContext = $context[NavMenuPopoutContextName] as NavMenuPopoutContext;
|
|
41
|
-
if (!popoutContext) {
|
|
42
|
-
throw new Error("NavMenuPopoutButton must be contained within a NavMenuPopout");
|
|
43
|
-
}
|
|
44
|
-
let $state = popoutContext.state;
|
|
45
|
-
|
|
46
|
-
// Register this item with the parent NavMenu and store the index
|
|
47
|
-
const { index } = registerItem(setFocused);
|
|
48
|
-
|
|
49
|
-
// TODO: $mount should be run AFTER the button has been set
|
|
50
|
-
//$mount(() => {
|
|
51
|
-
// // Set the anchor element to the button when it exists
|
|
52
|
-
// popoutContext.anchorElement = button;
|
|
53
|
-
//});
|
|
54
|
-
|
|
55
|
-
function setFocused() {
|
|
56
|
-
button.focus();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function handleClick() {
|
|
60
|
-
$state.visible = true;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function handlePopoutKey(e: KeyboardEvent) {
|
|
64
|
-
switch (e.key) {
|
|
65
|
-
case "Right":
|
|
66
|
-
case "ArrowRight":
|
|
67
|
-
// TODO: This should be based on what side the menu shows on
|
|
68
|
-
e.preventDefault();
|
|
69
|
-
$state.visible = true;
|
|
70
|
-
break;
|
|
71
|
-
default:
|
|
72
|
-
handleItemKey(e);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function handleMouseEnter() {
|
|
77
|
-
if ($props?.disabled) return;
|
|
78
|
-
|
|
79
|
-
// Handle the hover after a delay
|
|
80
|
-
if (!interval) {
|
|
81
|
-
interval = setTimeout(() => $state.visible = true, $props?.hoverDelay ?? defaultHoverDelay);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function handleMouseLeave() {
|
|
86
|
-
if ($props?.disabled) return;
|
|
87
|
-
|
|
88
|
-
// Prevent short hovers or touches from firing the event
|
|
89
|
-
if (interval) {
|
|
90
|
-
clearTimeout(interval);
|
|
91
|
-
interval = undefined;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function handleMouseMove() {
|
|
96
|
-
if ($props?.disabled) return;
|
|
97
|
-
|
|
98
|
-
// Reset the interval on mouse move
|
|
99
|
-
if (interval) {
|
|
100
|
-
clearTimeout(interval);
|
|
101
|
-
interval = setTimeout(() => $state.visible = true, $props?.hoverDelay ?? defaultHoverDelay);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
@render {
|
|
106
|
-
<button
|
|
107
|
-
{$props?.id}
|
|
108
|
-
class={["torp-nav-menu-popout-button", $props?.class]}
|
|
109
|
-
{$props?.style}
|
|
110
|
-
type="button"
|
|
111
|
-
{$props?.disabled}
|
|
112
|
-
role="menuitem"
|
|
113
|
-
aria-haspopup="true"
|
|
114
|
-
aria-expanded={$state.visible.toString()}
|
|
115
|
-
aria-disabled={$props?.disabled ? "true" : undefined}
|
|
116
|
-
data-disabled={$props?.disabled ? "true" : undefined}
|
|
117
|
-
onkeydown={handlePopoutKey}
|
|
118
|
-
onclick={handleClick}
|
|
119
|
-
onfocus={() => handleItemFocus(index)}
|
|
120
|
-
onmouseenter={handleMouseEnter}
|
|
121
|
-
onmouseleave={handleMouseLeave}
|
|
122
|
-
onmousemove={handleMouseMove}
|
|
123
|
-
&ref={button}
|
|
124
|
-
onmount={(el) => popoutContext.anchorElement = el }
|
|
125
|
-
>
|
|
126
|
-
<slot />
|
|
127
|
-
</button>
|
|
128
|
-
}
|
|
129
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import type { ClassValue, StyleValue } from "@torpor/view";
|
|
2
|
-
import getScrollParent from "../utils/getScrollParent";
|
|
3
|
-
import setPopoverPosition from "../utils/setPopoverPosition";
|
|
4
|
-
import { NavMenuPopoutContextName, type NavMenuPopoutContext } from "./NavMenuTypes";
|
|
5
|
-
|
|
6
|
-
interface NavMenuPopoutContentProps {
|
|
7
|
-
/** An ID for the root element */
|
|
8
|
-
id?: string;
|
|
9
|
-
/** Classes for the root element */
|
|
10
|
-
class?: ClassValue,
|
|
11
|
-
/** Styles for the root element */
|
|
12
|
-
style?: StyleValue,
|
|
13
|
-
/** Where the popout will be shown, relative to the popout button */
|
|
14
|
-
side?: "top" | "right" | "bottom" | "left",
|
|
15
|
-
/** How the popout will be aligned, relative to the popout button */
|
|
16
|
-
alignment?: "start" | "center" | "end",
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The content that is displayed for a NavMenuPopout when it is open.
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
export default function NavMenuPopoutContent($props: NavMenuPopoutContentProps | undefined) {
|
|
24
|
-
let div: HTMLDivElement;
|
|
25
|
-
let shown = false;
|
|
26
|
-
|
|
27
|
-
// Get stuff out of the NavMenuPopoutContext
|
|
28
|
-
const context = $context[NavMenuPopoutContextName] as NavMenuPopoutContext;
|
|
29
|
-
if (!context) {
|
|
30
|
-
throw new Error("NavMenuPopoutContent must be contained within a NavMenuPopout");
|
|
31
|
-
}
|
|
32
|
-
let $state = context.state;
|
|
33
|
-
|
|
34
|
-
$run(() => {
|
|
35
|
-
if (!$state.visible) {
|
|
36
|
-
hide();
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
function show() {
|
|
41
|
-
shown = true;
|
|
42
|
-
|
|
43
|
-
// Set the position and listen for window resize and scroll to reset the position
|
|
44
|
-
setPosition();
|
|
45
|
-
const anchorElement = context.anchorElement!
|
|
46
|
-
const scrollParent = getScrollParent(anchorElement)
|
|
47
|
-
scrollParent.addEventListener("resize", setPosition);
|
|
48
|
-
scrollParent.addEventListener("scroll", setPosition);
|
|
49
|
-
if (context.focusFirstElement) {
|
|
50
|
-
context.focusFirstElement();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function hide() {
|
|
55
|
-
if (!shown) return;
|
|
56
|
-
|
|
57
|
-
// Stop listening for window resize and focus the anchor element per WAI guidelines
|
|
58
|
-
const anchorElement = context.anchorElement!
|
|
59
|
-
const scrollParent = getScrollParent(anchorElement)
|
|
60
|
-
scrollParent.removeEventListener("resize", setPosition);
|
|
61
|
-
scrollParent.removeEventListener("scroll", setPosition);
|
|
62
|
-
if (anchorElement.focus) {
|
|
63
|
-
anchorElement.focus();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function setPosition() {
|
|
68
|
-
if (!context.anchorElement) {
|
|
69
|
-
throw new Error("NavMenuPopoutContent must have an anchor element");
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (div) {
|
|
73
|
-
let side = $props?.side ?? "bottom";
|
|
74
|
-
let alignment = $props?.alignment ?? "start";
|
|
75
|
-
setPopoverPosition(context.anchorElement, div, side, alignment);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
@render {
|
|
80
|
-
@if ($state.visible) {
|
|
81
|
-
<div
|
|
82
|
-
{$props?.id}
|
|
83
|
-
class={["torp-nav-menu-popout-content", $props?.class]}
|
|
84
|
-
{$props?.style}
|
|
85
|
-
&ref={div}
|
|
86
|
-
onmount={show}
|
|
87
|
-
>
|
|
88
|
-
<slot />
|
|
89
|
-
</div>
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { ClassValue, StyleValue } from "@torpor/view";
|
|
2
|
-
|
|
3
|
-
interface NavMenuSeparatorProps {
|
|
4
|
-
/** An ID for the root element */
|
|
5
|
-
id?: string;
|
|
6
|
-
/** Classes for the root element */
|
|
7
|
-
class?: ClassValue,
|
|
8
|
-
/** Styles for the root element */
|
|
9
|
-
style?: StyleValue,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* An element in a menu that separates logical sets of menu items.
|
|
14
|
-
*/
|
|
15
|
-
export default function NavMenuSeparator($props: NavMenuSeparatorProps | undefined) {
|
|
16
|
-
@render {
|
|
17
|
-
<div
|
|
18
|
-
{$props?.id}
|
|
19
|
-
class={`torp-nav-menu-separator ${$props?.class ?? ""}`.trim()} role="separator"
|
|
20
|
-
>
|
|
21
|
-
<slot />
|
|
22
|
-
</div>
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export const NavMenuContextName = "NavMenu";
|
|
2
|
-
export const NavMenuPopoutContextName = "NavMenuPopout";
|
|
3
|
-
export const NavMenuGroupContextName = "NavMenuGroup";
|
|
4
|
-
|
|
5
|
-
export interface NavMenuContext {
|
|
6
|
-
/** Called from a NavMenuLink or NavMenuButton when its button is focused */
|
|
7
|
-
handleItemFocus: (index: number) => void;
|
|
8
|
-
|
|
9
|
-
/** Called from a NavMenuLink or NavMenuButton when a key is pressed */
|
|
10
|
-
handleItemKey: (e: KeyboardEvent) => void;
|
|
11
|
-
|
|
12
|
-
/** Called from each NavMenuLink or NavMenuButton to register itself with this NavMenu */
|
|
13
|
-
registerItem: (setFocused: () => void) => { index: number };
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface NavMenuPopoutContext {
|
|
17
|
-
state: {
|
|
18
|
-
visible: boolean;
|
|
19
|
-
};
|
|
20
|
-
anchorElement?: HTMLElement;
|
|
21
|
-
focusFirstElement?: () => void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface NavMenuGroupContext {
|
|
25
|
-
state: {
|
|
26
|
-
headerId: string;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface ItemState {
|
|
31
|
-
setFocused: () => void;
|
|
32
|
-
}
|
package/src/NavMenu/index.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import NavMenu from "./NavMenu.torp";
|
|
2
|
-
import NavMenuButton from "./NavMenuButton.torp";
|
|
3
|
-
import NavMenuElement from "./NavMenuElement.torp";
|
|
4
|
-
import NavMenuGroup from "./NavMenuGroup.torp";
|
|
5
|
-
import NavMenuGroupHeader from "./NavMenuGroupHeader.torp";
|
|
6
|
-
import NavMenuLink from "./NavMenuLink.torp";
|
|
7
|
-
import NavMenuPopout from "./NavMenuPopout.torp";
|
|
8
|
-
import NavMenuPopoutButton from "./NavMenuPopoutButton.torp";
|
|
9
|
-
import NavMenuPopoutContent from "./NavMenuPopoutContent.torp";
|
|
10
|
-
import NavMenuSeparator from "./NavMenuSeparator.torp";
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
NavMenu,
|
|
14
|
-
NavMenuLink,
|
|
15
|
-
NavMenuButton,
|
|
16
|
-
NavMenuElement,
|
|
17
|
-
NavMenuPopout,
|
|
18
|
-
NavMenuPopoutButton,
|
|
19
|
-
NavMenuPopoutContent,
|
|
20
|
-
NavMenuGroup,
|
|
21
|
-
NavMenuGroupHeader,
|
|
22
|
-
NavMenuSeparator,
|
|
23
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { ClassValue, StyleValue } from "@torpor/view";
|
|
2
|
-
import { NotificationContextName, type NotificationContext } from "./NotificationTypes";
|
|
3
|
-
|
|
4
|
-
interface NotificationProps {
|
|
5
|
-
/** An ID for the root element */
|
|
6
|
-
id?: string;
|
|
7
|
-
/** Classes for the root element */
|
|
8
|
-
class?: ClassValue,
|
|
9
|
-
/** Styles for the root element */
|
|
10
|
-
style?: StyleValue,
|
|
11
|
-
/** Whether the notification is visible */
|
|
12
|
-
visible?: boolean,
|
|
13
|
-
/** The duration, in milliseconds, to keep the notification visible */
|
|
14
|
-
duration?: number,
|
|
15
|
-
/** Raised when the notification has closed, either after the duration has elapsed, or when the user has pressed the close button */
|
|
16
|
-
onclose?: () => void,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* An element that displays a brief, important message in a way that attracts
|
|
21
|
-
* the user's attention without interrupting the user's task.
|
|
22
|
-
*
|
|
23
|
-
* See [the WAI ARIA guidelines for Alerts](https://www.w3.org/WAI/ARIA/apg/patterns/alert/).
|
|
24
|
-
*/
|
|
25
|
-
export default function Notification($props: NotificationProps | undefined) {
|
|
26
|
-
let defaultDuration = 5000;
|
|
27
|
-
|
|
28
|
-
let $state = $watch({
|
|
29
|
-
visible: false
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
$run(() => {
|
|
33
|
-
$state.visible = $props?.visible ?? true;
|
|
34
|
-
});
|
|
35
|
-
$run(() => {
|
|
36
|
-
if ($props !== undefined) {
|
|
37
|
-
$props.visible = $state.visible;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// Set the context to pass down to items
|
|
42
|
-
let context: NotificationContext = {
|
|
43
|
-
closeNotification
|
|
44
|
-
};
|
|
45
|
-
$context[NotificationContextName] = context;
|
|
46
|
-
|
|
47
|
-
$mount(() => {
|
|
48
|
-
setTimeout(closeNotification, $props?.duration ?? defaultDuration);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
function closeNotification() {
|
|
52
|
-
$state.visible = false;
|
|
53
|
-
|
|
54
|
-
if ($props?.onclose) {
|
|
55
|
-
$props?.onclose();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@render {
|
|
60
|
-
@if ($state.visible) {
|
|
61
|
-
<div
|
|
62
|
-
{$props?.id}
|
|
63
|
-
class={["torp-notification", $props?.class]}
|
|
64
|
-
{$props?.style}
|
|
65
|
-
role="alert"
|
|
66
|
-
>
|
|
67
|
-
<slot />
|
|
68
|
-
</div>
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { ClassValue, StyleValue } from "@torpor/view";
|
|
2
|
-
import { NotificationContextName, type NotificationContext } from "./NotificationTypes";
|
|
3
|
-
|
|
4
|
-
interface NotificationCloseProps {
|
|
5
|
-
/** An ID for the root element */
|
|
6
|
-
id?: string;
|
|
7
|
-
/** Classes for the root element */
|
|
8
|
-
class?: ClassValue,
|
|
9
|
-
/** Styles for the root element */
|
|
10
|
-
style?: StyleValue,
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The button that a user can press to close this Notification.
|
|
15
|
-
*/
|
|
16
|
-
export default function NotificationClose($props: NotificationCloseProps | undefined) {
|
|
17
|
-
// Get stuff out of the NotificationContext
|
|
18
|
-
const context = $context[NotificationContextName] as NotificationContext;
|
|
19
|
-
if (!context) {
|
|
20
|
-
throw new Error("NotificationClose must be contained within a Notification");
|
|
21
|
-
}
|
|
22
|
-
const { closeNotification } = context;
|
|
23
|
-
|
|
24
|
-
function handleClick() {
|
|
25
|
-
closeNotification();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@render {
|
|
29
|
-
<button
|
|
30
|
-
{$props?.id}
|
|
31
|
-
class={["torp-notification-close", $props?.class]}
|
|
32
|
-
{$props?.style}
|
|
33
|
-
type="button"
|
|
34
|
-
onclick={handleClick}
|
|
35
|
-
>
|
|
36
|
-
<slot />
|
|
37
|
-
</button>
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { ClassValue, StyleValue } from "@torpor/view";
|
|
2
|
-
|
|
3
|
-
interface NotificationContainerProps {
|
|
4
|
-
/** An ID for the root element */
|
|
5
|
-
id?: string;
|
|
6
|
-
/** Classes for the root element */
|
|
7
|
-
class?: ClassValue,
|
|
8
|
-
/** Styles for the root element */
|
|
9
|
-
style?: StyleValue,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The container for one or more Notifications, which can be used to position
|
|
14
|
-
* the notifications inside the viewport.
|
|
15
|
-
*/
|
|
16
|
-
export default function NotificationContainer($props: NotificationContainerProps | undefined) {
|
|
17
|
-
@render {
|
|
18
|
-
<div
|
|
19
|
-
{$props?.id}
|
|
20
|
-
class={["torp-notification-container", $props?.class]}
|
|
21
|
-
{$props?.style}
|
|
22
|
-
>
|
|
23
|
-
<slot />
|
|
24
|
-
</div>
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { ClassValue, StyleValue } from "@torpor/view";
|
|
2
|
-
|
|
3
|
-
interface NotificationContentProps {
|
|
4
|
-
/** An ID for the root element */
|
|
5
|
-
id?: string;
|
|
6
|
-
/** Classes for the root element */
|
|
7
|
-
class?: ClassValue,
|
|
8
|
-
/** Styles for the root element */
|
|
9
|
-
style?: StyleValue,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The content to display within a Notification.
|
|
14
|
-
*/
|
|
15
|
-
export default function NotificationContent($props: NotificationContentProps | undefined) {
|
|
16
|
-
@render {
|
|
17
|
-
<div
|
|
18
|
-
{$props?.id}
|
|
19
|
-
class={["torp-notification-content", $props?.class]}
|
|
20
|
-
{$props?.style}
|
|
21
|
-
>
|
|
22
|
-
<slot />
|
|
23
|
-
</div>
|
|
24
|
-
}
|
|
25
|
-
}
|