funuicss 3.8.1 → 3.8.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/css/fun.css +197 -196
- 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/empty/Empty.d.ts +3 -3
- 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/table/Table.d.ts +4 -0
- package/ui/table/Table.js +14 -16
- 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
|
+
// }
|
package/ui/table/Table.d.ts
CHANGED
|
@@ -41,6 +41,10 @@ type TableProps = {
|
|
|
41
41
|
icon?: React.ReactNode;
|
|
42
42
|
title?: React.ReactNode;
|
|
43
43
|
subtitle: React.ReactNode;
|
|
44
|
+
ctaText?: string;
|
|
45
|
+
ctaIcon?: React.ReactNode | string;
|
|
46
|
+
showCta?: boolean;
|
|
47
|
+
ctaOnClick?: () => void;
|
|
44
48
|
};
|
|
45
49
|
customColumns?: {
|
|
46
50
|
title: string;
|
package/ui/table/Table.js
CHANGED
|
@@ -85,6 +85,7 @@ var Flex_1 = __importDefault(require("../flex/Flex"));
|
|
|
85
85
|
var ci_1 = require("react-icons/ci");
|
|
86
86
|
var io5_1 = require("react-icons/io5");
|
|
87
87
|
var Query_1 = require("./Query");
|
|
88
|
+
var Empty_1 = __importDefault(require("../empty/Empty"));
|
|
88
89
|
function Table(_a) {
|
|
89
90
|
var _b, _c;
|
|
90
91
|
var children = _a.children, funcss = _a.funcss, bordered = _a.bordered, noStripped = _a.noStripped, hoverable = _a.hoverable, _d = _a.title, title = _d === void 0 ? "" : _d, showTotal = _a.showTotal, light = _a.light, dark = _a.dark, head = _a.head, body = _a.body, data = _a.data, _e = _a.isLoading, isLoading = _e === void 0 ? false : _e, right = _a.right, hideExport = _a.hideExport, height = _a.height, _f = _a.pageSize, pageSize = _f === void 0 ? data ? 10 : 0 : _f, // Default page size,
|
|
@@ -376,19 +377,18 @@ function Table(_a) {
|
|
|
376
377
|
var _a;
|
|
377
378
|
// Calculate index for custom column (after regular data fields)
|
|
378
379
|
var colIndex = (((_a = data === null || data === void 0 ? void 0 : data.fields) === null || _a === void 0 ? void 0 : _a.length) || 0) + columnIndex;
|
|
379
|
-
return (React.createElement("div", { key: columnIndex, className: "table-cell", "data-label": column.title || "Action", style: {
|
|
380
|
+
return (React.createElement("div", { key: columnIndex, className: "table-cell wrap", "data-label": column.title || "Action", style: {
|
|
380
381
|
position: "relative",
|
|
381
382
|
overflow: "visible",
|
|
382
383
|
// Apply column-specific styles
|
|
383
384
|
minWidth: getColumnMinWidth(colIndex),
|
|
384
385
|
maxWidth: getColumnMaxWidth(colIndex),
|
|
385
|
-
width: getColumnWidth(colIndex)
|
|
386
|
+
width: getColumnWidth(colIndex),
|
|
387
|
+
whiteSpace: 'normal',
|
|
388
|
+
overflowWrap: 'break-word',
|
|
389
|
+
textOverflow: 'clip'
|
|
386
390
|
} },
|
|
387
|
-
|
|
388
|
-
position: "relative",
|
|
389
|
-
overflow: "visible",
|
|
390
|
-
zIndex: 50,
|
|
391
|
-
} }, column.render && column.render(mdoc)),
|
|
391
|
+
column.render && column.render(mdoc),
|
|
392
392
|
column.onClick && (React.createElement(Button_1.default, { onClick: function () { return column.onClick && column.onClick(mdoc); } }, column.title))));
|
|
393
393
|
})
|
|
394
394
|
: "")); });
|
|
@@ -416,23 +416,21 @@ function Table(_a) {
|
|
|
416
416
|
} }));
|
|
417
417
|
}))); }),
|
|
418
418
|
children ? children : ""),
|
|
419
|
-
filteredData.length === 0 && !isLoading && !children && (React.createElement("div",
|
|
420
|
-
React.createElement(
|
|
421
|
-
React.createElement("div", null, (emptyResponse === null || emptyResponse === void 0 ? void 0 : emptyResponse.title) || (React.createElement(Text_1.default, { text: "No Record Found!", size: "xl" }))),
|
|
422
|
-
React.createElement("div", null, (emptyResponse === null || emptyResponse === void 0 ? void 0 : emptyResponse.subtitle) || (React.createElement(Text_1.default, { text: "You can try reloading the page or check your query" }))))))),
|
|
419
|
+
filteredData.length === 0 && !isLoading && !children && (React.createElement("div", null,
|
|
420
|
+
React.createElement(Empty_1.default, { ctaIcon: (emptyResponse === null || emptyResponse === void 0 ? void 0 : emptyResponse.ctaIcon) || React.createElement(pi_1.PiSpinnerGap, null), title: (emptyResponse === null || emptyResponse === void 0 ? void 0 : emptyResponse.title) || 'No Record Found!', description: (emptyResponse === null || emptyResponse === void 0 ? void 0 : emptyResponse.subtitle) || 'You can try reloading the page or check your query', ctaText: (emptyResponse === null || emptyResponse === void 0 ? void 0 : emptyResponse.ctaText) || 'Reload', showCta: (emptyResponse === null || emptyResponse === void 0 ? void 0 : emptyResponse.showCta) || false, ctaOnClick: function () { return (emptyResponse === null || emptyResponse === void 0 ? void 0 : emptyResponse.ctaOnClick) ? emptyResponse === null || emptyResponse === void 0 ? void 0 : emptyResponse.ctaOnClick() : window.location.reload; } }))))),
|
|
423
421
|
data && pageSize && filteredData.length > pageSize && (React.createElement("div", { className: "padding bt" },
|
|
424
422
|
React.createElement(RowFlex_1.default, { gap: 1, funcss: 'pointer', justify: "center" },
|
|
425
423
|
React.createElement("div", { className: "pagination-nav ".concat(currentPage === 1 ? 'pagination-nav-disabled' : ''), onClick: function () { return currentPage > 1 && handleChangePage(1); }, title: "First page" },
|
|
426
424
|
React.createElement(Text_1.default, { text: "\u00AB\u00AB" })),
|
|
427
|
-
React.createElement("div", { className: "pagination-nav ".concat(currentPage === 1 ? 'pagination-nav-disabled' : ''), onClick: function () { return currentPage > 1 && handleChangePage(currentPage - 1); }, title: "Previous page" },
|
|
425
|
+
React.createElement("div", { className: "pagination-nav p ".concat(currentPage === 1 ? 'pagination-nav-disabled' : ''), onClick: function () { return currentPage > 1 && handleChangePage(currentPage - 1); }, title: "Previous page" },
|
|
428
426
|
React.createElement(Text_1.default, { text: "\u2039" })),
|
|
429
|
-
React.createElement(
|
|
427
|
+
React.createElement(Flex_1.default, null, Array.from({ length: endPage - startPage + 1 }, function (_, i) {
|
|
430
428
|
var pageNumber = startPage + i;
|
|
431
429
|
var isActive = currentPage === pageNumber;
|
|
432
|
-
return (React.createElement("div", { key: pageNumber
|
|
433
|
-
React.createElement(
|
|
430
|
+
return (React.createElement("div", { key: pageNumber },
|
|
431
|
+
React.createElement("div", { className: "pagination-item text-xs ".concat(isActive ? 'pagination-item-active primary' : ''), onClick: function () { return handleChangePage(pageNumber); } }, "".concat(pageNumber))));
|
|
434
432
|
})),
|
|
435
|
-
React.createElement("div", { className: "pagination-nav ".concat(currentPage === totalPages ? 'pagination-nav-disabled' : ''), onClick: function () { return currentPage < totalPages && handleChangePage(currentPage + 1); }, title: "Next page" },
|
|
433
|
+
React.createElement("div", { className: "pagination-nav p ".concat(currentPage === totalPages ? 'pagination-nav-disabled' : ''), onClick: function () { return currentPage < totalPages && handleChangePage(currentPage + 1); }, title: "Next page" },
|
|
436
434
|
React.createElement(Text_1.default, { text: "\u203A" })),
|
|
437
435
|
React.createElement("div", { className: "pagination-nav ".concat(currentPage === totalPages ? 'pagination-nav-disabled' : ''), onClick: function () { return currentPage < totalPages && handleChangePage(totalPages); }, title: "Last page" },
|
|
438
436
|
React.createElement(Text_1.default, { text: "\u00BB\u00BB" })))))));
|