Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript definitions HERE: please help to publish it :) #62

Open
hinsxd opened this issue Aug 31, 2023 · 0 comments
Open

Typescript definitions HERE: please help to publish it :) #62

hinsxd opened this issue Aug 31, 2023 · 0 comments

Comments

@hinsxd
Copy link

hinsxd commented Aug 31, 2023

I just wrote some definitions for my use but I don't know how to use bower. If anyone knows how to include a .d.ts file, please open a PR for that. :)

If you want to use the types, put the code below in a .d.ts included in your project!

declare module "js-spatial-navigation" {
  export default SpatialNavigation;
}

declare namespace SpatialNavigation {
  interface Config {
    id: string;
    selector: string;
    straightOnly: boolean;
    straightOverlapThreshold: number;
    rememberSource: boolean;
    disabled: boolean;
    defaultElement: string;
    enterTo: "last-focused" | "default-element";
    leaveFor: null | Record<"left" | "right" | "up" | "down", string>;
    restrict: "self-first" | "self-only" | "none";
    tabIndexIgnoreList: string;
    navigableFilter: null | ((el: HTMLElement) => void);
  }

  function init(): void;
  function uninit(): void;
  function clear(): void;

  function set(config: Partial<SpatialNavigation.Config>): void;
  function set(
    sectionId: string,
    config: Partial<SpatialNavigation.Config>
  ): void;

  function add(config: Partial<SpatialNavigation.Config>): string;
  function add(
    sectionId: string,
    config: Partial<SpatialNavigation.Config>
  ): string;

  function remove(sectionId: string): boolean;

  function disable(sectionId: string): boolean;

  function enable(sectionId: string): void;

  function pause(): void;

  function resume(): void;

  function focus(silent?: boolean): boolean;
  function focus(sectionId: string, silent?: boolean): boolean;
  function focus(extSelector: string, silent?: boolean): boolean;

  function move(direction: string): boolean;
  function move(direction: string, selector: string): boolean;

  function makeFocusable(sectionId?: string): void;
  function setDefaultSection(sectionId: string): void;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant