svelte-common
Version:
common components and utils used in svelte apps
34 lines (33 loc) • 1.33 kB
text/typescript
/**
* Deliver next value in the order by cycle.
* SORT_NONE -> SORT_ASCENDING -> SORT_DESCENDING -> SORT_NONE ...
* @param {string|null} [orderBy]
* @returns {string} new order either SORT_NONE, SORT_ASCENDING or SORT_DESCENDING
*/
export function toggleOrderBy(orderBy?: string | null): string;
/**
* Add sortable toggle button to a th node.
* Synchronizes store value with the nodes "aria-sort" attribute.
* Usable as svelte action function.
* @param {Element} th the header element
* @param {writable} store keep in sync with sorting properties
* @return {Object} with destroy function
*/
export function sortable(th: Element, store: typeof writable): any;
/**
* Generate a sort function for a given sort-by set.
* @param {Object|undefined} [sortBy]
* @param {Object} [getters]
* @return {(function(any,any):number)|undefined} sorter
*/
export function sorter(sortBy?: any | undefined, getters?: any): ((arg0: any, arg1: any) => number) | undefined;
export const SORT_NONE: "none";
export const SORT_ASCENDING: "ascending";
export const SORT_DESCENDING: "descending";
export const SORT_OTHER: "other";
export namespace orderByCycle {
export { SORT_ASCENDING as none };
export { SORT_DESCENDING as ascending };
export { SORT_ASCENDING as descending };
}
import { writable } from "svelte/store";