@kupola/kupola 1.2.0 → 1.3.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.
Files changed (97) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +330 -286
  3. package/adapters/axios.d.ts +34 -0
  4. package/adapters/axios.js +122 -0
  5. package/adapters/navios-http.d.ts +110 -0
  6. package/adapters/navios-http.js +151 -0
  7. package/dist/css/accessibility.css +119 -0
  8. package/dist/css/animations.css +224 -0
  9. package/dist/css/brand-themes.css +300 -0
  10. package/dist/css/colors_and_type.css +441 -0
  11. package/dist/css/components-ext.css +4165 -0
  12. package/dist/css/components.css +1483 -0
  13. package/dist/css/responsive.css +697 -0
  14. package/dist/css/scaffold.css +145 -0
  15. package/dist/css/states.css +316 -0
  16. package/dist/css/theme-dark.css +296 -0
  17. package/dist/css/theme-light.css +296 -0
  18. package/dist/css/utilities.css +171 -0
  19. package/dist/kupola.cjs.js +219 -161
  20. package/dist/kupola.cjs.js.map +1 -1
  21. package/dist/kupola.esm.js +6643 -5709
  22. package/dist/kupola.esm.js.map +1 -1
  23. package/dist/kupola.umd.js +219 -161
  24. package/dist/kupola.umd.js.map +1 -1
  25. package/dist/plugins/vite-plugin-kupola.js +120 -0
  26. package/dist/types/kupola.d.ts +421 -323
  27. package/js/calendar.js +334 -25
  28. package/js/carousel.js +182 -48
  29. package/js/collapse.js +148 -34
  30. package/js/color-picker.js +416 -108
  31. package/js/component.js +8 -19
  32. package/js/countdown.js +9 -8
  33. package/js/data-bind.js +73 -16
  34. package/js/datepicker.js +488 -110
  35. package/js/depends.js +710 -0
  36. package/js/dialog.js +4 -2
  37. package/js/drawer.js +172 -8
  38. package/js/dropdown.js +272 -17
  39. package/js/dynamic-tags.js +156 -40
  40. package/js/fileupload.js +9 -8
  41. package/js/form.js +280 -254
  42. package/js/global-events.js +281 -188
  43. package/js/heatmap.js +10 -7
  44. package/js/i18n.js +18 -10
  45. package/js/icons.js +141 -161
  46. package/js/image-preview.js +146 -2
  47. package/js/initializer.js +113 -71
  48. package/js/kupola-core.js +123 -45
  49. package/js/kupola-lifecycle.js +13 -11
  50. package/js/message.js +8 -1
  51. package/js/modal.js +207 -59
  52. package/js/notification.js +8 -1
  53. package/js/numberinput.js +9 -8
  54. package/js/pagination.js +263 -0
  55. package/js/registry.js +29 -12
  56. package/js/select.js +482 -27
  57. package/js/slide-captcha.js +11 -2
  58. package/js/slider.js +442 -25
  59. package/js/statcard.js +9 -7
  60. package/js/table.js +1210 -0
  61. package/js/tag.js +268 -14
  62. package/js/theme.js +14 -43
  63. package/js/timepicker.js +335 -66
  64. package/js/tooltip.js +317 -86
  65. package/js/utils.js +6 -2
  66. package/js/validation.js +6 -2
  67. package/js/virtual-list.js +11 -7
  68. package/js/web-components.js +288 -0
  69. package/package.json +77 -67
  70. package/plugins/vite-plugin-kupola.js +120 -0
  71. package/types/kupola.d.ts +421 -323
  72. package/CHANGELOG.md +0 -130
  73. package/INTEGRATION.md +0 -440
  74. package/PROJECT_SUMMARY.md +0 -312
  75. package/SKILL.md +0 -572
  76. package/dist/utils/utils/Kupola.cs +0 -77
  77. package/dist/utils/utils/Kupola.java +0 -104
  78. package/dist/utils/utils/kupola.go +0 -120
  79. package/dist/utils/utils/kupola.js +0 -63
  80. package/dist/utils/utils/kupola.py +0 -1392
  81. package/dist/utils/utils/kupola.rb +0 -69
  82. package/js/composition-api.js +0 -458
  83. package/js/error-handler.js +0 -181
  84. package/js/http.js +0 -419
  85. package/js/kupola-devtools.js +0 -598
  86. package/js/performance.js +0 -250
  87. package/js/router.js +0 -396
  88. package/js/security.js +0 -189
  89. package/js/test-utils.js +0 -251
  90. package/templates/base.html +0 -30
  91. package/templates/base_dashboard.html +0 -99
  92. package/utils/Kupola.cs +0 -77
  93. package/utils/Kupola.java +0 -104
  94. package/utils/kupola.go +0 -120
  95. package/utils/kupola.js +0 -63
  96. package/utils/kupola.py +0 -1392
  97. package/utils/kupola.rb +0 -69
@@ -48,79 +48,6 @@ interface PersistOptions {
48
48
  debounce?: number;
49
49
  }
50
50
 
