funda-ui 4.7.197 → 4.7.212

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.
@@ -895,8 +895,14 @@ var external_root_React_commonjs2_react_commonjs_react_amd_react_default = /*#__
895
895
  // EXTERNAL MODULE: ../Utils/dist/cjs/cls.js
896
896
  var cls = __webpack_require__(188);
897
897
  ;// CONCATENATED MODULE: ./src/AccordionItem.tsx
898
- var _excluded = ["heightObserver", "index", "itemClassName", "itemContentWrapperClassName", "itemContentClassName", "itemTriggerClassName", "itemHeaderClassName", "itemTriggerIcon", "itemStyle", "defaultActive", "title", "onToggleEv", "onTransitionEnd", "triggerType", "children"];
898
+ var _excluded = ["heightObserver", "index", "animSpeed", "easeType", "arrowOnly", "itemClassName", "itemContentWrapperClassName", "itemContentClassName", "itemTriggerClassName", "itemHeaderClassName", "itemTriggerIcon", "itemStyle", "defaultActive", "title", "onToggleEv", "onTransitionEnd", "onItemCollapse", "isExpanded", "children"];
899
899
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
900
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
901
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
902
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
903
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
904
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
905
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
900
906
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
901
907
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
902
908
 
@@ -904,6 +910,9 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
904
910
  var AccordionItem = function AccordionItem(props) {
905
911
  var heightObserver = props.heightObserver,
906
912
  index = props.index,
913
+ animSpeed = props.animSpeed,
914
+ easeType = props.easeType,
915
+ arrowOnly = props.arrowOnly,
907
916
  itemClassName = props.itemClassName,
908
917
  itemContentWrapperClassName = props.itemContentWrapperClassName,
909
918
  itemContentClassName = props.itemContentClassName,
@@ -915,13 +924,58 @@ var AccordionItem = function AccordionItem(props) {
915
924
  title = props.title,
916
925
  onToggleEv = props.onToggleEv,
917
926
  onTransitionEnd = props.onTransitionEnd,
918
- triggerType = props.triggerType,
927
+ onItemCollapse = props.onItemCollapse,
928
+ controlledExpanded = props.isExpanded,
919
929
  children = props.children,
920
930
  attributes = _objectWithoutProperties(props, _excluded);
921
- var activedClassName = typeof defaultActive !== 'undefined' && defaultActive !== false ? ' active' : '';
931
+ var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false),
932
+ _useState2 = _slicedToArray(_useState, 2),
933
+ internalExpanded = _useState2[0],
934
+ setInternalExpanded = _useState2[1];
935
+ var isFirstRender = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(true);
936
+ var initialHeightSet = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);
937
+
938
+ // Use controlled or uncontrolled expanded state
939
+ var isExpanded = controlledExpanded !== undefined ? controlledExpanded : internalExpanded;
922
940
  var observer = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
923
941
  var contentWrapperRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
924
942
  var contentRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
943
+ var triggerRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
944
+ var iconRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
945
+ var handleToggle = function handleToggle(e) {
946
+ e.preventDefault();
947
+ e.stopPropagation();
948
+ if (controlledExpanded === undefined) {
949
+ setInternalExpanded(function (prev) {
950
+ return !prev;
951
+ });
952
+ }
953
+ onToggleEv === null || onToggleEv === void 0 ? void 0 : onToggleEv(e);
954
+ };
955
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
956
+ if (triggerRef.current && typeof onItemCollapse === 'function') {
957
+ if (isFirstRender.current) {
958
+ isFirstRender.current = false;
959
+ return;
960
+ }
961
+ onItemCollapse(triggerRef.current, iconRef.current, isExpanded);
962
+ }
963
+ }, [isExpanded, onItemCollapse]);
964
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
965
+ if (contentWrapperRef.current && !initialHeightSet.current) {
966
+ initialHeightSet.current = true;
967
+ var shouldBeExpanded = typeof defaultActive !== 'undefined' && defaultActive !== false;
968
+ if (controlledExpanded === undefined) {
969
+ setInternalExpanded(shouldBeExpanded);
970
+ }
971
+
972
+ // Set initial height when defaultActive is true
973
+ if (shouldBeExpanded && contentRef.current) {
974
+ var contentHeight = contentRef.current.offsetHeight;
975
+ contentWrapperRef.current.style.height = "".concat(contentHeight, "px");
976
+ }
977
+ }
978
+ }, [defaultActive, controlledExpanded]);
925
979
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
926
980
  if (parseFloat(heightObserver) !== index) return;
927
981
 
@@ -945,26 +999,39 @@ var AccordionItem = function AccordionItem(props) {
945
999
  }, [heightObserver]);
946
1000
  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", _extends({}, attributes, {
947
1001
  "data-index": index,
948
- className: (0,cls.combinedCls)('custom-accordion-item', (0,cls.clsWrite)(itemClassName, 'accordion-item'), activedClassName),
949
- onClick: triggerType === 'click' ? onToggleEv : function () {},
950
- onMouseOver: triggerType === 'click' ? function () {} : onToggleEv,
951
- onTransitionEnd: typeof onTransitionEnd === 'function' ? onTransitionEnd : function () {},
952
- "aria-expanded": defaultActive ? 'true' : 'false',
1002
+ className: (0,cls.combinedCls)('custom-accordion-item', (0,cls.clsWrite)(itemClassName, 'accordion-item'), isExpanded ? ' active' : ''),
1003
+ onClick: arrowOnly ? undefined : handleToggle,
1004
+ onTransitionEnd: typeof onTransitionEnd === 'function' ? onTransitionEnd : undefined,
1005
+ "aria-expanded": isExpanded ? 'true' : 'false',
953
1006
  style: typeof itemStyle !== 'undefined' ? itemStyle : {}
954
1007
  }), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
955
1008
  className: (0,cls.combinedCls)('custom-accordion-header', (0,cls.clsWrite)(itemHeaderClassName, 'accordion-header position-relative')),
956
1009
  role: "presentation"
957
- }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("button", {
1010
+ }, arrowOnly ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
1011
+ ref: triggerRef,
1012
+ tabIndex: -1,
1013
+ className: (0,cls.combinedCls)('custom-accordion-trigger', (0,cls.clsWrite)(itemTriggerClassName, 'accordion-button'), isExpanded ? 'active' : 'collapsed')
1014
+ }, title) : /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("button", {
1015
+ ref: triggerRef,
958
1016
  tabIndex: -1,
959
- className: (0,cls.combinedCls)('custom-accordion-trigger', (0,cls.clsWrite)(itemTriggerClassName, 'accordion-button'), activedClassName === '' ? 'collapsed' : 'active'),
1017
+ className: (0,cls.combinedCls)('custom-accordion-trigger', (0,cls.clsWrite)(itemTriggerClassName, 'accordion-button'), isExpanded ? 'active' : 'collapsed'),
960
1018
  type: "button"
961
- }, title), itemTriggerIcon), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
1019
+ }, title), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
1020
+ ref: iconRef,
1021
+ onClick: !arrowOnly ? undefined : handleToggle,
1022
+ className: "custom-accordion-trigger__icon",
1023
+ style: !arrowOnly ? {
1024
+ pointerEvents: 'none'
1025
+ } : {
1026
+ cursor: 'pointer'
1027
+ }
1028
+ }, itemTriggerIcon)), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
962
1029
  ref: contentWrapperRef,
963
1030
  className: (0,cls.combinedCls)('custom-accordion-content__wrapper w-100', (0,cls.clsWrite)(itemContentWrapperClassName, 'accordion-collapse')),
964
1031
  role: "tabpanel",
965
1032
  style: {
966
- height: defaultActive ? 'auto' : '0px',
967
- overflow: 'hidden' // overflow affects the width, so add `w-100` to `custom-accordion-content__wrapper`
1033
+ height: '0',
1034
+ overflow: 'hidden' // "overflow" affects the width, so add `w-100` to `custom-accordion-content__wrapper`
968
1035
  }
969
1036
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
970
1037
  className: (0,cls.combinedCls)('custom-accordion-content', (0,cls.clsWrite)(itemContentClassName, 'accordion-body')),
@@ -983,12 +1050,16 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
983
1050
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
984
1051
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
985
1052
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
986
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
987
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
988
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
989
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
990
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
991
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1053
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || Accordion_unsupportedIterableToArray(arr) || _nonIterableSpread(); }
1054
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1055
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
1056
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return Accordion_arrayLikeToArray(arr); }
1057
+ function Accordion_slicedToArray(arr, i) { return Accordion_arrayWithHoles(arr) || Accordion_iterableToArrayLimit(arr, i) || Accordion_unsupportedIterableToArray(arr, i) || Accordion_nonIterableRest(); }
1058
+ function Accordion_nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1059
+ function Accordion_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return Accordion_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Accordion_arrayLikeToArray(o, minLen); }
1060
+ function Accordion_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
1061
+ function Accordion_iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
1062
+ function Accordion_arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
992
1063
 
993
1064
 
994
1065
 
@@ -1004,116 +1075,182 @@ var EasingList = /*#__PURE__*/function (EasingList) {
1004
1075
  }({});
