declare module "utilities/base-path" {
/** Sets the library's base path to the specified directory */
export function setBasePath(path: string): void;
/**
* Gets the library's base path.
*
* The base path is used to load assets such as icons and images, so it needs to be set for components to work properly.
* By default, this script will look for a script ending in zinc.js or zinc-autoloader.js and set the base path
* to the directory that contains that file. To override this behavior, you can add the data-zinc attribute to any
* script on the page (it probably makes the most sense to attach it to the Zinc script, but it could also be on a
* bundle). The value can be a local folder, or it can point to a CORS-enabled endpoint such as a CDN.
*
*
*
* Alternatively, you can set the base path manually using the exported setBasePath() function.
*
* @param subpath - An optional path to append to the base path.
*/
export function getBasePath(subpath?: string): string;
}
declare module "zinc-autoloader" {
/**
* Checks a node for undefined elements and attempts to register them
*/
export function discover(root: Element | ShadowRoot): Promise;
}
declare module "internal/tabbable" {
/**
* Returns the first and last bounding elements that are tabbable. This is more performant than checking every single
* element because it short-circuits after finding the first and last ones.
*/
export function getTabbableBoundary(root: HTMLElement | ShadowRoot): {
start: HTMLElement;
end: HTMLElement;
};
export function getTabbableElements(root: HTMLElement | ShadowRoot): HTMLElement[];
}
declare module "internal/theme" {
import type { ReactiveController, ReactiveControllerHost } from "lit";
/**
* ThemeController is a reactive controller that listens for theme changes
* and updates the theme property on the host element.
*
* if you want to reflect the theme attribute to the host element, you can use
* the following code:
*
* ```ts
* import { ThemeController } from "@zinc/internal/theme";
*
* export default class MyElement extends HTMLElement {
* @property({ reflect: true }) t = '';
* ...
* ```
*/
export class ThemeController implements ReactiveController {
host: ReactiveControllerHost & HTMLElement;
t: string;
constructor(host: ReactiveControllerHost & HTMLElement);
hostConnected(): void;
hostDisconnected(): void;
handleThemeEventUpdate: (e: CustomEvent & {
theme: string;
}) => void;
getDefaultTheme: () => void;
}
}
declare module "internal/event" {
export type EventTypeRequiresDetail = T extends keyof GlobalEventHandlersEventMap ? GlobalEventHandlersEventMap[T] extends CustomEvent> ? GlobalEventHandlersEventMap[T] extends CustomEvent> ? never : Partial extends GlobalEventHandlersEventMap[T]['detail'] ? never : T : never : never;
export type EventTypeDoesNotRequireDetail = T extends keyof GlobalEventHandlersEventMap ? GlobalEventHandlersEventMap[T] extends CustomEvent> ? GlobalEventHandlersEventMap[T] extends CustomEvent> ? T : Partial extends GlobalEventHandlersEventMap[T]['detail'] ? T : never : T : T;
export type EventTypesWithRequiredDetail = {
[EventType in keyof GlobalEventHandlersEventMap as EventTypeRequiresDetail]: true;
};
export type EventTypesWithoutRequiredDetail = {
[EventType in keyof GlobalEventHandlersEventMap as EventTypeDoesNotRequireDetail]: true;
};
type WithRequired = T & {
[P in K]-?: T[P];
};
export type ZincEventInit = T extends keyof GlobalEventHandlersEventMap ? GlobalEventHandlersEventMap[T] extends CustomEvent> ? GlobalEventHandlersEventMap[T] extends CustomEvent> ? CustomEventInit : Partial extends GlobalEventHandlersEventMap[T]['detail'] ? CustomEventInit : WithRequired, 'detail'> : CustomEventInit : CustomEventInit;
export type GetCustomEventType = T extends keyof GlobalEventHandlersEventMap ? GlobalEventHandlersEventMap[T] extends CustomEvent ? GlobalEventHandlersEventMap[T] : CustomEvent : CustomEvent;
export type ValidEventTypeMap = EventTypesWithRequiredDetail | EventTypesWithoutRequiredDetail;
export function waitForEvent(el: HTMLElement, eventName: string): Promise;
}
declare module "internal/zinc-element" {
import { LitElement } from "lit";
import type { EventTypeDoesNotRequireDetail, EventTypeRequiresDetail, EventTypesWithoutRequiredDetail, EventTypesWithRequiredDetail, GetCustomEventType, ZincEventInit } from "internal/event";
export default class ZincElement extends LitElement {
dir: string;
lang: string;
t: string;
static define(name: string, elementConstructor?: typeof ZincElement, options?: ElementDefinitionOptions): void;
static dependencies: Record;
constructor();
emit(name: EventTypeDoesNotRequireDetail, options?: ZincEventInit | undefined): GetCustomEventType;
emit(name: EventTypeRequiresDetail, options?: ZincEventInit): GetCustomEventType;
}
export interface ZincFormControl extends ZincElement {
name: string;
value: unknown;
disabled?: boolean;
defaultValue?: unknown;
defaultChecked?: boolean;
form?: string;
pattern?: string;
min?: number | string | Date;
max?: number | string | Date;
step?: number | 'any';
required?: boolean;
minlength?: number;
maxlength?: number;
readonly validity: ValidityState;
readonly validationMessage: string;
checkValidity: () => boolean;
getForm: () => HTMLFormElement | null;
reportValidity: () => boolean;
setCustomValidity: (message: string) => void;
}
}
declare module "internal/form-navigation" {
export class FormNavigationController {
private readonly form;
constructor(form: HTMLFormElement);
private handleKeyDown;
private shouldSkipEnterKey;
private shouldExcludeFromNavigation;
private isSelectOption;
private findParentSelect;
private findParentGroup;
private getGroupItems;
private focusNextInGroup;
private focusPreviousInGroup;
private areRequiredFieldsFilled;
private getNavigableControls;
private findCurrentControlIndex;
private focusNextControl;
private focusPreviousControl;
private submitForm;
destroy(): void;
}
/**
* Gets or creates a FormNavigationController for the given form
*/
export function getFormNavigationController(form: HTMLFormElement): FormNavigationController;
}
declare module "internal/form" {
import type { ReactiveController, ReactiveControllerHost } from "lit";
import type { ZincFormControl } from "internal/zinc-element";
import type Button from "components/button/index";
export const formCollections: WeakMap>;
export interface FormControlControllerOptions {
/** A function that returns the form containing the form control. */
form: (input: ZincFormControl) => HTMLFormElement | null;
/** A function that returns the form control's name, which will be submitted with the form data. */
name: (input: ZincFormControl) => string;
/** A function that returns the form control's current value. */
value: (input: ZincFormControl) => unknown | unknown[];
/** A function that returns the form control's default value. */
defaultValue: (input: ZincFormControl) => unknown | unknown[];
/** A function that returns the form control's current disabled state. If disabled, the value won't be submitted. */
disabled: (input: ZincFormControl) => boolean;
/**
* A function that maps to the form control's reportValidity() function. When the control is invalid, this will
* prevent submission and trigger the browser's constraint violation warning.
*/
reportValidity: (input: ZincFormControl) => boolean;
/**
* A function that maps to the form control's `checkValidity()` function. When the control is invalid, this will return false.
* this is helpful is you want to check validation without triggering the native browser constraint violation warning.
*/
checkValidity: (input: ZincFormControl) => boolean;
/** A function that sets the form control's value */
setValue: (input: ZincFormControl, value: unknown) => void;
/**
* An array of event names to listen to. When all events in the list are emitted, the control will receive validity
* states such as user-valid and user-invalid.user interacted validity states. */
assumeInteractionOn: string[];
}
export class FormControlController implements ReactiveController {
host: ZincFormControl & ReactiveControllerHost;
form?: HTMLFormElement | null;
options: FormControlControllerOptions;
constructor(host: ReactiveControllerHost & ZincFormControl, options?: Partial);
hostConnected(): Promise;
hostDisconnected(): void;
hostUpdated(): void;
private attachForm;
private detachForm;
private handleFormData;
private handleFormSubmit;
private enableSubmit;
private handleFormReset;
private handleInteraction;
private checkFormValidity;
private reportFormValidity;
private setUserInteracted;
private doAction;
/** Returns the associated `