@temboplus/frontend-react-core 0.1.3-beta.2 → 0.1.3-beta.21
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/CloseCircleOutlined-CMilRURi.js +3 -0
- package/dist/CloseCircleOutlined-CMilRURi.js.map +1 -0
- package/dist/CloseCircleOutlined-CSHx89Jn.js +3 -0
- package/dist/CloseCircleOutlined-CSHx89Jn.js.map +1 -0
- package/dist/InfoCircleOutlined-DR9DmuN-.js +5 -0
- package/dist/InfoCircleOutlined-DR9DmuN-.js.map +1 -0
- package/dist/InfoCircleOutlined-Hx86sClq.js +5 -0
- package/dist/InfoCircleOutlined-Hx86sClq.js.map +1 -0
- package/dist/alerts/index.cjs.js +1 -1
- package/dist/alerts/index.cjs.js.map +1 -1
- package/dist/alerts/index.js +1 -1
- package/dist/alerts/index.js.map +1 -1
- package/dist/dialogs/index.cjs.js +3 -1
- package/dist/dialogs/index.cjs.js.map +1 -1
- package/dist/dialogs/index.js +3 -1
- package/dist/dialogs/index.js.map +1 -1
- package/dist/features/alerts/alert.js +18 -18
- package/dist/features/dialogs/tembo-confirm.js +11 -11
- package/dist/features/notifications/tembo-notify.d.ts +32 -105
- package/dist/features/notifications/tembo-notify.js +102 -111
- package/dist/features/notifications/toast-config.d.ts +4 -6
- package/dist/features/notifications/toast-config.js +28 -21
- package/dist/features/notifications/toast-container.d.ts +13 -3
- package/dist/features/notifications/toast-container.js +80 -9
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/notifications/index.cjs.js +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/providers.d.ts +2 -32
- package/dist/providers.js +3 -24
- package/dist/tembo-notify-BbTi1OnP.js +3 -0
- package/dist/tembo-notify-BbTi1OnP.js.map +1 -0
- package/dist/tembo-notify-C09rXp6m.js +3 -0
- package/dist/tembo-notify-C09rXp6m.js.map +1 -0
- package/dist/theme/{colors.d.ts → deprecated/colors.d.ts} +55 -23
- package/dist/theme/deprecated/colors.js +212 -0
- package/dist/theme/deprecated/theme-provider.d.ts +100 -0
- package/dist/theme/deprecated/theme-provider.js +405 -0
- package/dist/theme/index.cjs.js +1 -1
- package/dist/theme/index.d.ts +3 -2
- package/dist/theme/index.js +1 -1
- package/dist/theme/theme-config.d.ts +15 -0
- package/dist/theme/theme-config.js +735 -0
- package/dist/theme/theme-provider.d.ts +13 -71
- package/dist/theme/theme-provider.js +21 -387
- package/dist/theme/tokens/colors.d.ts +108 -0
- package/dist/theme/tokens/colors.js +236 -0
- package/dist/theme/tokens/constants.d.ts +126 -0
- package/dist/theme/tokens/constants.js +126 -0
- package/dist/theme-provider-CCkR2IcZ.js +11 -0
- package/dist/theme-provider-CCkR2IcZ.js.map +1 -0
- package/dist/theme-provider-CCwq2x0C.js +2 -0
- package/dist/theme-provider-CCwq2x0C.js.map +1 -0
- package/dist/theme-provider-D2HR_D4s.js +11 -0
- package/dist/theme-provider-D2HR_D4s.js.map +1 -0
- package/dist/theme-provider-dbj9jb7X.js +2 -0
- package/dist/theme-provider-dbj9jb7X.js.map +1 -0
- package/dist/validation/index.cjs.js.map +1 -1
- package/dist/validation/index.js.map +1 -1
- package/package.json +17 -18
- package/dist/InfoCircleOutlined-B7d2aRfV.js +0 -7
- package/dist/InfoCircleOutlined-B7d2aRfV.js.map +0 -1
- package/dist/InfoCircleOutlined-DYs90hdV.js +0 -7
- package/dist/InfoCircleOutlined-DYs90hdV.js.map +0 -1
- package/dist/ZoomOutOutlined-BL6A5RSq.js +0 -2
- package/dist/ZoomOutOutlined-BL6A5RSq.js.map +0 -1
- package/dist/ZoomOutOutlined-BY_CCwq7.js +0 -2
- package/dist/ZoomOutOutlined-BY_CCwq7.js.map +0 -1
- package/dist/tembo-notify-C-QGduBt.js +0 -2
- package/dist/tembo-notify-C-QGduBt.js.map +0 -1
- package/dist/tembo-notify-D-uOV3t0.js +0 -2
- package/dist/tembo-notify-D-uOV3t0.js.map +0 -1
- package/dist/theme/colors.js +0 -138
- package/dist/theme-provider-D_oV1J_K.js +0 -11
- package/dist/theme-provider-D_oV1J_K.js.map +0 -1
- package/dist/theme-provider-Dqvy24OD.js +0 -11
- package/dist/theme-provider-Dqvy24OD.js.map +0 -1
- /package/dist/theme/{constants.d.ts → deprecated/constants.d.ts} +0 -0
- /package/dist/theme/{constants.js → deprecated/constants.js} +0 -0
|
@@ -1,124 +1,51 @@
|
|
|
1
1
|
import { ToastOptions, ToastContent, Id } from 'react-toastify';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { ColorPalette } from '../../theme/tokens/colors.js';
|
|
3
|
+
import { UIConstants } from '../../theme/tokens/constants.js';
|
|
4
|
+
/**
|
|
5
|
+
* Message input - can be simple string or object with title and description
|
|
6
|
+
*/
|
|
7
|
+
export type NotifyMessage = ToastContent | {
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
};
|
|
11
|
+
export interface NotifyOptions extends Omit<ToastOptions, 'type'> {
|
|
12
|
+
toastId?: Id;
|
|
8
13
|
duration?: number | false;
|
|
9
|
-
/**
|
|
10
|
-
* Custom position for the notification
|
|
11
|
-
*/
|
|
12
|
-
position?: ToastOptions['position'];
|
|
13
|
-
/**
|
|
14
|
-
* Callback when notification is clicked
|
|
15
|
-
*/
|
|
16
14
|
onClick?: () => void;
|
|
17
|
-
/**
|
|
18
|
-
* Callback when notification is closed
|
|
19
|
-
*/
|
|
20
15
|
onClose?: () => void;
|
|
21
16
|
}
|
|
22
17
|
/**
|
|
23
18
|
* TemboNotify - Unified notification system
|
|
24
|
-
*
|
|
25
|
-
* Wraps react-toastify with consistent styling and behavior
|
|
26
|
-
* aligned with Tembo's design system.
|
|
27
|
-
*
|
|
28
|
-
* Note: This class needs to be initialized with theme tokens before use.
|
|
29
|
-
* Call TemboNotify.init(colors, constants) in your app setup.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```typescript
|
|
33
|
-
* // In your app setup (e.g., App.tsx)
|
|
34
|
-
* const { colors, constants } = useTemboTheme();
|
|
35
|
-
* useEffect(() => {
|
|
36
|
-
* TemboNotify.init(colors, constants);
|
|
37
|
-
* }, [colors, constants]);
|
|
38
|
-
*
|
|
39
|
-
* // Then use anywhere in your app
|
|
40
|
-
* TemboNotify.success('Payment sent successfully!');
|
|
41
|
-
*
|
|
42
|
-
* // With options
|
|
43
|
-
* TemboNotify.error('Payment failed', {
|
|
44
|
-
* duration: 8000,
|
|
45
|
-
* onClick: () => console.log('Error clicked')
|
|
46
|
-
* });
|
|
47
|
-
*
|
|
48
|
-
* // Loading with promise
|
|
49
|
-
* const loadingId = TemboNotify.loading('Processing payment...');
|
|
50
|
-
* await processPayment();
|
|
51
|
-
* TemboNotify.success('Payment complete!', { id: loadingId });
|
|
52
|
-
*
|
|
53
|
-
* // Promise-based
|
|
54
|
-
* TemboNotify.promise(
|
|
55
|
-
* apiCall(),
|
|
56
|
-
* {
|
|
57
|
-
* pending: 'Processing...',
|
|
58
|
-
* success: 'Done!',
|
|
59
|
-
* error: 'Failed!'
|
|
60
|
-
* }
|
|
61
|
-
* );
|
|
62
|
-
* ```
|
|
63
19
|
*/
|
|
64
20
|
export declare class TemboNotify {
|
|
65
21
|
private static configs;
|
|
66
|
-
|
|
67
|
-
* Initialize TemboNotify with theme tokens
|
|
68
|
-
* Must be called before using any notification methods
|
|
69
|
-
*/
|
|
70
|
-
static init(colors: TemboColorPalette, constants: TemboUIConstants): void;
|
|
71
|
-
/**
|
|
72
|
-
* Get current toast configs, throws if not initialized
|
|
73
|
-
*/
|
|
22
|
+
static init(colors: ColorPalette, constants: UIConstants): void;
|
|
74
23
|
private static getConfigs;
|
|
75
24
|
/**
|
|
76
|
-
*
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
static
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
static
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
static
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
* Returns an ID that can be used to update/dismiss it
|
|
94
|
-
*/
|
|
95
|
-
static loading(message: ToastContent, options?: Omit<NotifyOptions, 'duration'>): Id;
|
|
96
|
-
/**
|
|
97
|
-
* Update an existing notification
|
|
98
|
-
*/
|
|
25
|
+
* Format message content for display
|
|
26
|
+
* - title only → bold
|
|
27
|
+
* - description only → weight 500
|
|
28
|
+
* - title + description → stacked
|
|
29
|
+
*/
|
|
30
|
+
private static formatMessage;
|
|
31
|
+
private static buildOptions;
|
|
32
|
+
private static getSuccessConfig;
|
|
33
|
+
private static getErrorConfig;
|
|
34
|
+
private static getWarningConfig;
|
|
35
|
+
private static getInfoConfig;
|
|
36
|
+
private static getLoadingConfig;
|
|
37
|
+
static success(message: NotifyMessage, options?: NotifyOptions): Id;
|
|
38
|
+
static error(message: NotifyMessage, options?: NotifyOptions): Id;
|
|
39
|
+
static warning(message: NotifyMessage, options?: NotifyOptions): Id;
|
|
40
|
+
static info(message: NotifyMessage, options?: NotifyOptions): Id;
|
|
41
|
+
static loading(message: NotifyMessage, options?: Omit<NotifyOptions, 'duration'>): Id;
|
|
99
42
|
static update(id: Id, options: {
|
|
100
43
|
type?: 'success' | 'error' | 'warning' | 'info';
|
|
101
|
-
message?:
|
|
44
|
+
message?: NotifyMessage;
|
|
102
45
|
autoClose?: number | false;
|
|
46
|
+
render?: ToastContent;
|
|
103
47
|
}): void;
|
|
104
|
-
|
|
105
|
-
* Dismiss a specific notification by ID
|
|
106
|
-
*/
|
|
107
|
-
static dismiss(id: Id): void;
|
|
108
|
-
/**
|
|
109
|
-
* Dismiss all notifications
|
|
110
|
-
*/
|
|
48
|
+
static dismiss(id?: Id): void;
|
|
111
49
|
static dismissAll(): void;
|
|
112
|
-
/**
|
|
113
|
-
* Check if a notification is active
|
|
114
|
-
*/
|
|
115
50
|
static isActive(id: Id): boolean;
|
|
116
|
-
/**
|
|
117
|
-
* Handle promise-based operations with notifications
|
|
118
|
-
*/
|
|
119
|
-
static promise<T>(promise: Promise<T>, messages: {
|
|
120
|
-
pending: ToastContent;
|
|
121
|
-
success: ToastContent<T>;
|
|
122
|
-
error: ToastContent | ((error: any) => ToastContent);
|
|
123
|
-
}, options?: NotifyOptions): Promise<T>;
|
|
124
51
|
}
|
|
@@ -1,149 +1,140 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
3
|
import { toast } from 'react-toastify';
|
|
2
4
|
import { buildToastConfigs } from './toast-config.js';
|
|
5
|
+
/**
|
|
6
|
+
* Simple fallback config when TemboNotify.init hasn't been called yet.
|
|
7
|
+
*/
|
|
8
|
+
const FALLBACK_BASE_CONFIG = {
|
|
9
|
+
position: 'top-right',
|
|
10
|
+
autoClose: 4000, // ~4 seconds for everything except loading
|
|
11
|
+
hideProgressBar: true,
|
|
12
|
+
closeOnClick: true,
|
|
13
|
+
pauseOnHover: true,
|
|
14
|
+
draggable: true,
|
|
15
|
+
closeButton: false,
|
|
16
|
+
};
|
|
3
17
|
/**
|
|
4
18
|
* TemboNotify - Unified notification system
|
|
5
|
-
*
|
|
6
|
-
* Wraps react-toastify with consistent styling and behavior
|
|
7
|
-
* aligned with Tembo's design system.
|
|
8
|
-
*
|
|
9
|
-
* Note: This class needs to be initialized with theme tokens before use.
|
|
10
|
-
* Call TemboNotify.init(colors, constants) in your app setup.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* // In your app setup (e.g., App.tsx)
|
|
15
|
-
* const { colors, constants } = useTemboTheme();
|
|
16
|
-
* useEffect(() => {
|
|
17
|
-
* TemboNotify.init(colors, constants);
|
|
18
|
-
* }, [colors, constants]);
|
|
19
|
-
*
|
|
20
|
-
* // Then use anywhere in your app
|
|
21
|
-
* TemboNotify.success('Payment sent successfully!');
|
|
22
|
-
*
|
|
23
|
-
* // With options
|
|
24
|
-
* TemboNotify.error('Payment failed', {
|
|
25
|
-
* duration: 8000,
|
|
26
|
-
* onClick: () => console.log('Error clicked')
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* // Loading with promise
|
|
30
|
-
* const loadingId = TemboNotify.loading('Processing payment...');
|
|
31
|
-
* await processPayment();
|
|
32
|
-
* TemboNotify.success('Payment complete!', { id: loadingId });
|
|
33
|
-
*
|
|
34
|
-
* // Promise-based
|
|
35
|
-
* TemboNotify.promise(
|
|
36
|
-
* apiCall(),
|
|
37
|
-
* {
|
|
38
|
-
* pending: 'Processing...',
|
|
39
|
-
* success: 'Done!',
|
|
40
|
-
* error: 'Failed!'
|
|
41
|
-
* }
|
|
42
|
-
* );
|
|
43
|
-
* ```
|
|
44
19
|
*/
|
|
45
20
|
export class TemboNotify {
|
|
46
|
-
/**
|
|
47
|
-
* Initialize TemboNotify with theme tokens
|
|
48
|
-
* Must be called before using any notification methods
|
|
49
|
-
*/
|
|
50
21
|
static init(colors, constants) {
|
|
51
22
|
this.configs = buildToastConfigs(colors, constants);
|
|
52
23
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Get current toast configs, throws if not initialized
|
|
55
|
-
*/
|
|
56
24
|
static getConfigs() {
|
|
57
|
-
if (!this.configs) {
|
|
58
|
-
throw new Error('TemboNotify not initialized. Call TemboNotify.init(colors, constants) before using notifications.');
|
|
59
|
-
}
|
|
60
25
|
return this.configs;
|
|
61
26
|
}
|
|
62
27
|
/**
|
|
63
|
-
*
|
|
28
|
+
* Format message content for display
|
|
29
|
+
* - title only → bold
|
|
30
|
+
* - description only → weight 500
|
|
31
|
+
* - title + description → stacked
|
|
64
32
|
*/
|
|
65
|
-
static
|
|
66
|
-
|
|
33
|
+
static formatMessage(message) {
|
|
34
|
+
if (message && typeof message === 'object' && !('$$typeof' in message)) {
|
|
35
|
+
const hasTitle = !!message.title;
|
|
36
|
+
const hasDescription = !!message.description;
|
|
37
|
+
if (hasTitle && hasDescription) {
|
|
38
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [_jsx("div", { style: { fontWeight: 500, fontSize: 14 }, children: message.title }), _jsx("div", { style: { fontSize: 13, fontWeight: 400, opacity: 0.96 }, children: message.description })] }));
|
|
39
|
+
}
|
|
40
|
+
if (hasTitle && !hasDescription) {
|
|
41
|
+
return (_jsx("div", { style: { fontWeight: 500, fontSize: 14 }, children: message.title }));
|
|
42
|
+
}
|
|
43
|
+
if (!hasTitle && hasDescription) {
|
|
44
|
+
return (_jsx("div", { style: { fontSize: 13, fontWeight: 500 }, children: message.description }));
|
|
45
|
+
}
|
|
46
|
+
// Empty object case
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
return message;
|
|
50
|
+
}
|
|
51
|
+
static buildOptions(baseConfig, options) {
|
|
52
|
+
const _a = options || {}, { duration, toastId, onClick, onClose } = _a, restOptions = __rest(_a, ["duration", "toastId", "onClick", "onClose"]);
|
|
53
|
+
const effectiveBase = baseConfig !== null && baseConfig !== void 0 ? baseConfig : FALLBACK_BASE_CONFIG;
|
|
54
|
+
return Object.assign(Object.assign(Object.assign({}, effectiveBase), restOptions), { // includes custom icon if provided
|
|
55
|
+
toastId, autoClose: duration !== undefined
|
|
56
|
+
? duration || false
|
|
57
|
+
: effectiveBase.autoClose, onClick,
|
|
58
|
+
onClose });
|
|
59
|
+
}
|
|
60
|
+
static getSuccessConfig() {
|
|
61
|
+
var _a, _b;
|
|
67
62
|
const configs = this.getConfigs();
|
|
68
|
-
return
|
|
63
|
+
return (_b = (_a = configs === null || configs === void 0 ? void 0 : configs.successConfig) !== null && _a !== void 0 ? _a : configs === null || configs === void 0 ? void 0 : configs.baseConfig) !== null && _b !== void 0 ? _b : undefined;
|
|
69
64
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
*/
|
|
73
|
-
static error(message, options) {
|
|
74
|
-
var _a;
|
|
65
|
+
static getErrorConfig() {
|
|
66
|
+
var _a, _b;
|
|
75
67
|
const configs = this.getConfigs();
|
|
76
|
-
return
|
|
68
|
+
return (_b = (_a = configs === null || configs === void 0 ? void 0 : configs.errorConfig) !== null && _a !== void 0 ? _a : configs === null || configs === void 0 ? void 0 : configs.baseConfig) !== null && _b !== void 0 ? _b : undefined;
|
|
77
69
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
*/
|
|
81
|
-
static warning(message, options) {
|
|
82
|
-
var _a;
|
|
70
|
+
static getWarningConfig() {
|
|
71
|
+
var _a, _b;
|
|
83
72
|
const configs = this.getConfigs();
|
|
84
|
-
return
|
|
73
|
+
return (_b = (_a = configs === null || configs === void 0 ? void 0 : configs.warningConfig) !== null && _a !== void 0 ? _a : configs === null || configs === void 0 ? void 0 : configs.baseConfig) !== null && _b !== void 0 ? _b : undefined;
|
|
85
74
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
*/
|
|
89
|
-
static info(message, options) {
|
|
90
|
-
var _a;
|
|
75
|
+
static getInfoConfig() {
|
|
76
|
+
var _a, _b;
|
|
91
77
|
const configs = this.getConfigs();
|
|
92
|
-
return
|
|
78
|
+
return (_b = (_a = configs === null || configs === void 0 ? void 0 : configs.infoConfig) !== null && _a !== void 0 ? _a : configs === null || configs === void 0 ? void 0 : configs.baseConfig) !== null && _b !== void 0 ? _b : undefined;
|
|
93
79
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
* Returns an ID that can be used to update/dismiss it
|
|
97
|
-
*/
|
|
98
|
-
static loading(message, options) {
|
|
80
|
+
static getLoadingConfig() {
|
|
81
|
+
var _a, _b;
|
|
99
82
|
const configs = this.getConfigs();
|
|
100
|
-
return
|
|
83
|
+
return (_b = (_a = configs === null || configs === void 0 ? void 0 : configs.loadingConfig) !== null && _a !== void 0 ? _a : configs === null || configs === void 0 ? void 0 : configs.baseConfig) !== null && _b !== void 0 ? _b : undefined;
|
|
101
84
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
85
|
+
static success(message, options) {
|
|
86
|
+
const content = this.formatMessage(message);
|
|
87
|
+
const toastOptions = this.buildOptions(this.getSuccessConfig(), options);
|
|
88
|
+
return toast.success(content, toastOptions);
|
|
89
|
+
}
|
|
90
|
+
static error(message, options) {
|
|
91
|
+
const content = this.formatMessage(message);
|
|
92
|
+
const toastOptions = this.buildOptions(this.getErrorConfig(), options);
|
|
93
|
+
return toast.error(content, toastOptions);
|
|
94
|
+
}
|
|
95
|
+
static warning(message, options) {
|
|
96
|
+
const content = this.formatMessage(message);
|
|
97
|
+
const toastOptions = this.buildOptions(this.getWarningConfig(), options);
|
|
98
|
+
return toast.warning(content, toastOptions);
|
|
99
|
+
}
|
|
100
|
+
static info(message, options) {
|
|
101
|
+
const content = this.formatMessage(message);
|
|
102
|
+
const toastOptions = this.buildOptions(this.getInfoConfig(), options);
|
|
103
|
+
return toast.info(content, toastOptions);
|
|
104
|
+
}
|
|
105
|
+
static loading(message, options) {
|
|
106
106
|
var _a;
|
|
107
|
+
const content = this.formatMessage(message);
|
|
108
|
+
const _b = options || {}, { toastId, onClick, onClose } = _b, restOptions = __rest(_b, ["toastId", "onClick", "onClose"]);
|
|
109
|
+
const baseConfig = (_a = this.getLoadingConfig()) !== null && _a !== void 0 ? _a : FALLBACK_BASE_CONFIG;
|
|
110
|
+
return toast.loading(content, Object.assign(Object.assign(Object.assign({}, baseConfig), restOptions), { toastId,
|
|
111
|
+
onClick,
|
|
112
|
+
onClose }));
|
|
113
|
+
}
|
|
114
|
+
static update(id, options) {
|
|
115
|
+
var _a, _b;
|
|
107
116
|
const configs = this.getConfigs();
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
117
|
+
const typeConfig = options.type && configs
|
|
118
|
+
? {
|
|
119
|
+
success: configs.successConfig,
|
|
120
|
+
error: configs.errorConfig,
|
|
121
|
+
warning: configs.warningConfig,
|
|
122
|
+
info: configs.infoConfig,
|
|
123
|
+
}[options.type]
|
|
124
|
+
: undefined;
|
|
125
|
+
const content = options.message
|
|
126
|
+
? this.formatMessage(options.message)
|
|
127
|
+
: options.render;
|
|
128
|
+
toast.update(id, Object.assign({ render: content, type: options.type, isLoading: false, autoClose: (_b = (_a = options.autoClose) !== null && _a !== void 0 ? _a : typeConfig === null || typeConfig === void 0 ? void 0 : typeConfig.autoClose) !== null && _b !== void 0 ? _b : FALLBACK_BASE_CONFIG.autoClose }, (typeConfig !== null && typeConfig !== void 0 ? typeConfig : {})));
|
|
115
129
|
}
|
|
116
|
-
/**
|
|
117
|
-
* Dismiss a specific notification by ID
|
|
118
|
-
*/
|
|
119
130
|
static dismiss(id) {
|
|
120
131
|
toast.dismiss(id);
|
|
121
132
|
}
|
|
122
|
-
/**
|
|
123
|
-
* Dismiss all notifications
|
|
124
|
-
*/
|
|
125
133
|
static dismissAll() {
|
|
126
134
|
toast.dismiss();
|
|
127
135
|
}
|
|
128
|
-
/**
|
|
129
|
-
* Check if a notification is active
|
|
130
|
-
*/
|
|
131
136
|
static isActive(id) {
|
|
132
137
|
return toast.isActive(id);
|
|
133
138
|
}
|
|
134
|
-
/**
|
|
135
|
-
* Handle promise-based operations with notifications
|
|
136
|
-
*/
|
|
137
|
-
static promise(promise, messages, options) {
|
|
138
|
-
var _a, _b;
|
|
139
|
-
const configs = this.getConfigs();
|
|
140
|
-
return toast.promise(promise, {
|
|
141
|
-
pending: Object.assign({ render: messages.pending }, configs.loadingConfig),
|
|
142
|
-
success: Object.assign(Object.assign({ render: messages.success }, configs.successConfig), { autoClose: (_a = options === null || options === void 0 ? void 0 : options.duration) !== null && _a !== void 0 ? _a : configs.successConfig.autoClose }),
|
|
143
|
-
error: Object.assign(Object.assign({ render: messages.error }, configs.errorConfig), { autoClose: (_b = options === null || options === void 0 ? void 0 : options.duration) !== null && _b !== void 0 ? _b : configs.errorConfig.autoClose }),
|
|
144
|
-
}, {
|
|
145
|
-
position: options === null || options === void 0 ? void 0 : options.position,
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
139
|
}
|
|
149
140
|
TemboNotify.configs = null;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { ToastOptions } from 'react-toastify';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* This function is called with theme values to generate toast configs
|
|
6
|
-
*/
|
|
7
|
-
export declare const buildToastConfigs: (colors: TemboColorPalette, constants: TemboUIConstants) => {
|
|
2
|
+
import { ColorPalette } from '../../theme/tokens/colors.js';
|
|
3
|
+
import { UIConstants } from '../../theme/tokens/constants.js';
|
|
4
|
+
export declare const buildToastConfigs: (colors: ColorPalette, constants: UIConstants) => {
|
|
8
5
|
loadingConfig: ToastOptions<unknown>;
|
|
9
6
|
infoConfig: ToastOptions<unknown>;
|
|
10
7
|
warningConfig: ToastOptions<unknown>;
|
|
11
8
|
errorConfig: ToastOptions<unknown>;
|
|
12
9
|
successConfig: ToastOptions<unknown>;
|
|
13
10
|
baseConfig: ToastOptions<unknown>;
|
|
11
|
+
colors: ColorPalette;
|
|
14
12
|
};
|
|
15
13
|
export type ToastConfigs = ReturnType<typeof buildToastConfigs>;
|
|
@@ -1,47 +1,53 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { CheckCircleOutlined, CloseCircleOutlined, ExclamationCircleOutlined, InfoCircleOutlined, } from '@ant-design/icons';
|
|
3
|
-
/**
|
|
4
|
-
* Build toast configurations from theme tokens
|
|
5
|
-
* This function is called with theme values to generate toast configs
|
|
6
|
-
*/
|
|
2
|
+
import { CheckCircleOutlined, CloseCircleOutlined, ExclamationCircleOutlined, InfoCircleOutlined, LoadingOutlined, } from '@ant-design/icons';
|
|
7
3
|
export const buildToastConfigs = (colors, constants) => {
|
|
8
4
|
/**
|
|
9
|
-
*
|
|
5
|
+
* Base = WHITE background for everything unless overridden
|
|
10
6
|
*/
|
|
11
7
|
const baseConfig = {
|
|
12
8
|
position: 'top-right',
|
|
13
9
|
autoClose: 4000,
|
|
14
|
-
hideProgressBar:
|
|
10
|
+
hideProgressBar: true,
|
|
15
11
|
closeOnClick: true,
|
|
16
12
|
pauseOnHover: true,
|
|
17
13
|
draggable: true,
|
|
18
|
-
|
|
14
|
+
closeButton: false,
|
|
19
15
|
style: {
|
|
20
|
-
fontFamily: constants.typography.fontFamily,
|
|
21
|
-
fontSize:
|
|
22
|
-
borderRadius:
|
|
16
|
+
fontFamily: constants.typography.fontFamily.base,
|
|
17
|
+
fontSize: 14,
|
|
18
|
+
borderRadius: 10,
|
|
19
|
+
padding: '10px 14px',
|
|
20
|
+
boxShadow: '0 12px 24px rgba(15, 23, 42, 0.12)',
|
|
21
|
+
border: 'none',
|
|
22
|
+
minHeight: 56,
|
|
23
|
+
backgroundColor: colors.surface.overlay,
|
|
24
|
+
color: colors.text.primary,
|
|
25
|
+
display: 'flex',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
gap: 8,
|
|
23
28
|
},
|
|
24
29
|
};
|
|
25
30
|
/**
|
|
26
|
-
*
|
|
31
|
+
* SUCCESS → success colors
|
|
27
32
|
*/
|
|
28
|
-
const successConfig = Object.assign(Object.assign({}, baseConfig), { icon: _jsx(CheckCircleOutlined, { style: { fontSize:
|
|
33
|
+
const successConfig = Object.assign(Object.assign({}, baseConfig), { icon: (_jsx(CheckCircleOutlined, { style: { fontSize: 18, color: colors.semantic.success.main } })), style: Object.assign(Object.assign({}, baseConfig.style), { backgroundColor: colors.semantic.success.subtle, color: colors.semantic.success.main }), className: 'toast-success' });
|
|
29
34
|
/**
|
|
30
|
-
*
|
|
35
|
+
* ERROR → error colors
|
|
31
36
|
*/
|
|
32
|
-
const errorConfig = Object.assign(Object.assign({}, baseConfig), { icon: _jsx(CloseCircleOutlined, { style: { fontSize:
|
|
37
|
+
const errorConfig = Object.assign(Object.assign({}, baseConfig), { icon: (_jsx(CloseCircleOutlined, { style: { fontSize: 18, color: colors.semantic.error.main } })), style: Object.assign(Object.assign({}, baseConfig.style), { backgroundColor: colors.semantic.error.subtle, color: colors.semantic.error.main }), className: 'toast-error' });
|
|
33
38
|
/**
|
|
34
|
-
*
|
|
39
|
+
* WARNING → warning colors
|
|
35
40
|
*/
|
|
36
|
-
const warningConfig = Object.assign(Object.assign({}, baseConfig), { icon: _jsx(ExclamationCircleOutlined, { style: { fontSize:
|
|
41
|
+
const warningConfig = Object.assign(Object.assign({}, baseConfig), { icon: (_jsx(ExclamationCircleOutlined, { style: { fontSize: 18, color: colors.semantic.warning.main } })), style: Object.assign(Object.assign({}, baseConfig.style), { backgroundColor: colors.semantic.warning.subtle, color: colors.semantic.warning.main }), className: 'toast-warning' });
|
|
37
42
|
/**
|
|
38
|
-
*
|
|
43
|
+
* INFO → *white background*, blue accents only
|
|
44
|
+
* (no colored background)
|
|
39
45
|
*/
|
|
40
|
-
const infoConfig = Object.assign(Object.assign({}, baseConfig), { icon: _jsx(InfoCircleOutlined, { style: { fontSize:
|
|
46
|
+
const infoConfig = Object.assign(Object.assign({}, baseConfig), { icon: (_jsx(InfoCircleOutlined, { style: { fontSize: 18, color: colors.text.primary } })), style: Object.assign(Object.assign({}, baseConfig.style), { backgroundColor: colors.surface.overlay, color: colors.text.primary }), className: 'toast-info' });
|
|
41
47
|
/**
|
|
42
|
-
*
|
|
48
|
+
* LOADING (unchanged)
|
|
43
49
|
*/
|
|
44
|
-
const loadingConfig = Object.assign(Object.assign({}, baseConfig), { autoClose: false, closeButton: false });
|
|
50
|
+
const loadingConfig = Object.assign(Object.assign({}, baseConfig), { icon: (_jsx(LoadingOutlined, { style: { fontSize: 18, color: colors.neutral[4] } })), style: Object.assign(Object.assign({}, baseConfig.style), { backgroundColor: colors.surface.overlay, color: colors.text.primary }), autoClose: false, closeButton: false, hideProgressBar: true, className: 'toast-loading' });
|
|
45
51
|
return {
|
|
46
52
|
loadingConfig,
|
|
47
53
|
infoConfig,
|
|
@@ -49,5 +55,6 @@ export const buildToastConfigs = (colors, constants) => {
|
|
|
49
55
|
errorConfig,
|
|
50
56
|
successConfig,
|
|
51
57
|
baseConfig,
|
|
58
|
+
colors,
|
|
52
59
|
};
|
|
53
60
|
};
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ToastContainerProps as RTToastContainerProps } from 'react-toastify';
|
|
3
|
-
export
|
|
3
|
+
export interface TemboToastContainerProps extends Omit<RTToastContainerProps, 'closeButton' | 'hideProgressBar'> {
|
|
4
|
+
/**
|
|
5
|
+
* Show the X close button on each toast
|
|
6
|
+
* @default false
|
|
7
|
+
*/
|
|
8
|
+
showCloseButton?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Show the progress bar at the bottom of each toast
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
showProgressBar?: boolean;
|
|
14
|
+
}
|
|
4
15
|
/**
|
|
5
|
-
* Toast container
|
|
6
|
-
* Reinitializes when theme changes to respect color/constant overrides
|
|
16
|
+
* Toast container with Tembo styling
|
|
7
17
|
*/
|
|
8
18
|
declare const TemboToastContainer: React.FC<TemboToastContainerProps>;
|
|
9
19
|
export default TemboToastContainer;
|
|
@@ -1,18 +1,89 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { useEffect } from 'react';
|
|
3
|
-
import { ToastContainer } from 'react-toastify';
|
|
4
|
-
import { useTemboTheme } from '../../theme/index.js';
|
|
4
|
+
import { ToastContainer, } from 'react-toastify';
|
|
5
5
|
import { TemboNotify } from './tembo-notify.js';
|
|
6
|
+
import { useNewTemboTheme } from '../../theme/theme-provider.js';
|
|
6
7
|
/**
|
|
7
|
-
* Toast container
|
|
8
|
-
* Reinitializes when theme changes to respect color/constant overrides
|
|
8
|
+
* Toast container with Tembo styling
|
|
9
9
|
*/
|
|
10
|
-
const TemboToastContainer = (
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const TemboToastContainer = (_a) => {
|
|
11
|
+
var { showCloseButton = false, showProgressBar = false } = _a, rest = __rest(_a, ["showCloseButton", "showProgressBar"]);
|
|
12
|
+
const { colors, constants } = useNewTemboTheme();
|
|
13
13
|
useEffect(() => {
|
|
14
14
|
TemboNotify.init(colors, constants);
|
|
15
15
|
}, [colors, constants]);
|
|
16
|
-
return _jsx(ToastContainer, Object.assign({},
|
|
16
|
+
return (_jsxs(_Fragment, { children: [_jsx(ToastContainer, Object.assign({ closeButton: showCloseButton, hideProgressBar: !showProgressBar }, rest)), _jsx("style", { children: `
|
|
17
|
+
.Toastify__toast {
|
|
18
|
+
font-family: ${constants.typography.fontFamily};
|
|
19
|
+
line-height: 1.5;
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center; /* center icon + content */
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.Toastify__toast-body {
|
|
25
|
+
padding: 0;
|
|
26
|
+
margin: 0;
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: flex-start;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.Toastify__toast-icon {
|
|
32
|
+
width: 18px;
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
margin-inline-end: 6px; /* tighter spacing */
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.Toastify__progress-bar {
|
|
40
|
+
display: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.Toastify__close-button {
|
|
44
|
+
opacity: 0.5;
|
|
45
|
+
transition: opacity 0.2s ease;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.Toastify__close-button:hover {
|
|
49
|
+
opacity: 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Force progress bar hidden in case someone enables it unintentionally */
|
|
53
|
+
.Toastify__progress-bar {
|
|
54
|
+
display: none;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* Smooth entrance animation */
|
|
58
|
+
@keyframes toastSlideIn {
|
|
59
|
+
from {
|
|
60
|
+
transform: translateX(110%);
|
|
61
|
+
opacity: 0;
|
|
62
|
+
}
|
|
63
|
+
to {
|
|
64
|
+
transform: translateX(0);
|
|
65
|
+
opacity: 1;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.Toastify__toast--top-right {
|
|
70
|
+
animation: toastSlideIn 0.3s ease-out;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Optional: full-width mobile behaviour */
|
|
74
|
+
@media (max-width: 480px) {
|
|
75
|
+
.Toastify__toast-container--top-right {
|
|
76
|
+
right: 0;
|
|
77
|
+
left: 0;
|
|
78
|
+
padding: 0;
|
|
79
|
+
width: 100vw;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.Toastify__toast {
|
|
83
|
+
margin-bottom: 0;
|
|
84
|
+
border-radius: 0;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
` })] }));
|
|
17
88
|
};
|
|
18
89
|
export default TemboToastContainer;
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n=require("./theme-provider-CCkR2IcZ.js"),e=require("@ebay/nice-modal-react"),t=require("tslib"),s=require("react"),i=require("react-toastify"),o=require("./tembo-notify-C09rXp6m.js");function r(n){return n&&n.__esModule?n:{default:n}}require("antd"),require("./InfoCircleOutlined-DR9DmuN-.js"),require("./CloseCircleOutlined-CMilRURi.js");var a=r(e);const l=e=>n.jsxRuntimeExports.jsx(a.default.Provider,{children:e.children}),d=e=>{var{showCloseButton:r=!1,showProgressBar:a=!1}=e,l=t.__rest(e,["showCloseButton","showProgressBar"]);const{colors:d,constants:c}=n.useNewTemboTheme();return s.useEffect(()=>{o.TemboNotify.init(d,c)},[d,c]),n.jsxRuntimeExports.jsxs(n.jsxRuntimeExports.Fragment,{children:[n.jsxRuntimeExports.jsx(i.ToastContainer,Object.assign({closeButton:r,hideProgressBar:!a},l)),n.jsxRuntimeExports.jsx("style",{children:`\n .Toastify__toast {\n font-family: ${c.typography.fontFamily};\n line-height: 1.5;\n display: flex;\n align-items: center; /* center icon + content */\n }\n\n .Toastify__toast-body {\n padding: 0;\n margin: 0;\n display: flex;\n align-items: flex-start;\n }\n\n .Toastify__toast-icon {\n width: 18px;\n display: flex;\n align-items: center;\n justify-content: center;\n margin-inline-end: 6px; /* tighter spacing */\n }\n\n .Toastify__progress-bar {\n display: none;\n }\n\n .Toastify__close-button {\n opacity: 0.5;\n transition: opacity 0.2s ease;\n }\n\n .Toastify__close-button:hover {\n opacity: 1;\n }\n\n /* Force progress bar hidden in case someone enables it unintentionally */\n .Toastify__progress-bar {\n display: none;\n }\n\n /* Smooth entrance animation */\n @keyframes toastSlideIn {\n from {\n transform: translateX(110%);\n opacity: 0;\n }\n to {\n transform: translateX(0);\n opacity: 1;\n }\n }\n\n .Toastify__toast--top-right {\n animation: toastSlideIn 0.3s ease-out;\n }\n\n /* Optional: full-width mobile behaviour */\n @media (max-width: 480px) {\n .Toastify__toast-container--top-right {\n right: 0;\n left: 0;\n padding: 0;\n width: 100vw;\n }\n\n .Toastify__toast {\n margin-bottom: 0;\n border-radius: 0;\n }\n }\n `})]})};exports.TemboUIProviders=({children:e,mode:t,antdThemeOverrides:s})=>n.jsxRuntimeExports.jsx(n.TemboThemeProvider,{mode:t,antdThemeOverrides:s,children:n.jsxRuntimeExports.jsxs(l,{children:[e,n.jsxRuntimeExports.jsx(d,{})]})});
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|