@mccustomapps/helaui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/rain/builtinImages.ts +7 -0
- package/dist/assets/rain/fritter.png +0 -0
- package/dist/assets/rain/kokis.png +0 -0
- package/dist/assets/rain/leaf.png +0 -0
- package/dist/assets/rain/swirl.png +0 -0
- package/dist/assets/sun-mandala/builtinImage.ts +4 -0
- package/dist/assets/sun-mandala/ira-handa.jpg +0 -0
- package/dist/assets/sun-mandala/ira-handa.png +0 -0
- package/dist/calendar.css +280 -0
- package/dist/fritter-INYFVKEH.png +0 -0
- package/dist/index.cjs +1026 -0
- package/dist/index.d.cts +341 -0
- package/dist/index.d.ts +341 -0
- package/dist/index.js +972 -0
- package/dist/ira-handa-7DIWZWI4.png +0 -0
- package/dist/kokis-R6R5HA62.png +0 -0
- package/dist/leaf-DEJYVWQI.png +0 -0
- package/dist/rain-background.css +40 -0
- package/dist/sinhala.css +10 -0
- package/dist/sun-mandala.css +66 -0
- package/dist/swirl-RVLEF6L5.png +0 -0
- package/dist/textfield.css +99 -0
- package/dist/theme.css +24 -0
- package/package.json +52 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/** Default Sinhala font stack used by HelaUI. */
|
|
2
|
+
declare const SINHALA_FONT_FAMILY = "\"Noto Sans Sinhala\", \"Iskoola Pota\", \"FM Abhaya\", sans-serif";
|
|
3
|
+
/** Inline styles object for applying Sinhala typography. */
|
|
4
|
+
declare const sinhalaFontStyles: {
|
|
5
|
+
readonly fontFamily: "\"Noto Sans Sinhala\", \"Iskoola Pota\", \"FM Abhaya\", sans-serif";
|
|
6
|
+
};
|
|
7
|
+
/** CSS class name applied by {@link applySinhalaFont}. */
|
|
8
|
+
declare const SINHALA_FONT_CLASS = "helaui-sinhala";
|
|
9
|
+
/**
|
|
10
|
+
* Applies Sinhala font styling to a DOM element.
|
|
11
|
+
* Import `helaui/sinhala.css` once in your app for the font files to load.
|
|
12
|
+
*/
|
|
13
|
+
declare function applySinhalaFont(element: HTMLElement): void;
|
|
14
|
+
|
|
15
|
+
/** Supported HelaUI locales. */
|
|
16
|
+
type HelaLocale = 'en' | 'si';
|
|
17
|
+
interface TextFieldStrings {
|
|
18
|
+
label: string;
|
|
19
|
+
placeholder: string;
|
|
20
|
+
value?: string;
|
|
21
|
+
}
|
|
22
|
+
interface HelaTextFieldTranslations {
|
|
23
|
+
name: TextFieldStrings;
|
|
24
|
+
password: TextFieldStrings;
|
|
25
|
+
email: TextFieldStrings;
|
|
26
|
+
disabled: TextFieldStrings;
|
|
27
|
+
}
|
|
28
|
+
interface CalendarStrings {
|
|
29
|
+
monthNames: [string, string, string, string, string, string, string, string, string, string, string, string];
|
|
30
|
+
sinhalaMonthNames: [string, string, string, string, string, string, string, string, string, string, string, string];
|
|
31
|
+
weekdayNames: [string, string, string, string, string, string, string];
|
|
32
|
+
shortWeekdayNames: [string, string, string, string, string, string, string];
|
|
33
|
+
buddhistEra: string;
|
|
34
|
+
today: string;
|
|
35
|
+
clear: string;
|
|
36
|
+
selectMonth: string;
|
|
37
|
+
poyaDay: string;
|
|
38
|
+
}
|
|
39
|
+
/** Built-in translation shape shipped with HelaUI. */
|
|
40
|
+
interface HelaTranslations {
|
|
41
|
+
textField: HelaTextFieldTranslations;
|
|
42
|
+
calendar: CalendarStrings;
|
|
43
|
+
}
|
|
44
|
+
type TextFieldVariant = keyof HelaTextFieldTranslations;
|
|
45
|
+
type DeepPartial<T> = {
|
|
46
|
+
[K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
|
|
47
|
+
};
|
|
48
|
+
/** User overrides may extend built-in keys with custom translation trees. */
|
|
49
|
+
type LocaleTranslationOverrides = DeepPartial<HelaTranslations> & {
|
|
50
|
+
[key: string]: unknown;
|
|
51
|
+
};
|
|
52
|
+
type HelaTranslationOverrides = Partial<Record<HelaLocale, LocaleTranslationOverrides>>;
|
|
53
|
+
|
|
54
|
+
/** Default HelaUI translations — English and Sinhala. */
|
|
55
|
+
declare const defaultTranslations: Record<HelaLocale, HelaTranslations>;
|
|
56
|
+
|
|
57
|
+
interface ApplyTranslationsOptions {
|
|
58
|
+
/** Active locale. When omitted, keeps the current locale. */
|
|
59
|
+
locale?: HelaLocale;
|
|
60
|
+
/** Partial overrides merged on top of built-in defaults (per locale). */
|
|
61
|
+
overrides?: HelaTranslationOverrides;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Sets the active locale and/or merges user translation overrides.
|
|
65
|
+
* Follows the same partial-override pattern as `applyTheme`.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* setLocale('si');
|
|
69
|
+
* applyTranslations({ overrides: { en: { textField: { name: { label: 'Full name' } } } } });
|
|
70
|
+
*/
|
|
71
|
+
declare function applyTranslations(options?: ApplyTranslationsOptions): LocaleTranslationOverrides;
|
|
72
|
+
/** Sets the active locale and notifies locale-aware components. */
|
|
73
|
+
declare function setLocale(locale: HelaLocale): LocaleTranslationOverrides;
|
|
74
|
+
/** Returns the active locale. */
|
|
75
|
+
declare function getLocale(): HelaLocale;
|
|
76
|
+
/** Resets user overrides back to built-in defaults. */
|
|
77
|
+
declare function resetTranslations(): LocaleTranslationOverrides;
|
|
78
|
+
/**
|
|
79
|
+
* Resolves a dot-separated translation key for the active (or given) locale.
|
|
80
|
+
* Falls back to English, then returns the key if unresolved.
|
|
81
|
+
*/
|
|
82
|
+
declare function t(path: string, locale?: HelaLocale): string;
|
|
83
|
+
/** Built-in TextField strings for a variant in the active (or given) locale. */
|
|
84
|
+
declare function getTextFieldTranslation(variant: TextFieldVariant, locale?: HelaLocale): TextFieldStrings;
|
|
85
|
+
/** Built-in Calendar strings for the active (or given) locale. */
|
|
86
|
+
declare function getCalendarTranslation(locale?: HelaLocale): CalendarStrings;
|
|
87
|
+
/** Subscribe to locale or override changes. Returns an unsubscribe function. */
|
|
88
|
+
declare function subscribeLocaleChange(listener: () => void): () => void;
|
|
89
|
+
|
|
90
|
+
interface TextFieldOptions {
|
|
91
|
+
/**
|
|
92
|
+
|
|
93
|
+
* Built-in translation variant — resolves label and placeholder from the active locale.
|
|
94
|
+
|
|
95
|
+
* User-provided `label` / `placeholder` take precedence over variant strings.
|
|
96
|
+
|
|
97
|
+
*/
|
|
98
|
+
variant?: TextFieldVariant;
|
|
99
|
+
/** Translation key for label (dot path, e.g. `textField.name.label`). */
|
|
100
|
+
labelKey?: string;
|
|
101
|
+
/** Translation key for placeholder (dot path, e.g. `textField.name.placeholder`). */
|
|
102
|
+
placeholderKey?: string;
|
|
103
|
+
/** Explicit label — overrides variant and labelKey. */
|
|
104
|
+
label?: string;
|
|
105
|
+
/** Explicit placeholder — overrides variant and placeholderKey. */
|
|
106
|
+
placeholder?: string;
|
|
107
|
+
type?: 'text' | 'password' | 'email';
|
|
108
|
+
value?: string;
|
|
109
|
+
id?: string;
|
|
110
|
+
/** Apply Sinhala font styling. When omitted on locale-aware fields, follows active locale. */
|
|
111
|
+
sinhala?: boolean;
|
|
112
|
+
}
|
|
113
|
+
declare class TextField {
|
|
114
|
+
readonly element: HTMLDivElement;
|
|
115
|
+
readonly input: HTMLInputElement;
|
|
116
|
+
private readonly labelEl?;
|
|
117
|
+
private readonly unsubscribeLocale?;
|
|
118
|
+
private readonly localeAware;
|
|
119
|
+
private readonly fixedLabel?;
|
|
120
|
+
private readonly fixedPlaceholder?;
|
|
121
|
+
private readonly fixedValue?;
|
|
122
|
+
private readonly variant?;
|
|
123
|
+
private readonly labelKey?;
|
|
124
|
+
private readonly placeholderKey?;
|
|
125
|
+
private readonly sinhalaExplicit;
|
|
126
|
+
private readonly sinhalaEnabled;
|
|
127
|
+
constructor(options?: TextFieldOptions);
|
|
128
|
+
private resolveStrings;
|
|
129
|
+
private applyLocaleStrings;
|
|
130
|
+
getValue(): string;
|
|
131
|
+
setValue(value: string): void;
|
|
132
|
+
focus(): void;
|
|
133
|
+
setDisabled(disabled: boolean): void;
|
|
134
|
+
setLabel(label: string): void;
|
|
135
|
+
setPlaceholder(placeholder: string): void;
|
|
136
|
+
setSinhala(enabled: boolean): void;
|
|
137
|
+
/** Removes locale subscription. Call when discarding the field. */
|
|
138
|
+
destroy(): void;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Built-in rain sprite URLs shipped with HelaUI. */
|
|
142
|
+
declare const BUILTIN_RAIN_IMAGES: readonly [string, string, string, string];
|
|
143
|
+
|
|
144
|
+
interface RainBackgroundOptions {
|
|
145
|
+
/** Image URLs used as falling particles. Defaults to {@link BUILTIN_RAIN_IMAGES}. */
|
|
146
|
+
images?: string[];
|
|
147
|
+
/** Number of particles visible at once. Defaults to 28. */
|
|
148
|
+
density?: number;
|
|
149
|
+
/** Minimum particle width in pixels. Defaults to 28. */
|
|
150
|
+
minSize?: number;
|
|
151
|
+
/** Maximum particle width in pixels. Defaults to 72. */
|
|
152
|
+
maxSize?: number;
|
|
153
|
+
/** Minimum fall duration in seconds. Defaults to 8. */
|
|
154
|
+
minDuration?: number;
|
|
155
|
+
/** Maximum fall duration in seconds. Defaults to 18. */
|
|
156
|
+
maxDuration?: number;
|
|
157
|
+
/** Container to mount into. Defaults to `document.body`. */
|
|
158
|
+
target?: HTMLElement;
|
|
159
|
+
/** Stacking order. Defaults to 0. */
|
|
160
|
+
zIndex?: number;
|
|
161
|
+
}
|
|
162
|
+
/** Full-screen animated background with falling image particles. */
|
|
163
|
+
declare class RainBackground {
|
|
164
|
+
readonly element: HTMLDivElement;
|
|
165
|
+
constructor(options?: RainBackgroundOptions);
|
|
166
|
+
private createDrop;
|
|
167
|
+
/** Removes the background from the DOM. */
|
|
168
|
+
destroy(): void;
|
|
169
|
+
}
|
|
170
|
+
/** Default rain sprite filenames shipped with HelaUI. */
|
|
171
|
+
declare const DEFAULT_RAIN_IMAGES: readonly ["fritter.png", "swirl.png", "kokis.png", "leaf.png"];
|
|
172
|
+
/** Builds image URLs from a base path (e.g. `/assets/rain/`). */
|
|
173
|
+
declare function getDefaultRainImageUrls(basePath: string): string[];
|
|
174
|
+
|
|
175
|
+
interface CalendarOptions {
|
|
176
|
+
/** Initial selected date (Date instance or YYYY-MM-DD string) */
|
|
177
|
+
value?: Date | string;
|
|
178
|
+
/** Initial displayed year & month (defaults to active value or current date) */
|
|
179
|
+
initialDate?: Date;
|
|
180
|
+
/** Minimum selectable date */
|
|
181
|
+
minDate?: Date;
|
|
182
|
+
/** Maximum selectable date */
|
|
183
|
+
maxDate?: Date;
|
|
184
|
+
/** Display Buddhist Era (බුද්ධ වර්ෂ / BE Year) in header. Default: true */
|
|
185
|
+
showBuddhistEra?: boolean;
|
|
186
|
+
/** Force Sinhala font styling on/off. If undefined, follows active i18n locale */
|
|
187
|
+
sinhala?: boolean;
|
|
188
|
+
/** Custom Poya dates (YYYY-MM-DD strings or Date objects) */
|
|
189
|
+
poyaDates?: (string | Date)[];
|
|
190
|
+
/** Highlight today's date. Default: true */
|
|
191
|
+
highlightToday?: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Fixed width of the calendar. Accepts any valid CSS value (e.g. '360px', '24rem', '100%').
|
|
194
|
+
* Defaults to 360px when not provided.
|
|
195
|
+
*/
|
|
196
|
+
width?: string;
|
|
197
|
+
/**
|
|
198
|
+
* Fixed height of the calendar. Accepts any valid CSS value (e.g. '420px', '30rem').
|
|
199
|
+
* Defaults to 420px when not provided.
|
|
200
|
+
*/
|
|
201
|
+
height?: string;
|
|
202
|
+
/** Callback fired when a date is selected */
|
|
203
|
+
onSelect?: (date: Date, sinhalaFormattedDate: string) => void;
|
|
204
|
+
/** Callback fired when month or year changes */
|
|
205
|
+
onMonthChange?: (year: number, month: number) => void;
|
|
206
|
+
}
|
|
207
|
+
/** Converts a number string or integer into Sinhala numerals. */
|
|
208
|
+
declare function formatSinhalaNumeral(num: number | string): string;
|
|
209
|
+
/** 12 Traditional Sinhala Month names (දුරුතු to උඳුඅප්). */
|
|
210
|
+
declare const SINHALA_MONTH_NAMES: readonly ["දුරුතු", "නවම්", "මැදින්", "බක්", "වෙසක්", "පොසොන්", "ඇසළ", "නිකිණි", "බිනර", "වප්", "ඉල්", "උඳුඅප්"];
|
|
211
|
+
declare class Calendar {
|
|
212
|
+
readonly element: HTMLDivElement;
|
|
213
|
+
private selectedDate;
|
|
214
|
+
private viewYear;
|
|
215
|
+
private viewMonth;
|
|
216
|
+
private showBuddhistEra;
|
|
217
|
+
private highlightToday;
|
|
218
|
+
private sinhalaExplicit;
|
|
219
|
+
private sinhalaEnabled;
|
|
220
|
+
private minDate?;
|
|
221
|
+
private maxDate?;
|
|
222
|
+
private poyaDatesSet;
|
|
223
|
+
private onSelectCallback?;
|
|
224
|
+
private onMonthChangeCallback?;
|
|
225
|
+
private unsubscribeLocale?;
|
|
226
|
+
/** True when the caller passed an explicit height — prevents auto six-row adjustment */
|
|
227
|
+
private readonly customHeight;
|
|
228
|
+
private monthTitleEl;
|
|
229
|
+
private subTitleEl;
|
|
230
|
+
private eraBadgeEl;
|
|
231
|
+
private weekdaysEl;
|
|
232
|
+
private daysGridEl;
|
|
233
|
+
private footerEl;
|
|
234
|
+
private selectedTextEl;
|
|
235
|
+
private monthPopoverEl;
|
|
236
|
+
constructor(options?: CalendarOptions);
|
|
237
|
+
private renderSkeleton;
|
|
238
|
+
private render;
|
|
239
|
+
private createDayButton;
|
|
240
|
+
private updateSelectedText;
|
|
241
|
+
/** Gets formatted string e.g. "2026 වෙසක් 15" (Western digits) */
|
|
242
|
+
getFormattedSinhalaDate(date: Date): string;
|
|
243
|
+
selectDate(date: Date): void;
|
|
244
|
+
getValue(): Date | null;
|
|
245
|
+
setValue(value: Date | string | null): void;
|
|
246
|
+
setSinhala(enabled: boolean): void;
|
|
247
|
+
setShowBuddhistEra(show: boolean): void;
|
|
248
|
+
nextMonth(): void;
|
|
249
|
+
prevMonth(): void;
|
|
250
|
+
goToToday(): void;
|
|
251
|
+
clear(): void;
|
|
252
|
+
private toggleMonthPopover;
|
|
253
|
+
private openMonthPopover;
|
|
254
|
+
private closeMonthPopover;
|
|
255
|
+
/** Cleans up subscriptions and event listeners */
|
|
256
|
+
destroy(): void;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** Built-in Sri Lankan Ira Handa (sun face) mandala artwork. */
|
|
260
|
+
declare const BUILTIN_SUN_MANDALA_IMAGE: string;
|
|
261
|
+
|
|
262
|
+
interface SunMandalaOptions {
|
|
263
|
+
/** Image URL. Defaults to the built-in Ira Handa artwork. */
|
|
264
|
+
src?: string;
|
|
265
|
+
/** Accessible label for the artwork. */
|
|
266
|
+
alt?: string;
|
|
267
|
+
/**
|
|
268
|
+
* Display size (width & height). Accepts any valid CSS length.
|
|
269
|
+
* Defaults to `280px`.
|
|
270
|
+
*/
|
|
271
|
+
size?: string;
|
|
272
|
+
/**
|
|
273
|
+
* Full rotation duration in seconds. Lower = faster.
|
|
274
|
+
* Defaults to `36`.
|
|
275
|
+
*/
|
|
276
|
+
duration?: number;
|
|
277
|
+
/**
|
|
278
|
+
* Clip radius of the static face overlay (CSS length or %).
|
|
279
|
+
* Tuned so only the face stays still while rays + rings spin.
|
|
280
|
+
* Defaults to `22%`.
|
|
281
|
+
*/
|
|
282
|
+
faceRadius?: string;
|
|
283
|
+
/** Start with rotation paused. Defaults to `false`. */
|
|
284
|
+
paused?: boolean;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Decorative Sri Lankan sun mandala (Ira Handa).
|
|
288
|
+
* The face stays still while the aura (rays + outer rings) rotates.
|
|
289
|
+
*/
|
|
290
|
+
declare class SunMandala {
|
|
291
|
+
readonly element: HTMLDivElement;
|
|
292
|
+
private readonly spinEl;
|
|
293
|
+
private readonly faceEl;
|
|
294
|
+
private readonly spinImg;
|
|
295
|
+
private readonly faceImg;
|
|
296
|
+
constructor(options?: SunMandalaOptions);
|
|
297
|
+
/** Pause or resume the aura rotation. */
|
|
298
|
+
setPaused(paused: boolean): void;
|
|
299
|
+
isPaused(): boolean;
|
|
300
|
+
/** Set full-circle rotation duration in seconds. */
|
|
301
|
+
setDuration(seconds: number): void;
|
|
302
|
+
/** Update display size (width & height). */
|
|
303
|
+
setSize(size: string): void;
|
|
304
|
+
/** Update the static face clip radius. */
|
|
305
|
+
setFaceRadius(radius: string): void;
|
|
306
|
+
destroy(): void;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** HelaUI brand palette — all values are customizable. */
|
|
310
|
+
interface HelaTheme {
|
|
311
|
+
primary: string;
|
|
312
|
+
secondary: string;
|
|
313
|
+
success: string;
|
|
314
|
+
accent: string;
|
|
315
|
+
black: string;
|
|
316
|
+
white: string;
|
|
317
|
+
grey: string;
|
|
318
|
+
}
|
|
319
|
+
type HelaThemeKey = keyof HelaTheme;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Applies theme colors to a DOM element via CSS custom properties.
|
|
323
|
+
* Pass partial overrides to customize individual colors.
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* applyTheme({ primary: '#1a1a2e' });
|
|
327
|
+
* applyTheme(customTheme, document.getElementById('my-app')!);
|
|
328
|
+
*/
|
|
329
|
+
declare function applyTheme(overrides?: Partial<HelaTheme>, target?: HTMLElement): HelaTheme;
|
|
330
|
+
/** Removes inline theme overrides so CSS defaults take effect again. */
|
|
331
|
+
declare function resetTheme(target?: HTMLElement): HelaTheme;
|
|
332
|
+
/** Returns a CSS string of custom properties for inline styles or SSR. */
|
|
333
|
+
declare function createThemeStyle(theme?: Partial<HelaTheme>): string;
|
|
334
|
+
|
|
335
|
+
/** Default HelaUI theme — Sri Lankan inspired palette. */
|
|
336
|
+
declare const defaultTheme: HelaTheme;
|
|
337
|
+
|
|
338
|
+
/** Maps theme keys to CSS custom property names. */
|
|
339
|
+
declare const THEME_VAR_MAP: Record<HelaThemeKey, string>;
|
|
340
|
+
|
|
341
|
+
export { type ApplyTranslationsOptions, BUILTIN_RAIN_IMAGES, BUILTIN_SUN_MANDALA_IMAGE, Calendar, type CalendarOptions, type CalendarStrings, DEFAULT_RAIN_IMAGES, type DeepPartial, type HelaLocale, type HelaTextFieldTranslations, type HelaTheme, type HelaThemeKey, type HelaTranslationOverrides, type HelaTranslations, type LocaleTranslationOverrides, RainBackground, type RainBackgroundOptions, SINHALA_FONT_CLASS, SINHALA_FONT_FAMILY, SINHALA_MONTH_NAMES, SunMandala, type SunMandalaOptions, THEME_VAR_MAP, TextField, type TextFieldOptions, type TextFieldStrings, type TextFieldVariant, applySinhalaFont, applyTheme, applyTranslations, createThemeStyle, defaultTheme, defaultTranslations, formatSinhalaNumeral, getCalendarTranslation, getDefaultRainImageUrls, getLocale, getTextFieldTranslation, resetTheme, resetTranslations, setLocale, sinhalaFontStyles, subscribeLocaleChange, t };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/** Default Sinhala font stack used by HelaUI. */
|
|
2
|
+
declare const SINHALA_FONT_FAMILY = "\"Noto Sans Sinhala\", \"Iskoola Pota\", \"FM Abhaya\", sans-serif";
|
|
3
|
+
/** Inline styles object for applying Sinhala typography. */
|
|
4
|
+
declare const sinhalaFontStyles: {
|
|
5
|
+
readonly fontFamily: "\"Noto Sans Sinhala\", \"Iskoola Pota\", \"FM Abhaya\", sans-serif";
|
|
6
|
+
};
|
|
7
|
+
/** CSS class name applied by {@link applySinhalaFont}. */
|
|
8
|
+
declare const SINHALA_FONT_CLASS = "helaui-sinhala";
|
|
9
|
+
/**
|
|
10
|
+
* Applies Sinhala font styling to a DOM element.
|
|
11
|
+
* Import `helaui/sinhala.css` once in your app for the font files to load.
|
|
12
|
+
*/
|
|
13
|
+
declare function applySinhalaFont(element: HTMLElement): void;
|
|
14
|
+
|
|
15
|
+
/** Supported HelaUI locales. */
|
|
16
|
+
type HelaLocale = 'en' | 'si';
|
|
17
|
+
interface TextFieldStrings {
|
|
18
|
+
label: string;
|
|
19
|
+
placeholder: string;
|
|
20
|
+
value?: string;
|
|
21
|
+
}
|
|
22
|
+
interface HelaTextFieldTranslations {
|
|
23
|
+
name: TextFieldStrings;
|
|
24
|
+
password: TextFieldStrings;
|
|
25
|
+
email: TextFieldStrings;
|
|
26
|
+
disabled: TextFieldStrings;
|
|
27
|
+
}
|
|
28
|
+
interface CalendarStrings {
|
|
29
|
+
monthNames: [string, string, string, string, string, string, string, string, string, string, string, string];
|
|
30
|
+
sinhalaMonthNames: [string, string, string, string, string, string, string, string, string, string, string, string];
|
|
31
|
+
weekdayNames: [string, string, string, string, string, string, string];
|
|
32
|
+
shortWeekdayNames: [string, string, string, string, string, string, string];
|
|
33
|
+
buddhistEra: string;
|
|
34
|
+
today: string;
|
|
35
|
+
clear: string;
|
|
36
|
+
selectMonth: string;
|
|
37
|
+
poyaDay: string;
|
|
38
|
+
}
|
|
39
|
+
/** Built-in translation shape shipped with HelaUI. */
|
|
40
|
+
interface HelaTranslations {
|
|
41
|
+
textField: HelaTextFieldTranslations;
|
|
42
|
+
calendar: CalendarStrings;
|
|
43
|
+
}
|
|
44
|
+
type TextFieldVariant = keyof HelaTextFieldTranslations;
|
|
45
|
+
type DeepPartial<T> = {
|
|
46
|
+
[K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
|
|
47
|
+
};
|
|
48
|
+
/** User overrides may extend built-in keys with custom translation trees. */
|
|
49
|
+
type LocaleTranslationOverrides = DeepPartial<HelaTranslations> & {
|
|
50
|
+
[key: string]: unknown;
|
|
51
|
+
};
|
|
52
|
+
type HelaTranslationOverrides = Partial<Record<HelaLocale, LocaleTranslationOverrides>>;
|
|
53
|
+
|
|
54
|
+
/** Default HelaUI translations — English and Sinhala. */
|
|
55
|
+
declare const defaultTranslations: Record<HelaLocale, HelaTranslations>;
|
|
56
|
+
|
|
57
|
+
interface ApplyTranslationsOptions {
|
|
58
|
+
/** Active locale. When omitted, keeps the current locale. */
|
|
59
|
+
locale?: HelaLocale;
|
|
60
|
+
/** Partial overrides merged on top of built-in defaults (per locale). */
|
|
61
|
+
overrides?: HelaTranslationOverrides;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Sets the active locale and/or merges user translation overrides.
|
|
65
|
+
* Follows the same partial-override pattern as `applyTheme`.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* setLocale('si');
|
|
69
|
+
* applyTranslations({ overrides: { en: { textField: { name: { label: 'Full name' } } } } });
|
|
70
|
+
*/
|
|
71
|
+
declare function applyTranslations(options?: ApplyTranslationsOptions): LocaleTranslationOverrides;
|
|
72
|
+
/** Sets the active locale and notifies locale-aware components. */
|
|
73
|
+
declare function setLocale(locale: HelaLocale): LocaleTranslationOverrides;
|
|
74
|
+
/** Returns the active locale. */
|
|
75
|
+
declare function getLocale(): HelaLocale;
|
|
76
|
+
/** Resets user overrides back to built-in defaults. */
|
|
77
|
+
declare function resetTranslations(): LocaleTranslationOverrides;
|
|
78
|
+
/**
|
|
79
|
+
* Resolves a dot-separated translation key for the active (or given) locale.
|
|
80
|
+
* Falls back to English, then returns the key if unresolved.
|
|
81
|
+
*/
|
|
82
|
+
declare function t(path: string, locale?: HelaLocale): string;
|
|
83
|
+
/** Built-in TextField strings for a variant in the active (or given) locale. */
|
|
84
|
+
declare function getTextFieldTranslation(variant: TextFieldVariant, locale?: HelaLocale): TextFieldStrings;
|
|
85
|
+
/** Built-in Calendar strings for the active (or given) locale. */
|
|
86
|
+
declare function getCalendarTranslation(locale?: HelaLocale): CalendarStrings;
|
|
87
|
+
/** Subscribe to locale or override changes. Returns an unsubscribe function. */
|
|
88
|
+
declare function subscribeLocaleChange(listener: () => void): () => void;
|
|
89
|
+
|
|
90
|
+
interface TextFieldOptions {
|
|
91
|
+
/**
|
|
92
|
+
|
|
93
|
+
* Built-in translation variant — resolves label and placeholder from the active locale.
|
|
94
|
+
|
|
95
|
+
* User-provided `label` / `placeholder` take precedence over variant strings.
|
|
96
|
+
|
|
97
|
+
*/
|
|
98
|
+
variant?: TextFieldVariant;
|
|
99
|
+
/** Translation key for label (dot path, e.g. `textField.name.label`). */
|
|
100
|
+
labelKey?: string;
|
|
101
|
+
/** Translation key for placeholder (dot path, e.g. `textField.name.placeholder`). */
|
|
102
|
+
placeholderKey?: string;
|
|
103
|
+
/** Explicit label — overrides variant and labelKey. */
|
|
104
|
+
label?: string;
|
|
105
|
+
/** Explicit placeholder — overrides variant and placeholderKey. */
|
|
106
|
+
placeholder?: string;
|
|
107
|
+
type?: 'text' | 'password' | 'email';
|
|
108
|
+
value?: string;
|
|
109
|
+
id?: string;
|
|
110
|
+
/** Apply Sinhala font styling. When omitted on locale-aware fields, follows active locale. */
|
|
111
|
+
sinhala?: boolean;
|
|
112
|
+
}
|
|
113
|
+
declare class TextField {
|
|
114
|
+
readonly element: HTMLDivElement;
|
|
115
|
+
readonly input: HTMLInputElement;
|
|
116
|
+
private readonly labelEl?;
|
|
117
|
+
private readonly unsubscribeLocale?;
|
|
118
|
+
private readonly localeAware;
|
|
119
|
+
private readonly fixedLabel?;
|
|
120
|
+
private readonly fixedPlaceholder?;
|
|
121
|
+
private readonly fixedValue?;
|
|
122
|
+
private readonly variant?;
|
|
123
|
+
private readonly labelKey?;
|
|
124
|
+
private readonly placeholderKey?;
|
|
125
|
+
private readonly sinhalaExplicit;
|
|
126
|
+
private readonly sinhalaEnabled;
|
|
127
|
+
constructor(options?: TextFieldOptions);
|
|
128
|
+
private resolveStrings;
|
|
129
|
+
private applyLocaleStrings;
|
|
130
|
+
getValue(): string;
|
|
131
|
+
setValue(value: string): void;
|
|
132
|
+
focus(): void;
|
|
133
|
+
setDisabled(disabled: boolean): void;
|
|
134
|
+
setLabel(label: string): void;
|
|
135
|
+
setPlaceholder(placeholder: string): void;
|
|
136
|
+
setSinhala(enabled: boolean): void;
|
|
137
|
+
/** Removes locale subscription. Call when discarding the field. */
|
|
138
|
+
destroy(): void;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Built-in rain sprite URLs shipped with HelaUI. */
|
|
142
|
+
declare const BUILTIN_RAIN_IMAGES: readonly [string, string, string, string];
|
|
143
|
+
|
|
144
|
+
interface RainBackgroundOptions {
|
|
145
|
+
/** Image URLs used as falling particles. Defaults to {@link BUILTIN_RAIN_IMAGES}. */
|
|
146
|
+
images?: string[];
|
|
147
|
+
/** Number of particles visible at once. Defaults to 28. */
|
|
148
|
+
density?: number;
|
|
149
|
+
/** Minimum particle width in pixels. Defaults to 28. */
|
|
150
|
+
minSize?: number;
|
|
151
|
+
/** Maximum particle width in pixels. Defaults to 72. */
|
|
152
|
+
maxSize?: number;
|
|
153
|
+
/** Minimum fall duration in seconds. Defaults to 8. */
|
|
154
|
+
minDuration?: number;
|
|
155
|
+
/** Maximum fall duration in seconds. Defaults to 18. */
|
|
156
|
+
maxDuration?: number;
|
|
157
|
+
/** Container to mount into. Defaults to `document.body`. */
|
|
158
|
+
target?: HTMLElement;
|
|
159
|
+
/** Stacking order. Defaults to 0. */
|
|
160
|
+
zIndex?: number;
|
|
161
|
+
}
|
|
162
|
+
/** Full-screen animated background with falling image particles. */
|
|
163
|
+
declare class RainBackground {
|
|
164
|
+
readonly element: HTMLDivElement;
|
|
165
|
+
constructor(options?: RainBackgroundOptions);
|
|
166
|
+
private createDrop;
|
|
167
|
+
/** Removes the background from the DOM. */
|
|
168
|
+
destroy(): void;
|
|
169
|
+
}
|
|
170
|
+
/** Default rain sprite filenames shipped with HelaUI. */
|
|
171
|
+
declare const DEFAULT_RAIN_IMAGES: readonly ["fritter.png", "swirl.png", "kokis.png", "leaf.png"];
|
|
172
|
+
/** Builds image URLs from a base path (e.g. `/assets/rain/`). */
|
|
173
|
+
declare function getDefaultRainImageUrls(basePath: string): string[];
|
|
174
|
+
|
|
175
|
+
interface CalendarOptions {
|
|
176
|
+
/** Initial selected date (Date instance or YYYY-MM-DD string) */
|
|
177
|
+
value?: Date | string;
|
|
178
|
+
/** Initial displayed year & month (defaults to active value or current date) */
|
|
179
|
+
initialDate?: Date;
|
|
180
|
+
/** Minimum selectable date */
|
|
181
|
+
minDate?: Date;
|
|
182
|
+
/** Maximum selectable date */
|
|
183
|
+
maxDate?: Date;
|
|
184
|
+
/** Display Buddhist Era (බුද්ධ වර්ෂ / BE Year) in header. Default: true */
|
|
185
|
+
showBuddhistEra?: boolean;
|
|
186
|
+
/** Force Sinhala font styling on/off. If undefined, follows active i18n locale */
|
|
187
|
+
sinhala?: boolean;
|
|
188
|
+
/** Custom Poya dates (YYYY-MM-DD strings or Date objects) */
|
|
189
|
+
poyaDates?: (string | Date)[];
|
|
190
|
+
/** Highlight today's date. Default: true */
|
|
191
|
+
highlightToday?: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Fixed width of the calendar. Accepts any valid CSS value (e.g. '360px', '24rem', '100%').
|
|
194
|
+
* Defaults to 360px when not provided.
|
|
195
|
+
*/
|
|
196
|
+
width?: string;
|
|
197
|
+
/**
|
|
198
|
+
* Fixed height of the calendar. Accepts any valid CSS value (e.g. '420px', '30rem').
|
|
199
|
+
* Defaults to 420px when not provided.
|
|
200
|
+
*/
|
|
201
|
+
height?: string;
|
|
202
|
+
/** Callback fired when a date is selected */
|
|
203
|
+
onSelect?: (date: Date, sinhalaFormattedDate: string) => void;
|
|
204
|
+
/** Callback fired when month or year changes */
|
|
205
|
+
onMonthChange?: (year: number, month: number) => void;
|
|
206
|
+
}
|
|
207
|
+
/** Converts a number string or integer into Sinhala numerals. */
|
|
208
|
+
declare function formatSinhalaNumeral(num: number | string): string;
|
|
209
|
+
/** 12 Traditional Sinhala Month names (දුරුතු to උඳුඅප්). */
|
|
210
|
+
declare const SINHALA_MONTH_NAMES: readonly ["දුරුතු", "නවම්", "මැදින්", "බක්", "වෙසක්", "පොසොන්", "ඇසළ", "නිකිණි", "බිනර", "වප්", "ඉල්", "උඳුඅප්"];
|
|
211
|
+
declare class Calendar {
|
|
212
|
+
readonly element: HTMLDivElement;
|
|
213
|
+
private selectedDate;
|
|
214
|
+
private viewYear;
|
|
215
|
+
private viewMonth;
|
|
216
|
+
private showBuddhistEra;
|
|
217
|
+
private highlightToday;
|
|
218
|
+
private sinhalaExplicit;
|
|
219
|
+
private sinhalaEnabled;
|
|
220
|
+
private minDate?;
|
|
221
|
+
private maxDate?;
|
|
222
|
+
private poyaDatesSet;
|
|
223
|
+
private onSelectCallback?;
|
|
224
|
+
private onMonthChangeCallback?;
|
|
225
|
+
private unsubscribeLocale?;
|
|
226
|
+
/** True when the caller passed an explicit height — prevents auto six-row adjustment */
|
|
227
|
+
private readonly customHeight;
|
|
228
|
+
private monthTitleEl;
|
|
229
|
+
private subTitleEl;
|
|
230
|
+
private eraBadgeEl;
|
|
231
|
+
private weekdaysEl;
|
|
232
|
+
private daysGridEl;
|
|
233
|
+
private footerEl;
|
|
234
|
+
private selectedTextEl;
|
|
235
|
+
private monthPopoverEl;
|
|
236
|
+
constructor(options?: CalendarOptions);
|
|
237
|
+
private renderSkeleton;
|
|
238
|
+
private render;
|
|
239
|
+
private createDayButton;
|
|
240
|
+
private updateSelectedText;
|
|
241
|
+
/** Gets formatted string e.g. "2026 වෙසක් 15" (Western digits) */
|
|
242
|
+
getFormattedSinhalaDate(date: Date): string;
|
|
243
|
+
selectDate(date: Date): void;
|
|
244
|
+
getValue(): Date | null;
|
|
245
|
+
setValue(value: Date | string | null): void;
|
|
246
|
+
setSinhala(enabled: boolean): void;
|
|
247
|
+
setShowBuddhistEra(show: boolean): void;
|
|
248
|
+
nextMonth(): void;
|
|
249
|
+
prevMonth(): void;
|
|
250
|
+
goToToday(): void;
|
|
251
|
+
clear(): void;
|
|
252
|
+
private toggleMonthPopover;
|
|
253
|
+
private openMonthPopover;
|
|
254
|
+
private closeMonthPopover;
|
|
255
|
+
/** Cleans up subscriptions and event listeners */
|
|
256
|
+
destroy(): void;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** Built-in Sri Lankan Ira Handa (sun face) mandala artwork. */
|
|
260
|
+
declare const BUILTIN_SUN_MANDALA_IMAGE: string;
|
|
261
|
+
|
|
262
|
+
interface SunMandalaOptions {
|
|
263
|
+
/** Image URL. Defaults to the built-in Ira Handa artwork. */
|
|
264
|
+
src?: string;
|
|
265
|
+
/** Accessible label for the artwork. */
|
|
266
|
+
alt?: string;
|
|
267
|
+
/**
|
|
268
|
+
* Display size (width & height). Accepts any valid CSS length.
|
|
269
|
+
* Defaults to `280px`.
|
|
270
|
+
*/
|
|
271
|
+
size?: string;
|
|
272
|
+
/**
|
|
273
|
+
* Full rotation duration in seconds. Lower = faster.
|
|
274
|
+
* Defaults to `36`.
|
|
275
|
+
*/
|
|
276
|
+
duration?: number;
|
|
277
|
+
/**
|
|
278
|
+
* Clip radius of the static face overlay (CSS length or %).
|
|
279
|
+
* Tuned so only the face stays still while rays + rings spin.
|
|
280
|
+
* Defaults to `22%`.
|
|
281
|
+
*/
|
|
282
|
+
faceRadius?: string;
|
|
283
|
+
/** Start with rotation paused. Defaults to `false`. */
|
|
284
|
+
paused?: boolean;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Decorative Sri Lankan sun mandala (Ira Handa).
|
|
288
|
+
* The face stays still while the aura (rays + outer rings) rotates.
|
|
289
|
+
*/
|
|
290
|
+
declare class SunMandala {
|
|
291
|
+
readonly element: HTMLDivElement;
|
|
292
|
+
private readonly spinEl;
|
|
293
|
+
private readonly faceEl;
|
|
294
|
+
private readonly spinImg;
|
|
295
|
+
private readonly faceImg;
|
|
296
|
+
constructor(options?: SunMandalaOptions);
|
|
297
|
+
/** Pause or resume the aura rotation. */
|
|
298
|
+
setPaused(paused: boolean): void;
|
|
299
|
+
isPaused(): boolean;
|
|
300
|
+
/** Set full-circle rotation duration in seconds. */
|
|
301
|
+
setDuration(seconds: number): void;
|
|
302
|
+
/** Update display size (width & height). */
|
|
303
|
+
setSize(size: string): void;
|
|
304
|
+
/** Update the static face clip radius. */
|
|
305
|
+
setFaceRadius(radius: string): void;
|
|
306
|
+
destroy(): void;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** HelaUI brand palette — all values are customizable. */
|
|
310
|
+
interface HelaTheme {
|
|
311
|
+
primary: string;
|
|
312
|
+
secondary: string;
|
|
313
|
+
success: string;
|
|
314
|
+
accent: string;
|
|
315
|
+
black: string;
|
|
316
|
+
white: string;
|
|
317
|
+
grey: string;
|
|
318
|
+
}
|
|
319
|
+
type HelaThemeKey = keyof HelaTheme;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Applies theme colors to a DOM element via CSS custom properties.
|
|
323
|
+
* Pass partial overrides to customize individual colors.
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* applyTheme({ primary: '#1a1a2e' });
|
|
327
|
+
* applyTheme(customTheme, document.getElementById('my-app')!);
|
|
328
|
+
*/
|
|
329
|
+
declare function applyTheme(overrides?: Partial<HelaTheme>, target?: HTMLElement): HelaTheme;
|
|
330
|
+
/** Removes inline theme overrides so CSS defaults take effect again. */
|
|
331
|
+
declare function resetTheme(target?: HTMLElement): HelaTheme;
|
|
332
|
+
/** Returns a CSS string of custom properties for inline styles or SSR. */
|
|
333
|
+
declare function createThemeStyle(theme?: Partial<HelaTheme>): string;
|
|
334
|
+
|
|
335
|
+
/** Default HelaUI theme — Sri Lankan inspired palette. */
|
|
336
|
+
declare const defaultTheme: HelaTheme;
|
|
337
|
+
|
|
338
|
+
/** Maps theme keys to CSS custom property names. */
|
|
339
|
+
declare const THEME_VAR_MAP: Record<HelaThemeKey, string>;
|
|
340
|
+
|
|
341
|
+
export { type ApplyTranslationsOptions, BUILTIN_RAIN_IMAGES, BUILTIN_SUN_MANDALA_IMAGE, Calendar, type CalendarOptions, type CalendarStrings, DEFAULT_RAIN_IMAGES, type DeepPartial, type HelaLocale, type HelaTextFieldTranslations, type HelaTheme, type HelaThemeKey, type HelaTranslationOverrides, type HelaTranslations, type LocaleTranslationOverrides, RainBackground, type RainBackgroundOptions, SINHALA_FONT_CLASS, SINHALA_FONT_FAMILY, SINHALA_MONTH_NAMES, SunMandala, type SunMandalaOptions, THEME_VAR_MAP, TextField, type TextFieldOptions, type TextFieldStrings, type TextFieldVariant, applySinhalaFont, applyTheme, applyTranslations, createThemeStyle, defaultTheme, defaultTranslations, formatSinhalaNumeral, getCalendarTranslation, getDefaultRainImageUrls, getLocale, getTextFieldTranslation, resetTheme, resetTranslations, setLocale, sinhalaFontStyles, subscribeLocaleChange, t };
|