1005
1076
  var Accordion = function Accordion(props) {
1006
1077
  var wrapperClassName = props.wrapperClassName,
1007
- triggerType = props.triggerType,
1008
- displayTheFirstItem = props.displayTheFirstItem,
1009
- displayAllItems = props.displayAllItems,
1078
+ defaultActiveIndex = props.defaultActiveIndex,
1079
+ _props$defaultActiveA = props.defaultActiveAll,
1080
+ defaultActiveAll = _props$defaultActiveA === void 0 ? false : _props$defaultActiveA,
1010
1081
  duration = props.duration,
1011
1082
  easing = props.easing,
1012
- alternateCollapse = props.alternateCollapse,
1083
+ _props$alternateColla = props.alternateCollapse,
1084
+ alternateCollapse = _props$alternateColla === void 0 ? true : _props$alternateColla,
1085
+ _props$arrowOnly = props.arrowOnly,
1086
+ arrowOnly = _props$arrowOnly === void 0 ? false : _props$arrowOnly,
1013
1087
  onChange = props.onChange,
1014
1088
  children = props.children;
1089
+ var animSpeed = duration || 200;
1015
1090
  var easeType = typeof alternateCollapse === 'undefined' ? EasingList['linear'] : EasingList[easing];
1016
- var ALTER = typeof alternateCollapse === 'undefined' ? true : alternateCollapse;
1017
1091
  var rootRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
1018
1092
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false),
1019
- _useState2 = _slicedToArray(_useState, 2),
1093
+ _useState2 = Accordion_slicedToArray(_useState, 2),
1020
1094
  animOK = _useState2[0],
