@antify/ui 1.0.4 → 1.2.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/components/AntAccordion.vue +32 -7
- package/dist/components/AntAccordionItem.vue +48 -15
- package/dist/components/AntAlert.vue +8 -6
- package/dist/components/AntDropdown.vue +50 -36
- package/dist/components/AntIcon.vue +8 -6
- package/dist/components/AntKeycap.vue +22 -17
- package/dist/components/AntListGroup.vue +5 -3
- package/dist/components/AntModal.vue +17 -7
- package/dist/components/AntPopover.vue +118 -42
- package/dist/components/AntSkeleton.vue +1 -1
- package/dist/components/AntTooltip.vue +102 -76
- package/dist/components/__stories/AntAccordion.stories.d.ts +1 -0
- package/dist/components/__stories/AntAccordion.stories.js +73 -1
- package/dist/components/__stories/AntAccordion.stories.mjs +68 -0
- package/dist/components/__stories/AntDropdown.stories.js +27 -23
- package/dist/components/__stories/AntDropdown.stories.mjs +26 -22
- package/dist/components/__stories/AntKeycap.stories.js +13 -15
- package/dist/components/__stories/AntKeycap.stories.mjs +13 -13
- package/dist/components/__stories/AntListGroup.stories.js +1 -1
- package/dist/components/__stories/AntListGroup.stories.mjs +1 -1
- package/dist/components/__stories/AntModal.stories.js +2 -1
- package/dist/components/__stories/AntModal.stories.mjs +2 -1
- package/dist/components/__stories/AntPopover.stories.js +22 -21
- package/dist/components/__stories/AntPopover.stories.mjs +22 -20
- package/dist/components/__stories/AntTooltip.stories.d.ts +0 -10
- package/dist/components/__stories/AntTooltip.stories.js +32 -212
- package/dist/components/__stories/AntTooltip.stories.mjs +29 -193
- package/dist/components/__types/AntKeycap.types.d.ts +1 -0
- package/dist/components/__types/AntKeycap.types.js +1 -0
- package/dist/components/__types/AntKeycap.types.mjs +1 -0
- package/dist/components/buttons/AntButton.vue +41 -44
- package/dist/components/crud/AntCrud.vue +1 -1
- package/dist/components/crud/AntCrudDetailActions.vue +1 -0
- package/dist/components/crud/AntCrudTableFilter.vue +20 -18
- package/dist/components/forms/AntField.vue +7 -2
- package/dist/components/forms/__stories/AntField.stories.js +0 -16
- package/dist/components/forms/__stories/AntField.stories.mjs +2 -16
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +7 -7
- package/dist/components/index.mjs +2 -2
- package/dist/components/inputs/AntCheckbox.vue +25 -6
- package/dist/components/inputs/AntDateInput.vue +1 -1
- package/dist/components/inputs/AntRadio.vue +2 -1
- package/dist/components/inputs/AntSelect.vue +25 -22
- package/dist/components/inputs/AntSwitch.vue +2 -7
- package/dist/components/inputs/AntTagInput.vue +91 -114
- package/dist/components/inputs/AntTextarea.vue +7 -3
- package/dist/components/inputs/Elements/AntBaseInput.vue +2 -2
- package/dist/components/inputs/Elements/{AntDropDown.vue → AntSelectMenu.vue} +85 -40
- package/dist/components/inputs/Elements/__stories/AntBaseInput.stories.d.ts +0 -1
- package/dist/components/inputs/Elements/__stories/AntBaseInput.stories.js +1 -29
- package/dist/components/inputs/Elements/__stories/AntBaseInput.stories.mjs +0 -22
- package/dist/components/inputs/Elements/index.d.ts +2 -1
- package/dist/components/inputs/Elements/index.js +7 -0
- package/dist/components/inputs/Elements/index.mjs +3 -1
- package/dist/components/inputs/__stories/AntCheckbox.stories.d.ts +0 -1
- package/dist/components/inputs/__stories/AntCheckbox.stories.js +1 -43
- package/dist/components/inputs/__stories/AntCheckbox.stories.mjs +0 -35
- package/dist/components/inputs/__stories/AntCheckboxGroup.stories.d.ts +0 -1
- package/dist/components/inputs/__stories/AntCheckboxGroup.stories.js +1 -31
- package/dist/components/inputs/__stories/AntCheckboxGroup.stories.mjs +0 -28
- package/dist/components/inputs/__stories/AntDateInput.stories.d.ts +0 -1
- package/dist/components/inputs/__stories/AntDateInput.stories.js +1 -32
- package/dist/components/inputs/__stories/AntDateInput.stories.mjs +0 -28
- package/dist/components/inputs/__stories/AntNumberInput.stories.d.ts +0 -2
- package/dist/components/inputs/__stories/AntNumberInput.stories.js +1 -65
- package/dist/components/inputs/__stories/AntNumberInput.stories.mjs +1 -54
- package/dist/components/inputs/__stories/AntPasswordInput.stories.d.ts +0 -1
- package/dist/components/inputs/__stories/AntPasswordInput.stories.js +1 -35
- package/dist/components/inputs/__stories/AntPasswordInput.stories.mjs +0 -25
- package/dist/components/inputs/__stories/AntRadioGroup.stories.d.ts +0 -1
- package/dist/components/inputs/__stories/AntRadioGroup.stories.js +1 -47
- package/dist/components/inputs/__stories/AntRadioGroup.stories.mjs +0 -46
- package/dist/components/inputs/__stories/AntRangeSlider.stories.d.ts +0 -1
- package/dist/components/inputs/__stories/AntRangeSlider.stories.js +1 -33
- package/dist/components/inputs/__stories/AntRangeSlider.stories.mjs +1 -28
- package/dist/components/inputs/__stories/AntSelect.stories.d.ts +0 -1
- package/dist/components/inputs/__stories/AntSelect.stories.js +18 -46
- package/dist/components/inputs/__stories/AntSelect.stories.mjs +16 -47
- package/dist/components/inputs/__stories/AntSwitch.stories.d.ts +0 -1
- package/dist/components/inputs/__stories/AntSwitch.stories.js +1 -42
- package/dist/components/inputs/__stories/AntSwitch.stories.mjs +1 -37
- package/dist/components/inputs/__stories/AntSwitcher.stories.d.ts +0 -1
- package/dist/components/inputs/__stories/AntSwitcher.stories.js +1 -51
- package/dist/components/inputs/__stories/AntSwitcher.stories.mjs +1 -51
- package/dist/components/inputs/__stories/AntTagInput.stories.d.ts +0 -1
- package/dist/components/inputs/__stories/AntTagInput.stories.js +1 -35
- package/dist/components/inputs/__stories/AntTagInput.stories.mjs +0 -33
- package/dist/components/inputs/__stories/AntTextInput.stories.d.ts +0 -2
- package/dist/components/inputs/__stories/AntTextInput.stories.js +1 -107
- package/dist/components/inputs/__stories/AntTextInput.stories.mjs +0 -104
- package/dist/components/inputs/__stories/AntTextarea.stories.d.ts +0 -2
- package/dist/components/inputs/__stories/AntTextarea.stories.js +7 -66
- package/dist/components/inputs/__stories/AntTextarea.stories.mjs +6 -55
- package/dist/components/inputs/__stories/AntUnitInput.stories.d.ts +0 -2
- package/dist/components/inputs/__stories/AntUnitInput.stories.js +1 -61
- package/dist/components/inputs/__stories/AntUnitInput.stories.mjs +0 -53
- package/dist/components/table/AntTable.vue +17 -15
- package/dist/components/table/AntTd.vue +1 -2
- package/dist/components/table/__stories/AntTable.stories.js +7 -14
- package/dist/components/table/__stories/AntTable.stories.mjs +7 -15
- package/dist/components/tabs/AntTabItem.vue +16 -6
- package/dist/components/tabs/AntTabs.vue +8 -0
- package/dist/components/tabs/__types/AntTabItem.types.d.ts +1 -0
- package/package.json +2 -1
|
@@ -1,57 +1,145 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {computed,
|
|
3
|
-
import {handleEnumValidation} from '../handler';
|
|
2
|
+
import {computed, ref} from 'vue';
|
|
4
3
|
import {Position} from '../enums/Position.enum';
|
|
5
4
|
import {classesToObjectSyntax} from '../utils';
|
|
5
|
+
import {arrow, autoUpdate, flip, offset, useFloating, shift, limitShift} from "@floating-ui/vue";
|
|
6
|
+
import {vOnClickOutside} from '@vueuse/components';
|
|
7
|
+
import {onKeyStroke} from "@vueuse/core";
|
|
6
8
|
|
|
7
9
|
const props = withDefaults(defineProps<{
|
|
8
10
|
showPopover: boolean,
|
|
9
11
|
title?: string,
|
|
10
|
-
|
|
12
|
+
isClickable?: boolean,
|
|
11
13
|
popoverClasses?: string | Record<string, boolean>
|
|
12
14
|
}>(), {
|
|
15
|
+
isClickable: true,
|
|
13
16
|
showPopover: false,
|
|
14
|
-
|
|
17
|
+
preferredPosition: Position.top,
|
|
15
18
|
popoverClasses: ''
|
|
16
19
|
});
|
|
20
|
+
|
|
21
|
+
const emit = defineEmits(['update:showPopover']);
|
|
22
|
+
|
|
23
|
+
const reference = ref<HTMLElement | null>(null)
|
|
24
|
+
const floating = ref<HTMLElement | null>(null)
|
|
25
|
+
const floatingArrow = ref<HTMLElement | null>(null);
|
|
26
|
+
|
|
27
|
+
const {floatingStyles, middlewareData, placement} = useFloating(reference, floating, {
|
|
28
|
+
transform: false,
|
|
29
|
+
placement: 'right',
|
|
30
|
+
whileElementsMounted: autoUpdate,
|
|
31
|
+
middleware: [
|
|
32
|
+
offset(() => 16),
|
|
33
|
+
shift({
|
|
34
|
+
limiter: limitShift({
|
|
35
|
+
offset: {
|
|
36
|
+
mainAxis: 62,
|
|
37
|
+
}
|
|
38
|
+
}),
|
|
39
|
+
}),
|
|
40
|
+
flip({
|
|
41
|
+
fallbackPlacements: ['top', 'bottom', 'left'],
|
|
42
|
+
}),
|
|
43
|
+
arrow({element: floatingArrow})
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const side = computed(() => placement.value.split('-')[0]);
|
|
48
|
+
const staticSide = computed(() => {
|
|
49
|
+
return {
|
|
50
|
+
top: "bottom",
|
|
51
|
+
right: "left",
|
|
52
|
+
bottom: "top",
|
|
53
|
+
left: "right"
|
|
54
|
+
}[side.value] as string
|
|
55
|
+
})
|
|
56
|
+
const arrowTransform = computed(() => {
|
|
57
|
+
if (placement.value === 'bottom') {
|
|
58
|
+
return 'rotate(0deg)'
|
|
59
|
+
} else if (placement.value === 'top') {
|
|
60
|
+
return 'rotate(180deg)'
|
|
61
|
+
} else if (placement.value === 'left') {
|
|
62
|
+
return 'rotate(90deg)'
|
|
63
|
+
} else {
|
|
64
|
+
return 'rotate(270deg)'
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
17
68
|
const _popoverClasses = computed(() => ({
|
|
18
|
-
'
|
|
19
|
-
'bottom-0 mb-[50%] pb-3.5': props.position === Position.top,
|
|
20
|
-
'top-0 mt-[50%] pt-3.5': props.position === Position.bottom,
|
|
21
|
-
'right-0 mr-[100%] pr-3.5': props.position === Position.left,
|
|
22
|
-
'left-0 ml-[100%] pl-3.5': props.position === Position.right,
|
|
69
|
+
'z-[90] min-w-[10rem]': true,
|
|
23
70
|
...classesToObjectSyntax(props.popoverClasses)
|
|
24
71
|
}));
|
|
25
|
-
const classes = computed(() => ({
|
|
26
|
-
'z-10 absolute flex': true,
|
|
27
|
-
'top-0 left-0 right-0 -m-[2.5px] justify-center': props.position === Position.bottom,
|
|
28
|
-
'bottom-0 left-0 right-0 -m-[2.5px] justify-center': props.position === Position.top,
|
|
29
|
-
'top-0 left-0 bottom-0 -ml-[2.5px] items-end pb-1': props.position === Position.right,
|
|
30
|
-
'top-0 right-0 bottom-0 -mr-[2.5px] items-end pb-1': props.position === Position.left,
|
|
31
|
-
}));
|
|
32
72
|
const itemContainerClasses = computed(() => ({
|
|
33
|
-
'relative flex items-center': true,
|
|
34
|
-
'justify-center': props.position === Position.bottom,
|
|
35
|
-
'justify-center rotate-180': props.position === Position.top,
|
|
36
|
-
'justify-start -rotate-90': props.position === Position.right,
|
|
37
|
-
'justify-end rotate-90': props.position === Position.left,
|
|
73
|
+
'relative flex items-center justify-center': true,
|
|
38
74
|
}));
|
|
39
75
|
|
|
40
|
-
|
|
41
|
-
|
|
76
|
+
onKeyStroke('Escape', (e: KeyboardEvent) => {
|
|
77
|
+
if (props.showPopover) {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
emit('update:showPopover', false);
|
|
80
|
+
}
|
|
42
81
|
});
|
|
82
|
+
|
|
83
|
+
const onClickOutside = [
|
|
84
|
+
(ev) => {
|
|
85
|
+
emit('update:showPopover', false);
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
ignore: [floating]
|
|
89
|
+
}
|
|
90
|
+
]
|
|
43
91
|
</script>
|
|
44
92
|
|
|
45
93
|
<template>
|
|
46
94
|
<div class="relative inline-flex justify-center items-end">
|
|
47
|
-
<
|
|
95
|
+
<div
|
|
96
|
+
v-on-click-outside="onClickOutside"
|
|
97
|
+
ref="reference"
|
|
98
|
+
>
|
|
99
|
+
<slot/>
|
|
100
|
+
</div>
|
|
48
101
|
|
|
49
102
|
<Transition name="bounce">
|
|
50
103
|
<template v-if="showPopover">
|
|
51
|
-
<
|
|
52
|
-
<div
|
|
104
|
+
<teleport to="body">
|
|
105
|
+
<div
|
|
106
|
+
:class="_popoverClasses"
|
|
107
|
+
ref="floating"
|
|
108
|
+
:style="floatingStyles"
|
|
109
|
+
>
|
|
110
|
+
<div class="shadow-lg border-neutral-300 rounded-md text-sm relative inline-flex flex-col">
|
|
111
|
+
|
|
112
|
+
<div
|
|
113
|
+
class="border-neutral-300 border-b p-2 bg-neutral-100 rounded-t-md border-t border-l border-r text-neutral-100-font font-semibold"
|
|
114
|
+
>
|
|
115
|
+
<slot name="title">
|
|
116
|
+
{{ title }}
|
|
117
|
+
</slot>
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
<div
|
|
121
|
+
class="p-2 rounded-b-md text-for-white-bg-font border-neutral-300 border-l border-b border-r bg-white"
|
|
122
|
+
>
|
|
123
|
+
<slot name="content"/>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
53
127
|
<div
|
|
54
|
-
|
|
128
|
+
class="flex items-center justify-center"
|
|
129
|
+
ref="floatingArrow"
|
|
130
|
+
:style="{
|
|
131
|
+
position: 'absolute',
|
|
132
|
+
left:
|
|
133
|
+
middlewareData.arrow?.x != null
|
|
134
|
+
? `${middlewareData.arrow.x}px`
|
|
135
|
+
: '',
|
|
136
|
+
top:
|
|
137
|
+
middlewareData.arrow?.y != null
|
|
138
|
+
? `${middlewareData.arrow.y}px`
|
|
139
|
+
: '',
|
|
140
|
+
[staticSide]: '-2.5px',
|
|
141
|
+
transform: arrowTransform
|
|
142
|
+
}"
|
|
55
143
|
>
|
|
56
144
|
<div
|
|
57
145
|
:class="itemContainerClasses"
|
|
@@ -66,12 +154,12 @@ onMounted(() => {
|
|
|
66
154
|
>
|
|
67
155
|
<path
|
|
68
156
|
d="M20.3284 1.82843L23.1569 4.65685C24.6571 6.15715 26.692 7 28.8137 7L6.18629 7C8.30802 7 10.3429 6.15715 11.8431 4.65686L14.6716 1.82843C16.2337 0.266331 18.7663 0.266328 20.3284 1.82843Z"
|
|
69
|
-
:class="{'fill-neutral-100':
|
|
157
|
+
:class="{'fill-neutral-100': placement === Position.bottom, 'fill-white': placement === Position.top || placement === Position.right || placement === Position.left}"
|
|
70
158
|
/>
|
|
71
159
|
|
|
72
160
|
<path
|
|
73
161
|
d="M34.5 7L28.8137 7C26.692 7 24.6571 6.15715 23.1569 4.65685L20.3284 1.82843C18.7663 0.266328 16.2337 0.266331 14.6716 1.82843L11.8431 4.65686C10.3429 6.15715 8.30802 7 6.18629 7L0.5 7L34.5 7Z"
|
|
74
|
-
:class="{'stroke-neutral-100':
|
|
162
|
+
:class="{'stroke-neutral-100': placement === Position.bottom, 'stroke-white': placement === Position.top || placement === Position.right || placement === Position.left}"
|
|
75
163
|
/>
|
|
76
164
|
</svg>
|
|
77
165
|
|
|
@@ -90,20 +178,8 @@ onMounted(() => {
|
|
|
90
178
|
</svg>
|
|
91
179
|
</div>
|
|
92
180
|
</div>
|
|
93
|
-
|
|
94
|
-
<div
|
|
95
|
-
class="border-neutral-300 border-b p-2 bg-neutral-100 rounded-t-md border-t border-l border-r text-neutral-100-font font-semibold"
|
|
96
|
-
>
|
|
97
|
-
{{ title }}
|
|
98
|
-
</div>
|
|
99
|
-
|
|
100
|
-
<div
|
|
101
|
-
class="p-2 rounded-b-md text-for-white-bg-font border-neutral-300 border-l border-b border-r bg-white"
|
|
102
|
-
>
|
|
103
|
-
<slot name="content"/>
|
|
104
|
-
</div>
|
|
105
181
|
</div>
|
|
106
|
-
</
|
|
182
|
+
</teleport>
|
|
107
183
|
</template>
|
|
108
184
|
</Transition>
|
|
109
185
|
</div>
|
|
@@ -25,7 +25,7 @@ const classList = computed(() => ({
|
|
|
25
25
|
'animate-skeleton min-h-[1px] min-w-[1px] inline-block': true,
|
|
26
26
|
'absolute inset-0 w-full h-full z-40': props.absolute,
|
|
27
27
|
'rounded-md': props.rounded && props.grouped === Grouped.none,
|
|
28
|
-
'rounded-
|
|
28
|
+
'rounded-full': props.roundedFull && props.grouped === Grouped.none,
|
|
29
29
|
...groupedClassList.value
|
|
30
30
|
}));
|
|
31
31
|
</script>
|
|
@@ -1,57 +1,59 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {computed,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {classesToObjectSyntax} from '../utils';
|
|
2
|
+
import {computed, ref} from 'vue';
|
|
3
|
+
import {InputState} from '../enums';
|
|
4
|
+
import {arrow, autoUpdate, flip, offset, useFloating} from "@floating-ui/vue";
|
|
6
5
|
import {hasSlotContent} from '../utils';
|
|
6
|
+
import {classesToObjectSyntax} from '../utils';
|
|
7
7
|
|
|
8
8
|
const props = withDefaults(defineProps<{
|
|
9
|
-
|
|
9
|
+
state?: InputState,
|
|
10
|
+
delay?: number,
|
|
10
11
|
tooltipClasses?: string | Record<string, boolean>
|
|
11
|
-
state?: InputState
|
|
12
|
-
expanded?: boolean
|
|
13
|
-
delay?: number
|
|
14
12
|
}>(), {
|
|
15
|
-
position: Position.left,
|
|
16
|
-
tooltipClasses: '',
|
|
17
13
|
state: InputState.base,
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
delay: 600,
|
|
15
|
+
tooltipClasses: '',
|
|
20
16
|
});
|
|
21
|
-
const visible = ref(false);
|
|
22
|
-
const _tooltipClasses = computed(() => ({
|
|
23
|
-
'absolute w-max inline-flex': true,
|
|
24
|
-
// Position
|
|
25
|
-
'bottom-full pb-3.5': props.position === Position.top,
|
|
26
|
-
'top-full pt-3.5': props.position === Position.bottom,
|
|
27
|
-
'right-full pr-3.5': props.position === Position.left,
|
|
28
|
-
'left-full pl-3.5': props.position === Position.right,
|
|
29
|
-
...classesToObjectSyntax(props.tooltipClasses)
|
|
30
|
-
}));
|
|
31
|
-
const classes = computed(() => ({
|
|
32
|
-
'z-10 absolute flex': true,
|
|
33
|
-
'top-0 left-0 right-0 -m-[2px] justify-center': props.position === Position.bottom,
|
|
34
|
-
'bottom-0 left-0 right-0 -m-[2px] justify-center': props.position === Position.top,
|
|
35
|
-
'top-0 left-0 bottom-0 -ml-[2.2px] items-center': props.position === Position.right,
|
|
36
|
-
'top-0 right-0 bottom-0 -mr-[2.2px] items-center': props.position === Position.left,
|
|
37
|
-
}));
|
|
38
|
-
const itemContainerClasses = computed(() => ({
|
|
39
|
-
'relative flex items-center': true,
|
|
40
|
-
'justify-center': props.position === Position.bottom,
|
|
41
|
-
'justify-center rotate-180': props.position === Position.top,
|
|
42
|
-
'justify-center -rotate-90': props.position === Position.right,
|
|
43
|
-
'justify-center rotate-90': props.position === Position.left,
|
|
44
|
-
}));
|
|
45
|
-
const contentClasses = computed(() => {
|
|
46
|
-
const variants: Record<InputState, string> = {
|
|
47
|
-
[InputState.base]: 'text-for-white-bg-font bg-white border-neutral-300',
|
|
48
|
-
[InputState.danger]: 'text-danger-500-font bg-danger-500 border-danger-500',
|
|
49
|
-
[InputState.info]: 'text-info-500-font bg-info-500 border-info-500',
|
|
50
|
-
[InputState.success]: 'text-success-500-font bg-success-500 border-success-500',
|
|
51
|
-
[InputState.warning]: 'text-warning-500-font bg-warning-500 border-warning-500',
|
|
52
|
-
};
|
|
53
17
|
|
|
54
|
-
|
|
18
|
+
const floatOpen = ref<boolean>(false)
|
|
19
|
+
const clickLock = ref(false);
|
|
20
|
+
const timeout = ref<number | undefined>();
|
|
21
|
+
|
|
22
|
+
const reference = ref<HTMLElement | null>(null)
|
|
23
|
+
const floating = ref<HTMLElement | null>(null)
|
|
24
|
+
const floatingArrow = ref<HTMLElement | null>(null);
|
|
25
|
+
|
|
26
|
+
const {floatingStyles, middlewareData, placement} = useFloating(reference, floating, {
|
|
27
|
+
placement: 'top',
|
|
28
|
+
whileElementsMounted: autoUpdate,
|
|
29
|
+
middleware: [
|
|
30
|
+
offset(() => 16),
|
|
31
|
+
flip({
|
|
32
|
+
fallbackPlacements: ['bottom', 'left', 'right'],
|
|
33
|
+
fallbackAxisSideDirection: 'none',
|
|
34
|
+
}),
|
|
35
|
+
arrow({element: floatingArrow})
|
|
36
|
+
]
|
|
37
|
+
});
|
|
38
|
+
const side = computed(() => placement.value.split('-')[0]);
|
|
39
|
+
const staticSide = computed(() => {
|
|
40
|
+
return {
|
|
41
|
+
top: "bottom",
|
|
42
|
+
right: "left",
|
|
43
|
+
bottom: "top",
|
|
44
|
+
left: "right"
|
|
45
|
+
}[side.value] as string
|
|
46
|
+
})
|
|
47
|
+
const arrowTransform = computed(() => {
|
|
48
|
+
if (placement.value === 'bottom') {
|
|
49
|
+
return 'rotate(0deg)'
|
|
50
|
+
} else if (placement.value === 'top') {
|
|
51
|
+
return 'rotate(180deg)'
|
|
52
|
+
} else if (placement.value === 'left') {
|
|
53
|
+
return 'rotate(90deg)'
|
|
54
|
+
} else {
|
|
55
|
+
return 'rotate(270deg)'
|
|
56
|
+
}
|
|
55
57
|
});
|
|
56
58
|
const svgPathClasses = computed(() => {
|
|
57
59
|
const variants: Record<InputState, string> = {
|
|
@@ -75,17 +77,24 @@ const arrowSvgPathClasses = computed(() => {
|
|
|
75
77
|
|
|
76
78
|
return {[variants[props.state]]: true};
|
|
77
79
|
});
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
|
|
80
|
+
const contentClasses = computed(() => {
|
|
81
|
+
const variants: Record<InputState, string> = {
|
|
82
|
+
[InputState.base]: 'text-for-white-bg-font bg-white border-neutral-300',
|
|
83
|
+
[InputState.danger]: 'text-danger-500-font bg-danger-500 border-danger-500',
|
|
84
|
+
[InputState.info]: 'text-info-500-font bg-info-500 border-info-500',
|
|
85
|
+
[InputState.success]: 'text-success-500-font bg-success-500 border-success-500',
|
|
86
|
+
[InputState.warning]: 'text-warning-500-font bg-warning-500 border-warning-500',
|
|
87
|
+
};
|
|
81
88
|
|
|
82
|
-
|
|
83
|
-
handleEnumValidation(props.position, Position, 'position');
|
|
84
|
-
handleEnumValidation(props.state, InputState, 'state');
|
|
89
|
+
return {[variants[props.state]]: true};
|
|
85
90
|
});
|
|
91
|
+
const _tooltipClasses = computed(() => ({
|
|
92
|
+
'w-max inline-flex shadow-lg text-sm z-[90] rounded-md': true,
|
|
93
|
+
...classesToObjectSyntax(props.tooltipClasses)
|
|
94
|
+
}));
|
|
86
95
|
|
|
87
96
|
function onMouseOver() {
|
|
88
|
-
if (
|
|
97
|
+
if (floatOpen.value || clickLock.value) {
|
|
89
98
|
return;
|
|
90
99
|
}
|
|
91
100
|
|
|
@@ -95,52 +104,76 @@ function onMouseOver() {
|
|
|
95
104
|
*/
|
|
96
105
|
clearTimeout(timeout.value);
|
|
97
106
|
|
|
98
|
-
timeout.value = setTimeout(() =>
|
|
107
|
+
timeout.value = setTimeout(() => floatOpen.value = true, props.delay) as unknown as number;
|
|
99
108
|
}
|
|
100
109
|
|
|
101
110
|
function onMouseLeave() {
|
|
102
111
|
clearTimeout(timeout.value);
|
|
103
112
|
|
|
104
|
-
|
|
113
|
+
floatOpen.value = false;
|
|
105
114
|
clickLock.value = false;
|
|
106
115
|
}
|
|
107
116
|
|
|
108
117
|
function onClick() {
|
|
109
118
|
clearTimeout(timeout.value);
|
|
110
119
|
|
|
111
|
-
|
|
120
|
+
floatOpen.value = false;
|
|
112
121
|
clickLock.value = true;
|
|
113
122
|
}
|
|
114
123
|
</script>
|
|
115
124
|
|
|
116
125
|
<template>
|
|
117
126
|
<div
|
|
118
|
-
|
|
119
|
-
class="relative justify-center items-center"
|
|
120
|
-
:class="{'flex w-full': props.expanded, 'inline-flex': !props.expanded}"
|
|
127
|
+
class="relative"
|
|
121
128
|
data-e2e="tooltip"
|
|
122
|
-
@mouseover="() => onMouseOver()"
|
|
123
|
-
@mouseleave="() => onMouseLeave()"
|
|
124
129
|
>
|
|
125
130
|
<div
|
|
126
|
-
|
|
131
|
+
ref="reference"
|
|
132
|
+
@mouseenter="() => onMouseOver()"
|
|
133
|
+
@mouseleave="() => onMouseLeave()"
|
|
127
134
|
@click="() => onClick()"
|
|
128
135
|
>
|
|
129
136
|
<slot/>
|
|
130
137
|
</div>
|
|
131
138
|
|
|
132
|
-
<
|
|
133
|
-
v-if="visible && hasSlotContent($slots.content)"
|
|
134
|
-
:class="_tooltipClasses"
|
|
135
|
-
>
|
|
139
|
+
<teleport to="body">
|
|
136
140
|
<div
|
|
137
|
-
|
|
141
|
+
v-if="floatOpen && hasSlotContent($slots.content)"
|
|
142
|
+
:class="_tooltipClasses"
|
|
143
|
+
ref="floating"
|
|
144
|
+
:style="{
|
|
145
|
+
...floatingStyles,
|
|
146
|
+
display: floatOpen
|
|
147
|
+
? 'block'
|
|
148
|
+
: 'none',
|
|
149
|
+
}"
|
|
150
|
+
data-e2e="tooltip-content"
|
|
138
151
|
>
|
|
139
152
|
<div
|
|
140
|
-
|
|
153
|
+
class="p-2 rounded-md border"
|
|
154
|
+
:class="contentClasses"
|
|
155
|
+
>
|
|
156
|
+
<slot name="content"/>
|
|
157
|
+
</div>
|
|
158
|
+
<div
|
|
159
|
+
class="flex items-center justify-center"
|
|
160
|
+
ref="floatingArrow"
|
|
161
|
+
:style="{
|
|
162
|
+
position: 'absolute',
|
|
163
|
+
left:
|
|
164
|
+
middlewareData.arrow?.x != null
|
|
165
|
+
? `${middlewareData.arrow.x}px`
|
|
166
|
+
: '',
|
|
167
|
+
top:
|
|
168
|
+
middlewareData.arrow?.y != null
|
|
169
|
+
? `${middlewareData.arrow.y}px`
|
|
170
|
+
: '',
|
|
171
|
+
[staticSide]: '-2px',
|
|
172
|
+
transform: arrowTransform
|
|
173
|
+
}"
|
|
141
174
|
>
|
|
142
175
|
<div
|
|
143
|
-
|
|
176
|
+
class="flex items-center justify-center"
|
|
144
177
|
>
|
|
145
178
|
<svg
|
|
146
179
|
class="absolute mt-[.5px]"
|
|
@@ -176,14 +209,7 @@ function onClick() {
|
|
|
176
209
|
</svg>
|
|
177
210
|
</div>
|
|
178
211
|
</div>
|
|
179
|
-
|
|
180
|
-
<div
|
|
181
|
-
class="p-2 rounded-md border"
|
|
182
|
-
:class="contentClasses"
|
|
183
|
-
>
|
|
184
|
-
<slot name="content"/>
|
|
185
|
-
</div>
|
|
186
212
|
</div>
|
|
187
|
-
</
|
|
213
|
+
</teleport>
|
|
188
214
|
</div>
|
|
189
215
|
</template>
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.htmlInContent = exports.default = exports.MultipleCollapseStrategy = exports.Docs = exports.CustomContent = void 0;
|
|
6
|
+
exports.mixedVariants = exports.htmlInContent = exports.default = exports.MultipleCollapseStrategy = exports.Docs = exports.CustomContent = void 0;
|
|
7
7
|
var _AntAccordion = _interopRequireDefault(require("../AntAccordion.vue"));
|
|
8
8
|
var _AntAccordionItem = _interopRequireDefault(require("../AntAccordionItem.vue"));
|
|
9
9
|
var _AntAccordion2 = require("../__types/AntAccordion.types");
|
|
10
|
+
var _AntIcon = _interopRequireDefault(require("../AntIcon.vue"));
|
|
11
|
+
var _freeSolidSvgIcons = require("@fortawesome/free-solid-svg-icons");
|
|
10
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
13
|
const meta = {
|
|
12
14
|
title: "Components/Accordion",
|
|
@@ -117,4 +119,74 @@ const htmlInContent = exports.htmlInContent = {
|
|
|
117
119
|
justo duo dolores et ea rebum. Stet clita kasd`
|
|
118
120
|
}]
|
|
119
121
|
}
|
|
122
|
+
};
|
|
123
|
+
const mixedVariants = exports.mixedVariants = {
|
|
124
|
+
parameters: {
|
|
125
|
+
chromatic: {
|
|
126
|
+
disableSnapshot: false
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
render: args => ({
|
|
130
|
+
components: {
|
|
131
|
+
AntAccordion: _AntAccordion.default,
|
|
132
|
+
AntAccordionItem: _AntAccordionItem.default,
|
|
133
|
+
AntIcon: _AntIcon.default
|
|
134
|
+
},
|
|
135
|
+
setup() {
|
|
136
|
+
return {
|
|
137
|
+
args,
|
|
138
|
+
faEye: _freeSolidSvgIcons.faEye
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
template: `
|
|
142
|
+
<AntAccordion
|
|
143
|
+
v-bind="args"
|
|
144
|
+
:contentPadding="false"
|
|
145
|
+
>
|
|
146
|
+
<template #icon-left="{item, index, isOpen}">
|
|
147
|
+
<AntIcon
|
|
148
|
+
v-if="index === 0"
|
|
149
|
+
:class="{'text-success-500-font': isOpen, 'text-success-200-font': !isOpen}"
|
|
150
|
+
:icon="faEye"/>
|
|
151
|
+
</template>
|
|
152
|
+
|
|
153
|
+
<template #item-content="{index}">
|
|
154
|
+
<div v-if="index === 0">
|
|
155
|
+
This content comes from <code>#item-content</code> slot instead of <code>items.content</code> prop. <br>
|
|
156
|
+
This should not be in skeleton state. The user need to handle it self.
|
|
157
|
+
</div>
|
|
158
|
+
</template>
|
|
159
|
+
</AntAccordion>`
|
|
160
|
+
}),
|
|
161
|
+
args: {
|
|
162
|
+
items: [{
|
|
163
|
+
label: "First entry"
|
|
164
|
+
}, {
|
|
165
|
+
label: `Second entry`,
|
|
166
|
+
content: `<div class="bg-success-100 p-4"><span class="font-bold text-success-500">Success</span> Content</div>`,
|
|
167
|
+
iconLeft: true,
|
|
168
|
+
activeLabelClasses: "bg-success-500 text-success-500-font",
|
|
169
|
+
activeIconClasses: "text-success-500-font",
|
|
170
|
+
inactiveLabelClasses: "bg-success-200 text-success-200-font",
|
|
171
|
+
inactiveIconClasses: "bg-success-200 text-success-200-font",
|
|
172
|
+
contentPadding: false
|
|
173
|
+
}, {
|
|
174
|
+
label: "Third entry",
|
|
175
|
+
content: `<div class="bg-warning-100 p-4"><span class="font-bold text-warning-500">Warning</span> Content</div>`,
|
|
176
|
+
activeLabelClasses: "bg-warning-500 text-warning-500-font",
|
|
177
|
+
activeIconClasses: "text-warning-500-font",
|
|
178
|
+
inactiveLabelClasses: "bg-warning-200 text-warning-200-font",
|
|
179
|
+
inactiveIconClasses: "text-warning-200-font"
|
|
180
|
+
}, {
|
|
181
|
+
label: "Fourth entry",
|
|
182
|
+
content: `<div class="bg-danger-100 p-8"><span class="font-bold text-danger-500">Danger</span> Content</div>`,
|
|
183
|
+
activeLabelClasses: "bg-danger-500 text-danger-500-font",
|
|
184
|
+
activeIconClasses: "text-danger-500-font",
|
|
185
|
+
inactiveLabelClasses: "bg-danger-200 text-danger-200-font",
|
|
186
|
+
inactiveIconClasses: "text-danger-200-font",
|
|
187
|
+
contentPadding: false
|
|
188
|
+
}],
|
|
189
|
+
skeleton: true,
|
|
190
|
+
collapseStrategy: _AntAccordion2.CollapseStrategy.multiple
|
|
191
|
+
}
|
|
120
192
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import AntAccordion from "../AntAccordion.vue";
|
|
2
2
|
import AntAccordionItem from "../AntAccordionItem.vue";
|
|
3
3
|
import { CollapseStrategy } from "../__types/AntAccordion.types.mjs";
|
|
4
|
+
import AntIcon from "../AntIcon.vue";
|
|
5
|
+
import { faEye } from "@fortawesome/free-solid-svg-icons";
|
|
4
6
|
const meta = {
|
|
5
7
|
title: "Components/Accordion",
|
|
6
8
|
component: AntAccordion,
|
|
@@ -99,3 +101,69 @@ export const htmlInContent = {
|
|
|
99
101
|
]
|
|
100
102
|
}
|
|
101
103
|
};
|
|
104
|
+
export const mixedVariants = {
|
|
105
|
+
parameters: {
|
|
106
|
+
chromatic: { disableSnapshot: false }
|
|
107
|
+
},
|
|
108
|
+
render: (args) => ({
|
|
109
|
+
components: { AntAccordion, AntAccordionItem, AntIcon },
|
|
110
|
+
setup() {
|
|
111
|
+
return { args, faEye };
|
|
112
|
+
},
|
|
113
|
+
template: `
|
|
114
|
+
<AntAccordion
|
|
115
|
+
v-bind="args"
|
|
116
|
+
:contentPadding="false"
|
|
117
|
+
>
|
|
118
|
+
<template #icon-left="{item, index, isOpen}">
|
|
119
|
+
<AntIcon
|
|
120
|
+
v-if="index === 0"
|
|
121
|
+
:class="{'text-success-500-font': isOpen, 'text-success-200-font': !isOpen}"
|
|
122
|
+
:icon="faEye"/>
|
|
123
|
+
</template>
|
|
124
|
+
|
|
125
|
+
<template #item-content="{index}">
|
|
126
|
+
<div v-if="index === 0">
|
|
127
|
+
This content comes from <code>#item-content</code> slot instead of <code>items.content</code> prop. <br>
|
|
128
|
+
This should not be in skeleton state. The user need to handle it self.
|
|
129
|
+
</div>
|
|
130
|
+
</template>
|
|
131
|
+
</AntAccordion>`
|
|
132
|
+
}),
|
|
133
|
+
args: {
|
|
134
|
+
items: [
|
|
135
|
+
{
|
|
136
|
+
label: "First entry"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
label: `Second entry`,
|
|
140
|
+
content: `<div class="bg-success-100 p-4"><span class="font-bold text-success-500">Success</span> Content</div>`,
|
|
141
|
+
iconLeft: true,
|
|
142
|
+
activeLabelClasses: "bg-success-500 text-success-500-font",
|
|
143
|
+
activeIconClasses: "text-success-500-font",
|
|
144
|
+
inactiveLabelClasses: "bg-success-200 text-success-200-font",
|
|
145
|
+
inactiveIconClasses: "bg-success-200 text-success-200-font",
|
|
146
|
+
contentPadding: false
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
label: "Third entry",
|
|
150
|
+
content: `<div class="bg-warning-100 p-4"><span class="font-bold text-warning-500">Warning</span> Content</div>`,
|
|
151
|
+
activeLabelClasses: "bg-warning-500 text-warning-500-font",
|
|
152
|
+
activeIconClasses: "text-warning-500-font",
|
|
153
|
+
inactiveLabelClasses: "bg-warning-200 text-warning-200-font",
|
|
154
|
+
inactiveIconClasses: "text-warning-200-font"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
label: "Fourth entry",
|
|
158
|
+
content: `<div class="bg-danger-100 p-8"><span class="font-bold text-danger-500">Danger</span> Content</div>`,
|
|
159
|
+
activeLabelClasses: "bg-danger-500 text-danger-500-font",
|
|
160
|
+
activeIconClasses: "text-danger-500-font",
|
|
161
|
+
inactiveLabelClasses: "bg-danger-200 text-danger-200-font",
|
|
162
|
+
inactiveIconClasses: "text-danger-200-font",
|
|
163
|
+
contentPadding: false
|
|
164
|
+
}
|
|
165
|
+
],
|
|
166
|
+
skeleton: true,
|
|
167
|
+
collapseStrategy: CollapseStrategy.multiple
|
|
168
|
+
}
|
|
169
|
+
};
|