funda-ui 4.7.755 → 4.7.760

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.
@@ -332,7 +332,7 @@ var external_root_React_commonjs2_react_commonjs_react_amd_react_default = /*#__
332
332
  // EXTERNAL MODULE: ../Utils/dist/cjs/cls.js
333
333
  var cls = __webpack_require__(188);
334
334
  ;// CONCATENATED MODULE: ./src/AccordionItem.tsx
335
- var _excluded = ["heightObserver", "index", "animSpeed", "easing", "arrowOnly", "itemClassName", "itemContentWrapperClassName", "itemContentClassName", "itemTriggerClassName", "itemHeaderClassName", "itemTriggerIcon", "itemStyle", "activeItem", "title", "onToggleEv", "onTransitionEnd", "onItemCollapse", "isExpanded", "children"];
335
+ var _excluded = ["heightObserver", "index", "animSpeed", "easing", "arrowOnly", "itemClassName", "itemContentWrapperClassName", "itemContentClassName", "itemTriggerClassName", "itemHeaderClassName", "itemTriggerIcon", "itemStyle", "activeItem", "title", "onToggleEv", "onTransitionEnd", "onItemCollapse", "isExpanded", "forceExpanded", "children"];
336
336
  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); }
337
337
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
338
338
  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."); }
@@ -363,6 +363,7 @@ var AccordionItem = function AccordionItem(props) {
363
363
  onTransitionEnd = props.onTransitionEnd,
364
364
  onItemCollapse = props.onItemCollapse,
365
365
  controlledExpanded = props.isExpanded,
366
+ forceExpanded = props.forceExpanded,
366
367
  children = props.children,
367
368
  attributes = _objectWithoutProperties(props, _excluded);
368
369
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false),
@@ -371,9 +372,12 @@ var AccordionItem = function AccordionItem(props) {
371
372
  setInternalExpanded = _useState2[1];
372
373
  var isFirstRender = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(true);
373
374
  var initialHeightSet = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);
375
+ var hasUserInteracted = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);
374
376
 
375
- // Use controlled or uncontrolled expanded state
376
- var isExpanded = controlledExpanded !== undefined ? controlledExpanded : internalExpanded;
377
+ // Use forceExpanded if provided and user hasn't interacted, otherwise use controlled or uncontrolled expanded state
378
+ // forceExpanded takes priority over isExpanded from parent, but only before user interaction
379
+ var actualExpanded = controlledExpanded !== undefined ? controlledExpanded : internalExpanded;
380
+ var isExpanded = forceExpanded !== undefined && !hasUserInteracted.current ? forceExpanded : actualExpanded;
377
381
  var observer = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
378
382
  var contentWrapperRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
379
383
  var contentRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
@@ -382,6 +386,9 @@ var AccordionItem = function AccordionItem(props) {
382
386
  var handleToggle = function handleToggle(e) {
383
387
  e.preventDefault();
384
388
  e.stopPropagation();
389
+
390
+ // Mark that user has interacted, so forceExpanded will be ignored
391
+ hasUserInteracted.current = true;
385
392
  if (controlledExpanded === undefined) {
386
393
  setInternalExpanded(function (prev) {
387
394
  return !prev;
@@ -399,6 +406,13 @@ var AccordionItem = function AccordionItem(props) {
399
406
  overflow: 'hidden'
400
407
  };
401
408
  };
409
+
410
+ // Reset user interaction flag when forceExpanded changes externally
411
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
412
+ if (forceExpanded !== undefined) {
413
+ hasUserInteracted.current = false;
414
+ }
415
+ }, [forceExpanded]);
402
416
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
403
417
  if (triggerRef.current && typeof onItemCollapse === 'function') {
404
418
  if (isFirstRender.current) {
@@ -332,7 +332,7 @@ var external_root_React_commonjs2_react_commonjs_react_amd_react_default = /*#__
332
332
  // EXTERNAL MODULE: ../Utils/dist/cjs/cls.js
333
333
  var cls = __webpack_require__(188);
334
334
  ;// CONCATENATED MODULE: ./src/AccordionItem.tsx
335
- var _excluded = ["heightObserver", "index", "animSpeed", "easing", "arrowOnly", "itemClassName", "itemContentWrapperClassName", "itemContentClassName", "itemTriggerClassName", "itemHeaderClassName", "itemTriggerIcon", "itemStyle", "activeItem", "title", "onToggleEv", "onTransitionEnd", "onItemCollapse", "isExpanded", "children"];
335
+ var _excluded = ["heightObserver", "index", "animSpeed", "easing", "arrowOnly", "itemClassName", "itemContentWrapperClassName", "itemContentClassName", "itemTriggerClassName", "itemHeaderClassName", "itemTriggerIcon", "itemStyle", "activeItem", "title", "onToggleEv", "onTransitionEnd", "onItemCollapse", "isExpanded", "forceExpanded", "children"];
336
336
  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); }
337
337
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
338
338
  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."); }
@@ -363,6 +363,7 @@ var AccordionItem = function AccordionItem(props) {
363
363
  onTransitionEnd = props.onTransitionEnd,
364
364
  onItemCollapse = props.onItemCollapse,
365
365
  controlledExpanded = props.isExpanded,
366
+ forceExpanded = props.forceExpanded,
366
367
  children = props.children,
367
368
  attributes = _objectWithoutProperties(props, _excluded);
368
369
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(false),
@@ -371,9 +372,12 @@ var AccordionItem = function AccordionItem(props) {
371
372
  setInternalExpanded = _useState2[1];
372
373
  var isFirstRender = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(true);
373
374
  var initialHeightSet = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);
375
+ var hasUserInteracted = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(false);
374
376
 
375
- // Use controlled or uncontrolled expanded state
376
- var isExpanded = controlledExpanded !== undefined ? controlledExpanded : internalExpanded;
377
+ // Use forceExpanded if provided and user hasn't interacted, otherwise use controlled or uncontrolled expanded state
378
+ // forceExpanded takes priority over isExpanded from parent, but only before user interaction
379
+ var actualExpanded = controlledExpanded !== undefined ? controlledExpanded : internalExpanded;
380
+ var isExpanded = forceExpanded !== undefined && !hasUserInteracted.current ? forceExpanded : actualExpanded;
377
381
  var observer = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
378
382
  var contentWrapperRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
379
383
  var contentRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
@@ -382,6 +386,9 @@ var AccordionItem = function AccordionItem(props) {
382
386
  var handleToggle = function handleToggle(e) {
383
387
  e.preventDefault();
384
388
  e.stopPropagation();
389
+
390
+ // Mark that user has interacted, so forceExpanded will be ignored
391
+ hasUserInteracted.current = true;
385
392
  if (controlledExpanded === undefined) {
386
393
  setInternalExpanded(function (prev) {
387
394
  return !prev;
@@ -399,6 +406,13 @@ var AccordionItem = function AccordionItem(props) {
399
406
  overflow: 'hidden'
400
407
  };
401
408
  };
409
+
410
+ // Reset user interaction flag when forceExpanded changes externally
411
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
412
+ if (forceExpanded !== undefined) {
413
+ hasUserInteracted.current = false;
414
+ }
415
+ }, [forceExpanded]);
402
416
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
403
417
  if (triggerRef.current && typeof onItemCollapse === 'function') {
404
418
  if (isFirstRender.current) {
@@ -2,7 +2,6 @@ import React, { useEffect, useRef, useState } from 'react';
2
2
 
3
3
  import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
4
4
 
5
-
6
5
  export type AccordionItemProps = {
7
6
  heightObserver?: number[];
8
7
  index?: number;
@@ -29,6 +28,8 @@ export type AccordionItemProps = {
29
28
  onItemCollapse?: (trigger: HTMLElement, icon: HTMLElement, isExpanded: boolean) => void;
30
29
  /** Control expanded state from parent */
