@antify/ui 2.2.1 → 2.2.4
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,17 +1,35 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
onMounted,
|
|
4
|
+
} from 'vue';
|
|
3
5
|
import AntButton from '../buttons/AntButton.vue';
|
|
4
6
|
import AntField from '../forms/AntField.vue';
|
|
5
7
|
import AntBaseInput from './Elements/AntBaseInput.vue';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
Size,
|
|
10
|
+
} from '../../enums/Size.enum';
|
|
11
|
+
import {
|
|
12
|
+
type IconDefinition,
|
|
13
|
+
} from '@fortawesome/free-solid-svg-icons';
|
|
14
|
+
import {
|
|
15
|
+
useVModel,
|
|
16
|
+
} from '@vueuse/core';
|
|
17
|
+
import {
|
|
18
|
+
State, InputState,
|
|
19
|
+
} from '../../enums';
|
|
20
|
+
import {
|
|
21
|
+
Grouped,
|
|
22
|
+
} from '../../enums/Grouped.enum';
|
|
23
|
+
import {
|
|
24
|
+
BaseInputType,
|
|
25
|
+
} from './Elements/__types';
|
|
26
|
+
import {
|
|
27
|
+
handleEnumValidation,
|
|
28
|
+
} from '../../handler';
|
|
13
29
|
|
|
14
|
-
defineOptions({
|
|
30
|
+
defineOptions({
|
|
31
|
+
inheritAttrs: false,
|
|
32
|
+
});
|
|
15
33
|
|
|
16
34
|
const props = withDefaults(defineProps<{
|
|
17
35
|
modelValue: number | null;
|
|
@@ -36,9 +54,12 @@ const props = withDefaults(defineProps<{
|
|
|
36
54
|
skeleton: false,
|
|
37
55
|
size: Size.md,
|
|
38
56
|
limiter: false,
|
|
39
|
-
messages: () => []
|
|
57
|
+
messages: () => [],
|
|
40
58
|
});
|
|
41
|
-
const emit = defineEmits([
|
|
59
|
+
const emit = defineEmits([
|
|
60
|
+
'update:modelValue',
|
|
61
|
+
'validate',
|
|
62
|
+
]);
|
|
42
63
|
const _modelValue = useVModel(props, 'modelValue', emit);
|
|
43
64
|
|
|
44
65
|
onMounted(() => {
|
|
@@ -65,7 +86,7 @@ onMounted(() => {
|
|
|
65
86
|
v-model="_modelValue"
|
|
66
87
|
:type="BaseInputType.number"
|
|
67
88
|
:grouped="Grouped.left"
|
|
68
|
-
wrapper-class="
|
|
89
|
+
wrapper-class="grow"
|
|
69
90
|
:state="state"
|
|
70
91
|
:size="size"
|
|
71
92
|
:min="min"
|
|
@@ -1,26 +1,49 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
computed, onMounted, watch, useSlots,
|
|
4
|
+
} from 'vue';
|
|
5
|
+
import {
|
|
6
|
+
Size,
|
|
7
|
+
} from '../../../enums/Size.enum';
|
|
4
8
|
import AntSkeleton from '../../AntSkeleton.vue';
|
|
5
9
|
import AntIcon from '../../AntIcon.vue';
|
|
6
|
-
import {
|
|
7
|
-
|
|
10
|
+
import {
|
|
11
|
+
BaseInputType,
|
|
12
|
+
} from './__types/AntBaseInput.types';
|
|
13
|
+
import {
|
|
14
|
+
Grouped,
|
|
15
|
+
} from '../../../enums/Grouped.enum';
|
|
8
16
|
import {
|
|
9
17
|
faCircleCheck,
|
|
10
18
|
faCircleInfo,
|
|
11
19
|
faExclamationCircle,
|
|
12
20
|
faExclamationTriangle,
|
|
13
21
|
faXmark,
|
|
14
|
-
type IconDefinition
|
|
22
|
+
type IconDefinition,
|
|
15
23
|
} from '@fortawesome/free-solid-svg-icons';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
handleEnumValidation,
|
|
26
|
+
} from '../../../handler';
|
|
27
|
+
import {
|
|
28
|
+
classesToObjectSyntax, hasSlotContent,
|
|
29
|
+
} from '../../../utils';
|
|
30
|
+
import {
|
|
31
|
+
InputState,
|
|
32
|
+
} from '../../../enums';
|
|
33
|
+
import {
|
|
34
|
+
IconSize,
|
|
35
|
+
} from '../../__types';
|
|
20
36
|
|
|
21
|
-
defineOptions({
|
|
37
|
+
defineOptions({
|
|
38
|
+
inheritAttrs: false,
|
|
39
|
+
});
|
|
22
40
|
|
|
23
|
-
const emit = defineEmits([
|
|
41
|
+
const emit = defineEmits([
|
|
42
|
+
'update:modelValue',
|
|
43
|
+
'blur',
|
|
44
|
+
'validate',
|
|
45
|
+
'update:inputRef',
|
|
46
|
+
]);
|
|
24
47
|
const props = withDefaults(defineProps<{
|
|
25
48
|
modelValue: string | number | null;
|
|
26
49
|
size?: Size;
|
|
@@ -47,7 +70,7 @@ const props = withDefaults(defineProps<{
|
|
|
47
70
|
showIcon: true,
|
|
48
71
|
default: false,
|
|
49
72
|
nullable: false,
|
|
50
|
-
inputRef: null
|
|
73
|
+
inputRef: null,
|
|
51
74
|
});
|
|
52
75
|
const slot = useSlots();
|
|
53
76
|
const hasInputState = computed(() => props.skeleton || props.readonly || props.disabled);
|
|
@@ -108,12 +131,12 @@ const inputClasses = computed(() => {
|
|
|
108
131
|
'rounded-none': props.grouped === Grouped.center,
|
|
109
132
|
'rounded-tl-none rounded-bl-none rounded-tr-md rounded-br-md': props.grouped === Grouped.right,
|
|
110
133
|
'rounded-md': props.grouped === Grouped.none,
|
|
111
|
-
|
|
134
|
+
invisible: props.skeleton,
|
|
112
135
|
};
|
|
113
136
|
});
|
|
114
137
|
const iconClasses = computed(() => ({
|
|
115
138
|
'transition-[height]': true,
|
|
116
|
-
'opacity-50': props.disabled
|
|
139
|
+
'opacity-50': props.disabled,
|
|
117
140
|
}));
|
|
118
141
|
const iconColorClass = computed(() => {
|
|
119
142
|
const variants: Record<InputState, string> = {
|
|
@@ -129,7 +152,7 @@ const iconColorClass = computed(() => {
|
|
|
129
152
|
const _wrapperClass = computed(() => ({
|
|
130
153
|
'-mr-px': props.grouped !== Grouped.none,
|
|
131
154
|
'cursor-not-allowed': props.disabled,
|
|
132
|
-
...classesToObjectSyntax(props.wrapperClass)
|
|
155
|
+
...classesToObjectSyntax(props.wrapperClass),
|
|
133
156
|
}));
|
|
134
157
|
const icon = computed(() => icons[props.state]);
|
|
135
158
|
const _modelValue = computed<string | number | null>({
|
|
@@ -155,14 +178,20 @@ const _inputRef = computed({
|
|
|
155
178
|
},
|
|
156
179
|
set(val) {
|
|
157
180
|
emit('update:inputRef', val);
|
|
158
|
-
}
|
|
181
|
+
},
|
|
159
182
|
});
|
|
160
183
|
|
|
161
184
|
watch(_modelValue, (val) => {
|
|
162
|
-
if ([
|
|
185
|
+
if ([
|
|
186
|
+
InputState.danger,
|
|
187
|
+
InputState.warning,
|
|
188
|
+
InputState.info,
|
|
189
|
+
].includes(props.state)) {
|
|
163
190
|
emit('validate', val);
|
|
164
191
|
}
|
|
165
|
-
}, {
|
|
192
|
+
}, {
|
|
193
|
+
deep: true,
|
|
194
|
+
});
|
|
166
195
|
watch(() => props.skeleton, (val) => {
|
|
167
196
|
if (!val && props.modelValue !== null) {
|
|
168
197
|
emit('validate', props.modelValue);
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
computed, onMounted,
|
|
4
|
+
} from 'vue';
|
|
5
|
+
import {
|
|
6
|
+
Size,
|
|
7
|
+
} from '../../../enums/Size.enum';
|
|
4
8
|
import AntSkeleton from '../../AntSkeleton.vue';
|
|
5
|
-
import {
|
|
6
|
-
|
|
9
|
+
import {
|
|
10
|
+
handleEnumValidation,
|
|
11
|
+
} from '../../../handler';
|
|
12
|
+
import {
|
|
13
|
+
InputState,
|
|
14
|
+
} from '../../../enums';
|
|
7
15
|
|
|
8
16
|
const props = withDefaults(defineProps<{
|
|
9
|
-
state?: InputState
|
|
17
|
+
state?: InputState;
|
|
10
18
|
size?: Size;
|
|
11
19
|
skeleton?: boolean;
|
|
12
20
|
}>(), {
|
|
13
21
|
skeleton: false,
|
|
14
22
|
size: Size.md,
|
|
15
|
-
state: InputState.base
|
|
23
|
+
state: InputState.base,
|
|
16
24
|
});
|
|
17
25
|
|
|
18
26
|
const classes = computed(() => {
|
|
@@ -31,7 +39,7 @@ const classes = computed(() => {
|
|
|
31
39
|
'text-sm': props.size === Size.sm,
|
|
32
40
|
'text-md': props.size === Size.md,
|
|
33
41
|
'text-lg': props.size === Size.lg,
|
|
34
|
-
[variants[props.state]]: true
|
|
42
|
+
[variants[props.state]]: true,
|
|
35
43
|
};
|
|
36
44
|
});
|
|
37
45
|
|
|
@@ -46,7 +54,7 @@ onMounted(() => {
|
|
|
46
54
|
:class="classes"
|
|
47
55
|
>
|
|
48
56
|
<span :class="{'invisible': skeleton}">
|
|
49
|
-
<slot/>
|
|
57
|
+
<slot />
|
|
50
58
|
</span>
|
|
51
59
|
|
|
52
60
|
<AntSkeleton
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
computed, onMounted,
|
|
4
|
+
} from 'vue';
|
|
5
|
+
import {
|
|
6
|
+
Size,
|
|
7
|
+
} from '../../../enums/Size.enum';
|
|
4
8
|
import AntSkeleton from '../../AntSkeleton.vue';
|
|
5
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
handleEnumValidation,
|
|
11
|
+
} from '../../../handler';
|
|
6
12
|
|
|
7
|
-
defineEmits([
|
|
13
|
+
defineEmits([
|
|
14
|
+
'clickContent',
|
|
15
|
+
]);
|
|
8
16
|
|
|
9
17
|
const props = withDefaults(defineProps<{
|
|
10
18
|
label?: string;
|
|
@@ -57,6 +65,6 @@ onMounted(() => {
|
|
|
57
65
|
/>
|
|
58
66
|
</span>
|
|
59
67
|
|
|
60
|
-
<slot/>
|
|
68
|
+
<slot />
|
|
61
69
|
</label>
|
|
62
70
|
</template>
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
computed, onMounted,
|
|
4
|
+
} from 'vue';
|
|
5
|
+
import {
|
|
6
|
+
Size,
|
|
7
|
+
} from '../../../enums/Size.enum';
|
|
4
8
|
import AntSkeleton from '../../AntSkeleton.vue';
|
|
5
|
-
import {
|
|
6
|
-
|
|
9
|
+
import {
|
|
10
|
+
handleEnumValidation,
|
|
11
|
+
} from '../../../handler';
|
|
12
|
+
import {
|
|
13
|
+
InputState,
|
|
14
|
+
} from '../../../enums';
|
|
7
15
|
|
|
8
16
|
const props = withDefaults(defineProps<{
|
|
9
17
|
value: number;
|
|
@@ -14,7 +22,7 @@ const props = withDefaults(defineProps<{
|
|
|
14
22
|
}>(), {
|
|
15
23
|
skeleton: false,
|
|
16
24
|
size: Size.md,
|
|
17
|
-
state: InputState.base
|
|
25
|
+
state: InputState.base,
|
|
18
26
|
});
|
|
19
27
|
|
|
20
28
|
const classes = computed(() => {
|
|
@@ -6,14 +6,31 @@
|
|
|
6
6
|
* Fix overflow bug (See Ellipsis Text story)
|
|
7
7
|
* TODO:: if the dropdown is open and the user types something, the element with a matching value should be focused.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
import {
|
|
10
|
+
computed, nextTick, onMounted, onUnmounted, ref, watch,
|
|
11
|
+
} from 'vue';
|
|
12
|
+
import {
|
|
13
|
+
InputState, Size,
|
|
14
|
+
} from '../../../enums';
|
|
15
|
+
import type {
|
|
16
|
+
SelectOption,
|
|
17
|
+
} from '../__types';
|
|
18
|
+
import {
|
|
19
|
+
useElementSize, useVModel, onClickOutside,
|
|
20
|
+
} from '@vueuse/core';
|
|
21
|
+
import type {
|
|
22
|
+
Validator,
|
|
23
|
+
} from '@antify/validate';
|
|
24
|
+
import {
|
|
25
|
+
autoUpdate, flip, offset, useFloating,
|
|
26
|
+
} from '@floating-ui/vue';
|
|
27
|
+
|
|
28
|
+
const emit = defineEmits([
|
|
29
|
+
'update:open',
|
|
30
|
+
'update:modelValue',
|
|
31
|
+
'update:focused',
|
|
32
|
+
'selectElement',
|
|
33
|
+
]);
|
|
17
34
|
const props = withDefaults(defineProps<{
|
|
18
35
|
modelValue: string | string[] | number | number[] | null;
|
|
19
36
|
focused: string | number | null;
|
|
@@ -33,18 +50,22 @@ const props = withDefaults(defineProps<{
|
|
|
33
50
|
autoSelectFirstOnOpen: true,
|
|
34
51
|
closeOnSelectItem: true,
|
|
35
52
|
});
|
|
36
|
-
const reference = ref<HTMLElement | null | undefined>(props.inputRef)
|
|
53
|
+
const reference = ref<HTMLElement | null | undefined>(props.inputRef);
|
|
37
54
|
const elementSize = useElementSize(reference);
|
|
38
|
-
const floating = ref<HTMLElement | null>(null)
|
|
39
|
-
const {
|
|
55
|
+
const floating = ref<HTMLElement | null>(null);
|
|
56
|
+
const {
|
|
57
|
+
floatingStyles, middlewareData, placement,
|
|
58
|
+
} = useFloating(reference, floating, {
|
|
40
59
|
placement: 'bottom',
|
|
41
60
|
whileElementsMounted: autoUpdate,
|
|
42
61
|
middleware: [
|
|
43
62
|
offset(8),
|
|
44
63
|
flip({
|
|
45
|
-
fallbackPlacements: [
|
|
64
|
+
fallbackPlacements: [
|
|
65
|
+
'top',
|
|
66
|
+
],
|
|
46
67
|
}),
|
|
47
|
-
]
|
|
68
|
+
],
|
|
48
69
|
});
|
|
49
70
|
|
|
50
71
|
onClickOutside(floating, () => {
|
|
@@ -68,7 +89,7 @@ const dropdownClasses = computed(() => {
|
|
|
68
89
|
};
|
|
69
90
|
|
|
70
91
|
return {
|
|
71
|
-
'w-full border flex flex-col gap-px outline-
|
|
92
|
+
'w-full border flex flex-col gap-px outline-hidden -mt-px overflow-y-auto shadow-md z-[90] max-h-[250px]': true,
|
|
72
93
|
'rounded-md': true,
|
|
73
94
|
[variants[props.state]]: true,
|
|
74
95
|
};
|
|
@@ -124,7 +145,7 @@ function onKeyDownDropDown(e: KeyboardEvent) {
|
|
|
124
145
|
}
|
|
125
146
|
|
|
126
147
|
if (!isOpen.value) {
|
|
127
|
-
isOpen.value = true
|
|
148
|
+
isOpen.value = true;
|
|
128
149
|
}
|
|
129
150
|
|
|
130
151
|
emit('selectElement', focusedDropDownItem.value);
|
|
@@ -135,7 +156,7 @@ function onKeyDownDropDown(e: KeyboardEvent) {
|
|
|
135
156
|
}
|
|
136
157
|
|
|
137
158
|
if (e.key === 'ArrowDown' || e.key === 'ArrowRight') {
|
|
138
|
-
e.preventDefault()
|
|
159
|
+
e.preventDefault();
|
|
139
160
|
isOpen.value = true;
|
|
140
161
|
|
|
141
162
|
const index = props.options.findIndex(option => option.value === focusedDropDownItem.value);
|
|
@@ -149,7 +170,7 @@ function onKeyDownDropDown(e: KeyboardEvent) {
|
|
|
149
170
|
}
|
|
150
171
|
|
|
151
172
|
if (e.key === 'ArrowUp' || e.key === 'ArrowLeft') {
|
|
152
|
-
e.preventDefault()
|
|
173
|
+
e.preventDefault();
|
|
153
174
|
isOpen.value = true;
|
|
154
175
|
|
|
155
176
|
const index = props.options.findIndex(option => option.value === focusedDropDownItem.value);
|
|
@@ -174,7 +195,10 @@ function getActiveDropDownItemClasses(option: SelectOption) {
|
|
|
174
195
|
[InputState.danger]: 'bg-danger-200',
|
|
175
196
|
};
|
|
176
197
|
|
|
177
|
-
return option.value === focusedDropDownItem.value ? {
|
|
198
|
+
return option.value === focusedDropDownItem.value ? {
|
|
199
|
+
'bg-white': false,
|
|
200
|
+
[variants[props.state]]: true,
|
|
201
|
+
} : {};
|
|
178
202
|
}
|
|
179
203
|
|
|
180
204
|
function onClickDropDownItem(e: MouseEvent, value: string | number | null) {
|
|
@@ -199,34 +223,34 @@ watch(_modelValue, (val) => {
|
|
|
199
223
|
ref="reference"
|
|
200
224
|
class="relative"
|
|
201
225
|
>
|
|
202
|
-
<slot/>
|
|
226
|
+
<slot />
|
|
203
227
|
|
|
204
228
|
<teleport to="body">
|
|
229
|
+
<div
|
|
230
|
+
v-if="isOpen"
|
|
231
|
+
ref="floating"
|
|
232
|
+
:class="dropdownClasses"
|
|
233
|
+
:style="{width: `${elementSize.width.value}px!important`, ...floatingStyles}"
|
|
234
|
+
>
|
|
235
|
+
<div
|
|
236
|
+
v-for="(option, index) in options"
|
|
237
|
+
:key="`option-${index}`"
|
|
238
|
+
:class="{...dropDownItemClasses, ...getActiveDropDownItemClasses(option)}"
|
|
239
|
+
@mousedown="(e) => onClickDropDownItem(e, option.value)"
|
|
240
|
+
@mouseover="() => focusedDropDownItem = option.value"
|
|
241
|
+
>
|
|
242
|
+
{{ option.label }}
|
|
243
|
+
</div>
|
|
244
|
+
|
|
205
245
|
<div
|
|
206
|
-
v-if="
|
|
207
|
-
:class="
|
|
208
|
-
ref="floating"
|
|
209
|
-
:style="{width: `${elementSize.width.value}px!important`, ...floatingStyles}"
|
|
246
|
+
v-if="options.length === 0"
|
|
247
|
+
:class="{...dropDownItemClasses}"
|
|
210
248
|
>
|
|
211
|
-
<
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
:class="{...dropDownItemClasses, ...getActiveDropDownItemClasses(option)}"
|
|
215
|
-
@mousedown="(e) => onClickDropDownItem(e, option.value)"
|
|
216
|
-
@mouseover="() => focusedDropDownItem = option.value"
|
|
217
|
-
>
|
|
218
|
-
{{ option.label }}
|
|
219
|
-
</div>
|
|
220
|
-
|
|
221
|
-
<div
|
|
222
|
-
v-if="options.length === 0"
|
|
223
|
-
:class="{...dropDownItemClasses}"
|
|
224
|
-
>
|
|
225
|
-
<slot name="empty">
|
|
226
|
-
No options available
|
|
227
|
-
</slot>
|
|
228
|
-
</div>
|
|
249
|
+
<slot name="empty">
|
|
250
|
+
No options available
|
|
251
|
+
</slot>
|
|
229
252
|
</div>
|
|
253
|
+
</div>
|
|
230
254
|
</teleport>
|
|
231
255
|
</div>
|
|
232
256
|
</template>
|
|
@@ -1,64 +1,119 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Size
|
|
3
|
+
} from "../../../../enums/Size.enum.mjs";
|
|
4
|
+
import {
|
|
5
|
+
BaseInputType
|
|
6
|
+
} from "../__types/AntBaseInput.types.mjs";
|
|
3
7
|
import AntBaseInput from "../AntBaseInput.vue";
|
|
4
8
|
import AntButton from "../../../buttons/AntButton.vue";
|
|
5
9
|
import AntIcon from "../../../AntIcon.vue";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
import {
|
|
11
|
+
Grouped as _Grouped
|
|
12
|
+
} from "../../../../enums/Grouped.enum.mjs";
|
|
13
|
+
import {
|
|
14
|
+
faSearch,
|
|
15
|
+
faEye
|
|
16
|
+
} from "@fortawesome/free-solid-svg-icons";
|
|
17
|
+
import {
|
|
18
|
+
InputState
|
|
19
|
+
} from "../../../../enums/index.mjs";
|
|
9
20
|
import AntFormGroup from "../../../forms/AntFormGroup.vue";
|
|
10
21
|
import AntFormGroupLabel from "../../../forms/AntFormGroupLabel.vue";
|
|
11
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
Direction
|
|
24
|
+
} from "../../../../enums/Direction.enum.mjs";
|
|
12
25
|
const meta = {
|
|
13
26
|
computed: {
|
|
14
27
|
Direction() {
|
|
15
28
|
return Direction;
|
|
16
29
|
}
|
|
17
30
|
},
|
|
18
|
-
components: {
|
|
31
|
+
components: {
|
|
32
|
+
AntFormGroup
|
|
33
|
+
},
|
|
19
34
|
title: "Inputs/Elements/Base Input",
|
|
20
35
|
component: AntBaseInput,
|
|
21
|
-
parameters: {
|
|
36
|
+
parameters: {
|
|
37
|
+
controls: {
|
|
38
|
+
sort: "requiredFirst"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
22
41
|
argTypes: {
|
|
23
42
|
modelValue: {
|
|
24
|
-
control: {
|
|
25
|
-
|
|
43
|
+
control: {
|
|
44
|
+
type: "text"
|
|
45
|
+
},
|
|
46
|
+
table: {
|
|
47
|
+
type: {
|
|
48
|
+
summary: "string|number|null"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
26
51
|
},
|
|
27
52
|
type: {
|
|
28
|
-
control: {
|
|
53
|
+
control: {
|
|
54
|
+
type: "select"
|
|
55
|
+
},
|
|
29
56
|
options: Object.values(BaseInputType),
|
|
30
|
-
table: {
|
|
57
|
+
table: {
|
|
58
|
+
defaultValue: {
|
|
59
|
+
summary: BaseInputType.text
|
|
60
|
+
}
|
|
61
|
+
}
|
|
31
62
|
},
|
|
32
63
|
state: {
|
|
33
|
-
control: {
|
|
64
|
+
control: {
|
|
65
|
+
type: "select"
|
|
66
|
+
},
|
|
34
67
|
options: Object.values(InputState)
|
|
35
68
|
},
|
|
36
69
|
size: {
|
|
37
|
-
control: {
|
|
70
|
+
control: {
|
|
71
|
+
type: "select"
|
|
72
|
+
},
|
|
38
73
|
options: Object.values(Size),
|
|
39
|
-
table: {
|
|
74
|
+
table: {
|
|
75
|
+
defaultValue: {
|
|
76
|
+
summary: Size.md
|
|
77
|
+
}
|
|
78
|
+
}
|
|
40
79
|
},
|
|
41
80
|
placeholder: {
|
|
42
81
|
control: "text",
|
|
43
|
-
table: {
|
|
82
|
+
table: {
|
|
83
|
+
defaultValue: {
|
|
84
|
+
summary: "this.label"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
44
87
|
},
|
|
45
88
|
grouped: {
|
|
46
|
-
control: {
|
|
89
|
+
control: {
|
|
90
|
+
type: "select"
|
|
91
|
+
},
|
|
47
92
|
options: Object.values(_Grouped),
|
|
48
93
|
description: "Where is this fields position in a group",
|
|
49
|
-
table: {
|
|
94
|
+
table: {
|
|
95
|
+
defaultValue: {
|
|
96
|
+
summary: _Grouped.none
|
|
97
|
+
}
|
|
98
|
+
}
|
|
50
99
|
},
|
|
51
100
|
wrapperClass: {
|
|
52
101
|
control: "text",
|
|
53
102
|
description: 'Class for the first element because the attribute "class" would affect the input element.',
|
|
54
|
-
table: {
|
|
103
|
+
table: {
|
|
104
|
+
type: {
|
|
105
|
+
summary: "string|object"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
55
108
|
},
|
|
56
109
|
showIcon: {
|
|
57
110
|
control: "boolean",
|
|
58
111
|
description: "Some InputStates can have an icon. Control with this property if it gets shown or not."
|
|
59
112
|
},
|
|
60
113
|
iconLeft: {
|
|
61
|
-
control: {
|
|
114
|
+
control: {
|
|
115
|
+
type: "none"
|
|
116
|
+
},
|
|
62
117
|
description: "Will be displayed left to the input text.<br>Use Font-awesome Icons."
|
|
63
118
|
}
|
|
64
119
|
}
|
|
@@ -66,9 +121,13 @@ const meta = {
|
|
|
66
121
|
export default meta;
|
|
67
122
|
export const Docs = {
|
|
68
123
|
render: (args) => ({
|
|
69
|
-
components: {
|
|
124
|
+
components: {
|
|
125
|
+
AntBaseInput
|
|
126
|
+
},
|
|
70
127
|
setup: () => {
|
|
71
|
-
return {
|
|
128
|
+
return {
|
|
129
|
+
args
|
|
130
|
+
};
|
|
72
131
|
},
|
|
73
132
|
template: `
|
|
74
133
|
<AntBaseInput
|
|
@@ -97,9 +156,15 @@ export const IconLeft = {
|
|
|
97
156
|
};
|
|
98
157
|
export const IconRight = {
|
|
99
158
|
render: (args) => ({
|
|
100
|
-
components: {
|
|
159
|
+
components: {
|
|
160
|
+
AntBaseInput,
|
|
161
|
+
AntIcon
|
|
162
|
+
},
|
|
101
163
|
setup: () => {
|
|
102
|
-
return {
|
|
164
|
+
return {
|
|
165
|
+
args,
|
|
166
|
+
faEye
|
|
167
|
+
};
|
|
103
168
|
},
|
|
104
169
|
template: `
|
|
105
170
|
<AntBaseInput
|
|
@@ -117,12 +182,24 @@ export const IconRight = {
|
|
|
117
182
|
};
|
|
118
183
|
export const Summary = {
|
|
119
184
|
parameters: {
|
|
120
|
-
chromatic: {
|
|
185
|
+
chromatic: {
|
|
186
|
+
disableSnapshot: false
|
|
187
|
+
}
|
|
121
188
|
},
|
|
122
189
|
render: (args) => ({
|
|
123
|
-
components: {
|
|
190
|
+
components: {
|
|
191
|
+
AntBaseInput,
|
|
192
|
+
AntButton,
|
|
193
|
+
AntFormGroup,
|
|
194
|
+
AntFormGroupLabel
|
|
195
|
+
},
|
|
124
196
|
setup: () => {
|
|
125
|
-
return {
|
|
197
|
+
return {
|
|
198
|
+
args,
|
|
199
|
+
faSearch,
|
|
200
|
+
Direction,
|
|
201
|
+
Size
|
|
202
|
+
};
|
|
126
203
|
},
|
|
127
204
|
template: `
|
|
128
205
|
<AntFormGroup>
|