zabi-components 1.0.5 → 1.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.
package/README.md CHANGED
@@ -12,6 +12,7 @@ A comprehensive Svelte component library built with TypeScript and Tailwind CSS,
12
12
  - 🎭 **Dark Mode Support** - Built-in dark mode support with CSS custom properties
13
13
  - 🧩 **Slot Support** - Flexible slot system for custom content
14
14
  - 📦 **Tree Shakeable** - Import only what you need
15
+ - ✅ **Production Ready** - Fully tested and optimized for production use
15
16
 
16
17
  ## Installation
17
18
 
@@ -19,18 +20,56 @@ A comprehensive Svelte component library built with TypeScript and Tailwind CSS,
19
20
  npm install zabi-components
20
21
  ```
21
22
 
23
+ ### Peer Dependencies
24
+
25
+ Make sure you have the required peer dependencies installed:
26
+
27
+ ```bash
28
+ npm install svelte@^4.0.0 || ^5.0.0
29
+ npm install @sveltejs/kit@^2.0.0 # Optional, for SvelteKit projects
30
+ ```
31
+
32
+ ## Import Methods
33
+
34
+ Zabi Components supports multiple import patterns:
35
+
36
+ ### Main Import (All Components)
37
+ ```typescript
38
+ import { Button, Input, Card, Alert, Badge, Modal } from 'zabi-components';
39
+ ```
40
+
41
+ ### Subpath Imports (Recommended for Tree Shaking)
42
+ ```typescript
43
+ // Import from specific categories
44
+ import { Button, Input, Badge } from 'zabi-components/atoms';
45
+ import { Alert, Modal, Dropdown } from 'zabi-components/molecules';
46
+ import { Navbar, ToastManager } from 'zabi-components/organisms';
47
+
48
+ // Import types separately
49
+ import type { ButtonEvents, InputEvents } from 'zabi-components/types';
50
+ ```
51
+
22
52
  ## Quick Start
23
53
 
24
54
  ```svelte
25
- <script>
55
+ <script lang="ts">
26
56
  import { Button, Input, Card, Alert } from 'zabi-components';
27
57
 
28
58
  let name = '';
29
59
  let showAlert = false;
30
60
 
