domma-js 0.58.0 → 0.58.2

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.
@@ -1,623 +0,0 @@
1
- /**
2
- * Domma TypeScript Definitions
3
- * Dynamic Object Manipulation & Modeling API
4
- *
5
- * A lightweight, zero-dependency JavaScript framework combining
6
- * jQuery-style DOM manipulation, Lodash utilities, and modern UI components.
7
- *
8
- * NOTE: This is a consolidated type definition file for the Domma framework.
9
- * For complete type definitions (generated from the source), see the domma-js npm package:
10
- * assets/types/index.d.ts - https://unpkg.com/domma-js/assets/types/index.d.ts
11
- */
12
-
13
- // ============================================
14
- // DOM Module - jQuery-compatible API
15
- // ============================================
16
-
17
- export interface DommaCollection {
18
- length: number;
19
- [index: number]: HTMLElement;
20
-
21
- // Traversal
22
- find(selector: string): DommaCollection;
23
- children(selector?: string): DommaCollection;
24
- parent(selector?: string): DommaCollection;
25
- parents(selector?: string): DommaCollection;
26
- closest(selector: string): DommaCollection;
27
- siblings(selector?: string): DommaCollection;
28
- next(selector?: string): DommaCollection;
29
- prev(selector?: string): DommaCollection;
30
- first(): DommaCollection;
31
- last(): DommaCollection;
32
- eq(index: number): DommaCollection;
33
- filter(selector: string | ((index: number, element: HTMLElement) => boolean)): DommaCollection;
34
- not(selector: string): DommaCollection;
35
- is(selector: string): boolean;
36
- has(selector: string): DommaCollection;
37
-
38
- // Content
39
- html(): string;
40
- html(content: string): DommaCollection;
41
- text(): string;
42
- text(content: string): DommaCollection;
43
- val(): string | string[] | number;
44
- val(value: string | string[] | number): DommaCollection;
45
-
46
- // Attributes
47
- attr(name: string): string | undefined;
48
- attr(name: string, value: string | number | boolean): DommaCollection;
49
- attr(attributes: Record<string, any>): DommaCollection;
50
- removeAttr(name: string): DommaCollection;
51
- prop(name: string): any;
52
- prop(name: string, value: any): DommaCollection;
53
- data(key: string): any;
54
- data(key: string, value: any): DommaCollection;
55
-
56
- // CSS & Classes
57
- css(property: string): string;
58
- css(property: string, value: string | number): DommaCollection;
59
- css(properties: Record<string, string | number>): DommaCollection;
60
- addClass(className: string): DommaCollection;
61
- removeClass(className: string): DommaCollection;
62
- toggleClass(className: string): DommaCollection;
63
- hasClass(className: string): boolean;
64
-
65
- // Manipulation
66
- append(content: string | HTMLElement | DommaCollection): DommaCollection;
67
- prepend(content: string | HTMLElement | DommaCollection): DommaCollection;
68
- after(content: string | HTMLElement | DommaCollection): DommaCollection;
69
- before(content: string | HTMLElement | DommaCollection): DommaCollection;
70
- remove(): DommaCollection;
71
- empty(): DommaCollection;
72
- clone(deep?: boolean): DommaCollection;
73
-
74
- // Events
75
- on(event: string, handler: (e: Event) => void): DommaCollection;
76
- on(event: string, selector: string, handler: (e: Event) => void): DommaCollection;
77
- off(event: string, handler?: (e: Event) => void): DommaCollection;
78
- one(event: string, handler: (e: Event) => void): DommaCollection;
79
- trigger(event: string, data?: any): DommaCollection;
80
- click(handler?: (e: MouseEvent) => void): DommaCollection;
81
- change(handler?: (e: Event) => void): DommaCollection;
82
- submit(handler?: (e: Event) => void): DommaCollection;
83
-
84
- // Effects
85
- show(duration?: number): DommaCollection;
86
- hide(duration?: number): DommaCollection;
87
- toggle(duration?: number): DommaCollection;
88
- fadeIn(duration?: number): DommaCollection;
89
- fadeOut(duration?: number): DommaCollection;
90
- slideUp(duration?: number): DommaCollection;
91
- slideDown(duration?: number): DommaCollection;
92
-
93
- // Dimensions
94
- width(): number;
95
- width(value: number | string): DommaCollection;
96
- height(): number;
97
- height(value: number | string): DommaCollection;
98
- offset(): { top: number; left: number };
99
- scrollTop(): number;
100
- scrollTop(value: number): DommaCollection;
101
-
102
- // Iteration
103
- each(callback: (index: number, element: HTMLElement) => void | boolean): DommaCollection;
104
- }
105
-
106
- export function dom(selector: string | HTMLElement | NodeList | DommaCollection, context?: HTMLElement | Document): DommaCollection;
107
-
108
- // ============================================
109
- // Utils Module - Lodash-compatible API
110
- // ============================================
111
-
112
- export interface Utils {
113
- // Array
114
- chunk<T>(array: T[], size: number): T[][];
115
- compact<T>(array: T[]): T[];
116
- difference<T>(array: T[], ...values: T[][]): T[];
117
- flatten<T>(array: any[]): T[];
118
- uniq<T>(array: T[]): T[];
119
- sortBy<T>(collection: T[], iteratee: string | ((item: T) => any)): T[];
120
- zip<T>(...arrays: T[][]): T[][];
121
-
122
- // Collection
123
- each<T>(collection: T[] | Record<string, T>, iteratee: (value: T, key: string | number) => void | boolean): T[] | Record<string, T>;
124
- filter<T>(collection: T[], predicate: (value: T) => boolean): T[];
125
- find<T>(collection: T[], predicate: (value: T) => boolean): T | undefined;
126
- groupBy<T>(collection: T[], iteratee: string | ((value: T) => any)): Record<string, T[]>;
127
- map<T, U>(collection: T[], iteratee: (value: T) => U): U[];
128
- reduce<T, U>(collection: T[], iteratee: (acc: U, value: T) => U, initial: U): U;
129
-
130
- // Function
131
- debounce<T extends (...args: any[]) => any>(func: T, wait: number): T;
132
- throttle<T extends (...args: any[]) => any>(func: T, wait: number): T;
133
- memoize<T extends (...args: any[]) => any>(func: T): T;
134
- once<T extends (...args: any[]) => any>(func: T): T;
135
-
136
- // Object
137
- get(object: any, path: string, defaultValue?: any): any;
138
- set(object: any, path: string, value: any): any;
139
- has(object: any, path: string): boolean;
140
- pick<T>(object: T, ...paths: string[]): Partial<T>;
141
- omit<T>(object: T, ...paths: string[]): Partial<T>;
142
- merge<T>(...objects: Partial<T>[]): T;
143
- cloneDeep<T>(value: T): T;
144
-
145
- // Lang
146
- isArray(value: any): value is any[];
147
- isObject(value: any): value is object;
148
- isFunction(value: any): value is Function;
149
- isEmpty(value: any): boolean;
150
- isEqual(value: any, other: any): boolean;
151
-
152
- // String
153
- camelCase(string: string): string;
154
- kebabCase(string: string): string;
155
- snakeCase(string: string): string;
156
- capitalize(string: string): string;
157
- truncate(string: string, length: number): string;
158
-
159
- // Math
160
- sum(array: number[]): number;
161
- mean(array: number[]): number;
162
- max(array: number[]): number;
163
- min(array: number[]): number;
164
- clamp(number: number, lower: number, upper: number): number;
165
- random(lower?: number, upper?: number): number;
166
-
167
- // Template
168
- template(templateString: string): (data: any) => string;
169
- render(templateString: string, data: any): string;
170
-
171
- // Browser
172
- copyToClipboard(text: string): Promise<void>;
173
- }
174
-
175
- export const utils: Utils;
176
-
177
- // ============================================
178
- // Dates Module - Moment.js-style API
179
- // ============================================
180
-
181
- export interface DommaDate {
182
- // Format
183
- format(format: string): string;
184
- toISOString(): string;
185
- unix(): number;
186
-
187
- // Manipulate
188
- add(value: number, unit: string): DommaDate;
189
- subtract(value: number, unit: string): DommaDate;
190
- startOf(unit: string): DommaDate;
191
- endOf(unit: string): DommaDate;
192
- set(unit: string, value: number): DommaDate;
193
-
194
- // Getters
195
- year(): number;
196
- month(): number;
197
- date(): number;
198
- day(): number;
199
- hour(): number;
200
- minute(): number;
201
- second(): number;
202
-
203
- // Compare
204
- isBefore(date: DommaDate | string | number): boolean;
205
- isAfter(date: DommaDate | string | number): boolean;
206
- isSame(date: DommaDate | string | number): boolean;
207
- isBetween(start: DommaDate | string | number, end: DommaDate | string | number): boolean;
208
- diff(date: DommaDate | string | number, unit?: string): number;
209
-
210
- // Relative
211
- fromNow(): string;
212
- from(date: DommaDate | string | number): string;
213
- toNow(): string;
214
- to(date: DommaDate | string | number): string;
215
- }
216
-
217
- export interface Dates {
218
- (date?: string | number | Date): DommaDate;
219
- now(): DommaDate;
220
- parse(dateString: string): DommaDate;
221
- isValid(date: any): boolean;
222
- }
223
-
224
- export const dates: Dates;
225
-
226
- // ============================================
227
- // Models Module - Reactive Models & Pub/Sub
228
- // ============================================
229
-
230
- export interface BlueprintField {
231
- type: 'string' | 'number' | 'boolean' | 'email' | 'password' | 'url' | 'date' | 'textarea' | 'select' | 'radio' | 'checkbox-group' | 'array' | 'object' | 'any';
232
- required?: boolean;
233
- minLength?: number;
234
- maxLength?: number;
235
- min?: number;
236
- max?: number;
237
- pattern?: RegExp;
238
- options?: Array<{ value: any; label: string }>;
239
- custom?: (value: any, allData?: any) => string | void;
240
- label?: string;
241
- rows?: number;
242
- schema?: Blueprint;
243
- formConfig?: {
244
- placeholder?: string;
245
- tooltip?: string;
246
- class?: string;
247
- prefix?: string;
248
- autocomplete?: string;
249
- readonly?: boolean;
250
- [key: string]: any;
251
- };
252
- }
253
-
254
- export interface Blueprint {
255
- [key: string]: BlueprintField;
256
- }
257
-
258
- export interface Model {
259
- get(key: string): any;
260
- set(key: string, value: any): void;
261
- set(data: Record<string, any>): void;
262
- toJSON(): Record<string, any>;
263
- validate(): Array<{ field: string; message: string }>;
264
- onChange(callback: (changes: Record<string, any>) => void): void;
265
- onChange(field: string, callback: (newValue: any, oldValue: any) => void): void;
266
- offChange(callback?: Function): void;
267
- reset(clearStorage?: boolean): void;
268
- save(): void;
269
- load(): void;
270
- clearStorage(): void;
271
- isPersisted(): boolean;
272
- }
273
-
274
- export interface Models {
275
- // Model creation
276
- create(blueprint: Blueprint, initialData?: any, options?: { persist?: string }): Model;
277
-
278
- // Blueprint composition
279
- extend(...blueprints: Blueprint[]): Blueprint;
280
- pick(blueprint: Blueprint, fields: string[]): Blueprint;
281
- omit(blueprint: Blueprint, fields: string[]): Blueprint;
282
-
283
- // Pub/Sub
284
- subscribe(event: string, callback: Function): void;
285
- publish(event: string, data?: any): void;
286
- unsubscribe(event: string, callback?: Function): void;
287
- once(event: string, callback: Function): void;
288
-
289
- // DOM Binding
290
- bind(model: Model, field: string, selector: string, options?: any): void;
291
- unbind(model: Model, field: string, selector: string): void;
292
-
293
- // Types
294
- types: {
295
- string: string;
296
- number: string;
297
- boolean: string;
298
- array: string;
299
- object: string;
300
- date: string;
301
- any: string;
302
- };
303
- }
304
-
305
- export const models: Models;
306
-
307
- // ============================================
308
- // Forms Module - Blueprint-driven Forms
309
- // ============================================
310
-
311
- export interface FormOptions {
312
- layout?: 'stacked' | 'grid' | 'inline';
313
- gridColumns?: number;
314
- submitText?: string;
315
- cancelText?: string;
316
- showCancel?: boolean;
317
- onSubmit?: (data: any, form: any) => void | boolean | Promise<void | boolean>;
318
- onCancel?: () => void;
319
- }
320
-
321
- export interface ModalFormOptions {
322
- title?: string;
323
- submitText?: string;
324
- cancelText?: string;
325
- initialData?: any;
326
- onSave?: (data: any) => void | Promise<void>;
327
- onError?: (error: Error) => void;
328
- }
329
-
330
- export interface CrudOptions {
331
- title?: string;
332
- apiEndpoint?: string;
333
- columns?: string[];
334
- pageSize?: number;
335
- sortable?: boolean;
336
- exportable?: boolean;
337
- onBeforeSave?: (data: any) => any;
338
- onAfterSave?: (data: any) => void;
339
- onAfterDelete?: (id: string | number) => void;
340
- }
341
-
342
- export interface Forms {
343
- render(selector: string, blueprint: Blueprint, initialData?: any, options?: FormOptions): any;
344
- modal(blueprint: Blueprint, options?: ModalFormOptions): void;
345
- wizard(selector: string, steps: Array<{ title: string; blueprint: Blueprint }>, options?: any): any;
346
- crud(selector: string, blueprint: Blueprint, options?: CrudOptions): any;
347
- }
348
-
349
- export const forms: Forms;
350
-
351
- // ============================================
352
- // Elements Module - UI Components
353
- // ============================================
354
-
355
- export interface Elements {
356
- // Modal
357
- modal(selector: string, options?: any): {
358
- open(): void;
359
- close(): void;
360
- toggle(): void;
361
- isOpen(): boolean;
362
- };
363
-
364
- // Toast
365
- toast(message: string, options?: { type?: 'success' | 'danger' | 'info' | 'warning'; duration?: number; position?: string }): void;
366
-
367
- // Dialog
368
- alert(message: string, options?: any): Promise<void>;
369
- confirm(message: string, options?: any): Promise<boolean>;
370
- prompt(message: string, options?: any): Promise<string | null>;
371
-
372
- // Tabs
373
- tabs(selector: string, options?: any): any;
374
-
375
- // Accordion
376
- accordion(selector: string, options?: any): any;
377
-
378
- // Tooltip
379
- tooltip(selector: string, options?: { content?: string; position?: string; trigger?: string }): any;
380
-
381
- // Carousel
382
- carousel(selector: string, options?: any): any;
383
-
384
- // Loader
385
- loader(selector: string, options?: { type?: 'spinner' | 'dots' | 'pulse' | 'bars'; size?: string | number; overlay?: boolean; text?: string }): {
386
- show(): void;
387
- hide(): void;
388
- toggle(): void;
389
- };
390
-
391
- // Card
392
- card(selector: string, options?: any): any;
393
-
394
- // Dropdown
395
- dropdown(selector: string, options?: any): any;
396
-
397
- // BackToTop
398
- backToTop(selector: string, options?: any): any;
399
-
400
- // Slideover
401
- slideover(selector: string, options?: any): {
402
- open(): void;
403
- close(): void;
404
- toggle(): void;
405
- isOpen(): boolean;
406
- };
407
- }
408
-
409
- export const elements: Elements;
410
-
411
- // ============================================
412
- // Tables Module - DataTable Functionality
413
- // ============================================
414
-
415
- export interface Tables {
416
- create(selector: string, options: {
417
- data: any[];
418
- columns: Array<{ field: string; title: string; sortable?: boolean }>;
419
- pagination?: boolean;
420
- pageSize?: number;
421
- selectable?: boolean;
422
- striped?: boolean;
423
- evenRowColor?: string;
424
- oddRowColor?: string;
425
- hoverColor?: string;
426
- }): {
427
- setData(data: any[]): void;
428
- addRow(row: any): void;
429
- removeRow(index: number): void;
430
- search(query: string): void;
431
- sort(field: string, direction?: 'asc' | 'desc'): void;
432
- getSelected(): any[];
433
- download(format: 'csv' | 'json', filename?: string): void;
434
- };
435
- }
436
-
437
- export const tables: Tables;
438
-
439
- // ============================================
440
- // Storage Module - localStorage Wrapper
441
- // ============================================
442
-
443
- export interface Storage {
444
- get(key: string, defaultValue?: any): any;
445
- set(key: string, value: any): void;
446
- remove(key: string): void;
447
- has(key: string): boolean;
448
- clear(): void;
449
- keys(): string[];
450
- size(key?: string): number;
451
- totalSize(): number;
452
- isAvailable(): boolean;
453
- }
454
-
455
- export const storage: Storage;
456
-
457
- // ============================================
458
- // HTTP Module - Fetch-based HTTP Client
459
- // ============================================
460
-
461
- export interface Http {
462
- get(url: string, params?: any): Promise<any>;
463
- post(url: string, data?: any): Promise<any>;
464
- put(url: string, data?: any): Promise<any>;
465
- delete(url: string): Promise<any>;
466
- }
467
-
468
- export const http: Http;
469
-
470
- // ============================================
471
- // Theme Module - Theme Management
472
- // ============================================
473
-
474
- export interface Theme {
475
- init(options?: { theme?: string; autoDetect?: boolean; persist?: boolean }): void;
476
- set(themeName: string): void;
477
- get(): string;
478
- getBase(): string;
479
- getMode(): string;
480
- isDark(): boolean;
481
- listThemes(): string[];
482
- listBases(): string[];
483
- }
484
-
485
- export const theme: Theme;
486
-
487
- // ============================================
488
- // Icons Module - SVG Icon System
489
- // ============================================
490
-
491
- export interface Icons {
492
- render(iconName: string, options?: { size?: number; color?: string; class?: string }): string;
493
- inject(selector: string, iconName: string, options?: any): void;
494
- scan(container?: HTMLElement | string): void;
495
- }
496
-
497
- export const icons: Icons;
498
-
499
- // ============================================
500
- // Config Engine
501
- // ============================================
502
-
503
- export interface SetupConfig {
504
- [selector: string]: {
505
- component?: string;
506
- options?: any;
507
- initial?: any;
508
- events?: Record<string, (e: Event, el: DommaCollection) => void>;
509
- };
510
- }
511
-
512
- // ============================================
513
- // Blueprint Composition (B Alias)
514
- // ============================================
515
-
516
- export interface BlueprintComposition {
517
- extend(...blueprints: Blueprint[]): Blueprint;
518
- pick(blueprint: Blueprint, fields: string[]): Blueprint;
519
- omit(blueprint: Blueprint, fields: string[]): Blueprint;
520
- }
521
-
522
- // ============================================
523
- // Main Domma Interface
524
- // ============================================
525
-
526
- export interface DommaStatic {
527
- // DOM selection
528
- (selector: string | HTMLElement | NodeList | DommaCollection, context?: HTMLElement | Document): DommaCollection;
529
- (callback: () => void): void;
530
-
531
- // Modules
532
- dom: typeof dom;
533
- utils: Utils;
534
- dates: Dates;
535
- models: Models;
536
- elements: Elements;
537
- tables: Tables;
538
- storage: Storage;
539
- http: Http;
540
- theme: Theme;
541
- icons: Icons;
542
- forms: Forms;
543
-
544
- // Config Engine
545
- setup(config: SetupConfig): void;
546
- update(selector: string, changes: any): any;
547
- config(selector?: string): any;
548
- reset(selector?: string): void;
549
- ready(callback: () => void): void;
550
-
551
- // Version
552
- version: string;
553
-
554
- // Aliases (exposed on Domma object)
555
- M: Models;
556
- D: Dates;
557
- S: Storage;
558
- A: any; // Auth module
559
- F: Forms;
560
- H: Http;
561
- E: Elements;
562
- I: Icons;
563
- T: Tables;
564
- B: BlueprintComposition;
565
- }
566
-
567
- // ============================================
568
- // Global Declarations
569
- // ============================================
570
-
571
- declare global {
572
- const Domma: DommaStatic;
573
- const $: DommaStatic;
574
- const _: Utils;
575
- const M: Models;
576
- const B: BlueprintComposition;
577
- const D: Dates;
578
- const S: Storage;
579
- const A: any; // Auth module
580
- const F: Forms;
581
- const H: Http;
582
- const E: Elements;
583
- const I: Icons;
584
- const T: Tables;
585
-
586
- interface Window {
587
- Domma: DommaStatic;
588
- $: DommaStatic;
589
- _: Utils;
590
- M: Models;
591
- B: BlueprintComposition;
592
- D: Dates;
593
- S: Storage;
594
- A: any;
595
- F: Forms;
596
- H: Http;
597
- E: Elements;
598
- I: Icons;
599
- T: Tables;
600
- }
601
- }
602
-
603
- // ============================================
604
- // Module Exports
605
- // ============================================
606
-
607
- declare const Domma: DommaStatic;
608
- export default Domma;
609
-
610
- export {
611
- Domma,
612
- dom,
613
- utils,
614
- dates,
615
- models,
616
- forms,
617
- elements,
618
- tables,
619
- storage,
620
- http,
621
- theme,
622
- icons
623
- };