@antify/ui 2.4.4 → 2.4.10
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/AntDropdown.vue +1 -2
- package/dist/components/buttons/AntButton.vue +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +7 -0
- package/dist/components/index.mjs +3 -1
- package/dist/components/inputs/AntColorInput/AntColorInput.stories.d.ts +7 -0
- package/dist/components/inputs/AntColorInput/AntColorInput.stories.js +173 -0
- package/dist/components/inputs/AntColorInput/AntColorInput.stories.mjs +192 -0
- package/dist/components/inputs/AntColorInput/AntColorInput.types.d.ts +9 -0
- package/dist/components/inputs/AntColorInput/AntColorInput.types.js +16 -0
- package/dist/components/inputs/AntColorInput/AntColorInput.types.mjs +10 -0
- package/dist/components/inputs/AntColorInput/AntColorInput.vue +231 -0
- package/dist/components/inputs/AntColorInput/Color.vue +81 -0
- package/dist/components/inputs/AntColorInput/ColorSelection.vue +60 -0
- package/dist/components/inputs/AntImageInput.vue +91 -22
- package/dist/components/inputs/AntSelect.vue +4 -3
- package/dist/components/inputs/AntTagInput.vue +6 -2
- package/dist/components/inputs/Elements/AntSelectMenu.vue +15 -7
- package/dist/components/inputs/__stories/AntSelect.stories.d.ts +1 -0
- package/dist/components/inputs/__stories/AntSelect.stories.js +47 -3
- package/dist/components/inputs/__stories/AntSelect.stories.mjs +48 -2
- package/dist/components/inputs/__types/index.d.ts +1 -0
- package/dist/components/inputs/__types/index.js +11 -0
- package/dist/components/inputs/__types/index.mjs +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import AntField from '../../forms/AntField.vue';
|
|
3
|
+
import AntButton from '../../buttons/AntButton.vue';
|
|
4
|
+
import {
|
|
5
|
+
faMultiply,
|
|
6
|
+
} from '@fortawesome/free-solid-svg-icons';
|
|
7
|
+
import AntSkeleton from '../../AntSkeleton.vue';
|
|
8
|
+
import {
|
|
9
|
+
Grouped, InputState, Size, State,
|
|
10
|
+
} from '../../../enums';
|
|
11
|
+
import {
|
|
12
|
+
computed, nextTick, onMounted, ref, watch,
|
|
13
|
+
} from 'vue';
|
|
14
|
+
import Color from './Color.vue';
|
|
15
|
+
import AntDropdown from '../../AntDropdown.vue';
|
|
16
|
+
import ColorSelection from './ColorSelection.vue';
|
|
17
|
+
import type {
|
|
18
|
+
ColorInputSize,
|
|
19
|
+
} from './AntColorInput.types';
|
|
20
|
+
|
|
21
|
+
const emit = defineEmits([
|
|
22
|
+
'update:modelValue',
|
|
23
|
+
'validate',
|
|
24
|
+
'blur',
|
|
25
|
+
]);
|
|
26
|
+
const props = withDefaults(defineProps<{
|
|
27
|
+
modelValue: string | null;
|
|
28
|
+
options: string[];
|
|
29
|
+
label?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
skeleton?: boolean;
|
|
32
|
+
readonly?: boolean;
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
state?: InputState;
|
|
35
|
+
size?: Size;
|
|
36
|
+
messages?: string[];
|
|
37
|
+
nullable?: boolean;
|
|
38
|
+
}>(), {
|
|
39
|
+
state: InputState.base,
|
|
40
|
+
size: Size.md,
|
|
41
|
+
messages: () => [],
|
|
42
|
+
nullable: false,
|
|
43
|
+
});
|
|
44
|
+
const _value = computed({
|
|
45
|
+
get() {
|
|
46
|
+
const found = props.options.find((option: string | ColorOption) => typeof option === 'string' ? option === props.modelValue : option.value === props.modelValue);
|
|
47
|
+
|
|
48
|
+
if (!found) {
|
|
49
|
+
return props.options[0];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return found;
|
|
53
|
+
},
|
|
54
|
+
set(val: string | ColorOption) {
|
|
55
|
+
emit('update:modelValue', typeof val === 'string' ? val : val.value);
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
const hasInputState = computed(() => props.skeleton || props.readonly || props.disabled);
|
|
59
|
+
const containerClasses = computed(() => {
|
|
60
|
+
const classes: {
|
|
61
|
+
[key: string]: boolean;
|
|
62
|
+
} = {
|
|
63
|
+
'flex relative w-fit ring-primary/25 rounded-md outline-hidden': true,
|
|
64
|
+
};
|
|
65
|
+
const colorVariant = {
|
|
66
|
+
[InputState.base]: 'focus:ring-primary-200',
|
|
67
|
+
[InputState.danger]: 'focus:ring-danger-200',
|
|
68
|
+
[InputState.info]: 'focus:ring-info-200',
|
|
69
|
+
[InputState.success]: 'focus:ring-success-200',
|
|
70
|
+
[InputState.warning]: 'focus:ring-warning-200',
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
classes[colorVariant[props.state]] = true;
|
|
74
|
+
|
|
75
|
+
return classes;
|
|
76
|
+
});
|
|
77
|
+
const hasRemoveButton = computed<boolean>(() => {
|
|
78
|
+
if (props.nullable) {
|
|
79
|
+
return props.modelValue !== null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return false;
|
|
83
|
+
});
|
|
84
|
+
const itemClasses = computed(() => {
|
|
85
|
+
const classes: {
|
|
86
|
+
[key: string]: boolean;
|
|
87
|
+
} = {
|
|
88
|
+
'relative outline outline-1 -outline-offset-1 rounded-l-md cursor-pointer': true,
|
|
89
|
+
'focus:ring-2': (props.size === Size.xs2 || props.size === Size.xs || props.size === Size.sm) && !hasInputState.value,
|
|
90
|
+
'focus:ring-4': (props.size === Size.md || props.size === Size.lg) && !hasInputState.value,
|
|
91
|
+
'rounded-r-md': !hasRemoveButton.value,
|
|
92
|
+
'p-1': props.size === Size.xs2,
|
|
93
|
+
'p-1.5': props.size === Size.xs || props.size === Size.sm,
|
|
94
|
+
'p-2': props.size === Size.md,
|
|
95
|
+
'p-2.5': props.size === Size.lg,
|
|
96
|
+
invisible: props.skeleton,
|
|
97
|
+
'opacity-50 cursor-not-allowed': props.disabled,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const colorVariant = {
|
|
101
|
+
[InputState.base]: 'outline-base-300 bg-white focus:ring-primary-200',
|
|
102
|
+
[InputState.success]: 'outline-success-500 bg-success-100 focus:ring-success-200',
|
|
103
|
+
[InputState.info]: 'outline-info-500 bg-info-100 focus:ring-info-200',
|
|
104
|
+
[InputState.warning]: 'outline-warning-500 bg-warning-100 focus:ring-warning-200',
|
|
105
|
+
[InputState.danger]: 'outline-danger-500 bg-danger-100 focus:ring-danger-200',
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
classes[colorVariant[props.state]] = true;
|
|
109
|
+
|
|
110
|
+
return classes;
|
|
111
|
+
});
|
|
112
|
+
const showDropdown = ref<boolean>(false);
|
|
113
|
+
const itemRef = ref<HTMLDivElement | null>(null);
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Validate default value if given after delayed data fetching.
|
|
117
|
+
*/
|
|
118
|
+
watch(() => props.skeleton, (val) => {
|
|
119
|
+
if (!val && props.modelValue !== null) {
|
|
120
|
+
emit('validate', props.modelValue);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
watch(_value, () => {
|
|
124
|
+
if (props.messages.length > 0) {
|
|
125
|
+
emit('validate', props.modelValue);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
function onBlur(e: FocusEvent) {
|
|
130
|
+
emit('validate', props.modelValue);
|
|
131
|
+
emit('blur', e);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function onColorSelect(val: string | null) {
|
|
135
|
+
emit('update:modelValue', val);
|
|
136
|
+
nextTick(() => showDropdown.value = false);
|
|
137
|
+
itemRef.value?.focus();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function onClick() {
|
|
141
|
+
if (props.readonly || props.disabled) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
showDropdown.value = true;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function onKeyDown(e: KeyboardEvent) {
|
|
149
|
+
if (props.readonly || props.disabled) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (e.key === 'Enter') {
|
|
154
|
+
showDropdown.value = true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
onMounted(() => {
|
|
159
|
+
if (!props.skeleton && props.modelValue !== null) {
|
|
160
|
+
emit('validate', props.modelValue);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
</script>
|
|
164
|
+
|
|
165
|
+
<template>
|
|
166
|
+
<AntField
|
|
167
|
+
:label="label"
|
|
168
|
+
:size="size"
|
|
169
|
+
:skeleton="skeleton"
|
|
170
|
+
:description="description"
|
|
171
|
+
:state="state"
|
|
172
|
+
:messages="messages"
|
|
173
|
+
label-for="noop"
|
|
174
|
+
>
|
|
175
|
+
<AntDropdown
|
|
176
|
+
v-model:show-dropdown="showDropdown"
|
|
177
|
+
:content-padding="false"
|
|
178
|
+
>
|
|
179
|
+
<div
|
|
180
|
+
:class="containerClasses"
|
|
181
|
+
>
|
|
182
|
+
<div
|
|
183
|
+
class="relative"
|
|
184
|
+
>
|
|
185
|
+
<div
|
|
186
|
+
ref="itemRef"
|
|
187
|
+
:class="itemClasses"
|
|
188
|
+
:tabindex="disabled || readonly ? -1 : 0"
|
|
189
|
+
@click="onClick"
|
|
190
|
+
@keydown="onKeyDown"
|
|
191
|
+
@blur="onBlur"
|
|
192
|
+
>
|
|
193
|
+
<Color
|
|
194
|
+
:value="modelValue"
|
|
195
|
+
:size="size as unknown as ColorInputSize"
|
|
196
|
+
readonly
|
|
197
|
+
/>
|
|
198
|
+
</div>
|
|
199
|
+
|
|
200
|
+
<AntSkeleton
|
|
201
|
+
v-if="skeleton"
|
|
202
|
+
absolute
|
|
203
|
+
:grouped="hasRemoveButton ? Grouped.left : Grouped.none"
|
|
204
|
+
rounded
|
|
205
|
+
/>
|
|
206
|
+
</div>
|
|
207
|
+
|
|
208
|
+
<AntButton
|
|
209
|
+
v-if="hasRemoveButton"
|
|
210
|
+
:icon-left="faMultiply"
|
|
211
|
+
:grouped="Grouped.right"
|
|
212
|
+
:state="state as unknown as State"
|
|
213
|
+
:size="size"
|
|
214
|
+
:skeleton="skeleton"
|
|
215
|
+
:readonly="readonly"
|
|
216
|
+
:disabled="disabled"
|
|
217
|
+
@click="() => emit('update:modelValue', null)"
|
|
218
|
+
@blur="onBlur"
|
|
219
|
+
/>
|
|
220
|
+
</div>
|
|
221
|
+
|
|
222
|
+
<template #content>
|
|
223
|
+
<ColorSelection
|
|
224
|
+
:value="modelValue"
|
|
225
|
+
:colors="props.options"
|
|
226
|
+
@select="onColorSelect"
|
|
227
|
+
/>
|
|
228
|
+
</template>
|
|
229
|
+
</AntDropdown>
|
|
230
|
+
</AntField>
|
|
231
|
+
</template>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import {
|
|
3
|
+
faCheck,
|
|
4
|
+
} from '@fortawesome/free-solid-svg-icons';
|
|
5
|
+
import AntIcon from '../../AntIcon.vue';
|
|
6
|
+
import {
|
|
7
|
+
ColorInputSize,
|
|
8
|
+
} from './AntColorInput.types';
|
|
9
|
+
import {
|
|
10
|
+
computed, ref,
|
|
11
|
+
} from 'vue';
|
|
12
|
+
|
|
13
|
+
defineEmits([
|
|
14
|
+
'select',
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
const props = withDefaults(defineProps<{
|
|
18
|
+
/**
|
|
19
|
+
* Value needs to be a variable name which exists in
|
|
20
|
+
* document computed style as CSS variable like --color-{value}
|
|
21
|
+
*/
|
|
22
|
+
value: string | null;
|
|
23
|
+
selected?: boolean;
|
|
24
|
+
size?: ColorInputSize;
|
|
25
|
+
readonly?: boolean;
|
|
26
|
+
}>(), {
|
|
27
|
+
selected: false,
|
|
28
|
+
size: ColorInputSize.xl,
|
|
29
|
+
readonly: false,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const buttonRef = ref<HTMLButtonElement | null>(null);
|
|
33
|
+
|
|
34
|
+
defineExpose({
|
|
35
|
+
buttonRef: buttonRef,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const buttonClasses = computed(() => ({
|
|
39
|
+
'rounded-sm cursor-pointer flex items-center justify-center': true,
|
|
40
|
+
'h-4 w-4': [
|
|
41
|
+
ColorInputSize.xs,
|
|
42
|
+
ColorInputSize.xs2,
|
|
43
|
+
].includes(props.size),
|
|
44
|
+
'h-5 w-5': [
|
|
45
|
+
ColorInputSize.lg,
|
|
46
|
+
ColorInputSize.md,
|
|
47
|
+
ColorInputSize.sm,
|
|
48
|
+
].includes(props.size),
|
|
49
|
+
'h-8 w-8': ColorInputSize.xl === props.size,
|
|
50
|
+
'h-10 w-10': ColorInputSize.xl2 === props.size,
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
const iconClasses = computed(() => {
|
|
54
|
+
const colorIntensity = Number(props.value?.split('-')[1]);
|
|
55
|
+
|
|
56
|
+
if(!colorIntensity) {
|
|
57
|
+
return 'text-white!';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return colorIntensity < 500 ? 'text-black!' : 'text-white!';
|
|
61
|
+
});
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<template>
|
|
65
|
+
<button
|
|
66
|
+
ref="buttonRef"
|
|
67
|
+
:class="buttonClasses"
|
|
68
|
+
:style="{
|
|
69
|
+
backgroundColor: `var(--color-${value})`,
|
|
70
|
+
outlineColor: `var(--color-${value})`,
|
|
71
|
+
}"
|
|
72
|
+
:tabindex="readonly ? -1 : 0"
|
|
73
|
+
@click.prevent="$emit('select', value)"
|
|
74
|
+
>
|
|
75
|
+
<AntIcon
|
|
76
|
+
v-if="selected"
|
|
77
|
+
:icon="faCheck"
|
|
78
|
+
:class="iconClasses"
|
|
79
|
+
/>
|
|
80
|
+
</button>
|
|
81
|
+
</template>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import {
|
|
3
|
+
Size,
|
|
4
|
+
} from '../../../enums';
|
|
5
|
+
import Color from './Color.vue';
|
|
6
|
+
import {
|
|
7
|
+
ColorInputSize,
|
|
8
|
+
} from './AntColorInput.types';
|
|
9
|
+
import {
|
|
10
|
+
onMounted, ref,
|
|
11
|
+
} from 'vue';
|
|
12
|
+
|
|
13
|
+
defineEmits([
|
|
14
|
+
'select',
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
withDefaults(defineProps<{
|
|
18
|
+
// The selected color value
|
|
19
|
+
value: string | null;
|
|
20
|
+
colors: string[];
|
|
21
|
+
size?: Size;
|
|
22
|
+
}>(), {
|
|
23
|
+
size: Size.md,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
type ColorComponentInstance = Element & {
|
|
27
|
+
buttonRef: HTMLButtonElement | null;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const colorButtonRefs = ref<(ColorComponentInstance | null)[]>([]);
|
|
31
|
+
|
|
32
|
+
onMounted(() => {
|
|
33
|
+
// Set focus to the first item in the colors list
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
colorButtonRefs.value[0]?.buttonRef?.focus();
|
|
36
|
+
}, 50);
|
|
37
|
+
});
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<template>
|
|
41
|
+
<div
|
|
42
|
+
class="grid grid-cols-4 gap-1.5"
|
|
43
|
+
:class="{
|
|
44
|
+
'p-1': size === Size.xs2,
|
|
45
|
+
'p-1.5': size === Size.xs || size === Size.sm,
|
|
46
|
+
'p-2': size === Size.md,
|
|
47
|
+
'p-2.5': size === Size.lg,
|
|
48
|
+
}"
|
|
49
|
+
>
|
|
50
|
+
<Color
|
|
51
|
+
v-for="(color, index) in colors"
|
|
52
|
+
:key="color"
|
|
53
|
+
:ref="(val) => colorButtonRefs[index] = val as ColorComponentInstance"
|
|
54
|
+
:value="color"
|
|
55
|
+
:selected="color === value"
|
|
56
|
+
:size="ColorInputSize.xl2"
|
|
57
|
+
@select="(val) => $emit('select', val)"
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import {
|
|
3
|
-
computed,
|
|
4
|
-
onMounted,
|
|
5
|
-
ref,
|
|
3
|
+
computed, onBeforeUnmount, onMounted, ref,
|
|
6
4
|
} from 'vue';
|
|
7
5
|
import AntField from '../forms/AntField.vue';
|
|
8
6
|
import {
|
|
@@ -11,9 +9,6 @@ import {
|
|
|
11
9
|
import {
|
|
12
10
|
InputState, State,
|
|
13
11
|
} from '../../enums';
|
|
14
|
-
import {
|
|
15
|
-
useVModel,
|
|
16
|
-
} from '@vueuse/core';
|
|
17
12
|
import {
|
|
18
13
|
handleEnumValidation,
|
|
19
14
|
} from '../../handler';
|
|
@@ -73,6 +68,44 @@ const openFileDialog = () => {
|
|
|
73
68
|
fileInput.value?.click();
|
|
74
69
|
};
|
|
75
70
|
|
|
71
|
+
const isDragging = ref<boolean>(false);
|
|
72
|
+
const isDraggingOverDropZone = ref<boolean>(false);
|
|
73
|
+
|
|
74
|
+
const dropZoneClasses = computed(() => {
|
|
75
|
+
return {
|
|
76
|
+
'h-full w-full border-2 border-transparent rounded overflow-y-auto p-2 -top-2 -left-2': true,
|
|
77
|
+
'border-primary-500!': isDraggingOverDropZone.value,
|
|
78
|
+
'border-dashed border-base-300!': isDragging.value,
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const handleDragOver = () => {
|
|
83
|
+
isDraggingOverDropZone.value = true;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const handleDragEnter = () => {
|
|
87
|
+
isDraggingOverDropZone.value = true;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const handleDragLeave = () => {
|
|
91
|
+
isDraggingOverDropZone.value = false;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const handleDrop = (event: DragEvent) => {
|
|
95
|
+
isDraggingOverDropZone.value = false;
|
|
96
|
+
isDragging.value = false;
|
|
97
|
+
|
|
98
|
+
if(!event.dataTransfer) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const file = event.dataTransfer.files?.[0];
|
|
103
|
+
|
|
104
|
+
if(file) {
|
|
105
|
+
emit('upload', file as File);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
76
109
|
const handleFileChange = (event: Event) => {
|
|
77
110
|
const target = event.target as HTMLInputElement;
|
|
78
111
|
const file = target.files?.[0];
|
|
@@ -82,9 +115,34 @@ const handleFileChange = (event: Event) => {
|
|
|
82
115
|
}
|
|
83
116
|
};
|
|
84
117
|
|
|
118
|
+
const handleDragOverBody = (e: DragEvent) => {
|
|
119
|
+
e.preventDefault();
|
|
120
|
+
isDragging.value = true;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const handleDragLeaveBody = (e: DragEvent) => {
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
isDragging.value = false;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const handleDropBody = (e: DragEvent) => {
|
|
129
|
+
e.preventDefault();
|
|
130
|
+
isDragging.value = false;
|
|
131
|
+
};
|
|
132
|
+
|
|
85
133
|
onMounted(() => {
|
|
86
134
|
handleEnumValidation(props.state, InputState, 'state');
|
|
87
135
|
handleEnumValidation(props.size, Size, 'size');
|
|
136
|
+
|
|
137
|
+
document.body.addEventListener('dragover', handleDragOverBody);
|
|
138
|
+
document.body.addEventListener('dragleave', handleDragLeaveBody);
|
|
139
|
+
document.body.addEventListener('drop', handleDropBody);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
onBeforeUnmount(() => {
|
|
143
|
+
document.body.removeEventListener('dragover', handleDragOverBody);
|
|
144
|
+
document.body.removeEventListener('dragleave', handleDragLeaveBody);
|
|
145
|
+
document.body.removeEventListener('drop', handleDropBody);
|
|
88
146
|
});
|
|
89
147
|
</script>
|
|
90
148
|
|
|
@@ -135,25 +193,36 @@ onMounted(() => {
|
|
|
135
193
|
</div>
|
|
136
194
|
|
|
137
195
|
<div class="flex flex-col gap-2.5 w-full">
|
|
138
|
-
<div class="flex items-center relative w-full justify-between">
|
|
139
|
-
<
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
196
|
+
<div class="flex items-center relative w-full justify-between gap-2">
|
|
197
|
+
<div class="relative w-full h-full flex items-center">
|
|
198
|
+
<input
|
|
199
|
+
v-if="!disabled && !skeleton"
|
|
200
|
+
ref="fileInput"
|
|
201
|
+
type="file"
|
|
202
|
+
accept="image/*"
|
|
203
|
+
class="hidden"
|
|
204
|
+
@change="handleFileChange"
|
|
205
|
+
>
|
|
206
|
+
|
|
207
|
+
<span class="text-sm text-for-white-bg-font relative">
|
|
208
|
+
Upload Image
|
|
147
209
|
|
|
148
|
-
|
|
149
|
-
|
|
210
|
+
<AntSkeleton
|
|
211
|
+
v-if="skeleton"
|
|
212
|
+
absolute
|
|
213
|
+
rounded
|
|
214
|
+
/>
|
|
215
|
+
</span>
|
|
150
216
|
|
|
151
|
-
<
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
217
|
+
<div
|
|
218
|
+
class="absolute top-0 left-0 w-full h-full border bg-transparent"
|
|
219
|
+
:class="dropZoneClasses"
|
|
220
|
+
@drop.prevent="handleDrop"
|
|
221
|
+
@dragenter.prevent="handleDragEnter"
|
|
222
|
+
@dragover.prevent="handleDragOver"
|
|
223
|
+
@dragleave.prevent="handleDragLeave"
|
|
155
224
|
/>
|
|
156
|
-
</
|
|
225
|
+
</div>
|
|
157
226
|
|
|
158
227
|
<AntButton
|
|
159
228
|
v-if="src"
|
|
@@ -283,7 +283,6 @@ function onClickRemoveButton() {
|
|
|
283
283
|
:size="size"
|
|
284
284
|
:state="state"
|
|
285
285
|
:close-on-enter="true"
|
|
286
|
-
@select-element="(e) => _modelValue = e"
|
|
287
286
|
>
|
|
288
287
|
<template #contentLeft="props">
|
|
289
288
|
<slot
|
|
@@ -324,7 +323,7 @@ function onClickRemoveButton() {
|
|
|
324
323
|
|
|
325
324
|
<div
|
|
326
325
|
v-else
|
|
327
|
-
class="flex items-center select-none
|
|
326
|
+
class="flex items-center select-none overflow-hidden w-full"
|
|
328
327
|
:class="{
|
|
329
328
|
'gap-1': size === Size.xs2,
|
|
330
329
|
'gap1.5': size === Size.xs,
|
|
@@ -338,7 +337,9 @@ function onClickRemoveButton() {
|
|
|
338
337
|
name="contentLeft"
|
|
339
338
|
v-bind="selectedOption"
|
|
340
339
|
/>
|
|
341
|
-
|
|
340
|
+
<div class="text-ellipsis overflow-hidden whitespace-nowrap w-full text-black">
|
|
341
|
+
{{ valueLabel }}
|
|
342
|
+
</div>
|
|
342
343
|
<slot
|
|
343
344
|
v-if="selectedOption !== null"
|
|
344
345
|
name="contentRight"
|
|
@@ -154,7 +154,6 @@ function onClickOutside() {
|
|
|
154
154
|
if (!dropDownOpen.value) {
|
|
155
155
|
return;
|
|
156
156
|
}
|
|
157
|
-
console.log('click outside');
|
|
158
157
|
// dropDownOpen.value = false;
|
|
159
158
|
}
|
|
160
159
|
|
|
@@ -183,7 +182,6 @@ function addTagFromOptions(item: string | number) {
|
|
|
183
182
|
addTag(item);
|
|
184
183
|
|
|
185
184
|
if (props.autoCloseAfterSelection) {
|
|
186
|
-
console.log('HIER');
|
|
187
185
|
dropDownOpen.value = false;
|
|
188
186
|
}
|
|
189
187
|
}
|
|
@@ -221,6 +219,10 @@ function changeFocus() {
|
|
|
221
219
|
dropDownOpen.value = true;
|
|
222
220
|
}
|
|
223
221
|
|
|
222
|
+
function closeDropdown() {
|
|
223
|
+
dropDownOpen.value = false;
|
|
224
|
+
}
|
|
225
|
+
|
|
224
226
|
function onBlur(e: FocusEvent) {
|
|
225
227
|
emit('validate', props.modelValue);
|
|
226
228
|
emit('blur', e);
|
|
@@ -312,9 +314,11 @@ onMounted(() => {
|
|
|
312
314
|
:class="inputClasses"
|
|
313
315
|
:disabled="disabled"
|
|
314
316
|
:readonly="readonly"
|
|
317
|
+
@click="changeFocus"
|
|
315
318
|
@focus="changeFocus"
|
|
316
319
|
@keydown.delete="removeLastTag"
|
|
317
320
|
@keydown.enter.prevent="checkCreateTag(tagInput)"
|
|
321
|
+
@keydown.esc.prevent="closeDropdown"
|
|
318
322
|
@blur="onBlur"
|
|
319
323
|
>
|
|
320
324
|
</div>
|
|
@@ -16,13 +16,13 @@ import type {
|
|
|
16
16
|
SelectOption,
|
|
17
17
|
} from '../__types';
|
|
18
18
|
import {
|
|
19
|
-
useElementSize, useVModel,
|
|
19
|
+
onClickOutside, useElementSize, useVModel,
|
|
20
20
|
} from '@vueuse/core';
|
|
21
21
|
import type {
|
|
22
22
|
Validator,
|
|
23
23
|
} from '@antify/validate';
|
|
24
24
|
import {
|
|
25
|
-
autoUpdate, flip, offset, useFloating,
|
|
25
|
+
autoPlacement, autoUpdate, flip, offset, useFloating,
|
|
26
26
|
} from '@floating-ui/vue';
|
|
27
27
|
|
|
28
28
|
const emit = defineEmits([
|
|
@@ -56,13 +56,21 @@ const floating = ref<HTMLElement | null>(null);
|
|
|
56
56
|
const {
|
|
57
57
|
floatingStyles,
|
|
58
58
|
} = useFloating(reference, floating, {
|
|
59
|
-
placement: 'bottom',
|
|
59
|
+
placement: 'bottom-start',
|
|
60
60
|
whileElementsMounted: autoUpdate,
|
|
61
61
|
middleware: [
|
|
62
62
|
offset(8),
|
|
63
|
+
autoPlacement({
|
|
64
|
+
allowedPlacements: [
|
|
65
|
+
'top-start',
|
|
66
|
+
'top-end',
|
|
67
|
+
'bottom-start',
|
|
68
|
+
'bottom-end',
|
|
69
|
+
],
|
|
70
|
+
}),
|
|
63
71
|
flip({
|
|
64
72
|
fallbackPlacements: [
|
|
65
|
-
'top',
|
|
73
|
+
'top-start',
|
|
66
74
|
],
|
|
67
75
|
}),
|
|
68
76
|
],
|
|
@@ -89,7 +97,7 @@ const dropdownClasses = computed(() => {
|
|
|
89
97
|
};
|
|
90
98
|
|
|
91
99
|
return {
|
|
92
|
-
'w-
|
|
100
|
+
'w-fit border flex flex-col gap-px outline-none -mt-px overflow-y-auto shadow-md z-[90] max-h-[250px]': true,
|
|
93
101
|
'rounded-md': true,
|
|
94
102
|
[variants[props.state]]: true,
|
|
95
103
|
};
|
|
@@ -121,7 +129,7 @@ watch(isOpen, () => {
|
|
|
121
129
|
focusedDropDownItem.value =
|
|
122
130
|
typeof _modelValue.value === 'string' || typeof _modelValue.value === 'number' ? _modelValue.value :
|
|
123
131
|
Array.isArray(_modelValue.value) ? _modelValue.value[0] :
|
|
124
|
-
(props.options[0]
|
|
132
|
+
(props.options[0]?.value || null);
|
|
125
133
|
} else {
|
|
126
134
|
focusedDropDownItem.value = null;
|
|
127
135
|
}
|
|
@@ -288,7 +296,7 @@ watch(_modelValue, (val) => {
|
|
|
288
296
|
ref="floating"
|
|
289
297
|
:class="dropdownClasses"
|
|
290
298
|
data-e2e="select-menu"
|
|
291
|
-
:style="{
|
|
299
|
+
:style="{minWidth: `${elementSize.width.value}px!important`, ...floatingStyles}"
|
|
292
300
|
>
|
|
293
301
|
<div
|
|
294
302
|
v-for="(option, index) in options"
|
|
@@ -6,6 +6,7 @@ type Story = StoryObj<typeof AntSelect>;
|
|
|
6
6
|
export declare const Docs: Story;
|
|
7
7
|
export declare const WithSlots: Story;
|
|
8
8
|
export declare const manyOptions: Story;
|
|
9
|
+
export declare const longOptions: Story;
|
|
9
10
|
export declare const nullable: Story;
|
|
10
11
|
export declare const skeleton: Story;
|
|
11
12
|
export declare const disabled: Story;
|