51
- interface RouteConfig {
52
- path: string;
53
- component: string | (() => Promise<{ default: typeof KupolaComponent } | typeof KupolaComponent>);
54
- name?: string;
55
- meta?: Record<string, unknown>;
56
- children?: RouteConfig[];
57
- }
58
-
59
- interface RouterOptions {
60
- mode?: 'hash' | 'history';
61
- routes: RouteConfig[];
62
- base?: string;
63
- }
64
-
65
- interface HttpRequestConfig {
66
- url: string;
67
- method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
68
- headers?: Record<string, string>;
69
- params?: Record<string, string | number | boolean>;
70
- data?: Record<string, unknown> | unknown[];
71
- timeout?: number;
72
- withCredentials?: boolean;
73
- responseType?: 'json' | 'text' | 'blob' | 'formData';
74
- cache?: boolean;
75
- retry?: boolean;
76
- }
77
-
78
- interface HttpResponse<T = unknown> {
79
- data: T;
80
- status: number;
81
- statusText: string;
82
- headers: Record<string, string>;
83
- config: HttpRequestConfig;
84
- }
85
-
86
- interface HttpError {
87
- message: string;
88
- code?: number;
89
- response?: HttpResponse;
90
- config: HttpRequestConfig;
91
- }
92
-
93
- interface HttpInterceptor {
94
- request?: (config: HttpRequestConfig) => HttpRequestConfig | Promise<HttpRequestConfig>;
95
- requestError?: (error: unknown) => Promise<never>;
96
- response?: <T = unknown>(response: HttpResponse<T>) => HttpResponse<T> | Promise<HttpResponse<T>>;
97
- responseError?: (error: HttpError) => Promise<never>;
98
- }
99
-
100
- interface HttpOptions {
101
- baseURL?: string;
102
- timeout?: number;
103
- headers?: Record<string, string>;
104
- interceptors?: HttpInterceptor;
105
- cacheTTL?: number;
106
- maxRetries?: number;
107
- retryDelay?: number;
108
- }
109
-
110
- interface UploadProgress {
111
- progress: number;
112
- uploaded: number;
113
- total: number;
114
- currentChunk: number;
115
- totalChunks: number;
116
- }
117
-
118
- interface UploadOptions {
119
- chunkSize?: number;
120
- onProgress?: (progress: UploadProgress) => void;
121
- headers?: Record<string, string>;
122
- parallel?: boolean;
123
- }
124
51
 