31
- function handleSubmit() {
61
+ function handleSubmit(event: CustomEvent) {
62
+ console.log('Form submitted!', event.detail.value);
32
63
  showAlert = true;
33
64
  }
65
+
66
+ function handleInput(event: CustomEvent) {
67
+ console.log('Input changed:', event.detail.value);
68
+ }
69
+
70
+ function handleClose() {
71
+ showAlert = false;
72
+ }
34
73
  </script>
35
74
 
36
75
  <Card>
@@ -42,7 +81,7 @@ npm install zabi-components
42
81
  bind:value={name}
43
82
  label="Name"
44
83
  placeholder="Enter your name"
45
- on:input={(e) => console.log(e.detail.value)}
84
+ on:input={handleInput}
46
85
  />
47
86
 
48
87
  <Button on:click={handleSubmit}>
@@ -50,9 +89,11 @@ npm install zabi-components
50
89
  </Button>
51
90
 
52
91
  <div slot="footer">
53
- <Alert variant="success" closable bind:show={showAlert}>
54
- Form submitted successfully!
55
- </Alert>
92
+ {#if showAlert}
93
+ <Alert variant="success" closable on:close={handleClose}>
94
+ Form submitted successfully!
95
+ </Alert>
96
+ {/if}
56
97
  </div>
57
98
  </Card>
58
99
  ```
@@ -267,7 +308,7 @@ interface BaseEventDetail<T = any> {
267
308
 
268
309
  ## TypeScript Support
269
310
 
270
- Full TypeScript definitions are included:
311
+ Full TypeScript definitions are included with proper event typing:
271
312
 
272
313
  ```typescript
273
314
  import type { ButtonEvents, InputEvents, CardEvents, AlertEvents } from 'zabi-components';
@@ -276,6 +317,53 @@ import type { ButtonEvents, InputEvents, CardEvents, AlertEvents } from 'zabi-co
276
317
  function handleButtonClick(event: CustomEvent<{ value: boolean; event?: MouseEvent }>) {
277
318
  console.log('Button clicked:', event.detail.value);
278
319
  }
320
+
321
+ function handleInputChange(event: CustomEvent<{ value: string; event?: InputEvent }>) {
322
+ console.log('Input changed:', event.detail.value);
323
+ }
324
+ ```
325
+
326
+ ### Event Types
327
+
328
+ All components use standardized event types:
329
+
330
+ ```typescript
331
+ // Base event structure
332
+ interface BaseEventDetail<T = any> {
333
+ value: T;
334
+ event?: Event;
335
+ }
336
+
337
+ // Specific event types
338
+ interface ClickEventDetail extends BaseEventDetail<boolean> {
339
+ event?: MouseEvent | KeyboardEvent;
340
+ }
341
+
342
+ interface InputEventDetail extends BaseEventDetail<string> {
343
+ event?: InputEvent;
344
+ }
345
+
346
+ interface ChangeEventDetail extends BaseEventDetail<string> {
347
+ event?: Event;
348
+ }
349
+ ```
350
+
351
+ ### Component Event Interfaces
352
+
353
+ ```typescript
354
+ interface ButtonEvents {
355
+ click: ClickEventDetail;
356
+ }
357
+
358
+ interface InputEvents {
359
+ input: InputEventDetail;
360
+ change: ChangeEventDetail;
361
+ focus: { event: FocusEvent };
362
+ blur: { event: FocusEvent };
363
+ keydown: { event: KeyboardEvent };
364
+ keyup: { event: KeyboardEvent };
365
+ clear: { event: Event };
366
+ }
279
367
  ```
280
368
 
281
369
  ## Advanced Usage
@@ -296,29 +384,42 @@ function handleButtonClick(event: CustomEvent<{ value: boolean; event?: MouseEve
296
384
  ### Form Integration
297
385
 
298
386
  ```svelte
299
- <script>
387
+ <script lang="ts">
300
388
  import { Button, Input, Card, Alert } from 'zabi-components';
301
389
 
302
- let formData = {
390
+ interface FormData {
391
+ name: string;
392
+ email: string;
393
+ message: string;
394
+ }
395
+
396
+ interface FormErrors {
397
+ name?: string;
398
+ email?: string;
399
+ message?: string;
400
+ }
401
+
402
+ let formData: FormData = {
303
403
  name: '',
304
404
  email: '',
305
405
  message: ''
306
406
  };
307
407
 
308
- let errors = {};
408
+ let errors: FormErrors = {};
309
409
  let showSuccess = false;
310
410
 
311
- function validateForm() {
411
+ function validateForm(): boolean {
312
412
  errors = {};
313
413
  if (!formData.name) errors.name = 'Name is required';
314
414
  if (!formData.email) errors.email = 'Email is required';
315
415
  return Object.keys(errors).length === 0;
316
416
  }
317
417
 
318
- function handleSubmit() {
418
+ function handleSubmit(event: CustomEvent) {
319
419
  if (validateForm()) {
320
420
  showSuccess = true;
321
421
  // Submit form
422
+ console.log('Form submitted:', formData);
322
423
  }
323
424
  }
324
425
  </script>
@@ -378,6 +479,69 @@ function handleButtonClick(event: CustomEvent<{ value: boolean; event?: MouseEve
378
479
 
379
480
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
380
481
 
482
+ ## Changelog
483
+
484
+ ### v1.0.5 (Latest)
485
+
486
+ #### 🐛 Bug Fixes
487
+ - **Fixed Package Exports**: Resolved "Package subpath './atoms' is not defined" errors
488
+ - **Fixed Runtime Errors**: Eliminated null reference errors that caused application crashes
489
+ - **Fixed TypeScript Types**: Properly typed event handlers and component props
490
+ - **Fixed Slot Definitions**: Ensured slots work correctly with proper typing
491
+ - **Fixed Main Export**: Ensured zabi-components main import works correctly
492
+
493
+ #### ✨ Improvements
494
+ - Enhanced TypeScript support with comprehensive event type definitions
495
+ - Improved build configuration for better tree shaking
496
+ - Added proper type generation for all component categories
497
+ - Standardized event structure across all components
498
+
499
+ #### 📦 Package Structure
500
+ - Added support for subpath imports (`zabi-components/atoms`, `zabi-components/molecules`, etc.)
501
+ - Improved type definitions with proper event interfaces
502
+ - Enhanced build output with proper ES module exports
503
+
504
+ ## Troubleshooting
505
+
506
+ ### Common Issues
507
+
508
+ #### Import Errors
509
+ If you encounter import errors like "Package subpath './atoms' is not defined", make sure you're using the latest version:
510
+
511
+ ```bash
512
+ npm install zabi-components@latest
513
+ ```
514
+
515
+ #### TypeScript Event Handler Errors
516
+ If you see TypeScript errors with event handlers, make sure to use proper typing:
517
+
518
+ ```typescript
519
+ // ✅ Correct
520
+ function handleClick(event: CustomEvent) {
521
+ console.log(event.detail.value);
522
+ }
523
+
524
+ // ❌ Incorrect - missing event parameter
525
+ function handleClick() {
526
+ console.log('clicked');
527
+ }
528
+ ```
529
+
530
+ #### Runtime Errors
531
+ If you encounter runtime errors, ensure you have the correct peer dependencies:
532
+
533
+ ```bash
534
+ npm install svelte@^5.0.0 @sveltejs/kit@^2.0.0
535
+ ```
536
+
537
+ ### Migration from Previous Versions
538
+
539
+ If you're upgrading from a previous version, note these changes:
540
+
541
+ 1. **Event Structure**: All events now follow the standardized `{ detail: { value, event? } }` structure
542
+ 2. **Import Paths**: Subpath imports are now fully supported (`zabi-components/atoms`, etc.)
543
+ 3. **TypeScript**: Enhanced type definitions with proper event typing
544
+
381
545
  ## Support
382
546
 
383
547
  For support, please open an issue on GitHub or contact the maintainers.