@trixwell/ngx-parl 5.0.0 → 5.0.1

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 CHANGED
@@ -68,22 +68,22 @@ assets/ngx-parl/...
68
68
 
69
69
  ## Signal Data
70
70
 
71
- | Name | Type | Description |
72
- |:--------------------:|:-------------------------:|:-----------------------------------------------------------------:|
73
- | header | boolean | Display the chat title with the name of the interlocutor |
74
- | theme | string | Choose a theme color (```primary``` or ```secondary```) |
75
- | language | string | Set language (```uk``` or ```en```). Default ```en``` |
76
- | messageList | ChatMessage[] | List of chat messages, user information |
77
- | messageUpdate | ChatMessage | Incoming message from external source (signal/subject/observable) |
78
- | messageAction | MessageActionEvent | Emits chat events: send, edit, delete |
79
- | loadHistory | boolean | Use scroll for load history |
80
- | incomingUser | string | User writing in messenger |
81
- | transportType | string | Transport type label (Telegram, etc.) |
82
- | transportTypeIcon | string | Path to transport icon (e.g. assets/ngx-parl/...) |
83
- | mobileMode | boolean | Enables mobile UI behavior (layout + quick actions) |
84
- | quickActionsResolver | ParlQuickActionsResolver | Maps `ChatMessage` -> quick action buttons (mobile only) |
85
- | quickActionsAutoSend | boolean | Auto-send quick action text on click. Default `true` |
86
- | quickActionClick | ParlQuickActionClickEvent | Emits when a quick action is clicked (two-way bind) |
71
+ | Name | Type | Description |
72
+ |:--------------------:|:-------------------------:|:----------------------------------------------------------------------------------------------:|
73
+ | header | boolean | Display the chat title with the name of the interlocutor |
74
+ | theme | string | Choose a theme color (```primary``` or ```secondary```) |
75
+ | language | string | Set language (```uk``` or ```en```). Default ```en``` |
76
+ | messageList | ChatMessage[] | List of chat messages, user information |
77
+ | messageUpdate | ChatMessage | Incoming message from external source (signal/subject/observable) |
78
+ | messageAction | MessageActionEvent | Emits chat events: send, edit, delete |
79
+ | loadHistory | boolean | Use scroll for load history |
80
+ | incomingUser | string | User writing in messenger |
81
+ | transportType | string | Transport type label (Telegram, etc.) |
82
+ | transportTypeIcon | string | Path to transport icon (e.g. assets/ngx-parl/...) |
83
+ | mobileMode | boolean | Enables mobile UI behavior (e.g. outgoing avatar, layout) |
84
+ | quickActionsResolver | ParlQuickActionsResolver | Optional. Custom mapping; if omitted, `message.actions` uses `defaultParlQuickActionsResolver` |
85
+ | quickActionsAutoSend | boolean | Auto-send quick action text on click. Default `true` |
86
+ | quickActionClick | ParlQuickActionClickEvent | Emits when a quick action is clicked (two-way bind) |
87
87
 
88
88
  ## Scrolling to the Bottom
89
89
 
@@ -147,10 +147,12 @@ export interface MessageActionEvent {
147
147
  }
148
148
  ```
149
149
 
150
- ## Quick actions (mobile)
150
+ ## Quick actions
151
151
 
152
- If your `ChatMessage` contains `actions`, you can expose them as UI buttons (quick actions) using `[quickActionsResolver]`.
152
+ If your `ChatMessage` contains `actions`, they are shown as quick action buttons for **outgoing** messages in both desktop and mobile layouts (`mobileMode` does not hide them).
153
153
 
154
+ - If you omit `[quickActionsResolver]`, the library uses `defaultParlQuickActionsResolver`, which maps `message.actions` to buttons.
155
+ - Provide a custom `[quickActionsResolver]` to filter, reorder, or replace actions; the context includes `isMobile` if you need different behavior per layout.
154
156
  - `ChatQuickButton.title` is the button text; `ChatQuickButton.value` is the text that will be sent.
155
157
  - Each action must include a stable `id`.
156
158
  - `quickActionsAutoSend` defaults to `true` (clicking a quick action triggers `sendMessage()`).
@@ -177,13 +179,15 @@ export interface ParlQuickActionClickEvent {
177
179
  }
178
180
 
179
181
  export type ParlQuickActionsResolver = (context: ParlQuickActionContext) => ParlQuickAction[];
182
+
183
+ export function defaultParlQuickActionsResolver(context: ParlQuickActionContext): ParlQuickAction[];
180
184
  ```
181
185
 
182
186
  ### Example resolver
183
187
 
184
188
  ```
185
- public quickActionsResolver: ParlQuickActionsResolver = ({message, isMobile}) => {
186
- if (!isMobile || message.type !== 'outgoing') {
189
+ public quickActionsResolver: ParlQuickActionsResolver = ({ message }) => {
190
+ if (message.type !== 'outgoing') {
187
191
  return [];
188
192
  }
189
193
 
@@ -201,12 +205,13 @@ public quickActionsResolver: ParlQuickActionsResolver = ({message, isMobile}) =>
201
205
  Set `[mobileMode]="true"` to enable mobile UI behavior:
202
206
 
203
207
  - Outgoing message avatars are hidden to save space.
204
- - Quick actions are only resolved/rendered when `mobileMode` is enabled.
205
- - Quick actions are shown as a separate “buttons-only” outgoing message when your resolver returns actions for that message.
208
+ - Quick actions use the default resolver from `message.actions` when `[quickActionsResolver]` is omitted, or your custom resolver when set (desktop and mobile).
209
+ - Quick actions are shown as a separate “buttons-only” outgoing message when the resolver returns actions for that message.
206
210
 
207
- To enable quick actions on mobile:
211
+ To use quick actions:
208
212
 
209
- - Provide `[quickActionsResolver]` that returns an array of actions for a given message.
213
+ - Put `actions` on outgoing `ChatMessage` instances, and optionally omit `[quickActionsResolver]` to use the default mapping.
214
+ - Or provide `[quickActionsResolver]` for full control.
210
215
  - Optionally bind `[(quickActionClick)]` to observe clicks (analytics/logging).
211
216
  - Keep `[quickActionsAutoSend]="true"` to send `action.value` on click (default).
212
217
 
@@ -217,9 +222,8 @@ To enable quick actions on mobile:
217
222
  [(messageList)]="messageList"
218
223
  [(messageUpdate)]="messageUpdate"
219
224
  [(messageAction)]="messageAction"
220
- [quickActionsResolver]="quickActionsResolver"
221
225
  [quickActionsAutoSend]="true"
222
- [mobileMode]="true"
226
+ [mobileMode]="false"
223
227
  [(quickActionClick)]="quickActionClick"
224
228
  [transportType]="transportType()"
225
229
  [transportTypeIcon]="transportTypeIcon()"