isometrik-plugin-chat-sdk 2.0.8 → 2.0.9

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.
Files changed (50) hide show
  1. package/dist/cjs/attachment-preview_22.cjs.entry.js +1 -1
  2. package/dist/cjs/login-page_3.cjs.entry.js +1 -1
  3. package/dist/cjs/member-add.cjs.entry.js +1 -1
  4. package/dist/cjs/reaction-container.cjs.entry.js +1 -1
  5. package/dist/cjs/toast-75ef0607.js +159 -0
  6. package/dist/cjs/toast-75ef0607.js.map +1 -0
  7. package/dist/cjs/toast-notification.cjs.entry.js +21 -15
  8. package/dist/cjs/toast-notification.cjs.entry.js.map +1 -1
  9. package/dist/collection/components/ChatUIComponent/shared/toast-notification/toast-notification.js +32 -26
  10. package/dist/collection/components/ChatUIComponent/shared/toast-notification/toast-notification.js.map +1 -1
  11. package/dist/collection/lib/friendly-toast-message.js +38 -0
  12. package/dist/collection/lib/friendly-toast-message.js.map +1 -0
  13. package/dist/collection/lib/toast.js +76 -21
  14. package/dist/collection/lib/toast.js.map +1 -1
  15. package/dist/components/toast-notification.js +21 -15
  16. package/dist/components/toast-notification.js.map +1 -1
  17. package/dist/components/toast.js +112 -21
  18. package/dist/components/toast.js.map +1 -1
  19. package/dist/esm/attachment-preview_22.entry.js +1 -1
  20. package/dist/esm/login-page_3.entry.js +1 -1
  21. package/dist/esm/member-add.entry.js +1 -1
  22. package/dist/esm/reaction-container.entry.js +1 -1
  23. package/dist/esm/toast-45ac7913.js +157 -0
  24. package/dist/esm/toast-45ac7913.js.map +1 -0
  25. package/dist/esm/toast-notification.entry.js +21 -15
  26. package/dist/esm/toast-notification.entry.js.map +1 -1
  27. package/dist/isometrik-webchat/isometrik-webchat.esm.js +1 -1
  28. package/dist/isometrik-webchat/p-0c06a021.js +2 -0
  29. package/dist/isometrik-webchat/p-0c06a021.js.map +1 -0
  30. package/dist/isometrik-webchat/{p-76341adb.entry.js → p-6024bf2a.entry.js} +2 -2
  31. package/dist/isometrik-webchat/{p-35d9ecdc.entry.js → p-63ff4eea.entry.js} +2 -2
  32. package/dist/isometrik-webchat/{p-a119be75.entry.js → p-9f036163.entry.js} +2 -2
  33. package/dist/isometrik-webchat/{p-2195b0c0.entry.js → p-ba6de4e2.entry.js} +2 -2
  34. package/dist/isometrik-webchat/p-d6fd2dd7.entry.js +2 -0
  35. package/dist/isometrik-webchat/p-d6fd2dd7.entry.js.map +1 -0
  36. package/dist/types/lib/friendly-toast-message.d.ts +5 -0
  37. package/dist/types/lib/toast.d.ts +1 -0
  38. package/package.json +1 -1
  39. package/dist/cjs/toast-f810e550.js +0 -68
  40. package/dist/cjs/toast-f810e550.js.map +0 -1
  41. package/dist/esm/toast-533dd183.js +0 -66
  42. package/dist/esm/toast-533dd183.js.map +0 -1
  43. package/dist/isometrik-webchat/p-4cb54460.js +0 -2
  44. package/dist/isometrik-webchat/p-4cb54460.js.map +0 -1
  45. package/dist/isometrik-webchat/p-e1d632b0.entry.js +0 -2
  46. package/dist/isometrik-webchat/p-e1d632b0.entry.js.map +0 -1
  47. /package/dist/isometrik-webchat/{p-76341adb.entry.js.map → p-6024bf2a.entry.js.map} +0 -0
  48. /package/dist/isometrik-webchat/{p-35d9ecdc.entry.js.map → p-63ff4eea.entry.js.map} +0 -0
  49. /package/dist/isometrik-webchat/{p-a119be75.entry.js.map → p-9f036163.entry.js.map} +0 -0
  50. /package/dist/isometrik-webchat/{p-2195b0c0.entry.js.map → p-ba6de4e2.entry.js.map} +0 -0
@@ -11,7 +11,7 @@ const index_m = require('./index.m-ff115b26.js');
11
11
  const drawer = require('./drawer-960b3f5d.js');
12
12
  const helpers = require('./helpers-154861e9.js');
13
13
  const index$1 = require('./index-66f98408.js');
14
- const toast = require('./toast-f810e550.js');
14
+ const toast = require('./toast-75ef0607.js');
15
15
  const groupcast = require('./groupcast-c93d4a7d.js');
16
16
  const IsometrikLogo = require('./IsometrikLogo-9e642f65.js');
17
17
  const groupMembers = require('./group-members-5a82ec8a.js');
@@ -15,7 +15,7 @@ const groupMembers = require('./group-members-5a82ec8a.js');
15
15
  const groupcast$1 = require('./groupcast-c93d4a7d.js');
16
16
  const sendMedia = require('./send-media-37e09e83.js');
17
17
  const client = require('./client-80851676.js');
18
- const toast = require('./toast-f810e550.js');
18
+ const toast = require('./toast-75ef0607.js');
19
19
  const groupMembers$1 = require('./group-members-1205fc4c.js');
20
20
  const index$1 = require('./index-66f98408.js');
21
21
  require('./destroy-chat-7ae8fc99.js');
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-f624fc47.js');
6
6
  const groupMembers = require('./group-members-1205fc4c.js');
7
7
  const groupcast = require('./groupcast-c93d4a7d.js');
8
- const toast = require('./toast-f810e550.js');
8
+ const toast = require('./toast-75ef0607.js');
9
9
  const drawer = require('./drawer-960b3f5d.js');
10
10
  const chatAssets = require('./chat-assets-686620e7.js');
11
11
  require('./index.m-ff115b26.js');
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-f624fc47.js');
6
6
  const messageReaction = require('./message-reaction-8f93a048.js');
7
- const toast = require('./toast-f810e550.js');
7
+ const toast = require('./toast-75ef0607.js');
8
8
  require('./index.m-ff115b26.js');
9
9
  require('./index-66f98408.js');
10
10
 
