funuicss 3.8.2 → 3.8.4
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/css/fun.css +178 -194
- package/package.json +1 -1
- package/ui/accordion/Accordion.d.ts +56 -13
- package/ui/accordion/Accordion.js +449 -25
- package/ui/appbar/AppBar.d.ts +1 -0
- package/ui/appbar/AppBar.js +2 -2
- package/ui/flex/Flex.d.ts +1 -1
- package/ui/notification/Notification.d.ts +69 -12
- package/ui/notification/Notification.js +408 -19
- package/ui/theme/theme.js +1177 -85
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
3
14
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
15
|
if (k2 === undefined) k2 = k;
|
|
5
16
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -37,28 +48,406 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
48
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
49
|
};
|
|
39
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.default = Notification;
|
|
41
51
|
var react_1 = __importStar(require("react"));
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
var componentUtils_1 = require("../../utils/componentUtils");
|
|
53
|
+
var Text_1 = __importDefault(require("../text/Text"));
|
|
54
|
+
var Button_1 = __importDefault(require("../button/Button"));
|
|
55
|
+
var Flex_1 = __importDefault(require("../flex/Flex"));
|
|
56
|
+
var getDynamicIcon_1 = require("../../utils/getDynamicIcon");
|
|
57
|
+
// Custom hook for dynamic icons
|
|
58
|
+
var useDynamicIcon = function (iconString) {
|
|
59
|
+
var _a = (0, react_1.useState)(null), iconNode = _a[0], setIconNode = _a[1];
|
|
60
|
+
var _b = (0, react_1.useState)(false), hasValidIcon = _b[0], setHasValidIcon = _b[1];
|
|
49
61
|
(0, react_1.useEffect)(function () {
|
|
50
|
-
if (
|
|
62
|
+
if (!iconString || typeof iconString !== 'string' || iconString.trim() === '') {
|
|
63
|
+
setIconNode(null);
|
|
64
|
+
setHasValidIcon(false);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
(0, getDynamicIcon_1.getDynamicIcon)(iconString).then(function (node) {
|
|
68
|
+
if (node) {
|
|
69
|
+
setIconNode(node);
|
|
70
|
+
setHasValidIcon(true);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
setIconNode(null);
|
|
74
|
+
setHasValidIcon(false);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}, [iconString]);
|
|
78
|
+
return { iconNode: iconNode, hasValidIcon: hasValidIcon };
|
|
79
|
+
};
|
|
80
|
+
// Icon component
|
|
81
|
+
var NotificationIcon = function (_a) {
|
|
82
|
+
var icon = _a.icon, iconColor = _a.iconColor, _b = _a.iconSize, iconSize = _b === void 0 ? 20 : _b, _c = _a.iconClassName, iconClassName = _c === void 0 ? '' : _c;
|
|
83
|
+
var isStringIcon = icon && typeof icon === 'string';
|
|
84
|
+
var _d = useDynamicIcon(isStringIcon ? icon : undefined), dynamicIconNode = _d.iconNode, hasValidDynamicIcon = _d.hasValidIcon;
|
|
85
|
+
// Get color class from color name
|
|
86
|
+
var getColorClass = function (color) {
|
|
87
|
+
if (!color)
|
|
88
|
+
return '';
|
|
89
|
+
if (color.startsWith('text-') || color.startsWith('bg-') || color.startsWith('border-')) {
|
|
90
|
+
return color;
|
|
91
|
+
}
|
|
92
|
+
var colorNames = ['primary', 'secondary', 'accent', 'success', 'warning', 'error', 'info', 'dark', 'light'];
|
|
93
|
+
if (colorNames.includes(color)) {
|
|
94
|
+
return "text-".concat(color);
|
|
95
|
+
}
|
|
96
|
+
return '';
|
|
97
|
+
};
|
|
98
|
+
var colorClass = getColorClass(iconColor);
|
|
99
|
+
var renderIconWithProps = function (iconElement, className, size) {
|
|
100
|
+
if (!react_1.default.isValidElement(iconElement))
|
|
101
|
+
return iconElement;
|
|
102
|
+
var props = {
|
|
103
|
+
className: "".concat(className, " ").concat(colorClass).trim(),
|
|
104
|
+
};
|
|
105
|
+
if (size !== undefined) {
|
|
106
|
+
props.size = size;
|
|
107
|
+
}
|
|
108
|
+
return react_1.default.cloneElement(iconElement, props);
|
|
109
|
+
};
|
|
110
|
+
if (icon && typeof icon !== 'string' && react_1.default.isValidElement(icon)) {
|
|
111
|
+
return renderIconWithProps(icon, "notification__icon ".concat(iconClassName).trim(), iconSize);
|
|
112
|
+
}
|
|
113
|
+
if (isStringIcon && hasValidDynamicIcon && dynamicIconNode) {
|
|
114
|
+
return renderIconWithProps(dynamicIconNode, "notification__icon ".concat(iconClassName).trim(), iconSize);
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
};
|
|
118
|
+
// Helper function to convert spacing string to number for Flex component
|
|
119
|
+
var getFlexGap = function (value) {
|
|
120
|
+
if (!value)
|
|
121
|
+
return 0.5; // Default gap for Flex
|
|
122
|
+
// If it's already a number string (like "0.5"), convert to number
|
|
123
|
+
if (/^\d+(\.\d+)?$/.test(value)) {
|
|
124
|
+
return parseFloat(value);
|
|
125
|
+
}
|
|
126
|
+
// If it has a unit (like "0.5rem", "8px", "1em"), extract the number part
|
|
127
|
+
var match = value.match(/^(\d+(\.\d+)?)/);
|
|
128
|
+
if (match) {
|
|
129
|
+
var num = parseFloat(match[1]);
|
|
130
|
+
// Convert rem to equivalent number (1rem = 4 in Flex component spacing system)
|
|
131
|
+
if (value.includes('rem')) {
|
|
132
|
+
return num * 4; // Assuming Flex uses a base unit where 1 = 0.25rem
|
|
133
|
+
}
|
|
134
|
+
// Convert px to approximate number (assuming 1px ≈ 0.0625rem ≈ 0.25 in Flex system)
|
|
135
|
+
if (value.includes('px')) {
|
|
136
|
+
return num / 4; // Rough approximation
|
|
137
|
+
}
|
|
138
|
+
// For other units or unitless numbers, just return the number
|
|
139
|
+
return num;
|
|
140
|
+
}
|
|
141
|
+
return 0.5; // Default fallback
|
|
142
|
+
};
|
|
143
|
+
// Helper function to get spacing value with unit for CSS
|
|
144
|
+
var getSpacingValue = function (value) {
|
|
145
|
+
if (!value)
|
|
146
|
+
return '';
|
|
147
|
+
// If it's just a number, convert to rem (assuming number * 0.25rem)
|
|
148
|
+
if (/^\d+$/.test(value)) {
|
|
149
|
+
return "".concat(parseInt(value) * 0.25, "rem");
|
|
150
|
+
}
|
|
151
|
+
// If it's a decimal number without unit, also convert to rem
|
|
152
|
+
if (/^\d+(\.\d+)?$/.test(value)) {
|
|
153
|
+
return "".concat(parseFloat(value) * 0.25, "rem");
|
|
154
|
+
}
|
|
155
|
+
// If it already has a unit, return as-is
|
|
156
|
+
return value;
|
|
157
|
+
};
|
|
158
|
+
// Notification Header Component
|
|
159
|
+
var NotificationHeader = function (_a) {
|
|
160
|
+
var globalProps = _a.globalProps;
|
|
161
|
+
var avatarUrl = globalProps.avatarUrl, _b = globalProps.avatarAlt, avatarAlt = _b === void 0 ? 'Avatar' : _b, _c = globalProps.avatarSize, avatarSize = _c === void 0 ? 60 : _c, _d = globalProps.avatarClassName, avatarClassName = _d === void 0 ? '' : _d, _e = globalProps.avatarRounded, avatarRounded = _e === void 0 ? '50%' : _e, title = globalProps.title, titleSize = globalProps.titleSize, titleWeight = globalProps.titleWeight, titleColor = globalProps.titleColor, titleClassName = globalProps.titleClassName, titleVariant = globalProps.titleVariant, subtitle = globalProps.subtitle, subtitleSize = globalProps.subtitleSize, subtitleWeight = globalProps.subtitleWeight, subtitleColor = globalProps.subtitleColor, subtitleClassName = globalProps.subtitleClassName, subtitleVariant = globalProps.subtitleVariant, timestamp = globalProps.timestamp, timestampSize = globalProps.timestampSize, timestampColor = globalProps.timestampColor, timestampClassName = globalProps.timestampClassName, icon = globalProps.icon, iconColor = globalProps.iconColor, iconSize = globalProps.iconSize, iconClassName = globalProps.iconClassName, _f = globalProps.iconPosition, iconPosition = _f === void 0 ? 'right' : _f, _g = globalProps.headerGap, headerGap = _g === void 0 ? '0.75rem' : _g, _h = globalProps.headerAlign, headerAlign = _h === void 0 ? 'start' : _h, _j = globalProps.headerJustify, headerJustify = _j === void 0 ? 'between' : _j;
|
|
162
|
+
// Get background class from color name
|
|
163
|
+
var getBgClass = function (color) {
|
|
164
|
+
if (!color)
|
|
165
|
+
return '';
|
|
166
|
+
if (color.startsWith('bg-')) {
|
|
167
|
+
return color;
|
|
168
|
+
}
|
|
169
|
+
var colorNames = ['primary', 'secondary', 'accent', 'success', 'warning', 'error', 'info', 'dark', 'light'];
|
|
170
|
+
if (colorNames.includes(color)) {
|
|
171
|
+
return "bg-".concat(color);
|
|
172
|
+
}
|
|
173
|
+
return '';
|
|
174
|
+
};
|
|
175
|
+
if (!title && !subtitle && !avatarUrl && !icon) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
return (react_1.default.createElement("div", { className: "notification__header ".concat(getBgClass(globalProps.headerBg)), style: {
|
|
179
|
+
display: 'flex',
|
|
180
|
+
alignItems: headerAlign,
|
|
181
|
+
justifyContent: headerJustify,
|
|
182
|
+
gap: getSpacingValue(headerGap),
|
|
183
|
+
} },
|
|
184
|
+
react_1.default.createElement("div", { className: "col", style: { flex: 1 } },
|
|
185
|
+
react_1.default.createElement(Flex_1.default, { alignItems: "flex-start", gap: getFlexGap(headerGap), width: '100%' },
|
|
186
|
+
avatarUrl && (react_1.default.createElement("img", { src: avatarUrl, alt: avatarAlt, className: "notification__avatar ".concat(avatarClassName), style: {
|
|
187
|
+
width: avatarSize,
|
|
188
|
+
height: avatarSize,
|
|
189
|
+
borderRadius: avatarRounded,
|
|
190
|
+
objectFit: 'cover',
|
|
191
|
+
} })),
|
|
192
|
+
react_1.default.createElement("div", { className: "col", style: { flex: 1 } },
|
|
193
|
+
react_1.default.createElement(Flex_1.default, { gap: 0.25, direction: 'column', fit: true },
|
|
194
|
+
title && (react_1.default.createElement(Text_1.default, { variant: titleVariant, block: true, size: titleSize || 'md', weight: titleWeight || 600, color: titleColor || 'default', funcss: "notification__title ".concat(titleClassName || '') }, title)),
|
|
195
|
+
subtitle && (react_1.default.createElement(Text_1.default, { block: true, size: subtitleSize || 'sm', weight: subtitleWeight || 400, lineHeight: '0.9', color: subtitleColor || 'muted', funcss: "notification__subtitle ".concat(subtitleClassName || '') }, subtitle)),
|
|
196
|
+
timestamp && (react_1.default.createElement(Text_1.default, { size: timestampSize || 'xs', color: timestampColor || 'light', funcss: "notification__timestamp ".concat(timestampClassName || ''), style: {
|
|
197
|
+
marginTop: '0.25rem',
|
|
198
|
+
opacity: 0.7,
|
|
199
|
+
} }, timestamp)))))),
|
|
200
|
+
icon && iconPosition === 'right' && (react_1.default.createElement(NotificationIcon, { icon: icon, iconColor: iconColor, iconSize: iconSize, iconClassName: iconClassName })),
|
|
201
|
+
icon && iconPosition === 'left' && (react_1.default.createElement(NotificationIcon, { icon: icon, iconColor: iconColor, iconSize: iconSize, iconClassName: iconClassName }))));
|
|
202
|
+
};
|
|
203
|
+
// Notification Content Component
|
|
204
|
+
var NotificationContent = function (_a) {
|
|
205
|
+
var globalProps = _a.globalProps;
|
|
206
|
+
var content = globalProps.content, contentSize = globalProps.contentSize, contentWeight = globalProps.contentWeight, contentColor = globalProps.contentColor, contentClassName = globalProps.contentClassName, contentVariant = globalProps.contentVariant;
|
|
207
|
+
if (!content) {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
if (typeof content === 'string') {
|
|
211
|
+
return (react_1.default.createElement(Text_1.default, { block: true, size: contentSize || 'md', weight: contentWeight || 400, color: contentColor || '', funcss: "notification__content ".concat(contentClassName || '') },
|
|
212
|
+
react_1.default.createElement("div", { dangerouslySetInnerHTML: { __html: content } })));
|
|
213
|
+
}
|
|
214
|
+
return (react_1.default.createElement("div", { className: "notification__content ".concat(contentClassName || '') }, content));
|
|
215
|
+
};
|
|
216
|
+
// Notification Footer Component
|
|
217
|
+
var NotificationFooter = function (_a) {
|
|
218
|
+
var globalProps = _a.globalProps, onClose = _a.onClose;
|
|
219
|
+
var ctaText = globalProps.ctaText, ctaUrl = globalProps.ctaUrl, ctaVariant = globalProps.ctaVariant, ctaOnClick = globalProps.ctaOnClick, ctaClassName = globalProps.ctaClassName, ctaCss = globalProps.ctaCss, _b = globalProps.ctaAlign, ctaAlign = _b === void 0 ? 'right' : _b;
|
|
220
|
+
var handleCTAClick = function () {
|
|
221
|
+
if (ctaOnClick) {
|
|
222
|
+
ctaOnClick();
|
|
223
|
+
}
|
|
224
|
+
if (onClose) {
|
|
225
|
+
onClose();
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
if (!ctaText && !onClose) {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
return (react_1.default.createElement("div", { className: "notification__footer", style: {
|
|
232
|
+
display: 'flex',
|
|
233
|
+
justifyContent: ctaAlign === 'left' ? 'flex-start' : ctaAlign === 'center' ? 'center' : 'flex-end',
|
|
234
|
+
gap: getSpacingValue('0.75rem'), // Using getSpacingValue for consistency
|
|
235
|
+
} },
|
|
236
|
+
ctaText && (react_1.default.createElement(Button_1.default, { url: ctaUrl, onClick: handleCTAClick, funcss: "".concat(ctaClassName || '', " ").concat(ctaCss || ''), text: ctaText })),
|
|
237
|
+
onClose && (react_1.default.createElement(Button_1.default, { onClick: onClose, funcss: "notification__close-btn", text: "Dismiss", style: {
|
|
238
|
+
color: 'var(--text-muted)',
|
|
239
|
+
opacity: 0.7,
|
|
240
|
+
} }))));
|
|
241
|
+
};
|
|
242
|
+
// Main Notification Component
|
|
243
|
+
var Notification = function (localProps) {
|
|
244
|
+
var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Notification', localProps.variant).mergeWithLocal;
|
|
245
|
+
var mergedProps = mergeWithLocal(localProps).props;
|
|
246
|
+
var final = mergedProps;
|
|
247
|
+
var _a = (0, react_1.useState)(final.state || false), isOpen = _a[0], setIsOpen = _a[1];
|
|
248
|
+
// Handle state changes
|
|
249
|
+
(0, react_1.useEffect)(function () {
|
|
250
|
+
if (final.state !== undefined) {
|
|
251
|
+
setIsOpen(final.state);
|
|
252
|
+
if (final.state && final.onOpen) {
|
|
253
|
+
final.onOpen();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}, [final.state]);
|
|
257
|
+
// Auto-hide timer
|
|
258
|
+
(0, react_1.useEffect)(function () {
|
|
259
|
+
if (isOpen && final.autoHide) {
|
|
260
|
+
var duration = final.autoHideDuration || 5;
|
|
51
261
|
var timer_1 = setTimeout(function () {
|
|
52
|
-
|
|
53
|
-
},
|
|
262
|
+
handleClose();
|
|
263
|
+
}, duration * 1000);
|
|
54
264
|
return function () { return clearTimeout(timer_1); };
|
|
55
265
|
}
|
|
56
|
-
}, [
|
|
57
|
-
|
|
266
|
+
}, [isOpen, final.autoHide, final.autoHideDuration]);
|
|
267
|
+
var handleClose = function () {
|
|
268
|
+
if (final.setOpen) {
|
|
269
|
+
final.setOpen(false);
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
setIsOpen(false);
|
|
273
|
+
}
|
|
274
|
+
if (final.onClose) {
|
|
275
|
+
final.onClose();
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
// Get background class from color name
|
|
279
|
+
var getBgClass = function (color) {
|
|
280
|
+
if (!color)
|
|
281
|
+
return '';
|
|
282
|
+
if (color.startsWith('bg-')) {
|
|
283
|
+
return color;
|
|
284
|
+
}
|
|
285
|
+
var colorNames = ['primary', 'secondary', 'accent', 'success', 'warning', 'error', 'info', 'dark', 'light'];
|
|
286
|
+
if (colorNames.includes(color)) {
|
|
287
|
+
return "bg-".concat(color);
|
|
288
|
+
}
|
|
289
|
+
return '';
|
|
290
|
+
};
|
|
291
|
+
// Get border class from color name
|
|
292
|
+
var getBorderClass = function (color) {
|
|
293
|
+
if (!color)
|
|
294
|
+
return '';
|
|
295
|
+
if (color.startsWith('border-')) {
|
|
296
|
+
return color;
|
|
297
|
+
}
|
|
298
|
+
var colorNames = ['primary', 'secondary', 'accent', 'success', 'warning', 'error', 'info', 'dark', 'light'];
|
|
299
|
+
if (colorNames.includes(color)) {
|
|
300
|
+
return "border-".concat(color);
|
|
301
|
+
}
|
|
302
|
+
return color === 'borderColor' ? 'border-default' : '';
|
|
303
|
+
};
|
|
304
|
+
var getAnimationStyle = function () {
|
|
305
|
+
if (!final.animation || final.animation === 'none') {
|
|
306
|
+
return {};
|
|
307
|
+
}
|
|
308
|
+
var duration = final.duration || 0.3;
|
|
309
|
+
return {
|
|
310
|
+
animation: "".concat(duration, "s ").concat(final.animation),
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
var getPositionStyle = function () {
|
|
314
|
+
var position = final.position || 'top-right';
|
|
315
|
+
var positionStyles = {
|
|
316
|
+
'top-right': {
|
|
317
|
+
top: '20px',
|
|
318
|
+
right: '20px',
|
|
319
|
+
},
|
|
320
|
+
'top-left': {
|
|
321
|
+
top: '20px',
|
|
322
|
+
left: '20px',
|
|
323
|
+
},
|
|
324
|
+
'bottom-right': {
|
|
325
|
+
bottom: '20px',
|
|
326
|
+
right: '20px',
|
|
327
|
+
},
|
|
328
|
+
'bottom-left': {
|
|
329
|
+
bottom: '20px',
|
|
330
|
+
left: '20px',
|
|
331
|
+
},
|
|
332
|
+
'top-center': {
|
|
333
|
+
top: '20px',
|
|
334
|
+
left: '50%',
|
|
335
|
+
transform: 'translateX(-50%)',
|
|
336
|
+
},
|
|
337
|
+
'bottom-center': {
|
|
338
|
+
bottom: '20px',
|
|
339
|
+
left: '50%',
|
|
340
|
+
transform: 'translateX(-50%)',
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
return __assign(__assign({ position: final.testing ? 'absolute' : 'fixed' }, positionStyles[position]), { zIndex: final.zIndex || 1000 });
|
|
344
|
+
};
|
|
345
|
+
var getContainerClasses = function () {
|
|
346
|
+
var classes = ['notification'];
|
|
347
|
+
// Background class
|
|
348
|
+
if (final.bg) {
|
|
349
|
+
var bgClass = getBgClass(final.bg);
|
|
350
|
+
if (bgClass) {
|
|
351
|
+
classes.push(bgClass);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
// Border classes
|
|
355
|
+
if (final.border) {
|
|
356
|
+
classes.push('border');
|
|
357
|
+
var borderClass = getBorderClass(final.borderColor);
|
|
358
|
+
if (borderClass) {
|
|
359
|
+
classes.push(borderClass);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
// Border radius
|
|
363
|
+
var borderRadius = getSpacingValue(final.borderRadius);
|
|
364
|
+
if (borderRadius === '0.25rem')
|
|
365
|
+
classes.push('rounded-sm');
|
|
366
|
+
else if (borderRadius === '0.5rem')
|
|
367
|
+
classes.push('rounded-md');
|
|
368
|
+
else if (borderRadius === '0.75rem')
|
|
369
|
+
classes.push('rounded-lg');
|
|
370
|
+
else if (borderRadius === '1rem')
|
|
371
|
+
classes.push('rounded-xl');
|
|
372
|
+
// Shadow
|
|
373
|
+
if (final.shadow && final.shadow !== 'none') {
|
|
374
|
+
classes.push("".concat(final.shadow ? "card" : ''));
|
|
375
|
+
}
|
|
376
|
+
// Custom classes
|
|
377
|
+
if (final.className) {
|
|
378
|
+
classes.push(final.className);
|
|
379
|
+
}
|
|
380
|
+
if (final.funcss) {
|
|
381
|
+
classes.push(final.funcss);
|
|
382
|
+
}
|
|
383
|
+
return classes.filter(Boolean).join(' ');
|
|
384
|
+
};
|
|
385
|
+
var getContainerStyles = function () {
|
|
386
|
+
return __assign(__assign(__assign(__assign({ width: final.width || '450px', maxWidth: final.maxWidth || '90vw', padding: getSpacingValue(final.padding) || '1.25rem', margin: getSpacingValue(final.margin) || '0', borderWidth: final.borderWidth || '1px' }, getAnimationStyle()), getPositionStyle()), final.style), { boxShadow: "var(--card)" });
|
|
387
|
+
};
|
|
388
|
+
if (!isOpen) {
|
|
58
389
|
return null;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
390
|
+
}
|
|
391
|
+
return (react_1.default.createElement("div", { className: getContainerClasses(), style: getContainerStyles() },
|
|
392
|
+
react_1.default.createElement(NotificationHeader, { globalProps: final }),
|
|
393
|
+
react_1.default.createElement(NotificationContent, { globalProps: final }),
|
|
394
|
+
react_1.default.createElement(NotificationFooter, { globalProps: final, onClose: handleClose }),
|
|
395
|
+
final.children));
|
|
396
|
+
};
|
|
397
|
+
exports.default = Notification;
|
|
398
|
+
// 'use client';
|
|
399
|
+
// import React, { useEffect, useState } from 'react';
|
|
400
|
+
// import NotificationHeader from './Header';
|
|
401
|
+
// import NotificationContent from './Content';
|
|
402
|
+
// import NotificationFooter from './Footer';
|
|
403
|
+
// type NotificationProps = {
|
|
404
|
+
// position: string;
|
|
405
|
+
// funcss?: string;
|
|
406
|
+
// animation?: string;
|
|
407
|
+
// duration?: number; // in seconds
|
|
408
|
+
// autoHide?: boolean;
|
|
409
|
+
// autoHideDuration?: number;
|
|
410
|
+
// children?: React.ReactNode;
|
|
411
|
+
// state: boolean;
|
|
412
|
+
// setOpen: (state: boolean) => void; // 👈 control from parent
|
|
413
|
+
// width?: string;
|
|
414
|
+
// header?: React.ReactNode;
|
|
415
|
+
// content?: React.ReactNode;
|
|
416
|
+
// footer?: React.ReactNode;
|
|
417
|
+
// };
|
|
418
|
+
// export default function Notification({
|
|
419
|
+
// position,
|
|
420
|
+
// funcss = '',
|
|
421
|
+
// animation = 'fadeIn',
|
|
422
|
+
// duration = 0.2,
|
|
423
|
+
// autoHide = false,
|
|
424
|
+
// autoHideDuration = 0.2,
|
|
425
|
+
// children,
|
|
426
|
+
// state,
|
|
427
|
+
// setOpen, // 👈 receives the setter from parent
|
|
428
|
+
// width = '450px',
|
|
429
|
+
// header,
|
|
430
|
+
// content,
|
|
431
|
+
// footer,
|
|
432
|
+
// }: NotificationProps) {
|
|
433
|
+
// useEffect(() => {
|
|
434
|
+
// if (state && autoHide) {
|
|
435
|
+
// const timer = setTimeout(() => {
|
|
436
|
+
// setOpen(false); // 👈 close from inside
|
|
437
|
+
// }, autoHideDuration * 1000);
|
|
438
|
+
// return () => clearTimeout(timer);
|
|
439
|
+
// }
|
|
440
|
+
// }, [state, autoHide, autoHideDuration, setOpen]);
|
|
441
|
+
// if (!state) return null;
|
|
442
|
+
// return (
|
|
443
|
+
// <div
|
|
444
|
+
// className={`notification ${position} ${funcss}`}
|
|
445
|
+
// style={{ animation: `${duration}s ${animation}`, width }}
|
|
446
|
+
// >
|
|
447
|
+
// {header && <NotificationHeader>{header}</NotificationHeader>}
|
|
448
|
+
// {content && <NotificationContent>{content}</NotificationContent>}
|
|
449
|
+
// {footer && <NotificationFooter>{footer}</NotificationFooter>}
|
|
450
|
+
// {children}
|
|
451
|
+
// </div>
|
|
452
|
+
// );
|
|
453
|
+
// }
|