svelte-ux
Version:
A large collection of Svelte components, actions, stores and utils to simplify creating highly interactive and visual applications. Built using Tailwind with extensibility and customization in mind.
51 lines (50 loc) • 2.58 kB
TypeScript
import { type Readable, type Writable } from 'svelte/store';
import { type FormatFunctions } from '@layerstack/utils/format';
import { type LocaleSettings, type LocaleStore, type LocaleSettingsInput } from '@layerstack/utils/locale';
import { type ThemeStore } from '@layerstack/svelte-stores';
import { type ComponentName, type ComponentSettings, type ResolvedComponentSettings } from './theme.js';
import type { LabelPlacement } from '../types/index.js';
export interface DefaultProps {
labelPlacement: LabelPlacement;
}
export type SettingsInput = {
/** Force a specific locale setting. */
forceLocale?: string;
/** Use this locale in case we don't have locale info for the user's current locale as returned from Intl.
* Defaults to `en` if not specified. */
fallbackLocale?: string;
/** Format information for additional locales that are not built-in to svelte-ux. */
localeFormats?: Record<string, LocaleSettingsInput>;
components?: ComponentSettings;
/** A list of the available themes */
themes?: {
light?: string[];
dark?: string[];
};
currentTheme?: ThemeStore;
/** The existing locale store, if calling settings when there is already an existing `Settings` object */
locale?: LocaleStore;
/** The existing locale store, if calling settings when there is already an existing `Settings` object */
localeSettings?: Readable<LocaleSettings>;
/** The existing locale store, if calling settings when there is already an existing `Settings` object */
format?: Readable<FormatFunctions>;
};
export interface Settings extends Omit<SettingsInput, 'formats' | 'dictionary'> {
/** The currently selected locale */
locale: LocaleStore;
/** The settings for the currently selected locale */
localeSettings: Readable<LocaleSettings>;
/** Formatting functions and information */
format: Readable<FormatFunctions>;
currentTheme: ThemeStore;
showDrawer: Writable<boolean>;
componentSettingsCache: Partial<Record<ComponentName, ResolvedComponentSettings<ComponentName>>>;
}
export declare function settings(settings?: SettingsInput): Settings;
export declare function getSettings(): Settings;
export declare function resolveComponentSettings<NAME extends ComponentName>(settings: Settings, name: NAME): ResolvedComponentSettings<NAME>;
/**
* Returns default component props and classes for a given component.
* @param name component name
*/
export declare function getComponentSettings<NAME extends ComponentName>(name: NAME): ResolvedComponentSettings<NAME>;