@@ -0,0 +1,159 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-66f98408.js');
4
+
5
+ /**
6
+ * Map raw API / SDK errors to short user-facing copy.
7
+ * Never surface HTTP status phrases like "Unprocessable entity".
8
+ */
9
+ function friendlyToastMessage(raw, fallback = 'Something went wrong. Try again.') {
10
+ var _a, _b;
11
+ const s = String((_b = (_a = raw === null || raw === void 0 ? void 0 : raw.message) !== null && _a !== void 0 ? _a : raw) !== null && _b !== void 0 ? _b : '')
12
+ .trim()
13
+ .replace(/\s+/g, ' ');
14
+ if (!s)
15
+ return fallback;
16
+ const lower = s.toLowerCase();
17
+ if (lower.includes('unprocessable') ||
18
+ lower.includes('422') ||
19
+ lower === 'bad request' ||
20
+ lower.includes('invalid payload')) {
21
+ return "Couldn't send that message. Please try again.";
22
+ }
23
+ if (lower.includes('network') ||
24
+ lower.includes('failed to fetch') ||
25
+ lower.includes('timeout')) {
26
+ return 'Network issue. Check your connection and try again.';
27
+ }
28
+ if (lower.includes('unauthorized') ||
29
+ lower.includes('401') ||
30
+ lower.includes('forbidden') ||
31
+ lower.includes('403')) {
32
+ return 'Session expired. Please refresh and try again.';
33
+ }
34
+ if (lower.includes('not found') || lower.includes('404')) {
35
+ return 'That chat is no longer available.';
36
+ }
37
+ // Keep short human messages; truncate giant stack/JSON blobs.
38
+ if (s.length > 120 || s.startsWith('{') || s.includes('\n'))
39
+ return fallback;
40
+ return s;
41
+ }
42
+
43
+ class ToastHelper {
44
+ constructor() {
45
+ this.container = document.createElement('div');
46
+ this.container.id = 'isometrik-toast-root';
47
+ Object.assign(this.container.style, {
48
+ position: 'fixed',
49
+ zIndex: '100000',
50
+ display: 'flex',
51
+ flexDirection: 'column',
52
+ gap: '8px',
53
+ pointerEvents: 'none',
54
+ maxWidth: 'min(22rem, calc(100vw - 2rem))',
55
+ });
56
+ document.body.appendChild(this.container);
57
+ }
58
+ static getInstance() {
59
+ if (!ToastHelper.instance)
60
+ ToastHelper.instance = new ToastHelper();
61
+ return ToastHelper.instance;
62
+ }
63
+ /**
64
+ * Solid fallbacks — host themes often leave --danger / --bg-primary unset
65
+ * or map --bg-primary to a light surface (white-on-white toast).
66
+ */
67
+ getTypeStyles(type = 'info') {
68
+ const styles = {
69
+ success: {
70
+ bgColor: 'var(--success, #15803d)',
71
+ color: '#ffffff',
72
+ progressBarColor: 'rgba(255,255,255,0.55)',
73
+ borderColor: 'transparent',
74
+ },
75
+ error: {
76
+ bgColor: 'var(--danger, #b91c1c)',
77
+ color: '#ffffff',
78
+ progressBarColor: 'rgba(255,255,255,0.55)',
79
+ borderColor: 'transparent',
80
+ },
81
+ warning: {
82
+ bgColor: 'var(--text-warning-color, #c2410c)',
83
+ color: '#ffffff',
84
+ progressBarColor: 'rgba(255,255,255,0.55)',
85
+ borderColor: 'transparent',
86
+ },
87
+ info: {
88
+ bgColor: 'var(--hoa-chat-ink, #18181b)',
89
+ color: '#ffffff',
90
+ progressBarColor: 'rgba(255,255,255,0.55)',
91
+ borderColor: 'transparent',
92
+ },
93
+ };
94
+ return styles[type] || styles.info;
95
+ }
96
+ setPosition(position = 'top-right') {
97
+ // Clear previous transform so center variants don't stick.
98
+ this.container.style.transform = '';
99
+ const positions = {
100
+ 'top-right': { top: '1rem', right: '1rem', bottom: 'auto', left: 'auto' },
101
+ 'top-left': { top: '1rem', right: 'auto', bottom: 'auto', left: '1rem' },
102
+ // Sit above typical chat composer (~5.5rem).
103
+ 'bottom-right': { top: 'auto', right: '1rem', bottom: '5.5rem', left: 'auto' },
104
+ 'bottom-left': { top: 'auto', right: 'auto', bottom: '5.5rem', left: '1rem' },
105
+ 'top-center': {
106
+ top: '1rem',
107
+ right: 'auto',
108
+ bottom: 'auto',
109
+ left: '50%',
110
+ transform: 'translateX(-50%)',
111
+ },
112
+ 'bottom-center': {
113
+ top: 'auto',
114
+ right: 'auto',
115
+ bottom: '5.5rem',
116
+ left: '50%',
117
+ transform: 'translateX(-50%)',
118
+ },
119
+ };
120
+ Object.assign(this.container.style, positions[position] || positions['top-right']);
121
+ }
122
+ show(options) {
123
+ const { duration = 3500, type = 'info', position = 'top-right' } = options;
124
+ const message = friendlyToastMessage(options.message);
125
+ this.setPosition(position);
126
+ const toast = document.createElement('toast-notification');
127
+ const styles = this.getTypeStyles(type);
128
+ toast.bgColor = styles.bgColor;
129
+ toast.color = styles.color;
130
+ toast.progressBarColor = styles.progressBarColor;
131
+ toast.progressBarBg = 'transparent';
132
+ toast.borderColor = styles.borderColor;
133
+ toast.borderWidth = '0';
134
+ toast.toastMessage = message;
135
+ toast.padding = '12px 14px';
136
+ toast.borderRadius = '0.5rem';
137
+ toast.width = '100%';
138
+ toast.fontWeight = '600';
139
+ toast.style.pointerEvents = 'auto';
140
+ toast.style.display = 'block';
141
+ toast.style.boxShadow = '0 8px 24px rgba(24, 24, 27, 0.18)';
142
+ this.container.appendChild(toast);
143
+ setTimeout(() => toast.remove(), duration);
144
+ }
145
+ }
146
+ const showToast = (options) => {
147
+ var _a;
148
+ const custom = index.createCustomPartElement('toast', Object.assign(Object.assign({}, options), { message: friendlyToastMessage(options.message) }));
149
+ if (custom) {
150
+ document.body.appendChild(custom);
151
+ setTimeout(() => custom.remove(), (_a = options.duration) !== null && _a !== void 0 ? _a : 3500);
152
+ return;
153
+ }
154
+ ToastHelper.getInstance().show(options);
155
+ };
156
+
157
+ exports.showToast = showToast;
158
+
159
+ //# sourceMappingURL=toast-75ef0607.js.map
@@ -0,0 +1 @@
1
+ {"file":"toast-75ef0607.js","mappings":";;;;AAAA;;;;SAIgB,oBAAoB,CAClC,GAAY,EACZ,QAAQ,GAAG,kCAAkC;;IAE7C,MAAM,CAAC,GAAG,MAAM,CAAC,MAAA,MAAC,GAA6B,aAA7B,GAAG,uBAAH,GAAG,CAA4B,OAAO,mCAAI,GAAG,mCAAI,EAAE,CAAC;SACnE,IAAI,EAAE;SACN,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACxB,IAAI,CAAC,CAAC;QAAE,OAAO,QAAQ,CAAC;IAExB,MAAM,KAAK,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAC9B,IACE,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC;QAC/B,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;QACrB,KAAK,KAAK,aAAa;QACvB,KAAK,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EACjC;QACA,OAAO,+CAA+C,CAAC;KACxD;IACD,IACE,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC;QACzB,KAAK,CAAC,QAAQ,CAAC,iBAAiB,CAAC;QACjC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EACzB;QAC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B,KAAK,CAAC,OAAO,GAAG,WAAW,CAAC;QAC5B,KAAK,CAAC,YAAY,GAAG,QAAQ,CAAC;QAC9B,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC;QACrB,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;QACzB,KAAK,CAAC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC;QACnC,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;QAC9B,KAAK,CAAC,KAAK,CAAC,SAAS,GAAG,mCAAmC,CAAC;QAC5D,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAClC,UAAU,CAAC,MAAM,KAAK,CAAC,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAC;KAC5C;CACF;MAEY,SAAS,GAAG,CAAC,OAAqB;;IAC7C,MAAM,MAAM,GAAGA,6BAAuB,CAAC,OAAO,EAAE,gCAC3C,OAAO,KACV,OAAO,EAAE,oBAAoB,CAAC,OAAO,CAAC,OAAO,CAAC,GACxC,CAAC,CAAC;IACV,IAAI,MAAM,EAAE;QACV,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAClC,UAAU,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,EAAE,MAAA,OAAO,CAAC,QAAQ,mCAAI,IAAI,CAAC,CAAC;QAC5D,OAAO;KACR;IACD,WAAW,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC1C;;;;","names":["createCustomPartElement"],"sources":["src/lib/friendly-toast-message.ts","src/lib/toast.ts"],"sourcesContent":["/**\n * Map raw API / SDK errors to short user-facing copy.\n * Never surface HTTP status phrases like \"Unprocessable entity\".\n */\nexport function friendlyToastMessage(\n raw: unknown,\n fallback = 'Something went wrong. Try again.',\n): string {\n const s = String((raw as { message?: unknown })?.message ?? raw ?? '')\n .trim()\n .replace(/\\s+/g, ' ');\n if (!s) return fallback;\n\n const lower = s.toLowerCase();\n if (\n lower.includes('unprocessable') ||\n lower.includes('422') ||\n lower === 'bad request' ||\n lower.includes('invalid payload')\n ) {\n return \"Couldn't send that message. Please try again.\";\n }\n if (\n lower.includes('network') ||\n lower.includes('failed to fetch') ||\n lower.includes('timeout')\n ) {\n return 'Network issue. Check your connection and try again.';\n }\n if (\n lower.includes('unauthorized') ||\n lower.includes('401') ||\n lower.includes('forbidden') ||\n lower.includes('403')\n ) {\n return 'Session expired. Please refresh and try again.';\n }\n if (lower.includes('not found') || lower.includes('404')) {\n return 'That chat is no longer available.';\n }\n // Keep short human messages; truncate giant stack/JSON blobs.\n if (s.length > 120 || s.startsWith('{') || s.includes('\\n')) return fallback;\n return s;\n}\n","import '../components/ChatUIComponent/shared/toast-notification/toast-notification';\nimport { createCustomPartElement } from './custom-ui';\nimport { friendlyToastMessage } from './friendly-toast-message';\n\nexport { friendlyToastMessage } from './friendly-toast-message';\n\nexport interface ToastOptions {\n message: string;\n duration?: number;\n type?: 'success' | 'error' | 'warning' | 'info';\n position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';\n}\n\nclass ToastHelper {\n private static instance: ToastHelper;\n private container: HTMLDivElement;\n\n private constructor() {\n this.container = document.createElement('div');\n this.container.id = 'isometrik-toast-root';\n Object.assign(this.container.style, {\n position: 'fixed',\n zIndex: '100000',\n display: 'flex',\n flexDirection: 'column',\n gap: '8px',\n pointerEvents: 'none',\n maxWidth: 'min(22rem, calc(100vw - 2rem))',\n } as CSSStyleDeclaration);\n document.body.appendChild(this.container);\n }\n\n public static getInstance(): ToastHelper {\n if (!ToastHelper.instance) ToastHelper.instance = new ToastHelper();\n return ToastHelper.instance;\n }\n\n /**\n * Solid fallbacks — host themes often leave --danger / --bg-primary unset\n * or map --bg-primary to a light surface (white-on-white toast).\n */\n private getTypeStyles(type: string = 'info') {\n const styles: Record<\n string,\n { bgColor: string; color: string; progressBarColor: string; borderColor: string }\n > = {\n success: {\n bgColor: 'var(--success, #15803d)',\n color: '#ffffff',\n progressBarColor: 'rgba(255,255,255,0.55)',\n borderColor: 'transparent',\n },\n error: {\n bgColor: 'var(--danger, #b91c1c)',\n color: '#ffffff',\n progressBarColor: 'rgba(255,255,255,0.55)',\n borderColor: 'transparent',\n },\n warning: {\n bgColor: 'var(--text-warning-color, #c2410c)',\n color: '#ffffff',\n progressBarColor: 'rgba(255,255,255,0.55)',\n borderColor: 'transparent',\n },\n info: {\n bgColor: 'var(--hoa-chat-ink, #18181b)',\n color: '#ffffff',\n progressBarColor: 'rgba(255,255,255,0.55)',\n borderColor: 'transparent',\n },\n };\n return styles[type] || styles.info;\n }\n\n private setPosition(position: string = 'top-right') {\n // Clear previous transform so center variants don't stick.\n this.container.style.transform = '';\n const positions: Record<string, Partial<CSSStyleDeclaration>> = {\n 'top-right': { top: '1rem', right: '1rem', bottom: 'auto', left: 'auto' },\n 'top-left': { top: '1rem', right: 'auto', bottom: 'auto', left: '1rem' },\n // Sit above typical chat composer (~5.5rem).\n 'bottom-right': { top: 'auto', right: '1rem', bottom: '5.5rem', left: 'auto' },\n 'bottom-left': { top: 'auto', right: 'auto', bottom: '5.5rem', left: '1rem' },\n 'top-center': {\n top: '1rem',\n right: 'auto',\n bottom: 'auto',\n left: '50%',\n transform: 'translateX(-50%)',\n },\n 'bottom-center': {\n top: 'auto',\n right: 'auto',\n bottom: '5.5rem',\n left: '50%',\n transform: 'translateX(-50%)',\n },\n };\n Object.assign(this.container.style, positions[position] || positions['top-right']);\n }\n\n public show(options: ToastOptions): void {\n const { duration = 3500, type = 'info', position = 'top-right' } = options;\n const message = friendlyToastMessage(options.message);\n this.setPosition(position);\n const toast = document.createElement('toast-notification') as any;\n const styles = this.getTypeStyles(type);\n toast.bgColor = styles.bgColor;\n toast.color = styles.color;\n toast.progressBarColor = styles.progressBarColor;\n toast.progressBarBg = 'transparent';\n toast.borderColor = styles.borderColor;\n toast.borderWidth = '0';\n toast.toastMessage = message;\n toast.padding = '12px 14px';\n toast.borderRadius = '0.5rem';\n toast.width = '100%';\n toast.fontWeight = '600';\n toast.style.pointerEvents = 'auto';\n toast.style.display = 'block';\n toast.style.boxShadow = '0 8px 24px rgba(24, 24, 27, 0.18)';\n this.container.appendChild(toast);\n setTimeout(() => toast.remove(), duration);\n }\n}\n\nexport const showToast = (options: ToastOptions): void => {\n const custom = createCustomPartElement('toast', {\n ...options,\n message: friendlyToastMessage(options.message),\n } as any);\n if (custom) {\n document.body.appendChild(custom);\n setTimeout(() => custom.remove(), options.duration ?? 3500);\n return;\n }\n ToastHelper.getInstance().show(options);\n};\n"],"version":3}
@@ -7,36 +7,42 @@ const index = require('./index-f624fc47.js');
7
7
  const ToastNotification = class {
8
8
  constructor(hostRef) {
9
9
  index.registerInstance(this, hostRef);
10
- this.bgColor = 'white';
10
+ this.bgColor = '#18181b';
11
11
  this.width = '200px';
12
12
  this.height = 'auto';
13
- this.borderWidth = '1px';
14
- this.borderColor = 'black';
15
- this.color = 'black';
16
- this.fontSize = '14px';
17
- this.borderRadius = '5px';
18
- this.fontWeight = 'normal';
19
- this.progressBarBg = 'white';
20
- this.progressBarHeight = '5px';
21
- this.progressBarColor = 'var(--success)';
22
- this.progressBarBorderRadius = '5px';
13
+ this.borderWidth = '0';
14
+ this.borderColor = 'transparent';
15
+ this.color = '#ffffff';
16
+ this.fontSize = '0.875rem';
17
+ this.borderRadius = '0.5rem';
18
+ this.fontWeight = '600';
19
+ this.progressBarBg = 'transparent';
20
+ this.progressBarHeight = '3px';
21
+ this.progressBarColor = 'rgba(255,255,255,0.55)';
22
+ this.progressBarBorderRadius = '0';
23
23
  this.toastMessage = 'Default message';
24
24
  this.padding = undefined;
25
25
  }
26
26
  render() {
27
- return (index.h("div", { key: '29d9794c50052cde03e6fbd84cd8906567e5340c', class: "toast-container", style: {
27
+ const borderW = this.borderWidth || '0';
28
+ const borderC = this.borderColor || 'transparent';
29
+ return (index.h("div", { key: '26860c462525339767af80e40eb7f81cbd2100fb', class: "toast-container", role: "status", style: {
28
30
  backgroundColor: this.bgColor,
29
31
  color: this.color,
30
32
  width: this.width,
31
33
  height: this.height,
32
- border: `${this.borderWidth} solid ${this.borderColor}`,
34
+ border: borderW === '0' || borderW === '0px' ? 'none' : `${borderW} solid ${borderC}`,
33
35
  borderRadius: this.borderRadius,
34
36
  fontSize: this.fontSize,
35
37
  fontWeight: this.fontWeight,
36
- } }, index.h("div", { key: '7acd2b848a46ae3512ed15f71b537f5fecc4de19', class: "toast-message", style: { padding: this.padding } }, this.toastMessage), index.h("div", { key: 'a518972b61a8b77df6bccbec2537b06c9a7ea895', class: "progress-container", style: { height: this.progressBarHeight, borderRadius: this.progressBarBorderRadius, background: this.progressBarBg } }, index.h("div", { key: '6735d8fb2c4fcbd1262e9a51bdcb90be6203f389', class: "progress-bar", style: { backgroundColor: this.progressBarColor } }))));
38
+ } }, index.h("div", { key: '894c28f99edda42212508bd4035b99bd125d1681', class: "toast-message", style: { padding: this.padding } }, this.toastMessage), index.h("div", { key: 'a40e5a0d3e8746efedbd175a555deb4a2fdaea1b', class: "progress-container", style: {
39
+ height: this.progressBarHeight,
40
+ borderRadius: this.progressBarBorderRadius,
41
+ background: this.progressBarBg,
42
+ } }, index.h("div", { key: 'f3248675f982049e927d41bb6c899050695f02e4', class: "progress-bar", style: { backgroundColor: this.progressBarColor } }))));
37
43
  }
38
44
  };