1021
1095
  setAnimOK = _useState2[1];
1022
1096
  var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(-1),
1023
- _useState4 = _slicedToArray(_useState3, 2),
1097
+ _useState4 = Accordion_slicedToArray(_useState3, 2),
1024
1098
  heightObserver = _useState4[0],
1025
1099
  setHeightObserver = _useState4[1];
1100
+ var _useState5 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(new Set()),
1101
+ _useState6 = Accordion_slicedToArray(_useState5, 2),
1102
+ expandedItems = _useState6[0],
1103
+ setExpandedItems = _useState6[1]; // Keep track of all expanded items
1104
+ var animationInProgress = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);
1026
1105
  function handleClickItem(e) {
1106
+ if (animationInProgress.current) return;
1027
1107
  if (e.target.closest('.custom-accordion-header') === null) return;
1028
1108
  if (animOK) return;
1029
-
1030
- // DO NOT place it before the above code, otherwise it will cause the checkbox and radio controls to fail.
1031
- e.preventDefault();
1032
-
1033
- //Prevents further propagation of the current event in the capturing and bubbling phases(if use `e.target`).
1034
- e.stopPropagation();
1035
-
1036
- //
1037
- var reactDomEl = e.currentTarget;
1038
- var curIndex = reactDomEl.dataset.index;
1109
+ animationInProgress.current = true;
1110
+ var reactDomEl = arrowOnly ? e.currentTarget.closest('.custom-accordion-item') : e.currentTarget;
1111
+ var curIndex = parseInt(reactDomEl.dataset.index);
1039
1112
  var reactDomWrapperEl = rootRef.current;
1040
- var animSpeed = duration || 200;
1041
1113
  var $li = reactDomWrapperEl.querySelectorAll('.custom-accordion-item');
1042
1114
  var $allContent = reactDomWrapperEl.querySelectorAll('.custom-accordion-content__wrapper');
1043
1115
  var $curContent = reactDomEl.querySelector('.custom-accordion-content__wrapper');
1116
+ var $trigger = reactDomEl.querySelector('.custom-accordion-trigger');
1044
1117
  if (reactDomEl.getAttribute('aria-expanded') === 'false' || reactDomEl.getAttribute('aria-expanded') === null) {
1045
- var _reactDomEl$querySele, _reactDomEl$querySele2;
1118
+ var _curIndex;
1046
1119
  setAnimOK(true);
1047
1120
  setTimeout(function () {
1048
1121
  setAnimOK(false);
1049
1122
  }, animSpeed);
1050
- if (ALTER) {
1051
- //Hide other all sibling <dt> of the selected element
1123
+ if (alternateCollapse) {
1124
+ // Hide other all sibling content
1052
1125
  Array.prototype.forEach.call($allContent, function (node) {
1053
1126
  if (node.clientHeight > 0) {
1054
1127
  anim_default()(node, {
1055
1128
  startHeight: node.scrollHeight,
1056
1129
  endHeight: 0,
1057
1130
  speed: animSpeed
1058
- }, easeType);
1131
+ }, easeType, function () {
1132
+ animationInProgress.current = false;
1133
+ });
1059
1134
  }
1060
1135
  });
1061
1136
 
1062
- //to open
1137
+ // Update all items to collapsed state
1063
1138
  Array.prototype.forEach.call($li, function (node) {
1064
- var _node$querySelector, _node$querySelector2;
1065
- node.classList.remove('active');
1066
- (_node$querySelector = node.querySelector('.custom-accordion-trigger')) === null || _node$querySelector === void 0 ? void 0 : _node$querySelector.classList.remove('active');
1067
- (_node$querySelector2 = node.querySelector('.custom-accordion-trigger')) === null || _node$querySelector2 === void 0 ? void 0 : _node$querySelector2.classList.add('collapsed');
1068
- node.setAttribute('aria-expanded', false);
1139
+ node.setAttribute('aria-expanded', 'false');
1140
+ });
1141
+
1142
+ // Update expanded items state
1143
+ setExpandedItems(new Set([curIndex]));
1144
+ } else {
1145
+ // Add current item to expanded items
1146
+ setExpandedItems(function (prev) {
1147
+ return new Set([].concat(_toConsumableArray(prev), [curIndex]));
1069
1148
  });
1070
1149
  }
1071
- reactDomEl.classList.add('active');
1072
- (_reactDomEl$querySele = reactDomEl.querySelector('.custom-accordion-trigger')) === null || _reactDomEl$querySele === void 0 ? void 0 : _reactDomEl$querySele.classList.add('active');
1073
- (_reactDomEl$querySele2 = reactDomEl.querySelector('.custom-accordion-trigger')) === null || _reactDomEl$querySele2 === void 0 ? void 0 : _reactDomEl$querySele2.classList.remove('collapsed');
1074
- reactDomEl.setAttribute('aria-expanded', true);
1075
- // When the height of the element is 0, the value of `offsetHeight` and `clientHeight` will be 0
1150
+ reactDomEl.setAttribute('aria-expanded', 'true');
1151
+
1152
+ // Call onTriggerChange if it exists in the child props
1153
+ var childProps = (_curIndex = children[curIndex]) === null || _curIndex === void 0 ? void 0 : _curIndex.props;
1154
+ if (typeof (childProps === null || childProps === void 0 ? void 0 : childProps.onTriggerChange) === 'function' && $trigger) {
1155
+ childProps.onTriggerChange($trigger, true);
1156
+ }
1076
1157
  anim_default()($curContent, {
1077
1158
  startHeight: 0,
1078
1159
  endHeight: $curContent.scrollHeight,
1079
1160
  speed: animSpeed
1080
1161
  }, easeType, function () {
1081
- // content height observer
1082
1162
  setHeightObserver(curIndex);
1163
+ animationInProgress.current = false;
1083
1164
  });
1084
1165
  } else {
1085
- if (e.type == 'click') {
1086
- var _reactDomEl$querySele3, _reactDomEl$querySele4;
1087
- //to close
1088
- reactDomEl.classList.remove('active');
1089
- (_reactDomEl$querySele3 = reactDomEl.querySelector('.custom-accordion-trigger')) === null || _reactDomEl$querySele3 === void 0 ? void 0 : _reactDomEl$querySele3.classList.remove('active');
1090
- (_reactDomEl$querySele4 = reactDomEl.querySelector('.custom-accordion-trigger')) === null || _reactDomEl$querySele4 === void 0 ? void 0 : _reactDomEl$querySele4.classList.add('collapsed');
1091
- reactDomEl.setAttribute('aria-expanded', false);
1092
- anim_default()($curContent, {
1093
- startHeight: $curContent.scrollHeight,
1094
- endHeight: 0,
1095
- speed: animSpeed
1096
- }, easeType);
1166
+ var _curIndex2;
1167
+ reactDomEl.setAttribute('aria-expanded', 'false');
1168
+
1169
+ // Call onTriggerChange if it exists in the child props
1170
+ var _childProps = (_curIndex2 = children[curIndex]) === null || _curIndex2 === void 0 ? void 0 : _curIndex2.props;
1171
+ if (typeof (_childProps === null || _childProps === void 0 ? void 0 : _childProps.onTriggerChange) === 'function' && $trigger) {
1172
+ _childProps.onTriggerChange($trigger, false);
1097
1173
  }
1174
+
1175
+ // Remove current item from expanded items
1176
+ setExpandedItems(function (prev) {
1177
+ var newSet = new Set(prev);
1178
+ newSet["delete"](curIndex);
1179
+ return newSet;
1180
+ });
1181
+ anim_default()($curContent, {
1182
+ startHeight: $curContent.scrollHeight,
1183
+ endHeight: 0,
1184
+ speed: animSpeed
1185
+ }, easeType, function () {
1186
+ animationInProgress.current = false;
1187
+ });
1098
1188
  }
1099
- if (typeof onChange === 'function') {
1100
- onChange(reactDomEl, Number(curIndex));
1101
- }
1189
+ onChange === null || onChange === void 0 ? void 0 : onChange(reactDomEl, curIndex);
1102
1190
  }
