@r01al/simple-toast 1.0.2 → 1.0.3
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/dist/simple-toast.cjs.js +17 -4
- package/dist/simple-toast.esm.js +17 -4
- package/dist/simple-toast.min.js +1 -1
- package/dist/simple-toast.umd.js +17 -4
- package/package.json +1 -1
package/dist/simple-toast.cjs.js
CHANGED
|
@@ -47,7 +47,7 @@ function _toPropertyKey(t) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
const defaultConfig = {
|
|
50
|
-
position: '
|
|
50
|
+
position: 'bc',
|
|
51
51
|
duration: 3000,
|
|
52
52
|
theme: 'l',
|
|
53
53
|
dismissible: true,
|
|
@@ -66,7 +66,7 @@ function injectStyles() {
|
|
|
66
66
|
if (stylesInjected) return;
|
|
67
67
|
const style = document.createElement('style');
|
|
68
68
|
style.setAttribute('data-r01st', '');
|
|
69
|
-
style.textContent = "\n.r01st-container {\n position: fixed;\n z-index: 9999;\n pointer-events: none;\n padding: 16px;\n}\n.r01st-container[data-position=\"tl\"] {\n top: 0;\n left: 0;\n}\n\n.r01st-container[data-position=\"tc\"] {\n top: 0;\n left: 50%;\n margin-left: -210px;\n}\n\n.r01st-container[data-position=\"tr\"] {\n top: 0;\n right: 0;\n}\n.r01st-container[data-position=\"ml\"] {\n top: 50%;\n left: 0;\n margin-top: -50px;\n}\n\n.r01st-container[data-position=\"mc\"] {\n top: 50%;\n left: 50%;\n margin-left: -210px;\n margin-top: -50px;\n}\n\n.r01st-container[data-position=\"mr\"] {\n top: 50%;\n right: 0;\n margin-top: -50px;\n}\n.r01st-container[data-position=\"bl\"] {\n bottom: 0;\n left: 0;\n}\n\n.r01st-container[data-position=\"bc\"] {\n bottom: 0;\n left: 50%;\n margin-left: -210px;\n}\n\n.r01st-container[data-position=\"br\"] {\n bottom: 0;\n right: 0;\n}\n.r01st {\n pointer-events: auto;\n position: relative;\n min-width: 280px;\n max-width: 420px;\n padding: 16px;\n margin-bottom: 16px;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n font-size: 14px;\n line-height: 1.5;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;\n color: #ffffff;\n opacity: 0;\n transition: opacity 0.3s ease, margin-top 0.3s ease;\n margin-top: -20px;\n}\n.r01st-show {\n opacity: 1;\n margin-top: 0;\n}\n.r01st-container[data-theme=\"l\"] .r01st-success {\n background-color: #10b981;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-error {\n background-color: #ef4444;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-info {\n background-color: #3b82f6;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-warning {\n background-color: #f59e0b;\n}\n.r01st-container[data-theme=\"d\"] .r01st-success {\n background-color: #059669;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-error {\n background-color: #dc2626;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-info {\n background-color: #2563eb;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-warning {\n background-color: #d97706;\n}\n.r01st-content {\n display: inline-block;\n width: 100%;\n vertical-align: top;\n padding-
|
|
69
|
+
style.textContent = "\n.r01st-container {\n position: fixed;\n z-index: 9999;\n pointer-events: none;\n padding: 16px;\n}\n.r01st-container[data-position=\"tl\"] {\n top: 0;\n left: 0;\n}\n\n.r01st-container[data-position=\"tc\"] {\n top: 0;\n left: 50%;\n margin-left: -210px;\n}\n\n.r01st-container[data-position=\"tr\"] {\n top: 0;\n right: 0;\n}\n.r01st-container[data-position=\"ml\"] {\n top: 50%;\n left: 0;\n margin-top: -50px;\n}\n\n.r01st-container[data-position=\"mc\"] {\n top: 50%;\n left: 50%;\n margin-left: -210px;\n margin-top: -50px;\n}\n\n.r01st-container[data-position=\"mr\"] {\n top: 50%;\n right: 0;\n margin-top: -50px;\n}\n.r01st-container[data-position=\"bl\"] {\n bottom: 0;\n left: 0;\n}\n\n.r01st-container[data-position=\"bc\"] {\n bottom: 0;\n left: 50%;\n margin-left: -210px;\n}\n\n.r01st-container[data-position=\"br\"] {\n bottom: 0;\n right: 0;\n}\n.r01st {\n pointer-events: auto;\n position: relative;\n min-width: 280px;\n max-width: 420px;\n padding: 16px;\n margin-bottom: 16px;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n font-size: 14px;\n line-height: 1.5;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;\n color: #ffffff;\n opacity: 0;\n transition: opacity 0.3s ease, margin-top 0.3s ease;\n margin-top: -20px;\n}\n.r01st-show {\n opacity: 1;\n margin-top: 0;\n}\n.r01st-container[data-theme=\"l\"] .r01st-success {\n background-color: #10b981;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-error {\n background-color: #ef4444;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-info {\n background-color: #3b82f6;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-warning {\n background-color: #f59e0b;\n}\n.r01st-container[data-theme=\"d\"] .r01st-success {\n background-color: #059669;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-error {\n background-color: #dc2626;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-info {\n background-color: #2563eb;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-warning {\n background-color: #d97706;\n}\n.r01st-content {\n display: inline-block;\n width: 100%;\n vertical-align: top;\n}\n.r01st-table {\n width: 100%;\n border-collapse: collapse;\n}\n.r01st-cell {\n vertical-align: middle;\n}\n.r01st-message-cell {\n width: 100%;\n}\n.r01st-close-cell {\n width: 1%;\n padding-left: 8px;\n}\n.r01st-icon {\n display: inline-block;\n width: 20px;\n height: 20px;\n vertical-align: middle;\n margin-right: 12px;\n}\n\n.r01st-icon svg {\n width: 100%;\n height: 100%;\n display: block;\n}\n.r01st-message {\n display: inline-block;\n vertical-align: middle;\n word-wrap: break-word;\n max-width: calc(100% - 32px);\n}\n.r01st-close {\n background: transparent;\n border: none;\n color: #ffffff;\n font-size: 24px;\n line-height: 1;\n cursor: pointer;\n padding: 0;\n width: 24px;\n height: 24px;\n text-align: center;\n border-radius: 4px;\n opacity: 0.8;\n}\n\n.r01st-close:hover {\n background-color: rgba(255, 255, 255, 0.2);\n opacity: 1;\n}\n\n.r01st-close:focus {\n outline: 2px solid #ffffff;\n outline-offset: 2px;\n}\n.r01st-container[data-position^=\"b\"] .r01st {\n margin-top: 0;\n margin-bottom: -20px;\n}\n\n.r01st-container[data-position^=\"b\"] .r01st-show {\n margin-bottom: 16px;\n}\n@media (max-width: 480px) {\n .r01st-container {\n left: 0 !important;\n right: 0 !important;\n margin-left: 0 !important;\n padding: 8px;\n }\n\n .r01st {\n min-width: auto;\n max-width: none;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .r01st {\n transition: opacity 0.2s;\n margin-top: 0;\n }\n}\n@media print {\n .r01st-container {\n display: none;\n }\n}\n";
|
|
70
70
|
document.head.appendChild(style);
|
|
71
71
|
stylesInjected = true;
|
|
72
72
|
}
|
|
@@ -123,14 +123,27 @@ function createToastElement(message, type, dismissible, className, id, onClose)
|
|
|
123
123
|
messageEl.className = 'r01st-message';
|
|
124
124
|
messageEl.textContent = message;
|
|
125
125
|
content.appendChild(messageEl);
|
|
126
|
-
toastEl.appendChild(content);
|
|
127
126
|
if (dismissible) {
|
|
127
|
+
const layoutTable = document.createElement('table');
|
|
128
|
+
layoutTable.className = 'r01st-table';
|
|
129
|
+
const layoutRow = document.createElement('tr');
|
|
130
|
+
const messageCell = document.createElement('td');
|
|
131
|
+
messageCell.className = 'r01st-cell r01st-message-cell';
|
|
132
|
+
messageCell.appendChild(content);
|
|
133
|
+
const closeCell = document.createElement('td');
|
|
134
|
+
closeCell.className = 'r01st-cell r01st-close-cell';
|
|
128
135
|
const closeBtn = document.createElement('button');
|
|
129
136
|
closeBtn.className = 'r01st-close';
|
|
130
137
|
closeBtn.innerHTML = '×';
|
|
131
138
|
closeBtn.setAttribute('aria-label', 'Close notification');
|
|
132
139
|
closeBtn.onclick = onClose;
|
|
133
|
-
|
|
140
|
+
closeCell.appendChild(closeBtn);
|
|
141
|
+
layoutRow.appendChild(messageCell);
|
|
142
|
+
layoutRow.appendChild(closeCell);
|
|
143
|
+
layoutTable.appendChild(layoutRow);
|
|
144
|
+
toastEl.appendChild(layoutTable);
|
|
145
|
+
} else {
|
|
146
|
+
toastEl.appendChild(content);
|
|
134
147
|
}
|
|
135
148
|
return toastEl;
|
|
136
149
|
}
|
package/dist/simple-toast.esm.js
CHANGED
|
@@ -43,7 +43,7 @@ function _toPropertyKey(t) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
const defaultConfig = {
|
|
46
|
-
position: '
|
|
46
|
+
position: 'bc',
|
|
47
47
|
duration: 3000,
|
|
48
48
|
theme: 'l',
|
|
49
49
|
dismissible: true,
|
|
@@ -62,7 +62,7 @@ function injectStyles() {
|
|
|
62
62
|
if (stylesInjected) return;
|
|
63
63
|
const style = document.createElement('style');
|
|
64
64
|
style.setAttribute('data-r01st', '');
|
|
65
|
-
style.textContent = "\n.r01st-container {\n position: fixed;\n z-index: 9999;\n pointer-events: none;\n padding: 16px;\n}\n.r01st-container[data-position=\"tl\"] {\n top: 0;\n left: 0;\n}\n\n.r01st-container[data-position=\"tc\"] {\n top: 0;\n left: 50%;\n margin-left: -210px;\n}\n\n.r01st-container[data-position=\"tr\"] {\n top: 0;\n right: 0;\n}\n.r01st-container[data-position=\"ml\"] {\n top: 50%;\n left: 0;\n margin-top: -50px;\n}\n\n.r01st-container[data-position=\"mc\"] {\n top: 50%;\n left: 50%;\n margin-left: -210px;\n margin-top: -50px;\n}\n\n.r01st-container[data-position=\"mr\"] {\n top: 50%;\n right: 0;\n margin-top: -50px;\n}\n.r01st-container[data-position=\"bl\"] {\n bottom: 0;\n left: 0;\n}\n\n.r01st-container[data-position=\"bc\"] {\n bottom: 0;\n left: 50%;\n margin-left: -210px;\n}\n\n.r01st-container[data-position=\"br\"] {\n bottom: 0;\n right: 0;\n}\n.r01st {\n pointer-events: auto;\n position: relative;\n min-width: 280px;\n max-width: 420px;\n padding: 16px;\n margin-bottom: 16px;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n font-size: 14px;\n line-height: 1.5;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;\n color: #ffffff;\n opacity: 0;\n transition: opacity 0.3s ease, margin-top 0.3s ease;\n margin-top: -20px;\n}\n.r01st-show {\n opacity: 1;\n margin-top: 0;\n}\n.r01st-container[data-theme=\"l\"] .r01st-success {\n background-color: #10b981;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-error {\n background-color: #ef4444;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-info {\n background-color: #3b82f6;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-warning {\n background-color: #f59e0b;\n}\n.r01st-container[data-theme=\"d\"] .r01st-success {\n background-color: #059669;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-error {\n background-color: #dc2626;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-info {\n background-color: #2563eb;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-warning {\n background-color: #d97706;\n}\n.r01st-content {\n display: inline-block;\n width: 100%;\n vertical-align: top;\n padding-
|
|
65
|
+
style.textContent = "\n.r01st-container {\n position: fixed;\n z-index: 9999;\n pointer-events: none;\n padding: 16px;\n}\n.r01st-container[data-position=\"tl\"] {\n top: 0;\n left: 0;\n}\n\n.r01st-container[data-position=\"tc\"] {\n top: 0;\n left: 50%;\n margin-left: -210px;\n}\n\n.r01st-container[data-position=\"tr\"] {\n top: 0;\n right: 0;\n}\n.r01st-container[data-position=\"ml\"] {\n top: 50%;\n left: 0;\n margin-top: -50px;\n}\n\n.r01st-container[data-position=\"mc\"] {\n top: 50%;\n left: 50%;\n margin-left: -210px;\n margin-top: -50px;\n}\n\n.r01st-container[data-position=\"mr\"] {\n top: 50%;\n right: 0;\n margin-top: -50px;\n}\n.r01st-container[data-position=\"bl\"] {\n bottom: 0;\n left: 0;\n}\n\n.r01st-container[data-position=\"bc\"] {\n bottom: 0;\n left: 50%;\n margin-left: -210px;\n}\n\n.r01st-container[data-position=\"br\"] {\n bottom: 0;\n right: 0;\n}\n.r01st {\n pointer-events: auto;\n position: relative;\n min-width: 280px;\n max-width: 420px;\n padding: 16px;\n margin-bottom: 16px;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n font-size: 14px;\n line-height: 1.5;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;\n color: #ffffff;\n opacity: 0;\n transition: opacity 0.3s ease, margin-top 0.3s ease;\n margin-top: -20px;\n}\n.r01st-show {\n opacity: 1;\n margin-top: 0;\n}\n.r01st-container[data-theme=\"l\"] .r01st-success {\n background-color: #10b981;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-error {\n background-color: #ef4444;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-info {\n background-color: #3b82f6;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-warning {\n background-color: #f59e0b;\n}\n.r01st-container[data-theme=\"d\"] .r01st-success {\n background-color: #059669;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-error {\n background-color: #dc2626;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-info {\n background-color: #2563eb;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-warning {\n background-color: #d97706;\n}\n.r01st-content {\n display: inline-block;\n width: 100%;\n vertical-align: top;\n}\n.r01st-table {\n width: 100%;\n border-collapse: collapse;\n}\n.r01st-cell {\n vertical-align: middle;\n}\n.r01st-message-cell {\n width: 100%;\n}\n.r01st-close-cell {\n width: 1%;\n padding-left: 8px;\n}\n.r01st-icon {\n display: inline-block;\n width: 20px;\n height: 20px;\n vertical-align: middle;\n margin-right: 12px;\n}\n\n.r01st-icon svg {\n width: 100%;\n height: 100%;\n display: block;\n}\n.r01st-message {\n display: inline-block;\n vertical-align: middle;\n word-wrap: break-word;\n max-width: calc(100% - 32px);\n}\n.r01st-close {\n background: transparent;\n border: none;\n color: #ffffff;\n font-size: 24px;\n line-height: 1;\n cursor: pointer;\n padding: 0;\n width: 24px;\n height: 24px;\n text-align: center;\n border-radius: 4px;\n opacity: 0.8;\n}\n\n.r01st-close:hover {\n background-color: rgba(255, 255, 255, 0.2);\n opacity: 1;\n}\n\n.r01st-close:focus {\n outline: 2px solid #ffffff;\n outline-offset: 2px;\n}\n.r01st-container[data-position^=\"b\"] .r01st {\n margin-top: 0;\n margin-bottom: -20px;\n}\n\n.r01st-container[data-position^=\"b\"] .r01st-show {\n margin-bottom: 16px;\n}\n@media (max-width: 480px) {\n .r01st-container {\n left: 0 !important;\n right: 0 !important;\n margin-left: 0 !important;\n padding: 8px;\n }\n\n .r01st {\n min-width: auto;\n max-width: none;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .r01st {\n transition: opacity 0.2s;\n margin-top: 0;\n }\n}\n@media print {\n .r01st-container {\n display: none;\n }\n}\n";
|
|
66
66
|
document.head.appendChild(style);
|
|
67
67
|
stylesInjected = true;
|
|
68
68
|
}
|
|
@@ -119,14 +119,27 @@ function createToastElement(message, type, dismissible, className, id, onClose)
|
|
|
119
119
|
messageEl.className = 'r01st-message';
|
|
120
120
|
messageEl.textContent = message;
|
|
121
121
|
content.appendChild(messageEl);
|
|
122
|
-
toastEl.appendChild(content);
|
|
123
122
|
if (dismissible) {
|
|
123
|
+
const layoutTable = document.createElement('table');
|
|
124
|
+
layoutTable.className = 'r01st-table';
|
|
125
|
+
const layoutRow = document.createElement('tr');
|
|
126
|
+
const messageCell = document.createElement('td');
|
|
127
|
+
messageCell.className = 'r01st-cell r01st-message-cell';
|
|
128
|
+
messageCell.appendChild(content);
|
|
129
|
+
const closeCell = document.createElement('td');
|
|
130
|
+
closeCell.className = 'r01st-cell r01st-close-cell';
|
|
124
131
|
const closeBtn = document.createElement('button');
|
|
125
132
|
closeBtn.className = 'r01st-close';
|
|
126
133
|
closeBtn.innerHTML = '×';
|
|
127
134
|
closeBtn.setAttribute('aria-label', 'Close notification');
|
|
128
135
|
closeBtn.onclick = onClose;
|
|
129
|
-
|
|
136
|
+
closeCell.appendChild(closeBtn);
|
|
137
|
+
layoutRow.appendChild(messageCell);
|
|
138
|
+
layoutRow.appendChild(closeCell);
|
|
139
|
+
layoutTable.appendChild(layoutRow);
|
|
140
|
+
toastEl.appendChild(layoutTable);
|
|
141
|
+
} else {
|
|
142
|
+
toastEl.appendChild(content);
|
|
130
143
|
}
|
|
131
144
|
return toastEl;
|
|
132
145
|
}
|
package/dist/simple-toast.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).SimpleToast={})}(this,function(n){"use strict";function t(n,t,e){return(t=function(n){var t=function(n,t){if("object"!=typeof n||!n)return n;var e=n[Symbol.toPrimitive];if(void 0!==e){var r=e.call(n,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(n)}(n,"string");return"symbol"==typeof t?t:t+""}(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function e(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})),e.push.apply(e,r)}return e}function r(n){for(var r=1;arguments.length>r;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?e(Object(o),!0).forEach(function(e){t(n,e,o[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(o,t))})}return n}let o=r({},{position:"
|
|
1
|
+
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).SimpleToast={})}(this,function(n){"use strict";function t(n,t,e){return(t=function(n){var t=function(n,t){if("object"!=typeof n||!n)return n;var e=n[Symbol.toPrimitive];if(void 0!==e){var r=e.call(n,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(n)}(n,"string");return"symbol"==typeof t?t:t+""}(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function e(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})),e.push.apply(e,r)}return e}function r(n){for(var r=1;arguments.length>r;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?e(Object(o),!0).forEach(function(e){t(n,e,o[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(o,t))})}return n}let o=r({},{position:"bc",duration:3e3,theme:"l",dismissible:!0,maxToasts:10});function i(){return o}let a=!1;let s=null;function l(n,t){return function(){if(a)return;const n=document.createElement("style");n.setAttribute("data-r01st",""),n.textContent='\n.r01st-container {\n position: fixed;\n z-index: 9999;\n pointer-events: none;\n padding: 16px;\n}\n.r01st-container[data-position="tl"] {\n top: 0;\n left: 0;\n}\n\n.r01st-container[data-position="tc"] {\n top: 0;\n left: 50%;\n margin-left: -210px;\n}\n\n.r01st-container[data-position="tr"] {\n top: 0;\n right: 0;\n}\n.r01st-container[data-position="ml"] {\n top: 50%;\n left: 0;\n margin-top: -50px;\n}\n\n.r01st-container[data-position="mc"] {\n top: 50%;\n left: 50%;\n margin-left: -210px;\n margin-top: -50px;\n}\n\n.r01st-container[data-position="mr"] {\n top: 50%;\n right: 0;\n margin-top: -50px;\n}\n.r01st-container[data-position="bl"] {\n bottom: 0;\n left: 0;\n}\n\n.r01st-container[data-position="bc"] {\n bottom: 0;\n left: 50%;\n margin-left: -210px;\n}\n\n.r01st-container[data-position="br"] {\n bottom: 0;\n right: 0;\n}\n.r01st {\n pointer-events: auto;\n position: relative;\n min-width: 280px;\n max-width: 420px;\n padding: 16px;\n margin-bottom: 16px;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n font-size: 14px;\n line-height: 1.5;\n font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;\n color: #ffffff;\n opacity: 0;\n transition: opacity 0.3s ease, margin-top 0.3s ease;\n margin-top: -20px;\n}\n.r01st-show {\n opacity: 1;\n margin-top: 0;\n}\n.r01st-container[data-theme="l"] .r01st-success {\n background-color: #10b981;\n}\n\n.r01st-container[data-theme="l"] .r01st-error {\n background-color: #ef4444;\n}\n\n.r01st-container[data-theme="l"] .r01st-info {\n background-color: #3b82f6;\n}\n\n.r01st-container[data-theme="l"] .r01st-warning {\n background-color: #f59e0b;\n}\n.r01st-container[data-theme="d"] .r01st-success {\n background-color: #059669;\n}\n\n.r01st-container[data-theme="d"] .r01st-error {\n background-color: #dc2626;\n}\n\n.r01st-container[data-theme="d"] .r01st-info {\n background-color: #2563eb;\n}\n\n.r01st-container[data-theme="d"] .r01st-warning {\n background-color: #d97706;\n}\n.r01st-content {\n display: inline-block;\n width: 100%;\n vertical-align: top;\n}\n.r01st-table {\n width: 100%;\n border-collapse: collapse;\n}\n.r01st-cell {\n vertical-align: middle;\n}\n.r01st-message-cell {\n width: 100%;\n}\n.r01st-close-cell {\n width: 1%;\n padding-left: 8px;\n}\n.r01st-icon {\n display: inline-block;\n width: 20px;\n height: 20px;\n vertical-align: middle;\n margin-right: 12px;\n}\n\n.r01st-icon svg {\n width: 100%;\n height: 100%;\n display: block;\n}\n.r01st-message {\n display: inline-block;\n vertical-align: middle;\n word-wrap: break-word;\n max-width: calc(100% - 32px);\n}\n.r01st-close {\n background: transparent;\n border: none;\n color: #ffffff;\n font-size: 24px;\n line-height: 1;\n cursor: pointer;\n padding: 0;\n width: 24px;\n height: 24px;\n text-align: center;\n border-radius: 4px;\n opacity: 0.8;\n}\n\n.r01st-close:hover {\n background-color: rgba(255, 255, 255, 0.2);\n opacity: 1;\n}\n\n.r01st-close:focus {\n outline: 2px solid #ffffff;\n outline-offset: 2px;\n}\n.r01st-container[data-position^="b"] .r01st {\n margin-top: 0;\n margin-bottom: -20px;\n}\n\n.r01st-container[data-position^="b"] .r01st-show {\n margin-bottom: 16px;\n}\n@media (max-width: 480px) {\n .r01st-container {\n left: 0 !important;\n right: 0 !important;\n margin-left: 0 !important;\n padding: 8px;\n }\n\n .r01st {\n min-width: auto;\n max-width: none;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .r01st {\n transition: opacity 0.2s;\n margin-top: 0;\n }\n}\n@media print {\n .r01st-container {\n display: none;\n }\n}\n',document.head.appendChild(n),a=!0}(),!s||s.getAttribute("data-position")===n&&s.getAttribute("data-theme")===t||(s.parentNode.removeChild(s),s=null),s||(s=document.createElement("div"),s.className="r01st-container",s.setAttribute("role","region"),s.setAttribute("aria-label","Notifications"),s.setAttribute("aria-live","polite"),s.setAttribute("data-position",n),s.setAttribute("data-theme",t),document.body.appendChild(s)),s}let c=0;const d=new Map;function p(n){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const e=r(r({},i()),t),{position:o,duration:a,dismissible:s,theme:p,className:m,type:f="info"}=e,g=++c;if(d.size>=i().maxToasts){u(d.keys().next().value)}const b=l(o,p),h=function(n,t,e,r,o,i){const a=document.createElement("div");a.className="r01st r01st-"+t+(r?" "+r:""),a.setAttribute("role","alert"),a.setAttribute("data-toast-id",o);const s=document.createElement("div");s.className="r01st-content";const l=document.createElement("span");l.className="r01st-icon",l.innerHTML=function(n){const t={success:'<svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/></svg>',error:'<svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"/></svg>',info:'<svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"/></svg>',warning:'<svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clip-rule="evenodd"/></svg>'};return t[n]||t.info}(t),l.setAttribute("aria-hidden","true"),s.appendChild(l);const c=document.createElement("span");if(c.className="r01st-message",c.textContent=n,s.appendChild(c),e){const n=document.createElement("table");n.className="r01st-table";const t=document.createElement("tr"),e=document.createElement("td");e.className="r01st-cell r01st-message-cell",e.appendChild(s);const r=document.createElement("td");r.className="r01st-cell r01st-close-cell";const o=document.createElement("button");o.className="r01st-close",o.innerHTML="×",o.setAttribute("aria-label","Close notification"),o.onclick=i,r.appendChild(o),t.appendChild(e),t.appendChild(r),n.appendChild(t),a.appendChild(n)}else a.appendChild(s);return a}(n,f,s,m,g,()=>u(g));var v;b.appendChild(h),v=h,requestAnimationFrame(()=>{v.className=v.className+" r01st-show"});const x={element:h,timeoutId:null};return a>0&&(x.timeoutId=setTimeout(()=>u(g),a)),d.set(g,x),g}function u(n){const t=d.get(n);if(!t)return;const{element:e,timeoutId:r}=t;r&&clearTimeout(r),d.delete(n),function(n,t){n.className=n.className.replace(" r01st-show",""),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t&&t()},300)}(e,()=>{var n;n=d.size,s&&0===n&&(s.parentNode.removeChild(s),s=null)})}function m(n){return p(n,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}m.success=function(n){return m(n,r(r({},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),{},{type:"success"}))},m.error=function(n){return m(n,r(r({},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),{},{type:"error"}))},m.info=function(n){return m(n,r(r({},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),{},{type:"info"}))},m.warning=function(n){return m(n,r(r({},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),{},{type:"warning"}))},m.dismiss=u,m.dismissAll=function(){Array.from(d.keys()).forEach(n=>u(n))},n.configure=function(n){o=r(r({},o),n)},n.default=m,n.toast=m,Object.defineProperty(n,"__esModule",{value:!0})});
|
package/dist/simple-toast.umd.js
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
const defaultConfig = {
|
|
52
|
-
position: '
|
|
52
|
+
position: 'bc',
|
|
53
53
|
duration: 3000,
|
|
54
54
|
theme: 'l',
|
|
55
55
|
dismissible: true,
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
if (stylesInjected) return;
|
|
69
69
|
const style = document.createElement('style');
|
|
70
70
|
style.setAttribute('data-r01st', '');
|
|
71
|
-
style.textContent = "\n.r01st-container {\n position: fixed;\n z-index: 9999;\n pointer-events: none;\n padding: 16px;\n}\n.r01st-container[data-position=\"tl\"] {\n top: 0;\n left: 0;\n}\n\n.r01st-container[data-position=\"tc\"] {\n top: 0;\n left: 50%;\n margin-left: -210px;\n}\n\n.r01st-container[data-position=\"tr\"] {\n top: 0;\n right: 0;\n}\n.r01st-container[data-position=\"ml\"] {\n top: 50%;\n left: 0;\n margin-top: -50px;\n}\n\n.r01st-container[data-position=\"mc\"] {\n top: 50%;\n left: 50%;\n margin-left: -210px;\n margin-top: -50px;\n}\n\n.r01st-container[data-position=\"mr\"] {\n top: 50%;\n right: 0;\n margin-top: -50px;\n}\n.r01st-container[data-position=\"bl\"] {\n bottom: 0;\n left: 0;\n}\n\n.r01st-container[data-position=\"bc\"] {\n bottom: 0;\n left: 50%;\n margin-left: -210px;\n}\n\n.r01st-container[data-position=\"br\"] {\n bottom: 0;\n right: 0;\n}\n.r01st {\n pointer-events: auto;\n position: relative;\n min-width: 280px;\n max-width: 420px;\n padding: 16px;\n margin-bottom: 16px;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n font-size: 14px;\n line-height: 1.5;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;\n color: #ffffff;\n opacity: 0;\n transition: opacity 0.3s ease, margin-top 0.3s ease;\n margin-top: -20px;\n}\n.r01st-show {\n opacity: 1;\n margin-top: 0;\n}\n.r01st-container[data-theme=\"l\"] .r01st-success {\n background-color: #10b981;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-error {\n background-color: #ef4444;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-info {\n background-color: #3b82f6;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-warning {\n background-color: #f59e0b;\n}\n.r01st-container[data-theme=\"d\"] .r01st-success {\n background-color: #059669;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-error {\n background-color: #dc2626;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-info {\n background-color: #2563eb;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-warning {\n background-color: #d97706;\n}\n.r01st-content {\n display: inline-block;\n width: 100%;\n vertical-align: top;\n padding-
|
|
71
|
+
style.textContent = "\n.r01st-container {\n position: fixed;\n z-index: 9999;\n pointer-events: none;\n padding: 16px;\n}\n.r01st-container[data-position=\"tl\"] {\n top: 0;\n left: 0;\n}\n\n.r01st-container[data-position=\"tc\"] {\n top: 0;\n left: 50%;\n margin-left: -210px;\n}\n\n.r01st-container[data-position=\"tr\"] {\n top: 0;\n right: 0;\n}\n.r01st-container[data-position=\"ml\"] {\n top: 50%;\n left: 0;\n margin-top: -50px;\n}\n\n.r01st-container[data-position=\"mc\"] {\n top: 50%;\n left: 50%;\n margin-left: -210px;\n margin-top: -50px;\n}\n\n.r01st-container[data-position=\"mr\"] {\n top: 50%;\n right: 0;\n margin-top: -50px;\n}\n.r01st-container[data-position=\"bl\"] {\n bottom: 0;\n left: 0;\n}\n\n.r01st-container[data-position=\"bc\"] {\n bottom: 0;\n left: 50%;\n margin-left: -210px;\n}\n\n.r01st-container[data-position=\"br\"] {\n bottom: 0;\n right: 0;\n}\n.r01st {\n pointer-events: auto;\n position: relative;\n min-width: 280px;\n max-width: 420px;\n padding: 16px;\n margin-bottom: 16px;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n font-size: 14px;\n line-height: 1.5;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;\n color: #ffffff;\n opacity: 0;\n transition: opacity 0.3s ease, margin-top 0.3s ease;\n margin-top: -20px;\n}\n.r01st-show {\n opacity: 1;\n margin-top: 0;\n}\n.r01st-container[data-theme=\"l\"] .r01st-success {\n background-color: #10b981;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-error {\n background-color: #ef4444;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-info {\n background-color: #3b82f6;\n}\n\n.r01st-container[data-theme=\"l\"] .r01st-warning {\n background-color: #f59e0b;\n}\n.r01st-container[data-theme=\"d\"] .r01st-success {\n background-color: #059669;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-error {\n background-color: #dc2626;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-info {\n background-color: #2563eb;\n}\n\n.r01st-container[data-theme=\"d\"] .r01st-warning {\n background-color: #d97706;\n}\n.r01st-content {\n display: inline-block;\n width: 100%;\n vertical-align: top;\n}\n.r01st-table {\n width: 100%;\n border-collapse: collapse;\n}\n.r01st-cell {\n vertical-align: middle;\n}\n.r01st-message-cell {\n width: 100%;\n}\n.r01st-close-cell {\n width: 1%;\n padding-left: 8px;\n}\n.r01st-icon {\n display: inline-block;\n width: 20px;\n height: 20px;\n vertical-align: middle;\n margin-right: 12px;\n}\n\n.r01st-icon svg {\n width: 100%;\n height: 100%;\n display: block;\n}\n.r01st-message {\n display: inline-block;\n vertical-align: middle;\n word-wrap: break-word;\n max-width: calc(100% - 32px);\n}\n.r01st-close {\n background: transparent;\n border: none;\n color: #ffffff;\n font-size: 24px;\n line-height: 1;\n cursor: pointer;\n padding: 0;\n width: 24px;\n height: 24px;\n text-align: center;\n border-radius: 4px;\n opacity: 0.8;\n}\n\n.r01st-close:hover {\n background-color: rgba(255, 255, 255, 0.2);\n opacity: 1;\n}\n\n.r01st-close:focus {\n outline: 2px solid #ffffff;\n outline-offset: 2px;\n}\n.r01st-container[data-position^=\"b\"] .r01st {\n margin-top: 0;\n margin-bottom: -20px;\n}\n\n.r01st-container[data-position^=\"b\"] .r01st-show {\n margin-bottom: 16px;\n}\n@media (max-width: 480px) {\n .r01st-container {\n left: 0 !important;\n right: 0 !important;\n margin-left: 0 !important;\n padding: 8px;\n }\n\n .r01st {\n min-width: auto;\n max-width: none;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .r01st {\n transition: opacity 0.2s;\n margin-top: 0;\n }\n}\n@media print {\n .r01st-container {\n display: none;\n }\n}\n";
|
|
72
72
|
document.head.appendChild(style);
|
|
73
73
|
stylesInjected = true;
|
|
74
74
|
}
|
|
@@ -125,14 +125,27 @@
|
|
|
125
125
|
messageEl.className = 'r01st-message';
|
|
126
126
|
messageEl.textContent = message;
|
|
127
127
|
content.appendChild(messageEl);
|
|
128
|
-
toastEl.appendChild(content);
|
|
129
128
|
if (dismissible) {
|
|
129
|
+
const layoutTable = document.createElement('table');
|
|
130
|
+
layoutTable.className = 'r01st-table';
|
|
131
|
+
const layoutRow = document.createElement('tr');
|
|
132
|
+
const messageCell = document.createElement('td');
|
|
133
|
+
messageCell.className = 'r01st-cell r01st-message-cell';
|
|
134
|
+
messageCell.appendChild(content);
|
|
135
|
+
const closeCell = document.createElement('td');
|
|
136
|
+
closeCell.className = 'r01st-cell r01st-close-cell';
|
|
130
137
|
const closeBtn = document.createElement('button');
|
|
131
138
|
closeBtn.className = 'r01st-close';
|
|
132
139
|
closeBtn.innerHTML = '×';
|
|
133
140
|
closeBtn.setAttribute('aria-label', 'Close notification');
|
|
134
141
|
closeBtn.onclick = onClose;
|
|
135
|
-
|
|
142
|
+
closeCell.appendChild(closeBtn);
|
|
143
|
+
layoutRow.appendChild(messageCell);
|
|
144
|
+
layoutRow.appendChild(closeCell);
|
|
145
|
+
layoutTable.appendChild(layoutRow);
|
|
146
|
+
toastEl.appendChild(layoutTable);
|
|
147
|
+
} else {
|
|
148
|
+
toastEl.appendChild(content);
|
|
136
149
|
}
|
|
137
150
|
return toastEl;
|
|
138
151
|
}
|