@torpor/ui 0.2.1 → 0.3.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 +32 -0
- package/dist/Accordion/Accordion.torp +29 -22
- package/dist/Accordion/AccordionContent.torp +7 -8
- package/dist/Accordion/AccordionHeader.torp +4 -6
- package/dist/Accordion/AccordionItem.torp +15 -12
- package/dist/Accordion/AccordionTrigger.torp +6 -7
- package/dist/Accordion/AccordionTypes.ts +4 -3
- package/dist/Accordion/index.d.ts +5 -5
- package/dist/Breadcrumb/Breadcrumb.torp +9 -10
- package/dist/Breadcrumb/BreadcrumbItem.torp +5 -7
- package/dist/Breadcrumb/BreadcrumbSeparator.torp +3 -5
- package/dist/Breadcrumb/index.d.ts +8 -7
- package/dist/Calendar/Calendar.torp +12 -13
- package/dist/Calendar/CalendarDay.torp +3 -3
- package/dist/Contextual/Contextual.torp +125 -0
- package/dist/{Popover/PopoverContentContextual.torp → Contextual/ContextualContent.torp} +15 -15
- 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 +38 -72
- package/dist/Dialog/DialogBody.torp +6 -8
- package/dist/Dialog/DialogButton.torp +14 -12
- package/dist/Dialog/DialogFooter.torp +3 -5
- package/dist/Dialog/DialogHeader.torp +6 -8
- package/dist/Dialog/DialogTypes.ts +3 -2
- package/dist/Dialog/index.d.ts +16 -11
- package/dist/Disclosure/Disclosure.torp +22 -23
- package/dist/Disclosure/DisclosureContent.torp +7 -8
- package/dist/Disclosure/DisclosureHeader.torp +5 -7
- package/dist/Disclosure/DisclosureTrigger.torp +7 -8
- package/dist/Disclosure/DisclosureTypes.ts +0 -1
- package/dist/Disclosure/index.d.ts +12 -12
- package/dist/Drawer/Drawer.torp +101 -70
- 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 +90 -3
- package/dist/Drawer/index.js +13 -1
- package/dist/Form/CheckBox.torp +91 -0
- package/dist/Form/Field.torp +2 -4
- package/dist/Form/File.torp +106 -0
- package/dist/Form/Form.torp +17 -10
- package/dist/Form/FormTypes.ts +5 -0
- package/dist/Form/Input.torp +28 -17
- package/dist/Form/Label.torp +1 -1
- package/dist/Form/Message.torp +1 -1
- package/dist/Form/Option.torp +24 -0
- package/dist/Form/Select.torp +97 -0
- package/dist/Form/TextArea.torp +101 -0
- package/dist/Form/index.d.ts +192 -5
- package/dist/Form/index.js +21 -1
- package/dist/Menu/Menu.torp +16 -15
- package/dist/Menu/MenuButton.torp +19 -13
- package/dist/Menu/MenuCheck.torp +18 -14
- package/dist/Menu/MenuGroup.torp +4 -6
- package/dist/Menu/MenuIndicator.torp +5 -7
- package/dist/Menu/MenuPopout.torp +12 -15
- package/dist/Menu/MenuPopoutContent.torp +6 -8
- package/dist/Menu/MenuPopoutTrigger.torp +12 -14
- package/dist/Menu/MenuRadio.torp +14 -14
- package/dist/Menu/MenuRadioGroup.torp +22 -14
- package/dist/Menu/MenuSeparator.torp +3 -5
- package/dist/Menu/MenuTypes.ts +7 -5
- package/dist/Menu/index.d.ts +28 -22
- package/dist/MenuBar/MenuBar.torp +13 -14
- package/dist/MenuBar/MenuBarItem.torp +13 -16
- package/dist/MenuBar/MenuBarItemContent.torp +7 -9
- package/dist/MenuBar/MenuBarItemTrigger.torp +6 -9
- package/dist/MenuBar/index.d.ts +16 -16
- 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 +7 -8
- package/dist/NavMenu/NavMenuButton.torp +6 -8
- package/dist/NavMenu/NavMenuElement.torp +8 -8
- package/dist/NavMenu/NavMenuGroup.torp +4 -6
- package/dist/NavMenu/NavMenuGroupHeader.torp +5 -6
- package/dist/NavMenu/NavMenuLink.torp +8 -11
- package/dist/NavMenu/NavMenuPopout.torp +25 -17
- package/dist/NavMenu/NavMenuPopoutButton.torp +12 -13
- package/dist/NavMenu/NavMenuPopoutContent.torp +12 -12
- package/dist/NavMenu/NavMenuSeparator.torp +3 -5
- package/dist/NavMenu/index.d.ts +17 -11
- package/dist/Notification/Notification.torp +22 -13
- package/dist/Notification/NotificationClose.torp +3 -5
- package/dist/Notification/NotificationContainer.torp +3 -5
- package/dist/Notification/NotificationContent.torp +3 -5
- package/dist/Notification/index.d.ts +4 -4
- package/dist/Popover/Popover.torp +31 -25
- package/dist/Popover/PopoverContent.torp +35 -10
- package/dist/Popover/PopoverTrigger.torp +24 -4
- package/dist/Popover/PopoverTypes.ts +1 -1
- package/dist/Popover/index.d.ts +16 -124
- package/dist/Popover/index.js +1 -163
- package/dist/Popover/index.js.map +1 -1
- package/dist/TabGroup/TabContent.torp +12 -9
- package/dist/TabGroup/TabGroup.torp +41 -35
- package/dist/TabGroup/TabGroupTypes.ts +10 -5
- package/dist/TabGroup/TabHeader.torp +15 -8
- package/dist/TabGroup/TabList.torp +4 -6
- package/dist/TabGroup/TabTrigger.torp +8 -9
- package/dist/TabGroup/index.d.ts +14 -6
- package/dist/icons/ArrowDown.torp +3 -1
- package/dist/icons/ArrowLeft.torp +3 -1
- package/dist/icons/ArrowRight.torp +3 -1
- package/dist/icons/ArrowUp.torp +3 -1
- package/dist/icons/Bars.torp +3 -1
- package/dist/icons/Check.torp +3 -1
- package/dist/icons/ChevronDown.torp +3 -1
- package/dist/icons/ChevronLeft.torp +3 -1
- package/dist/icons/ChevronRight.torp +3 -1
- package/dist/icons/ChevronUp.torp +3 -1
- package/dist/icons/Cross.torp +3 -1
- package/dist/icons/IconTypes.ts +6 -0
- package/dist/icons/Loading.torp +3 -1
- package/dist/icons/Minus.torp +3 -1
- package/dist/icons/Plus.torp +3 -1
- package/dist/icons/index.d.ts +271 -14
- 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 +21 -14
- package/scripts/postbuild.ts +11 -1
- package/src/Accordion/Accordion.torp +29 -22
- package/src/Accordion/AccordionContent.torp +7 -8
- package/src/Accordion/AccordionHeader.torp +4 -6
- package/src/Accordion/AccordionItem.torp +15 -12
- package/src/Accordion/AccordionTrigger.torp +6 -7
- package/src/Accordion/AccordionTypes.ts +4 -3
- package/src/Breadcrumb/Breadcrumb.torp +9 -10
- package/src/Breadcrumb/BreadcrumbItem.torp +5 -7
- package/src/Breadcrumb/BreadcrumbSeparator.torp +3 -5
- package/src/Calendar/Calendar.torp +12 -13
- package/src/Calendar/CalendarDay.torp +3 -3
- package/src/Contextual/Contextual.torp +125 -0
- package/src/{Popover/PopoverContentContextual.torp → Contextual/ContextualContent.torp} +15 -15
- 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 +38 -72
- package/src/Dialog/DialogBody.torp +6 -8
- package/src/Dialog/DialogButton.torp +14 -12
- package/src/Dialog/DialogFooter.torp +3 -5
- package/src/Dialog/DialogHeader.torp +6 -8
- package/src/Dialog/DialogTypes.ts +3 -2
- package/src/Disclosure/Disclosure.torp +22 -23
- package/src/Disclosure/DisclosureContent.torp +7 -8
- package/src/Disclosure/DisclosureHeader.torp +5 -7
- package/src/Disclosure/DisclosureTrigger.torp +7 -8
- package/src/Disclosure/DisclosureTypes.ts +0 -1
- package/src/Drawer/Drawer.torp +101 -70
- 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/CheckBox.torp +91 -0
- package/src/Form/Field.torp +2 -4
- package/src/Form/File.torp +106 -0
- package/src/Form/Form.torp +17 -10
- package/src/Form/FormTypes.ts +5 -0
- package/src/Form/Input.torp +28 -17
- package/src/Form/Label.torp +1 -1
- package/src/Form/Message.torp +1 -1
- package/src/Form/Option.torp +24 -0
- package/src/Form/Select.torp +97 -0
- package/src/Form/TextArea.torp +101 -0
- package/src/Form/index.ts +6 -1
- package/src/Menu/Menu.torp +16 -15
- package/src/Menu/MenuButton.torp +19 -13
- package/src/Menu/MenuCheck.torp +18 -14
- package/src/Menu/MenuGroup.torp +4 -6
- package/src/Menu/MenuIndicator.torp +5 -7
- package/src/Menu/MenuPopout.torp +12 -15
- package/src/Menu/MenuPopoutContent.torp +6 -8
- package/src/Menu/MenuPopoutTrigger.torp +12 -14
- package/src/Menu/MenuRadio.torp +14 -14
- package/src/Menu/MenuRadioGroup.torp +22 -14
- package/src/Menu/MenuSeparator.torp +3 -5
- package/src/Menu/MenuTypes.ts +7 -5
- package/src/MenuBar/MenuBar.torp +13 -14
- package/src/MenuBar/MenuBarItem.torp +13 -16
- package/src/MenuBar/MenuBarItemContent.torp +7 -9
- package/src/MenuBar/MenuBarItemTrigger.torp +6 -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 +7 -8
- package/src/NavMenu/NavMenuButton.torp +6 -8
- package/src/NavMenu/NavMenuElement.torp +8 -8
- package/src/NavMenu/NavMenuGroup.torp +4 -6
- package/src/NavMenu/NavMenuGroupHeader.torp +5 -6
- package/src/NavMenu/NavMenuLink.torp +8 -11
- package/src/NavMenu/NavMenuPopout.torp +25 -17
- package/src/NavMenu/NavMenuPopoutButton.torp +12 -13
- package/src/NavMenu/NavMenuPopoutContent.torp +12 -12
- package/src/NavMenu/NavMenuSeparator.torp +3 -5
- package/src/Notification/Notification.torp +22 -13
- package/src/Notification/NotificationClose.torp +3 -5
- package/src/Notification/NotificationContainer.torp +3 -5
- package/src/Notification/NotificationContent.torp +3 -5
- package/src/Popover/Popover.torp +31 -25
- package/src/Popover/PopoverContent.torp +35 -10
- package/src/Popover/PopoverTrigger.torp +24 -4
- 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 +12 -9
- package/src/TabGroup/TabGroup.torp +41 -35
- package/src/TabGroup/TabGroupTypes.ts +10 -5
- package/src/TabGroup/TabHeader.torp +15 -8
- package/src/TabGroup/TabList.torp +4 -6
- package/src/TabGroup/TabTrigger.torp +8 -9
- package/src/icons/ArrowDown.torp +3 -1
- package/src/icons/ArrowLeft.torp +3 -1
- package/src/icons/ArrowRight.torp +3 -1
- package/src/icons/ArrowUp.torp +3 -1
- package/src/icons/Bars.torp +3 -1
- package/src/icons/Check.torp +3 -1
- package/src/icons/ChevronDown.torp +3 -1
- package/src/icons/ChevronLeft.torp +3 -1
- package/src/icons/ChevronRight.torp +3 -1
- package/src/icons/ChevronUp.torp +3 -1
- package/src/icons/Cross.torp +3 -1
- package/src/icons/IconTypes.ts +6 -0
- package/src/icons/Loading.torp +3 -1
- package/src/icons/Minus.torp +3 -1
- package/src/icons/Plus.torp +3 -1
- 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 -3
- package/test/Accordion/components/AccordionKeyboard.torp +1 -3
- package/test/Accordion/components/AccordionList.torp +1 -3
- package/test/Accordion/components/AccordionMultiple.torp +2 -4
- package/test/Accordion/components/AccordionSingle.torp +2 -4
- 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/components/DisclosureTest.torp +1 -3
- package/test/Menu/components/MenuAccessibility.torp +5 -5
- package/test/Menu/components/MenuBasic.torp +5 -5
- 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 -3
- package/test/TabGroup/components/TabGroupKeyboard.torp +1 -3
- package/test/TabGroup/components/TabGroupList.torp +1 -3
- package/test/TabGroup/components/TabGroupTrigger.torp +1 -3
- package/tsup.config.ts +2 -0
- package/dist/Popover/PopoverContentAnchored.torp +0 -113
- package/dist/Popover/PopoverOverlay.torp +0 -39
- package/dist/Popover/PopoverTriggerContextual.torp +0 -46
- package/dist/Popover/PopoverTriggerHover.torp +0 -47
- 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 -113
- package/src/Popover/PopoverOverlay.torp +0 -39
- package/src/Popover/PopoverTriggerContextual.torp +0 -46
- package/src/Popover/PopoverTriggerHover.torp +0 -47
- 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
|
@@ -33,9 +33,8 @@ interface NavMenuProps {
|
|
|
33
33
|
* </NavMenu>
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
|
-
export default function NavMenu($props: NavMenuProps) {
|
|
37
|
-
$props
|
|
38
|
-
$props.orientation ||= "horizontal";
|
|
36
|
+
export default function NavMenu($props: NavMenuProps | undefined) {
|
|
37
|
+
let orientation = $props?.orientation ?? "horizontal";
|
|
39
38
|
|
|
40
39
|
// A collection containing the state and some functions for each item
|
|
41
40
|
let itemStates: ItemState[] = [];
|
|
@@ -60,7 +59,7 @@ export default function NavMenu($props: NavMenuProps) {
|
|
|
60
59
|
$context[NavMenuContextName] = context;
|
|
61
60
|
|
|
62
61
|
// If the NavMenu is not in a popout, focus its first item. Otherwise the popout will call focusFirstElement, below
|
|
63
|
-
function handleFocus(
|
|
62
|
+
function handleFocus() {
|
|
64
63
|
if (!popoutContext && itemStates.length) {
|
|
65
64
|
itemStates[0].setFocused();
|
|
66
65
|
}
|
|
@@ -173,12 +172,12 @@ export default function NavMenu($props: NavMenuProps) {
|
|
|
173
172
|
|
|
174
173
|
@render {
|
|
175
174
|
<nav
|
|
176
|
-
{$props
|
|
177
|
-
class={`torp-nav-menu ${$props
|
|
175
|
+
{$props?.id}
|
|
176
|
+
class={`torp-nav-menu ${$props?.class ?? ""}`.trim()}
|
|
178
177
|
tabindex="0"
|
|
179
178
|
role="menubar"
|
|
180
|
-
aria-label={$props
|
|
181
|
-
aria-orientation={
|
|
179
|
+
aria-label={$props?.ariaLabel}
|
|
180
|
+
aria-orientation={orientation}
|
|
182
181
|
onfocus={handleFocus}
|
|
183
182
|
>
|
|
184
183
|
<slot />
|
|
@@ -13,9 +13,7 @@ interface NavMenuButtonProps {
|
|
|
13
13
|
* A button that is placed in a NavMenu to carry out a non-navigation action such as logging out.
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
|
-
export default function NavMenuButton($props: NavMenuButtonProps) {
|
|
17
|
-
$props ??= $watch({});
|
|
18
|
-
|
|
16
|
+
export default function NavMenuButton($props: NavMenuButtonProps | undefined) {
|
|
19
17
|
let button: HTMLButtonElement;
|
|
20
18
|
|
|
21
19
|
// Get stuff out of the NavMenuContext
|
|
@@ -34,13 +32,13 @@ export default function NavMenuButton($props: NavMenuButtonProps) {
|
|
|
34
32
|
|
|
35
33
|
@render {
|
|
36
34
|
<button
|
|
37
|
-
{$props
|
|
38
|
-
class={`torp-nav-menu-button ${$props
|
|
35
|
+
{$props?.id}
|
|
36
|
+
class={`torp-nav-menu-button ${$props?.class ?? ""}`.trim()}
|
|
39
37
|
type="button"
|
|
40
|
-
{$props
|
|
38
|
+
{$props?.disabled}
|
|
41
39
|
role="menuitem"
|
|
42
|
-
aria-disabled={$props
|
|
43
|
-
data-disabled={$props
|
|
40
|
+
aria-disabled={$props?.disabled ? "true" : undefined}
|
|
41
|
+
data-disabled={$props?.disabled ? "true" : undefined}
|
|
44
42
|
onkeydown
|
|
45
43
|
onkeydown={handleItemKey}
|
|
46
44
|
onclick
|
|
@@ -15,9 +15,7 @@ interface NavMenuElementProps {
|
|
|
15
15
|
* An element of any type that can be placed in a NavMenu.
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
18
|
-
export default function NavMenuElement($props: NavMenuElementProps) {
|
|
19
|
-
$props ??= $watch({});
|
|
20
|
-
|
|
18
|
+
export default function NavMenuElement($props: NavMenuElementProps | undefined) {
|
|
21
19
|
// Get stuff out of the NavMenuContext
|
|
22
20
|
const menuContext = $context[NavMenuContextName] as NavMenuContext;
|
|
23
21
|
if (!menuContext) {
|
|
@@ -29,17 +27,19 @@ export default function NavMenuElement($props: NavMenuElementProps) {
|
|
|
29
27
|
const { index } = registerItem(setFocused);
|
|
30
28
|
|
|
31
29
|
function setFocused() {
|
|
32
|
-
element
|
|
30
|
+
if ($props?.element) {
|
|
31
|
+
$props.element.focus();
|
|
32
|
+
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
@render {
|
|
36
36
|
<div
|
|
37
|
-
{$props
|
|
38
|
-
class={`torp-nav-menu-div ${$props
|
|
37
|
+
{$props?.id}
|
|
38
|
+
class={`torp-nav-menu-div ${$props?.class ?? ""}`.trim()}
|
|
39
39
|
type="div"
|
|
40
40
|
role="menuitem"
|
|
41
|
-
aria-disabled={$props
|
|
42
|
-
data-disabled={$props
|
|
41
|
+
aria-disabled={$props?.disabled ? "true" : undefined}
|
|
42
|
+
data-disabled={$props?.disabled ? "true" : undefined}
|
|
43
43
|
onkeydown
|
|
44
44
|
onkeydown={handleItemKey}
|
|
45
45
|
onclick
|
|
@@ -12,9 +12,7 @@ interface NavMenuGroupProps {
|
|
|
12
12
|
/**
|
|
13
13
|
* A container for a logical group of navigation menu items.
|
|
14
14
|
*/
|
|
15
|
-
export default function NavMenuGroup($props: NavMenuGroupProps) {
|
|
16
|
-
$props ??= $watch({});
|
|
17
|
-
|
|
15
|
+
export default function NavMenuGroup($props: NavMenuGroupProps | undefined) {
|
|
18
16
|
let $state = $watch({
|
|
19
17
|
headerId: ""
|
|
20
18
|
});
|
|
@@ -27,10 +25,10 @@ export default function NavMenuGroup($props: NavMenuGroupProps) {
|
|
|
27
25
|
|
|
28
26
|
@render {
|
|
29
27
|
<div
|
|
30
|
-
{$props
|
|
31
|
-
class={`torp-nav-menu-group ${$props
|
|
28
|
+
{$props?.id}
|
|
29
|
+
class={`torp-nav-menu-group ${$props?.class ?? ""}`.trim()}
|
|
32
30
|
role="group"
|
|
33
|
-
aria-label={$props
|
|
31
|
+
aria-label={$props?.ariaLabel}
|
|
34
32
|
aria-labelledby={$state.headerId}
|
|
35
33
|
>
|
|
36
34
|
<slot />
|
|
@@ -13,9 +13,8 @@ interface NavMenuGroupHeaderProps {
|
|
|
13
13
|
/**
|
|
14
14
|
* The header for a NavMenuGroup.
|
|
15
15
|
*/
|
|
16
|
-
export default function NavMenuGroupHeader($props: NavMenuGroupHeaderProps) {
|
|
17
|
-
|
|
18
|
-
$props.id ??= getId();
|
|
16
|
+
export default function NavMenuGroupHeader($props: NavMenuGroupHeaderProps | undefined) {
|
|
17
|
+
let defaultId = getId();
|
|
19
18
|
|
|
20
19
|
const context = $context[NavMenuGroupContextName] as NavMenuGroupContext;
|
|
21
20
|
if (!context) {
|
|
@@ -24,13 +23,13 @@ export default function NavMenuGroupHeader($props: NavMenuGroupHeaderProps) {
|
|
|
24
23
|
let $state = context.state;
|
|
25
24
|
|
|
26
25
|
// Set the header ID now that we know what it is
|
|
27
|
-
$state.headerId = $props
|
|
26
|
+
$state.headerId = $props?.id ?? defaultId;
|
|
28
27
|
|
|
29
28
|
@render {
|
|
30
29
|
@// TODO: self={$props.as}
|
|
31
30
|
<h4
|
|
32
|
-
{$props
|
|
33
|
-
class={`torp-nav-menu-group-header ${$props
|
|
31
|
+
id={$props?.id ?? defaultId}
|
|
32
|
+
class={`torp-nav-menu-group-header ${$props?.class ?? ""}`.trim()}
|
|
34
33
|
>
|
|
35
34
|
<slot />
|
|
36
35
|
</h4>
|
|
@@ -18,10 +18,7 @@ interface NavMenuLinkProps {
|
|
|
18
18
|
* A link that is placed in a NavMenu and signals a response by a user.
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
|
-
export default function NavMenuLink($props: NavMenuLinkProps) {
|
|
22
|
-
$props ??= $watch({ href: "#" });
|
|
23
|
-
$props.newWindow ??= false;
|
|
24
|
-
|
|
21
|
+
export default function NavMenuLink($props: NavMenuLinkProps | undefined) {
|
|
25
22
|
let link: HTMLAnchorElement;
|
|
26
23
|
|
|
27
24
|
// Get stuff out of the NavMenuContext
|
|
@@ -40,14 +37,14 @@ export default function NavMenuLink($props: NavMenuLinkProps) {
|
|
|
40
37
|
|
|
41
38
|
@render {
|
|
42
39
|
<a
|
|
43
|
-
{$props
|
|
44
|
-
class={`torp-nav-menu-link ${$props
|
|
45
|
-
|
|
46
|
-
{$props
|
|
47
|
-
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}
|
|
48
45
|
role="menuitem"
|
|
49
|
-
aria-disabled={$props
|
|
50
|
-
data-disabled={$props
|
|
46
|
+
aria-disabled={$props?.disabled ? "true" : undefined}
|
|
47
|
+
data-disabled={$props?.disabled ? "true" : undefined}
|
|
51
48
|
onkeydown
|
|
52
49
|
onkeydown={handleItemKey}
|
|
53
50
|
onclick
|
|
@@ -7,6 +7,12 @@ interface NavMenuPopoutProps {
|
|
|
7
7
|
class?: string,
|
|
8
8
|
/** Whether the popout is visible */
|
|
9
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,
|
|
10
16
|
}
|
|
11
17
|
|
|
12
18
|
/**
|
|
@@ -16,17 +22,24 @@ interface NavMenuPopoutProps {
|
|
|
16
22
|
*
|
|
17
23
|
* ```
|
|
18
24
|
* <NavMenuPopout>
|
|
19
|
-
*
|
|
25
|
+
* <NavMenuPopoutButton />
|
|
20
26
|
* <NavMenuPopoutContent />
|
|
21
27
|
* </NavMenuPopout>
|
|
22
28
|
* ```
|
|
23
29
|
*/
|
|
24
|
-
export default function NavMenuPopout($props: NavMenuPopoutProps) {
|
|
25
|
-
$props ??= $watch({});
|
|
26
|
-
$props.visible ??= false;
|
|
27
|
-
|
|
30
|
+
export default function NavMenuPopout($props: NavMenuPopoutProps | undefined) {
|
|
28
31
|
let $state = $watch({
|
|
29
|
-
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
|
+
}
|
|
30
43
|
});
|
|
31
44
|
|
|
32
45
|
let result: any;
|
|
@@ -37,18 +50,13 @@ export default function NavMenuPopout($props: NavMenuPopoutProps) {
|
|
|
37
50
|
};
|
|
38
51
|
$context[NavMenuPopoutContextName] = context;
|
|
39
52
|
|
|
40
|
-
// Copy props into state whenever they change
|
|
41
|
-
$run(() => {
|
|
42
|
-
$state.visible = $props.visible ?? false;
|
|
43
|
-
});
|
|
44
|
-
|
|
45
53
|
// Dispatch the toggle event when the popout is opened or closed
|
|
46
54
|
let firstToggle = true;
|
|
47
55
|
$run(() => {
|
|
48
|
-
const ontoggle = $props
|
|
49
|
-
const onopen = $props
|
|
50
|
-
const onclose = $props
|
|
51
|
-
const visible = $
|
|
56
|
+
const ontoggle = $props?.ontoggle;
|
|
57
|
+
const onopen = $props?.onopen;
|
|
58
|
+
const onclose = $props?.onclose;
|
|
59
|
+
const visible = $state.visible;
|
|
52
60
|
if (firstToggle) {
|
|
53
61
|
firstToggle = false;
|
|
54
62
|
} else {
|
|
@@ -67,8 +75,8 @@ export default function NavMenuPopout($props: NavMenuPopoutProps) {
|
|
|
67
75
|
|
|
68
76
|
@render {
|
|
69
77
|
<div
|
|
70
|
-
{$props
|
|
71
|
-
class={`torp-nav-menu-popout ${$props
|
|
78
|
+
{$props?.id}
|
|
79
|
+
class={`torp-nav-menu-popout ${$props?.class ?? ""}`.trim()}
|
|
72
80
|
onmouseleave={handleMouseLeave}
|
|
73
81
|
>
|
|
74
82
|
<slot />
|
|
@@ -20,9 +20,8 @@ interface NavMenuPopoutButtonProps {
|
|
|
20
20
|
* A button that is placed in a NavMenu and signals a response by a user.
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
export default function NavMenuPopoutButton($props: NavMenuPopoutButtonProps) {
|
|
24
|
-
|
|
25
|
-
$props.hoverDelay ??= 500;
|
|
23
|
+
export default function NavMenuPopoutButton($props: NavMenuPopoutButtonProps | undefined) {
|
|
24
|
+
let defaultHoverDelay = 500;
|
|
26
25
|
|
|
27
26
|
let button: HTMLButtonElement;
|
|
28
27
|
let interval: NodeJS.Timeout | undefined;
|
|
@@ -72,16 +71,16 @@ export default function NavMenuPopoutButton($props: NavMenuPopoutButtonProps) {
|
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
function handleMouseEnter() {
|
|
75
|
-
if ($props
|
|
74
|
+
if ($props?.disabled) return;
|
|
76
75
|
|
|
77
76
|
// Handle the hover after a delay
|
|
78
77
|
if (!interval) {
|
|
79
|
-
interval = setTimeout(() => $state.visible = true, $props
|
|
78
|
+
interval = setTimeout(() => $state.visible = true, $props?.hoverDelay ?? defaultHoverDelay);
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
function handleMouseLeave() {
|
|
84
|
-
if ($props
|
|
83
|
+
if ($props?.disabled) return;
|
|
85
84
|
|
|
86
85
|
// Prevent short hovers or touches from firing the event
|
|
87
86
|
if (interval) {
|
|
@@ -91,26 +90,26 @@ export default function NavMenuPopoutButton($props: NavMenuPopoutButtonProps) {
|
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
function handleMouseMove() {
|
|
94
|
-
if ($props
|
|
93
|
+
if ($props?.disabled) return;
|
|
95
94
|
|
|
96
95
|
// Reset the interval on mouse move
|
|
97
96
|
if (interval) {
|
|
98
97
|
clearTimeout(interval);
|
|
99
|
-
interval = setTimeout(() => $state.visible = true, $props
|
|
98
|
+
interval = setTimeout(() => $state.visible = true, $props?.hoverDelay ?? defaultHoverDelay);
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
@render {
|
|
104
103
|
<button
|
|
105
|
-
{$props
|
|
106
|
-
class={`torp-nav-menu-popout-button ${$props
|
|
104
|
+
{$props?.id}
|
|
105
|
+
class={`torp-nav-menu-popout-button ${$props?.class ?? ""}`.trim()}
|
|
107
106
|
type="button"
|
|
108
|
-
{$props
|
|
107
|
+
{$props?.disabled}
|
|
109
108
|
role="menuitem"
|
|
110
109
|
aria-haspopup="true"
|
|
111
110
|
aria-expanded={$state.visible.toString()}
|
|
112
|
-
aria-disabled={$props
|
|
113
|
-
data-disabled={$
|
|
111
|
+
aria-disabled={$props?.disabled ? "true" : undefined}
|
|
112
|
+
data-disabled={$props?.disabled ? "true" : undefined}
|
|
114
113
|
onkeydown={handlePopoutKey}
|
|
115
114
|
onclick={handleClick}
|
|
116
115
|
onfocus={() => handleItemFocus(index)}
|
|
@@ -18,11 +18,7 @@ interface NavMenuPopoutContentProps {
|
|
|
18
18
|
* The content that is displayed for a NavMenuPopout when it is open.
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
|
-
export default function NavMenuPopoutContent($props: NavMenuPopoutContentProps) {
|
|
22
|
-
$props ??= $watch({});
|
|
23
|
-
$props.side ??= "bottom";
|
|
24
|
-
$props.alignment ??= "start";
|
|
25
|
-
|
|
21
|
+
export default function NavMenuPopoutContent($props: NavMenuPopoutContentProps | undefined) {
|
|
26
22
|
let div: HTMLDivElement;
|
|
27
23
|
let shown = false;
|
|
28
24
|
|
|
@@ -44,7 +40,8 @@ export default function NavMenuPopoutContent($props: NavMenuPopoutContentProps)
|
|
|
44
40
|
|
|
45
41
|
// Set the position and listen for window resize and scroll to reset the position
|
|
46
42
|
setPosition();
|
|
47
|
-
const
|
|
43
|
+
const anchorElement = context.anchorElement!
|
|
44
|
+
const scrollParent = getScrollParent(anchorElement)
|
|
48
45
|
scrollParent.addEventListener("resize", setPosition);
|
|
49
46
|
scrollParent.addEventListener("scroll", setPosition);
|
|
50
47
|
if (context.focusFirstElement) {
|
|
@@ -56,11 +53,12 @@ export default function NavMenuPopoutContent($props: NavMenuPopoutContentProps)
|
|
|
56
53
|
if (!shown) return;
|
|
57
54
|
|
|
58
55
|
// Stop listening for window resize and focus the anchor element per WAI guidelines
|
|
59
|
-
const
|
|
56
|
+
const anchorElement = context.anchorElement!
|
|
57
|
+
const scrollParent = getScrollParent(anchorElement)
|
|
60
58
|
scrollParent.removeEventListener("resize", setPosition);
|
|
61
59
|
scrollParent.removeEventListener("scroll", setPosition);
|
|
62
|
-
if (
|
|
63
|
-
|
|
60
|
+
if (anchorElement.focus) {
|
|
61
|
+
anchorElement.focus();
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
64
|
|
|
@@ -70,15 +68,17 @@ export default function NavMenuPopoutContent($props: NavMenuPopoutContentProps)
|
|
|
70
68
|
}
|
|
71
69
|
|
|
72
70
|
if (div) {
|
|
73
|
-
|
|
71
|
+
let side = $props?.side ?? "bottom";
|
|
72
|
+
let alignment = $props?.alignment ?? "start";
|
|
73
|
+
setPopoverPosition(context.anchorElement, div, side, alignment);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
@render {
|
|
78
78
|
@if ($state.visible) {
|
|
79
79
|
<div
|
|
80
|
-
{$props
|
|
81
|
-
class={`torp-nav-menu-popout-content ${$props
|
|
80
|
+
{$props?.id}
|
|
81
|
+
class={`torp-nav-menu-popout-content ${$props?.class ?? ""}`.trim()}
|
|
82
82
|
&ref={div}
|
|
83
83
|
onmount={show}
|
|
84
84
|
>
|
|
@@ -9,13 +9,11 @@ interface NavMenuSeparatorProps {
|
|
|
9
9
|
/**
|
|
10
10
|
* An element in a menu that separates logical sets of menu items.
|
|
11
11
|
*/
|
|
12
|
-
export default function NavMenuSeparator($props: NavMenuSeparatorProps) {
|
|
13
|
-
$props ??= $watch({});
|
|
14
|
-
|
|
12
|
+
export default function NavMenuSeparator($props: NavMenuSeparatorProps | undefined) {
|
|
15
13
|
@render {
|
|
16
14
|
<div
|
|
17
|
-
{$props
|
|
18
|
-
class={`torp-nav-menu-separator ${$props
|
|
15
|
+
{$props?.id}
|
|
16
|
+
class={`torp-nav-menu-separator ${$props?.class ?? ""}`.trim()} role="separator"
|
|
19
17
|
>
|
|
20
18
|
<slot />
|
|
21
19
|
</div>
|
package/dist/NavMenu/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ interface NavMenuProps {
|
|
|
31
31
|
declare function NavMenu(
|
|
32
32
|
$parent: ParentNode,
|
|
33
33
|
$anchor: Node | null,
|
|
34
|
-
$props: NavMenuProps,
|
|
34
|
+
$props: NavMenuProps | undefined,
|
|
35
35
|
$context?: Record<PropertyKey, any>,
|
|
36
36
|
$slots?: Record<string, SlotRender>,
|
|
37
37
|
): void;
|
|
@@ -54,7 +54,7 @@ interface NavMenuButtonProps {
|
|
|
54
54
|
declare function NavMenuButton(
|
|
55
55
|
$parent: ParentNode,
|
|
56
56
|
$anchor: Node | null,
|
|
57
|
-
$props: NavMenuButtonProps,
|
|
57
|
+
$props: NavMenuButtonProps | undefined,
|
|
58
58
|
$context?: Record<PropertyKey, any>,
|
|
59
59
|
$slots?: Record<string, SlotRender>,
|
|
60
60
|
): void;
|
|
@@ -79,7 +79,7 @@ interface NavMenuElementProps {
|
|
|
79
79
|
declare function NavMenuElement(
|
|
80
80
|
$parent: ParentNode,
|
|
81
81
|
$anchor: Node | null,
|
|
82
|
-
$props: NavMenuElementProps,
|
|
82
|
+
$props: NavMenuElementProps | undefined,
|
|
83
83
|
$context?: Record<PropertyKey, any>,
|
|
84
84
|
$slots?: Record<string, SlotRender>,
|
|
85
85
|
): void;
|
|
@@ -101,7 +101,7 @@ interface NavMenuGroupProps {
|
|
|
101
101
|
declare function NavMenuGroup(
|
|
102
102
|
$parent: ParentNode,
|
|
103
103
|
$anchor: Node | null,
|
|
104
|
-
$props: NavMenuGroupProps,
|
|
104
|
+
$props: NavMenuGroupProps | undefined,
|
|
105
105
|
$context?: Record<PropertyKey, any>,
|
|
106
106
|
$slots?: Record<string, SlotRender>,
|
|
107
107
|
): void;
|
|
@@ -123,7 +123,7 @@ interface NavMenuGroupHeaderProps {
|
|
|
123
123
|
declare function NavMenuGroupHeader(
|
|
124
124
|
$parent: ParentNode,
|
|
125
125
|
$anchor: Node | null,
|
|
126
|
-
$props: NavMenuGroupHeaderProps,
|
|
126
|
+
$props: NavMenuGroupHeaderProps | undefined,
|
|
127
127
|
$context?: Record<PropertyKey, any>,
|
|
128
128
|
$slots?: Record<string, SlotRender>,
|
|
129
129
|
): void;
|
|
@@ -150,7 +150,7 @@ interface NavMenuLinkProps {
|
|
|
150
150
|
declare function NavMenuLink(
|
|
151
151
|
$parent: ParentNode,
|
|
152
152
|
$anchor: Node | null,
|
|
153
|
-
$props: NavMenuLinkProps,
|
|
153
|
+
$props: NavMenuLinkProps | undefined,
|
|
154
154
|
$context?: Record<PropertyKey, any>,
|
|
155
155
|
$slots?: Record<string, SlotRender>,
|
|
156
156
|
): void;
|
|
@@ -164,6 +164,12 @@ interface NavMenuPopoutProps {
|
|
|
164
164
|
class?: string,
|
|
165
165
|
/** Whether the popout is visible */
|
|
166
166
|
visible?: boolean,
|
|
167
|
+
/** Raised when the popout is opened or closed */
|
|
168
|
+
ontoggle?: (open: boolean) => void,
|
|
169
|
+
/** Raised when the popout has opened */
|
|
170
|
+
onopen?: () => void,
|
|
171
|
+
/** Raised when the popout has closed */
|
|
172
|
+
onclose?: (result: any) => void,
|
|
167
173
|
}
|
|
168
174
|
|
|
169
175
|
/**
|
|
@@ -173,7 +179,7 @@ interface NavMenuPopoutProps {
|
|
|
173
179
|
*
|
|
174
180
|
* ```
|
|
175
181
|
* <NavMenuPopout>
|
|
176
|
-
*
|
|
182
|
+
* <NavMenuPopoutButton />
|
|
177
183
|
* <NavMenuPopoutContent />
|
|
178
184
|
* </NavMenuPopout>
|
|
179
185
|
* ```
|
|
@@ -181,7 +187,7 @@ interface NavMenuPopoutProps {
|
|
|
181
187
|
declare function NavMenuPopout(
|
|
182
188
|
$parent: ParentNode,
|
|
183
189
|
$anchor: Node | null,
|
|
184
|
-
$props: NavMenuPopoutProps,
|
|
190
|
+
$props: NavMenuPopoutProps | undefined,
|
|
185
191
|
$context?: Record<PropertyKey, any>,
|
|
186
192
|
$slots?: Record<string, SlotRender>,
|
|
187
193
|
): void;
|
|
@@ -206,7 +212,7 @@ interface NavMenuPopoutButtonProps {
|
|
|
206
212
|
declare function NavMenuPopoutButton(
|
|
207
213
|
$parent: ParentNode,
|
|
208
214
|
$anchor: Node | null,
|
|
209
|
-
$props: NavMenuPopoutButtonProps,
|
|
215
|
+
$props: NavMenuPopoutButtonProps | undefined,
|
|
210
216
|
$context?: Record<PropertyKey, any>,
|
|
211
217
|
$slots?: Record<string, SlotRender>,
|
|
212
218
|
): void;
|
|
@@ -231,7 +237,7 @@ interface NavMenuPopoutContentProps {
|
|
|
231
237
|
declare function NavMenuPopoutContent(
|
|
232
238
|
$parent: ParentNode,
|
|
233
239
|
$anchor: Node | null,
|
|
234
|
-
$props: NavMenuPopoutContentProps,
|
|
240
|
+
$props: NavMenuPopoutContentProps | undefined,
|
|
235
241
|
$context?: Record<PropertyKey, any>,
|
|
236
242
|
$slots?: Record<string, SlotRender>,
|
|
237
243
|
): void;
|
|
@@ -251,7 +257,7 @@ interface NavMenuSeparatorProps {
|
|
|
251
257
|
declare function NavMenuSeparator(
|
|
252
258
|
$parent: ParentNode,
|
|
253
259
|
$anchor: Node | null,
|
|
254
|
-
$props: NavMenuSeparatorProps,
|
|
260
|
+
$props: NavMenuSeparatorProps | undefined,
|
|
255
261
|
$context?: Record<PropertyKey, any>,
|
|
256
262
|
$slots?: Record<string, SlotRender>,
|
|
257
263
|
): void;
|
|
@@ -19,10 +19,21 @@ interface NotificationProps {
|
|
|
19
19
|
*
|
|
20
20
|
* See [the WAI ARIA guidelines for Alerts](https://www.w3.org/WAI/ARIA/apg/patterns/alert/).
|
|
21
21
|
*/
|
|
22
|
-
export default function Notification($props: NotificationProps) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
$
|
|
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
|
+
});
|
|
26
37
|
|
|
27
38
|
// Set the context to pass down to items
|
|
28
39
|
let context: NotificationContext = {
|
|
@@ -31,24 +42,22 @@ export default function Notification($props: NotificationProps) {
|
|
|
31
42
|
$context[NotificationContextName] = context;
|
|
32
43
|
|
|
33
44
|
$mount(() => {
|
|
34
|
-
|
|
35
|
-
setTimeout(closeNotification, $props.duration);
|
|
36
|
-
}
|
|
45
|
+
setTimeout(closeNotification, $props?.duration ?? defaultDuration);
|
|
37
46
|
});
|
|
38
47
|
|
|
39
48
|
function closeNotification() {
|
|
40
|
-
$
|
|
49
|
+
$state.visible = false;
|
|
41
50
|
|
|
42
|
-
if ($props
|
|
43
|
-
$props
|
|
51
|
+
if ($props?.onclose) {
|
|
52
|
+
$props?.onclose();
|
|
44
53
|
}
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
@render {
|
|
48
|
-
@if ($
|
|
57
|
+
@if ($state.visible) {
|
|
49
58
|
<div
|
|
50
|
-
{$props
|
|
51
|
-
class={`torp-notification ${$props
|
|
59
|
+
{$props?.id}
|
|
60
|
+
class={`torp-notification ${$props?.class ?? ""}`.trim()}
|
|
52
61
|
role="alert"
|
|
53
62
|
>
|
|
54
63
|
<slot />
|
|
@@ -10,9 +10,7 @@ interface NotificationCloseProps {
|
|
|
10
10
|
/**
|
|
11
11
|
* The button that a user can press to close this Notification.
|
|
12
12
|
*/
|
|
13
|
-
export default function NotificationClose($props: NotificationCloseProps) {
|
|
14
|
-
$props ??= $watch({});
|
|
15
|
-
|
|
13
|
+
export default function NotificationClose($props: NotificationCloseProps | undefined) {
|
|
16
14
|
// Get stuff out of the NotificationContext
|
|
17
15
|
const context = $context[NotificationContextName] as NotificationContext;
|
|
18
16
|
if (!context) {
|
|
@@ -26,8 +24,8 @@ export default function NotificationClose($props: NotificationCloseProps) {
|
|
|
26
24
|
|
|
27
25
|
@render {
|
|
28
26
|
<button
|
|
29
|
-
{$props
|
|
30
|
-
class={`torp-notification-close ${$props
|
|
27
|
+
{$props?.id}
|
|
28
|
+
class={`torp-notification-close ${$props?.class ?? ""}`.trim()}
|
|
31
29
|
type="button"
|
|
32
30
|
onclick={handleClick}
|
|
33
31
|
>
|
|
@@ -10,13 +10,11 @@ interface NotificationContainerProps {
|
|
|
10
10
|
* The container for one or more Notifications, which can be used to position
|
|
11
11
|
* the notifications inside the viewport.
|
|
12
12
|
*/
|
|
13
|
-
export default function NotificationContainer($props: NotificationContainerProps) {
|
|
14
|
-
$props ??= $watch({});
|
|
15
|
-
|
|
13
|
+
export default function NotificationContainer($props: NotificationContainerProps | undefined) {
|
|
16
14
|
@render {
|
|
17
15
|
<div
|
|
18
|
-
{$props
|
|
19
|
-
class={`torp-notification-container ${$props
|
|
16
|
+
{$props?.id}
|
|
17
|
+
class={`torp-notification-container ${$props?.class ?? ""}`.trim()}
|
|
20
18
|
>
|
|
21
19
|
<slot />
|
|
22
20
|
</div>
|
|
@@ -9,13 +9,11 @@ interface NotificationContentProps {
|
|
|
9
9
|
/**
|
|
10
10
|
* The content to display within a Notification.
|
|
11
11
|
*/
|
|
12
|
-
export default function NotificationContent($props: NotificationContentProps) {
|
|
13
|
-
$props ??= $watch({});
|
|
14
|
-
|
|
12
|
+
export default function NotificationContent($props: NotificationContentProps | undefined) {
|
|
15
13
|
@render {
|
|
16
14
|
<div
|
|
17
|
-
{$props
|
|
18
|
-
class={`torp-notification-content ${$props
|
|
15
|
+
{$props?.id}
|
|
16
|
+
class={`torp-notification-content ${$props?.class ?? ""}`.trim()}
|
|
19
17
|
>
|
|
20
18
|
<slot />
|
|
21
19
|
</div>
|
|
@@ -23,7 +23,7 @@ interface NotificationProps {
|
|
|
23
23
|
declare function Notification(
|
|
24
24
|
$parent: ParentNode,
|
|
25
25
|
$anchor: Node | null,
|
|
26
|
-
$props: NotificationProps,
|
|
26
|
+
$props: NotificationProps | undefined,
|
|
27
27
|
$context?: Record<PropertyKey, any>,
|
|
28
28
|
$slots?: Record<string, SlotRender>,
|
|
29
29
|
): void;
|
|
@@ -43,7 +43,7 @@ interface NotificationCloseProps {
|
|
|
43
43
|
declare function NotificationClose(
|
|
44
44
|
$parent: ParentNode,
|
|
45
45
|
$anchor: Node | null,
|
|
46
|
-
$props: NotificationCloseProps,
|
|
46
|
+
$props: NotificationCloseProps | undefined,
|
|
47
47
|
$context?: Record<PropertyKey, any>,
|
|
48
48
|
$slots?: Record<string, SlotRender>,
|
|
49
49
|
): void;
|
|
@@ -64,7 +64,7 @@ interface NotificationContainerProps {
|
|
|
64
64
|
declare function NotificationContainer(
|
|
65
65
|
$parent: ParentNode,
|
|
66
66
|
$anchor: Node | null,
|
|
67
|
-
$props: NotificationContainerProps,
|
|
67
|
+
$props: NotificationContainerProps | undefined,
|
|
68
68
|
$context?: Record<PropertyKey, any>,
|
|
69
69
|
$slots?: Record<string, SlotRender>,
|
|
70
70
|
): void;
|
|
@@ -84,7 +84,7 @@ interface NotificationContentProps {
|
|
|
84
84
|
declare function NotificationContent(
|
|
85
85
|
$parent: ParentNode,
|
|
86
86
|
$anchor: Node | null,
|
|
87
|
-
$props: NotificationContentProps,
|
|
87
|
+
$props: NotificationContentProps | undefined,
|
|
88
88
|
$context?: Record<PropertyKey, any>,
|
|
89
89
|
$slots?: Record<string, SlotRender>,
|
|
90
90
|
): void;
|