Skip to content

Commit

Permalink
onTabSelected event
Browse files Browse the repository at this point in the history
  • Loading branch information
capnmidnight committed Aug 20, 2023
1 parent dd6bd67 commit 672ce2c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Juniper.TypeScript/@juniper-lib/dom/evts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -78,7 +78,7 @@ implements IElementAppliable {
}


function onEvent<T extends Event>(eventName: string, callback: (evt: T) => void, opts?: EventListenerOpts): HtmlEvt<T> { return new HtmlEvt<T>(eventName as any, callback, opts); }
export function onEvent<T extends Event>(eventName: string, callback: (evt: T) => void, opts?: EventListenerOpts): HtmlEvt<T> { return new HtmlEvt<T>(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); }
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -23,6 +23,8 @@ export function TabPanel<TabNames extends string>(...rest: ElementChild[]) {
}>("tab-panel", ...rest);
}

export function onTabSelected<TabNames>(callback: (evt: TabPanelTabSelectedEvent<TabNames>) => void, opts?: EventListenerOpts) { return onEvent("tabselected", callback, opts); }


@CustomElement("tab-panel")
export class TabPanelElement<TabNames extends string>
Expand Down

0 comments on commit 672ce2c

Please sign in to comment.