@antify/ui-module 1.5.0 → 1.5.1
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/AntTooltip.vue +30 -18
- 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/form/AntFormGroup.vue +22 -7
- package/package.json +11 -11
- 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/form/AntFormGroup.vue +22 -7
package/dist/module.json
CHANGED
|
@@ -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)"
|
|
@@ -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>
|
|
@@ -7,9 +7,10 @@ import AntSpinner from '../AntSpinner.vue';
|
|
|
7
7
|
import {Grouped} from '../../enums/Grouped.enum';
|
|
8
8
|
import {Size} from '../../enums/Size.enum';
|
|
9
9
|
import {handleEnumValidation} from '../../handler';
|
|
10
|
-
import {ColorType} from '../../enums';
|
|
10
|
+
import {ColorType, InputColorType, Position} from '../../enums';
|
|
11
11
|
import {ButtonType} from './__types';
|
|
12
12
|
import AntIcon from '../AntIcon.vue';
|
|
13
|
+
import AntTooltip from '../AntTooltip.vue';
|
|
13
14
|
import {IconSize} from '../__types/AntIcon.types';
|
|
14
15
|
|
|
15
16
|
defineEmits(['click', 'blur']);
|
|
@@ -30,6 +31,9 @@ const props = withDefaults(defineProps<{
|
|
|
30
31
|
submit?: boolean;
|
|
31
32
|
outlined?: boolean;
|
|
32
33
|
noFocus?: boolean;
|
|
34
|
+
tooltipPosition?: Position;
|
|
35
|
+
tooltipColorType?: InputColorType;
|
|
36
|
+
tooltipDelay?: number;
|
|
33
37
|
}>(), {
|
|
34
38
|
colorType: ColorType.base,
|
|
35
39
|
disabled: false,
|
|
@@ -43,6 +47,9 @@ const props = withDefaults(defineProps<{
|
|
|
43
47
|
submit: false,
|
|
44
48
|
outlined: true,
|
|
45
49
|
noFocus: false,
|
|
50
|
+
tooltipPosition: Position.bottom,
|
|
51
|
+
tooltipColorType: InputColorType.base,
|
|
52
|
+
tooltipDelay: 800
|
|
46
53
|
});
|
|
47
54
|
|
|
48
55
|
const hasAction = computed(() => (props.skeleton || props.readonly || props.disabled))
|
|
@@ -178,50 +185,63 @@ onMounted(() => {
|
|
|
178
185
|
absolute
|
|
179
186
|
/>
|
|
180
187
|
|
|
181
|
-
<
|
|
182
|
-
:
|
|
183
|
-
:
|
|
184
|
-
:type="
|
|
185
|
-
:
|
|
186
|
-
:disabled="disabled || undefined"
|
|
187
|
-
:tabindex="noFocus || hasAction ? '-1' : '0'"
|
|
188
|
-
@click="() => !props.readonly ? $emit('click') : null"
|
|
189
|
-
@blur="() => !props.readonly ? $emit('blur') : null"
|
|
188
|
+
<AntTooltip
|
|
189
|
+
:expanded="expanded"
|
|
190
|
+
:position="tooltipPosition"
|
|
191
|
+
:color-type="tooltipColorType"
|
|
192
|
+
:delay="tooltipDelay"
|
|
190
193
|
>
|
|
191
|
-
<
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
<template #default>
|
|
195
|
+
<component
|
|
196
|
+
:is="is"
|
|
197
|
+
:class="classes"
|
|
198
|
+
:type="type"
|
|
199
|
+
:to="to"
|
|
200
|
+
:disabled="disabled || undefined"
|
|
201
|
+
:tabindex="noFocus || hasAction ? '-1' : '0'"
|
|
202
|
+
@click="() => !props.readonly ? $emit('click') : null"
|
|
203
|
+
@blur="() => !props.readonly ? $emit('blur') : null"
|
|
204
|
+
>
|
|
205
|
+
<AntSpinner
|
|
206
|
+
v-if="spinner"
|
|
207
|
+
:size="size"
|
|
208
|
+
:color-type="colorType"
|
|
209
|
+
:inverted="!filled"
|
|
210
|
+
/>
|
|
197
211
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
212
|
+
<slot
|
|
213
|
+
v-if="!spinner"
|
|
214
|
+
name="icon-left"
|
|
215
|
+
>
|
|
216
|
+
<AntIcon
|
|
217
|
+
v-if="iconLeft"
|
|
218
|
+
:icon="iconLeft"
|
|
219
|
+
:size="size as unknown as IconSize"
|
|
220
|
+
:color="iconColor"
|
|
221
|
+
/>
|
|
222
|
+
</slot>
|
|
209
223
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
224
|
+
<slot
|
|
225
|
+
v-if="!spinner"
|
|
226
|
+
/>
|
|
213
227
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
228
|
+
<slot
|
|
229
|
+
v-if="!spinner"
|
|
230
|
+
name="icon-right"
|
|
231
|
+
>
|
|
232
|
+
<AntIcon
|
|
233
|
+
v-if="iconRight"
|
|
234
|
+
:icon="iconRight"
|
|
235
|
+
:size="size as unknown as IconSize"
|
|
236
|
+
:color="iconColor"
|
|
237
|
+
/>
|
|
238
|
+
</slot>
|
|
239
|
+
</component>
|
|
240
|
+
</template>
|
|
241
|
+
|
|
242
|
+
<template #content>
|
|
243
|
+
<slot name="tooltip-content" />
|
|
244
|
+
</template>
|
|
245
|
+
</AntTooltip>
|
|
226
246
|
</div>
|
|
227
247
|
</template>
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {Grouped} from '../../enums/Grouped.enum';
|
|
3
|
-
import {Size} from '../../enums/Size.enum';
|
|
4
2
|
import AntActionButton from './AntActionButton.vue';
|
|
5
|
-
import {Position} from '../../enums';
|
|
3
|
+
import {Position, Size, Grouped, ColorType} from '../../enums';
|
|
4
|
+
import {faPlus} from '@fortawesome/free-solid-svg-icons';
|
|
6
5
|
|
|
7
6
|
defineEmits(['click', 'blur']);
|
|
8
7
|
withDefaults(defineProps<{
|
|
8
|
+
iconVariant?: boolean;
|
|
9
9
|
size?: Size;
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
grouped?: Grouped;
|
|
12
12
|
skeleton?: boolean;
|
|
13
13
|
expanded?: boolean;
|
|
14
14
|
canCreate?: boolean;
|
|
15
|
-
|
|
15
|
+
tooltipPosition?: Position;
|
|
16
16
|
}>(), {
|
|
17
|
+
iconVariant: false,
|
|
17
18
|
canCreate: true
|
|
18
19
|
});
|
|
19
20
|
</script>
|
|
@@ -21,22 +22,33 @@ withDefaults(defineProps<{
|
|
|
21
22
|
<template>
|
|
22
23
|
<AntActionButton
|
|
23
24
|
:filled="false"
|
|
25
|
+
:color-type="ColorType.primary"
|
|
24
26
|
:size="size"
|
|
25
27
|
:disabled="disabled"
|
|
28
|
+
:icon-left="iconVariant ? faPlus : undefined"
|
|
26
29
|
:grouped="grouped"
|
|
27
30
|
:skeleton="skeleton"
|
|
28
31
|
:expanded="expanded"
|
|
29
32
|
:has-permission="canCreate"
|
|
30
|
-
:
|
|
33
|
+
:tooltip-position="tooltipPosition"
|
|
31
34
|
data-e2e="create-button"
|
|
32
35
|
@click="$emit('click')"
|
|
33
36
|
@blur="$emit('blur')"
|
|
34
37
|
>
|
|
35
|
-
<template
|
|
38
|
+
<template
|
|
39
|
+
v-if="!iconVariant"
|
|
40
|
+
#default
|
|
41
|
+
>
|
|
42
|
+
Create
|
|
43
|
+
</template>
|
|
36
44
|
|
|
37
45
|
<template #invalidPermissionTooltipContent>
|
|
38
46
|
You have no permission to create new entries.<br>
|
|
39
47
|
Please contact your administrator.
|
|
40
48
|
</template>
|
|
49
|
+
|
|
50
|
+
<template #tooltipContent>
|
|
51
|
+
Create new entry
|
|
52
|
+
</template>
|
|
41
53
|
</AntActionButton>
|
|
42
54
|
</template>
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {Grouped} from '../../enums/Grouped.enum';
|
|
3
|
-
import {Size} from '../../enums/Size.enum';
|
|
4
|
-
import {ColorType} from '../../enums/ColorType.enum';
|
|
5
2
|
import AntActionButton from './AntActionButton.vue';
|
|
6
|
-
import {Position} from '../../enums';
|
|
3
|
+
import {Position, Size, Grouped, ColorType} from '../../enums';
|
|
7
4
|
import {faTrash} from '@fortawesome/free-solid-svg-icons';
|
|
8
5
|
|
|
9
6
|
defineEmits(['click', 'blur']);
|
|
@@ -15,25 +12,25 @@ withDefaults(defineProps<{
|
|
|
15
12
|
skeleton?: boolean;
|
|
16
13
|
expanded?: boolean;
|
|
17
14
|
canDelete?: boolean;
|
|
18
|
-
|
|
15
|
+
tooltipPosition?: Position;
|
|
19
16
|
}>(), {
|
|
20
17
|
iconVariant: false,
|
|
21
18
|
canDelete: true
|
|
22
|
-
})
|
|
19
|
+
});
|
|
23
20
|
</script>
|
|
24
21
|
|
|
25
22
|
<template>
|
|
26
23
|
<AntActionButton
|
|
27
|
-
:icon-left="iconVariant ? faTrash : undefined"
|
|
28
24
|
:filled="false"
|
|
25
|
+
:color-type="ColorType.danger"
|
|
29
26
|
:size="size"
|
|
30
27
|
:disabled="disabled"
|
|
28
|
+
:icon-left="iconVariant ? faTrash : undefined"
|
|
31
29
|
:grouped="grouped"
|
|
32
30
|
:skeleton="skeleton"
|
|
33
31
|
:expanded="expanded"
|
|
34
|
-
:color-type="ColorType.danger"
|
|
35
32
|
:has-permission="canDelete"
|
|
36
|
-
:
|
|
33
|
+
:tooltip-position="tooltipPosition"
|
|
37
34
|
data-e2e="delete-button"
|
|
38
35
|
@click="$emit('click')"
|
|
39
36
|
@blur="$emit('blur')"
|
|
@@ -46,8 +43,12 @@ withDefaults(defineProps<{
|
|
|
46
43
|
</template>
|
|
47
44
|
|
|
48
45
|
<template #invalidPermissionTooltipContent>
|
|
49
|
-
You have no permission to delete
|
|
46
|
+
You have no permission to delete entries.<br>
|
|
50
47
|
Please contact your administrator.
|
|
51
48
|
</template>
|
|
49
|
+
|
|
50
|
+
<template #tooltipContent>
|
|
51
|
+
Delete entry
|
|
52
|
+
</template>
|
|
52
53
|
</AntActionButton>
|
|
53
54
|
</template>
|