@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,601 @@
|
|
|
1
|
+
# Accordion
|
|
2
|
+
|
|
3
|
+
A Vue UI kit component for Baklava's `bl-accordion` and `bl-accordion-group` components for collapsible content sections. The Accordion component can work in two modes: as a single accordion item or as a group container for multiple accordions.
|
|
4
|
+
|
|
5
|
+
## Single Accordion
|
|
6
|
+
|
|
7
|
+
Use the Accordion component without the `multiple` prop to create a single collapsible section.
|
|
8
|
+
|
|
9
|
+
### Basic Single Accordion
|
|
10
|
+
|
|
11
|
+
<div class="component-demo">
|
|
12
|
+
|
|
13
|
+
<BvAccordion caption="What is BaklaVue?">
|
|
14
|
+
<p style="color:black">
|
|
15
|
+
BaklaVue is a comprehensive Vue 3 UI kit for the Trendyol Baklava
|
|
16
|
+
Design System. It provides Vue-friendly APIs with full TypeScript support.
|
|
17
|
+
</p>
|
|
18
|
+
</BvAccordion>
|
|
19
|
+
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
```vue
|
|
23
|
+
<template>
|
|
24
|
+
<BvAccordion caption="What is BaklaVue?">
|
|
25
|
+
<p>
|
|
26
|
+
BaklaVue is a comprehensive Vue 3 UI kit for the Trendyol Baklava
|
|
27
|
+
Design System. It provides Vue-friendly APIs with full TypeScript support.
|
|
28
|
+
</p>
|
|
29
|
+
</BvAccordion>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<script setup>
|
|
33
|
+
import { BvAccordion } from "@baklavue/ui";
|
|
34
|
+
</script>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### With Icon
|
|
38
|
+
|
|
39
|
+
Add an icon to the accordion header using the `icon` prop.
|
|
40
|
+
|
|
41
|
+
<div class="component-demo">
|
|
42
|
+
|
|
43
|
+
<BvAccordion caption="Settings" icon="settings">
|
|
44
|
+
<p style="color:black">Configure your application settings here.</p>
|
|
45
|
+
</BvAccordion>
|
|
46
|
+
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
```vue
|
|
50
|
+
<template>
|
|
51
|
+
<BvAccordion caption="Settings" icon="settings">
|
|
52
|
+
<p>Configure your application settings here.</p>
|
|
53
|
+
</BvAccordion>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<script setup>
|
|
57
|
+
import { BvAccordion } from "@baklavue/ui";
|
|
58
|
+
</script>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Disabled State
|
|
62
|
+
|
|
63
|
+
Disable an accordion to prevent user interaction.
|
|
64
|
+
|
|
65
|
+
<div class="component-demo">
|
|
66
|
+
|
|
67
|
+
<BvAccordion caption="Disabled Accordion" :disabled="true">
|
|
68
|
+
<p>This content cannot be accessed.</p>
|
|
69
|
+
</BvAccordion>
|
|
70
|
+
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
```vue
|
|
74
|
+
<template>
|
|
75
|
+
<BvAccordion caption="Disabled Accordion" :disabled="true" />
|
|
76
|
+
</template>
|
|
77
|
+
|
|
78
|
+
<script setup>
|
|
79
|
+
import { BvAccordion } from "@baklavue/ui";
|
|
80
|
+
</script>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Accordion Group
|
|
84
|
+
|
|
85
|
+
Use the Accordion component with the `multiple` and `items` props to create a group of accordions. When `multiple` is `false` (default), only one accordion can be open at a time. When `multiple` is `true`, multiple accordions can be open simultaneously. Content for each item is provided via the `#item` scoped slot.
|
|
86
|
+
|
|
87
|
+
### Basic Items Example
|
|
88
|
+
|
|
89
|
+
<div class="component-demo">
|
|
90
|
+
|
|
91
|
+
<BvAccordion :multiple="false" :items="[
|
|
92
|
+
{ caption: 'What is BaklaVue?', content: 'BaklaVue is a comprehensive Vue 3 UI kit for the Trendyol Baklava Design System. It provides Vue-friendly APIs with full TypeScript support.' },
|
|
93
|
+
{ caption: 'How do I install BaklaVue?', content: 'Install BaklaVue using your preferred package manager: bun add @baklavue/ui @baklavue/composables' },
|
|
94
|
+
{ caption: 'Is BaklaVue free to use?', content: 'Yes, BaklaVue is open source and free to use in your projects.' },
|
|
95
|
+
{ caption: 'Does BaklaVue support TypeScript?', content: 'Yes, BaklaVue is built with TypeScript and provides comprehensive type definitions for all components, props, events, and composables.' }
|
|
96
|
+
]">
|
|
97
|
+
<template #item="{ item }">
|
|
98
|
+
<p style="color: black">{{ item.content }}</p>
|
|
99
|
+
</template>
|
|
100
|
+
</BvAccordion>
|
|
101
|
+
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
```vue
|
|
105
|
+
<template>
|
|
106
|
+
<BvAccordion :multiple="false" :items="faqItems">
|
|
107
|
+
<template #item="{ item }">
|
|
108
|
+
<p>{{ item.content }}</p>
|
|
109
|
+
</template>
|
|
110
|
+
</BvAccordion>
|
|
111
|
+
</template>
|
|
112
|
+
|
|
113
|
+
<script setup>
|
|
114
|
+
import { BvAccordion } from "@baklavue/ui";
|
|
115
|
+
|
|
116
|
+
const faqItems = [
|
|
117
|
+
{
|
|
118
|
+
caption: "What is BaklaVue?",
|
|
119
|
+
content:
|
|
120
|
+
"BaklaVue is a comprehensive Vue 3 UI kit for the Trendyol Baklava Design System. It provides Vue-friendly APIs with full TypeScript support.",
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
caption: "How do I install BaklaVue?",
|
|
124
|
+
content:
|
|
125
|
+
"Install BaklaVue using your preferred package manager: bun add @baklavue/ui @baklavue/composables",
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
caption: "Is BaklaVue free to use?",
|
|
129
|
+
content: "Yes, BaklaVue is open source and free to use in your projects.",
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
caption: "Does BaklaVue support TypeScript?",
|
|
133
|
+
content:
|
|
134
|
+
"Yes, BaklaVue is built with TypeScript and provides comprehensive type definitions for all components, props, events, and composables.",
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
</script>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Multiple Open with Items
|
|
141
|
+
|
|
142
|
+
<div class="component-demo">
|
|
143
|
+
|
|
144
|
+
<BvAccordion :multiple="true" :items="[
|
|
145
|
+
{ caption: 'Getting Started', content: 'Learn the basics of BaklaVue and how to set up your project.', open: true },
|
|
146
|
+
{ caption: 'Components', content: 'Explore all available components in the BaklaVue library.' },
|
|
147
|
+
{ caption: 'Composables', content: 'Discover powerful composables for common functionality.' }
|
|
148
|
+
]">
|
|
149
|
+
<template #item="{ item }">
|
|
150
|
+
<p style="color: black">{{ item.content }}</p>
|
|
151
|
+
</template>
|
|
152
|
+
</BvAccordion>
|
|
153
|
+
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
```vue
|
|
157
|
+
<template>
|
|
158
|
+
<BvAccordion :multiple="true" :items="sections">
|
|
159
|
+
<template #item="{ item }">
|
|
160
|
+
<p>{{ item.content }}</p>
|
|
161
|
+
</template>
|
|
162
|
+
</BvAccordion>
|
|
163
|
+
</template>
|
|
164
|
+
|
|
165
|
+
<script setup>
|
|
166
|
+
import { BvAccordion } from "@baklavue/ui";
|
|
167
|
+
|
|
168
|
+
const sections = [
|
|
169
|
+
{
|
|
170
|
+
caption: "Getting Started",
|
|
171
|
+
content: "Learn the basics of BaklaVue and how to set up your project.",
|
|
172
|
+
open: true,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
caption: "Components",
|
|
176
|
+
content: "Explore all available components in the BaklaVue library.",
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
caption: "Composables",
|
|
180
|
+
content: "Discover powerful composables for common functionality.",
|
|
181
|
+
},
|
|
182
|
+
];
|
|
183
|
+
</script>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Items with Icons
|
|
187
|
+
|
|
188
|
+
<div class="component-demo">
|
|
189
|
+
|
|
190
|
+
<BvAccordion :multiple="false" :items="[
|
|
191
|
+
{ caption: 'Dashboard', icon: 'dashboard', content: 'View your dashboard with key metrics and insights.' },
|
|
192
|
+
{ caption: 'Settings', icon: 'settings', content: 'Configure your application settings and preferences.' },
|
|
193
|
+
{ caption: 'Profile', icon: 'user', content: 'Manage your profile information and account details.' }
|
|
194
|
+
]">
|
|
195
|
+
<template #item="{ item }">
|
|
196
|
+
<p style="color: black">{{ item.content }}</p>
|
|
197
|
+
</template>
|
|
198
|
+
</BvAccordion>
|
|
199
|
+
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
```vue
|
|
203
|
+
<template>
|
|
204
|
+
<BvAccordion :multiple="false" :items="menuItems">
|
|
205
|
+
<template #item="{ item }">
|
|
206
|
+
<p>{{ item.content }}</p>
|
|
207
|
+
</template>
|
|
208
|
+
</BvAccordion>
|
|
209
|
+
</template>
|
|
210
|
+
|
|
211
|
+
<script setup>
|
|
212
|
+
import { BvAccordion } from "@baklavue/ui";
|
|
213
|
+
|
|
214
|
+
const menuItems = [
|
|
215
|
+
{
|
|
216
|
+
caption: "Dashboard",
|
|
217
|
+
icon: "dashboard",
|
|
218
|
+
content: "View your dashboard with key metrics and insights.",
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
caption: "Settings",
|
|
222
|
+
icon: "settings",
|
|
223
|
+
content: "Configure your application settings and preferences.",
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
caption: "Profile",
|
|
227
|
+
icon: "user",
|
|
228
|
+
content: "Manage your profile information and account details.",
|
|
229
|
+
},
|
|
230
|
+
];
|
|
231
|
+
</script>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Dynamic Items from API
|
|
235
|
+
|
|
236
|
+
<div class="component-demo">
|
|
237
|
+
|
|
238
|
+
<DynamicItemsDemo />
|
|
239
|
+
|
|
240
|
+
</div>
|
|
241
|
+
|
|
242
|
+
```vue
|
|
243
|
+
<template>
|
|
244
|
+
<div>
|
|
245
|
+
<div v-if="loading">Loading...</div>
|
|
246
|
+
<BvAccordion v-else :multiple="true" :items="accordionItems">
|
|
247
|
+
<template #item="{ item }">
|
|
248
|
+
<p>{{ item.content }}</p>
|
|
249
|
+
</template>
|
|
250
|
+
</BvAccordion>
|
|
251
|
+
</div>
|
|
252
|
+
</template>
|
|
253
|
+
|
|
254
|
+
<script setup>
|
|
255
|
+
import { ref, computed, onMounted } from "vue";
|
|
256
|
+
import { BvAccordion } from "@baklavue/ui";
|
|
257
|
+
|
|
258
|
+
const loading = ref(true);
|
|
259
|
+
const apiData = ref([]);
|
|
260
|
+
|
|
261
|
+
const accordionItems = computed(() => {
|
|
262
|
+
return apiData.value.map((item) => ({
|
|
263
|
+
caption: item.title,
|
|
264
|
+
content: item.description,
|
|
265
|
+
icon: item.icon,
|
|
266
|
+
disabled: item.disabled,
|
|
267
|
+
}));
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
onMounted(async () => {
|
|
271
|
+
// Simulate API call
|
|
272
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
273
|
+
apiData.value = [
|
|
274
|
+
{ title: "Item 1", description: "Description 1", icon: "info" },
|
|
275
|
+
{ title: "Item 2", description: "Description 2", icon: "help" },
|
|
276
|
+
{ title: "Item 3", description: "Description 3", disabled: true },
|
|
277
|
+
];
|
|
278
|
+
loading.value = false;
|
|
279
|
+
});
|
|
280
|
+
</script>
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Custom Content with #item Slot
|
|
284
|
+
|
|
285
|
+
Use the `#item` scoped slot to customize the content of each accordion. The slot receives `{ item, index }` and lets you render complex markup (e.g. code blocks, lists).
|
|
286
|
+
|
|
287
|
+
<div class="component-demo">
|
|
288
|
+
|
|
289
|
+
<SlotsAccordionDemo :multiple="false" />
|
|
290
|
+
|
|
291
|
+
</div>
|
|
292
|
+
|
|
293
|
+
```vue
|
|
294
|
+
<template>
|
|
295
|
+
<BvAccordion :multiple="false" :items="items">
|
|
296
|
+
<template #item="{ item }">
|
|
297
|
+
<p>{{ item.content }}</p>
|
|
298
|
+
</template>
|
|
299
|
+
</BvAccordion>
|
|
300
|
+
</template>
|
|
301
|
+
|
|
302
|
+
<script setup>
|
|
303
|
+
import { BvAccordion } from "@baklavue/ui";
|
|
304
|
+
|
|
305
|
+
const items = [
|
|
306
|
+
{ caption: "Question 1", content: "Answer to question 1 goes here." },
|
|
307
|
+
{ caption: "Question 2", content: "Answer to question 2 goes here." },
|
|
308
|
+
{ caption: "Question 3", content: "Answer to question 3 goes here." },
|
|
309
|
+
];
|
|
310
|
+
</script>
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Complete Examples
|
|
314
|
+
|
|
315
|
+
### FAQ Section with Items Prop
|
|
316
|
+
|
|
317
|
+
A complete FAQ section using the `items` prop with the `#item` slot:
|
|
318
|
+
|
|
319
|
+
<div class="component-demo">
|
|
320
|
+
|
|
321
|
+
<div>
|
|
322
|
+
<h2 style="color: black; margin-bottom: 1rem">Frequently Asked Questions</h2>
|
|
323
|
+
<BvAccordion :multiple="false" :items="[
|
|
324
|
+
{ caption: 'What is BaklaVue?', content: 'BaklaVue is a comprehensive Vue 3 UI kit for the Trendyol Baklava Design System. It provides Vue-friendly APIs with full TypeScript support.' },
|
|
325
|
+
{ caption: 'How do I install BaklaVue?', content: 'Install BaklaVue using your preferred package manager:' },
|
|
326
|
+
{ caption: 'Is BaklaVue free to use?', content: 'Yes, BaklaVue is open source and free to use in your projects.' },
|
|
327
|
+
{ caption: 'Does BaklaVue support TypeScript?', content: 'Yes, BaklaVue is built with TypeScript and provides comprehensive type definitions for all components, props, events, and composables.' }
|
|
328
|
+
]">
|
|
329
|
+
<template #item="{ item }">
|
|
330
|
+
<p style="color: black">{{ item.content }}</p>
|
|
331
|
+
</template>
|
|
332
|
+
</BvAccordion>
|
|
333
|
+
</div>
|
|
334
|
+
|
|
335
|
+
</div>
|
|
336
|
+
|
|
337
|
+
```vue
|
|
338
|
+
<template>
|
|
339
|
+
<div>
|
|
340
|
+
<h2>Frequently Asked Questions</h2>
|
|
341
|
+
<BvAccordion :multiple="false" :items="faqItems">
|
|
342
|
+
<template #item="{ item }">
|
|
343
|
+
<p>{{ item.content }}</p>
|
|
344
|
+
</template>
|
|
345
|
+
</BvAccordion>
|
|
346
|
+
</div>
|
|
347
|
+
</template>
|
|
348
|
+
|
|
349
|
+
<script setup>
|
|
350
|
+
import { BvAccordion } from "@baklavue/ui";
|
|
351
|
+
|
|
352
|
+
const faqItems = [
|
|
353
|
+
{
|
|
354
|
+
caption: "What is BaklaVue?",
|
|
355
|
+
content:
|
|
356
|
+
"BaklaVue is a comprehensive Vue 3 UI kit for the Trendyol Baklava Design System. It provides Vue-friendly APIs with full TypeScript support.",
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
caption: "How do I install BaklaVue?",
|
|
360
|
+
content: "Install BaklaVue using your preferred package manager:",
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
caption: "Is BaklaVue free to use?",
|
|
364
|
+
content: "Yes, BaklaVue is open source and free to use in your projects.",
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
caption: "Does BaklaVue support TypeScript?",
|
|
368
|
+
content:
|
|
369
|
+
"Yes, BaklaVue is built with TypeScript and provides comprehensive type definitions for all components, props, events, and composables.",
|
|
370
|
+
},
|
|
371
|
+
];
|
|
372
|
+
</script>
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### FAQ Section with Complex Content (Code Blocks)
|
|
376
|
+
|
|
377
|
+
Use the `#item` slot for items that need custom markup like code blocks:
|
|
378
|
+
|
|
379
|
+
<div class="component-demo">
|
|
380
|
+
|
|
381
|
+
<FaqSlotsDemo />
|
|
382
|
+
|
|
383
|
+
</div>
|
|
384
|
+
|
|
385
|
+
```vue
|
|
386
|
+
<template>
|
|
387
|
+
<div>
|
|
388
|
+
<h2>Frequently Asked Questions</h2>
|
|
389
|
+
<BvAccordion :multiple="false" :items="faqItems">
|
|
390
|
+
<template #item="{ item }">
|
|
391
|
+
<div v-if="item.code">
|
|
392
|
+
<p>{{ item.content }}</p>
|
|
393
|
+
<pre><code>{{ item.code }}</code></pre>
|
|
394
|
+
</div>
|
|
395
|
+
<p v-else>{{ item.content }}</p>
|
|
396
|
+
</template>
|
|
397
|
+
</BvAccordion>
|
|
398
|
+
</div>
|
|
399
|
+
</template>
|
|
400
|
+
|
|
401
|
+
<script setup>
|
|
402
|
+
import { BvAccordion } from "@baklavue/ui";
|
|
403
|
+
|
|
404
|
+
const faqItems = [
|
|
405
|
+
{
|
|
406
|
+
caption: "What is BaklaVue?",
|
|
407
|
+
content:
|
|
408
|
+
"BaklaVue is a comprehensive Vue 3 UI kit for the Trendyol Baklava Design System.",
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
caption: "How do I install BaklaVue?",
|
|
412
|
+
content: "Install BaklaVue using your preferred package manager:",
|
|
413
|
+
code: "bun add @baklavue/ui @baklavue/composables",
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
caption: "Is BaklaVue free to use?",
|
|
417
|
+
content: "Yes, BaklaVue is open source and free to use in your projects.",
|
|
418
|
+
},
|
|
419
|
+
];
|
|
420
|
+
</script>
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
## Programmatic Control
|
|
424
|
+
|
|
425
|
+
Access accordion methods programmatically using template refs (single accordion mode only).
|
|
426
|
+
|
|
427
|
+
<div class="component-demo">
|
|
428
|
+
|
|
429
|
+
<ProgrammaticControlDemo />
|
|
430
|
+
|
|
431
|
+
</div>
|
|
432
|
+
|
|
433
|
+
```vue
|
|
434
|
+
<template>
|
|
435
|
+
<div>
|
|
436
|
+
<div style="margin-bottom: 1rem; display: flex; gap: 0.5rem;">
|
|
437
|
+
<BvButton @click="expandAccordion">Expand</BvButton>
|
|
438
|
+
<BvButton @click="collapseAccordion">Collapse</BvButton>
|
|
439
|
+
</div>
|
|
440
|
+
<BvAccordion
|
|
441
|
+
ref="accordionRef"
|
|
442
|
+
:open="isOpen"
|
|
443
|
+
@toggle="isOpen = $event"
|
|
444
|
+
caption="Programmatically Controlled Accordion"
|
|
445
|
+
>
|
|
446
|
+
<p>This accordion can be controlled via buttons or programmatically.</p>
|
|
447
|
+
</BvAccordion>
|
|
448
|
+
</div>
|
|
449
|
+
</template>
|
|
450
|
+
|
|
451
|
+
<script setup>
|
|
452
|
+
import { ref } from "vue";
|
|
453
|
+
import { BvAccordion, BvButton } from "@baklavue/ui";
|
|
454
|
+
|
|
455
|
+
const accordionRef = ref();
|
|
456
|
+
const isOpen = ref(false);
|
|
457
|
+
|
|
458
|
+
const expandAccordion = () => {
|
|
459
|
+
accordionRef.value?.expand();
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
const collapseAccordion = () => {
|
|
463
|
+
accordionRef.value?.collapse();
|
|
464
|
+
};
|
|
465
|
+
</script>
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
## Custom Animation Duration
|
|
469
|
+
|
|
470
|
+
Control the expand/collapse animation duration.
|
|
471
|
+
|
|
472
|
+
<div class="component-demo">
|
|
473
|
+
|
|
474
|
+
<CustomAnimationDemo />
|
|
475
|
+
|
|
476
|
+
</div>
|
|
477
|
+
|
|
478
|
+
```vue
|
|
479
|
+
<template>
|
|
480
|
+
<BvAccordion
|
|
481
|
+
caption="Slow Animation"
|
|
482
|
+
:animation-duration="500"
|
|
483
|
+
:open="isOpen"
|
|
484
|
+
@toggle="isOpen = $event"
|
|
485
|
+
>
|
|
486
|
+
<p>This accordion has a slower animation (500ms).</p>
|
|
487
|
+
</BvAccordion>
|
|
488
|
+
</template>
|
|
489
|
+
|
|
490
|
+
<script setup>
|
|
491
|
+
import { ref } from "vue";
|
|
492
|
+
import { BvAccordion } from "@baklavue/ui";
|
|
493
|
+
|
|
494
|
+
const isOpen = ref(false);
|
|
495
|
+
</script>
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
## Props
|
|
499
|
+
|
|
500
|
+
### Single Accordion Mode Props
|
|
501
|
+
|
|
502
|
+
When used as a single accordion (without `multiple` prop):
|
|
503
|
+
|
|
504
|
+
| Prop | Type | Default | Description |
|
|
505
|
+
| ------------------- | ------------------------ | ----------- | ----------------------------------------------------------------------------- |
|
|
506
|
+
| `open` | `boolean` | `false` | Whether the accordion is open/expanded |
|
|
507
|
+
| `caption` | `string` | `undefined` | The caption text displayed in the accordion header |
|
|
508
|
+
| `icon` | `boolean \| BaklavaIcon` | `undefined` | Icon configuration - boolean to show/hide default icon, or specific icon name |
|
|
509
|
+
| `disabled` | `boolean` | `false` | Whether the accordion is disabled |
|
|
510
|
+
| `animationDuration` | `number` | `250` | Duration of the expand/collapse animation in milliseconds |
|
|
511
|
+
|
|
512
|
+
### Group Mode Props
|
|
513
|
+
|
|
514
|
+
When used as an accordion group (with `multiple` prop):
|
|
515
|
+
|
|
516
|
+
| Prop | Type | Default | Description |
|
|
517
|
+
| ---------- | ----------------- | ----------- | ---------------------------------------------------------------------------------------- |
|
|
518
|
+
| `multiple` | `boolean` | `false` | Allow multiple accordions to be open at once |
|
|
519
|
+
| `items` | `AccordionItem[]` | `undefined` | Array of accordion items to render. Each item will be rendered as a bl-accordion element |
|
|
520
|
+
|
|
521
|
+
### AccordionItem Interface
|
|
522
|
+
|
|
523
|
+
When using the `items` prop, each item should follow the `AccordionItem` interface. Items include all bl-accordion props; content is provided via the `#item` scoped slot.
|
|
524
|
+
|
|
525
|
+
| Property | Type | Default | Description |
|
|
526
|
+
| ------------------- | ------------------------ | ----------- | --------------------------------------------------------------------------------- |
|
|
527
|
+
| `open` | `boolean` | `false` | Whether the accordion is open/expanded |
|
|
528
|
+
| `caption` | `string` | `undefined` | The caption text displayed in the accordion header |
|
|
529
|
+
| `icon` | `boolean \| BaklavaIcon` | `undefined` | Icon configuration - boolean to show/hide default icon, or specific icon name |
|
|
530
|
+
| `disabled` | `boolean` | `false` | Whether the accordion is disabled |
|
|
531
|
+
| `animationDuration` | `number` | `250` | Duration of the expand/collapse animation in milliseconds |
|
|
532
|
+
|
|
533
|
+
Items may include additional custom data for use in the `#item` slot (e.g. `content`, `description`, `code`).
|
|
534
|
+
|
|
535
|
+
## Events
|
|
536
|
+
|
|
537
|
+
### Single Accordion Mode Events
|
|
538
|
+
|
|
539
|
+
When used as a single accordion:
|
|
540
|
+
|
|
541
|
+
| Event | Payload | Description |
|
|
542
|
+
| -------- | --------- | ------------------------------------------------------------------------- |
|
|
543
|
+
| `toggle` | `boolean` | Emitted when the accordion is toggled. The payload is the new open state. |
|
|
544
|
+
|
|
545
|
+
## Methods
|
|
546
|
+
|
|
547
|
+
### Single Accordion Mode Methods
|
|
548
|
+
|
|
549
|
+
When used as a single accordion, you can access these methods via template refs:
|
|
550
|
+
|
|
551
|
+
| Method | Description |
|
|
552
|
+
| ------------ | ---------------------------------------- |
|
|
553
|
+
| `expand()` | Expands the accordion programmatically |
|
|
554
|
+
| `collapse()` | Collapses the accordion programmatically |
|
|
555
|
+
|
|
556
|
+
## Slots
|
|
557
|
+
|
|
558
|
+
| Slot | Props | Description |
|
|
559
|
+
| --------- | ------------------ | --------------------------------------------------------------------------- |
|
|
560
|
+
| `default` | - | Content displayed when accordion is expanded (single accordion mode only) |
|
|
561
|
+
| `item` | `{ item, index }` | Scoped slot for each accordion item content in group mode |
|
|
562
|
+
|
|
563
|
+
## Types
|
|
564
|
+
|
|
565
|
+
```typescript
|
|
566
|
+
import type { AccordionProps, AccordionItem } from "@baklavue/ui";
|
|
567
|
+
|
|
568
|
+
interface AccordionItem {
|
|
569
|
+
open?: boolean;
|
|
570
|
+
caption?: string;
|
|
571
|
+
icon?: boolean | BaklavaIcon;
|
|
572
|
+
disabled?: boolean;
|
|
573
|
+
animationDuration?: number;
|
|
574
|
+
[key: string]: unknown; // Additional custom data for #item slot
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
interface AccordionProps {
|
|
578
|
+
// Single accordion mode props
|
|
579
|
+
open?: boolean;
|
|
580
|
+
caption?: string;
|
|
581
|
+
icon?: boolean | BaklavaIcon;
|
|
582
|
+
disabled?: boolean;
|
|
583
|
+
animationDuration?: number;
|
|
584
|
+
|
|
585
|
+
// Group mode props
|
|
586
|
+
multiple?: boolean;
|
|
587
|
+
items?: AccordionItem[];
|
|
588
|
+
}
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
## Usage Notes
|
|
592
|
+
|
|
593
|
+
- **Single vs Group Mode**: The component automatically switches between single accordion mode and group mode based on whether the `multiple` prop is provided. When `multiple` is `undefined`, it acts as a single accordion. When `multiple` is provided (even if `false`), it acts as a group container using the `items` prop.
|
|
594
|
+
|
|
595
|
+
- **Items Prop Required**: In group mode, accordions are rendered from the `items` prop. There is no default slot for nested accordion children. Content for each item is provided via the `#item` scoped slot.
|
|
596
|
+
|
|
597
|
+
- **State Management**: With the `items` prop, you can control the initial `open` state directly in the items array. In group mode, the underlying `bl-accordion-group` manages which accordions are open.
|
|
598
|
+
|
|
599
|
+
- **Accessibility**: The component follows Baklava's accessibility guidelines and includes proper ARIA attributes for screen readers.
|
|
600
|
+
|
|
601
|
+
- **Styling**: The component uses Baklava's default styling. Custom styling can be applied through CSS variables or by overriding the component styles.
|