sveltacular 1.0.6 → 1.0.7
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 +232 -28
- package/dist/forms/bool-box/bool-box.svelte +21 -2
- package/dist/forms/bool-box/bool-box.svelte.d.ts +5 -0
- package/dist/forms/check-box/check-box-group.svelte +1 -0
- package/dist/forms/check-box/check-box.svelte +73 -31
- package/dist/forms/check-box/check-box.svelte.d.ts +7 -0
- package/dist/forms/date-box/date-box.svelte +7 -3
- package/dist/forms/date-box/date-box.svelte.d.ts +3 -0
- package/dist/forms/file-box/file-box.svelte +33 -7
- package/dist/forms/form-field/form-field.svelte +128 -33
- package/dist/forms/form-field/form-field.svelte.d.ts +9 -3
- package/dist/forms/form-label/form-label.svelte +4 -2
- package/dist/forms/form-label/form-label.svelte.d.ts +2 -2
- package/dist/forms/info-box/info-box.svelte +9 -7
- package/dist/forms/list-box/list-box.svelte +270 -89
- package/dist/forms/list-box/list-box.svelte.d.ts +3 -0
- package/dist/forms/money-box/money-box.svelte +20 -16
- package/dist/forms/number-box/number-box.svelte +16 -3
- package/dist/forms/number-box/number-box.svelte.d.ts +6 -0
- package/dist/forms/phone-box/phone-box.svelte +17 -3
- package/dist/forms/phone-box/phone-box.svelte.d.ts +5 -0
- package/dist/forms/radio-group/radio-box.svelte +11 -2
- package/dist/forms/radio-group/radio-box.svelte.d.ts +1 -0
- package/dist/forms/radio-group/radio-group.svelte +10 -4
- package/dist/forms/radio-group/radio-group.svelte.d.ts +4 -0
- package/dist/forms/switch-box/switch-box.svelte +33 -13
- package/dist/forms/switch-box/switch-box.svelte.d.ts +6 -0
- package/dist/forms/tag-input-box/tag-input-box.svelte +8 -7
- package/dist/forms/tag-input-box/tag-input-box.svelte.d.ts +2 -1
- package/dist/forms/text-area/text-area.svelte +19 -3
- package/dist/forms/text-area/text-area.svelte.d.ts +7 -0
- package/dist/forms/text-box/text-box.svelte +18 -15
- package/dist/forms/text-box/text-box.svelte.d.ts +2 -2
- package/dist/forms/time-box/time-box.svelte +7 -3
- package/dist/forms/time-box/time-box.svelte.d.ts +3 -0
- package/dist/forms/url-box/url-box.svelte +31 -1
- package/dist/forms/url-box/url-box.svelte.d.ts +10 -0
- package/dist/generic/avatar/avatar.svelte +1 -0
- package/dist/generic/chip/chip.svelte +1 -0
- package/dist/generic/menu/menu.svelte +2 -3
- package/dist/navigation/context-menu/README.md +1 -0
- package/dist/navigation/context-menu/context-menu-divider.svelte +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
-
Sveltacular is a TypeScript and SASS based component library for Svelte 5, with
|
|
3
|
+
Sveltacular is a comprehensive TypeScript and SASS based component library for Svelte 5, with **zero runtime dependencies**.
|
|
4
4
|
|
|
5
5
|
Why did I create it when there are other options? Well, mainly because the best options out there were based on Tailwind. And, no disrespect to those who love it, but I didn't want to use Tailwind. So since I didn't find what I was looking for, I made my own.
|
|
6
6
|
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- ✅ **100+ Components** - Comprehensive component library covering forms, navigation, modals, tables, and more
|
|
10
|
+
- ✅ **Zero Dependencies** - Built with pure Svelte 5, TypeScript, and SASS
|
|
11
|
+
- ✅ **Fully Accessible** - WCAG 2.1 AA compliant with ARIA support and keyboard navigation
|
|
12
|
+
- ✅ **Svelte 5 Native** - Uses modern runes (`$state`, `$derived`, `$props`) throughout
|
|
13
|
+
- ✅ **TypeScript** - Full type safety with comprehensive type definitions
|
|
14
|
+
- ✅ **Themable** - CSS custom properties for easy customization
|
|
15
|
+
- ✅ **Well Tested** - Unit tests, E2E tests, and comprehensive test utilities
|
|
16
|
+
- ✅ **Storybook** - Interactive documentation for all components
|
|
17
|
+
|
|
7
18
|
## Installation
|
|
8
19
|
|
|
9
20
|
```bash
|
|
@@ -48,57 +59,95 @@ npm i sveltacular
|
|
|
48
59
|
|
|
49
60
|
### Forms
|
|
50
61
|
|
|
51
|
-
- **Button** - Multiple variants (primary, secondary, positive, danger, outline)
|
|
52
|
-
- **TextBox** - Text input with validation and
|
|
62
|
+
- **Button** - Multiple variants (primary, secondary, positive, danger, outline) with loading states
|
|
63
|
+
- **TextBox** - Text input with validation, success states, loading indicators, and character counting
|
|
53
64
|
- **NumberBox** - Number input with min/max/decimals
|
|
54
|
-
- **
|
|
55
|
-
- **
|
|
65
|
+
- **NumberRangeBox** - Range input for min/max values
|
|
66
|
+
- **TextArea** - Multi-line text input with auto-resize support
|
|
67
|
+
- **CheckBox** / **CheckBoxGroup** - Checkbox inputs with grouping
|
|
56
68
|
- **RadioGroup** / **RadioBox** - Radio button inputs
|
|
57
|
-
- **ListBox** - Dropdown/select with search
|
|
69
|
+
- **ListBox** - Dropdown/select with search and virtual scrolling
|
|
58
70
|
- **DateBox** - Date picker
|
|
59
71
|
- **TimeBox** - Time picker
|
|
60
|
-
- **PhoneBox** - Phone number input
|
|
61
|
-
- **FileBox** / **FileArea** - File upload
|
|
62
|
-
- **Slider** - Range slider
|
|
72
|
+
- **PhoneBox** - Phone number input with formatting
|
|
73
|
+
- **FileBox** / **FileArea** - File upload with drag-and-drop
|
|
74
|
+
- **Slider** - Range slider with tooltip and value display
|
|
75
|
+
- **SwitchBox** - Toggle switch component
|
|
76
|
+
- **BoolBox** - Boolean input component
|
|
77
|
+
- **MoneyBox** - Currency input with formatting
|
|
78
|
+
- **TagInputBox** - Tag input with chip display
|
|
79
|
+
- **UrlBox** - URL input with validation
|
|
80
|
+
- **InfoBox** - Information display box
|
|
81
|
+
- **NewOrExistingCombo** - Combo component for new/existing selection
|
|
63
82
|
- **Form** - Form container with validation
|
|
83
|
+
- **FormField** - Form field wrapper with label and error handling
|
|
84
|
+
- **FormLabel** - Accessible form label
|
|
85
|
+
- **FormRow** - Form row layout
|
|
86
|
+
- **FormSection** - Form section grouping
|
|
87
|
+
- **FormHeader** / **FormFooter** - Form header and footer components
|
|
64
88
|
|
|
65
89
|
### Generic Components
|
|
66
90
|
|
|
67
|
-
- **Card** - Card container
|
|
91
|
+
- **Card** - Card container with variants
|
|
68
92
|
- **Pill** - Badge/pill component
|
|
69
93
|
- **Badge** - Notification badge
|
|
70
94
|
- **Avatar** - User avatar with initials fallback
|
|
71
|
-
- **Tooltip** - Hover tooltip
|
|
72
|
-
- **Popover** - Popover dialog
|
|
95
|
+
- **Tooltip** - Hover tooltip with positioning
|
|
96
|
+
- **Popover** - Popover dialog with smart positioning
|
|
73
97
|
- **Spinner** - Loading spinner
|
|
74
98
|
- **Rating** - Star rating component
|
|
75
99
|
- **Chip** - Removable tag/chip
|
|
76
100
|
- **Notice** - Alert/notice component
|
|
77
|
-
- **Menu** - Dropdown menu
|
|
78
|
-
- **List** - Styled list component
|
|
101
|
+
- **Menu** - Dropdown menu with keyboard navigation
|
|
102
|
+
- **List** - Styled list component with variants
|
|
103
|
+
- **Empty** - Empty state component
|
|
104
|
+
- **Divider** - Visual divider/separator
|
|
105
|
+
- **Dot** - Status dot indicator
|
|
106
|
+
- **Panel** - Panel container
|
|
107
|
+
- **Section** - Section container
|
|
108
|
+
- **Header** - Header component
|
|
109
|
+
- **Link** - Styled link component
|
|
110
|
+
- **Email** - Email display component
|
|
111
|
+
- **Phone** - Phone number display
|
|
112
|
+
- **Address** - Address display component
|
|
113
|
+
- **DateTime** - Date/time display
|
|
114
|
+
- **Scorecard** - Scorecard/metric display
|
|
115
|
+
- **Toaster** - Toast notification system
|
|
116
|
+
- **Overlay** - Overlay component
|
|
117
|
+
- **DropdownItem** - Dropdown menu item
|
|
118
|
+
- **ThemeProvider** - Theme provider component
|
|
79
119
|
|
|
80
120
|
### Navigation
|
|
81
121
|
|
|
82
|
-
- **AppBar** - Application bar
|
|
122
|
+
- **AppBar** - Application bar with navigation
|
|
83
123
|
- **SideBar** - Side navigation
|
|
84
124
|
- **Breadcrumbs** - Breadcrumb navigation
|
|
85
|
-
- **Tabs** - Tab navigation
|
|
125
|
+
- **Tabs** - Tab navigation with keyboard support
|
|
86
126
|
- **Accordion** - Collapsible sections
|
|
87
127
|
- **Wizard** - Multi-step wizard
|
|
88
128
|
- **Pagination** - Page navigation
|
|
89
129
|
- **Drawer** - Slide-out drawer
|
|
130
|
+
- **CommandPalette** - Keyboard-driven command interface (⌘K / Ctrl+K) with fuzzy search
|
|
131
|
+
- **ContextMenu** - Right-click context menu with nested submenus
|
|
132
|
+
- **DropdownButton** - Button with dropdown menu
|
|
90
133
|
|
|
91
134
|
### Modals
|
|
92
135
|
|
|
93
|
-
- **Modal** - Generic modal dialog
|
|
136
|
+
- **Modal** - Generic modal dialog with focus trap
|
|
94
137
|
- **Alert** - Alert dialog
|
|
95
138
|
- **Confirm** - Confirmation dialog
|
|
96
139
|
- **Prompt** - Input prompt dialog
|
|
140
|
+
- **DialogWindow** - Dialog window component
|
|
141
|
+
- **DialogHeader** / **DialogBody** / **DialogFooter** - Dialog structure components
|
|
142
|
+
- **DialogCloseButton** - Dialog close button
|
|
97
143
|
|
|
98
144
|
### Tables
|
|
99
145
|
|
|
100
146
|
- **Table** - Table component with header/body/footer
|
|
101
|
-
- **DataGrid** - Advanced data grid
|
|
147
|
+
- **DataGrid** - Advanced data grid with sorting and formatting
|
|
148
|
+
- **TableRow** / **TableCell** - Table row and cell components
|
|
149
|
+
- **TableHeader** / **TableHeaderCell** - Table header components
|
|
150
|
+
- **TableCaption** - Table caption component
|
|
102
151
|
|
|
103
152
|
### Typography
|
|
104
153
|
|
|
@@ -106,12 +155,42 @@ npm i sveltacular
|
|
|
106
155
|
- **Subtitle** - Subtitle component
|
|
107
156
|
- **Text** - Text component
|
|
108
157
|
- **Paragraph** - Paragraph component
|
|
109
|
-
- **CodeBlock** - Code block
|
|
158
|
+
- **CodeBlock** - Code block with syntax highlighting
|
|
159
|
+
- **Code** - Inline code component
|
|
110
160
|
|
|
111
161
|
### Layout
|
|
112
162
|
|
|
113
|
-
- **FlexRow** / **FlexCol** - Flexbox layout
|
|
114
|
-
- **
|
|
163
|
+
- **FlexRow** / **FlexCol** - Flexbox layout components
|
|
164
|
+
- **FlexItem** - Flex item component
|
|
165
|
+
- **Grid** - Grid layout component
|
|
166
|
+
|
|
167
|
+
### Placeholders
|
|
168
|
+
|
|
169
|
+
- **Loading** - Loading placeholder
|
|
170
|
+
- **Progress** - Progress indicator
|
|
171
|
+
- **SkeletonText** - Text skeleton loader
|
|
172
|
+
- **SkeletonParagraph** - Paragraph skeleton loader
|
|
173
|
+
- **SkeletonInput** - Input skeleton loader
|
|
174
|
+
- **SkeletonTable** - Table skeleton loader
|
|
175
|
+
|
|
176
|
+
### Timeline
|
|
177
|
+
|
|
178
|
+
- **Timeline** - Timeline container
|
|
179
|
+
- **TimelineItem** - Timeline item component
|
|
180
|
+
|
|
181
|
+
### Images & Icons
|
|
182
|
+
|
|
183
|
+
- **Image** - Image component with lazy loading
|
|
184
|
+
- **Icon** - Icon component
|
|
185
|
+
- **SvgIcon** - SVG icon wrapper
|
|
186
|
+
- Built-in icons: AngleRightIcon, AngleUpIcon, CheckIcon, CopyIcon, EnvelopeIcon, FolderOpenIcon, HamburgerIcon, HomeIcon, LinkIcon, MobilePhoneIcon, PhoneIcon, UploadIcon
|
|
187
|
+
|
|
188
|
+
### Data
|
|
189
|
+
|
|
190
|
+
- **Countries** - Country data utilities
|
|
191
|
+
- **UnitedStates** - US states data
|
|
192
|
+
- **Canada** - Canadian provinces data
|
|
193
|
+
- **Colors** - Color utilities
|
|
115
194
|
|
|
116
195
|
## Import Patterns
|
|
117
196
|
|
|
@@ -195,14 +274,112 @@ if (!result.isValid) {
|
|
|
195
274
|
|
|
196
275
|
## Accessibility
|
|
197
276
|
|
|
198
|
-
Sveltacular components
|
|
277
|
+
Sveltacular is committed to **WCAG 2.1 AA compliance** across all components. Every component includes:
|
|
278
|
+
|
|
279
|
+
- ✅ **ARIA Attributes** - Proper roles, states, and properties for screen readers
|
|
280
|
+
- ✅ **Keyboard Navigation** - Full keyboard support for all interactive components
|
|
281
|
+
- ✅ **Focus Management** - Focus traps for modals, roving tabindex for menus
|
|
282
|
+
- ✅ **Screen Reader Support** - Live region announcements for dynamic content
|
|
283
|
+
- ✅ **Semantic HTML** - Proper HTML structure with meaningful elements
|
|
284
|
+
- ✅ **Color Contrast** - All components meet WCAG contrast requirements
|
|
285
|
+
- ✅ **Focus Indicators** - Visible focus rings for keyboard navigation
|
|
286
|
+
- ✅ **Reduced Motion** - Respects `prefers-reduced-motion` preference
|
|
287
|
+
|
|
288
|
+
See [ACCESSIBILITY.md](./ACCESSIBILITY.md) for detailed accessibility documentation and best practices.
|
|
289
|
+
|
|
290
|
+
## Form Enhancements
|
|
291
|
+
|
|
292
|
+
Sveltacular includes enhanced form components with modern UX features:
|
|
293
|
+
|
|
294
|
+
### TextBox Enhancements
|
|
199
295
|
|
|
200
|
-
-
|
|
201
|
-
-
|
|
202
|
-
-
|
|
203
|
-
- Semantic HTML structure
|
|
296
|
+
- **Success States** - Visual success feedback with animated checkmark
|
|
297
|
+
- **Loading Indicators** - Show loading spinner during async validation
|
|
298
|
+
- **Character Counting** - Display character count with visual warnings (90% yellow, 100% red)
|
|
204
299
|
|
|
205
|
-
|
|
300
|
+
### TextArea Enhancements
|
|
301
|
+
|
|
302
|
+
- **Auto-Resize** - Automatically grows/shrinks based on content
|
|
303
|
+
- **Min/Max Rows** - Configurable row constraints
|
|
304
|
+
|
|
305
|
+
### Slider Enhancements
|
|
306
|
+
|
|
307
|
+
- **Tooltip Display** - Show value tooltip on drag/focus
|
|
308
|
+
- **Value Display** - Optional value display below slider
|
|
309
|
+
- **Custom Formatting** - Format values with custom formatter function
|
|
310
|
+
|
|
311
|
+
### FileArea Enhancements
|
|
312
|
+
|
|
313
|
+
- **Enhanced Drag States** - Visual feedback with scale, glow, and transitions
|
|
314
|
+
- **Smooth Animations** - CSS-based animations for optimal performance
|
|
315
|
+
|
|
316
|
+
## Testing
|
|
317
|
+
|
|
318
|
+
Sveltacular includes comprehensive testing infrastructure:
|
|
319
|
+
|
|
320
|
+
### Unit Tests
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
npm run test # Run unit tests
|
|
324
|
+
npm run test:ui # Run with UI
|
|
325
|
+
npm run test:coverage # Run with coverage report
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### E2E Tests
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
npm run test:e2e # Run E2E tests
|
|
332
|
+
npm run test:e2e:ui # Run with UI
|
|
333
|
+
npm run test:e2e:debug # Debug mode
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### All Tests
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
npm run test:all # Run unit and E2E tests
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
See [TESTING.md](./TESTING.md) for comprehensive testing documentation.
|
|
343
|
+
|
|
344
|
+
## Helpers & Utilities
|
|
345
|
+
|
|
346
|
+
Sveltacular provides a rich set of helper utilities:
|
|
347
|
+
|
|
348
|
+
### Focus Management
|
|
349
|
+
|
|
350
|
+
- `createFocusTrap` - Trap focus within modals
|
|
351
|
+
- `RovingTabindexManager` - Manage keyboard navigation in lists/menus
|
|
352
|
+
|
|
353
|
+
### Screen Reader Announcements
|
|
354
|
+
|
|
355
|
+
- `announcePolite` - Polite announcements
|
|
356
|
+
- `announceError` - Error announcements
|
|
357
|
+
- `announceLoading` - Loading state announcements
|
|
358
|
+
|
|
359
|
+
### Search & Filtering
|
|
360
|
+
|
|
361
|
+
- `fuzzySearch` - Zero-dependency fuzzy search implementation
|
|
362
|
+
|
|
363
|
+
### Animation Helpers
|
|
364
|
+
|
|
365
|
+
- Animation actions for fade, scale, slide effects
|
|
366
|
+
- Spring animations
|
|
367
|
+
- Respects `prefers-reduced-motion`
|
|
368
|
+
|
|
369
|
+
### Other Utilities
|
|
370
|
+
|
|
371
|
+
- `debounce` - Debounce function calls
|
|
372
|
+
- `uniqueId` - Generate unique IDs
|
|
373
|
+
- `capitalize` / `ucfirst` - String utilities
|
|
374
|
+
- `ago` - Relative time formatting
|
|
375
|
+
- `roundToDecimals` - Number formatting
|
|
376
|
+
- Date utilities, positioning helpers, and more
|
|
377
|
+
|
|
378
|
+
See the [helpers documentation](./src/lib/helpers/) for the complete list.
|
|
379
|
+
|
|
380
|
+
## Development
|
|
381
|
+
|
|
382
|
+
### Run Storybook
|
|
206
383
|
|
|
207
384
|
Browse all available components and their props by running Storybook locally:
|
|
208
385
|
|
|
@@ -210,10 +387,37 @@ Browse all available components and their props by running Storybook locally:
|
|
|
210
387
|
npm run storybook
|
|
211
388
|
```
|
|
212
389
|
|
|
390
|
+
### Development Scripts
|
|
391
|
+
|
|
392
|
+
```bash
|
|
393
|
+
npm run dev # Start dev server
|
|
394
|
+
npm run build # Build for production
|
|
395
|
+
npm run check # Type check
|
|
396
|
+
npm run lint # Lint code
|
|
397
|
+
npm run format # Format code
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
## Documentation
|
|
401
|
+
|
|
402
|
+
- **[THEMING.md](./THEMING.md)** - Complete theming guide with all CSS variables
|
|
403
|
+
- **[ACCESSIBILITY.md](./ACCESSIBILITY.md)** - Accessibility features and best practices
|
|
404
|
+
- **[TESTING.md](./TESTING.md)** - Testing guide and utilities
|
|
405
|
+
- **[Storybook](http://localhost:6006)** - Interactive component documentation (run `npm run storybook`)
|
|
406
|
+
|
|
407
|
+
## Recent Updates
|
|
408
|
+
|
|
409
|
+
### Version 1.0.6
|
|
410
|
+
|
|
411
|
+
- ✅ **Command Palette** - Keyboard-driven command interface with fuzzy search
|
|
412
|
+
- ✅ **Context Menu** - Right-click menu with nested submenus
|
|
413
|
+
- ✅ **Form Enhancements** - Success states, loading indicators, character counting, auto-resize
|
|
414
|
+
- ✅ **Comprehensive Testing** - Unit tests, E2E tests, and test utilities
|
|
415
|
+
- ✅ **Accessibility Improvements** - Enhanced ARIA support and keyboard navigation
|
|
416
|
+
|
|
213
417
|
## Contributing
|
|
214
418
|
|
|
215
419
|
Contributions are welcome! Please see the contributing guidelines (coming soon).
|
|
216
420
|
|
|
217
421
|
## License
|
|
218
422
|
|
|
219
|
-
|
|
423
|
+
Apache-2.0
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import ListBox from '../list-box/list-box.svelte';
|
|
3
3
|
import type { FormFieldSizeOptions } from '../../index.js';
|
|
4
|
+
import type { FormFieldFeedback } from '../form-field/form-field.svelte';
|
|
4
5
|
|
|
5
6
|
let {
|
|
6
7
|
value = $bindable(false),
|
|
7
8
|
options = ['Yes', 'No'] as [yes: string, no: string],
|
|
8
9
|
size = 'md' as FormFieldSizeOptions,
|
|
9
10
|
onChange = undefined,
|
|
10
|
-
label = undefined
|
|
11
|
+
label = undefined,
|
|
12
|
+
helperText = undefined,
|
|
13
|
+
feedback = undefined,
|
|
14
|
+
disabled = false,
|
|
15
|
+
required = false
|
|
11
16
|
}: {
|
|
12
17
|
value?: boolean;
|
|
13
18
|
options?: [yes: string, no: string];
|
|
14
19
|
size?: FormFieldSizeOptions;
|
|
15
20
|
onChange?: ((value: boolean) => void) | undefined;
|
|
16
21
|
label?: string;
|
|
22
|
+
helperText?: string;
|
|
23
|
+
feedback?: FormFieldFeedback;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
required?: boolean;
|
|
17
26
|
} = $props();
|
|
18
27
|
|
|
19
28
|
let stringValue = $state(value ? 'true' : 'false');
|
|
@@ -29,4 +38,14 @@
|
|
|
29
38
|
]);
|
|
30
39
|
</script>
|
|
31
40
|
|
|
32
|
-
<ListBox
|
|
41
|
+
<ListBox
|
|
42
|
+
{items}
|
|
43
|
+
bind:value={stringValue}
|
|
44
|
+
{size}
|
|
45
|
+
onChange={handleChange}
|
|
46
|
+
{label}
|
|
47
|
+
{helperText}
|
|
48
|
+
{feedback}
|
|
49
|
+
{disabled}
|
|
50
|
+
{required}
|
|
51
|
+
/>
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type { FormFieldSizeOptions } from '../../index.js';
|
|
2
|
+
import type { FormFieldFeedback } from '../form-field/form-field.svelte';
|
|
2
3
|
type $$ComponentProps = {
|
|
3
4
|
value?: boolean;
|
|
4
5
|
options?: [yes: string, no: string];
|
|
5
6
|
size?: FormFieldSizeOptions;
|
|
6
7
|
onChange?: ((value: boolean) => void) | undefined;
|
|
7
8
|
label?: string;
|
|
9
|
+
helperText?: string;
|
|
10
|
+
feedback?: FormFieldFeedback;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
required?: boolean;
|
|
8
13
|
};
|
|
9
14
|
declare const BoolBox: import("svelte").Component<$$ComponentProps, {}, "value">;
|
|
10
15
|
type BoolBox = ReturnType<typeof BoolBox>;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
import { uniqueId } from '../../helpers/unique-id.js';
|
|
4
4
|
import CheckIcon from '../../icons/check-icon.svelte';
|
|
5
|
+
import FormField, { type FormFieldFeedback } from '../form-field/form-field.svelte';
|
|
6
|
+
import type { FormFieldSizeOptions } from '../../types/form.js';
|
|
5
7
|
|
|
6
8
|
let {
|
|
7
9
|
value = '',
|
|
@@ -10,7 +12,12 @@
|
|
|
10
12
|
name = undefined,
|
|
11
13
|
onChange = undefined,
|
|
12
14
|
label,
|
|
13
|
-
children
|
|
15
|
+
children,
|
|
16
|
+
size = 'full' as FormFieldSizeOptions,
|
|
17
|
+
helperText = undefined,
|
|
18
|
+
feedback = undefined,
|
|
19
|
+
required = false,
|
|
20
|
+
inline = false
|
|
14
21
|
}: {
|
|
15
22
|
value?: string;
|
|
16
23
|
isChecked?: boolean;
|
|
@@ -19,6 +26,11 @@
|
|
|
19
26
|
onChange?: ((data: { isChecked: boolean; value: string }) => void) | undefined;
|
|
20
27
|
label?: string;
|
|
21
28
|
children?: Snippet;
|
|
29
|
+
size?: FormFieldSizeOptions;
|
|
30
|
+
helperText?: string;
|
|
31
|
+
feedback?: FormFieldFeedback;
|
|
32
|
+
required?: boolean;
|
|
33
|
+
inline?: boolean;
|
|
22
34
|
} = $props();
|
|
23
35
|
|
|
24
36
|
const id = uniqueId();
|
|
@@ -33,43 +45,73 @@
|
|
|
33
45
|
};
|
|
34
46
|
</script>
|
|
35
47
|
|
|
36
|
-
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
</
|
|
48
|
+
{#if inline}
|
|
49
|
+
<label class="checkbox-label">
|
|
50
|
+
<input
|
|
51
|
+
type="checkbox"
|
|
52
|
+
{id}
|
|
53
|
+
{disabled}
|
|
54
|
+
{name}
|
|
55
|
+
{value}
|
|
56
|
+
bind:checked={isChecked}
|
|
57
|
+
onchange={onChecked}
|
|
58
|
+
{required}
|
|
59
|
+
/>
|
|
60
|
+
<span class="checkbox">
|
|
61
|
+
<span class="checkmark"><CheckIcon /></span>
|
|
62
|
+
</span>
|
|
63
|
+
{#if children}
|
|
64
|
+
<div class="text">
|
|
65
|
+
{@render children()}
|
|
66
|
+
</div>
|
|
67
|
+
{:else if label}
|
|
68
|
+
<div class="text">
|
|
69
|
+
{label}
|
|
70
|
+
</div>
|
|
71
|
+
{/if}
|
|
72
|
+
</label>
|
|
73
|
+
{:else}
|
|
74
|
+
<FormField {size} {label} {id} {required} {disabled} {helperText} {feedback}>
|
|
75
|
+
<label class="checkbox-label">
|
|
76
|
+
<input
|
|
77
|
+
type="checkbox"
|
|
78
|
+
{id}
|
|
79
|
+
{disabled}
|
|
80
|
+
{name}
|
|
81
|
+
{value}
|
|
82
|
+
bind:checked={isChecked}
|
|
83
|
+
onchange={onChecked}
|
|
84
|
+
{required}
|
|
85
|
+
/>
|
|
86
|
+
<span class="checkbox">
|
|
87
|
+
<span class="checkmark"><CheckIcon /></span>
|
|
88
|
+
</span>
|
|
89
|
+
{#if children}
|
|
90
|
+
<div class="text">
|
|
91
|
+
{@render children()}
|
|
92
|
+
</div>
|
|
93
|
+
{:else if label}
|
|
94
|
+
<div class="text">
|
|
95
|
+
{label}
|
|
96
|
+
</div>
|
|
97
|
+
{/if}
|
|
98
|
+
</label>
|
|
99
|
+
</FormField>
|
|
100
|
+
{/if}
|
|
59
101
|
|
|
60
|
-
<style
|
|
102
|
+
<style>.checkbox-label {
|
|
61
103
|
display: flex;
|
|
62
104
|
align-items: center;
|
|
63
105
|
justify-content: flex-start;
|
|
64
106
|
cursor: pointer;
|
|
65
107
|
}
|
|
66
|
-
label .text {
|
|
108
|
+
.checkbox-label .text {
|
|
67
109
|
display: block;
|
|
68
110
|
margin-left: var(--spacing-sm);
|
|
69
111
|
font-size: var(--font-md);
|
|
70
112
|
line-height: 2rem;
|
|
71
113
|
}
|
|
72
|
-
label .checkbox {
|
|
114
|
+
.checkbox-label .checkbox {
|
|
73
115
|
position: relative;
|
|
74
116
|
display: block;
|
|
75
117
|
width: var(--spacing-base);
|
|
@@ -80,7 +122,7 @@ label .checkbox {
|
|
|
80
122
|
transition: background-color var(--transition-base) var(--ease-in-out), border-color var(--transition-base) var(--ease-in-out), color var(--transition-base) var(--ease-in-out), fill var(--transition-base) var(--ease-in-out), stroke var(--transition-base) var(--ease-in-out);
|
|
81
123
|
user-select: none;
|
|
82
124
|
}
|
|
83
|
-
label .checkbox .checkmark {
|
|
125
|
+
.checkbox-label .checkbox .checkmark {
|
|
84
126
|
display: block;
|
|
85
127
|
position: absolute;
|
|
86
128
|
top: 0;
|
|
@@ -94,15 +136,15 @@ label .checkbox .checkmark {
|
|
|
94
136
|
stroke: var(--form-input-selected-fg);
|
|
95
137
|
transition: width var(--transition-base) var(--ease-in-out), height var(--transition-base) var(--ease-in-out);
|
|
96
138
|
}
|
|
97
|
-
label input {
|
|
139
|
+
.checkbox-label input {
|
|
98
140
|
width: 0;
|
|
99
141
|
height: 0;
|
|
100
142
|
}
|
|
101
|
-
label input:checked + .checkbox {
|
|
143
|
+
.checkbox-label input:checked + .checkbox {
|
|
102
144
|
background-color: var(--form-input-bg);
|
|
103
145
|
border-color: var(--form-input-border);
|
|
104
146
|
}
|
|
105
|
-
label input:checked + .checkbox .checkmark {
|
|
147
|
+
.checkbox-label input:checked + .checkbox .checkmark {
|
|
106
148
|
width: 100%;
|
|
107
149
|
height: 100%;
|
|
108
150
|
}</style>
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type FormFieldFeedback } from '../form-field/form-field.svelte';
|
|
3
|
+
import type { FormFieldSizeOptions } from '../../types/form.js';
|
|
2
4
|
type $$ComponentProps = {
|
|
3
5
|
value?: string;
|
|
4
6
|
isChecked?: boolean;
|
|
@@ -10,6 +12,11 @@ type $$ComponentProps = {
|
|
|
10
12
|
}) => void) | undefined;
|
|
11
13
|
label?: string;
|
|
12
14
|
children?: Snippet;
|
|
15
|
+
size?: FormFieldSizeOptions;
|
|
16
|
+
helperText?: string;
|
|
17
|
+
feedback?: FormFieldFeedback;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
inline?: boolean;
|
|
13
20
|
};
|
|
14
21
|
declare const CheckBox: import("svelte").Component<$$ComponentProps, {}, "isChecked">;
|
|
15
22
|
type CheckBox = ReturnType<typeof CheckBox>;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
isDateTimeString
|
|
9
9
|
} from '../../helpers/date.js';
|
|
10
10
|
import { uniqueId } from '../../helpers/unique-id.js';
|
|
11
|
-
import FormField from '../form-field/form-field.svelte';
|
|
11
|
+
import FormField, { type FormFieldFeedback } from '../form-field/form-field.svelte';
|
|
12
12
|
import type { DateUnit, FormFieldSizeOptions } from '../../index.js';
|
|
13
13
|
import Button from '../button/button.svelte';
|
|
14
14
|
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
steps = [] as DateIncrementStep[],
|
|
29
29
|
onChange = undefined,
|
|
30
30
|
onCheckChanged = undefined,
|
|
31
|
-
label = undefined
|
|
31
|
+
label = undefined,
|
|
32
|
+
helperText = undefined,
|
|
33
|
+
feedback = undefined
|
|
32
34
|
}: {
|
|
33
35
|
value?: string | undefined | null;
|
|
34
36
|
defaultValue?: string | undefined;
|
|
@@ -42,6 +44,8 @@
|
|
|
42
44
|
onChange?: ((value: string | null) => void) | undefined;
|
|
43
45
|
onCheckChanged?: ((enabled: boolean) => void) | undefined;
|
|
44
46
|
label?: string;
|
|
47
|
+
helperText?: string;
|
|
48
|
+
feedback?: FormFieldFeedback;
|
|
45
49
|
} = $props();
|
|
46
50
|
|
|
47
51
|
const getDefaultValue = () => {
|
|
@@ -84,7 +88,7 @@
|
|
|
84
88
|
let disabled = $derived(!enabled);
|
|
85
89
|
</script>
|
|
86
90
|
|
|
87
|
-
<FormField {size} {label} {id} {required} {disabled}>
|
|
91
|
+
<FormField {size} {label} {id} {required} {disabled} {helperText} {feedback}>
|
|
88
92
|
<div class:nullable class:disabled>
|
|
89
93
|
<span class="input">
|
|
90
94
|
<input {...{ type }} {id} {placeholder} {disabled} bind:value {required} oninput={onInput} />
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type FormFieldFeedback } from '../form-field/form-field.svelte';
|
|
1
2
|
import type { DateUnit, FormFieldSizeOptions } from '../../index.js';
|
|
2
3
|
type DateIncrementStep = {
|
|
3
4
|
label: string;
|
|
@@ -17,6 +18,8 @@ type $$ComponentProps = {
|
|
|
17
18
|
onChange?: ((value: string | null) => void) | undefined;
|
|
18
19
|
onCheckChanged?: ((enabled: boolean) => void) | undefined;
|
|
19
20
|
label?: string;
|
|
21
|
+
helperText?: string;
|
|
22
|
+
feedback?: FormFieldFeedback;
|
|
20
23
|
};
|
|
21
24
|
declare const DateBox: import("svelte").Component<$$ComponentProps, {}, "value" | "enabled">;
|
|
22
25
|
type DateBox = ReturnType<typeof DateBox>;
|