1191
+
1192
+ // Initialize expanded items based on defaultActiveIndex or defaultActiveAll
1193
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
1194
+ if (defaultActiveAll && children && rootRef.current) {
1195
+ var allIndices = Array.from({
1196
+ length: children.length
1197
+ }, function (_, i) {
1198
+ return i;
1199
+ });
1200
+ setExpandedItems(new Set(allIndices));
1201
+
1202
+ // Actually expand all items without animation
1203
+ var $allItems = rootRef.current.querySelectorAll('.custom-accordion-item');
1204
+ Array.prototype.forEach.call($allItems, function (node, index) {
1205
+ var _index;
1206
+ node.setAttribute('aria-expanded', 'true');
1207
+ var $curContent = node.querySelector('.custom-accordion-content__wrapper');
1208
+ var $trigger = node.querySelector('.custom-accordion-trigger');
1209
+
1210
+ // Call onTriggerChange if it exists in the child props
1211
+ var childProps = (_index = children[index]) === null || _index === void 0 ? void 0 : _index.props;
1212
+ if (typeof (childProps === null || childProps === void 0 ? void 0 : childProps.onTriggerChange) === 'function' && $trigger) {
1213
+ childProps.onTriggerChange($trigger, true);
1214
+ }
1215
+
1216
+ // Directly set height without animation
1217
+ if ($curContent) {
1218
+ $curContent.style.height = "".concat($curContent.scrollHeight, "px");
1219
+ }
1220
+ });
1221
+ } else if (defaultActiveIndex !== undefined) {
1222
+ var initialExpanded = new Set();
1223
+ if (Array.isArray(defaultActiveIndex)) {
1224
+ defaultActiveIndex.forEach(function (index) {
1225
+ return initialExpanded.add(index);
1226
+ });
1227
+ } else if (typeof defaultActiveIndex === 'number') {
1228
+ initialExpanded.add(defaultActiveIndex);
1229
+ }
1230
+ setExpandedItems(initialExpanded);
1231
+ }
1232
+ }, [defaultActiveIndex, defaultActiveAll, children]);
1103
1233
  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", {
