@antify/ui-module 1.5.0 → 1.6.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/dist/module.json +1 -1
- package/dist/runtime/components/AntAlert.vue +14 -5
- package/dist/runtime/components/AntContent.vue +16 -0
- package/dist/runtime/components/AntPagination.vue +8 -3
- package/dist/runtime/components/AntTooltip.vue +30 -18
- package/dist/runtime/components/__stories/AntAlert.stories.d.ts +1 -0
- package/dist/runtime/components/__stories/AntAlert.stories.mjs +15 -9
- package/dist/runtime/components/__stories/AntContent.stories.d.ts +6 -0
- package/dist/runtime/components/__stories/AntContent.stories.mjs +26 -0
- package/dist/runtime/components/__stories/AntTooltip.stories.d.ts +1 -1
- package/dist/runtime/components/__stories/AntTooltip.stories.mjs +164 -12
- package/dist/runtime/components/buttons/AntActionButton.vue +37 -34
- package/dist/runtime/components/buttons/AntButton.vue +62 -42
- package/dist/runtime/components/buttons/AntCreateButton.vue +18 -6
- package/dist/runtime/components/buttons/AntDeleteButton.vue +11 -10
- package/dist/runtime/components/buttons/AntDuplicateButton.vue +19 -7
- package/dist/runtime/components/buttons/AntEditButton.vue +54 -0
- package/dist/runtime/components/buttons/AntSaveAndNewButton.vue +21 -8
- package/dist/runtime/components/buttons/AntSaveButton.vue +21 -10
- package/dist/runtime/components/buttons/__stories/AntActionButton.stories.d.ts +1 -1
- package/dist/runtime/components/buttons/__stories/AntActionButton.stories.mjs +18 -17
- package/dist/runtime/components/buttons/__stories/AntButton.stories.d.ts +1 -0
- package/dist/runtime/components/buttons/__stories/AntButton.stories.mjs +38 -3
- package/dist/runtime/components/buttons/__stories/AntCreateButton.stories.d.ts +1 -0
- package/dist/runtime/components/buttons/__stories/AntCreateButton.stories.mjs +13 -4
- package/dist/runtime/components/buttons/__stories/AntDeleteButton.stories.d.ts +1 -1
- package/dist/runtime/components/buttons/__stories/AntDeleteButton.stories.mjs +13 -11
- package/dist/runtime/components/buttons/__stories/AntDuplicateButton.stories.d.ts +1 -0
- package/dist/runtime/components/buttons/__stories/AntDuplicateButton.stories.mjs +13 -4
- package/dist/runtime/components/buttons/__stories/AntEditButton.stories.d.ts +12 -0
- package/dist/runtime/components/buttons/__stories/AntEditButton.stories.mjs +76 -0
- package/dist/runtime/components/buttons/__stories/AntSaveAndNewButton.stories.d.ts +1 -0
- package/dist/runtime/components/buttons/__stories/AntSaveAndNewButton.stories.mjs +13 -4
- package/dist/runtime/components/buttons/__stories/AntSaveButton.stories.d.ts +1 -0
- package/dist/runtime/components/buttons/__stories/AntSaveButton.stories.mjs +13 -4
- package/dist/runtime/components/crud/AntCrudTableNav.vue +11 -2
- package/dist/runtime/components/crud/__stories/AntCrudTableNav.stories.mjs +1 -1
- package/dist/runtime/components/form/AntFormGroup.vue +22 -7
- package/dist/runtime/components/form/AntNumberInput.vue +6 -2
- package/dist/runtime/components/form/AntSelect.vue +3 -3
- package/dist/runtime/components/form/AntTagInput.vue +7 -7
- package/dist/runtime/components/form/Elements/AntField.vue +24 -21
- package/dist/runtime/components/form/Elements/AntInputDescription.vue +5 -5
- package/dist/runtime/components/form/__stories/AntNumberInput.stories.d.ts +1 -0
- package/dist/runtime/components/form/__stories/AntNumberInput.stories.mjs +7 -0
- package/dist/runtime/components/layouts/AntNavLeftLayout.vue +2 -2
- package/dist/runtime/components/layouts/__stories/AntNavLeftLayout.stories.mjs +1 -1
- package/package.json +11 -11
- package/src/runtime/components/AntAlert.vue +14 -5
- package/src/runtime/components/AntContent.vue +16 -0
- package/src/runtime/components/AntPagination.vue +8 -3
- package/src/runtime/components/AntTooltip.vue +30 -18
- package/src/runtime/components/buttons/AntActionButton.vue +37 -34
- package/src/runtime/components/buttons/AntButton.vue +62 -42
- package/src/runtime/components/buttons/AntCreateButton.vue +18 -6
- package/src/runtime/components/buttons/AntDeleteButton.vue +11 -10
- package/src/runtime/components/buttons/AntDuplicateButton.vue +19 -7
- package/src/runtime/components/buttons/AntEditButton.vue +54 -0
- package/src/runtime/components/buttons/AntSaveAndNewButton.vue +21 -8
- package/src/runtime/components/buttons/AntSaveButton.vue +21 -10
- package/src/runtime/components/crud/AntCrudTableNav.vue +11 -2
- package/src/runtime/components/form/AntFormGroup.vue +22 -7
- package/src/runtime/components/form/AntNumberInput.vue +6 -2
- package/src/runtime/components/form/AntSelect.vue +3 -3
- package/src/runtime/components/form/AntTagInput.vue +7 -7
- package/src/runtime/components/form/Elements/AntField.vue +24 -21
- package/src/runtime/components/form/Elements/AntInputDescription.vue +5 -5
- package/src/runtime/components/layouts/AntNavLeftLayout.vue +2 -2
package/dist/module.json
CHANGED
|
@@ -18,17 +18,19 @@ import {IconSize} from './__types';
|
|
|
18
18
|
defineEmits(['close']);
|
|
19
19
|
|
|
20
20
|
const props = withDefaults(defineProps<{
|
|
21
|
-
title
|
|
21
|
+
title?: string | null,
|
|
22
22
|
colorType?: InputColorType,
|
|
23
23
|
icon?: boolean,
|
|
24
24
|
expanded?: boolean,
|
|
25
|
-
questionMarkText?: string,
|
|
25
|
+
questionMarkText?: string | null,
|
|
26
26
|
skeleton?: boolean,
|
|
27
27
|
dismissBtn?: boolean,
|
|
28
28
|
}>(), {
|
|
29
|
+
title: null,
|
|
29
30
|
colorType: InputColorType.base,
|
|
30
31
|
icon: true,
|
|
31
32
|
expanded: false,
|
|
33
|
+
questionMarkText: null,
|
|
32
34
|
skeleton: false,
|
|
33
35
|
dismissBtn: true,
|
|
34
36
|
});
|
|
@@ -81,9 +83,14 @@ onMounted(() => {
|
|
|
81
83
|
:class="classes"
|
|
82
84
|
data-e2e="alert"
|
|
83
85
|
>
|
|
84
|
-
<AntSkeleton
|
|
86
|
+
<AntSkeleton
|
|
87
|
+
v-if="skeleton"
|
|
88
|
+
absolute
|
|
89
|
+
rounded
|
|
90
|
+
/>
|
|
85
91
|
|
|
86
92
|
<div
|
|
93
|
+
v-if="icon || hasQuestionMark || dismissBtn || title"
|
|
87
94
|
class="inline-flex items-center justify-between w-content gap-2.5"
|
|
88
95
|
:class="{'invisible': skeleton}"
|
|
89
96
|
>
|
|
@@ -95,7 +102,9 @@ onMounted(() => {
|
|
|
95
102
|
:size="IconSize.sm"
|
|
96
103
|
/>
|
|
97
104
|
|
|
98
|
-
<div
|
|
105
|
+
<div
|
|
106
|
+
:class="{'font-semibold': hasDefaultSlot}"
|
|
107
|
+
>
|
|
99
108
|
<slot name="title">
|
|
100
109
|
{{ title }}
|
|
101
110
|
</slot>
|
|
@@ -131,7 +140,7 @@ onMounted(() => {
|
|
|
131
140
|
</div>
|
|
132
141
|
|
|
133
142
|
<div v-if="hasDefaultSlot">
|
|
134
|
-
<slot/>
|
|
143
|
+
<slot />
|
|
135
144
|
</div>
|
|
136
145
|
</div>
|
|
137
146
|
</template>
|
|
@@ -162,7 +162,11 @@ const pagination = computed(() => {
|
|
|
162
162
|
class="inline-flex relative"
|
|
163
163
|
data-e2e="pagination"
|
|
164
164
|
>
|
|
165
|
-
<AntSkeleton
|
|
165
|
+
<AntSkeleton
|
|
166
|
+
v-if="skeleton"
|
|
167
|
+
rounded
|
|
168
|
+
absolute
|
|
169
|
+
/>
|
|
166
170
|
|
|
167
171
|
<div
|
|
168
172
|
class="inline-flex gap-px"
|
|
@@ -177,14 +181,15 @@ const pagination = computed(() => {
|
|
|
177
181
|
/>
|
|
178
182
|
|
|
179
183
|
<AntButton
|
|
180
|
-
v-for="(pageObj
|
|
184
|
+
v-for="(pageObj) in pagination"
|
|
185
|
+
:key="`pagination-button-${pageObj}`"
|
|
181
186
|
:color-type="pageObj === page ? ColorType.primary : ColorType.base"
|
|
182
187
|
:class="{'text-primary-500 z-10': pageObj === page}"
|
|
183
188
|
:disabled="pageObj === '...'"
|
|
184
189
|
:grouped="Grouped.center"
|
|
185
190
|
:filled="pageObj !== page"
|
|
191
|
+
:readonly="pageObj === page"
|
|
186
192
|
@click="() => page = pageObj"
|
|
187
|
-
v-bind:key="`pagination-button-${index}`"
|
|
188
193
|
>
|
|
189
194
|
{{ pageObj }}
|
|
190
195
|
</AntButton>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {computed, onMounted, ref} from 'vue';
|
|
2
|
+
import {computed, onMounted, ref, getCurrentInstance} from 'vue';
|
|
3
3
|
import {handleEnumValidation} from '../handler';
|
|
4
4
|
import {InputColorType, Position} from '../enums';
|
|
5
5
|
import {classesToObjectSyntax} from '../utils';
|
|
@@ -10,11 +10,13 @@ const props = withDefaults(defineProps<{
|
|
|
10
10
|
tooltipClasses?: string | Record<string, boolean>
|
|
11
11
|
colorType?: InputColorType
|
|
12
12
|
expanded?: boolean
|
|
13
|
+
delay?: number
|
|
13
14
|
}>(), {
|
|
14
15
|
position: Position.left,
|
|
15
16
|
tooltipClasses: '',
|
|
16
17
|
colorType: InputColorType.base,
|
|
17
|
-
expanded: false
|
|
18
|
+
expanded: false,
|
|
19
|
+
delay: 800
|
|
18
20
|
});
|
|
19
21
|
const visible = ref(false);
|
|
20
22
|
const _tooltipClasses = computed(() => ({
|
|
@@ -73,43 +75,53 @@ const arrowSvgPathClasses = computed(() => {
|
|
|
73
75
|
|
|
74
76
|
return {[variants[props.colorType]]: true};
|
|
75
77
|
});
|
|
78
|
+
const timeout = ref<number | undefined>();
|
|
79
|
+
const clickLock = ref(false);
|
|
80
|
+
const uuid = ref(getCurrentInstance()?.uid)
|
|
76
81
|
|
|
77
82
|
onMounted(() => {
|
|
78
83
|
handleEnumValidation(props.position, Position, 'Position')
|
|
79
84
|
handleEnumValidation(props.colorType, InputColorType, 'colorType')
|
|
80
85
|
});
|
|
81
86
|
|
|
82
|
-
/**
|
|
83
|
-
* To prevent a fliggering ux, add a delay on hover and leaving the hover target,
|
|
84
|
-
* before showing the tooltip content.
|
|
85
|
-
*/
|
|
86
|
-
const delayVisible = ref(visible.value);
|
|
87
|
-
|
|
88
87
|
function onMouseOver() {
|
|
89
|
-
|
|
88
|
+
if (visible.value || clickLock.value) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
90
91
|
|
|
91
|
-
setTimeout(() =>
|
|
92
|
-
if (delayVisible.value) {
|
|
93
|
-
visible.value = true
|
|
94
|
-
}
|
|
95
|
-
}, 300)
|
|
92
|
+
timeout.value = setTimeout(() => visible.value = true, props.delay) as unknown as number
|
|
96
93
|
}
|
|
97
94
|
|
|
98
95
|
function onMouseLeave() {
|
|
99
|
-
|
|
96
|
+
clearTimeout(timeout.value)
|
|
97
|
+
|
|
100
98
|
visible.value = false
|
|
99
|
+
clickLock.value = false
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function onClick() {
|
|
103
|
+
clearTimeout(timeout.value)
|
|
104
|
+
|
|
105
|
+
visible.value = false
|
|
106
|
+
clickLock.value = true
|
|
101
107
|
}
|
|
102
108
|
</script>
|
|
103
109
|
|
|
104
110
|
<template>
|
|
105
111
|
<div
|
|
112
|
+
:key="uuid"
|
|
106
113
|
class="relative justify-center items-center"
|
|
107
114
|
:class="{'flex w-full': props.expanded, 'inline-flex': !props.expanded}"
|
|
108
115
|
data-e2e="tooltip"
|
|
109
|
-
@mouseover="onMouseOver"
|
|
110
|
-
@mouseleave="onMouseLeave"
|
|
116
|
+
@mouseover="() => onMouseOver()"
|
|
117
|
+
@mouseleave="() => onMouseLeave()"
|
|
111
118
|
>
|
|
112
|
-
<
|
|
119
|
+
<div
|
|
120
|
+
class="w-full"
|
|
121
|
+
@click="() => onClick()"
|
|
122
|
+
>
|
|
123
|
+
<slot />
|
|
124
|
+
</div>
|
|
113
125
|
|
|
114
126
|
<div
|
|
115
127
|
v-if="visible && hasSlotContent($slots.content)"
|
|
@@ -4,6 +4,7 @@ declare const meta: Meta<typeof AntAlert>;
|
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof AntAlert>;
|
|
6
6
|
export declare const Docs: Story;
|
|
7
|
+
export declare const WithOutTitle: Story;
|
|
7
8
|
export declare const WithContent: Story;
|
|
8
9
|
export declare const WithoutContent: Story;
|
|
9
10
|
export declare const WithQuestionIcon: Story;
|
|
@@ -22,21 +22,27 @@ export const Docs = {
|
|
|
22
22
|
return { args, logClick };
|
|
23
23
|
},
|
|
24
24
|
template: `
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
</AntAlert>
|
|
33
|
-
</div>
|
|
25
|
+
<AntAlert v-bind="args" @close="logClick">
|
|
26
|
+
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, <br/>
|
|
27
|
+
sed diam nonumy eirmod tempor invidunt <br/>
|
|
28
|
+
ut labore et dolore magna aliquyam erat, <br/>
|
|
29
|
+
sed diam voluptua. At vero eos et accusam et <br/>
|
|
30
|
+
justo duo dolores et ea rebum. Stet clita kasd
|
|
31
|
+
</AntAlert>
|
|
34
32
|
`
|
|
35
33
|
}),
|
|
36
34
|
args: {
|
|
37
35
|
title: "Lorem ipsum dolor"
|
|
38
36
|
}
|
|
39
37
|
};
|
|
38
|
+
export const WithOutTitle = {
|
|
39
|
+
render: Docs.render,
|
|
40
|
+
args: {
|
|
41
|
+
title: "",
|
|
42
|
+
dismissBtn: false,
|
|
43
|
+
icon: false
|
|
44
|
+
}
|
|
45
|
+
};
|
|
40
46
|
export const WithContent = {
|
|
41
47
|
render: Docs.render,
|
|
42
48
|
args: {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import AntContent from "../AntContent.vue";
|
|
2
|
+
const meta = {
|
|
3
|
+
title: "Components/Content",
|
|
4
|
+
component: AntContent,
|
|
5
|
+
parameters: { controls: { sort: "requiredFirst" } },
|
|
6
|
+
argTypes: {}
|
|
7
|
+
};
|
|
8
|
+
export default meta;
|
|
9
|
+
export const Docs = {
|
|
10
|
+
parameters: {
|
|
11
|
+
chromatic: { disableSnapshot: false }
|
|
12
|
+
},
|
|
13
|
+
render: (args) => ({
|
|
14
|
+
components: { AntContent },
|
|
15
|
+
setup() {
|
|
16
|
+
return { args };
|
|
17
|
+
},
|
|
18
|
+
template: `
|
|
19
|
+
<div class="outline outline-neutral-300">
|
|
20
|
+
<AntContent v-bind="args" class="h-40">
|
|
21
|
+
<div class="slot h-60">SLOT</div>
|
|
22
|
+
</AntContent>
|
|
23
|
+
</div>`
|
|
24
|
+
}),
|
|
25
|
+
args: {}
|
|
26
|
+
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import AntTooltip from "../AntTooltip.vue";
|
|
2
|
-
import
|
|
2
|
+
import AntFormGroup from "../form/AntFormGroup.vue";
|
|
3
|
+
import AntFormGroupLabel from "../form/AntFormGroupLabel.vue";
|
|
3
4
|
import { Position } from "../../enums/Position.enum.mjs";
|
|
4
5
|
import { InputColorType } from "../../enums/index.mjs";
|
|
6
|
+
import { expect, userEvent, waitFor, within } from "@storybook/test";
|
|
5
7
|
const meta = {
|
|
6
8
|
title: "Components/Tooltip",
|
|
7
9
|
component: AntTooltip,
|
|
8
|
-
parameters: {
|
|
10
|
+
parameters: {
|
|
11
|
+
controls: { sort: "requiredFirst" }
|
|
12
|
+
},
|
|
9
13
|
argTypes: {
|
|
10
14
|
position: {
|
|
11
15
|
control: { type: "select" },
|
|
@@ -20,46 +24,194 @@ const meta = {
|
|
|
20
24
|
export default meta;
|
|
21
25
|
export const Docs = {
|
|
22
26
|
render: (args) => ({
|
|
23
|
-
components: { AntTooltip
|
|
27
|
+
components: { AntTooltip },
|
|
24
28
|
setup() {
|
|
25
29
|
return { args };
|
|
26
30
|
},
|
|
27
31
|
template: `
|
|
28
32
|
<div class="p-32 flex justify-center items-center">
|
|
29
33
|
<AntTooltip v-bind="args">
|
|
30
|
-
<template #content>Lorem ipsum dolor sit
|
|
34
|
+
<template #content>Lorem ipsum dolor sit <br/>amet</template>
|
|
31
35
|
<template #default>
|
|
32
|
-
<
|
|
36
|
+
<div class="box">Hover me</div>
|
|
33
37
|
</template>
|
|
34
38
|
</AntTooltip>
|
|
35
39
|
</div>
|
|
36
40
|
`
|
|
37
41
|
}),
|
|
42
|
+
play: async ({ canvasElement, step }) => {
|
|
43
|
+
const canvas = within(canvasElement);
|
|
44
|
+
const target = canvas.getByText("Hover me");
|
|
45
|
+
function queryTooltip() {
|
|
46
|
+
return canvas.queryByText("Lorem ipsum dolor sit amet");
|
|
47
|
+
}
|
|
48
|
+
await step("Hover over the target and expect showing the tooltip", async () => {
|
|
49
|
+
await userEvent.hover(target);
|
|
50
|
+
await waitFor(() => expect(queryTooltip()).toBeInTheDocument(), { timeout: 600 });
|
|
51
|
+
});
|
|
52
|
+
await step("Leave hover state and expect not showing the tooltip anymore", async () => {
|
|
53
|
+
await userEvent.unhover(target);
|
|
54
|
+
expect(queryTooltip()).not.toBeInTheDocument();
|
|
55
|
+
});
|
|
56
|
+
await step("Hover over the target, wait until the tooltip is visible, click the target and expect not showing the tooltip", async () => {
|
|
57
|
+
await userEvent.hover(target);
|
|
58
|
+
await waitFor(() => expect(queryTooltip()).toBeInTheDocument(), { timeout: 600 });
|
|
59
|
+
await userEvent.click(target);
|
|
60
|
+
expect(queryTooltip()).not.toBeInTheDocument();
|
|
61
|
+
});
|
|
62
|
+
await step("Hover over the target, click it while delay and expect not showing the tooltip", async () => {
|
|
63
|
+
await userEvent.hover(target);
|
|
64
|
+
await waitFor(() => expect(queryTooltip()).not.toBeInTheDocument(), { timeout: 200 });
|
|
65
|
+
await userEvent.click(target);
|
|
66
|
+
expect(queryTooltip()).not.toBeInTheDocument();
|
|
67
|
+
});
|
|
68
|
+
},
|
|
38
69
|
args: {
|
|
70
|
+
delay: 600,
|
|
39
71
|
position: Position.top
|
|
40
72
|
}
|
|
41
73
|
};
|
|
42
74
|
export const WithoutContent = {
|
|
43
75
|
render: (args) => ({
|
|
44
|
-
components: { AntTooltip
|
|
76
|
+
components: { AntTooltip },
|
|
45
77
|
setup() {
|
|
46
78
|
return { args };
|
|
47
79
|
},
|
|
48
80
|
template: `
|
|
49
81
|
<div class="p-32 flex justify-center items-center">
|
|
50
82
|
<AntTooltip v-bind="args">
|
|
51
|
-
<
|
|
83
|
+
<div class="box">Hover me</div>
|
|
52
84
|
|
|
53
85
|
<template #content></template>
|
|
54
86
|
</AntTooltip>
|
|
55
87
|
</div>
|
|
56
|
-
|
|
88
|
+
`
|
|
57
89
|
}),
|
|
90
|
+
play: async ({ canvasElement, step }) => {
|
|
91
|
+
const canvas = within(canvasElement);
|
|
92
|
+
await step("Hover over the target and expect not showing the tooltip", async () => {
|
|
93
|
+
await userEvent.hover(canvas.getByText("Hover me"));
|
|
94
|
+
await waitFor(() => expect(
|
|
95
|
+
canvas.queryByText(
|
|
96
|
+
"Lorem ipsum dolor sit amet"
|
|
97
|
+
)
|
|
98
|
+
).not.toBeInTheDocument());
|
|
99
|
+
});
|
|
100
|
+
},
|
|
58
101
|
args: {}
|
|
59
102
|
};
|
|
60
|
-
export const
|
|
61
|
-
render:
|
|
62
|
-
|
|
63
|
-
|
|
103
|
+
export const Summary = {
|
|
104
|
+
render: (args) => ({
|
|
105
|
+
components: {
|
|
106
|
+
AntTooltip,
|
|
107
|
+
AntFormGroup,
|
|
108
|
+
AntFormGroupLabel
|
|
109
|
+
},
|
|
110
|
+
setup() {
|
|
111
|
+
return { args, Position, InputColorType };
|
|
112
|
+
},
|
|
113
|
+
template: `
|
|
114
|
+
<AntFormGroup>
|
|
115
|
+
<AntFormGroupLabel>Position</AntFormGroupLabel>
|
|
116
|
+
<AntFormGroup direction="row" class="gap-x-32 py-16 dashed">
|
|
117
|
+
<AntTooltip :position="Position.top">
|
|
118
|
+
<div class="box">Hover me</div>
|
|
119
|
+
|
|
120
|
+
<template #content>Lorem</template>
|
|
121
|
+
</AntTooltip>
|
|
122
|
+
|
|
123
|
+
<AntTooltip :position="Position.right">
|
|
124
|
+
<div class="box">Hover me</div>
|
|
125
|
+
|
|
126
|
+
<template #content>Lorem</template>
|
|
127
|
+
</AntTooltip>
|
|
128
|
+
|
|
129
|
+
<AntTooltip :position="Position.bottom">
|
|
130
|
+
<div class="box">Hover me</div>
|
|
131
|
+
|
|
132
|
+
<template #content>Lorem</template>
|
|
133
|
+
</AntTooltip>
|
|
134
|
+
|
|
135
|
+
<AntTooltip :position="Position.left">
|
|
136
|
+
<div class="box">Hover me</div>
|
|
137
|
+
|
|
138
|
+
<template #content>Lorem</template>
|
|
139
|
+
</AntTooltip>
|
|
140
|
+
</AntFormGroup>
|
|
141
|
+
|
|
142
|
+
<AntFormGroupLabel>Color type</AntFormGroupLabel>
|
|
143
|
+
<AntFormGroup direction="row" class="pb-16 dashed">
|
|
144
|
+
<AntTooltip :position="Position.bottom" :color-type="InputColorType.base">
|
|
145
|
+
<div class="box">Hover me</div>
|
|
146
|
+
|
|
147
|
+
<template #content>Lorem</template>
|
|
148
|
+
</AntTooltip>
|
|
149
|
+
|
|
150
|
+
<AntTooltip :position="Position.bottom" :color-type="InputColorType.info">
|
|
151
|
+
<div class="box">Hover me</div>
|
|
152
|
+
|
|
153
|
+
<template #content>Lorem</template>
|
|
154
|
+
</AntTooltip>
|
|
155
|
+
|
|
156
|
+
<AntTooltip :position="Position.bottom" :color-type="InputColorType.success">
|
|
157
|
+
<div class="box">Hover me</div>
|
|
158
|
+
|
|
159
|
+
<template #content>Lorem</template>
|
|
160
|
+
</AntTooltip>
|
|
161
|
+
|
|
162
|
+
<AntTooltip :position="Position.bottom" :color-type="InputColorType.warning">
|
|
163
|
+
<div class="box">Hover me</div>
|
|
164
|
+
|
|
165
|
+
<template #content>Lorem</template>
|
|
166
|
+
</AntTooltip>
|
|
167
|
+
|
|
168
|
+
<AntTooltip :position="Position.bottom" :color-type="InputColorType.danger">
|
|
169
|
+
<div class="box">Hover me</div>
|
|
170
|
+
|
|
171
|
+
<template #content>Lorem</template>
|
|
172
|
+
</AntTooltip>
|
|
173
|
+
</AntFormGroup>
|
|
174
|
+
|
|
175
|
+
<AntFormGroupLabel>Expanded</AntFormGroupLabel>
|
|
176
|
+
<AntFormGroup class="p-32 dashed gap-y-16">
|
|
177
|
+
<AntTooltip :position="Position.top" expanded>
|
|
178
|
+
<div class="box">Hover me</div>
|
|
179
|
+
|
|
180
|
+
<template #content>Lorem</template>
|
|
181
|
+
</AntTooltip>
|
|
182
|
+
|
|
183
|
+
<AntTooltip :position="Position.right" expanded>
|
|
184
|
+
<div class="box">Hover me</div>
|
|
185
|
+
|
|
186
|
+
<template #content>Lorem</template>
|
|
187
|
+
</AntTooltip>
|
|
188
|
+
|
|
189
|
+
<AntTooltip :position="Position.bottom" expanded>
|
|
190
|
+
<div class="box">Hover me</div>
|
|
191
|
+
|
|
192
|
+
<template #content>Lorem</template>
|
|
193
|
+
</AntTooltip>
|
|
194
|
+
|
|
195
|
+
<AntTooltip :position="Position.left" expanded>
|
|
196
|
+
<div class="box">Hover me</div>
|
|
197
|
+
|
|
198
|
+
<template #content>Lorem</template>
|
|
199
|
+
</AntTooltip>
|
|
200
|
+
</AntFormGroup>
|
|
201
|
+
</AntFormGroup>
|
|
202
|
+
`
|
|
203
|
+
}),
|
|
204
|
+
parameters: {
|
|
205
|
+
chromatic: { disableSnapshot: false }
|
|
206
|
+
},
|
|
207
|
+
play: async ({ canvasElement, step }) => {
|
|
208
|
+
const canvas = within(canvasElement);
|
|
209
|
+
await step("Hover over the targets and expect showing the tooltips", async () => {
|
|
210
|
+
const targets = canvas.getAllByText("Hover me");
|
|
211
|
+
await Promise.all(targets.map(async (target) => {
|
|
212
|
+
await userEvent.hover(target);
|
|
213
|
+
}));
|
|
214
|
+
await waitFor(() => expect(canvas.queryAllByText("Lorem")).toHaveLength(targets.length));
|
|
215
|
+
});
|
|
64
216
|
}
|
|
65
217
|
};
|
|
@@ -3,16 +3,14 @@
|
|
|
3
3
|
* This button is used for everything what is the primary
|
|
4
4
|
* action like save, confirm, create, etc.
|
|
5
5
|
*/
|
|
6
|
-
import {Grouped} from '../../enums
|
|
7
|
-
import {Size} from '../../enums/Size.enum';
|
|
8
|
-
import {ColorType, InputColorType} from '../../enums/ColorType.enum';
|
|
9
|
-
import {Position} from '../../enums/Position.enum';
|
|
6
|
+
import {Position, ColorType, InputColorType, Size, Grouped} from '../../enums';
|
|
10
7
|
import AntButton from './AntButton.vue';
|
|
11
|
-
import AntTooltip from '../AntTooltip.vue';
|
|
12
8
|
import type {IconDefinition} from '@fortawesome/free-solid-svg-icons';
|
|
9
|
+
import {computed, useSlots} from 'vue';
|
|
10
|
+
import {hasSlotContent} from '../../utils';
|
|
13
11
|
|
|
14
12
|
defineEmits(['click', 'blur']);
|
|
15
|
-
withDefaults(
|
|
13
|
+
const props = withDefaults(
|
|
16
14
|
defineProps<{
|
|
17
15
|
iconLeft?: IconDefinition;
|
|
18
16
|
iconRight?: IconDefinition;
|
|
@@ -24,45 +22,50 @@ withDefaults(
|
|
|
24
22
|
expanded?: boolean;
|
|
25
23
|
filled?: boolean;
|
|
26
24
|
hasPermission?: boolean;
|
|
27
|
-
|
|
25
|
+
tooltipPosition?: Position;
|
|
26
|
+
tooltipColorType?: InputColorType;
|
|
27
|
+
tooltipDelay?: number;
|
|
28
28
|
}>(), {
|
|
29
29
|
colorType: ColorType.primary,
|
|
30
30
|
hasPermission: true,
|
|
31
31
|
filled: true
|
|
32
32
|
}
|
|
33
33
|
)
|
|
34
|
+
const slots = useSlots();
|
|
35
|
+
const hasTooltip = computed(() => !props.skeleton && !props.disabled && props.hasPermission && hasSlotContent(slots['tooltipContent']));
|
|
36
|
+
const hasPermissionTooltip = computed(() => !props.skeleton && !props.disabled && !props.hasPermission && hasSlotContent(slots['invalidPermissionTooltipContent']));
|
|
34
37
|
</script>
|
|
35
38
|
|
|
36
39
|
<template>
|
|
37
|
-
<
|
|
40
|
+
<AntButton
|
|
41
|
+
:icon-left="iconLeft"
|
|
42
|
+
:icon-right="iconRight"
|
|
43
|
+
:size="size"
|
|
44
|
+
:disabled="disabled || !hasPermission"
|
|
45
|
+
:grouped="grouped"
|
|
46
|
+
:skeleton="skeleton"
|
|
38
47
|
:expanded="expanded"
|
|
39
|
-
:
|
|
40
|
-
:
|
|
48
|
+
:color-type="colorType"
|
|
49
|
+
:filled="filled"
|
|
50
|
+
:tooltip-position="tooltipPosition"
|
|
51
|
+
:tooltip-color-type="hasPermissionTooltip ? InputColorType.info : tooltipColorType"
|
|
52
|
+
:tooltip-delay="hasPermissionTooltip ? 300 : tooltipDelay"
|
|
53
|
+
data-e2e="action-button"
|
|
54
|
+
@click="$emit('click')"
|
|
55
|
+
@blur="$emit('blur')"
|
|
41
56
|
>
|
|
42
|
-
<slot
|
|
43
|
-
<AntButton
|
|
44
|
-
:icon-left="iconLeft"
|
|
45
|
-
:icon-right="iconRight"
|
|
46
|
-
:size="size"
|
|
47
|
-
:disabled="disabled || !hasPermission"
|
|
48
|
-
:grouped="grouped"
|
|
49
|
-
:skeleton="skeleton"
|
|
50
|
-
:expanded="expanded"
|
|
51
|
-
:color-type="colorType"
|
|
52
|
-
:filled="filled"
|
|
53
|
-
data-e2e="action-button"
|
|
54
|
-
@click="$emit('click')"
|
|
55
|
-
@blur="$emit('blur')"
|
|
56
|
-
>
|
|
57
|
-
<slot />
|
|
58
|
-
</AntButton>
|
|
59
|
-
</slot>
|
|
57
|
+
<slot />
|
|
60
58
|
|
|
61
|
-
<template
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
<template #tooltip-content>
|
|
60
|
+
<slot
|
|
61
|
+
v-if="hasTooltip"
|
|
62
|
+
name="tooltipContent"
|
|
63
|
+
/>
|
|
64
|
+
|
|
65
|
+
<slot
|
|
66
|
+
v-if="hasPermissionTooltip"
|
|
67
|
+
name="invalidPermissionTooltipContent"
|
|
68
|
+
/>
|
|
66
69
|
</template>
|
|
67
|
-
</
|
|
70
|
+
</AntButton>
|
|
68
71
|
</template>
|