39
- ToastNotification.style = ":host { display: block; }\n .toast-container { box-shadow: 0 4px 12px var(--overlay); overflow: hidden; }\n .toast-message { padding: 8px; }\n .progress-container { width: 100%; overflow: hidden; position: relative; }\n .progress-bar {\n height: 100%; width: 100%; transform-origin: left;\n animation: progress 3s linear forwards;\n }\n @keyframes progress {\n from { width: 100%; }\n to { width: 0%; }\n }";
45
+ ToastNotification.style = ":host { display: block; }\n .toast-container {\n overflow: hidden;\n box-shadow: 0 8px 24px rgba(24, 24, 27, 0.18);\n letter-spacing: -0.01em;\n line-height: 1.35;\n }\n .toast-message { padding: 8px; word-break: break-word; }\n .progress-container { width: 100%; overflow: hidden; position: relative; }\n .progress-bar {\n height: 100%; width: 100%; transform-origin: left;\n animation: progress 3.5s linear forwards;\n }\n @keyframes progress {\n from { width: 100%; }\n to { width: 0%; }\n }";
40
46
 
41
47
  exports.toast_notification = ToastNotification;
42
48
 
@@ -1 +1 @@
1
- {"file":"toast-notification.entry.cjs.js","mappings":";;;;;;MAoBa,iBAAiB;;;uBACF,OAAO;qBACT,OAAO;sBACN,MAAM;2BACD,KAAK;2BACL,OAAO;qBACb,OAAO;wBACJ,MAAM;4BACF,KAAK;0BACP,QAAQ;6BACL,OAAO;iCACH,KAAK;gCACN,gBAAgB;uCACT,KAAK;4BAChB,iBAAiB;;;IAGhD,MAAM;QACJ,QACEA,kEACE,KAAK,EAAC,iBAAiB,EACvB,KAAK,EAAE;gBACL,eAAe,EAAE,IAAI,CAAC,OAAO;gBAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,MAAM,EAAE,GAAG,IAAI,CAAC,WAAW,UAAU,IAAI,CAAC,WAAW,EAAE;gBACvD,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,UAAU,EAAE,IAAI,CAAC,UAAU;aAC5B,IAEDA,kEAAK,KAAK,EAAC,eAAe,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IACxD,IAAI,CAAC,YAAY,CACd,EACNA,kEACE,KAAK,EAAC,oBAAoB,EAC1B,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,YAAY,EAAE,IAAI,CAAC,uBAAuB,EAAE,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,IAErHA,kEAAK,KAAK,EAAC,cAAc,EAAC,KAAK,EAAE,EAAE,eAAe,EAAE,IAAI,CAAC,gBAAgB,EAAE,GAAI,CAC3E,CACF,EACN;KACH;;;;;;","names":["h"],"sources":["src/components/ChatUIComponent/shared/toast-notification/toast-notification.tsx"],"sourcesContent":["import { Component, Prop, h } from '@stencil/core';\n\n@Component({\n tag: 'toast-notification',\n shadow: true,\n styles: `\n :host { display: block; }\n .toast-container { box-shadow: 0 4px 12px var(--overlay); overflow: hidden; }\n .toast-message { padding: 8px; }\n .progress-container { width: 100%; overflow: hidden; position: relative; }\n .progress-bar {\n height: 100%; width: 100%; transform-origin: left;\n animation: progress 3s linear forwards;\n }\n @keyframes progress {\n from { width: 100%; }\n to { width: 0%; }\n }\n `,\n})\nexport class ToastNotification {\n @Prop() bgColor: string = 'white';\n @Prop() width: string = '200px';\n @Prop() height: string = 'auto';\n @Prop() borderWidth: string = '1px';\n @Prop() borderColor: string = 'black';\n @Prop() color: string = 'black';\n @Prop() fontSize: string = '14px';\n @Prop() borderRadius: string = '5px';\n @Prop() fontWeight: string = 'normal';\n @Prop() progressBarBg: string = 'white';\n @Prop() progressBarHeight: string = '5px';\n @Prop() progressBarColor: string = 'var(--success)';\n @Prop() progressBarBorderRadius: string = '5px';\n @Prop() toastMessage: string = 'Default message';\n @Prop() padding: string;\n\n render() {\n return (\n <div\n class=\"toast-container\"\n style={{\n backgroundColor: this.bgColor,\n color: this.color,\n width: this.width,\n height: this.height,\n border: `${this.borderWidth} solid ${this.borderColor}`,\n borderRadius: this.borderRadius,\n fontSize: this.fontSize,\n fontWeight: this.fontWeight,\n }}\n >\n <div class=\"toast-message\" style={{ padding: this.padding }}>\n {this.toastMessage}\n </div>\n <div\n class=\"progress-container\"\n style={{ height: this.progressBarHeight, borderRadius: this.progressBarBorderRadius, background: this.progressBarBg }}\n >\n <div class=\"progress-bar\" style={{ backgroundColor: this.progressBarColor }} />\n </div>\n </div>\n );\n }\n}\n"],"version":3}
1
+ {"file":"toast-notification.entry.cjs.js","mappings":";;;;;;MAyBa,iBAAiB;;;uBACF,SAAS;qBACX,OAAO;sBACN,MAAM;2BACD,GAAG;2BACH,aAAa;qBACnB,SAAS;wBACN,UAAU;4BACN,QAAQ;0BACV,KAAK;6BACF,aAAa;iCACT,KAAK;gCACN,wBAAwB;uCACjB,GAAG;4BACd,iBAAiB;;;IAGhD,MAAM;QACJ,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,IAAI,GAAG,CAAC;QACxC,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,IAAI,aAAa,CAAC;QAClD,QACEA,kEACE,KAAK,EAAC,iBAAiB,EACvB,IAAI,EAAC,QAAQ,EACb,KAAK,EAAE;gBACL,eAAe,EAAE,IAAI,CAAC,OAAO;gBAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,MAAM,EAAE,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,KAAK,GAAG,MAAM,GAAG,GAAG,OAAO,UAAU,OAAO,EAAE;gBACrF,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,UAAU,EAAE,IAAI,CAAC,UAAU;aAC5B,IAEDA,kEAAK,KAAK,EAAC,eAAe,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IACxD,IAAI,CAAC,YAAY,CACd,EACNA,kEACE,KAAK,EAAC,oBAAoB,EAC1B,KAAK,EAAE;gBACL,MAAM,EAAE,IAAI,CAAC,iBAAiB;gBAC9B,YAAY,EAAE,IAAI,CAAC,uBAAuB;gBAC1C,UAAU,EAAE,IAAI,CAAC,aAAa;aAC/B,IAEDA,kEAAK,KAAK,EAAC,cAAc,EAAC,KAAK,EAAE,EAAE,eAAe,EAAE,IAAI,CAAC,gBAAgB,EAAE,GAAI,CAC3E,CACF,EACN;KACH;;;;;;","names":["h"],"sources":["src/components/ChatUIComponent/shared/toast-notification/toast-notification.tsx"],"sourcesContent":["import { Component, Prop, h } from '@stencil/core';\n\n@Component({\n tag: 'toast-notification',\n shadow: true,\n styles: `\n :host { display: block; }\n .toast-container {\n overflow: hidden;\n box-shadow: 0 8px 24px rgba(24, 24, 27, 0.18);\n letter-spacing: -0.01em;\n line-height: 1.35;\n }\n .toast-message { padding: 8px; word-break: break-word; }\n .progress-container { width: 100%; overflow: hidden; position: relative; }\n .progress-bar {\n height: 100%; width: 100%; transform-origin: left;\n animation: progress 3.5s linear forwards;\n }\n @keyframes progress {\n from { width: 100%; }\n to { width: 0%; }\n }\n `,\n})\nexport class ToastNotification {\n @Prop() bgColor: string = '#18181b';\n @Prop() width: string = '200px';\n @Prop() height: string = 'auto';\n @Prop() borderWidth: string = '0';\n @Prop() borderColor: string = 'transparent';\n @Prop() color: string = '#ffffff';\n @Prop() fontSize: string = '0.875rem';\n @Prop() borderRadius: string = '0.5rem';\n @Prop() fontWeight: string = '600';\n @Prop() progressBarBg: string = 'transparent';\n @Prop() progressBarHeight: string = '3px';\n @Prop() progressBarColor: string = 'rgba(255,255,255,0.55)';\n @Prop() progressBarBorderRadius: string = '0';\n @Prop() toastMessage: string = 'Default message';\n @Prop() padding: string;\n\n render() {\n const borderW = this.borderWidth || '0';\n const borderC = this.borderColor || 'transparent';\n return (\n <div\n class=\"toast-container\"\n role=\"status\"\n style={{\n backgroundColor: this.bgColor,\n color: this.color,\n width: this.width,\n height: this.height,\n border: borderW === '0' || borderW === '0px' ? 'none' : `${borderW} solid ${borderC}`,\n borderRadius: this.borderRadius,\n fontSize: this.fontSize,\n fontWeight: this.fontWeight,\n }}\n >\n <div class=\"toast-message\" style={{ padding: this.padding }}>\n {this.toastMessage}\n </div>\n <div\n class=\"progress-container\"\n style={{\n height: this.progressBarHeight,\n borderRadius: this.progressBarBorderRadius,\n background: this.progressBarBg,\n }}\n >\n <div class=\"progress-bar\" style={{ backgroundColor: this.progressBarColor }} />\n </div>\n </div>\n );\n }\n}\n"],"version":3}
@@ -1,37 +1,43 @@
1
1
  import { h } from "@stencil/core";
