@messaia/cdk 20.0.0-RC.11 → 20.0.0-RC.13
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/fesm2022/messaia-cdk.mjs +10 -4
- package/fesm2022/messaia-cdk.mjs.map +1 -1
- package/index.d.ts +4 -3
- package/package.json +1 -1
package/fesm2022/messaia-cdk.mjs
CHANGED
|
@@ -1625,16 +1625,22 @@ class BaseComponent {
|
|
|
1625
1625
|
/**
|
|
1626
1626
|
* Displays a message using the snack bar service.
|
|
1627
1627
|
*
|
|
1628
|
-
* @param message The message to display
|
|
1628
|
+
* @param message The message to display.
|
|
1629
1629
|
* @param type The type of the message (Success, Warning, or Error). Defaults to Success.
|
|
1630
|
-
* @param duration
|
|
1630
|
+
* @param duration Optional duration (in milliseconds) to show the message.
|
|
1631
|
+
* If omitted, duration is adjusted based on message length.
|
|
1631
1632
|
* @param actionLabel The label for the action button. Defaults to 'OK'.
|
|
1632
|
-
* @param playSound A flag indicating whether to play a warning sound when the message type is Warning. Defaults to false.
|
|
1633
|
+
* @param playSound A flag indicating whether to play a warning sound when the message type is Warning or Error. Defaults to false.
|
|
1633
1634
|
* @returns An observable that emits when the action button is clicked.
|
|
1634
1635
|
*/
|
|
1635
|
-
showMessage(message, type = MessageType.Success, duration
|
|
1636
|
+
showMessage(message, type = MessageType.Success, duration, actionLabel = $localize `:@@ok:OK`, playSound = false) {
|
|
1636
1637
|
/* Default snack bar class to 'primary' (for success messages) */
|
|
1637
1638
|
let snackBarClass = 'primary';
|
|
1639
|
+
/* If duration is not provided, calculate it based on message length */
|
|
1640
|
+
if (duration === undefined) {
|
|
1641
|
+
/* Calculate duration: base 2000ms + 50ms per character, min 2000ms, max 10000ms */
|
|
1642
|
+
duration = Math.min(Math.max(2000 + message.length * 50, 2000), 10000);
|
|
1643
|
+
}
|
|
1638
1644
|
/* Determine the appropriate CSS class based on the message type */
|
|
1639
1645
|
switch (type) {
|
|
1640
1646
|
case MessageType.Success:
|