@kupola/kupola 1.4.2 → 1.4.4

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 (71) hide show
  1. package/README.md +28 -3
  2. package/css/components-ext.css +1 -1
  3. package/css/kupola.css +3 -2
  4. package/css/table.css +74 -0
  5. package/dist/css/components-ext.css +158 -1
  6. package/dist/css/components.css +93 -1
  7. package/dist/css/kupola.css +13 -1
  8. package/dist/css/table.css +74 -0
  9. package/dist/css/theme-dark.css +5 -5
  10. package/dist/css/utilities.css +159 -1
  11. package/dist/kupola.cjs.js +214 -17409
  12. package/dist/kupola.cjs.js.map +1 -1
  13. package/dist/kupola.css +101 -4
  14. package/dist/kupola.esm.js +8196 -17225
  15. package/dist/kupola.esm.js.map +1 -1
  16. package/dist/kupola.min.css +1 -1
  17. package/dist/kupola.umd.js +214 -17415
  18. package/dist/kupola.umd.js.map +1 -1
  19. package/dist/types/kupola.d.ts +41 -25
  20. package/js/calendar.js +3 -10
  21. package/js/carousel.js +3 -10
  22. package/js/collapse.js +3 -10
  23. package/js/color-picker.js +5 -16
  24. package/js/component.js +4 -18
  25. package/js/countdown.js +3 -10
  26. package/js/data-bind.js +56 -36
  27. package/js/datepicker.js +16 -24
  28. package/js/depends.js +27 -16
  29. package/js/dialog.js +1 -5
  30. package/js/drawer.js +3 -11
  31. package/js/dropdown.js +11 -18
  32. package/js/dynamic-tags.js +3 -10
  33. package/js/fileupload.js +10 -12
  34. package/js/form.js +26 -20
  35. package/js/global-events.js +1 -14
  36. package/js/heatmap.js +3 -12
  37. package/js/i18n.js +1 -14
  38. package/js/icons.js +2 -2
  39. package/js/image-preview.js +1 -7
  40. package/js/initializer.js +0 -43
  41. package/js/kupola-core.js +1 -13
  42. package/js/kupola-lifecycle.js +1 -9
  43. package/js/message.js +1 -6
  44. package/js/modal.js +22 -20
  45. package/js/notification.js +1 -6
  46. package/js/numberinput.js +3 -10
  47. package/js/pagination.js +0 -5
  48. package/js/registry.js +0 -4
  49. package/js/select.js +5 -16
  50. package/js/slide-captcha.js +8 -21
  51. package/js/slider.js +3 -10
  52. package/js/statcard.js +3 -11
  53. package/js/table.js +240 -262
  54. package/js/tag.js +3 -10
  55. package/js/theme.js +11 -16
  56. package/js/timepicker.js +6 -19
  57. package/js/tooltip.js +3 -10
  58. package/js/utils.js +281 -1439
  59. package/js/validation.js +2 -7
  60. package/js/virtual-list.js +13 -38
  61. package/js/web-components.js +0 -9
  62. package/package.json +12 -7
  63. package/scripts/build-css.cjs +3 -2
  64. package/types/kupola.d.ts +41 -25
  65. package/version.json +10 -0
  66. package/dist/css/kupola.min.css +0 -1
  67. package/dist/icons.svg +0 -284
  68. package/dist/kupola.min.js +0 -2
  69. package/dist/kupola.min.js.map +0 -1
  70. /package/css/{colors_and_type.css → colors-and-type.css} +0 -0
  71. /package/dist/css/{colors_and_type.css → colors-and-type.css} +0 -0
package/js/validation.js CHANGED
@@ -518,7 +518,7 @@ if (!window.__kupolaValidationInitialized) {
518
518
  let timeout;
519
519
  return (...args) => {
520
520
  clearTimeout(timeout);
521
- timeout = setTimeout(() => func.apply(this, args), wait);
521
+ timeout = setTimeout(() => func(...args), wait);
522
522
  };
523
523
  };
524
524
 
@@ -549,9 +549,4 @@ if (!window.__kupolaValidationInitialized) {
549
549
  });
550
550
  }
551
551
 