125
52
  interface StoreOptions<S extends object = Record<string, unknown>> {
126
53
  state?: () => S;
@@ -205,14 +132,6 @@ interface VirtualListItem<T = unknown> {
205
132
  element: HTMLElement;
206
133
  }
207
134
 
208
- interface VirtualListOptions<T = unknown> {
209
- data?: T[];
210
- itemHeight?: number;
211
- containerHeight?: number;
212
- renderItem?: (item: T, index: number) => string;
213
- onItemClick?: (item: VirtualListItem<T>) => void;
214
- }
215
-
216
135
  declare class KupolaDataBind<T extends object = Record<string, unknown>> {
217
136
  constructor();
218
137
 
@@ -584,50 +503,6 @@ declare class KupolaValidator {
584
503
 
585
504
  declare const validator: KupolaValidator;
586
505
 
587
- declare class KupolaRouter {
588
- constructor(options: RouterOptions);
589
-
590
- push(path: string): void;
591
- replace(path: string): void;
592
- go(delta: number): void;
593
- back(): void;
594
- forward(): void;
595
-
596
- readonly currentRoute: RouteConfig | null;
597
- readonly path: string;
598
- readonly params: Record<string, string>;
599
- readonly query: Record<string, string>;
600
-
601
- beforeEach(callback: (to: RouteConfig, from: RouteConfig | null) => boolean | void | Promise<boolean>): void;
602
- afterEach(callback: (to: RouteConfig) => void): void;
603
-
604
- setAnimation(name: string): void;
605
-
606
- destroy(): void;
607
- }
608
-
609
- declare class KupolaHttp {
610
- constructor(options?: HttpOptions);
611
-
612
- get<T = unknown>(url: string, config?: Omit<HttpRequestConfig, 'method' | 'url'>): Promise<HttpResponse<T>>;
613
- post<T = unknown>(url: string, data?: HttpRequestConfig['data'], config?: Omit<HttpRequestConfig, 'method' | 'url'>): Promise<HttpResponse<T>>;
614
- put<T = unknown>(url: string, data?: HttpRequestConfig['data'], config?: Omit<HttpRequestConfig, 'method' | 'url'>): Promise<HttpResponse<T>>;
615
- delete<T = unknown>(url: string, config?: Omit<HttpRequestConfig, 'method' | 'url'>): Promise<HttpResponse<T>>;
616
- patch<T = unknown>(url: string, data?: HttpRequestConfig['data'], config?: Omit<HttpRequestConfig, 'method' | 'url'>): Promise<HttpResponse<T>>;
617
-
618
- uploadFile<T = unknown>(url: string, file: File, options?: UploadOptions): Promise<HttpResponse<T>>;
619
-
620
- setHeader(name: string, value: string): void;
621
- setToken(token: string, type?: string): void;
622
- setCacheTTL(ttl: number): void;
623
- setMaxRetries(retries: number): void;
624
-
625
- cancelRequest(url: string, params?: Record<string, string | number | boolean>): boolean;
626
- clearCache(): void;
627
- clearCacheByUrl(url: string): void;
628
-
629
- interceptors: HttpInterceptor;
630
- }
631
506
 
632
507
  interface ComponentMixin {
633
508
  [key: string]: unknown;
@@ -749,6 +624,8 @@ declare function toggleTheme(): void;
749
624
 
750
625
  declare function setBrand(brand: BrandColor): void;
751
626
  declare function getBrand(): BrandColor;
627
+ declare function createThemeToggle(): { toggleBtn: HTMLElement; container: HTMLElement };
628
+ declare function createBrandPicker(): { toggleBtn: HTMLElement; container: HTMLElement };
752
629
  declare const BRAND_OPTIONS: readonly BrandOption[];
753
630
 
754
631
  declare function showToast(options: ToastOptions | string): void;
@@ -763,10 +640,6 @@ declare function showAlert(content: string, title?: string): Promise<void>;
763
640
 
764
641
  declare function showNotification(options: NotificationOptions): void;
765
642
 
766
- declare function createRouter(options: RouterOptions): KupolaRouter;
767
-
768
- declare function createHttp(options?: HttpOptions): KupolaHttp;
769
-
770
643
  declare function registerComponent(name: string, componentClass: typeof KupolaComponent): void;
771
644
 
772
645
  declare function registerLazyComponent(name: string, loader: () => Promise<{ default: typeof KupolaComponent } | typeof KupolaComponent>): void;
@@ -777,50 +650,279 @@ declare function defineMixin(name: string, mixin: ComponentMixin): void;
777
650
 
778
651
  declare function useMixin(componentClass: typeof KupolaComponent, ...mixinNames: string[]): void;
779
652
 
653
+ interface DefineComponentOptions {
654
+ componentClass?: typeof KupolaComponent;
655
+ lazy?: () => Promise<{ default: typeof KupolaComponent } | typeof KupolaComponent>;
656
+ init?: (element: HTMLElement) => void | Promise<void>;
657
+ cleanup?: (element: HTMLElement) => void;
658
+ dataAttribute?: string;
659
+ cssClass?: string;
660
+ }
661
+ declare function defineComponent(name: string, options: DefineComponentOptions): void;
662
+
663
+ declare function registerWebComponents(): void;
664
+
665
+ declare class KupolaDropdownElement extends HTMLElement {
666
+ static get observedAttributes(): string[];
667
+ }
668
+ declare class KupolaTooltipElement extends HTMLElement {
669
+ static get observedAttributes(): string[];
670
+ }
671
+ declare class KupolaCollapseElement extends HTMLElement {}
672
+ declare class KupolaCollapseItemElement extends HTMLElement {
673
+ static get observedAttributes(): string[];
674
+ }
675
+ declare class KupolaDrawerElement extends HTMLElement {
676
+ static get observedAttributes(): string[];
677
+ }
678
+ declare class KupolaModalElement extends HTMLElement {
679
+ static get observedAttributes(): string[];
680
+ open(): void;
681
+ close(): void;
682
+ }
683
+
684
+ declare function createModal(options?: Record<string, unknown>): any;
685
+ declare function confirmModal(options: Record<string, unknown> | string): any;
686
+ declare function alertModal(options: Record<string, unknown> | string): any;
687
+
688
+ declare function cleanupAllDropdowns(): void;
689
+ declare function cleanupAllSlideCaptchas(): void;
690
+
691
+ declare function ref<T = unknown>(initialValue?: T): { value: T; _subscribers: Set<Function> };
692
+
693
+ declare class Modal {
694
+ constructor(element: HTMLElement, options?: Record<string, unknown>);
695
+ open(): void;
696
+ close(): void;
697
+ toggleFullscreen(): void;
698
+ isVisible(): boolean;
699
+ destroy(): void;
700
+ }
701
+
780
702
  declare const kupolaRegistry: KupolaComponentRegistry;
781
703
 
782
704
  declare const kupolaPersist: KupolaStatePersist;
783
705
 
784
706
  declare const kupolaStoreManager: KupolaStoreManager;
785
707
 
786
- declare class KupolaDevTools {
787
- constructor(options?: { enabled?: boolean });
788
-
789
- init(): void;
790
- togglePanel(): void;
791
- switchTab(tabName: 'storage' | 'network'): void;
792
- renderStorageContent(): void;
793
- renderNetworkContent(): void;
794
- clearNetworkHistory(): void;
795
- addRequest(entry: NetworkRequest): void;
796
- updateRequest(entry: NetworkRequest): void;
797
- destroy(): void;
798
-
799
- enabled: boolean;
800
- isOpen: boolean;
801
- activeTab: 'storage' | 'network';
802
- activeStorageType: 'cookies' | 'localStorage' | 'sessionStorage';
803
- requestHistory: NetworkRequest[];
804
- }
708
+ declare function createStore<S extends object = Record<string, unknown>>(name: string, options?: StoreOptions<S>): KupolaStore<S>;
709
+
710
+ declare function getStore<S extends object = Record<string, unknown>>(name: string): KupolaStore<S> | undefined;
805
711
 
806
- interface NetworkRequest {
807
- id?: number;
808
- method: string;
809
- url: string;
810
- params?: Record<string, string>;
811
- requestBody?: string;
712
+ // ============================================================
713
+ // @kupola/depends - Declarative Data Dependencies
714
+ // ============================================================
715
+
716
+ // --- HTTP Client Plugin System ---
717
+ interface KupolaHttpResponse {
718
+ ok: boolean;
812
719
  status: number;
813
- response?: unknown;
814
- duration?: number;
720
+ statusText?: string;
721
+ headers: Record<string, string>;
722
+ url?: string;
723
+ json(): Promise<any>;
724
+ text(): Promise<string>;
815
725
  }
816
726
 
817
- declare const kupolaDevTools: KupolaDevTools;
727
+ interface KupolaHttpClient {
728
+ fetch(url: string, options?: {
729
+ method?: string;
730
+ headers?: Record<string, string>;
731
+ body?: string;
732
+ }): Promise<KupolaHttpResponse>;
733
+ }
818
734
 
819
- declare function initDevTools(): void;
735
+ declare function configureHttpClient(client: KupolaHttpClient): void;
736
+ declare function getHttpClient(): KupolaHttpClient['fetch'];
737
+ declare function resetHttpClient(): void;
820
738
 
821
- declare function createStore<S extends object = Record<string, unknown>>(name: string, options?: StoreOptions<S>): KupolaStore<S>;
739
+ declare class Scheduler {
740
+ constructor();
741
+ schedule(fn: () => void): void;
742
+ }
743
+
744
+ declare class CacheEntry<T = unknown> {
745
+ constructor(data: T, ttl: number);
746
+ readonly data: T;
747
+ readonly createdAt: number;
748
+ readonly ttl: number;
749
+ readonly isFresh: boolean;
750
+ readonly isStale: boolean;
751
+ }
752
+
753
+ declare class CacheManager {
754
+ constructor();
755
+ get<T = unknown>(key: string): CacheEntry<T> | null;
756
+ set<T = unknown>(key: string, data: T, ttl?: number): void;
757
+ has(key: string): boolean;
758
+ delete(key: string): void;
759
+ clear(): void;
760
+ getStale<T = unknown>(key: string): T | null;
761
+ }
762
+
763
+ declare class DependsError extends Error {
764
+ constructor(message: string, code: string, cause?: unknown);
765
+ readonly code: string;
766
+ readonly cause?: unknown;
767
+ readonly timestamp: number;
768
+ }
769
+
770
+ type SourceType = string | ((params: Record<string, unknown>) => unknown | Promise<unknown>);
771
+
772
+ interface DepsSourceConfig {
773
+ source: SourceType;
774
+ cacheKey?: string;
775
+ staleTime?: number;
776
+ retry?: number;
777
+ retryDelay?: number;
778
+ onError?: (error: DependsError) => void;
779
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
780
+ headers?: Record<string, string>;
781
+ query?: Record<string, string | number | boolean>;
782
+ default?: unknown;
783
+ sync?: boolean;
784
+ reconnect?: boolean;
785
+ reconnectDelay?: number;
786
+ }
787
+
788
+ interface DepRef<T = unknown> {
789
+ data: { value: T | null };
790
+ loading: { value: boolean };
791
+ error: { value: string | null };
792
+ lastUpdated: { value: number | null };
793
+ refresh(): Promise<void>;
794
+ setValue?(value: unknown): void;
795
+ send?(msg: unknown): void;
796
+ }
797
+
798
+ type DepsConfig = Record<string, DepsSourceConfig | string>;
799
+ type DepsProps = Record<string, unknown | { value: unknown }>;
800
+ type DepsResult<C extends DepsConfig> = {
801
+ [K in keyof C]: DepRef;
802
+ } & { _dispose(): void };
803
+
804
+ declare function useDeps<C extends DepsConfig>(props: DepsProps, depsConfig: C): DepsResult<C>;
805
+
806
+ declare function useQuery<T = unknown>(config: DepsSourceConfig): {
807
+ data: { value: T | null };
808
+ loading: { value: boolean };
809
+ error: { value: string | null };
810
+ refresh(): Promise<void>;
811
+ };
812
+
813
+ declare function clearCache(): void;
814
+
815
+ // ============================================================
816
+ // Table & Pagination Components
817
+ // ============================================================
818
+
819
+ interface KupolaTableColumn {
820
+ key: string;
821
+ title: string;
822
+ width?: string | number;
823
+ minWidth?: string | number;
824
+ align?: 'left' | 'center' | 'right';
825
+ sortable?: boolean;
826
+ sorter?: (a: unknown, b: unknown, order?: string) => number;
827
+ fixed?: 'left' | 'right';
828
+ render?: (value: unknown, row: unknown, index?: number) => string | HTMLElement;
829
+ editable?: boolean;
830
+ editType?: string;
831
+ editOptions?: Array<{ value: string; label: string }>;
832
+ }
833
+
834
+ interface KupolaTableTreeOptions {
835
+ childrenKey?: string;
836
+ defaultExpandAll?: boolean;
837
+ }
838
+
839
+ interface KupolaTableVirtualScrollOptions {
840
+ rowHeight: number;
841
+ overscan?: number;
842
+ maxHeight?: string;
843
+ }
844
+
845
+ interface KupolaTableOptions {
846
+ columns: KupolaTableColumn[];
847
+ rowKey?: string;
848
+ striped?: boolean;
849
+ bordered?: boolean;
850
+ hoverable?: boolean;
851
+ compact?: boolean;
852
+ pageSize?: number;
853
+ pageSizes?: number[];
854
+ emptyText?: string;
855
+ loadingText?: string;
856
+ showFilter?: boolean;
857
+ showToolbar?: boolean;
858
+ showExport?: boolean;
859
+ showPageSize?: boolean;
860
+ selection?: 'checkbox' | 'radio';
861
+ expandable?: (row: unknown) => string | HTMLElement;
862
+ editable?: boolean;
863
+ resizable?: boolean;
864
+ draggable?: boolean;
865
+ multiSort?: boolean;
866
+ tree?: KupolaTableTreeOptions;
867
+ virtualScroll?: KupolaTableVirtualScrollOptions;
868
+ mergeCells?: (data: unknown[]) => Array<{ row: number; col: number; rowSpan: number; colSpan: number }>;
869
+ onSort?: (sorts: Array<{ key: string; order: string }>) => void;
870
+ onFilter?: (text: string) => void;
871
+ onRowClick?: (row: unknown, index: number, event: Event) => void;
872
+ onPageChange?: (page: number, pageSize: number) => void;
873
+ onSelect?: (selectedKeys: unknown[], selectedRows: unknown[]) => void;
874
+ onExpand?: (key: unknown, isExpanded: boolean) => void;
875
+ onEditSave?: (row: unknown, colKey: string, newValue: unknown, allData: unknown[]) => void;
876
+ onEditCancel?: (editingCell: unknown) => void;
877
+ onColumnResize?: (colKey: string, newWidth: number) => void;
878
+ onRowDragEnd?: (movedRow: unknown, fromIndex: number, toIndex: number, newData: unknown[]) => void;
879
+ }
880
+
881
+ declare class KupolaTable {
882
+ constructor(element: HTMLElement | string, options?: KupolaTableOptions);
883
+ setData(data: unknown[] | { value: unknown[] | null }): void;
884
+ setLoading(loading: boolean): void;
885
+ setColumns(columns: KupolaTableColumn[]): void;
886
+ setPageSize(size: number): void;
887
+ getSortState(): { key: string | null; order: string | null } | Array<{ key: string; order: string }>;
888
+ getPage(): { current: number; pageSize: number; total: number };
889
+ refresh(): void;
890
+ exportCSV(filename?: string): void;
891
+ selectAll(): void;
892
+ deselectAll(): void;
893
+ invertSelection(): void;
894
+ selectRow(key: unknown): void;
895
+ deselectRow(key: unknown): void;
896
+ getSelectedKeys(): unknown[];
897
+ getSelectedRows(): unknown[];
898
+ destroy(): void;
899
+ }
900
+
901
+ declare function initTable(element: HTMLElement | string, options?: KupolaTableOptions): KupolaTable;
902
+ declare function initAllTables(): KupolaTable[];
903
+
904
+ interface KupolaPaginationOptions {
905
+ current?: number;
906
+ total?: number;
907
+ pageSize?: number;
908
+ maxPages?: number;
909
+ showTotal?: boolean;
910
+ showSizeChanger?: boolean;
911
+ pageSizes?: number[];
912
+ simple?: boolean;
913
+ onChange?: (page: number, pageSize: number) => void;
914
+ }
915
+
916
+ declare class KupolaPagination {
917
+ constructor(element: HTMLElement | string, options?: KupolaPaginationOptions);
918
+ setCurrent(page: number): void;
919
+ setTotal(total: number): void;
920
+ setPageSize(size: number): void;
921
+ destroy(): void;
922
+ }
923
+
924
+ declare function initPagination(element: HTMLElement | string, options?: KupolaPaginationOptions): KupolaPagination;
822
925
 
823
- declare function getStore<S extends object = Record<string, unknown>>(name: string): KupolaStore<S> | undefined;
824
926
 
825
927
  declare module 'kupola' {
826
928
  export type Primitive = string | number | boolean | null | undefined;
@@ -869,72 +971,6 @@ declare module 'kupola' {
869
971
  storage?: 'local' | 'session';
870
972
  debounce?: number;
871
973
  }
872
- export interface RouteConfig {
873
- path: string;
874
- component: string | (() => Promise<{ default: typeof KupolaComponent } | typeof KupolaComponent>);
875
- name?: string;
876
- meta?: Record<string, unknown>;
877
- children?: RouteConfig[];
878
- }
879
- export interface RouterOptions {
880
- mode?: 'hash' | 'history';
881
- routes: RouteConfig[];
882
- base?: string;
883
- }
884
- export interface HttpRequestConfig {
885
- url: string;
886
- method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
887
- headers?: Record<string, string>;
888
- params?: Record<string, string | number | boolean>;
889
- data?: Record<string, unknown> | unknown[];
890
- timeout?: number;
891
- withCredentials?: boolean;
892
- responseType?: 'json' | 'text' | 'blob' | 'formData';
893
- }
894
- export interface HttpResponse<T = unknown> {
895
- data: T;
896
- status: number;
897
- statusText: string;
898
- headers: Record<string, string>;
899
- config: HttpRequestConfig;
900
- }
901
- export interface HttpError {
902
- message: string;
903
- code?: number;
904
- response?: HttpResponse;
905
- config: HttpRequestConfig;
906
- }
907
- export interface HttpInterceptor {
908
- request?: (config: HttpRequestConfig) => HttpRequestConfig | Promise<HttpRequestConfig>;
909
- requestError?: (error: unknown) => Promise<never>;
910
- response?: <T = unknown>(response: HttpResponse<T>) => HttpResponse<T> | Promise<HttpResponse<T>>;
911
- responseError?: (error: HttpError) => Promise<never>;
912
- }
913
- export interface HttpOptions {
914
- baseURL?: string;
915
- timeout?: number;
916
- headers?: Record<string, string>;
917
- interceptors?: HttpInterceptor;
918
- cacheTTL?: number;
919
- maxRetries?: number;
920
- retryDelay?: number;
921
- }
922
-
923
- export interface UploadProgress {
924
- progress: number;
925
- uploaded: number;
926
- total: number;
927
- currentChunk: number;
928
- totalChunks: number;
929
- }
930
-
931
- export interface UploadOptions {
932
- chunkSize?: number;
933
- onProgress?: (progress: UploadProgress) => void;
934
- headers?: Record<string, string>;
935
- abortController?: AbortController;
936
- parallel?: boolean;
937
- }
938
974
 
939
975
  export interface FormState {
940
976
  valid: boolean;
@@ -945,19 +981,6 @@ declare module 'kupola' {
945
981
  disabled: boolean;
946
982
  }
947
983
 
948
- export interface HttpRequestConfig {
949
- url: string;
950
- method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
951
- headers?: Record<string, string>;
952
- params?: Record<string, string | number | boolean>;
953
- data?: Record<string, unknown> | unknown[];
954
- timeout?: number;
955
- withCredentials?: boolean;
956
- responseType?: 'json' | 'text' | 'blob' | 'formData';
957
- cache?: boolean;
958
- retry?: boolean;
959
- }
960
-
961
984
  export interface StoreOptions<S extends object = Record<string, unknown>> {
962
985
  state?: () => S;
963
986
  getters?: Record<string, (state: S) => unknown>;
@@ -1124,51 +1147,7 @@ declare module 'kupola' {
1124
1147
  dispose(): void;
1125
1148
  }
1126
1149
 
1127
- export class KupolaRouter {
1128
- constructor(options: RouterOptions);
1129
-
1130
- push(path: string): void;
1131
- replace(path: string): void;
1132
- go(delta: number): void;
1133
- back(): void;
1134
- forward(): void;
1135
-
1136
- readonly currentRoute: RouteConfig | null;
1137
- readonly path: string;
1138
- readonly params: Record<string, string>;
1139
- readonly query: Record<string, string>;
1140
-
1141
- beforeEach(callback: (to: RouteConfig, from: RouteConfig | null) => boolean | void | Promise<boolean>): void;
1142
- afterEach(callback: (to: RouteConfig) => void): void;
1143
-
1144
- setAnimation(name: string): void;
1145
-
1146
- destroy(): void;
1147
- }
1148
-
1149
- export class KupolaHttp {
1150
- constructor(options?: HttpOptions);
1151
-
1152
- get<T = unknown>(url: string, config?: Omit<HttpRequestConfig, 'method' | 'url'>): Promise<HttpResponse<T>>;
1153
- post<T = unknown>(url: string, data?: HttpRequestConfig['data'], config?: Omit<HttpRequestConfig, 'method' | 'url'>): Promise<HttpResponse<T>>;
1154
- put<T = unknown>(url: string, data?: HttpRequestConfig['data'], config?: Omit<HttpRequestConfig, 'method' | 'url'>): Promise<HttpResponse<T>>;
1155
- delete<T = unknown>(url: string, config?: Omit<HttpRequestConfig, 'method' | 'url'>): Promise<HttpResponse<T>>;
1156
- patch<T = unknown>(url: string, data?: HttpRequestConfig['data'], config?: Omit<HttpRequestConfig, 'method' | 'url'>): Promise<HttpResponse<T>>;
1157
-
1158
- uploadFile<T = unknown>(url: string, file: File, options?: UploadOptions): Promise<HttpResponse<T>>;
1159
-
1160
- setHeader(name: string, value: string): void;
1161
- setToken(token: string, type?: string): void;
1162
- setCacheTTL(ttl: number): void;
1163
- setMaxRetries(retries: number): void;
1164
-
1165
- cancelRequest(url: string, params?: Record<string, string | number | boolean>): boolean;
1166
- clearCache(): void;
1167
- clearCacheByUrl(url: string): void;
1168
-
1169
- interceptors: HttpInterceptor;
1170
- }
1171
-
1150
+
1172
1151
  export interface ComponentMixin {
1173
1152
  [key: string]: unknown;
1174
1153
  }
@@ -1218,37 +1197,7 @@ declare module 'kupola' {
1218
1197
  destroy(): void;
1219
1198
  }
1220
1199
 
1221
- export interface NetworkRequest {
1222
- id?: number;
1223
- method: string;
1224
- url: string;
1225
- params?: Record<string, string>;
1226
- requestBody?: string;
1227
- status: number;
1228
- response?: unknown;
1229
- duration?: number;
1230
- }
1231
-
1232
- export class KupolaDevTools {
1233
- constructor(options?: { enabled?: boolean });
1234
-
1235
- init(): void;
1236
- togglePanel(): void;
1237
- switchTab(tabName: 'storage' | 'network'): void;
1238
- renderStorageContent(): void;
1239
- renderNetworkContent(): void;
1240
- clearNetworkHistory(): void;
1241
- addRequest(entry: NetworkRequest): void;
1242
- updateRequest(entry: NetworkRequest): void;
1243
- destroy(): void;
1244
-
1245
- enabled: boolean;
1246
- isOpen: boolean;
1247
- activeTab: 'storage' | 'network';
1248
- activeStorageType: 'cookies' | 'localStorage' | 'sessionStorage';
1249
- requestHistory: NetworkRequest[];
1250
- }
1251
-
1200
+
1252
1201
  export class KupolaStatePersist {
1253
1202
  constructor();
1254
1203
 
@@ -1321,6 +1270,8 @@ declare module 'kupola' {
1321
1270
 
1322
1271
  export function setBrand(brand: BrandColor): void;
1323
1272
  export function getBrand(): BrandColor;
1273
+ export function createThemeToggle(): { toggleBtn: HTMLElement; container: HTMLElement };
1274
+ export function createBrandPicker(): { toggleBtn: HTMLElement; container: HTMLElement };
1324
1275
  export const BRAND_OPTIONS: readonly BrandOption[];
1325
1276
 
1326
1277
  export function showToast(options: ToastOptions | string): void;
@@ -1335,10 +1286,6 @@ declare module 'kupola' {
1335
1286
 
1336
1287
  export function showNotification(options: NotificationOptions): void;
1337
1288
 
1338
- export function createRouter(options: RouterOptions): KupolaRouter;
1339
-
1340
- export function createHttp(options?: HttpOptions): KupolaHttp;
1341
-
1342
1289
  export function registerComponent(name: string, componentClass: typeof KupolaComponent): void;
1343
1290
 
1344
1291
  export function registerLazyComponent(name: string, loader: () => Promise<{ default: typeof KupolaComponent } | typeof KupolaComponent>): void;
@@ -1348,12 +1295,163 @@ declare module 'kupola' {
1348
1295
  export function defineMixin(name: string, mixin: ComponentMixin): void;
1349
1296
 
1350
1297
  export function useMixin(componentClass: typeof KupolaComponent, ...mixinNames: string[]): void;
1351
-
1298
+
1299
+ export interface DefineComponentOptions {
1300
+ componentClass?: typeof KupolaComponent;
1301
+ lazy?: () => Promise<{ default: typeof KupolaComponent } | typeof KupolaComponent>;
1302
+ init?: (element: HTMLElement) => void | Promise<void>;
1303
+ cleanup?: (element: HTMLElement) => void;
1304
+ dataAttribute?: string;
1305
+ cssClass?: string;
1306
+ }
1307
+ export function defineComponent(name: string, options: DefineComponentOptions): void;
1308
+
1309
+ export function registerWebComponents(): void;
1310
+
1311
+ export class KupolaDropdownElement extends HTMLElement {
1312
+ static get observedAttributes(): string[];
1313
+ }
1314
+ export class KupolaTooltipElement extends HTMLElement {
1315
+ static get observedAttributes(): string[];
1316
+ }
1317
+ export class KupolaCollapseElement extends HTMLElement {}
1318
+ export class KupolaCollapseItemElement extends HTMLElement {
1319
+ static get observedAttributes(): string[];
1320
+ }
1321
+ export class KupolaDrawerElement extends HTMLElement {
1322
+ static get observedAttributes(): string[];
1323
+ }
1324
+ export class KupolaModalElement extends HTMLElement {
1325
+ static get observedAttributes(): string[];
1326
+ open(): void;
1327
+ close(): void;
1328
+ }
1329
+
1330
+ export function createModal(options?: Record<string, unknown>): InstanceType<typeof Modal>;
1331
+ export function confirmModal(options: Record<string, unknown> | string): InstanceType<typeof Modal>;
1332
+ export function alertModal(options: Record<string, unknown> | string): InstanceType<typeof Modal>;
1333
+
1334
+ export function cleanupAllDropdowns(): void;
1335
+ export function cleanupAllSlideCaptchas(): void;
1336
+
1337
+ export function ref<T = unknown>(initialValue?: T): { value: T; _subscribers: Set<Function> };
1338
+
1339
+ export class Modal {
1340
+ constructor(element: HTMLElement, options?: Record<string, unknown>);
1341
+ open(): void;
1342
+ close(): void;
1343
+ toggleFullscreen(): void;
1344
+ isVisible(): boolean;
1345
+ destroy(): void;
1346
+ }
1347
+
1352
1348
  export function createStore<S extends object = Record<string, unknown>>(name: string, options?: StoreOptions<S>): KupolaStore<S>;
1353
1349
 
1354
1350
  export function getStore<S extends object = Record<string, unknown>>(name: string): KupolaStore<S> | undefined;
1355
1351
 
1356
- export const kupolaDevTools: KupolaDevTools;
1357
-
1358
- export function initDevTools(): void;
1352
+ // @kupola/depends
1353
+
1354
+ // HTTP Client Plugin System
1355
+ export interface KupolaHttpResponse {
1356
+ ok: boolean;
1357
+ status: number;
1358
+ statusText?: string;
1359
+ headers: Record<string, string>;
1360
+ url?: string;
1361
+ json(): Promise<any>;
1362
+ text(): Promise<string>;
1363
+ }
1364
+
1365
+ export interface KupolaHttpClient {
1366
+ fetch(url: string, options?: {
1367
+ method?: string;
1368
+ headers?: Record<string, string>;
1369
+ body?: string;
1370
+ }): Promise<KupolaHttpResponse>;
1371
+ }
1372
+
1373
+ export function configureHttpClient(client: KupolaHttpClient): void;
1374
+ export function getHttpClient(): KupolaHttpClient['fetch'];
1375
+ export function resetHttpClient(): void;
1376
+
1377
+ export class Scheduler {
1378
+ constructor();
1379
+ schedule(fn: () => void): void;
1380
+ }
1381
+
1382
+ export class CacheEntry<T = unknown> {
1383
+ constructor(data: T, ttl: number);
1384
+ readonly data: T;
1385
+ readonly createdAt: number;
1386
+ readonly ttl: number;
1387
+ readonly isFresh: boolean;
1388
+ readonly isStale: boolean;
1389
+ }
1390
+
1391
+ export class CacheManager {
1392
+ constructor();
1393
+ get<T = unknown>(key: string): CacheEntry<T> | null;
1394
+ set<T = unknown>(key: string, data: T, ttl?: number): void;
1395
+ has(key: string): boolean;
1396
+ delete(key: string): void;
1397
+ clear(): void;
1398
+ getStale<T = unknown>(key: string): T | null;
1399
+ }
1400
+
1401
+ export class DependsError extends Error {
1402
+ constructor(message: string, code: string, cause?: unknown);
1403
+ readonly code: string;
1404
+ readonly cause?: unknown;
1405
+ readonly timestamp: number;
1406
+ }
1407
+
1408
+ export type SourceType = string | ((params: Record<string, unknown>) => unknown | Promise<unknown>);
1409
+
1410
+ export interface DepsSourceConfig {
1411
+ source: SourceType;
1412
+ cacheKey?: string;
1413
+ staleTime?: number;
1414
+ retry?: number;
1415
+ retryDelay?: number;
1416
+ onError?: (error: DependsError) => void;
1417
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
1418
+ headers?: Record<string, string>;
1419
+ query?: Record<string, string | number | boolean>;
1420
+ default?: unknown;
1421
+ sync?: boolean;
1422
+ reconnect?: boolean;
1423
+ reconnectDelay?: number;
1424
+ }
1425
+
1426
+ export interface DepRef<T = unknown> {
1427
+ data: { value: T | null };
1428
+ loading: { value: boolean };
1429
+ error: { value: string | null };
1430
+ lastUpdated: { value: number | null };
1431
+ refresh(): Promise<void>;
1432
+ setValue?(value: unknown): void;
1433
+ send?(msg: unknown): void;
1434
+ }
1435
+
1436
+ export type DepsConfig = Record<string, DepsSourceConfig | string>;
1437
+ export type DepsProps = Record<string, unknown | { value: unknown }>;
1438
+ export type DepsResult<C extends DepsConfig> = {
1439
+ [K in keyof C]: DepRef;
1440
+ } & { _dispose(): void };
1441
+
1442
+ export function useDeps<C extends DepsConfig>(props: DepsProps, depsConfig: C): DepsResult<C>;
1443
+
1444
+ export function useQuery<T = unknown>(config: DepsSourceConfig): {
1445
+ data: { value: T | null };
1446
+ loading: { value: boolean };
1447
+ error: { value: string | null };
1448
+ refresh(): Promise<void>;
1449
+ };
1450
+
1451
+ export function clearCache(): void;
1452
+
1453
+ // Table & Pagination
1454
+ export { KupolaTable, KupolaTableColumn, KupolaTableOptions, KupolaPagination, KupolaPaginationOptions };
1455
+ export { initTable, initAllTables, initPagination };
1456
+
1359
1457
  }