funuicss 3.8.13 → 3.8.15
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 +10 -155
- package/package.json +1 -1
- package/ui/accordion/Accordion.js +589 -18
- package/ui/feature/Feature.d.ts +40 -70
- package/ui/feature/Feature.js +913 -175
- package/ui/form/Form.js +25 -7
- package/ui/sidebar/SideBar.js +354 -14
- package/ui/text/Text.d.ts +3 -0
- package/ui/text/Text.js +15 -2
- package/ui/vista/Vista.d.ts +8 -10
- package/ui/vista/Vista.js +57 -120
- package/utils/componentUtils.d.ts +2 -2
- package/utils/componentUtils.js +361 -310
|
@@ -259,7 +259,7 @@ var AccordionItem = function (_a) {
|
|
|
259
259
|
};
|
|
260
260
|
return (react_1.default.createElement("div", { className: getContainerClasses(), style: {
|
|
261
261
|
marginBottom: getSpacingValue(globalProps.gap) || '0.5rem',
|
|
262
|
-
overflow: 'visible',
|
|
262
|
+
overflow: 'visible',
|
|
263
263
|
} },
|
|
264
264
|
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
265
|
if (!disabled && (e.key === 'Enter' || e.key === ' ')) {
|
|
@@ -305,6 +305,8 @@ var Accordion = function (localProps) {
|
|
|
305
305
|
var final = mergedProps;
|
|
306
306
|
var _a = (0, react_1.useState)([]), openIndexes = _a[0], setOpenIndexes = _a[1];
|
|
307
307
|
var _b = (0, react_1.useState)([]), itemsArray = _b[0], setItemsArray = _b[1];
|
|
308
|
+
// Use ref to track if we've initialized
|
|
309
|
+
var hasInitialized = (0, react_1.useRef)(false);
|
|
308
310
|
// Parse items from JSON string if needed
|
|
309
311
|
(0, react_1.useEffect)(function () {
|
|
310
312
|
if (typeof final.items === 'string') {
|
|
@@ -324,17 +326,20 @@ var Accordion = function (localProps) {
|
|
|
324
326
|
setItemsArray([]);
|
|
325
327
|
}
|
|
326
328
|
}, [final.items]);
|
|
327
|
-
// Initialize open indexes
|
|
329
|
+
// Initialize open indexes only once
|
|
328
330
|
(0, react_1.useEffect)(function () {
|
|
329
|
-
if (
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
331
|
+
if (!hasInitialized.current) {
|
|
332
|
+
if (final.allowMultiple) {
|
|
333
|
+
setOpenIndexes(final.defaultOpenIndexes || []);
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
setOpenIndexes(final.defaultOpenIndexes && final.defaultOpenIndexes.length > 0
|
|
337
|
+
? [final.defaultOpenIndexes[0]]
|
|
338
|
+
: []);
|
|
339
|
+
}
|
|
340
|
+
hasInitialized.current = true;
|
|
336
341
|
}
|
|
337
|
-
}, [
|
|
342
|
+
}, []);
|
|
338
343
|
var toggleIndex = function (index) {
|
|
339
344
|
var newOpenIndexes = [];
|
|
340
345
|
if (final.allowMultiple) {
|
|
@@ -364,6 +369,14 @@ var Accordion = function (localProps) {
|
|
|
364
369
|
}
|
|
365
370
|
return classes.filter(Boolean).join(' ');
|
|
366
371
|
};
|
|
372
|
+
var getSpacingValue = function (value) {
|
|
373
|
+
if (!value)
|
|
374
|
+
return '';
|
|
375
|
+
if (/^\d+$/.test(value)) {
|
|
376
|
+
return "".concat(parseInt(value) * 0.25, "rem");
|
|
377
|
+
}
|
|
378
|
+
return value;
|
|
379
|
+
};
|
|
367
380
|
var getContainerStyles = function () {
|
|
368
381
|
var styles = {};
|
|
369
382
|
if (final.margin) {
|
|
@@ -377,14 +390,6 @@ var Accordion = function (localProps) {
|
|
|
377
390
|
}
|
|
378
391
|
return styles;
|
|
379
392
|
};
|
|
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
393
|
if (itemsArray.length === 0) {
|
|
389
394
|
return null;
|
|
390
395
|
}
|
|
@@ -392,6 +397,572 @@ var Accordion = function (localProps) {
|
|
|
392
397
|
};
|
|
393
398
|
exports.default = Accordion;
|
|
394
399
|
// 'use client';
|
|
400
|
+
// import React, { useState, useEffect } from 'react';
|
|
401
|
+
// import { getCssVariableValue } from '../../utils/getCssVariable';
|
|
402
|
+
// import { useComponentConfiguration } from '../../utils/componentUtils';
|
|
403
|
+
// import RowFlex from '../specials/RowFlex';
|
|
404
|
+
// import { getDynamicIcon } from '../../utils/getDynamicIcon';
|
|
405
|
+
// import { PiCaretDown } from 'react-icons/pi';
|
|
406
|
+
// // Define types for dynamic icons
|
|
407
|
+
// type AccordionItemType = {
|
|
408
|
+
// // Core content
|
|
409
|
+
// title: string | React.ReactNode;
|
|
410
|
+
// content: React.ReactNode;
|
|
411
|
+
// icon?: string | React.ReactNode;
|
|
412
|
+
// // Customization per item
|
|
413
|
+
// itemClass?: string;
|
|
414
|
+
// titleClass?: string;
|
|
415
|
+
// iconClass?: string;
|
|
416
|
+
// contentClass?: string;
|
|
417
|
+
// activeClass?: string;
|
|
418
|
+
// // Icon customization per item
|
|
419
|
+
// iconColor?: string;
|
|
420
|
+
// iconSize?: number;
|
|
421
|
+
// iconClassName?: string;
|
|
422
|
+
// expandIcon?: string | React.ReactNode;
|
|
423
|
+
// expandIconColor?: string;
|
|
424
|
+
// expandIconSize?: number;
|
|
425
|
+
// expandIconClassName?: string;
|
|
426
|
+
// // Title styling per item
|
|
427
|
+
// titleSize?: string;
|
|
428
|
+
// titleWeight?: number;
|
|
429
|
+
// titleColor?: string;
|
|
430
|
+
// // Content styling per item
|
|
431
|
+
// contentSize?: string;
|
|
432
|
+
// contentWeight?: number;
|
|
433
|
+
// contentColor?: string;
|
|
434
|
+
// // Animation
|
|
435
|
+
// animationDuration?: number;
|
|
436
|
+
// animationEasing?: string;
|
|
437
|
+
// // Advanced
|
|
438
|
+
// disabled?: boolean;
|
|
439
|
+
// customRender?: (isOpen: boolean) => React.ReactNode;
|
|
440
|
+
// };
|
|
441
|
+
// type AccordionProps = {
|
|
442
|
+
// // Core props
|
|
443
|
+
// items: AccordionItemType[] | string; // Support JSON string
|
|
444
|
+
// allowMultiple?: boolean;
|
|
445
|
+
// defaultOpenIndexes?: number[];
|
|
446
|
+
// variant?: string;
|
|
447
|
+
// // Icons
|
|
448
|
+
// icon?: string | React.ReactNode;
|
|
449
|
+
// iconColor?: string;
|
|
450
|
+
// iconSize?: number;
|
|
451
|
+
// iconClassName?: string;
|
|
452
|
+
// iconPosition?: 'left' | 'right' | 'none';
|
|
453
|
+
// expandIcon?: string | React.ReactNode;
|
|
454
|
+
// expandIconColor?: string;
|
|
455
|
+
// expandIconSize?: number;
|
|
456
|
+
// expandIconClassName?: string;
|
|
457
|
+
// expandIconRotate?: boolean;
|
|
458
|
+
// // Styling
|
|
459
|
+
// itemClass?: string;
|
|
460
|
+
// titleClass?: string;
|
|
461
|
+
// iconClass?: string;
|
|
462
|
+
// contentClass?: string;
|
|
463
|
+
// activeClass?: string;
|
|
464
|
+
// // Title styling
|
|
465
|
+
// titleSize?: string;
|
|
466
|
+
// titleWeight?: number;
|
|
467
|
+
// titleColor?: string;
|
|
468
|
+
// titleClassName?: string;
|
|
469
|
+
// // Content styling
|
|
470
|
+
// contentSize?: string;
|
|
471
|
+
// contentWeight?: number;
|
|
472
|
+
// contentColor?: string;
|
|
473
|
+
// contentClassName?: string;
|
|
474
|
+
// // Layout
|
|
475
|
+
// gap?: string;
|
|
476
|
+
// padding?: string;
|
|
477
|
+
// margin?: string;
|
|
478
|
+
// border?: boolean;
|
|
479
|
+
// borderColor?: string;
|
|
480
|
+
// borderRadius?: string;
|
|
481
|
+
// shadow?: 'sm' | 'md' | 'lg' | 'xl' | 'none';
|
|
482
|
+
// // Animation
|
|
483
|
+
// animationDuration?: number;
|
|
484
|
+
// animationEasing?: string;
|
|
485
|
+
// // Advanced
|
|
486
|
+
// className?: string;
|
|
487
|
+
// funcss?: string;
|
|
488
|
+
// style?: React.CSSProperties;
|
|
489
|
+
// // Callbacks
|
|
490
|
+
// onItemToggle?: (index: number, isOpen: boolean) => void;
|
|
491
|
+
// onAllClose?: () => void;
|
|
492
|
+
// onAllOpen?: () => void;
|
|
493
|
+
// };
|
|
494
|
+
// // Custom hook for dynamic icons
|
|
495
|
+
// const useDynamicIcon = (iconString?: string) => {
|
|
496
|
+
// const [iconNode, setIconNode] = useState<React.ReactNode>(null);
|
|
497
|
+
// const [hasValidIcon, setHasValidIcon] = useState(false);
|
|
498
|
+
// useEffect(() => {
|
|
499
|
+
// if (!iconString || typeof iconString !== 'string' || iconString.trim() === '') {
|
|
500
|
+
// setIconNode(null);
|
|
501
|
+
// setHasValidIcon(false);
|
|
502
|
+
// return;
|
|
503
|
+
// }
|
|
504
|
+
// getDynamicIcon(iconString).then((node) => {
|
|
505
|
+
// if (node) {
|
|
506
|
+
// setIconNode(node);
|
|
507
|
+
// setHasValidIcon(true);
|
|
508
|
+
// } else {
|
|
509
|
+
// setIconNode(null);
|
|
510
|
+
// setHasValidIcon(false);
|
|
511
|
+
// }
|
|
512
|
+
// });
|
|
513
|
+
// }, [iconString]);
|
|
514
|
+
// return { iconNode, hasValidIcon };
|
|
515
|
+
// };
|
|
516
|
+
// // Icon component with dynamic icon support
|
|
517
|
+
// const AccordionIcon: React.FC<{
|
|
518
|
+
// icon?: string | React.ReactNode;
|
|
519
|
+
// iconColor?: string;
|
|
520
|
+
// iconSize?: number;
|
|
521
|
+
// iconClassName?: string;
|
|
522
|
+
// isExpandIcon?: boolean;
|
|
523
|
+
// expandIcon?: string | React.ReactNode;
|
|
524
|
+
// expandIconColor?: string;
|
|
525
|
+
// expandIconSize?: number;
|
|
526
|
+
// expandIconClassName?: string;
|
|
527
|
+
// isOpen?: boolean;
|
|
528
|
+
// rotate?: boolean;
|
|
529
|
+
// }> = ({
|
|
530
|
+
// icon,
|
|
531
|
+
// iconColor,
|
|
532
|
+
// iconSize = 15,
|
|
533
|
+
// iconClassName = '',
|
|
534
|
+
// isExpandIcon = false,
|
|
535
|
+
// expandIcon,
|
|
536
|
+
// expandIconColor,
|
|
537
|
+
// expandIconSize = 15,
|
|
538
|
+
// expandIconClassName = '',
|
|
539
|
+
// isOpen = false,
|
|
540
|
+
// rotate = true
|
|
541
|
+
// }) => {
|
|
542
|
+
// const iconToUse = isExpandIcon ? expandIcon : icon;
|
|
543
|
+
// const colorToUse = isExpandIcon ? expandIconColor : iconColor;
|
|
544
|
+
// const sizeToUse = isExpandIcon ? expandIconSize : iconSize;
|
|
545
|
+
// const classNameToUse = isExpandIcon ? expandIconClassName : iconClassName;
|
|
546
|
+
// // Handle string icons (dynamic)
|
|
547
|
+
// const isStringIcon = iconToUse && typeof iconToUse === 'string';
|
|
548
|
+
// const { iconNode: dynamicIconNode, hasValidIcon: hasValidDynamicIcon } = useDynamicIcon(
|
|
549
|
+
// isStringIcon ? iconToUse as string : undefined
|
|
550
|
+
// );
|
|
551
|
+
// // Get color class from color name
|
|
552
|
+
// const getColorClass = (color?: string): string => {
|
|
553
|
+
// if (!color) return '';
|
|
554
|
+
// if (color.startsWith('text-') || color.startsWith('bg-') || color.startsWith('border-')) {
|
|
555
|
+
// return color;
|
|
556
|
+
// }
|
|
557
|
+
// const colorNames = ['primary', 'secondary', 'accent', 'success', 'warning', 'error', 'info', 'dark', 'light'];
|
|
558
|
+
// if (colorNames.includes(color)) {
|
|
559
|
+
// return `text-${color}`;
|
|
560
|
+
// }
|
|
561
|
+
// return '';
|
|
562
|
+
// };
|
|
563
|
+
// const colorClass = getColorClass(colorToUse);
|
|
564
|
+
// const renderIconWithProps = (iconElement: React.ReactNode, className: string, size?: number) => {
|
|
565
|
+
// if (!React.isValidElement(iconElement)) return iconElement;
|
|
566
|
+
// const props: any = {
|
|
567
|
+
// className: `${className} ${colorClass}`.trim(),
|
|
568
|
+
// };
|
|
569
|
+
// if (size !== undefined) {
|
|
570
|
+
// props.size = size;
|
|
571
|
+
// }
|
|
572
|
+
// return React.cloneElement(iconElement, props);
|
|
573
|
+
// };
|
|
574
|
+
// // If it's a React element icon
|
|
575
|
+
// if (iconToUse && typeof iconToUse !== 'string' && React.isValidElement(iconToUse)) {
|
|
576
|
+
// return renderIconWithProps(
|
|
577
|
+
// iconToUse,
|
|
578
|
+
// `${isExpandIcon ? 'accordion-expand-icon' : 'accordion-icon'} ${classNameToUse} ${isOpen && rotate ? 'accordion-rotated' : ''}`.trim(),
|
|
579
|
+
// sizeToUse
|
|
580
|
+
// );
|
|
581
|
+
// }
|
|
582
|
+
// // If it's a string icon (dynamic)
|
|
583
|
+
// if (isStringIcon && hasValidDynamicIcon && dynamicIconNode) {
|
|
584
|
+
// return renderIconWithProps(
|
|
585
|
+
// dynamicIconNode,
|
|
586
|
+
// `${isExpandIcon ? 'accordion-expand-icon' : 'accordion-icon'} ${classNameToUse} ${isOpen && rotate ? 'accordion-rotated' : ''}`.trim(),
|
|
587
|
+
// sizeToUse
|
|
588
|
+
// );
|
|
589
|
+
// }
|
|
590
|
+
// // Default expand icon (PiCaretDown)
|
|
591
|
+
// if (isExpandIcon && !iconToUse) {
|
|
592
|
+
// return (
|
|
593
|
+
// <PiCaretDown
|
|
594
|
+
// className={`accordion-expand-icon ${expandIconClassName || ''} ${colorClass} ${isOpen && rotate ? 'accordion-rotated' : ''}`.trim()}
|
|
595
|
+
// style={{
|
|
596
|
+
// fontSize: expandIconSize,
|
|
597
|
+
// transition: 'transform 0.3s ease',
|
|
598
|
+
// }}
|
|
599
|
+
// />
|
|
600
|
+
// );
|
|
601
|
+
// }
|
|
602
|
+
// return null;
|
|
603
|
+
// };
|
|
604
|
+
// // Accordion Item Component
|
|
605
|
+
// const AccordionItem: React.FC<{
|
|
606
|
+
// item: AccordionItemType;
|
|
607
|
+
// index: number;
|
|
608
|
+
// isOpen: boolean;
|
|
609
|
+
// onToggle: (index: number) => void;
|
|
610
|
+
// globalProps: any;
|
|
611
|
+
// animationDuration?: number;
|
|
612
|
+
// animationEasing?: string;
|
|
613
|
+
// }> = ({ item, index, isOpen, onToggle, globalProps, animationDuration = 300, animationEasing = 'ease' }) => {
|
|
614
|
+
// // Merge item props with global props (item props take precedence)
|
|
615
|
+
// const mergedProps = {
|
|
616
|
+
// ...globalProps,
|
|
617
|
+
// ...item
|
|
618
|
+
// };
|
|
619
|
+
// const {
|
|
620
|
+
// itemClass,
|
|
621
|
+
// titleClass,
|
|
622
|
+
// iconClass,
|
|
623
|
+
// contentClass,
|
|
624
|
+
// activeClass,
|
|
625
|
+
// icon,
|
|
626
|
+
// iconColor,
|
|
627
|
+
// iconSize,
|
|
628
|
+
// iconClassName,
|
|
629
|
+
// iconPosition = 'left',
|
|
630
|
+
// expandIcon,
|
|
631
|
+
// expandIconColor,
|
|
632
|
+
// expandIconSize,
|
|
633
|
+
// expandIconClassName,
|
|
634
|
+
// expandIconRotate = true,
|
|
635
|
+
// titleSize,
|
|
636
|
+
// titleWeight,
|
|
637
|
+
// titleColor,
|
|
638
|
+
// contentSize,
|
|
639
|
+
// contentWeight,
|
|
640
|
+
// contentColor,
|
|
641
|
+
// disabled,
|
|
642
|
+
// customRender
|
|
643
|
+
// } = mergedProps;
|
|
644
|
+
// // Get background class from color name
|
|
645
|
+
// const getBgClass = (color?: string): string => {
|
|
646
|
+
// if (!color) return '';
|
|
647
|
+
// if (color.startsWith('bg-')) {
|
|
648
|
+
// return color;
|
|
649
|
+
// }
|
|
650
|
+
// const colorNames = ['primary', 'secondary', 'accent', 'success', 'warning', 'error', 'info', 'dark', 'light'];
|
|
651
|
+
// if (colorNames.includes(color)) {
|
|
652
|
+
// return `bg-${color}`;
|
|
653
|
+
// }
|
|
654
|
+
// return '';
|
|
655
|
+
// };
|
|
656
|
+
// // Get border class from color name
|
|
657
|
+
// const getBorderClass = (color?: string): string => {
|
|
658
|
+
// if (!color) return '';
|
|
659
|
+
// if (color.startsWith('border-')) {
|
|
660
|
+
// return color;
|
|
661
|
+
// }
|
|
662
|
+
// const colorNames = ['primary', 'secondary', 'accent', 'success', 'warning', 'error', 'info', 'dark', 'light'];
|
|
663
|
+
// if (colorNames.includes(color)) {
|
|
664
|
+
// return `border-${color}`;
|
|
665
|
+
// }
|
|
666
|
+
// // Special handling for borderColor
|
|
667
|
+
// if (color === 'borderColor') {
|
|
668
|
+
// return 'border-default';
|
|
669
|
+
// }
|
|
670
|
+
// return '';
|
|
671
|
+
// };
|
|
672
|
+
// // Get text size class
|
|
673
|
+
// const getTextSizeClass = (size?: string): string => {
|
|
674
|
+
// if (!size) return 'text-sm';
|
|
675
|
+
// if (size.startsWith('text-')) {
|
|
676
|
+
// return size;
|
|
677
|
+
// }
|
|
678
|
+
// const validSizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl'];
|
|
679
|
+
// if (validSizes.includes(size)) {
|
|
680
|
+
// return `text-${size}`;
|
|
681
|
+
// }
|
|
682
|
+
// return 'text-sm';
|
|
683
|
+
// };
|
|
684
|
+
// // Get text color class
|
|
685
|
+
// const getTextColorClass = (color?: string): string => {
|
|
686
|
+
// if (!color) return 'text-default';
|
|
687
|
+
// if (color.startsWith('text-')) {
|
|
688
|
+
// return color;
|
|
689
|
+
// }
|
|
690
|
+
// const colorNames = ['primary', 'secondary', 'accent', 'success', 'warning', 'error', 'info', 'dark', 'light', 'default', 'muted'];
|
|
691
|
+
// if (colorNames.includes(color)) {
|
|
692
|
+
// return `text-${color}`;
|
|
693
|
+
// }
|
|
694
|
+
// return 'text-default';
|
|
695
|
+
// };
|
|
696
|
+
// const getSpacingValue = (value?: string): string => {
|
|
697
|
+
// if (!value) return '';
|
|
698
|
+
// if (/^\d+$/.test(value)) {
|
|
699
|
+
// return `${parseInt(value) * 0.25}rem`;
|
|
700
|
+
// }
|
|
701
|
+
// return value;
|
|
702
|
+
// };
|
|
703
|
+
// if (customRender) {
|
|
704
|
+
// return customRender(isOpen);
|
|
705
|
+
// }
|
|
706
|
+
// const titleContent = typeof item.title === 'string' ? (
|
|
707
|
+
// <div
|
|
708
|
+
// className={`
|
|
709
|
+
// ${getTextSizeClass(titleSize)}
|
|
710
|
+
// ${getTextColorClass(titleColor)}
|
|
711
|
+
// ${titleClass || ''}
|
|
712
|
+
// `.trim()}
|
|
713
|
+
// style={{
|
|
714
|
+
// fontWeight: titleWeight || 400,
|
|
715
|
+
// }}
|
|
716
|
+
// >
|
|
717
|
+
// {item.title}
|
|
718
|
+
// </div>
|
|
719
|
+
// ) : item.title;
|
|
720
|
+
// // Get container classes
|
|
721
|
+
// const getContainerClasses = (): string => {
|
|
722
|
+
// const classes = ['accordion-item'];
|
|
723
|
+
// // Background
|
|
724
|
+
// if (globalProps.bg) {
|
|
725
|
+
// const bgClass = getBgClass(globalProps.bg);
|
|
726
|
+
// if (bgClass) {
|
|
727
|
+
// classes.push(bgClass);
|
|
728
|
+
// }
|
|
729
|
+
// }
|
|
730
|
+
// // Border
|
|
731
|
+
// if (globalProps.border) {
|
|
732
|
+
// classes.push('border');
|
|
733
|
+
// const borderClass = getBorderClass(globalProps.borderColor);
|
|
734
|
+
// if (borderClass) {
|
|
735
|
+
// classes.push(borderClass);
|
|
736
|
+
// }
|
|
737
|
+
// }
|
|
738
|
+
// // Border radius
|
|
739
|
+
// if (globalProps.borderRadius) {
|
|
740
|
+
// const radius = getSpacingValue(globalProps.borderRadius);
|
|
741
|
+
// if (radius === '0.25rem') classes.push('rounded-sm');
|
|
742
|
+
// else if (radius === '0.5rem') classes.push('rounded-md');
|
|
743
|
+
// else if (radius === '0.75rem') classes.push('rounded-lg');
|
|
744
|
+
// else if (radius === '1rem') classes.push('rounded-xl');
|
|
745
|
+
// }
|
|
746
|
+
// // Shadow
|
|
747
|
+
// if (globalProps.shadow && globalProps.shadow !== 'none') {
|
|
748
|
+
// classes.push(`shadow-${globalProps.shadow}`);
|
|
749
|
+
// }
|
|
750
|
+
// // State classes
|
|
751
|
+
// if (isOpen) {
|
|
752
|
+
// classes.push(activeClass || 'active');
|
|
753
|
+
// }
|
|
754
|
+
// if (disabled) {
|
|
755
|
+
// classes.push('disabled');
|
|
756
|
+
// }
|
|
757
|
+
// // Custom classes
|
|
758
|
+
// if (itemClass) {
|
|
759
|
+
// classes.push(itemClass);
|
|
760
|
+
// }
|
|
761
|
+
// return classes.filter(Boolean).join(' ');
|
|
762
|
+
// };
|
|
763
|
+
// return (
|
|
764
|
+
// <div
|
|
765
|
+
// className={getContainerClasses()}
|
|
766
|
+
// style={{
|
|
767
|
+
// marginBottom: getSpacingValue(globalProps.gap) || '0.5rem',
|
|
768
|
+
// overflow: 'visible', // Add overflow hidden to prevent content overflow
|
|
769
|
+
// }}
|
|
770
|
+
// >
|
|
771
|
+
// <div
|
|
772
|
+
// className={`accordion-header ${titleClass || ''}`}
|
|
773
|
+
// onClick={!disabled ? () => onToggle(index) : undefined}
|
|
774
|
+
// role="button"
|
|
775
|
+
// tabIndex={disabled ? -1 : 0}
|
|
776
|
+
// aria-expanded={isOpen}
|
|
777
|
+
// onKeyDown={(e) => {
|
|
778
|
+
// if (!disabled && (e.key === 'Enter' || e.key === ' ')) {
|
|
779
|
+
// e.preventDefault();
|
|
780
|
+
// onToggle(index);
|
|
781
|
+
// }
|
|
782
|
+
// }}
|
|
783
|
+
// style={{
|
|
784
|
+
// cursor: disabled ? 'not-allowed' : 'pointer',
|
|
785
|
+
// opacity: disabled ? 0.6 : 1,
|
|
786
|
+
// padding: getSpacingValue(globalProps.padding) || '0',
|
|
787
|
+
// display: 'flex',
|
|
788
|
+
// alignItems: 'center',
|
|
789
|
+
// justifyContent: 'space-between',
|
|
790
|
+
// }}
|
|
791
|
+
// >
|
|
792
|
+
// <div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem', flex: 1 }}>
|
|
793
|
+
// {iconPosition === 'left' && (
|
|
794
|
+
// <AccordionIcon
|
|
795
|
+
// icon={icon}
|
|
796
|
+
// iconColor={iconColor}
|
|
797
|
+
// iconSize={iconSize}
|
|
798
|
+
// iconClassName={iconClass || iconClassName}
|
|
799
|
+
// isOpen={isOpen}
|
|
800
|
+
// />
|
|
801
|
+
// )}
|
|
802
|
+
// <div className="col" style={{ flex: 1 }}>
|
|
803
|
+
// {titleContent}
|
|
804
|
+
// </div>
|
|
805
|
+
// {iconPosition === 'right' && (
|
|
806
|
+
// <AccordionIcon
|
|
807
|
+
// icon={icon}
|
|
808
|
+
// iconColor={iconColor}
|
|
809
|
+
// iconSize={iconSize}
|
|
810
|
+
// iconClassName={iconClass || iconClassName}
|
|
811
|
+
// isOpen={isOpen}
|
|
812
|
+
// />
|
|
813
|
+
// )}
|
|
814
|
+
// </div>
|
|
815
|
+
// <div style={{ lineHeight: 0 }}>
|
|
816
|
+
// <AccordionIcon
|
|
817
|
+
// isExpandIcon
|
|
818
|
+
// expandIcon={expandIcon}
|
|
819
|
+
// expandIconColor={expandIconColor}
|
|
820
|
+
// expandIconSize={expandIconSize}
|
|
821
|
+
// expandIconClassName={expandIconClassName}
|
|
822
|
+
// isOpen={isOpen}
|
|
823
|
+
// rotate={expandIconRotate}
|
|
824
|
+
// />
|
|
825
|
+
// </div>
|
|
826
|
+
// </div>
|
|
827
|
+
// <div
|
|
828
|
+
// className={`accordion-content ${contentClass || ''} ${isOpen ? 'open' : ''}`}
|
|
829
|
+
// style={{
|
|
830
|
+
// maxHeight: isOpen ? '10000px' : '0',
|
|
831
|
+
// overflow: 'visible',
|
|
832
|
+
// opacity: isOpen ? 1 : 0,
|
|
833
|
+
// visibility: isOpen ? 'visible' : 'hidden',
|
|
834
|
+
// transition: `max-height ${animationDuration}ms ${animationEasing}`,
|
|
835
|
+
// padding: isOpen ? getSpacingValue(globalProps.padding) || '0.5rem 0' : '0',
|
|
836
|
+
// backgroundColor: globalProps.contentBg ? getBgClass(globalProps.contentBg) : '',
|
|
837
|
+
// borderTop: isOpen && globalProps.border ? `1px solid ${getCssVariableValue(globalProps.borderColor) || 'var(--borderColor)'}` : 'none',
|
|
838
|
+
// }}
|
|
839
|
+
// >
|
|
840
|
+
// <div
|
|
841
|
+
// className={`
|
|
842
|
+
// accordion-inner
|
|
843
|
+
// ${getTextSizeClass(contentSize)}
|
|
844
|
+
// ${getTextColorClass(contentColor)}
|
|
845
|
+
// `.trim()}
|
|
846
|
+
// style={{
|
|
847
|
+
// opacity: isOpen ? 1 : 0,
|
|
848
|
+
// transition: `opacity ${animationDuration}ms ${animationEasing}`,
|
|
849
|
+
// fontWeight: contentWeight || 400,
|
|
850
|
+
// lineHeight: 1.6,
|
|
851
|
+
// }}
|
|
852
|
+
// >
|
|
853
|
+
// {item.content}
|
|
854
|
+
// </div>
|
|
855
|
+
// </div>
|
|
856
|
+
// </div>
|
|
857
|
+
// );
|
|
858
|
+
// };
|
|
859
|
+
// // Main Accordion Component
|
|
860
|
+
// const Accordion: React.FC<AccordionProps> = (localProps) => {
|
|
861
|
+
// // Merge props with configuration
|
|
862
|
+
// const { mergeWithLocal } = useComponentConfiguration('Accordion', localProps.variant);
|
|
863
|
+
// const { props: mergedProps } = mergeWithLocal(localProps);
|
|
864
|
+
// const final = mergedProps;
|
|
865
|
+
// const [openIndexes, setOpenIndexes] = useState<number[]>([]);
|
|
866
|
+
// const [itemsArray, setItemsArray] = useState<AccordionItemType[]>([]);
|
|
867
|
+
// // Parse items from JSON string if needed
|
|
868
|
+
// useEffect(() => {
|
|
869
|
+
// if (typeof final.items === 'string') {
|
|
870
|
+
// try {
|
|
871
|
+
// const parsed = JSON.parse(final.items);
|
|
872
|
+
// setItemsArray(Array.isArray(parsed) ? parsed : [parsed]);
|
|
873
|
+
// } catch (error) {
|
|
874
|
+
// console.error('Error parsing items JSON:', error);
|
|
875
|
+
// setItemsArray([]);
|
|
876
|
+
// }
|
|
877
|
+
// } else if (Array.isArray(final.items)) {
|
|
878
|
+
// setItemsArray(final.items);
|
|
879
|
+
// } else {
|
|
880
|
+
// setItemsArray([]);
|
|
881
|
+
// }
|
|
882
|
+
// }, [final.items]);
|
|
883
|
+
// // Initialize open indexes
|
|
884
|
+
// useEffect(() => {
|
|
885
|
+
// if (final.allowMultiple) {
|
|
886
|
+
// setOpenIndexes(final.defaultOpenIndexes || []);
|
|
887
|
+
// } else {
|
|
888
|
+
// setOpenIndexes(final.defaultOpenIndexes && final.defaultOpenIndexes.length > 0
|
|
889
|
+
// ? [final.defaultOpenIndexes[0]]
|
|
890
|
+
// : []);
|
|
891
|
+
// }
|
|
892
|
+
// }, [final.defaultOpenIndexes, final.allowMultiple]);
|
|
893
|
+
// const toggleIndex = (index: number) => {
|
|
894
|
+
// let newOpenIndexes: number[] = [];
|
|
895
|
+
// if (final.allowMultiple) {
|
|
896
|
+
// if (openIndexes.includes(index)) {
|
|
897
|
+
// newOpenIndexes = openIndexes.filter((i) => i !== index);
|
|
898
|
+
// } else {
|
|
899
|
+
// newOpenIndexes = [...openIndexes, index];
|
|
900
|
+
// }
|
|
901
|
+
// } else {
|
|
902
|
+
// newOpenIndexes = openIndexes.includes(index) ? [] : [index];
|
|
903
|
+
// }
|
|
904
|
+
// setOpenIndexes(newOpenIndexes);
|
|
905
|
+
// // Call callback if provided
|
|
906
|
+
// if (final.onItemToggle) {
|
|
907
|
+
// final.onItemToggle(index, !openIndexes.includes(index));
|
|
908
|
+
// }
|
|
909
|
+
// };
|
|
910
|
+
// const getContainerClasses = (): string => {
|
|
911
|
+
// const classes = ['accordion'];
|
|
912
|
+
// if (final.className) {
|
|
913
|
+
// classes.push(final.className);
|
|
914
|
+
// }
|
|
915
|
+
// if (final.funcss) {
|
|
916
|
+
// classes.push(final.funcss);
|
|
917
|
+
// }
|
|
918
|
+
// return classes.filter(Boolean).join(' ');
|
|
919
|
+
// };
|
|
920
|
+
// const getContainerStyles = (): React.CSSProperties => {
|
|
921
|
+
// const styles: React.CSSProperties = {};
|
|
922
|
+
// if (final.margin) {
|
|
923
|
+
// const marginValue = getSpacingValue(final.margin);
|
|
924
|
+
// if (marginValue) {
|
|
925
|
+
// styles.margin = marginValue;
|
|
926
|
+
// }
|
|
927
|
+
// }
|
|
928
|
+
// if (final.style) {
|
|
929
|
+
// Object.assign(styles, final.style);
|
|
930
|
+
// }
|
|
931
|
+
// return styles;
|
|
932
|
+
// };
|
|
933
|
+
// const getSpacingValue = (value?: string): string => {
|
|
934
|
+
// if (!value) return '';
|
|
935
|
+
// if (/^\d+$/.test(value)) {
|
|
936
|
+
// return `${parseInt(value) * 0.25}rem`;
|
|
937
|
+
// }
|
|
938
|
+
// return value;
|
|
939
|
+
// };
|
|
940
|
+
// if (itemsArray.length === 0) {
|
|
941
|
+
// return null;
|
|
942
|
+
// }
|
|
943
|
+
// return (
|
|
944
|
+
// <div
|
|
945
|
+
// className={getContainerClasses()}
|
|
946
|
+
// style={getContainerStyles()}
|
|
947
|
+
// >
|
|
948
|
+
// {itemsArray.map((item, index) => (
|
|
949
|
+
// <AccordionItem
|
|
950
|
+
// key={index}
|
|
951
|
+
// item={item}
|
|
952
|
+
// index={index}
|
|
953
|
+
// isOpen={openIndexes.includes(index)}
|
|
954
|
+
// onToggle={toggleIndex}
|
|
955
|
+
// globalProps={final}
|
|
956
|
+
// animationDuration={final.animationDuration}
|
|
957
|
+
// animationEasing={final.animationEasing}
|
|
958
|
+
// />
|
|
959
|
+
// ))}
|
|
960
|
+
// </div>
|
|
961
|
+
// );
|
|
962
|
+
// };
|
|
963
|
+
// export default Accordion;
|
|
964
|
+
// export type { AccordionItemType, AccordionProps };
|
|
965
|
+
// 'use client';
|
|
395
966
|
// import React, { useState } from 'react';
|
|
396
967
|
// import { PiCaretDown } from 'react-icons/pi';
|
|
397
968
|
// import RowFlex from '../specials/RowFlex';
|