@finema/core 2.18.3 → 2.20.0
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/README.md +79 -79
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/DevToolsWindow/index.vue +98 -95
- package/dist/runtime/components/Dialog/index.vue +20 -19
- package/dist/runtime/components/Form/FieldWrapper.vue +13 -13
- package/dist/runtime/components/Form/Fields.vue +5 -0
- package/dist/runtime/components/Form/InputCheckbox/index.vue +18 -18
- package/dist/runtime/components/Form/InputNumber/index.vue +20 -20
- package/dist/runtime/components/Form/InputSearch/index.vue +79 -0
- package/dist/runtime/components/Form/InputSearch/index.vue.d.ts +13 -0
- package/dist/runtime/components/Form/InputSearch/types.d.ts +16 -0
- package/dist/runtime/components/Form/InputSearch/types.js +0 -0
- package/dist/runtime/components/Form/InputSelectMultiple/index.vue +43 -43
- package/dist/runtime/components/Form/InputText/index.vue +216 -79
- package/dist/runtime/components/Form/InputText/types.d.ts +1 -0
- package/dist/runtime/components/Form/InputTextarea/index.vue +18 -18
- package/dist/runtime/components/Form/InputToggle/index.vue +17 -17
- package/dist/runtime/components/Form/InputUploadDropzoneAuto/EmptyState.vue +4 -4
- package/dist/runtime/components/Form/InputUploadDropzoneAuto/FailedState.vue +7 -7
- package/dist/runtime/components/Form/InputUploadDropzoneAuto/LoadingState.vue +5 -5
- package/dist/runtime/components/Form/InputUploadDropzoneAuto/SuccessState.vue +7 -7
- package/dist/runtime/components/Form/index.vue +5 -5
- package/dist/runtime/components/Form/types.d.ts +3 -1
- package/dist/runtime/components/Form/types.js +1 -0
- package/dist/runtime/components/Image.vue +28 -28
- package/dist/runtime/components/Log/index.vue +17 -17
- package/dist/runtime/components/Table/Base.vue +1 -1
- package/dist/runtime/components/Table/ColumnDate.vue +1 -1
- package/dist/runtime/components/Table/ColumnDateTime.vue +1 -1
- package/dist/runtime/components/Table/ColumnImage.vue +4 -4
- package/dist/runtime/components/Table/ColumnNumber.vue +1 -1
- package/dist/runtime/components/Table/ColumnText.vue +1 -1
- package/dist/runtime/components/Table/index.vue +3 -1
- package/dist/runtime/composables/useConfig.d.ts +2 -2
- package/dist/runtime/composables/useConfig.js +4 -4
- package/dist/runtime/server/tsconfig.json +3 -3
- package/dist/runtime/styles/main.css +1 -1
- package/dist/runtime/theme/dialog.d.ts +6 -4
- package/dist/runtime/theme/dialog.js +7 -5
- package/dist/runtime/theme/input.d.ts +3 -0
- package/dist/runtime/theme/input.js +4 -1
- package/dist/runtime/theme/uploadFileDropzone.d.ts +11 -9
- package/dist/runtime/theme/uploadFileDropzone.js +11 -9
- package/package.json +3 -7
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
+
<Input
|
|
4
|
+
:model-value="value"
|
|
5
|
+
:disabled="wrapperProps.disabled"
|
|
6
|
+
:leading-icon="leadingIcon || searchIcon || 'i-heroicons-magnifying-glass'"
|
|
7
|
+
:trailing-icon="trailingIcon"
|
|
8
|
+
:loading="loading"
|
|
9
|
+
:loading-icon="loadingIcon"
|
|
10
|
+
:name="name"
|
|
11
|
+
:placeholder="wrapperProps.placeholder || 'Search...'"
|
|
12
|
+
type="text"
|
|
13
|
+
:autofocus="!!autoFocus"
|
|
14
|
+
:icon="icon"
|
|
15
|
+
:readonly="readonly"
|
|
16
|
+
:ui="ui"
|
|
17
|
+
@update:model-value="onInput"
|
|
18
|
+
>
|
|
19
|
+
<template #trailing>
|
|
20
|
+
<Button
|
|
21
|
+
v-if="clearable && value && value.length > 0"
|
|
22
|
+
color="neutral"
|
|
23
|
+
class="p-0"
|
|
24
|
+
variant="link"
|
|
25
|
+
:icon="clearIcon || 'i-heroicons-x-mark'"
|
|
26
|
+
:padded="false"
|
|
27
|
+
title="ล้างการค้นหา"
|
|
28
|
+
@click="onClear"
|
|
29
|
+
/>
|
|
30
|
+
</template>
|
|
31
|
+
</Input>
|
|
32
|
+
</FieldWrapper>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script setup>
|
|
36
|
+
import { useFieldHOC } from "#core/composables/useForm";
|
|
37
|
+
import FieldWrapper from "#core/components/Form/FieldWrapper.vue";
|
|
38
|
+
const emits = defineEmits(["change", "search", "clear"]);
|
|
39
|
+
const props = defineProps({
|
|
40
|
+
leadingIcon: { type: null, required: false },
|
|
41
|
+
trailingIcon: { type: null, required: false },
|
|
42
|
+
loading: { type: Boolean, required: false },
|
|
43
|
+
loadingIcon: { type: null, required: false },
|
|
44
|
+
icon: { type: String, required: false },
|
|
45
|
+
clearable: { type: Boolean, required: false, default: true },
|
|
46
|
+
clearIcon: { type: String, required: false },
|
|
47
|
+
searchIcon: { type: String, required: false },
|
|
48
|
+
form: { type: Object, required: false },
|
|
49
|
+
name: { type: String, required: true },
|
|
50
|
+
errorMessage: { type: String, required: false },
|
|
51
|
+
label: { type: null, required: false },
|
|
52
|
+
description: { type: String, required: false },
|
|
53
|
+
hint: { type: String, required: false },
|
|
54
|
+
rules: { type: null, required: false },
|
|
55
|
+
autoFocus: { type: Boolean, required: false },
|
|
56
|
+
placeholder: { type: String, required: false },
|
|
57
|
+
disabled: { type: Boolean, required: false },
|
|
58
|
+
readonly: { type: Boolean, required: false },
|
|
59
|
+
required: { type: Boolean, required: false },
|
|
60
|
+
help: { type: String, required: false },
|
|
61
|
+
ui: { type: null, required: false }
|
|
62
|
+
});
|
|
63
|
+
const {
|
|
64
|
+
value,
|
|
65
|
+
wrapperProps,
|
|
66
|
+
handleChange
|
|
67
|
+
} = useFieldHOC(props);
|
|
68
|
+
const onInput = (newValue) => {
|
|
69
|
+
handleChange(newValue);
|
|
70
|
+
emits("change", newValue);
|
|
71
|
+
emits("search", newValue);
|
|
72
|
+
};
|
|
73
|
+
const onClear = () => {
|
|
74
|
+
handleChange("");
|
|
75
|
+
emits("change", "");
|
|
76
|
+
emits("clear");
|
|
77
|
+
emits("search", "");
|
|
78
|
+
};
|
|
79
|
+
</script>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ISearchFieldProps } from '#core/components/Form/InputSearch/types';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<ISearchFieldProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
3
|
+
search: (...args: any[]) => void;
|
|
4
|
+
clear: (...args: any[]) => void;
|
|
5
|
+
change: (...args: any[]) => void;
|
|
6
|
+
}, string, import("vue").PublicProps, Readonly<ISearchFieldProps> & Readonly<{
|
|
7
|
+
onSearch?: ((...args: any[]) => any) | undefined;
|
|
8
|
+
onClear?: ((...args: any[]) => any) | undefined;
|
|
9
|
+
onChange?: ((...args: any[]) => any) | undefined;
|
|
10
|
+
}>, {
|
|
11
|
+
clearable: boolean;
|
|
12
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IFieldProps, IFormFieldBase, INPUT_TYPES } from '#core/components/Form/types';
|
|
2
|
+
export interface ISearchFieldProps extends IFieldProps {
|
|
3
|
+
leadingIcon?: any;
|
|
4
|
+
trailingIcon?: any;
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
loadingIcon?: any;
|
|
7
|
+
icon?: string;
|
|
8
|
+
clearable?: boolean;
|
|
9
|
+
clearIcon?: string;
|
|
10
|
+
searchIcon?: string;
|
|
11
|
+
}
|
|
12
|
+
export type ISearchField = IFormFieldBase<INPUT_TYPES.SEARCH, ISearchFieldProps, {
|
|
13
|
+
change?: (value: string) => void;
|
|
14
|
+
search?: (value: string) => void;
|
|
15
|
+
clear?: () => void;
|
|
16
|
+
}>;
|
|
File without changes
|
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
-
<SelectMenu
|
|
4
|
-
:model-value="value"
|
|
5
|
-
:items="options"
|
|
6
|
-
multiple
|
|
7
|
-
:placeholder="wrapperProps.placeholder"
|
|
8
|
-
:disabled="wrapperProps.disabled"
|
|
9
|
-
:loading="loading"
|
|
10
|
-
:search-input="searchInput"
|
|
11
|
-
:selected-icon="selectedIcon"
|
|
12
|
-
value-key="value"
|
|
13
|
-
label-key="label"
|
|
14
|
-
:icon="icon"
|
|
15
|
-
:ui="ui"
|
|
16
|
-
:ignore-filter="!!$attrs.onSearch"
|
|
17
|
-
@update:model-value="onChange"
|
|
18
|
-
@update:searchTerm="onSearch"
|
|
19
|
-
>
|
|
20
|
-
<template #default="{ modelValue }">
|
|
21
|
-
<div
|
|
22
|
-
v-if="!ArrayHelper.isEmpty(value)"
|
|
2
|
+
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
+
<SelectMenu
|
|
4
|
+
:model-value="value"
|
|
5
|
+
:items="options"
|
|
6
|
+
multiple
|
|
7
|
+
:placeholder="wrapperProps.placeholder"
|
|
8
|
+
:disabled="wrapperProps.disabled"
|
|
9
|
+
:loading="loading"
|
|
10
|
+
:search-input="searchInput"
|
|
11
|
+
:selected-icon="selectedIcon"
|
|
12
|
+
value-key="value"
|
|
13
|
+
label-key="label"
|
|
14
|
+
:icon="icon"
|
|
15
|
+
:ui="ui"
|
|
16
|
+
:ignore-filter="!!$attrs.onSearch"
|
|
17
|
+
@update:model-value="onChange"
|
|
18
|
+
@update:searchTerm="onSearch"
|
|
19
|
+
>
|
|
20
|
+
<template #default="{ modelValue }">
|
|
21
|
+
<div
|
|
22
|
+
v-if="!ArrayHelper.isEmpty(value)"
|
|
23
23
|
:class="theme.tagsWrapper({
|
|
24
24
|
class: [ui?.tagsWrapper]
|
|
25
|
-
})"
|
|
26
|
-
>
|
|
27
|
-
<div
|
|
28
|
-
v-for="_value in ArrayHelper.toArray(modelValue)"
|
|
29
|
-
:key="_value"
|
|
25
|
+
})"
|
|
26
|
+
>
|
|
27
|
+
<div
|
|
28
|
+
v-for="_value in ArrayHelper.toArray(modelValue)"
|
|
29
|
+
:key="_value"
|
|
30
30
|
:class="theme.tagsItem({
|
|
31
31
|
class: [ui?.tagsItem]
|
|
32
|
-
})"
|
|
33
|
-
>
|
|
34
|
-
<div
|
|
32
|
+
})"
|
|
33
|
+
>
|
|
34
|
+
<div
|
|
35
35
|
:class="theme.tagsItemText({
|
|
36
36
|
class: [ui?.tagsItemText]
|
|
37
|
-
})"
|
|
38
|
-
>
|
|
39
|
-
{{ options.find((item) => item.value === _value)?.label || _value }}
|
|
40
|
-
<Icon
|
|
37
|
+
})"
|
|
38
|
+
>
|
|
39
|
+
{{ options.find((item) => item.value === _value)?.label || _value }}
|
|
40
|
+
<Icon
|
|
41
41
|
:name="theme.tagsItemDeleteIcon({
|
|
42
42
|
class: [ui?.tagsItemDeleteIcon]
|
|
43
|
-
})"
|
|
43
|
+
})"
|
|
44
44
|
:class="theme.tagsItemDelete({
|
|
45
45
|
class: [ui?.tagsItemDelete]
|
|
46
|
-
})"
|
|
47
|
-
@click.stop="handleDelete(_value)"
|
|
48
|
-
/>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
</div>
|
|
52
|
-
</template>
|
|
53
|
-
</SelectMenu>
|
|
54
|
-
</FieldWrapper>
|
|
46
|
+
})"
|
|
47
|
+
@click.stop="handleDelete(_value)"
|
|
48
|
+
/>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</template>
|
|
53
|
+
</SelectMenu>
|
|
54
|
+
</FieldWrapper>
|
|
55
55
|
</template>
|
|
56
56
|
|
|
57
57
|
<script setup>
|
|
@@ -1,60 +1,90 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
2
|
+
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
+
<div class="relative">
|
|
4
|
+
<Input
|
|
5
|
+
v-if="type === 'password'"
|
|
6
|
+
ref="inputRef"
|
|
7
|
+
v-maska="activeMaskOptions"
|
|
8
|
+
:model-value="value"
|
|
9
|
+
:disabled="wrapperProps.disabled"
|
|
10
|
+
:leading-icon="leadingIcon"
|
|
11
|
+
:trailing-icon="trailingIcon"
|
|
12
|
+
:loading="loading"
|
|
13
|
+
:loading-icon="loadingIcon"
|
|
14
|
+
:name="name"
|
|
15
|
+
:placeholder="wrapperProps.placeholder"
|
|
16
|
+
:type="isShowPassword ? 'text' : 'password'"
|
|
17
|
+
:autofocus="!!autoFocus"
|
|
18
|
+
:icon="icon"
|
|
19
|
+
:readonly="readonly"
|
|
20
|
+
:ui="defu(ui, { icon: { trailing: { pointer: '' } } })"
|
|
21
|
+
@update:model-value="onChange"
|
|
22
|
+
@focus="onFocus"
|
|
23
|
+
@blur="onBlur"
|
|
24
|
+
@keydown="onKeydown"
|
|
25
|
+
>
|
|
26
|
+
<template #trailing>
|
|
27
|
+
<Button
|
|
28
|
+
color="neutral"
|
|
29
|
+
variant="link"
|
|
30
|
+
:icon="isShowPassword ? 'i-heroicons-eye-slash' : 'i-heroicons-eye'"
|
|
31
|
+
:padded="false"
|
|
32
|
+
@click="isShowPassword = !isShowPassword"
|
|
33
|
+
/>
|
|
34
|
+
</template>
|
|
35
|
+
</Input>
|
|
36
|
+
<Input
|
|
37
|
+
v-else
|
|
38
|
+
ref="inputRef"
|
|
39
|
+
v-maska="activeMaskOptions"
|
|
40
|
+
:model-value="value"
|
|
41
|
+
:disabled="wrapperProps.disabled"
|
|
42
|
+
:leading-icon="leadingIcon"
|
|
43
|
+
:trailing-icon="trailingIcon"
|
|
44
|
+
:loading="loading"
|
|
45
|
+
:loading-icon="loadingIcon"
|
|
46
|
+
:name="name"
|
|
47
|
+
:placeholder="wrapperProps.placeholder"
|
|
48
|
+
:type="type"
|
|
49
|
+
:autofocus="!!autoFocus"
|
|
50
|
+
:icon="icon"
|
|
51
|
+
:readonly="readonly"
|
|
52
|
+
:ui="ui"
|
|
53
|
+
@update:model-value="onChange"
|
|
54
|
+
@focus="onFocus"
|
|
55
|
+
@blur="onBlur"
|
|
56
|
+
@keydown="onKeydown"
|
|
57
|
+
/>
|
|
58
|
+
<div
|
|
59
|
+
v-if="showSuggestions && filteredSuggestions.length > 0"
|
|
60
|
+
ref="suggestionsContainerRef"
|
|
61
|
+
:class="theme.suggestionsContainer()"
|
|
62
|
+
>
|
|
63
|
+
<div
|
|
64
|
+
v-for="(suggestion, index) in filteredSuggestions"
|
|
65
|
+
:key="suggestion"
|
|
66
|
+
:ref="(el) => setSuggestionItemRef(el, index)"
|
|
67
|
+
:class="[
|
|
68
|
+
theme.suggestionItem(),
|
|
69
|
+
{ [theme.suggestionItemActive()]: index === selectedSuggestionIndex }
|
|
70
|
+
]"
|
|
71
|
+
@mousedown.prevent="selectSuggestion(suggestion, index)"
|
|
72
|
+
@mouseenter="selectedSuggestionIndex = index"
|
|
73
|
+
>
|
|
74
|
+
{{ suggestion }}
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
</FieldWrapper>
|
|
50
79
|
</template>
|
|
51
80
|
|
|
52
81
|
<script setup>
|
|
53
82
|
import { vMaska } from "maska/vue";
|
|
54
83
|
import { defu } from "defu";
|
|
55
|
-
import { ref, computed } from "#imports";
|
|
84
|
+
import { ref, computed, nextTick, useUiConfig } from "#imports";
|
|
56
85
|
import { useFieldHOC } from "#core/composables/useForm";
|
|
57
86
|
import FieldWrapper from "#core/components/Form/FieldWrapper.vue";
|
|
87
|
+
import { inputTheme } from "#core/theme/input";
|
|
58
88
|
const emits = defineEmits(["change"]);
|
|
59
89
|
const props = defineProps({
|
|
60
90
|
type: { type: String, required: false, default: "text" },
|
|
@@ -69,6 +99,7 @@ const props = defineProps({
|
|
|
69
99
|
maskEager: { type: Boolean, required: false },
|
|
70
100
|
maskTokensReplace: { type: Boolean, required: false },
|
|
71
101
|
maskReversed: { type: Boolean, required: false },
|
|
102
|
+
suggestions: { type: Array, required: false },
|
|
72
103
|
form: { type: Object, required: false },
|
|
73
104
|
name: { type: String, required: true },
|
|
74
105
|
errorMessage: { type: String, required: false },
|
|
@@ -84,52 +115,158 @@ const props = defineProps({
|
|
|
84
115
|
help: { type: String, required: false },
|
|
85
116
|
ui: { type: null, required: false }
|
|
86
117
|
});
|
|
118
|
+
const theme = computed(() => useUiConfig(inputTheme, "input")());
|
|
87
119
|
const {
|
|
88
120
|
value,
|
|
89
121
|
wrapperProps,
|
|
90
122
|
handleChange
|
|
91
123
|
} = useFieldHOC(props);
|
|
92
124
|
const isShowPassword = ref(false);
|
|
125
|
+
const inputRef = ref();
|
|
126
|
+
const showSuggestions = ref(false);
|
|
127
|
+
const selectedSuggestionIndex = ref(-1);
|
|
128
|
+
const suggestionsContainerRef = ref();
|
|
129
|
+
const suggestionItemRefs = ref([]);
|
|
130
|
+
const setSuggestionItemRef = (el, index) => {
|
|
131
|
+
if (suggestionItemRefs.value) {
|
|
132
|
+
suggestionItemRefs.value[index] = el;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
93
135
|
const onChange = (value2) => {
|
|
136
|
+
if (props.suggestions && props.suggestions.length > 0) {
|
|
137
|
+
showSuggestions.value = true;
|
|
138
|
+
selectedSuggestionIndex.value = -1;
|
|
139
|
+
}
|
|
94
140
|
handleChange(value2);
|
|
95
141
|
emits("change", value2);
|
|
96
142
|
};
|
|
97
|
-
const
|
|
98
|
-
if (props.
|
|
99
|
-
|
|
100
|
-
return props.maskOptions.mask;
|
|
101
|
-
}
|
|
102
|
-
return props.maskOptions;
|
|
143
|
+
const filteredSuggestions = computed(() => {
|
|
144
|
+
if (!props.suggestions || !value.value) {
|
|
145
|
+
return props.suggestions || [];
|
|
103
146
|
}
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
147
|
+
const inputValue = value.value.toLowerCase();
|
|
148
|
+
return props.suggestions.filter(
|
|
149
|
+
(suggestion) => suggestion.toLowerCase().includes(inputValue)
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
const onFocus = () => {
|
|
153
|
+
if (props.suggestions && props.suggestions.length > 0) {
|
|
154
|
+
showSuggestions.value = true;
|
|
155
|
+
selectedSuggestionIndex.value = -1;
|
|
109
156
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
157
|
+
};
|
|
158
|
+
const onBlur = (event) => {
|
|
159
|
+
setTimeout(() => {
|
|
160
|
+
showSuggestions.value = false;
|
|
161
|
+
selectedSuggestionIndex.value = -1;
|
|
162
|
+
}, 150);
|
|
163
|
+
};
|
|
164
|
+
const onKeydown = (event) => {
|
|
165
|
+
if (!showSuggestions.value || filteredSuggestions.value.length === 0) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
switch (event.key) {
|
|
169
|
+
case "ArrowDown":
|
|
170
|
+
event.preventDefault();
|
|
171
|
+
selectedSuggestionIndex.value = selectedSuggestionIndex.value < filteredSuggestions.value.length - 1 ? selectedSuggestionIndex.value + 1 : 0;
|
|
172
|
+
scrollToSelectedSuggestion();
|
|
173
|
+
break;
|
|
174
|
+
case "ArrowUp":
|
|
175
|
+
event.preventDefault();
|
|
176
|
+
selectedSuggestionIndex.value = selectedSuggestionIndex.value > 0 ? selectedSuggestionIndex.value - 1 : filteredSuggestions.value.length - 1;
|
|
177
|
+
scrollToSelectedSuggestion();
|
|
178
|
+
break;
|
|
179
|
+
case "Enter":
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
if (selectedSuggestionIndex.value >= 0) {
|
|
182
|
+
selectSuggestion(filteredSuggestions.value[selectedSuggestionIndex.value], selectedSuggestionIndex.value);
|
|
183
|
+
}
|
|
184
|
+
break;
|
|
185
|
+
case "Escape":
|
|
186
|
+
showSuggestions.value = false;
|
|
187
|
+
selectedSuggestionIndex.value = -1;
|
|
188
|
+
break;
|
|
113
189
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
190
|
+
};
|
|
191
|
+
const selectSuggestion = (suggestion, index) => {
|
|
192
|
+
if (index !== void 0) {
|
|
193
|
+
scrollToSuggestionByIndex(index);
|
|
117
194
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
195
|
+
handleChange(suggestion);
|
|
196
|
+
emits("change", suggestion);
|
|
197
|
+
showSuggestions.value = false;
|
|
198
|
+
selectedSuggestionIndex.value = -1;
|
|
199
|
+
nextTick(() => {
|
|
200
|
+
if (inputRef.value) {
|
|
201
|
+
inputRef.value.$el.querySelector("input")?.focus();
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
const scrollToSelectedSuggestion = () => {
|
|
206
|
+
nextTick(() => {
|
|
207
|
+
if (selectedSuggestionIndex.value >= 0) {
|
|
208
|
+
scrollToSuggestionByIndex(selectedSuggestionIndex.value);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
const scrollToSuggestionByIndex = (index) => {
|
|
213
|
+
if (!suggestionsContainerRef.value || !suggestionItemRefs.value[index]) {
|
|
214
|
+
return;
|
|
121
215
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
216
|
+
const container = suggestionsContainerRef.value;
|
|
217
|
+
const item = suggestionItemRefs.value[index];
|
|
218
|
+
if (item) {
|
|
219
|
+
const containerRect = container.getBoundingClientRect();
|
|
220
|
+
const itemRect = item.getBoundingClientRect();
|
|
221
|
+
const isAboveView = itemRect.top < containerRect.top;
|
|
222
|
+
const isBelowView = itemRect.bottom > containerRect.bottom;
|
|
223
|
+
if (isAboveView || isBelowView) {
|
|
224
|
+
item.scrollIntoView({
|
|
225
|
+
behavior: "smooth",
|
|
226
|
+
block: "nearest",
|
|
227
|
+
inline: "nearest"
|
|
228
|
+
});
|
|
229
|
+
}
|
|
125
230
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
231
|
+
};
|
|
232
|
+
const activeMaskOptions = computed(
|
|
233
|
+
() => {
|
|
234
|
+
if (props.maskOptions && Object.keys(props.maskOptions).length > 0) {
|
|
235
|
+
if (typeof props.maskOptions.mask === "string" && Object.keys(props.maskOptions).length === 1) {
|
|
236
|
+
return props.maskOptions.mask;
|
|
237
|
+
}
|
|
238
|
+
return props.maskOptions;
|
|
239
|
+
}
|
|
240
|
+
const options = {};
|
|
241
|
+
let hasIndividualProps = false;
|
|
242
|
+
if (props.mask !== void 0) {
|
|
243
|
+
options.mask = props.mask;
|
|
244
|
+
hasIndividualProps = true;
|
|
245
|
+
}
|
|
246
|
+
if (props.maskTokens !== void 0) {
|
|
247
|
+
options.tokens = props.maskTokens;
|
|
248
|
+
hasIndividualProps = true;
|
|
130
249
|
}
|
|
131
|
-
|
|
250
|
+
if (props.maskEager !== void 0) {
|
|
251
|
+
options.eager = props.maskEager;
|
|
252
|
+
hasIndividualProps = true;
|
|
253
|
+
}
|
|
254
|
+
if (props.maskReversed !== void 0) {
|
|
255
|
+
options.reversed = props.maskReversed;
|
|
256
|
+
hasIndividualProps = true;
|
|
257
|
+
}
|
|
258
|
+
if (props.maskTokensReplace !== void 0) {
|
|
259
|
+
options.tokensReplace = props.maskTokensReplace;
|
|
260
|
+
hasIndividualProps = true;
|
|
261
|
+
}
|
|
262
|
+
if (hasIndividualProps) {
|
|
263
|
+
const keys = Object.keys(options);
|
|
264
|
+
if (keys.length === 1 && keys[0] === "mask" && typeof options.mask === "string") {
|
|
265
|
+
return options.mask;
|
|
266
|
+
}
|
|
267
|
+
return options;
|
|
268
|
+
}
|
|
269
|
+
return void 0;
|
|
132
270
|
}
|
|
133
|
-
|
|
134
|
-
});
|
|
271
|
+
);
|
|
135
272
|
</script>
|
|
@@ -13,6 +13,7 @@ export interface ITextFieldProps extends IFieldProps {
|
|
|
13
13
|
maskEager?: boolean;
|
|
14
14
|
maskTokensReplace?: boolean;
|
|
15
15
|
maskReversed?: boolean;
|
|
16
|
+
suggestions?: string[];
|
|
16
17
|
}
|
|
17
18
|
export type ITextField = IFormFieldBase<INPUT_TYPES.TEXT | INPUT_TYPES.PASSWORD | INPUT_TYPES.EMAIL, ITextFieldProps, {
|
|
18
19
|
change?: (value: string) => void;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
-
<Textarea
|
|
4
|
-
:model-value="value"
|
|
5
|
-
:disabled="wrapperProps.disabled"
|
|
6
|
-
:name="name"
|
|
7
|
-
:resize="resize"
|
|
8
|
-
:placeholder="wrapperProps.placeholder"
|
|
9
|
-
:autofocus="!!autoFocus"
|
|
10
|
-
:autoresize="autoresize"
|
|
11
|
-
:rows="rows"
|
|
12
|
-
:maxrows="maxrows"
|
|
13
|
-
:loading="loading"
|
|
14
|
-
:loading-icon="loadingIcon"
|
|
15
|
-
:readonly="readonly"
|
|
16
|
-
:ui="ui"
|
|
17
|
-
@update:model-value="onChange"
|
|
18
|
-
/>
|
|
19
|
-
</FieldWrapper>
|
|
2
|
+
<FieldWrapper v-bind="wrapperProps">
|
|
3
|
+
<Textarea
|
|
4
|
+
:model-value="value"
|
|
5
|
+
:disabled="wrapperProps.disabled"
|
|
6
|
+
:name="name"
|
|
7
|
+
:resize="resize"
|
|
8
|
+
:placeholder="wrapperProps.placeholder"
|
|
9
|
+
:autofocus="!!autoFocus"
|
|
10
|
+
:autoresize="autoresize"
|
|
11
|
+
:rows="rows"
|
|
12
|
+
:maxrows="maxrows"
|
|
13
|
+
:loading="loading"
|
|
14
|
+
:loading-icon="loadingIcon"
|
|
15
|
+
:readonly="readonly"
|
|
16
|
+
:ui="ui"
|
|
17
|
+
@update:model-value="onChange"
|
|
18
|
+
/>
|
|
19
|
+
</FieldWrapper>
|
|
20
20
|
</template>
|
|
21
21
|
|
|
22
22
|
<script setup>
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<FieldWrapper
|
|
3
|
-
v-bind="wrapperProps"
|
|
4
|
-
label=""
|
|
5
|
-
description=""
|
|
6
|
-
>
|
|
7
|
-
<Switch
|
|
8
|
-
:model-value="value"
|
|
9
|
-
:disabled="wrapperProps.disabled"
|
|
10
|
-
:name="name"
|
|
11
|
-
:ui="ui"
|
|
12
|
-
:label="label"
|
|
13
|
-
:description="description"
|
|
14
|
-
:loading="loading"
|
|
15
|
-
:loading-icon="loadingIcon"
|
|
16
|
-
@update:modelValue="onChange"
|
|
17
|
-
/>
|
|
18
|
-
</FieldWrapper>
|
|
2
|
+
<FieldWrapper
|
|
3
|
+
v-bind="wrapperProps"
|
|
4
|
+
label=""
|
|
5
|
+
description=""
|
|
6
|
+
>
|
|
7
|
+
<Switch
|
|
8
|
+
:model-value="value"
|
|
9
|
+
:disabled="wrapperProps.disabled"
|
|
10
|
+
:name="name"
|
|
11
|
+
:ui="ui"
|
|
12
|
+
:label="label"
|
|
13
|
+
:description="description"
|
|
14
|
+
:loading="loading"
|
|
15
|
+
:loading-icon="loadingIcon"
|
|
16
|
+
@update:modelValue="onChange"
|
|
17
|
+
/>
|
|
18
|
+
</FieldWrapper>
|
|
19
19
|
</template>
|
|
20
20
|
|
|
21
21
|
<script setup>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :class="theme.placeholderWrapper()">
|
|
3
3
|
<Icon
|
|
4
|
-
:name="
|
|
4
|
+
:name="icons.uploadIcon"
|
|
5
5
|
:class="theme.labelIcon()"
|
|
6
6
|
/>
|
|
7
7
|
<div :class="theme.labelWrapper()">
|
|
8
8
|
<p
|
|
9
|
-
class="cursor-pointer font-bold
|
|
9
|
+
class="text-primary cursor-pointer font-bold"
|
|
10
10
|
@click="$emit('openFile')"
|
|
11
11
|
>
|
|
12
12
|
{{ selectFileLabel }}
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
</template>
|
|
24
24
|
|
|
25
25
|
<script setup>
|
|
26
|
-
import {
|
|
26
|
+
import { useUiIconConfig } from "#imports";
|
|
27
27
|
defineProps({
|
|
28
28
|
theme: { type: null, required: true },
|
|
29
29
|
selectFileLabel: { type: String, required: true },
|
|
@@ -31,5 +31,5 @@ defineProps({
|
|
|
31
31
|
placeholder: { type: String, required: false }
|
|
32
32
|
});
|
|
33
33
|
defineEmits(["openFile"]);
|
|
34
|
-
const
|
|
34
|
+
const icons = useUiIconConfig("uploadFileDropzone");
|
|
35
35
|
</script>
|