Skip to main content Link Search Menu Expand Document (external link)

ElementSource overview

Added in v1.0.0


Table of contents


utils

CssSelectors

Signature

export declare function CssSelectors(selectors: ReadonlyArray<string>): CssSelectors

Added in v1.0.0

CssSelectors (interface)

Signature

export interface CssSelectors {
  readonly _tag: "css"
  readonly selectors: ReadonlyArray<string>
}

Added in v1.0.0

DefaultEventMap (type alias)

Signature

export type DefaultEventMap<T> = T extends Window
  ? WindowEventMap
  : T extends Document
    ? DocumentEventMap
    : T extends HTMLVideoElement
      ? HTMLVideoElementEventMap
      : T extends HTMLMediaElement
        ? HTMLMediaElementEventMap
        : T extends HTMLElement
          ? HTMLElementEventMap
          : T extends SVGElement
            ? SVGElementEventMap
            : T extends Element
              ? ElementEventMap & Readonly<Record<string, Event>>
              : Readonly<Record<string, Event>>

Added in v1.0.0

ElementSelector

Signature

export declare function ElementSelector(element: Element): ElementSelector

Added in v1.0.0

ElementSelector (interface)

Signature

export interface ElementSelector {
  readonly _tag: "element"
  readonly element: Element
}

Added in v1.0.0

ElementSource

Signature

export declare function ElementSource<T extends Rendered, EventMap extends {} = DefaultEventMap<T>>(
  rootElement: RefSubject.Filtered<T>
): ElementSource<T, EventMap>

Added in v1.0.0

ElementSource (interface)

Signature

export interface ElementSource<
  T extends Rendered = Element,
  EventMap extends {} = DefaultEventMap<Rendered.Elements<T>[number]>
> extends Versioned.Versioned<
    never,
    never,
    Rendered.Elements<T>,
    never,
    Scope.Scope,
    Rendered.Elements<T>,
    NoSuchElementException,
    never
  > {
  readonly selector: Selector

  readonly query: {
    <S extends string, Ev extends {} = DefaultEventMap<ParseSelector<S, Element>>>(
      selector: S
    ): ElementSource<ParseSelector<S, Element>, Ev>

    <Target extends Rendered, EventMap extends {} = DefaultEventMap<Target>>(
      rendered: Target
    ): ElementSource<Target, EventMap>
  }

  readonly elements: RefSubject.Filtered<Rendered.Elements<T>>

  readonly events: <Type extends keyof EventMap>(
    type: Type,
    options?: AddEventListenerOptions
  ) => Fx.Fx<EventWithCurrentTarget<Rendered.Elements<T>[number], EventMap[Type]>, never, Scope.Scope>

  readonly dispatchEvent: (event: Event, wait?: DurationInput) => Effect.Effect<void, NoSuchElementException>
}

Added in v1.0.0

ParseSelector (type alias)

Signature

export type ParseSelector<T extends string, Fallback> = [T] extends [typeof ROOT_CSS_SELECTOR]
  ? Fallback
  : Fallback extends globalThis.Element
    ? Extract<TQS.ParseSelector<T, Fallback>, globalThis.Element>
    : Fallback

Added in v1.0.0

ROOT_CSS_SELECTOR

Signature

export declare const ROOT_CSS_SELECTOR: ":root"

Added in v1.0.0

Selector (type alias)

Signature

export type Selector = CssSelectors | ElementSelector

Added in v1.0.0

fromElement

Signature

export declare function fromElement<T extends Element, EventMap extends {} = DefaultEventMap<T>>(
  rootElement: T
): ElementSource<T, EventMap>

Added in v1.0.0

getElements

Signature

export declare function getElements<T extends Rendered>(element: T): ReadonlyArray<Element>

Added in v1.0.0