1104
1234
  className: (0,cls.combinedCls)('custom-accordion-item', (0,cls.clsWrite)(wrapperClassName, 'accordion')),
1105
1235
  role: "tablist",
1106
1236
  ref: rootRef
1107
1237
  }, children != null ? children.map(function (item, i) {
1108
1238
  var childProps = _objectSpread({}, item.props);
1109
- var _defaultActive = i === 0 && displayTheFirstItem ? true : false;
1239
+ var _defaultActive = false;
1240
+ if (Array.isArray(defaultActiveIndex)) {
1241
+ _defaultActive = defaultActiveIndex.includes(i);
1242
+ } else if (typeof defaultActiveIndex === 'number') {
1243
+ _defaultActive = defaultActiveIndex === i;
1244
+ }
1110
1245
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(src_AccordionItem, Accordion_extends({
1111
1246
  key: "item" + i,
1112
1247
  index: i,
1248
+ animSpeed: animSpeed,
1249
+ arrowOnly: arrowOnly,
1113
1250
  heightObserver: heightObserver,
1114
- defaultActive: typeof displayAllItems === 'undefined' ? _defaultActive : displayAllItems,
1115
- triggerType: triggerType || 'click',
1116
- onToggleEv: handleClickItem
1251
+ defaultActive: _defaultActive,
1252
+ onToggleEv: handleClickItem,
1253
+ isExpanded: expandedItems.has(i) // Both controlled and uncontrolled modes are implemented
1117
1254
  }, childProps));
1118
1255
  }) : null));
