@baklavue/mcp 1.0.0
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 +72 -0
- package/dist/data/component-categories.d.ts +7 -0
- package/dist/data/component-categories.js +48 -0
- package/dist/data/loaders.d.ts +22 -0
- package/dist/data/loaders.js +346 -0
- package/dist/docs/components/accordion.md +601 -0
- package/dist/docs/components/alert.md +233 -0
- package/dist/docs/components/badge.md +100 -0
- package/dist/docs/components/banner.md +231 -0
- package/dist/docs/components/button.md +324 -0
- package/dist/docs/components/checkbox.md +343 -0
- package/dist/docs/components/chip.md +199 -0
- package/dist/docs/components/datepicker.md +243 -0
- package/dist/docs/components/dialog.md +224 -0
- package/dist/docs/components/drawer.md +188 -0
- package/dist/docs/components/dropdown.md +291 -0
- package/dist/docs/components/file-upload.md +248 -0
- package/dist/docs/components/icon.md +142 -0
- package/dist/docs/components/image.md +161 -0
- package/dist/docs/components/index.md +151 -0
- package/dist/docs/components/input.md +407 -0
- package/dist/docs/components/link.md +249 -0
- package/dist/docs/components/notification.md +179 -0
- package/dist/docs/components/pagination.md +168 -0
- package/dist/docs/components/radio.md +221 -0
- package/dist/docs/components/scroll-to-top.md +90 -0
- package/dist/docs/components/select.md +239 -0
- package/dist/docs/components/skeleton.md +79 -0
- package/dist/docs/components/spinner.md +93 -0
- package/dist/docs/components/split-button.md +165 -0
- package/dist/docs/components/stepper.md +337 -0
- package/dist/docs/components/switch.md +144 -0
- package/dist/docs/components/tab.md +140 -0
- package/dist/docs/components/table.md +362 -0
- package/dist/docs/components/tag.md +243 -0
- package/dist/docs/components/textarea.md +190 -0
- package/dist/docs/components/tooltip.md +155 -0
- package/dist/docs/composables/alert.md +87 -0
- package/dist/docs/composables/asyncState.md +74 -0
- package/dist/docs/composables/base64.md +72 -0
- package/dist/docs/composables/breakpoints.md +129 -0
- package/dist/docs/composables/clipboard.md +108 -0
- package/dist/docs/composables/colorScheme.md +110 -0
- package/dist/docs/composables/confirmDialog.md +105 -0
- package/dist/docs/composables/containerScroll.md +89 -0
- package/dist/docs/composables/cookie.md +137 -0
- package/dist/docs/composables/debounce.md +69 -0
- package/dist/docs/composables/disclosure.md +69 -0
- package/dist/docs/composables/elementSize.md +84 -0
- package/dist/docs/composables/fetch.md +257 -0
- package/dist/docs/composables/fieldArray.md +104 -0
- package/dist/docs/composables/file.md +343 -0
- package/dist/docs/composables/focusTrap.md +87 -0
- package/dist/docs/composables/formPersistence.md +69 -0
- package/dist/docs/composables/formState.md +71 -0
- package/dist/docs/composables/formValidation.md +355 -0
- package/dist/docs/composables/format.md +107 -0
- package/dist/docs/composables/id.md +54 -0
- package/dist/docs/composables/index.md +112 -0
- package/dist/docs/composables/infiniteQuery.md +104 -0
- package/dist/docs/composables/intersectionObserver.md +64 -0
- package/dist/docs/composables/lazyQuery.md +68 -0
- package/dist/docs/composables/loading.md +91 -0
- package/dist/docs/composables/mutation.md +83 -0
- package/dist/docs/composables/notification.md +169 -0
- package/dist/docs/composables/pagination.md +109 -0
- package/dist/docs/composables/polling.md +76 -0
- package/dist/docs/composables/previous.md +58 -0
- package/dist/docs/composables/query.md +248 -0
- package/dist/docs/composables/raf.md +78 -0
- package/dist/docs/composables/scrollLock.md +46 -0
- package/dist/docs/composables/scrollToError.md +291 -0
- package/dist/docs/composables/scrollVisibility.md +60 -0
- package/dist/docs/composables/share.md +78 -0
- package/dist/docs/composables/slug.md +58 -0
- package/dist/docs/composables/stepper.md +117 -0
- package/dist/docs/composables/stepperForm.md +74 -0
- package/dist/docs/composables/sticky.md +91 -0
- package/dist/docs/composables/storage.md +193 -0
- package/dist/docs/composables/theme.md +252 -0
- package/dist/docs/composables/themePreset.md +62 -0
- package/dist/docs/composables/throttle.md +76 -0
- package/dist/docs/composables/timer.md +78 -0
- package/dist/docs/composables/toggle.md +55 -0
- package/dist/docs/guide/contributing.md +364 -0
- package/dist/docs/guide/design-tokens.md +29 -0
- package/dist/docs/guide/getting-started.md +181 -0
- package/dist/docs/guide/installation.md +287 -0
- package/dist/docs/guide/localization.md +132 -0
- package/dist/docs/guide/mcp.md +141 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +177 -0
- package/package.json +48 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# Notification
|
|
2
|
+
|
|
3
|
+
A Vue UI kit component for Baklava's `bl-notification` web component for toast notifications. Place the Notification component once in your app (typically at root or layout level). Notifications are triggered programmatically via the `useNotification` composable from `@baklavue/composables`.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
Place `<BvNotification />` in your app. It acts as a container for toast notifications that appear when you call `useNotification()` methods.
|
|
8
|
+
|
|
9
|
+
<div class="component-demo">
|
|
10
|
+
|
|
11
|
+
<NotificationBasicDemo />
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
```vue
|
|
16
|
+
<template>
|
|
17
|
+
<div>
|
|
18
|
+
<BvButton @click="showSuccess">Show Success</BvButton>
|
|
19
|
+
<BvButton kind="danger" @click="showError">Show Error</BvButton>
|
|
20
|
+
<BvNotification />
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup>
|
|
25
|
+
import { BvButton, BvNotification } from "@baklavue/ui";
|
|
26
|
+
import { useNotification } from "@baklavue/composables";
|
|
27
|
+
|
|
28
|
+
const { success, error } = useNotification();
|
|
29
|
+
|
|
30
|
+
const showSuccess = () => {
|
|
31
|
+
success({
|
|
32
|
+
caption: "Success!",
|
|
33
|
+
description: "Operation completed successfully.",
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const showError = () => {
|
|
38
|
+
error({
|
|
39
|
+
caption: "Error",
|
|
40
|
+
description: "Something went wrong.",
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
</script>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## With Composables
|
|
47
|
+
|
|
48
|
+
The `useNotification` composable provides four methods: `success`, `error`, `warning`, and `info`. Each displays a notification with the corresponding kind (icon and styling).
|
|
49
|
+
|
|
50
|
+
<div class="component-demo">
|
|
51
|
+
|
|
52
|
+
<NotificationBasicDemo />
|
|
53
|
+
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
```vue
|
|
57
|
+
<template>
|
|
58
|
+
<div>
|
|
59
|
+
<BvButton kind="success" @click="showSuccess">Success</BvButton>
|
|
60
|
+
<BvButton kind="danger" @click="showError">Error</BvButton>
|
|
61
|
+
<BvButton kind="neutral" @click="showWarning">Warning</BvButton>
|
|
62
|
+
<BvButton @click="showInfo">Info</BvButton>
|
|
63
|
+
<BvNotification />
|
|
64
|
+
</div>
|
|
65
|
+
</template>
|
|
66
|
+
|
|
67
|
+
<script setup>
|
|
68
|
+
import { BvButton, BvNotification } from "@baklavue/ui";
|
|
69
|
+
import { useNotification } from "@baklavue/composables";
|
|
70
|
+
|
|
71
|
+
const { success, error, warning, info } = useNotification();
|
|
72
|
+
|
|
73
|
+
const showSuccess = () =>
|
|
74
|
+
success({
|
|
75
|
+
caption: "Success!",
|
|
76
|
+
description: "Operation completed successfully.",
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const showError = () =>
|
|
80
|
+
error({
|
|
81
|
+
caption: "Error",
|
|
82
|
+
description: "Something went wrong.",
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const showWarning = () =>
|
|
86
|
+
warning({
|
|
87
|
+
caption: "Warning",
|
|
88
|
+
description: "Please check your input.",
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const showInfo = () =>
|
|
92
|
+
info({
|
|
93
|
+
caption: "Info",
|
|
94
|
+
description: "This is an informational message.",
|
|
95
|
+
});
|
|
96
|
+
</script>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Custom Duration
|
|
100
|
+
|
|
101
|
+
Control the default duration via the `duration` prop on the component (in seconds). You can also override duration per notification when calling `success`, `error`, `warning`, or `info`.
|
|
102
|
+
|
|
103
|
+
<div class="component-demo">
|
|
104
|
+
|
|
105
|
+
<NotificationDurationDemo />
|
|
106
|
+
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
```vue
|
|
110
|
+
<template>
|
|
111
|
+
<div>
|
|
112
|
+
<BvButton @click="showShort">Show 3s notification</BvButton>
|
|
113
|
+
<BvButton @click="showLong">Show 10s notification</BvButton>
|
|
114
|
+
<BvNotification :duration="5" />
|
|
115
|
+
</div>
|
|
116
|
+
</template>
|
|
117
|
+
|
|
118
|
+
<script setup>
|
|
119
|
+
import { BvButton, BvNotification } from "@baklavue/ui";
|
|
120
|
+
import { useNotification } from "@baklavue/composables";
|
|
121
|
+
|
|
122
|
+
const { success } = useNotification();
|
|
123
|
+
|
|
124
|
+
const showShort = () => {
|
|
125
|
+
success({
|
|
126
|
+
caption: "Short duration",
|
|
127
|
+
description: "This notification stays for 3 seconds.",
|
|
128
|
+
duration: 3,
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const showLong = () => {
|
|
133
|
+
success({
|
|
134
|
+
caption: "Long duration",
|
|
135
|
+
description: "This notification stays for 10 seconds.",
|
|
136
|
+
duration: 10,
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
</script>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Props
|
|
143
|
+
|
|
144
|
+
| Prop | Type | Default | Description |
|
|
145
|
+
| ------------- | --------- | ------- | --------------------------------------------------------------- |
|
|
146
|
+
| `duration` | `number` | `7` | Default duration of notifications in seconds |
|
|
147
|
+
| `noAnimation` | `boolean` | `false` | Disable animations. Respects user's reduced-motion preferences. |
|
|
148
|
+
|
|
149
|
+
## Types
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
import type { NotificationProps } from "@baklavue/ui";
|
|
153
|
+
|
|
154
|
+
// Notification component props (duration, noAnimation)
|
|
155
|
+
interface NotificationProps {
|
|
156
|
+
duration?: number;
|
|
157
|
+
noAnimation?: boolean;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// useNotification options (caption, description) - maps to Baklava NotificationProps
|
|
161
|
+
interface UseNotificationOptions {
|
|
162
|
+
caption?: string; // Notification title
|
|
163
|
+
description: string; // Notification message (required)
|
|
164
|
+
duration?: number;
|
|
165
|
+
permanent?: boolean;
|
|
166
|
+
primaryAction?: { label: string; onClick: () => void };
|
|
167
|
+
secondaryAction?: { label: string; onClick: () => void };
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Usage Notes
|
|
172
|
+
|
|
173
|
+
- **Placement**: Place `<BvNotification />` once in your app, typically at the root layout or App.vue. It renders the `bl-notification` container; notifications are added via `useNotification()`.
|
|
174
|
+
|
|
175
|
+
- **useNotification requirement**: The `useNotification` composable requires a `<BvNotification />` (or `<bl-notification>`) component to be present in the DOM. If it is missing, a console warning is shown and notifications will not appear.
|
|
176
|
+
|
|
177
|
+
- **Accessibility**: The component follows Baklava's accessibility guidelines. The `noAnimation` prop respects the user's reduced-motion preferences.
|
|
178
|
+
|
|
179
|
+
- **Styling**: The component uses Baklava's default styling. Custom styling can be applied through CSS variables or by overriding the component styles.
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# Pagination
|
|
2
|
+
|
|
3
|
+
A Vue UI kit component for Baklava's `bl-pagination` web component for page navigation. Supports v-model for two-way binding of the current page and emits change events when the user navigates.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
Use the Pagination component with `v-model:current-page` for two-way binding. Pass `total-items` (total item count) and `page-size` (items per page).
|
|
8
|
+
|
|
9
|
+
<div class="component-demo">
|
|
10
|
+
|
|
11
|
+
<PaginationBasicDemo />
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
```vue
|
|
16
|
+
<template>
|
|
17
|
+
<div>
|
|
18
|
+
<p>Current page: {{ currentPage }}</p>
|
|
19
|
+
<BvPagination
|
|
20
|
+
v-model:current-page="currentPage"
|
|
21
|
+
:total-items="100"
|
|
22
|
+
:page-size="10"
|
|
23
|
+
@change="handlePageChange"
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script setup>
|
|
29
|
+
import { ref } from "vue";
|
|
30
|
+
import { BvPagination } from "@baklavue/ui";
|
|
31
|
+
|
|
32
|
+
const currentPage = ref(1);
|
|
33
|
+
|
|
34
|
+
const handlePageChange = (event) => {
|
|
35
|
+
const detail = event.detail;
|
|
36
|
+
if (detail) {
|
|
37
|
+
console.log(
|
|
38
|
+
"Page changed:",
|
|
39
|
+
detail.selectedPage,
|
|
40
|
+
"Previous:",
|
|
41
|
+
detail.prevPage,
|
|
42
|
+
"Items per page:",
|
|
43
|
+
detail.itemsPerPage
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
</script>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## With Jumper
|
|
51
|
+
|
|
52
|
+
Add a jumper input to let users jump directly to a page. Set `has-jumper` to `true` and optionally provide a `jumper-label`.
|
|
53
|
+
|
|
54
|
+
<div class="component-demo">
|
|
55
|
+
|
|
56
|
+
<PaginationJumperDemo />
|
|
57
|
+
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
```vue
|
|
61
|
+
<template>
|
|
62
|
+
<BvPagination
|
|
63
|
+
v-model:current-page="currentPage"
|
|
64
|
+
:total-items="250"
|
|
65
|
+
:page-size="25"
|
|
66
|
+
:has-jumper="true"
|
|
67
|
+
jumper-label="Go to page"
|
|
68
|
+
/>
|
|
69
|
+
</template>
|
|
70
|
+
|
|
71
|
+
<script setup>
|
|
72
|
+
import { ref } from "vue";
|
|
73
|
+
import { BvPagination } from "@baklavue/ui";
|
|
74
|
+
|
|
75
|
+
const currentPage = ref(1);
|
|
76
|
+
</script>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## With Items Per Page Select
|
|
80
|
+
|
|
81
|
+
Add a select dropdown to let users choose how many items per page to display. Set `has-select` to `true` and provide `items-per-page-options`.
|
|
82
|
+
|
|
83
|
+
<div class="component-demo">
|
|
84
|
+
|
|
85
|
+
<PaginationSelectDemo />
|
|
86
|
+
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
```vue
|
|
90
|
+
<template>
|
|
91
|
+
<BvPagination
|
|
92
|
+
v-model:current-page="currentPage"
|
|
93
|
+
:total-items="100"
|
|
94
|
+
:page-size="10"
|
|
95
|
+
:has-select="true"
|
|
96
|
+
select-label="Items per page"
|
|
97
|
+
:items-per-page-options="itemsPerPageOptions"
|
|
98
|
+
/>
|
|
99
|
+
</template>
|
|
100
|
+
|
|
101
|
+
<script setup>
|
|
102
|
+
import { ref } from "vue";
|
|
103
|
+
import { BvPagination } from "@baklavue/ui";
|
|
104
|
+
|
|
105
|
+
const currentPage = ref(1);
|
|
106
|
+
|
|
107
|
+
const itemsPerPageOptions = [
|
|
108
|
+
{ text: "10 Items", value: 10 },
|
|
109
|
+
{ text: "25 Items", value: 25 },
|
|
110
|
+
{ text: "50 Items", value: 50 },
|
|
111
|
+
{ text: "100 Items", value: 100 },
|
|
112
|
+
];
|
|
113
|
+
</script>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Props
|
|
117
|
+
|
|
118
|
+
| Prop | Type | Default | Description |
|
|
119
|
+
| ---------------------- | ----------------------- | ----------- | -------------------------------------------------------------- |
|
|
120
|
+
| `currentPage` | `number` | `undefined` | Current page number (1-based). Supports v-model:currentPage. |
|
|
121
|
+
| `totalItems` | `number` | `undefined` | Total number of items to be paginated |
|
|
122
|
+
| `pageSize` | `number` | `undefined` | Number of items per page |
|
|
123
|
+
| `hasJumper` | `boolean` | `false` | When true, adds a jumper input to jump directly to a page |
|
|
124
|
+
| `jumperLabel` | `string` | `undefined` | Label for the jumper input |
|
|
125
|
+
| `hasSelect` | `boolean` | `false` | When true, adds a select to choose items per page |
|
|
126
|
+
| `selectLabel` | `string` | `undefined` | Label for the items-per-page select |
|
|
127
|
+
| `itemsPerPageOptions` | `ItemsPerPageOption[]` | `undefined` | Options for the items-per-page select (`text`, `value`) |
|
|
128
|
+
|
|
129
|
+
## Events
|
|
130
|
+
|
|
131
|
+
| Event | Payload | Description |
|
|
132
|
+
| ---------------------- | ------- | --------------------------------------------------------------------------- |
|
|
133
|
+
| `update:currentPage` | `number`| Emitted when the current page changes (for v-model:currentPage) |
|
|
134
|
+
| `change` | `CustomEvent` | Emitted when the user navigates. `event.detail` has `{ selectedPage, prevPage, itemsPerPage }` |
|
|
135
|
+
|
|
136
|
+
## Types
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import type { PaginationProps, ItemsPerPageOption } from "@baklavue/ui";
|
|
140
|
+
|
|
141
|
+
interface ItemsPerPageOption {
|
|
142
|
+
text: string;
|
|
143
|
+
value: number;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
interface PaginationProps {
|
|
147
|
+
currentPage?: number;
|
|
148
|
+
totalItems?: number;
|
|
149
|
+
pageSize?: number;
|
|
150
|
+
hasJumper?: boolean;
|
|
151
|
+
jumperLabel?: string;
|
|
152
|
+
hasSelect?: boolean;
|
|
153
|
+
selectLabel?: string;
|
|
154
|
+
itemsPerPageOptions?: ItemsPerPageOption[];
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Usage Notes
|
|
159
|
+
|
|
160
|
+
- **Total Items vs Total Pages**: The component uses `totalItems` (total item count), not total pages. Baklava computes the page count internally from `totalItems` and `pageSize`.
|
|
161
|
+
|
|
162
|
+
- **v-model**: Use `v-model:current-page` for two-way binding of the current page number.
|
|
163
|
+
|
|
164
|
+
- **Change Event**: The `change` event receives a `CustomEvent` whose `detail` contains `{ selectedPage, prevPage, itemsPerPage }`.
|
|
165
|
+
|
|
166
|
+
- **Accessibility**: The component follows Baklava's accessibility guidelines for pagination controls.
|
|
167
|
+
|
|
168
|
+
- **Styling**: The component uses Baklava's default styling. Custom styling can be applied through CSS variables or by overriding the component styles.
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Radio
|
|
2
|
+
|
|
3
|
+
A Vue UI kit component for Baklava's `bl-radio` and `bl-radio-group` components for single-choice selections. Use the `items` prop to create a radio group. Selected value is bound via v-model.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
<div class="component-demo">
|
|
8
|
+
|
|
9
|
+
<RadioSingleDemo />
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
```vue
|
|
14
|
+
<template>
|
|
15
|
+
<BvRadio v-model="selected" :items="items">
|
|
16
|
+
<template #item="{ item }">{{ item.label }}</template>
|
|
17
|
+
</BvRadio>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script setup>
|
|
21
|
+
import { ref } from "vue";
|
|
22
|
+
import { BvRadio } from "@baklavue/ui";
|
|
23
|
+
|
|
24
|
+
const selected = ref("option1");
|
|
25
|
+
const items = [
|
|
26
|
+
{ value: "option1", label: "Option 1" },
|
|
27
|
+
{ value: "option2", label: "Option 2" },
|
|
28
|
+
];
|
|
29
|
+
</script>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Multiple Options
|
|
33
|
+
|
|
34
|
+
<div class="component-demo">
|
|
35
|
+
|
|
36
|
+
<RadioGroupDemo />
|
|
37
|
+
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
```vue
|
|
41
|
+
<template>
|
|
42
|
+
<BvRadio v-model="choice" :items="items">
|
|
43
|
+
<template #item="{ item }">{{ item.label }}</template>
|
|
44
|
+
</BvRadio>
|
|
45
|
+
</template>
|
|
46
|
+
|
|
47
|
+
<script setup>
|
|
48
|
+
import { ref } from "vue";
|
|
49
|
+
import { BvRadio } from "@baklavue/ui";
|
|
50
|
+
|
|
51
|
+
const choice = ref("yes");
|
|
52
|
+
const items = [
|
|
53
|
+
{ value: "yes", label: "Yes" },
|
|
54
|
+
{ value: "no", label: "No" },
|
|
55
|
+
{ value: "maybe", label: "Maybe" },
|
|
56
|
+
];
|
|
57
|
+
</script>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Disabled State
|
|
61
|
+
|
|
62
|
+
Disable individual radios to prevent user interaction.
|
|
63
|
+
|
|
64
|
+
<div class="component-demo">
|
|
65
|
+
|
|
66
|
+
<RadioDisabledDemo />
|
|
67
|
+
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
```vue
|
|
71
|
+
<template>
|
|
72
|
+
<BvRadio v-model="choice" :items="items">
|
|
73
|
+
<template #item="{ item }">{{ item.label }}</template>
|
|
74
|
+
</BvRadio>
|
|
75
|
+
</template>
|
|
76
|
+
|
|
77
|
+
<script setup>
|
|
78
|
+
import { ref } from "vue";
|
|
79
|
+
import { BvRadio } from "@baklavue/ui";
|
|
80
|
+
|
|
81
|
+
const choice = ref("yes");
|
|
82
|
+
const items = [
|
|
83
|
+
{ value: "yes", label: "Yes" },
|
|
84
|
+
{ value: "no", label: "No" },
|
|
85
|
+
{ value: "maybe", label: "Maybe (disabled)", disabled: true },
|
|
86
|
+
];
|
|
87
|
+
</script>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Custom Content with #item Slot
|
|
91
|
+
|
|
92
|
+
Use the `#item` scoped slot to customize the label or content of each radio. The slot receives `{ item, index }`.
|
|
93
|
+
|
|
94
|
+
```vue
|
|
95
|
+
<template>
|
|
96
|
+
<BvRadio v-model="choice" :items="items">
|
|
97
|
+
<template #item="{ item }">
|
|
98
|
+
<span>{{ item.label }}</span>
|
|
99
|
+
</template>
|
|
100
|
+
</BvRadio>
|
|
101
|
+
</template>
|
|
102
|
+
|
|
103
|
+
<script setup>
|
|
104
|
+
import { ref } from "vue";
|
|
105
|
+
import { BvRadio } from "@baklavue/ui";
|
|
106
|
+
|
|
107
|
+
const choice = ref("email");
|
|
108
|
+
const items = [
|
|
109
|
+
{ value: "email", label: "Email notifications" },
|
|
110
|
+
{ value: "sms", label: "SMS notifications" },
|
|
111
|
+
{ value: "push", label: "Push notifications" },
|
|
112
|
+
];
|
|
113
|
+
</script>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Complete Examples
|
|
117
|
+
|
|
118
|
+
### Survey Form
|
|
119
|
+
|
|
120
|
+
<div class="component-demo">
|
|
121
|
+
|
|
122
|
+
<RadioGroupDemo />
|
|
123
|
+
|
|
124
|
+
</div>
|
|
125
|
+
|
|
126
|
+
```vue
|
|
127
|
+
<template>
|
|
128
|
+
<div>
|
|
129
|
+
<h3>How satisfied are you?</h3>
|
|
130
|
+
<BvRadio v-model="rating" :items="ratingItems">
|
|
131
|
+
<template #item="{ item }">{{ item.label }}</template>
|
|
132
|
+
</BvRadio>
|
|
133
|
+
</div>
|
|
134
|
+
</template>
|
|
135
|
+
|
|
136
|
+
<script setup>
|
|
137
|
+
import { ref } from "vue";
|
|
138
|
+
import { BvRadio } from "@baklavue/ui";
|
|
139
|
+
|
|
140
|
+
const rating = ref("5");
|
|
141
|
+
const ratingItems = [
|
|
142
|
+
{ value: "5", label: "Very satisfied" },
|
|
143
|
+
{ value: "4", label: "Satisfied" },
|
|
144
|
+
{ value: "3", label: "Neutral" },
|
|
145
|
+
{ value: "2", label: "Dissatisfied" },
|
|
146
|
+
{ value: "1", label: "Very dissatisfied" },
|
|
147
|
+
];
|
|
148
|
+
</script>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Props
|
|
152
|
+
|
|
153
|
+
| Prop | Type | Default | Description |
|
|
154
|
+
| ------------ | ------------------ | ----------- | ------------------------------------------------------------------- |
|
|
155
|
+
| `modelValue` | `string \| number` | `undefined` | Selected value (use v-model for two-way binding) |
|
|
156
|
+
| `items` | `RadioItem[]` | `undefined` | Array of radio items. Each item renders as a bl-radio element |
|
|
157
|
+
| `label` | `string` | `undefined` | Label for the radio group (bl-radio-group label attribute) |
|
|
158
|
+
| `required` | `boolean` | `undefined` | Whether the radio group is required (for form validation) |
|
|
159
|
+
|
|
160
|
+
### RadioItem Interface
|
|
161
|
+
|
|
162
|
+
When using the `items` prop, each item should follow the `RadioItem` interface:
|
|
163
|
+
|
|
164
|
+
| Property | Type | Default | Description |
|
|
165
|
+
| ---------- | ------------------ | ----------- | ----------------------------------------- |
|
|
166
|
+
| `value` | `string \| number` | required | The value of the radio (for v-model) |
|
|
167
|
+
| `label` | `string` | `undefined` | Label text displayed next to the radio |
|
|
168
|
+
| `disabled` | `boolean` | `false` | Whether the radio is disabled |
|
|
169
|
+
| `name` | `string` | `undefined` | Name attribute for the radio |
|
|
170
|
+
|
|
171
|
+
Items may include additional custom data for use in the `#item` slot.
|
|
172
|
+
|
|
173
|
+
## Events
|
|
174
|
+
|
|
175
|
+
| Event | Payload | Description |
|
|
176
|
+
| ------------------- | --------------------- | -------------------------------------------- |
|
|
177
|
+
| `update:modelValue` | `string \| number` | Emitted when selection changes (for v-model) |
|
|
178
|
+
| `change` | `CustomEvent` | Emitted when the selection changes |
|
|
179
|
+
|
|
180
|
+
## Slots
|
|
181
|
+
|
|
182
|
+
| Slot | Props | Description |
|
|
183
|
+
| ------ | ----------------- | ------------------------------------------------------ |
|
|
184
|
+
| `item` | `{ item, index }` | Scoped slot for each radio item content |
|
|
185
|
+
|
|
186
|
+
## Types
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
import type { RadioProps, RadioItem } from "@baklavue/ui";
|
|
190
|
+
|
|
191
|
+
interface RadioItem {
|
|
192
|
+
value: string | number;
|
|
193
|
+
label?: string;
|
|
194
|
+
disabled?: boolean;
|
|
195
|
+
name?: string;
|
|
196
|
+
[key: string]: unknown; // Additional custom data for #item slot
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
interface RadioProps {
|
|
200
|
+
modelValue?: string | number;
|
|
201
|
+
items?: RadioItem[];
|
|
202
|
+
label?: string;
|
|
203
|
+
required?: boolean;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Events
|
|
207
|
+
interface RadioEmits {
|
|
208
|
+
"update:modelValue": [value: string | number];
|
|
209
|
+
change: [event: CustomEvent];
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Usage Notes
|
|
214
|
+
|
|
215
|
+
- **Items Prop**: Radios are rendered from the `items` prop. Content for each item is provided via the `#item` scoped slot or defaults to `item.label`.
|
|
216
|
+
|
|
217
|
+
- **v-model Behavior**: v-model binds the selected value (string or number).
|
|
218
|
+
|
|
219
|
+
- **Accessibility**: The component follows Baklava's accessibility guidelines and includes proper ARIA attributes for screen readers.
|
|
220
|
+
|
|
221
|
+
- **Styling**: The component uses Baklava's default styling. Custom styling can be applied via CSS variables such as `--bl-radio-align-items` (default: center) and `--bl-radio-direction` (row|column) for layout.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# ScrollToTop
|
|
2
|
+
|
|
3
|
+
A floating button that appears when the user scrolls past a threshold. Clicking it scrolls smoothly to the top of the page.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
<div class="component-demo">
|
|
8
|
+
|
|
9
|
+
<ScrollToTopBasicDemo />
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
```vue
|
|
14
|
+
<template>
|
|
15
|
+
<BvScrollToTop />
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup>
|
|
19
|
+
import { BvScrollToTop } from "@baklavue/ui";
|
|
20
|
+
</script>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Position
|
|
24
|
+
|
|
25
|
+
Control the fixed position of the button using the `position` prop.
|
|
26
|
+
|
|
27
|
+
```vue
|
|
28
|
+
<template>
|
|
29
|
+
<BvScrollToTop position="bottom-left" />
|
|
30
|
+
<BvScrollToTop position="bottom-right" />
|
|
31
|
+
<BvScrollToTop position="top-left" />
|
|
32
|
+
<BvScrollToTop position="top-right" />
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script setup>
|
|
36
|
+
import { BvScrollToTop } from "@baklavue/ui";
|
|
37
|
+
</script>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Custom Threshold
|
|
41
|
+
|
|
42
|
+
Set the scroll threshold in pixels. The button becomes visible when the user scrolls past this value.
|
|
43
|
+
|
|
44
|
+
```vue
|
|
45
|
+
<template>
|
|
46
|
+
<BvScrollToTop :threshold="500" />
|
|
47
|
+
</template>
|
|
48
|
+
|
|
49
|
+
<script setup>
|
|
50
|
+
import { BvScrollToTop } from "@baklavue/ui";
|
|
51
|
+
</script>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Props
|
|
55
|
+
|
|
56
|
+
| Prop | Type | Default | Description |
|
|
57
|
+
| ---------- | ------------------- | --------------- | ---------------------------------------------------------- |
|
|
58
|
+
| `threshold` | `number` | `300` | Scroll threshold in pixels before button appears |
|
|
59
|
+
| `position` | `ScrollToTopPosition` | `"bottom-right"` | Fixed position (bottom-right, bottom-left, top-right, top-left) |
|
|
60
|
+
| `label` | `string` | `"Scroll to top"` | Accessible label for screen readers |
|
|
61
|
+
| `size` | `ButtonSize` | `"medium"` | Button size |
|
|
62
|
+
| `variant` | `ButtonVariant` | `"primary"` | Button variant |
|
|
63
|
+
|
|
64
|
+
## Events
|
|
65
|
+
|
|
66
|
+
| Event | Payload | Description |
|
|
67
|
+
| ------- | ------- | --------------------------- |
|
|
68
|
+
| `click` | - | Emitted when button is clicked |
|
|
69
|
+
|
|
70
|
+
## Types
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import type { ScrollToTopProps, ScrollToTopPosition } from "@baklavue/ui";
|
|
74
|
+
|
|
75
|
+
type ScrollToTopPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
76
|
+
|
|
77
|
+
interface ScrollToTopProps {
|
|
78
|
+
threshold?: number;
|
|
79
|
+
position?: ScrollToTopPosition;
|
|
80
|
+
label?: string;
|
|
81
|
+
size?: ButtonSize;
|
|
82
|
+
variant?: ButtonVariant;
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Usage Notes
|
|
87
|
+
|
|
88
|
+
- **Accessibility**: The component includes `role="complementary"` and `aria-label` for screen readers. The `label` prop is passed to the underlying button for additional context.
|
|
89
|
+
- **Window scroll**: The button listens to `window.scrollY` and scrolls the window. For scrollable containers (e.g. `overflow: auto`), consider a custom implementation.
|
|
90
|
+
- **Z-index**: The button uses `z-index: 1000` to stay above most content. Override via CSS if needed.
|