zabi-components 1.0.4 → 1.0.5
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 +339 -98
- package/dist/{Tabs-CQvsdYPW.js → Tabs-ksSPSd0I.js} +254 -258
- package/dist/Toggle-DYKQFP4Y.js +2277 -0
- package/dist/{Tooltip-B-wUMg6c.js → Tooltip-D6yYgExv.js} +238 -242
- package/dist/atoms/index.js +2 -2
- package/dist/index/index.js +3 -3
- package/dist/molecules/index.js +2 -2
- package/dist/zabi-components.css +1 -0
- package/package.json +1 -1
- package/dist/Toggle-DuPArdKN.js +0 -2315
package/README.md
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
# Zabi Components
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A comprehensive Svelte component library built with TypeScript and Tailwind CSS, designed for easy integration across multiple Svelte projects.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- 🎨 **
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
- ♿ **
|
|
11
|
-
-
|
|
12
|
-
-
|
|
7
|
+
- 🎨 **Consistent Design System** - Standardized props, events, and styling across all components
|
|
8
|
+
- 🎯 **TypeScript First** - Full TypeScript support with comprehensive type definitions
|
|
9
|
+
- 🎨 **Tailwind CSS Integration** - Built with Tailwind CSS and CSS custom properties for easy theming
|
|
10
|
+
- ♿ **Accessibility First** - ARIA compliant components with keyboard navigation support
|
|
11
|
+
- 📱 **Responsive Design** - Mobile-first approach with responsive utilities
|
|
12
|
+
- 🎭 **Dark Mode Support** - Built-in dark mode support with CSS custom properties
|
|
13
|
+
- 🧩 **Slot Support** - Flexible slot system for custom content
|
|
14
|
+
- 📦 **Tree Shakeable** - Import only what you need
|
|
13
15
|
|
|
14
16
|
## Installation
|
|
15
17
|
|
|
@@ -17,130 +19,369 @@ A modern SvelteKit component library with TypeScript and Tailwind CSS support.
|
|
|
17
19
|
npm install zabi-components
|
|
18
20
|
```
|
|
19
21
|
|
|
20
|
-
##
|
|
22
|
+
## Quick Start
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
```svelte
|
|
25
|
+
<script>
|
|
26
|
+
import { Button, Input, Card, Alert } from 'zabi-components';
|
|
27
|
+
|
|
28
|
+
let name = '';
|
|
29
|
+
let showAlert = false;
|
|
30
|
+
|
|
31
|
+
function handleSubmit() {
|
|
32
|
+
showAlert = true;
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
23
35
|
|
|
24
|
-
|
|
25
|
-
|
|
36
|
+
<Card>
|
|
37
|
+
<div slot="header">
|
|
38
|
+
<h2>User Form</h2>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<Input
|
|
42
|
+
bind:value={name}
|
|
43
|
+
label="Name"
|
|
44
|
+
placeholder="Enter your name"
|
|
45
|
+
on:input={(e) => console.log(e.detail.value)}
|
|
46
|
+
/>
|
|
47
|
+
|
|
48
|
+
<Button on:click={handleSubmit}>
|
|
49
|
+
Submit
|
|
50
|
+
</Button>
|
|
51
|
+
|
|
52
|
+
<div slot="footer">
|
|
53
|
+
<Alert variant="success" closable bind:show={showAlert}>
|
|
54
|
+
Form submitted successfully!
|
|
55
|
+
</Alert>
|
|
56
|
+
</div>
|
|
57
|
+
</Card>
|
|
26
58
|
```
|
|
27
59
|
|
|
28
|
-
|
|
60
|
+
## Component API
|
|
29
61
|
|
|
30
|
-
|
|
31
|
-
// Atomic components
|
|
32
|
-
import { Button, Input, Card } from 'zabi-components/atoms';
|
|
62
|
+
### Button Component
|
|
33
63
|
|
|
34
|
-
|
|
35
|
-
|
|
64
|
+
```svelte
|
|
65
|
+
<Button
|
|
66
|
+
variant="primary" | "secondary" | "danger" | "success" | "warning" | "info"
|
|
67
|
+
size="sm" | "md" | "lg"
|
|
68
|
+
disabled={boolean}
|
|
69
|
+
loading={boolean}
|
|
70
|
+
type="button" | "submit" | "reset"
|
|
71
|
+
className={string}
|
|
72
|
+
on:click={(e) => console.log(e.detail.value, e.detail.event)}
|
|
73
|
+
>
|
|
74
|
+
Button Content
|
|
75
|
+
</Button>
|
|
76
|
+
```
|
|
36
77
|
|
|
37
|
-
|
|
38
|
-
|
|
78
|
+
**Props:**
|
|
79
|
+
- `variant`: Button style variant (default: "primary")
|
|
80
|
+
- `size`: Button size (default: "md")
|
|
81
|
+
- `disabled`: Disable the button (default: false)
|
|
82
|
+
- `loading`: Show loading state (default: false)
|
|
83
|
+
- `type`: HTML button type (default: "button")
|
|
84
|
+
- `className`: Additional CSS classes
|
|
85
|
+
|
|
86
|
+
**Events:**
|
|
87
|
+
- `click`: Fired when button is clicked - `{ detail: { value: true, event: MouseEvent } }`
|
|
88
|
+
|
|
89
|
+
### Input Component
|
|
90
|
+
|
|
91
|
+
```svelte
|
|
92
|
+
<Input
|
|
93
|
+
bind:value={string}
|
|
94
|
+
type={string}
|
|
95
|
+
label={string}
|
|
96
|
+
placeholder={string}
|
|
97
|
+
required={boolean}
|
|
98
|
+
disabled={boolean}
|
|
99
|
+
size="sm" | "md" | "lg"
|
|
100
|
+
variant="default" | "error" | "success"
|
|
101
|
+
error={string}
|
|
102
|
+
success={string}
|
|
103
|
+
helpText={string}
|
|
104
|
+
className={string}
|
|
105
|
+
id={string}
|
|
106
|
+
on:input={(e) => console.log(e.detail.value, e.detail.event)}
|
|
107
|
+
on:change={(e) => console.log(e.detail.value, e.detail.event)}
|
|
108
|
+
/>
|
|
39
109
|
```
|
|
40
110
|
|
|
41
|
-
|
|
111
|
+
**Props:**
|
|
112
|
+
- `value`: Input value (bindable)
|
|
113
|
+
- `type`: Input type (default: "text")
|
|
114
|
+
- `label`: Input label
|
|
115
|
+
- `placeholder`: Input placeholder
|
|
116
|
+
- `required`: Mark as required (default: false)
|
|
117
|
+
- `disabled`: Disable the input (default: false)
|
|
118
|
+
- `size`: Input size (default: "md")
|
|
119
|
+
- `variant`: Input variant (default: "default")
|
|
120
|
+
- `error`: Error message
|
|
121
|
+
- `success`: Success message
|
|
122
|
+
- `helpText`: Helper text
|
|
123
|
+
- `className`: Additional CSS classes
|
|
124
|
+
- `id`: Input ID
|
|
125
|
+
|
|
126
|
+
**Events:**
|
|
127
|
+
- `input`: Fired on input - `{ detail: { value: string, event: InputEvent } }`
|
|
128
|
+
- `change`: Fired on change - `{ detail: { value: string, event: Event } }`
|
|
129
|
+
|
|
130
|
+
### Card Component
|
|
42
131
|
|
|
43
132
|
```svelte
|
|
44
|
-
<
|
|
45
|
-
|
|
133
|
+
<Card
|
|
134
|
+
variant="default" | "elevated" | "outlined"
|
|
135
|
+
density="comfortable" | "compact"
|
|
136
|
+
disabled={boolean}
|
|
137
|
+
loading={boolean}
|
|
138
|
+
className={string}
|
|
139
|
+
on:click={(e) => console.log(e.detail.value, e.detail.event)}
|
|
140
|
+
>
|
|
141
|
+
<div slot="header">Header Content</div>
|
|
142
|
+
Main Content
|
|
143
|
+
<div slot="footer">Footer Content</div>
|
|
144
|
+
</Card>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Props:**
|
|
148
|
+
- `variant`: Card style variant (default: "default")
|
|
149
|
+
- `density`: Card density (default: "comfortable")
|
|
150
|
+
- `disabled`: Disable interactions (default: false)
|
|
151
|
+
- `loading`: Show loading state (default: false)
|
|
152
|
+
- `className`: Additional CSS classes
|
|
153
|
+
|
|
154
|
+
**Slots:**
|
|
155
|
+
- `header`: Card header content
|
|
156
|
+
- `default`: Main card content
|
|
157
|
+
- `footer`: Card footer content
|
|
158
|
+
|
|
159
|
+
**Events:**
|
|
160
|
+
- `click`: Fired when card is clicked - `{ detail: { value: true, event: MouseEvent } }`
|
|
161
|
+
|
|
162
|
+
### Alert Component
|
|
163
|
+
|
|
164
|
+
```svelte
|
|
165
|
+
<Alert
|
|
166
|
+
variant="info" | "success" | "warning" | "error"
|
|
167
|
+
title={string}
|
|
168
|
+
message={string}
|
|
169
|
+
closable={boolean}
|
|
170
|
+
className={string}
|
|
171
|
+
on:close={(e) => console.log(e.detail.value, e.detail.event)}
|
|
172
|
+
>
|
|
173
|
+
Custom Alert Content
|
|
174
|
+
</Alert>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Props:**
|
|
178
|
+
- `variant`: Alert type (default: "info")
|
|
179
|
+
- `title`: Alert title
|
|
180
|
+
- `message`: Alert message
|
|
181
|
+
- `closable`: Show close button (default: false)
|
|
182
|
+
- `className`: Additional CSS classes
|
|
183
|
+
|
|
184
|
+
**Slots:**
|
|
185
|
+
- `default`: Custom alert content (overrides message prop)
|
|
186
|
+
|
|
187
|
+
**Events:**
|
|
188
|
+
- `close`: Fired when alert is closed - `{ detail: { value: true, event: Event } }`
|
|
189
|
+
|
|
190
|
+
## Theming
|
|
191
|
+
|
|
192
|
+
Zabi Components uses CSS custom properties for easy theming. You can customize the appearance by overriding these variables:
|
|
193
|
+
|
|
194
|
+
```css
|
|
195
|
+
:root {
|
|
196
|
+
/* Primary Colors */
|
|
197
|
+
--zabi-primary: theme('colors.blue.600');
|
|
198
|
+
--zabi-primary-hover: theme('colors.blue.700');
|
|
199
|
+
--zabi-primary-active: theme('colors.blue.800');
|
|
46
200
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
201
|
+
/* Secondary Colors */
|
|
202
|
+
--zabi-secondary: theme('colors.gray.600');
|
|
203
|
+
--zabi-secondary-hover: theme('colors.gray.700');
|
|
204
|
+
|
|
205
|
+
/* Success Colors */
|
|
206
|
+
--zabi-success: theme('colors.green.600');
|
|
207
|
+
--zabi-success-hover: theme('colors.green.700');
|
|
208
|
+
|
|
209
|
+
/* Warning Colors */
|
|
210
|
+
--zabi-warning: theme('colors.yellow.600');
|
|
211
|
+
--zabi-warning-hover: theme('colors.yellow.700');
|
|
212
|
+
|
|
213
|
+
/* Error Colors */
|
|
214
|
+
--zabi-error: theme('colors.red.600');
|
|
215
|
+
--zabi-error-hover: theme('colors.red.700');
|
|
216
|
+
|
|
217
|
+
/* Info Colors */
|
|
218
|
+
--zabi-info: theme('colors.blue.600');
|
|
219
|
+
--zabi-info-hover: theme('colors.blue.700');
|
|
220
|
+
|
|
221
|
+
/* Surface Colors */
|
|
222
|
+
--zabi-surface: theme('colors.white');
|
|
223
|
+
--zabi-surface-hover: theme('colors.gray.50');
|
|
224
|
+
|
|
225
|
+
/* Border Colors */
|
|
226
|
+
--zabi-border: theme('colors.gray.300');
|
|
227
|
+
--zabi-border-hover: theme('colors.gray.400');
|
|
228
|
+
--zabi-border-focus: theme('colors.blue.500');
|
|
229
|
+
|
|
230
|
+
/* Text Colors */
|
|
231
|
+
--zabi-text: theme('colors.gray.900');
|
|
232
|
+
--zabi-text-muted: theme('colors.gray.600');
|
|
233
|
+
--zabi-text-placeholder: theme('colors.gray.400');
|
|
234
|
+
--zabi-text-inverse: theme('colors.white');
|
|
235
|
+
}
|
|
236
|
+
```
|
|
50
237
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
</Button>
|
|
238
|
+
### Dark Mode
|
|
239
|
+
|
|
240
|
+
Dark mode is automatically supported through CSS custom properties:
|
|
55
241
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
242
|
+
```css
|
|
243
|
+
.dark {
|
|
244
|
+
--zabi-surface: theme('colors.gray.900');
|
|
245
|
+
--zabi-surface-hover: theme('colors.gray.800');
|
|
246
|
+
--zabi-text: theme('colors.gray.100');
|
|
247
|
+
--zabi-text-muted: theme('colors.gray.400');
|
|
248
|
+
--zabi-border: theme('colors.gray.700');
|
|
249
|
+
}
|
|
61
250
|
```
|
|
62
251
|
|
|
63
|
-
##
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
- `
|
|
76
|
-
- `
|
|
77
|
-
- `
|
|
78
|
-
- `TextAlignment` - Text alignment controls
|
|
79
|
-
- `Toggle` - Switch controls
|
|
80
|
-
|
|
81
|
-
### Molecules
|
|
82
|
-
Simple combinations of atoms:
|
|
83
|
-
- `Alert` - Notification messages
|
|
84
|
-
- `Modal` - Overlay dialogs
|
|
85
|
-
- `FileUpload` - File upload interface
|
|
86
|
-
- `DynamicForm` - Dynamic form builder
|
|
87
|
-
- `Dropdown` - Dropdown menus
|
|
88
|
-
- `SlideUp` - Slide-up animations
|
|
89
|
-
|
|
90
|
-
### Organisms
|
|
91
|
-
Complex components with state management:
|
|
92
|
-
- `ToastContainer` - Notification management system
|
|
252
|
+
## Event Structure
|
|
253
|
+
|
|
254
|
+
All components follow a consistent event structure:
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
interface BaseEventDetail<T = any> {
|
|
258
|
+
value: T;
|
|
259
|
+
event?: Event;
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
**Examples:**
|
|
264
|
+
- Button click: `{ detail: { value: true, event: MouseEvent } }`
|
|
265
|
+
- Input change: `{ detail: { value: string, event: Event } }`
|
|
266
|
+
- Checkbox change: `{ detail: { value: boolean, event: Event } }`
|
|
93
267
|
|
|
94
268
|
## TypeScript Support
|
|
95
269
|
|
|
96
|
-
|
|
270
|
+
Full TypeScript definitions are included:
|
|
97
271
|
|
|
98
272
|
```typescript
|
|
99
|
-
import type {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
label: 'Email Address',
|
|
106
|
-
required: true
|
|
107
|
-
}
|
|
108
|
-
];
|
|
273
|
+
import type { ButtonEvents, InputEvents, CardEvents, AlertEvents } from 'zabi-components';
|
|
274
|
+
|
|
275
|
+
// Event handlers with proper typing
|
|
276
|
+
function handleButtonClick(event: CustomEvent<{ value: boolean; event?: MouseEvent }>) {
|
|
277
|
+
console.log('Button clicked:', event.detail.value);
|
|
278
|
+
}
|
|
109
279
|
```
|
|
110
280
|
|
|
111
|
-
##
|
|
281
|
+
## Advanced Usage
|
|
112
282
|
|
|
113
|
-
|
|
283
|
+
### Custom Styling
|
|
114
284
|
|
|
115
|
-
```
|
|
116
|
-
|
|
285
|
+
```svelte
|
|
286
|
+
<Button
|
|
287
|
+
variant="primary"
|
|
288
|
+
size="lg"
|
|
289
|
+
className="w-full shadow-lg hover:shadow-xl"
|
|
290
|
+
on:click={(e) => console.log('Clicked!', e.detail.value)}
|
|
291
|
+
>
|
|
292
|
+
Custom Button
|
|
293
|
+
</Button>
|
|
117
294
|
```
|
|
118
295
|
|
|
119
|
-
|
|
296
|
+
### Form Integration
|
|
120
297
|
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
|
|
298
|
+
```svelte
|
|
299
|
+
<script>
|
|
300
|
+
import { Button, Input, Card, Alert } from 'zabi-components';
|
|
301
|
+
|
|
302
|
+
let formData = {
|
|
303
|
+
name: '',
|
|
304
|
+
email: '',
|
|
305
|
+
message: ''
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
let errors = {};
|
|
309
|
+
let showSuccess = false;
|
|
310
|
+
|
|
311
|
+
function validateForm() {
|
|
312
|
+
errors = {};
|
|
313
|
+
if (!formData.name) errors.name = 'Name is required';
|
|
314
|
+
if (!formData.email) errors.email = 'Email is required';
|
|
315
|
+
return Object.keys(errors).length === 0;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function handleSubmit() {
|
|
319
|
+
if (validateForm()) {
|
|
320
|
+
showSuccess = true;
|
|
321
|
+
// Submit form
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
</script>
|
|
325
|
+
|
|
326
|
+
<Card>
|
|
327
|
+
<div slot="header">
|
|
328
|
+
<h2>Contact Form</h2>
|
|
329
|
+
</div>
|
|
330
|
+
|
|
331
|
+
<form on:submit|preventDefault={handleSubmit}>
|
|
332
|
+
<Input
|
|
333
|
+
bind:value={formData.name}
|
|
334
|
+
label="Name"
|
|
335
|
+
placeholder="Enter your name"
|
|
336
|
+
required
|
|
337
|
+
error={errors.name}
|
|
338
|
+
/>
|
|
339
|
+
|
|
340
|
+
<Input
|
|
341
|
+
bind:value={formData.email}
|
|
342
|
+
type="email"
|
|
343
|
+
label="Email"
|
|
344
|
+
placeholder="Enter your email"
|
|
345
|
+
required
|
|
346
|
+
error={errors.email}
|
|
347
|
+
/>
|
|
348
|
+
|
|
349
|
+
<Input
|
|
350
|
+
bind:value={formData.message}
|
|
351
|
+
label="Message"
|
|
352
|
+
placeholder="Enter your message"
|
|
353
|
+
helpText="Tell us what you think"
|
|
354
|
+
/>
|
|
355
|
+
|
|
356
|
+
<Button type="submit" variant="primary">
|
|
357
|
+
Send Message
|
|
358
|
+
</Button>
|
|
359
|
+
</form>
|
|
360
|
+
|
|
361
|
+
<div slot="footer">
|
|
362
|
+
<Alert variant="success" closable bind:show={showSuccess}>
|
|
363
|
+
Message sent successfully!
|
|
364
|
+
</Alert>
|
|
365
|
+
</div>
|
|
366
|
+
</Card>
|
|
367
|
+
```
|
|
124
368
|
|
|
125
|
-
|
|
126
|
-
npm run dev
|
|
369
|
+
## Contributing
|
|
127
370
|
|
|
128
|
-
|
|
129
|
-
|
|
371
|
+
1. Fork the repository
|
|
372
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
373
|
+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
374
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
375
|
+
5. Open a Pull Request
|
|
130
376
|
|
|
131
|
-
|
|
132
|
-
npm run storybook
|
|
133
|
-
```
|
|
377
|
+
## License
|
|
134
378
|
|
|
135
|
-
|
|
379
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
136
380
|
|
|
137
|
-
|
|
381
|
+
## Support
|
|
138
382
|
|
|
139
|
-
|
|
140
|
-
2. **Build the library**: `npm run build:lib`
|
|
141
|
-
3. **Test locally**: `npm pack` to create a tarball
|
|
142
|
-
4. **Publish**: `npm publish`
|
|
383
|
+
For support, please open an issue on GitHub or contact the maintainers.
|
|
143
384
|
|
|
144
|
-
|
|
385
|
+
---
|
|
145
386
|
|
|
146
|
-
|
|
387
|
+
Built with ❤️ using Svelte, TypeScript, and Tailwind CSS.
|