1119
1256
  };
@@ -28,6 +28,7 @@ export interface DragDropListProps {
28
28
  doubleIndent?: boolean;
29
29
  alternateCollapse?: boolean;
30
30
  arrow?: React.ReactNode;
31
+ renderOption?: (item: ListItem, dragHandleClassName: string, index: number) => React.ReactNode;
31
32
  onUpdate?: (items: ListItem[], curId: number) => void;
32
33
  }
33
34
  export interface EditValue {
@@ -1163,7 +1163,7 @@ __webpack_require__.r(__webpack_exports__);
1163
1163
  /* harmony import */ var funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__);
1164
1164
  /* harmony import */ var funda_utils_dist_cjs_useBoundedDrag__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(759);
1165
1165
  /* harmony import */ var funda_utils_dist_cjs_useBoundedDrag__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_useBoundedDrag__WEBPACK_IMPORTED_MODULE_3__);
1166
- var _excluded = ["wrapperClassName", "prefix", "data", "draggable", "handleHide", "handleIcon", "handlePos", "dragMode", "editable", "itemStyle", "hierarchical", "indentation", "doubleIndent", "alternateCollapse", "arrow", "onUpdate"];
1166
+ var _excluded = ["wrapperClassName", "prefix", "data", "draggable", "handleHide", "handleIcon", "handlePos", "dragMode", "editable", "itemStyle", "hierarchical", "indentation", "doubleIndent", "alternateCollapse", "arrow", "renderOption", "onUpdate"];
1167
1167
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1168
1168
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1169
1169
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -1219,6 +1219,7 @@ var DragDropList = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef
1219
1219
  transform: "matrix(.03541-.00013.00013.03541 2.98 3.02)",
1220
1220
  fill: "#a5a5a5"
1221
1221
  }))) : _props$arrow,
1222
+ renderOption = props.renderOption,
1222
1223
  onUpdate = props.onUpdate,
1223
1224
  attributes = _objectWithoutProperties(props, _excluded);
1224
1225
  var INDENT_PLACEHOLDER = doubleIndent ? "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" : "&nbsp;&nbsp;&nbsp;&nbsp;";
@@ -1232,7 +1233,6 @@ var DragDropList = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef
1232
1233
  _useState4 = _slicedToArray(_useState3, 2),
1233
1234
  editingItem = _useState4[0],
1234
1235
  setEditingItem = _useState4[1];
1235
- var dragHandle = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
1236
1236
 
1237
1237
  // Edit
1238
1238
  var _useState5 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)({}),
@@ -1552,8 +1552,7 @@ var DragDropList = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef
1552
1552
  }
1553
1553
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
1554
1554
  className: "".concat(prefix, "-draggable-list__itemcontent")
1555
- }, draggable && !handleHide ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
1556
- ref: dragHandle,
1555
+ }, renderOption ? renderOption(item, "".concat(prefix, "-draggable-list__handle"), index) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, draggable && !handleHide ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
1557
1556
  className: "".concat(prefix, "-draggable-list__handle ").concat(handlePos !== null && handlePos !== void 0 ? handlePos : 'left'),
