@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,78 @@
|
|
|
1
|
+
# useIntervalFn / useTimeoutFn
|
|
2
|
+
|
|
3
|
+
Pausable interval and cancellable timeout. Useful for polling, countdown timers, and delayed execution.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
### useIntervalFn
|
|
8
|
+
|
|
9
|
+
Returns an object with `pause`, `resume`, and `isActive`. Useful for polling and auto-refresh.
|
|
10
|
+
|
|
11
|
+
```vue
|
|
12
|
+
<script setup>
|
|
13
|
+
import { onMounted } from "vue";
|
|
14
|
+
import { useIntervalFn } from "@baklavue/composables";
|
|
15
|
+
|
|
16
|
+
const { pause, resume, isActive } = useIntervalFn(() => {
|
|
17
|
+
fetchLatestData();
|
|
18
|
+
}, 5000);
|
|
19
|
+
|
|
20
|
+
// Pause when tab is hidden
|
|
21
|
+
onMounted(() => {
|
|
22
|
+
document.addEventListener("visibilitychange", () => {
|
|
23
|
+
document.hidden ? pause() : resume();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
</script>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### useTimeoutFn
|
|
30
|
+
|
|
31
|
+
Returns an object with `run`, `cancel`, and `isPending`. Useful for delayed execution.
|
|
32
|
+
|
|
33
|
+
```vue
|
|
34
|
+
<script setup>
|
|
35
|
+
import { useNotification } from "@baklavue/composables";
|
|
36
|
+
import { useTimeoutFn } from "@baklavue/composables";
|
|
37
|
+
|
|
38
|
+
const { success } = useNotification();
|
|
39
|
+
const { run } = useTimeoutFn(() => {
|
|
40
|
+
success({ description: "Saved!" });
|
|
41
|
+
}, 2000);
|
|
42
|
+
|
|
43
|
+
const handleSave = async () => {
|
|
44
|
+
await saveData();
|
|
45
|
+
run();
|
|
46
|
+
};
|
|
47
|
+
</script>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## API
|
|
51
|
+
|
|
52
|
+
### useIntervalFn
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
useIntervalFn(
|
|
56
|
+
callback: () => void,
|
|
57
|
+
interval: number,
|
|
58
|
+
options?: { immediate?: boolean }
|
|
59
|
+
): { pause: () => void; resume: () => void; isActive: Ref<boolean> }
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- `callback` — Function to execute on each tick
|
|
63
|
+
- `interval` — Interval in milliseconds
|
|
64
|
+
- `options.immediate` — Run callback on start. Default: true
|
|
65
|
+
- Returns `{ pause, resume, isActive }`
|
|
66
|
+
|
|
67
|
+
### useTimeoutFn
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
useTimeoutFn(
|
|
71
|
+
callback: () => void,
|
|
72
|
+
delay: number
|
|
73
|
+
): { run: () => void; cancel: () => void; isPending: Ref<boolean> }
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
- `callback` — Function to execute after delay
|
|
77
|
+
- `delay` — Delay in milliseconds
|
|
78
|
+
- Returns `{ run, cancel, isPending }`
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# useToggle
|
|
2
|
+
|
|
3
|
+
A composable for a simple boolean toggle. Lighter than `useDisclosure` when you only need a toggle without open/close semantics. Use `useDisclosure` for Dialog, Drawer, Dropdown.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<button @click="toggle">{{ value ? "Hide" : "Show" }}</button>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup>
|
|
13
|
+
import { useToggle } from "@baklavue/composables";
|
|
14
|
+
|
|
15
|
+
const [value, toggle] = useToggle(false);
|
|
16
|
+
</script>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Set Explicitly
|
|
20
|
+
|
|
21
|
+
```vue
|
|
22
|
+
<script setup>
|
|
23
|
+
import { useToggle } from "@baklavue/composables";
|
|
24
|
+
|
|
25
|
+
const [darkMode, setDarkMode] = useToggle(true);
|
|
26
|
+
|
|
27
|
+
setDarkMode(false); // set explicitly
|
|
28
|
+
setDarkMode(true);
|
|
29
|
+
</script>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## API
|
|
33
|
+
|
|
34
|
+
### Arguments
|
|
35
|
+
|
|
36
|
+
| Argument | Type | Default | Description |
|
|
37
|
+
| --- | --- | --- | --- |
|
|
38
|
+
| `initial` | `boolean` | `false` | Initial boolean value |
|
|
39
|
+
|
|
40
|
+
### Return Value
|
|
41
|
+
|
|
42
|
+
| Property | Type | Description |
|
|
43
|
+
| --- | --- | --- |
|
|
44
|
+
| `[0]` | `Ref<boolean>` | The boolean value |
|
|
45
|
+
| `[1]` | `(value?: boolean) => void` | Toggle function. Call with no args to flip, or with a boolean to set |
|
|
46
|
+
|
|
47
|
+
## TypeScript Support
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { useToggle } from "@baklavue/composables";
|
|
51
|
+
|
|
52
|
+
const [value, toggle] = useToggle(false);
|
|
53
|
+
toggle(); // flips
|
|
54
|
+
toggle(true); // sets to true
|
|
55
|
+
```
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to BaklaVue! This guide covers the development setup, workflow, conventions, and how to add new components and composables.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Development Setup](#development-setup)
|
|
8
|
+
- [Development Workflow](#development-workflow)
|
|
9
|
+
- [Adding New Components](#adding-new-components)
|
|
10
|
+
- [Adding New Composables](#adding-new-composables)
|
|
11
|
+
- [Documentation](#documentation)
|
|
12
|
+
- [Code Style](#code-style)
|
|
13
|
+
- [Testing](#testing)
|
|
14
|
+
- [Release Process](#release-process)
|
|
15
|
+
- [Getting Help](#getting-help)
|
|
16
|
+
|
|
17
|
+
## Development Setup
|
|
18
|
+
|
|
19
|
+
### Prerequisites
|
|
20
|
+
|
|
21
|
+
- **Bun** (recommended) or **Node.js 20.8.1+** — The project uses Bun for package management
|
|
22
|
+
- **Git** — For version control
|
|
23
|
+
- **Code editor** — VS Code recommended; the project uses TypeScript and Vue
|
|
24
|
+
|
|
25
|
+
### Clone and Install
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Clone the repository
|
|
29
|
+
git clone https://github.com/erbilnas/baklavue.git
|
|
30
|
+
cd baklavue
|
|
31
|
+
|
|
32
|
+
# Install dependencies (uses Bun workspaces)
|
|
33
|
+
bun install
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Project Structure
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
baklavue/
|
|
40
|
+
├── packages/
|
|
41
|
+
│ ├── ui/ # @baklavue/ui — Vue UI components
|
|
42
|
+
│ │ ├── src/
|
|
43
|
+
│ │ │ ├── accordion/ # One folder per component
|
|
44
|
+
│ │ │ ├── button/
|
|
45
|
+
│ │ │ ├── input/
|
|
46
|
+
│ │ │ ├── ...
|
|
47
|
+
│ │ │ ├── utils/ # Shared utilities (e.g. loadBaklavaResources)
|
|
48
|
+
│ │ │ └── index.ts # Main exports
|
|
49
|
+
│ │ ├── package.json
|
|
50
|
+
│ │ └── tsconfig.json
|
|
51
|
+
│ │
|
|
52
|
+
│ └── composables/ # @baklavue/composables
|
|
53
|
+
│ ├── theme.ts
|
|
54
|
+
│ ├── notification.ts
|
|
55
|
+
│ ├── file.ts
|
|
56
|
+
│ ├── scrollToError.ts
|
|
57
|
+
│ ├── index.ts
|
|
58
|
+
│ └── package.json
|
|
59
|
+
│
|
|
60
|
+
├── docs/ # VitePress documentation site
|
|
61
|
+
│ ├── .vitepress/
|
|
62
|
+
│ ├── components/ # Component docs
|
|
63
|
+
│ ├── composables/ # Composable docs
|
|
64
|
+
│ ├── guide/ # Getting started, installation, contributing
|
|
65
|
+
│ ├── tokens/ # Design token docs
|
|
66
|
+
│ └── package.json
|
|
67
|
+
│
|
|
68
|
+
├── scripts/
|
|
69
|
+
│ └── commit.sh # Conventional commit helper
|
|
70
|
+
├── .github/workflows/ # CI (release, deploy docs)
|
|
71
|
+
├── package.json # Root workspace config
|
|
72
|
+
└── tsconfig.json
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Run the Documentation Site
|
|
76
|
+
|
|
77
|
+
The docs site doubles as a development playground. Run it to test components live:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
bun run docs:dev
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
This starts the VitePress dev server (typically at `http://localhost:5173`). Components are loaded from the workspace packages, so changes in `packages/ui` or `packages/composables` are reflected immediately with hot reload.
|
|
84
|
+
|
|
85
|
+
## Development Workflow
|
|
86
|
+
|
|
87
|
+
### 1. Create a Branch
|
|
88
|
+
|
|
89
|
+
Create a feature or fix branch from `main`:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
git checkout main
|
|
93
|
+
git pull origin main
|
|
94
|
+
git checkout -b feat/your-feature-name
|
|
95
|
+
# or
|
|
96
|
+
git checkout -b fix/issue-description
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Branch naming conventions:
|
|
100
|
+
|
|
101
|
+
- `feat/` — New features
|
|
102
|
+
- `fix/` — Bug fixes
|
|
103
|
+
- `docs/` — Documentation only
|
|
104
|
+
- `refactor/` — Code refactoring
|
|
105
|
+
|
|
106
|
+
### 2. Make Changes
|
|
107
|
+
|
|
108
|
+
- Follow existing code style and patterns
|
|
109
|
+
- Add TypeScript types for all new code
|
|
110
|
+
- Update documentation when adding or changing components or composables
|
|
111
|
+
- Ensure Baklava resources are loaded (either via component mount or manually)
|
|
112
|
+
|
|
113
|
+
### 3. Verify the Build
|
|
114
|
+
|
|
115
|
+
Build the docs site to ensure everything compiles:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
bun run docs:build
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
If the build succeeds, TypeScript and Vue components are compiling correctly.
|
|
122
|
+
|
|
123
|
+
### 4. Test in the Docs Site
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
bun run docs:dev
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Open the docs, navigate to relevant component or composable pages, and verify behavior and styling.
|
|
130
|
+
|
|
131
|
+
### 5. Commit Changes
|
|
132
|
+
|
|
133
|
+
Use [Conventional Commits](https://www.conventionalcommits.org/):
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
<type>[optional scope]: <description>
|
|
137
|
+
|
|
138
|
+
[optional body]
|
|
139
|
+
|
|
140
|
+
[optional footer(s)]
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Types:**
|
|
144
|
+
|
|
145
|
+
| Type | Purpose | Release impact |
|
|
146
|
+
| ---- | ------- | -------------- |
|
|
147
|
+
| `feat` | New feature | Minor |
|
|
148
|
+
| `fix` | Bug fix | Patch |
|
|
149
|
+
| `docs` | Documentation only | — |
|
|
150
|
+
| `style` | Formatting, whitespace | — |
|
|
151
|
+
| `refactor` | Code change, no behavior change | — |
|
|
152
|
+
| `perf` | Performance improvement | Patch |
|
|
153
|
+
| `test` | Tests | — |
|
|
154
|
+
| `chore` | Build, tooling | — |
|
|
155
|
+
|
|
156
|
+
**Examples:**
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
git commit -m "feat: add new button variant"
|
|
160
|
+
git commit -m "fix(ui): resolve button alignment issue"
|
|
161
|
+
git commit -m "docs: update installation guide"
|
|
162
|
+
git commit -m "feat(composables): add useNotification hook"
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Optional:** Use the commit helper script:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
./scripts/commit.sh feat add new button variant
|
|
169
|
+
./scripts/commit.sh fix ui resolve alignment issue
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### 6. Push and Create a Pull Request
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
git push origin feat/your-feature-name
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Then open a pull request on GitHub. Provide:
|
|
179
|
+
|
|
180
|
+
- A clear title and description
|
|
181
|
+
- What changed and why
|
|
182
|
+
- Any screenshots or examples for UI changes
|
|
183
|
+
|
|
184
|
+
## Adding New Components
|
|
185
|
+
|
|
186
|
+
### Component Structure
|
|
187
|
+
|
|
188
|
+
Each component lives in its own directory under `packages/ui/src/`:
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
packages/ui/src/my-component/
|
|
192
|
+
├── MyComponent.vue # Vue component
|
|
193
|
+
├── my-component.types.ts # TypeScript interfaces
|
|
194
|
+
└── index.ts # Exports (must use Bv prefix)
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Step-by-Step: Create a New Component
|
|
198
|
+
|
|
199
|
+
#### 1. Create the directory and files
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
mkdir -p packages/ui/src/my-component
|
|
203
|
+
touch packages/ui/src/my-component/MyComponent.vue
|
|
204
|
+
touch packages/ui/src/my-component/my-component.types.ts
|
|
205
|
+
touch packages/ui/src/my-component/index.ts
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
#### 2. Define types in `my-component.types.ts`
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
export interface MyComponentProps {
|
|
212
|
+
label?: string;
|
|
213
|
+
disabled?: boolean;
|
|
214
|
+
// ... other props matching the Baklava web component
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
#### 3. Implement the component in `MyComponent.vue`
|
|
219
|
+
|
|
220
|
+
```vue
|
|
221
|
+
<script setup lang="ts">
|
|
222
|
+
import { onMounted } from "vue";
|
|
223
|
+
import { loadBaklavaResources } from "../utils/loadBaklavaResources";
|
|
224
|
+
import type { MyComponentProps } from "./my-component.types";
|
|
225
|
+
|
|
226
|
+
const props = withDefaults(defineProps<MyComponentProps>(), {
|
|
227
|
+
// default values
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
const emit = defineEmits<{
|
|
231
|
+
change: [value: string];
|
|
232
|
+
}>();
|
|
233
|
+
|
|
234
|
+
onMounted(() => {
|
|
235
|
+
loadBaklavaResources();
|
|
236
|
+
});
|
|
237
|
+
</script>
|
|
238
|
+
|
|
239
|
+
<template>
|
|
240
|
+
<bl-my-component
|
|
241
|
+
v-bind="props"
|
|
242
|
+
@bl-change="emit('change', $event.detail)"
|
|
243
|
+
>
|
|
244
|
+
<slot />
|
|
245
|
+
</bl-my-component>
|
|
246
|
+
</template>
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### 4. Export from `index.ts` (with Bv prefix)
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
export { default as BvMyComponent } from "./MyComponent.vue";
|
|
253
|
+
export type { MyComponentProps } from "./my-component.types";
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
#### 5. Register in `packages/ui/src/index.ts`
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
export * from "./my-component";
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Component Guidelines
|
|
263
|
+
|
|
264
|
+
- **Bv prefix:** All components must be exported with the `Bv` prefix (e.g. `BvButton`, `BvInput`).
|
|
265
|
+
- **Wrap Baklava web components:** Use the corresponding `bl-*` custom element; do not reimplement from scratch.
|
|
266
|
+
- **Load resources:** Call `loadBaklavaResources()` in `onMounted` so scripts and styles are available.
|
|
267
|
+
- **TypeScript:** Provide prop and event types in a `.types.ts` file.
|
|
268
|
+
- **Composition API:** Use Vue 3 Composition API with `<script setup>`.
|
|
269
|
+
- **Events:** Map Baklava events (e.g. `bl-click`) to Vue emits (e.g. `click`).
|
|
270
|
+
- **v-model:** Support `v-model` where appropriate (e.g. input value, checkbox checked).
|
|
271
|
+
- **JSDoc:** Add JSDoc for non-obvious props and complex logic.
|
|
272
|
+
|
|
273
|
+
### Checking Baklava Component API
|
|
274
|
+
|
|
275
|
+
Consult the [Baklava Design System](https://baklava.design) and the [@trendyol/baklava](https://www.npmjs.com/package/@trendyol/baklava) package to see:
|
|
276
|
+
|
|
277
|
+
- Available `bl-*` elements and their attributes
|
|
278
|
+
- Events (typically prefixed with `bl-`)
|
|
279
|
+
- Slots and structure
|
|
280
|
+
|
|
281
|
+
## Adding New Composables
|
|
282
|
+
|
|
283
|
+
### Structure
|
|
284
|
+
|
|
285
|
+
1. Create the file in `packages/composables/`:
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
// packages/composables/myComposable.ts
|
|
289
|
+
export const useMyComposable = () => {
|
|
290
|
+
// composable logic
|
|
291
|
+
return {
|
|
292
|
+
doSomething: () => {},
|
|
293
|
+
state: ref(0),
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
2. Export from `packages/composables/index.ts`:
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
export { useMyComposable } from "./myComposable";
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Guidelines
|
|
305
|
+
|
|
306
|
+
- Use Vue 3 Composition API patterns
|
|
307
|
+
- Export named functions (e.g. `useMyComposable`)
|
|
308
|
+
- Provide TypeScript types for arguments and return values
|
|
309
|
+
- Add JSDoc for public API
|
|
310
|
+
|
|
311
|
+
## Documentation
|
|
312
|
+
|
|
313
|
+
When adding or modifying components or composables:
|
|
314
|
+
|
|
315
|
+
1. **Component docs:** Add or update `docs/components/<component>.md`.
|
|
316
|
+
2. **Composable docs:** Add or update `docs/composables/<composable>.md`.
|
|
317
|
+
3. **Include:**
|
|
318
|
+
- Description and usage
|
|
319
|
+
- Code examples (with `<script setup>` and `<template>`)
|
|
320
|
+
- Props, events, and slots tables
|
|
321
|
+
- TypeScript usage examples where relevant
|
|
322
|
+
|
|
323
|
+
4. **Sidebar:** Update `docs/.vitepress/config.ts` if adding new pages.
|
|
324
|
+
|
|
325
|
+
5. **Demo components:** For complex demos, add Vue components in `docs/.vitepress/theme/components/` and register them in the theme.
|
|
326
|
+
|
|
327
|
+
## Code Style
|
|
328
|
+
|
|
329
|
+
- **TypeScript:** Use TypeScript for all new code; avoid `any` where possible.
|
|
330
|
+
- **Composition API:** Prefer `<script setup>` and Composition API.
|
|
331
|
+
- **Naming:** Use clear, descriptive names for variables and functions.
|
|
332
|
+
- **Comments:** Document complex logic; keep comments up to date.
|
|
333
|
+
- **Single-purpose:** Keep components and composables focused.
|
|
334
|
+
|
|
335
|
+
## Testing
|
|
336
|
+
|
|
337
|
+
- **Manual testing:** Use the docs site (`bun run docs:dev`) to verify components.
|
|
338
|
+
- **Build:** Ensure `bun run docs:build` completes successfully.
|
|
339
|
+
- **Baklava resources:** Confirm components render correctly and styles load.
|
|
340
|
+
- **Different scenarios:** Test with various props, slots, and edge cases.
|
|
341
|
+
|
|
342
|
+
## Release Process
|
|
343
|
+
|
|
344
|
+
BaklaVue uses [Semantic Release](https://semantic-release.gitbook.io/) for versioning:
|
|
345
|
+
|
|
346
|
+
- Commits follow [Conventional Commits](https://www.conventionalcommits.org/)
|
|
347
|
+
- Pushing to `main` triggers the release workflow
|
|
348
|
+
- Versions are derived from commit types (`feat` → minor, `fix` → patch)
|
|
349
|
+
- Changelogs are generated from commit messages
|
|
350
|
+
|
|
351
|
+
See the [Release Guide](/release/guide) for:
|
|
352
|
+
|
|
353
|
+
- Commit message format
|
|
354
|
+
- Breaking changes (`!` suffix)
|
|
355
|
+
- Manual release and dry-run
|
|
356
|
+
- Package-specific releases
|
|
357
|
+
|
|
358
|
+
## Getting Help
|
|
359
|
+
|
|
360
|
+
- **Issues:** Open an issue on [GitHub](https://github.com/erbilnas/baklavue/issues)
|
|
361
|
+
- **Documentation:** Check the [docs](/guide/getting-started) and [API Reference](/api/)
|
|
362
|
+
- **Examples:** Review existing components in `packages/ui/src/` for patterns
|
|
363
|
+
|
|
364
|
+
Thank you for contributing to BaklaVue!
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Design Tokens
|
|
2
|
+
|
|
3
|
+
BaklaVue uses the [Baklava Design System](https://baklava.design) tokens. You can customize them via `useBaklavaTheme().applyTheme()` for a consistent, branded look.
|
|
4
|
+
|
|
5
|
+
## Token Categories
|
|
6
|
+
|
|
7
|
+
| Category | Description | Docs |
|
|
8
|
+
| -------- | ----------- | ---- |
|
|
9
|
+
| [Colors](/tokens/colors) | Primary, semantic, and neutral colors | [Colors →](/tokens/colors) |
|
|
10
|
+
| [Border Radius](/tokens/border-radius) | Corner roundness for components | [Border Radius →](/tokens/border-radius) |
|
|
11
|
+
| [Size & Spacing](/tokens/size-spacing) | Sizes and spacing scale | [Size & Spacing →](/tokens/size-spacing) |
|
|
12
|
+
| [Typography](/tokens/typography) | Font family, size, and weight | [Typography →](/tokens/typography) |
|
|
13
|
+
| [Z-Index](/tokens/z-index) | Layering for overlays and dialogs | [Z-Index →](/tokens/z-index) |
|
|
14
|
+
|
|
15
|
+
## Quick Example
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<script setup>
|
|
19
|
+
import { useBaklavaTheme } from "@baklavue/composables";
|
|
20
|
+
|
|
21
|
+
useBaklavaTheme().applyTheme({
|
|
22
|
+
preset: "vue",
|
|
23
|
+
borderRadius: { m: "0.5rem" },
|
|
24
|
+
typography: { fontFamily: "'Inter', sans-serif" },
|
|
25
|
+
});
|
|
26
|
+
</script>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
See [useBaklavaTheme](/composables/theme) for the full API.
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
::: tip Disclaimer
|
|
4
|
+
BaklaVue builds on [@trendyol/baklava](https://www.npmjs.com/package/@trendyol/baklava) v3.4.2. Not all Baklava components and features are yet available in BaklaVue. Check the [components list](/components/) for what's supported. Contributions welcome.
|
|
5
|
+
:::
|
|
6
|
+
|
|
7
|
+
BaklaVue is a Vue 3 UI kit that brings the [Trendyol Baklava Design System](https://baklava.design) to Vue applications. It provides Vue-native wrappers around Baklava's web components, offering full TypeScript support, Vue 3 Composition API patterns, and composables for common use cases.
|
|
8
|
+
|
|
9
|
+
This guide walks you through setting up BaklaVue in a new or existing Vue 3 project and building your first components.
|
|
10
|
+
|
|
11
|
+
## What is BaklaVue?
|
|
12
|
+
|
|
13
|
+
BaklaVue consists of two packages:
|
|
14
|
+
|
|
15
|
+
| Package | Purpose |
|
|
16
|
+
| ------- | ------- |
|
|
17
|
+
| `@baklavue/ui` | Vue components that wrap Baklava web components (`bl-*` custom elements) |
|
|
18
|
+
| `@baklavue/composables` | Vue composables for theming, notifications, CSV parsing, form validation, and more |
|
|
19
|
+
|
|
20
|
+
Each UI component loads Baklava resources (script and styles) when mounted, so you don't need to manually include them in your app. Components use the `Bv` prefix (e.g. `BvButton`, `BvInput`) to avoid naming conflicts and follow a consistent convention.
|
|
21
|
+
|
|
22
|
+
## Prerequisites
|
|
23
|
+
|
|
24
|
+
Before installing BaklaVue, ensure your project meets these requirements:
|
|
25
|
+
|
|
26
|
+
- **Vue 3.0+** — BaklaVue targets Vue 3 and uses the Composition API
|
|
27
|
+
- **Node.js 18+** or **Bun** — For package installation and builds
|
|
28
|
+
- **TypeScript 5.9.2+** (recommended) — Full type definitions are provided
|
|
29
|
+
- **Vite** or **Nuxt 3** — Officially supported; Vue CLI works with additional configuration
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
Install both packages with your preferred package manager:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Using npm
|
|
37
|
+
npm install @baklavue/ui @baklavue/composables
|
|
38
|
+
|
|
39
|
+
# Using yarn
|
|
40
|
+
yarn add @baklavue/ui @baklavue/composables
|
|
41
|
+
|
|
42
|
+
# Using pnpm
|
|
43
|
+
pnpm add @baklavue/ui @baklavue/composables
|
|
44
|
+
|
|
45
|
+
# Using bun
|
|
46
|
+
bun add @baklavue/ui @baklavue/composables
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
For detailed installation steps, framework-specific setup, and troubleshooting, see the [Installation Guide](/guide/installation).
|
|
50
|
+
|
|
51
|
+
## Basic Usage
|
|
52
|
+
|
|
53
|
+
### 1. Import and Use Components
|
|
54
|
+
|
|
55
|
+
Components are imported individually. Use the `Bv` prefix when importing:
|
|
56
|
+
|
|
57
|
+
```vue
|
|
58
|
+
<template>
|
|
59
|
+
<div>
|
|
60
|
+
<BvButton variant="primary" @click="handleClick">Click me</BvButton>
|
|
61
|
+
</div>
|
|
62
|
+
</template>
|
|
63
|
+
|
|
64
|
+
<script setup>
|
|
65
|
+
import { BvButton } from "@baklavue/ui";
|
|
66
|
+
|
|
67
|
+
const handleClick = () => {
|
|
68
|
+
console.log("Button clicked!");
|
|
69
|
+
};
|
|
70
|
+
</script>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
All components follow the same pattern: import from `@baklavue/ui` and use the `Bv` prefix in templates.
|
|
74
|
+
|
|
75
|
+
### 2. Use Composables
|
|
76
|
+
|
|
77
|
+
Composables provide reusable logic that works seamlessly with BaklaVue components. For example, `useNotification` controls the notification toast:
|
|
78
|
+
|
|
79
|
+
```vue
|
|
80
|
+
<template>
|
|
81
|
+
<div>
|
|
82
|
+
<BvButton @click="showNotification">Show Notification</BvButton>
|
|
83
|
+
<BvNotification />
|
|
84
|
+
</div>
|
|
85
|
+
</template>
|
|
86
|
+
|
|
87
|
+
<script setup>
|
|
88
|
+
import { BvButton, BvNotification } from "@baklavue/ui";
|
|
89
|
+
import { useNotification } from "@baklavue/composables";
|
|
90
|
+
|
|
91
|
+
const { success } = useNotification();
|
|
92
|
+
|
|
93
|
+
const showNotification = () => {
|
|
94
|
+
success({
|
|
95
|
+
caption: "Success!",
|
|
96
|
+
description: "Operation completed successfully",
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
</script>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The `<BvNotification />` component must be present in your app layout for notifications to appear. See [useNotification](/composables/notification) for the full API.
|
|
103
|
+
|
|
104
|
+
### 3. Customize Theme (Optional)
|
|
105
|
+
|
|
106
|
+
Use `useBaklavaTheme` to apply design tokens and brand colors. Built-in presets include `vue` (Vue.js brand colors) and `default`:
|
|
107
|
+
|
|
108
|
+
```vue
|
|
109
|
+
<script setup>
|
|
110
|
+
import { useBaklavaTheme } from "@baklavue/composables";
|
|
111
|
+
|
|
112
|
+
// Apply Vue.js brand preset
|
|
113
|
+
useBaklavaTheme().applyTheme({ preset: "vue" });
|
|
114
|
+
</script>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
You can also override specific tokens:
|
|
118
|
+
|
|
119
|
+
```vue
|
|
120
|
+
<script setup>
|
|
121
|
+
import { useBaklavaTheme } from "@baklavue/composables";
|
|
122
|
+
|
|
123
|
+
useBaklavaTheme().applyTheme({
|
|
124
|
+
preset: "vue",
|
|
125
|
+
borderRadius: { m: "0.5rem" },
|
|
126
|
+
typography: { fontFamily: "'Inter', sans-serif" },
|
|
127
|
+
});
|
|
128
|
+
</script>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
See [useBaklavaTheme](/composables/theme) and [Design Tokens](/guide/design-tokens) for customization options.
|
|
132
|
+
|
|
133
|
+
## Loading Baklava Resources
|
|
134
|
+
|
|
135
|
+
BaklaVue components automatically load Baklava JavaScript and CSS when they mount. In most cases, you don't need to do anything.
|
|
136
|
+
|
|
137
|
+
If you need to load resources manually (e.g. before any component mounts, or in a non-Vue context), call `loadBaklavaResources`:
|
|
138
|
+
|
|
139
|
+
```vue
|
|
140
|
+
<script setup>
|
|
141
|
+
import { onMounted } from "vue";
|
|
142
|
+
import { loadBaklavaResources } from "@baklavue/ui";
|
|
143
|
+
|
|
144
|
+
onMounted(() => {
|
|
145
|
+
loadBaklavaResources();
|
|
146
|
+
});
|
|
147
|
+
</script>
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## TypeScript Support
|
|
151
|
+
|
|
152
|
+
BaklaVue is written in TypeScript and ships with full type definitions. Import types for props and composables:
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
import type { ButtonProps, InputProps } from "@baklavue/ui";
|
|
156
|
+
|
|
157
|
+
const buttonProps: ButtonProps = {
|
|
158
|
+
variant: "primary",
|
|
159
|
+
size: "medium",
|
|
160
|
+
disabled: false,
|
|
161
|
+
};
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Types are exported from `@baklavue/ui` and `@baklavue/composables`. Check the [API Reference](/api/) for available types.
|
|
165
|
+
|
|
166
|
+
## Component Naming Convention
|
|
167
|
+
|
|
168
|
+
All UI components use the `Bv` prefix:
|
|
169
|
+
|
|
170
|
+
- `BvButton`, `BvInput`, `BvCheckbox`, `BvSelect`, etc.
|
|
171
|
+
- `BvDialog`, `BvDrawer`, `BvDropdown`, etc.
|
|
172
|
+
|
|
173
|
+
This convention helps avoid conflicts with native HTML elements and other libraries.
|
|
174
|
+
|
|
175
|
+
## Next Steps
|
|
176
|
+
|
|
177
|
+
- **[Components](/components/)** — Browse all available components with examples
|
|
178
|
+
- **[Composables](/composables/)** — Explore composables for notifications, theming, CSV, and more
|
|
179
|
+
- **[Design Tokens](/guide/design-tokens)** — Customize colors, typography, spacing, and more
|
|
180
|
+
- **[API Reference](/api/)** — Full API documentation
|
|
181
|
+
- **[Contributing](/guide/contributing)** — Help improve BaklaVue
|