@antify/ui 2.4.5 → 2.4.11
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/buttons/AntButton.vue +1 -1
- package/dist/components/inputs/AntColorInput/AntColorInput.stories.js +26 -20
- package/dist/components/inputs/AntColorInput/AntColorInput.stories.mjs +35 -20
- package/dist/components/inputs/AntColorInput/AntColorInput.vue +52 -30
- package/dist/components/inputs/AntColorInput/Color.vue +44 -12
- package/dist/components/inputs/AntColorInput/ColorSelection.vue +18 -1
- package/dist/components/inputs/AntImageInput.vue +91 -22
- package/dist/components/inputs/AntPasswordInput.vue +5 -0
- package/dist/components/inputs/AntSelect.vue +4 -3
- package/dist/components/inputs/AntTagInput.vue +6 -2
- package/dist/components/inputs/AntTextInput.vue +5 -0
- package/dist/components/inputs/Elements/AntSelectMenu.vue +15 -7
- package/dist/components/inputs/Elements/__stories/AntBaseInput.stories.d.ts +1 -0
- package/dist/components/inputs/Elements/__stories/AntBaseInput.stories.js +35 -1
- package/dist/components/inputs/Elements/__stories/AntBaseInput.stories.mjs +36 -0
- package/dist/components/inputs/__stories/AntPasswordInput.stories.d.ts +2 -1
- package/dist/components/inputs/__stories/AntPasswordInput.stories.js +36 -1
- package/dist/components/inputs/__stories/AntPasswordInput.stories.mjs +37 -0
- 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/__stories/AntTextInput.stories.d.ts +2 -1
- package/dist/components/inputs/__stories/AntTextInput.stories.js +37 -1
- package/dist/components/inputs/__stories/AntTextInput.stories.mjs +38 -0
- package/package.json +1 -1
|
@@ -128,7 +128,7 @@ const classes = computed(() => {
|
|
|
128
128
|
};
|
|
129
129
|
|
|
130
130
|
return {
|
|
131
|
-
'transition-all inline-flex items-center justify-center relative font-medium': true,
|
|
131
|
+
'transition-all inline-flex items-center justify-center relative font-medium cursor-pointer select-none': true,
|
|
132
132
|
'active:shadow-[inset_0_4px_4px_rgba(0,0,0,0.25)]': !hasInputState.value,
|
|
133
133
|
'p-1 text-xs gap-1': props.size === Size.xs2,
|
|
134
134
|
'p-1.5 text-xs gap-1.5': props.size === Size.xs,
|
|
@@ -33,6 +33,7 @@ const meta = {
|
|
|
33
33
|
};
|
|
34
34
|
module.exports = meta;
|
|
35
35
|
const defaultOptions = ["primary-500", "red-500", "green-500", "blue-500", "yellow-500", "purple-500", "pink-500", "orange-500"];
|
|
36
|
+
const lightColorOptions = ["primary-300", "red-300", "green-300", "blue-300", "yellow-300", "purple-300", "pink-300", "orange-300"];
|
|
36
37
|
const Docs = exports.Docs = {
|
|
37
38
|
render: args => ({
|
|
38
39
|
components: {
|
|
@@ -79,9 +80,12 @@ const Summary = exports.Summary = {
|
|
|
79
80
|
set: val => args.modelValue = val
|
|
80
81
|
});
|
|
81
82
|
const skeleton = (0, _vue.ref)(true);
|
|
83
|
+
const lightModelValue = (0, _vue.ref)("primary-300");
|
|
82
84
|
return {
|
|
83
85
|
args,
|
|
84
86
|
modelValue,
|
|
87
|
+
lightModelValue,
|
|
88
|
+
lightColorOptions,
|
|
85
89
|
InputState: _enums.InputState,
|
|
86
90
|
skeleton,
|
|
87
91
|
Size: _enums.Size
|
|
@@ -92,71 +96,73 @@ const Summary = exports.Summary = {
|
|
|
92
96
|
<AntFormGroupLabel>States</AntFormGroupLabel>
|
|
93
97
|
<AntFormGroup direction="row">
|
|
94
98
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label"
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
100
|
+
:state="InputState.base"/>
|
|
97
101
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label"
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
103
|
+
:state="InputState.info"/>
|
|
100
104
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label"
|
|
101
|
-
|
|
102
|
-
|
|
105
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
106
|
+
:state="InputState.success"/>
|
|
103
107
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label"
|
|
104
|
-
|
|
105
|
-
|
|
108
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
109
|
+
:state="InputState.warning"/>
|
|
106
110
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label"
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
112
|
+
:state="InputState.danger"/>
|
|
109
113
|
</AntFormGroup>
|
|
110
114
|
<AntFormGroupLabel>Sizes</AntFormGroupLabel>
|
|
111
115
|
<AntFormGroup direction="row">
|
|
112
116
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label" :size="Size.lg"
|
|
113
|
-
|
|
117
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
114
118
|
/>
|
|
115
119
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label" :size="Size.md"
|
|
116
|
-
|
|
120
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
117
121
|
/>
|
|
118
122
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label" :size="Size.sm"
|
|
119
|
-
|
|
123
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
120
124
|
/>
|
|
121
125
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label" :size="Size.xs"
|
|
122
|
-
|
|
126
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
123
127
|
/>
|
|
124
128
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label" :size="Size.xs2"
|
|
125
|
-
|
|
129
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
126
130
|
/>
|
|
127
131
|
</AntFormGroup>
|
|
128
132
|
<AntFormGroup direction="row">
|
|
129
133
|
<AntFormGroup>
|
|
130
134
|
<AntFormGroupLabel>Disabled</AntFormGroupLabel>
|
|
131
135
|
<AntColorInput v-bind="args" v-model="modelValue" :disabled="true" label="Label"
|
|
132
|
-
|
|
136
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
133
137
|
/>
|
|
134
138
|
</AntFormGroup>
|
|
135
139
|
<AntFormGroup>
|
|
136
140
|
<AntFormGroupLabel>Readonly</AntFormGroupLabel>
|
|
137
141
|
<AntColorInput v-bind="args" v-model="modelValue" :readonly="true" label="Label"
|
|
138
|
-
|
|
142
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
139
143
|
/>
|
|
140
144
|
</AntFormGroup>
|
|
141
145
|
<AntFormGroup>
|
|
142
146
|
<AntFormGroupLabel>Skeleton</AntFormGroupLabel>
|
|
143
147
|
<AntColorInput v-bind="args" v-model="modelValue" :skeleton="true" label="Label"
|
|
144
|
-
|
|
148
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
145
149
|
/>
|
|
146
150
|
</AntFormGroup>
|
|
147
151
|
</AntFormGroup>
|
|
148
152
|
<AntFormGroupLabel>Plain</AntFormGroupLabel>
|
|
149
153
|
<AntColorInput v-bind="args" v-model="modelValue"/>
|
|
154
|
+
<AntFormGroupLabel>Light Color Options</AntFormGroupLabel>
|
|
155
|
+
<AntColorInput v-model="lightModelValue" :options="lightColorOptions" />
|
|
150
156
|
<AntFormGroupLabel>Nullable</AntFormGroupLabel>
|
|
151
157
|
<AntColorInput v-bind="args" v-model="modelValue" nullable/>
|
|
152
158
|
<AntFormGroupLabel>With label</AntFormGroupLabel>
|
|
153
159
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label"/>
|
|
154
160
|
<AntFormGroupLabel>With description</AntFormGroupLabel>
|
|
155
161
|
<AntColorInput v-bind="args" v-model="modelValue"
|
|
156
|
-
|
|
162
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"/>
|
|
157
163
|
<AntFormGroupLabel>With label + description</AntFormGroupLabel>
|
|
158
164
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label"
|
|
159
|
-
|
|
165
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"/>
|
|
160
166
|
</AntFormGroup>
|
|
161
167
|
`
|
|
162
168
|
}),
|
|
@@ -43,6 +43,16 @@ const defaultOptions = [
|
|
|
43
43
|
"pink-500",
|
|
44
44
|
"orange-500"
|
|
45
45
|
];
|
|
46
|
+
const lightColorOptions = [
|
|
47
|
+
"primary-300",
|
|
48
|
+
"red-300",
|
|
49
|
+
"green-300",
|
|
50
|
+
"blue-300",
|
|
51
|
+
"yellow-300",
|
|
52
|
+
"purple-300",
|
|
53
|
+
"pink-300",
|
|
54
|
+
"orange-300"
|
|
55
|
+
];
|
|
46
56
|
export const Docs = {
|
|
47
57
|
render: (args) => ({
|
|
48
58
|
components: {
|
|
@@ -89,9 +99,12 @@ export const Summary = {
|
|
|
89
99
|
set: (val) => args.modelValue = val
|
|
90
100
|
});
|
|
91
101
|
const skeleton = ref(true);
|
|
102
|
+
const lightModelValue = ref("primary-300");
|
|
92
103
|
return {
|
|
93
104
|
args,
|
|
94
105
|
modelValue,
|
|
106
|
+
lightModelValue,
|
|
107
|
+
lightColorOptions,
|
|
95
108
|
InputState,
|
|
96
109
|
skeleton,
|
|
97
110
|
Size
|
|
@@ -102,71 +115,73 @@ export const Summary = {
|
|
|
102
115
|
<AntFormGroupLabel>States</AntFormGroupLabel>
|
|
103
116
|
<AntFormGroup direction="row">
|
|
104
117
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label"
|
|
105
|
-
|
|
106
|
-
|
|
118
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
119
|
+
:state="InputState.base"/>
|
|
107
120
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label"
|
|
108
|
-
|
|
109
|
-
|
|
121
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
122
|
+
:state="InputState.info"/>
|
|
110
123
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label"
|
|
111
|
-
|
|
112
|
-
|
|
124
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
125
|
+
:state="InputState.success"/>
|
|
113
126
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label"
|
|
114
|
-
|
|
115
|
-
|
|
127
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
128
|
+
:state="InputState.warning"/>
|
|
116
129
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label"
|
|
117
|
-
|
|
118
|
-
|
|
130
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
131
|
+
:state="InputState.danger"/>
|
|
119
132
|
</AntFormGroup>
|
|
120
133
|
<AntFormGroupLabel>Sizes</AntFormGroupLabel>
|
|
121
134
|
<AntFormGroup direction="row">
|
|
122
135
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label" :size="Size.lg"
|
|
123
|
-
|
|
136
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
124
137
|
/>
|
|
125
138
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label" :size="Size.md"
|
|
126
|
-
|
|
139
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
127
140
|
/>
|
|
128
141
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label" :size="Size.sm"
|
|
129
|
-
|
|
142
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
130
143
|
/>
|
|
131
144
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label" :size="Size.xs"
|
|
132
|
-
|
|
145
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
133
146
|
/>
|
|
134
147
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label" :size="Size.xs2"
|
|
135
|
-
|
|
148
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
136
149
|
/>
|
|
137
150
|
</AntFormGroup>
|
|
138
151
|
<AntFormGroup direction="row">
|
|
139
152
|
<AntFormGroup>
|
|
140
153
|
<AntFormGroupLabel>Disabled</AntFormGroupLabel>
|
|
141
154
|
<AntColorInput v-bind="args" v-model="modelValue" :disabled="true" label="Label"
|
|
142
|
-
|
|
155
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
143
156
|
/>
|
|
144
157
|
</AntFormGroup>
|
|
145
158
|
<AntFormGroup>
|
|
146
159
|
<AntFormGroupLabel>Readonly</AntFormGroupLabel>
|
|
147
160
|
<AntColorInput v-bind="args" v-model="modelValue" :readonly="true" label="Label"
|
|
148
|
-
|
|
161
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
149
162
|
/>
|
|
150
163
|
</AntFormGroup>
|
|
151
164
|
<AntFormGroup>
|
|
152
165
|
<AntFormGroupLabel>Skeleton</AntFormGroupLabel>
|
|
153
166
|
<AntColorInput v-bind="args" v-model="modelValue" :skeleton="true" label="Label"
|
|
154
|
-
|
|
167
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"
|
|
155
168
|
/>
|
|
156
169
|
</AntFormGroup>
|
|
157
170
|
</AntFormGroup>
|
|
158
171
|
<AntFormGroupLabel>Plain</AntFormGroupLabel>
|
|
159
172
|
<AntColorInput v-bind="args" v-model="modelValue"/>
|
|
173
|
+
<AntFormGroupLabel>Light Color Options</AntFormGroupLabel>
|
|
174
|
+
<AntColorInput v-model="lightModelValue" :options="lightColorOptions" />
|
|
160
175
|
<AntFormGroupLabel>Nullable</AntFormGroupLabel>
|
|
161
176
|
<AntColorInput v-bind="args" v-model="modelValue" nullable/>
|
|
162
177
|
<AntFormGroupLabel>With label</AntFormGroupLabel>
|
|
163
178
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label"/>
|
|
164
179
|
<AntFormGroupLabel>With description</AntFormGroupLabel>
|
|
165
180
|
<AntColorInput v-bind="args" v-model="modelValue"
|
|
166
|
-
|
|
181
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"/>
|
|
167
182
|
<AntFormGroupLabel>With label + description</AntFormGroupLabel>
|
|
168
183
|
<AntColorInput v-bind="args" v-model="modelValue" label="Label"
|
|
169
|
-
|
|
184
|
+
description="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod"/>
|
|
170
185
|
</AntFormGroup>
|
|
171
186
|
`
|
|
172
187
|
}),
|
|
@@ -6,16 +6,10 @@ import {
|
|
|
6
6
|
} from '@fortawesome/free-solid-svg-icons';
|
|
7
7
|
import AntSkeleton from '../../AntSkeleton.vue';
|
|
8
8
|
import {
|
|
9
|
-
Size,
|
|
10
|
-
State,
|
|
11
|
-
Grouped,
|
|
12
|
-
InputState,
|
|
9
|
+
Grouped, InputState, Size, State,
|
|
13
10
|
} from '../../../enums';
|
|
14
11
|
import {
|
|
15
|
-
ref,
|
|
16
|
-
watch,
|
|
17
|
-
computed,
|
|
18
|
-
onMounted, nextTick,
|
|
12
|
+
computed, nextTick, onMounted, ref, watch,
|
|
19
13
|
} from 'vue';
|
|
20
14
|
import Color from './Color.vue';
|
|
21
15
|
import AntDropdown from '../../AntDropdown.vue';
|
|
@@ -67,15 +61,13 @@ const containerClasses = computed(() => {
|
|
|
67
61
|
[key: string]: boolean;
|
|
68
62
|
} = {
|
|
69
63
|
'flex relative w-fit ring-primary/25 rounded-md outline-hidden': true,
|
|
70
|
-
'focus-within:ring-2': (props.size === Size.xs2 || props.size === Size.xs || props.size === Size.sm) && !hasInputState.value,
|
|
71
|
-
'focus-within:ring-4': (props.size === Size.md || props.size === Size.lg) && !hasInputState.value,
|
|
72
64
|
};
|
|
73
65
|
const colorVariant = {
|
|
74
|
-
[InputState.base]: 'focus
|
|
75
|
-
[InputState.danger]: 'focus
|
|
76
|
-
[InputState.info]: 'focus
|
|
77
|
-
[InputState.success]: 'focus
|
|
78
|
-
[InputState.warning]: 'focus
|
|
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',
|
|
79
71
|
};
|
|
80
72
|
|
|
81
73
|
classes[colorVariant[props.state]] = true;
|
|
@@ -94,6 +86,8 @@ const itemClasses = computed(() => {
|
|
|
94
86
|
[key: string]: boolean;
|
|
95
87
|
} = {
|
|
96
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,
|
|
97
91
|
'rounded-r-md': !hasRemoveButton.value,
|
|
98
92
|
'p-1': props.size === Size.xs2,
|
|
99
93
|
'p-1.5': props.size === Size.xs || props.size === Size.sm,
|
|
@@ -104,11 +98,11 @@ const itemClasses = computed(() => {
|
|
|
104
98
|
};
|
|
105
99
|
|
|
106
100
|
const colorVariant = {
|
|
107
|
-
[InputState.
|
|
108
|
-
[InputState.
|
|
109
|
-
[InputState.info]: 'outline-info-500 bg-info-100',
|
|
110
|
-
[InputState.
|
|
111
|
-
[InputState.
|
|
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',
|
|
112
106
|
};
|
|
113
107
|
|
|
114
108
|
classes[colorVariant[props.state]] = true;
|
|
@@ -116,6 +110,7 @@ const itemClasses = computed(() => {
|
|
|
116
110
|
return classes;
|
|
117
111
|
});
|
|
118
112
|
const showDropdown = ref<boolean>(false);
|
|
113
|
+
const itemRef = ref<HTMLDivElement | null>(null);
|
|
119
114
|
|
|
120
115
|
/**
|
|
121
116
|
* Validate default value if given after delayed data fetching.
|
|
@@ -136,6 +131,30 @@ function onBlur(e: FocusEvent) {
|
|
|
136
131
|
emit('blur', e);
|
|
137
132
|
}
|
|
138
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
|
+
|
|
139
158
|
onMounted(() => {
|
|
140
159
|
if (!props.skeleton && props.modelValue !== null) {
|
|
141
160
|
emit('validate', props.modelValue);
|
|
@@ -159,15 +178,22 @@ onMounted(() => {
|
|
|
159
178
|
>
|
|
160
179
|
<div
|
|
161
180
|
:class="containerClasses"
|
|
162
|
-
tabindex="0"
|
|
163
|
-
@blur="onBlur"
|
|
164
181
|
>
|
|
165
|
-
<div
|
|
166
|
-
|
|
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
|
+
>
|
|
167
193
|
<Color
|
|
168
194
|
:value="modelValue"
|
|
169
195
|
:size="size as unknown as ColorInputSize"
|
|
170
|
-
|
|
196
|
+
readonly
|
|
171
197
|
/>
|
|
172
198
|
</div>
|
|
173
199
|
|
|
@@ -183,7 +209,6 @@ onMounted(() => {
|
|
|
183
209
|
v-if="hasRemoveButton"
|
|
184
210
|
:icon-left="faMultiply"
|
|
185
211
|
:grouped="Grouped.right"
|
|
186
|
-
:no-focus="true"
|
|
187
212
|
:state="state as unknown as State"
|
|
188
213
|
:size="size"
|
|
189
214
|
:skeleton="skeleton"
|
|
@@ -198,10 +223,7 @@ onMounted(() => {
|
|
|
198
223
|
<ColorSelection
|
|
199
224
|
:value="modelValue"
|
|
200
225
|
:colors="props.options"
|
|
201
|
-
@select="
|
|
202
|
-
$emit('update:modelValue', val);
|
|
203
|
-
nextTick(() => showDropdown = false);
|
|
204
|
-
}"
|
|
226
|
+
@select="onColorSelect"
|
|
205
227
|
/>
|
|
206
228
|
</template>
|
|
207
229
|
</AntDropdown>
|
|
@@ -6,12 +6,15 @@ import AntIcon from '../../AntIcon.vue';
|
|
|
6
6
|
import {
|
|
7
7
|
ColorInputSize,
|
|
8
8
|
} from './AntColorInput.types';
|
|
9
|
+
import {
|
|
10
|
+
computed, ref,
|
|
11
|
+
} from 'vue';
|
|
9
12
|
|
|
10
13
|
defineEmits([
|
|
11
14
|
'select',
|
|
12
15
|
]);
|
|
13
16
|
|
|
14
|
-
withDefaults(defineProps<{
|
|
17
|
+
const props = withDefaults(defineProps<{
|
|
15
18
|
/**
|
|
16
19
|
* Value needs to be a variable name which exists in
|
|
17
20
|
* document computed style as CSS variable like --color-{value}
|
|
@@ -19,31 +22,60 @@ withDefaults(defineProps<{
|
|
|
19
22
|
value: string | null;
|
|
20
23
|
selected?: boolean;
|
|
21
24
|
size?: ColorInputSize;
|
|
25
|
+
readonly?: boolean;
|
|
22
26
|
}>(), {
|
|
23
27
|
selected: false,
|
|
24
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!';
|
|
25
61
|
});
|
|
26
62
|
</script>
|
|
27
63
|
|
|
28
64
|
<template>
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
:class="
|
|
32
|
-
'h-4 w-4': [ColorInputSize.xs, ColorInputSize.xs2].includes(size),
|
|
33
|
-
'h-5 w-5': [ColorInputSize.lg, ColorInputSize.md, ColorInputSize.sm].includes(size),
|
|
34
|
-
'h-8 w-8': ColorInputSize.xl === size,
|
|
35
|
-
'h-10 w-10': ColorInputSize.xl2 === size,
|
|
36
|
-
}"
|
|
65
|
+
<button
|
|
66
|
+
ref="buttonRef"
|
|
67
|
+
:class="buttonClasses"
|
|
37
68
|
:style="{
|
|
38
69
|
backgroundColor: `var(--color-${value})`,
|
|
39
70
|
outlineColor: `var(--color-${value})`,
|
|
40
71
|
}"
|
|
41
|
-
|
|
72
|
+
:tabindex="readonly ? -1 : 0"
|
|
73
|
+
@click.prevent="$emit('select', value)"
|
|
42
74
|
>
|
|
43
75
|
<AntIcon
|
|
44
76
|
v-if="selected"
|
|
45
77
|
:icon="faCheck"
|
|
46
|
-
class="
|
|
78
|
+
:class="iconClasses"
|
|
47
79
|
/>
|
|
48
|
-
</
|
|
80
|
+
</button>
|
|
49
81
|
</template>
|
|
@@ -6,6 +6,9 @@ import Color from './Color.vue';
|
|
|
6
6
|
import {
|
|
7
7
|
ColorInputSize,
|
|
8
8
|
} from './AntColorInput.types';
|
|
9
|
+
import {
|
|
10
|
+
onMounted, ref,
|
|
11
|
+
} from 'vue';
|
|
9
12
|
|
|
10
13
|
defineEmits([
|
|
11
14
|
'select',
|
|
@@ -19,6 +22,19 @@ withDefaults(defineProps<{
|
|
|
19
22
|
}>(), {
|
|
20
23
|
size: Size.md,
|
|
21
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
|
+
});
|
|
22
38
|
</script>
|
|
23
39
|
|
|
24
40
|
<template>
|
|
@@ -32,8 +48,9 @@ withDefaults(defineProps<{
|
|
|
32
48
|
}"
|
|
33
49
|
>
|
|
34
50
|
<Color
|
|
35
|
-
v-for="color in colors"
|
|
51
|
+
v-for="(color, index) in colors"
|
|
36
52
|
:key="color"
|
|
53
|
+
:ref="(val) => colorButtonRefs[index] = val as ColorComponentInstance"
|
|
37
54
|
:value="color"
|
|
38
55
|
:selected="color === value"
|
|
39
56
|
:size="ColorInputSize.xl2"
|