funuicss 3.8.14 → 3.8.16

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.
@@ -44,6 +44,42 @@ var __importStar = (this && this.__importStar) || (function () {
44
44
  return result;
45
45
  };
46
46
  })();
47
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
48
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
49
+ return new (P || (P = Promise))(function (resolve, reject) {
50
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
51
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
52
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
53
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
54
+ });
55
+ };
56
+ var __generator = (this && this.__generator) || function (thisArg, body) {
57
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
58
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
59
+ function verb(n) { return function (v) { return step([n, v]); }; }
60
+ function step(op) {
61
+ if (f) throw new TypeError("Generator is already executing.");
62
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
63
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
64
+ if (y = 0, t) op = [op[0] & 2, t.value];
65
+ switch (op[0]) {
66
+ case 0: case 1: t = op; break;
67
+ case 4: _.label++; return { value: op[1], done: false };
68
+ case 5: _.label++; y = op[1]; op = [0]; continue;
69
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
70
+ default:
71
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
72
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
73
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
74
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
75
+ if (t[2]) _.ops.pop();
76
+ _.trys.pop(); continue;
77
+ }
78
+ op = body.call(thisArg, _);
79
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
80
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
81
+ }
82
+ };
47
83
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
48
84
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
49
85
  if (ar || !(i in from)) {
@@ -55,10 +91,24 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
55
91
  };
56
92
  Object.defineProperty(exports, "__esModule", { value: true });
57
93
  var react_1 = __importStar(require("react"));
58
- var getCssVariable_1 = require("../../utils/getCssVariable");
59
- var componentUtils_1 = require("../../utils/componentUtils");
60
- var getDynamicIcon_1 = require("../../utils/getDynamicIcon");
61
94
  var pi_1 = require("react-icons/pi");
95
+ // Mock utilities - replace with your actual imports
96
+ var getCssVariableValue = function (varName) {
97
+ if (typeof window === 'undefined')
98
+ return '';
99
+ return getComputedStyle(document.documentElement).getPropertyValue("--".concat(varName)).trim();
100
+ };
101
+ var useComponentConfiguration = function (componentName, variant) {
102
+ return {
103
+ mergeWithLocal: function (localProps) { return ({ props: localProps }); }
104
+ };
105
+ };
106
+ var getDynamicIcon = function (iconString) { return __awaiter(void 0, void 0, void 0, function () {
107
+ return __generator(this, function (_a) {
108
+ // Mock implementation - replace with your actual icon loader
109
+ return [2 /*return*/, null];
110
+ });
111
+ }); };
62
112
  // Custom hook for dynamic icons
