@antify/ui 2.2.0 → 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 +61 -36
- package/dist/components/inputs/AntCheckboxGroup.vue +40 -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 +36 -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 +227 -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 +132 -14
- package/dist/components/table/__stories/AntTable.stories.mjs +253 -31
- package/dist/components/table/__types/index.d.ts +0 -1
- package/dist/components/table/__types/index.js +0 -11
- package/dist/components/table/__types/index.mjs +0 -1
- 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,11 +1,22 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import AntField from '../forms/AntField.vue';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
computed, watch,
|
|
5
|
+
} from 'vue';
|
|
4
6
|
import AntSkeleton from '../AntSkeleton.vue';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
+
import {
|
|
8
|
+
InputState, Size,
|
|
9
|
+
} from '../../enums';
|
|
10
|
+
import {
|
|
11
|
+
hasSlotContent,
|
|
12
|
+
} from '../../utils';
|
|
7
13
|
|
|
8
|
-
const emit = defineEmits([
|
|
14
|
+
const emit = defineEmits([
|
|
15
|
+
'update:modelValue',
|
|
16
|
+
'input',
|
|
17
|
+
'blur',
|
|
18
|
+
'validate',
|
|
19
|
+
]);
|
|
9
20
|
const props = withDefaults(defineProps<{
|
|
10
21
|
modelValue: boolean | null;
|
|
11
22
|
label?: string;
|
|
@@ -14,35 +25,37 @@ const props = withDefaults(defineProps<{
|
|
|
14
25
|
readonly?: boolean;
|
|
15
26
|
disabled?: boolean;
|
|
16
27
|
size?: Size;
|
|
17
|
-
state?: InputState
|
|
18
|
-
messages?: string[]
|
|
28
|
+
state?: InputState;
|
|
29
|
+
messages?: string[];
|
|
19
30
|
}>(), {
|
|
20
31
|
size: Size.md,
|
|
21
32
|
state: InputState.base,
|
|
22
|
-
messages: () => []
|
|
33
|
+
messages: () => [],
|
|
23
34
|
});
|
|
24
35
|
const _value = computed({
|
|
25
36
|
get: () => props.modelValue,
|
|
26
37
|
set: (val: boolean | null) => {
|
|
27
38
|
emit('update:modelValue', val);
|
|
28
39
|
emit('input', val);
|
|
29
|
-
}
|
|
40
|
+
},
|
|
30
41
|
});
|
|
31
42
|
const hasInputState = computed(() => props.skeleton || props.readonly || props.disabled);
|
|
32
43
|
const buttonClasses = computed(() => {
|
|
33
|
-
const classes: {
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
const classes: {
|
|
45
|
+
[key: string]: boolean;
|
|
46
|
+
} = {
|
|
47
|
+
'relative inline-flex shrink-0': true,
|
|
48
|
+
'focus:outline-hidden': true,
|
|
36
49
|
'rounded-full ease-in-out duration-200': true,
|
|
37
50
|
'focus-within:ring-4': !hasInputState.value && (props.size === Size.lg || props.size === Size.md),
|
|
38
51
|
'focus-within:ring-2': !hasInputState.value && (props.size === Size.sm || props.size === Size.xs || props.size === Size.xs2),
|
|
39
52
|
'h-5 w-9': props.size === Size.lg || props.size === Size.md || props.size === Size.sm,
|
|
40
53
|
'h-4 w-[30px]': props.size === Size.xs || props.size === Size.xs2,
|
|
41
54
|
'bg-base-300': !_value.value,
|
|
42
|
-
|
|
55
|
+
invisible: props.skeleton,
|
|
43
56
|
// Disabled
|
|
44
57
|
'opacity-50 cursor-not-allowed': props.disabled,
|
|
45
|
-
'cursor-default': props.readonly
|
|
58
|
+
'cursor-default': props.readonly,
|
|
46
59
|
};
|
|
47
60
|
const colorVariant = {
|
|
48
61
|
[InputState.base]: 'focus-within:ring-primary-200',
|
|
@@ -65,14 +78,14 @@ const buttonClasses = computed(() => {
|
|
|
65
78
|
return classes;
|
|
66
79
|
});
|
|
67
80
|
const ballClasses = computed(() => ({
|
|
68
|
-
'pointer-events-none inline-block rounded-full bg-base-100 shadow transform ring-0 transition ease-in-out duration-200': true,
|
|
81
|
+
'pointer-events-none inline-block rounded-full bg-base-100 shadow-sm transform ring-0 transition ease-in-out duration-200': true,
|
|
69
82
|
'h-4 w-4 translate-y-0.5': props.size === Size.lg || props.size === Size.md || props.size === Size.sm,
|
|
70
83
|
'translate-x-[1.125rem]': _value.value && (props.size === Size.lg || props.size === Size.md || props.size === Size.sm),
|
|
71
84
|
'translate-x-0.5': !_value.value && (props.size === Size.lg || props.size === Size.md || props.size === Size.sm),
|
|
72
85
|
'h-3.5 w-3.5 translate-y-[1px]': props.size === Size.xs || props.size === Size.xs2,
|
|
73
86
|
'translate-x-[.925rem]': _value.value && (props.size === Size.xs || props.size === Size.xs2),
|
|
74
87
|
'translate-x-[1px]': !_value.value && (props.size === Size.xs || props.size === Size.xs2),
|
|
75
|
-
|
|
88
|
+
invisible: props.skeleton,
|
|
76
89
|
}));
|
|
77
90
|
const valueClasses = computed(() => ({
|
|
78
91
|
'text-for-white-bg-font': true,
|
|
@@ -111,7 +124,11 @@ watch(() => props.skeleton, (val) => {
|
|
|
111
124
|
}
|
|
112
125
|
});
|
|
113
126
|
watch(_value, () => {
|
|
114
|
-
if ([
|
|
127
|
+
if ([
|
|
128
|
+
InputState.danger,
|
|
129
|
+
InputState.info,
|
|
130
|
+
InputState.warning,
|
|
131
|
+
].includes(props.state)) {
|
|
115
132
|
emit('validate', props.modelValue);
|
|
116
133
|
}
|
|
117
134
|
});
|
|
@@ -130,6 +147,7 @@ function onBlur(e: FocusEvent) {
|
|
|
130
147
|
|
|
131
148
|
<template>
|
|
132
149
|
<AntField
|
|
150
|
+
data-e2e="switch"
|
|
133
151
|
:label="label"
|
|
134
152
|
:size="size"
|
|
135
153
|
:description="description"
|
|
@@ -155,7 +173,7 @@ function onBlur(e: FocusEvent) {
|
|
|
155
173
|
aria-hidden="true"
|
|
156
174
|
:class="ballClasses"
|
|
157
175
|
>
|
|
158
|
-
<slot name="icon"/>
|
|
176
|
+
<slot name="icon" />
|
|
159
177
|
</span>
|
|
160
178
|
</button>
|
|
161
179
|
|
|
@@ -172,7 +190,7 @@ function onBlur(e: FocusEvent) {
|
|
|
172
190
|
:class="props.size === Size.lg || props.size === Size.md ||props.size === Size.sm ? 'h-5' : 'h-4'"
|
|
173
191
|
>
|
|
174
192
|
<span :class="valueClasses">
|
|
175
|
-
<slot/>
|
|
193
|
+
<slot />
|
|
176
194
|
</span>
|
|
177
195
|
|
|
178
196
|
<AntSkeleton
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import AntField from '../forms/AntField.vue';
|
|
3
3
|
import AntButton from '../buttons/AntButton.vue';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
faChevronLeft, faChevronRight,
|
|
6
|
+
} from '@fortawesome/free-solid-svg-icons';
|
|
5
7
|
import AntSkeleton from '../AntSkeleton.vue';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import {
|
|
9
|
+
type SwitcherOption,
|
|
10
|
+
} from './__types/AntSwitcher.types';
|
|
11
|
+
import {
|
|
12
|
+
State, Grouped, InputState, Size,
|
|
13
|
+
} from '../../enums';
|
|
14
|
+
import {
|
|
15
|
+
computed, onMounted, watch,
|
|
16
|
+
} from 'vue';
|
|
17
|
+
|
|
18
|
+
const emit = defineEmits([
|
|
19
|
+
'update:modelValue',
|
|
20
|
+
'validate',
|
|
21
|
+
'blur',
|
|
22
|
+
]);
|
|
11
23
|
const props = withDefaults(defineProps<{
|
|
12
24
|
modelValue: string | null;
|
|
13
25
|
options: string[] | SwitcherOption[];
|
|
@@ -17,17 +29,16 @@ const props = withDefaults(defineProps<{
|
|
|
17
29
|
readonly?: boolean;
|
|
18
30
|
disabled?: boolean;
|
|
19
31
|
state?: InputState;
|
|
20
|
-
size?: Size
|
|
32
|
+
size?: Size;
|
|
21
33
|
messages?: string[];
|
|
22
34
|
}>(), {
|
|
23
35
|
state: InputState.base,
|
|
24
36
|
size: Size.md,
|
|
25
|
-
messages: () => []
|
|
37
|
+
messages: () => [],
|
|
26
38
|
});
|
|
27
39
|
const _value = computed({
|
|
28
40
|
get() {
|
|
29
|
-
const found = props.options.find((option: string | SwitcherOption) =>
|
|
30
|
-
typeof option === 'string' ? option === props.modelValue : option.value === props.modelValue);
|
|
41
|
+
const found = props.options.find((option: string | SwitcherOption) => typeof option === 'string' ? option === props.modelValue : option.value === props.modelValue);
|
|
31
42
|
|
|
32
43
|
if (!found) {
|
|
33
44
|
return props.options[0];
|
|
@@ -37,12 +48,14 @@ const _value = computed({
|
|
|
37
48
|
},
|
|
38
49
|
set(val: string | SwitcherOption) {
|
|
39
50
|
emit('update:modelValue', typeof val === 'string' ? val : val.value);
|
|
40
|
-
}
|
|
51
|
+
},
|
|
41
52
|
});
|
|
42
53
|
const hasInputState = computed(() => props.skeleton || props.readonly || props.disabled);
|
|
43
54
|
const containerClasses = computed(() => {
|
|
44
|
-
const classes: {
|
|
45
|
-
|
|
55
|
+
const classes: {
|
|
56
|
+
[key: string]: boolean;
|
|
57
|
+
} = {
|
|
58
|
+
'flex relative ring-primary/25 rounded-md outline-hidden': true,
|
|
46
59
|
'focus-within:ring-2': (props.size === Size.xs2 || props.size === Size.xs || props.size === Size.sm) && !hasInputState.value,
|
|
47
60
|
'focus-within:ring-4': (props.size === Size.md || props.size === Size.lg) && !hasInputState.value,
|
|
48
61
|
};
|
|
@@ -59,14 +72,16 @@ const containerClasses = computed(() => {
|
|
|
59
72
|
return classes;
|
|
60
73
|
});
|
|
61
74
|
const itemClasses = computed(() => {
|
|
62
|
-
const classes: {
|
|
75
|
+
const classes: {
|
|
76
|
+
[key: string]: boolean;
|
|
77
|
+
} = {
|
|
63
78
|
'grow text-center text-black relative outline outline-1 -outline-offset-1': true,
|
|
64
79
|
'p-1 text-xs ': props.size === Size.xs2,
|
|
65
80
|
'p-1.5 text-xs ': props.size === Size.xs,
|
|
66
81
|
'p-1.5 text-sm ': props.size === Size.sm,
|
|
67
82
|
'p-2 text-sm ': props.size === Size.md,
|
|
68
83
|
'p-2.5 text-sm ': props.size === Size.lg,
|
|
69
|
-
|
|
84
|
+
invisible: props.skeleton,
|
|
70
85
|
'opacity-50 cursor-not-allowed': props.disabled,
|
|
71
86
|
};
|
|
72
87
|
|
|
@@ -1,59 +1,81 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import {
|
|
3
|
+
AntField,
|
|
4
|
+
} from './Elements';
|
|
5
|
+
import type {
|
|
6
|
+
SelectOption,
|
|
7
|
+
} from './__types';
|
|
8
|
+
import {
|
|
9
|
+
Grouped, InputState, Size,
|
|
10
|
+
} from '../../enums';
|
|
11
|
+
import {
|
|
12
|
+
useVModel,
|
|
13
|
+
} from '@vueuse/core';
|
|
14
|
+
import {
|
|
15
|
+
faChevronRight, type IconDefinition,
|
|
16
|
+
} from '@fortawesome/free-solid-svg-icons';
|
|
17
|
+
import {
|
|
18
|
+
computed, onMounted, type Ref, ref, watch,
|
|
19
|
+
} from 'vue';
|
|
8
20
|
import AntTag from '../AntTag.vue';
|
|
9
21
|
import AntIcon from '../AntIcon.vue';
|
|
10
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
AntTagSize, IconSize,
|
|
24
|
+
} from '../__types';
|
|
11
25
|
import AntSelectMenu from './Elements/AntSelectMenu.vue';
|
|
12
26
|
import AntSkeleton from '../AntSkeleton.vue';
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
27
|
+
import {
|
|
28
|
+
vOnClickOutside,
|
|
29
|
+
} from '@vueuse/components';
|
|
30
|
+
import {
|
|
31
|
+
AntTagInputSize,
|
|
32
|
+
} from './__types/AntTagInput.types';
|
|
33
|
+
import type {
|
|
34
|
+
TagState,
|
|
35
|
+
} from '../__types/AntTag.types';
|
|
16
36
|
|
|
17
|
-
const emit = defineEmits([
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
37
|
+
const emit = defineEmits([
|
|
38
|
+
'update:modelValue',
|
|
39
|
+
'blur',
|
|
40
|
+
'validate',
|
|
41
|
+
]);
|
|
42
|
+
const props = withDefaults(defineProps<{
|
|
43
|
+
modelValue: (string | number)[] | null;
|
|
44
|
+
options: SelectOption[];
|
|
45
|
+
label?: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
placeholder?: string;
|
|
48
|
+
size?: AntTagInputSize;
|
|
49
|
+
state?: InputState;
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
readonly?: boolean;
|
|
52
|
+
skeleton?: boolean;
|
|
53
|
+
name?: string;
|
|
54
|
+
expanded?: boolean;
|
|
55
|
+
icon?: IconDefinition;
|
|
56
|
+
grouped?: Grouped;
|
|
57
|
+
nullable?: boolean;
|
|
58
|
+
messages?: string[];
|
|
59
|
+
allowCreate?: boolean;
|
|
60
|
+
allowDuplicates?: boolean;
|
|
61
|
+
openOnFocus?: boolean;
|
|
62
|
+
autoCloseAfterSelection?: boolean;
|
|
63
|
+
createCallback?: (item: string) => Promise<SelectOption>;
|
|
64
|
+
}>(), {
|
|
65
|
+
size: AntTagInputSize.md,
|
|
66
|
+
state: InputState.base,
|
|
67
|
+
icon: () => faChevronRight,
|
|
68
|
+
messages: () => [],
|
|
69
|
+
grouped: Grouped.none,
|
|
70
|
+
allowCreate: false,
|
|
71
|
+
allowDuplicates: false,
|
|
72
|
+
openOnFocus: true,
|
|
73
|
+
readonly: false,
|
|
74
|
+
disabled: false,
|
|
75
|
+
skeleton: false,
|
|
76
|
+
autoCloseAfterSelection: false,
|
|
77
|
+
placeholder: 'Add new tag',
|
|
78
|
+
});
|
|
57
79
|
|
|
58
80
|
const _modelValue: Ref<(string | number)[] | null> = useVModel(props, 'modelValue', emit);
|
|
59
81
|
const _skeleton = useVModel(props, 'skeleton', emit);
|
|
@@ -88,7 +110,7 @@ const inputContainerClasses = computed(() => {
|
|
|
88
110
|
'rounded-none': props.grouped === Grouped.center,
|
|
89
111
|
'rounded-tl-none rounded-bl-none rounded-tr-md rounded-br-md': props.grouped === Grouped.right,
|
|
90
112
|
'rounded-md': props.grouped === Grouped.none,
|
|
91
|
-
|
|
113
|
+
invisible: props.skeleton,
|
|
92
114
|
};
|
|
93
115
|
});
|
|
94
116
|
const inputClasses = computed(() => {
|
|
@@ -101,7 +123,7 @@ const inputClasses = computed(() => {
|
|
|
101
123
|
};
|
|
102
124
|
|
|
103
125
|
return {
|
|
104
|
-
'outline-0
|
|
126
|
+
'outline-0 bg-transparent w-full': true,
|
|
105
127
|
'opacity-50 cursor-not-allowed': props.disabled,
|
|
106
128
|
[variants[props.state]]: true,
|
|
107
129
|
};
|
|
@@ -124,15 +146,15 @@ const filteredOptions = computed(() => {
|
|
|
124
146
|
return !_modelValue.value?.includes(option.value);
|
|
125
147
|
}
|
|
126
148
|
|
|
127
|
-
return option.label.toLowerCase().includes(tagInput.value.toLowerCase())
|
|
149
|
+
return option.label.toLowerCase().includes(tagInput.value.toLowerCase());
|
|
128
150
|
});
|
|
129
|
-
})
|
|
151
|
+
});
|
|
130
152
|
|
|
131
153
|
function onClickOutside() {
|
|
132
154
|
if (!dropDownOpen.value) {
|
|
133
155
|
return;
|
|
134
156
|
}
|
|
135
|
-
console.log(
|
|
157
|
+
console.log('click outside');
|
|
136
158
|
// dropDownOpen.value = false;
|
|
137
159
|
}
|
|
138
160
|
|
|
@@ -161,7 +183,7 @@ function addTagFromOptions(item: string | number) {
|
|
|
161
183
|
addTag(item);
|
|
162
184
|
|
|
163
185
|
if (props.autoCloseAfterSelection) {
|
|
164
|
-
console.log(
|
|
186
|
+
console.log('HIER');
|
|
165
187
|
dropDownOpen.value = false;
|
|
166
188
|
}
|
|
167
189
|
}
|
|
@@ -175,7 +197,9 @@ function addTag(tagValue: string | number): void {
|
|
|
175
197
|
if (Array.isArray(_modelValue.value)) {
|
|
176
198
|
_modelValue.value.push(tagValue);
|
|
177
199
|
} else {
|
|
178
|
-
_modelValue.value = [
|
|
200
|
+
_modelValue.value = [
|
|
201
|
+
tagValue,
|
|
202
|
+
];
|
|
179
203
|
}
|
|
180
204
|
|
|
181
205
|
tagInput.value = '';
|
|
@@ -211,10 +235,16 @@ watch(() => props.skeleton, (val) => {
|
|
|
211
235
|
}
|
|
212
236
|
});
|
|
213
237
|
watch(_modelValue, (val) => {
|
|
214
|
-
if ([
|
|
238
|
+
if ([
|
|
239
|
+
InputState.danger,
|
|
240
|
+
InputState.warning,
|
|
241
|
+
InputState.info,
|
|
242
|
+
].includes(props.state)) {
|
|
215
243
|
emit('validate', val);
|
|
216
244
|
}
|
|
217
|
-
}, {
|
|
245
|
+
}, {
|
|
246
|
+
deep: true,
|
|
247
|
+
});
|
|
218
248
|
|
|
219
249
|
onMounted(() => {
|
|
220
250
|
/**
|
|
@@ -248,9 +278,9 @@ onMounted(() => {
|
|
|
248
278
|
/>
|
|
249
279
|
|
|
250
280
|
<div
|
|
281
|
+
v-on-click-outside="onClickOutside"
|
|
251
282
|
:class="inputContainerClasses"
|
|
252
283
|
class="w-full flex items-center"
|
|
253
|
-
v-on-click-outside="onClickOutside"
|
|
254
284
|
>
|
|
255
285
|
<div
|
|
256
286
|
class="flex gap-2.5 items-center"
|
|
@@ -286,7 +316,7 @@ onMounted(() => {
|
|
|
286
316
|
@keydown.delete="removeLastTag"
|
|
287
317
|
@keydown.enter.prevent="checkCreateTag(tagInput)"
|
|
288
318
|
@blur="onBlur"
|
|
289
|
-
|
|
319
|
+
>
|
|
290
320
|
</div>
|
|
291
321
|
</div>
|
|
292
322
|
|
|
@@ -1,17 +1,37 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
onMounted,
|
|
4
|
+
} from 'vue';
|
|
3
5
|
import AntField from '../forms/AntField.vue';
|
|
4
6
|
import AntBaseInput from './Elements/AntBaseInput.vue';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import {
|
|
8
|
+
Size,
|
|
9
|
+
} from '../../enums/Size.enum';
|
|
10
|
+
import {
|
|
11
|
+
TextInputType,
|
|
12
|
+
} from './__types/AntTextInput.types';
|
|
13
|
+
import {
|
|
14
|
+
handleEnumValidation,
|
|
15
|
+
} from '../../handler';
|
|
16
|
+
import {
|
|
17
|
+
useVModel,
|
|
18
|
+
} from '@vueuse/core';
|
|
19
|
+
import {
|
|
20
|
+
InputState,
|
|
21
|
+
} from '../../enums';
|
|
22
|
+
import {
|
|
23
|
+
BaseInputType,
|
|
24
|
+
} from './Elements/__types';
|
|
11
25
|
|
|
12
|
-
defineOptions({
|
|
26
|
+
defineOptions({
|
|
27
|
+
inheritAttrs: false,
|
|
28
|
+
});
|
|
13
29
|
|
|
14
|
-
const emit = defineEmits([
|
|
30
|
+
const emit = defineEmits([
|
|
31
|
+
'update:modelValue',
|
|
32
|
+
'update:skeleton',
|
|
33
|
+
'validate',
|
|
34
|
+
]);
|
|
15
35
|
const props = withDefaults(defineProps<{
|
|
16
36
|
modelValue: string | null;
|
|
17
37
|
label?: string;
|
|
@@ -34,7 +54,7 @@ const props = withDefaults(defineProps<{
|
|
|
34
54
|
size: Size.md,
|
|
35
55
|
type: TextInputType.text,
|
|
36
56
|
limiter: false,
|
|
37
|
-
messages: () => []
|
|
57
|
+
messages: () => [],
|
|
38
58
|
});
|
|
39
59
|
|
|
40
60
|
const _value = useVModel(props, 'modelValue', emit);
|
|
@@ -60,7 +80,7 @@ onMounted(() => {
|
|
|
60
80
|
<AntBaseInput
|
|
61
81
|
v-model="_value"
|
|
62
82
|
:type="type as unknown as BaseInputType"
|
|
63
|
-
wrapper-class="
|
|
83
|
+
wrapper-class="grow"
|
|
64
84
|
:state="state"
|
|
65
85
|
:size="size"
|
|
66
86
|
:skeleton="skeleton"
|
|
@@ -1,25 +1,47 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
computed, onMounted, ref, watch,
|
|
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 {
|
|
10
|
+
import {
|
|
11
|
+
Grouped,
|
|
12
|
+
} from '../../enums/Grouped.enum';
|
|
7
13
|
import {
|
|
8
14
|
faExclamationTriangle,
|
|
9
15
|
faExclamationCircle,
|
|
10
16
|
faCircleCheck,
|
|
11
|
-
faCircleInfo
|
|
17
|
+
faCircleInfo,
|
|
12
18
|
} from '@fortawesome/free-solid-svg-icons';
|
|
13
|
-
import {
|
|
14
|
-
|
|
19
|
+
import {
|
|
20
|
+
handleEnumValidation,
|
|
21
|
+
} from '../../handler';
|
|
22
|
+
import {
|
|
23
|
+
classesToObjectSyntax,
|
|
24
|
+
} from '../../utils';
|
|
15
25
|
import AntField from '../forms/AntField.vue';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
import {
|
|
27
|
+
useVModel,
|
|
28
|
+
} from '@vueuse/core';
|
|
29
|
+
import {
|
|
30
|
+
InputState,
|
|
31
|
+
} from '../../enums';
|
|
32
|
+
import {
|
|
33
|
+
IconSize,
|
|
34
|
+
} from '../__types';
|
|
19
35
|
|
|
20
|
-
defineOptions({
|
|
36
|
+
defineOptions({
|
|
37
|
+
inheritAttrs: false,
|
|
38
|
+
});
|
|
21
39
|
|
|
22
|
-
const emit = defineEmits([
|
|
40
|
+
const emit = defineEmits([
|
|
41
|
+
'update:modelValue',
|
|
42
|
+
'validate',
|
|
43
|
+
'blur',
|
|
44
|
+
]);
|
|
23
45
|
const props = withDefaults(defineProps<{
|
|
24
46
|
modelValue: string | null;
|
|
25
47
|
size?: Size;
|
|
@@ -47,7 +69,7 @@ const props = withDefaults(defineProps<{
|
|
|
47
69
|
showIcon: true,
|
|
48
70
|
limiter: false,
|
|
49
71
|
resize: true,
|
|
50
|
-
messages: () => []
|
|
72
|
+
messages: () => [],
|
|
51
73
|
});
|
|
52
74
|
|
|
53
75
|
const _modelValue = useVModel(props, 'modelValue', emit);
|
|
@@ -93,19 +115,19 @@ const inputClasses = computed(() => {
|
|
|
93
115
|
'rounded-none': props.grouped === Grouped.center,
|
|
94
116
|
'rounded-tl-none rounded-bl-none rounded-tr-md rounded-br-md': props.grouped === Grouped.right,
|
|
95
117
|
'rounded-md': props.grouped === Grouped.none,
|
|
96
|
-
|
|
97
|
-
'resize-none': !props.resize
|
|
118
|
+
invisible: props.skeleton,
|
|
119
|
+
'resize-none': !props.resize,
|
|
98
120
|
};
|
|
99
121
|
});
|
|
100
122
|
const iconColor = computed(() => {
|
|
101
123
|
const variants = {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
124
|
+
base: undefined,
|
|
125
|
+
danger: 'text-danger-500',
|
|
126
|
+
info: 'text-info-500',
|
|
127
|
+
primary: 'text-primary-500',
|
|
128
|
+
secondary: 'text-secondary-500',
|
|
129
|
+
success: 'text-success-500',
|
|
130
|
+
warning: 'text-warning-500',
|
|
109
131
|
};
|
|
110
132
|
|
|
111
133
|
return variants[props.state];
|
|
@@ -132,10 +154,16 @@ onMounted(() => {
|
|
|
132
154
|
});
|
|
133
155
|
|
|
134
156
|
watch(_modelValue, (val) => {
|
|
135
|
-
if ([
|
|
157
|
+
if ([
|
|
158
|
+
InputState.danger,
|
|
159
|
+
InputState.warning,
|
|
160
|
+
InputState.info,
|
|
161
|
+
].includes(props.state)) {
|
|
136
162
|
emit('validate', val);
|
|
137
163
|
}
|
|
138
|
-
}, {
|
|
164
|
+
}, {
|
|
165
|
+
deep: true,
|
|
166
|
+
});
|
|
139
167
|
watch(() => props.skeleton, (val) => {
|
|
140
168
|
if (!val && props.modelValue !== null) {
|
|
141
169
|
emit('validate', props.modelValue);
|
|
@@ -148,7 +176,7 @@ function onBlur(e: FocusEvent) {
|
|
|
148
176
|
}
|
|
149
177
|
|
|
150
178
|
defineExpose({
|
|
151
|
-
getTextAreaRef: () => textAreaRef.value
|
|
179
|
+
getTextAreaRef: () => textAreaRef.value,
|
|
152
180
|
});
|
|
153
181
|
|
|
154
182
|
</script>
|
|
@@ -170,12 +198,12 @@ defineExpose({
|
|
|
170
198
|
:class="{...{'-mr-px': grouped !== Grouped.none}, ..._wrapperClass}"
|
|
171
199
|
>
|
|
172
200
|
<textarea
|
|
201
|
+
ref="textAreaRef"
|
|
173
202
|
v-model="_modelValue"
|
|
174
203
|
:class="inputClasses"
|
|
175
204
|
:placeholder="placeholder !== undefined ? placeholder : label"
|
|
176
205
|
:disabled="disabled || skeleton"
|
|
177
206
|
:readonly="readonly"
|
|
178
|
-
ref="textAreaRef"
|
|
179
207
|
v-bind="$attrs"
|
|
180
208
|
@blur="onBlur"
|
|
181
209
|
/>
|