@torpor/ui 0.1.7 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/dist/Accordion/Accordion.torp +25 -13
- package/dist/Accordion/AccordionContent.torp +15 -8
- package/dist/Accordion/AccordionHeader.torp +16 -7
- package/dist/Accordion/AccordionItem.torp +24 -10
- package/dist/Accordion/AccordionTrigger.torp +16 -8
- package/dist/Accordion/AccordionTypes.ts +2 -0
- package/dist/Accordion/index.d.ts +157 -0
- package/dist/Breadcrumb/Breadcrumb.torp +42 -0
- package/dist/Breadcrumb/BreadcrumbItem.torp +28 -0
- package/dist/Breadcrumb/BreadcrumbSeparator.torp +25 -0
- package/dist/Breadcrumb/index.d.ts +84 -0
- package/dist/Breadcrumb/index.js +14 -0
- package/dist/Calendar/Calendar.torp +273 -0
- package/dist/Calendar/CalendarDay.torp +75 -0
- package/dist/Calendar/CalendarTypes.ts +22 -0
- package/dist/Calendar/index.d.ts +36 -0
- package/dist/Calendar/index.js +10 -0
- package/dist/Calendar/index.js.map +1 -0
- package/dist/Dialog/Dialog.torp +16 -6
- package/dist/Dialog/DialogBody.torp +13 -5
- package/dist/Dialog/DialogButton.torp +18 -6
- package/dist/Dialog/DialogFooter.torp +13 -3
- package/dist/Dialog/DialogHeader.torp +13 -4
- package/dist/Dialog/index.d.ts +135 -0
- package/dist/Disclosure/Disclosure.torp +79 -0
- package/dist/Disclosure/DisclosureContent.torp +43 -0
- package/dist/Disclosure/DisclosureHeader.torp +43 -0
- package/dist/Disclosure/DisclosureTrigger.torp +44 -0
- package/dist/Disclosure/DisclosureTypes.ts +14 -0
- package/dist/Disclosure/index.d.ts +113 -0
- package/dist/Disclosure/index.js +18 -0
- package/dist/Disclosure/index.js.map +1 -0
- package/{src/Offscreen/Offscreen.torp → dist/Drawer/Drawer.torp} +20 -19
- package/dist/Drawer/index.d.ts +21 -0
- package/dist/Drawer/index.js +6 -0
- package/dist/Drawer/index.js.map +1 -0
- package/dist/Form/Field.torp +93 -0
- package/dist/Form/Form.torp +131 -0
- package/dist/Form/FormTypes.ts +30 -0
- package/dist/Form/Input.torp +94 -0
- package/dist/Form/Label.torp +31 -0
- package/dist/Form/Message.torp +35 -0
- package/dist/Form/StandardSchemaV1.ts +70 -0
- package/dist/Form/index.d.ts +117 -0
- package/dist/Form/index.js +22 -0
- package/dist/Form/index.js.map +1 -0
- package/dist/Menu/Menu.torp +169 -0
- package/dist/Menu/MenuButton.torp +64 -0
- package/dist/Menu/MenuCheck.torp +81 -0
- package/dist/Menu/MenuGroup.torp +29 -0
- package/dist/Menu/MenuIndicator.torp +38 -0
- package/dist/Menu/MenuPopout.torp +82 -0
- package/dist/Menu/MenuPopoutContent.torp +83 -0
- package/dist/Menu/MenuPopoutTrigger.torp +126 -0
- package/dist/Menu/MenuRadio.torp +99 -0
- package/dist/Menu/MenuRadioGroup.torp +97 -0
- package/dist/Menu/MenuSeparator.torp +24 -0
- package/dist/Menu/MenuTypes.ts +58 -0
- package/dist/Menu/index.d.ts +293 -0
- package/dist/Menu/index.js +46 -0
- package/dist/Menu/index.js.map +1 -0
- package/dist/MenuBar/MenuBar.torp +159 -0
- package/dist/MenuBar/MenuBarItem.torp +115 -0
- package/dist/MenuBar/MenuBarItemContent.torp +117 -0
- package/dist/MenuBar/MenuBarItemTrigger.torp +98 -0
- package/dist/MenuBar/MenuBarTypes.ts +36 -0
- package/dist/MenuBar/index.d.ts +125 -0
- package/dist/MenuBar/index.js +18 -0
- package/dist/MenuBar/index.js.map +1 -0
- package/dist/NavMenu/NavMenu.torp +15 -6
- package/dist/NavMenu/NavMenuButton.torp +14 -7
- package/dist/NavMenu/NavMenuElement.torp +16 -8
- package/dist/NavMenu/NavMenuGroup.torp +14 -5
- package/dist/NavMenu/NavMenuGroupHeader.torp +14 -6
- package/dist/NavMenu/NavMenuLink.torp +18 -10
- package/dist/NavMenu/NavMenuPopout.torp +13 -5
- package/dist/NavMenu/NavMenuPopoutButton.torp +17 -11
- package/dist/NavMenu/NavMenuPopoutContent.torp +42 -30
- package/dist/NavMenu/NavMenuSeparator.torp +12 -3
- package/dist/NavMenu/index.d.ts +259 -0
- package/dist/Notification/Notification.torp +58 -0
- package/dist/Notification/NotificationClose.torp +37 -0
- package/dist/Notification/NotificationContainer.torp +24 -0
- package/dist/Notification/NotificationContent.torp +23 -0
- package/dist/Notification/NotificationTypes.ts +5 -0
- package/dist/Notification/index.d.ts +92 -0
- package/dist/Notification/index.js +36 -0
- package/dist/Notification/index.js.map +1 -0
- package/dist/Notification/showNotification.ts +30 -0
- package/dist/Popover/Popover.torp +22 -8
- package/dist/Popover/PopoverContent.torp +41 -29
- package/dist/Popover/PopoverContentAnchored.torp +52 -44
- package/dist/Popover/PopoverContentContextual.torp +49 -37
- package/dist/Popover/PopoverOverlay.torp +13 -4
- package/dist/Popover/PopoverTrigger.torp +12 -3
- package/dist/Popover/PopoverTriggerContextual.torp +12 -3
- package/dist/Popover/PopoverTriggerHover.torp +14 -5
- package/dist/Popover/index.d.ts +191 -0
- package/dist/TabGroup/TabContent.torp +13 -7
- package/dist/TabGroup/TabGroup.torp +23 -11
- package/dist/TabGroup/TabHeader.torp +16 -7
- package/dist/TabGroup/TabList.torp +15 -6
- package/dist/TabGroup/TabTrigger.torp +14 -6
- package/dist/TabGroup/index.d.ts +150 -0
- package/dist/icons/ArrowDown.torp +15 -0
- package/dist/icons/ArrowLeft.torp +15 -0
- package/dist/icons/ArrowRight.torp +15 -0
- package/dist/icons/ArrowUp.torp +15 -0
- package/dist/icons/Bars.torp +17 -0
- package/dist/icons/Check.torp +15 -0
- package/dist/icons/ChevronDown.torp +15 -0
- package/dist/icons/ChevronLeft.torp +15 -0
- package/dist/icons/ChevronRight.torp +15 -0
- package/dist/icons/ChevronUp.torp +15 -0
- package/dist/icons/Cross.torp +16 -0
- package/dist/icons/Loading.torp +16 -0
- package/dist/icons/Minus.torp +15 -0
- package/dist/icons/Plus.torp +16 -0
- package/dist/icons/index.d.ts +142 -0
- package/dist/icons/index.js +58 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/{motion.d.cts → index.d.ts} +2 -2
- package/dist/metafile-esm.json +1 -1
- package/dist/motion/fade.ts +7 -0
- package/dist/motion/index.d.ts +2 -0
- package/dist/{motion.js → motion/index.js} +1 -1
- package/dist/motion/index.js.map +1 -0
- package/dist/mount/index.d.ts +2 -0
- package/dist/utils/dateUtils.ts +244 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/setPopoverPosition.ts +4 -0
- package/package.json +60 -35
- package/scripts/postbuild.ts +42 -5
- package/src/Accordion/Accordion.torp +25 -13
- package/src/Accordion/AccordionContent.torp +15 -8
- package/src/Accordion/AccordionHeader.torp +16 -7
- package/src/Accordion/AccordionItem.torp +24 -10
- package/src/Accordion/AccordionTrigger.torp +16 -8
- package/src/Accordion/AccordionTypes.ts +2 -0
- package/src/Breadcrumb/Breadcrumb.torp +42 -0
- package/src/Breadcrumb/BreadcrumbItem.torp +28 -0
- package/src/Breadcrumb/BreadcrumbSeparator.torp +25 -0
- package/src/Breadcrumb/index.ts +5 -0
- package/src/Calendar/Calendar.torp +273 -0
- package/src/Calendar/CalendarDay.torp +75 -0
- package/src/Calendar/CalendarTypes.ts +22 -0
- package/src/Calendar/index.ts +4 -0
- package/src/Dialog/Dialog.torp +16 -6
- package/src/Dialog/DialogBody.torp +13 -5
- package/src/Dialog/DialogButton.torp +18 -6
- package/src/Dialog/DialogFooter.torp +13 -3
- package/src/Dialog/DialogHeader.torp +13 -4
- package/src/Disclosure/Disclosure.torp +79 -0
- package/src/Disclosure/DisclosureContent.torp +43 -0
- package/src/Disclosure/DisclosureHeader.torp +43 -0
- package/src/Disclosure/DisclosureTrigger.torp +44 -0
- package/src/Disclosure/DisclosureTypes.ts +14 -0
- package/src/Disclosure/index.ts +6 -0
- package/{dist/Offscreen/Offscreen.torp → src/Drawer/Drawer.torp} +20 -19
- package/src/Drawer/index.ts +3 -0
- package/src/Form/Field.torp +93 -0
- package/src/Form/Form.torp +131 -0
- package/src/Form/FormTypes.ts +30 -0
- package/src/Form/Input.torp +94 -0
- package/src/Form/Label.torp +31 -0
- package/src/Form/Message.torp +35 -0
- package/src/Form/StandardSchemaV1.ts +70 -0
- package/src/Form/index.ts +7 -0
- package/src/Menu/Menu.torp +169 -0
- package/src/Menu/MenuButton.torp +64 -0
- package/src/Menu/MenuCheck.torp +81 -0
- package/src/Menu/MenuGroup.torp +29 -0
- package/src/Menu/MenuIndicator.torp +38 -0
- package/src/Menu/MenuPopout.torp +82 -0
- package/src/Menu/MenuPopoutContent.torp +83 -0
- package/src/Menu/MenuPopoutTrigger.torp +126 -0
- package/src/Menu/MenuRadio.torp +99 -0
- package/src/Menu/MenuRadioGroup.torp +97 -0
- package/src/Menu/MenuSeparator.torp +24 -0
- package/src/Menu/MenuTypes.ts +58 -0
- package/src/Menu/index.ts +25 -0
- package/src/MenuBar/MenuBar.torp +159 -0
- package/src/MenuBar/MenuBarItem.torp +115 -0
- package/src/MenuBar/MenuBarItemContent.torp +117 -0
- package/src/MenuBar/MenuBarItemTrigger.torp +98 -0
- package/src/MenuBar/MenuBarTypes.ts +36 -0
- package/src/MenuBar/index.ts +6 -0
- package/src/NavMenu/NavMenu.torp +15 -6
- package/src/NavMenu/NavMenuButton.torp +14 -7
- package/src/NavMenu/NavMenuElement.torp +16 -8
- package/src/NavMenu/NavMenuGroup.torp +14 -5
- package/src/NavMenu/NavMenuGroupHeader.torp +14 -6
- package/src/NavMenu/NavMenuLink.torp +18 -10
- package/src/NavMenu/NavMenuPopout.torp +13 -5
- package/src/NavMenu/NavMenuPopoutButton.torp +17 -11
- package/src/NavMenu/NavMenuPopoutContent.torp +42 -30
- package/src/NavMenu/NavMenuSeparator.torp +12 -3
- package/src/Notification/Notification.torp +58 -0
- package/src/Notification/NotificationClose.torp +37 -0
- package/src/Notification/NotificationContainer.torp +24 -0
- package/src/Notification/NotificationContent.torp +23 -0
- package/src/Notification/NotificationTypes.ts +5 -0
- package/src/Notification/index.ts +13 -0
- package/src/Notification/showNotification.ts +30 -0
- package/src/Popover/Popover.torp +22 -8
- package/src/Popover/PopoverContent.torp +41 -29
- package/src/Popover/PopoverContentAnchored.torp +52 -44
- package/src/Popover/PopoverContentContextual.torp +49 -37
- package/src/Popover/PopoverOverlay.torp +13 -4
- package/src/Popover/PopoverTrigger.torp +12 -3
- package/src/Popover/PopoverTriggerContextual.torp +12 -3
- package/src/Popover/PopoverTriggerHover.torp +14 -5
- package/src/Slider/Slider.torp +83 -0
- package/src/Slider/index.ts +3 -0
- package/src/TabGroup/TabContent.torp +13 -7
- package/src/TabGroup/TabGroup.torp +23 -11
- package/src/TabGroup/TabHeader.torp +16 -7
- package/src/TabGroup/TabList.torp +15 -6
- package/src/TabGroup/TabTrigger.torp +14 -6
- package/src/icons/ArrowDown.torp +15 -0
- package/src/icons/ArrowLeft.torp +15 -0
- package/src/icons/ArrowRight.torp +15 -0
- package/src/icons/ArrowUp.torp +15 -0
- package/src/icons/Bars.torp +17 -0
- package/src/icons/Check.torp +15 -0
- package/src/icons/ChevronDown.torp +15 -0
- package/src/icons/ChevronLeft.torp +15 -0
- package/src/icons/ChevronRight.torp +15 -0
- package/src/icons/ChevronUp.torp +15 -0
- package/src/icons/Cross.torp +16 -0
- package/src/icons/Loading.torp +16 -0
- package/src/icons/Minus.torp +15 -0
- package/src/icons/Plus.torp +16 -0
- package/src/icons/index.ts +31 -0
- package/src/motion/fade.ts +2 -2
- package/src/motion/index.ts +3 -0
- package/src/utils/dateUtils.ts +244 -0
- package/src/utils/setPopoverPosition.ts +4 -0
- package/test/Accordion/components/AccordionAccessibility.torp +2 -0
- package/test/Accordion/components/AccordionKeyboard.torp +2 -0
- package/test/Accordion/components/AccordionList.torp +2 -0
- package/test/Accordion/components/AccordionMultiple.torp +2 -0
- package/test/Accordion/components/AccordionSingle.torp +2 -0
- package/test/Breadcrumb/accessibility.test.ts +29 -0
- package/test/Breadcrumb/basic.test.ts +17 -0
- package/test/Breadcrumb/components/BreadcrumbTest.torp +15 -0
- package/test/Calendar/components/CalendarTest.torp +9 -0
- package/test/Calendar/default.test.ts +18 -0
- package/test/Dialog/components/DialogAccessibility.torp +5 -5
- package/test/Disclosure/accessibility.test.ts +31 -0
- package/test/Disclosure/components/DisclosureTest.torp +19 -0
- package/test/Disclosure/default.test.ts +15 -0
- package/test/Disclosure/toggle.test.ts +20 -0
- 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 +83 -0
- package/test/Menu/basic.test.ts +58 -0
- package/test/Menu/components/MenuAccessibility.torp +59 -0
- package/test/Menu/components/MenuBasic.torp +58 -0
- package/test/MenuBar/accessibility.test.ts +87 -0
- package/test/MenuBar/basic.test.ts +22 -0
- package/test/MenuBar/components/MenuBarAccessibility.torp +34 -0
- package/test/MenuBar/components/MenuBarBasic.torp +25 -0
- package/test/NavMenu/basic.test.ts +1 -1
- package/test/NavMenu/components/{NavMenu.torp → NavMenuBasic.torp} +1 -1
- package/test/Notification/accessibility.test.ts +21 -0
- package/test/Notification/components/CustomNotification.torp +14 -0
- package/test/Notification/components/NotificationAccessibility.torp +14 -0
- package/test/Notification/components/NotificationFunction.torp +20 -0
- package/test/Notification/components/NotificationVariable.torp +22 -0
- package/test/Notification/function.test.ts +25 -0
- package/test/Notification/variable.test.ts +25 -0
- package/test/Popover/components/CustomDialog.torp +25 -0
- package/test/Popover/components/PromptFunction.torp +19 -0
- package/test/Popover/components/PromptVariable.torp +38 -0
- package/test/Popover/function.test.ts +26 -0
- package/test/Popover/variable.test.ts +27 -0
- package/test/TabGroup/components/TabGroupAccessibility.torp +2 -0
- package/test/TabGroup/components/TabGroupKeyboard.torp +2 -0
- package/test/TabGroup/components/TabGroupList.torp +2 -0
- package/test/TabGroup/components/TabGroupTrigger.torp +2 -0
- package/tsup.config.ts +12 -4
- package/dist/Accordion/index.cjs +0 -53
- package/dist/Accordion/index.cjs.map +0 -1
- package/dist/Dialog/index.cjs +0 -53
- package/dist/Dialog/index.cjs.map +0 -1
- package/dist/NavMenu/index.cjs +0 -78
- package/dist/NavMenu/index.cjs.map +0 -1
- package/dist/Offscreen/index.cjs +0 -33
- package/dist/Offscreen/index.cjs.map +0 -1
- package/dist/Offscreen/index.js +0 -6
- package/dist/Popover/index.cjs +0 -222
- package/dist/Popover/index.cjs.map +0 -1
- package/dist/TabGroup/index.cjs +0 -53
- package/dist/TabGroup/index.cjs.map +0 -1
- package/dist/metafile-cjs.json +0 -1
- package/dist/motion.cjs +0 -34
- package/dist/motion.cjs.map +0 -1
- package/dist/motion.d.ts +0 -6
- package/dist/motion.js.map +0 -1
- package/src/Accordion.ts +0 -7
- package/src/Dialog.ts +0 -7
- package/src/NavMenu.ts +0 -23
- package/src/Offscreen/index.ts +0 -3
- package/src/Popover.ts +0 -29
- package/src/TabGroup.ts +0 -7
- package/src/motion.ts +0 -3
- /package/dist/{Offscreen → Breadcrumb}/index.js.map +0 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { type SlotRender } from "@torpor/view";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
interface NavMenuProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Class name(s) for the root element */
|
|
8
|
+
class?: string,
|
|
9
|
+
/** An ARIA label for describing the menu to screen readers */
|
|
10
|
+
ariaLabel?: string | undefined,
|
|
11
|
+
/** The orientation of the menu, which affects keyboard navigation */
|
|
12
|
+
orientation?: "horizontal" | "vertical",
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A list of links for navigating a website.
|
|
17
|
+
*
|
|
18
|
+
* See [the WAI ARIA guidelines for Menus](https://www.w3.org/WAI/ARIA/apg/patterns/menu/).
|
|
19
|
+
*
|
|
20
|
+
* The structure of a NavMenu is:
|
|
21
|
+
*
|
|
22
|
+
* ```
|
|
23
|
+
* <NavMenu>
|
|
24
|
+
* <NavMenuLink />
|
|
25
|
+
* <NavMenuSeparator /> (optional)
|
|
26
|
+
* <NavMenuPopout /> (optional)
|
|
27
|
+
* ...
|
|
28
|
+
* </NavMenu>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare function NavMenu(
|
|
32
|
+
$parent: ParentNode,
|
|
33
|
+
$anchor: Node | null,
|
|
34
|
+
$props: NavMenuProps,
|
|
35
|
+
$context?: Record<PropertyKey, any>,
|
|
36
|
+
$slots?: Record<string, SlotRender>,
|
|
37
|
+
): void;
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
interface NavMenuButtonProps {
|
|
42
|
+
/** An ID for the root element */
|
|
43
|
+
id?: string;
|
|
44
|
+
/** Class name(s) for the root element */
|
|
45
|
+
class?: string,
|
|
46
|
+
/** Whether this button is disabled */
|
|
47
|
+
disabled?: boolean,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A button that is placed in a NavMenu to carry out a non-navigation action such as logging out.
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
declare function NavMenuButton(
|
|
55
|
+
$parent: ParentNode,
|
|
56
|
+
$anchor: Node | null,
|
|
57
|
+
$props: NavMenuButtonProps,
|
|
58
|
+
$context?: Record<PropertyKey, any>,
|
|
59
|
+
$slots?: Record<string, SlotRender>,
|
|
60
|
+
): void;
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
interface NavMenuElementProps {
|
|
65
|
+
/** An ID for the root element */
|
|
66
|
+
id?: string;
|
|
67
|
+
/** Class name(s) for the root element */
|
|
68
|
+
class?: string,
|
|
69
|
+
/** Whether this button is disabled */
|
|
70
|
+
disabled?: boolean,
|
|
71
|
+
/** An element that can be focused via keyboard navigation */
|
|
72
|
+
element?: HTMLElement,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* An element of any type that can be placed in a NavMenu.
|
|
77
|
+
*
|
|
78
|
+
*/
|
|
79
|
+
declare function NavMenuElement(
|
|
80
|
+
$parent: ParentNode,
|
|
81
|
+
$anchor: Node | null,
|
|
82
|
+
$props: NavMenuElementProps,
|
|
83
|
+
$context?: Record<PropertyKey, any>,
|
|
84
|
+
$slots?: Record<string, SlotRender>,
|
|
85
|
+
): void;
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
interface NavMenuGroupProps {
|
|
90
|
+
/** An ID for the root element */
|
|
91
|
+
id?: string;
|
|
92
|
+
/** Class name(s) for the root element */
|
|
93
|
+
class?: string,
|
|
94
|
+
/** An ARIA label for describing the group to screen readers */
|
|
95
|
+
ariaLabel?: string,
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A container for a logical group of navigation menu items.
|
|
100
|
+
*/
|
|
101
|
+
declare function NavMenuGroup(
|
|
102
|
+
$parent: ParentNode,
|
|
103
|
+
$anchor: Node | null,
|
|
104
|
+
$props: NavMenuGroupProps,
|
|
105
|
+
$context?: Record<PropertyKey, any>,
|
|
106
|
+
$slots?: Record<string, SlotRender>,
|
|
107
|
+
): void;
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
interface NavMenuGroupHeaderProps {
|
|
112
|
+
/** An ID for the root element */
|
|
113
|
+
id?: string;
|
|
114
|
+
/** Class name(s) for the root element */
|
|
115
|
+
class?: string,
|
|
116
|
+
/** The type of HTML header to use */
|
|
117
|
+
as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6",
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The header for a NavMenuGroup.
|
|
122
|
+
*/
|
|
123
|
+
declare function NavMenuGroupHeader(
|
|
124
|
+
$parent: ParentNode,
|
|
125
|
+
$anchor: Node | null,
|
|
126
|
+
$props: NavMenuGroupHeaderProps,
|
|
127
|
+
$context?: Record<PropertyKey, any>,
|
|
128
|
+
$slots?: Record<string, SlotRender>,
|
|
129
|
+
): void;
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
interface NavMenuLinkProps {
|
|
134
|
+
/** An ID for the root element */
|
|
135
|
+
id?: string;
|
|
136
|
+
/** Class name(s) for the root element */
|
|
137
|
+
class?: string,
|
|
138
|
+
/** The URL for the menu link */
|
|
139
|
+
href: string,
|
|
140
|
+
/** Whether the menu link should open in a new tab/window */
|
|
141
|
+
newWindow?: boolean,
|
|
142
|
+
/** Whether this link is disabled */
|
|
143
|
+
disabled?: boolean,
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* A link that is placed in a NavMenu and signals a response by a user.
|
|
148
|
+
*
|
|
149
|
+
*/
|
|
150
|
+
declare function NavMenuLink(
|
|
151
|
+
$parent: ParentNode,
|
|
152
|
+
$anchor: Node | null,
|
|
153
|
+
$props: NavMenuLinkProps,
|
|
154
|
+
$context?: Record<PropertyKey, any>,
|
|
155
|
+
$slots?: Record<string, SlotRender>,
|
|
156
|
+
): void;
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
interface NavMenuPopoutProps {
|
|
161
|
+
/** An ID for the root element */
|
|
162
|
+
id?: string;
|
|
163
|
+
/** Class name(s) for the root element */
|
|
164
|
+
class?: string,
|
|
165
|
+
/** Whether the popout is visible */
|
|
166
|
+
visible?: boolean,
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* A popout that is attached to a menu button and can be used to show a submenu.
|
|
171
|
+
*
|
|
172
|
+
* The structure of a NavMenuPopout is:
|
|
173
|
+
*
|
|
174
|
+
* ```
|
|
175
|
+
* <NavMenuPopout>
|
|
176
|
+
* <NavMenuPopoutButton />
|
|
177
|
+
* <NavMenuPopoutContent />
|
|
178
|
+
* </NavMenuPopout>
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
declare function NavMenuPopout(
|
|
182
|
+
$parent: ParentNode,
|
|
183
|
+
$anchor: Node | null,
|
|
184
|
+
$props: NavMenuPopoutProps,
|
|
185
|
+
$context?: Record<PropertyKey, any>,
|
|
186
|
+
$slots?: Record<string, SlotRender>,
|
|
187
|
+
): void;
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
interface NavMenuPopoutButtonProps {
|
|
192
|
+
/** An ID for the root element */
|
|
193
|
+
id?: string;
|
|
194
|
+
/** Class name(s) for the root element */
|
|
195
|
+
class?: string,
|
|
196
|
+
/** The delay before showing the popout, in milliseconds */
|
|
197
|
+
hoverDelay?: number,
|
|
198
|
+
/** Whether this button is disabled */
|
|
199
|
+
disabled?: boolean,
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* A button that is placed in a NavMenu and signals a response by a user.
|
|
204
|
+
*
|
|
205
|
+
*/
|
|
206
|
+
declare function NavMenuPopoutButton(
|
|
207
|
+
$parent: ParentNode,
|
|
208
|
+
$anchor: Node | null,
|
|
209
|
+
$props: NavMenuPopoutButtonProps,
|
|
210
|
+
$context?: Record<PropertyKey, any>,
|
|
211
|
+
$slots?: Record<string, SlotRender>,
|
|
212
|
+
): void;
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
interface NavMenuPopoutContentProps {
|
|
217
|
+
/** An ID for the root element */
|
|
218
|
+
id?: string;
|
|
219
|
+
/** Class name(s) for the root element */
|
|
220
|
+
class?: string,
|
|
221
|
+
/** Where the popout will be shown, relative to the popout button */
|
|
222
|
+
side?: "top" | "right" | "bottom" | "left",
|
|
223
|
+
/** How the popout will be aligned, relative to the popout button */
|
|
224
|
+
alignment?: "start" | "center" | "end",
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* The content that is displayed for a NavMenuPopout when it is open.
|
|
229
|
+
*
|
|
230
|
+
*/
|
|
231
|
+
declare function NavMenuPopoutContent(
|
|
232
|
+
$parent: ParentNode,
|
|
233
|
+
$anchor: Node | null,
|
|
234
|
+
$props: NavMenuPopoutContentProps,
|
|
235
|
+
$context?: Record<PropertyKey, any>,
|
|
236
|
+
$slots?: Record<string, SlotRender>,
|
|
237
|
+
): void;
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
interface NavMenuSeparatorProps {
|
|
242
|
+
/** An ID for the root element */
|
|
243
|
+
id?: string;
|
|
244
|
+
/** Class name(s) for the root element */
|
|
245
|
+
class?: string,
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* An element in a menu that separates logical sets of menu items.
|
|
250
|
+
*/
|
|
251
|
+
declare function NavMenuSeparator(
|
|
252
|
+
$parent: ParentNode,
|
|
253
|
+
$anchor: Node | null,
|
|
254
|
+
$props: NavMenuSeparatorProps,
|
|
255
|
+
$context?: Record<PropertyKey, any>,
|
|
256
|
+
$slots?: Record<string, SlotRender>,
|
|
257
|
+
): void;
|
|
258
|
+
|
|
259
|
+
export { NavMenu, NavMenuButton, NavMenuElement, NavMenuGroup, NavMenuGroupHeader, NavMenuLink, NavMenuPopout, NavMenuPopoutButton, NavMenuPopoutContent, NavMenuSeparator };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { NotificationContextName, type NotificationContext } from "./NotificationTypes";
|
|
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
|
+
|
|
16
|
+
/**
|
|
17
|
+
* An element that displays a brief, important message in a way that attracts
|
|
18
|
+
* the user's attention without interrupting the user's task.
|
|
19
|
+
*
|
|
20
|
+
* See [the WAI ARIA guidelines for Alerts](https://www.w3.org/WAI/ARIA/apg/patterns/alert/).
|
|
21
|
+
*/
|
|
22
|
+
export default function Notification($props: NotificationProps) {
|
|
23
|
+
$props ??= $watch({});
|
|
24
|
+
$props.visible ??= true;
|
|
25
|
+
$props.duration ??= 5000;
|
|
26
|
+
|
|
27
|
+
// Set the context to pass down to items
|
|
28
|
+
let context: NotificationContext = {
|
|
29
|
+
closeNotification
|
|
30
|
+
};
|
|
31
|
+
$context[NotificationContextName] = context;
|
|
32
|
+
|
|
33
|
+
$mount(() => {
|
|
34
|
+
if ($props.duration) {
|
|
35
|
+
setTimeout(closeNotification, $props.duration);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
function closeNotification() {
|
|
40
|
+
$props.visible = false;
|
|
41
|
+
|
|
42
|
+
if ($props.onclose) {
|
|
43
|
+
$props.onclose();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@render {
|
|
48
|
+
@if ($props.visible) {
|
|
49
|
+
<div
|
|
50
|
+
{$props.id}
|
|
51
|
+
class={`torp-notification ${$props.class ?? ""}`.trim()}
|
|
52
|
+
role="alert"
|
|
53
|
+
>
|
|
54
|
+
<slot />
|
|
55
|
+
</div>
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { NotificationContextName, type NotificationContext } from "./NotificationTypes";
|
|
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
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The button that a user can press to close this Notification.
|
|
12
|
+
*/
|
|
13
|
+
export default function NotificationClose($props: NotificationCloseProps) {
|
|
14
|
+
$props ??= $watch({});
|
|
15
|
+
|
|
16
|
+
// Get stuff out of the NotificationContext
|
|
17
|
+
const context = $context[NotificationContextName] as NotificationContext;
|
|
18
|
+
if (!context) {
|
|
19
|
+
throw new Error("NotificationClose must be contained within a Notification");
|
|
20
|
+
}
|
|
21
|
+
const { closeNotification } = context;
|
|
22
|
+
|
|
23
|
+
function handleClick() {
|
|
24
|
+
closeNotification();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@render {
|
|
28
|
+
<button
|
|
29
|
+
{$props.id}
|
|
30
|
+
class={`torp-notification-close ${$props.class ?? ""}`.trim()}
|
|
31
|
+
type="button"
|
|
32
|
+
onclick={handleClick}
|
|
33
|
+
>
|
|
34
|
+
<slot />
|
|
35
|
+
</button>
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The container for one or more Notifications, which can be used to position
|
|
11
|
+
* the notifications inside the viewport.
|
|
12
|
+
*/
|
|
13
|
+
export default function NotificationContainer($props: NotificationContainerProps) {
|
|
14
|
+
$props ??= $watch({});
|
|
15
|
+
|
|
16
|
+
@render {
|
|
17
|
+
<div
|
|
18
|
+
{$props.id}
|
|
19
|
+
class={`torp-notification-container ${$props.class ?? ""}`.trim()}
|
|
20
|
+
>
|
|
21
|
+
<slot />
|
|
22
|
+
</div>
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The content to display within a Notification.
|
|
11
|
+
*/
|
|
12
|
+
export default function NotificationContent($props: NotificationContentProps) {
|
|
13
|
+
$props ??= $watch({});
|
|
14
|
+
|
|
15
|
+
@render {
|
|
16
|
+
<div
|
|
17
|
+
{$props.id}
|
|
18
|
+
class={`torp-notification-content ${$props.class ?? ""}`.trim()}
|
|
19
|
+
>
|
|
20
|
+
<slot />
|
|
21
|
+
</div>
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { type SlotRender } from "@torpor/view";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
interface NotificationProps {
|
|
5
|
+
/** An ID for the root element */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** Class name(s) for the root element */
|
|
8
|
+
class?: string,
|
|
9
|
+
/** Whether the notification is visible */
|
|
10
|
+
visible?: boolean,
|
|
11
|
+
/** The duration, in milliseconds, to keep the notification visible */
|
|
12
|
+
duration?: number,
|
|
13
|
+
/** Raised when the notification has closed, either after the duration has elapsed, or when the user has pressed the close button */
|
|
14
|
+
onclose?: () => void,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* An element that displays a brief, important message in a way that attracts
|
|
19
|
+
* the user's attention without interrupting the user's task.
|
|
20
|
+
*
|
|
21
|
+
* See [the WAI ARIA guidelines for Alerts](https://www.w3.org/WAI/ARIA/apg/patterns/alert/).
|
|
22
|
+
*/
|
|
23
|
+
declare function Notification(
|
|
24
|
+
$parent: ParentNode,
|
|
25
|
+
$anchor: Node | null,
|
|
26
|
+
$props: NotificationProps,
|
|
27
|
+
$context?: Record<PropertyKey, any>,
|
|
28
|
+
$slots?: Record<string, SlotRender>,
|
|
29
|
+
): void;
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
interface NotificationCloseProps {
|
|
34
|
+
/** An ID for the root element */
|
|
35
|
+
id?: string;
|
|
36
|
+
/** Class name(s) for the root element */
|
|
37
|
+
class?: string,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The button that a user can press to close this Notification.
|
|
42
|
+
*/
|
|
43
|
+
declare function NotificationClose(
|
|
44
|
+
$parent: ParentNode,
|
|
45
|
+
$anchor: Node | null,
|
|
46
|
+
$props: NotificationCloseProps,
|
|
47
|
+
$context?: Record<PropertyKey, any>,
|
|
48
|
+
$slots?: Record<string, SlotRender>,
|
|
49
|
+
): void;
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
interface NotificationContainerProps {
|
|
54
|
+
/** An ID for the root element */
|
|
55
|
+
id?: string;
|
|
56
|
+
/** Class name(s) for the root element */
|
|
57
|
+
class?: string,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The container for one or more Notifications, which can be used to position
|
|
62
|
+
* the notifications inside the viewport.
|
|
63
|
+
*/
|
|
64
|
+
declare function NotificationContainer(
|
|
65
|
+
$parent: ParentNode,
|
|
66
|
+
$anchor: Node | null,
|
|
67
|
+
$props: NotificationContainerProps,
|
|
68
|
+
$context?: Record<PropertyKey, any>,
|
|
69
|
+
$slots?: Record<string, SlotRender>,
|
|
70
|
+
): void;
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
interface NotificationContentProps {
|
|
75
|
+
/** An ID for the root element */
|
|
76
|
+
id?: string;
|
|
77
|
+
/** Class name(s) for the root element */
|
|
78
|
+
class?: string,
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The content to display within a Notification.
|
|
83
|
+
*/
|
|
84
|
+
declare function NotificationContent(
|
|
85
|
+
$parent: ParentNode,
|
|
86
|
+
$anchor: Node | null,
|
|
87
|
+
$props: NotificationContentProps,
|
|
88
|
+
$context?: Record<PropertyKey, any>,
|
|
89
|
+
$slots?: Record<string, SlotRender>,
|
|
90
|
+
): void;
|
|
91
|
+
|
|
92
|
+
export { Notification, NotificationClose, NotificationContainer, NotificationContent };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/Notification/Notification.torp
|
|
2
|
+
import Notification_default from "./Notification.torp";
|
|
3
|
+
|
|
4
|
+
// src/Notification/NotificationClose.torp
|
|
5
|
+
import NotificationClose_default from "./NotificationClose.torp";
|
|
6
|
+
|
|
7
|
+
// src/Notification/NotificationContainer.torp
|
|
8
|
+
import NotificationContainer_default from "./NotificationContainer.torp";
|
|
9
|
+
|
|
10
|
+
// src/Notification/NotificationContent.torp
|
|
11
|
+
import NotificationContent_default from "./NotificationContent.torp";
|
|
12
|
+
|
|
13
|
+
// src/Notification/showNotification.ts
|
|
14
|
+
import { mount } from "@torpor/view";
|
|
15
|
+
function showNotification(notification, props, target) {
|
|
16
|
+
if (!target) {
|
|
17
|
+
target = document.getElementsByClassName("torp-notification-container")[0];
|
|
18
|
+
if (!target) {
|
|
19
|
+
throw new Error("No notification container found");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
var fragment = document.createDocumentFragment();
|
|
23
|
+
while (target.firstChild) {
|
|
24
|
+
fragment.append(target.firstChild);
|
|
25
|
+
}
|
|
26
|
+
mount(target, notification, props);
|
|
27
|
+
target.prepend(fragment);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
Notification_default as Notification,
|
|
31
|
+
NotificationClose_default as NotificationClose,
|
|
32
|
+
NotificationContainer_default as NotificationContainer,
|
|
33
|
+
NotificationContent_default as NotificationContent,
|
|
34
|
+
showNotification
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/Notification/showNotification.ts"],"sourcesContent":["import { mount } from \"@torpor/view\";\n\n/**\n * Shows a notification component in code.\n * @param notification The notification component\n * @param props The properties for the notification component\n * @param target The target element to show the notification in\n */\nexport default function showNotification(notification: any, props: any, target?: Element): void {\n\tif (!target) {\n\t\t// Put the notification in the first NotificationContainer, or the\n\t\t// document body if there are no NotificationContainers\n\t\ttarget = document.getElementsByClassName(\"torp-notification-container\")[0];\n\t\tif (!target) {\n\t\t\tthrow new Error(\"No notification container found\");\n\t\t}\n\t}\n\n\t// HACK: Should allow mounting in a non-empty container\n\t// Move existing nodes into a fragment, and add them back after mounting\n\tvar fragment = document.createDocumentFragment();\n\twhile (target.firstChild) {\n\t\tfragment.append(target.firstChild);\n\t}\n\n\t// Create the notification\n\tmount(target, notification, props);\n\n\ttarget.prepend(fragment);\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,aAAa;AAQP,SAAR,iBAAkC,cAAmB,OAAY,QAAwB;AAC/F,MAAI,CAAC,QAAQ;AAGZ,aAAS,SAAS,uBAAuB,6BAA6B,EAAE,CAAC;AACzE,QAAI,CAAC,QAAQ;AACZ,YAAM,IAAI,MAAM,iCAAiC;AAAA,IAClD;AAAA,EACD;AAIA,MAAI,WAAW,SAAS,uBAAuB;AAC/C,SAAO,OAAO,YAAY;AACzB,aAAS,OAAO,OAAO,UAAU;AAAA,EAClC;AAGA,QAAM,QAAQ,cAAc,KAAK;AAEjC,SAAO,QAAQ,QAAQ;AACxB;","names":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { mount } from "@torpor/view";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shows a notification component in code.
|
|
5
|
+
* @param notification The notification component
|
|
6
|
+
* @param props The properties for the notification component
|
|
7
|
+
* @param target The target element to show the notification in
|
|
8
|
+
*/
|
|
9
|
+
export default function showNotification(notification: any, props: any, target?: Element): void {
|
|
10
|
+
if (!target) {
|
|
11
|
+
// Put the notification in the first NotificationContainer, or the
|
|
12
|
+
// document body if there are no NotificationContainers
|
|
13
|
+
target = document.getElementsByClassName("torp-notification-container")[0];
|
|
14
|
+
if (!target) {
|
|
15
|
+
throw new Error("No notification container found");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// HACK: Should allow mounting in a non-empty container
|
|
20
|
+
// Move existing nodes into a fragment, and add them back after mounting
|
|
21
|
+
var fragment = document.createDocumentFragment();
|
|
22
|
+
while (target.firstChild) {
|
|
23
|
+
fragment.append(target.firstChild);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Create the notification
|
|
27
|
+
mount(target, notification, props);
|
|
28
|
+
|
|
29
|
+
target.prepend(fragment);
|
|
30
|
+
}
|
|
@@ -1,5 +1,22 @@
|
|
|
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
|
+
}
|
|
19
|
+
|
|
3
20
|
/**
|
|
4
21
|
* A popover that can be used to show rich content or obtain information from a user.
|
|
5
22
|
*
|
|
@@ -14,13 +31,10 @@ import { PopoverContextName, type Point, type PopoverContext, type PopoverState
|
|
|
14
31
|
* <PopoverContent/PopoverContentAnchored/PopoverContentContextual />
|
|
15
32
|
* </Popover>
|
|
16
33
|
* ```
|
|
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
34
|
*/
|
|
23
|
-
export default function Popover($props:
|
|
35
|
+
export default function Popover($props: PopoverProps) {
|
|
36
|
+
$props ??= $watch({});
|
|
37
|
+
|
|
24
38
|
let $state: PopoverState = $watch({
|
|
25
39
|
visible: false,
|
|
26
40
|
position: { x: 0, y: 0 }
|
|
@@ -96,10 +110,10 @@ export default function Popover($props: any) {
|
|
|
96
110
|
|
|
97
111
|
@render {
|
|
98
112
|
<div
|
|
99
|
-
|
|
113
|
+
{$props.id}
|
|
100
114
|
class={`torp-popover ${$props.class ?? ""}`.trim()}
|
|
101
115
|
>
|
|
102
|
-
|
|
116
|
+
<slot />
|
|
103
117
|
</div>
|
|
104
118
|
}
|
|
105
119
|
}
|