funda-ui 1.0.600 → 1.0.607
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/Accordion/index.js
CHANGED
|
@@ -27,10 +27,12 @@ var _require = __webpack_require__(711),
|
|
|
27
27
|
*
|
|
28
28
|
* @param {HTMLElement} curElement - Element of animation.
|
|
29
29
|
* @param {?JSON} config - Configuration of animation
|
|
30
|
-
* @param {?string} easeType
|
|
30
|
+
* @param {?string} easeType - Types of easing animation.
|
|
31
|
+
* @param {?Function} callback - Callback after animation ends
|
|
31
32
|
*/
|
|
32
33
|
function animateStyles(curElement, config) {
|
|
33
34
|
var easeType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'linear';
|
|
35
|
+
var callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function () {};
|
|
34
36
|
if (_typeof(curElement) === ( true ? "undefined" : 0)) return;
|
|
35
37
|
|
|
36
38
|
// Set a default configuration
|
|
@@ -88,6 +90,7 @@ function animateStyles(curElement, config) {
|
|
|
88
90
|
} else {
|
|
89
91
|
// change height
|
|
90
92
|
curElement.style.height = _endHeight + 'px';
|
|
93
|
+
if (typeof callback === 'function') callback();
|
|
91
94
|
|
|
92
95
|
//
|
|
93
96
|
window.cancelAnimationFrame(requestId);
|
|
@@ -440,7 +443,8 @@ var external_root_React_commonjs2_react_commonjs_react_amd_react_default = /*#__
|
|
|
440
443
|
;// CONCATENATED MODULE: ./src/AccordionItem.tsx
|
|
441
444
|
|
|
442
445
|
var AccordionItem = function AccordionItem(props) {
|
|
443
|
-
var
|
|
446
|
+
var heightObserver = props.heightObserver,
|
|
447
|
+
index = props.index,
|
|
444
448
|
itemClassName = props.itemClassName,
|
|
445
449
|
itemContentWrapperClassName = props.itemContentWrapperClassName,
|
|
446
450
|
itemContentClassName = props.itemContentClassName,
|
|
@@ -455,6 +459,27 @@ var AccordionItem = function AccordionItem(props) {
|
|
|
455
459
|
triggerType = props.triggerType,
|
|
456
460
|
children = props.children;
|
|
457
461
|
var activedClassName = typeof defaultActive !== 'undefined' && defaultActive !== false ? ' active' : '';
|
|
462
|
+
var observer = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
|
|
463
|
+
var contentWrapperRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
|
|
464
|
+
var contentRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
|
|
465
|
+
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
466
|
+
if (parseFloat(heightObserver) !== index) return;
|
|
467
|
+
|
|
468
|
+
// When the content height changes dynamically, change the height of the wrapper
|
|
469
|
+
if (contentRef.current && contentWrapperRef.current) {
|
|
470
|
+
var _contentPadding = window.getComputedStyle(contentRef.current).getPropertyValue('padding-bottom');
|
|
471
|
+
observer.current = new ResizeObserver(function (entries) {
|
|
472
|
+
entries.forEach(function (entry) {
|
|
473
|
+
contentWrapperRef.current.style.height = entry.contentRect.bottom + parseFloat(_contentPadding) + 'px';
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
observer.current.observe(contentRef.current);
|
|
477
|
+
}
|
|
478
|
+
return function () {
|
|
479
|
+
var _observer$current;
|
|
480
|
+
if (contentRef.current) (_observer$current = observer.current) === null || _observer$current === void 0 ? void 0 : _observer$current.unobserve(contentRef.current);
|
|
481
|
+
};
|
|
482
|
+
}, [heightObserver]);
|
|
458
483
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
459
484
|
"data-index": index,
|
|
460
485
|
className: "custom-accordion-item ".concat(itemClassName || itemClassName === '' ? itemClassName : "accordion-item", " ").concat(activedClassName),
|
|
@@ -471,6 +496,7 @@ var AccordionItem = function AccordionItem(props) {
|
|
|
471
496
|
className: "custom-accordion-trigger ".concat(itemTriggerClassName || itemTriggerClassName === '' ? itemTriggerClassName : "accordion-button", " ").concat(activedClassName === '' ? 'collapsed' : 'active'),
|
|
472
497
|
type: "button"
|
|
473
498
|
}, title), itemTriggerIcon), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
499
|
+
ref: contentWrapperRef,
|
|
474
500
|
className: "custom-accordion-content__wrapper ".concat(itemContentWrapperClassName || itemContentWrapperClassName === '' ? itemContentWrapperClassName : "accordion-collapse"),
|
|
475
501
|
role: "tabpanel",
|
|
476
502
|
style: {
|
|
@@ -478,7 +504,8 @@ var AccordionItem = function AccordionItem(props) {
|
|
|
478
504
|
overflow: 'hidden'
|
|
479
505
|
}
|
|
480
506
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
481
|
-
className: "custom-accordion-content ".concat(itemContentClassName || itemContentClassName === '' ? itemContentClassName : "accordion-body")
|
|
507
|
+
className: "custom-accordion-content ".concat(itemContentClassName || itemContentClassName === '' ? itemContentClassName : "accordion-body"),
|
|
508
|
+
ref: contentRef
|
|
482
509
|
}, children))));
|
|
483
510
|
};
|
|
484
511
|
/* harmony default export */ const src_AccordionItem = (AccordionItem);
|
|
@@ -515,6 +542,7 @@ var Accordion = function Accordion(props) {
|
|
|
515
542
|
var wrapperClassName = props.wrapperClassName,
|
|
516
543
|
triggerType = props.triggerType,
|
|
517
544
|
displayTheFirstItem = props.displayTheFirstItem,
|
|
545
|
+
displayAllItems = props.displayAllItems,
|
|
518
546
|
duration = props.duration,
|
|
519
547
|
easing = props.easing,
|
|
520
548
|
alternateCollapse = props.alternateCollapse,
|
|
@@ -527,11 +555,19 @@ var Accordion = function Accordion(props) {
|
|
|
527
555
|
_useState2 = _slicedToArray(_useState, 2),
|
|
528
556
|
animOK = _useState2[0],
|
|
529
557
|
setAnimOK = _useState2[1];
|
|
558
|
+
var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(-1),
|
|
559
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
560
|
+
heightObserver = _useState4[0],
|
|
561
|
+
setHeightObserver = _useState4[1];
|
|
530
562
|
function handleClickItem(e) {
|
|
563
|
+
if (e.target.closest('.custom-accordion-header') === null) return;
|
|
564
|
+
if (animOK) return;
|
|
565
|
+
|
|
566
|
+
// DO NOT place it before the above code, otherwise it will cause the checkbox and radio controls to fail.
|
|
531
567
|
e.preventDefault();
|
|
568
|
+
|
|
532
569
|
//Prevents further propagation of the current event in the capturing and bubbling phases(if use `e.target`).
|
|
533
570
|
e.stopPropagation();
|
|
534
|
-
if (animOK) return;
|
|
535
571
|
|
|
536
572
|
//
|
|
537
573
|
var reactDomEl = e.currentTarget;
|
|
@@ -577,7 +613,10 @@ var Accordion = function Accordion(props) {
|
|
|
577
613
|
startHeight: 0,
|
|
578
614
|
endHeight: $curContent.scrollHeight,
|
|
579
615
|
speed: animSpeed
|
|
580
|
-
}, easeType)
|
|
616
|
+
}, easeType, function () {
|
|
617
|
+
// content height observer
|
|
618
|
+
setHeightObserver(curIndex);
|
|
619
|
+
});
|
|
581
620
|
} else {
|
|
582
621
|
if (e.type == 'click') {
|
|
583
622
|
var _reactDomEl$querySele3, _reactDomEl$querySele4;
|
|
@@ -607,7 +646,8 @@ var Accordion = function Accordion(props) {
|
|
|
607
646
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(src_AccordionItem, _extends({
|
|
608
647
|
key: "item" + i,
|
|
609
648
|
index: i,
|
|
610
|
-
|
|
649
|
+
heightObserver: heightObserver,
|
|
650
|
+
defaultActive: typeof displayAllItems === 'undefined' ? _defaultActive : displayAllItems,
|
|
611
651
|
triggerType: triggerType || 'click',
|
|
612
652
|
onToggleEv: handleClickItem
|
|
613
653
|
}, childProps));
|
|
@@ -27,10 +27,12 @@ var _require = __webpack_require__(711),
|
|
|
27
27
|
*
|
|
28
28
|
* @param {HTMLElement} curElement - Element of animation.
|
|
29
29
|
* @param {?JSON} config - Configuration of animation
|
|
30
|
-
* @param {?string} easeType
|
|
30
|
+
* @param {?string} easeType - Types of easing animation.
|
|
31
|
+
* @param {?Function} callback - Callback after animation ends
|
|
31
32
|
*/
|
|
32
33
|
function animateStyles(curElement, config) {
|
|
33
34
|
var easeType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'linear';
|
|
35
|
+
var callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : function () {};
|
|
34
36
|
if (_typeof(curElement) === ( true ? "undefined" : 0)) return;
|
|
35
37
|
|
|
36
38
|
// Set a default configuration
|
|
@@ -88,6 +90,7 @@ function animateStyles(curElement, config) {
|
|
|
88
90
|
} else {
|
|
89
91
|
// change height
|
|
90
92
|
curElement.style.height = _endHeight + 'px';
|
|
93
|
+
if (typeof callback === 'function') callback();
|
|
91
94
|
|
|
92
95
|
//
|
|
93
96
|
window.cancelAnimationFrame(requestId);
|
|
@@ -440,7 +443,8 @@ var external_root_React_commonjs2_react_commonjs_react_amd_react_default = /*#__
|
|
|
440
443
|
;// CONCATENATED MODULE: ./src/AccordionItem.tsx
|
|
441
444
|
|
|
442
445
|
var AccordionItem = function AccordionItem(props) {
|
|
443
|
-
var
|
|
446
|
+
var heightObserver = props.heightObserver,
|
|
447
|
+
index = props.index,
|
|
444
448
|
itemClassName = props.itemClassName,
|
|
445
449
|
itemContentWrapperClassName = props.itemContentWrapperClassName,
|
|
446
450
|
itemContentClassName = props.itemContentClassName,
|
|
@@ -455,6 +459,27 @@ var AccordionItem = function AccordionItem(props) {
|
|
|
455
459
|
triggerType = props.triggerType,
|
|
456
460
|
children = props.children;
|
|
457
461
|
var activedClassName = typeof defaultActive !== 'undefined' && defaultActive !== false ? ' active' : '';
|
|
462
|
+
var observer = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
|
|
463
|
+
var contentWrapperRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
|
|
464
|
+
var contentRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
|
|
465
|
+
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
466
|
+
if (parseFloat(heightObserver) !== index) return;
|
|
467
|
+
|
|
468
|
+
// When the content height changes dynamically, change the height of the wrapper
|
|
469
|
+
if (contentRef.current && contentWrapperRef.current) {
|
|
470
|
+
var _contentPadding = window.getComputedStyle(contentRef.current).getPropertyValue('padding-bottom');
|
|
471
|
+
observer.current = new ResizeObserver(function (entries) {
|
|
472
|
+
entries.forEach(function (entry) {
|
|
473
|
+
contentWrapperRef.current.style.height = entry.contentRect.bottom + parseFloat(_contentPadding) + 'px';
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
observer.current.observe(contentRef.current);
|
|
477
|
+
}
|
|
478
|
+
return function () {
|
|
479
|
+
var _observer$current;
|
|
480
|
+
if (contentRef.current) (_observer$current = observer.current) === null || _observer$current === void 0 ? void 0 : _observer$current.unobserve(contentRef.current);
|
|
481
|
+
};
|
|
482
|
+
}, [heightObserver]);
|
|
458
483
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
459
484
|
"data-index": index,
|
|
460
485
|
className: "custom-accordion-item ".concat(itemClassName || itemClassName === '' ? itemClassName : "accordion-item", " ").concat(activedClassName),
|
|
@@ -471,6 +496,7 @@ var AccordionItem = function AccordionItem(props) {
|
|
|
471
496
|
className: "custom-accordion-trigger ".concat(itemTriggerClassName || itemTriggerClassName === '' ? itemTriggerClassName : "accordion-button", " ").concat(activedClassName === '' ? 'collapsed' : 'active'),
|
|
472
497
|
type: "button"
|
|
473
498
|
}, title), itemTriggerIcon), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
499
|
+
ref: contentWrapperRef,
|
|
474
500
|
className: "custom-accordion-content__wrapper ".concat(itemContentWrapperClassName || itemContentWrapperClassName === '' ? itemContentWrapperClassName : "accordion-collapse"),
|
|
475
501
|
role: "tabpanel",
|
|
476
502
|
style: {
|
|
@@ -478,7 +504,8 @@ var AccordionItem = function AccordionItem(props) {
|
|
|
478
504
|
overflow: 'hidden'
|
|
479
505
|
}
|
|
480
506
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
481
|
-
className: "custom-accordion-content ".concat(itemContentClassName || itemContentClassName === '' ? itemContentClassName : "accordion-body")
|
|
507
|
+
className: "custom-accordion-content ".concat(itemContentClassName || itemContentClassName === '' ? itemContentClassName : "accordion-body"),
|
|
508
|
+
ref: contentRef
|
|
482
509
|
}, children))));
|
|
483
510
|
};
|
|
484
511
|
/* harmony default export */ const src_AccordionItem = (AccordionItem);
|
|
@@ -515,6 +542,7 @@ var Accordion = function Accordion(props) {
|
|
|
515
542
|
var wrapperClassName = props.wrapperClassName,
|
|
516
543
|
triggerType = props.triggerType,
|
|
517
544
|
displayTheFirstItem = props.displayTheFirstItem,
|
|
545
|
+
displayAllItems = props.displayAllItems,
|
|
518
546
|
duration = props.duration,
|
|
519
547
|
easing = props.easing,
|
|
520
548
|
alternateCollapse = props.alternateCollapse,
|
|
@@ -527,11 +555,19 @@ var Accordion = function Accordion(props) {
|
|
|
527
555
|
_useState2 = _slicedToArray(_useState, 2),
|
|
528
556
|
animOK = _useState2[0],
|
|
529
557
|
setAnimOK = _useState2[1];
|
|
558
|
+
var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(-1),
|
|
559
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
560
|
+
heightObserver = _useState4[0],
|
|
561
|
+
setHeightObserver = _useState4[1];
|
|
530
562
|
function handleClickItem(e) {
|
|
563
|
+
if (e.target.closest('.custom-accordion-header') === null) return;
|
|
564
|
+
if (animOK) return;
|
|
565
|
+
|
|
566
|
+
// DO NOT place it before the above code, otherwise it will cause the checkbox and radio controls to fail.
|
|
531
567
|
e.preventDefault();
|
|
568
|
+
|
|
532
569
|
//Prevents further propagation of the current event in the capturing and bubbling phases(if use `e.target`).
|
|
533
570
|
e.stopPropagation();
|
|
534
|
-
if (animOK) return;
|
|
535
571
|
|
|
536
572
|
//
|
|
537
573
|
var reactDomEl = e.currentTarget;
|
|
@@ -577,7 +613,10 @@ var Accordion = function Accordion(props) {
|
|
|
577
613
|
startHeight: 0,
|
|
578
614
|
endHeight: $curContent.scrollHeight,
|
|
579
615
|
speed: animSpeed
|
|
580
|
-
}, easeType)
|
|
616
|
+
}, easeType, function () {
|
|
617
|
+
// content height observer
|
|
618
|
+
setHeightObserver(curIndex);
|
|
619
|
+
});
|
|
581
620
|
} else {
|
|
582
621
|
if (e.type == 'click') {
|
|
583
622
|
var _reactDomEl$querySele3, _reactDomEl$querySele4;
|
|
@@ -607,7 +646,8 @@ var Accordion = function Accordion(props) {
|
|
|
607
646
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(src_AccordionItem, _extends({
|
|
608
647
|
key: "item" + i,
|
|
609
648
|
index: i,
|
|
610
|
-
|
|
649
|
+
heightObserver: heightObserver,
|
|
650
|
+
defaultActive: typeof displayAllItems === 'undefined' ? _defaultActive : displayAllItems,
|
|
611
651
|
triggerType: triggerType || 'click',
|
|
612
652
|
onToggleEv: handleClickItem
|
|
613
653
|
}, childProps));
|
|
@@ -29,6 +29,8 @@ type AccordionProps = {
|
|
|
29
29
|
triggerType?: string;
|
|
30
30
|
/** Display the only first item of a list */
|
|
31
31
|
displayTheFirstItem?: boolean;
|
|
32
|
+
/** Display all items */
|
|
33
|
+
displayAllItems?: boolean;
|
|
32
34
|
/** The number of milliseconds(ms) each iteration of the animation takes to complete */
|
|
33
35
|
duration?: number;
|
|
34
36
|
/** Types of easing animation */
|
|
@@ -48,6 +50,7 @@ const Accordion = (props: AccordionProps) => {
|
|
|
48
50
|
wrapperClassName,
|
|
49
51
|
triggerType,
|
|
50
52
|
displayTheFirstItem,
|
|
53
|
+
displayAllItems,
|
|
51
54
|
duration,
|
|
52
55
|
easing,
|
|
53
56
|
alternateCollapse,
|
|
@@ -60,16 +63,19 @@ const Accordion = (props: AccordionProps) => {
|
|
|
60
63
|
const ALTER = typeof alternateCollapse === 'undefined' ? true : alternateCollapse;
|
|
61
64
|
const rootRef = useRef<any>(null);
|
|
62
65
|
const [animOK, setAnimOK] = useState<boolean>(false);
|
|
66
|
+
const [heightObserver, setHeightObserver] = useState<number>(-1);
|
|
63
67
|
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
|
|
66
69
|
function handleClickItem(e: React.MouseEvent) {
|
|
67
|
-
|
|
70
|
+
if ((e.target as any).closest('.custom-accordion-header') === null) return;
|
|
71
|
+
if ( animOK ) return;
|
|
72
|
+
|
|
73
|
+
// DO NOT place it before the above code, otherwise it will cause the checkbox and radio controls to fail.
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
|
|
68
76
|
//Prevents further propagation of the current event in the capturing and bubbling phases(if use `e.target`).
|
|
69
77
|
e.stopPropagation();
|
|
70
78
|
|
|
71
|
-
if ( animOK ) return;
|
|
72
|
-
|
|
73
79
|
|
|
74
80
|
//
|
|
75
81
|
const reactDomEl: any = e.currentTarget;
|
|
@@ -121,7 +127,10 @@ const Accordion = (props: AccordionProps) => {
|
|
|
121
127
|
startHeight : 0,
|
|
122
128
|
endHeight : $curContent.scrollHeight,
|
|
123
129
|
speed : animSpeed
|
|
124
|
-
} as never, easeType)
|
|
130
|
+
} as never, easeType, () => {
|
|
131
|
+
// content height observer
|
|
132
|
+
setHeightObserver(curIndex);
|
|
133
|
+
});
|
|
125
134
|
|
|
126
135
|
} else {
|
|
127
136
|
|
|
@@ -158,7 +167,8 @@ const Accordion = (props: AccordionProps) => {
|
|
|
158
167
|
return <Item
|
|
159
168
|
key={"item" + i}
|
|
160
169
|
index={i}
|
|
161
|
-
|
|
170
|
+
heightObserver={heightObserver}
|
|
171
|
+
defaultActive={typeof displayAllItems === 'undefined' ? _defaultActive : displayAllItems}
|
|
162
172
|
triggerType={triggerType || 'click'}
|
|
163
173
|
onToggleEv={handleClickItem}
|
|
164
174
|
{...childProps}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
type AccordionItemProps = {
|
|
5
|
+
heightObserver?: number;
|
|
5
6
|
index?: number;
|
|
6
7
|
/** Class of items */
|
|
7
8
|
itemClassName?: string;
|
|
@@ -29,6 +30,7 @@ type AccordionItemProps = {
|
|
|
29
30
|
const AccordionItem = (props: AccordionItemProps) => {
|
|
30
31
|
|
|
31
32
|
const {
|
|
33
|
+
heightObserver,
|
|
32
34
|
index,
|
|
33
35
|
itemClassName,
|
|
34
36
|
itemContentWrapperClassName,
|
|
@@ -45,8 +47,37 @@ const AccordionItem = (props: AccordionItemProps) => {
|
|
|
45
47
|
children
|
|
46
48
|
} = props;
|
|
47
49
|
|
|
50
|
+
|
|
51
|
+
|
|
48
52
|
const activedClassName = typeof(defaultActive) !== 'undefined' && defaultActive !== false ? ' active' : '';
|
|
53
|
+
const observer = useRef<ResizeObserver | null>(null);
|
|
54
|
+
const contentWrapperRef = useRef<HTMLDivElement | null>(null);
|
|
55
|
+
const contentRef = useRef<HTMLDivElement | null>(null);
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
|
|
60
|
+
if (parseFloat(heightObserver as never) !== index) return;
|
|
61
|
+
|
|
62
|
+
// When the content height changes dynamically, change the height of the wrapper
|
|
63
|
+
if (contentRef.current && contentWrapperRef.current) {
|
|
64
|
+
const _contentPadding = window.getComputedStyle(contentRef.current as HTMLDivElement).getPropertyValue('padding-bottom');
|
|
65
|
+
|
|
66
|
+
observer.current = new ResizeObserver(entries => {
|
|
67
|
+
entries.forEach(entry => {
|
|
68
|
+
(contentWrapperRef.current as HTMLDivElement).style.height = entry.contentRect.bottom + parseFloat(_contentPadding) + 'px';
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
observer.current.observe(contentRef.current);
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return () => {
|
|
76
|
+
if (contentRef.current) observer.current?.unobserve(contentRef.current);
|
|
77
|
+
};
|
|
78
|
+
|
|
49
79
|
|
|
80
|
+
}, [heightObserver]);
|
|
50
81
|
|
|
51
82
|
return (
|
|
52
83
|
<>
|
|
@@ -68,12 +99,12 @@ const AccordionItem = (props: AccordionItemProps) => {
|
|
|
68
99
|
|
|
69
100
|
{itemTriggerIcon}
|
|
70
101
|
</div>
|
|
71
|
-
<div className={`custom-accordion-content__wrapper ${itemContentWrapperClassName || itemContentWrapperClassName === '' ? itemContentWrapperClassName : "accordion-collapse"}`}
|
|
102
|
+
<div ref={contentWrapperRef} className={`custom-accordion-content__wrapper ${itemContentWrapperClassName || itemContentWrapperClassName === '' ? itemContentWrapperClassName : "accordion-collapse"}`}
|
|
72
103
|
role="tabpanel" style={{
|
|
73
104
|
height: defaultActive ? 'auto' : '0px',
|
|
74
105
|
overflow: 'hidden'
|
|
75
106
|
}}>
|
|
76
|
-
<div className={`custom-accordion-content ${itemContentClassName || itemContentClassName === '' ? itemContentClassName : "accordion-body"}`}>
|
|
107
|
+
<div className={`custom-accordion-content ${itemContentClassName || itemContentClassName === '' ? itemContentClassName : "accordion-body"}`} ref={contentRef} >
|
|
77
108
|
{children}
|
|
78
109
|
</div>
|
|
79
110
|
</div>
|
|
@@ -13,9 +13,10 @@ const {
|
|
|
13
13
|
*
|
|
14
14
|
* @param {HTMLElement} curElement - Element of animation.
|
|
15
15
|
* @param {?JSON} config - Configuration of animation
|
|
16
|
-
* @param {?string} easeType
|
|
16
|
+
* @param {?string} easeType - Types of easing animation.
|
|
17
|
+
* @param {?Function} callback - Callback after animation ends
|
|
17
18
|
*/
|
|
18
|
-
function animateStyles(curElement, config, easeType = 'linear') {
|
|
19
|
+
function animateStyles(curElement, config, easeType = 'linear', callback = () => {}) {
|
|
19
20
|
if (typeof curElement === typeof undefined) return;
|
|
20
21
|
|
|
21
22
|
// Set a default configuration
|
|
@@ -80,6 +81,8 @@ function animateStyles(curElement, config, easeType = 'linear') {
|
|
|
80
81
|
// change height
|
|
81
82
|
curElement.style.height = _endHeight + 'px';
|
|
82
83
|
|
|
84
|
+
if (typeof callback === 'function') callback();
|
|
85
|
+
|
|
83
86
|
//
|
|
84
87
|
window.cancelAnimationFrame(requestId);
|
|
85
88
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"author": "UIUX Lab",
|
|
3
3
|
"email": "uiuxlab@gmail.com",
|
|
4
4
|
"name": "funda-ui",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.607",
|
|
6
6
|
"description": "React components using pure Bootstrap 5+ which does not contain any external style and script libraries.",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|