kimu-core 0.4.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 (146) hide show
  1. package/.editorconfig +30 -0
  2. package/.gitattributes +11 -0
  3. package/.github/FUNDING.yml +8 -0
  4. package/.github/copilot-instructions.md +103 -0
  5. package/.github/kimu-copilot-instructions.md +3779 -0
  6. package/.github/workflows/deploy-demo.yml +39 -0
  7. package/AUTHORS.md +20 -0
  8. package/CHANGELOG.md +20 -0
  9. package/CODE_GUIDELINES.md +165 -0
  10. package/CODE_OF_CONDUCT.md +47 -0
  11. package/CONTRIBUTING.md +62 -0
  12. package/FUNDING.md +31 -0
  13. package/ISSUE_GUIDELINES.md +74 -0
  14. package/LICENSE +17 -0
  15. package/LICENSE.it.md +17 -0
  16. package/MPL-2.0.txt +373 -0
  17. package/NOTICE +65 -0
  18. package/README-KIMU.md +40 -0
  19. package/README.it.md +208 -0
  20. package/README.md +266 -0
  21. package/SECURITY.md +64 -0
  22. package/docs/get-started-en.md +207 -0
  23. package/docs/images/icon.svg +64 -0
  24. package/docs/images/logo_kimu.png +0 -0
  25. package/docs/index.md +29 -0
  26. package/env/dev.config.json +6 -0
  27. package/env/local.config.json +6 -0
  28. package/env/prod.config.json +6 -0
  29. package/env/staging.config.json +6 -0
  30. package/env/test.config.json +4 -0
  31. package/icon.svg +10 -0
  32. package/logo_kimu.png +0 -0
  33. package/package.json +79 -0
  34. package/public/favicon.svg +64 -0
  35. package/public/logo_kimu.svg +1 -0
  36. package/scripts/build-all-config.js +59 -0
  37. package/scripts/build-all-core.js +65 -0
  38. package/scripts/build-all-extensions.js +64 -0
  39. package/scripts/build-all-modules.js +99 -0
  40. package/scripts/build-extension.js +60 -0
  41. package/scripts/clear-kimu-build.js +31 -0
  42. package/scripts/generate-kimu-build-config.js +79 -0
  43. package/scripts/install-module.js +162 -0
  44. package/scripts/list-modules.js +109 -0
  45. package/scripts/minify-css-assets.js +82 -0
  46. package/scripts/remove-module.js +122 -0
  47. package/scripts/utils/fix-imports.js +85 -0
  48. package/src/assets/index.css +43 -0
  49. package/src/assets/kimu-style.css +84 -0
  50. package/src/assets/style.css +116 -0
  51. package/src/config/kimu-base-config.json +5 -0
  52. package/src/core/index.ts +47 -0
  53. package/src/core/kimu-app.ts +76 -0
  54. package/src/core/kimu-asset-manager.ts +167 -0
  55. package/src/core/kimu-component-element.ts +325 -0
  56. package/src/core/kimu-component.ts +33 -0
  57. package/src/core/kimu-engine.ts +188 -0
  58. package/src/core/kimu-extension-manager.ts +281 -0
  59. package/src/core/kimu-global-styles.ts +136 -0
  60. package/src/core/kimu-module-manager.ts +69 -0
  61. package/src/core/kimu-module.ts +21 -0
  62. package/src/core/kimu-path-config.ts +127 -0
  63. package/src/core/kimu-reactive.ts +196 -0
  64. package/src/core/kimu-render.ts +91 -0
  65. package/src/core/kimu-store.ts +147 -0
  66. package/src/core/kimu-types.ts +65 -0
  67. package/src/extensions/.gitkeep +0 -0
  68. package/src/extensions/extensions-manifest.json +13 -0
  69. package/src/extensions/kimu-home/component.ts +80 -0
  70. package/src/extensions/kimu-home/lang/en.json +5 -0
  71. package/src/extensions/kimu-home/lang/it.json +5 -0
  72. package/src/extensions/kimu-home/style.css +61 -0
  73. package/src/extensions/kimu-home/view.html +51 -0
  74. package/src/index.html +26 -0
  75. package/src/main.ts +68 -0
  76. package/src/modules/.gitkeep +0 -0
  77. package/src/modules/README.md +79 -0
  78. package/src/modules/i18n/README.it.md +63 -0
  79. package/src/modules/i18n/README.md +63 -0
  80. package/src/modules/i18n/kimu-global-lang.ts +26 -0
  81. package/src/modules/i18n/kimu-i18n-service.ts +108 -0
  82. package/src/modules/i18n/manifest.json +22 -0
  83. package/src/modules/i18n/module.ts +39 -0
  84. package/src/modules/modules-manifest.json +12 -0
  85. package/src/modules-repository/README.md +108 -0
  86. package/src/modules-repository/api-axios/CHANGELOG.md +48 -0
  87. package/src/modules-repository/api-axios/QUICK-REFERENCE.md +178 -0
  88. package/src/modules-repository/api-axios/README.md +304 -0
  89. package/src/modules-repository/api-axios/api-axios-service.ts +355 -0
  90. package/src/modules-repository/api-axios/examples.ts +293 -0
  91. package/src/modules-repository/api-axios/index.ts +19 -0
  92. package/src/modules-repository/api-axios/interfaces.ts +71 -0
  93. package/src/modules-repository/api-axios/module.ts +41 -0
  94. package/src/modules-repository/api-core/CHANGELOG.md +42 -0
  95. package/src/modules-repository/api-core/QUICK-REFERENCE.md +192 -0
  96. package/src/modules-repository/api-core/README.md +435 -0
  97. package/src/modules-repository/api-core/api-core-service.ts +289 -0
  98. package/src/modules-repository/api-core/examples.ts +432 -0
  99. package/src/modules-repository/api-core/index.ts +8 -0
  100. package/src/modules-repository/api-core/interfaces.ts +83 -0
  101. package/src/modules-repository/api-core/module.ts +30 -0
  102. package/src/modules-repository/event-bus/README.md +273 -0
  103. package/src/modules-repository/event-bus/event-bus-service.ts +176 -0
  104. package/src/modules-repository/event-bus/module.ts +30 -0
  105. package/src/modules-repository/i18n/README.it.md +63 -0
  106. package/src/modules-repository/i18n/README.md +63 -0
  107. package/src/modules-repository/i18n/kimu-global-lang.ts +26 -0
  108. package/src/modules-repository/i18n/kimu-i18n-service.ts +108 -0
  109. package/src/modules-repository/i18n/manifest.json +22 -0
  110. package/src/modules-repository/i18n/module.ts +39 -0
  111. package/src/modules-repository/notification/README.md +423 -0
  112. package/src/modules-repository/notification/module.ts +30 -0
  113. package/src/modules-repository/notification/notification-service.ts +436 -0
  114. package/src/modules-repository/router/README.it.md +39 -0
  115. package/src/modules-repository/router/README.md +39 -0
  116. package/src/modules-repository/router/manifest.json +21 -0
  117. package/src/modules-repository/router/module.ts +23 -0
  118. package/src/modules-repository/router/router.ts +144 -0
  119. package/src/modules-repository/state/README.md +409 -0
  120. package/src/modules-repository/state/module.ts +30 -0
  121. package/src/modules-repository/state/state-service.ts +296 -0
  122. package/src/modules-repository/theme/README.md +267 -0
  123. package/src/modules-repository/theme/module.ts +30 -0
  124. package/src/modules-repository/theme/pre-build.js +40 -0
  125. package/src/modules-repository/theme/theme-service.ts +389 -0
  126. package/src/modules-repository/theme/themes/theme-cherry-blossom.css +78 -0
  127. package/src/modules-repository/theme/themes/theme-cozy.css +111 -0
  128. package/src/modules-repository/theme/themes/theme-cyberpunk.css +150 -0
  129. package/src/modules-repository/theme/themes/theme-dark.css +79 -0
  130. package/src/modules-repository/theme/themes/theme-forest.css +171 -0
  131. package/src/modules-repository/theme/themes/theme-gold.css +100 -0
  132. package/src/modules-repository/theme/themes/theme-high-contrast.css +126 -0
  133. package/src/modules-repository/theme/themes/theme-lava.css +101 -0
  134. package/src/modules-repository/theme/themes/theme-lavender.css +90 -0
  135. package/src/modules-repository/theme/themes/theme-light.css +79 -0
  136. package/src/modules-repository/theme/themes/theme-matrix.css +103 -0
  137. package/src/modules-repository/theme/themes/theme-midnight.css +81 -0
  138. package/src/modules-repository/theme/themes/theme-nord.css +94 -0
  139. package/src/modules-repository/theme/themes/theme-ocean.css +84 -0
  140. package/src/modules-repository/theme/themes/theme-retro80s.css +343 -0
  141. package/src/modules-repository/theme/themes/theme-sunset.css +62 -0
  142. package/src/modules-repository/theme/themes-config.d.ts +27 -0
  143. package/src/modules-repository/theme/themes-config.json +213 -0
  144. package/src/vite-env.d.ts +1 -0
  145. package/tsconfig.json +33 -0
  146. package/vite.config.ts +99 -0
