@v1nt1248/3nclient-lib 0.2.99 → 0.3.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/ui3n-input/types.d.ts +1 -0
- package/dist/components/ui3n-input/ui3n-input.vue.d.ts +0 -1
- package/dist/style.css +1 -1
- package/dist/ui3n-components.js +1127 -1127
- package/package.json +1 -1
- package/src/components/ui3n-input/types.ts +1 -0
- package/src/components/ui3n-input/ui3n-input.vue +29 -56
- package/src/components/ui3n-selector/ui3n-selector.vue +15 -15
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { computed, onMounted, ref, watch
|
|
3
|
-
import isEmpty from 'lodash/isEmpty';
|
|
2
|
+
import { computed, onMounted, ref, watch } from 'vue';
|
|
4
3
|
import Ui3nIcon from '../ui3n-icon/ui3n-icon.vue';
|
|
5
4
|
import Ui3nButton from '../ui3n-button/ui3n-button.vue';
|
|
6
5
|
import type { Ui3nInputEmits, Ui3nInputProps } from './types';
|
|
@@ -8,8 +7,6 @@
|
|
|
8
7
|
const props = defineProps<Ui3nInputProps>();
|
|
9
8
|
const emits = defineEmits<Ui3nInputEmits>();
|
|
10
9
|
|
|
11
|
-
const css = useCssModule();
|
|
12
|
-
|
|
13
10
|
const inputElement = ref<HTMLInputElement | null>(null);
|
|
14
11
|
const text = ref<string>('');
|
|
15
12
|
const isDirty = ref(false);
|
|
@@ -24,43 +21,6 @@
|
|
|
24
21
|
return props.iconColor || 'var(--color-icon-control-primary-default)';
|
|
25
22
|
});
|
|
26
23
|
|
|
27
|
-
const isValid = computed(() => {
|
|
28
|
-
if (!isDirty.value) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return !errorMessage.value;
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const mainCssClasses = computed(() => {
|
|
36
|
-
const val = [css.ui3nInput];
|
|
37
|
-
props.label && val.push(css.withLabel);
|
|
38
|
-
props.hideBottomSpace && val.push(css.withoutBottomSpace);
|
|
39
|
-
props.icon && val.push(css.withIcon);
|
|
40
|
-
props.clearable && text.value && val.push(css.clearable);
|
|
41
|
-
props.disabled && val.push(css.disabled);
|
|
42
|
-
((!!errorMessage.value && !isValid.value) || props.displayStateMode === 'error') && val.push(css.error);
|
|
43
|
-
props.displayStateMode === 'success' && val.push(css.success);
|
|
44
|
-
|
|
45
|
-
return val;
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const iconCssClasses = computed(() => {
|
|
49
|
-
const val = [css.ui3nInputIcon];
|
|
50
|
-
props.disabled && val.push(css.ui3nInputIconDisabled);
|
|
51
|
-
|
|
52
|
-
return val;
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const messageCssClasses = computed(() => {
|
|
56
|
-
const val = [css.ui3nInputFieldMessage];
|
|
57
|
-
(errorMessage.value || (props.displayStateMode === 'error' && !!props.displayStateMessage)) &&
|
|
58
|
-
val.push(css.ui3nInputErrorMessage);
|
|
59
|
-
props.displayStateMode === 'success' && props.displayStateMessage && val.push(css.ui3nInputSuccessMessage);
|
|
60
|
-
|
|
61
|
-
return val;
|
|
62
|
-
});
|
|
63
|
-
|
|
64
24
|
function onFocus(event: Event) {
|
|
65
25
|
isFocused.value = true;
|
|
66
26
|
emits('focus', event);
|
|
@@ -131,6 +91,10 @@
|
|
|
131
91
|
}
|
|
132
92
|
}
|
|
133
93
|
}
|
|
94
|
+
|
|
95
|
+
if (isDirty.value) {
|
|
96
|
+
emits('update:valid', !errorMessage.value);
|
|
97
|
+
}
|
|
134
98
|
}
|
|
135
99
|
|
|
136
100
|
defineExpose({
|
|
@@ -145,21 +109,18 @@
|
|
|
145
109
|
}
|
|
146
110
|
|
|
147
111
|
emits('init', inputElement.value!);
|
|
112
|
+
if (props.validateAtStartup) {
|
|
113
|
+
validate(text.value);
|
|
114
|
+
}
|
|
148
115
|
});
|
|
149
116
|
|
|
150
117
|
watch(
|
|
151
118
|
() => props.modelValue,
|
|
152
|
-
val => {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
);
|
|
158
|
-
|
|
159
|
-
watch(
|
|
160
|
-
() => isValid.value,
|
|
161
|
-
val => {
|
|
162
|
-
emits('update:valid', val);
|
|
119
|
+
(val, oldVal) => {
|
|
120
|
+
if ((val ?? '') !== (oldVal ?? '')) {
|
|
121
|
+
text.value = val ?? '';
|
|
122
|
+
validate(text.value);
|
|
123
|
+
}
|
|
163
124
|
},
|
|
164
125
|
{ immediate: true },
|
|
165
126
|
);
|
|
@@ -167,8 +128,16 @@
|
|
|
167
128
|
|
|
168
129
|
<template>
|
|
169
130
|
<div
|
|
170
|
-
|
|
171
|
-
|
|
131
|
+
:class="[
|
|
132
|
+
$style.ui3nInput,
|
|
133
|
+
label && $style.withLabel,
|
|
134
|
+
hideBottomSpace && $style.withoutBottomSpace,
|
|
135
|
+
icon && $style.withIcon,
|
|
136
|
+
clearable && text && $style.clearable,
|
|
137
|
+
disabled && $style.disabled,
|
|
138
|
+
(!!errorMessage || displayStateMode === 'error') && $style.error,
|
|
139
|
+
displayStateMode === 'success' && $style.success,
|
|
140
|
+
]"
|
|
172
141
|
>
|
|
173
142
|
<label
|
|
174
143
|
v-if="label"
|
|
@@ -199,7 +168,7 @@
|
|
|
199
168
|
:icon="icon"
|
|
200
169
|
:width="16"
|
|
201
170
|
:height="16"
|
|
202
|
-
:class="
|
|
171
|
+
:class="[$style.ui3nInputIcon, disabled && $style.ui3nInputIconDisabled]"
|
|
203
172
|
/>
|
|
204
173
|
|
|
205
174
|
<ui3n-icon
|
|
@@ -225,7 +194,11 @@
|
|
|
225
194
|
|
|
226
195
|
<div
|
|
227
196
|
v-if="(isDirty && errorMessage) || (displayStateMode && displayStateMessage)"
|
|
228
|
-
:class="
|
|
197
|
+
:class="[
|
|
198
|
+
$style.ui3nInputFieldMessage,
|
|
199
|
+
(errorMessage || (displayStateMode === 'error' && displayStateMessage)) && $style.ui3nInputErrorMessage,
|
|
200
|
+
displayStateMode === 'success' && displayStateMessage && $style.ui3nInputSuccessMessage,
|
|
201
|
+
]"
|
|
229
202
|
>
|
|
230
203
|
{{ errorMessage || displayStateMessage }}
|
|
231
204
|
</div>
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
label: '',
|
|
36
36
|
items: () => [] as T[],
|
|
37
37
|
itemValue: 'id',
|
|
38
|
-
itemDisplay: 'id' as keyof T,
|
|
39
38
|
clearable: false,
|
|
40
39
|
withSearch: false,
|
|
41
40
|
returnObject: false,
|
|
@@ -95,23 +94,24 @@
|
|
|
95
94
|
});
|
|
96
95
|
|
|
97
96
|
function getItemTitle(value: T | T[keyof T], withProcessing?: boolean): string {
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
: '';
|
|
97
|
+
if (!value) {
|
|
98
|
+
return '';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (typeof value !== 'object') {
|
|
102
|
+
const val = (value as T[keyof T]).toString();
|
|
105
103
|
return withProcessing ? val.toLowerCase() : val;
|
|
106
104
|
}
|
|
107
105
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
106
|
+
const isItemDisplayFunction = props.itemDisplay && typeof props.itemDisplay === 'function';
|
|
107
|
+
const preVal = isItemDisplayFunction
|
|
108
|
+
? (props.itemDisplay as Ui3nSelectorItemDisplayingFunction<T>)(value as T)
|
|
109
|
+
: props.itemDisplay
|
|
110
|
+
? (value as T)[props.itemDisplay as keyof T]
|
|
111
|
+
: (value as T).id;
|
|
112
|
+
// @ts-expect-error
|
|
113
|
+
const val = preVal.toString();
|
|
114
|
+
return withProcessing ? val.toLowerCase() : val;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
function onFocus() {
|