@aslaluroba/help-center 1.1.13 → 1.1.16
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 +131 -34
- package/fesm2022/aslaluroba-help-center.mjs +276 -69
- package/fesm2022/aslaluroba-help-center.mjs.map +1 -1
- package/package.json +5 -2
- package/public_api.d.ts +1 -0
- package/src/app/chat/chat.component.d.ts +9 -6
- package/src/app/help-center-widget/help-center-widget.component.d.ts +8 -4
- package/src/app/help-screen-data/help-screen-data.component.d.ts +8 -1
- package/src/app/language.service.d.ts +11 -0
- package/src/app/services/translation.service.d.ts +3 -1
- package/src/app/shared/components/loading/loading.component.d.ts +2 -1
- package/assets/i18n/ar.json +0 -17
- package/assets/i18n/en.json +0 -17
- package/assets/icons/arrow-stripped-colored.svg +0 -3
- package/assets/icons/arrow-stripped.svg +0 -3
- package/assets/icons/chat.svg +0 -4
- package/assets/icons/close-circle.svg +0 -3
- package/assets/icons/menu.svg +0 -3
- package/assets/icons/person.svg +0 -4
- package/assets/icons/send.svg +0 -3
- package/assets/images/animatedLogo.gif +0 -0
- package/assets/images/seperator.svg +0 -5
- package/assets/images/stars.svg +0 -7
- package/assets/logo-primary.svg +0 -6
- package/assets/logo-white.svg +0 -6
- /package/{Shape.png → assets/Shape.png} +0 -0
- /package/{favicon.ico → assets/favicon.ico} +0 -0
package/README.md
CHANGED
|
@@ -10,6 +10,35 @@ Install the package and its peer dependencies:
|
|
|
10
10
|
npm install @babylai/help-center
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
### Assets Configuration
|
|
14
|
+
|
|
15
|
+
The help center widget requires certain assets (icons, images, etc.) to function properly. You need to configure your Angular application to include these assets:
|
|
16
|
+
|
|
17
|
+
1. Update your angular.json to include the package assets:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"projects": {
|
|
22
|
+
"your-app": {
|
|
23
|
+
"architect": {
|
|
24
|
+
"build": {
|
|
25
|
+
"options": {
|
|
26
|
+
"assets": [
|
|
27
|
+
"src/assets",
|
|
28
|
+
{
|
|
29
|
+
"glob": "**/*",
|
|
30
|
+
"input": "./node_modules/@babylai/help-center/assets",
|
|
31
|
+
"output": "/assets"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
13
42
|
### Markdown Support
|
|
14
43
|
|
|
15
44
|
This library uses [ngx-markdown](https://github.com/jfcere/ngx-markdown) for rendering markdown content. Please refer to their [official documentation](https://github.com/jfcere/ngx-markdown) for detailed installation and configuration instructions, including:
|
|
@@ -22,55 +51,123 @@ This library uses [ngx-markdown](https://github.com/jfcere/ngx-markdown) for ren
|
|
|
22
51
|
|
|
23
52
|
## Basic Usage
|
|
24
53
|
|
|
25
|
-
1. Import the
|
|
26
|
-
|
|
27
|
-
```typescript
|
|
28
|
-
typescript
|
|
29
|
-
import { HelpCenterModule } from '@babylai/help-center'
|
|
30
|
-
@NgModule({
|
|
31
|
-
imports: [
|
|
32
|
-
// ... other imports
|
|
33
|
-
HelpCenterModule
|
|
34
|
-
]
|
|
35
|
-
})
|
|
36
|
-
export class AppModule {}
|
|
37
|
-
```
|
|
54
|
+
1. Import the required components and services in your component:
|
|
38
55
|
|
|
39
|
-
2. Add the HelpCenterComponent to your template:
|
|
40
56
|
```typescript
|
|
41
|
-
import { HelpCenterWidgetComponent } from '@babylai/help-center'
|
|
57
|
+
import { HelpCenterWidgetComponent, LanguageService, TranslationService, Language } from '@babylai/help-center'
|
|
42
58
|
|
|
43
59
|
@Component({
|
|
44
60
|
selector: 'app-root',
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
standalone: true,
|
|
62
|
+
imports: [CommonModule, HelpCenterWidgetComponent],
|
|
63
|
+
template: `
|
|
64
|
+
<div class="container">
|
|
65
|
+
<!-- Language Switcher -->
|
|
66
|
+
<div class="language-switcher">
|
|
67
|
+
<button [class.active]="currentLang === 'en'" (click)="switchLanguage('en')">English</button>
|
|
68
|
+
<button [class.active]="currentLang === 'ar'" (click)="switchLanguage('ar')">العربية</button>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<!-- Help Center Widget -->
|
|
72
|
+
<app-help-center-widget
|
|
73
|
+
[getToken]="getTokenFunction"
|
|
74
|
+
[helpScreenId]="yourHelpScreenId"
|
|
75
|
+
[showArrow]="true"
|
|
76
|
+
[messageLabel]="'Need help? Click here!'"
|
|
77
|
+
>
|
|
78
|
+
</app-help-center-widget>
|
|
79
|
+
</div>
|
|
80
|
+
`,
|
|
81
|
+
styles: [
|
|
82
|
+
`
|
|
83
|
+
.language-switcher {
|
|
84
|
+
display: flex;
|
|
85
|
+
gap: 1rem;
|
|
86
|
+
margin-bottom: 1rem;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.language-switcher button {
|
|
90
|
+
padding: 0.5rem 1rem;
|
|
91
|
+
border: 1px solid #ccc;
|
|
92
|
+
border-radius: 4px;
|
|
93
|
+
cursor: pointer;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.language-switcher button.active {
|
|
97
|
+
background-color: #ad49e1;
|
|
98
|
+
color: white;
|
|
99
|
+
border-color: #ad49e1;
|
|
100
|
+
}
|
|
101
|
+
`
|
|
102
|
+
]
|
|
47
103
|
})
|
|
104
|
+
export class AppComponent implements OnInit, OnDestroy {
|
|
105
|
+
currentLang: Language = 'en'
|
|
106
|
+
private langSubscription?: Subscription
|
|
107
|
+
|
|
108
|
+
constructor(
|
|
109
|
+
private languageService: LanguageService,
|
|
110
|
+
private translationService: TranslationService
|
|
111
|
+
) {}
|
|
112
|
+
|
|
113
|
+
ngOnInit() {
|
|
114
|
+
// Subscribe to language changes
|
|
115
|
+
this.langSubscription = this.translationService.currentLang.subscribe((lang) => {
|
|
116
|
+
this.currentLang = lang
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
ngOnDestroy() {
|
|
121
|
+
// Clean up subscription
|
|
122
|
+
if (this.langSubscription) {
|
|
123
|
+
this.langSubscription.unsubscribe()
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
switchLanguage(lang: Language) {
|
|
128
|
+
this.languageService.switchLanguage(lang)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Your token function implementation
|
|
132
|
+
getTokenFunction = async () => {
|
|
133
|
+
// Implement your token retrieval logic here
|
|
134
|
+
return 'your-token'
|
|
135
|
+
}
|
|
136
|
+
}
|
|
48
137
|
```
|
|
49
138
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
139
|
+
2. Make sure to provide the services in your app.config.ts:
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
import { ApplicationConfig } from '@angular/core'
|
|
143
|
+
import { LanguageService } from '@babylai/help-center'
|
|
144
|
+
import { TranslationService } from '@babylai/help-center'
|
|
145
|
+
|
|
146
|
+
export const appConfig: ApplicationConfig = {
|
|
147
|
+
providers: [
|
|
148
|
+
// ... other providers
|
|
149
|
+
LanguageService,
|
|
150
|
+
TranslationService
|
|
151
|
+
]
|
|
152
|
+
}
|
|
59
153
|
```
|
|
60
154
|
|
|
155
|
+
## Language Service Features
|
|
156
|
+
|
|
157
|
+
The LanguageService provides the following functionality:
|
|
158
|
+
|
|
159
|
+
- `switchLanguage(language: Language)`: Switch between supported languages ('en' | 'ar')
|
|
160
|
+
- `getCurrentLang(): Language`: Get the current active language
|
|
161
|
+
- Automatic RTL support for Arabic language
|
|
162
|
+
- Automatic translation of all widget content
|
|
163
|
+
- Real-time language switching without page reload
|
|
164
|
+
|
|
61
165
|
## Configuration Options
|
|
62
166
|
|
|
63
167
|
The widget accepts the following inputs:
|
|
64
168
|
|
|
65
169
|
- `getToken`: () => Promise<string> - A function that returns a promise resolving to an authentication token
|
|
66
170
|
- `helpScreenId`: string - The ID of the help screen to display
|
|
67
|
-
- `user`: Object - (Optional) Current user information
|
|
68
|
-
```typescript
|
|
69
|
-
{
|
|
70
|
-
id: string
|
|
71
|
-
name: string
|
|
72
|
-
email: string
|
|
73
|
-
}
|
|
74
|
-
```
|
|
75
171
|
- `showArrow`: boolean - (Optional) Whether to show the attention arrow animation
|
|
76
172
|
- `messageLabel`: string - (Optional) Custom message for the arrow tooltip
|
|
173
|
+
- `currentLang`: string - (Optional) Initial language setting ('en' | 'ar')
|