63
113
  var useDynamicIcon = function (iconString) {
64
114
  var _a = (0, react_1.useState)(null), iconNode = _a[0], setIconNode = _a[1];
@@ -69,7 +119,7 @@ var useDynamicIcon = function (iconString) {
69
119
  setHasValidIcon(false);
70
120
  return;
71
121
  }
72
- (0, getDynamicIcon_1.getDynamicIcon)(iconString).then(function (node) {
122
+ getDynamicIcon(iconString).then(function (node) {
73
123
  if (node) {
74
124
  setIconNode(node);
75
125
  setHasValidIcon(true);
@@ -89,10 +139,8 @@ var AccordionIcon = function (_a) {
89
139
  var colorToUse = isExpandIcon ? expandIconColor : iconColor;
90
140
  var sizeToUse = isExpandIcon ? expandIconSize : iconSize;
91
141
  var classNameToUse = isExpandIcon ? expandIconClassName : iconClassName;
92
- // Handle string icons (dynamic)
93
142
  var isStringIcon = iconToUse && typeof iconToUse === 'string';
94
143
  var _j = useDynamicIcon(isStringIcon ? iconToUse : undefined), dynamicIconNode = _j.iconNode, hasValidDynamicIcon = _j.hasValidIcon;
95
- // Get color class from color name
96
144
  var getColorClass = function (color) {
97
145
  if (!color)
98
146
  return '';
@@ -117,15 +165,12 @@ var AccordionIcon = function (_a) {
117
165
  }
118
166
  return react_1.default.cloneElement(iconElement, props);
119
167
  };
120
- // If it's a React element icon
121
168
  if (iconToUse && typeof iconToUse !== 'string' && react_1.default.isValidElement(iconToUse)) {
122
169
  return renderIconWithProps(iconToUse, "".concat(isExpandIcon ? 'accordion-expand-icon' : 'accordion-icon', " ").concat(classNameToUse, " ").concat(isOpen && rotate ? 'accordion-rotated' : '').trim(), sizeToUse);
123
170
  }
124
- // If it's a string icon (dynamic)
125
171
  if (isStringIcon && hasValidDynamicIcon && dynamicIconNode) {
126
172
  return renderIconWithProps(dynamicIconNode, "".concat(isExpandIcon ? 'accordion-expand-icon' : 'accordion-icon', " ").concat(classNameToUse, " ").concat(isOpen && rotate ? 'accordion-rotated' : '').trim(), sizeToUse);
127
173
  }
128
- // Default expand icon (PiCaretDown)
129
174
  if (isExpandIcon && !iconToUse) {
130
175
  return (react_1.default.createElement(pi_1.PiCaretDown, { className: "accordion-expand-icon ".concat(expandIconClassName || '', " ").concat(colorClass, " ").concat(isOpen && rotate ? 'accordion-rotated' : '').trim(), style: {
131
176
  fontSize: expandIconSize,
@@ -137,10 +182,8 @@ var AccordionIcon = function (_a) {
137
182
  // Accordion Item Component
138
183
  var AccordionItem = function (_a) {
139
184
  var item = _a.item, index = _a.index, isOpen = _a.isOpen, onToggle = _a.onToggle, globalProps = _a.globalProps, _b = _a.animationDuration, animationDuration = _b === void 0 ? 300 : _b, _c = _a.animationEasing, animationEasing = _c === void 0 ? 'ease' : _c;
140
- // Merge item props with global props (item props take precedence)
141
185
  var mergedProps = __assign(__assign({}, globalProps), item);
142
186
  var itemClass = mergedProps.itemClass, titleClass = mergedProps.titleClass, iconClass = mergedProps.iconClass, contentClass = mergedProps.contentClass, activeClass = mergedProps.activeClass, icon = mergedProps.icon, iconColor = mergedProps.iconColor, iconSize = mergedProps.iconSize, iconClassName = mergedProps.iconClassName, _d = mergedProps.iconPosition, iconPosition = _d === void 0 ? 'left' : _d, expandIcon = mergedProps.expandIcon, expandIconColor = mergedProps.expandIconColor, expandIconSize = mergedProps.expandIconSize, expandIconClassName = mergedProps.expandIconClassName, _e = mergedProps.expandIconRotate, expandIconRotate = _e === void 0 ? true : _e, titleSize = mergedProps.titleSize, titleWeight = mergedProps.titleWeight, titleColor = mergedProps.titleColor, contentSize = mergedProps.contentSize, contentWeight = mergedProps.contentWeight, contentColor = mergedProps.contentColor, disabled = mergedProps.disabled, customRender = mergedProps.customRender;
143
- // Get background class from color name
144
187
  var getBgClass = function (color) {
145
188
  if (!color)
146
189
  return '';
@@ -153,7 +196,6 @@ var AccordionItem = function (_a) {
153
196
  }
154
197
  return '';
155
198
  };
156
- // Get border class from color name
157
199
  var getBorderClass = function (color) {
158
200
  if (!color)
159
201
  return '';
@@ -164,13 +206,11 @@ var AccordionItem = function (_a) {
164
206
  if (colorNames.includes(color)) {
165
207
  return "border-".concat(color);
166
208
  }
167
- // Special handling for borderColor
168
209
  if (color === 'borderColor') {
169
210
  return 'border-default';
170
211
  }
171
212
  return '';
172
213
  };
173
- // Get text size class
174
214
  var getTextSizeClass = function (size) {
175
215
  if (!size)
176
216
  return 'text-sm';
@@ -183,7 +223,6 @@ var AccordionItem = function (_a) {
183
223
  }
184
224
  return 'text-sm';
185
225
  };
186
- // Get text color class
187
226
  var getTextColorClass = function (color) {
188
227
  if (!color)
189
228
  return 'text-default';
@@ -210,17 +249,14 @@ var AccordionItem = function (_a) {
210
249
  var titleContent = typeof item.title === 'string' ? (react_1.default.createElement("div", { className: "\n ".concat(getTextSizeClass(titleSize), " \n ").concat(getTextColorClass(titleColor), "\n ").concat(titleClass || '', "\n ").trim(), style: {
211
250
  fontWeight: titleWeight || 400,
212
251
  } }, item.title)) : item.title;
213
- // Get container classes
214
252
  var getContainerClasses = function () {
215
253
  var classes = ['accordion-item'];
216
- // Background
217
254
  if (globalProps.bg) {
218
255
  var bgClass = getBgClass(globalProps.bg);
219
256
  if (bgClass) {
220
257
  classes.push(bgClass);
221
258
  }
222
259
  }
223
- // Border
224
260
  if (globalProps.border) {
225
261
  classes.push('border');
226
262
  var borderClass = getBorderClass(globalProps.borderColor);
@@ -228,7 +264,6 @@ var AccordionItem = function (_a) {
228
264
  classes.push(borderClass);
229
265
  }
230
266
  }
231
- // Border radius
232
267
  if (globalProps.borderRadius) {
233
268
  var radius = getSpacingValue(globalProps.borderRadius);
234
269
  if (radius === '0.25rem')
@@ -240,18 +275,15 @@ var AccordionItem = function (_a) {
240
275
  else if (radius === '1rem')
241
276
  classes.push('rounded-xl');
242
277
  }
243
- // Shadow
244
278
  if (globalProps.shadow && globalProps.shadow !== 'none') {
245
279
  classes.push("shadow-".concat(globalProps.shadow));
246
280
  }
247
- // State classes
248
281
  if (isOpen) {
249
282
  classes.push(activeClass || 'active');
250
283
  }
251
284
  if (disabled) {
252
285
  classes.push('disabled');
253
286
  }
254
- // Custom classes
255
287
  if (itemClass) {
256
288
  classes.push(itemClass);
257
289
  }
@@ -259,7 +291,7 @@ var AccordionItem = function (_a) {
259
291
  };
260
292
  return (react_1.default.createElement("div", { className: getContainerClasses(), style: {
261
293
  marginBottom: getSpacingValue(globalProps.gap) || '0.5rem',
262
- overflow: 'visible', // Add overflow hidden to prevent content overflow
294
+ overflow: 'visible',
263
295
  } },
264
296
  react_1.default.createElement("div", { className: "accordion-header ".concat(titleClass || ''), onClick: !disabled ? function () { return onToggle(index); } : undefined, role: "button", tabIndex: disabled ? -1 : 0, "aria-expanded": isOpen, onKeyDown: function (e) {
265
297
  if (!disabled && (e.key === 'Enter' || e.key === ' ')) {
@@ -288,7 +320,7 @@ var AccordionItem = function (_a) {
288
320
  transition: "max-height ".concat(animationDuration, "ms ").concat(animationEasing),
289
321
  padding: isOpen ? getSpacingValue(globalProps.padding) || '0.5rem 0' : '0',
290
322
  backgroundColor: globalProps.contentBg ? getBgClass(globalProps.contentBg) : '',
291
- borderTop: isOpen && globalProps.border ? "1px solid ".concat((0, getCssVariable_1.getCssVariableValue)(globalProps.borderColor) || 'var(--borderColor)') : 'none',
323
+ borderTop: isOpen && globalProps.border ? "1px solid ".concat(getCssVariableValue(globalProps.borderColor) || 'var(--borderColor)') : 'none',
292
324
  } },
293
325
  react_1.default.createElement("div", { className: "\n accordion-inner\n ".concat(getTextSizeClass(contentSize), "\n ").concat(getTextColorClass(contentColor), "\n ").trim(), style: {
294
326
  opacity: isOpen ? 1 : 0,
@@ -299,12 +331,10 @@ var AccordionItem = function (_a) {
299
331
  };
300
332
  // Main Accordion Component
301
333
  var Accordion = function (localProps) {
302
- // Merge props with configuration
303
- var mergeWithLocal = (0, componentUtils_1.useComponentConfiguration)('Accordion', localProps.variant).mergeWithLocal;
334
+ var mergeWithLocal = useComponentConfiguration('Accordion', localProps.variant).mergeWithLocal;
304
335
  var mergedProps = mergeWithLocal(localProps).props;
305
336
  var final = mergedProps;
306
- var _a = (0, react_1.useState)([]), openIndexes = _a[0], setOpenIndexes = _a[1];
307
- var _b = (0, react_1.useState)([]), itemsArray = _b[0], setItemsArray = _b[1];
337
+ var _a = (0, react_1.useState)([]), itemsArray = _a[0], setItemsArray = _a[1];
308
338
  // Parse items from JSON string if needed
309
339
  (0, react_1.useEffect)(function () {
310
340
  if (typeof final.items === 'string') {
@@ -324,35 +354,38 @@ var Accordion = function (localProps) {
324
354
  setItemsArray([]);
325
355
  }
326
356
  }, [final.items]);
327
- // Initialize open indexes
328
- (0, react_1.useEffect)(function () {
357
+ // Initialize open indexes using useMemo to compute initial value
358
+ var initialOpenIndexes = react_1.default.useMemo(function () {
329
359
  if (final.allowMultiple) {
330
- setOpenIndexes(final.defaultOpenIndexes || []);
360
+ return final.defaultOpenIndexes || [];
331
361
  }
332
362
  else {
333
- setOpenIndexes(final.defaultOpenIndexes && final.defaultOpenIndexes.length > 0
363
+ return final.defaultOpenIndexes && final.defaultOpenIndexes.length > 0
334
364
  ? [final.defaultOpenIndexes[0]]
335
- : []);
365
+ : [];
336
366
  }
337
- }, [final.defaultOpenIndexes, final.allowMultiple]);
367
+ }, [final.allowMultiple, final.defaultOpenIndexes]);
368
+ var _b = (0, react_1.useState)(initialOpenIndexes), openIndexes = _b[0], setOpenIndexes = _b[1];
338
369
  var toggleIndex = function (index) {
339
- var newOpenIndexes = [];
340
- if (final.allowMultiple) {
341
- if (openIndexes.includes(index)) {
342
- newOpenIndexes = openIndexes.filter(function (i) { return i !== index; });
370
+ setOpenIndexes(function (prevOpenIndexes) {
371
+ var newOpenIndexes = [];
372
+ if (final.allowMultiple) {
373
+ if (prevOpenIndexes.includes(index)) {
374
+ newOpenIndexes = prevOpenIndexes.filter(function (i) { return i !== index; });
375
+ }
376
+ else {
377
+ newOpenIndexes = __spreadArray(__spreadArray([], prevOpenIndexes, true), [index], false);
378
+ }
343
379
  }
344
380
  else {
345
- newOpenIndexes = __spreadArray(__spreadArray([], openIndexes, true), [index], false);
381
+ newOpenIndexes = prevOpenIndexes.includes(index) ? [] : [index];
346
382
  }
347
- }
348
- else {
349
- newOpenIndexes = openIndexes.includes(index) ? [] : [index];
350
- }
351
- setOpenIndexes(newOpenIndexes);
352
- // Call callback if provided
353
- if (final.onItemToggle) {
354
- final.onItemToggle(index, !openIndexes.includes(index));
355
- }
383
+ // Call callback if provided
384
+ if (final.onItemToggle) {
385
+ final.onItemToggle(index, !prevOpenIndexes.includes(index));
386
+ }
387
+ return newOpenIndexes;
388
+ });
356
389
  };
357
390
  var getContainerClasses = function () {
358
391
  var classes = ['accordion'];
@@ -364,6 +397,14 @@ var Accordion = function (localProps) {
364
397
  }
365
398
  return classes.filter(Boolean).join(' ');
366
399
  };
400
+ var getSpacingValue = function (value) {
401
+ if (!value)
402
+ return '';
403
+ if (/^\d+$/.test(value)) {
404
+ return "".concat(parseInt(value) * 0.25, "rem");
405
+ }
406
+ return value;
407
+ };
367
408
  var getContainerStyles = function () {
368
409
  var styles = {};
369
410
  if (final.margin) {
@@ -377,14 +418,6 @@ var Accordion = function (localProps) {
377
418
  }
378
419
  return styles;
379
420
  };
380
- var getSpacingValue = function (value) {
381
- if (!value)
382
- return '';
383
- if (/^\d+$/.test(value)) {
384
- return "".concat(parseInt(value) * 0.25, "rem");
385
- }
386
- return value;
387
- };
388
421
  if (itemsArray.length === 0) {
389
422
  return null;
390
423
  }
@@ -392,6 +425,572 @@ var Accordion = function (localProps) {
392
425
  };
393
426
  exports.default = Accordion;
394
427
  // 'use client';
428
+ // import React, { useState, useEffect } from 'react';
429
+ // import { getCssVariableValue } from '../../utils/getCssVariable';
430
+ // import { useComponentConfiguration } from '../../utils/componentUtils';
431
+ // import RowFlex from '../specials/RowFlex';
432
+ // import { getDynamicIcon } from '../../utils/getDynamicIcon';
433
+ // import { PiCaretDown } from 'react-icons/pi';
434
+ // // Define types for dynamic icons
435
+ // type AccordionItemType = {
436
+ // // Core content
437
+ // title: string | React.ReactNode;
438
+ // content: React.ReactNode;
439
+ // icon?: string | React.ReactNode;
440
+ // // Customization per item
441
+ // itemClass?: string;
442
+ // titleClass?: string;
443
+ // iconClass?: string;
444
+ // contentClass?: string;
445
+ // activeClass?: string;
446
+ // // Icon customization per item
447
+ // iconColor?: string;
448
+ // iconSize?: number;
449
+ // iconClassName?: string;
450
+ // expandIcon?: string | React.ReactNode;
451
+ // expandIconColor?: string;
452
+ // expandIconSize?: number;
453
+ // expandIconClassName?: string;
454
+ // // Title styling per item
455
+ // titleSize?: string;
456
+ // titleWeight?: number;
457
+ // titleColor?: string;
458
+ // // Content styling per item
459
+ // contentSize?: string;
460
+ // contentWeight?: number;
461
+ // contentColor?: string;
462
+ // // Animation
463
+ // animationDuration?: number;
464
+ // animationEasing?: string;
465
+ // // Advanced
466
+ // disabled?: boolean;
467
+ // customRender?: (isOpen: boolean) => React.ReactNode;
468
+ // };
469
+ // type AccordionProps = {
470
+ // // Core props
471
+ // items: AccordionItemType[] | string; // Support JSON string
472
+ // allowMultiple?: boolean;
473
+ // defaultOpenIndexes?: number[];
474
+ // variant?: string;
475
+ // // Icons
476
+ // icon?: string | React.ReactNode;
477
+ // iconColor?: string;
478
+ // iconSize?: number;
479
+ // iconClassName?: string;
480
+ // iconPosition?: 'left' | 'right' | 'none';
481
+ // expandIcon?: string | React.ReactNode;
482
+ // expandIconColor?: string;
483
+ // expandIconSize?: number;
484
+ // expandIconClassName?: string;
485
+ // expandIconRotate?: boolean;
486
+ // // Styling
487
+ // itemClass?: string;
488
+ // titleClass?: string;
489
+ // iconClass?: string;
490
+ // contentClass?: string;
491
+ // activeClass?: string;
492
+ // // Title styling
493
+ // titleSize?: string;
494
+ // titleWeight?: number;
495
+ // titleColor?: string;
496
+ // titleClassName?: string;
497
+ // // Content styling
498
+ // contentSize?: string;
499
+ // contentWeight?: number;
500
+ // contentColor?: string;
501
+ // contentClassName?: string;
502
+ // // Layout
503
+ // gap?: string;
504
+ // padding?: string;
505
+ // margin?: string;
506
+ // border?: boolean;
507
+ // borderColor?: string;
508
+ // borderRadius?: string;
509
+ // shadow?: 'sm' | 'md' | 'lg' | 'xl' | 'none';
510
+ // // Animation
511
+ // animationDuration?: number;
512
+ // animationEasing?: string;
513
+ // // Advanced
514
+ // className?: string;
515
+ // funcss?: string;
516
+ // style?: React.CSSProperties;
517
+ // // Callbacks
518
+ // onItemToggle?: (index: number, isOpen: boolean) => void;
519
+ // onAllClose?: () => void;
520
+ // onAllOpen?: () => void;
521
+ // };
522
+ // // Custom hook for dynamic icons
523
+ // const useDynamicIcon = (iconString?: string) => {
524
+ // const [iconNode, setIconNode] = useState<React.ReactNode>(null);
525
+ // const [hasValidIcon, setHasValidIcon] = useState(false);
526
+ // useEffect(() => {
527
+ // if (!iconString || typeof iconString !== 'string' || iconString.trim() === '') {
528
+ // setIconNode(null);
529
+ // setHasValidIcon(false);
530
+ // return;
531
+ // }
532
+ // getDynamicIcon(iconString).then((node) => {
533
+ // if (node) {
534
+ // setIconNode(node);
535
+ // setHasValidIcon(true);
536
+ // } else {
537
+ // setIconNode(null);
538
+ // setHasValidIcon(false);
539
+ // }
540
+ // });
541
+ // }, [iconString]);
542
+ // return { iconNode, hasValidIcon };
543
+ // };
544
+ // // Icon component with dynamic icon support
545
+ // const AccordionIcon: React.FC<{
546
+ // icon?: string | React.ReactNode;
547
+ // iconColor?: string;
548
+ // iconSize?: number;
549
+ // iconClassName?: string;
550
+ // isExpandIcon?: boolean;
551
+ // expandIcon?: string | React.ReactNode;
552
+ // expandIconColor?: string;
553
+ // expandIconSize?: number;
554
+ // expandIconClassName?: string;
555
+ // isOpen?: boolean;
556
+ // rotate?: boolean;
557
+ // }> = ({
558
+ // icon,
559
+ // iconColor,
560
+ // iconSize = 15,
561
+ // iconClassName = '',
562
+ // isExpandIcon = false,
563
+ // expandIcon,
564
+ // expandIconColor,
565
+ // expandIconSize = 15,
566
+ // expandIconClassName = '',
567
+ // isOpen = false,
568
+ // rotate = true
569
+ // }) => {
570
+ // const iconToUse = isExpandIcon ? expandIcon : icon;
571
+ // const colorToUse = isExpandIcon ? expandIconColor : iconColor;
572
+ // const sizeToUse = isExpandIcon ? expandIconSize : iconSize;
573
+ // const classNameToUse = isExpandIcon ? expandIconClassName : iconClassName;
574
+ // // Handle string icons (dynamic)
575
+ // const isStringIcon = iconToUse && typeof iconToUse === 'string';
576
+ // const { iconNode: dynamicIconNode, hasValidIcon: hasValidDynamicIcon } = useDynamicIcon(
577
+ // isStringIcon ? iconToUse as string : undefined
578
+ // );
579
+ // // Get color class from color name
580
+ // const getColorClass = (color?: string): string => {
581
+ // if (!color) return '';
582
+ // if (color.startsWith('text-') || color.startsWith('bg-') || color.startsWith('border-')) {
583
+ // return color;
584
+ // }
585
+ // const colorNames = ['primary', 'secondary', 'accent', 'success', 'warning', 'error', 'info', 'dark', 'light'];
586
+ // if (colorNames.includes(color)) {
587
+ // return `text-${color}`;
588
+ // }
589
+ // return '';
590
+ // };
591
+ // const colorClass = getColorClass(colorToUse);
592
+ // const renderIconWithProps = (iconElement: React.ReactNode, className: string, size?: number) => {
593
+ // if (!React.isValidElement(iconElement)) return iconElement;
594
+ // const props: any = {
595
+ // className: `${className} ${colorClass}`.trim(),
596
+ // };
597
+ // if (size !== undefined) {
598
+ // props.size = size;
599
+ // }
600
+ // return React.cloneElement(iconElement, props);
601
+ // };
602
+ // // If it's a React element icon
603
+ // if (iconToUse && typeof iconToUse !== 'string' && React.isValidElement(iconToUse)) {
604
+ // return renderIconWithProps(
605
+ // iconToUse,
606
+ // `${isExpandIcon ? 'accordion-expand-icon' : 'accordion-icon'} ${classNameToUse} ${isOpen && rotate ? 'accordion-rotated' : ''}`.trim(),
607
+ // sizeToUse
608
+ // );
609
+ // }
610
+ // // If it's a string icon (dynamic)
611
+ // if (isStringIcon && hasValidDynamicIcon && dynamicIconNode) {
612
+ // return renderIconWithProps(
613
+ // dynamicIconNode,
614
+ // `${isExpandIcon ? 'accordion-expand-icon' : 'accordion-icon'} ${classNameToUse} ${isOpen && rotate ? 'accordion-rotated' : ''}`.trim(),
615
+ // sizeToUse
616
+ // );
617
+ // }
618
+ // // Default expand icon (PiCaretDown)
619
+ // if (isExpandIcon && !iconToUse) {
620
+ // return (
621
+ // <PiCaretDown
622
+ // className={`accordion-expand-icon ${expandIconClassName || ''} ${colorClass} ${isOpen && rotate ? 'accordion-rotated' : ''}`.trim()}
623
+ // style={{
624
+ // fontSize: expandIconSize,
625
+ // transition: 'transform 0.3s ease',
626
+ // }}
627
+ // />
628
+ // );
629
+ // }
630
+ // return null;
631
+ // };
632
+ // // Accordion Item Component
633
+ // const AccordionItem: React.FC<{
634
+ // item: AccordionItemType;
635
+ // index: number;
636
+ // isOpen: boolean;
637
+ // onToggle: (index: number) => void;
638
+ // globalProps: any;
639
+ // animationDuration?: number;
640
+ // animationEasing?: string;
641
+ // }> = ({ item, index, isOpen, onToggle, globalProps, animationDuration = 300, animationEasing = 'ease' }) => {
642
+ // // Merge item props with global props (item props take precedence)
643
+ // const mergedProps = {
644
+ // ...globalProps,
645
+ // ...item
646
+ // };
647
+ // const {
648
+ // itemClass,
649
+ // titleClass,
650
+ // iconClass,
651
+ // contentClass,
652
+ // activeClass,
653
+ // icon,
654
+ // iconColor,
655
+ // iconSize,
656
+ // iconClassName,
657
+ // iconPosition = 'left',
658
+ // expandIcon,
659
+ // expandIconColor,
660
+ // expandIconSize,
661
+ // expandIconClassName,
662
+ // expandIconRotate = true,
663
+ // titleSize,
664
+ // titleWeight,
665
+ // titleColor,
666
+ // contentSize,
667
+ // contentWeight,
668
+ // contentColor,
669
+ // disabled,
670
+ // customRender
671
+ // } = mergedProps;
672
+ // // Get background class from color name
673
+ // const getBgClass = (color?: string): string => {
674
+ // if (!color) return '';
675
+ // if (color.startsWith('bg-')) {
676
+ // return color;
677
+ // }
678
+ // const colorNames = ['primary', 'secondary', 'accent', 'success', 'warning', 'error', 'info', 'dark', 'light'];
679
+ // if (colorNames.includes(color)) {
680
+ // return `bg-${color}`;
681
+ // }
682
+ // return '';
683
+ // };
684
+ // // Get border class from color name
685
+ // const getBorderClass = (color?: string): string => {
686
+ // if (!color) return '';
687
+ // if (color.startsWith('border-')) {
688
+ // return color;
689
+ // }
690
+ // const colorNames = ['primary', 'secondary', 'accent', 'success', 'warning', 'error', 'info', 'dark', 'light'];
691
+ // if (colorNames.includes(color)) {
692
+ // return `border-${color}`;
693
+ // }
694
+ // // Special handling for borderColor
695
+ // if (color === 'borderColor') {
696
+ // return 'border-default';
697
+ // }
698
+ // return '';
699
+ // };
700
+ // // Get text size class
701
+ // const getTextSizeClass = (size?: string): string => {
702
+ // if (!size) return 'text-sm';
703
+ // if (size.startsWith('text-')) {
704
+ // return size;
705
+ // }
706
+ // const validSizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl'];
707
+ // if (validSizes.includes(size)) {
708
+ // return `text-${size}`;
709
+ // }
710
+ // return 'text-sm';
711
+ // };
712
+ // // Get text color class
713
+ // const getTextColorClass = (color?: string): string => {
714
+ // if (!color) return 'text-default';
715
+ // if (color.startsWith('text-')) {
716
+ // return color;
717
+ // }
718
+ // const colorNames = ['primary', 'secondary', 'accent', 'success', 'warning', 'error', 'info', 'dark', 'light', 'default', 'muted'];
719
+ // if (colorNames.includes(color)) {
720
+ // return `text-${color}`;
721
+ // }
722
+ // return 'text-default';
723
+ // };
724
+ // const getSpacingValue = (value?: string): string => {
725
+ // if (!value) return '';
726
+ // if (/^\d+$/.test(value)) {
727
+ // return `${parseInt(value) * 0.25}rem`;
728
+ // }
729
+ // return value;
730
+ // };
731
+ // if (customRender) {
732
+ // return customRender(isOpen);
733
+ // }
734
+ // const titleContent = typeof item.title === 'string' ? (
735
+ // <div
736
+ // className={`
737
+ // ${getTextSizeClass(titleSize)}
738
+ // ${getTextColorClass(titleColor)}
739
+ // ${titleClass || ''}
740
+ // `.trim()}
741
+ // style={{
742
+ // fontWeight: titleWeight || 400,
743
+ // }}
744
+ // >
745
+ // {item.title}
746
+ // </div>
747
+ // ) : item.title;
748
+ // // Get container classes
749
+ // const getContainerClasses = (): string => {
750
+ // const classes = ['accordion-item'];
751
+ // // Background
752
+ // if (globalProps.bg) {
753
+ // const bgClass = getBgClass(globalProps.bg);
754
+ // if (bgClass) {
755
+ // classes.push(bgClass);
756
+ // }
757
+ // }
758
+ // // Border
759
+ // if (globalProps.border) {
760
+ // classes.push('border');
761
+ // const borderClass = getBorderClass(globalProps.borderColor);
762
+ // if (borderClass) {
763
+ // classes.push(borderClass);
764
+ // }
765
+ // }
766
+ // // Border radius
767
+ // if (globalProps.borderRadius) {
768
+ // const radius = getSpacingValue(globalProps.borderRadius);
769
+ // if (radius === '0.25rem') classes.push('rounded-sm');
770
+ // else if (radius === '0.5rem') classes.push('rounded-md');
771
+ // else if (radius === '0.75rem') classes.push('rounded-lg');
772
+ // else if (radius === '1rem') classes.push('rounded-xl');
773
+ // }
774
+ // // Shadow
775
+ // if (globalProps.shadow && globalProps.shadow !== 'none') {
776
+ // classes.push(`shadow-${globalProps.shadow}`);
777
+ // }
778
+ // // State classes
779
+ // if (isOpen) {
780
+ // classes.push(activeClass || 'active');
781
+ // }
782
+ // if (disabled) {
783
+ // classes.push('disabled');
784
+ // }
785
+ // // Custom classes
786
+ // if (itemClass) {
787
+ // classes.push(itemClass);
788
+ // }
789
+ // return classes.filter(Boolean).join(' ');
790
+ // };
791
+ // return (
792
+ // <div
793
+ // className={getContainerClasses()}
794
+ // style={{
795
+ // marginBottom: getSpacingValue(globalProps.gap) || '0.5rem',
796
+ // overflow: 'visible', // Add overflow hidden to prevent content overflow
797
+ // }}
798
+ // >
799
+ // <div
800
+ // className={`accordion-header ${titleClass || ''}`}
801
+ // onClick={!disabled ? () => onToggle(index) : undefined}
802
+ // role="button"
803
+ // tabIndex={disabled ? -1 : 0}
804
+ // aria-expanded={isOpen}
805
+ // onKeyDown={(e) => {
806
+ // if (!disabled && (e.key === 'Enter' || e.key === ' ')) {
807
+ // e.preventDefault();
808
+ // onToggle(index);
809
+ // }
810
+ // }}
811
+ // style={{
812
+ // cursor: disabled ? 'not-allowed' : 'pointer',
813
+ // opacity: disabled ? 0.6 : 1,
814
+ // padding: getSpacingValue(globalProps.padding) || '0',
815
+ // display: 'flex',
816
+ // alignItems: 'center',
817
+ // justifyContent: 'space-between',
818
+ // }}
819
+ // >
820
+ // <div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem', flex: 1 }}>
821
+ // {iconPosition === 'left' && (
822
+ // <AccordionIcon
823
+ // icon={icon}
824
+ // iconColor={iconColor}
825
+ // iconSize={iconSize}
826
+ // iconClassName={iconClass || iconClassName}
827
+ // isOpen={isOpen}
828
+ // />
829
+ // )}
830
+ // <div className="col" style={{ flex: 1 }}>
831
+ // {titleContent}
832
+ // </div>
833
+ // {iconPosition === 'right' && (
834
+ // <AccordionIcon
835
+ // icon={icon}
836
+ // iconColor={iconColor}
837
+ // iconSize={iconSize}
838
+ // iconClassName={iconClass || iconClassName}
839
+ // isOpen={isOpen}
840
+ // />
841
+ // )}
842
+ // </div>
843
+ // <div style={{ lineHeight: 0 }}>
844
+ // <AccordionIcon
845
+ // isExpandIcon
846
+ // expandIcon={expandIcon}
847
+ // expandIconColor={expandIconColor}
848
+ // expandIconSize={expandIconSize}
849
+ // expandIconClassName={expandIconClassName}
850
+ // isOpen={isOpen}
851
+ // rotate={expandIconRotate}
852
+ // />
853
+ // </div>
854
+ // </div>
855
+ // <div
856
+ // className={`accordion-content ${contentClass || ''} ${isOpen ? 'open' : ''}`}
857
+ // style={{
858
+ // maxHeight: isOpen ? '10000px' : '0',
859
+ // overflow: 'visible',
860
+ // opacity: isOpen ? 1 : 0,
861
+ // visibility: isOpen ? 'visible' : 'hidden',
862
+ // transition: `max-height ${animationDuration}ms ${animationEasing}`,
863
+ // padding: isOpen ? getSpacingValue(globalProps.padding) || '0.5rem 0' : '0',
864
+ // backgroundColor: globalProps.contentBg ? getBgClass(globalProps.contentBg) : '',
865
+ // borderTop: isOpen && globalProps.border ? `1px solid ${getCssVariableValue(globalProps.borderColor) || 'var(--borderColor)'}` : 'none',
866
+ // }}
867
+ // >
868
+ // <div
869
+ // className={`
870
+ // accordion-inner
871
+ // ${getTextSizeClass(contentSize)}
872
+ // ${getTextColorClass(contentColor)}
873
+ // `.trim()}
874
+ // style={{
875
+ // opacity: isOpen ? 1 : 0,
876
+ // transition: `opacity ${animationDuration}ms ${animationEasing}`,
877
+ // fontWeight: contentWeight || 400,
878
+ // lineHeight: 1.6,
879
+ // }}
880
+ // >
881
+ // {item.content}
882
+ // </div>
883
+ // </div>
884
+ // </div>
885
+ // );
886
+ // };
887
+ // // Main Accordion Component
888
+ // const Accordion: React.FC<AccordionProps> = (localProps) => {
889
+ // // Merge props with configuration
890
+ // const { mergeWithLocal } = useComponentConfiguration('Accordion', localProps.variant);
891
+ // const { props: mergedProps } = mergeWithLocal(localProps);
892
+ // const final = mergedProps;
893
+ // const [openIndexes, setOpenIndexes] = useState<number[]>([]);
894
+ // const [itemsArray, setItemsArray] = useState<AccordionItemType[]>([]);
895
+ // // Parse items from JSON string if needed
896
+ // useEffect(() => {
897
+ // if (typeof final.items === 'string') {
898
+ // try {
899
+ // const parsed = JSON.parse(final.items);
900
+ // setItemsArray(Array.isArray(parsed) ? parsed : [parsed]);
901
+ // } catch (error) {
902
+ // console.error('Error parsing items JSON:', error);
903
+ // setItemsArray([]);
904
+ // }
905
+ // } else if (Array.isArray(final.items)) {
906
+ // setItemsArray(final.items);
907
+ // } else {
908
+ // setItemsArray([]);
909
+ // }
910
+ // }, [final.items]);
911
+ // // Initialize open indexes
912
+ // useEffect(() => {
913
+ // if (final.allowMultiple) {
914
+ // setOpenIndexes(final.defaultOpenIndexes || []);
915
+ // } else {
916
+ // setOpenIndexes(final.defaultOpenIndexes && final.defaultOpenIndexes.length > 0
917
+ // ? [final.defaultOpenIndexes[0]]
918
+ // : []);
919
+ // }
920
+ // }, [final.defaultOpenIndexes, final.allowMultiple]);
921
+ // const toggleIndex = (index: number) => {
922
+ // let newOpenIndexes: number[] = [];
923
+ // if (final.allowMultiple) {
924
+ // if (openIndexes.includes(index)) {
925
+ // newOpenIndexes = openIndexes.filter((i) => i !== index);
926
+ // } else {
927
+ // newOpenIndexes = [...openIndexes, index];
928
+ // }
929
+ // } else {
930
+ // newOpenIndexes = openIndexes.includes(index) ? [] : [index];
931
+ // }
932
+ // setOpenIndexes(newOpenIndexes);
933
+ // // Call callback if provided
934
+ // if (final.onItemToggle) {
935
+ // final.onItemToggle(index, !openIndexes.includes(index));
936
+ // }
937
+ // };
938
+ // const getContainerClasses = (): string => {
939
+ // const classes = ['accordion'];
940
+ // if (final.className) {
941
+ // classes.push(final.className);
942
+ // }
943
+ // if (final.funcss) {
944
+ // classes.push(final.funcss);
945
+ // }
946
+ // return classes.filter(Boolean).join(' ');
947
+ // };
948
+ // const getContainerStyles = (): React.CSSProperties => {
949
+ // const styles: React.CSSProperties = {};
950
+ // if (final.margin) {
951
+ // const marginValue = getSpacingValue(final.margin);
952
+ // if (marginValue) {
953
+ // styles.margin = marginValue;
954
+ // }
955
+ // }
956
+ // if (final.style) {
957
+ // Object.assign(styles, final.style);
958
+ // }
959
+ // return styles;
960
+ // };
961
+ // const getSpacingValue = (value?: string): string => {
962
+ // if (!value) return '';
963
+ // if (/^\d+$/.test(value)) {
964
+ // return `${parseInt(value) * 0.25}rem`;
965
+ // }
966
+ // return value;
967
+ // };
968
+ // if (itemsArray.length === 0) {
969
+ // return null;
970
+ // }
971
+ // return (
972
+ // <div
973
+ // className={getContainerClasses()}
974
+ // style={getContainerStyles()}
975
+ // >
976
+ // {itemsArray.map((item, index) => (
977
+ // <AccordionItem
978
+ // key={index}
979
+ // item={item}
980
+ // index={index}
981
+ // isOpen={openIndexes.includes(index)}
982
+ // onToggle={toggleIndex}
983
+ // globalProps={final}
984
+ // animationDuration={final.animationDuration}
985
+ // animationEasing={final.animationEasing}
986
+ // />
987
+ // ))}
988
+ // </div>
989
+ // );
990
+ // };
991
+ // export default Accordion;
992
+ // export type { AccordionItemType, AccordionProps };
993
+ // 'use client';
395
994
  // import React, { useState } from 'react';
396
995
  // import { PiCaretDown } from 'react-icons/pi';
397
996
  // import RowFlex from '../specials/RowFlex';