@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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import {
|
|
3
2
|
NavMenuContextName,
|
|
4
3
|
NavMenuPopoutContextName,
|
|
@@ -6,17 +5,23 @@ 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:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/** Set when the item is disabled */
|
|
19
|
-
let dataDisabled = $props.disabled || undefined;
|
|
23
|
+
export default function NavMenuPopoutButton($props: NavMenuPopoutButtonProps | undefined) {
|
|
24
|
+
let defaultHoverDelay = 500;
|
|
20
25
|
|
|
21
26
|
let button: HTMLButtonElement;
|
|
22
27
|
let interval: NodeJS.Timeout | undefined;
|
|
@@ -66,16 +71,16 @@ export default function NavMenuPopoutButton($props: any) {
|
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
function handleMouseEnter() {
|
|
69
|
-
if ($props
|
|
74
|
+
if ($props?.disabled) return;
|
|
70
75
|
|
|
71
76
|
// Handle the hover after a delay
|
|
72
77
|
if (!interval) {
|
|
73
|
-
interval = setTimeout(() => $state.visible = true, $props
|
|
78
|
+
interval = setTimeout(() => $state.visible = true, $props?.hoverDelay ?? defaultHoverDelay);
|
|
74
79
|
}
|
|
75
80
|
}
|
|
76
81
|
|
|
77
82
|
function handleMouseLeave() {
|
|
78
|
-
if ($props
|
|
83
|
+
if ($props?.disabled) return;
|
|
79
84
|
|
|
80
85
|
// Prevent short hovers or touches from firing the event
|
|
81
86
|
if (interval) {
|
|
@@ -85,26 +90,26 @@ export default function NavMenuPopoutButton($props: any) {
|
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
function handleMouseMove() {
|
|
88
|
-
if ($props
|
|
93
|
+
if ($props?.disabled) return;
|
|
89
94
|
|
|
90
95
|
// Reset the interval on mouse move
|
|
91
96
|
if (interval) {
|
|
92
97
|
clearTimeout(interval);
|
|
93
|
-
interval = setTimeout(() => $state.visible = true, $props
|
|
98
|
+
interval = setTimeout(() => $state.visible = true, $props?.hoverDelay ?? defaultHoverDelay);
|
|
94
99
|
}
|
|
95
100
|
}
|
|
96
101
|
|
|
97
102
|
@render {
|
|
98
103
|
<button
|
|
99
|
-
{$props
|
|
100
|
-
class={`torp-nav-menu-popout-button ${$props
|
|
104
|
+
{$props?.id}
|
|
105
|
+
class={`torp-nav-menu-popout-button ${$props?.class ?? ""}`.trim()}
|
|
101
106
|
type="button"
|
|
102
|
-
{$props
|
|
107
|
+
{$props?.disabled}
|
|
103
108
|
role="menuitem"
|
|
104
109
|
aria-haspopup="true"
|
|
105
110
|
aria-expanded={$state.visible.toString()}
|
|
106
|
-
aria-disabled={$props
|
|
107
|
-
data-disabled={
|
|
111
|
+
aria-disabled={$props?.disabled ? "true" : undefined}
|
|
112
|
+
data-disabled={$props?.disabled ? "true" : undefined}
|
|
108
113
|
onkeydown={handlePopoutKey}
|
|
109
114
|
onclick={handleClick}
|
|
110
115
|
onfocus={() => handleItemFocus(index)}
|
|
@@ -3,16 +3,22 @@ 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:
|
|
13
|
-
$props.side ??= "bottom";
|
|
14
|
-
$props.alignment ??= "start";
|
|
15
|
-
|
|
21
|
+
export default function NavMenuPopoutContent($props: NavMenuPopoutContentProps | undefined) {
|
|
16
22
|
let div: HTMLDivElement;
|
|
17
23
|
let shown = false;
|
|
18
24
|
|
|
@@ -34,7 +40,8 @@ export default function NavMenuPopoutContent($props: any) {
|
|
|
34
40
|
|
|
35
41
|
// Set the position and listen for window resize and scroll to reset the position
|
|
36
42
|
setPosition();
|
|
37
|
-
const
|
|
43
|
+
const anchorElement = context.anchorElement!
|
|
44
|
+
const scrollParent = getScrollParent(anchorElement)
|
|
38
45
|
scrollParent.addEventListener("resize", setPosition);
|
|
39
46
|
scrollParent.addEventListener("scroll", setPosition);
|
|
40
47
|
if (context.focusFirstElement) {
|
|
@@ -46,11 +53,12 @@ export default function NavMenuPopoutContent($props: any) {
|
|
|
46
53
|
if (!shown) return;
|
|
47
54
|
|
|
48
55
|
// Stop listening for window resize and focus the anchor element per WAI guidelines
|
|
49
|
-
const
|
|
56
|
+
const anchorElement = context.anchorElement!
|
|
57
|
+
const scrollParent = getScrollParent(anchorElement)
|
|
50
58
|
scrollParent.removeEventListener("resize", setPosition);
|
|
51
59
|
scrollParent.removeEventListener("scroll", setPosition);
|
|
52
|
-
if (
|
|
53
|
-
|
|
60
|
+
if (anchorElement.focus) {
|
|
61
|
+
anchorElement.focus();
|
|
54
62
|
}
|
|
55
63
|
}
|
|
56
64
|
|
|
@@ -60,15 +68,17 @@ export default function NavMenuPopoutContent($props: any) {
|
|
|
60
68
|
}
|
|
61
69
|
|
|
62
70
|
if (div) {
|
|
63
|
-
|
|
71
|
+
let side = $props?.side ?? "bottom";
|
|
72
|
+
let alignment = $props?.alignment ?? "start";
|
|
73
|
+
setPopoverPosition(context.anchorElement, div, side, alignment);
|
|
64
74
|
}
|
|
65
75
|
}
|
|
66
76
|
|
|
67
77
|
@render {
|
|
68
78
|
@if ($state.visible) {
|
|
69
79
|
<div
|
|
70
|
-
{$props
|
|
71
|
-
class={`torp-nav-menu-popout-content ${$props
|
|
80
|
+
{$props?.id}
|
|
81
|
+
class={`torp-nav-menu-popout-content ${$props?.class ?? ""}`.trim()}
|
|
72
82
|
&ref={div}
|
|
73
83
|
onmount={show}
|
|
74
84
|
>
|
|
@@ -1,12 +1,19 @@
|
|
|
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 | undefined) {
|
|
6
13
|
@render {
|
|
7
14
|
<div
|
|
8
|
-
{$props
|
|
9
|
-
class={`torp-nav-menu-separator ${$props
|
|
15
|
+
{$props?.id}
|
|
16
|
+
class={`torp-nav-menu-separator ${$props?.class ?? ""}`.trim()} role="separator"
|
|
10
17
|
>
|
|
11
18
|
<slot />
|
|
12
19
|
</div>
|
|
@@ -1,18 +1,39 @@
|
|
|
1
1
|
import { NotificationContextName, type NotificationContext } from "./NotificationTypes";
|
|
2
2
|
|
|
3
|
+
interface NotificationProps {
|
|
4
|
+
/** An ID for the root element */
|
|
5
|
+
id?: string;
|
|
6
|
+
/** Class name(s) for the root element */
|
|
7
|
+
class?: string,
|
|
8
|
+
/** Whether the notification is visible */
|
|
9
|
+
visible?: boolean,
|
|
10
|
+
/** The duration, in milliseconds, to keep the notification visible */
|
|
11
|
+
duration?: number,
|
|
12
|
+
/** Raised when the notification has closed, either after the duration has elapsed, or when the user has pressed the close button */
|
|
13
|
+
onclose?: () => void,
|
|
14
|
+
}
|
|
15
|
+
|
|
3
16
|
/**
|
|
4
17
|
* An element that displays a brief, important message in a way that attracts
|
|
5
18
|
* the user's attention without interrupting the user's task.
|
|
6
19
|
*
|
|
7
20
|
* See [the WAI ARIA guidelines for Alerts](https://www.w3.org/WAI/ARIA/apg/patterns/alert/).
|
|
8
|
-
*
|
|
9
|
-
* @prop {boolean} visible -- Whether the notification is visible
|
|
10
|
-
* @prop {number | undefined} duration -- The duration, in milliseconds, to keep the notification visible
|
|
11
|
-
* @prop {() => void} onclose -- Raised when the notification has closed, either after the duration has elapsed, or when the user has pressed the close button
|
|
12
21
|
*/
|
|
13
|
-
export default function Notification($props) {
|
|
14
|
-
|
|
15
|
-
|
|
22
|
+
export default function Notification($props: NotificationProps | undefined) {
|
|
23
|
+
let defaultDuration = 5000;
|
|
24
|
+
|
|
25
|
+
let $state = $watch({
|
|
26
|
+
visible: false
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
$run(() => {
|
|
30
|
+
$state.visible = $props?.visible ?? true;
|
|
31
|
+
});
|
|
32
|
+
$run(() => {
|
|
33
|
+
if ($props !== undefined) {
|
|
34
|
+
$props.visible = $state.visible;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
16
37
|
|
|
17
38
|
// Set the context to pass down to items
|
|
18
39
|
let context: NotificationContext = {
|
|
@@ -21,24 +42,22 @@ export default function Notification($props) {
|
|
|
21
42
|
$context[NotificationContextName] = context;
|
|
22
43
|
|
|
23
44
|
$mount(() => {
|
|
24
|
-
|
|
25
|
-
setTimeout(closeNotification, $props.duration);
|
|
26
|
-
}
|
|
45
|
+
setTimeout(closeNotification, $props?.duration ?? defaultDuration);
|
|
27
46
|
});
|
|
28
47
|
|
|
29
48
|
function closeNotification() {
|
|
30
|
-
$
|
|
49
|
+
$state.visible = false;
|
|
31
50
|
|
|
32
|
-
if ($props
|
|
33
|
-
$props
|
|
51
|
+
if ($props?.onclose) {
|
|
52
|
+
$props?.onclose();
|
|
34
53
|
}
|
|
35
54
|
}
|
|
36
55
|
|
|
37
56
|
@render {
|
|
38
|
-
@if ($
|
|
57
|
+
@if ($state.visible) {
|
|
39
58
|
<div
|
|
40
|
-
{$props
|
|
41
|
-
class={`torp-notification ${$props
|
|
59
|
+
{$props?.id}
|
|
60
|
+
class={`torp-notification ${$props?.class ?? ""}`.trim()}
|
|
42
61
|
role="alert"
|
|
43
62
|
>
|
|
44
63
|
<slot />
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { NotificationContextName, type NotificationContext } from "./NotificationTypes";
|
|
2
2
|
|
|
3
|
+
interface NotificationCloseProps {
|
|
4
|
+
/** An ID for the root element */
|
|
5
|
+
id?: string;
|
|
6
|
+
/** Class name(s) for the root element */
|
|
7
|
+
class?: string,
|
|
8
|
+
}
|
|
9
|
+
|
|
3
10
|
/**
|
|
4
11
|
* The button that a user can press to close this Notification.
|
|
5
12
|
*/
|
|
6
|
-
export default function NotificationClose() {
|
|
13
|
+
export default function NotificationClose($props: NotificationCloseProps | undefined) {
|
|
7
14
|
// Get stuff out of the NotificationContext
|
|
8
15
|
const context = $context[NotificationContextName] as NotificationContext;
|
|
9
16
|
if (!context) {
|
|
@@ -17,8 +24,8 @@ export default function NotificationClose() {
|
|
|
17
24
|
|
|
18
25
|
@render {
|
|
19
26
|
<button
|
|
20
|
-
{$props
|
|
21
|
-
class={`torp-notification-close ${$props
|
|
27
|
+
{$props?.id}
|
|
28
|
+
class={`torp-notification-close ${$props?.class ?? ""}`.trim()}
|
|
22
29
|
type="button"
|
|
23
30
|
onclick={handleClick}
|
|
24
31
|
>
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
interface NotificationContainerProps {
|
|
3
|
+
/** An ID for the root element */
|
|
4
|
+
id?: string;
|
|
5
|
+
/** Class name(s) for the root element */
|
|
6
|
+
class?: string,
|
|
7
|
+
}
|
|
8
|
+
|
|
1
9
|
/**
|
|
2
10
|
* The container for one or more Notifications, which can be used to position
|
|
3
11
|
* the notifications inside the viewport.
|
|
4
12
|
*/
|
|
5
|
-
export default function NotificationContainer() {
|
|
13
|
+
export default function NotificationContainer($props: NotificationContainerProps | undefined) {
|
|
6
14
|
@render {
|
|
7
15
|
<div
|
|
8
|
-
{$props
|
|
9
|
-
class={`torp-notification-container ${$props
|
|
16
|
+
{$props?.id}
|
|
17
|
+
class={`torp-notification-container ${$props?.class ?? ""}`.trim()}
|
|
10
18
|
>
|
|
11
19
|
<slot />
|
|
12
20
|
</div>
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
interface NotificationContentProps {
|
|
3
|
+
/** An ID for the root element */
|
|
4
|
+
id?: string;
|
|
5
|
+
/** Class name(s) for the root element */
|
|
6
|
+
class?: string,
|
|
7
|
+
}
|
|
8
|
+
|
|
1
9
|
/**
|
|
2
10
|
* The content to display within a Notification.
|
|
3
11
|
*/
|
|
4
|
-
export default function NotificationContent() {
|
|
12
|
+
export default function NotificationContent($props: NotificationContentProps | undefined) {
|
|
5
13
|
@render {
|
|
6
14
|
<div
|
|
7
|
-
{$props
|
|
8
|
-
class={`torp-notification-content ${$props
|
|
15
|
+
{$props?.id}
|
|
16
|
+
class={`torp-notification-content ${$props?.class ?? ""}`.trim()}
|
|
9
17
|
>
|
|
10
18
|
<slot />
|
|
11
19
|
</div>
|
package/src/Popover/Popover.torp
CHANGED
|
@@ -1,31 +1,57 @@
|
|
|
1
1
|
import { PopoverContextName, type Point, type PopoverContext, type PopoverState } from "./PopoverTypes";
|
|
2
2
|
|
|
3
|
+
interface PopoverProps {
|
|
4
|
+
/** An ID for the root element */
|
|
5
|
+
id?: string;
|
|
6
|
+
/** Class name(s) for the root element */
|
|
7
|
+
class?: string,
|
|
8
|
+
/** Whether the popover is modal. If true, an overlay should be supplied to obscure outside content, and only the popover content will be visible to screen readers */
|
|
9
|
+
modal?: boolean,
|
|
10
|
+
/** Whether the popover is visible */
|
|
11
|
+
visible?: boolean,
|
|
12
|
+
/** The element to anchor this popover to, as an alternative to supplying a PopoverTrigger */
|
|
13
|
+
anchor?: HTMLElement,
|
|
14
|
+
/** The position to display this popover at if it's contextual, as an alternative to supplying a PopoverTriggerContextual */
|
|
15
|
+
position?: Point,
|
|
16
|
+
/** A function to be called when the user selects a response */
|
|
17
|
+
callback?: ((value: any) => void),
|
|
18
|
+
/** Raised when the popover is opened or closed */
|
|
19
|
+
ontoggle?: (open: boolean) => void,
|
|
20
|
+
/** Raised when the popover has opened */
|
|
21
|
+
onopen?: () => void,
|
|
22
|
+
/** Raised when the popover has closed */
|
|
23
|
+
onclose?: (result: any) => void,
|
|
24
|
+
}
|
|
25
|
+
|
|
3
26
|
/**
|
|
4
|
-
* A popover that
|
|
5
|
-
*
|
|
6
|
-
* See [the WAI ARIA guidelines for Dialogs](https://www.w3.org/WAI/ARIA/apg/patterns/dialogmodal/).
|
|
27
|
+
* A popover window that is shown to the user relative to an anchor element.
|
|
7
28
|
*
|
|
8
29
|
* The structure of a Popover is:
|
|
9
30
|
*
|
|
10
31
|
* ```
|
|
11
32
|
* <Popover>
|
|
12
|
-
* <
|
|
13
|
-
* <
|
|
14
|
-
* <PopoverContent/PopoverContentAnchored/PopoverContentContextual />
|
|
33
|
+
* <PopoverTrigger /> (optional)
|
|
34
|
+
* <PopoverContent />
|
|
15
35
|
* </Popover>
|
|
16
36
|
* ```
|
|
17
|
-
* @prop {boolean} modal -- Whether the popover is modal. If true, an overlay should be supplied to obscure outside content, and only the popover content will be visible to screen readers
|
|
18
|
-
* @prop {boolean} visible -- Whether the popover is visible
|
|
19
|
-
* @prop {HTMLElement | undefined} anchor -- The element to anchor this popover to, as an alternative to supplying a PopoverTrigger
|
|
20
|
-
* @prop {Point | undefined} position -- The position to display this popover at if it's contextual, as an alternative to supplying a PopoverTriggerContextual
|
|
21
|
-
* @prop {((value: any) => void) | undefined} [callback] -- A function to be called when the user selects a response
|
|
22
37
|
*/
|
|
23
|
-
export default function Popover($props:
|
|
38
|
+
export default function Popover($props: PopoverProps | undefined) {
|
|
24
39
|
let $state: PopoverState = $watch({
|
|
25
40
|
visible: false,
|
|
26
41
|
position: { x: 0, y: 0 }
|
|
27
42
|
})
|
|
28
43
|
|
|
44
|
+
// Sync props and state
|
|
45
|
+
$run(() => {
|
|
46
|
+
$state.visible = $props?.visible ?? false;
|
|
47
|
+
$state.position = $props?.position ?? { x: 0, y: 0 };
|
|
48
|
+
});
|
|
49
|
+
$run(() => {
|
|
50
|
+
if ($props !== undefined) {
|
|
51
|
+
$props.visible = $state.visible;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
29
55
|
let result: any;
|
|
30
56
|
|
|
31
57
|
// Set the context to pass down to items
|
|
@@ -33,23 +59,17 @@ export default function Popover($props: any) {
|
|
|
33
59
|
handleButton,
|
|
34
60
|
handleClickOutside,
|
|
35
61
|
state: $state,
|
|
36
|
-
modal: $props
|
|
37
|
-
anchorElement: $unwrap($props.anchor),
|
|
62
|
+
modal: $props?.modal,
|
|
63
|
+
anchorElement: $props?.anchor ? $unwrap($props.anchor) : undefined,
|
|
38
64
|
};
|
|
39
65
|
$context[PopoverContextName] = context;
|
|
40
66
|
|
|
41
|
-
//
|
|
42
|
-
$run(() => {
|
|
43
|
-
$state.visible = $props.visible ?? false;
|
|
44
|
-
$state.position = $props.position ?? { x: 0, y: 0 };
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
// Dispatch the toggle event when the popout is opened or closed
|
|
67
|
+
// Dispatch the toggle event when the popover is opened or closed
|
|
48
68
|
let firstToggle = true;
|
|
49
69
|
$run(() => {
|
|
50
|
-
const ontoggle = $props
|
|
51
|
-
const onopen = $props
|
|
52
|
-
const onclose = $props
|
|
70
|
+
const ontoggle = $props?.ontoggle;
|
|
71
|
+
const onopen = $props?.onopen;
|
|
72
|
+
const onclose = $props?.onclose;
|
|
53
73
|
const visible = $state.visible;
|
|
54
74
|
if (firstToggle) {
|
|
55
75
|
firstToggle = false;
|
|
@@ -84,8 +104,8 @@ export default function Popover($props: any) {
|
|
|
84
104
|
$state.visible = false;
|
|
85
105
|
|
|
86
106
|
// Call the callback
|
|
87
|
-
if ($props
|
|
88
|
-
$props
|
|
107
|
+
if ($props?.callback) {
|
|
108
|
+
$props?.callback(result);
|
|
89
109
|
}
|
|
90
110
|
}
|
|
91
111
|
|
|
@@ -96,8 +116,8 @@ export default function Popover($props: any) {
|
|
|
96
116
|
|
|
97
117
|
@render {
|
|
98
118
|
<div
|
|
99
|
-
{$props
|
|
100
|
-
class={`torp-popover ${$props
|
|
119
|
+
{$props?.id}
|
|
120
|
+
class={`torp-popover ${$props?.class ?? ""}`.trim()}
|
|
101
121
|
>
|
|
102
122
|
<slot />
|
|
103
123
|
</div>
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import { addDocumentEvent, removeDocumentEvent } from "../utils/documentEvents";
|
|
2
|
+
import getScrollParent from "../utils/getScrollParent";
|
|
3
|
+
import setPopoverPosition from "../utils/setPopoverPosition";
|
|
2
4
|
import { PopoverContextName, type PopoverContext } from "./PopoverTypes";
|
|
3
5
|
|
|
6
|
+
interface PopoverContentProps {
|
|
7
|
+
/** An ID for the root element */
|
|
8
|
+
id?: string;
|
|
9
|
+
/** Class name(s) for the root element */
|
|
10
|
+
class?: string,
|
|
11
|
+
/** Where the popover will be shown, relative to the popover trigger */
|
|
12
|
+
side?: "top" | "right" | "bottom" | "left",
|
|
13
|
+
/** How the popover will be aligned, relative to the popover trigger */
|
|
14
|
+
alignment?: "start" | "center" | "end",
|
|
15
|
+
}
|
|
16
|
+
|
|
4
17
|
/**
|
|
5
|
-
* The content that is displayed for a Popover when it is open,
|
|
6
|
-
*
|
|
18
|
+
* The content that is displayed for a Popover when it is open, displayed
|
|
19
|
+
* alongside an element.
|
|
7
20
|
*/
|
|
8
|
-
export default function PopoverContent($props
|
|
21
|
+
export default function PopoverContent($props?: PopoverContentProps | undefined) {
|
|
9
22
|
let div: HTMLDivElement;
|
|
10
23
|
let shown = false;
|
|
11
24
|
let closeOnClick = false;
|
|
@@ -32,6 +45,12 @@ export default function PopoverContent($props: any) {
|
|
|
32
45
|
addDocumentEvent("mousedown", handleDocumentMouseDown);
|
|
33
46
|
addDocumentEvent("click", handleDocumentClick);
|
|
34
47
|
|
|
48
|
+
// Set the position and listen for window resize and scroll to reset the position
|
|
49
|
+
setPosition();
|
|
50
|
+
const anchorElement = context.anchorElement!
|
|
51
|
+
const scrollParent = getScrollParent(anchorElement)
|
|
52
|
+
scrollParent.addEventListener("resize", setPosition);
|
|
53
|
+
scrollParent.addEventListener("scroll", setPosition);
|
|
35
54
|
if (context.focusFirstElement) {
|
|
36
55
|
context.focusFirstElement();
|
|
37
56
|
}
|
|
@@ -43,9 +62,13 @@ export default function PopoverContent($props: any) {
|
|
|
43
62
|
removeDocumentEvent("mousedown", handleDocumentMouseDown);
|
|
44
63
|
removeDocumentEvent("click", handleDocumentClick);
|
|
45
64
|
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
|
|
65
|
+
// Stop listening for window resize and focus the anchor element per WAI guidelines
|
|
66
|
+
const anchorElement = context.anchorElement!
|
|
67
|
+
const scrollParent = getScrollParent(anchorElement)
|
|
68
|
+
scrollParent.removeEventListener("resize", setPosition);
|
|
69
|
+
scrollParent.removeEventListener("scroll", setPosition);
|
|
70
|
+
if (anchorElement.focus) {
|
|
71
|
+
anchorElement.focus();
|
|
49
72
|
}
|
|
50
73
|
}
|
|
51
74
|
|
|
@@ -60,15 +83,26 @@ export default function PopoverContent($props: any) {
|
|
|
60
83
|
!div.contains(e.target as HTMLElement) &&
|
|
61
84
|
(!context.anchorElement || !context.anchorElement.contains(e.target as HTMLElement))
|
|
62
85
|
) {
|
|
86
|
+
e.preventDefault();
|
|
63
87
|
context.handleClickOutside!(e);
|
|
64
88
|
}
|
|
65
89
|
}
|
|
66
90
|
|
|
91
|
+
function setPosition() {
|
|
92
|
+
if (!context.anchorElement) {
|
|
93
|
+
throw new Error("Popover must have an anchor element");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let side = $props?.side ?? "bottom";
|
|
97
|
+
let alignment = $props?.alignment ?? "center";
|
|
98
|
+
setPopoverPosition(context.anchorElement, div, side, alignment);
|
|
99
|
+
}
|
|
100
|
+
|
|
67
101
|
@render {
|
|
68
102
|
@if ($state.visible) {
|
|
69
103
|
<div
|
|
70
|
-
{$props
|
|
71
|
-
class={`torp-popover-content ${$props
|
|
104
|
+
{$props?.id}
|
|
105
|
+
class={`torp-popover-content ${$props?.class ?? ""}`.trim()}
|
|
72
106
|
&ref={div}
|
|
73
107
|
onmount={show}
|
|
74
108
|
>
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { PopoverContextName, type PopoverContext } from "./PopoverTypes";
|
|
2
|
+
import hoverTrigger from "../mount/hoverTrigger";
|
|
3
|
+
|
|
4
|
+
interface PopoverTriggerProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Class name(s) for the root element */
|
|
8
|
+
class?: string,
|
|
9
|
+
/** Whether the popover is activated by click/press or by hover **/
|
|
10
|
+
activation?: "press" | "hover"
|
|
11
|
+
}
|
|
2
12
|
|
|
3
13
|
/**
|
|
4
14
|
* The button that causes a Popover to appear or disappear.
|
|
5
15
|
*/
|
|
6
|
-
export default function PopoverTrigger($props:
|
|
16
|
+
export default function PopoverTrigger($props: PopoverTriggerProps | undefined) {
|
|
17
|
+
let activation = $props?.activation ?? "press";
|
|
18
|
+
|
|
7
19
|
// Get stuff out of the PopoverContext
|
|
8
20
|
const context = $context[PopoverContextName] as PopoverContext;
|
|
9
21
|
if (!context) {
|
|
@@ -12,15 +24,32 @@ export default function PopoverTrigger($props: any) {
|
|
|
12
24
|
let $state = context.state;
|
|
13
25
|
|
|
14
26
|
function handleClick() {
|
|
27
|
+
if (activation !== "press") return;
|
|
28
|
+
|
|
15
29
|
$state.visible = !$state.visible;
|
|
16
30
|
}
|
|
17
31
|
|
|
32
|
+
function handleHover(node: HTMLElement, e: MouseEvent) {
|
|
33
|
+
if (activation !== "hover") return;
|
|
34
|
+
|
|
35
|
+
if ($state.position) {
|
|
36
|
+
// Get the position relative to the element, so we can reposition on scroll
|
|
37
|
+
const rect = node.getBoundingClientRect();
|
|
38
|
+
const x = e.clientX - rect.left;
|
|
39
|
+
const y = e.clientY - rect.top;
|
|
40
|
+
$state.position = { x, y };
|
|
41
|
+
//$state.position = { x: window.scrollX + e.clientX, y: window.scrollY + e.clientY };
|
|
42
|
+
}
|
|
43
|
+
$state.visible = !$state.visible
|
|
44
|
+
}
|
|
45
|
+
|
|
18
46
|
@render {
|
|
19
47
|
<button
|
|
20
48
|
type="button"
|
|
21
|
-
{$props
|
|
22
|
-
class={`torp-popover-trigger ${$props
|
|
49
|
+
{$props?.id}
|
|
50
|
+
class={`torp-popover-trigger ${$props?.class ?? ""}`.trim()}
|
|
23
51
|
onclick={handleClick}
|
|
52
|
+
onmount={(el) => hoverTrigger(el, { onHover: handleHover, onExit: handleHover })}
|
|
24
53
|
&ref={context.anchorElement}
|
|
25
54
|
>
|
|
26
55
|
<slot />
|
|
@@ -7,7 +7,7 @@ export interface PopoverContext {
|
|
|
7
7
|
// There may be a more elegant way to accomplish this too
|
|
8
8
|
handleClickOutside?: (e: MouseEvent) => void;
|
|
9
9
|
state: PopoverState;
|
|
10
|
-
modal: boolean;
|
|
10
|
+
//modal: boolean;
|
|
11
11
|
anchorElement?: HTMLElement;
|
|
12
12
|
// HACK: focusFirstElement is necessary because if we focus the first element e.g. in a Dialog's
|
|
13
13
|
// onMount, it will scroll the page to the focused element and mess up our careful positioning
|
package/src/Popover/index.ts
CHANGED
|
@@ -1,29 +1,6 @@
|
|
|
1
1
|
import Popover from "./Popover.torp";
|
|
2
2
|
import PopoverContent from "./PopoverContent.torp";
|
|
3
|
-
import PopoverContentAnchored from "./PopoverContentAnchored.torp";
|
|
4
|
-
import PopoverContentContextual from "./PopoverContentContextual.torp";
|
|
5
|
-
import PopoverOverlay from "./PopoverOverlay.torp";
|
|
6
3
|
import PopoverTrigger from "./PopoverTrigger.torp";
|
|
7
|
-
import PopoverTriggerContextual from "./PopoverTriggerContextual.torp";
|
|
8
|
-
import PopoverTriggerHover from "./PopoverTriggerHover.torp";
|
|
9
|
-
import clickPopover from "./mountClickPopover";
|
|
10
|
-
import contextPopover from "./mountContextPopover";
|
|
11
|
-
import hoverPopover from "./mountHoverPopover";
|
|
12
4
|
import showPopover from "./showPopover";
|
|
13
|
-
import showPopoverPrompt from "./showPopoverPrompt";
|
|
14
5
|
|
|
15
|
-
export {
|
|
16
|
-
Popover,
|
|
17
|
-
PopoverOverlay,
|
|
18
|
-
PopoverTrigger,
|
|
19
|
-
PopoverTriggerHover,
|
|
20
|
-
PopoverTriggerContextual,
|
|
21
|
-
PopoverContentAnchored,
|
|
22
|
-
PopoverContentContextual,
|
|
23
|
-
PopoverContent,
|
|
24
|
-
showPopover,
|
|
25
|
-
showPopoverPrompt,
|
|
26
|
-
clickPopover,
|
|
27
|
-
contextPopover,
|
|
28
|
-
hoverPopover,
|
|
29
|
-
};
|
|
6
|
+
export { Popover, PopoverTrigger, PopoverContent, showPopover };
|
package/src/Slider/Slider.torp
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default function Slider() {
|
|
1
|
+
export default function Slider($props: any | undefined) {
|
|
2
2
|
//export let value = 0;
|
|
3
3
|
//export let total = 0;
|
|
4
4
|
|
|
@@ -71,8 +71,8 @@ export default function Slider() {
|
|
|
71
71
|
|
|
72
72
|
@render {
|
|
73
73
|
<div
|
|
74
|
-
|
|
75
|
-
class={`torp-slider ${$props
|
|
74
|
+
{$props?.id}
|
|
75
|
+
class={`torp-slider ${$props?.class ?? ""}`.trim()}
|
|
76
76
|
onmousemove={handleMouseMove}
|
|
77
77
|
onmouseup={handleMouseUp}
|
|
78
78
|
>
|