@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.
Files changed (93) hide show
  1. package/README.md +72 -0
  2. package/dist/data/component-categories.d.ts +7 -0
  3. package/dist/data/component-categories.js +48 -0
  4. package/dist/data/loaders.d.ts +22 -0
  5. package/dist/data/loaders.js +346 -0
  6. package/dist/docs/components/accordion.md +601 -0
  7. package/dist/docs/components/alert.md +233 -0
  8. package/dist/docs/components/badge.md +100 -0
  9. package/dist/docs/components/banner.md +231 -0
  10. package/dist/docs/components/button.md +324 -0
  11. package/dist/docs/components/checkbox.md +343 -0
  12. package/dist/docs/components/chip.md +199 -0
  13. package/dist/docs/components/datepicker.md +243 -0
  14. package/dist/docs/components/dialog.md +224 -0
  15. package/dist/docs/components/drawer.md +188 -0
  16. package/dist/docs/components/dropdown.md +291 -0
  17. package/dist/docs/components/file-upload.md +248 -0
  18. package/dist/docs/components/icon.md +142 -0
  19. package/dist/docs/components/image.md +161 -0
  20. package/dist/docs/components/index.md +151 -0
  21. package/dist/docs/components/input.md +407 -0
  22. package/dist/docs/components/link.md +249 -0
  23. package/dist/docs/components/notification.md +179 -0
  24. package/dist/docs/components/pagination.md +168 -0
  25. package/dist/docs/components/radio.md +221 -0
  26. package/dist/docs/components/scroll-to-top.md +90 -0
  27. package/dist/docs/components/select.md +239 -0
  28. package/dist/docs/components/skeleton.md +79 -0
  29. package/dist/docs/components/spinner.md +93 -0
  30. package/dist/docs/components/split-button.md +165 -0
  31. package/dist/docs/components/stepper.md +337 -0
  32. package/dist/docs/components/switch.md +144 -0
  33. package/dist/docs/components/tab.md +140 -0
  34. package/dist/docs/components/table.md +362 -0
  35. package/dist/docs/components/tag.md +243 -0
  36. package/dist/docs/components/textarea.md +190 -0
  37. package/dist/docs/components/tooltip.md +155 -0
  38. package/dist/docs/composables/alert.md +87 -0
  39. package/dist/docs/composables/asyncState.md +74 -0
  40. package/dist/docs/composables/base64.md +72 -0
  41. package/dist/docs/composables/breakpoints.md +129 -0
  42. package/dist/docs/composables/clipboard.md +108 -0
  43. package/dist/docs/composables/colorScheme.md +110 -0
  44. package/dist/docs/composables/confirmDialog.md +105 -0
  45. package/dist/docs/composables/containerScroll.md +89 -0
  46. package/dist/docs/composables/cookie.md +137 -0
  47. package/dist/docs/composables/debounce.md +69 -0
  48. package/dist/docs/composables/disclosure.md +69 -0
  49. package/dist/docs/composables/elementSize.md +84 -0
  50. package/dist/docs/composables/fetch.md +257 -0
  51. package/dist/docs/composables/fieldArray.md +104 -0
  52. package/dist/docs/composables/file.md +343 -0
  53. package/dist/docs/composables/focusTrap.md +87 -0
  54. package/dist/docs/composables/formPersistence.md +69 -0
  55. package/dist/docs/composables/formState.md +71 -0
  56. package/dist/docs/composables/formValidation.md +355 -0
  57. package/dist/docs/composables/format.md +107 -0
  58. package/dist/docs/composables/id.md +54 -0
  59. package/dist/docs/composables/index.md +112 -0
  60. package/dist/docs/composables/infiniteQuery.md +104 -0
  61. package/dist/docs/composables/intersectionObserver.md +64 -0
  62. package/dist/docs/composables/lazyQuery.md +68 -0
  63. package/dist/docs/composables/loading.md +91 -0
  64. package/dist/docs/composables/mutation.md +83 -0
  65. package/dist/docs/composables/notification.md +169 -0
  66. package/dist/docs/composables/pagination.md +109 -0
  67. package/dist/docs/composables/polling.md +76 -0
  68. package/dist/docs/composables/previous.md +58 -0
  69. package/dist/docs/composables/query.md +248 -0
  70. package/dist/docs/composables/raf.md +78 -0
  71. package/dist/docs/composables/scrollLock.md +46 -0
  72. package/dist/docs/composables/scrollToError.md +291 -0
  73. package/dist/docs/composables/scrollVisibility.md +60 -0
  74. package/dist/docs/composables/share.md +78 -0
  75. package/dist/docs/composables/slug.md +58 -0
  76. package/dist/docs/composables/stepper.md +117 -0
  77. package/dist/docs/composables/stepperForm.md +74 -0
  78. package/dist/docs/composables/sticky.md +91 -0
  79. package/dist/docs/composables/storage.md +193 -0
  80. package/dist/docs/composables/theme.md +252 -0
  81. package/dist/docs/composables/themePreset.md +62 -0
  82. package/dist/docs/composables/throttle.md +76 -0
  83. package/dist/docs/composables/timer.md +78 -0
  84. package/dist/docs/composables/toggle.md +55 -0
  85. package/dist/docs/guide/contributing.md +364 -0
  86. package/dist/docs/guide/design-tokens.md +29 -0
  87. package/dist/docs/guide/getting-started.md +181 -0
  88. package/dist/docs/guide/installation.md +287 -0
  89. package/dist/docs/guide/localization.md +132 -0
  90. package/dist/docs/guide/mcp.md +141 -0
  91. package/dist/index.d.ts +2 -0
  92. package/dist/index.js +177 -0
  93. package/package.json +48 -0
