@baklavue/ui 1.0.0-preview.2
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/.releaserc.json +14 -0
- package/CHANGELOG.md +40 -0
- package/README.md +15 -0
- package/index.ts +1 -0
- package/package.json +45 -0
- package/src/accordion/Accordion.vue +206 -0
- package/src/accordion/accordion.types.ts +109 -0
- package/src/accordion/index.ts +3 -0
- package/src/alert/Alert.vue +199 -0
- package/src/alert/alert.types.ts +58 -0
- package/src/alert/index.ts +2 -0
- package/src/badge/Badge.vue +20 -0
- package/src/badge/badge.types.ts +7 -0
- package/src/badge/index.ts +2 -0
- package/src/button/Button.vue +45 -0
- package/src/button/button.types.ts +30 -0
- package/src/button/index.ts +3 -0
- package/src/checkbox/Checkbox.vue +148 -0
- package/src/checkbox/checkbox.types.ts +108 -0
- package/src/checkbox/index.ts +2 -0
- package/src/datepicker/Datepicker.vue +172 -0
- package/src/datepicker/datepicker.types.ts +39 -0
- package/src/datepicker/index.ts +2 -0
- package/src/dialog/Dialog.vue +178 -0
- package/src/dialog/dialog.types.ts +17 -0
- package/src/dialog/index.ts +2 -0
- package/src/drawer/Drawer.vue +162 -0
- package/src/drawer/drawer.types.ts +17 -0
- package/src/drawer/index.ts +2 -0
- package/src/dropdown/Dropdown.vue +231 -0
- package/src/dropdown/dropdown.types.ts +110 -0
- package/src/dropdown/index.ts +2 -0
- package/src/icon/Icon.vue +102 -0
- package/src/icon/icon.types.ts +25 -0
- package/src/icon/index.ts +2 -0
- package/src/index.ts +37 -0
- package/src/input/Input.vue +148 -0
- package/src/input/index.ts +3 -0
- package/src/input/input.types.ts +156 -0
- package/src/link/Link.vue +133 -0
- package/src/link/index.ts +2 -0
- package/src/link/link.types.ts +42 -0
- package/src/notification/Notification.vue +57 -0
- package/src/notification/index.ts +2 -0
- package/src/notification/notification.types.ts +25 -0
- package/src/pagination/Pagination.vue +137 -0
- package/src/pagination/index.ts +2 -0
- package/src/pagination/pagination.types.ts +61 -0
- package/src/radio/Radio.vue +205 -0
- package/src/radio/index.ts +2 -0
- package/src/radio/radio.types.ts +95 -0
- package/src/select/Select.vue +147 -0
- package/src/select/index.ts +2 -0
- package/src/select/select.types.ts +53 -0
- package/src/spinner/Spinner.vue +49 -0
- package/src/spinner/index.ts +2 -0
- package/src/spinner/spinner.types.ts +11 -0
- package/src/split-button/SplitButton.vue +73 -0
- package/src/split-button/index.ts +2 -0
- package/src/split-button/split-button.types.ts +19 -0
- package/src/stepper/Stepper.vue +100 -0
- package/src/stepper/index.ts +2 -0
- package/src/stepper/stepper.types.ts +29 -0
- package/src/switch/Switch.vue +80 -0
- package/src/switch/index.ts +2 -0
- package/src/switch/switch.types.ts +13 -0
- package/src/tab/Tab.vue +99 -0
- package/src/tab/index.ts +2 -0
- package/src/tab/tab.types.ts +17 -0
- package/src/table/Table.vue +264 -0
- package/src/table/index.ts +7 -0
- package/src/table/table.types.ts +62 -0
- package/src/tag/Tag.vue +83 -0
- package/src/tag/index.ts +2 -0
- package/src/tag/tag.types.ts +24 -0
- package/src/textarea/Textarea.vue +84 -0
- package/src/textarea/index.ts +2 -0
- package/src/textarea/textarea.types.ts +37 -0
- package/src/tooltip/Tooltip.vue +81 -0
- package/src/tooltip/index.ts +3 -0
- package/src/tooltip/tooltip.types.ts +29 -0
- package/src/utils/loadBaklavaResources.ts +24 -0
- package/tsconfig.json +28 -0
package/.releaserc.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "semantic-release-monorepo",
|
|
3
|
+
"tagFormat": "@baklavue/ui-v${version}",
|
|
4
|
+
"branches": ["main", { "name": "preview", "prerelease": true, "channel": "beta" }],
|
|
5
|
+
"repositoryUrl": "https://github.com/erbilnas/baklavue",
|
|
6
|
+
"plugins": [
|
|
7
|
+
"@semantic-release/commit-analyzer",
|
|
8
|
+
"@semantic-release/release-notes-generator",
|
|
9
|
+
"@semantic-release/changelog",
|
|
10
|
+
["@semantic-release/npm", { "npmPublish": true }],
|
|
11
|
+
"@semantic-release/github",
|
|
12
|
+
"@semantic-release/git"
|
|
13
|
+
]
|
|
14
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# [@baklavue/ui-v1.0.0-preview.2](https://github.com/erbilnas/baklavue/compare/@baklavue/ui-v1.0.0-preview.1...@baklavue/ui-v1.0.0-preview.2) (2026-02-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add theme customizer tool for docs ([70c08cf](https://github.com/erbilnas/baklavue/commit/70c08cf505ff02b1ab6c3e569055b703674bb822))
|
|
7
|
+
|
|
8
|
+
# @baklavue/ui-v1.0.0-preview.1 (2026-02-11)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* fix package version ([620618d](https://github.com/erbilnas/baklavue/commit/620618df664022f1b68859aee4b374f6586731bb))
|
|
14
|
+
* fix release ci ([6c22554](https://github.com/erbilnas/baklavue/commit/6c225541b182c4b8692af000e7c13ca6e546599a))
|
|
15
|
+
* fix release ci ([6e23d99](https://github.com/erbilnas/baklavue/commit/6e23d99cac122d033c72d6d98819e0329c92bcdc))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* add accordion and alert components ([10b8155](https://github.com/erbilnas/baklavue/commit/10b81556184432deb2772d3489c24be6115e667c))
|
|
21
|
+
* add accordion, alert and badge components ([b939941](https://github.com/erbilnas/baklavue/commit/b939941e469a29b10ddcc6196f97700951672f97))
|
|
22
|
+
* add github pages support ([c76dffa](https://github.com/erbilnas/baklavue/commit/c76dffa8eb32b8293aca7c7e1f5d2ee4139802b0))
|
|
23
|
+
* add info for npm package ([8ffbb9f](https://github.com/erbilnas/baklavue/commit/8ffbb9f81d108d633608ebe8d3854a2f6861475a))
|
|
24
|
+
* add new components ([f977070](https://github.com/erbilnas/baklavue/commit/f977070bc1634941a5566f079922410838e1e257))
|
|
25
|
+
* add new components ([fa3b4d1](https://github.com/erbilnas/baklavue/commit/fa3b4d1586f7e5b15194d182931e5bc89fd2f1dd))
|
|
26
|
+
* add new components ([ec926f0](https://github.com/erbilnas/baklavue/commit/ec926f0e9ba11c1a28a97c8afee4829b38ed8539))
|
|
27
|
+
* add new components ([5d3d7e2](https://github.com/erbilnas/baklavue/commit/5d3d7e2e5a040cb57bd964db2cee2178bb574a82))
|
|
28
|
+
* add new components ([22a1506](https://github.com/erbilnas/baklavue/commit/22a150681ad8587c92ad5546fbc256d9275b6d00))
|
|
29
|
+
* disable npm package-lock for bun ([d91c5ca](https://github.com/erbilnas/baklavue/commit/d91c5ca0d8566aff9c021b1cad431eda86bc2d95))
|
|
30
|
+
* disable npm package-lock for bun ([86fd15e](https://github.com/erbilnas/baklavue/commit/86fd15ed42ded4e198ed22845acdb659cdfde191))
|
|
31
|
+
* initial commit ([d98b3f9](https://github.com/erbilnas/baklavue/commit/d98b3f9e6cc6e8238f197eaa117a050365987b18))
|
|
32
|
+
* remove playground to develop new docs ([043d89c](https://github.com/erbilnas/baklavue/commit/043d89c7944c8b2acff3bb21c571691f21c99162))
|
|
33
|
+
* seperate publishing packages ([e8092d8](https://github.com/erbilnas/baklavue/commit/e8092d87a6579cf6d2798053cd6150fc4ccd98a8))
|
|
34
|
+
|
|
35
|
+
# [1.0.0-preview.4](https://github.com/erbilnas/baklavue/compare/v1.0.0-preview.3...v1.0.0-preview.4) (2026-02-09)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Features
|
|
39
|
+
|
|
40
|
+
* remove playground to develop new docs ([043d89c](https://github.com/erbilnas/baklavue/commit/043d89c7944c8b2acff3bb21c571691f21c99162))
|
package/README.md
ADDED
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src";
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@baklavue/ui",
|
|
3
|
+
"version": "1.0.0-preview.2",
|
|
4
|
+
"description": "Vue 3 UI kit for Trendyol Baklava Design System",
|
|
5
|
+
"author": "erbilnas",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/erbilnas/baklavue/tree/main/packages/ui#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/erbilnas/baklavue.git",
|
|
11
|
+
"directory": "packages/ui"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/erbilnas/baklavue/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"vue",
|
|
18
|
+
"vue3",
|
|
19
|
+
"baklava",
|
|
20
|
+
"trendyol",
|
|
21
|
+
"design-system",
|
|
22
|
+
"components",
|
|
23
|
+
"ui"
|
|
24
|
+
],
|
|
25
|
+
"module": "index.ts",
|
|
26
|
+
"type": "module",
|
|
27
|
+
"scripts": {
|
|
28
|
+
"release": "semantic-release -e semantic-release-monorepo",
|
|
29
|
+
"release:dry-run": "semantic-release --dry-run -e semantic-release-monorepo"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/bun": "latest"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"typescript": "^5.9.2"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@trendyol/baklava": "^3.4.2",
|
|
39
|
+
"@trendyol/baklava-icons": "^1.1.0",
|
|
40
|
+
"vue": "^3.5.21"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Accordion Component
|
|
4
|
+
*
|
|
5
|
+
* A Vue UI kit component for Baklava's `bl-accordion` and `bl-accordion-group` web components.
|
|
6
|
+
* Can be used as either a single accordion or as a group container for multiple accordions.
|
|
7
|
+
*
|
|
8
|
+
* @component
|
|
9
|
+
* @example
|
|
10
|
+
* ```vue
|
|
11
|
+
* <!-- Single accordion -->
|
|
12
|
+
* <template>
|
|
13
|
+
* <Accordion :open="isOpen" @toggle="isOpen = $event" caption="Section Title">
|
|
14
|
+
* <p>Accordion content goes here</p>
|
|
15
|
+
* </Accordion>
|
|
16
|
+
* </template>
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```vue
|
|
21
|
+
* <!-- Accordion group - only one open at a time -->
|
|
22
|
+
* <template>
|
|
23
|
+
* <Accordion :multiple="false" :items="items">
|
|
24
|
+
* <template #item="{ item }">
|
|
25
|
+
* <p>{{ item.answer }}</p>
|
|
26
|
+
* </template>
|
|
27
|
+
* </Accordion>
|
|
28
|
+
* </template>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```vue
|
|
33
|
+
* <!-- Accordion group - multiple can be open -->
|
|
34
|
+
* <template>
|
|
35
|
+
* <Accordion :multiple="true" :items="sections">
|
|
36
|
+
* <template #item="{ item }">
|
|
37
|
+
* <p>{{ item.description }}</p>
|
|
38
|
+
* </template>
|
|
39
|
+
* </Accordion>
|
|
40
|
+
* </template>
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
import { computed, onMounted, ref, watch } from "vue";
|
|
44
|
+
import { loadBaklavaResources } from "../utils/loadBaklavaResources";
|
|
45
|
+
import type { AccordionProps } from "./accordion.types";
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Component props with default values.
|
|
49
|
+
*/
|
|
50
|
+
const props = withDefaults(defineProps<AccordionProps>(), {
|
|
51
|
+
open: false,
|
|
52
|
+
caption: undefined,
|
|
53
|
+
icon: undefined,
|
|
54
|
+
disabled: false,
|
|
55
|
+
animationDuration: 250,
|
|
56
|
+
multiple: undefined,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Component events.
|
|
61
|
+
*/
|
|
62
|
+
const emit = defineEmits<{
|
|
63
|
+
/**
|
|
64
|
+
* Emitted when the accordion is toggled (opened or closed).
|
|
65
|
+
* Only used when component is in single accordion mode.
|
|
66
|
+
*
|
|
67
|
+
* @param {boolean} open - The new open state of the accordion.
|
|
68
|
+
*/
|
|
69
|
+
toggle: [open: boolean];
|
|
70
|
+
}>();
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Reference to the underlying web component element.
|
|
74
|
+
*/
|
|
75
|
+
const accordionRef = ref<HTMLElement | null>(null);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Determines if the component should act as a group container.
|
|
79
|
+
* When `multiple` prop is provided and `items` is defined, it acts as a group.
|
|
80
|
+
*/
|
|
81
|
+
const isGroupMode = computed(
|
|
82
|
+
() => props.multiple !== undefined && Array.isArray(props.items),
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Watches for changes to the `open` prop and syncs with the web component.
|
|
87
|
+
* Only applies when in single accordion mode.
|
|
88
|
+
*
|
|
89
|
+
* When the prop changes, it calls the appropriate expand/collapse method
|
|
90
|
+
* on the underlying web component.
|
|
91
|
+
*/
|
|
92
|
+
watch(
|
|
93
|
+
() => props.open,
|
|
94
|
+
(newValue) => {
|
|
95
|
+
if (!isGroupMode.value && accordionRef.value) {
|
|
96
|
+
const blAccordion = accordionRef.value as any;
|
|
97
|
+
if (newValue && !blAccordion.open) {
|
|
98
|
+
blAccordion.expand();
|
|
99
|
+
} else if (!newValue && blAccordion.open) {
|
|
100
|
+
blAccordion.collapse();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{ immediate: true },
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Handles the toggle event from the underlying web component.
|
|
109
|
+
* Only used when component is in single accordion mode.
|
|
110
|
+
*
|
|
111
|
+
* @param {CustomEvent<boolean>} event - The toggle event from bl-accordion.
|
|
112
|
+
*/
|
|
113
|
+
const handleToggle = (event: CustomEvent<boolean>): void => {
|
|
114
|
+
if (!isGroupMode.value) {
|
|
115
|
+
const isOpen = event.detail;
|
|
116
|
+
emit("toggle", isOpen);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Lifecycle hook: Component mounted.
|
|
122
|
+
*
|
|
123
|
+
* Loads Baklava resources and syncs the initial open state with the web component
|
|
124
|
+
* (only when in single accordion mode).
|
|
125
|
+
*/
|
|
126
|
+
onMounted(() => {
|
|
127
|
+
loadBaklavaResources();
|
|
128
|
+
|
|
129
|
+
// Sync initial state (only for single accordion mode)
|
|
130
|
+
if (!isGroupMode.value && accordionRef.value) {
|
|
131
|
+
const blAccordion = accordionRef.value as any;
|
|
132
|
+
if (props.open && !blAccordion.open) {
|
|
133
|
+
blAccordion.expand();
|
|
134
|
+
} else if (!props.open && blAccordion.open) {
|
|
135
|
+
blAccordion.collapse();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Exposed methods for programmatic control of the accordion.
|
|
142
|
+
* Only available when component is in single accordion mode.
|
|
143
|
+
*/
|
|
144
|
+
defineExpose({
|
|
145
|
+
/**
|
|
146
|
+
* Expands the accordion programmatically.
|
|
147
|
+
*
|
|
148
|
+
* @public
|
|
149
|
+
*/
|
|
150
|
+
expand: (): void => {
|
|
151
|
+
if (!isGroupMode.value && accordionRef.value) {
|
|
152
|
+
(accordionRef.value as any).expand();
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Collapses the accordion programmatically.
|
|
158
|
+
*
|
|
159
|
+
* @public
|
|
160
|
+
*/
|
|
161
|
+
collapse: (): void => {
|
|
162
|
+
if (!isGroupMode.value && accordionRef.value) {
|
|
163
|
+
(accordionRef.value as any).collapse();
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
</script>
|
|
168
|
+
|
|
169
|
+
<template>
|
|
170
|
+
<!-- Group mode: render as bl-accordion-group -->
|
|
171
|
+
<!-- Render bl-accordion for each item in props.items. Content via #item slot. -->
|
|
172
|
+
<bl-accordion-group
|
|
173
|
+
v-if="isGroupMode"
|
|
174
|
+
:multiple="props.multiple === true ? true : undefined"
|
|
175
|
+
>
|
|
176
|
+
<bl-accordion
|
|
177
|
+
v-for="(item, index) in props.items"
|
|
178
|
+
:key="index"
|
|
179
|
+
v-bind="{
|
|
180
|
+
open: item.open === true ? true : undefined,
|
|
181
|
+
caption: item.caption,
|
|
182
|
+
icon: item.icon,
|
|
183
|
+
disabled: item.disabled === true ? true : undefined,
|
|
184
|
+
animationDuration: item.animationDuration,
|
|
185
|
+
}"
|
|
186
|
+
>
|
|
187
|
+
<slot name="item" :item="item" :index="index" />
|
|
188
|
+
</bl-accordion>
|
|
189
|
+
</bl-accordion-group>
|
|
190
|
+
|
|
191
|
+
<!-- Single accordion mode: render as bl-accordion -->
|
|
192
|
+
<bl-accordion
|
|
193
|
+
v-else
|
|
194
|
+
ref="accordionRef"
|
|
195
|
+
v-bind="{
|
|
196
|
+
open: props.open === true ? true : undefined,
|
|
197
|
+
caption: props.caption,
|
|
198
|
+
icon: props.icon,
|
|
199
|
+
disabled: props.disabled === true ? true : undefined,
|
|
200
|
+
animationDuration: props.animationDuration,
|
|
201
|
+
}"
|
|
202
|
+
@bl-toggle="handleToggle"
|
|
203
|
+
>
|
|
204
|
+
<slot />
|
|
205
|
+
</bl-accordion>
|
|
206
|
+
</template>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { BaklavaIcon } from "@trendyol/baklava-icons";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Properties for a single accordion item when used in group mode.
|
|
5
|
+
*
|
|
6
|
+
* @interface AccordionItem
|
|
7
|
+
*/
|
|
8
|
+
export interface AccordionItem {
|
|
9
|
+
/**
|
|
10
|
+
* Whether the accordion is open/expanded.
|
|
11
|
+
*
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
open?: boolean;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The caption text displayed in the accordion header.
|
|
18
|
+
*/
|
|
19
|
+
caption?: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Icon configuration for the accordion header.
|
|
23
|
+
* Can be a boolean to show/hide default icon, or a specific BaklavaIcon.
|
|
24
|
+
*/
|
|
25
|
+
icon?: boolean | BaklavaIcon;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Whether the accordion is disabled.
|
|
29
|
+
*
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Duration of the expand/collapse animation in milliseconds.
|
|
36
|
+
*
|
|
37
|
+
* @default 250
|
|
38
|
+
*/
|
|
39
|
+
animationDuration?: number;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Additional custom data for use in the #item scoped slot.
|
|
43
|
+
* Content is provided via the #item slot, not via a property.
|
|
44
|
+
*/
|
|
45
|
+
[key: string]: unknown;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Props for the Accordion component.
|
|
50
|
+
*
|
|
51
|
+
* When `multiple` prop is provided, the component acts as an accordion group container.
|
|
52
|
+
* Otherwise, it acts as a single accordion.
|
|
53
|
+
*
|
|
54
|
+
* @interface AccordionProps
|
|
55
|
+
*/
|
|
56
|
+
export interface AccordionProps {
|
|
57
|
+
/**
|
|
58
|
+
* Whether the accordion is open/expanded.
|
|
59
|
+
* Only used when component is in single accordion mode.
|
|
60
|
+
*
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
open?: boolean;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The caption text displayed in the accordion header.
|
|
67
|
+
* Only used when component is in single accordion mode.
|
|
68
|
+
*/
|
|
69
|
+
caption?: string;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Icon configuration for the accordion header.
|
|
73
|
+
* Can be a boolean to show/hide default icon, or a specific BaklavaIcon.
|
|
74
|
+
* Only used when component is in single accordion mode.
|
|
75
|
+
*/
|
|
76
|
+
icon?: boolean | BaklavaIcon;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Whether the accordion is disabled.
|
|
80
|
+
* Only used when component is in single accordion mode.
|
|
81
|
+
*
|
|
82
|
+
* @default false
|
|
83
|
+
*/
|
|
84
|
+
disabled?: boolean;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Duration of the expand/collapse animation in milliseconds.
|
|
88
|
+
* Only used when component is in single accordion mode.
|
|
89
|
+
*
|
|
90
|
+
* @default 250
|
|
91
|
+
*/
|
|
92
|
+
animationDuration?: number;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Allow multiple accordions to be open at once.
|
|
96
|
+
* When this prop is provided, the component acts as an accordion group container.
|
|
97
|
+
* When not provided, the component acts as a single accordion.
|
|
98
|
+
*
|
|
99
|
+
* @default false (when used as group)
|
|
100
|
+
*/
|
|
101
|
+
multiple?: boolean;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Array of accordion items to render when in group mode.
|
|
105
|
+
* Each item will be rendered as a bl-accordion element.
|
|
106
|
+
* Only used when component is in group mode.
|
|
107
|
+
*/
|
|
108
|
+
items?: AccordionItem[];
|
|
109
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Alert Component
|
|
4
|
+
*
|
|
5
|
+
* A Vue UI kit component for Baklava's `bl-alert` web component.
|
|
6
|
+
* Displays contextual feedback messages with variants (info, success, warning, danger).
|
|
7
|
+
*
|
|
8
|
+
* @component
|
|
9
|
+
* @example
|
|
10
|
+
* ```vue
|
|
11
|
+
* <!-- Basic alert -->
|
|
12
|
+
* <template>
|
|
13
|
+
* <BvAlert variant="info" description="This is an informational message" />
|
|
14
|
+
* </template>
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```vue
|
|
19
|
+
* <!-- Closable alert with controlled state -->
|
|
20
|
+
* <template>
|
|
21
|
+
* <BvAlert
|
|
22
|
+
* variant="warning"
|
|
23
|
+
* caption="Warning"
|
|
24
|
+
* closable
|
|
25
|
+
* :closed="isClosed"
|
|
26
|
+
* @close="isClosed = true"
|
|
27
|
+
* >
|
|
28
|
+
* <p>You can close this alert.</p>
|
|
29
|
+
* </BvAlert>
|
|
30
|
+
* </template>
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```vue
|
|
35
|
+
* <!-- Programmatic control via ref -->
|
|
36
|
+
* <template>
|
|
37
|
+
* <BvAlert ref="alertRef" variant="success" closable>
|
|
38
|
+
* <p>Content</p>
|
|
39
|
+
* </BvAlert>
|
|
40
|
+
* <button @click="alertRef?.close()">Close</button>
|
|
41
|
+
* </template>
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
import { nextTick, onMounted, ref, watch } from "vue";
|
|
45
|
+
import { loadBaklavaResources } from "../utils/loadBaklavaResources";
|
|
46
|
+
import type { AlertProps, BlAlertElement } from "./alert.types";
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Component props with default values.
|
|
50
|
+
*/
|
|
51
|
+
const props = withDefaults(defineProps<AlertProps>(), {
|
|
52
|
+
variant: "info",
|
|
53
|
+
description: undefined,
|
|
54
|
+
icon: undefined,
|
|
55
|
+
closable: false,
|
|
56
|
+
caption: undefined,
|
|
57
|
+
closed: false,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const emit = defineEmits<{
|
|
61
|
+
/**
|
|
62
|
+
* Emitted when the close button is clicked (only when closable is true).
|
|
63
|
+
*/
|
|
64
|
+
close: [];
|
|
65
|
+
}>();
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Reference to the underlying bl-alert element.
|
|
69
|
+
*/
|
|
70
|
+
const alertRef = ref<HTMLElement | null>(null);
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Safely casts an HTMLElement to BlAlertElement.
|
|
74
|
+
*
|
|
75
|
+
* @param el - The element to cast.
|
|
76
|
+
* @returns The element typed as BlAlertElement, or null.
|
|
77
|
+
*/
|
|
78
|
+
function asBlAlert(el: HTMLElement | null): BlAlertElement | null {
|
|
79
|
+
return el as BlAlertElement | null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Waits for the bl-alert custom element to be defined.
|
|
84
|
+
* Used when Baklava script loads asynchronously.
|
|
85
|
+
*/
|
|
86
|
+
async function waitForBlAlert(): Promise<void> {
|
|
87
|
+
if (!customElements.get("bl-alert")) {
|
|
88
|
+
await customElements.whenDefined("bl-alert");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Syncs the `closed` prop state with the underlying bl-alert web component.
|
|
94
|
+
* Calls open() or close() on the element when prop and element state differ.
|
|
95
|
+
*
|
|
96
|
+
* @param el - The bl-alert element to sync.
|
|
97
|
+
*/
|
|
98
|
+
function syncWithBlAlert(el: HTMLElement): void {
|
|
99
|
+
const blAlert = asBlAlert(el);
|
|
100
|
+
if (!blAlert || typeof blAlert.close !== "function" || typeof blAlert.open !== "function") {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (props.closed && !blAlert.closed) {
|
|
104
|
+
blAlert.close();
|
|
105
|
+
} else if (!props.closed && blAlert.closed) {
|
|
106
|
+
blAlert.open();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Calls open or close on the bl-alert element when available.
|
|
112
|
+
*
|
|
113
|
+
* @param method - The method to call ("open" or "close").
|
|
114
|
+
*/
|
|
115
|
+
function callBlAlertMethod(method: "open" | "close"): void {
|
|
116
|
+
const el = asBlAlert(alertRef.value);
|
|
117
|
+
if (el && typeof el[method] === "function") {
|
|
118
|
+
el[method]!();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Watches for changes to the closed prop and syncs with the web component.
|
|
124
|
+
*/
|
|
125
|
+
watch(
|
|
126
|
+
() => props.closed,
|
|
127
|
+
() => {
|
|
128
|
+
if (alertRef.value) {
|
|
129
|
+
syncWithBlAlert(alertRef.value);
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Handles the bl-close event from the underlying web component.
|
|
136
|
+
* Forwards it to the component's emit.
|
|
137
|
+
*/
|
|
138
|
+
function handleClose(): void {
|
|
139
|
+
emit("close");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Lifecycle hook: Component mounted.
|
|
144
|
+
*
|
|
145
|
+
* Loads Baklava resources, waits for bl-alert to be defined,
|
|
146
|
+
* then syncs the initial closed state with the web component.
|
|
147
|
+
*/
|
|
148
|
+
onMounted(async () => {
|
|
149
|
+
loadBaklavaResources();
|
|
150
|
+
|
|
151
|
+
await nextTick();
|
|
152
|
+
await waitForBlAlert();
|
|
153
|
+
|
|
154
|
+
if (alertRef.value) {
|
|
155
|
+
syncWithBlAlert(alertRef.value);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Exposed methods for programmatic control of the alert.
|
|
161
|
+
*/
|
|
162
|
+
defineExpose({
|
|
163
|
+
/**
|
|
164
|
+
* Opens the alert programmatically.
|
|
165
|
+
*
|
|
166
|
+
* @public
|
|
167
|
+
*/
|
|
168
|
+
open: async (): Promise<void> => {
|
|
169
|
+
await nextTick();
|
|
170
|
+
callBlAlertMethod("open");
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Closes the alert programmatically.
|
|
175
|
+
*
|
|
176
|
+
* @public
|
|
177
|
+
*/
|
|
178
|
+
close: async (): Promise<void> => {
|
|
179
|
+
await nextTick();
|
|
180
|
+
callBlAlertMethod("close");
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
</script>
|
|
184
|
+
|
|
185
|
+
<template>
|
|
186
|
+
<bl-alert
|
|
187
|
+
ref="alertRef"
|
|
188
|
+
v-bind="{
|
|
189
|
+
...props,
|
|
190
|
+
closable: props.closable === true ? true : undefined,
|
|
191
|
+
closed: props.closed,
|
|
192
|
+
}"
|
|
193
|
+
@bl-close="handleClose"
|
|
194
|
+
>
|
|
195
|
+
<slot v-if="$slots['caption']" name="caption" />
|
|
196
|
+
<slot v-if="$slots['default']" />
|
|
197
|
+
<slot v-if="$slots['action']" name="action" />
|
|
198
|
+
</bl-alert>
|
|
199
|
+
</template>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { BaklavaIcon } from "@trendyol/baklava-icons";
|
|
2
|
+
import type { AlertVariant } from "@trendyol/baklava/dist/components/alert/bl-alert";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Interface for the bl-alert custom element.
|
|
6
|
+
* Extends HTMLElement with Baklava Alert API.
|
|
7
|
+
*
|
|
8
|
+
* @interface BlAlertElement
|
|
9
|
+
*/
|
|
10
|
+
export interface BlAlertElement extends HTMLElement {
|
|
11
|
+
closed?: boolean;
|
|
12
|
+
open?: () => void;
|
|
13
|
+
close?: () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Props for the Alert component.
|
|
18
|
+
* Wraps Baklava's bl-alert web component.
|
|
19
|
+
*
|
|
20
|
+
* @interface AlertProps
|
|
21
|
+
*/
|
|
22
|
+
export interface AlertProps {
|
|
23
|
+
/**
|
|
24
|
+
* Alert variant (success, danger, info, warning).
|
|
25
|
+
*
|
|
26
|
+
* @default "info"
|
|
27
|
+
*/
|
|
28
|
+
variant?: AlertVariant;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Alert description text.
|
|
32
|
+
*/
|
|
33
|
+
description?: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Icon configuration: boolean to show/hide default icon, or a specific BaklavaIcon.
|
|
37
|
+
*/
|
|
38
|
+
icon?: boolean | BaklavaIcon;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Whether to show the close button.
|
|
42
|
+
*
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
closable?: boolean;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Alert caption text.
|
|
49
|
+
*/
|
|
50
|
+
caption?: string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Whether the alert is closed/collapsed.
|
|
54
|
+
*
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
closed?: boolean;
|
|
58
|
+
}
|