@velkymx/vibeui 0.8.0 → 0.8.2
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/CLAUDE.md +48 -0
- package/dist/vibeui.css +1 -1
- package/dist/vibeui.es.js +149 -148
- package/dist/vibeui.umd.js +1 -1
- package/docs/README.md +153 -0
- package/docs/components/advanced/popover.md +150 -0
- package/docs/components/advanced/scrollspy.md +64 -0
- package/docs/components/advanced/tooltip.md +111 -0
- package/docs/components/card/card.md +215 -0
- package/docs/components/core/alert.md +72 -0
- package/docs/components/core/badge.md +81 -0
- package/docs/components/core/button-group.md +105 -0
- package/docs/components/core/button.md +127 -0
- package/docs/components/core/close-button.md +82 -0
- package/docs/components/core/link.md +36 -0
- package/docs/components/core/placeholder.md +135 -0
- package/docs/components/core/spinner.md +109 -0
- package/docs/components/data/datatable.md +416 -0
- package/docs/components/interactive/accordion.md +92 -0
- package/docs/components/interactive/carousel.md +97 -0
- package/docs/components/interactive/collapse.md +105 -0
- package/docs/components/interactive/dropdown.md +93 -0
- package/docs/components/interactive/modal.md +148 -0
- package/docs/components/interactive/offcanvas.md +89 -0
- package/docs/components/interactive/toast.md +114 -0
- package/docs/components/layout/col.md +123 -0
- package/docs/components/layout/container.md +59 -0
- package/docs/components/layout/row.md +113 -0
- package/docs/components/list/list-group.md +221 -0
- package/docs/components/navigation/breadcrumb.md +116 -0
- package/docs/components/navigation/nav.md +88 -0
- package/docs/components/navigation/navbar.md +106 -0
- package/docs/components/navigation/pagination.md +146 -0
- package/docs/components/progress/progress.md +182 -0
- package/docs/composables/back-button.md +28 -0
- package/docs/composables/breakpoints.md +54 -0
- package/docs/composables/color-mode.md +141 -0
- package/docs/forms/README.md +88 -0
- package/docs/forms/form-checkbox.md +50 -0
- package/docs/forms/form-datepicker.md +50 -0
- package/docs/forms/form-group.md +80 -0
- package/docs/forms/form-input.md +55 -0
- package/docs/forms/form-radio.md +58 -0
- package/docs/forms/form-select.md +54 -0
- package/docs/forms/form-spinbutton.md +55 -0
- package/docs/forms/form-switch.md +47 -0
- package/docs/forms/form-textarea.md +51 -0
- package/docs/forms/form-wysiwyg.md +64 -0
- package/docs/forms/input-group.md +51 -0
- package/docs/forms/validation.md +599 -0
- package/llms.txt +422 -0
- package/package.json +5 -2
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# VibePagination
|
|
2
|
+
|
|
3
|
+
Data-driven pagination component with v-model support.
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Default | Description |
|
|
8
|
+
|------|------|---------|-------------|
|
|
9
|
+
| `size` | `'sm' \| 'lg'` | `undefined` | Pagination size |
|
|
10
|
+
| `ariaLabel` | `String` | `'Pagination'` | ARIA label for the nav element |
|
|
11
|
+
| `totalPages` | `Number` | Required | Total number of pages |
|
|
12
|
+
| `currentPage` | `Number` | `1` | Current active page |
|
|
13
|
+
| `showPrevNext` | `Boolean` | `true` | Show previous/next buttons |
|
|
14
|
+
| `prevText` | `String` | `'Previous'` | Text for previous button |
|
|
15
|
+
| `nextText` | `String` | `'Next'` | Text for next button |
|
|
16
|
+
|
|
17
|
+
## Events
|
|
18
|
+
|
|
19
|
+
| Event | Payload | Description |
|
|
20
|
+
|-------|---------|-------------|
|
|
21
|
+
| `update:currentPage` | `page: number` | Emitted when page changes (v-model) |
|
|
22
|
+
| `page-click` | `page: number` | Emitted when a page is clicked |
|
|
23
|
+
|
|
24
|
+
## Slots
|
|
25
|
+
|
|
26
|
+
| Slot | Scope | Description |
|
|
27
|
+
|------|-------|-------------|
|
|
28
|
+
| `prev` | `{ disabled }` | Custom previous button |
|
|
29
|
+
| `page` | `{ page, active }` | Custom page button |
|
|
30
|
+
| `next` | `{ disabled }` | Custom next button |
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
### Basic Example
|
|
35
|
+
|
|
36
|
+
```vue
|
|
37
|
+
<template>
|
|
38
|
+
<VibePagination
|
|
39
|
+
:total-pages="10"
|
|
40
|
+
v-model:current-page="currentPage"
|
|
41
|
+
/>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script setup>
|
|
45
|
+
import { ref } from 'vue'
|
|
46
|
+
|
|
47
|
+
const currentPage = ref(1)
|
|
48
|
+
</script>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Sizes
|
|
52
|
+
|
|
53
|
+
```vue
|
|
54
|
+
<template>
|
|
55
|
+
<!-- Small -->
|
|
56
|
+
<VibePagination :total-pages="5" size="sm" v-model:current-page="page1" />
|
|
57
|
+
|
|
58
|
+
<!-- Default -->
|
|
59
|
+
<VibePagination :total-pages="5" v-model:current-page="page2" />
|
|
60
|
+
|
|
61
|
+
<!-- Large -->
|
|
62
|
+
<VibePagination :total-pages="5" size="lg" v-model:current-page="page3" />
|
|
63
|
+
</template>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Without Prev/Next Buttons
|
|
67
|
+
|
|
68
|
+
```vue
|
|
69
|
+
<template>
|
|
70
|
+
<VibePagination
|
|
71
|
+
:total-pages="10"
|
|
72
|
+
:show-prev-next="false"
|
|
73
|
+
v-model:current-page="currentPage"
|
|
74
|
+
/>
|
|
75
|
+
</template>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Custom Button Text
|
|
79
|
+
|
|
80
|
+
```vue
|
|
81
|
+
<template>
|
|
82
|
+
<VibePagination
|
|
83
|
+
:total-pages="10"
|
|
84
|
+
prev-text="← Back"
|
|
85
|
+
next-text="Forward →"
|
|
86
|
+
v-model:current-page="currentPage"
|
|
87
|
+
/>
|
|
88
|
+
</template>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Custom Page Rendering
|
|
92
|
+
|
|
93
|
+
Use scoped slots for complete customization:
|
|
94
|
+
|
|
95
|
+
```vue
|
|
96
|
+
<template>
|
|
97
|
+
<VibePagination :total-pages="10" v-model:current-page="currentPage">
|
|
98
|
+
<template #prev="{ disabled }">
|
|
99
|
+
<VibeIcon icon="chevron-left" />
|
|
100
|
+
</template>
|
|
101
|
+
|
|
102
|
+
<template #page="{ page, active }">
|
|
103
|
+
Page {{ page }}
|
|
104
|
+
</template>
|
|
105
|
+
|
|
106
|
+
<template #next="{ disabled }">
|
|
107
|
+
<VibeIcon icon="chevron-right" />
|
|
108
|
+
</template>
|
|
109
|
+
</VibePagination>
|
|
110
|
+
</template>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### With Event Handling
|
|
114
|
+
|
|
115
|
+
```vue
|
|
116
|
+
<template>
|
|
117
|
+
<VibePagination
|
|
118
|
+
:total-pages="20"
|
|
119
|
+
v-model:current-page="currentPage"
|
|
120
|
+
@page-click="handlePageClick"
|
|
121
|
+
/>
|
|
122
|
+
|
|
123
|
+
<p>Current page: {{ currentPage }}</p>
|
|
124
|
+
</template>
|
|
125
|
+
|
|
126
|
+
<script setup>
|
|
127
|
+
import { ref } from 'vue'
|
|
128
|
+
|
|
129
|
+
const currentPage = ref(1)
|
|
130
|
+
|
|
131
|
+
const handlePageClick = (page) => {
|
|
132
|
+
console.log(`Navigated to page ${page}`)
|
|
133
|
+
// Fetch data for the new page
|
|
134
|
+
}
|
|
135
|
+
</script>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Bootstrap CSS Classes
|
|
139
|
+
|
|
140
|
+
- `.pagination`
|
|
141
|
+
- `.pagination-sm`
|
|
142
|
+
- `.pagination-lg`
|
|
143
|
+
- `.page-item`
|
|
144
|
+
- `.page-link`
|
|
145
|
+
- `.active`
|
|
146
|
+
- `.disabled`
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# VibeProgress
|
|
2
|
+
|
|
3
|
+
Data-driven progress bar component supporting single or multiple bars.
|
|
4
|
+
|
|
5
|
+
## Props
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Default | Description |
|
|
8
|
+
|------|------|---------|-------------|
|
|
9
|
+
| `height` | `String` | `undefined` | Custom height (e.g., `'20px'`, `'2rem'`) |
|
|
10
|
+
| `bars` | `ProgressBar[]` | Required | Array of progress bars to display |
|
|
11
|
+
|
|
12
|
+
### ProgressBar Interface
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
interface ProgressBar {
|
|
16
|
+
value: number
|
|
17
|
+
max?: number
|
|
18
|
+
variant?: Variant
|
|
19
|
+
striped?: boolean
|
|
20
|
+
animated?: boolean
|
|
21
|
+
label?: string
|
|
22
|
+
showValue?: boolean
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Slots
|
|
27
|
+
|
|
28
|
+
| Slot | Scope | Description |
|
|
29
|
+
|------|-------|-------------|
|
|
30
|
+
| `label` | `{ bar, index }` | Custom label rendering for each bar |
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
### Basic Progress
|
|
35
|
+
|
|
36
|
+
```vue
|
|
37
|
+
<template>
|
|
38
|
+
<VibeProgress :bars="[{ value: 25 }]" />
|
|
39
|
+
</template>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### With Label
|
|
43
|
+
|
|
44
|
+
```vue
|
|
45
|
+
<template>
|
|
46
|
+
<VibeProgress :bars="[{ value: 75, showValue: true }]" />
|
|
47
|
+
</template>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Custom Height
|
|
51
|
+
|
|
52
|
+
```vue
|
|
53
|
+
<template>
|
|
54
|
+
<VibeProgress height="20px" :bars="[{ value: 50 }]" />
|
|
55
|
+
</template>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Colored Progress Bars
|
|
59
|
+
|
|
60
|
+
```vue
|
|
61
|
+
<template>
|
|
62
|
+
<div class="d-flex flex-column gap-2">
|
|
63
|
+
<VibeProgress :bars="[{ value: 25, variant: 'success' }]" />
|
|
64
|
+
<VibeProgress :bars="[{ value: 50, variant: 'info' }]" />
|
|
65
|
+
<VibeProgress :bars="[{ value: 75, variant: 'warning' }]" />
|
|
66
|
+
<VibeProgress :bars="[{ value: 100, variant: 'danger' }]" />
|
|
67
|
+
</div>
|
|
68
|
+
</template>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Striped and Animated
|
|
72
|
+
|
|
73
|
+
```vue
|
|
74
|
+
<template>
|
|
75
|
+
<div class="d-flex flex-column gap-2">
|
|
76
|
+
<!-- Striped -->
|
|
77
|
+
<VibeProgress :bars="[{ value: 60, variant: 'success', striped: true }]" />
|
|
78
|
+
|
|
79
|
+
<!-- Animated stripes -->
|
|
80
|
+
<VibeProgress :bars="[{ value: 75, variant: 'info', animated: true }]" />
|
|
81
|
+
</div>
|
|
82
|
+
</template>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Multiple Bars
|
|
86
|
+
|
|
87
|
+
Stack multiple progress bars in a single component:
|
|
88
|
+
|
|
89
|
+
```vue
|
|
90
|
+
<template>
|
|
91
|
+
<VibeProgress :bars="progressBars" />
|
|
92
|
+
</template>
|
|
93
|
+
|
|
94
|
+
<script setup>
|
|
95
|
+
const progressBars = [
|
|
96
|
+
{ value: 15, variant: 'success' },
|
|
97
|
+
{ value: 30, variant: 'warning' },
|
|
98
|
+
{ value: 20, variant: 'danger' }
|
|
99
|
+
]
|
|
100
|
+
</script>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Dynamic Progress
|
|
104
|
+
|
|
105
|
+
```vue
|
|
106
|
+
<script setup>
|
|
107
|
+
import { ref, onMounted } from 'vue'
|
|
108
|
+
|
|
109
|
+
const progress = ref(0)
|
|
110
|
+
|
|
111
|
+
onMounted(() => {
|
|
112
|
+
const interval = setInterval(() => {
|
|
113
|
+
if (progress.value < 100) {
|
|
114
|
+
progress.value += 10
|
|
115
|
+
} else {
|
|
116
|
+
clearInterval(interval)
|
|
117
|
+
}
|
|
118
|
+
}, 500)
|
|
119
|
+
})
|
|
120
|
+
</script>
|
|
121
|
+
|
|
122
|
+
<template>
|
|
123
|
+
<VibeProgress :bars="[{
|
|
124
|
+
value: progress,
|
|
125
|
+
variant: 'primary',
|
|
126
|
+
showValue: true
|
|
127
|
+
}]" />
|
|
128
|
+
</template>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Custom Label Rendering
|
|
132
|
+
|
|
133
|
+
Use the `label` scoped slot for custom labels:
|
|
134
|
+
|
|
135
|
+
```vue
|
|
136
|
+
<template>
|
|
137
|
+
<VibeProgress :bars="progressBars">
|
|
138
|
+
<template #label="{ bar }">
|
|
139
|
+
<strong>{{ bar.value }}% Complete</strong>
|
|
140
|
+
</template>
|
|
141
|
+
</VibeProgress>
|
|
142
|
+
</template>
|
|
143
|
+
|
|
144
|
+
<script setup>
|
|
145
|
+
const progressBars = [{ value: 75, variant: 'success' }]
|
|
146
|
+
</script>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Complex Example
|
|
150
|
+
|
|
151
|
+
```vue
|
|
152
|
+
<script setup>
|
|
153
|
+
import { ref } from 'vue'
|
|
154
|
+
|
|
155
|
+
const tasks = ref([
|
|
156
|
+
{ name: 'Design', value: 100, variant: 'success' },
|
|
157
|
+
{ name: 'Development', value: 75, variant: 'primary', animated: true },
|
|
158
|
+
{ name: 'Testing', value: 50, variant: 'warning', striped: true },
|
|
159
|
+
{ name: 'Deployment', value: 0, variant: 'secondary' }
|
|
160
|
+
])
|
|
161
|
+
</script>
|
|
162
|
+
|
|
163
|
+
<template>
|
|
164
|
+
<div class="d-flex flex-column gap-3">
|
|
165
|
+
<div v-for="task in tasks" :key="task.name">
|
|
166
|
+
<div class="d-flex justify-content-between mb-1">
|
|
167
|
+
<span>{{ task.name }}</span>
|
|
168
|
+
<span>{{ task.value }}%</span>
|
|
169
|
+
</div>
|
|
170
|
+
<VibeProgress :bars="[task]" />
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
</template>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Bootstrap CSS Classes
|
|
177
|
+
|
|
178
|
+
- `.progress`
|
|
179
|
+
- `.progress-bar`
|
|
180
|
+
- `.bg-{variant}`
|
|
181
|
+
- `.progress-bar-striped`
|
|
182
|
+
- `.progress-bar-animated`
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# useBackButton
|
|
2
|
+
|
|
3
|
+
A composable to handle the Android hardware back button in hybrid mobile environments (like Capacitor or WebView apps).
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
import { useBackButton } from '@velkymx/vibeui'
|
|
9
|
+
|
|
10
|
+
// Automatically closes this logic when the back button is pressed
|
|
11
|
+
useBackButton(() => {
|
|
12
|
+
console.log('Back button pressed!')
|
|
13
|
+
closeMyOverlay()
|
|
14
|
+
})
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## How it Works
|
|
18
|
+
- It listens for the native `backbutton` event emitted by hybrid wrappers.
|
|
19
|
+
- It maintains an internal stack of "closeable" actions.
|
|
20
|
+
- When the back button is pressed, it executes the most recently registered action and prevents the default app-exit behavior.
|
|
21
|
+
- It automatically handles cleanup when the component using it is unmounted.
|
|
22
|
+
|
|
23
|
+
## Integrated Components
|
|
24
|
+
The following VibeUI components have `useBackButton` integrated automatically:
|
|
25
|
+
- `VibeModal`
|
|
26
|
+
- `VibeOffcanvas`
|
|
27
|
+
|
|
28
|
+
You don't need to manually use this composable if you are using these components; they will "just work" on Android devices.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# useBreakpoints
|
|
2
|
+
|
|
3
|
+
A composable for programmatic breakpoint detection using standard Bootstrap grid sizes.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
import { useBreakpoints } from '@velkymx/vibeui'
|
|
9
|
+
|
|
10
|
+
const { isMobile, isTablet, isLg, isXxl } = useBreakpoints()
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## API
|
|
14
|
+
|
|
15
|
+
| Property | Type | Description |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| `isXs` | `ComputedRef<boolean>` | `true` if width < 576px |
|
|
18
|
+
| `isSm` | `Ref<boolean>` | `true` if width >= 576px |
|
|
19
|
+
| `isMd` | `Ref<boolean>` | `true` if width >= 768px |
|
|
20
|
+
| `isLg` | `Ref<boolean>` | `true` if width >= 992px |
|
|
21
|
+
| `isXl` | `Ref<boolean>` | `true` if width >= 1200px |
|
|
22
|
+
| `isXxl` | `Ref<boolean>` | `true` if width >= 1400px |
|
|
23
|
+
| `isMobile` | `ComputedRef<boolean>` | `true` if screen is `xs` or `sm` (width < 768px) |
|
|
24
|
+
| `isTablet` | `ComputedRef<boolean>` | `true` if screen is exactly `md` (768px - 991px) |
|
|
25
|
+
|
|
26
|
+
## Performance
|
|
27
|
+
This composable uses `window.matchMedia` listeners instead of `resize` events, making it highly performant and efficient. It automatically cleans up listeners when the component is unmounted.
|
|
28
|
+
|
|
29
|
+
## Example: Adaptive Layout
|
|
30
|
+
|
|
31
|
+
```vue
|
|
32
|
+
<template>
|
|
33
|
+
<div>
|
|
34
|
+
<!-- Show offcanvas navigation on mobile, standard nav on desktop -->
|
|
35
|
+
<VibeOffcanvas v-if="isMobile" v-model="showSidebar">
|
|
36
|
+
<MySidebarContent />
|
|
37
|
+
</VibeOffcanvas>
|
|
38
|
+
|
|
39
|
+
<VibeRow v-else>
|
|
40
|
+
<VibeCol cols="3">
|
|
41
|
+
<MySidebarContent />
|
|
42
|
+
</VibeCol>
|
|
43
|
+
<VibeCol cols="9">
|
|
44
|
+
<slot />
|
|
45
|
+
</VibeCol>
|
|
46
|
+
</VibeRow>
|
|
47
|
+
</div>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<script setup>
|
|
51
|
+
import { useBreakpoints } from '@velkymx/vibeui'
|
|
52
|
+
const { isMobile } = useBreakpoints()
|
|
53
|
+
</script>
|
|
54
|
+
```
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# useColorMode
|
|
2
|
+
|
|
3
|
+
Manages Bootstrap 5.3 color modes (`light`, `dark`, `auto`) for the entire app. Sets the `data-bs-theme` attribute on `<html>`, persists the user's preference to `localStorage`, and provides a reactive ref that components can watch.
|
|
4
|
+
|
|
5
|
+
**Singleton** — every call to `useColorMode()` returns the same shared state. There is one active color mode per app.
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { useColorMode } from '@velkymx/vibeui'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Return Values
|
|
14
|
+
|
|
15
|
+
| Name | Type | Description |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| `colorMode` | `Ref<ColorMode>` | Reactive current mode. Bind to template or watch for changes. |
|
|
18
|
+
| `setColorMode(mode)` | `(mode: ColorMode) => void` | Set a specific mode. Persists to `localStorage` and updates `<html data-bs-theme>`. |
|
|
19
|
+
| `toggleColorMode()` | `() => void` | Cycle through `light → dark → auto → light`. |
|
|
20
|
+
| `initColorMode()` | `() => void` | Restore the saved preference from `localStorage`. **Call once at app startup.** Subsequent calls are no-ops. |
|
|
21
|
+
| `onColorModeChange(cb)` | `(mode: ColorMode) => void` | Register a callback that fires whenever the mode changes. Useful for hybrid app status bars. |
|
|
22
|
+
|
|
23
|
+
## Type
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
type ColorMode = 'light' | 'dark' | 'auto'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
| Value | Behavior |
|
|
30
|
+
|---|---|
|
|
31
|
+
| `'light'` | Forces light theme regardless of OS setting |
|
|
32
|
+
| `'dark'` | Forces dark theme regardless of OS setting |
|
|
33
|
+
| `'auto'` | Follows the OS `prefers-color-scheme` media query |
|
|
34
|
+
|
|
35
|
+
## Setup
|
|
36
|
+
|
|
37
|
+
Call `initColorMode()` once in `main.ts` before mounting the app. This restores the user's last saved preference.
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
// main.ts
|
|
41
|
+
import { createApp } from 'vue'
|
|
42
|
+
import VibeUI, { useColorMode } from '@velkymx/vibeui'
|
|
43
|
+
import 'bootstrap/dist/css/bootstrap.min.css'
|
|
44
|
+
import App from './App.vue'
|
|
45
|
+
|
|
46
|
+
const { initColorMode } = useColorMode()
|
|
47
|
+
initColorMode()
|
|
48
|
+
|
|
49
|
+
createApp(App).use(VibeUI).mount('#app')
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
### Toggle button
|
|
55
|
+
|
|
56
|
+
The most common use case — a button that cycles through all three modes.
|
|
57
|
+
|
|
58
|
+
```vue
|
|
59
|
+
<script setup lang="ts">
|
|
60
|
+
import { useColorMode } from '@velkymx/vibeui'
|
|
61
|
+
|
|
62
|
+
const { colorMode, toggleColorMode } = useColorMode()
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<template>
|
|
66
|
+
<VibeButton variant="secondary" @click="toggleColorMode">
|
|
67
|
+
Theme: {{ colorMode }}
|
|
68
|
+
</VibeButton>
|
|
69
|
+
</template>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Explicit mode switcher
|
|
73
|
+
|
|
74
|
+
A select or set of buttons that lets the user pick a specific mode.
|
|
75
|
+
|
|
76
|
+
```vue
|
|
77
|
+
<script setup lang="ts">
|
|
78
|
+
import { useColorMode } from '@velkymx/vibeui'
|
|
79
|
+
import type { ColorMode } from '@velkymx/vibeui'
|
|
80
|
+
|
|
81
|
+
const { colorMode, setColorMode } = useColorMode()
|
|
82
|
+
|
|
83
|
+
const options: { label: string; value: ColorMode }[] = [
|
|
84
|
+
{ label: 'Light', value: 'light' },
|
|
85
|
+
{ label: 'Dark', value: 'dark' },
|
|
86
|
+
{ label: 'System', value: 'auto' },
|
|
87
|
+
]
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
<template>
|
|
91
|
+
<div class="btn-group">
|
|
92
|
+
<VibeButton
|
|
93
|
+
v-for="option in options"
|
|
94
|
+
:key="option.value"
|
|
95
|
+
:variant="colorMode === option.value ? 'primary' : 'outline-secondary'"
|
|
96
|
+
@click="setColorMode(option.value)"
|
|
97
|
+
>
|
|
98
|
+
{{ option.label }}
|
|
99
|
+
</VibeButton>
|
|
100
|
+
</div>
|
|
101
|
+
</template>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Watching for changes
|
|
105
|
+
|
|
106
|
+
React to color mode changes anywhere in the app — for example, to swap a chart theme.
|
|
107
|
+
|
|
108
|
+
```vue
|
|
109
|
+
<script setup lang="ts">
|
|
110
|
+
import { watch } from 'vue'
|
|
111
|
+
import { useColorMode } from '@velkymx/vibeui'
|
|
112
|
+
|
|
113
|
+
const { colorMode } = useColorMode()
|
|
114
|
+
|
|
115
|
+
watch(colorMode, (mode) => {
|
|
116
|
+
console.log('Color mode changed to:', mode)
|
|
117
|
+
// e.g. update a third-party chart library's theme
|
|
118
|
+
})
|
|
119
|
+
</script>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Scoping color mode to a single component
|
|
123
|
+
|
|
124
|
+
Bootstrap's `data-bs-theme` attribute works on any element, not just `<html>`. For cases where one section of the page should always be dark regardless of the app-level setting, apply it directly in the template instead of using the composable.
|
|
125
|
+
|
|
126
|
+
```vue
|
|
127
|
+
<template>
|
|
128
|
+
<div data-bs-theme="dark">
|
|
129
|
+
<!-- This section is always dark -->
|
|
130
|
+
<VibeCard>Always dark card</VibeCard>
|
|
131
|
+
</div>
|
|
132
|
+
</template>
|
|
133
|
+
```
|
|
134
|
+
## Behavior Notes
|
|
135
|
+
|
|
136
|
+
- **Persistence** — the selected mode is stored in `localStorage` under the key `vibe-color-mode`. It survives page reloads.
|
|
137
|
+
- **System Theme Reactivity** — when the mode is set to `'auto'`, VibeUI automatically listens for OS-level theme changes (via `matchMedia`) and updates the DOM immediately without a page reload.
|
|
138
|
+
- **SSR-safe** — all `document` and `localStorage` access is guarded. The composable is safe to import in server-rendered environments; `applyColorMode` simply does nothing when `document` is undefined.
|
|
139
|
+
...
|
|
140
|
+
- **Invalid values** — `setColorMode` silently ignores any value that is not `'light'`, `'dark'`, or `'auto'`. No error is thrown.
|
|
141
|
+
- **`initColorMode` is idempotent** — it is safe to call it multiple times (e.g. from multiple entry points). Only the first call reads `localStorage` and applies the theme. All subsequent calls are no-ops and do not overwrite changes the user made after initialization.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# VibeUI Form Components
|
|
2
|
+
|
|
3
|
+
Comprehensive form components with built-in validation support for both front-end and API-based validation.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
VibeUI provides a complete set of form components that seamlessly integrate with Bootstrap styling and include powerful validation capabilities out of the box.
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- ✅ **Full Bootstrap Integration** - Uses native Bootstrap classes and styling
|
|
12
|
+
- ✅ **Zero-Boilerplate IDs** - `id` props are now optional and automatically generated
|
|
13
|
+
- ✅ **Form Automation** - `VibeFormGroup` automatically links its label to child inputs via ID injection
|
|
14
|
+
- ✅ **Two-Way Data Binding** - v-model support on all components
|
|
15
|
+
- ✅ **Built-in Validation** - Comprehensive validation system with custom validators
|
|
16
|
+
- ✅ **Accessible** - Automatic ARIA attribute management and label linking
|
|
17
|
+
- ✅ **TypeScript** - Fully typed components and APIs
|
|
18
|
+
|
|
19
|
+
## Components
|
|
20
|
+
|
|
21
|
+
### Input Components
|
|
22
|
+
|
|
23
|
+
| Component | Description | Documentation |
|
|
24
|
+
|-----------|-------------|---------------|
|
|
25
|
+
| **VibeFormInput** | Text, email, password, number, and other input types | [Docs](./form-input.md) |
|
|
26
|
+
| **VibeInputGroup** | Input group for prepending/appending text or buttons | [Docs](./input-group.md) |
|
|
27
|
+
| **VibeFormTextarea** | Multi-line text input | [Docs](./form-textarea.md) |
|
|
28
|
+
| **VibeFormSelect** | Single and multiple selection dropdowns | [Docs](./form-select.md) |
|
|
29
|
+
| **VibeFormSpinbutton** | Number input with increment/decrement buttons | [Docs](./form-spinbutton.md) |
|
|
30
|
+
| **VibeFormDatepicker** | Date, time, and datetime inputs | [Docs](./form-datepicker.md) |
|
|
31
|
+
|
|
32
|
+
### Choice Components
|
|
33
|
+
|
|
34
|
+
| Component | Description | Documentation |
|
|
35
|
+
|-----------|-------------|---------------|
|
|
36
|
+
| **VibeFormCheckbox** | Single checkboxes and checkbox groups | [Docs](./form-checkbox.md) |
|
|
37
|
+
| **VibeFormRadio** | Radio button groups for exclusive selection | [Docs](./form-radio.md) |
|
|
38
|
+
| **VibeFormSwitch** | Toggle switches for boolean settings | [Docs](./form-switch.md) |
|
|
39
|
+
|
|
40
|
+
### Advanced Components
|
|
41
|
+
|
|
42
|
+
| Component | Description | Documentation |
|
|
43
|
+
|-----------|-------------|---------------|
|
|
44
|
+
| **VibeFormWysiwyg** | WYSIWYG editor powered by QuillJS | [Docs](./form-wysiwyg.md) |
|
|
45
|
+
| **VibeFormGroup** | Form group container for layout and automated label linking | [Docs](./form-group.md) |
|
|
46
|
+
|
|
47
|
+
## Quick Start
|
|
48
|
+
|
|
49
|
+
### Basic Example (Automated)
|
|
50
|
+
|
|
51
|
+
VibeUI automatically handles ID generation and label linking. No `id` or `label-for` is required when using `VibeFormGroup`.
|
|
52
|
+
|
|
53
|
+
```vue
|
|
54
|
+
<script setup lang="ts">
|
|
55
|
+
import { ref } from 'vue'
|
|
56
|
+
const email = ref('')
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<template>
|
|
60
|
+
<VibeFormGroup label="Email Address">
|
|
61
|
+
<VibeFormInput
|
|
62
|
+
v-model="email"
|
|
63
|
+
type="email"
|
|
64
|
+
placeholder="Enter email"
|
|
65
|
+
/>
|
|
66
|
+
</VibeFormGroup>
|
|
67
|
+
</template>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Documentation
|
|
71
|
+
|
|
72
|
+
### Component Documentation
|
|
73
|
+
|
|
74
|
+
- [VibeFormInput](./form-input.md) - Text inputs with validation
|
|
75
|
+
- [VibeInputGroup](./input-group.md) - Prepend/append groups
|
|
76
|
+
- [VibeFormSelect](./form-select.md) - Select dropdowns
|
|
77
|
+
- [VibeFormTextarea](./form-textarea.md) - Multi-line text input
|
|
78
|
+
- [VibeFormSpinbutton](./form-spinbutton.md) - Number input with buttons
|
|
79
|
+
- [VibeFormDatepicker](./form-datepicker.md) - Date and time inputs
|
|
80
|
+
- [VibeFormCheckbox](./form-checkbox.md) - Checkboxes and groups
|
|
81
|
+
- [VibeFormRadio](./form-radio.md) - Radio button groups
|
|
82
|
+
- [VibeFormSwitch](./form-switch.md) - Toggle switches
|
|
83
|
+
- [VibeFormGroup](./form-group.md) - Form group container
|
|
84
|
+
- [VibeFormWysiwyg](./form-wysiwyg.md) - WYSIWYG editor
|
|
85
|
+
|
|
86
|
+
### Guides
|
|
87
|
+
|
|
88
|
+
- [Validation Guide](./validation.md) - Comprehensive validation documentation
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# VibeFormCheckbox
|
|
2
|
+
|
|
3
|
+
Checkbox component for single boolean values or multiple selections.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<script setup lang="ts">
|
|
9
|
+
import { ref } from 'vue'
|
|
10
|
+
const agreed = ref(false)
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<VibeFormCheckbox
|
|
15
|
+
v-model="agreed"
|
|
16
|
+
label="I agree to the terms"
|
|
17
|
+
/>
|
|
18
|
+
</template>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Props
|
|
22
|
+
|
|
23
|
+
| Prop | Type | Default | Description |
|
|
24
|
+
|------|------|---------|-------------|
|
|
25
|
+
| `modelValue` | `any` | `false` | The checked state (v-model) |
|
|
26
|
+
| `value` | `any` | `true` | Value when checked |
|
|
27
|
+
| `id` | `String` | `Auto-generated` | Unique identifier |
|
|
28
|
+
| `label` | `String` | `undefined` | Label text |
|
|
29
|
+
| `disabled` | `Boolean` | `false` | Disable the checkbox |
|
|
30
|
+
| `required` | `Boolean` | `false` | Mark as required |
|
|
31
|
+
| `inline` | `Boolean` | `false` | Display inline |
|
|
32
|
+
| `indeterminate` | `Boolean` | `false` | Set indeterminate state |
|
|
33
|
+
| `validationState` | `'valid' \| 'invalid' \| null` | `null` | Validation state |
|
|
34
|
+
| `validationMessage` | `String` | `undefined` | Validation message |
|
|
35
|
+
| `validateOn` | `'change' \| 'blur'` | `'change'` | When to validate |
|
|
36
|
+
| `helpText` | `String` | `undefined` | Help text |
|
|
37
|
+
| `reverse` | `Boolean` | `false` | Reverse label and input |
|
|
38
|
+
|
|
39
|
+
## Important Notes
|
|
40
|
+
|
|
41
|
+
**Automatic ID Generation:** This component automatically generates a unique ID if one is not provided.
|
|
42
|
+
|
|
43
|
+
**Automatic ID Injection:** When used inside a `VibeFormGroup`, this component will automatically inherit the group's ID to ensure proper label association and accessibility.
|
|
44
|
+
|
|
45
|
+
## Bootstrap CSS Classes
|
|
46
|
+
|
|
47
|
+
- `.form-check`
|
|
48
|
+
- `.form-check-input`
|
|
49
|
+
- `.form-check-label`
|
|
50
|
+
- `.is-valid`, `.is-invalid`
|