adminator-admin-dashboard 2.7.1 → 2.8.1
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/CHANGELOG.md +116 -0
- package/CLAUDE.md +5 -5
- package/README.md +63 -24
- package/dist/main.js +1779 -2571
- package/dist/main.js.map +1 -1
- package/package.json +28 -36
- package/src/assets/scripts/app 2.js +645 -0
- package/src/assets/scripts/app.js +3 -3
- package/src/assets/scripts/utils/theme.js +4 -2
- package/src/assets/scripts/vectorMaps/index.js +5 -5
- package/dist/55b07f26c86c8e3d3754.svg +0 -1
- package/dist/9fad440d8ee7a949a9a9.svg +0 -1
- package/dist/test.html +0 -91
- package/src/assets/scripts/app.ts +0 -757
- package/src/assets/scripts/components/Chart.ts +0 -1350
- package/src/assets/scripts/components/Sidebar.ts +0 -388
- package/src/assets/scripts/datatable/index.ts +0 -707
- package/src/assets/scripts/datepicker/index.ts +0 -699
- package/src/assets/scripts/ui/index.ts +0 -740
- package/src/assets/scripts/utils/date.ts +0 -363
- package/src/assets/scripts/utils/dom.ts +0 -513
- package/src/assets/scripts/utils/theme.ts +0 -313
- package/src/assets/scripts/vectorMaps/index.ts +0 -542
- package/src/test.html +0 -96
- package/src/types/index.ts +0 -236
- /package/dist/assets/{c1e38fd9e0e74ba58f7a2b77ef29fdd3.svg → fontawesome-webfont.svg} +0 -0
- /package/dist/assets/{f0fc8c798eac5636249c4ea287832422.svg → themify.svg} +0 -0
|
@@ -1,513 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DOM Utility Functions
|
|
3
|
-
* Provides jQuery-like functionality using vanilla JavaScript with TypeScript support
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { DOMUtilities, AnimationOptions } from '../../../types';
|
|
7
|
-
|
|
8
|
-
export type ElementSelector = string | Element | null;
|
|
9
|
-
|
|
10
|
-
interface ElementDimensions {
|
|
11
|
-
width: number;
|
|
12
|
-
height: number;
|
|
13
|
-
top: number;
|
|
14
|
-
left: number;
|
|
15
|
-
bottom: number;
|
|
16
|
-
right: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface SlideAnimationKeyframes {
|
|
20
|
-
height: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface FadeAnimationKeyframes {
|
|
24
|
-
opacity: number;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Convert string selector to element or return element as-is
|
|
29
|
-
*/
|
|
30
|
-
function getElement(element: ElementSelector): Element | null {
|
|
31
|
-
if (typeof element === 'string') {
|
|
32
|
-
return document.querySelector(element);
|
|
33
|
-
}
|
|
34
|
-
return element;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* DOM Utility object with type-safe methods
|
|
39
|
-
*/
|
|
40
|
-
export const DOM: DOMUtilities = {
|
|
41
|
-
/**
|
|
42
|
-
* Document ready (replaces $(document).ready())
|
|
43
|
-
*/
|
|
44
|
-
ready: (callback: () => void): void => {
|
|
45
|
-
if (document.readyState === 'loading') {
|
|
46
|
-
document.addEventListener('DOMContentLoaded', callback);
|
|
47
|
-
} else {
|
|
48
|
-
callback();
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Select single element (replaces $('selector'))
|
|
54
|
-
*/
|
|
55
|
-
select: (selector: string, context: Element | Document = document): HTMLElement | null => {
|
|
56
|
-
return context.querySelector(selector);
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Select multiple elements (replaces $('selector'))
|
|
61
|
-
*/
|
|
62
|
-
selectAll: (selector: string, context: Element | Document = document): HTMLElement[] => {
|
|
63
|
-
return Array.from(context.querySelectorAll(selector));
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Check if element exists
|
|
68
|
-
*/
|
|
69
|
-
exists: (selector: string, context: Element | Document = document): boolean => {
|
|
70
|
-
return context.querySelector(selector) !== null;
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Add event listener (replaces $.on())
|
|
75
|
-
*/
|
|
76
|
-
on: (
|
|
77
|
-
element: Element | Window | Document,
|
|
78
|
-
event: string,
|
|
79
|
-
handler: (event: Event) => void,
|
|
80
|
-
options: AddEventListenerOptions = {}
|
|
81
|
-
): void => {
|
|
82
|
-
if (element) {
|
|
83
|
-
element.addEventListener(event, handler, options);
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Remove event listener (replaces $.off())
|
|
89
|
-
*/
|
|
90
|
-
off: (
|
|
91
|
-
element: Element | Window | Document,
|
|
92
|
-
event: string,
|
|
93
|
-
handler: (event: Event) => void
|
|
94
|
-
): void => {
|
|
95
|
-
if (element) {
|
|
96
|
-
element.removeEventListener(event, handler);
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Add class (replaces $.addClass())
|
|
102
|
-
*/
|
|
103
|
-
addClass: (element: Element, className: string): void => {
|
|
104
|
-
const el = getElement(element);
|
|
105
|
-
if (el) {
|
|
106
|
-
el.classList.add(className);
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Remove class (replaces $.removeClass())
|
|
112
|
-
*/
|
|
113
|
-
removeClass: (element: Element, className: string): void => {
|
|
114
|
-
const el = getElement(element);
|
|
115
|
-
if (el) {
|
|
116
|
-
el.classList.remove(className);
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Toggle class (replaces $.toggleClass())
|
|
122
|
-
*/
|
|
123
|
-
toggleClass: (element: Element, className: string): void => {
|
|
124
|
-
const el = getElement(element);
|
|
125
|
-
if (el) {
|
|
126
|
-
el.classList.toggle(className);
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Check if element has class (replaces $.hasClass())
|
|
132
|
-
*/
|
|
133
|
-
hasClass: (element: Element, className: string): boolean => {
|
|
134
|
-
const el = getElement(element);
|
|
135
|
-
return el ? el.classList.contains(className) : false;
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Get/Set attribute (replaces $.attr())
|
|
140
|
-
*/
|
|
141
|
-
attr: (element: Element, name: string, value?: string): string | void => {
|
|
142
|
-
const el = getElement(element);
|
|
143
|
-
if (!el) return;
|
|
144
|
-
|
|
145
|
-
if (value === undefined) {
|
|
146
|
-
return el.getAttribute(name) || '';
|
|
147
|
-
} else {
|
|
148
|
-
el.setAttribute(name, value);
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Get/Set data attribute (replaces $.data())
|
|
154
|
-
*/
|
|
155
|
-
data: (element: Element, name: string, value?: any): any => {
|
|
156
|
-
const el = getElement(element);
|
|
157
|
-
if (!el) return null;
|
|
158
|
-
|
|
159
|
-
const dataName = `data-${name}`;
|
|
160
|
-
|
|
161
|
-
if (value === undefined) {
|
|
162
|
-
const attrValue = el.getAttribute(dataName);
|
|
163
|
-
// Try to parse JSON for complex data
|
|
164
|
-
if (attrValue) {
|
|
165
|
-
try {
|
|
166
|
-
return JSON.parse(attrValue);
|
|
167
|
-
} catch {
|
|
168
|
-
return attrValue;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return null;
|
|
172
|
-
} else {
|
|
173
|
-
const stringValue = typeof value === 'object' ? JSON.stringify(value) : String(value);
|
|
174
|
-
el.setAttribute(dataName, stringValue);
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Extended DOM utilities with additional functionality
|
|
181
|
-
*/
|
|
182
|
-
export const DOMExtended = {
|
|
183
|
-
...DOM,
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Get/Set text content (replaces $.text())
|
|
187
|
-
*/
|
|
188
|
-
text: (element: ElementSelector, content?: string): string | void => {
|
|
189
|
-
const el = getElement(element);
|
|
190
|
-
if (!el) return;
|
|
191
|
-
|
|
192
|
-
if (content === undefined) {
|
|
193
|
-
return el.textContent || '';
|
|
194
|
-
} else {
|
|
195
|
-
el.textContent = content;
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Get/Set HTML content (replaces $.html())
|
|
201
|
-
*/
|
|
202
|
-
html: (element: ElementSelector, content?: string): string | void => {
|
|
203
|
-
const el = getElement(element);
|
|
204
|
-
if (!el) return;
|
|
205
|
-
|
|
206
|
-
if (content === undefined) {
|
|
207
|
-
return (el as HTMLElement).innerHTML;
|
|
208
|
-
} else {
|
|
209
|
-
(el as HTMLElement).innerHTML = content;
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Hide element (replaces $.hide())
|
|
215
|
-
*/
|
|
216
|
-
hide: (element: ElementSelector): void => {
|
|
217
|
-
const el = getElement(element) as HTMLElement;
|
|
218
|
-
if (el) {
|
|
219
|
-
el.style.display = 'none';
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Show element (replaces $.show())
|
|
225
|
-
*/
|
|
226
|
-
show: (element: ElementSelector, display: string = 'block'): void => {
|
|
227
|
-
const el = getElement(element) as HTMLElement;
|
|
228
|
-
if (el) {
|
|
229
|
-
el.style.display = display;
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Toggle visibility (replaces $.toggle())
|
|
235
|
-
*/
|
|
236
|
-
toggle: (element: ElementSelector, display: string = 'block'): void => {
|
|
237
|
-
const el = getElement(element) as HTMLElement;
|
|
238
|
-
if (el) {
|
|
239
|
-
if (el.style.display === 'none') {
|
|
240
|
-
el.style.display = display;
|
|
241
|
-
} else {
|
|
242
|
-
el.style.display = 'none';
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
},
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Slide up animation (replaces $.slideUp())
|
|
249
|
-
*/
|
|
250
|
-
slideUp: (element: ElementSelector, duration: number = 300): Promise<void> => {
|
|
251
|
-
const el = getElement(element) as HTMLElement;
|
|
252
|
-
if (!el) return Promise.resolve();
|
|
253
|
-
|
|
254
|
-
return new Promise((resolve) => {
|
|
255
|
-
const height = el.scrollHeight;
|
|
256
|
-
el.style.height = `${height}px`;
|
|
257
|
-
el.style.overflow = 'hidden';
|
|
258
|
-
|
|
259
|
-
const animation = el.animate([
|
|
260
|
-
{ height: `${height}px` } as SlideAnimationKeyframes,
|
|
261
|
-
{ height: '0px' } as SlideAnimationKeyframes,
|
|
262
|
-
], {
|
|
263
|
-
duration,
|
|
264
|
-
easing: 'ease-in-out',
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
animation.onfinish = (): void => {
|
|
268
|
-
el.style.display = 'none';
|
|
269
|
-
el.style.height = '';
|
|
270
|
-
el.style.overflow = '';
|
|
271
|
-
resolve();
|
|
272
|
-
};
|
|
273
|
-
});
|
|
274
|
-
},
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Slide down animation (replaces $.slideDown())
|
|
278
|
-
*/
|
|
279
|
-
slideDown: (element: ElementSelector, duration: number = 300): Promise<void> => {
|
|
280
|
-
const el = getElement(element) as HTMLElement;
|
|
281
|
-
if (!el) return Promise.resolve();
|
|
282
|
-
|
|
283
|
-
return new Promise((resolve) => {
|
|
284
|
-
el.style.display = 'block';
|
|
285
|
-
el.style.height = '0px';
|
|
286
|
-
el.style.overflow = 'hidden';
|
|
287
|
-
|
|
288
|
-
const height = el.scrollHeight;
|
|
289
|
-
|
|
290
|
-
const animation = el.animate([
|
|
291
|
-
{ height: '0px' } as SlideAnimationKeyframes,
|
|
292
|
-
{ height: `${height}px` } as SlideAnimationKeyframes,
|
|
293
|
-
], {
|
|
294
|
-
duration,
|
|
295
|
-
easing: 'ease-in-out',
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
animation.onfinish = (): void => {
|
|
299
|
-
el.style.height = 'auto';
|
|
300
|
-
el.style.overflow = 'visible';
|
|
301
|
-
resolve();
|
|
302
|
-
};
|
|
303
|
-
});
|
|
304
|
-
},
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Fade in animation (replaces $.fadeIn())
|
|
308
|
-
*/
|
|
309
|
-
fadeIn: (element: ElementSelector, duration: number = 300): Promise<void> => {
|
|
310
|
-
const el = getElement(element) as HTMLElement;
|
|
311
|
-
if (!el) return Promise.resolve();
|
|
312
|
-
|
|
313
|
-
return new Promise((resolve) => {
|
|
314
|
-
el.style.opacity = '0';
|
|
315
|
-
el.style.display = 'block';
|
|
316
|
-
|
|
317
|
-
const animation = el.animate([
|
|
318
|
-
{ opacity: 0 } as FadeAnimationKeyframes,
|
|
319
|
-
{ opacity: 1 } as FadeAnimationKeyframes,
|
|
320
|
-
], {
|
|
321
|
-
duration,
|
|
322
|
-
easing: 'ease-in-out',
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
animation.onfinish = (): void => {
|
|
326
|
-
el.style.opacity = '';
|
|
327
|
-
resolve();
|
|
328
|
-
};
|
|
329
|
-
});
|
|
330
|
-
},
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Fade out animation (replaces $.fadeOut())
|
|
334
|
-
*/
|
|
335
|
-
fadeOut: (element: ElementSelector, duration: number = 300): Promise<void> => {
|
|
336
|
-
const el = getElement(element) as HTMLElement;
|
|
337
|
-
if (!el) return Promise.resolve();
|
|
338
|
-
|
|
339
|
-
return new Promise((resolve) => {
|
|
340
|
-
const animation = el.animate([
|
|
341
|
-
{ opacity: 1 } as FadeAnimationKeyframes,
|
|
342
|
-
{ opacity: 0 } as FadeAnimationKeyframes,
|
|
343
|
-
], {
|
|
344
|
-
duration,
|
|
345
|
-
easing: 'ease-in-out',
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
animation.onfinish = (): void => {
|
|
349
|
-
el.style.display = 'none';
|
|
350
|
-
el.style.opacity = '';
|
|
351
|
-
resolve();
|
|
352
|
-
};
|
|
353
|
-
});
|
|
354
|
-
},
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* Get element dimensions and position
|
|
358
|
-
*/
|
|
359
|
-
dimensions: (element: ElementSelector): ElementDimensions | null => {
|
|
360
|
-
const el = getElement(element);
|
|
361
|
-
if (!el) return null;
|
|
362
|
-
|
|
363
|
-
const rect = el.getBoundingClientRect();
|
|
364
|
-
return {
|
|
365
|
-
width: rect.width,
|
|
366
|
-
height: rect.height,
|
|
367
|
-
top: rect.top,
|
|
368
|
-
left: rect.left,
|
|
369
|
-
bottom: rect.bottom,
|
|
370
|
-
right: rect.right,
|
|
371
|
-
};
|
|
372
|
-
},
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Wait for DOM to be ready (replaces $(document).ready())
|
|
376
|
-
*/
|
|
377
|
-
ready: (callback: () => void): void => {
|
|
378
|
-
if (document.readyState === 'loading') {
|
|
379
|
-
document.addEventListener('DOMContentLoaded', callback);
|
|
380
|
-
} else {
|
|
381
|
-
callback();
|
|
382
|
-
}
|
|
383
|
-
},
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* Create element with attributes and content
|
|
387
|
-
*/
|
|
388
|
-
create: (tagName: string, attributes?: Record<string, string>, content?: string): HTMLElement => {
|
|
389
|
-
const element = document.createElement(tagName);
|
|
390
|
-
|
|
391
|
-
if (attributes) {
|
|
392
|
-
Object.entries(attributes).forEach(([key, value]) => {
|
|
393
|
-
element.setAttribute(key, value);
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
if (content) {
|
|
398
|
-
element.textContent = content;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
return element;
|
|
402
|
-
},
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* Append element to parent
|
|
406
|
-
*/
|
|
407
|
-
append: (parent: ElementSelector, child: Element): void => {
|
|
408
|
-
const parentEl = getElement(parent);
|
|
409
|
-
if (parentEl) {
|
|
410
|
-
parentEl.appendChild(child);
|
|
411
|
-
}
|
|
412
|
-
},
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Remove element from DOM
|
|
416
|
-
*/
|
|
417
|
-
remove: (element: ElementSelector): void => {
|
|
418
|
-
const el = getElement(element);
|
|
419
|
-
if (el && el.parentNode) {
|
|
420
|
-
el.parentNode.removeChild(el);
|
|
421
|
-
}
|
|
422
|
-
},
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
* Get/Set CSS styles
|
|
426
|
-
*/
|
|
427
|
-
css: (element: ElementSelector, property: string, value?: string): string | void => {
|
|
428
|
-
const el = getElement(element) as HTMLElement;
|
|
429
|
-
if (!el) return;
|
|
430
|
-
|
|
431
|
-
if (value === undefined) {
|
|
432
|
-
return window.getComputedStyle(el).getPropertyValue(property);
|
|
433
|
-
} else {
|
|
434
|
-
el.style.setProperty(property, value);
|
|
435
|
-
}
|
|
436
|
-
},
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* Get/Set element value (for form elements)
|
|
440
|
-
*/
|
|
441
|
-
val: (element: ElementSelector, value?: string): string | void => {
|
|
442
|
-
const el = getElement(element) as HTMLInputElement;
|
|
443
|
-
if (!el) return;
|
|
444
|
-
|
|
445
|
-
if (value === undefined) {
|
|
446
|
-
return el.value;
|
|
447
|
-
} else {
|
|
448
|
-
el.value = value;
|
|
449
|
-
}
|
|
450
|
-
},
|
|
451
|
-
|
|
452
|
-
/**
|
|
453
|
-
* Trigger custom event
|
|
454
|
-
*/
|
|
455
|
-
trigger: (element: ElementSelector, eventName: string, detail?: any): void => {
|
|
456
|
-
const el = getElement(element);
|
|
457
|
-
if (el) {
|
|
458
|
-
const event = new CustomEvent(eventName, { detail });
|
|
459
|
-
el.dispatchEvent(event);
|
|
460
|
-
}
|
|
461
|
-
},
|
|
462
|
-
|
|
463
|
-
/**
|
|
464
|
-
* Check if element is visible
|
|
465
|
-
*/
|
|
466
|
-
isVisible: (element: ElementSelector): boolean => {
|
|
467
|
-
const el = getElement(element) as HTMLElement;
|
|
468
|
-
if (!el) return false;
|
|
469
|
-
|
|
470
|
-
const style = window.getComputedStyle(el);
|
|
471
|
-
return style.display !== 'none' && style.visibility !== 'hidden' && style.opacity !== '0';
|
|
472
|
-
},
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* Get element offset relative to document
|
|
476
|
-
*/
|
|
477
|
-
offset: (element: ElementSelector): { top: number; left: number } | null => {
|
|
478
|
-
const el = getElement(element);
|
|
479
|
-
if (!el) return null;
|
|
480
|
-
|
|
481
|
-
const rect = el.getBoundingClientRect();
|
|
482
|
-
return {
|
|
483
|
-
top: rect.top + window.pageYOffset,
|
|
484
|
-
left: rect.left + window.pageXOffset,
|
|
485
|
-
};
|
|
486
|
-
},
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* Delegate event handling
|
|
490
|
-
*/
|
|
491
|
-
delegate: (
|
|
492
|
-
parent: ElementSelector,
|
|
493
|
-
selector: string,
|
|
494
|
-
event: string,
|
|
495
|
-
handler: (event: Event) => void
|
|
496
|
-
): void => {
|
|
497
|
-
const parentEl = getElement(parent);
|
|
498
|
-
if (parentEl) {
|
|
499
|
-
parentEl.addEventListener(event, (e) => {
|
|
500
|
-
const target = e.target as Element;
|
|
501
|
-
if (target && target.matches(selector)) {
|
|
502
|
-
handler(e);
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
},
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
// Export both the basic DOM utilities and extended version
|
|
510
|
-
export { DOM as default, DOMExtended };
|
|
511
|
-
|
|
512
|
-
// Re-export types for convenience
|
|
513
|
-
export type { DOMUtilities, ElementSelector, ElementDimensions };
|