@0djek/sveltix 0.0.6

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 (244) hide show
  1. package/README.md +103 -0
  2. package/dist/button/Button.svelte +24 -0
  3. package/dist/button/Button.svelte.d.ts +4 -0
  4. package/dist/button/ButtonComponent.svelte.d.ts +15 -0
  5. package/dist/button/ButtonComponent.svelte.js +26 -0
  6. package/dist/button/ButtonStyles.d.ts +11 -0
  7. package/dist/button/ButtonStyles.js +2 -0
  8. package/dist/button/__tests__/builders/ButtonBuilder.d.ts +23 -0
  9. package/dist/button/__tests__/builders/ButtonBuilder.js +61 -0
  10. package/dist/button/__tests__/builders/ButtonStory.svelte +27 -0
  11. package/dist/button/__tests__/builders/ButtonStory.svelte.d.ts +14 -0
  12. package/dist/button/__tests__/pom/ButtonPom.d.ts +6 -0
  13. package/dist/button/__tests__/pom/ButtonPom.js +14 -0
  14. package/dist/button/buttonDefaults.d.ts +9 -0
  15. package/dist/button/buttonDefaults.js +9 -0
  16. package/dist/button/index.d.ts +5 -0
  17. package/dist/button/index.js +9 -0
  18. package/dist/button/internal/DefaultButtonStyles.d.ts +15 -0
  19. package/dist/button/internal/DefaultButtonStyles.js +64 -0
  20. package/dist/button/models/ButtonProps.d.ts +45 -0
  21. package/dist/button/models/ButtonProps.js +1 -0
  22. package/dist/button/models/ButtonSize.d.ts +6 -0
  23. package/dist/button/models/ButtonSize.js +7 -0
  24. package/dist/button/models/ButtonVariant.d.ts +5 -0
  25. package/dist/button/models/ButtonVariant.js +6 -0
  26. package/dist/button/models/index.d.ts +3 -0
  27. package/dist/button/models/index.js +3 -0
  28. package/dist/cache/Cache.d.ts +18 -0
  29. package/dist/cache/Cache.js +20 -0
  30. package/dist/cache/MappedCache.d.ts +7 -0
  31. package/dist/cache/MappedCache.js +35 -0
  32. package/dist/cache/__tests__/builders/CacheBuilder.d.ts +7 -0
  33. package/dist/cache/__tests__/builders/CacheBuilder.js +18 -0
  34. package/dist/cache/__tests__/builders/MappedCacheBuilder.d.ts +7 -0
  35. package/dist/cache/__tests__/builders/MappedCacheBuilder.js +18 -0
  36. package/dist/cache/index.d.ts +2 -0
  37. package/dist/cache/index.js +2 -0
  38. package/dist/datagrid/SveltixGrid.svelte.d.ts +35 -0
  39. package/dist/datagrid/SveltixGrid.svelte.js +90 -0
  40. package/dist/datagrid/SveltixGridGlobal.d.ts +9 -0
  41. package/dist/datagrid/SveltixGridGlobal.js +12 -0
  42. package/dist/datagrid/components/Datagrid.svelte +114 -0
  43. package/dist/datagrid/components/Datagrid.svelte.d.ts +39 -0
  44. package/dist/datagrid/core-modules/columns/Column.svelte.d.ts +79 -0
  45. package/dist/datagrid/core-modules/columns/Column.svelte.js +322 -0
  46. package/dist/datagrid/core-modules/columns/ColumnsModule.svelte.d.ts +26 -0
  47. package/dist/datagrid/core-modules/columns/ColumnsModule.svelte.js +77 -0
  48. package/dist/datagrid/core-modules/columns/components/CalculateCellWidth.svelte +18 -0
  49. package/dist/datagrid/core-modules/columns/components/CalculateCellWidth.svelte.d.ts +25 -0
  50. package/dist/datagrid/core-modules/columns/index.d.ts +5 -0
  51. package/dist/datagrid/core-modules/columns/index.js +11 -0
  52. package/dist/datagrid/core-modules/columns/models/ColumnOptions.d.ts +2 -0
  53. package/dist/datagrid/core-modules/columns/models/ColumnOptions.js +1 -0
  54. package/dist/datagrid/core-modules/custom/CustomComponentsModule.svelte.d.ts +27 -0
  55. package/dist/datagrid/core-modules/custom/CustomComponentsModule.svelte.js +58 -0
  56. package/dist/datagrid/core-modules/custom/components/CustomComponents.svelte +36 -0
  57. package/dist/datagrid/core-modules/custom/components/CustomComponents.svelte.d.ts +30 -0
  58. package/dist/datagrid/core-modules/custom/index.d.ts +3 -0
  59. package/dist/datagrid/core-modules/custom/index.js +10 -0
  60. package/dist/datagrid/core-modules/custom/models/CustomComponentPosition.d.ts +21 -0
  61. package/dist/datagrid/core-modules/custom/models/CustomComponentPosition.js +22 -0
  62. package/dist/datagrid/core-modules/index.d.ts +4 -0
  63. package/dist/datagrid/core-modules/index.js +4 -0
  64. package/dist/datagrid/core-modules/pipelines/PipelinesModule.svelte.d.ts +12 -0
  65. package/dist/datagrid/core-modules/pipelines/PipelinesModule.svelte.js +58 -0
  66. package/dist/datagrid/core-modules/pipelines/index.d.ts +4 -0
  67. package/dist/datagrid/core-modules/pipelines/index.js +11 -0
  68. package/dist/datagrid/core-modules/pipelines/models/CallbackSignature.d.ts +9 -0
  69. package/dist/datagrid/core-modules/pipelines/models/CallbackSignature.js +1 -0
  70. package/dist/datagrid/core-modules/rows/Cell.svelte.d.ts +27 -0
  71. package/dist/datagrid/core-modules/rows/Cell.svelte.js +103 -0
  72. package/dist/datagrid/core-modules/rows/Row.svelte.d.ts +24 -0
  73. package/dist/datagrid/core-modules/rows/Row.svelte.js +117 -0
  74. package/dist/datagrid/core-modules/rows/RowsModule.svelte.d.ts +33 -0
  75. package/dist/datagrid/core-modules/rows/RowsModule.svelte.js +115 -0
  76. package/dist/datagrid/core-modules/rows/components/body/BodyCell.svelte +31 -0
  77. package/dist/datagrid/core-modules/rows/components/body/BodyCell.svelte.d.ts +30 -0
  78. package/dist/datagrid/core-modules/rows/components/body/GroupCell.svelte +26 -0
  79. package/dist/datagrid/core-modules/rows/components/body/GroupCell.svelte.d.ts +25 -0
  80. package/dist/datagrid/core-modules/rows/index.d.ts +8 -0
  81. package/dist/datagrid/core-modules/rows/index.js +13 -0
  82. package/dist/datagrid/core-modules/rows/internal/CreateRowOptions.d.ts +15 -0
  83. package/dist/datagrid/core-modules/rows/internal/CreateRowOptions.js +1 -0
  84. package/dist/datagrid/core-modules/rows/models/RowsOptions.d.ts +3 -0
  85. package/dist/datagrid/core-modules/rows/models/RowsOptions.js +1 -0
  86. package/dist/datagrid/core-modules/rows/models/index.d.ts +1 -0
  87. package/dist/datagrid/core-modules/rows/models/index.js +1 -0
  88. package/dist/datagrid/events/generateEvents.d.ts +2 -0
  89. package/dist/datagrid/events/generateEvents.js +16 -0
  90. package/dist/datagrid/events/index.d.ts +2 -0
  91. package/dist/datagrid/events/index.js +2 -0
  92. package/dist/datagrid/events/models/RowUpdatedArgs.d.ts +5 -0
  93. package/dist/datagrid/events/models/RowUpdatedArgs.js +1 -0
  94. package/dist/datagrid/events/models/SveltixEvents.d.ts +20 -0
  95. package/dist/datagrid/events/models/SveltixEvents.js +1 -0
  96. package/dist/datagrid/events/models/index.d.ts +2 -0
  97. package/dist/datagrid/events/models/index.js +2 -0
  98. package/dist/datagrid/index.d.ts +5 -0
  99. package/dist/datagrid/index.js +5 -0
  100. package/dist/datagrid/interfaces/ISveltixGrid.d.ts +22 -0
  101. package/dist/datagrid/interfaces/ISveltixGrid.js +1 -0
  102. package/dist/datagrid/interfaces/Module.d.ts +11 -0
  103. package/dist/datagrid/interfaces/Module.js +13 -0
  104. package/dist/datagrid/interfaces/index.d.ts +2 -0
  105. package/dist/datagrid/interfaces/index.js +2 -0
  106. package/dist/datagrid/models/BaseColumn.d.ts +23 -0
  107. package/dist/datagrid/models/BaseColumn.js +1 -0
  108. package/dist/datagrid/models/Formatter.d.ts +32 -0
  109. package/dist/datagrid/models/Formatter.js +7 -0
  110. package/dist/datagrid/models/SveltixGridOptions.d.ts +12 -0
  111. package/dist/datagrid/models/SveltixGridOptions.js +1 -0
  112. package/dist/datagrid/models/Value.d.ts +21 -0
  113. package/dist/datagrid/models/Value.js +6 -0
  114. package/dist/datagrid/models/index.d.ts +4 -0
  115. package/dist/datagrid/models/index.js +4 -0
  116. package/dist/datagrid/models/module/ModuleConstructor.d.ts +5 -0
  117. package/dist/datagrid/models/module/ModuleConstructor.js +1 -0
  118. package/dist/datagrid/models/module/ModuleRegistrationEntry.d.ts +6 -0
  119. package/dist/datagrid/models/module/ModuleRegistrationEntry.js +1 -0
  120. package/dist/datagrid/models/module/index.d.ts +2 -0
  121. package/dist/datagrid/models/module/index.js +2 -0
  122. package/dist/datagrid/modules/flash/FlashModule.svelte.d.ts +9 -0
  123. package/dist/datagrid/modules/flash/FlashModule.svelte.js +33 -0
  124. package/dist/datagrid/modules/flash/index.d.ts +5 -0
  125. package/dist/datagrid/modules/flash/index.js +10 -0
  126. package/dist/datagrid/modules/flash/models/FlashModuleOptions.d.ts +4 -0
  127. package/dist/datagrid/modules/flash/models/FlashModuleOptions.js +1 -0
  128. package/dist/datagrid/modules/flash/models/index.d.ts +1 -0
  129. package/dist/datagrid/modules/flash/models/index.js +1 -0
  130. package/dist/datagrid/modules/resize/ResizeModule.svelte.d.ts +14 -0
  131. package/dist/datagrid/modules/resize/ResizeModule.svelte.js +68 -0
  132. package/dist/datagrid/modules/resize/components/ResizeCustomComponent.svelte +15 -0
  133. package/dist/datagrid/modules/resize/components/ResizeCustomComponent.svelte.d.ts +25 -0
  134. package/dist/datagrid/modules/resize/components/ResizeHandle.svelte +29 -0
  135. package/dist/datagrid/modules/resize/components/ResizeHandle.svelte.d.ts +28 -0
  136. package/dist/datagrid/modules/resize/index.d.ts +5 -0
  137. package/dist/datagrid/modules/resize/index.js +12 -0
  138. package/dist/datagrid/modules/resize/models/ResizeModuleOptions.d.ts +15 -0
  139. package/dist/datagrid/modules/resize/models/ResizeModuleOptions.js +1 -0
  140. package/dist/datagrid/modules/resize/models/index.d.ts +1 -0
  141. package/dist/datagrid/modules/resize/models/index.js +1 -0
  142. package/dist/deep-equal/deepEqual.d.ts +7 -0
  143. package/dist/deep-equal/deepEqual.js +79 -0
  144. package/dist/deep-equal/index.d.ts +1 -0
  145. package/dist/deep-equal/index.js +1 -0
  146. package/dist/di/DiContainer.d.ts +20 -0
  147. package/dist/di/DiContainer.js +42 -0
  148. package/dist/event-bus/EventBus.d.ts +9 -0
  149. package/dist/event-bus/EventBus.js +38 -0
  150. package/dist/event-bus/createEventDefinition.d.ts +1 -0
  151. package/dist/event-bus/createEventDefinition.js +5 -0
  152. package/dist/event-bus/index.d.ts +3 -0
  153. package/dist/event-bus/index.js +3 -0
  154. package/dist/event-bus/models/Event.d.ts +6 -0
  155. package/dist/event-bus/models/Event.js +1 -0
  156. package/dist/event-bus/models/SubscriberEntry.d.ts +5 -0
  157. package/dist/event-bus/models/SubscriberEntry.js +1 -0
  158. package/dist/event-bus/models/SubscriberSignature.d.ts +3 -0
  159. package/dist/event-bus/models/SubscriberSignature.js +1 -0
  160. package/dist/event-bus/models/UnsubscribeSignature.d.ts +3 -0
  161. package/dist/event-bus/models/UnsubscribeSignature.js +1 -0
  162. package/dist/event-bus/models/index.d.ts +4 -0
  163. package/dist/event-bus/models/index.js +4 -0
  164. package/dist/groupBy/groupBy.d.ts +2 -0
  165. package/dist/groupBy/groupBy.js +22 -0
  166. package/dist/groupBy/index.d.ts +2 -0
  167. package/dist/groupBy/index.js +2 -0
  168. package/dist/groupBy/models/Grouping.d.ts +4 -0
  169. package/dist/groupBy/models/Grouping.js +1 -0
  170. package/dist/groupBy/models/index.d.ts +1 -0
  171. package/dist/groupBy/models/index.js +1 -0
  172. package/dist/heading/Heading.svelte +28 -0
  173. package/dist/heading/Heading.svelte.d.ts +4 -0
  174. package/dist/heading/HeadingComponent.svelte.d.ts +13 -0
  175. package/dist/heading/HeadingComponent.svelte.js +20 -0
  176. package/dist/heading/HeadingStyles.d.ts +11 -0
  177. package/dist/heading/HeadingStyles.js +1 -0
  178. package/dist/heading/__tests__/HeadingBuilder.d.ts +12 -0
  179. package/dist/heading/__tests__/HeadingBuilder.js +34 -0
  180. package/dist/heading/__tests__/HeadingStory.svelte +16 -0
  181. package/dist/heading/__tests__/HeadingStory.svelte.d.ts +10 -0
  182. package/dist/heading/headingClasses.d.ts +8 -0
  183. package/dist/heading/headingClasses.js +8 -0
  184. package/dist/heading/index.d.ts +5 -0
  185. package/dist/heading/index.js +8 -0
  186. package/dist/heading/internal/DefaultHeadingStyles.d.ts +15 -0
  187. package/dist/heading/internal/DefaultHeadingStyles.js +75 -0
  188. package/dist/heading/models/Align.d.ts +8 -0
  189. package/dist/heading/models/Align.js +9 -0
  190. package/dist/heading/models/HeadingProps.d.ts +25 -0
  191. package/dist/heading/models/HeadingProps.js +1 -0
  192. package/dist/heading/models/HeadingTag.d.ts +1 -0
  193. package/dist/heading/models/HeadingTag.js +1 -0
  194. package/dist/heading/models/index.d.ts +3 -0
  195. package/dist/heading/models/index.js +3 -0
  196. package/dist/index.d.ts +2 -0
  197. package/dist/index.js +2 -0
  198. package/dist/ordered-map/OrderedMap.svelte.d.ts +27 -0
  199. package/dist/ordered-map/OrderedMap.svelte.js +138 -0
  200. package/dist/ordered-map/__tests__/builders/OrderedMapBuilder.d.ts +9 -0
  201. package/dist/ordered-map/__tests__/builders/OrderedMapBuilder.js +26 -0
  202. package/dist/ordered-map/index.d.ts +1 -0
  203. package/dist/ordered-map/index.js +1 -0
  204. package/dist/paragraph/P.svelte +21 -0
  205. package/dist/paragraph/P.svelte.d.ts +4 -0
  206. package/dist/paragraph/PComponents.svelte.d.ts +13 -0
  207. package/dist/paragraph/PComponents.svelte.js +20 -0
  208. package/dist/paragraph/ParagraphStyles.d.ts +11 -0
  209. package/dist/paragraph/ParagraphStyles.js +1 -0
  210. package/dist/paragraph/__tests__/PStory.svelte +15 -0
  211. package/dist/paragraph/__tests__/PStory.svelte.d.ts +10 -0
  212. package/dist/paragraph/__tests__/ParagraphBuilder.d.ts +10 -0
  213. package/dist/paragraph/__tests__/ParagraphBuilder.js +28 -0
  214. package/dist/paragraph/index.d.ts +5 -0
  215. package/dist/paragraph/index.js +8 -0
  216. package/dist/paragraph/internal/DefaultParagraphStyles.d.ts +15 -0
  217. package/dist/paragraph/internal/DefaultParagraphStyles.js +61 -0
  218. package/dist/paragraph/internal/classes.d.ts +6 -0
  219. package/dist/paragraph/internal/classes.js +7 -0
  220. package/dist/paragraph/models/PFont.d.ts +4 -0
  221. package/dist/paragraph/models/PFont.js +5 -0
  222. package/dist/paragraph/models/PProps.d.ts +12 -0
  223. package/dist/paragraph/models/PProps.js +1 -0
  224. package/dist/paragraph/models/PSize.d.ts +6 -0
  225. package/dist/paragraph/models/PSize.js +7 -0
  226. package/dist/paragraph/models/index.d.ts +3 -0
  227. package/dist/paragraph/models/index.js +3 -0
  228. package/dist/theme/Component.svelte.d.ts +13 -0
  229. package/dist/theme/Component.svelte.js +20 -0
  230. package/dist/theme/index.d.ts +2 -0
  231. package/dist/theme/index.js +2 -0
  232. package/dist/theme/models/ThemableComponent.d.ts +6 -0
  233. package/dist/theme/models/ThemableComponent.js +1 -0
  234. package/dist/theme/models/Theme.d.ts +9 -0
  235. package/dist/theme/models/Theme.js +10 -0
  236. package/dist/theme/models/index.d.ts +2 -0
  237. package/dist/theme/models/index.js +2 -0
  238. package/dist/theme/themeDefaults.d.ts +2 -0
  239. package/dist/theme/themeDefaults.js +2 -0
  240. package/dist/types/KeysOfType.d.ts +3 -0
  241. package/dist/types/KeysOfType.js +1 -0
  242. package/dist/types/SurfaceContainerStyles.d.ts +4 -0
  243. package/dist/types/SurfaceContainerStyles.js +1 -0
  244. package/package.json +82 -0
