kitzo 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/react.esm.js +23 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ npm i kitzo
|
|
|
25
25
|
or
|
|
26
26
|
|
|
27
27
|
```javascript
|
|
28
|
-
<script src="https://cdn.jsdelivr.net/npm/kitzo@2.0.
|
|
28
|
+
<script src="https://cdn.jsdelivr.net/npm/kitzo@2.0.5/dist/kitzo.umd.min.js"></script>
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
> Attach this script tag in the html head tag and you are good to go.
|
package/dist/react.esm.js
CHANGED
|
@@ -319,6 +319,7 @@ function LoadingSvg() {
|
|
|
319
319
|
})));
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
+
const GAP = 10;
|
|
322
323
|
function Toast({
|
|
323
324
|
toast,
|
|
324
325
|
setToasts,
|
|
@@ -328,32 +329,35 @@ function Toast({
|
|
|
328
329
|
useLayoutEffect(() => {
|
|
329
330
|
if (!ref.current) return;
|
|
330
331
|
const h = ref.current.getBoundingClientRect().height;
|
|
331
|
-
setToasts(prev =>
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
332
|
+
setToasts(prev => {
|
|
333
|
+
const idx = prev.findIndex(t => t.options.id === toast.id);
|
|
334
|
+
if (idx === -1) return prev;
|
|
335
|
+
const newToasts = [...prev];
|
|
336
|
+
newToasts[idx] = {
|
|
337
|
+
...newToasts[idx],
|
|
338
|
+
height: h
|
|
339
|
+
};
|
|
340
|
+
let offset = 0;
|
|
341
|
+
for (let i = 0; i < newToasts.length; i++) {
|
|
342
|
+
newToasts[i] = {
|
|
343
|
+
...newToasts[i],
|
|
344
|
+
offset
|
|
345
|
+
};
|
|
346
|
+
offset += newToasts[i].height + GAP;
|
|
343
347
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
}
|
|
348
|
+
return newToasts;
|
|
349
|
+
});
|
|
350
|
+
}, [setToasts, toast.id]);
|
|
351
|
+
const transformY = position.includes('bottom') ? `translateY(-${toast.offset || 0}px)` : `translateY(${toast.offset || 0}px)`;
|
|
348
352
|
return /*#__PURE__*/React.createElement("div", {
|
|
349
353
|
ref: ref,
|
|
350
354
|
className: "toast",
|
|
351
355
|
style: {
|
|
352
|
-
transform:
|
|
356
|
+
transform: transformY,
|
|
353
357
|
...getToastPosition(position)
|
|
354
358
|
}
|
|
355
359
|
}, /*#__PURE__*/React.createElement("div", {
|
|
356
|
-
className: `toast-content ${toast.leaving ? 'exit' : ''}`
|
|
360
|
+
className: `toast-content${position.includes('bottom') ? '-bottom' : ''} ${toast.leaving ? 'exit' : ''}`
|
|
357
361
|
}, toast.type === 'loading' && /*#__PURE__*/React.createElement(LoadingSvg, null), toast.type === 'success' && /*#__PURE__*/React.createElement(SuccessSvg, null), toast.type === 'error' && /*#__PURE__*/React.createElement(ErrorSvg, null), /*#__PURE__*/React.createElement("span", null, toast.text)));
|
|
358
362
|
}
|
|
359
363
|
function getToastPosition(position) {
|
|
@@ -389,6 +393,7 @@ function ToastContainer(props) {
|
|
|
389
393
|
const unsub = subscribe(toast => {
|
|
390
394
|
const duration = toast.options.duration;
|
|
391
395
|
const id = toast.options.id;
|
|
396
|
+
console.log(id);
|
|
392
397
|
setToasts(prev => {
|
|
393
398
|
const exists = prev.some(t => t.options.id === id);
|
|
394
399
|
if (exists) {
|