@@ -0,0 +1,108 @@
1
+ import { KimuExtensionLanguages } from '../../core/kimu-types';
2
+
3
+ /**
4
+ * KimuI18nService provides internationalization support for Kimu extensions.
5
+ * It loads translation files, manages language switching, and supports parameterized translations.
6
+ */
7
+ export class KimuI18nService {
8
+ private lang: string;
9
+ private translations: Record<string, string> = {};
10
+ private basePath: string;
11
+ private languages: KimuExtensionLanguages;
12
+
13
+ /**
14
+ * Creates a new I18n service instance.
15
+ * @param defaultLang The default language code (e.g. 'it').
16
+ * @param basePath The base path for language files.
17
+ * @param languages Optional: supported languages metadata. If not provided, fallback to default only.
18
+ */
19
+ constructor(defaultLang: string = 'it', basePath: string = './lang', languages?: KimuExtensionLanguages | null) {
20
+ this.lang = defaultLang;
21
+ this.basePath = basePath;
22
+ // If languages is not defined, fallback to only the initial language
23
+ this.languages = languages ?? {
24
+ default: defaultLang,
25
+ supported: {
26
+ [defaultLang]: { code: defaultLang },
27
+ },
28
+ };
29
+ // Use requested language only if supported, otherwise fallback to default
30
+ this.lang = this.resolveLang(defaultLang);
31
+ // Always bind translate to this instance
32
+ this.translate = this.translate.bind(this);
33
+ }
34
+
35
+ /**
36
+ * Returns the effective language to use (fallbacks to default if not supported).
37
+ * @param lang Requested language code.
38
+ */
39
+ private resolveLang(lang: string): string {
40
+ if (this.languages.supported[lang]) return lang;
41
+ return this.languages.default;
42
+ }
43
+
44
+ /**
45
+ * Changes the current language and loads the corresponding translation file.
46
+ * Returns a promise that resolves when the file is loaded.
47
+ * @param lang Language code to set.
48
+ */
49
+ async setLang(lang: string) {
50
+ this.lang = this.resolveLang(lang);
51
+ return await this.loadLang();
52
+ }
53
+
54
+ /**
55
+ * Returns the current language code for the extension.
56
+ */
57
+ getLang(): string {
58
+ return this.lang;
59
+ }
60
+
61
+ /**
62
+ * Loads the translation file for the current language.
63
+ * Uses the language metadata if available, otherwise defaults to <lang>.json.
64
+ * Returns a promise that resolves when the file is loaded.
65
+ */
66
+ async loadLang(): Promise<void> {
67
+ const langMeta = this.languages.supported[this.lang];
68
+ // Use custom file name if provided, otherwise default to <lang>.json
69
+ const file = langMeta.file || `${this.lang}.json`;
70
+ const url = `${this.basePath}/${file}`;
71
+ return await this.loadFromUrl(url);
72
+ }
73
+
74
+ /**
75
+ * Loads translations from a given URL (internal or external).
76
+ * If the file is not found or invalid, falls back to an empty translation object.
77
+ * @param url The URL to fetch the translation file from.
78
+ */
79
+ async loadFromUrl(url: string): Promise<void> {
80
+ try {
81
+ const res = await fetch(url);
82
+ if (!res.ok) {
83
+ throw new Error(`Lang file not found: ${url}`);
84
+ }
85
+ this.translations = await res.json();
86
+ } catch (err) {
87
+ console.warn(`[KimuI18nService] ERROR: ${err}`);
88
+ this.translations = {}; // fallback to empty translations
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Translates a key using the loaded translations.
94
+ * Supports optional parameters identified by {{param}} in the translation string.
95
+ * If the key is not found, returns the key itself.
96
+ * @param key The translation key.
97
+ * @param params Optional: parameters to replace in the translation string.
98
+ */
99
+ translate(key: string, params?: Record<string, any>): string {
100
+ let value = this.translations[key] || key;
101
+ if (params) {
102
+ for (const [k, v] of Object.entries(params)) {
103
+ value = value.replace(new RegExp(`{{${k}}}`, 'g'), v);
104
+ }
105
+ }
106
+ return value;
107
+ }
108
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "i18n",
3
+ "version": "1.0.0",
4
+ "description": "Internationalization module for KIMU applications with multi-language support and dynamic translation system",
5
+ "author": "KIMU Team",
6
+ "license": "MPL-2.0",
7
+ "dependencies": [],
8
+ "kimuCoreVersion": "^0.3.0",
9
+ "keywords": [
10
+ "i18n",
11
+ "internationalization",
12
+ "localization",
13
+ "translation",
14
+ "multilingual",
15
+ "language"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/UnicoVerso/kimu-core",
20
+ "directory": "src/modules/i18n"
21
+ }
22
+ }
@@ -0,0 +1,39 @@
1
+ import { KimuModule } from '../../core/kimu-module';
2
+ import { KimuModuleOptions } from '../../core/kimu-types';
3
+ import { KimuGlobalLang } from './kimu-global-lang';
4
+ import { KimuI18nService } from './kimu-i18n-service';
5
+
6
+ export default class I18nModule extends KimuModule {
7
+ private static instance: I18nModule | null = null;
8
+ private globalLang: typeof KimuGlobalLang;
9
+ private service: KimuI18nService;
10
+
11
+ constructor(name: string, version: string, options?: KimuModuleOptions & { basePath?: string; languages?: any }) {
12
+ super(name, version, options);
13
+ this.singleton = true; // Marca come singleton
14
+ this.globalLang = KimuGlobalLang;
15
+ this.service = new KimuI18nService(
16
+ options?.lang || 'it',
17
+ options?.basePath || './lang',
18
+ options?.languages
19
+ );
20
+ }
21
+
22
+ static getInstance(options?: KimuModuleOptions & { basePath?: string; languages?: any }): I18nModule {
23
+ if (!I18nModule.instance) {
24
+ I18nModule.instance = new I18nModule('i18n', '1.0.0', options);
25
+ }
26
+ return I18nModule.instance;
27
+ }
28
+
29
+ getService(): KimuI18nService {
30
+ return this.service;
31
+ }
32
+
33
+ getGlobalLang(): typeof KimuGlobalLang {
34
+ return this.globalLang;
35
+ }
36
+ }
37
+
38
+ // Export direct access to services (for optimized extension usage)
39
+ export { KimuGlobalLang, KimuI18nService };
@@ -0,0 +1,423 @@
1
+ # Notification Module
2
+
3
+ ## Overview
4
+ The Notification module provides a toast notification system for KIMU-Core applications. It supports different notification types (success, error, warning, info), customizable durations, positions, and styling.
5
+
6
+ ## Features
7
+ - ✅ **Multiple types** - Success, error, warning, info notifications
8
+ - ✅ **Customizable position** - 6 position options (top/bottom + left/center/right)
9
+ - ✅ **Auto-dismiss** - Configurable duration or persistent
10
+ - ✅ **Dismissible** - Optional close button
11
+ - ✅ **Click handlers** - Custom actions on click
12
+ - ✅ **Styled** - Beautiful, responsive design out-of-the-box
13
+ - ✅ **Max limit** - Prevents notification overflow
14
+ - ✅ **Animations** - Smooth enter/exit transitions
15
+ - ✅ **Debug mode** - Optional logging for development
16
+
17
+ ## Installation
18
+ The Notification module is included in KIMU-Core. No additional installation required.
19
+
20
+ ## Usage
21
+
22
+ ### Basic Examples
23
+ ```typescript
24
+ import { notificationService } from './modules/notification/notification-service';
25
+
26
+ // Success notification
27
+ notificationService.success('Profile updated successfully!');
28
+
29
+ // Error notification
30
+ notificationService.error('Failed to save changes');
31
+
32
+ // Warning notification
33
+ notificationService.warning('Your session will expire in 5 minutes');
34
+
35
+ // Info notification
36
+ notificationService.info('New message received');
37
+ ```
38
+
39
+ ### Custom Duration
40
+ ```typescript
41
+ // Show for 5 seconds
42
+ notificationService.success('Operation completed!', { duration: 5000 });
43
+
44
+ // Persistent (no auto-dismiss)
45
+ notificationService.info('Important message', { duration: 0 });
46
+ ```
47
+
48
+ ### Custom Position
49
+ ```typescript
50
+ // Bottom right
51
+ notificationService.info('Download complete', {
52
+ position: 'bottom-right'
53
+ });
54
+
55
+ // Top center
56
+ notificationService.warning('Network connection lost', {
57
+ position: 'top-center'
58
+ });
59
+
60
+ // Available positions:
61
+ // 'top-right', 'top-left', 'top-center'
62
+ // 'bottom-right', 'bottom-left', 'bottom-center'
63
+ ```
64
+
65
+ ### Click Handlers
66
+ ```typescript
67
+ // Execute action on click
68
+ notificationService.info('New message from John', {
69
+ onClick: () => {
70
+ console.log('Opening chat...');
71
+ openChat('john');
72
+ }
73
+ });
74
+
75
+ // Callback on close
76
+ notificationService.success('Changes saved', {
77
+ onClose: () => {
78
+ console.log('Notification closed');
79
+ }
80
+ });
81
+ ```
82
+
83
+ ### In a Component
84
+ ```typescript
85
+ import { KimuComponent } from '../core/kimu-component';
86
+ import { KimuComponentElement } from '../core/kimu-component-element';
87
+ import { notificationService } from '../modules/notification/notification-service';
88
+
89
+ @KimuComponent({
90
+ tag: 'user-form',
91
+ name: 'User Form',
92
+ // ...
93
+ })
94
+ export class UserFormComponent extends KimuComponentElement {
95
+
96
+ async saveUser(userData: any) {
97
+ try {
98
+ await this.apiService.post('/users', userData);
99
+
100
+ // Show success notification
101
+ notificationService.success('User created successfully!', {
102
+ duration: 3000,
103
+ position: 'top-right'
104
+ });
105
+
106
+ this.resetForm();
107
+ } catch (error) {
108
+ // Show error notification
109
+ notificationService.error('Failed to create user. Please try again.', {
110
+ duration: 5000,
111
+ dismissible: true
112
+ });
113
+ }
114
+ }
115
+
116
+ validateForm() {
117
+ if (!this.isValid) {
118
+ notificationService.warning('Please fill all required fields', {
119
+ duration: 4000
120
+ });
121
+ return false;
122
+ }
123
+ return true;
124
+ }
125
+
126
+ showInfo() {
127
+ notificationService.info('This form requires authentication', {
128
+ duration: 0, // Persistent
129
+ dismissible: true,
130
+ onClick: () => {
131
+ this.showLoginDialog();
132
+ }
133
+ });
134
+ }
135
+ }
136
+ ```
137
+
138
+ ### Dismiss Notifications
139
+ ```typescript
140
+ // Dismiss specific notification (returns ID)
141
+ const id = notificationService.success('Task completed');
142
+ notificationService.dismiss(id);
143
+
144
+ // Dismiss all notifications
145
+ notificationService.dismissAll();
146
+ ```
147
+
148
+ ### Configuration
149
+ ```typescript
150
+ // Set default duration (default: 3000ms)
151
+ notificationService.setDefaultDuration(5000);
152
+
153
+ // Set default position (default: 'top-right')
154
+ notificationService.setDefaultPosition('bottom-right');
155
+
156
+ // Set max visible notifications (default: 5)
157
+ notificationService.setMaxNotifications(3);
158
+
159
+ // Enable debug mode
160
+ notificationService.setDebugMode(true);
161
+ ```
162
+
163
+ ### Custom Icons
164
+ ```typescript
165
+ // Use custom emoji or icon
166
+ notificationService.success('Payment received', {
167
+ icon: '💰'
168
+ });
169
+
170
+ notificationService.info('New follower', {
171
+ icon: '👤'
172
+ });
173
+
174
+ notificationService.warning('Battery low', {
175
+ icon: '🔋'
176
+ });
177
+ ```
178
+
179
+ ## API Reference
180
+
181
+ ### `notificationService.success(message, options?)`
182
+ Show a success notification.
183
+ - **message**: `string` - Notification message
184
+ - **options**: `NotificationOptions` (optional)
185
+ - **Returns**: `string` - Notification ID
186
+
187
+ ### `notificationService.error(message, options?)`
188
+ Show an error notification.
189
+ - **message**: `string` - Notification message
190
+ - **options**: `NotificationOptions` (optional)
191
+ - **Returns**: `string` - Notification ID
192
+
193
+ ### `notificationService.warning(message, options?)`
194
+ Show a warning notification.
195
+ - **message**: `string` - Notification message
196
+ - **options**: `NotificationOptions` (optional)
197
+ - **Returns**: `string` - Notification ID
198
+
199
+ ### `notificationService.info(message, options?)`
200
+ Show an info notification.
201
+ - **message**: `string` - Notification message
202
+ - **options**: `NotificationOptions` (optional)
203
+ - **Returns**: `string` - Notification ID
204
+
205
+ ### `notificationService.show(message, options?)`
206
+ Show a notification with custom options.
207
+ - **message**: `string` - Notification message
208
+ - **options**: `NotificationOptions` (optional)
209
+ - **Returns**: `string` - Notification ID
210
+
211
+ ### `notificationService.dismiss(id)`
212
+ Dismiss a specific notification.
213
+ - **id**: `string` - Notification ID
214
+
215
+ ### `notificationService.dismissAll()`
216
+ Dismiss all active notifications.
217
+
218
+ ### `notificationService.getAll()`
219
+ Get all active notifications.
220
+ - **Returns**: `Notification[]`
221
+
222
+ ### `notificationService.getCount()`
223
+ Get count of active notifications.
224
+ - **Returns**: `number`
225
+
226
+ ### Configuration Methods
227
+
228
+ ### `notificationService.setDefaultDuration(duration)`
229
+ Set default notification duration.
230
+ - **duration**: `number` - Duration in milliseconds
231
+
232
+ ### `notificationService.setDefaultPosition(position)`
233
+ Set default notification position.
234
+ - **position**: `NotificationPosition`
235
+
236
+ ### `notificationService.setMaxNotifications(max)`
237
+ Set maximum visible notifications.
238
+ - **max**: `number`
239
+
240
+ ### `notificationService.setDebugMode(enabled)`
241
+ Enable or disable debug logging.
242
+ - **enabled**: `boolean`
243
+
244
+ ## NotificationOptions Interface
245
+ ```typescript
246
+ interface NotificationOptions {
247
+ type?: 'success' | 'error' | 'warning' | 'info';
248
+ duration?: number; // milliseconds, 0 = no auto-dismiss
249
+ position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';
250
+ dismissible?: boolean; // show close button
251
+ icon?: string; // custom icon (emoji or HTML)
252
+ onClick?: () => void; // click handler
253
+ onClose?: () => void; // close callback
254
+ }
255
+ ```
256
+
257
+ ## Styling
258
+
259
+ ### Default Styles
260
+ The module includes built-in styles with smooth animations and responsive design. Notifications are styled based on their type:
261
+ - **Success**: Green accent with ✅ icon
262
+ - **Error**: Red accent with ❌ icon
263
+ - **Warning**: Orange accent with ⚠️ icon
264
+ - **Info**: Blue accent with ℹ️ icon
265
+
266
+ ### Custom Styles
267
+ You can override default styles using CSS:
268
+ ```css
269
+ /* Custom notification styling */
270
+ .kimu-notification {
271
+ border-radius: 12px;
272
+ font-family: 'Your Font', sans-serif;
273
+ }
274
+
275
+ .kimu-notification-success {
276
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
277
+ color: white;
278
+ }
279
+
280
+ .kimu-notification-message {
281
+ font-weight: bold;
282
+ }
283
+ ```
284
+
285
+ ## Best Practices
286
+
287
+ ### 1. Use Appropriate Types
288
+ ```typescript
289
+ // Success for completed actions
290
+ notificationService.success('Profile updated');
291
+
292
+ // Error for failures
293
+ notificationService.error('Network error');
294
+
295
+ // Warning for attention needed
296
+ notificationService.warning('Unsaved changes');
297
+
298
+ // Info for general messages
299
+ notificationService.info('New feature available');
300
+ ```
301
+
302
+ ### 2. Keep Messages Concise
303
+ ```typescript
304
+ // Good
305
+ notificationService.success('Changes saved');
306
+
307
+ // Too verbose
308
+ notificationService.success('Your changes have been successfully saved to the database and will be reflected immediately');
309
+ ```
310
+
311
+ ### 3. Use Appropriate Durations
312
+ ```typescript
313
+ // Quick confirmations (2-3 seconds)
314
+ notificationService.success('Copied to clipboard', { duration: 2000 });
315
+
316
+ // Errors (4-5 seconds)
317
+ notificationService.error('Invalid email format', { duration: 4000 });
318
+
319
+ // Important messages (persistent)
320
+ notificationService.warning('Session expiring soon', {
321
+ duration: 0,
322
+ dismissible: true
323
+ });
324
+ ```
325
+
326
+ ### 4. Provide Actions When Needed
327
+ ```typescript
328
+ // Actionable notifications
329
+ notificationService.info('New message received', {
330
+ onClick: () => {
331
+ openMessages();
332
+ }
333
+ });
334
+
335
+ notificationService.error('Network error', {
336
+ onClick: () => {
337
+ retryConnection();
338
+ }
339
+ });
340
+ ```
341
+
342
+ ## Common Use Cases
343
+
344
+ ### 1. Form Validation
345
+ ```typescript
346
+ function validateAndSave() {
347
+ if (!form.isValid()) {
348
+ notificationService.error('Please fill all required fields');
349
+ return;
350
+ }
351
+
352
+ saveForm();
353
+ notificationService.success('Form submitted successfully');
354
+ }
355
+ ```
356
+
357
+ ### 2. API Responses
358
+ ```typescript
359
+ async function loadData() {
360
+ try {
361
+ const data = await api.get('/data');
362
+ notificationService.success('Data loaded successfully');
363
+ return data;
364
+ } catch (error) {
365
+ notificationService.error('Failed to load data. Please try again.');
366
+ throw error;
367
+ }
368
+ }
369
+ ```
370
+
371
+ ### 3. Background Tasks
372
+ ```typescript
373
+ function startExport() {
374
+ notificationService.info('Export started...', { duration: 2000 });
375
+
376
+ exportData().then(() => {
377
+ notificationService.success('Export completed!', {
378
+ onClick: () => downloadFile()
379
+ });
380
+ }).catch(() => {
381
+ notificationService.error('Export failed');
382
+ });
383
+ }
384
+ ```
385
+
386
+ ### 4. User Actions
387
+ ```typescript
388
+ function deleteItem() {
389
+ const id = notificationService.warning('This action cannot be undone', {
390
+ duration: 0,
391
+ dismissible: true
392
+ });
393
+
394
+ // Show confirmation UI
395
+ showConfirmDialog(() => {
396
+ notificationService.dismiss(id);
397
+ performDelete();
398
+ notificationService.success('Item deleted');
399
+ });
400
+ }
401
+ ```
402
+
403
+ ## Accessibility
404
+ - Notifications have proper ARIA labels
405
+ - Close buttons include aria-label="Close"
406
+ - Animations respect user preferences (prefers-reduced-motion)
407
+ - Keyboard accessible (Tab to close button, Enter to dismiss)
408
+
409
+ ## Performance Considerations
410
+ - Maximum 5 notifications by default (configurable)
411
+ - Automatic cleanup of old notifications
412
+ - CSS-based animations for smooth performance
413
+ - Minimal DOM manipulation
414
+
415
+ ## Browser Support
416
+ - Modern browsers with ES6+ support
417
+ - Chrome 60+, Firefox 60+, Safari 12+, Edge 79+
418
+
419
+ ## License
420
+ This module is part of KIMU-Core and follows the same license (MPL-2.0).
421
+
422
+ ## Version History
423
+ - **1.0.0** - Initial release with toast notifications
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Notification Module for KIMU-Core
3
+ *
4
+ * Provides toast notifications and alerts.
5
+ *
6
+ * @module NotificationModule
7
+ */
8
+
9
+ import { KimuModule } from '../../core/kimu-module';
10
+ import { notificationService } from './notification-service';
11
+
12
+ /**
13
+ * NotificationModule - Module class for notification system integration
14
+ */
15
+ export default class NotificationModule extends KimuModule {
16
+ constructor(name = 'notification', version = '1.0.0', options?: any) {
17
+ super(name, version, options);
18
+ }
19
+
20
+ /**
21
+ * Get the notification service instance
22
+ */
23
+ getService() {
24
+ return notificationService;
25
+ }
26
+ }
27
+
28
+ // Re-export for convenience
29
+ export { notificationService } from './notification-service';
30
+ export { NotificationService } from './notification-service';