@@ -0,0 +1,18 @@
1
+ import { Cache } from '../../Cache';
2
+ export class CacheBuilder {
3
+ _entries = [];
4
+ static create() {
5
+ return new CacheBuilder();
6
+ }
7
+ setEntry(key, value) {
8
+ this._entries.push({ key, value });
9
+ return this;
10
+ }
11
+ build() {
12
+ const cache = new Cache();
13
+ this._entries.forEach((entry) => {
14
+ cache.set(entry.key, entry.value);
15
+ });
16
+ return cache;
17
+ }
18
+ }
@@ -0,0 +1,7 @@
1
+ import { MappedCache } from '../../MappedCache';
2
+ export declare class MappedCacheBuilder {
3
+ private _entries;
4
+ static create(): MappedCacheBuilder;
5
+ setEntry(mapKey: string, key: string, value: number): MappedCacheBuilder;
6
+ build(): MappedCache<number>;
7
+ }
@@ -0,0 +1,18 @@
1
+ import { MappedCache } from '../../MappedCache';
2
+ export class MappedCacheBuilder {
3
+ _entries = [];
4
+ static create() {
5
+ return new MappedCacheBuilder();
6
+ }
7
+ setEntry(mapKey, key, value) {
8
+ this._entries.push({ mapKey, key, value });
9
+ return this;
10
+ }
11
+ build() {
12
+ const cache = new MappedCache();
13
+ this._entries.forEach((entry) => {
14
+ cache.set(entry.mapKey, entry.key, entry.value);
15
+ });
16
+ return cache;
17
+ }
18
+ }
@@ -0,0 +1,2 @@
1
+ export * from './Cache';
2
+ export * from './MappedCache';
@@ -0,0 +1,2 @@
1
+ export * from './Cache';
2
+ export * from './MappedCache';
@@ -0,0 +1,35 @@
1
+ import type { ISveltixGrid } from './interfaces';
2
+ import type { BaseColumn, ModuleRegistrationEntry } from './models';
3
+ import type { SveltixGridOptions } from './models/SveltixGridOptions';
4
+ import { ColumnsModule } from './core-modules/columns';
5
+ import { RowsModule } from './core-modules/rows';
6
+ import { type Event, type SubscriberSignature } from '../event-bus';
7
+ import { type PipelinesModule } from './core-modules';
8
+ import { CustomComponentsModule } from './core-modules/custom/CustomComponentsModule.svelte';
9
+ import { type SveltixEvents } from './events';
10
+ export interface CoreModules<T> {
11
+ custom: CustomComponentsModule<T>;
12
+ rows: RowsModule<T>;
13
+ columns: ColumnsModule<T>;
14
+ pipelines: PipelinesModule<T>;
15
+ }
16
+ export declare class SveltixGrid<T> implements ISveltixGrid<T> {
17
+ get ready(): boolean;
18
+ get dom(): HTMLDivElement;
19
+ get core(): CoreModules<T>;
20
+ private readonly _modules;
21
+ private _ready;
22
+ private _dom;
23
+ set dom(value: HTMLDivElement);
24
+ private _core;
25
+ private _events;
26
+ get events(): SveltixEvents<T>;
27
+ private _eventBus;
28
+ constructor(options?: SveltixGridOptions<T>);
29
+ on<TEvent>(event: Event<TEvent>, callback: SubscriberSignature<TEvent>): import("../event-bus").UnsubscribeSignature;
30
+ emit<TEvent>(event: Event<TEvent>, data: TEvent): void;
31
+ init(rows: T[], columns: BaseColumn<T>[]): Promise<void>;
32
+ addModule<TOption>(entry: ModuleRegistrationEntry<T, TOption>): void;
33
+ getModule<TModule>(id: symbol): TModule;
34
+ destroy(): void;
35
+ }
@@ -0,0 +1,90 @@
1
+ import { ColumnsModule, columnsModule } from './core-modules/columns';
2
+ import { ROWS_MODULE, rowsModule, RowsModule } from './core-modules/rows';
3
+ import { EventBus } from '../event-bus';
4
+ import { COLUMNS_MODULE, PIPELINES_MODULE, pipelinesModule, } from './core-modules';
5
+ import { tick } from 'svelte';
6
+ import { CustomComponentsModule } from './core-modules/custom/CustomComponentsModule.svelte';
7
+ import { CUSTOM_COMPONENTS_MODULE, customComponentsModule } from './core-modules/custom';
8
+ import { generateEvent } from './events';
9
+ export class SveltixGrid {
10
+ get ready() {
11
+ return this._ready;
12
+ }
13
+ get dom() {
14
+ return this._dom;
15
+ }
16
+ get core() {
17
+ return this._core;
18
+ }
19
+ _modules = new Map();
20
+ _ready = $state(false);
21
+ _dom = undefined;
22
+ set dom(value) {
23
+ this._dom = value;
24
+ }
25
+ _core;
26
+ _events;
27
+ get events() {
28
+ return this._events;
29
+ }
30
+ _eventBus = new EventBus();
31
+ constructor(options) {
32
+ this._events = generateEvent();
33
+ this.addModule(pipelinesModule());
34
+ this.addModule(columnsModule());
35
+ this.addModule(rowsModule(options?.rows));
36
+ this.addModule(customComponentsModule());
37
+ this._core = {
38
+ rows: this.getModule(ROWS_MODULE),
39
+ columns: this.getModule(COLUMNS_MODULE),
40
+ pipelines: this.getModule(PIPELINES_MODULE),
41
+ custom: this.getModule(CUSTOM_COMPONENTS_MODULE),
42
+ };
43
+ if (options?.modules != null) {
44
+ for (const module of options?.modules) {
45
+ this.addModule(module);
46
+ }
47
+ }
48
+ }
49
+ on(event, callback) {
50
+ return this._eventBus.on(event, callback);
51
+ }
52
+ emit(event, data) {
53
+ this._eventBus.emit(event, data);
54
+ }
55
+ async init(rows, columns) {
56
+ if (this._ready) {
57
+ return;
58
+ }
59
+ this._modules.forEach((value) => {
60
+ value.init();
61
+ });
62
+ this._core.columns.create(columns);
63
+ this._core.rows.create(rows, true);
64
+ await tick();
65
+ await this._core.columns.calculateWidth();
66
+ this._ready = true;
67
+ this._core.pipelines.execute();
68
+ }
69
+ addModule(entry) {
70
+ if (this._modules.has(entry.key)) {
71
+ console.warn(`Can't register '${entry.key.toString()}' because it's already registered.`);
72
+ return;
73
+ }
74
+ const instance = new entry.module(this, entry.options);
75
+ this._modules.set(entry.key, instance);
76
+ }
77
+ getModule(id) {
78
+ const instance = this._modules.get(id);
79
+ if (instance == null) {
80
+ throw new Error(`Module with ID '${id.toString()}' was not found.`);
81
+ }
82
+ return instance;
83
+ }
84
+ destroy() {
85
+ for (const module of this._modules.values()) {
86
+ module.uninit();
87
+ module.unsubscribe();
88
+ }
89
+ }
90
+ }
@@ -0,0 +1,9 @@
1
+ import type { ModuleRegistrationEntry } from './models';
2
+ /**
3
+ * Global options for the datagrids', that will be created.
4
+ */
5
+ export declare class SveltixGridGlobal {
6
+ private static _modules;
7
+ static setModules(modules: ModuleRegistrationEntry<unknown, unknown>[]): void;
8
+ static getModules<T>(): ModuleRegistrationEntry<T, unknown>[];
9
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Global options for the datagrids', that will be created.
3
+ */
4
+ export class SveltixGridGlobal {
5
+ static _modules = [];
6
+ static setModules(modules) {
7
+ this._modules = modules;
8
+ }
9
+ static getModules() {
10
+ return this._modules;
11
+ }
12
+ }
@@ -0,0 +1,114 @@
1
+ <script
2
+ lang="ts"
3
+ generics="T">
4
+ import { onDestroy, onMount } from 'svelte';
5
+ import type { BaseColumn } from '../models';
6
+ import { SveltixGridGlobal } from '../SveltixGridGlobal';
7
+ import { SveltixGrid } from '../SveltixGrid.svelte';
8
+ import { fade } from 'svelte/transition';
9
+ import { FormatterValue } from '../core-modules/columns/Column.svelte';
10
+ import CustomComponents from '../core-modules/custom/components/CustomComponents.svelte';
11
+ import { CustomComponentPosition } from '../core-modules/custom/models/CustomComponentPosition';
12
+ import BodyCell from '../core-modules/rows/components/body/BodyCell.svelte';
13
+ import { flip } from 'svelte/animate';
14
+
15
+ /**
16
+ * Required and optional props to create datagrid.
17
+ */
18
+ interface Props {
19
+ /**
20
+ * Rows to render.
21
+ */
22
+ rows: T[];
23
+ /**
24
+ * Columns to render.
25
+ */
26
+ columns: BaseColumn<T>[];
27
+ /**
28
+ * API instance to control the datagrid.
29
+ */
30
+ api: SveltixGrid<T>;
31
+ }
32
+
33
+ const { rows, columns, api }: Props = $props();
34
+
35
+ let dom: HTMLDivElement;
36
+
37
+ $effect(() => {
38
+ if (dom == null) {
39
+ return;
40
+ }
41
+
42
+ api.dom = dom;
43
+ });
44
+
45
+ onMount(async () => {
46
+ SveltixGridGlobal.getModules<T>().forEach((module) => {
47
+ api.addModule(module);
48
+ });
49
+
50
+ await api.init(rows, columns);
51
+ });
52
+
53
+ onDestroy(() => {
54
+ api.destroy();
55
+ });
56
+ </script>
57
+
58
+ <!-- Main element -->
59
+ <div
60
+ bind:this={dom}
61
+ class="w-full">
62
+ <CustomComponents
63
+ {api}
64
+ position={CustomComponentPosition.Action} />
65
+ <!-- Header -->
66
+ <div>
67
+ <div class="flex">
68
+ {#each api.core.columns.visible as column (column.id)}
69
+ <div
70
+ class="relative flex"
71
+ data-headerCellId={column.id}>
72
+ {#each column.helperBefore as helper (helper.id)}
73
+ <helper.helper
74
+ {api}
75
+ {column}
76
+ options={helper.option} />
77
+ {/each}
78
+ <div
79
+ class="px-4 border-b-2 h-14 flex items-center"
80
+ style="max-width: {column.width}px; min-width: {column.width}px">
81
+ <span class="text-nowrap overflow-hidden text-ellipsis">
82
+ {column.publicColumn.header}
83
+ </span>
84
+ </div>
85
+ {#each column.helperAfter as helper (helper.id)}
86
+ <helper.helper
87
+ {api}
88
+ {column}
89
+ options={helper.option} />
90
+ {/each}
91
+ </div>
92
+ {/each}
93
+ </div>
94
+ </div>
95
+ <!-- Body -->
96
+ <div class="relative">
97
+ {api.core.rows.visible.length}
98
+ {#each api.core.rows.visible.slice(0, 10) as row (row.id)}
99
+ <div
100
+ class="flex group"
101
+ animate:flip
102
+ in:fade>
103
+ {#each row.cells as cell (cell.id)}
104
+ <BodyCell
105
+ {api}
106
+ {cell} />
107
+ {/each}
108
+ </div>
109
+ {/each}
110
+ </div>
111
+ <CustomComponents
112
+ {api}
113
+ position={CustomComponentPosition.Footer} />
114
+ </div>
@@ -0,0 +1,39 @@
1
+ import type { BaseColumn } from '../models';
2
+ import { SveltixGrid } from '../SveltixGrid.svelte';
3
+ declare function $$render<T>(): {
4
+ props: {
5
+ /**
6
+ * Rows to render.
7
+ */
8
+ rows: T[];
9
+ /**
10
+ * Columns to render.
11
+ */
12
+ columns: BaseColumn<T>[];
13
+ /**
14
+ * API instance to control the datagrid.
15
+ */
16
+ api: SveltixGrid<T>;
17
+ };
18
+ exports: {};
19
+ bindings: "";
20
+ slots: {};
21
+ events: {};
22
+ };
23
+ declare class __sveltets_Render<T> {
24
+ props(): ReturnType<typeof $$render<T>>['props'];
25
+ events(): ReturnType<typeof $$render<T>>['events'];
26
+ slots(): ReturnType<typeof $$render<T>>['slots'];
27
+ bindings(): "";
28
+ exports(): {};
29
+ }
30
+ interface $$IsomorphicComponent {
31
+ new <T>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
32
+ $$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
33
+ } & ReturnType<__sveltets_Render<T>['exports']>;
34
+ <T>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
35
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
36
+ }
37
+ declare const Datagrid: $$IsomorphicComponent;
38
+ type Datagrid<T> = InstanceType<typeof Datagrid<T>>;
39
+ export default Datagrid;
@@ -0,0 +1,79 @@
1
+ import type { ISveltixGrid } from '../../interfaces';
2
+ import { type BaseColumn, type Formatter, type FormatterComponentProps, type Value } from '../../models';
3
+ import { type Component, type Snippet } from 'svelte';
4
+ import type { Row } from '../rows/Row.svelte';
5
+ export declare enum FormatterValue {
6
+ Static = "Static",
7
+ Snippet = "Snippet",
8
+ Component = "Component"
9
+ }
10
+ interface BaseFormatted<T extends FormatterValue> {
11
+ mode: T;
12
+ }
13
+ export interface FormattedStatic extends BaseFormatted<FormatterValue.Static> {
14
+ format: string;
15
+ }
16
+ export interface FormattedSnippet extends BaseFormatted<FormatterValue.Snippet> {
17
+ snippet: Snippet<[value: any]>;
18
+ }
19
+ export interface FormattedComponent<T> extends BaseFormatted<FormatterValue.Component> {
20
+ component: Component<FormatterComponentProps<T>>;
21
+ }
22
+ export type Formatted<T> = FormattedSnippet | FormattedStatic | FormattedComponent<T>;
23
+ export interface HelperComponentProps<T, TOptions = void> {
24
+ api: ISveltixGrid<T>;
25
+ column: Column<T>;
26
+ options: TOptions;
27
+ }
28
+ export type HelperComponent<T, TOption> = Component<HelperComponentProps<T, TOption>>;
29
+ export declare enum HelperPosition {
30
+ Before = "Before",
31
+ After = "After"
32
+ }
33
+ interface HelperEntry<T> {
34
+ id: string;
35
+ helper: HelperComponent<T, unknown>;
36
+ option: unknown;
37
+ }
38
+ export declare class Column<T> {
39
+ get id(): string;
40
+ get publicColumn(): BaseColumn<T>;
41
+ get width(): number;
42
+ get valueGetter(): Value<T> | undefined;
43
+ get helperBefore(): HelperEntry<T>[];
44
+ get helperAfter(): HelperEntry<T>[];
45
+ get minimumWidth(): number;
46
+ private _api;
47
+ private _id;
48
+ private _valueGetters;
49
+ private _formatters;
50
+ private _valuesCache;
51
+ private _formatsCache;
52
+ private _publicColumn;
53
+ private _width;
54
+ private _valueGetter;
55
+ private _helperBefore;
56
+ private _helperAfter;
57
+ private _minimumWidth;
58
+ constructor(api: ISveltixGrid<T>, id: string, column: BaseColumn<T>);
59
+ private getFormatterFunction;
60
+ private getValueGetterFunction;
61
+ addValueGetter(key: string, getter: Value<T>): void;
62
+ clearCache(row: Row<T>, key?: string): void;
63
+ getValue(row: Row<T>, key?: string, ignoreCache?: boolean): unknown | undefined;
64
+ addFormatter(key: string, formatter: Formatter<T>): void;
65
+ format(value: unknown, row: Row<T>, key?: string): Formatted<T>;
66
+ private formatStatic;
67
+ private getKey;
68
+ addHelperStart<TOption = void>(id: string, helper: HelperComponent<T, TOption>, position: HelperPosition, option: TOption): void;
69
+ addHelperEnd<TOption = void>(id: string, helper: HelperComponent<T, TOption>, position: HelperPosition, option: TOption): void;
70
+ addHelper<TOption = void>(id: string, helper: HelperComponent<T, TOption>, position: HelperPosition, option: TOption): void;
71
+ private getMap;
72
+ calculateWidth(): Promise<void>;
73
+ private processRowForWidth;
74
+ private getCellFormatWidth;
75
+ getDom(): HTMLDivElement | undefined;
76
+ getWidth(): number | undefined;
77
+ setWidth(width: number): void;
78
+ }
79
+ export {};