@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
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* Tooltip Component
|
|
4
|
+
*
|
|
5
|
+
* A Vue UI kit component for Baklava's `bl-tooltip` web component for displaying contextual
|
|
6
|
+
* information on hover or focus. The trigger is provided via the default slot;
|
|
7
|
+
* content can be set via the `content` prop or the `#content` slot.
|
|
8
|
+
*
|
|
9
|
+
* @component
|
|
10
|
+
* @example
|
|
11
|
+
* ```vue
|
|
12
|
+
* <!-- Basic usage -->
|
|
13
|
+
* <template>
|
|
14
|
+
* <BvTooltip content="This is a tooltip">
|
|
15
|
+
* <BvButton>Hover me</BvButton>
|
|
16
|
+
* </BvTooltip>
|
|
17
|
+
* </template>
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```vue
|
|
22
|
+
* <!-- With placement -->
|
|
23
|
+
* <template>
|
|
24
|
+
* <BvTooltip content="Tooltip" placement="bottom">
|
|
25
|
+
* <span>Trigger</span>
|
|
26
|
+
* </BvTooltip>
|
|
27
|
+
* </template>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
import { computed, onMounted } from "vue";
|
|
31
|
+
import { loadBaklavaResources } from "../utils/loadBaklavaResources";
|
|
32
|
+
import type { TooltipProps } from "./tooltip.types";
|
|
33
|
+
|
|
34
|
+
const props = withDefaults(defineProps<TooltipProps>(), {
|
|
35
|
+
content: undefined,
|
|
36
|
+
placement: undefined,
|
|
37
|
+
trigger: undefined,
|
|
38
|
+
disabled: undefined,
|
|
39
|
+
delay: undefined,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const emit = defineEmits<{
|
|
43
|
+
/**
|
|
44
|
+
* Emitted when the tooltip is shown.
|
|
45
|
+
*/
|
|
46
|
+
show: [];
|
|
47
|
+
/**
|
|
48
|
+
* Emitted when the tooltip is hidden.
|
|
49
|
+
*/
|
|
50
|
+
hide: [];
|
|
51
|
+
}>();
|
|
52
|
+
|
|
53
|
+
// bl-tooltip only supports placement and target. Do not pass trigger (read-only),
|
|
54
|
+
// content, disabled, or delay as they are not supported and cause errors.
|
|
55
|
+
const tooltipProps = computed(() => {
|
|
56
|
+
const bind: Record<string, unknown> = {};
|
|
57
|
+
if (props.placement !== undefined) bind.placement = props.placement;
|
|
58
|
+
if (props.target !== undefined) bind.target = props.target;
|
|
59
|
+
return bind;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
onMounted(() => {
|
|
63
|
+
loadBaklavaResources();
|
|
64
|
+
});
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<template>
|
|
68
|
+
<bl-tooltip
|
|
69
|
+
v-if="!props.disabled"
|
|
70
|
+
v-bind="tooltipProps"
|
|
71
|
+
@bl-tooltip-show="emit('show')"
|
|
72
|
+
@bl-tooltip-hide="emit('hide')"
|
|
73
|
+
>
|
|
74
|
+
<div slot="tooltip-trigger">
|
|
75
|
+
<slot />
|
|
76
|
+
</div>
|
|
77
|
+
<slot v-if="$slots['content']" name="content" />
|
|
78
|
+
<span v-else-if="content">{{ content }}</span>
|
|
79
|
+
</bl-tooltip>
|
|
80
|
+
<slot v-else />
|
|
81
|
+
</template>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Tooltip placement relative to trigger */
|
|
2
|
+
export type TooltipPlacement =
|
|
3
|
+
| "top"
|
|
4
|
+
| "top-start"
|
|
5
|
+
| "top-end"
|
|
6
|
+
| "bottom"
|
|
7
|
+
| "bottom-start"
|
|
8
|
+
| "bottom-end"
|
|
9
|
+
| "left"
|
|
10
|
+
| "left-start"
|
|
11
|
+
| "left-end"
|
|
12
|
+
| "right"
|
|
13
|
+
| "right-start"
|
|
14
|
+
| "right-end";
|
|
15
|
+
|
|
16
|
+
export interface TooltipProps {
|
|
17
|
+
/** Tooltip content text */
|
|
18
|
+
content?: string;
|
|
19
|
+
/** Placement of tooltip relative to trigger (default: 'top') */
|
|
20
|
+
placement?: TooltipPlacement;
|
|
21
|
+
/** Target element (selector or Element) when using external trigger */
|
|
22
|
+
target?: string | Element;
|
|
23
|
+
/** Trigger type: 'hover' | 'click' etc. (passed to bl-tooltip) */
|
|
24
|
+
trigger?: string;
|
|
25
|
+
/** Disabled state */
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/** Delay before showing tooltip (ms) */
|
|
28
|
+
delay?: number;
|
|
29
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const BAKLAVA_VERSION = "3.4.2";
|
|
2
|
+
|
|
3
|
+
export const loadBaklavaResources = () => {
|
|
4
|
+
const loadScript = () => {
|
|
5
|
+
if (!document.querySelector('script[src*="baklava.js"]')) {
|
|
6
|
+
const script = document.createElement("script");
|
|
7
|
+
script.type = "module";
|
|
8
|
+
script.src = `https://cdn.jsdelivr.net/npm/@trendyol/baklava@${BAKLAVA_VERSION}/dist/baklava.js`;
|
|
9
|
+
document.head.appendChild(script);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const loadStyles = () => {
|
|
14
|
+
if (!document.querySelector('link[href*="default.css"]')) {
|
|
15
|
+
const link = document.createElement("link");
|
|
16
|
+
link.rel = "stylesheet";
|
|
17
|
+
link.href = `https://cdn.jsdelivr.net/npm/@trendyol/baklava@${BAKLAVA_VERSION}/dist/themes/default.css`;
|
|
18
|
+
document.head.appendChild(link);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
loadScript();
|
|
23
|
+
loadStyles();
|
|
24
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Enable latest features
|
|
4
|
+
"lib": ["ESNext", "DOM"],
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"moduleDetection": "force",
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
|
|
11
|
+
// Bundler mode
|
|
12
|
+
"moduleResolution": "bundler",
|
|
13
|
+
"allowImportingTsExtensions": true,
|
|
14
|
+
"verbatimModuleSyntax": true,
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
|
|
17
|
+
// Best practices
|
|
18
|
+
"strict": true,
|
|
19
|
+
"skipLibCheck": true,
|
|
20
|
+
"noFallthroughCasesInSwitch": true,
|
|
21
|
+
|
|
22
|
+
// Some stricter flags (disabled by default)
|
|
23
|
+
"noUnusedLocals": true,
|
|
24
|
+
"noUnusedParameters": true,
|
|
25
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
26
|
+
"noImplicitAny": true
|
|
27
|
+
}
|
|
28
|
+
}
|