kitzo 2.0.27 → 2.0.28
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 +54 -25
- package/dist/react.d.ts +8 -5
- 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.28/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.
|
|
@@ -126,13 +126,14 @@ kitzo.clippath(selectors | element | NodeList, {
|
|
|
126
126
|
style: object,
|
|
127
127
|
});
|
|
128
128
|
```
|
|
129
|
+
|
|
129
130
|
##### TypeCheck API:
|
|
130
131
|
|
|
131
132
|
```javascript
|
|
132
133
|
kitzo.getType(type);
|
|
133
134
|
|
|
134
135
|
const data = [];
|
|
135
|
-
console.log(kitzo.getType(data)) // 'array'
|
|
136
|
+
console.log(kitzo.getType(data)); // 'array'
|
|
136
137
|
```
|
|
137
138
|
|
|
138
139
|
---
|
|
@@ -156,17 +157,32 @@ import { ToastContainer, toast, ... } from 'kitzo/react';
|
|
|
156
157
|
```jsx
|
|
157
158
|
import { toast } from 'kitzo/react';
|
|
158
159
|
|
|
159
|
-
toast.success('toast message', {});
|
|
160
|
-
toast.error('toast message', {});
|
|
160
|
+
toast.success('toast message', { duration: 2000, style: {}, showIcon: true });
|
|
161
|
+
toast.error('toast message', { duration: 2000, style: {}, showIcon: true });
|
|
162
|
+
|
|
161
163
|
toast.promise(
|
|
162
|
-
promise(),
|
|
164
|
+
promise(), // call a function that returns promise
|
|
163
165
|
{
|
|
164
166
|
loading: 'Saving...',
|
|
165
|
-
success: 'Saved',
|
|
166
|
-
error: 'Error occured',
|
|
167
|
+
success: 'Saved' | (response) => 'Saved',
|
|
168
|
+
error: 'Error occured' | (error) => 'Error occured',
|
|
167
169
|
},
|
|
168
|
-
{ duration: 2000 }
|
|
170
|
+
{ duration: 2000, style: {}, showIcon: true },
|
|
169
171
|
);
|
|
172
|
+
|
|
173
|
+
// JSX element
|
|
174
|
+
toast.custom(<MyCustomComponent />, { duration: 2000 });
|
|
175
|
+
|
|
176
|
+
// Function that receives a dismiss handler
|
|
177
|
+
toast.custom((dismiss) => (
|
|
178
|
+
<div>
|
|
179
|
+
<span>Custom toast message</span>
|
|
180
|
+
<button onClick={dismiss}>Close</button>
|
|
181
|
+
</div>
|
|
182
|
+
), { duration: 3000 | Infinity });
|
|
183
|
+
|
|
184
|
+
// (and optionally)
|
|
185
|
+
toast.custom("string");
|
|
170
186
|
```
|
|
171
187
|
|
|
172
188
|
##### Toast API Usage
|
|
@@ -179,29 +195,42 @@ function App() {
|
|
|
179
195
|
return new Promise((resolved, rejected) => {
|
|
180
196
|
setTimeout(() => {
|
|
181
197
|
Math.random() > 0.5 ? resolved('resolved') : rejected('rejected');
|
|
182
|
-
}, 2000)
|
|
183
|
-
})
|
|
198
|
+
}, 2000);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function promiseToast() {
|
|
203
|
+
toast.promise(
|
|
204
|
+
fakePromise(),
|
|
205
|
+
{
|
|
206
|
+
loading: 'Saving data...',
|
|
207
|
+
success: 'Data saved',
|
|
208
|
+
error: 'Failed saving data',
|
|
209
|
+
},
|
|
210
|
+
{ duration: 2500 },
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function customToast() {
|
|
215
|
+
toast.custom(
|
|
216
|
+
(dismiss) => (
|
|
217
|
+
<div>
|
|
218
|
+
<span>Funtion that return jsx</span>
|
|
219
|
+
<button onClick={dismiss}>Close</button>
|
|
220
|
+
</div>
|
|
221
|
+
),
|
|
222
|
+
{
|
|
223
|
+
duration: 2000,
|
|
224
|
+
},
|
|
225
|
+
);
|
|
184
226
|
}
|
|
185
227
|
|
|
186
228
|
return (
|
|
187
229
|
<div>
|
|
188
230
|
<button onClick={() => toast.success('✅ Success toast message')}>Succes</button>
|
|
189
231
|
<button onClick={() => toast.error('❌ Error toast message')}>Error</button>
|
|
190
|
-
<button
|
|
191
|
-
|
|
192
|
-
toast.promise(
|
|
193
|
-
fakePromise(),
|
|
194
|
-
{
|
|
195
|
-
loading: 'Saving data...',
|
|
196
|
-
success: 'Data saved',
|
|
197
|
-
error: 'Failed saving data',
|
|
198
|
-
},
|
|
199
|
-
{ duration: 2500 }
|
|
200
|
-
);
|
|
201
|
-
}}
|
|
202
|
-
>
|
|
203
|
-
Promise
|
|
204
|
-
</button>
|
|
232
|
+
<button onClick={promiseToast}>Promise</button>
|
|
233
|
+
<button onClick={customToast}>Custom Toast</button>
|
|
205
234
|
|
|
206
235
|
{/* Toast container must needed */}
|
|
207
236
|
<ToastContainer position="top-center" />
|
package/dist/react.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
1
3
|
export interface ToastOptions {
|
|
2
4
|
duration?: number;
|
|
3
5
|
style?: React.CSSProperties;
|
|
4
6
|
showIcon?: boolean;
|
|
5
7
|
}
|
|
6
8
|
|
|
9
|
+
export type CustomContent = string | React.ReactNode | ((dismiss: () => void) => React.ReactNode);
|
|
10
|
+
|
|
7
11
|
export interface ToastAPI {
|
|
8
12
|
success(text?: string, options?: ToastOptions): void;
|
|
9
13
|
error(text?: string, options?: ToastOptions): void;
|
|
@@ -14,12 +18,11 @@ export interface ToastAPI {
|
|
|
14
18
|
success?: string | ((res: T) => string);
|
|
15
19
|
error?: string | ((err: Error) => string);
|
|
16
20
|
},
|
|
17
|
-
options?: ToastOptions
|
|
21
|
+
options?: ToastOptions,
|
|
18
22
|
): Promise<T>;
|
|
23
|
+
custom(content: CustomContent, options?: { duration?: number | Infinity; }): void;
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
export declare const toast: ToastAPI;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
gap?: number;
|
|
25
|
-
}): JSX.Element;
|
|
27
|
+
|
|
28
|
+
export declare function ToastContainer(props: { position?: 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right'; gap?: number }): JSX.Element;
|