From 672ce2c348e179e1547e602a7c266603a3535964 Mon Sep 17 00:00:00 2001 From: "Sean T. McBeth" Date: Sun, 20 Aug 2023 13:09:00 -0400 Subject: [PATCH] onTabSelected event --- src/Juniper.TypeScript/@juniper-lib/dom/evts.ts | 4 ++-- src/Juniper.TypeScript/@juniper-lib/widgets/TabPanel/index.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Juniper.TypeScript/@juniper-lib/dom/evts.ts b/src/Juniper.TypeScript/@juniper-lib/dom/evts.ts index 7bce89c73..f114d89d9 100644 --- a/src/Juniper.TypeScript/@juniper-lib/dom/evts.ts +++ b/src/Juniper.TypeScript/@juniper-lib/dom/evts.ts @@ -3,7 +3,7 @@ import { IProgress } from "@juniper-lib/progress/IProgress"; import { isFunction } from "@juniper-lib/tslib/typeChecks"; import { HtmlRender, IElementAppliable } from "./tags"; -type EventListenerOpts = boolean | AddEventListenerOptions; +export type EventListenerOpts = boolean | AddEventListenerOptions; export function isModifierless(evt: KeyboardEvent | MouseEvent | PointerEvent) { return !(evt.shiftKey || evt.altKey || evt.ctrlKey || evt.metaKey); @@ -78,7 +78,7 @@ implements IElementAppliable { } -function onEvent(eventName: string, callback: (evt: T) => void, opts?: EventListenerOpts): HtmlEvt { return new HtmlEvt(eventName as any, callback, opts); } +export function onEvent(eventName: string, callback: (evt: T) => void, opts?: EventListenerOpts): HtmlEvt { return new HtmlEvt(eventName as any, callback, opts); } export function onAbort(callback: (evt: Event) => void, opts?: EventListenerOpts) { return onEvent("abort", callback, opts); } export function onAfterPrint(callback: (evt: Event) => void, opts?: EventListenerOpts) { return onEvent("afterprint", callback, opts); } diff --git a/src/Juniper.TypeScript/@juniper-lib/widgets/TabPanel/index.ts b/src/Juniper.TypeScript/@juniper-lib/widgets/TabPanel/index.ts index df89a5214..5c9f43dc7 100644 --- a/src/Juniper.TypeScript/@juniper-lib/widgets/TabPanel/index.ts +++ b/src/Juniper.TypeScript/@juniper-lib/widgets/TabPanel/index.ts @@ -1,6 +1,6 @@ import { CustomElement } from "@juniper-lib/dom/CustomElement"; import { ClassList, QueryAll } from "@juniper-lib/dom/attrs"; -import { onClick } from "@juniper-lib/dom/evts"; +import { EventListenerOpts, onClick, onEvent } from "@juniper-lib/dom/evts"; import { ButtonSmall, Div, ElementChild, HtmlTag, elementSetClass, elementSetDisplay, isDisableable, resolveElement } from "@juniper-lib/dom/tags"; import { EventTargetMixin } from "@juniper-lib/events/EventTarget"; import { ITypedEventTarget, TypedEvent, TypedEventListenerOrEventListenerObject } from "@juniper-lib/events/TypedEventTarget"; @@ -23,6 +23,8 @@ export function TabPanel(...rest: ElementChild[]) { }>("tab-panel", ...rest); } +export function onTabSelected(callback: (evt: TabPanelTabSelectedEvent) => void, opts?: EventListenerOpts) { return onEvent("tabselected", callback, opts); } + @CustomElement("tab-panel") export class TabPanelElement