@torpor/ui 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/dist/Accordion/Accordion.torp +44 -25
- package/dist/Accordion/AccordionContent.torp +18 -12
- package/dist/Accordion/AccordionHeader.torp +15 -8
- package/dist/Accordion/AccordionItem.torp +34 -17
- package/dist/Accordion/AccordionTrigger.torp +17 -10
- package/dist/Accordion/AccordionTypes.ts +6 -3
- package/dist/Accordion/index.d.ts +100 -35
- package/dist/Breadcrumb/Breadcrumb.torp +18 -10
- package/dist/Breadcrumb/BreadcrumbItem.torp +14 -7
- package/dist/Breadcrumb/BreadcrumbSeparator.torp +10 -3
- package/dist/Breadcrumb/index.d.ts +50 -21
- package/dist/Calendar/Calendar.torp +21 -14
- package/dist/Calendar/CalendarDay.torp +12 -4
- package/dist/Calendar/index.d.ts +16 -18
- package/dist/Contextual/Contextual.torp +125 -0
- package/dist/{Popover/PopoverContentContextual.torp → Contextual/ContextualContent.torp} +21 -12
- package/dist/Contextual/ContextualTrigger.torp +66 -0
- package/dist/Contextual/ContextualTypes.ts +30 -0
- package/dist/Contextual/index.d.ts +90 -0
- package/dist/Contextual/index.js +14 -0
- package/dist/Contextual/index.js.map +1 -0
- package/dist/Dialog/Dialog.torp +49 -73
- package/dist/Dialog/DialogBody.torp +15 -9
- package/dist/Dialog/DialogButton.torp +27 -13
- package/dist/Dialog/DialogFooter.torp +11 -3
- package/dist/Dialog/DialogHeader.torp +15 -8
- package/dist/Dialog/DialogTypes.ts +3 -2
- package/dist/Dialog/index.d.ts +83 -35
- package/dist/Disclosure/Disclosure.torp +34 -25
- package/dist/Disclosure/DisclosureContent.torp +18 -12
- package/dist/Disclosure/DisclosureHeader.torp +16 -9
- package/dist/Disclosure/DisclosureTrigger.torp +15 -8
- package/dist/Disclosure/DisclosureTypes.ts +0 -1
- package/dist/Disclosure/index.d.ts +67 -28
- package/dist/Drawer/Drawer.torp +109 -68
- package/dist/Drawer/DrawerContent.torp +80 -0
- package/dist/Drawer/DrawerOverlay.torp +38 -0
- package/dist/Drawer/DrawerTrigger.torp +35 -0
- package/dist/Drawer/DrawerTypes.ts +24 -0
- package/dist/Drawer/index.d.ts +96 -8
- package/dist/Drawer/index.js +13 -1
- package/dist/Form/Field.torp +91 -0
- package/dist/Form/Form.torp +129 -0
- package/dist/Form/FormTypes.ts +30 -0
- package/dist/Form/Input.torp +97 -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 +131 -0
- package/dist/Form/index.js +22 -0
- package/dist/Form/index.js.map +1 -0
- package/dist/Menu/Menu.torp +25 -15
- package/dist/Menu/MenuButton.torp +30 -13
- package/dist/Menu/MenuCheck.torp +29 -14
- package/dist/Menu/MenuGroup.torp +14 -6
- package/dist/Menu/MenuIndicator.torp +14 -7
- package/dist/Menu/MenuPopout.torp +23 -15
- package/dist/Menu/MenuPopoutContent.torp +17 -10
- package/dist/Menu/MenuPopoutTrigger.torp +23 -16
- package/dist/Menu/MenuRadio.torp +27 -16
- package/dist/Menu/MenuRadioGroup.torp +34 -15
- package/dist/Menu/MenuSeparator.torp +11 -3
- package/dist/Menu/MenuTypes.ts +7 -5
- package/dist/Menu/index.d.ts +176 -77
- package/dist/MenuBar/MenuBar.torp +24 -16
- package/dist/MenuBar/MenuBarItem.torp +24 -16
- package/dist/MenuBar/MenuBarItemContent.torp +18 -11
- package/dist/MenuBar/MenuBarItemTrigger.torp +15 -9
- package/dist/MenuBar/index.d.ts +79 -28
- package/dist/Modal/Modal.torp +118 -0
- package/dist/Modal/ModalContent.torp +77 -0
- package/dist/Modal/ModalOverlay.torp +38 -0
- package/dist/Modal/ModalTrigger.torp +50 -0
- package/dist/Modal/ModalTypes.ts +22 -0
- package/dist/Modal/index.d.ts +108 -0
- package/dist/Modal/index.js +33 -0
- package/dist/Modal/index.js.map +1 -0
- package/dist/Modal/showModal.ts +19 -0
- package/dist/Modal/showPrompt.ts +23 -0
- package/dist/NavMenu/NavMenu.torp +18 -10
- package/dist/NavMenu/NavMenuButton.torp +15 -10
- package/dist/NavMenu/NavMenuElement.torp +19 -11
- package/dist/NavMenu/NavMenuGroup.torp +13 -6
- package/dist/NavMenu/NavMenuGroupHeader.torp +15 -8
- package/dist/NavMenu/NavMenuLink.torp +21 -16
- package/dist/NavMenu/NavMenuPopout.torp +34 -18
- package/dist/NavMenu/NavMenuPopoutButton.torp +23 -18
- package/dist/NavMenu/NavMenuPopoutContent.torp +23 -13
- package/dist/NavMenu/NavMenuSeparator.torp +10 -3
- package/dist/NavMenu/index.d.ts +153 -70
- package/dist/Notification/Notification.torp +35 -16
- package/dist/Notification/NotificationClose.torp +10 -3
- package/dist/Notification/NotificationContainer.torp +11 -3
- package/dist/Notification/NotificationContent.torp +11 -3
- package/dist/Notification/index.d.ts +46 -28
- package/dist/Popover/Popover.torp +48 -28
- package/dist/Popover/PopoverContent.torp +42 -8
- package/dist/Popover/PopoverTrigger.torp +32 -3
- package/dist/Popover/PopoverTypes.ts +1 -1
- package/dist/Popover/index.d.ts +48 -111
- package/dist/Popover/index.js +1 -163
- package/dist/Popover/index.js.map +1 -1
- package/dist/TabGroup/TabContent.torp +20 -11
- package/dist/TabGroup/TabGroup.torp +58 -40
- package/dist/TabGroup/TabGroupTypes.ts +10 -5
- package/dist/TabGroup/TabHeader.torp +26 -10
- package/dist/TabGroup/TabList.torp +14 -7
- package/dist/TabGroup/TabTrigger.torp +17 -10
- package/dist/TabGroup/index.d.ts +101 -35
- package/dist/icons/ArrowDown.torp +5 -3
- package/dist/icons/ArrowLeft.torp +5 -3
- package/dist/icons/ArrowRight.torp +5 -3
- package/dist/icons/ArrowUp.torp +5 -3
- package/dist/icons/Bars.torp +5 -3
- package/dist/icons/Check.torp +5 -3
- package/dist/icons/ChevronDown.torp +5 -3
- package/dist/icons/ChevronLeft.torp +5 -3
- package/dist/icons/ChevronRight.torp +5 -3
- package/dist/icons/ChevronUp.torp +5 -3
- package/dist/icons/Cross.torp +5 -3
- package/dist/icons/IconTypes.ts +6 -0
- package/dist/icons/Loading.torp +5 -3
- package/dist/icons/Minus.torp +5 -3
- package/dist/icons/Plus.torp +5 -3
- package/dist/icons/index.d.ts +271 -126
- package/dist/index.d.ts +17 -4
- package/dist/metafile-esm.json +1 -1
- package/dist/motion/fade.ts +15 -6
- package/dist/motion/grow.ts +23 -0
- package/dist/motion/index.d.ts +19 -2
- package/dist/motion/index.js +93 -3
- package/dist/motion/index.js.map +1 -1
- package/dist/motion/measure.ts +28 -0
- package/dist/motion/slide.ts +45 -0
- package/dist/mount/clickPopover.ts +51 -0
- package/dist/mount/contextPopover.ts +51 -0
- package/dist/mount/hoverPopover.ts +58 -0
- package/package.json +28 -12
- package/scripts/postbuild.ts +11 -1
- package/src/Accordion/Accordion.torp +44 -25
- package/src/Accordion/AccordionContent.torp +18 -12
- package/src/Accordion/AccordionHeader.torp +15 -8
- package/src/Accordion/AccordionItem.torp +34 -17
- package/src/Accordion/AccordionTrigger.torp +17 -10
- package/src/Accordion/AccordionTypes.ts +6 -3
- package/src/Breadcrumb/Breadcrumb.torp +18 -10
- package/src/Breadcrumb/BreadcrumbItem.torp +14 -7
- package/src/Breadcrumb/BreadcrumbSeparator.torp +10 -3
- package/src/Calendar/Calendar.torp +21 -14
- package/src/Calendar/CalendarDay.torp +12 -4
- package/src/Contextual/Contextual.torp +125 -0
- package/src/{Popover/PopoverContentContextual.torp → Contextual/ContextualContent.torp} +21 -12
- package/src/Contextual/ContextualTrigger.torp +66 -0
- package/src/Contextual/ContextualTypes.ts +30 -0
- package/src/Contextual/index.ts +5 -0
- package/src/Dialog/Dialog.torp +49 -73
- package/src/Dialog/DialogBody.torp +15 -9
- package/src/Dialog/DialogButton.torp +27 -13
- package/src/Dialog/DialogFooter.torp +11 -3
- package/src/Dialog/DialogHeader.torp +15 -8
- package/src/Dialog/DialogTypes.ts +3 -2
- package/src/Disclosure/Disclosure.torp +34 -25
- package/src/Disclosure/DisclosureContent.torp +18 -12
- package/src/Disclosure/DisclosureHeader.torp +16 -9
- package/src/Disclosure/DisclosureTrigger.torp +15 -8
- package/src/Disclosure/DisclosureTypes.ts +0 -1
- package/src/Drawer/Drawer.torp +109 -68
- package/src/Drawer/DrawerContent.torp +80 -0
- package/src/Drawer/DrawerOverlay.torp +38 -0
- package/src/Drawer/DrawerTrigger.torp +35 -0
- package/src/Drawer/DrawerTypes.ts +24 -0
- package/src/Drawer/index.ts +4 -1
- package/src/Form/Field.torp +91 -0
- package/src/Form/Form.torp +129 -0
- package/src/Form/FormTypes.ts +30 -0
- package/src/Form/Input.torp +97 -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 +25 -15
- package/src/Menu/MenuButton.torp +30 -13
- package/src/Menu/MenuCheck.torp +29 -14
- package/src/Menu/MenuGroup.torp +14 -6
- package/src/Menu/MenuIndicator.torp +14 -7
- package/src/Menu/MenuPopout.torp +23 -15
- package/src/Menu/MenuPopoutContent.torp +17 -10
- package/src/Menu/MenuPopoutTrigger.torp +23 -16
- package/src/Menu/MenuRadio.torp +27 -16
- package/src/Menu/MenuRadioGroup.torp +34 -15
- package/src/Menu/MenuSeparator.torp +11 -3
- package/src/Menu/MenuTypes.ts +7 -5
- package/src/MenuBar/MenuBar.torp +24 -16
- package/src/MenuBar/MenuBarItem.torp +24 -16
- package/src/MenuBar/MenuBarItemContent.torp +18 -11
- package/src/MenuBar/MenuBarItemTrigger.torp +15 -9
- package/src/Modal/Modal.torp +118 -0
- package/src/Modal/ModalContent.torp +77 -0
- package/src/Modal/ModalOverlay.torp +38 -0
- package/src/Modal/ModalTrigger.torp +50 -0
- package/src/Modal/ModalTypes.ts +22 -0
- package/src/Modal/index.ts +10 -0
- package/src/Modal/showModal.ts +19 -0
- package/src/Modal/showPrompt.ts +23 -0
- package/src/NavMenu/NavMenu.torp +18 -10
- package/src/NavMenu/NavMenuButton.torp +15 -10
- package/src/NavMenu/NavMenuElement.torp +19 -11
- package/src/NavMenu/NavMenuGroup.torp +13 -6
- package/src/NavMenu/NavMenuGroupHeader.torp +15 -8
- package/src/NavMenu/NavMenuLink.torp +21 -16
- package/src/NavMenu/NavMenuPopout.torp +34 -18
- package/src/NavMenu/NavMenuPopoutButton.torp +23 -18
- package/src/NavMenu/NavMenuPopoutContent.torp +23 -13
- package/src/NavMenu/NavMenuSeparator.torp +10 -3
- package/src/Notification/Notification.torp +35 -16
- package/src/Notification/NotificationClose.torp +10 -3
- package/src/Notification/NotificationContainer.torp +11 -3
- package/src/Notification/NotificationContent.torp +11 -3
- package/src/Popover/Popover.torp +48 -28
- package/src/Popover/PopoverContent.torp +42 -8
- package/src/Popover/PopoverTrigger.torp +32 -3
- package/src/Popover/PopoverTypes.ts +1 -1
- package/src/Popover/index.ts +1 -24
- package/src/Slider/Slider.torp +3 -3
- package/src/TabGroup/TabContent.torp +20 -11
- package/src/TabGroup/TabGroup.torp +58 -40
- package/src/TabGroup/TabGroupTypes.ts +10 -5
- package/src/TabGroup/TabHeader.torp +26 -10
- package/src/TabGroup/TabList.torp +14 -7
- package/src/TabGroup/TabTrigger.torp +17 -10
- package/src/icons/ArrowDown.torp +5 -3
- package/src/icons/ArrowLeft.torp +5 -3
- package/src/icons/ArrowRight.torp +5 -3
- package/src/icons/ArrowUp.torp +5 -3
- package/src/icons/Bars.torp +5 -3
- package/src/icons/Check.torp +5 -3
- package/src/icons/ChevronDown.torp +5 -3
- package/src/icons/ChevronLeft.torp +5 -3
- package/src/icons/ChevronRight.torp +5 -3
- package/src/icons/ChevronUp.torp +5 -3
- package/src/icons/Cross.torp +5 -3
- package/src/icons/IconTypes.ts +6 -0
- package/src/icons/Loading.torp +5 -3
- package/src/icons/Minus.torp +5 -3
- package/src/icons/Plus.torp +5 -3
- package/src/motion/fade.ts +15 -6
- package/src/motion/grow.ts +23 -0
- package/src/motion/index.ts +4 -1
- package/src/motion/measure.ts +28 -0
- package/src/motion/slide.ts +45 -0
- package/src/mount/clickPopover.ts +51 -0
- package/src/mount/contextPopover.ts +51 -0
- package/src/mount/hoverPopover.ts +58 -0
- package/test/Accordion/components/AccordionAccessibility.torp +1 -1
- package/test/Accordion/components/AccordionKeyboard.torp +1 -1
- package/test/Accordion/components/AccordionList.torp +1 -1
- package/test/Accordion/components/AccordionMultiple.torp +2 -2
- package/test/Accordion/components/AccordionSingle.torp +2 -2
- package/test/Dialog/accessibility-modal.test.ts +2 -2
- package/test/Dialog/components/DialogAccessibility.torp +8 -14
- package/test/Dialog/components/DialogFunction.torp +20 -4
- package/test/Dialog/components/DialogModal.torp +30 -0
- package/test/Dialog/components/DialogVariable.torp +7 -7
- package/test/Disclosure/accessibility.test.ts +3 -2
- package/test/Disclosure/components/DisclosureTest.torp +1 -1
- 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/Menu/components/MenuAccessibility.torp +5 -5
- package/test/Menu/components/MenuBasic.torp +5 -5
- 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/Notification/components/NotificationFunction.torp +0 -3
- package/test/Notification/components/NotificationVariable.torp +1 -1
- package/test/Popover/components/PopoverFunction.torp +37 -0
- package/test/Popover/components/PopoverTrigger.torp +36 -0
- package/test/Popover/components/{PromptVariable.torp → PopoverVariable.torp} +5 -3
- package/test/Popover/function.test.ts +2 -7
- package/test/Popover/trigger.test.ts +27 -0
- package/test/Popover/variable.test.ts +2 -2
- package/test/TabGroup/components/TabGroupAccessibility.torp +1 -1
- package/test/TabGroup/components/TabGroupKeyboard.torp +1 -1
- package/test/TabGroup/components/TabGroupList.torp +1 -1
- package/test/TabGroup/components/TabGroupTrigger.torp +1 -1
- package/tsup.config.ts +3 -1
- package/dist/Popover/PopoverContentAnchored.torp +0 -106
- package/dist/Popover/PopoverOverlay.torp +0 -30
- package/dist/Popover/PopoverTriggerContextual.torp +0 -37
- package/dist/Popover/PopoverTriggerHover.torp +0 -38
- package/dist/Popover/mountClickPopover.ts +0 -50
- package/dist/Popover/mountContextPopover.ts +0 -50
- package/dist/Popover/mountHoverPopover.ts +0 -57
- package/dist/Popover/showPopoverPrompt.ts +0 -23
- package/src/Popover/PopoverContentAnchored.torp +0 -106
- package/src/Popover/PopoverOverlay.torp +0 -30
- package/src/Popover/PopoverTriggerContextual.torp +0 -37
- package/src/Popover/PopoverTriggerHover.torp +0 -38
- package/src/Popover/mountClickPopover.ts +0 -50
- package/src/Popover/mountContextPopover.ts +0 -50
- package/src/Popover/mountHoverPopover.ts +0 -57
- package/src/Popover/showPopoverPrompt.ts +0 -23
- package/test/Dialog/components/CustomDialog.torp +0 -20
- package/test/Popover/components/PromptFunction.torp +0 -19
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { addDocumentEvent, removeDocumentEvent } from "../utils/documentEvents";
|
|
2
|
+
import { ModalContextName, type ModalContext } from "./ModalTypes";
|
|
3
|
+
|
|
4
|
+
interface ModalContentProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Class name(s) for the root element */
|
|
8
|
+
class?: string,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The content that is displayed for a Modal when it is open, displayed
|
|
13
|
+
* alongside an element.
|
|
14
|
+
*/
|
|
15
|
+
export default function ModalContent($props: ModalContentProps | undefined) {
|
|
16
|
+
let div: HTMLDivElement;
|
|
17
|
+
let shown = false;
|
|
18
|
+
let closeOnClick = false;
|
|
19
|
+
|
|
20
|
+
// Get stuff out of the ModalContext
|
|
21
|
+
const context = $context[ModalContextName] as ModalContext;
|
|
22
|
+
if (!context) {
|
|
23
|
+
throw new Error("ModalContent must be contained within a Modal");
|
|
24
|
+
}
|
|
25
|
+
let $state = context.state;
|
|
26
|
+
|
|
27
|
+
$run(() => {
|
|
28
|
+
if (!$state.visible) {
|
|
29
|
+
hide();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
function show() {
|
|
34
|
+
shown = true;
|
|
35
|
+
|
|
36
|
+
// HACK: Because this Modal could be shown with a click, we need to wait for another mousedown
|
|
37
|
+
// before we close on click. Otherwise the click immediately bubbles to the document
|
|
38
|
+
closeOnClick = false;
|
|
39
|
+
addDocumentEvent("mousedown", handleDocumentMouseDown);
|
|
40
|
+
addDocumentEvent("click", handleDocumentClick);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function hide() {
|
|
44
|
+
if (!shown) return;
|
|
45
|
+
|
|
46
|
+
removeDocumentEvent("mousedown", handleDocumentMouseDown);
|
|
47
|
+
removeDocumentEvent("click", handleDocumentClick);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function handleDocumentMouseDown() {
|
|
51
|
+
closeOnClick = true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function handleDocumentClick(e: MouseEvent) {
|
|
55
|
+
if (
|
|
56
|
+
closeOnClick &&
|
|
57
|
+
div &&
|
|
58
|
+
!div.contains(e.target as HTMLElement)
|
|
59
|
+
) {
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
context.handleClickOutside!(e);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@render {
|
|
66
|
+
@if ($state.visible) {
|
|
67
|
+
<div
|
|
68
|
+
{$props?.id}
|
|
69
|
+
class={`torp-modal-content ${$props?.class ?? ""}`.trim()}
|
|
70
|
+
&ref={div}
|
|
71
|
+
onmount={show}
|
|
72
|
+
>
|
|
73
|
+
<slot />
|
|
74
|
+
</div>
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { disableScroll } from "../mount/disableScroll";
|
|
2
|
+
import { ModalContextName, type ModalContext } from "./ModalTypes";
|
|
3
|
+
|
|
4
|
+
interface ModalOverlayProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Class name(s) for the root element */
|
|
8
|
+
class?: string,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The background overlay for a modal popup component (e.g. Context, Dialog or Popover).
|
|
13
|
+
* Adding an overlay automatically sets the component's `modal` value to true.
|
|
14
|
+
*/
|
|
15
|
+
export default function ModalOverlay($props: ModalOverlayProps | undefined) {
|
|
16
|
+
// Get stuff out of the ModalContext
|
|
17
|
+
const context = $context[ModalContextName] as ModalContext;
|
|
18
|
+
if (!context) {
|
|
19
|
+
throw new Error("ModalOverlay must be contained within a Modal");
|
|
20
|
+
}
|
|
21
|
+
let $state = context.state;
|
|
22
|
+
|
|
23
|
+
// Any popup with an overlay is modal
|
|
24
|
+
$state.modal = true;
|
|
25
|
+
|
|
26
|
+
@render {
|
|
27
|
+
@if ($state.visible) {
|
|
28
|
+
<div
|
|
29
|
+
{$props?.id}
|
|
30
|
+
class={`torp-modal-overlay ${$props?.class ?? ""}`.trim()}
|
|
31
|
+
tabindex="-1"
|
|
32
|
+
onmount={(el) => disableScroll(el)}
|
|
33
|
+
>
|
|
34
|
+
<slot />
|
|
35
|
+
</div>
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ModalContextName, type ModalContext } from "./ModalTypes";
|
|
2
|
+
import hoverTrigger from "../mount/hoverTrigger";
|
|
3
|
+
|
|
4
|
+
interface ModalTriggerProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Class name(s) for the root element */
|
|
8
|
+
class?: string,
|
|
9
|
+
/** Whether the modal is activated by click/press or by hover **/
|
|
10
|
+
activation?: "press" | "hover"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The button that causes a Modal to appear or disappear.
|
|
15
|
+
*/
|
|
16
|
+
export default function ModalTrigger($props: ModalTriggerProps | undefined) {
|
|
17
|
+
let activation = $props?.activation ?? "press";
|
|
18
|
+
|
|
19
|
+
// Get stuff out of the ModalContext
|
|
20
|
+
const context = $context[ModalContextName] as ModalContext;
|
|
21
|
+
if (!context) {
|
|
22
|
+
throw new Error("ModalTrigger must be contained within a Modal");
|
|
23
|
+
}
|
|
24
|
+
let $state = context.state;
|
|
25
|
+
|
|
26
|
+
function handleClick() {
|
|
27
|
+
if (activation !== "press") return;
|
|
28
|
+
|
|
29
|
+
$state.visible = !$state.visible;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function handleHover() {
|
|
33
|
+
if (activation !== "hover") return;
|
|
34
|
+
|
|
35
|
+
$state.visible = !$state.visible
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@render {
|
|
39
|
+
<button
|
|
40
|
+
type="button"
|
|
41
|
+
{$props?.id}
|
|
42
|
+
class={`torp-modal-trigger ${$props?.class ?? ""}`.trim()}
|
|
43
|
+
onclick={handleClick}
|
|
44
|
+
onmount={(el) => hoverTrigger(el, { onHover: handleHover, onExit: handleHover })}
|
|
45
|
+
&ref={context.anchorElement}
|
|
46
|
+
>
|
|
47
|
+
<slot />
|
|
48
|
+
</button>
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const ModalContextName = "Modal";
|
|
2
|
+
|
|
3
|
+
/** The shared context for modal components (Contextual, Prompt and Modal) */
|
|
4
|
+
export interface ModalContext {
|
|
5
|
+
handleButton: (type: "confirm" | "cancel" | undefined, value?: any) => void;
|
|
6
|
+
// HACK: We need to be able to let children (i.e. Dialogs) override the click outside functionality
|
|
7
|
+
// There may be a more elegant way to accomplish this too
|
|
8
|
+
handleClickOutside?: (e: MouseEvent) => void;
|
|
9
|
+
state: ModalState;
|
|
10
|
+
// HACK: focusFirstElement is necessary because if we focus the first element e.g. in a Dialog's
|
|
11
|
+
// onMount, it will scroll the page to the focused element and mess up our careful positioning
|
|
12
|
+
// We need to be able to manually set the order to
|
|
13
|
+
// 1. set visible (so we have an element with content)
|
|
14
|
+
// 2. set position (so the element is in the right place)
|
|
15
|
+
// 3. set focus (for accessibility)
|
|
16
|
+
// There may be a more elegant way to accomplish this!
|
|
17
|
+
focusFirstElement?: () => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ModalState {
|
|
21
|
+
visible: boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Modal from "./Modal.torp";
|
|
2
|
+
import ModalContent from "./ModalContent.torp";
|
|
3
|
+
import ModalOverlay from "./ModalOverlay.torp";
|
|
4
|
+
import ModalTrigger from "./ModalTrigger.torp";
|
|
5
|
+
import showModal from "./showModal";
|
|
6
|
+
import showPrompt from "./showPrompt";
|
|
7
|
+
|
|
8
|
+
export { Modal, ModalContent, ModalOverlay, ModalTrigger };
|
|
9
|
+
|
|
10
|
+
export { showModal, showPrompt };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// TODO: Allow passing in a variable -- so that you can show an inline modal
|
|
2
|
+
import type { Component } from "@torpor/view";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Shows a modal component in code.
|
|
6
|
+
* @param modal The modal component
|
|
7
|
+
* @param props The properties for the modal component
|
|
8
|
+
* @param target The target element to show the modal in
|
|
9
|
+
* @returns The value selected by the user
|
|
10
|
+
*/
|
|
11
|
+
export default function showModal(
|
|
12
|
+
modal: Component,
|
|
13
|
+
props?: Record<PropertyKey, any>,
|
|
14
|
+
target?: Element,
|
|
15
|
+
): void {
|
|
16
|
+
// Create the modal
|
|
17
|
+
// TODO: This needs to clean up after itself, like the mount methods do
|
|
18
|
+
modal(target || document.body, null, props);
|
|
19
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Component } from "@torpor/view";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shows a modal component in code, and asynchronously returns the value selected by the user.
|
|
5
|
+
* @param modal The modal component
|
|
6
|
+
* @param props The properties for the modal component
|
|
7
|
+
* @param target The target element to show the modal in
|
|
8
|
+
* @returns The value selected by the user
|
|
9
|
+
*/
|
|
10
|
+
export default function showPrompt(
|
|
11
|
+
modal: Component,
|
|
12
|
+
props?: Record<PropertyKey, any>,
|
|
13
|
+
target?: Element,
|
|
14
|
+
): Promise<any> {
|
|
15
|
+
return new Promise((resolve) => {
|
|
16
|
+
// Add the promise as the callback
|
|
17
|
+
const allProps = Object.assign({}, props, { callback: resolve });
|
|
18
|
+
|
|
19
|
+
// Create the modal
|
|
20
|
+
// TODO: This needs to clean up after itself, like the use methods do
|
|
21
|
+
modal(target || document.body, null, allProps);
|
|
22
|
+
});
|
|
23
|
+
}
|
package/src/NavMenu/NavMenu.torp
CHANGED
|
@@ -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,12 +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:
|
|
29
|
-
$props
|
|
36
|
+
export default function NavMenu($props: NavMenuProps | undefined) {
|
|
37
|
+
let orientation = $props?.orientation ?? "horizontal";
|
|
30
38
|
|
|
31
39
|
// A collection containing the state and some functions for each item
|
|
32
40
|
let itemStates: ItemState[] = [];
|
|
@@ -51,7 +59,7 @@ export default function NavMenu($props: any) {
|
|
|
51
59
|
$context[NavMenuContextName] = context;
|
|
52
60
|
|
|
53
61
|
// If the NavMenu is not in a popout, focus its first item. Otherwise the popout will call focusFirstElement, below
|
|
54
|
-
function handleFocus(
|
|
62
|
+
function handleFocus() {
|
|
55
63
|
if (!popoutContext && itemStates.length) {
|
|
56
64
|
itemStates[0].setFocused();
|
|
57
65
|
}
|
|
@@ -164,12 +172,12 @@ export default function NavMenu($props: any) {
|
|
|
164
172
|
|
|
165
173
|
@render {
|
|
166
174
|
<nav
|
|
167
|
-
{$props
|
|
168
|
-
class={`torp-nav-menu ${$props
|
|
175
|
+
{$props?.id}
|
|
176
|
+
class={`torp-nav-menu ${$props?.class ?? ""}`.trim()}
|
|
169
177
|
tabindex="0"
|
|
170
178
|
role="menubar"
|
|
171
|
-
aria-label={$props
|
|
172
|
-
aria-orientation={
|
|
179
|
+
aria-label={$props?.ariaLabel}
|
|
180
|
+
aria-orientation={orientation}
|
|
173
181
|
onfocus={handleFocus}
|
|
174
182
|
>
|
|
175
183
|
<slot />
|
|
@@ -1,14 +1,19 @@
|
|
|
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
|
-
/** Set when the item is disabled */
|
|
10
|
-
let dataDisabled = $props.disabled || undefined;
|
|
11
|
-
|
|
16
|
+
export default function NavMenuButton($props: NavMenuButtonProps | undefined) {
|
|
12
17
|
let button: HTMLButtonElement;
|
|
13
18
|
|
|
14
19
|
// Get stuff out of the NavMenuContext
|
|
@@ -27,13 +32,13 @@ export default function NavMenuButton($props: any) {
|
|
|
27
32
|
|
|
28
33
|
@render {
|
|
29
34
|
<button
|
|
30
|
-
{$props
|
|
31
|
-
class={`torp-nav-menu-button ${$props
|
|
35
|
+
{$props?.id}
|
|
36
|
+
class={`torp-nav-menu-button ${$props?.class ?? ""}`.trim()}
|
|
32
37
|
type="button"
|
|
33
|
-
{$props
|
|
38
|
+
{$props?.disabled}
|
|
34
39
|
role="menuitem"
|
|
35
|
-
aria-disabled={$props
|
|
36
|
-
data-disabled={
|
|
40
|
+
aria-disabled={$props?.disabled ? "true" : undefined}
|
|
41
|
+
data-disabled={$props?.disabled ? "true" : undefined}
|
|
37
42
|
onkeydown
|
|
38
43
|
onkeydown={handleItemKey}
|
|
39
44
|
onclick
|
|
@@ -1,15 +1,21 @@
|
|
|
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
|
-
/** Set when the item is disabled */
|
|
11
|
-
let dataDisabled = $props.disabled || undefined;
|
|
12
|
-
|
|
18
|
+
export default function NavMenuElement($props: NavMenuElementProps | undefined) {
|
|
13
19
|
// Get stuff out of the NavMenuContext
|
|
14
20
|
const menuContext = $context[NavMenuContextName] as NavMenuContext;
|
|
15
21
|
if (!menuContext) {
|
|
@@ -21,17 +27,19 @@ export default function NavMenuElement($props: any) {
|
|
|
21
27
|
const { index } = registerItem(setFocused);
|
|
22
28
|
|
|
23
29
|
function setFocused() {
|
|
24
|
-
element
|
|
30
|
+
if ($props?.element) {
|
|
31
|
+
$props.element.focus();
|
|
32
|
+
}
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
@render {
|
|
28
36
|
<div
|
|
29
|
-
{$props
|
|
30
|
-
class={`torp-nav-menu-div ${$props
|
|
37
|
+
{$props?.id}
|
|
38
|
+
class={`torp-nav-menu-div ${$props?.class ?? ""}`.trim()}
|
|
31
39
|
type="div"
|
|
32
40
|
role="menuitem"
|
|
33
|
-
aria-disabled={$props
|
|
34
|
-
data-disabled={
|
|
41
|
+
aria-disabled={$props?.disabled ? "true" : undefined}
|
|
42
|
+
data-disabled={$props?.disabled ? "true" : undefined}
|
|
35
43
|
onkeydown
|
|
36
44
|
onkeydown={handleItemKey}
|
|
37
45
|
onclick
|
|
@@ -1,11 +1,18 @@
|
|
|
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 | undefined) {
|
|
9
16
|
let $state = $watch({
|
|
10
17
|
headerId: ""
|
|
11
18
|
});
|
|
@@ -18,10 +25,10 @@ export default function NavMenuGroup($props: any) {
|
|
|
18
25
|
|
|
19
26
|
@render {
|
|
20
27
|
<div
|
|
21
|
-
{$props
|
|
22
|
-
class={`torp-nav-menu-group ${$props
|
|
28
|
+
{$props?.id}
|
|
29
|
+
class={`torp-nav-menu-group ${$props?.class ?? ""}`.trim()}
|
|
23
30
|
role="group"
|
|
24
|
-
aria-label={$props
|
|
31
|
+
aria-label={$props?.ariaLabel}
|
|
25
32
|
aria-labelledby={$state.headerId}
|
|
26
33
|
>
|
|
27
34
|
<slot />
|
|
@@ -1,13 +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:
|
|
10
|
-
|
|
16
|
+
export default function NavMenuGroupHeader($props: NavMenuGroupHeaderProps | undefined) {
|
|
17
|
+
let defaultId = getId();
|
|
11
18
|
|
|
12
19
|
const context = $context[NavMenuGroupContextName] as NavMenuGroupContext;
|
|
13
20
|
if (!context) {
|
|
@@ -16,13 +23,13 @@ export default function NavMenuGroupHeader($props: any) {
|
|
|
16
23
|
let $state = context.state;
|
|
17
24
|
|
|
18
25
|
// Set the header ID now that we know what it is
|
|
19
|
-
$state.headerId = $props
|
|
26
|
+
$state.headerId = $props?.id ?? defaultId;
|
|
20
27
|
|
|
21
28
|
@render {
|
|
29
|
+
@// TODO: self={$props.as}
|
|
22
30
|
<h4
|
|
23
|
-
|
|
24
|
-
{$props
|
|
25
|
-
class={`torp-nav-menu-group-header ${$props.class ?? ""}`.trim()}
|
|
31
|
+
id={$props?.id ?? defaultId}
|
|
32
|
+
class={`torp-nav-menu-group-header ${$props?.class ?? ""}`.trim()}
|
|
26
33
|
>
|
|
27
34
|
<slot />
|
|
28
35
|
</h4>
|
|
@@ -1,19 +1,24 @@
|
|
|
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:
|
|
12
|
-
$props.newWindow ??= false;
|
|
13
|
-
|
|
14
|
-
/** Set when the item is disabled */
|
|
15
|
-
let dataDisabled = $props.disabled || undefined;
|
|
16
|
-
|
|
21
|
+
export default function NavMenuLink($props: NavMenuLinkProps | undefined) {
|
|
17
22
|
let link: HTMLAnchorElement;
|
|
18
23
|
|
|
19
24
|
// Get stuff out of the NavMenuContext
|
|
@@ -32,14 +37,14 @@ export default function NavMenuLink($props: any) {
|
|
|
32
37
|
|
|
33
38
|
@render {
|
|
34
39
|
<a
|
|
35
|
-
{$props
|
|
36
|
-
class={`torp-nav-menu-link ${$props
|
|
37
|
-
|
|
38
|
-
{$props
|
|
39
|
-
target={$props
|
|
40
|
+
{$props?.id}
|
|
41
|
+
class={`torp-nav-menu-link ${$props?.class ?? ""}`.trim()}
|
|
42
|
+
{$props?.href}
|
|
43
|
+
{$props?.disabled}
|
|
44
|
+
target={$props?.newWindow ? "_blank" : undefined}
|
|
40
45
|
role="menuitem"
|
|
41
|
-
aria-disabled={$props
|
|
42
|
-
data-disabled={
|
|
46
|
+
aria-disabled={$props?.disabled ? "true" : undefined}
|
|
47
|
+
data-disabled={$props?.disabled ? "true" : undefined}
|
|
43
48
|
onkeydown
|
|
44
49
|
onkeydown={handleItemKey}
|
|
45
50
|
onclick
|
|
@@ -1,5 +1,20 @@
|
|
|
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
|
+
/** Raised when the popout is opened or closed */
|
|
11
|
+
ontoggle?: (open: boolean) => void,
|
|
12
|
+
/** Raised when the popout has opened */
|
|
13
|
+
onopen?: () => void,
|
|
14
|
+
/** Raised when the popout has closed */
|
|
15
|
+
onclose?: (result: any) => void,
|
|
16
|
+
}
|
|
17
|
+
|
|
3
18
|
/**
|
|
4
19
|
* A popout that is attached to a menu button and can be used to show a submenu.
|
|
5
20
|
*
|
|
@@ -7,18 +22,24 @@ import { NavMenuPopoutContextName, type NavMenuPopoutContext } from "./NavMenuTy
|
|
|
7
22
|
*
|
|
8
23
|
* ```
|
|
9
24
|
* <NavMenuPopout>
|
|
10
|
-
*
|
|
25
|
+
* <NavMenuPopoutButton />
|
|
11
26
|
* <NavMenuPopoutContent />
|
|
12
27
|
* </NavMenuPopout>
|
|
13
28
|
* ```
|
|
14
|
-
*
|
|
15
|
-
* @prop {boolean} visible -- Whether the popout is visible
|
|
16
29
|
*/
|
|
17
|
-
export default function NavMenuPopout($props:
|
|
18
|
-
$props.visible ??= false;
|
|
19
|
-
|
|
30
|
+
export default function NavMenuPopout($props: NavMenuPopoutProps | undefined) {
|
|
20
31
|
let $state = $watch({
|
|
21
|
-
visible:
|
|
32
|
+
visible: false
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Sync props and state
|
|
36
|
+
$run(() => {
|
|
37
|
+
$state.visible = $props?.visible ?? false;
|
|
38
|
+
});
|
|
39
|
+
$run(() => {
|
|
40
|
+
if ($props !== undefined) {
|
|
41
|
+
$props.visible = $state.visible;
|
|
42
|
+
}
|
|
22
43
|
});
|
|
23
44
|
|
|
24
45
|
let result: any;
|
|
@@ -29,18 +50,13 @@ export default function NavMenuPopout($props: any) {
|
|
|
29
50
|
};
|
|
30
51
|
$context[NavMenuPopoutContextName] = context;
|
|
31
52
|
|
|
32
|
-
// Copy props into state whenever they change
|
|
33
|
-
$run(() => {
|
|
34
|
-
$state.visible = $props.visible ?? false;
|
|
35
|
-
});
|
|
36
|
-
|
|
37
53
|
// Dispatch the toggle event when the popout is opened or closed
|
|
38
54
|
let firstToggle = true;
|
|
39
55
|
$run(() => {
|
|
40
|
-
const ontoggle = $props
|
|
41
|
-
const onopen = $props
|
|
42
|
-
const onclose = $props
|
|
43
|
-
const visible = $
|
|
56
|
+
const ontoggle = $props?.ontoggle;
|
|
57
|
+
const onopen = $props?.onopen;
|
|
58
|
+
const onclose = $props?.onclose;
|
|
59
|
+
const visible = $state.visible;
|
|
44
60
|
if (firstToggle) {
|
|
45
61
|
firstToggle = false;
|
|
46
62
|
} else {
|
|
@@ -59,8 +75,8 @@ export default function NavMenuPopout($props: any) {
|
|
|
59
75
|
|
|
60
76
|
@render {
|
|
61
77
|
<div
|
|
62
|
-
{$props
|
|
63
|
-
class={`torp-nav-menu-popout ${$props
|
|
78
|
+
{$props?.id}
|
|
79
|
+
class={`torp-nav-menu-popout ${$props?.class ?? ""}`.trim()}
|
|
64
80
|
onmouseleave={handleMouseLeave}
|
|
65
81
|
>
|
|
66
82
|
<slot />
|