@@ -0,0 +1,108 @@
1
+ # useClipboard
2
+
3
+ A composable for copying text to the clipboard. Integrates well with `useNotification` for copy feedback.
4
+
5
+ ## Basic Usage
6
+
7
+ ```vue
8
+ <template>
9
+ <BvButton @click="handleCopy">Copy token</BvButton>
10
+ </template>
11
+
12
+ <script setup>
13
+ import { BvButton } from "@baklavue/ui";
14
+ import { useClipboard, useNotification } from "@baklavue/composables";
15
+
16
+ const { copy, copied } = useClipboard();
17
+ const { success } = useNotification();
18
+
19
+ const handleCopy = async () => {
20
+ const ok = await copy("secret-token-123");
21
+ if (ok) {
22
+ success({ description: "Copied to clipboard!" });
23
+ }
24
+ };
25
+ </script>
26
+ ```
27
+
28
+ ## With Copied State
29
+
30
+ ```vue
31
+ <template>
32
+ <BvButton @click="copy(text)">
33
+ {{ copied ? "Copied!" : "Copy" }}
34
+ </BvButton>
35
+ </template>
36
+
37
+ <script setup>
38
+ import { BvButton } from "@baklavue/ui";
39
+ import { useClipboard } from "@baklavue/composables";
40
+
41
+ const text = ref("https://example.com/link");
42
+ const { copy, copied } = useClipboard();
43
+ </script>
44
+ ```
45
+
46
+ ## With Options
47
+
48
+ ```vue
49
+ <template>
50
+ <BvButton v-if="isSupported" @click="copy()">
51
+ {{ copied ? "Copied!" : "Copy" }}
52
+ </BvButton>
53
+ <p v-else>Clipboard not supported</p>
54
+ </template>
55
+
56
+ <script setup>
57
+ import { BvButton } from "@baklavue/ui";
58
+ import { useClipboard } from "@baklavue/composables";
59
+
60
+ const link = ref("https://example.com/share");
61
+ const { copy, copied, isSupported } = useClipboard({
62
+ source: link,
63
+ copiedDuring: 1500,
64
+ legacy: true,
65
+ });
66
+ </script>
67
+ ```
68
+
69
+ ## API
70
+
71
+ ### Options
72
+
73
+ | Option | Type | Default | Description |
74
+ | -------------- | ------------------ | ------- | -------------------------------------------------------------------------------- |
75
+ | `source` | `MaybeRef<string>` | — | Default text to copy when `copy()` is called without arguments |
76
+ | `copiedDuring` | `number` | — | Milliseconds before `copied` resets to `false`. Omit to disable auto-reset. |
77
+ | `legacy` | `boolean` | `false` | Fallback to `document.execCommand` when Clipboard API is unavailable (e.g. HTTP) |
78
+
79
+ ### Return Value
80
+
81
+ | Property | Type | Description |
82
+ | ------------- | ------------------------------------- | ----------------------------------------------------------------- |
83
+ | `copy` | `(text?: string) => Promise<boolean>` | Copies text to clipboard. Uses `source` when called without args. |
84
+ | `copied` | `Ref<boolean>` | True after successful copy |
85
+ | `isSupported` | `ComputedRef<boolean>` | Whether clipboard is available (native or legacy when enabled) |
86
+
87
+ ### Notes
88
+
89
+ - Uses `navigator.clipboard.writeText()` when available
90
+ - Returns `false` in environments without clipboard API (e.g. non-HTTPS) unless `legacy: true`
91
+ - `copied` resets to `false` on each `copy()` call; with `copiedDuring`, it auto-resets after the specified ms
92
+ - When `source` is provided, `copy()` can be called without arguments
93
+
94
+ ## TypeScript Support
95
+
96
+ ```typescript
97
+ import { useClipboard, type UseClipboardOptions } from "@baklavue/composables";
98
+
99
+ const { copy, copied, isSupported } = useClipboard();
100
+ const ok = await copy("hello");
101
+
102
+ const { copy: copyFromSource } = useClipboard({
103
+ source: ref("default"),
104
+ copiedDuring: 1500,
105
+ legacy: true,
106
+ });
107
+ await copyFromSource(); // copies "default"
108
+ ```
@@ -0,0 +1,110 @@
1
+ # useColorScheme
2
+
3
+ A composable for light/dark/system color scheme with persistence. Supports `prefers-color-scheme` for system preference, optional attribute on document, and localStorage persistence.
4
+
5
+ ## Basic Usage
6
+
7
+ ```vue
8
+ <template>
9
+ <BvButton @click="toggleScheme">
10
+ {{ isDark ? "Light" : "Dark" }} mode
11
+ </BvButton>
12
+ </template>
13
+
14
+ <script setup>
15
+ import { BvButton } from "@baklavue/ui";
16
+ import { useColorScheme } from "@baklavue/composables";
17
+
18
+ const { scheme, isDark, setScheme } = useColorScheme();
19
+
20
+ function toggleScheme() {
21
+ setScheme(isDark.value ? "light" : "dark");
22
+ }
23
+ </script>
24
+ ```
25
+
26
+ ## System Preference
27
+
28
+ Use `"system"` to follow the OS preference:
29
+
30
+ ```vue
31
+ <script setup>
32
+ import { useColorScheme } from "@baklavue/composables";
33
+
34
+ const { scheme, setScheme } = useColorScheme();
35
+
36
+ // Follow system
37
+ setScheme("system");
38
+ </script>
39
+ ```
40
+
41
+ ## Options
42
+
43
+ ```vue
44
+ <script setup>
45
+ import { useColorScheme } from "@baklavue/composables";
46
+
47
+ const { scheme, isDark, setScheme } = useColorScheme({
48
+ storageKey: "app-color-scheme",
49
+ attribute: "data-theme",
50
+ selector: "html",
51
+ defaultScheme: "system",
52
+ });
53
+ </script>
54
+ ```
55
+
56
+ | Option | Type | Default | Description |
57
+ | --- | --- | --- | --- |
58
+ | `storageKey` | `string \| false` | `"color-scheme"` | localStorage key. Set to `false` to disable persistence |
59
+ | `attribute` | `"data-theme" \| "class"` | `"data-theme"` | Attribute to set on `document.documentElement` |
60
+ | `selector` | `string` | `"html"` | Selector for the element to apply the attribute |
61
+ | `defaultScheme` | `"light" \| "dark" \| "system"` | `"system"` | Default when no stored value exists |
62
+
63
+ ## With `attribute: "class"`
64
+
65
+ When using `attribute: "class"`, the composable adds `dark` class for dark mode and removes it for light:
66
+
67
+ ```vue
68
+ <script setup>
69
+ import { useColorScheme } from "@baklavue/composables";
70
+
71
+ useColorScheme({ attribute: "class" });
72
+ </script>
73
+
74
+ <template>
75
+ <div class="bg-white dark:bg-gray-900 text-gray-900 dark:text-white">
76
+ Content
77
+ </div>
78
+ </template>
79
+ ```
80
+
81
+ ## API
82
+
83
+ ### Return Value
84
+
85
+ | Property | Type | Description |
86
+ | --- | --- | --- |
87
+ | `scheme` | `Ref<"light" \| "dark" \| "system">` | Current scheme choice |
88
+ | `isDark` | `Ref<boolean>` | `true` when dark mode is active |
89
+ | `setScheme` | `(value: ColorScheme) => void` | Set scheme and persist |
90
+
91
+ ### ColorScheme
92
+
93
+ ```typescript
94
+ type ColorScheme = "light" | "dark" | "system";
95
+ ```
96
+
97
+ ## TypeScript Support
98
+
99
+ ```typescript
100
+ import {
101
+ useColorScheme,
102
+ type ColorScheme,
103
+ type UseColorSchemeOptions,
104
+ } from "@baklavue/composables";
105
+
106
+ const { scheme, isDark, setScheme } = useColorScheme({
107
+ storageKey: "my-app-theme",
108
+ defaultScheme: "system",
109
+ });
110
+ ```
@@ -0,0 +1,105 @@
1
+ # useConfirmDialog
2
+
3
+ A composable for driving BvDialog confirm/cancel flows. Returns a promise that resolves to `true` when the user confirms, `false` when cancelled. Often used with `useNotification` for success/error feedback.
4
+
5
+ ## Basic Usage
6
+
7
+ ```vue
8
+ <template>
9
+ <BvButton @click="handleDelete">Delete</BvButton>
10
+
11
+ <BvDialog v-model:open="isOpen" :caption="caption">
12
+ <p>{{ description }}</p>
13
+ <template #footer>
14
+ <BvButton variant="tertiary" @click="handleCancel">Cancel</BvButton>
15
+ <BvButton variant="primary" @click="handleConfirm">Confirm</BvButton>
16
+ </template>
17
+ </BvDialog>
18
+ </template>
19
+
20
+ <script setup>
21
+ import { BvButton, BvDialog } from "@baklavue/ui";
22
+ import { useConfirmDialog, useNotification } from "@baklavue/composables";
23
+
24
+ const { success } = useNotification();
25
+ const {
26
+ confirm,
27
+ isOpen,
28
+ caption,
29
+ description,
30
+ handleConfirm,
31
+ handleCancel,
32
+ } = useConfirmDialog();
33
+
34
+ const handleDelete = async () => {
35
+ const ok = await confirm({
36
+ caption: "Delete item?",
37
+ description: "Are you sure? This action cannot be undone.",
38
+ });
39
+ if (ok) {
40
+ // Perform delete
41
+ success({ description: "Deleted successfully" });
42
+ }
43
+ };
44
+ </script>
45
+ ```
46
+
47
+ ## With Async Action
48
+
49
+ ```vue
50
+ <script setup>
51
+ import { useConfirmDialog, useNotification } from "@baklavue/composables";
52
+
53
+ const { success, error } = useNotification();
54
+ const { confirm, isOpen, caption, description, handleConfirm, handleCancel, isPending } =
55
+ useConfirmDialog();
56
+
57
+ const handleDelete = async () => {
58
+ const ok = await confirm({
59
+ caption: "Delete item?",
60
+ description: "This cannot be undone.",
61
+ });
62
+ if (ok) {
63
+ try {
64
+ await api.deleteItem(id);
65
+ success({ description: "Deleted" });
66
+ } catch (e) {
67
+ error({ description: e.message });
68
+ }
69
+ }
70
+ };
71
+ </script>
72
+ ```
73
+
74
+ ## API
75
+
76
+ ### Return Value
77
+
78
+ | Property | Type | Description |
79
+ | --- | --- | --- |
80
+ | `confirm` | `(options?) => Promise<boolean>` | Opens dialog, returns promise |
81
+ | `isOpen` | `Ref<boolean>` | Dialog visibility |
82
+ | `caption` | `Ref<string>` | Dialog title |
83
+ | `description` | `Ref<string>` | Dialog body text |
84
+ | `isPending` | `Ref<boolean>` | True while dialog is open |
85
+ | `handleConfirm` | `() => void` | Wire to Confirm button |
86
+ | `handleCancel` | `() => void` | Wire to Cancel button |
87
+ | `close` | `(result: boolean) => void` | Close with result |
88
+
89
+ ### Options
90
+
91
+ ```typescript
92
+ interface ConfirmDialogOptions {
93
+ caption?: string; // Dialog title
94
+ description?: string; // Dialog body
95
+ }
96
+ ```
97
+
98
+ ## TypeScript Support
99
+
100
+ ```typescript
101
+ import { useConfirmDialog, type ConfirmDialogOptions } from "@baklavue/composables";
102
+
103
+ const { confirm } = useConfirmDialog();
104
+ const ok = await confirm({ caption: "Confirm?", description: "Sure?" });
105
+ ```
@@ -0,0 +1,89 @@
1
+ # useContainerScroll
2
+
3
+ A composable for reactive scroll position inside a scrollable container. Uses scroll event with RAF throttling. Useful for virtual lists, custom scroll UIs, and horizontal scroll indicators.
4
+
5
+ ## Basic Usage
6
+
7
+ ```vue
8
+ <template>
9
+ <div ref="container" class="overflow-auto h-64">
10
+ <div class="p-4">Content</div>
11
+ </div>
12
+ <p>Scroll: {{ scrollTop }}px, {{ scrollLeft }}px</p>
13
+ </template>
14
+
15
+ <script setup>
16
+ import { ref } from "vue";
17
+ import { useContainerScroll } from "@baklavue/composables";
18
+
19
+ const container = ref<HTMLElement | null>(null);
20
+ const { scrollTop, scrollLeft } = useContainerScroll(container);
21
+ </script>
22
+ ```
23
+
24
+ ## Scroll Shadow Indicator
25
+
26
+ ```vue
27
+ <template>
28
+ <div class="relative">
29
+ <div
30
+ v-show="scrollLeft > 0"
31
+ class="absolute left-0 top-0 h-full w-8 bg-gradient-to-r from-white to-transparent"
32
+ />
33
+ <div ref="scroll" class="overflow-x-auto">
34
+ <div class="flex gap-4 p-4">...</div>
35
+ </div>
36
+ </div>
37
+ </template>
38
+
39
+ <script setup>
40
+ import { ref } from "vue";
41
+ import { useContainerScroll } from "@baklavue/composables";
42
+
43
+ const scroll = ref<HTMLElement | null>(null);
44
+ const { scrollLeft } = useContainerScroll(scroll);
45
+ </script>
46
+ ```
47
+
48
+ ## Options
49
+
50
+ ```vue
51
+ <script setup>
52
+ import { useContainerScroll } from "@baklavue/composables";
53
+
54
+ const container = ref<HTMLElement | null>(null);
55
+ const { scrollTop, scrollLeft } = useContainerScroll(container, {
56
+ passive: true,
57
+ });
58
+ </script>
59
+ ```
60
+
61
+ | Option | Type | Default | Description |
62
+ | --- | --- | --- | --- |
63
+ | `passive` | `boolean` | `true` | Use passive scroll listener |
64
+
65
+ ## API
66
+
67
+ ### Parameters
68
+
69
+ - `target` — `Ref<Element | null | undefined>` — Ref to the scrollable element
70
+ - `options` — Optional `UseContainerScrollOptions`
71
+
72
+ ### Return Value
73
+
74
+ | Property | Type | Description |
75
+ | --- | --- | --- |
76
+ | `scrollTop` | `Ref<number>` | Scroll position from top |
77
+ | `scrollLeft` | `Ref<number>` | Scroll position from left |
78
+
79
+ ## TypeScript Support
80
+
81
+ ```typescript
82
+ import {
83
+ useContainerScroll,
84
+ type UseContainerScrollOptions,
85
+ } from "@baklavue/composables";
86
+
87
+ const container = ref<HTMLElement | null>(null);
88
+ const { scrollTop, scrollLeft } = useContainerScroll(container);
89
+ ```
@@ -0,0 +1,137 @@
1
+ # useCookie
2
+
3
+ Reactive sync with `document.cookie`. Persists values in a cookie. Use for auth tokens, preferences that must be sent to the server, or when you need path/domain/expiry control. Cookies are sent with every request to matching paths.
4
+
5
+ Returns `{ value, get, set, remove }` for reactive and imperative cookie access.
6
+
7
+ ## Basic usage
8
+
9
+ ```vue
10
+ <script setup>
11
+ import { useCookie } from "@baklavue/composables";
12
+
13
+ const { value: token, get, set, remove } = useCookie("auth-token", "");
14
+ const { value: theme } = useCookie("theme", "vue", { path: "/", maxAge: 60 * 60 * 24 * 365 });
15
+
16
+ // Imperative API
17
+ set("new-token");
18
+ const current = get(); // read from cookie
19
+ remove(); // clear cookie
20
+ </script>
21
+ ```
22
+
23
+ ## Imperative API
24
+
25
+ | Method | Description |
26
+ | --- | --- |
27
+ | `value` | Reactive ref for `v-model` and template binding |
28
+ | `get()` | Read current value from cookie |
29
+ | `set(value)` | Write value to cookie |
30
+ | `remove()` | Delete cookie and reset to defaultValue |
31
+
32
+ ## Cookie options
33
+
34
+ | Option | Type | Description |
35
+ | --- | --- | --- |
36
+ | `path` | `string` | Cookie path. Default: `'/'` |
37
+ | `domain` | `string` | Cookie domain |
38
+ | `maxAge` | `number` | Max age in seconds. Takes precedence over `expires` |
39
+ | `expires` | `Date` | Expiration date |
40
+ | `secure` | `boolean` | HTTPS only |
41
+ | `sameSite` | `'Strict' \| 'Lax' \| 'None'` | SameSite attribute |
42
+
43
+ `useCookie` also supports `mergeDefaults`, `serializer`, and `onError`.
44
+
45
+ ## Options
46
+
47
+ ```typescript
48
+ interface UseCookieOptions<T> {
49
+ mergeDefaults?: boolean | ((storageValue: T, defaults: T) => T);
50
+ serializer?: { read: (raw: string) => T; write: (value: T) => string };
51
+ onError?: (error: unknown) => void;
52
+ path?: string;
53
+ domain?: string;
54
+ maxAge?: number;
55
+ expires?: Date;
56
+ secure?: boolean;
57
+ sameSite?: "Strict" | "Lax" | "None";
58
+ }
59
+ ```
60
+
61
+ ### mergeDefaults
62
+
63
+ When you add new properties to your default object, existing stored values won't have them. Enable `mergeDefaults: true` for a shallow merge:
64
+
65
+ ```typescript
66
+ import { useCookie } from "@baklavue/composables";
67
+
68
+ const { value: prefs } = useCookie("prefs", { theme: "vue", compact: false }, {
69
+ mergeDefaults: true,
70
+ path: "/",
71
+ });
72
+ ```
73
+
74
+ ### Custom serializer
75
+
76
+ Store `Map`, `Set`, `Date`, or custom formats:
77
+
78
+ ```typescript
79
+ import { useCookie } from "@baklavue/composables";
80
+
81
+ const { value: lastVisit } = useCookie("last-visit", new Date(), {
82
+ serializer: {
83
+ read: (v) => new Date(v),
84
+ write: (v) => v.toISOString(),
85
+ },
86
+ path: "/",
87
+ });
88
+ ```
89
+
90
+ ### onError
91
+
92
+ Handle parse errors:
93
+
94
+ ```typescript
95
+ const { value: prefs } = useCookie("prefs", {}, {
96
+ onError: (e) => console.error("Cookie error:", e),
97
+ path: "/",
98
+ });
99
+ ```
100
+
101
+ ## API
102
+
103
+ ```typescript
104
+ useCookie<T>(key: string, defaultValue: T): UseCookieReturn<T>
105
+ useCookie<T>(key: string, defaultValue: T, options: UseCookieOptions<T>): UseCookieReturn<T>
106
+ ```
107
+
108
+ ```typescript
109
+ interface UseCookieReturn<T> {
110
+ value: Ref<T>;
111
+ get: () => T;
112
+ set: (value: T) => void;
113
+ remove: () => void;
114
+ }
115
+ ```
116
+
117
+ | Parameter | Type | Description |
118
+ | --- | --- | --- |
119
+ | `key` | `string` | Cookie name |
120
+ | `defaultValue` | `T` | Default when cookie is missing or on SSR |
121
+ | `options` | `UseCookieOptions<T>` | Optional: mergeDefaults, serializer, onError, path, domain, maxAge, expires, secure, sameSite |
122
+
123
+ ### Notes
124
+
125
+ - Values are JSON-serialized by default. Primitives, objects, and arrays are supported.
126
+ - On SSR, returns `defaultValue` (cookies are not available).
127
+ - Changes to the ref are written to the cookie (with `{ deep: true }` for objects).
128
+ - Cookies have a ~4KB size limit per cookie.
129
+
130
+ ## TypeScript Support
131
+
132
+ ```typescript
133
+ import { useCookie, type UseCookieOptions, type UseCookieReturn } from "@baklavue/composables";
134
+
135
+ const { value: token, set, remove } = useCookie("auth-token", "");
136
+ const { value: theme } = useCookie("theme", "vue", { path: "/", maxAge: 31536000 });
137
+ ```
@@ -0,0 +1,69 @@
1
+ # useDebounceFn / useDebouncedRef
2
+
3
+ Debounce function execution or ref value. Useful for search inputs, autocomplete, and form validation.
4
+
5
+ ## Basic Usage
6
+
7
+ ### useDebounceFn
8
+
9
+ Returns a debounced version of a function. The function is called only after the specified delay has passed since the last invocation.
10
+
11
+ ```vue
12
+ <template>
13
+ <BvInput v-model="searchQuery" placeholder="Search..." />
14
+ </template>
15
+
16
+ <script setup>
17
+ import { ref, watch } from "vue";
18
+ import { BvInput } from "@baklavue/ui";
19
+ import { useDebounceFn } from "@baklavue/composables";
20
+
21
+ const searchQuery = ref("");
22
+
23
+ const debouncedSearch = useDebounceFn((query) => {
24
+ if (query) fetchResults(query);
25
+ }, 300);
26
+
27
+ watch(searchQuery, (q) => debouncedSearch(q));
28
+ </script>
29
+ ```
30
+
31
+ ### useDebouncedRef
32
+
33
+ Returns a ref that updates only after the specified delay since the last change. Useful for debounced v-model.
34
+
35
+ ```vue
36
+ <script setup>
37
+ import { ref, watch } from "vue";
38
+ import { useDebouncedRef } from "@baklavue/composables";
39
+
40
+ const searchQuery = ref("");
41
+ const debouncedQuery = useDebouncedRef(searchQuery, 300);
42
+
43
+ watch(debouncedQuery, (q) => {
44
+ if (q) fetchResults(q);
45
+ });
46
+ </script>
47
+ ```
48
+
49
+ ## API
50
+
51
+ ### useDebounceFn
52
+
53
+ ```typescript
54
+ useDebounceFn<T>(fn: T, delay?: number): (...args: Parameters<T>) => void
55
+ ```
56
+
57
+ - `fn` — Function to debounce
58
+ - `delay` — Delay in milliseconds. Default: 200
59
+ - Returns a debounced function
60
+
61
+ ### useDebouncedRef
62
+
63
+ ```typescript
64
+ useDebouncedRef<T>(value: Ref<T>, delay?: number): Ref<T>
65
+ ```
66
+
67
+ - `value` — Ref to debounce
68
+ - `delay` — Delay in milliseconds. Default: 200
69
+ - Returns a ref with debounced value
@@ -0,0 +1,69 @@
1
+ # useDisclosure
2
+
3
+ A minimal composable for open/close state used by Dialog, Drawer, Dropdown, Accordion, and Tooltip. Avoids repetitive `ref(false)`, `open()`, `close()`, `toggle()`.
4
+
5
+ ## Basic Usage
6
+
7
+ ```vue
8
+ <template>
9
+ <BvButton @click="open">Open Dialog</BvButton>
10
+ <BvDialog v-model:open="isOpen" caption="Dialog Title">
11
+ <p>Content goes here.</p>
12
+ <template #footer>
13
+ <BvButton @click="close">Close</BvButton>
14
+ </template>
15
+ </BvDialog>
16
+ </template>
17
+
18
+ <script setup>
19
+ import { BvButton, BvDialog } from "@baklavue/ui";
20
+ import { useDisclosure } from "@baklavue/composables";
21
+
22
+ const { isOpen, open, close, toggle } = useDisclosure(false);
23
+ </script>
24
+ ```
25
+
26
+ ## With Toggle
27
+
28
+ ```vue
29
+ <template>
30
+ <BvButton @click="toggle">Toggle Drawer</BvButton>
31
+ <BvDrawer v-model:open="isOpen" caption="Drawer">
32
+ <p>Drawer content.</p>
33
+ </BvDrawer>
34
+ </template>
35
+
36
+ <script setup>
37
+ import { BvButton, BvDrawer } from "@baklavue/ui";
38
+ import { useDisclosure } from "@baklavue/composables";
39
+
40
+ const { isOpen, toggle } = useDisclosure(false);
41
+ </script>
42
+ ```
43
+
44
+ ## API
45
+
46
+ ### Return Value
47
+
48
+ | Property | Type | Description |
49
+ | --- | --- | --- |
50
+ | `isOpen` | `Ref<boolean>` | Reactive open state |
51
+ | `open` | `() => void` | Sets isOpen to true |
52
+ | `close` | `() => void` | Sets isOpen to false |
53
+ | `toggle` | `() => void` | Flips isOpen |
54
+
55
+ ### Parameters
56
+
57
+ ```typescript
58
+ useDisclosure(initialState?: boolean)
59
+ ```
60
+
61
+ - `initialState` — Initial open state. Default: `false`
62
+
63
+ ## TypeScript Support
64
+
65
+ ```typescript
66
+ import { useDisclosure } from "@baklavue/composables";
67
+
68
+ const { isOpen, open, close, toggle } = useDisclosure(true);
69
+ ```