@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,190 @@
|
|
|
1
|
+
# Textarea
|
|
2
|
+
|
|
3
|
+
A Vue UI kit component for Baklava's `bl-textarea` component with v-model support. Supports label, placeholder, validation, character counter, help text, and more.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
Use `v-model` for two-way binding with `label` and `placeholder` props.
|
|
8
|
+
|
|
9
|
+
<div class="component-demo">
|
|
10
|
+
|
|
11
|
+
<TextareaBasicDemo />
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
```vue
|
|
16
|
+
<template>
|
|
17
|
+
<BvTextarea
|
|
18
|
+
v-model="message"
|
|
19
|
+
label="Message"
|
|
20
|
+
placeholder="Enter your message"
|
|
21
|
+
/>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup>
|
|
25
|
+
import { ref } from "vue";
|
|
26
|
+
import { BvTextarea } from "@baklavue/ui";
|
|
27
|
+
|
|
28
|
+
const message = ref("");
|
|
29
|
+
</script>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Rows and Maxlength
|
|
33
|
+
|
|
34
|
+
Control the visible rows and maximum character length.
|
|
35
|
+
|
|
36
|
+
```vue
|
|
37
|
+
<template>
|
|
38
|
+
<BvTextarea
|
|
39
|
+
v-model="text"
|
|
40
|
+
label="Description"
|
|
41
|
+
:rows="6"
|
|
42
|
+
:maxlength="500"
|
|
43
|
+
/>
|
|
44
|
+
</template>
|
|
45
|
+
|
|
46
|
+
<script setup>
|
|
47
|
+
import { ref } from "vue";
|
|
48
|
+
import { BvTextarea } from "@baklavue/ui";
|
|
49
|
+
|
|
50
|
+
const text = ref("");
|
|
51
|
+
</script>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## With Validation
|
|
55
|
+
|
|
56
|
+
Use `required`, `helpText`, and `invalidText` for validation feedback.
|
|
57
|
+
|
|
58
|
+
<div class="component-demo">
|
|
59
|
+
|
|
60
|
+
<TextareaValidationDemo />
|
|
61
|
+
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
```vue
|
|
65
|
+
<template>
|
|
66
|
+
<BvTextarea
|
|
67
|
+
v-model="comment"
|
|
68
|
+
label="Comment"
|
|
69
|
+
placeholder="Enter your comment"
|
|
70
|
+
:maxlength="200"
|
|
71
|
+
help-text="Maximum 200 characters"
|
|
72
|
+
:required="true"
|
|
73
|
+
/>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<script setup>
|
|
77
|
+
import { ref } from "vue";
|
|
78
|
+
import { BvTextarea } from "@baklavue/ui";
|
|
79
|
+
|
|
80
|
+
const comment = ref("");
|
|
81
|
+
</script>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Disabled and Readonly
|
|
85
|
+
|
|
86
|
+
Disable or make the textarea readonly.
|
|
87
|
+
|
|
88
|
+
```vue
|
|
89
|
+
<template>
|
|
90
|
+
<BvTextarea v-model="text" label="Disabled" :disabled="true" />
|
|
91
|
+
<BvTextarea v-model="text" label="Readonly" :readonly="true" />
|
|
92
|
+
</template>
|
|
93
|
+
|
|
94
|
+
<script setup>
|
|
95
|
+
import { ref } from "vue";
|
|
96
|
+
import { BvTextarea } from "@baklavue/ui";
|
|
97
|
+
|
|
98
|
+
const text = ref("Cannot edit");
|
|
99
|
+
</script>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Character Counter
|
|
103
|
+
|
|
104
|
+
Enable the character counter with `characterCounter`.
|
|
105
|
+
|
|
106
|
+
```vue
|
|
107
|
+
<template>
|
|
108
|
+
<BvTextarea
|
|
109
|
+
v-model="bio"
|
|
110
|
+
label="Bio"
|
|
111
|
+
:maxlength="300"
|
|
112
|
+
:character-counter="true"
|
|
113
|
+
/>
|
|
114
|
+
</template>
|
|
115
|
+
|
|
116
|
+
<script setup>
|
|
117
|
+
import { ref } from "vue";
|
|
118
|
+
import { BvTextarea } from "@baklavue/ui";
|
|
119
|
+
|
|
120
|
+
const bio = ref("");
|
|
121
|
+
</script>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Props
|
|
125
|
+
|
|
126
|
+
| Prop | Type | Default | Description |
|
|
127
|
+
| ------------------- | ---------------- | ----------- | ------------------------------------ |
|
|
128
|
+
| `modelValue` | `string \| null` | `undefined` | Textarea value (v-model) |
|
|
129
|
+
| `label` | `string` | `undefined` | Label text |
|
|
130
|
+
| `placeholder` | `string` | `undefined` | Placeholder text |
|
|
131
|
+
| `rows` | `number` | `undefined` | Number of visible rows |
|
|
132
|
+
| `maxlength` | `number` | `undefined` | Maximum character length |
|
|
133
|
+
| `minlength` | `number` | `undefined` | Minimum character length |
|
|
134
|
+
| `disabled` | `boolean` | `undefined` | Disabled state |
|
|
135
|
+
| `required` | `boolean` | `undefined` | Required field |
|
|
136
|
+
| `readonly` | `boolean` | `undefined` | Readonly state |
|
|
137
|
+
| `helpText` | `string` | `undefined` | Help text below the textarea |
|
|
138
|
+
| `invalidText` | `string` | `undefined` | Custom error/invalid message |
|
|
139
|
+
| `characterCounter` | `boolean` | `undefined` | Enable character counter |
|
|
140
|
+
| `expand` | `boolean` | `undefined` | Enable auto-expand up to maxRows |
|
|
141
|
+
| `maxRows` | `number` | `undefined` | Max rows when expand is true |
|
|
142
|
+
| `size` | `TextareaSize` | `undefined` | Textarea size: small, medium, large |
|
|
143
|
+
| `name` | `string` | `undefined` | Name attribute for forms |
|
|
144
|
+
|
|
145
|
+
## Events
|
|
146
|
+
|
|
147
|
+
| Event | Payload | Description |
|
|
148
|
+
| ------------------- | --------------- | -------------------------------------- |
|
|
149
|
+
| `update:modelValue` | `string \| null`| Emitted when value changes (v-model) |
|
|
150
|
+
| `input` | `CustomEvent` | Emitted on user input |
|
|
151
|
+
| `change` | `CustomEvent` | Emitted when value commits (blur) |
|
|
152
|
+
|
|
153
|
+
## Slots
|
|
154
|
+
|
|
155
|
+
| Slot | Description |
|
|
156
|
+
| --------- | -------------------------- |
|
|
157
|
+
| `default` | Additional content/slots |
|
|
158
|
+
|
|
159
|
+
## Types
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
import type { TextareaProps, TextareaSize } from "@baklavue/ui";
|
|
163
|
+
|
|
164
|
+
type TextareaSize = "small" | "medium" | "large";
|
|
165
|
+
|
|
166
|
+
interface TextareaProps {
|
|
167
|
+
modelValue?: string | null;
|
|
168
|
+
label?: string;
|
|
169
|
+
placeholder?: string;
|
|
170
|
+
rows?: number;
|
|
171
|
+
maxlength?: number;
|
|
172
|
+
minlength?: number;
|
|
173
|
+
disabled?: boolean;
|
|
174
|
+
required?: boolean;
|
|
175
|
+
readonly?: boolean;
|
|
176
|
+
helpText?: string;
|
|
177
|
+
invalidText?: string;
|
|
178
|
+
characterCounter?: boolean;
|
|
179
|
+
expand?: boolean;
|
|
180
|
+
maxRows?: number;
|
|
181
|
+
size?: TextareaSize;
|
|
182
|
+
name?: string;
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Usage Notes
|
|
187
|
+
|
|
188
|
+
- **v-model**: Use `v-model` for two-way binding of the textarea value.
|
|
189
|
+
- **Validation**: Use `invalidText` to display custom error messages when validation fails.
|
|
190
|
+
- **Character counter**: Enable `characterCounter` with `maxlength` to show character count.
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Tooltip
|
|
2
|
+
|
|
3
|
+
A Vue UI kit component for Baklava's `bl-tooltip` component for displaying contextual information on hover or focus. The trigger is provided via the default slot; content can be set via the `content` prop or the `#content` slot.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
Wrap a trigger element and set the tooltip text with the `content` prop.
|
|
8
|
+
|
|
9
|
+
<div class="component-demo">
|
|
10
|
+
|
|
11
|
+
<TooltipBasicDemo />
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
```vue
|
|
16
|
+
<template>
|
|
17
|
+
<BvTooltip content="This is a tooltip">
|
|
18
|
+
<BvButton>Hover me</BvButton>
|
|
19
|
+
</BvTooltip>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup>
|
|
23
|
+
import { BvTooltip, BvButton } from "@baklavue/ui";
|
|
24
|
+
</script>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Placement
|
|
28
|
+
|
|
29
|
+
Control where the tooltip appears with the `placement` prop.
|
|
30
|
+
|
|
31
|
+
<div class="component-demo">
|
|
32
|
+
|
|
33
|
+
<TooltipPlacementDemo />
|
|
34
|
+
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
```vue
|
|
38
|
+
<template>
|
|
39
|
+
<div style="display: flex; gap: 1rem; flex-wrap: wrap">
|
|
40
|
+
<BvTooltip content="Tooltip on top" placement="top">
|
|
41
|
+
<BvButton>Top</BvButton>
|
|
42
|
+
</BvTooltip>
|
|
43
|
+
<BvTooltip content="Tooltip on bottom" placement="bottom">
|
|
44
|
+
<BvButton>Bottom</BvButton>
|
|
45
|
+
</BvTooltip>
|
|
46
|
+
<BvTooltip content="Tooltip on left" placement="left">
|
|
47
|
+
<BvButton>Left</BvButton>
|
|
48
|
+
</BvTooltip>
|
|
49
|
+
<BvTooltip content="Tooltip on right" placement="right">
|
|
50
|
+
<BvButton>Right</BvButton>
|
|
51
|
+
</BvTooltip>
|
|
52
|
+
</div>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<script setup>
|
|
56
|
+
import { BvTooltip, BvButton } from "@baklavue/ui";
|
|
57
|
+
</script>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Custom Content Slot
|
|
61
|
+
|
|
62
|
+
Use the `#content` slot for rich or dynamic tooltip content.
|
|
63
|
+
|
|
64
|
+
```vue
|
|
65
|
+
<template>
|
|
66
|
+
<BvTooltip>
|
|
67
|
+
<template #content>
|
|
68
|
+
<div style="padding: 0.5rem">
|
|
69
|
+
<strong>Custom content</strong>
|
|
70
|
+
<p>You can add HTML or components here.</p>
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|
|
73
|
+
<span>Hover for custom content</span>
|
|
74
|
+
</BvTooltip>
|
|
75
|
+
</template>
|
|
76
|
+
|
|
77
|
+
<script setup>
|
|
78
|
+
import { BvTooltip } from "@baklavue/ui";
|
|
79
|
+
</script>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Disabled
|
|
83
|
+
|
|
84
|
+
Disable the tooltip to prevent it from showing.
|
|
85
|
+
|
|
86
|
+
```vue
|
|
87
|
+
<template>
|
|
88
|
+
<BvTooltip content="This won't show" :disabled="true">
|
|
89
|
+
<BvButton>Disabled tooltip</BvButton>
|
|
90
|
+
</BvTooltip>
|
|
91
|
+
</template>
|
|
92
|
+
|
|
93
|
+
<script setup>
|
|
94
|
+
import { BvTooltip, BvButton } from "@baklavue/ui";
|
|
95
|
+
</script>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Props
|
|
99
|
+
|
|
100
|
+
| Prop | Type | Default | Description |
|
|
101
|
+
| ----------- | ------------------ | ----------- | ---------------------------------------- |
|
|
102
|
+
| `content` | `string` | `undefined` | Tooltip content text |
|
|
103
|
+
| `placement` | `TooltipPlacement` | `undefined` | Placement: top, bottom, left, right, etc. |
|
|
104
|
+
| `trigger` | `string` | `undefined` | Trigger type: hover, click, etc. |
|
|
105
|
+
| `disabled` | `boolean` | `undefined` | Disabled state |
|
|
106
|
+
| `delay` | `number` | `undefined` | Delay before showing (ms) |
|
|
107
|
+
|
|
108
|
+
## Events
|
|
109
|
+
|
|
110
|
+
| Event | Payload | Description |
|
|
111
|
+
| ------- | ------- | ------------------------------ |
|
|
112
|
+
| `show` | - | Emitted when tooltip is shown |
|
|
113
|
+
| `hide` | - | Emitted when tooltip is hidden |
|
|
114
|
+
|
|
115
|
+
## Slots
|
|
116
|
+
|
|
117
|
+
| Slot | Description |
|
|
118
|
+
| --------- | ----------------------------------- |
|
|
119
|
+
| `default` | Trigger element (hover/focus target) |
|
|
120
|
+
| `content` | Custom tooltip content (overrides `content` prop) |
|
|
121
|
+
|
|
122
|
+
## Types
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
import type { TooltipProps, TooltipPlacement } from "@baklavue/ui";
|
|
126
|
+
|
|
127
|
+
type TooltipPlacement =
|
|
128
|
+
| "top"
|
|
129
|
+
| "top-start"
|
|
130
|
+
| "top-end"
|
|
131
|
+
| "bottom"
|
|
132
|
+
| "bottom-start"
|
|
133
|
+
| "bottom-end"
|
|
134
|
+
| "left"
|
|
135
|
+
| "left-start"
|
|
136
|
+
| "left-end"
|
|
137
|
+
| "right"
|
|
138
|
+
| "right-start"
|
|
139
|
+
| "right-end";
|
|
140
|
+
|
|
141
|
+
interface TooltipProps {
|
|
142
|
+
content?: string;
|
|
143
|
+
placement?: TooltipPlacement;
|
|
144
|
+
trigger?: string;
|
|
145
|
+
disabled?: boolean;
|
|
146
|
+
delay?: number;
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Usage Notes
|
|
151
|
+
|
|
152
|
+
- **Trigger**: The default slot content is the element that triggers the tooltip on hover or focus.
|
|
153
|
+
- **Content**: Use the `content` prop for simple text, or the `#content` slot for custom markup.
|
|
154
|
+
- **Placement**: Default is `top`. Use `placement` to control position relative to the trigger.
|
|
155
|
+
- **Accessibility**: The component follows Baklava's accessibility guidelines; tooltips are announced to screen readers.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# useAlert
|
|
2
|
+
|
|
3
|
+
A composable for programmatic show/hide of inline BvAlert. Use with `v-if="isVisible"` or `:closed="!isVisible"` on BvAlert.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<div>
|
|
10
|
+
<BvButton @click="showSuccess">Show success</BvButton>
|
|
11
|
+
<BvAlert
|
|
12
|
+
v-if="isVisible"
|
|
13
|
+
:variant="variant"
|
|
14
|
+
:caption="caption"
|
|
15
|
+
:description="description"
|
|
16
|
+
:closable="closable"
|
|
17
|
+
@close="hide"
|
|
18
|
+
/>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup>
|
|
23
|
+
import { BvButton, BvAlert } from "@baklavue/ui";
|
|
24
|
+
import { useAlert } from "@baklavue/composables";
|
|
25
|
+
|
|
26
|
+
const { isVisible, variant, caption, description, closable, show, hide } = useAlert();
|
|
27
|
+
|
|
28
|
+
const showSuccess = () => {
|
|
29
|
+
show({
|
|
30
|
+
variant: "success",
|
|
31
|
+
caption: "Saved",
|
|
32
|
+
description: "Your changes have been saved.",
|
|
33
|
+
closable: true,
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
</script>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## With Closable
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<script setup>
|
|
43
|
+
import { useAlert } from "@baklavue/composables";
|
|
44
|
+
|
|
45
|
+
const { isVisible, variant, caption, description, closable, show, hide } = useAlert();
|
|
46
|
+
|
|
47
|
+
show({
|
|
48
|
+
variant: "warning",
|
|
49
|
+
description: "Please fix the errors before submitting.",
|
|
50
|
+
closable: true,
|
|
51
|
+
});
|
|
52
|
+
</script>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## API
|
|
56
|
+
|
|
57
|
+
### Return Value
|
|
58
|
+
|
|
59
|
+
| Property | Type | Description |
|
|
60
|
+
| --- | --- | --- |
|
|
61
|
+
| `isVisible` | `Ref<boolean>` | Whether alert is visible |
|
|
62
|
+
| `variant` | `Ref<AlertVariant>` | info, success, warning, danger |
|
|
63
|
+
| `caption` | `Ref<string>` | Alert title |
|
|
64
|
+
| `description` | `Ref<string>` | Alert message |
|
|
65
|
+
| `closable` | `Ref<boolean>` | Whether close button is shown |
|
|
66
|
+
| `show` | `(options?) => void` | Show alert with options |
|
|
67
|
+
| `hide` | `() => void` | Hide alert |
|
|
68
|
+
|
|
69
|
+
### Options
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
interface UseAlertOptions {
|
|
73
|
+
variant?: "info" | "success" | "warning" | "danger";
|
|
74
|
+
caption?: string;
|
|
75
|
+
description?: string;
|
|
76
|
+
closable?: boolean;
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## TypeScript Support
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { useAlert, type UseAlertOptions, type AlertVariant } from "@baklavue/composables";
|
|
84
|
+
|
|
85
|
+
const { show } = useAlert();
|
|
86
|
+
show({ variant: "success", description: "Done!" });
|
|
87
|
+
```
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# useAsyncState
|
|
2
|
+
|
|
3
|
+
A composable for generic async state (loading, error, data) without fetch. Complements `useFetch`/`useQuery` for non-HTTP async operations like IndexedDB, Web Worker, or custom logic.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<script setup>
|
|
9
|
+
import { useAsyncState } from "@baklavue/composables";
|
|
10
|
+
|
|
11
|
+
const { state, execute, isLoading, error } = useAsyncState(async () => {
|
|
12
|
+
const data = await readFromIndexedDB();
|
|
13
|
+
return data;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
await execute();
|
|
17
|
+
</script>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Lazy with Immediate
|
|
21
|
+
|
|
22
|
+
```vue
|
|
23
|
+
<script setup>
|
|
24
|
+
import { useAsyncState } from "@baklavue/composables";
|
|
25
|
+
|
|
26
|
+
const { state, execute, isLoading } = useAsyncState(() => fetchUser(userId), {
|
|
27
|
+
immediate: true,
|
|
28
|
+
initialData: null,
|
|
29
|
+
});
|
|
30
|
+
</script>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## With Callbacks
|
|
34
|
+
|
|
35
|
+
```vue
|
|
36
|
+
<script setup>
|
|
37
|
+
import { useAsyncState, useNotification } from "@baklavue/composables";
|
|
38
|
+
|
|
39
|
+
const { success, error } = useNotification();
|
|
40
|
+
const { state, execute } = useAsyncState(() => loadData(), {
|
|
41
|
+
onSuccess: () => success({ description: "Loaded!" }),
|
|
42
|
+
onError: (err) => error({ description: err.message }),
|
|
43
|
+
});
|
|
44
|
+
</script>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## API
|
|
48
|
+
|
|
49
|
+
### Options
|
|
50
|
+
|
|
51
|
+
| Option | Type | Default | Description |
|
|
52
|
+
| --- | --- | --- | --- |
|
|
53
|
+
| `immediate` | `boolean` | `false` | Execute immediately on mount |
|
|
54
|
+
| `initialData` | `T` | `undefined` | Initial data value |
|
|
55
|
+
| `onSuccess` | `(data: T) => void` | — | Callback on success |
|
|
56
|
+
| `onError` | `(error: Error) => void` | — | Callback on error |
|
|
57
|
+
|
|
58
|
+
### Return Value
|
|
59
|
+
|
|
60
|
+
| Property | Type | Description |
|
|
61
|
+
| --- | --- | --- |
|
|
62
|
+
| `state` | `ShallowRef<T \| undefined>` | The resolved data |
|
|
63
|
+
| `execute` | `() => Promise<T>` | Run the async function |
|
|
64
|
+
| `isLoading` | `Ref<boolean>` | True while executing |
|
|
65
|
+
| `error` | `Ref<Error \| null>` | Last error if any |
|
|
66
|
+
|
|
67
|
+
## TypeScript Support
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { useAsyncState, type UseAsyncStateOptions } from "@baklavue/composables";
|
|
71
|
+
|
|
72
|
+
const { state, execute } = useAsyncState<User>(() => fetchUser(id));
|
|
73
|
+
// state: ShallowRef<User | undefined>
|
|
74
|
+
```
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# useBase64
|
|
2
|
+
|
|
3
|
+
A composable for converting Blob/File/ArrayBuffer/canvas/image to Base64 data URLs. Complements `useFile` for image preview before upload, avatar uploads, and thumbnails.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<input type="file" accept="image/*" @change="handleFile" />
|
|
10
|
+
<img v-if="base64" :src="base64" alt="Preview" />
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup>
|
|
14
|
+
import { ref } from "vue";
|
|
15
|
+
import { useBase64 } from "@baklavue/composables";
|
|
16
|
+
|
|
17
|
+
const file = ref<File | undefined>();
|
|
18
|
+
const { base64 } = useBase64(file);
|
|
19
|
+
|
|
20
|
+
const handleFile = (e: Event) => {
|
|
21
|
+
file.value = (e.target as HTMLInputElement).files?.[0];
|
|
22
|
+
};
|
|
23
|
+
</script>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## With Canvas
|
|
27
|
+
|
|
28
|
+
```vue
|
|
29
|
+
<script setup>
|
|
30
|
+
import { useBase64 } from "@baklavue/composables";
|
|
31
|
+
|
|
32
|
+
const canvasRef = ref<HTMLCanvasElement>();
|
|
33
|
+
const { base64, execute } = useBase64(canvasRef, {
|
|
34
|
+
type: "image/jpeg",
|
|
35
|
+
quality: 0.8,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
await execute();
|
|
39
|
+
</script>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## API
|
|
43
|
+
|
|
44
|
+
### Options
|
|
45
|
+
|
|
46
|
+
| Option | Type | Default | Description |
|
|
47
|
+
| --- | --- | --- | --- |
|
|
48
|
+
| `dataUrl` | `boolean` | `true` | Output as Data URL format (e.g. `data:image/png;base64,...`) |
|
|
49
|
+
| `type` | `string` | `"image/png"` | MIME type for canvas/image |
|
|
50
|
+
| `quality` | `number` | — | Image quality for jpeg or webp (0-1) |
|
|
51
|
+
|
|
52
|
+
### Return Value
|
|
53
|
+
|
|
54
|
+
| Property | Type | Description |
|
|
55
|
+
| --- | --- | --- |
|
|
56
|
+
| `base64` | `ShallowRef<string>` | Base64 string (or data URL when `dataUrl: true`) |
|
|
57
|
+
| `execute` | `() => Promise<string>` | Manually trigger conversion |
|
|
58
|
+
| `promise` | `ShallowRef<Promise<string>>` | Current conversion promise |
|
|
59
|
+
|
|
60
|
+
### Supported Sources
|
|
61
|
+
|
|
62
|
+
- `string` | `Blob` | `File` | `ArrayBuffer`
|
|
63
|
+
- `HTMLCanvasElement` | `HTMLImageElement`
|
|
64
|
+
|
|
65
|
+
## TypeScript Support
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { useBase64, type UseBase64Options } from "@baklavue/composables";
|
|
69
|
+
|
|
70
|
+
const { base64 } = useBase64(fileRef);
|
|
71
|
+
const { base64: canvasBase64 } = useBase64(canvasRef, { type: "image/jpeg" });
|
|
72
|
+
```
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# useBreakpoints / useMediaQuery
|
|
2
|
+
|
|
3
|
+
Composables for responsive breakpoints. Use `useBreakpoints` for predefined mobile/tablet/desktop flags, or `useMediaQuery` for custom media queries.
|
|
4
|
+
|
|
5
|
+
## useBreakpoints
|
|
6
|
+
|
|
7
|
+
Reactively detects viewport size. Useful for switching layouts (e.g. Drawer vs Dialog on mobile).
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<template>
|
|
11
|
+
<component :is="useDrawer ? BvDrawer : BvDialog" v-model:open="isOpen">
|
|
12
|
+
<p>Content</p>
|
|
13
|
+
</component>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup>
|
|
17
|
+
import { computed } from "vue";
|
|
18
|
+
import { BvDrawer, BvDialog } from "@baklavue/ui";
|
|
19
|
+
import { useBreakpoints, useDisclosure } from "@baklavue/composables";
|
|
20
|
+
|
|
21
|
+
const { isMobile, isTablet, isDesktop } = useBreakpoints();
|
|
22
|
+
const { isOpen } = useDisclosure();
|
|
23
|
+
|
|
24
|
+
const useDrawer = computed(() => isMobile.value);
|
|
25
|
+
</script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Custom Breakpoints
|
|
29
|
+
|
|
30
|
+
```vue
|
|
31
|
+
<script setup>
|
|
32
|
+
import { useBreakpoints } from "@baklavue/composables";
|
|
33
|
+
|
|
34
|
+
const { isMobile, isTablet, isDesktop } = useBreakpoints({
|
|
35
|
+
mobile: 640, // < 640px = mobile
|
|
36
|
+
tablet: 1280, // 640-1279 = tablet, >= 1280 = desktop
|
|
37
|
+
});
|
|
38
|
+
</script>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## useMediaQuery
|
|
42
|
+
|
|
43
|
+
For a single media query:
|
|
44
|
+
|
|
45
|
+
```vue
|
|
46
|
+
<template>
|
|
47
|
+
<div v-if="matches">Visible on small screens only</div>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<script setup>
|
|
51
|
+
import { useMediaQuery } from "@baklavue/composables";
|
|
52
|
+
|
|
53
|
+
const matches = useMediaQuery("(max-width: 768px)");
|
|
54
|
+
</script>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## API
|
|
58
|
+
|
|
59
|
+
### useBreakpoints
|
|
60
|
+
|
|
61
|
+
#### Return Value
|
|
62
|
+
|
|
63
|
+
| Property | Type | Description |
|
|
64
|
+
| --- | --- | --- |
|
|
65
|
+
| `isMobile` | `Ref<boolean>` | Viewport < mobile breakpoint |
|
|
66
|
+
| `isTablet` | `Ref<boolean>` | Viewport between mobile and tablet |
|
|
67
|
+
| `isDesktop` | `Ref<boolean>` | Viewport >= tablet breakpoint |
|
|
68
|
+
|
|
69
|
+
#### Options
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
interface BreakpointOptions {
|
|
73
|
+
mobile?: number; // Default: 768 (px)
|
|
74
|
+
tablet?: number; // Default: 1024 (px)
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Default breakpoints:
|
|
79
|
+
- Mobile: < 768px
|
|
80
|
+
- Tablet: 768px - 1023px
|
|
81
|
+
- Desktop: >= 1024px
|
|
82
|
+
|
|
83
|
+
### useMediaQuery
|
|
84
|
+
|
|
85
|
+
#### Parameters
|
|
86
|
+
|
|
87
|
+
- `query` — Media query string (e.g. `"(max-width: 768px)"`)
|
|
88
|
+
|
|
89
|
+
#### Return Value
|
|
90
|
+
|
|
91
|
+
- `Ref<boolean>` — `true` when the query matches
|
|
92
|
+
|
|
93
|
+
## useWindowSize {#use-window-size}
|
|
94
|
+
|
|
95
|
+
Reactive viewport width and height. Useful for layout calculations and charts that need actual dimensions.
|
|
96
|
+
|
|
97
|
+
```vue
|
|
98
|
+
<template>
|
|
99
|
+
<p>Viewport: {{ width }} × {{ height }}</p>
|
|
100
|
+
</template>
|
|
101
|
+
|
|
102
|
+
<script setup>
|
|
103
|
+
import { useWindowSize } from "@baklavue/composables";
|
|
104
|
+
|
|
105
|
+
const { width, height } = useWindowSize();
|
|
106
|
+
</script>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### Return Value
|
|
110
|
+
|
|
111
|
+
| Property | Type | Description |
|
|
112
|
+
| --- | --- | --- |
|
|
113
|
+
| `width` | `Ref<number>` | Window inner width |
|
|
114
|
+
| `height` | `Ref<number>` | Window inner height |
|
|
115
|
+
|
|
116
|
+
## TypeScript Support
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import {
|
|
120
|
+
useBreakpoints,
|
|
121
|
+
useMediaQuery,
|
|
122
|
+
useWindowSize,
|
|
123
|
+
type BreakpointOptions,
|
|
124
|
+
} from "@baklavue/composables";
|
|
125
|
+
|
|
126
|
+
const { isMobile } = useBreakpoints({ mobile: 640 });
|
|
127
|
+
const darkMode = useMediaQuery("(prefers-color-scheme: dark)");
|
|
128
|
+
const { width, height } = useWindowSize();
|
|
129
|
+
```
|