31
30
  isExpanded?: boolean;
31
+ /** Force expanded state, takes priority over isExpanded from parent */
32
+ forceExpanded?: boolean;
32
33
  /** -- */
33
34
  children: React.ReactNode;
34
35
  };
@@ -56,6 +57,7 @@ const AccordionItem = (props: AccordionItemProps) => {
56
57
  onTransitionEnd,
57
58
  onItemCollapse,
58
59
  isExpanded: controlledExpanded,
60
+ forceExpanded,
59
61
  children,
60
62
  ...attributes
61
63
  } = props;
@@ -63,9 +65,12 @@ const AccordionItem = (props: AccordionItemProps) => {
63
65
  const [internalExpanded, setInternalExpanded] = useState<boolean>(false);
64
66
  const isFirstRender = useRef<boolean>(true);
65
67
  const initialHeightSet = useRef<boolean>(false);
68
+ const hasUserInteracted = useRef<boolean>(false);
66
69
 
67
- // Use controlled or uncontrolled expanded state
68
- const isExpanded = controlledExpanded !== undefined ? controlledExpanded : internalExpanded;
70
+ // Use forceExpanded if provided and user hasn't interacted, otherwise use controlled or uncontrolled expanded state
71
+ // forceExpanded takes priority over isExpanded from parent, but only before user interaction
72
+ const actualExpanded = controlledExpanded !== undefined ? controlledExpanded : internalExpanded;
73
+ const isExpanded = (forceExpanded !== undefined && !hasUserInteracted.current) ? forceExpanded : actualExpanded;
69
74
 
70
75
  const observer = useRef<ResizeObserver | null>(null);
71
76
  const contentWrapperRef = useRef<HTMLDivElement | null>(null);
@@ -77,6 +82,9 @@ const AccordionItem = (props: AccordionItemProps) => {
77
82
  e.preventDefault();
78
83
  e.stopPropagation();
79
84
 
85
+ // Mark that user has interacted, so forceExpanded will be ignored
86
+ hasUserInteracted.current = true;
87
+
80
88
  if (controlledExpanded === undefined) {
81
89
  setInternalExpanded(prev => !prev);
82
90
  }
@@ -96,6 +104,13 @@ const AccordionItem = (props: AccordionItemProps) => {
96
104
  };
97
105
 
98
106
 
107
+ // Reset user interaction flag when forceExpanded changes externally
108
+ useEffect(() => {
109
+ if (forceExpanded !== undefined) {
110
+ hasUserInteracted.current = false;
111
+ }
112
+ }, [forceExpanded]);
113
+
99
114
  useEffect(() => {
100
115
  if (triggerRef.current && typeof onItemCollapse === 'function') {
101
116
  if (isFirstRender.current) {
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"UIUX Lab","email":"uiuxlab@gmail.com","name":"funda-ui","version":"4.7.755","description":"React components using pure Bootstrap 5+ which does not contain any external style and script libraries.","repository":{"type":"git","url":"git+https://github.com/xizon/funda-ui.git"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["bootstrap","react-bootstrap","react-components","components","components-react","react-bootstrap-components","react","funda-ui","fundaui","uikit","ui-kit","ui-components"],"bugs":{"url":"https://github.com/xizon/funda-ui/issues"},"homepage":"https://github.com/xizon/funda-ui#readme","main":"all.js","license":"MIT","dependencies":{"react":"^18.2.0","react-dom":"^18.2.0"},"types":"all.d.ts","publishConfig":{"directory":"lib"}}
1
+ {"author":"UIUX Lab","email":"uiuxlab@gmail.com","name":"funda-ui","version":"4.7.760","description":"React components using pure Bootstrap 5+ which does not contain any external style and script libraries.","repository":{"type":"git","url":"git+https://github.com/xizon/funda-ui.git"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["bootstrap","react-bootstrap","react-components","components","components-react","react-bootstrap-components","react","funda-ui","fundaui","uikit","ui-kit","ui-components"],"bugs":{"url":"https://github.com/xizon/funda-ui/issues"},"homepage":"https://github.com/xizon/funda-ui#readme","main":"all.js","license":"MIT","dependencies":{"react":"^18.2.0","react-dom":"^18.2.0"},"types":"all.d.ts","publishConfig":{"directory":"lib"},"directories":{"lib":"lib"}}