ozdenui 0.1.0

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 (149) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +14 -0
  3. data/NOTICE +5 -0
  4. data/README.md +242 -0
  5. data/exe/ozdenui +17 -0
  6. data/lib/ozdenui/AGENTS.md +210 -0
  7. data/lib/ozdenui/COMPONENTS.md +3017 -0
  8. data/lib/ozdenui/app.rb +749 -0
  9. data/lib/ozdenui/command.rb +107 -0
  10. data/lib/ozdenui/components.rb +368 -0
  11. data/lib/ozdenui/dialogs.rb +212 -0
  12. data/lib/ozdenui/files.rb +124 -0
  13. data/lib/ozdenui/icon.png +0 -0
  14. data/lib/ozdenui/kit.json +1 -0
  15. data/lib/ozdenui/kit.rb +115 -0
  16. data/lib/ozdenui/look.rb +229 -0
  17. data/lib/ozdenui/objects.rb +652 -0
  18. data/lib/ozdenui/server.rb +270 -0
  19. data/lib/ozdenui/values.rb +273 -0
  20. data/lib/ozdenui/version.rb +15 -0
  21. data/lib/ozdenui/web/basic/LICENSE +14 -0
  22. data/lib/ozdenui/web/basic/basic.min.css +1 -0
  23. data/lib/ozdenui/web/basic/basic.min.js +78 -0
  24. data/lib/ozdenui/web/basic/font/open-sans/LICENSE.txt +206 -0
  25. data/lib/ozdenui/web/basic/font/open-sans/OpenSans-Bold.ttf +0 -0
  26. data/lib/ozdenui/web/basic/font/open-sans/OpenSans-Regular.ttf +0 -0
  27. data/lib/ozdenui/web/basic/scroll-bar.min.js +3 -0
  28. data/lib/ozdenui/web/bridge.js +584 -0
  29. data/lib/ozdenui/web/comp/accordion.js +659 -0
  30. data/lib/ozdenui/web/comp/action-button/add.png +0 -0
  31. data/lib/ozdenui/web/comp/action-button.js +521 -0
  32. data/lib/ozdenui/web/comp/action-tab-bar.js +383 -0
  33. data/lib/ozdenui/web/comp/app-bar.js +237 -0
  34. data/lib/ozdenui/web/comp/badge.js +292 -0
  35. data/lib/ozdenui/web/comp/bottom-bar.js +555 -0
  36. data/lib/ozdenui/web/comp/breadcrumbs.js +524 -0
  37. data/lib/ozdenui/web/comp/canvas.js +652 -0
  38. data/lib/ozdenui/web/comp/chat-view.js +827 -0
  39. data/lib/ozdenui/web/comp/check-box.js +490 -0
  40. data/lib/ozdenui/web/comp/code-editor.js +965 -0
  41. data/lib/ozdenui/web/comp/color-picker.js +636 -0
  42. data/lib/ozdenui/web/comp/context-menu.js +951 -0
  43. data/lib/ozdenui/web/comp/currency-field.js +209 -0
  44. data/lib/ozdenui/web/comp/data-table/arrow.svg +2 -0
  45. data/lib/ozdenui/web/comp/data-table.js +937 -0
  46. data/lib/ozdenui/web/comp/date-picker.js +1055 -0
  47. data/lib/ozdenui/web/comp/dialog.js +992 -0
  48. data/lib/ozdenui/web/comp/email-field.js +65 -0
  49. data/lib/ozdenui/web/comp/file-picker.js +920 -0
  50. data/lib/ozdenui/web/comp/filters.js +807 -0
  51. data/lib/ozdenui/web/comp/form.js +602 -0
  52. data/lib/ozdenui/web/comp/full-screen-select/arrow.svg +2 -0
  53. data/lib/ozdenui/web/comp/full-screen-select/cancel.svg +2 -0
  54. data/lib/ozdenui/web/comp/full-screen-select.js +614 -0
  55. data/lib/ozdenui/web/comp/gauge.js +439 -0
  56. data/lib/ozdenui/web/comp/graph-box.js +3911 -0
  57. data/lib/ozdenui/web/comp/grid-group.js +185 -0
  58. data/lib/ozdenui/web/comp/hold-to-confirm-button/trash-red.png +0 -0
  59. data/lib/ozdenui/web/comp/hold-to-confirm-button/trash.png +0 -0
  60. data/lib/ozdenui/web/comp/hold-to-confirm-button.js +289 -0
  61. data/lib/ozdenui/web/comp/image-view.js +598 -0
  62. data/lib/ozdenui/web/comp/item-list.js +1740 -0
  63. data/lib/ozdenui/web/comp/json-editor.js +3221 -0
  64. data/lib/ozdenui/web/comp/json-view.js +597 -0
  65. data/lib/ozdenui/web/comp/label-editor.js +1140 -0
  66. data/lib/ozdenui/web/comp/left-menu/data-table.png +0 -0
  67. data/lib/ozdenui/web/comp/left-menu/home.png +0 -0
  68. data/lib/ozdenui/web/comp/left-menu/reports.png +0 -0
  69. data/lib/ozdenui/web/comp/left-menu/setting.png +0 -0
  70. data/lib/ozdenui/web/comp/left-menu.js +548 -0
  71. data/lib/ozdenui/web/comp/line-progress-bar.js +343 -0
  72. data/lib/ozdenui/web/comp/loading-screen.js +413 -0
  73. data/lib/ozdenui/web/comp/log-view.js +530 -0
  74. data/lib/ozdenui/web/comp/login-page.js +685 -0
  75. data/lib/ozdenui/web/comp/markdown-view.js +1045 -0
  76. data/lib/ozdenui/web/comp/menu-bar.js +624 -0
  77. data/lib/ozdenui/web/comp/mini-graph-box.js +492 -0
  78. data/lib/ozdenui/web/comp/minimal-accent.js +208 -0
  79. data/lib/ozdenui/web/comp/notice.js +229 -0
  80. data/lib/ozdenui/web/comp/number-field.js +128 -0
  81. data/lib/ozdenui/web/comp/numeric-keyboard.js +298 -0
  82. data/lib/ozdenui/web/comp/page-control.js +762 -0
  83. data/lib/ozdenui/web/comp/page-header.js +191 -0
  84. data/lib/ozdenui/web/comp/password-field/hide-btn.png +0 -0
  85. data/lib/ozdenui/web/comp/password-field/hide-btn2.png +0 -0
  86. data/lib/ozdenui/web/comp/password-field/show-btn.png +0 -0
  87. data/lib/ozdenui/web/comp/password-field/show-btn2.png +0 -0
  88. data/lib/ozdenui/web/comp/password-field.js +192 -0
  89. data/lib/ozdenui/web/comp/period-bar.js +436 -0
  90. data/lib/ozdenui/web/comp/phone-field.js +322 -0
  91. data/lib/ozdenui/web/comp/progress-bar.js +992 -0
  92. data/lib/ozdenui/web/comp/property-panel.js +3639 -0
  93. data/lib/ozdenui/web/comp/radio-button.js +527 -0
  94. data/lib/ozdenui/web/comp/range-slider.js +569 -0
  95. data/lib/ozdenui/web/comp/rich-text-editor.js +1064 -0
  96. data/lib/ozdenui/web/comp/scroll-area.js +308 -0
  97. data/lib/ozdenui/web/comp/scrolling-text.js +297 -0
  98. data/lib/ozdenui/web/comp/search-input/clear-round.svg +1 -0
  99. data/lib/ozdenui/web/comp/search-input/clear.svg +1 -0
  100. data/lib/ozdenui/web/comp/search-input/filter.png +0 -0
  101. data/lib/ozdenui/web/comp/search-input/filter.svg +1 -0
  102. data/lib/ozdenui/web/comp/search-input/search.svg +1 -0
  103. data/lib/ozdenui/web/comp/search-input.js +725 -0
  104. data/lib/ozdenui/web/comp/search-results.js +596 -0
  105. data/lib/ozdenui/web/comp/select-box.js +1862 -0
  106. data/lib/ozdenui/web/comp/settings-row.js +299 -0
  107. data/lib/ozdenui/web/comp/side-panel.js +616 -0
  108. data/lib/ozdenui/web/comp/slider-field.js +952 -0
  109. data/lib/ozdenui/web/comp/slider.js +838 -0
  110. data/lib/ozdenui/web/comp/smart-button/alert-black.png +0 -0
  111. data/lib/ozdenui/web/comp/smart-button/clock.png +0 -0
  112. data/lib/ozdenui/web/comp/smart-button.js +981 -0
  113. data/lib/ozdenui/web/comp/smart-table/clock.png +0 -0
  114. data/lib/ozdenui/web/comp/smart-table/down.png +0 -0
  115. data/lib/ozdenui/web/comp/smart-table/scroll.png +0 -0
  116. data/lib/ozdenui/web/comp/smart-table/sort.png +0 -0
  117. data/lib/ozdenui/web/comp/smart-table/up.png +0 -0
  118. data/lib/ozdenui/web/comp/smart-table.js +1883 -0
  119. data/lib/ozdenui/web/comp/sortable-list.js +1181 -0
  120. data/lib/ozdenui/web/comp/spark-line-box.js +738 -0
  121. data/lib/ozdenui/web/comp/splitter.js +411 -0
  122. data/lib/ozdenui/web/comp/status-bar.js +408 -0
  123. data/lib/ozdenui/web/comp/step-bar.js +345 -0
  124. data/lib/ozdenui/web/comp/stepper.js +753 -0
  125. data/lib/ozdenui/web/comp/tabs.js +1366 -0
  126. data/lib/ozdenui/web/comp/tag-input.js +1107 -0
  127. data/lib/ozdenui/web/comp/tap-effect.js +170 -0
  128. data/lib/ozdenui/web/comp/text-area-field.js +233 -0
  129. data/lib/ozdenui/web/comp/text-field.js +1006 -0
  130. data/lib/ozdenui/web/comp/time-line.js +398 -0
  131. data/lib/ozdenui/web/comp/time-picker.js +1032 -0
  132. data/lib/ozdenui/web/comp/tiny-select/arrow.svg +1 -0
  133. data/lib/ozdenui/web/comp/tiny-select.js +322 -0
  134. data/lib/ozdenui/web/comp/tiny-table.js +283 -0
  135. data/lib/ozdenui/web/comp/toast.js +891 -0
  136. data/lib/ozdenui/web/comp/toggle.js +757 -0
  137. data/lib/ozdenui/web/comp/tool-bar.js +760 -0
  138. data/lib/ozdenui/web/comp/tooltip.js +534 -0
  139. data/lib/ozdenui/web/comp/tree-view.js +1179 -0
  140. data/lib/ozdenui/web/comp/ui-effects.js +1097 -0
  141. data/lib/ozdenui/web/comp/ui-standards.js +403 -0
  142. data/lib/ozdenui/web/comp/url-field.js +190 -0
  143. data/lib/ozdenui/web/comp/web-view.js +588 -0
  144. data/lib/ozdenui/web/components.js +123 -0
  145. data/lib/ozdenui/web/index.html +39 -0
  146. data/lib/ozdenui/window.rb +188 -0
  147. data/lib/ozdenui/window_cocoa.rb +221 -0
  148. data/lib/ozdenui.rb +32 -0
  149. metadata +200 -0
