@zero-studio/library 1.0.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/LICENSE +21 -0
- package/README.md +755 -0
- package/dist/index.d.ts +359 -0
- package/dist/ztl.cjs.js +1148 -0
- package/dist/ztl.css +1875 -0
- package/dist/ztl.esm.js +1166 -0
- package/dist/ztl.min.css +2 -0
- package/dist/ztl.umd.js +1156 -0
- package/package.json +75 -0
- package/src/index.js +1160 -0
- package/src/ztl.css +1874 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ZERO Technology Library (ZTL) v1.0.0
|
|
3
|
+
* TypeScript Definitions
|
|
4
|
+
* MIT License — https://zero-tech.dev
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
8
|
+
// TYPES
|
|
9
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
10
|
+
|
|
11
|
+
export type ZTLTheme = 'dark' | 'light';
|
|
12
|
+
export type ZTLLang = 'en' | 'ar';
|
|
13
|
+
export type ZTLToastPos = 'br' | 'bl' | 'tr' | 'tl' | 'tc';
|
|
14
|
+
export type ZTLToastType = 'success' | 'danger' | 'warning' | 'info';
|
|
15
|
+
export type ZTLModalSize = 'sm' | 'lg' | 'xl' | 'full' | '';
|
|
16
|
+
export type ZTLBtnSize = 'xs' | 'sm' | 'lg' | 'xl';
|
|
17
|
+
export type ZTLAvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
18
|
+
export type ZTLStatus = 'online' | 'offline' | 'busy' | 'away';
|
|
19
|
+
export type ZTLAlertType = 'success' | 'danger' | 'warning' | 'info';
|
|
20
|
+
export type ZTLProgressColor = 'success' | 'purple' | 'warning' | 'info' | 'danger';
|
|
21
|
+
export type ZTLDirection = 'ltr' | 'rtl';
|
|
22
|
+
|
|
23
|
+
export interface ZTLConfig {
|
|
24
|
+
/** UI theme. Default: 'dark' */
|
|
25
|
+
theme?: ZTLTheme;
|
|
26
|
+
/** Brand accent color (CSS color). Default: '#00f5a0' */
|
|
27
|
+
accent?: string;
|
|
28
|
+
/** Enable RTL layout. Auto-set if lang='ar'. Default: false */
|
|
29
|
+
rtl?: boolean;
|
|
30
|
+
/** Primary language. Default: 'en' */
|
|
31
|
+
lang?: ZTLLang;
|
|
32
|
+
/** Toast position. Default: 'br' */
|
|
33
|
+
toastPosition?: ZTLToastPos;
|
|
34
|
+
/** Toast auto-dismiss duration in ms. Default: 4000 */
|
|
35
|
+
toastDuration?: number;
|
|
36
|
+
/** Auto-initialize [data-ztl-*] elements. Default: true */
|
|
37
|
+
autoInit?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
41
|
+
// i18n
|
|
42
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
43
|
+
|
|
44
|
+
export interface ZTLTranslations {
|
|
45
|
+
close: string;
|
|
46
|
+
confirm: string;
|
|
47
|
+
cancel: string;
|
|
48
|
+
ok: string;
|
|
49
|
+
copy: string;
|
|
50
|
+
copied: string;
|
|
51
|
+
loading: string;
|
|
52
|
+
noData: string;
|
|
53
|
+
error: string;
|
|
54
|
+
success: string;
|
|
55
|
+
warning: string;
|
|
56
|
+
info: string;
|
|
57
|
+
required: string;
|
|
58
|
+
minLength: (n: number) => string;
|
|
59
|
+
maxLength: (n: number) => string;
|
|
60
|
+
invalid: string;
|
|
61
|
+
search: string;
|
|
62
|
+
prev: string;
|
|
63
|
+
next: string;
|
|
64
|
+
showing: (from: number, to: number, total: number) => string;
|
|
65
|
+
deleteConfirm: string;
|
|
66
|
+
uploadDrop: string;
|
|
67
|
+
uploadLimit: (mb: number) => string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export declare const i18n: Record<ZTLLang, ZTLTranslations>;
|
|
71
|
+
|
|
72
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
73
|
+
// TOAST
|
|
74
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
75
|
+
|
|
76
|
+
export interface ToastOptions {
|
|
77
|
+
/** Auto-dismiss duration in ms. Default: 4000 */
|
|
78
|
+
duration?: number;
|
|
79
|
+
/** Custom icon (emoji / HTML) */
|
|
80
|
+
icon?: string;
|
|
81
|
+
/** Show close button. Default: true */
|
|
82
|
+
closable?: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export declare class ToastManager {
|
|
86
|
+
constructor(position?: ZTLToastPos, lang?: ZTLLang);
|
|
87
|
+
show(message: string, type?: ZTLToastType, options?: ToastOptions): HTMLElement;
|
|
88
|
+
success(message: string, options?: ToastOptions): HTMLElement;
|
|
89
|
+
danger(message: string, options?: ToastOptions): HTMLElement;
|
|
90
|
+
warning(message: string, options?: ToastOptions): HTMLElement;
|
|
91
|
+
info(message: string, options?: ToastOptions): HTMLElement;
|
|
92
|
+
clear(): void;
|
|
93
|
+
destroy(): void;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
97
|
+
// MODAL
|
|
98
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
99
|
+
|
|
100
|
+
export interface ModalOptions {
|
|
101
|
+
title?: string;
|
|
102
|
+
body?: string;
|
|
103
|
+
size?: ZTLModalSize;
|
|
104
|
+
closable?: boolean;
|
|
105
|
+
onConfirm?: () => void;
|
|
106
|
+
onCancel?: () => void;
|
|
107
|
+
confirmLabel?: string;
|
|
108
|
+
cancelLabel?: string;
|
|
109
|
+
lang?: ZTLLang;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export declare class Modal {
|
|
113
|
+
constructor(options?: ModalOptions);
|
|
114
|
+
open(): this;
|
|
115
|
+
close(): this;
|
|
116
|
+
destroy(): void;
|
|
117
|
+
setBody(html: string): this;
|
|
118
|
+
setTitle(text: string): this;
|
|
119
|
+
static confirm(message: string, options?: Omit<ModalOptions, 'body'>): Promise<boolean>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
123
|
+
// TABS
|
|
124
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
125
|
+
|
|
126
|
+
export interface TabsOptions {
|
|
127
|
+
onChange?: (index: number, prev: number) => void;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export declare class Tabs {
|
|
131
|
+
constructor(container: HTMLElement | string, options?: TabsOptions);
|
|
132
|
+
activate(index: number): void;
|
|
133
|
+
getActive(): number;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
137
|
+
// DROPDOWN
|
|
138
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
139
|
+
|
|
140
|
+
export declare class Dropdown {
|
|
141
|
+
constructor(trigger: HTMLElement | string, menu: HTMLElement | string);
|
|
142
|
+
open(): void;
|
|
143
|
+
close(): void;
|
|
144
|
+
toggle(): void;
|
|
145
|
+
isOpen(): boolean;
|
|
146
|
+
destroy(): void;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
150
|
+
// PROGRESS
|
|
151
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
152
|
+
|
|
153
|
+
export interface ProgressBarOptions {
|
|
154
|
+
value?: number;
|
|
155
|
+
min?: number;
|
|
156
|
+
max?: number;
|
|
157
|
+
animate?: boolean;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export declare class ProgressBar {
|
|
161
|
+
constructor(element: HTMLElement | string, options?: ProgressBarOptions);
|
|
162
|
+
set(value: number): this;
|
|
163
|
+
increment(by?: number): this;
|
|
164
|
+
decrement(by?: number): this;
|
|
165
|
+
complete(): this;
|
|
166
|
+
reset(): this;
|
|
167
|
+
animateTo(target: number, duration?: number): this;
|
|
168
|
+
readonly value: number;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface CircularProgressOptions {
|
|
172
|
+
value?: number;
|
|
173
|
+
size?: number;
|
|
174
|
+
strokeWidth?: number;
|
|
175
|
+
color?: string;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export declare class CircularProgress {
|
|
179
|
+
constructor(container: HTMLElement | string, options?: CircularProgressOptions);
|
|
180
|
+
set(value: number): this;
|
|
181
|
+
animateTo(target: number, duration?: number): this;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
185
|
+
// TOOLTIP
|
|
186
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
187
|
+
|
|
188
|
+
export type TooltipPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
189
|
+
|
|
190
|
+
export declare class Tooltip {
|
|
191
|
+
constructor(element: HTMLElement | string, text: string, position?: TooltipPosition);
|
|
192
|
+
update(text: string): this;
|
|
193
|
+
destroy(): void;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
197
|
+
// FORM VALIDATOR
|
|
198
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
199
|
+
|
|
200
|
+
export type ValidationRule =
|
|
201
|
+
| 'required'
|
|
202
|
+
| { type: 'minLength'; value: number }
|
|
203
|
+
| { type: 'maxLength'; value: number }
|
|
204
|
+
| { type: 'email' }
|
|
205
|
+
| { type: 'pattern'; value: RegExp; message?: string }
|
|
206
|
+
| { type: 'custom'; validate: (value: string) => true | string };
|
|
207
|
+
|
|
208
|
+
export interface FormValidatorOptions {
|
|
209
|
+
lang?: ZTLLang;
|
|
210
|
+
onSubmit?: (values: Record<string, string>, event: Event) => void;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export declare class FormValidator {
|
|
214
|
+
constructor(
|
|
215
|
+
form: HTMLFormElement | string,
|
|
216
|
+
rules: Record<string, ValidationRule[]>,
|
|
217
|
+
options?: FormValidatorOptions
|
|
218
|
+
);
|
|
219
|
+
validate(): boolean;
|
|
220
|
+
getValues(): Record<string, string>;
|
|
221
|
+
clearErrors(): void;
|
|
222
|
+
setErrors(errors: Record<string, string>): void;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
226
|
+
// TAG INPUT
|
|
227
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
228
|
+
|
|
229
|
+
export interface TagInputOptions {
|
|
230
|
+
initial?: string[];
|
|
231
|
+
max?: number;
|
|
232
|
+
onChange?: (tags: string[]) => void;
|
|
233
|
+
onAdd?: (tag: string, tags: string[]) => void;
|
|
234
|
+
onRemove?: (tag: string, tags: string[]) => void;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export declare class TagInput {
|
|
238
|
+
constructor(container: HTMLElement | string, options?: TagInputOptions);
|
|
239
|
+
add(text: string): this;
|
|
240
|
+
remove(text: string): this;
|
|
241
|
+
getTags(): string[];
|
|
242
|
+
clear(): this;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
246
|
+
// DATA TABLE
|
|
247
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
248
|
+
|
|
249
|
+
export interface TableColumn<T = Record<string, unknown>> {
|
|
250
|
+
key: keyof T & string;
|
|
251
|
+
label: string;
|
|
252
|
+
sortable?: boolean;
|
|
253
|
+
render?: (value: unknown, row: T) => string;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export interface DataTableOptions<T = Record<string, unknown>> {
|
|
257
|
+
columns: TableColumn<T>[];
|
|
258
|
+
data: T[];
|
|
259
|
+
pageSize?: number;
|
|
260
|
+
searchable?: boolean;
|
|
261
|
+
lang?: ZTLLang;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export declare class DataTable<T = Record<string, unknown>> {
|
|
265
|
+
constructor(container: HTMLElement | string, options: DataTableOptions<T>);
|
|
266
|
+
update(data: T[]): this;
|
|
267
|
+
setPage(page: number): this;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
271
|
+
// THEME MANAGER
|
|
272
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
273
|
+
|
|
274
|
+
export interface ThemeManagerOptions {
|
|
275
|
+
storageKey?: string;
|
|
276
|
+
default?: ZTLTheme;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export declare class ThemeManager {
|
|
280
|
+
constructor(options?: ThemeManagerOptions);
|
|
281
|
+
apply(theme: ZTLTheme): void;
|
|
282
|
+
toggle(): void;
|
|
283
|
+
setAccent(color: string): void;
|
|
284
|
+
readonly current: ZTLTheme;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
288
|
+
// UTILITIES
|
|
289
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
290
|
+
|
|
291
|
+
export interface CounterOptions {
|
|
292
|
+
duration?: number;
|
|
293
|
+
prefix?: string;
|
|
294
|
+
suffix?: string;
|
|
295
|
+
decimals?: number;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export interface ClipboardResult {
|
|
299
|
+
success: boolean;
|
|
300
|
+
message: string;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export interface SkeletonInstance {
|
|
304
|
+
clear: () => void;
|
|
305
|
+
replace: (html: string) => void;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export declare function copyToClipboard(text: string, lang?: ZTLLang): Promise<ClipboardResult>;
|
|
309
|
+
export declare function animateCounter(el: HTMLElement, target: number, options?: CounterOptions): void;
|
|
310
|
+
export declare function skeleton(container: HTMLElement | string, count?: number): SkeletonInstance;
|
|
311
|
+
export declare function initScrollReveal(selector?: string): void;
|
|
312
|
+
export declare function initCounters(selector?: string): void;
|
|
313
|
+
export declare function initCopyButtons(lang?: ZTLLang): void;
|
|
314
|
+
|
|
315
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
316
|
+
// MAIN ZTL INTERFACE
|
|
317
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
318
|
+
|
|
319
|
+
export interface ZTLInstance {
|
|
320
|
+
readonly version: string;
|
|
321
|
+
lang: ZTLLang;
|
|
322
|
+
theme: ThemeManager;
|
|
323
|
+
toast: ToastManager;
|
|
324
|
+
|
|
325
|
+
init(config?: ZTLConfig): ZTLInstance;
|
|
326
|
+
|
|
327
|
+
// Components
|
|
328
|
+
Modal: typeof Modal;
|
|
329
|
+
Tabs: typeof Tabs;
|
|
330
|
+
Dropdown: typeof Dropdown;
|
|
331
|
+
ProgressBar: typeof ProgressBar;
|
|
332
|
+
CircularProgress: typeof CircularProgress;
|
|
333
|
+
Tooltip: typeof Tooltip;
|
|
334
|
+
FormValidator: typeof FormValidator;
|
|
335
|
+
TagInput: typeof TagInput;
|
|
336
|
+
DataTable: typeof DataTable;
|
|
337
|
+
ThemeManager: typeof ThemeManager;
|
|
338
|
+
ToastManager: typeof ToastManager;
|
|
339
|
+
|
|
340
|
+
// Utils
|
|
341
|
+
copyToClipboard: typeof copyToClipboard;
|
|
342
|
+
animateCounter: typeof animateCounter;
|
|
343
|
+
skeleton: typeof skeleton;
|
|
344
|
+
initScrollReveal: typeof initScrollReveal;
|
|
345
|
+
initCounters: typeof initCounters;
|
|
346
|
+
initCopyButtons: typeof initCopyButtons;
|
|
347
|
+
|
|
348
|
+
// i18n
|
|
349
|
+
i18n: typeof i18n;
|
|
350
|
+
t(key: keyof ZTLTranslations, ...args: unknown[]): string;
|
|
351
|
+
|
|
352
|
+
// DOM
|
|
353
|
+
$: (selector: string, context?: Document | HTMLElement) => HTMLElement | null;
|
|
354
|
+
$$: (selector: string, context?: Document | HTMLElement) => HTMLElement[];
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
declare const ZTL: ZTLInstance;
|
|
358
|
+
export default ZTL;
|
|
359
|
+
export { ZTL };
|