adata-ui 2.1.40-beta.3 → 2.1.40-beta.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.
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import * as z from 'zod'
|
|
3
3
|
import { useUIValidation } from '#adata-ui/composables/useUIValidation'
|
|
4
|
+
import AButtonV2 from '#adata-ui/components/elements/button/AButtonV2.vue'
|
|
4
5
|
|
|
5
|
-
const props = defineProps<{
|
|
6
|
+
const props = withDefaults(defineProps<{
|
|
6
7
|
isError?: boolean,
|
|
7
8
|
errorText?: string
|
|
8
|
-
}>()
|
|
9
|
+
}>(), {
|
|
10
|
+
isError: false,
|
|
11
|
+
errorText: '',
|
|
12
|
+
})
|
|
9
13
|
|
|
10
14
|
const emit = defineEmits<{
|
|
15
|
+
(e: 'onCancel'): void
|
|
11
16
|
(e: 'onSubmit'): void
|
|
12
17
|
}>()
|
|
13
18
|
|
|
@@ -30,6 +35,12 @@ const { validation, getError } = useUIValidation(
|
|
|
30
35
|
submitted,
|
|
31
36
|
)
|
|
32
37
|
|
|
38
|
+
function onCancel() {
|
|
39
|
+
submitted.value = false
|
|
40
|
+
note.value = ''
|
|
41
|
+
emit('onCancel')
|
|
42
|
+
}
|
|
43
|
+
|
|
33
44
|
async function onSubmit() {
|
|
34
45
|
submitted.value = true
|
|
35
46
|
if (validation.value) return
|
|
@@ -48,31 +59,41 @@ defineExpose({
|
|
|
48
59
|
</p>
|
|
49
60
|
<a-textarea
|
|
50
61
|
v-model="note"
|
|
62
|
+
class="min-h-[120px]"
|
|
63
|
+
color-classes="bg-deepblue-900/5 outline outline-1 outline-gray-200 dark:outline-gray-600 dark:bg-gray-200/5 !rounded-[10px]"
|
|
64
|
+
size="sm"
|
|
65
|
+
resizeable="y"
|
|
51
66
|
:label="t('forms.leaveNote.placeholder')"
|
|
52
67
|
:error="getError('note')"
|
|
53
|
-
class="mb-2 min-h-[120px]"
|
|
54
|
-
resizeable="none"
|
|
55
|
-
clearable
|
|
56
|
-
required
|
|
57
68
|
>
|
|
58
69
|
<template #alert>
|
|
59
70
|
<a-alert
|
|
60
|
-
v-if="isError
|
|
71
|
+
v-if="isError"
|
|
61
72
|
color="red"
|
|
62
73
|
class="mt-1"
|
|
63
74
|
>
|
|
64
|
-
{{
|
|
75
|
+
{{ isError ? (!!errorText ? errorText : t('forms.leaveNote.limit')) : '' }}
|
|
65
76
|
</a-alert>
|
|
66
77
|
</template>
|
|
67
78
|
</a-textarea>
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
<div class="mt-2 flex w-full justify-end items-center gap-2 md:gap-[10px]">
|
|
80
|
+
<a-button-v2
|
|
81
|
+
class="w-full sm:w-auto"
|
|
82
|
+
view="outline"
|
|
83
|
+
size="md"
|
|
84
|
+
@click="onCancel"
|
|
85
|
+
>
|
|
86
|
+
{{ t('actions.cancel') }}
|
|
87
|
+
</a-button-v2>
|
|
88
|
+
<a-button-v2
|
|
89
|
+
:disabled="!note.trim() && isLoading"
|
|
90
|
+
class="w-full sm:w-auto"
|
|
91
|
+
size="md"
|
|
92
|
+
:loading="isLoading"
|
|
93
|
+
@click="onSubmit"
|
|
94
|
+
>
|
|
95
|
+
{{ t('actions.send') }}
|
|
96
|
+
</a-button-v2>
|
|
97
|
+
</div>
|
|
77
98
|
</div>
|
|
78
99
|
</template>
|
|
@@ -18,6 +18,8 @@ interface Props {
|
|
|
18
18
|
fontSize?: number;
|
|
19
19
|
error?: string | boolean;
|
|
20
20
|
errorSize?: 'sm' | 'lg';
|
|
21
|
+
hideValue?: boolean;
|
|
22
|
+
hideEmptyStars?: boolean;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -32,7 +34,9 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
32
34
|
ratingPlacement: 'left',
|
|
33
35
|
fontSize: 14,
|
|
34
36
|
error: false,
|
|
35
|
-
errorSize: 'lg'
|
|
37
|
+
errorSize: 'lg',
|
|
38
|
+
hideValue: false,
|
|
39
|
+
hideEmptyStars: false
|
|
36
40
|
})
|
|
37
41
|
|
|
38
42
|
const fillLevel = ref<number[]>([])
|
|
@@ -51,6 +55,10 @@ const roundedRating = computed(() => {
|
|
|
51
55
|
})
|
|
52
56
|
const shouldRound = computed(() => ratingSelected.value || props.roundStartRating)
|
|
53
57
|
|
|
58
|
+
const visibleStarsCount = computed(() => {
|
|
59
|
+
if (!props.hideEmptyStars) return props.max
|
|
60
|
+
return Math.min(props.max, Math.max(1, Math.ceil(currentRating.value)))
|
|
61
|
+
})
|
|
54
62
|
|
|
55
63
|
watch(modelValue, (e)=>{
|
|
56
64
|
currentRating.value = e
|
|
@@ -105,7 +113,7 @@ createStars(shouldRound.value)
|
|
|
105
113
|
<div>
|
|
106
114
|
<div class="w-full flex items-center gap-2">
|
|
107
115
|
<span
|
|
108
|
-
v-if="ratingPlacement === 'left'"
|
|
116
|
+
v-if="ratingPlacement === 'left' && !hideValue"
|
|
109
117
|
class="text-gray-600 dark:text-gray-300 mt-px"
|
|
110
118
|
:style="{fontSize: `${fontSize}px`}"
|
|
111
119
|
>
|
|
@@ -118,7 +126,7 @@ createStars(shouldRound.value)
|
|
|
118
126
|
@mouseleave="resetRating"
|
|
119
127
|
>
|
|
120
128
|
<star
|
|
121
|
-
v-for="n in
|
|
129
|
+
v-for="n in visibleStarsCount"
|
|
122
130
|
:key="n"
|
|
123
131
|
:fill="fillLevel[n-1]"
|
|
124
132
|
:size="starSize"
|
|
@@ -127,7 +135,7 @@ createStars(shouldRound.value)
|
|
|
127
135
|
/>
|
|
128
136
|
</div>
|
|
129
137
|
<span
|
|
130
|
-
v-if="ratingPlacement === 'right'"
|
|
138
|
+
v-if="ratingPlacement === 'right' && !hideValue"
|
|
131
139
|
class="text-sm text-gray-600 dark:text-gray-300 mt-px"
|
|
132
140
|
>
|
|
133
141
|
{{ modelValue }}
|
package/lang/en.ts
CHANGED
|
@@ -470,7 +470,7 @@ const EnLocale: RuLocale = {
|
|
|
470
470
|
},
|
|
471
471
|
leaveNote: {
|
|
472
472
|
title: 'Leave a note',
|
|
473
|
-
placeholder: '
|
|
473
|
+
placeholder: 'Your note',
|
|
474
474
|
limit: 'The limit on notes for this company by you has expired',
|
|
475
475
|
errors: {
|
|
476
476
|
required: 'This field is required',
|
package/lang/kk.ts
CHANGED
|
@@ -471,7 +471,7 @@ const KkLocale: RuLocale = {
|
|
|
471
471
|
},
|
|
472
472
|
leaveNote: {
|
|
473
473
|
title: 'Ескертпе қалдыру',
|
|
474
|
-
placeholder: '
|
|
474
|
+
placeholder: 'Сіздің жазбаңыз',
|
|
475
475
|
limit: 'Сіз осы компанияға арналған жазбалар лимитін тауысып қойдыңыз',
|
|
476
476
|
errors: {
|
|
477
477
|
required: 'Бұл өріс міндетті',
|
package/lang/ru.ts
CHANGED
|
@@ -471,7 +471,7 @@ const RuLocale = {
|
|
|
471
471
|
},
|
|
472
472
|
leaveNote: {
|
|
473
473
|
title: 'Оставить заметку',
|
|
474
|
-
placeholder: '
|
|
474
|
+
placeholder: 'Ваша заметка',
|
|
475
475
|
limit: 'Лимит на заметки для этой компании, установленный вами, истек',
|
|
476
476
|
errors: {
|
|
477
477
|
required: 'Обязательное поле',
|