@@ -0,0 +1,891 @@
1
+ /* Bismillah */
2
+
3
+ /*
4
+
5
+ Toast - v26.09
6
+
7
+ UI COMPONENT TEMPLATE
8
+ - Short messages that come and go: "Saved", "Copied", "Could not connect"...
9
+ - Types: "success", "error", "warning", "info", "loading". Icons are drawn with SVG (no image files).
10
+ - Title, message, an action button (Ex: "Undo") and a close button.
11
+ - A time bar shows when it closes. The time stops while the mouse (or the keyboard focus)
12
+ is on the toast, and while the browser tab is hidden.
13
+ - key: A toast with the same key is updated, not added again. (Ex: pressing "Copy" many times)
14
+ - Toast.promise(): "loading" toast that becomes "success" or "error".
15
+ - Positions: "top-right", "top-center", "top-left", "bottom-right", "bottom-center", "bottom-left".
16
+ - Themes: "light", "dark", "auto" (follows the system setting).
17
+ - maxVisible: Old toasts are closed when there are too many.
18
+ - Small screens: Toasts use the full width.
19
+ - Accessibility: Errors use role="alert", others role="status". Escape closes the focused toast.
20
+ - Scale: scale multiplies every size of a toast (its style, its shadow, its motion); the scale of
21
+ Toast.options multiplies the places of the toasts (width, offsets, gap, smallScreenWidth). null (default):
22
+ Toast.options.scale, else basic.uiScale (1; a page fitted with page.fit() sets 1 / page.zoom: the toasts keep
23
+ their size on the screen).
24
+
25
+ USAGE:
26
+ Toast.success("Changes are saved.");
27
+ Toast.error("Could not save the file.", { titleText: "Upload failed", duration: 0 });
28
+ Toast.show({ type: "info", titleText: "Item deleted", messageText: "report.pdf", action: { text: "Undo", onClick: undoDelete } });
29
+ Toast.show({ key: "copy", type: "success", messageText: "Link is copied." }); // Same key: updates the visible toast
30
+ Toast.promise(saveData(), { loading: "Saving...", success: "Saved.", error: (err) => "Failed: " + err.message });
31
+ Toast.setOptions({ position: "bottom-right", theme: "dark" });
32
+ Toast.setOptions({ scale: 1.5 }); // every toast and its place x 1.5 (default: basic.uiScale)
33
+
34
+ const toast = Toast.show({ type: "loading", messageText: "Uploading 0%" });
35
+ toast.update({ messageText: "Uploading 60%" });
36
+ toast.update({ type: "success", messageText: "Uploaded." }); // Starts its timer (loading has no timer)
37
+ toast.close();
38
+
39
+ Started Date: September 2026
40
+ Webpage: https://bug7a.github.io/js-components/
41
+
42
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
43
+ Licensed under the Apache License, Version 2.0
44
+ SPDX-License-Identifier: Apache-2.0
45
+
46
+ */
47
+
48
+ "use strict";
49
+
50
+ // Default values:
51
+ const ToastDefaults = {
52
+ key: "", // Same key: updates the visible toast.
53
+ type: "info", // "success", "error", "warning", "info", "loading"
54
+ titleText: "",
55
+ messageText: "",
56
+ allowHtml: 0, // 0: titleText and messageText are shown as text. 1: As HTML (use only your own texts).
57
+ duration: null, // ms. null: Toast.options.durations[type]. 0: Stays until it is closed.
58
+ closable: 1, // 1: Close button
59
+ showProgress: 1, // 1: Time bar
60
+ pauseOnHover: 1,
61
+ action: null, // { text: "Undo", onClick: function (toast) {} } onClick returns false: the toast stays open.
62
+ position: null, // null: Toast.options.position
63
+ theme: null, // null: Toast.options.theme
64
+ scale: null, // every size multiplied (Ex: 1.5). null: Toast.options.scale
65
+ onClick: null, // function (toast) {} Click on the toast (not on the buttons)
66
+ onClose: function (self, reason) { }, // reason: "timeout", "close", "action", "limit", "api"
67
+ style: { // (its sizes are px, multiplied by scale)
68
+ card: {
69
+ round: 10,
70
+ padding: [14, 12],
71
+ gap: 12,
72
+ border: 1,
73
+ },
74
+ icon: {
75
+ size: 20,
76
+ marginTop: 1, // in the line of the title
77
+ },
78
+ texts: {
79
+ gap: 2, // between the title, the message and the action
80
+ },
81
+ title: {
82
+ fontSize: 14,
83
+ },
84
+ message: {
85
+ fontSize: 13,
86
+ },
87
+ action: { // the action button (Ex: "Undo")
88
+ fontSize: 13,
89
+ padding: [10, 4],
90
+ round: 6,
91
+ marginTop: 6,
92
+ },
93
+ close: { // the close button
94
+ size: 24,
95
+ iconSize: 16,
96
+ round: 6,
97
+ marginTop: -2, // a little up and right: its icon in the line of the title, near the corner
98
+ marginRight: -4,
99
+ },
100
+ progress: {
101
+ height: 3,
102
+ opacity: 0.45,
103
+ },
104
+ }
105
+ };
106
+
107
+ const Toast = function (params = {}) {
108
+
109
+ // WHY: The other components take styleName; a toast takes theme (the colors, also "auto") and style (the shapes).
110
+ // Without this line a styleName is kept quietly and the toast keeps the theme of the page.
111
+ if (params.styleName) console.warn("Toast: styleName is not used. The colors come with theme (\"light\", \"dark\", \"auto\", \"minimal\", \"minimalDark\"), the shapes with style.");
112
+
113
+ // Merge params: the shapes of its theme (Toast.THEMES[name].style: minimal), then the defaults
114
+ // WHY before the defaults: the shapes of a theme win over the default shapes, a style of the page over both
115
+ const themeOfParams = Toast.THEMES[params.theme || Toast.options.theme];
116
+ if (themeOfParams && themeOfParams.style) {
117
+ const ownStyle = {};
118
+ mergeIntoIfMissing(ownStyle, params.style || {});
119
+ mergeIntoIfMissing(ownStyle, themeOfParams.style);
120
+ params.style = ownStyle;
121
+ }
122
+ mergeIntoIfMissing(params, ToastDefaults);
123
+
124
+ const options = Toast.options;
125
+ const position = Toast.POSITIONS.includes(params.position) ? params.position : options.position;
126
+
127
+ // Same key: update the visible toast.
128
+ if (params.key) {
129
+ const old = Toast.list.find(function (toast) { return toast.key == params.key && !toast.isClosing; });
130
+ if (old) {
131
+ old.update(params);
132
+ old.bump();
133
+ return old;
134
+ }
135
+ }
136
+
137
+ // WHY: Only the listed values are changed later with update(). Functions and objects are kept as they are.
138
+ const action = params.action;
139
+ const onClick = params.onClick;
140
+
141
+ // Edit params, if needed:
142
+ params.scale = Toast.getScale(params.scale);
143
+ params.style = basic.scaleStyle(params.style, params.scale);
144
+ params.width = "100%";
145
+ params.height = "auto";
146
+ params.color = "transparent";
147
+ params.position = "relative"; // WHY: "position" is a basic.js property too. The toast position is kept below.
148
+
149
+ const container = Toast.getContainer(position);
150
+ const isBottom = position.startsWith("bottom");
151
+
152
+ // WHY: Toasts must be over everything. They are created in their container on the page.
153
+ const previousContainer = getDefaultContainerBox();
154
+ setDefaultContainerBox(container);
155
+
156
+ // BOX: Component container (a slot in the stack; its height is animated on close)
157
+ let box = startObject(params);
158
+
159
+ // *** PRIVATE VARIABLES:
160
+ const _s = box.style;
161
+ let timer = null; // The cancel function of box.after (stopped by remove())
162
+ let removeVisibilityEvent = null;
163
+ let remaining = 0; // ms
164
+ let startedAt = 0;
165
+ let isHovered = 0;
166
+ let isFocused = 0;
167
+ const SLIDE_X = 16 * box.scale; // px: a toast at the left or right side comes from (and goes to) that side
168
+ const SLIDE_Y = 12 * box.scale; // px: a centered toast comes from the top or the bottom
169
+ const ENTER_TIME = "0.2s";
170
+ const LEAVE_TIME = "0.16s"; // The fade out, then the closing of the space in the stack
171
+ const LEAVE_WAIT = 150; // ms: the space starts to close a little before the fade ends
172
+ const COLLAPSE_WAIT = 170; // ms: a little after the space is closed
173
+ const BUMP_TIME = 120; // ms
174
+
175
+ // *** PUBLIC VARIABLES:
176
+ // [var] "top-right", ...
177
+ box.toastPosition = position;
178
+ // [var]
179
+ box.action = action;
180
+ // [var]
181
+ box.onClick = onClick;
182
+ // [var] 1: Close animation started.
183
+ box.isClosing = 0;
184
+
185
+ // *** PRIVATE FUNCTIONS:
186
+
187
+ const getTheme = function () {
188
+ return basic.resolveTheme(Toast.THEMES, box.theme || options.theme);
189
+ };
190
+
191
+ const getDuration = function () {
192
+ if (box.duration !== null && box.duration !== undefined) return box.duration;
193
+ return options.durations[box.type] ?? 4000;
194
+ };
195
+
196
+ const getViewText = function (value) {
197
+ return (box.allowHtml == 1) ? String(value) : Toast.escapeHtml(value);
198
+ };
199
+
200
+ // The move of the enter and the close animations: { x, y } in px
201
+ const getSlideOffset = function () {
202
+ if (box.toastPosition.endsWith("left")) return { x: -SLIDE_X, y: 0 };
203
+ if (box.toastPosition.endsWith("right")) return { x: SLIDE_X, y: 0 };
204
+ return { x: 0, y: (isBottom) ? SLIDE_Y : -SLIDE_Y };
205
+ };
206
+
207
+ // Writes the values to the view. (On create and update)
208
+ const render = function () {
209
+
210
+ const theme = getTheme();
211
+ const color = theme.colors[box.type] || theme.colors.info;
212
+ const isError = (box.type == "error");
213
+
214
+ box.card.color = theme.background;
215
+ box.card.borderColor = theme.border;
216
+ box.card.boxShadow = basic.scaleCssText(theme.shadow, box.scale);
217
+ box.card.role = (isError) ? "alert" : "status";
218
+ box.card.aria = { live: (isError) ? "assertive" : "polite" };
219
+ box.card.cursor = (box.onClick) ? "pointer" : "default";
220
+
221
+ box.icon.text = Toast.getIconSvg(box.type, color, _s.icon.size);
222
+
223
+ box.lblTitle.visible = (box.titleText) ? 1 : 0;
224
+ box.lblTitle.text = getViewText(box.titleText);
225
+ box.lblTitle.textColor = theme.title;
226
+
227
+ box.lblMessage.visible = (box.messageText) ? 1 : 0;
228
+ box.lblMessage.text = getViewText(box.messageText);
229
+ box.lblMessage.textColor = (box.titleText) ? theme.message : theme.title; // WHY: Without a title, the message is the main text.
230
+
231
+ const hasAction = !!(box.action && box.action.text);
232
+ box.btnAction.visible = (hasAction) ? 1 : 0;
233
+ if (hasAction) {
234
+ box.btnAction.plainText = box.action.text;
235
+ box.btnAction.textColor = theme.actionText || color;
236
+ box.btnAction.color = theme.actionFill || Toast.alpha(color, 0.12);
237
+ }
238
+
239
+ box.btnClose.visible = (box.closable == 1) ? 1 : 0;
240
+ box.btnClose.text = Toast.getCloseSvg(theme.close, _s.close.iconSize);
241
+
242
+ box.progress.color = color;
243
+
244
+ };
245
+
246
+ // Time bar: from full to empty in ms.
247
+ const animateProgress = function (ms, fromFull) {
248
+ const style = box.progress.css;
249
+ if (fromFull) {
250
+ style.transition = "none";
251
+ style.width = "100%";
252
+ void box.progress.elem.offsetWidth; // WHY: Apply 100% before the transition starts.
253
+ }
254
+ style.transition = "width " + ms + "ms linear";
255
+ style.width = "0%";
256
+ };
257
+
258
+ const freezeProgress = function () {
259
+ const style = box.progress.css;
260
+ const width = window.getComputedStyle(box.progress.elem).width;
261
+ style.transition = "none";
262
+ style.width = width;
263
+ };
264
+
265
+ // Closes the toast after the remaining time.
266
+ const waitAndClose = function () {
267
+ startedAt = Date.now();
268
+ timer = box.after(remaining, function () {
269
+ timer = null;
270
+ box.close("timeout");
271
+ });
272
+ };
273
+
274
+ const stopTimer = function () {
275
+ if (timer) timer();
276
+ timer = null;
277
+ };
278
+
279
+ const startTimer = function () {
280
+
281
+ stopTimer();
282
+ const duration = getDuration();
283
+
284
+ const showProgress = duration > 0 && box.showProgress == 1;
285
+ box.progress.visible = (showProgress) ? 1 : 0;
286
+
287
+ if (!(duration > 0)) {
288
+ remaining = 0;
289
+ return;
290
+ }
291
+
292
+ remaining = duration;
293
+ if (isPaused()) {
294
+ // Starts when the pause ends.
295
+ box.progress.css = { transition: "none", width: "100%" };
296
+ return;
297
+ }
298
+
299
+ waitAndClose();
300
+ if (showProgress) animateProgress(remaining, true);
301
+
302
+ };
303
+
304
+ const isPaused = function () {
305
+ return (box.pauseOnHover == 1 && (isHovered || isFocused)) || document.hidden;
306
+ };
307
+
308
+ const pause = function () {
309
+ if (!timer) return;
310
+ stopTimer();
311
+ remaining = Math.max(0, remaining - (Date.now() - startedAt));
312
+ freezeProgress();
313
+ };
314
+
315
+ const resume = function () {
316
+ if (timer || !(remaining > 0) || isPaused() || box.isClosing) return;
317
+ waitAndClose();
318
+ if (box.progress.visible) animateProgress(remaining, false);
319
+ };
320
+
321
+ const updatePause = function () {
322
+ if (!box) return;
323
+ if (isPaused()) pause();
324
+ else resume();
325
+ };
326
+
327
+ const onVisibilityChange = function () {
328
+ updatePause();
329
+ };
330
+
331
+ // *** PUBLIC FUNCTIONS:
332
+
333
+ // Changes the toast and starts its timer again.
334
+ box.update = function (values = {}) {
335
+ if (!box || box.isClosing) return box;
336
+ ["type", "titleText", "messageText", "allowHtml", "duration", "closable", "showProgress", "pauseOnHover", "theme", "onClick", "action"].forEach(function (key) {
337
+ if (key in values) box[key] = values[key];
338
+ });
339
+ if (!("duration" in values)) box.duration = null; // WHY: A new type (loading -> success) uses its own duration.
340
+ render();
341
+ startTimer();
342
+ return box;
343
+ };
344
+ // USAGE: toast.update({ type: "success", messageText: "Uploaded." })
345
+
346
+ // A small move to show that the toast is updated.
347
+ box.bump = function () {
348
+ if (!box) return;
349
+ const cardStyle = box.card.css;
350
+ cardStyle.transition = "transform " + (BUMP_TIME / 1000) + "s";
351
+ cardStyle.transform = "scale(1.03)";
352
+ box.after(BUMP_TIME, function () {
353
+ cardStyle.transform = "scale(1)";
354
+ });
355
+ };
356
+
357
+ box.close = function (reason = "api") {
358
+
359
+ if (!box || box.isClosing) return;
360
+ box.isClosing = 1;
361
+
362
+ stopTimer();
363
+ if (removeVisibilityEvent) removeVisibilityEvent();
364
+ Toast.list = Toast.list.filter(function (toast) { return toast !== box; });
365
+
366
+ const self = box;
367
+ const cardStyle = self.card.css;
368
+ const move = getSlideOffset();
369
+
370
+ // 1. Fade and move out
371
+ cardStyle.transition = "opacity " + LEAVE_TIME + ", transform " + LEAVE_TIME;
372
+ cardStyle.opacity = "0";
373
+ cardStyle.transform = "translate(" + move.x + "px, " + move.y + "px) scale(0.98)";
374
+
375
+ setTimeout(function () {
376
+
377
+ // 2. Close the space in the stack
378
+ const slotStyle = self.css;
379
+ slotStyle.height = self.elem.offsetHeight + "px";
380
+ void self.elem.offsetHeight; // WHY: Apply the fixed height before the transition starts.
381
+ slotStyle.transition = "height " + LEAVE_TIME + ", padding " + LEAVE_TIME;
382
+ slotStyle.height = "0px";
383
+ slotStyle.paddingTop = "0px";
384
+ slotStyle.paddingBottom = "0px";
385
+
386
+ setTimeout(function () {
387
+ self.onClose(self, reason);
388
+ self.remove();
389
+ if (box === self) box = null;
390
+ }, COLLAPSE_WAIT);
391
+
392
+ }, LEAVE_WAIT);
393
+
394
+ };
395
+ // reason: "timeout", "close", "action", "limit", "api"
396
+
397
+ // WHY: box.superRemove is overwritten by a component that extends this one, so the local copy is called below.
398
+ const superRemove = box.remove;
399
+ box.superRemove = superRemove;
400
+ box.remove = function () {
401
+ if (!box) return; // WHY: remove() can be called twice (also by the parent's remove()).
402
+ Toast.list = Toast.list.filter(function (toast) { return toast !== box; });
403
+ superRemove.call(box); // NOTE: basic.js remove(). It cleans all the events and the objects inside.
404
+ box = null;
405
+ };
406
+
407
+ // *** OBJECT VIEW:
408
+
409
+ box.css = { overflow: "visible", boxSizing: "border-box" };
410
+ // (the gap between the toasts is a place: the scale of Toast.options, like the offsets)
411
+ box.css[(isBottom) ? "paddingTop" : "paddingBottom"] = (options.gap * Toast.getScale()) + "px";
412
+
413
+ // GROUP: Card
414
+ box.card = HGroup({
415
+ width: "100%",
416
+ height: "auto",
417
+ align: "left top",
418
+ gap: _s.card.gap,
419
+ padding: _s.card.padding,
420
+ border: _s.card.border,
421
+ round: _s.card.round,
422
+ clickable: 1,
423
+ position: "relative",
424
+ });
425
+ box.card.css = { overflow: "hidden", boxSizing: "border-box", outline: "none" };
426
+ box.card.tabIndex = -1;
427
+
428
+ // LABEL: Icon (SVG)
429
+ box.icon = Label({
430
+ text: "",
431
+ width: _s.icon.size,
432
+ height: _s.icon.size,
433
+ });
434
+ box.icon.shrink = 0;
435
+ box.icon.lineHeight = "0";
436
+ box.icon.css.marginTop = _s.icon.marginTop + "px";
437
+ box.icon.aria = { hidden: "true" };
438
+
439
+ // GROUP: Texts and action
440
+ box.textGroup = VGroup({
441
+ width: "auto",
442
+ height: "auto",
443
+ align: "left top",
444
+ gap: _s.texts.gap,
445
+ });
446
+ box.textGroup.css = { flex: "1 1 auto", minWidth: "0" };
447
+
448
+ box.lblTitle = Label({ text: "", width: "100%", fontSize: _s.title.fontSize });
449
+ box.lblTitle.css = { fontFamily: "opensans-bold", overflowWrap: "anywhere" };
450
+
451
+ box.lblMessage = Label({ text: "", width: "100%", fontSize: _s.message.fontSize });
452
+ box.lblMessage.css.overflowWrap = "anywhere";
453
+ box.lblMessage.lineHeight = "1.45";
454
+
455
+ // LABEL: Action button
456
+ box.btnAction = Label({
457
+ text: "",
458
+ fontSize: _s.action.fontSize,
459
+ padding: _s.action.padding,
460
+ round: _s.action.round,
461
+ clickable: 1,
462
+ });
463
+ box.btnAction.css = { fontFamily: "opensans-bold", marginTop: _s.action.marginTop + "px" };
464
+ box.btnAction.cursor = "pointer";
465
+ box.btnAction.tabIndex = 0;
466
+ box.btnAction.role = "button";
467
+
468
+ endGroup();
469
+
470
+ // LABEL: Close button (SVG)
471
+ box.btnClose = Label({
472
+ text: "",
473
+ width: _s.close.size,
474
+ height: _s.close.size,
475
+ round: _s.close.round,
476
+ clickable: 1,
477
+ });
478
+ box.btnClose.shrink = 0;
479
+ box.btnClose.lineHeight = "0";
480
+ box.btnClose.cursor = "pointer";
481
+ box.btnClose.elem.style.display = "flex";
482
+ const closeMargin = _s.close.marginTop + "px " + _s.close.marginRight + "px 0 0";
483
+ box.btnClose.css = { alignItems: "center", justifyContent: "center", margin: closeMargin };
484
+ box.btnClose.tabIndex = 0;
485
+ box.btnClose.role = "button";
486
+ box.btnClose.aria = { label: "Close" };
487
+
488
+ // BOX: Time bar
489
+ box.progress = Box({
490
+ width: "100%",
491
+ height: _s.progress.height,
492
+ opacity: _s.progress.opacity,
493
+ });
494
+
495
+ endGroup();
496
+
497
+ // WHY: The card is a flex group. The bar must be out of the flow, at the bottom.
498
+ box.progress.position = "absolute";
499
+ box.progress.left = 0;
500
+ box.progress.bottom = 0;
501
+
502
+ // *** OBJECT INIT CODE:
503
+
504
+ // Newest toast is next to the screen edge.
505
+ if (!isBottom && container.elem.firstChild !== box.elem) {
506
+ container.elem.insertBefore(box.elem, container.elem.firstChild);
507
+ }
508
+
509
+ // Buttons (mouse and keyboard)
510
+ const pressKey = function (event, func) {
511
+ if (event.key == "Enter" || event.key == " ") {
512
+ event.preventDefault();
513
+ func();
514
+ }
515
+ };
516
+
517
+ const runAction = function () {
518
+ // WHY isClosing: the card fades for a moment after close(); a double click ran the action (Undo) twice
519
+ if (!box || !box.action || box.isClosing) return;
520
+ const result = (typeof box.action.onClick === "function") ? box.action.onClick(box) : undefined;
521
+ if (result !== false) box.close("action");
522
+ };
523
+
524
+ box.btnAction.on("click", runAction);
525
+ box.btnAction.on("keydown", function (self, event) {
526
+ pressKey(event, runAction);
527
+ });
528
+
529
+ const closeByButton = function () {
530
+ box.close("close");
531
+ };
532
+
533
+ box.btnClose.on("click", closeByButton);
534
+ box.btnClose.on("keydown", function (self, event) {
535
+ pressKey(event, closeByButton);
536
+ });
537
+ box.btnClose.on("mouseover", function () {
538
+ box.btnClose.color = getTheme().closeHover;
539
+ });
540
+ box.btnClose.on("mouseout", function () {
541
+ box.btnClose.color = "transparent";
542
+ });
543
+
544
+ box.card.on("click", function (self, event) {
545
+ if (!box || !box.onClick) return;
546
+ if (box.btnAction.elem.contains(event.target) || box.btnClose.elem.contains(event.target)) return;
547
+ box.onClick(box);
548
+ });
549
+
550
+ box.card.on("keydown", function (self, event) {
551
+ if (event.key == "Escape" && box && box.closable == 1) box.close("close");
552
+ });
553
+
554
+ // Pause the time
555
+ box.card.on("mouseenter", function () {
556
+ isHovered = 1;
557
+ updatePause();
558
+ });
559
+ box.card.on("mouseleave", function () {
560
+ isHovered = 0;
561
+ updatePause();
562
+ });
563
+ box.card.on("focusin", function () {
564
+ isFocused = 1;
565
+ updatePause();
566
+ });
567
+ box.card.on("focusout", function () {
568
+ isFocused = 0;
569
+ updatePause();
570
+ });
571
+ removeVisibilityEvent = box.listenTo(document, "visibilitychange", onVisibilityChange);
572
+
573
+ render();
574
+
575
+ // Enter animation
576
+ const cardStyle = box.card.css;
577
+ const enterMove = getSlideOffset();
578
+ cardStyle.opacity = "0";
579
+ cardStyle.transform = "translate(" + enterMove.x + "px, " + enterMove.y + "px) scale(0.98)";
580
+ void box.card.elem.offsetWidth; // WHY: Apply the start position before the transition starts.
581
+ cardStyle.transition = "opacity " + ENTER_TIME + ", transform " + ENTER_TIME;
582
+ cardStyle.opacity = "1";
583
+ cardStyle.transform = "translate(0px, 0px) scale(1)";
584
+
585
+ Toast.list.push(box);
586
+
587
+ endObject(box);
588
+ setDefaultContainerBox(previousContainer);
589
+
590
+ startTimer();
591
+
592
+ // Too many toasts in this position: close the oldest.
593
+ const sameList = Toast.list.filter(function (toast) { return toast.toastPosition == position; });
594
+ if (sameList.length > options.maxVisible) {
595
+ sameList.slice(0, sameList.length - options.maxVisible).forEach(function (toast) { toast.close("limit"); });
596
+ }
597
+
598
+ return box;
599
+
600
+ };
601
+
602
+ // *** STATIC VARIABLES:
603
+
604
+ Toast.POSITIONS = ["top-right", "top-center", "top-left", "bottom-right", "bottom-center", "bottom-left"];
605
+
606
+ // Global options. Change with Toast.setOptions().
607
+ Toast.options = {
608
+ position: "top-right",
609
+ theme: "auto", // "light", "dark", "auto", "minimal", "minimalDark"
610
+ width: 360,
611
+ offset: 16, // Space to the screen edges
612
+ offsetTop: null, // Space to the top edge (Ex: under the header of an app). null: offset
613
+ offsetBottom: null, // Space to the bottom edge (Ex: over a tab bar). null: offset
614
+ gap: 10, // Space between toasts
615
+ maxVisible: 5, // In one position
616
+ zIndex: 45000, // WHY: over the Dialogs (4000 and up: a toast under the cover of a dialog could not be clicked, its
617
+ // Undo closed the dialog), under Notice (50000) and Tooltip (100000)
618
+ smallScreenWidth: 520, // Page width: toasts use the full width below this.
619
+ durations: { success: 3000, info: 4000, warning: 5000, error: 7000, loading: 0 },
620
+ // The px above (width, offsets, gap, smallScreenWidth) multiplied, and the scale of a toast without its own.
621
+ // null: basic.uiScale (1 / page.zoom on a page fitted with page.fit())
622
+ scale: null,
623
+ };
624
+
625
+ // *** THEMES: the colors. (The style param has the shapes and the sizes.)
626
+ // USAGE: Toast.success("Saved", { theme: "dark" })
627
+ // USAGE: Toast.setOptions({ theme: "auto" }) // Every toast: "light", "dark", "auto" (the system setting)
628
+ // NOTE: A new theme needs only the keys that differ from the light theme. actionText / actionFill: the colors of the
629
+ // action button ("": the color of the type, and a pale fill of it).
630
+ // USAGE: Toast.THEMES.ocean = { background: "#0B2239", title: "#FFFFFF" };
631
+ Toast.THEMES = {
632
+ light: {
633
+ background: "#FFFFFF",
634
+ border: "rgba(11, 11, 11, 0.08)",
635
+ shadow: "0 8px 28px rgba(0, 0, 0, 0.14)",
636
+ title: "#1B1B1A",
637
+ message: "#5F5E5A",
638
+ close: "rgba(11, 11, 11, 0.45)",
639
+ closeHover: "rgba(11, 11, 11, 0.06)",
640
+ colors: { success: "#15935F", error: "#D93F3E", warning: "#B77A00", info: "#2A78D6", loading: "#6B6A65" },
641
+ },
642
+ dark: {
643
+ background: "#262625",
644
+ border: "rgba(255, 255, 255, 0.10)",
645
+ shadow: "0 8px 28px rgba(0, 0, 0, 0.5)",
646
+ title: "rgba(255, 255, 255, 0.95)",
647
+ message: "rgba(255, 255, 255, 0.65)",
648
+ close: "rgba(255, 255, 255, 0.5)",
649
+ closeHover: "rgba(255, 255, 255, 0.08)",
650
+ colors: { success: "#3CC08A", error: "#EF6B6A", warning: "#E8B23A", info: "#5A9CF0", loading: "rgba(255, 255, 255, 0.7)" },
651
+ },
652
+ };
653
+
654
+ // The minimal theme (_designs/minimal-theme.htm): on the ground of the window with a line and no shadow; style: its
655
+ // shapes too (a theme with a style gives the shapes, under the style of the page): smaller and less round.
656
+ Toast.MINIMAL_SHAPES = {
657
+ card: { round: 4, padding: [12, 10], gap: 10, border: 1 },
658
+ icon: { size: 16, marginTop: 1 },
659
+ title: { fontSize: 13 },
660
+ message: { fontSize: 12 },
661
+ action: { fontSize: 12, padding: [0, 2], round: 4, marginTop: 4 }, // WHY no side room: a text with no fill, in the line of the message
662
+ close: { size: 20, iconSize: 14, round: 4, marginTop: -2, marginRight: -4 },
663
+ progress: { height: 2, opacity: 0.45 },
664
+ };
665
+ Toast.THEMES.minimal = {
666
+ background: "#FFFFFF",
667
+ border: Black(0.2),
668
+ shadow: "none",
669
+ title: Black(0.85),
670
+ message: Black(0.55),
671
+ close: Black(0.45),
672
+ closeHover: Black(0.05),
673
+ actionText: "#1F1F1F",
674
+ actionFill: "transparent",
675
+ colors: { success: "#2E9E74", error: "#C24A36", warning: "#B77A00", info: "#3D8BD9", loading: Black(0.55) },
676
+ style: Toast.MINIMAL_SHAPES,
677
+ };
678
+ Toast.THEMES.minimalDark = {
679
+ background: "#1A1A19",
680
+ border: White(0.18),
681
+ shadow: "none",
682
+ title: White(0.88),
683
+ message: White(0.55),
684
+ close: White(0.5),
685
+ closeHover: White(0.06),
686
+ actionText: "#EDEDEB",
687
+ actionFill: "transparent",
688
+ colors: { success: "#7FE3B5", error: "#FF9F93", warning: "#E8B23A", info: "#7FB6DE", loading: White(0.55) },
689
+ style: Toast.MINIMAL_SHAPES,
690
+ };
691
+
692
+ // [toast] Visible toasts (oldest first)
693
+ Toast.list = [];
694
+
695
+ Toast._containers = {};
696
+ Toast._isResizeListening = 0;
697
+ Toast._layoutScale = 1; // the scale of the last layoutContainers()
698
+
699
+ // *** STATIC FUNCTIONS:
700
+
701
+ Toast.show = function (params = {}) {
702
+ return Toast(params);
703
+ };
704
+
705
+ Toast.success = function (message, params = {}) {
706
+ return Toast(Object.assign({}, params, { type: "success", messageText: message }));
707
+ };
708
+
709
+ Toast.error = function (message, params = {}) {
710
+ return Toast(Object.assign({}, params, { type: "error", messageText: message }));
711
+ };
712
+
713
+ Toast.warning = function (message, params = {}) {
714
+ return Toast(Object.assign({}, params, { type: "warning", messageText: message }));
715
+ };
716
+
717
+ Toast.info = function (message, params = {}) {
718
+ return Toast(Object.assign({}, params, { type: "info", messageText: message }));
719
+ };
720
+
721
+ // A "loading" toast that becomes "success" or "error". Returns the promise.
722
+ // texts: { loading, success, error } success and error can be functions: (value) => text
723
+ Toast.promise = function (promise, texts = {}, params = {}) {
724
+
725
+ const toast = Toast(Object.assign({}, params, {
726
+ type: "loading",
727
+ messageText: texts.loading || "Loading...",
728
+ duration: 0,
729
+ closable: 0,
730
+ }));
731
+
732
+ const getText = function (value, data) {
733
+ return (typeof value === "function") ? value(data) : value;
734
+ };
735
+
736
+ promise.then(function (data) {
737
+ toast.update({ type: "success", messageText: getText(texts.success, data) || "Done.", closable: 1 });
738
+ }, function (error) {
739
+ toast.update({ type: "error", messageText: getText(texts.error, error) || "Something went wrong.", closable: 1 });
740
+ });
741
+
742
+ return promise;
743
+
744
+ };
745
+ // USAGE: Toast.promise(fetch(url), { loading: "Sending...", success: "Sent.", error: (e) => e.message })
746
+
747
+ Toast.closeAll = function () {
748
+ Toast.list.slice().forEach(function (toast) { toast.close("api"); });
749
+ };
750
+
751
+ // USAGE: Toast.setOptions({ position: "bottom-center", theme: "dark", maxVisible: 3 })
752
+ // USAGE: Toast.setOptions({ position: "top-center", offsetTop: 64 }) // under a 56 px header
753
+ Toast.setOptions = function (values = {}) {
754
+ Object.keys(values).forEach(function (key) {
755
+ if (key == "durations") Object.assign(Toast.options.durations, values.durations);
756
+ else Toast.options[key] = values[key];
757
+ });
758
+ Toast.layoutContainers();
759
+ };
760
+
761
+ // GROUP: The stack of one position (created one time, on the page)
762
+ Toast.getContainer = function (position) {
763
+
764
+ let container = Toast._containers[position];
765
+ if (container && container.elem.isConnected) {
766
+ // WHY: a page changes basic.uiScale with page.zoom, often without a resize of the window
767
+ if (Toast.getScale() !== Toast._layoutScale) Toast.layoutContainers();
768
+ return container;
769
+ }
770
+
771
+ const getAlign = function () {
772
+ if (position.endsWith("left")) return "left top";
773
+ if (position.endsWith("right")) return "right top";
774
+ return "center top";
775
+ };
776
+
777
+ const previous = getDefaultContainerBox();
778
+ setDefaultContainerBox(page);
779
+
780
+ container = VGroup({
781
+ width: Toast.options.width,
782
+ height: "auto",
783
+ align: getAlign(),
784
+ gap: 0,
785
+ });
786
+ container.css = {
787
+ alignItems: "stretch",
788
+ overflow: "visible", // WHY: Groups hide overflow. The card shadows were cut at the edges.
789
+ };
790
+ container.role = "region";
791
+ container.aria = { label: "Notifications" };
792
+
793
+ endGroup();
794
+ setDefaultContainerBox(previous);
795
+
796
+ container.toastPosition = position;
797
+ Toast._containers[position] = container;
798
+
799
+ if (!Toast._isResizeListening) {
800
+ Toast._isResizeListening = 1;
801
+ page.onResize(function () { Toast.layoutContainers(); });
802
+ }
803
+
804
+ Toast.layoutContainers();
805
+ return container;
806
+
807
+ };
808
+
809
+ // The scale of a toast: its own, else Toast.options.scale, else basic.uiScale. Toast.getScale(): of the containers
810
+ Toast.getScale = function (ownScale = null) {
811
+ return ownScale ?? Toast.options.scale ?? basic.uiScale;
812
+ };
813
+
814
+ // Places the containers. (Full width on small screens)
815
+ Toast.layoutContainers = function () {
816
+
817
+ const options = Toast.options;
818
+ const scale = Toast.getScale();
819
+ const offset = options.offset * scale;
820
+ const offsetTop = (options.offsetTop ?? options.offset) * scale;
821
+ const offsetBottom = (options.offsetBottom ?? options.offset) * scale;
822
+ // WHY smallScreenWidth x scale: page.width is in the px of the page, a fitted page has more of them
823
+ const isSmall = page.width < options.smallScreenWidth * scale;
824
+ Toast._layoutScale = scale;
825
+
826
+ Object.keys(Toast._containers).forEach(function (position) {
827
+
828
+ const container = Toast._containers[position];
829
+ const style = container.css;
830
+
831
+ // WHY: "absolute", not "fixed": the container is on page (page never scrolls). page.fit() / page.zoom give
832
+ // <body> a transform, and a fixed box is placed on the scaled <body> (a toast in the middle of a phone screen).
833
+ style.position = "absolute";
834
+ style.zIndex = String(options.zIndex);
835
+ style.top = "";
836
+ style.bottom = "";
837
+ style.left = "";
838
+ style.right = "";
839
+ style.transform = "none";
840
+ style.maxWidth = "calc(100% - " + (offset * 2) + "px)";
841
+
842
+ // WHY own top / bottom spaces: a bigger offset for a header also narrowed the toasts at the sides
843
+ if (position.startsWith("top")) style.top = offsetTop + "px";
844
+ else style.bottom = offsetBottom + "px";
845
+
846
+ if (isSmall) {
847
+ style.left = offset + "px";
848
+ style.width = "calc(100% - " + (offset * 2) + "px)";
849
+ return;
850
+ }
851
+
852
+ style.width = (options.width * scale) + "px";
853
+ if (position.endsWith("left")) style.left = offset + "px";
854
+ else if (position.endsWith("right")) style.right = offset + "px";
855
+ else {
856
+ style.left = "50%";
857
+ style.transform = "translateX(-50%)";
858
+ }
859
+
860
+ });
861
+
862
+ };
863
+
864
+ // WHY: Label.text uses innerHTML. Texts must not be read as HTML.
865
+ Toast.escapeHtml = basic.escapeHtml; // (the name is kept: other code may use it)
866
+
867
+ // "#2A78D6", 0.2 -> "rgba(42, 120, 214, 0.2)" (rgba texts are used as they are)
868
+ Toast.alpha = function (color, alpha) {
869
+ if (!/^#[0-9a-f]{6}$/i.test(color)) return color.replace(/[\d.]+\)$/, alpha + ")");
870
+ const n = parseInt(color.slice(1), 16);
871
+ return "rgba(" + (n >> 16) + ", " + ((n >> 8) & 255) + ", " + (n & 255) + ", " + alpha + ")";
872
+ };
873
+
874
+ Toast.ICON_PATHS = {
875
+ success: '<circle cx="12" cy="12" r="10"/><path d="m7.5 12.5 3 3 6-6.5"/>',
876
+ error: '<circle cx="12" cy="12" r="10"/><path d="M15 9l-6 6M9 9l6 6"/>',
877
+ warning: '<path d="M10.3 3.9 2.4 17.6A2 2 0 0 0 4.1 20.6h15.8a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z"/><path d="M12 9.5v4M12 17h.01"/>',
878
+ info: '<circle cx="12" cy="12" r="10"/><path d="M12 11v5.5M12 7.5h.01"/>',
879
+ // WHY: SVG animation (SMIL): a turning icon without a CSS file.
880
+ loading: '<circle cx="12" cy="12" r="9" opacity="0.25"/><path d="M21 12a9 9 0 0 0-9-9"><animateTransform attributeName="transform" type="rotate" from="0 12 12" to="360 12 12" dur="0.8s" repeatCount="indefinite"/></path>',
881
+ };
882
+
883
+ Toast.getIconSvg = function (type, color, size) {
884
+ return '<svg xmlns="http://www.w3.org/2000/svg" width="' + size + '" height="' + size + '" viewBox="0 0 24 24" fill="none" stroke="' + color +
885
+ '" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">' + (Toast.ICON_PATHS[type] || Toast.ICON_PATHS.info) + '</svg>';
886
+ };
887
+
888
+ Toast.getCloseSvg = function (color, size = 16) {
889
+ return '<svg xmlns="http://www.w3.org/2000/svg" width="' + size + '" height="' + size + '" viewBox="0 0 24 24" fill="none" stroke="' + color +
890
+ '" stroke-width="2" stroke-linecap="round"><path d="M6 6l12 12M18 6 6 18"/></svg>';
891
+ };