552
- export { KupolaValidator, validator };
553
-
554
- if (typeof window !== 'undefined') {
555
- window.KupolaValidator = KupolaValidator;
556
- window.kupolaValidator = validator;
557
- }
552
+ export { KupolaValidator, validator };
@@ -1,3 +1,5 @@
1
+ import { kupolaInitializer } from './initializer.js';
2
+
1
3
  class VirtualList {
2
4
  constructor(element, options = {}) {
3
5
  this.element = element;
@@ -241,32 +243,7 @@ class VirtualList {
241
243
  const key = item[this.keyField] || actualIndex;
242
244
  const isSelected = this.selectedKey === key;
243
245
  const itemSize = this.getItemSize(actualIndex);
244
- const position = currentPosition;
245
-
246
- if (isHorizontal) {
247
- html += `
248
- <div
249
- class="ds-virtual-list__item${isSelected ? ' is-selected' : ''}"
250
- style="position: absolute; top: 0; left: ${position}px; width: ${itemSize}px; height: 100%;"
251
- data-index="${actualIndex}"
252
- data-key="${key}"
253
- >
254
- ${this.renderItem(item, actualIndex)}
255
- </div>
256
- `;
257
- } else {
258
- html += `
259
- <div
260
- class="ds-virtual-list__item${isSelected ? ' is-selected' : ''}"
261
- style="position: absolute; top: ${position}px; left: 0; right: 0; height: ${itemSize}px;"
262
- data-index="${actualIndex}"
263
- data-key="${key}"
264
- >
265
- ${this.renderItem(item, actualIndex)}
266
- </div>
267
- `;
268
- }
269
-
246
+ html += this._buildItemHtml(item, actualIndex, key, isSelected, itemSize, currentPosition, isHorizontal);
270
247
  currentPosition += itemSize;
271
248
  });
272
249
 
@@ -281,6 +258,15 @@ class VirtualList {
281
258
  });
282
259
  }
283
260
 
261
+ _buildItemHtml(item, index, key, isSelected, size, position, isHorizontal) {
262
+ const selectedClass = isSelected ? ' is-selected' : '';
263
+ const content = this.renderItem(item, index);
264
+ if (isHorizontal) {
265
+ return `<div class="ds-virtual-list__item${selectedClass}" style="position: absolute; top: 0; left: ${position}px; width: ${size}px; height: 100%;" data-index="${index}" data-key="${key}">${content}</div>`;
266
+ }
267
+ return `<div class="ds-virtual-list__item${selectedClass}" style="position: absolute; top: ${position}px; left: 0; right: 0; height: ${size}px;" data-index="${index}" data-key="${key}">${content}</div>`;
268
+ }
269
+
284
270
  updateDynamicHeights() {
285
271
  if (this.isUpdating) return;
286
272
 
@@ -583,15 +569,4 @@ function initVirtualLists() {
583
569
 
584
570
  export { VirtualList, initVirtualLists, initVirtualList, cleanupVirtualList, createVirtualList, generateMockVirtualListData };
585
571
 
586
- if (typeof window !== 'undefined') {
587
- window.VirtualList = VirtualList;
588
- window.initVirtualList = initVirtualList;
589
- window.cleanupVirtualList = cleanupVirtualList;
590
- window.initVirtualLists = initVirtualLists;
591
- window.createVirtualList = createVirtualList;
592
- window.generateMockVirtualListData = generateMockVirtualListData;
593
-
594
- if (window.kupolaInitializer) {
595
- window.kupolaInitializer.register('virtual-list', initVirtualList, cleanupVirtualList);
596
- }
597
- }
572
+ kupolaInitializer.register('virtual-list', initVirtualList, cleanupVirtualList);
@@ -277,12 +277,3 @@ export {
277
277
  KupolaDrawerElement,
278
278
  KupolaModalElement
279
279
  };
280
-
281
- if (typeof window !== 'undefined') {
282
- window.registerWebComponents = registerWebComponents;
283
- window.KupolaDropdownElement = KupolaDropdownElement;
284
- window.KupolaTooltipElement = KupolaTooltipElement;
285
- window.KupolaCollapseElement = KupolaCollapseElement;
286
- window.KupolaDrawerElement = KupolaDrawerElement;
287
- window.KupolaModalElement = KupolaModalElement;
288
- }
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@kupola/kupola",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "A lightweight UI toolkit for any web project. No heavy frontend frameworks required.",
5
5
  "main": "dist/kupola.cjs.js",
6
6
  "module": "dist/kupola.esm.js",
7
7
  "types": "dist/types/kupola.d.ts",
8
8
  "type": "module",
9
- "sideEffects": false,
9
+ "sideEffects": [
10
+ "./js/icons.js",
11
+ "./js/theme-standalone.js",
12
+ "*.css"
13
+ ],
10
14
  "engines": {
11
15
  "node": ">=16.0.0"
12
16
  },
@@ -46,13 +50,14 @@
46
50
  "import": "./adapters/navios-http.js",
47
51
  "types": "./adapters/navios-http.d.ts"
48
52
  },
49
- "./kupola.css": "./dist/css/kupola.css",
50
- "./kupola.min.css": "./dist/css/kupola.min.css",
53
+ "./kupola.css": "./dist/kupola.css",
54
+ "./kupola.min.css": "./dist/kupola.min.css",
51
55
  "./kupola.umd.js": "./dist/kupola.umd.js",
52
56
  "./kupola.min.js": "./dist/kupola.min.js",
53
57
  "./dist/css/kupola.css": "./dist/css/kupola.css",
54
58
  "./dist/css/*": "./dist/css/*",
55
- "./dist/icons/*": "./dist/icons/*"
59
+ "./dist/icons/*": "./dist/icons/*",
60
+ "./version.json": "./version.json"
56
61
  },
