@antify/ui 2.2.1 → 2.2.3
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 +25 -12
- package/dist/components/AntAccordionItem.vue +28 -13
- package/dist/components/AntAlert.vue +25 -15
- package/dist/components/AntCard.vue +26 -14
- package/dist/components/AntContent.vue +4 -4
- package/dist/components/AntDropdown.vue +41 -23
- package/dist/components/AntIcon.vue +18 -6
- package/dist/components/AntKeycap.vue +31 -16
- package/dist/components/AntListGroup.vue +13 -11
- package/dist/components/AntListGroupItem.vue +19 -9
- package/dist/components/AntModal.vue +26 -15
- package/dist/components/AntPagination.vue +28 -15
- package/dist/components/AntPopover.vue +74 -51
- package/dist/components/AntSkeleton.vue +8 -4
- package/dist/components/AntSpinner.vue +14 -6
- package/dist/components/AntTag.vue +25 -13
- package/dist/components/AntToast.vue +19 -11
- package/dist/components/AntToaster.vue +13 -5
- package/dist/components/AntTooltip.vue +78 -54
- package/dist/components/__stories/AntAccordion.stories.js +4 -4
- package/dist/components/__stories/AntAccordion.stories.mjs +50 -17
- package/dist/components/__stories/AntAlert.stories.mjs +18 -5
- package/dist/components/__stories/AntCard.stories.mjs +36 -10
- package/dist/components/__stories/AntContent.stories.mjs +14 -4
- package/dist/components/__stories/AntDropdown.stories.mjs +20 -4
- package/dist/components/__stories/AntIcon.stories.mjs +38 -12
- package/dist/components/__stories/AntKeycap.stories.mjs +35 -10
- package/dist/components/__stories/AntListGroup.stories.d.ts +1 -1
- package/dist/components/__stories/AntListGroup.stories.mjs +22 -4
- package/dist/components/__stories/AntListGroupItem.stories.mjs +27 -8
- package/dist/components/__stories/AntModal.stories.mjs +17 -4
- package/dist/components/__stories/AntPagination.stories.mjs +21 -6
- package/dist/components/__stories/AntPopover.stories.mjs +20 -4
- package/dist/components/__stories/AntSkeleton.stories.mjs +17 -5
- package/dist/components/__stories/AntSpinner.stories.mjs +33 -9
- package/dist/components/__stories/AntTag.stories.mjs +28 -8
- package/dist/components/__stories/AntToast.stories.mjs +19 -5
- package/dist/components/__stories/AntToaster.stories.d.ts +1 -1
- package/dist/components/__stories/AntToaster.stories.mjs +35 -9
- package/dist/components/__stories/AntTooltip.stories.js +1 -1
- package/dist/components/__stories/AntTooltip.stories.mjs +44 -13
- package/dist/components/buttons/AntActionButton.vue +38 -29
- package/dist/components/buttons/AntButton.vue +34 -13
- package/dist/components/buttons/AntCreateButton.vue +11 -4
- package/dist/components/buttons/AntDeleteButton.vue +11 -4
- package/dist/components/buttons/AntDuplicateButton.vue +11 -4
- package/dist/components/buttons/AntEditButton.vue +11 -4
- package/dist/components/buttons/AntSaveAndNewButton.vue +11 -4
- package/dist/components/buttons/AntSaveButton.vue +11 -4
- package/dist/components/buttons/__stories/AntActionButton.stories.mjs +35 -10
- package/dist/components/buttons/__stories/AntButton.stories.mjs +77 -23
- package/dist/components/buttons/__stories/AntCreateButton.stories.mjs +25 -7
- package/dist/components/buttons/__stories/AntDeleteButton.stories.mjs +25 -7
- package/dist/components/buttons/__stories/AntDuplicateButton.stories.mjs +25 -7
- package/dist/components/buttons/__stories/AntEditButton.stories.mjs +25 -7
- package/dist/components/buttons/__stories/AntSaveAndNewButton.stories.mjs +25 -7
- package/dist/components/buttons/__stories/AntSaveButton.stories.mjs +25 -7
- package/dist/components/crud/AntCrud.vue +6 -6
- package/dist/components/crud/AntCrudDetail.vue +8 -5
- package/dist/components/crud/AntCrudDetailActions.vue +14 -8
- package/dist/components/crud/AntCrudDetailNav.vue +21 -13
- package/dist/components/crud/AntCrudTableFilter.vue +29 -17
- package/dist/components/crud/AntCrudTableNav.vue +36 -22
- package/dist/components/crud/__stories/AntCrud.stories.mjs +17 -5
- package/dist/components/crud/__stories/AntCrudDetail.stories.mjs +11 -3
- package/dist/components/crud/__stories/AntCrudDetailActions.stories.mjs +10 -2
- package/dist/components/crud/__stories/AntCrudDetailNav.stories.mjs +11 -3
- package/dist/components/crud/__stories/AntCrudTableFilter.stories.mjs +17 -5
- package/dist/components/crud/__stories/AntCrudTableNav.stories.mjs +23 -7
- package/dist/components/dialogs/AntDeleteDialog.vue +13 -5
- package/dist/components/dialogs/AntDialog.vue +23 -13
- package/dist/components/dialogs/__stories/AndDeleteDialog.stories.mjs +12 -3
- package/dist/components/dialogs/__stories/AntDialog.stories.mjs +28 -7
- package/dist/components/forms/AntField.vue +18 -7
- package/dist/components/forms/AntFormGroup.vue +9 -5
- package/dist/components/forms/AntFormGroupLabel.vue +1 -1
- package/dist/components/forms/__stories/AntField.stories.mjs +37 -9
- package/dist/components/forms/__stories/AntFormGroup.stories.mjs +20 -5
- package/dist/components/forms/__stories/AntFormGroupLabel.stories.mjs +11 -3
- package/dist/components/index.d.ts +1 -1
- package/dist/components/inputs/AntCheckbox.vue +60 -36
- package/dist/components/inputs/AntCheckboxGroup.vue +39 -15
- package/dist/components/inputs/AntDateInput.vue +35 -12
- package/dist/components/inputs/AntNumberInput.vue +33 -12
- package/dist/components/inputs/AntPasswordInput.vue +32 -11
- package/dist/components/inputs/AntRadio.vue +57 -34
- package/dist/components/inputs/AntRadioGroup.vue +60 -35
- package/dist/components/inputs/AntRangeSlider.vue +31 -12
- package/dist/components/inputs/AntSearch.vue +19 -7
- package/dist/components/inputs/AntSelect.vue +107 -83
- package/dist/components/inputs/AntSwitch.vue +35 -18
- package/dist/components/inputs/AntSwitcher.vue +30 -15
- package/dist/components/inputs/AntTagInput.vue +91 -61
- package/dist/components/inputs/AntTextInput.vue +31 -11
- package/dist/components/inputs/AntTextarea.vue +53 -25
- package/dist/components/inputs/AntUnitInput.vue +33 -12
- package/dist/components/inputs/Elements/AntBaseInput.vue +47 -18
- package/dist/components/inputs/Elements/AntInputDescription.vue +16 -8
- package/dist/components/inputs/Elements/AntInputLabel.vue +13 -5
- package/dist/components/inputs/Elements/AntInputLimiter.vue +13 -5
- package/dist/components/inputs/Elements/AntSelectMenu.vue +65 -41
- package/dist/components/inputs/Elements/__stories/AntBaseInput.stories.mjs +104 -27
- package/dist/components/inputs/Elements/__stories/AntInputDescription.stories.mjs +33 -9
- package/dist/components/inputs/Elements/__stories/AntInputLabel.stories.mjs +34 -9
- package/dist/components/inputs/Elements/__stories/AntInputLimiter.stories.mjs +33 -9
- package/dist/components/inputs/Elements/index.d.ts +1 -1
- package/dist/components/inputs/__stories/AntCheckbox.stories.mjs +34 -9
- package/dist/components/inputs/__stories/AntCheckboxGroup.stories.mjs +45 -21
- package/dist/components/inputs/__stories/AntDateInput.stories.mjs +52 -14
- package/dist/components/inputs/__stories/AntNumberInput.stories.mjs +66 -17
- package/dist/components/inputs/__stories/AntPasswordInput.stories.mjs +51 -13
- package/dist/components/inputs/__stories/AntRadioGroup.stories.mjs +45 -12
- package/dist/components/inputs/__stories/AntRangeSlider.stories.mjs +16 -5
- package/dist/components/inputs/__stories/AntSearch.stories.mjs +41 -10
- package/dist/components/inputs/__stories/AntSelect.stories.mjs +59 -15
- package/dist/components/inputs/__stories/AntSwitch.stories.js +126 -102
- package/dist/components/inputs/__stories/AntSwitch.stories.mjs +162 -112
- package/dist/components/inputs/__stories/AntSwitcher.stories.mjs +38 -10
- package/dist/components/inputs/__stories/AntTagInput.stories.mjs +46 -12
- package/dist/components/inputs/__stories/AntTextInput.stories.mjs +59 -16
- package/dist/components/inputs/__stories/AntTextarea.stories.mjs +47 -13
- package/dist/components/inputs/__stories/AntUnitInput.stories.mjs +46 -12
- package/dist/components/layouts/AntNavLeftLayout.vue +12 -6
- package/dist/components/layouts/__stories/AntNavLeftLayout.stories.mjs +10 -2
- package/dist/components/navbar/AntNavbar.vue +7 -3
- package/dist/components/navbar/AntNavbarItem.vue +12 -6
- package/dist/components/navbar/__stories/AntNavbar.stories.mjs +59 -37
- package/dist/components/table/AntCollapsibleTableRowContent.vue +7 -5
- package/dist/components/table/AntTable.vue +210 -165
- package/dist/components/table/AntTableSkeleton.vue +126 -0
- package/dist/components/table/AntTableSortButton.vue +22 -13
- package/dist/components/table/AntTd.vue +21 -17
- package/dist/components/table/AntTh.vue +19 -12
- package/dist/components/table/__stories/AntTable.stories.js +1 -1
- package/dist/components/table/__stories/AntTable.stories.mjs +190 -62
- package/dist/components/tabs/AntTabItem.vue +20 -8
- package/dist/components/tabs/AntTabs.vue +35 -21
- package/dist/components/tabs/__stories/AntTabItem.stories.mjs +23 -7
- package/dist/components/tabs/__stories/AntTabs.stories.mjs +45 -13
- package/dist/components/transitions/AntTransitionCollapseHeight.vue +1 -1
- package/dist/composables/useToaster.mjs +25 -7
- package/dist/index.css +1 -0
- package/dist/utils.mjs +3 -1
- package/package.json +23 -16
- package/dist/tailwind.config.d.ts +0 -3
- package/dist/tailwind.config.js +0 -198
- package/dist/tailwind.config.mjs +0 -189
|
@@ -1,46 +1,63 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
AntField,
|
|
4
|
+
} from './Elements';
|
|
5
|
+
import {
|
|
6
|
+
InputState, Size,
|
|
7
|
+
} from '../../enums';
|
|
4
8
|
import AntSkeleton from '../AntSkeleton.vue';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
9
|
+
import {
|
|
10
|
+
computed, onMounted, watch,
|
|
11
|
+
} from 'vue';
|
|
12
|
+
import {
|
|
13
|
+
type AntRadioTypes,
|
|
14
|
+
} from './__types/AntRadio.types';
|
|
15
|
+
import {
|
|
16
|
+
handleEnumValidation,
|
|
17
|
+
} from '../../handler';
|
|
18
|
+
|
|
19
|
+
defineOptions({
|
|
20
|
+
inheritAttrs: false,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const emit = defineEmits([
|
|
24
|
+
'update:modelValue',
|
|
25
|
+
'update:skeleton',
|
|
26
|
+
'validate',
|
|
27
|
+
'blur',
|
|
28
|
+
]);
|
|
29
|
+
const props = withDefaults(defineProps<{
|
|
30
|
+
modelValue: string | null;
|
|
31
|
+
value: AntRadioTypes;
|
|
32
|
+
description?: string;
|
|
33
|
+
skeleton?: boolean;
|
|
34
|
+
state?: InputState;
|
|
35
|
+
size?: Size;
|
|
36
|
+
readonly?: boolean;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
messages?: string[];
|
|
39
|
+
}>(), {
|
|
40
|
+
state: InputState.base,
|
|
41
|
+
size: Size.md,
|
|
42
|
+
readonly: false,
|
|
43
|
+
disabled: false,
|
|
44
|
+
messages: () => [],
|
|
45
|
+
});
|
|
31
46
|
const _modelValue = computed({
|
|
32
47
|
get(): string | null | AntRadioTypes {
|
|
33
48
|
return props.modelValue;
|
|
34
49
|
},
|
|
35
50
|
set(val: string | null | AntRadioTypes) {
|
|
36
51
|
emit('update:modelValue', val ? typeof val === 'string' ? val : val.value : null);
|
|
37
|
-
}
|
|
52
|
+
},
|
|
38
53
|
});
|
|
39
54
|
const hasInputState = computed(() => props.skeleton || props.readonly || props.disabled);
|
|
40
55
|
const isActive = computed(() => _modelValue.value === props.value.value);
|
|
41
56
|
const inputClasses = computed(() => {
|
|
42
|
-
const classes: {
|
|
43
|
-
|
|
57
|
+
const classes: {
|
|
58
|
+
[key: string]: boolean;
|
|
59
|
+
} = {
|
|
60
|
+
'relative inline-flex shrink-0': true,
|
|
44
61
|
'focus:ring-offset-0 outline outline-offset-[-1px] outline-1 focus:outline-offset-[-1px] focus:outline-1 rounded-full': true,
|
|
45
62
|
'flex items-center justify-center rounded-full appearance-none': true,
|
|
46
63
|
'cursor-pointer': !hasInputState.value,
|
|
@@ -114,10 +131,16 @@ const innerRadioClass = computed(() => (
|
|
|
114
131
|
* Validate default value if given after delayed data fetching.
|
|
115
132
|
*/
|
|
116
133
|
watch(_modelValue, (val) => {
|
|
117
|
-
if ([
|
|
134
|
+
if ([
|
|
135
|
+
InputState.danger,
|
|
136
|
+
InputState.warning,
|
|
137
|
+
InputState.info,
|
|
138
|
+
].includes(props.state)) {
|
|
118
139
|
emit('validate', val);
|
|
119
140
|
}
|
|
120
|
-
}, {
|
|
141
|
+
}, {
|
|
142
|
+
deep: true,
|
|
143
|
+
});
|
|
121
144
|
watch(() => props.skeleton, (val) => {
|
|
122
145
|
if (!val && props.modelValue !== null) {
|
|
123
146
|
emit('validate', props.modelValue);
|
|
@@ -175,7 +198,7 @@ onMounted(() => {
|
|
|
175
198
|
:aria-checked="isActive"
|
|
176
199
|
:disabled="disabled || readonly"
|
|
177
200
|
@blur="onBlur"
|
|
178
|
-
|
|
201
|
+
>
|
|
179
202
|
|
|
180
203
|
<AntSkeleton
|
|
181
204
|
v-if="skeleton"
|
|
@@ -1,38 +1,53 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import AntRadio from './AntRadio.vue';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
useVModel,
|
|
5
|
+
} from '@vueuse/core';
|
|
6
|
+
import {
|
|
7
|
+
AntField,
|
|
8
|
+
} from './Elements';
|
|
9
|
+
import {
|
|
10
|
+
type AntRadioTypes,
|
|
11
|
+
} from './__types/AntRadio.types';
|
|
12
|
+
import {
|
|
13
|
+
InputState, Size,
|
|
14
|
+
} from '../../enums';
|
|
15
|
+
import {
|
|
16
|
+
computed, onMounted, ref, watch,
|
|
17
|
+
} from 'vue';
|
|
18
|
+
import {
|
|
19
|
+
Direction,
|
|
20
|
+
} from '../../enums/Direction.enum';
|
|
21
|
+
import {
|
|
22
|
+
handleEnumValidation,
|
|
23
|
+
} from '../../handler';
|
|
10
24
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
const emit = defineEmits([
|
|
26
|
+
'update:modelValue',
|
|
27
|
+
'update:skeleton',
|
|
28
|
+
'validate',
|
|
29
|
+
]);
|
|
30
|
+
const props = withDefaults(defineProps<{
|
|
31
|
+
modelValue: string | null;
|
|
32
|
+
radioButtons: AntRadioTypes[];
|
|
33
|
+
label?: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
direction?: Direction;
|
|
36
|
+
state?: InputState;
|
|
37
|
+
size?: Size;
|
|
38
|
+
skeleton?: boolean;
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
readonly?: boolean;
|
|
41
|
+
messages?: string[];
|
|
42
|
+
}>(), {
|
|
43
|
+
direction: Direction.column,
|
|
44
|
+
state: InputState.base,
|
|
45
|
+
size: Size.md,
|
|
46
|
+
skeleton: false,
|
|
47
|
+
disabled: false,
|
|
48
|
+
readonly: false,
|
|
49
|
+
messages: () => [],
|
|
50
|
+
});
|
|
36
51
|
const _modelValue = useVModel(props, 'modelValue', emit);
|
|
37
52
|
const containerClasses = computed(() => ({
|
|
38
53
|
'flex justify-start': true,
|
|
@@ -60,12 +75,22 @@ const fieldSize = computed(() => {
|
|
|
60
75
|
});
|
|
61
76
|
|
|
62
77
|
watch(_modelValue, (val) => {
|
|
63
|
-
if ([
|
|
78
|
+
if ([
|
|
79
|
+
InputState.danger,
|
|
80
|
+
InputState.warning,
|
|
81
|
+
InputState.info,
|
|
82
|
+
].includes(props.state)) {
|
|
64
83
|
emit('validate', val);
|
|
65
84
|
}
|
|
66
|
-
}, {
|
|
85
|
+
}, {
|
|
86
|
+
deep: true,
|
|
87
|
+
});
|
|
67
88
|
watch(_modelValue, (val) => {
|
|
68
|
-
if ([
|
|
89
|
+
if ([
|
|
90
|
+
InputState.danger,
|
|
91
|
+
InputState.warning,
|
|
92
|
+
InputState.info,
|
|
93
|
+
].includes(props.state)) {
|
|
69
94
|
emit('validate', val);
|
|
70
95
|
}
|
|
71
96
|
});
|
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import AntField from '../forms/AntField.vue';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
useVModel,
|
|
5
|
+
} from '@vueuse/core';
|
|
6
|
+
import {
|
|
7
|
+
computed, onMounted, watch,
|
|
8
|
+
} from 'vue';
|
|
9
|
+
import {
|
|
10
|
+
InputState, Size,
|
|
11
|
+
} from '../../enums';
|
|
12
|
+
import {
|
|
13
|
+
handleEnumValidation,
|
|
14
|
+
} from '../../handler';
|
|
7
15
|
|
|
8
|
-
defineOptions({
|
|
16
|
+
defineOptions({
|
|
17
|
+
inheritAttrs: false,
|
|
18
|
+
});
|
|
9
19
|
|
|
10
|
-
const emit = defineEmits([
|
|
20
|
+
const emit = defineEmits([
|
|
21
|
+
'update:modelValue',
|
|
22
|
+
'update:skeleton',
|
|
23
|
+
'validate',
|
|
24
|
+
'blur',
|
|
25
|
+
]);
|
|
11
26
|
const props = withDefaults(defineProps<{
|
|
12
27
|
modelValue: number | number[] | null;
|
|
13
28
|
label?: string;
|
|
14
29
|
description?: string;
|
|
15
30
|
state?: InputState;
|
|
16
|
-
size?: Size
|
|
31
|
+
size?: Size;
|
|
17
32
|
disabled?: boolean;
|
|
18
33
|
skeleton?: boolean;
|
|
19
34
|
min?: number;
|
|
@@ -25,7 +40,7 @@ const props = withDefaults(defineProps<{
|
|
|
25
40
|
disabled: false,
|
|
26
41
|
skeleton: false,
|
|
27
42
|
limiter: false,
|
|
28
|
-
messages: () => []
|
|
43
|
+
messages: () => [],
|
|
29
44
|
});
|
|
30
45
|
const _modelValue = useVModel(props, 'modelValue', emit);
|
|
31
46
|
const inputClasses = computed(() => {
|
|
@@ -38,10 +53,10 @@ const inputClasses = computed(() => {
|
|
|
38
53
|
};
|
|
39
54
|
|
|
40
55
|
return {
|
|
41
|
-
'ant-range-slider transition-colors relative border-none w-full h-2 bg-base-300 rounded-md outline-
|
|
56
|
+
'ant-range-slider transition-colors relative border-none w-full h-2 bg-base-300 rounded-md outline-hidden': true,
|
|
42
57
|
'disabled:opacity-50 disabled:cursor-not-allowed': props.disabled,
|
|
43
|
-
|
|
44
|
-
[variants[props.state]]: true
|
|
58
|
+
invisible: props.skeleton,
|
|
59
|
+
[variants[props.state]]: true,
|
|
45
60
|
};
|
|
46
61
|
});
|
|
47
62
|
|
|
@@ -54,7 +69,11 @@ watch(() => props.skeleton, (val) => {
|
|
|
54
69
|
}
|
|
55
70
|
});
|
|
56
71
|
watch(_modelValue, (val) => {
|
|
57
|
-
if ([
|
|
72
|
+
if ([
|
|
73
|
+
InputState.danger,
|
|
74
|
+
InputState.warning,
|
|
75
|
+
InputState.info,
|
|
76
|
+
].includes(props.state)) {
|
|
58
77
|
emit('validate', val);
|
|
59
78
|
}
|
|
60
79
|
});
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
computed, onMounted, ref,
|
|
4
|
+
} from 'vue';
|
|
3
5
|
import AntBaseInput from './Elements/AntBaseInput.vue';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
Size,
|
|
8
|
+
} from '../../enums/Size.enum';
|
|
9
|
+
import {
|
|
10
|
+
handleEnumValidation,
|
|
11
|
+
} from '../../handler';
|
|
12
|
+
import {
|
|
13
|
+
faSearch,
|
|
14
|
+
} from '@fortawesome/free-solid-svg-icons';
|
|
15
|
+
import {
|
|
16
|
+
BaseInputType,
|
|
17
|
+
} from './Elements/__types';
|
|
8
18
|
import AntField from '../forms/AntField.vue';
|
|
9
19
|
|
|
10
|
-
const emits = defineEmits([
|
|
20
|
+
const emits = defineEmits([
|
|
21
|
+
'update:modelValue',
|
|
22
|
+
]);
|
|
11
23
|
const props = withDefaults(defineProps<{
|
|
12
24
|
modelValue: string | null;
|
|
13
25
|
label?: string;
|
|
@@ -25,7 +37,7 @@ const props = withDefaults(defineProps<{
|
|
|
25
37
|
readonly: false,
|
|
26
38
|
size: Size.md,
|
|
27
39
|
inputTimeout: 300,
|
|
28
|
-
placeholder: 'Search'
|
|
40
|
+
placeholder: 'Search',
|
|
29
41
|
});
|
|
30
42
|
|
|
31
43
|
const timeout = ref<ReturnType<typeof setTimeout> | null>(null);
|
|
@@ -13,53 +13,75 @@
|
|
|
13
13
|
* TODO:: if the dropdown is open and the user types something, the element with a matching value should be focused.
|
|
14
14
|
*/
|
|
15
15
|
import AntField from '../forms/AntField.vue';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
|
|
16
|
+
import {
|
|
17
|
+
type SelectOption,
|
|
18
|
+
} from './__types/AntSelect.types';
|
|
19
|
+
import {
|
|
20
|
+
computed, onMounted, ref, watch,
|
|
21
|
+
} from 'vue';
|
|
22
|
+
import {
|
|
23
|
+
Size,
|
|
24
|
+
} from '../../enums/Size.enum';
|
|
25
|
+
import {
|
|
26
|
+
handleEnumValidation,
|
|
27
|
+
} from '../../handler';
|
|
28
|
+
import {
|
|
29
|
+
Grouped,
|
|
30
|
+
} from '../../enums/Grouped.enum';
|
|
21
31
|
import AntIcon from '../AntIcon.vue';
|
|
22
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
faChevronDown, faChevronUp, faMultiply,
|
|
34
|
+
} from '@fortawesome/free-solid-svg-icons';
|
|
23
35
|
import AntSkeleton from '../AntSkeleton.vue';
|
|
24
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
vOnClickOutside,
|
|
38
|
+
} from '@vueuse/components';
|
|
25
39
|
import AntButton from '../buttons/AntButton.vue';
|
|
26
|
-
import {
|
|
27
|
-
|
|
40
|
+
import {
|
|
41
|
+
State, InputState,
|
|
42
|
+
} from '../../enums';
|
|
43
|
+
import {
|
|
44
|
+
IconSize,
|
|
45
|
+
} from '../__types';
|
|
28
46
|
import AntSelectMenu from './Elements/AntSelectMenu.vue';
|
|
29
47
|
|
|
30
|
-
defineOptions({
|
|
48
|
+
defineOptions({
|
|
49
|
+
inheritAttrs: false,
|
|
50
|
+
});
|
|
31
51
|
|
|
32
|
-
const props = withDefaults(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
const props = withDefaults(defineProps<{
|
|
53
|
+
modelValue: string | number | null;
|
|
54
|
+
options: SelectOption[];
|
|
55
|
+
label?: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
placeholder?: string;
|
|
58
|
+
size?: Size;
|
|
59
|
+
state?: InputState;
|
|
60
|
+
disabled?: boolean;
|
|
61
|
+
readonly?: boolean;
|
|
62
|
+
skeleton?: boolean;
|
|
63
|
+
nullable?: boolean;
|
|
64
|
+
grouped?: Grouped;
|
|
65
|
+
name?: string;
|
|
66
|
+
wrapperClass?: string | Record<string, boolean>;
|
|
67
|
+
expanded?: boolean;
|
|
68
|
+
messages?: string[];
|
|
69
|
+
}>(), {
|
|
70
|
+
state: InputState.base,
|
|
71
|
+
grouped: Grouped.none,
|
|
72
|
+
size: Size.md,
|
|
73
|
+
disabled: false,
|
|
74
|
+
readonly: false,
|
|
75
|
+
skeleton: false,
|
|
76
|
+
nullable: false,
|
|
77
|
+
expanded: true,
|
|
78
|
+
messages: () => [],
|
|
79
|
+
});
|
|
80
|
+
const emit = defineEmits([
|
|
81
|
+
'update:modelValue',
|
|
82
|
+
'blur',
|
|
83
|
+
'validate',
|
|
84
|
+
]);
|
|
63
85
|
const isOpen = ref(false);
|
|
64
86
|
const _modelValue = computed({
|
|
65
87
|
get: () => props.modelValue,
|
|
@@ -83,7 +105,7 @@ const inputClasses = computed(() => {
|
|
|
83
105
|
'outline-offset-[-1px] outline-1 focus:outline-offset-[-1px] focus:outline-1': true,
|
|
84
106
|
[variants[props.state]]: true,
|
|
85
107
|
// Skeleton
|
|
86
|
-
|
|
108
|
+
invisible: props.skeleton,
|
|
87
109
|
// Disabled
|
|
88
110
|
'disabled:opacity-50 disabled:cursor-not-allowed': true,
|
|
89
111
|
// Size
|
|
@@ -127,7 +149,9 @@ const arrowClasses = computed(() => {
|
|
|
127
149
|
[InputState.danger]: 'text-danger-100-font',
|
|
128
150
|
};
|
|
129
151
|
|
|
130
|
-
return {
|
|
152
|
+
return {
|
|
153
|
+
[variants[props.state]]: true,
|
|
154
|
+
};
|
|
131
155
|
});
|
|
132
156
|
const skeletonGrouped = computed(() => {
|
|
133
157
|
if (!props.nullable || (props.nullable && _modelValue.value === null)) {
|
|
@@ -146,7 +170,7 @@ const iconSize = computed(() => {
|
|
|
146
170
|
}
|
|
147
171
|
|
|
148
172
|
return IconSize.xs;
|
|
149
|
-
})
|
|
173
|
+
});
|
|
150
174
|
const inputRef = ref<HTMLElement | null>(null);
|
|
151
175
|
const dropDownRef = ref<HTMLElement | null>(null);
|
|
152
176
|
const focusedDropDownItem = ref<string | number | null>(null);
|
|
@@ -260,51 +284,51 @@ function onClickRemoveButton() {
|
|
|
260
284
|
:close-on-enter="true"
|
|
261
285
|
@select-element="(e) => _modelValue = e"
|
|
262
286
|
>
|
|
263
|
-
|
|
264
|
-
<div
|
|
265
|
-
:class="inputClasses"
|
|
266
|
-
ref="inputRef"
|
|
267
|
-
:tabindex="disabled || readonly ? -1 : 0"
|
|
268
|
-
v-bind="$attrs"
|
|
269
|
-
@mousedown="onClickSelectInput"
|
|
270
|
-
@click="() => inputRef?.focus()"
|
|
271
|
-
@blur="onBlur"
|
|
272
|
-
>
|
|
287
|
+
<!-- Input -->
|
|
273
288
|
<div
|
|
274
|
-
|
|
275
|
-
:class="
|
|
289
|
+
ref="inputRef"
|
|
290
|
+
:class="inputClasses"
|
|
291
|
+
:tabindex="disabled || readonly ? -1 : 0"
|
|
292
|
+
v-bind="$attrs"
|
|
293
|
+
@mousedown="onClickSelectInput"
|
|
294
|
+
@click="() => inputRef?.focus()"
|
|
295
|
+
@blur="onBlur"
|
|
276
296
|
>
|
|
277
|
-
|
|
278
|
-
|
|
297
|
+
<div
|
|
298
|
+
v-if="_modelValue === null && placeholder !== undefined"
|
|
299
|
+
:class="placeholderClasses"
|
|
300
|
+
>
|
|
301
|
+
{{ placeholder }}
|
|
302
|
+
</div>
|
|
279
303
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
304
|
+
<div
|
|
305
|
+
v-else-if="_modelValue === null && label !== undefined"
|
|
306
|
+
:class="placeholderClasses"
|
|
307
|
+
>
|
|
308
|
+
{{ label }}
|
|
309
|
+
</div>
|
|
286
310
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
311
|
+
<div
|
|
312
|
+
v-else
|
|
313
|
+
class="select-none text-ellipsis overflow-hidden whitespace-nowrap w-full text-black"
|
|
314
|
+
>
|
|
315
|
+
{{ valueLabel }}
|
|
316
|
+
</div>
|
|
293
317
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
318
|
+
<AntIcon
|
|
319
|
+
v-if="isOpen"
|
|
320
|
+
:icon="faChevronUp"
|
|
321
|
+
:size="iconSize"
|
|
322
|
+
:class="arrowClasses"
|
|
323
|
+
/>
|
|
300
324
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
325
|
+
<AntIcon
|
|
326
|
+
v-else
|
|
327
|
+
:icon="faChevronDown"
|
|
328
|
+
:size="iconSize"
|
|
329
|
+
:class="arrowClasses"
|
|
330
|
+
/>
|
|
331
|
+
</div>
|
|
308
332
|
</AntSelectMenu>
|
|
309
333
|
</div>
|
|
310
334
|
|