2
2
  export class ToastNotification {
3
3
  constructor() {
4
- this.bgColor = 'white';
4
+ this.bgColor = '#18181b';
5
5
  this.width = '200px';
6
6
  this.height = 'auto';
7
- this.borderWidth = '1px';
8
- this.borderColor = 'black';
9
- this.color = 'black';
10
- this.fontSize = '14px';
11
- this.borderRadius = '5px';
12
- this.fontWeight = 'normal';
13
- this.progressBarBg = 'white';
14
- this.progressBarHeight = '5px';
15
- this.progressBarColor = 'var(--success)';
16
- this.progressBarBorderRadius = '5px';
7
+ this.borderWidth = '0';
8
+ this.borderColor = 'transparent';
9
+ this.color = '#ffffff';
10
+ this.fontSize = '0.875rem';
11
+ this.borderRadius = '0.5rem';
12
+ this.fontWeight = '600';
13
+ this.progressBarBg = 'transparent';
14
+ this.progressBarHeight = '3px';
15
+ this.progressBarColor = 'rgba(255,255,255,0.55)';
16
+ this.progressBarBorderRadius = '0';
17
17
  this.toastMessage = 'Default message';
18
18
  this.padding = undefined;
19
19
  }
20
20
  render() {
21
- return (h("div", { key: '29d9794c50052cde03e6fbd84cd8906567e5340c', class: "toast-container", style: {
21
+ const borderW = this.borderWidth || '0';
22
+ const borderC = this.borderColor || 'transparent';
23
+ return (h("div", { key: '26860c462525339767af80e40eb7f81cbd2100fb', class: "toast-container", role: "status", style: {
22
24
  backgroundColor: this.bgColor,
23
25
  color: this.color,
24
26
  width: this.width,
25
27
  height: this.height,
26
- border: `${this.borderWidth} solid ${this.borderColor}`,
28
+ border: borderW === '0' || borderW === '0px' ? 'none' : `${borderW} solid ${borderC}`,
27
29
  borderRadius: this.borderRadius,
28
30
  fontSize: this.fontSize,
29
31
  fontWeight: this.fontWeight,
30
- } }, h("div", { key: '7acd2b848a46ae3512ed15f71b537f5fecc4de19', class: "toast-message", style: { padding: this.padding } }, this.toastMessage), h("div", { key: 'a518972b61a8b77df6bccbec2537b06c9a7ea895', class: "progress-container", style: { height: this.progressBarHeight, borderRadius: this.progressBarBorderRadius, background: this.progressBarBg } }, h("div", { key: '6735d8fb2c4fcbd1262e9a51bdcb90be6203f389', class: "progress-bar", style: { backgroundColor: this.progressBarColor } }))));
32
+ } }, h("div", { key: '894c28f99edda42212508bd4035b99bd125d1681', class: "toast-message", style: { padding: this.padding } }, this.toastMessage), h("div", { key: 'a40e5a0d3e8746efedbd175a555deb4a2fdaea1b', class: "progress-container", style: {
33
+ height: this.progressBarHeight,
34
+ borderRadius: this.progressBarBorderRadius,
35
+ background: this.progressBarBg,
36
+ } }, h("div", { key: 'f3248675f982049e927d41bb6c899050695f02e4', class: "progress-bar", style: { backgroundColor: this.progressBarColor } }))));
31
37
  }
32
38
  static get is() { return "toast-notification"; }
33
39
  static get encapsulation() { return "shadow"; }
34
- static get styles() { return ":host { display: block; }\n .toast-container { box-shadow: 0 4px 12px var(--overlay); overflow: hidden; }\n .toast-message { padding: 8px; }\n .progress-container { width: 100%; overflow: hidden; position: relative; }\n .progress-bar {\n height: 100%; width: 100%; transform-origin: left;\n animation: progress 3s linear forwards;\n }\n @keyframes progress {\n from { width: 100%; }\n to { width: 0%; }\n }"; }
40
+ static get styles() { return ":host { display: block; }\n .toast-container {\n overflow: hidden;\n box-shadow: 0 8px 24px rgba(24, 24, 27, 0.18);\n letter-spacing: -0.01em;\n line-height: 1.35;\n }\n .toast-message { padding: 8px; word-break: break-word; }\n .progress-container { width: 100%; overflow: hidden; position: relative; }\n .progress-bar {\n height: 100%; width: 100%; transform-origin: left;\n animation: progress 3.5s linear forwards;\n }\n @keyframes progress {\n from { width: 100%; }\n to { width: 0%; }\n }"; }
35
41
  static get properties() {
36
42
  return {
37
43
  "bgColor": {
@@ -50,7 +56,7 @@ export class ToastNotification {
50
56
  },
51
57
  "attribute": "bg-color",
52
58
  "reflect": false,
53
- "defaultValue": "'white'"
59
+ "defaultValue": "'#18181b'"
54
60
  },
55
61
  "width": {
56
62
  "type": "string",
@@ -104,7 +110,7 @@ export class ToastNotification {
104
110
  },
105
111
  "attribute": "border-width",
106
112
  "reflect": false,
107
- "defaultValue": "'1px'"
113
+ "defaultValue": "'0'"
108
114
  },
109
115
  "borderColor": {
110
116
  "type": "string",
@@ -122,7 +128,7 @@ export class ToastNotification {
122
128
  },
123
129
  "attribute": "border-color",
124
130
  "reflect": false,
125
- "defaultValue": "'black'"
131
+ "defaultValue": "'transparent'"
126
132
  },
127
133
  "color": {
128
134
  "type": "string",
@@ -140,7 +146,7 @@ export class ToastNotification {
140
146
  },
141
147
  "attribute": "color",
142
148
  "reflect": false,
143
- "defaultValue": "'black'"
149
+ "defaultValue": "'#ffffff'"
144
150
  },
145
151
  "fontSize": {
146
152
  "type": "string",
@@ -158,7 +164,7 @@ export class ToastNotification {
158
164
  },
159
165
  "attribute": "font-size",
160
166
  "reflect": false,
161
- "defaultValue": "'14px'"
167
+ "defaultValue": "'0.875rem'"
162
168
  },
163
169
  "borderRadius": {
164
170
  "type": "string",
@@ -176,7 +182,7 @@ export class ToastNotification {
176
182
  },
177
183
  "attribute": "border-radius",
178
184
  "reflect": false,
179
- "defaultValue": "'5px'"
185
+ "defaultValue": "'0.5rem'"
180
186
  },
181
187
  "fontWeight": {
182
188
  "type": "string",
@@ -194,7 +200,7 @@ export class ToastNotification {
194
200
  },
195
201
  "attribute": "font-weight",
196
202
  "reflect": false,
197
- "defaultValue": "'normal'"
203
+ "defaultValue": "'600'"
198
204
  },
199
205
  "progressBarBg": {
200
206
  "type": "string",
@@ -212,7 +218,7 @@ export class ToastNotification {
212
218
  },
213
219
  "attribute": "progress-bar-bg",
214
220
  "reflect": false,
215
- "defaultValue": "'white'"
221
+ "defaultValue": "'transparent'"
216
222
  },
217
223
  "progressBarHeight": {
218
224
  "type": "string",
@@ -230,7 +236,7 @@ export class ToastNotification {
230
236
  },
231
237
  "attribute": "progress-bar-height",
232
238
  "reflect": false,
233
- "defaultValue": "'5px'"
239
+ "defaultValue": "'3px'"
234
240
  },
235
241
  "progressBarColor": {
236
242
  "type": "string",
@@ -248,7 +254,7 @@ export class ToastNotification {
248
254
  },
249
255
  "attribute": "progress-bar-color",
250
256
  "reflect": false,
251
- "defaultValue": "'var(--success)'"
257
+ "defaultValue": "'rgba(255,255,255,0.55)'"
252
258
  },
253
259
  "progressBarBorderRadius": {
254
260
  "type": "string",
@@ -266,7 +272,7 @@ export class ToastNotification {
266
272
  },
267
273
  "attribute": "progress-bar-border-radius",
268
274
  "reflect": false,
269
- "defaultValue": "'5px'"
275
+ "defaultValue": "'0'"
270
276
  },
271
277
  "toastMessage": {
272
278
  "type": "string",
@@ -1 +1 @@
1
- {"version":3,"file":"toast-notification.js","sourceRoot":"","sources":["../../../../../src/components/ChatUIComponent/shared/toast-notification/toast-notification.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAoBnD,MAAM,OAAO,iBAAiB;;uBACF,OAAO;qBACT,OAAO;sBACN,MAAM;2BACD,KAAK;2BACL,OAAO;qBACb,OAAO;wBACJ,MAAM;4BACF,KAAK;0BACP,QAAQ;6BACL,OAAO;iCACH,KAAK;gCACN,gBAAgB;uCACT,KAAK;4BAChB,iBAAiB;;;IAGhD,MAAM;QACJ,OAAO,CACL,4DACE,KAAK,EAAC,iBAAiB,EACvB,KAAK,EAAE;gBACL,eAAe,EAAE,IAAI,CAAC,OAAO;gBAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,MAAM,EAAE,GAAG,IAAI,CAAC,WAAW,UAAU,IAAI,CAAC,WAAW,EAAE;gBACvD,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,UAAU,EAAE,IAAI,CAAC,UAAU;aAC5B;YAED,4DAAK,KAAK,EAAC,eAAe,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IACxD,IAAI,CAAC,YAAY,CACd;YACN,4DACE,KAAK,EAAC,oBAAoB,EAC1B,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,YAAY,EAAE,IAAI,CAAC,uBAAuB,EAAE,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE;gBAErH,4DAAK,KAAK,EAAC,cAAc,EAAC,KAAK,EAAE,EAAE,eAAe,EAAE,IAAI,CAAC,gBAAgB,EAAE,GAAI,CAC3E,CACF,CACP,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, h } from '@stencil/core';\n\n@Component({\n tag: 'toast-notification',\n shadow: true,\n styles: `\n :host { display: block; }\n .toast-container { box-shadow: 0 4px 12px var(--overlay); overflow: hidden; }\n .toast-message { padding: 8px; }\n .progress-container { width: 100%; overflow: hidden; position: relative; }\n .progress-bar {\n height: 100%; width: 100%; transform-origin: left;\n animation: progress 3s linear forwards;\n }\n @keyframes progress {\n from { width: 100%; }\n to { width: 0%; }\n }\n `,\n})\nexport class ToastNotification {\n @Prop() bgColor: string = 'white';\n @Prop() width: string = '200px';\n @Prop() height: string = 'auto';\n @Prop() borderWidth: string = '1px';\n @Prop() borderColor: string = 'black';\n @Prop() color: string = 'black';\n @Prop() fontSize: string = '14px';\n @Prop() borderRadius: string = '5px';\n @Prop() fontWeight: string = 'normal';\n @Prop() progressBarBg: string = 'white';\n @Prop() progressBarHeight: string = '5px';\n @Prop() progressBarColor: string = 'var(--success)';\n @Prop() progressBarBorderRadius: string = '5px';\n @Prop() toastMessage: string = 'Default message';\n @Prop() padding: string;\n\n render() {\n return (\n <div\n class=\"toast-container\"\n style={{\n backgroundColor: this.bgColor,\n color: this.color,\n width: this.width,\n height: this.height,\n border: `${this.borderWidth} solid ${this.borderColor}`,\n borderRadius: this.borderRadius,\n fontSize: this.fontSize,\n fontWeight: this.fontWeight,\n }}\n >\n <div class=\"toast-message\" style={{ padding: this.padding }}>\n {this.toastMessage}\n </div>\n <div\n class=\"progress-container\"\n style={{ height: this.progressBarHeight, borderRadius: this.progressBarBorderRadius, background: this.progressBarBg }}\n >\n <div class=\"progress-bar\" style={{ backgroundColor: this.progressBarColor }} />\n </div>\n </div>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"toast-notification.js","sourceRoot":"","sources":["../../../../../src/components/ChatUIComponent/shared/toast-notification/toast-notification.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAyBnD,MAAM,OAAO,iBAAiB;;uBACF,SAAS;qBACX,OAAO;sBACN,MAAM;2BACD,GAAG;2BACH,aAAa;qBACnB,SAAS;wBACN,UAAU;4BACN,QAAQ;0BACV,KAAK;6BACF,aAAa;iCACT,KAAK;gCACN,wBAAwB;uCACjB,GAAG;4BACd,iBAAiB;;;IAGhD,MAAM;QACJ,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,IAAI,GAAG,CAAC;QACxC,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,IAAI,aAAa,CAAC;QAClD,OAAO,CACL,4DACE,KAAK,EAAC,iBAAiB,EACvB,IAAI,EAAC,QAAQ,EACb,KAAK,EAAE;gBACL,eAAe,EAAE,IAAI,CAAC,OAAO;gBAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,MAAM,EAAE,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,UAAU,OAAO,EAAE;gBACrF,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,UAAU,EAAE,IAAI,CAAC,UAAU;aAC5B;YAED,4DAAK,KAAK,EAAC,eAAe,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IACxD,IAAI,CAAC,YAAY,CACd;YACN,4DACE,KAAK,EAAC,oBAAoB,EAC1B,KAAK,EAAE;oBACL,MAAM,EAAE,IAAI,CAAC,iBAAiB;oBAC9B,YAAY,EAAE,IAAI,CAAC,uBAAuB;oBAC1C,UAAU,EAAE,IAAI,CAAC,aAAa;iBAC/B;gBAED,4DAAK,KAAK,EAAC,cAAc,EAAC,KAAK,EAAE,EAAE,eAAe,EAAE,IAAI,CAAC,gBAAgB,EAAE,GAAI,CAC3E,CACF,CACP,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, h } from '@stencil/core';\n\n@Component({\n tag: 'toast-notification',\n shadow: true,\n styles: `\n :host { display: block; }\n .toast-container {\n overflow: hidden;\n box-shadow: 0 8px 24px rgba(24, 24, 27, 0.18);\n letter-spacing: -0.01em;\n line-height: 1.35;\n }\n .toast-message { padding: 8px; word-break: break-word; }\n .progress-container { width: 100%; overflow: hidden; position: relative; }\n .progress-bar {\n height: 100%; width: 100%; transform-origin: left;\n animation: progress 3.5s linear forwards;\n }\n @keyframes progress {\n from { width: 100%; }\n to { width: 0%; }\n }\n `,\n})\nexport class ToastNotification {\n @Prop() bgColor: string = '#18181b';\n @Prop() width: string = '200px';\n @Prop() height: string = 'auto';\n @Prop() borderWidth: string = '0';\n @Prop() borderColor: string = 'transparent';\n @Prop() color: string = '#ffffff';\n @Prop() fontSize: string = '0.875rem';\n @Prop() borderRadius: string = '0.5rem';\n @Prop() fontWeight: string = '600';\n @Prop() progressBarBg: string = 'transparent';\n @Prop() progressBarHeight: string = '3px';\n @Prop() progressBarColor: string = 'rgba(255,255,255,0.55)';\n @Prop() progressBarBorderRadius: string = '0';\n @Prop() toastMessage: string = 'Default message';\n @Prop() padding: string;\n\n render() {\n const borderW = this.borderWidth || '0';\n const borderC = this.borderColor || 'transparent';\n return (\n <div\n class=\"toast-container\"\n role=\"status\"\n style={{\n backgroundColor: this.bgColor,\n color: this.color,\n width: this.width,\n height: this.height,\n border: borderW === '0' || borderW === '0px' ? 'none' : `${borderW} solid ${borderC}`,\n borderRadius: this.borderRadius,\n fontSize: this.fontSize,\n fontWeight: this.fontWeight,\n }}\n >\n <div class=\"toast-message\" style={{ padding: this.padding }}>\n {this.toastMessage}\n </div>\n <div\n class=\"progress-container\"\n style={{\n height: this.progressBarHeight,\n borderRadius: this.progressBarBorderRadius,\n background: this.progressBarBg,\n }}\n >\n <div class=\"progress-bar\" style={{ backgroundColor: this.progressBarColor }} />\n </div>\n </div>\n );\n }\n}\n"]}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Map raw API / SDK errors to short user-facing copy.
3
+ * Never surface HTTP status phrases like "Unprocessable entity".
4
+ */
5
+ export function friendlyToastMessage(raw, fallback = 'Something went wrong. Try again.') {
6
+ var _a, _b;
7
+ const s = String((_b = (_a = raw === null || raw === void 0 ? void 0 : raw.message) !== null && _a !== void 0 ? _a : raw) !== null && _b !== void 0 ? _b : '')
8
+ .trim()
9
+ .replace(/\s+/g, ' ');
10
+ if (!s)
11
+ return fallback;
12
+ const lower = s.toLowerCase();
13
+ if (lower.includes('unprocessable') ||
14
+ lower.includes('422') ||
15
+ lower === 'bad request' ||
16
+ lower.includes('invalid payload')) {
17
+ return "Couldn't send that message. Please try again.";
18
+ }
19
+ if (lower.includes('network') ||
20
+ lower.includes('failed to fetch') ||
21
+ lower.includes('timeout')) {
22
+ return 'Network issue. Check your connection and try again.';
23
+ }
24
+ if (lower.includes('unauthorized') ||
25
+ lower.includes('401') ||
26
+ lower.includes('forbidden') ||
27
+ lower.includes('403')) {
28
+ return 'Session expired. Please refresh and try again.';
29
+ }
30
+ if (lower.includes('not found') || lower.includes('404')) {
31
+ return 'That chat is no longer available.';
32
+ }
33
+ // Keep short human messages; truncate giant stack/JSON blobs.
34
+ if (s.length > 120 || s.startsWith('{') || s.includes('\n'))
35
+ return fallback;
36
+ return s;
37
+ }
38
+ //# sourceMappingURL=friendly-toast-message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"friendly-toast-message.js","sourceRoot":"","sources":["../../src/lib/friendly-toast-message.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAAY,EACZ,QAAQ,GAAG,kCAAkC;;IAE7C,MAAM,CAAC,GAAG,MAAM,CAAC,MAAA,MAAC,GAA6B,aAA7B,GAAG,uBAAH,GAAG,CAA4B,OAAO,mCAAI,GAAG,mCAAI,EAAE,CAAC;SACnE,IAAI,EAAE;SACN,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACxB,IAAI,CAAC,CAAC;QAAE,OAAO,QAAQ,CAAC;IAExB,MAAM,KAAK,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAC9B,IACE,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC;QAC/B,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;QACrB,KAAK,KAAK,aAAa;QACvB,KAAK,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EACjC,CAAC;QACD,OAAO,+CAA+C,CAAC;IACzD,CAAC;IACD,IACE,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC;QACzB,KAAK,CAAC,QAAQ,CAAC,iBAAiB,CAAC;QACjC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EACzB,CAAC;QACD,OAAO,qDAAqD,CAAC;IAC/D,CAAC;IACD,IACE,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC;QAC9B,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;QACrB,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC3B,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EACrB,CAAC;QACD,OAAO,gDAAgD,CAAC;IAC1D,CAAC;IACD,IAAI,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACzD,OAAO,mCAAmC,CAAC;IAC7C,CAAC;IACD,8DAA8D;IAC9D,IAAI,CAAC,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC7E,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["/**\n * Map raw API / SDK errors to short user-facing copy.\n * Never surface HTTP status phrases like \"Unprocessable entity\".\n */\nexport function friendlyToastMessage(\n raw: unknown,\n fallback = 'Something went wrong. Try again.',\n): string {\n const s = String((raw as { message?: unknown })?.message ?? raw ?? '')\n .trim()\n .replace(/\\s+/g, ' ');\n if (!s) return fallback;\n\n const lower = s.toLowerCase();\n if (\n lower.includes('unprocessable') ||\n lower.includes('422') ||\n lower === 'bad request' ||\n lower.includes('invalid payload')\n ) {\n return \"Couldn't send that message. Please try again.\";\n }\n if (\n lower.includes('network') ||\n lower.includes('failed to fetch') ||\n lower.includes('timeout')\n ) {\n return 'Network issue. Check your connection and try again.';\n }\n if (\n lower.includes('unauthorized') ||\n lower.includes('401') ||\n lower.includes('forbidden') ||\n lower.includes('403')\n ) {\n return 'Session expired. Please refresh and try again.';\n }\n if (lower.includes('not found') || lower.includes('404')) {\n return 'That chat is no longer available.';\n }\n // Keep short human messages; truncate giant stack/JSON blobs.\n if (s.length > 120 || s.startsWith('{') || s.includes('\\n')) return fallback;\n return s;\n}\n"]}