57
62
  "scripts": {
58
63
  "dev": "vite",
@@ -106,7 +111,8 @@
106
111
  "plugins/",
107
112
  "adapters/",
108
113
  "types/",
109
- "scripts/"
114
+ "scripts/",
115
+ "version.json"
110
116
  ],
111
117
  "devDependencies": {
112
118
  "@rollup/plugin-commonjs": "^25.0.7",
@@ -117,7 +123,6 @@
117
123
  "prettier": "^3.2.5",
118
124
  "rollup": "^4.13.0",
119
125
  "rollup-plugin-copy": "^3.5.0",
120
- "rollup-plugin-postcss": "^4.0.2",
121
126
  "vite": "^5.1.6"
122
127
  }
123
128
  }
@@ -18,7 +18,7 @@ const OUTPUT_DIR = path.resolve(__dirname, '..', 'dist');
18
18
 
19
19
  // Import order must match kupola.css @import order
20
20
  const IMPORT_ORDER = [
21
- 'colors_and_type.css',
21
+ 'colors-and-type.css',
22
22
  'theme-light.css',
23
23
  'theme-dark.css',
24
24
  'brand-themes.css',
@@ -29,7 +29,8 @@ const IMPORT_ORDER = [
29
29
  'utilities.css',
30
30
  'responsive.css',
31
31
  'accessibility.css',
32
- 'animations.css'
32
+ 'animations.css',
33
+ 'table.css'
33
34
  ];
34
35
 
35
36
  function resolveImports(cssContent, basePath) {
package/types/kupola.d.ts CHANGED
@@ -468,6 +468,18 @@ declare class KupolaUtils {
468
468
 
469
469
  declare const kupolaUtils: KupolaUtils;
470
470
 
471
+ declare const stringUtils: KupolaUtils['string'];
472
+ declare const arrayUtils: KupolaUtils['array'];
473
+ declare const objectUtils: KupolaUtils['object'];
474
+ declare const numberUtils: KupolaUtils['number'];
475
+ declare const dateUtils: KupolaUtils['date'];
476
+ declare const validatorUtils: KupolaUtils['validator'];
477
+ declare const cryptoUtils: KupolaUtils['crypto'];
478
+ declare const preloadUtils: KupolaUtils['preload'];
479
+
480
+ declare function debounce<T extends (...args: unknown[]) => void>(func: T, wait: number, options?: DebounceOptions): T;
481
+ declare function throttle<T extends (...args: unknown[]) => void>(func: T, limit: number, options?: ThrottleOptions): T;
482
+
471
483
  declare interface FormState {
472
484
  valid: boolean;
473
485
  errors: Record<string, string>;
@@ -681,14 +693,14 @@ declare class KupolaModalElement extends HTMLElement {
681
693
  close(): void;
682
694
  }
683
695
 
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;
696
+ declare function createModal(options?: Record<string, unknown>): Modal;
697
+ declare function confirmModal(options: Record<string, unknown> | string): Modal;
698
+ declare function alertModal(options: Record<string, unknown> | string): Modal;
687
699
 
688
700
  declare function cleanupAllDropdowns(): void;
689
701
  declare function cleanupAllSlideCaptchas(): void;
690
702
 
691
- declare function ref<T = unknown>(initialValue?: T): { value: T; _subscribers: Set<Function> };
703
+ declare function ref<T = unknown>(initialValue?: T): { value: T; _subscribers: Set<Function>; subscribe: (callback: Function) => { unsubscribe: () => void } };
692
704
 
693
705
  declare class Modal {
694
706
  constructor(element: HTMLElement, options?: Record<string, unknown>);
@@ -720,7 +732,7 @@ interface KupolaHttpResponse {
720
732
  statusText?: string;
721
733
  headers: Record<string, string>;
722
734
  url?: string;
723
- json(): Promise<any>;
735
+ json(): Promise<unknown>;
724
736
  text(): Promise<string>;
725
737
  }
726
738
 
@@ -816,16 +828,16 @@ declare function clearCache(): void;
816
828
  // Table & Pagination Components
817
829
  // ============================================================
818
830
 
819
- interface KupolaTableColumn {
831
+ interface KupolaTableColumn<T = Record<string, unknown>> {
820
832
  key: string;
821
833
  title: string;
822
834
  width?: string | number;
823
835
  minWidth?: string | number;
824
836
  align?: 'left' | 'center' | 'right';
825
837
  sortable?: boolean;
826
- sorter?: (a: unknown, b: unknown, order?: string) => number;
838
+ sorter?: (a: T, b: T, order?: string) => number;
827
839
  fixed?: 'left' | 'right';
828
- render?: (value: unknown, row: unknown, index?: number) => string | HTMLElement;
840
+ render?: (value: unknown, row: T, index?: number) => string | HTMLElement;
829
841
  editable?: boolean;
830
842
  editType?: string;
831
843
  editOptions?: Array<{ value: string; label: string }>;
@@ -842,8 +854,8 @@ interface KupolaTableVirtualScrollOptions {
842
854
  maxHeight?: string;
843
855
  }
844
856
 
845
- interface KupolaTableOptions {
846
- columns: KupolaTableColumn[];
857
+ interface KupolaTableOptions<T = Record<string, unknown>> {
858
+ columns: KupolaTableColumn<T>[];
847
859
  rowKey?: string;
848
860
  striped?: boolean;
849
861
  bordered?: boolean;
@@ -858,31 +870,31 @@ interface KupolaTableOptions {
858
870
  showExport?: boolean;
859
871
  showPageSize?: boolean;
860
872
  selection?: 'checkbox' | 'radio';
861
- expandable?: (row: unknown) => string | HTMLElement;
873
+ expandable?: (row: T) => string | HTMLElement;
862
874
  editable?: boolean;
863
875
  resizable?: boolean;
864
876
  draggable?: boolean;
865
877
  multiSort?: boolean;
866
878
  tree?: KupolaTableTreeOptions;
867
879
  virtualScroll?: KupolaTableVirtualScrollOptions;
868
- mergeCells?: (data: unknown[]) => Array<{ row: number; col: number; rowSpan: number; colSpan: number }>;
880
+ mergeCells?: (data: T[]) => Array<{ row: number; col: number; rowSpan: number; colSpan: number }>;
869
881
  onSort?: (sorts: Array<{ key: string; order: string }>) => void;
870
882
  onFilter?: (text: string) => void;
871
- onRowClick?: (row: unknown, index: number, event: Event) => void;
883
+ onRowClick?: (row: T, index: number, event: Event) => void;
872
884
  onPageChange?: (page: number, pageSize: number) => void;
873
- onSelect?: (selectedKeys: unknown[], selectedRows: unknown[]) => void;
885
+ onSelect?: (selectedKeys: unknown[], selectedRows: T[]) => void;
874
886
  onExpand?: (key: unknown, isExpanded: boolean) => void;
875
- onEditSave?: (row: unknown, colKey: string, newValue: unknown, allData: unknown[]) => void;
876
- onEditCancel?: (editingCell: unknown) => void;
887
+ onEditSave?: (row: T, colKey: string, newValue: unknown, allData: T[]) => void;
888
+ onEditCancel?: (editingCell: { row: T; colKey: string; value: unknown }) => void;
877
889
  onColumnResize?: (colKey: string, newWidth: number) => void;
878
- onRowDragEnd?: (movedRow: unknown, fromIndex: number, toIndex: number, newData: unknown[]) => void;
890
+ onRowDragEnd?: (movedRow: T, fromIndex: number, toIndex: number, newData: T[]) => void;
879
891
  }
880
892
 
881
- declare class KupolaTable {
882
- constructor(element: HTMLElement | string, options?: KupolaTableOptions);
883
- setData(data: unknown[] | { value: unknown[] | null }): void;
893
+ declare class KupolaTable<T = Record<string, unknown>> {
894
+ constructor(element: HTMLElement | string, options?: KupolaTableOptions<T>);
895
+ setData(data: T[] | { value: T[] | null }): void;
884
896
  setLoading(loading: boolean): void;
885
- setColumns(columns: KupolaTableColumn[]): void;
897
+ setColumns(columns: KupolaTableColumn<T>[]): void;
886
898
  setPageSize(size: number): void;
887
899
  getSortState(): { key: string | null; order: string | null } | Array<{ key: string; order: string }>;
888
900
  getPage(): { current: number; pageSize: number; total: number };
@@ -894,11 +906,11 @@ declare class KupolaTable {
894
906
  selectRow(key: unknown): void;
895
907
  deselectRow(key: unknown): void;
896
908
  getSelectedKeys(): unknown[];
897
- getSelectedRows(): unknown[];
909
+ getSelectedRows(): T[];
898
910
  destroy(): void;
899
911
  }
900
912
 
901
- declare function initTable(element: HTMLElement | string, options?: KupolaTableOptions): KupolaTable;
913
+ declare function initTable<T = Record<string, unknown>>(element: HTMLElement | string, options?: KupolaTableOptions<T>): KupolaTable<T>;
902
914
  declare function initAllTables(): KupolaTable[];
903
915
 
904
916
  interface KupolaPaginationOptions {
@@ -1334,7 +1346,7 @@ declare module 'kupola' {
1334
1346
  export function cleanupAllDropdowns(): void;
1335
1347
  export function cleanupAllSlideCaptchas(): void;
1336
1348
 
1337
- export function ref<T = unknown>(initialValue?: T): { value: T; _subscribers: Set<Function> };
1349
+ export function ref<T = unknown>(initialValue?: T): { value: T; _subscribers: Set<Function>; subscribe: (callback: Function) => { unsubscribe: () => void } };
1338
1350
 
1339
1351
  export class Modal {
1340
1352
  constructor(element: HTMLElement, options?: Record<string, unknown>);
@@ -1358,7 +1370,7 @@ declare module 'kupola' {
1358
1370
  statusText?: string;
1359
1371
  headers: Record<string, string>;
1360
1372
  url?: string;
1361
- json(): Promise<any>;
1373
+ json(): Promise<unknown>;
1362
1374
  text(): Promise<string>;
1363
1375
  }
1364
1376
 
@@ -1454,4 +1466,8 @@ declare module 'kupola' {
1454
1466
  export { KupolaTable, KupolaTableColumn, KupolaTableOptions, KupolaPagination, KupolaPaginationOptions };
1455
1467
  export { initTable, initAllTables, initPagination };
1456
1468
 
1469
+ // Utils (tree-shakeable namespace exports)
1470
+ export { KupolaUtils, stringUtils, arrayUtils, objectUtils, numberUtils, dateUtils };
1471
+ export { debounce, throttle, validatorUtils, cryptoUtils, preloadUtils };
1472
+
1457
1473
  }
package/version.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": "1.4.3",
3
+ "name": "Kupola",
4
+ "description": "A lightweight, dependency-free declarative UI component system for any server-side rendered web application",
5
+ "author": "Kupola Team",
6
+ "license": "MIT",
7
+ "homepage": "https://github.com/kupola-cn/kupola",
8
+ "repository": "https://github.com/kupola-cn/kupola",
9
+ "changelog": "CHANGELOG.md"
10
+ }
@@ -1 +0,0 @@
1
- @import "../css/scaffold.css";@import "../css/colors_and_type.css";@import "../css/theme-light.css";@import "../css/brand-themes.css";@import "../css/components.css";@import "../css/components-ext.css";@import "../css/states.css";@import "../css/responsive.css";@import "../css/animations.css";@import "../css/accessibility.css";@import "../css/utilities.css";