@aslaluroba/help-center-react 3.2.10 → 3.2.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/index.css +1 -1
- package/dist/index.esm.js +308 -163
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +308 -163
- package/dist/index.js.map +1 -1
- package/dist/ui/chatbot-popup/options-list-screen/helpscreen-list.d.ts +1 -0
- package/dist/ui/chatbot-popup/options-list-screen/index.d.ts +1 -0
- package/dist/ui/help-popup.d.ts +3 -1
- package/package.json +1 -1
- package/src/components/ui/agent-response/agent-response.tsx +1 -1
- package/src/globals.css +29 -2
- package/src/locales/ar.json +1 -1
- package/src/locales/en.json +1 -1
- package/src/ui/chatbot-popup/chat-window-screen/in-chat-review.tsx +38 -6
- package/src/ui/chatbot-popup/chat-window-screen/typing-indicator.tsx +8 -4
- package/src/ui/chatbot-popup/options-list-screen/helpscreen-list.tsx +15 -7
- package/src/ui/chatbot-popup/options-list-screen/helpscreen-option.tsx +11 -1
- package/src/ui/chatbot-popup/options-list-screen/index.tsx +3 -0
- package/src/ui/confirmation-modal/index.tsx +34 -30
- package/src/ui/help-center.tsx +24 -6
- package/src/ui/help-popup.tsx +35 -15
- package/src/ui/review-dialog/index.tsx +95 -43
- package/src/ui/review-dialog/rating.tsx +4 -3
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { ReviewProps } from '@/lib/types'
|
|
2
|
+
import { cn } from '@/lib/utils'
|
|
2
3
|
import { Rating } from '@/ui/review-dialog/rating'
|
|
3
4
|
import { useLocalTranslation } from '../../useLocalTranslation'
|
|
4
5
|
import { useState } from 'react';
|
|
5
6
|
import SolarCloseCircleLineDuotone from '~icons/solar/close-circle-line-duotone'
|
|
6
7
|
import { Button } from '@/components';
|
|
8
|
+
import PoweredBy from '../powered-by';
|
|
9
|
+
|
|
10
|
+
const COMMENT_MAX_LENGTH = 500;
|
|
7
11
|
|
|
8
12
|
interface ReviewDialogProps {
|
|
9
13
|
handleSubmit: ({ rating }: ReviewProps) => void;
|
|
@@ -14,25 +18,31 @@ interface ReviewDialogProps {
|
|
|
14
18
|
const ReviewDialog: React.FC<ReviewDialogProps> = (props) => {
|
|
15
19
|
const { t } = useLocalTranslation()
|
|
16
20
|
const [rating, setRating] = useState<number>(0)
|
|
21
|
+
const [comment, setComment] = useState<string>('');
|
|
17
22
|
const [error, setError] = useState<{ comment?: string; rating?: string }>({})
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
const hasRating = rating >= 1 && rating <= 5;
|
|
20
25
|
const isRatingValid = rating >= 1 && rating <= 5
|
|
21
26
|
|
|
22
27
|
const validateAndSubmit = () => {
|
|
23
28
|
const newError: typeof error = {}
|
|
29
|
+
const trimmedComment = comment.trim()
|
|
24
30
|
|
|
25
31
|
if (!isRatingValid) {
|
|
26
32
|
newError.rating = t('homeSdk.ReviewDialog.rating_error') || 'Rating must be between 1 and 5.'
|
|
27
33
|
}
|
|
28
34
|
|
|
35
|
+
if (trimmedComment.length > COMMENT_MAX_LENGTH) {
|
|
36
|
+
newError.comment = t('homeSdk.ReviewDialog.comment_error') || 'The field Comment must be a string with a maximum length of 500.'
|
|
37
|
+
}
|
|
38
|
+
|
|
29
39
|
if (Object.keys(newError).length > 0) {
|
|
30
40
|
setError(newError)
|
|
31
41
|
return
|
|
32
42
|
}
|
|
33
43
|
|
|
34
44
|
setError({})
|
|
35
|
-
props.handleSubmit({ rating })
|
|
45
|
+
props.handleSubmit({ rating, comment: trimmedComment })
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
const handleRatingChange = (val: number) => {
|
|
@@ -42,53 +52,95 @@ const ReviewDialog: React.FC<ReviewDialogProps> = (props) => {
|
|
|
42
52
|
}
|
|
43
53
|
}
|
|
44
54
|
|
|
55
|
+
const handleCommentChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
56
|
+
const value = e.target.value
|
|
57
|
+
setComment(value)
|
|
58
|
+
if (error.comment && value.length <= COMMENT_MAX_LENGTH) {
|
|
59
|
+
setError((prev) => ({ ...prev, comment: undefined }))
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
45
63
|
return (
|
|
46
64
|
<section className="babylai:absolute babylai:inset-0 babylai:z-50 babylai:flex babylai:items-end babylai:rounded-3xl babylai:overflow-hidden">
|
|
47
65
|
<div className='babylai:absolute babylai:inset-0 babylai:bg-black/60' onClick={props.onClose}></div>
|
|
48
|
-
<div className='babylai:flex babylai:flex-col babylai:bg-card babylai:rounded-2xl babylai:
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
>
|
|
53
|
-
<SolarCloseCircleLineDuotone className="babylai:w-6 babylai:h-6" />
|
|
54
|
-
</button>
|
|
55
|
-
|
|
56
|
-
<section className='babylai:flex babylai:items-center babylai:justify-center babylai:border-b babylai:border-black-white-200 babylai:pb-6 babylai:mb-6'>
|
|
57
|
-
<Rating value={rating} onChange={handleRatingChange} size='lg' />
|
|
58
|
-
</section>
|
|
59
|
-
|
|
60
|
-
<h2 className="babylai:text-2xl! babylai:text-center babylai:font-bold! babylai:mb-2! babylai:text-card-foreground">{t('homeSdk.ReviewDialog.title')}</h2>
|
|
61
|
-
|
|
62
|
-
<p className="babylai:text-sm babylai:text-center babylai:text-muted-foreground babylai:mb-4">
|
|
63
|
-
{t('homeSdk.ReviewDialog.description')}
|
|
64
|
-
</p>
|
|
65
|
-
|
|
66
|
-
<footer className="babylai:flex babylai:justify-between babylai:gap-3 babylai:mt-6">
|
|
67
|
-
<Button
|
|
66
|
+
<div className='babylai:flex babylai:flex-col babylai:bg-card babylai:rounded-2xl babylai:w-full babylai:z-50 babylai:shadow-lg'>
|
|
67
|
+
<div className='babylai:flex babylai:flex-col babylai:p-6 babylai:pb-5 babylai:w-full'>
|
|
68
|
+
<button className="babylai:border-0 babylai:p-0 babylai:flex babylai:bg-transparent babylai:cursor-pointer babylai:mb-6 babylai:ms-auto babylai:text-card-foreground"
|
|
69
|
+
type='button'
|
|
68
70
|
onClick={props.onClose}
|
|
69
|
-
variant='secondary'
|
|
70
|
-
disabled={props.isSubmitting}
|
|
71
71
|
>
|
|
72
|
-
|
|
73
|
-
</
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
72
|
+
<SolarCloseCircleLineDuotone className="babylai:w-7 babylai:h-7" />
|
|
73
|
+
</button>
|
|
74
|
+
|
|
75
|
+
<section className='babylai:flex babylai:items-center babylai:justify-center babylai:border-b babylai:border-black-white-200 babylai:pb-6 babylai:mb-6'>
|
|
76
|
+
<Rating value={rating} onChange={handleRatingChange} size='lg' />
|
|
77
|
+
</section>
|
|
78
|
+
|
|
79
|
+
<h2 className="babylai:text-2xl! babylai:text-center babylai:font-bold! babylai:mb-2! babylai:text-card-foreground">{t('homeSdk.ReviewDialog.title')}</h2>
|
|
80
|
+
|
|
81
|
+
<p className="babylai:text-xs babylai:text-center babylai:text-muted-foreground babylai:mb-4 babylai:leading-snug">
|
|
82
|
+
{t('homeSdk.ReviewDialog.description')}
|
|
83
|
+
</p>
|
|
84
|
+
|
|
85
|
+
{hasRating && (
|
|
86
|
+
<div className='babylai:flex babylai:flex-col babylai:gap-6 babylai:mt-6'>
|
|
87
|
+
<p className="babylai:text-sm babylai:text-card-foreground babylai:leading-snug">{t('homeSdk.InChatReview.follow_up')}</p>
|
|
88
|
+
|
|
89
|
+
<div className='babylai:flex babylai:flex-col babylai:gap-2'>
|
|
90
|
+
<textarea
|
|
91
|
+
className={cn(
|
|
92
|
+
"babylai:resize-none babylai:w-full babylai:bg-secondary babylai:border babylai:rounded-xl babylai:text-card-foreground babylai:text-sm babylai:p-3 babylai:resize-vertical babylai:min-h-20 babylai:disabled:opacity-50 babylai:disabled:cursor-not-allowed babylai:disabled:bg-secondary",
|
|
93
|
+
error.comment ? "babylai:border-destructive" : "babylai:border-black-white-200"
|
|
94
|
+
)}
|
|
95
|
+
rows={4}
|
|
96
|
+
maxLength={COMMENT_MAX_LENGTH}
|
|
97
|
+
placeholder={t('homeSdk.InChatReview.note_placeholder')}
|
|
98
|
+
value={comment}
|
|
99
|
+
onChange={handleCommentChange}
|
|
100
|
+
aria-label={t('homeSdk.InChatReview.note_placeholder')}
|
|
101
|
+
aria-invalid={!!error.comment}
|
|
102
|
+
aria-describedby={error.comment ? 'review-comment-error' : undefined}
|
|
84
103
|
/>
|
|
85
|
-
{
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
104
|
+
{error.comment && (
|
|
105
|
+
<p id="review-comment-error" className="babylai:text-sm babylai:text-destructive" role="alert">
|
|
106
|
+
{error.comment}
|
|
107
|
+
</p>
|
|
108
|
+
)}
|
|
109
|
+
<p className="babylai:text-xs babylai:text-muted-foreground">
|
|
110
|
+
{comment.length}/{COMMENT_MAX_LENGTH}
|
|
111
|
+
</p>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
)}
|
|
115
|
+
|
|
116
|
+
<footer className="babylai:flex babylai:justify-between babylai:gap-3 babylai:mt-6">
|
|
117
|
+
<Button
|
|
118
|
+
onClick={props.onClose}
|
|
119
|
+
variant='secondary'
|
|
120
|
+
disabled={props.isSubmitting}
|
|
121
|
+
>
|
|
122
|
+
{t('homeSdk.ReviewDialog.skip_button')}
|
|
123
|
+
</Button>
|
|
124
|
+
<Button
|
|
125
|
+
onClick={validateAndSubmit}
|
|
126
|
+
variant='default'
|
|
127
|
+
disabled={props.isSubmitting || !hasRating}
|
|
128
|
+
>
|
|
129
|
+
{props.isSubmitting ? (
|
|
130
|
+
<span className="babylai:inline-flex babylai:items-center babylai:gap-2">
|
|
131
|
+
<span
|
|
132
|
+
className="babylai:inline-block babylai:animate-spin babylai:rounded-full babylai:h-4 babylai:w-4 babylai:border-2 babylai:border-white babylai:border-t-transparent babylai:box-border"
|
|
133
|
+
aria-hidden
|
|
134
|
+
/>
|
|
135
|
+
{t('homeSdk.ReviewDialog.submit_button')}
|
|
136
|
+
</span>
|
|
137
|
+
) : (
|
|
138
|
+
t('homeSdk.ReviewDialog.submit_button')
|
|
139
|
+
)}
|
|
140
|
+
</Button>
|
|
141
|
+
</footer>
|
|
142
|
+
</div>
|
|
143
|
+
<PoweredBy />
|
|
92
144
|
</div>
|
|
93
145
|
</section>
|
|
94
146
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cn } from '@/lib'
|
|
2
|
-
import { IconHeart as Heart,
|
|
2
|
+
import { IconHeart as Heart, IconThumbUp as ThumbsUp } from '@tabler/icons-react'
|
|
3
|
+
import SolarStarBold from '~icons/solar/star-bold'
|
|
3
4
|
import * as React from 'react'
|
|
4
5
|
|
|
5
6
|
export interface RatingProps {
|
|
@@ -14,7 +15,7 @@ export interface RatingProps {
|
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
const iconMap = {
|
|
17
|
-
star:
|
|
18
|
+
star: SolarStarBold,
|
|
18
19
|
heart: Heart,
|
|
19
20
|
thumbsUp: ThumbsUp
|
|
20
21
|
}
|
|
@@ -57,7 +58,7 @@ export const Rating = React.forwardRef<HTMLDivElement, RatingProps>(
|
|
|
57
58
|
className={cn(
|
|
58
59
|
sizeMap[size],
|
|
59
60
|
'babylai:cursor-pointer babylai:transition-colors',
|
|
60
|
-
filled ? 'babylai:text-
|
|
61
|
+
filled ? 'babylai:text-[#F49E00] babylai:fill-[#F49E00]' : 'babylai:text-gray-300',
|
|
61
62
|
readOnly && 'babylai:cursor-default'
|
|
62
63
|
)}
|
|
63
64
|
onMouseEnter={() => handleMouseEnter(index + 1)}
|