mirror of
https://github.com/multipleof4/octopus-file-browser.git
synced 2026-09-25 12:35:25 +00:00
Document and prepare npm package
This commit is contained in:
Vendored
+58
@@ -0,0 +1,58 @@
|
||||
export type OctopusDate = string | number | Date;
|
||||
|
||||
export interface OctopusEntry {
|
||||
name: string;
|
||||
type: 'file' | 'directory';
|
||||
size?: number;
|
||||
modified?: OctopusDate;
|
||||
icon?: string;
|
||||
children?: OctopusEntry[];
|
||||
}
|
||||
|
||||
export interface OctopusOpenDetail {
|
||||
entry: OctopusEntry;
|
||||
path: string[];
|
||||
}
|
||||
|
||||
export interface OctopusNavigateDetail {
|
||||
entries: OctopusEntry[];
|
||||
path: string[];
|
||||
}
|
||||
|
||||
export interface OctopusFileBrowserEventMap {
|
||||
'octopus:open': CustomEvent<OctopusOpenDetail>;
|
||||
'octopus:navigate': CustomEvent<OctopusNavigateDetail>;
|
||||
}
|
||||
|
||||
export class OctopusFileBrowser extends HTMLElement {
|
||||
entries: OctopusEntry[];
|
||||
readonly path: string[];
|
||||
navigate(path?: string[]): void;
|
||||
addEventListener<K extends keyof OctopusFileBrowserEventMap>(
|
||||
type: K,
|
||||
listener: (this: OctopusFileBrowser, event: OctopusFileBrowserEventMap[K]) => void,
|
||||
options?: boolean | AddEventListenerOptions,
|
||||
): void;
|
||||
addEventListener(
|
||||
type: string,
|
||||
listener: EventListenerOrEventListenerObject | null,
|
||||
options?: boolean | AddEventListenerOptions,
|
||||
): void;
|
||||
}
|
||||
|
||||
export function createOctopusFileBrowser(
|
||||
target: Element,
|
||||
options?: { entries?: OctopusEntry[]; emptyLabel?: string },
|
||||
): OctopusFileBrowser;
|
||||
|
||||
export function fileKindLabel(name?: string): string;
|
||||
export function formatFileSize(bytes?: number): string;
|
||||
export function formatRelativeDate(value: OctopusDate, now?: number): string;
|
||||
export function isRecent(value: OctopusDate, now?: number): boolean;
|
||||
export function sortEntries(entries?: OctopusEntry[]): OctopusEntry[];
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'octopus-file-browser': OctopusFileBrowser;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user