1558
1557
  draggable: dragMode === 'handle',
1559
1558
  dangerouslySetInnerHTML: {
@@ -1575,7 +1574,7 @@ var DragDropList = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef
1575
1574
  }, arrow || (isCollapsed ? '▶' : '▼'))), item.appendControl ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
1576
1575
  className: "".concat(prefix, "-draggable-list__itemext"),
1577
1576
  id: "".concat(prefix, "-draggable-list__itemext-").concat(item.value)
1578
- }, item.appendControl)) : null)));
1577
+ }, item.appendControl)) : null))));
1579
1578
  }));
1580
1579
  });
1581
1580
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (DragDropList);
@@ -1254,7 +1254,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1254
1254
  var funda_utils_dist_cjs_useBoundedDrag__WEBPACK_IMPORTED_MODULE_3__ = __nested_webpack_require_54634__(759);
1255
1255
  /* harmony import */
1256
1256
  var funda_utils_dist_cjs_useBoundedDrag__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__nested_webpack_require_54634__.n(funda_utils_dist_cjs_useBoundedDrag__WEBPACK_IMPORTED_MODULE_3__);
1257
- var _excluded = ["wrapperClassName", "prefix", "data", "draggable", "handleHide", "handleIcon", "handlePos", "dragMode", "editable", "itemStyle", "hierarchical", "indentation", "doubleIndent", "alternateCollapse", "arrow", "onUpdate"];
1257
+ var _excluded = ["wrapperClassName", "prefix", "data", "draggable", "handleHide", "handleIcon", "handlePos", "dragMode", "editable", "itemStyle", "hierarchical", "indentation", "doubleIndent", "alternateCollapse", "arrow", "renderOption", "onUpdate"];
1258
1258
  function _extends() {
1259
1259
  _extends = Object.assign ? Object.assign.bind() : function (target) {
1260
1260
  for (var i = 1; i < arguments.length; i++) {
@@ -1447,6 +1447,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1447
1447
  transform: "matrix(.03541-.00013.00013.03541 2.98 3.02)",
1448
1448
  fill: "#a5a5a5"
1449
1449
  }))) : _props$arrow,
1450
+ renderOption = props.renderOption,
1450
1451
  onUpdate = props.onUpdate,
1451
1452
  attributes = _objectWithoutProperties(props, _excluded);
1452
1453
  var INDENT_PLACEHOLDER = doubleIndent ? "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" : "&nbsp;&nbsp;&nbsp;&nbsp;";
@@ -1460,7 +1461,6 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1460
1461
  _useState4 = _slicedToArray(_useState3, 2),
1461
1462
  editingItem = _useState4[0],
1462
1463
  setEditingItem = _useState4[1];
1463
- var dragHandle = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
1464
1464
 
1465
1465
  // Edit
1466
1466
  var _useState5 = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)({}),
@@ -1780,8 +1780,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1780
1780
  }
1781
1781
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
1782
1782
  className: "".concat(prefix, "-draggable-list__itemcontent")
1783
- }, draggable && !handleHide ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
1784
- ref: dragHandle,
1783
+ }, renderOption ? renderOption(item, "".concat(prefix, "-draggable-list__handle"), index) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(react__WEBPACK_IMPORTED_MODULE_0___default().Fragment, null, draggable && !handleHide ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
1785
1784
  className: "".concat(prefix, "-draggable-list__handle ").concat(handlePos !== null && handlePos !== void 0 ? handlePos : 'left'),
1786
1785
  draggable: dragMode === 'handle',
1787
1786
  dangerouslySetInnerHTML: {
@@ -1803,7 +1802,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
1803
1802
  }, arrow || (isCollapsed ? '▶' : '▼'))), item.appendControl ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(react__WEBPACK_IMPORTED_MODULE_0___default().Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
1804
1803
  className: "".concat(prefix, "-draggable-list__itemext"),
1805
1804
  id: "".concat(prefix, "-draggable-list__itemext-").concat(item.value)
1806
- }, item.appendControl)) : null)));
1805
+ }, item.appendControl)) : null))));
1807
1806
  }));
1808
1807
  });
1809
1808
  /* harmony default export */