@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
package/dist/Menu/MenuGroup.torp
CHANGED
|
@@ -11,17 +11,15 @@ interface MenuGroupProps {
|
|
|
11
11
|
/**
|
|
12
12
|
* A container for a logical group of menu items.
|
|
13
13
|
*/
|
|
14
|
-
export default function MenuGroup($props: MenuGroupProps) {
|
|
15
|
-
$props ??= $watch({});
|
|
16
|
-
|
|
14
|
+
export default function MenuGroup($props: MenuGroupProps | undefined) {
|
|
17
15
|
// TODO: Intercept the context to steal toggleItem??
|
|
18
16
|
|
|
19
17
|
@render {
|
|
20
18
|
<div
|
|
21
|
-
{$props
|
|
22
|
-
class={`torp-menu-group ${$props
|
|
19
|
+
{$props?.id}
|
|
20
|
+
class={`torp-menu-group ${$props?.class ?? ""}`.trim()}
|
|
23
21
|
role="group"
|
|
24
|
-
aria-label={$props
|
|
22
|
+
aria-label={$props?.ariaLabel}
|
|
25
23
|
>
|
|
26
24
|
<slot />
|
|
27
25
|
</div>
|
|
@@ -13,9 +13,7 @@ interface MenuIndicatorProps {
|
|
|
13
13
|
* An indicator for a MenuCheck or MenuRadio component, which is displayed
|
|
14
14
|
* when the value of checked is true.
|
|
15
15
|
*/
|
|
16
|
-
export default function MenuIndicator($props: MenuIndicatorProps) {
|
|
17
|
-
$props ??= $watch({});
|
|
18
|
-
|
|
16
|
+
export default function MenuIndicator($props: MenuIndicatorProps | undefined) {
|
|
19
17
|
// Get stuff out of the MenuButtonContext
|
|
20
18
|
const context = $context[MenuButtonContextName] as MenuButtonContext;
|
|
21
19
|
if (!context) {
|
|
@@ -26,10 +24,10 @@ export default function MenuIndicator($props: MenuIndicatorProps) {
|
|
|
26
24
|
@render {
|
|
27
25
|
@if ($state.checked) {
|
|
28
26
|
<div
|
|
29
|
-
{$props
|
|
30
|
-
class={`torp-menu-indicator ${$props
|
|
31
|
-
aria-disabled={$props
|
|
32
|
-
data-disabled={$props
|
|
27
|
+
{$props?.id}
|
|
28
|
+
class={`torp-menu-indicator ${$props?.class ?? ""}`.trim()}
|
|
29
|
+
aria-disabled={$props?.disabled ? "true" : undefined}
|
|
30
|
+
data-disabled={$props?.disabled ? "true" : undefined}
|
|
33
31
|
>
|
|
34
32
|
<slot />
|
|
35
33
|
</div>
|
|
@@ -7,12 +7,12 @@ interface MenuPopoutProps {
|
|
|
7
7
|
class?: string,
|
|
8
8
|
/** Whether the popout is visible */
|
|
9
9
|
visible?: boolean,
|
|
10
|
-
/**
|
|
10
|
+
/** Raised when the popout is opened or closed */
|
|
11
11
|
ontoggle?: (open: boolean) => void,
|
|
12
|
-
/**
|
|
12
|
+
/** Raised when the popout has opened */
|
|
13
13
|
onopen?: () => void,
|
|
14
|
-
/**
|
|
15
|
-
onclose?: () => void,
|
|
14
|
+
/** Raised when the popout has closed */
|
|
15
|
+
onclose?: (result: any) => void,
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -22,17 +22,14 @@ interface MenuPopoutProps {
|
|
|
22
22
|
*
|
|
23
23
|
* ```
|
|
24
24
|
* <MenuPopout>
|
|
25
|
-
*
|
|
25
|
+
* <MenuPopoutTrigger /> (optional)
|
|
26
26
|
* <MenuPopoutContent />
|
|
27
27
|
* </MenuPopout>
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
export default function MenuPopout($props: MenuPopoutProps) {
|
|
31
|
-
$props ??= $watch({});
|
|
32
|
-
$props.visible ??= false;
|
|
33
|
-
|
|
30
|
+
export default function MenuPopout($props: MenuPopoutProps | undefined) {
|
|
34
31
|
let $state = $watch({
|
|
35
|
-
visible: $props
|
|
32
|
+
visible: $props?.visible ?? false
|
|
36
33
|
});
|
|
37
34
|
|
|
38
35
|
let result: any;
|
|
@@ -50,9 +47,9 @@ export default function MenuPopout($props: MenuPopoutProps) {
|
|
|
50
47
|
|
|
51
48
|
let firstToggle = true;
|
|
52
49
|
$run(() => {
|
|
53
|
-
const ontoggle = $props
|
|
54
|
-
const onopen = $props
|
|
55
|
-
const onclose = $props
|
|
50
|
+
const ontoggle = $props?.ontoggle;
|
|
51
|
+
const onopen = $props?.onopen;
|
|
52
|
+
const onclose = $props?.onclose;
|
|
56
53
|
const visible = $state.visible;
|
|
57
54
|
if (firstToggle) {
|
|
58
55
|
firstToggle = false;
|
|
@@ -72,8 +69,8 @@ export default function MenuPopout($props: MenuPopoutProps) {
|
|
|
72
69
|
|
|
73
70
|
@render {
|
|
74
71
|
<div
|
|
75
|
-
{$props
|
|
76
|
-
class={`torp-menu-popout ${$props
|
|
72
|
+
{$props?.id}
|
|
73
|
+
class={`torp-menu-popout ${$props?.class ?? ""}`.trim()}
|
|
77
74
|
onmouseleave={handleMouseLeave}
|
|
78
75
|
>
|
|
79
76
|
<slot />
|
|
@@ -16,11 +16,7 @@ interface MenuPopoutContentProps {
|
|
|
16
16
|
/**
|
|
17
17
|
* The content that is displayed for a MenuPopout when it is open.
|
|
18
18
|
*/
|
|
19
|
-
export default function MenuPopoutContent($props: MenuPopoutContentProps) {
|
|
20
|
-
$props ??= $watch({});
|
|
21
|
-
$props.side ??= "right";
|
|
22
|
-
$props.alignment ??= "start";
|
|
23
|
-
|
|
19
|
+
export default function MenuPopoutContent($props: MenuPopoutContentProps | undefined) {
|
|
24
20
|
let div: HTMLDivElement;
|
|
25
21
|
let shown = false;
|
|
26
22
|
|
|
@@ -65,14 +61,16 @@ export default function MenuPopoutContent($props: MenuPopoutContentProps) {
|
|
|
65
61
|
throw new Error("MenuPopoutContent must have an anchor element");
|
|
66
62
|
}
|
|
67
63
|
|
|
68
|
-
|
|
64
|
+
let side = $props?.side ?? "right";
|
|
65
|
+
let alignment = $props?.alignment ?? "start";
|
|
66
|
+
setPopoverPosition(popoutContext.anchorElement, div, side, alignment);
|
|
69
67
|
}
|
|
70
68
|
|
|
71
69
|
@render {
|
|
72
70
|
@if ($state.visible) {
|
|
73
71
|
<div
|
|
74
|
-
{$props
|
|
75
|
-
class={`torp-menu-popout-content ${$props
|
|
72
|
+
{$props?.id}
|
|
73
|
+
class={`torp-menu-popout-content ${$props?.class ?? ""}`.trim()}
|
|
76
74
|
&ref={div}
|
|
77
75
|
onmount={show}
|
|
78
76
|
>
|
|
@@ -19,10 +19,8 @@ interface MenuPopoutTriggerProps {
|
|
|
19
19
|
/**
|
|
20
20
|
* A button that is placed in a Menu or MenuGroup and signals a response by a user.
|
|
21
21
|
*/
|
|
22
|
-
export default function MenuPopoutTrigger($props: MenuPopoutTriggerProps) {
|
|
23
|
-
|
|
24
|
-
$props.hoverDelay ??= 500;
|
|
25
|
-
$props.disabled ??= false;
|
|
22
|
+
export default function MenuPopoutTrigger($props: MenuPopoutTriggerProps | undefined) {
|
|
23
|
+
let defaultHoverDelay = 500;
|
|
26
24
|
|
|
27
25
|
let button: HTMLButtonElement;
|
|
28
26
|
let interval: NodeJS.Timeout | undefined;
|
|
@@ -72,16 +70,16 @@ export default function MenuPopoutTrigger($props: MenuPopoutTriggerProps) {
|
|
|
72
70
|
}
|
|
73
71
|
|
|
74
72
|
function handleMouseEnter() {
|
|
75
|
-
if ($props
|
|
73
|
+
if ($props?.disabled) return;
|
|
76
74
|
|
|
77
75
|
// Handle the hover after a delay
|
|
78
76
|
if (!interval) {
|
|
79
|
-
interval = setTimeout(() => setVisible(true), $props
|
|
77
|
+
interval = setTimeout(() => setVisible(true), $props?.hoverDelay ?? defaultHoverDelay);
|
|
80
78
|
}
|
|
81
79
|
}
|
|
82
80
|
|
|
83
81
|
function handleMouseLeave() {
|
|
84
|
-
if ($props
|
|
82
|
+
if ($props?.disabled) return;
|
|
85
83
|
|
|
86
84
|
// Prevent short hovers or touches from firing the event
|
|
87
85
|
if (interval) {
|
|
@@ -91,26 +89,26 @@ export default function MenuPopoutTrigger($props: MenuPopoutTriggerProps) {
|
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
function handleMouseMove() {
|
|
94
|
-
if ($props
|
|
92
|
+
if ($props?.disabled) return;
|
|
95
93
|
|
|
96
94
|
// Reset the interval on mouse move
|
|
97
95
|
if (interval) {
|
|
98
96
|
clearTimeout(interval);
|
|
99
|
-
interval = setTimeout(() => setVisible(true), $props
|
|
97
|
+
interval = setTimeout(() => setVisible(true), $props?.hoverDelay ?? defaultHoverDelay);
|
|
100
98
|
}
|
|
101
99
|
}
|
|
102
100
|
|
|
103
101
|
@render {
|
|
104
102
|
<button
|
|
105
|
-
{$props
|
|
106
|
-
class={`torp-menu-popout-trigger ${$props
|
|
103
|
+
{$props?.id}
|
|
104
|
+
class={`torp-menu-popout-trigger ${$props?.class ?? ""}`.trim()}
|
|
107
105
|
type="button"
|
|
108
|
-
{$props
|
|
106
|
+
{$props?.disabled}
|
|
109
107
|
role="menuitem"
|
|
110
108
|
aria-haspopup="true"
|
|
111
109
|
aria-expanded={($state.visible ?? false).toString()}
|
|
112
|
-
aria-disabled={$props
|
|
113
|
-
data-disabled={$props
|
|
110
|
+
aria-disabled={$props?.disabled ? "true" : undefined}
|
|
111
|
+
data-disabled={$props?.disabled ? "true" : undefined}
|
|
114
112
|
onkeydown={handlePopoutKey}
|
|
115
113
|
onclick={handleClick}
|
|
116
114
|
onfocus={() => handleItemFocus(index)}
|
package/dist/Menu/MenuRadio.torp
CHANGED
|
@@ -24,15 +24,15 @@ interface MenuRadioProps {
|
|
|
24
24
|
* A button that is placed in a Menu or MenuGroup to allow the user to select
|
|
25
25
|
* from a number of options.
|
|
26
26
|
*/
|
|
27
|
-
export default function MenuRadio($props: MenuRadioProps) {
|
|
28
|
-
$props ??= $watch({});
|
|
29
|
-
|
|
27
|
+
export default function MenuRadio($props: MenuRadioProps | undefined) {
|
|
30
28
|
let $state = $watch({
|
|
31
|
-
checked: $props
|
|
29
|
+
checked: $props?.checked ?? false,
|
|
32
30
|
});
|
|
33
31
|
|
|
34
32
|
$run(() => {
|
|
35
|
-
$props
|
|
33
|
+
if ($props !== undefined) {
|
|
34
|
+
$props.checked = $state.checked;
|
|
35
|
+
}
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
let button: HTMLButtonElement;
|
|
@@ -55,7 +55,7 @@ export default function MenuRadio($props: MenuRadioProps) {
|
|
|
55
55
|
const { index } = registerItem(setFocused);
|
|
56
56
|
|
|
57
57
|
// Register this item with the parent MenuRadioGroup
|
|
58
|
-
registerItemInGroup($props
|
|
58
|
+
registerItemInGroup($props?.value ?? "", setChecked);
|
|
59
59
|
|
|
60
60
|
// Set the context to pass down to items
|
|
61
61
|
let context: MenuButtonContext = {
|
|
@@ -73,21 +73,21 @@ export default function MenuRadio($props: MenuRadioProps) {
|
|
|
73
73
|
|
|
74
74
|
function handleClick() {
|
|
75
75
|
if (!$state.checked) {
|
|
76
|
-
toggleItem($props
|
|
76
|
+
toggleItem($props?.value ?? "");
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
@render {
|
|
81
81
|
<button
|
|
82
|
-
{$props
|
|
83
|
-
class={`torp-menu-radio ${$props
|
|
82
|
+
{$props?.id}
|
|
83
|
+
class={`torp-menu-radio ${$props?.class ?? ""}`.trim()}
|
|
84
84
|
type="button"
|
|
85
|
-
{$props
|
|
85
|
+
{$props?.disabled}
|
|
86
86
|
role="menuitemradio"
|
|
87
|
-
aria-checked={$props
|
|
88
|
-
aria-disabled={$props
|
|
89
|
-
data-state={$props
|
|
90
|
-
data-disabled={$props
|
|
87
|
+
aria-checked={$props?.checked}
|
|
88
|
+
aria-disabled={$props?.disabled ? "true" : undefined}
|
|
89
|
+
data-state={$props?.checked ? "checked" : "unchecked"}
|
|
90
|
+
data-disabled={$props?.disabled ? "true" : undefined}
|
|
91
91
|
onkeydown={handleItemKey}
|
|
92
92
|
onclick={handleClick}
|
|
93
93
|
onfocus={() => handleItemFocus(index)}
|
|
@@ -13,19 +13,27 @@ interface MenuRadioGroupProps {
|
|
|
13
13
|
ariaLabel?: string,
|
|
14
14
|
/** The value of the checked MenuRadio */
|
|
15
15
|
value?: string | undefined,
|
|
16
|
-
/**
|
|
16
|
+
/** Raised when the checked item has changed */
|
|
17
17
|
onchange?: (value: any) => void,
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* A container for a logical group of menu RadioGroup items.
|
|
22
22
|
*/
|
|
23
|
-
export default function MenuRadioGroup($props: MenuRadioGroupProps) {
|
|
24
|
-
$props ??= $watch({});
|
|
25
|
-
|
|
23
|
+
export default function MenuRadioGroup($props: MenuRadioGroupProps | undefined) {
|
|
26
24
|
// A collection containing the state and some functions for each item
|
|
27
25
|
let itemStates: RadioGroupItemState[] = [];
|
|
28
26
|
|
|
27
|
+
let $state = $watch({
|
|
28
|
+
value: $props?.value
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
$run(() => {
|
|
32
|
+
if ($props !== undefined) {
|
|
33
|
+
$props.value = $state.value;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
29
37
|
// Set the context to pass down to items
|
|
30
38
|
let context: MenuRadioGroupContext = {
|
|
31
39
|
registerItemInGroup,
|
|
@@ -35,11 +43,11 @@ export default function MenuRadioGroup($props: MenuRadioGroupProps) {
|
|
|
35
43
|
|
|
36
44
|
$mount(() => {
|
|
37
45
|
// Set the initial checked item
|
|
38
|
-
setValue($props
|
|
46
|
+
setValue($props?.value);
|
|
39
47
|
});
|
|
40
48
|
|
|
41
49
|
function registerItemInGroup(itemValue: string, setChecked: (value: boolean) => void) {
|
|
42
|
-
// Add the item
|
|
50
|
+
// Add the item's state to the array
|
|
43
51
|
const newItemState: RadioGroupItemState = {
|
|
44
52
|
value: itemValue,
|
|
45
53
|
checked: false,
|
|
@@ -63,11 +71,11 @@ export default function MenuRadioGroup($props: MenuRadioGroupProps) {
|
|
|
63
71
|
}
|
|
64
72
|
|
|
65
73
|
// Set the value
|
|
66
|
-
if ($
|
|
67
|
-
$
|
|
74
|
+
if ($state.value !== newValue) {
|
|
75
|
+
$state.value = newValue;
|
|
68
76
|
|
|
69
|
-
if ($props
|
|
70
|
-
$props
|
|
77
|
+
if ($props?.onchange) {
|
|
78
|
+
$props?.onchange($props?.value);
|
|
71
79
|
}
|
|
72
80
|
}
|
|
73
81
|
}
|
|
@@ -81,15 +89,15 @@ export default function MenuRadioGroup($props: MenuRadioGroupProps) {
|
|
|
81
89
|
newValue = item.value;
|
|
82
90
|
}
|
|
83
91
|
}
|
|
84
|
-
$
|
|
92
|
+
$state.value = newValue;
|
|
85
93
|
}
|
|
86
94
|
|
|
87
95
|
@render {
|
|
88
96
|
<div
|
|
89
|
-
{$props
|
|
90
|
-
class={`torp-menu-radio-group ${$props
|
|
97
|
+
{$props?.id}
|
|
98
|
+
class={`torp-menu-radio-group ${$props?.class ?? ""}`.trim()}
|
|
91
99
|
role="group"
|
|
92
|
-
aria-label={$props
|
|
100
|
+
aria-label={$props?.ariaLabel}
|
|
93
101
|
>
|
|
94
102
|
<slot />
|
|
95
103
|
</div>
|
|
@@ -9,13 +9,11 @@ interface MenuSeparatorProps {
|
|
|
9
9
|
/**
|
|
10
10
|
* An element in a menu that separates logical sets of menu items.
|
|
11
11
|
*/
|
|
12
|
-
export default function MenuSeparator($props: MenuSeparatorProps) {
|
|
13
|
-
$props ??= $watch({});
|
|
14
|
-
|
|
12
|
+
export default function MenuSeparator($props: MenuSeparatorProps | undefined) {
|
|
15
13
|
@render {
|
|
16
14
|
<div
|
|
17
|
-
{$props
|
|
18
|
-
class={`torp-menu-separator ${$props
|
|
15
|
+
{$props?.id}
|
|
16
|
+
class={`torp-menu-separator ${$props?.class ?? ""}`.trim()}
|
|
19
17
|
role="separator"
|
|
20
18
|
>
|
|
21
19
|
<slot />
|
package/dist/Menu/MenuTypes.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface MenuContext {
|
|
|
7
7
|
setVisible: (value: boolean, result?: any) => void;
|
|
8
8
|
|
|
9
9
|
/** Called from a MenuButton to close the Menu and return a result */
|
|
10
|
-
|
|
10
|
+
handleButton: (type: "confirm" | "cancel" | undefined, value?: any) => void;
|
|
11
11
|
|
|
12
12
|
/** Called from a MenuButton when its button is focused */
|
|
13
13
|
handleItemFocus: (index: number) => void;
|
|
@@ -15,10 +15,7 @@ export interface MenuContext {
|
|
|
15
15
|
/** Called from a MenuButton when a key is pressed */
|
|
16
16
|
handleItemKey: (e: KeyboardEvent) => void;
|
|
17
17
|
|
|
18
|
-
state:
|
|
19
|
-
/** Whether the Menu is visible. Writable so that it can be subscribed to by children */
|
|
20
|
-
visible: boolean;
|
|
21
|
-
};
|
|
18
|
+
state: MenuState;
|
|
22
19
|
|
|
23
20
|
/** The element that caused this Menu to be shown */
|
|
24
21
|
anchorElement?: HTMLElement;
|
|
@@ -27,6 +24,11 @@ export interface MenuContext {
|
|
|
27
24
|
registerItem: (setFocused: () => void) => { index: number };
|
|
28
25
|
}
|
|
29
26
|
|
|
27
|
+
export interface MenuState {
|
|
28
|
+
/** Whether the Menu is visible */
|
|
29
|
+
visible: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
30
32
|
export interface MenuButtonContext {
|
|
31
33
|
state: {
|
|
32
34
|
checked: boolean;
|
package/dist/Menu/index.d.ts
CHANGED
|
@@ -20,18 +20,18 @@ interface MenuProps {
|
|
|
20
20
|
*
|
|
21
21
|
* ```
|
|
22
22
|
* <Menu>
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
23
|
+
* <MenuButton />
|
|
24
|
+
* <MenuSeparator /> (optional)
|
|
25
|
+
* <MenuGroup> (optional)
|
|
26
|
+
* <MenuButton />
|
|
27
|
+
* </MenuGroup>
|
|
28
28
|
* </Menu>
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
declare function Menu(
|
|
32
32
|
$parent: ParentNode,
|
|
33
33
|
$anchor: Node | null,
|
|
34
|
-
$props: MenuProps,
|
|
34
|
+
$props: MenuProps | undefined,
|
|
35
35
|
$context?: Record<PropertyKey, any>,
|
|
36
36
|
$slots?: Record<string, SlotRender>,
|
|
37
37
|
): void;
|
|
@@ -47,6 +47,10 @@ interface MenuButtonProps {
|
|
|
47
47
|
value?: any,
|
|
48
48
|
/** Whether this button is disabled */
|
|
49
49
|
disabled?: boolean,
|
|
50
|
+
/** Raised when the button is clicked */
|
|
51
|
+
onclick?: (e: MouseEvent) => void,
|
|
52
|
+
/** Raised when a key is pressed down */
|
|
53
|
+
onkeydown?: (e: KeyboardEvent) => void,
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
/**
|
|
@@ -56,7 +60,7 @@ interface MenuButtonProps {
|
|
|
56
60
|
declare function MenuButton(
|
|
57
61
|
$parent: ParentNode,
|
|
58
62
|
$anchor: Node | null,
|
|
59
|
-
$props: MenuButtonProps,
|
|
63
|
+
$props: MenuButtonProps | undefined,
|
|
60
64
|
$context?: Record<PropertyKey, any>,
|
|
61
65
|
$slots?: Record<string, SlotRender>,
|
|
62
66
|
): void;
|
|
@@ -72,6 +76,8 @@ interface MenuCheckProps {
|
|
|
72
76
|
checked?: boolean,
|
|
73
77
|
/** Whether this item is disabled */
|
|
74
78
|
disabled?: boolean,
|
|
79
|
+
/** Raised when the checkbox is clicked */
|
|
80
|
+
onclick?: (e: MouseEvent) => void,
|
|
75
81
|
}
|
|
76
82
|
|
|
77
83
|
/**
|
|
@@ -82,7 +88,7 @@ interface MenuCheckProps {
|
|
|
82
88
|
declare function MenuCheck(
|
|
83
89
|
$parent: ParentNode,
|
|
84
90
|
$anchor: Node | null,
|
|
85
|
-
$props: MenuCheckProps,
|
|
91
|
+
$props: MenuCheckProps | undefined,
|
|
86
92
|
$context?: Record<PropertyKey, any>,
|
|
87
93
|
$slots?: Record<string, SlotRender>,
|
|
88
94
|
): void;
|
|
@@ -104,7 +110,7 @@ interface MenuGroupProps {
|
|
|
104
110
|
declare function MenuGroup(
|
|
105
111
|
$parent: ParentNode,
|
|
106
112
|
$anchor: Node | null,
|
|
107
|
-
$props: MenuGroupProps,
|
|
113
|
+
$props: MenuGroupProps | undefined,
|
|
108
114
|
$context?: Record<PropertyKey, any>,
|
|
109
115
|
$slots?: Record<string, SlotRender>,
|
|
110
116
|
): void;
|
|
@@ -127,7 +133,7 @@ interface MenuIndicatorProps {
|
|
|
127
133
|
declare function MenuIndicator(
|
|
128
134
|
$parent: ParentNode,
|
|
129
135
|
$anchor: Node | null,
|
|
130
|
-
$props: MenuIndicatorProps,
|
|
136
|
+
$props: MenuIndicatorProps | undefined,
|
|
131
137
|
$context?: Record<PropertyKey, any>,
|
|
132
138
|
$slots?: Record<string, SlotRender>,
|
|
133
139
|
): void;
|
|
@@ -141,12 +147,12 @@ interface MenuPopoutProps {
|
|
|
141
147
|
class?: string,
|
|
142
148
|
/** Whether the popout is visible */
|
|
143
149
|
visible?: boolean,
|
|
144
|
-
/**
|
|
150
|
+
/** Raised when the popout is opened or closed */
|
|
145
151
|
ontoggle?: (open: boolean) => void,
|
|
146
|
-
/**
|
|
152
|
+
/** Raised when the popout has opened */
|
|
147
153
|
onopen?: () => void,
|
|
148
|
-
/**
|
|
149
|
-
onclose?: () => void,
|
|
154
|
+
/** Raised when the popout has closed */
|
|
155
|
+
onclose?: (result: any) => void,
|
|
150
156
|
}
|
|
151
157
|
|
|
152
158
|
/**
|
|
@@ -156,7 +162,7 @@ interface MenuPopoutProps {
|
|
|
156
162
|
*
|
|
157
163
|
* ```
|
|
158
164
|
* <MenuPopout>
|
|
159
|
-
*
|
|
165
|
+
* <MenuPopoutTrigger /> (optional)
|
|
160
166
|
* <MenuPopoutContent />
|
|
161
167
|
* </MenuPopout>
|
|
162
168
|
* ```
|
|
@@ -164,7 +170,7 @@ interface MenuPopoutProps {
|
|
|
164
170
|
declare function MenuPopout(
|
|
165
171
|
$parent: ParentNode,
|
|
166
172
|
$anchor: Node | null,
|
|
167
|
-
$props: MenuPopoutProps,
|
|
173
|
+
$props: MenuPopoutProps | undefined,
|
|
168
174
|
$context?: Record<PropertyKey, any>,
|
|
169
175
|
$slots?: Record<string, SlotRender>,
|
|
170
176
|
): void;
|
|
@@ -188,7 +194,7 @@ interface MenuPopoutContentProps {
|
|
|
188
194
|
declare function MenuPopoutContent(
|
|
189
195
|
$parent: ParentNode,
|
|
190
196
|
$anchor: Node | null,
|
|
191
|
-
$props: MenuPopoutContentProps,
|
|
197
|
+
$props: MenuPopoutContentProps | undefined,
|
|
192
198
|
$context?: Record<PropertyKey, any>,
|
|
193
199
|
$slots?: Record<string, SlotRender>,
|
|
194
200
|
): void;
|
|
@@ -212,7 +218,7 @@ interface MenuPopoutTriggerProps {
|
|
|
212
218
|
declare function MenuPopoutTrigger(
|
|
213
219
|
$parent: ParentNode,
|
|
214
220
|
$anchor: Node | null,
|
|
215
|
-
$props: MenuPopoutTriggerProps,
|
|
221
|
+
$props: MenuPopoutTriggerProps | undefined,
|
|
216
222
|
$context?: Record<PropertyKey, any>,
|
|
217
223
|
$slots?: Record<string, SlotRender>,
|
|
218
224
|
): void;
|
|
@@ -239,7 +245,7 @@ interface MenuRadioProps {
|
|
|
239
245
|
declare function MenuRadio(
|
|
240
246
|
$parent: ParentNode,
|
|
241
247
|
$anchor: Node | null,
|
|
242
|
-
$props: MenuRadioProps,
|
|
248
|
+
$props: MenuRadioProps | undefined,
|
|
243
249
|
$context?: Record<PropertyKey, any>,
|
|
244
250
|
$slots?: Record<string, SlotRender>,
|
|
245
251
|
): void;
|
|
@@ -255,7 +261,7 @@ interface MenuRadioGroupProps {
|
|
|
255
261
|
ariaLabel?: string,
|
|
256
262
|
/** The value of the checked MenuRadio */
|
|
257
263
|
value?: string | undefined,
|
|
258
|
-
/**
|
|
264
|
+
/** Raised when the checked item has changed */
|
|
259
265
|
onchange?: (value: any) => void,
|
|
260
266
|
}
|
|
261
267
|
|
|
@@ -265,7 +271,7 @@ interface MenuRadioGroupProps {
|
|
|
265
271
|
declare function MenuRadioGroup(
|
|
266
272
|
$parent: ParentNode,
|
|
267
273
|
$anchor: Node | null,
|
|
268
|
-
$props: MenuRadioGroupProps,
|
|
274
|
+
$props: MenuRadioGroupProps | undefined,
|
|
269
275
|
$context?: Record<PropertyKey, any>,
|
|
270
276
|
$slots?: Record<string, SlotRender>,
|
|
271
277
|
): void;
|
|
@@ -285,7 +291,7 @@ interface MenuSeparatorProps {
|
|
|
285
291
|
declare function MenuSeparator(
|
|
286
292
|
$parent: ParentNode,
|
|
287
293
|
$anchor: Node | null,
|
|
288
|
-
$props: MenuSeparatorProps,
|
|
294
|
+
$props: MenuSeparatorProps | undefined,
|
|
289
295
|
$context?: Record<PropertyKey, any>,
|
|
290
296
|
$slots?: Record<string, SlotRender>,
|
|
291
297
|
): void;
|
|
@@ -20,18 +20,17 @@ interface MenuBarProps {
|
|
|
20
20
|
*
|
|
21
21
|
* ```
|
|
22
22
|
* <MenuBar>
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
23
|
+
* <MenuBarItem>
|
|
24
|
+
* <MenuBarItemTrigger />
|
|
25
|
+
* <MenuBarItemContent>
|
|
26
|
+
* <Menu />
|
|
27
|
+
* </MenuBarItemContent>
|
|
28
|
+
* </MenuBarItem>
|
|
29
29
|
* </MenuBar>
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
export default function MenuBar($props: MenuBarProps) {
|
|
33
|
-
$props
|
|
34
|
-
$props.orientation ??= "horizontal";
|
|
32
|
+
export default function MenuBar($props: MenuBarProps | undefined) {
|
|
33
|
+
let orientation = $props?.orientation ?? "horizontal";
|
|
35
34
|
|
|
36
35
|
let $state = $watch({
|
|
37
36
|
active: false,
|
|
@@ -52,7 +51,7 @@ export default function MenuBar($props: MenuBarProps) {
|
|
|
52
51
|
$context[MenuBarContextName] = context;
|
|
53
52
|
|
|
54
53
|
function registerItem(setVisible: (value: boolean) => void, setFocused: () => void) {
|
|
55
|
-
// Add the item
|
|
54
|
+
// Add the item's state to the array and return its index
|
|
56
55
|
const newItemState: ItemState = {
|
|
57
56
|
setVisible,
|
|
58
57
|
setFocused
|
|
@@ -146,12 +145,12 @@ export default function MenuBar($props: MenuBarProps) {
|
|
|
146
145
|
|
|
147
146
|
@render {
|
|
148
147
|
<div
|
|
149
|
-
{$props
|
|
150
|
-
class={`torp-menu-bar ${$props
|
|
148
|
+
{$props?.id}
|
|
149
|
+
class={`torp-menu-bar ${$props?.class ?? ""}`.trim()}
|
|
151
150
|
tabindex="-1"
|
|
152
151
|
role="menubar"
|
|
153
|
-
aria-label={$props
|
|
154
|
-
aria-orientation={
|
|
152
|
+
aria-label={$props?.ariaLabel}
|
|
153
|
+
aria-orientation={orientation}
|
|
155
154
|
>
|
|
156
155
|
<slot />
|
|
157
156
|
</div>
|
|
@@ -13,12 +13,12 @@ interface MenuBarItemProps {
|
|
|
13
13
|
class?: string,
|
|
14
14
|
/** Whether the item is visible */
|
|
15
15
|
visible?: boolean,
|
|
16
|
-
/**
|
|
16
|
+
/** Raised when the item is opened or closed */
|
|
17
17
|
ontoggle?: (visible: boolean) => void,
|
|
18
|
-
/**
|
|
18
|
+
/** Raised when the item has opened */
|
|
19
19
|
onopen?: () => void,
|
|
20
|
-
/**
|
|
21
|
-
onclose?: () => void,
|
|
20
|
+
/** Raised when the item has closed */
|
|
21
|
+
onclose?: (result: any) => void,
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -28,17 +28,14 @@ interface MenuBarItemProps {
|
|
|
28
28
|
*
|
|
29
29
|
* ```
|
|
30
30
|
* <MenuBarItem>
|
|
31
|
-
*
|
|
32
|
-
*
|
|
31
|
+
* <MenuBarItemTrigger /> (optional)
|
|
32
|
+
* <MenuBarItemContent />
|
|
33
33
|
* </MenuBarItem>
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
|
-
export default function MenuBarItem($props: MenuBarItemProps) {
|
|
37
|
-
$props ??= $watch({});
|
|
38
|
-
$props.visible ??= false;
|
|
39
|
-
|
|
36
|
+
export default function MenuBarItem($props: MenuBarItemProps | undefined) {
|
|
40
37
|
let $state = $watch({
|
|
41
|
-
visible: $props
|
|
38
|
+
visible: $props?.visible ?? false
|
|
42
39
|
});
|
|
43
40
|
|
|
44
41
|
let result: any;
|
|
@@ -83,9 +80,9 @@ export default function MenuBarItem($props: MenuBarItemProps) {
|
|
|
83
80
|
|
|
84
81
|
let firstToggle = true;
|
|
85
82
|
$run(() => {
|
|
86
|
-
const ontoggle = $props
|
|
87
|
-
const onopen = $props
|
|
88
|
-
const onclose = $props
|
|
83
|
+
const ontoggle = $props?.ontoggle;
|
|
84
|
+
const onopen = $props?.onopen;
|
|
85
|
+
const onclose = $props?.onclose;
|
|
89
86
|
const visible = $state.visible;
|
|
90
87
|
if (firstToggle) {
|
|
91
88
|
firstToggle = false;
|
|
@@ -106,8 +103,8 @@ export default function MenuBarItem($props: MenuBarItemProps) {
|
|
|
106
103
|
|
|
107
104
|
@render {
|
|
108
105
|
<div
|
|
109
|
-
{$props
|
|
110
|
-
class={`torp-menu-bar-item ${$props
|
|
106
|
+
{$props?.id}
|
|
107
|
+
class={`torp-menu-bar-item ${$props?.class ?? ""}`.trim()}
|
|
111
108
|
>
|
|
112
109
|
<slot />
|
|
113
110
|
</div>
|