funda-ui 4.7.701 → 4.7.723

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/Utils/useSSE.js CHANGED
@@ -108,20 +108,44 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
108
108
  *
109
109
  * @usage:
110
110
  *
111
- * const App = () => {
112
- * const { connected, messages, disconnect, reconnect } = useSSE('http://localhost:3000/sse');
113
- *
114
- * return (
115
- * <div>
116
- * <p>Status: {connected ? '✅ Connected' : '❌ Disconnected'}</p>
117
- * <button onClick={disconnect}>Disconnect</button>
118
- * <button onClick={reconnect}>Reconnect</button>
119
- * {messages.map((m, i) => <div key={i}>{m}</div>)}
120
- * </div>
121
- * );
122
- * };
111
+ const App = () => {
112
+ const { connected, messages, disconnect, reconnect } = useSSE('http://localhost:3000/sse');
113
+
114
+ return (
115
+ <div>
116
+ <p>Status: {connected ? '✅ Connected' : '❌ Disconnected'}</p>
117
+ <button onClick={disconnect}>Disconnect</button>
118
+ <button onClick={reconnect}>Reconnect</button>
119
+ {messages.map((m, i) => <div key={i}>{m}</div>)}
120
+ </div>
121
+ );
122
+ };
123
+
124
+ * It is recommended to use it in conjunction with usePageVisibility, because in HTTP mode,
125
+ * browsers allow a maximum of 6 connections; otherwise, other normal interfaces will be suspended and inaccessible.
126
+
127
+ import usePageVisibility from 'funda-ui/Utils/usePageVisibility';
128
+
129
+ const App = () => {
130
+ const { connected, messages, disconnect, reconnect } = useSSE('http://localhost:3000/sse');
131
+
132
+ // add new
133
+ usePageVisibility(
134
+ () => {
135
+ reconnect();
136
+ },
137
+ () => {
138
+ disconnect();
139
+ },
140
+ () => console.log("🎬 Page initialized while visible.")
141
+ );
142
+
143
+ return '';
144
+ };
145
+
123
146
  */
124
147
 
148
+
125
149
  var useSSE = function useSSE(url) {
126
150
  var retryDelay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3000;
127
151
  var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
@@ -12,6 +12,7 @@ export declare type DynamicFieldsProps = {
12
12
  label?: React.ReactNode | string;
13
13
  data: DynamicFieldsValueProps | null;
14
14
  maxFields?: any;
15
+ defaultRows?: number;
15
16
  confirmText?: string;
16
17
  doNotRemoveDom?: boolean;
17
18
  iconAddBefore?: React.ReactNode | string;
@@ -495,7 +495,7 @@ __webpack_require__.r(__webpack_exports__);
495
495
  /* harmony import */ var funda_utils_dist_cjs_useComId__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(funda_utils_dist_cjs_useComId__WEBPACK_IMPORTED_MODULE_1__);
496
496
  /* harmony import */ var funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(188);
497
497
  /* 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__);
498
- var _excluded = ["contentRef", "wrapperClassName", "btnAddWrapperClassName", "btnRemoveWrapperClassName", "label", "data", "maxFields", "iconAddBefore", "iconAddAfter", "iconAdd", "iconAddPosition", "iconRemove", "doNotRemoveDom", "id", "confirmText", "innerAppendClassName", "innerAppendCellClassName", "innerAppendLastCellClassName", "innerAppendHideClassName", "innerAppendBodyClassName", "innerAppendHeadData", "innerAppendHeadRowShowFirst", "innerAppendHeadRowClassName", "innerAppendHeadCellClassName", "innerAppendHeadCellStyles", "innerAppendEmptyContent", "onAdd", "onRemove", "onLoad"];
498
+ var _excluded = ["contentRef", "wrapperClassName", "btnAddWrapperClassName", "btnRemoveWrapperClassName", "label", "data", "maxFields", "defaultRows", "iconAddBefore", "iconAddAfter", "iconAdd", "iconAddPosition", "iconRemove", "doNotRemoveDom", "id", "confirmText", "innerAppendClassName", "innerAppendCellClassName", "innerAppendLastCellClassName", "innerAppendHideClassName", "innerAppendBodyClassName", "innerAppendHeadData", "innerAppendHeadRowShowFirst", "innerAppendHeadRowClassName", "innerAppendHeadCellClassName", "innerAppendHeadCellStyles", "innerAppendEmptyContent", "onAdd", "onRemove", "onLoad"];
499
499
  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); }
500
500
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
501
501
  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."); }
@@ -520,6 +520,7 @@ var DynamicFields = function DynamicFields(props) {
520
520
  label = props.label,
521
521
  data = props.data,
522
522
  maxFields = props.maxFields,
523
+ defaultRows = props.defaultRows,
523
524
  iconAddBefore = props.iconAddBefore,
524
525
  iconAddAfter = props.iconAddAfter,
525
526
  iconAdd = props.iconAdd,
@@ -564,6 +565,10 @@ var DynamicFields = function DynamicFields(props) {
564
565
  setTmpl = _useState4[1];
565
566
  var addBtnIdRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)('');
566
567
  addBtnIdRef.current = "dynamic-fields-add-".concat(idRes);
568
+ var defaultRowsInitializedRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
569
+ var isInitializingDefaultRowsRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
570
+ var rafIdRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
571
+ var timeoutIdsRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)([]);
567
572
 
568
573
  // exposes the following methods
569
574
  (0,react__WEBPACK_IMPORTED_MODULE_0__.useImperativeHandle)(contentRef, function () {
@@ -629,18 +634,13 @@ var DynamicFields = function DynamicFields(props) {
629
634
  addBtnRef.current.style.setProperty('display', 'none', 'important');
630
635
  }
631
636
  }
632
- function handleClickAdd() {
633
- var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
634
- if (event !== null) {
635
- if (typeof event !== 'undefined') event.preventDefault();
636
- }
637
-
637
+ function addRowWithTemplate(template) {
638
638
  //button status
639
639
  checkMaxStatus();
640
640
 
641
641
  //
642
642
  setVal(function (prevState) {
643
- return [].concat(_toConsumableArray(prevState), _toConsumableArray(generateGroup(tmpl)));
643
+ return [].concat(_toConsumableArray(prevState), _toConsumableArray(generateGroup(template)));
644
644
  });
645
645
 
646
646
  //
@@ -667,6 +667,13 @@ var DynamicFields = function DynamicFields(props) {
667
667
  onAdd === null || onAdd === void 0 ? void 0 : onAdd(perRow, rootRef.current, addBtnRef.current, PER_ROW_DOM_STRING);
668
668
  }, 0);
669
669
  }
670
+ function handleClickAdd() {
671
+ var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
672
+ if (event !== null) {
673
+ if (typeof event !== 'undefined') event.preventDefault();
674
+ }
675
+ addRowWithTemplate(tmpl);
676
+ }
670
677
  function handleClickRemove(e) {
671
678
  if (e !== null && typeof e !== 'undefined') e.preventDefault();
672
679
  var $target = e.currentTarget.closest('.dynamic-fields__data__wrapper');
@@ -778,6 +785,99 @@ var DynamicFields = function DynamicFields(props) {
778
785
 
779
786
  //
780
787
  onLoad === null || onLoad === void 0 ? void 0 : onLoad(addBtnIdRef.current, rootRef.current, PER_ROW_DOM_STRING);
788
+
789
+ // Reset initialization flag when data becomes null
790
+ if (!data) {
791
+ defaultRowsInitializedRef.current = false;
792
+ isInitializingDefaultRowsRef.current = false;
793
+ }
794
+
795
+ // Add default rows if specified (only initialize once per data setup)
796
+ if (!defaultRowsInitializedRef.current && typeof defaultRows === 'number' && defaultRows > 0 && data && data.tmpl) {
797
+ // Get the initial data length
798
+ var initDataLength = Array.isArray(data.init) ? data.init.length : 0;
799
+
800
+ // Calculate how many rows need to be added
801
+ var maxRows = typeof maxFields !== 'undefined' ? parseFloat(maxFields) : Infinity;
802
+ var targetRows = Math.min(defaultRows, maxRows);
803
+ var rowsToAdd = Math.max(0, targetRows - initDataLength);
804
+
805
+ // Mark as initialized immediately to prevent re-adding
806
+ defaultRowsInitializedRef.current = true;
807
+
808
+ // Only add rows if needed
809
+ if (rowsToAdd > 0) {
810
+ // Mark that we're initializing default rows
811
+ isInitializingDefaultRowsRef.current = true;
812
+
813
+ // Clear any existing timeouts
814
+ timeoutIdsRef.current.forEach(function (id) {
815
+ return clearTimeout(id);
816
+ });
817
+ timeoutIdsRef.current = [];
818
+
819
+ // Use requestAnimationFrame to ensure DOM is ready and state is updated
820
+ rafIdRef.current = requestAnimationFrame(function () {
821
+ // Check if component is still mounted
822
+ if (!rootRef.current) {
823
+ isInitializingDefaultRowsRef.current = false;
824
+ return;
825
+ }
826
+ var timeoutId1 = setTimeout(function () {
827
+ // Check if component is still mounted
828
+ if (!rootRef.current) {
829
+ isInitializingDefaultRowsRef.current = false;
830
+ return;
831
+ }
832
+
833
+ // Add rows one by one with a small delay to ensure state updates
834
+ var addedCount = 0;
835
+ var addNextRow = function addNextRow() {
836
+ // Check if component is still mounted before each operation
837
+ if (addedCount < rowsToAdd && rootRef.current) {
838
+ // Use data.tmpl directly to avoid dependency on state
839
+ addRowWithTemplate(data.tmpl);
840
+ addedCount++;
841
+ // Wait a bit before adding the next row to ensure state updates
842
+ if (addedCount < rowsToAdd) {
843
+ var timeoutId2 = setTimeout(addNextRow, 10);
844
+ timeoutIdsRef.current.push(timeoutId2);
845
+ } else {
846
+ // All rows added, mark initialization as complete
847
+ isInitializingDefaultRowsRef.current = false;
848
+ }
849
+ } else {
850
+ // No more rows to add or component unmounted
851
+ isInitializingDefaultRowsRef.current = false;
852
+ }
853
+ };
854
+ addNextRow();
855
+ }, 50);
856
+ timeoutIdsRef.current.push(timeoutId1);
857
+ });
858
+ }
859
+ }
860
+
861
+ // Cleanup function to cancel requestAnimationFrame and timeouts
862
+ return function () {
863
+ // Don't cleanup if we're in the middle of initializing defaultRows
864
+ // This prevents the cleanup from canceling the async operations before they complete
865
+ if (isInitializingDefaultRowsRef.current) {
866
+ // Allow defaultRows initialization to complete
867
+ // The cleanup will happen naturally when initialization finishes
868
+ return;
869
+ }
870
+
871
+ // Normal cleanup for other cases
872
+ if (rafIdRef.current !== null) {
873
+ cancelAnimationFrame(rafIdRef.current);
874
+ rafIdRef.current = null;
875
+ }
876
+ timeoutIdsRef.current.forEach(function (id) {
877
+ return clearTimeout(id);
878
+ });
879
+ timeoutIdsRef.current = [];
880
+ };
781
881
  }, [data]);
782
882
  return /*#__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", {
783
883
  className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(wrapperClassName, 'mb-3 position-relative'),
@@ -51,7 +51,7 @@ export declare type EventCalendarTimelineProps = {
51
51
  cellAddBtnLabel?: string | React.ReactNode;
52
52
  forwardAndBackFillDisabled?: boolean;
53
53
  draggable?: boolean;
54
- showWeek?: boolean;
54
+ headerShowWeek?: boolean;
55
55
  autoScroll?: boolean;
56
56
  onChangeDate?: (e: any, currentData: any) => void;
57
57
  onChangeMonth?: (currentData: any) => void;
@@ -60,6 +60,7 @@ export declare type EventCalendarTimelineProps = {
60
60
  onChangeWeek?: (startDate: string, endDate: string) => void;
61
61
  onListRenderComplete?: () => void;
62
62
  onChangeAppearanceMode?: (mode: string) => void;
63
+ enableHeaderResize?: boolean;
63
64
  modalMaskOpacity?: string;
64
65
  modalMaxWidth?: number | string;
65
66
  modalMinHeight?: number | string;
@@ -3977,7 +3977,7 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
3977
3977
  cellAddBtnLabel = props.cellAddBtnLabel,
3978
3978
  forwardAndBackFillDisabled = props.forwardAndBackFillDisabled,
3979
3979
  draggable = props.draggable,
3980
- showWeek = props.showWeek,
3980
+ headerShowWeek = props.headerShowWeek,
3981
3981
  autoScroll = props.autoScroll,
3982
3982
  onChangeDate = props.onChangeDate,
3983
3983
  onChangeMonth = props.onChangeMonth,
@@ -3986,6 +3986,7 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
3986
3986
  onChangeWeek = props.onChangeWeek,
3987
3987
  onListRenderComplete = props.onListRenderComplete,
3988
3988
  onChangeAppearanceMode = props.onChangeAppearanceMode,
3989
+ enableHeaderResize = props.enableHeaderResize,
3989
3990
  modalMaskOpacity = props.modalMaskOpacity,
3990
3991
  modalMaxWidth = props.modalMaxWidth,
3991
3992
  modalMinHeight = props.modalMinHeight,
@@ -4115,14 +4116,20 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
4115
4116
 
4116
4117
  // table grid
4117
4118
  var AUTO_SCROLL = autoScroll || false;
4118
- var SHOW_WEEK = showWeek || false;
4119
+ var HEADER_SHOW_WEEK = headerShowWeek || false;
4119
4120
  var BODY_DRAG = draggable || false;
4121
+ var ENABLE_HEADER_RESIZE = enableHeaderResize || false;
4120
4122
  var tableGridRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
4121
4123
  var tableGridHeaderRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
4122
4124
  var scrollHeaderRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
4123
4125
  var scrollBodyRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
4124
4126
  var scrollListRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
4125
4127
 
4128
+ // header resize drag
4129
+ var isResizingRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
4130
+ var resizeStartXRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(0);
4131
+ var resizeStartWidthRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(0);
4132
+
4126
4133
  // Temporary date
4127
4134
  var _useState27 = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(''),
4128
4135
  _useState28 = _slicedToArray(_useState27, 2),
@@ -4161,13 +4168,13 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
4161
4168
  // Calculate CELL_MIN_W based on appearanceMode and tableCellMinWidth
4162
4169
  var CELL_MIN_W = (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(function () {
4163
4170
  if (typeof tableCellMinWidth === 'undefined') {
4164
- return appearanceMode === 'week' ? 100 : 50;
4171
+ return headerShowWeek || false ? 100 : 50;
4165
4172
  }
4166
4173
  if (typeof tableCellMinWidth === 'function') {
4167
4174
  return tableCellMinWidth(appearanceMode);
4168
4175
  }
4169
4176
  return tableCellMinWidth;
4170
- }, [tableCellMinWidth, appearanceMode]);
4177
+ }, [tableCellMinWidth, appearanceMode, headerShowWeek]);
4171
4178
  var findMondayAndTruncate = function findMondayAndTruncate(dates) {
4172
4179
  var _res = dates.map(function (s) {
4173
4180
  return new Date(s);
@@ -5076,7 +5083,7 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
5076
5083
 
5077
5084
  // week day
5078
5085
  var weekDay = item.week[i];
5079
- var _weekDayStr = SHOW_WEEK ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
5086
+ var _weekDayStr = HEADER_SHOW_WEEK ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
5080
5087
  dangerouslySetInnerHTML: {
5081
5088
  __html: item.weekDisplay[i]
5082
5089
  }
@@ -5547,9 +5554,17 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
5547
5554
  var tableGridEl = tableGridRef.current;
5548
5555
 
5549
5556
  // initialize cell height
5550
- var headerTitleTrElements = tableGridEl.querySelector('.custom-event-tl-table__datagrid-body__title tbody').getElementsByTagName('tr');
5551
- var trElements = tableGridEl.querySelector('.custom-event-tl-table__datagrid-body__content tbody').getElementsByTagName('tr');
5557
+ var headerTitleTbody = tableGridEl.querySelector('.custom-event-tl-table__datagrid-body__title tbody');
5558
+ var contentTbody = tableGridEl.querySelector('.custom-event-tl-table__datagrid-body__content tbody');
5559
+ if (!headerTitleTbody || !contentTbody) return;
5560
+ var headerTitleTrElements = headerTitleTbody.getElementsByTagName('tr');
5561
+ var trElements = contentTbody.getElementsByTagName('tr');
5562
+
5563
+ // Reset any previously set inline heights so we measure natural heights.
5552
5564
  for (var i = 0; i < headerTitleTrElements.length; i++) {
5565
+ // set to 'auto' (or remove inline style) to allow shrink
5566
+ headerTitleTrElements[i].style.height = 'auto';
5567
+ if (trElements[i]) trElements[i].style.height = 'auto';
5553
5568
  var targetElement = headerTitleTrElements[i].offsetHeight > trElements[i].offsetHeight ? headerTitleTrElements[i] : trElements[i];
5554
5569
  var tdOHeight = window.getComputedStyle(targetElement).height;
5555
5570
  headerTitleTrElements[i].style.height = tdOHeight;
@@ -5775,10 +5790,7 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
5775
5790
  }
5776
5791
  }
5777
5792
 
5778
- // ================================================================
5779
- //
5780
- // ================================================================
5781
- //if user change the selectedYear, then udate the years array that is displayed on year tab view
5793
+ // if user change the selectedYear, then udate the years array that is displayed on year tab view
5782
5794
  (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
5783
5795
  var years = [];
5784
5796
  for (var y = selectedYear - 10; y < selectedYear + 10; y++) {
@@ -5832,6 +5844,83 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
5832
5844
  setCopiedCells(null);
5833
5845
  };
5834
5846
  }, []);
5847
+
5848
+ // ================================================================
5849
+ // Handle header resize drag
5850
+ // ================================================================
5851
+ var handleHeaderResizeMove = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) {
5852
+ var _e$touches$;
5853
+ if (!isResizingRef.current || !tableGridRef.current) return;
5854
+ var tableGridEl = tableGridRef.current;
5855
+ // Find the header title element that should have the CSS variable
5856
+ var headerTitleEl = tableGridEl.querySelector('.custom-event-tl-table__cell-cushion-headertitle');
5857
+ if (!headerTitleEl) return;
5858
+
5859
+ // Get clientX from either MouseEvent or TouchEvent
5860
+ var clientX = 'touches' in e ? (_e$touches$ = e.touches[0]) === null || _e$touches$ === void 0 ? void 0 : _e$touches$.clientX : e.clientX;
5861
+ if (clientX === undefined) return;
5862
+ var deltaX = clientX - resizeStartXRef.current;
5863
+ var newWidth = Math.max(100, resizeStartWidthRef.current + deltaX); // Minimum width 100px
5864
+
5865
+ // Update CSS variable on the header title element
5866
+ headerTitleEl.style.setProperty('--custom-event-tl-table-header-w', "".concat(newWidth, "px"));
5867
+ }, []);
5868
+ var handleHeaderResizeEnd = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function () {
5869
+ if (!isResizingRef.current) return;
5870
+ isResizingRef.current = false;
5871
+ document.removeEventListener('mousemove', handleHeaderResizeMove);
5872
+ document.removeEventListener('mouseup', handleHeaderResizeEnd);
5873
+ document.removeEventListener('touchmove', handleHeaderResizeMove);
5874
+ document.removeEventListener('touchend', handleHeaderResizeEnd);
5875
+
5876
+ // Recalculate table grid after resize
5877
+ if (tableGridRef.current) {
5878
+ tableGridInit();
5879
+ }
5880
+ }, [handleHeaderResizeMove]);
5881
+ var handleHeaderResizeStart = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) {
5882
+ if (!ENABLE_HEADER_RESIZE || !tableGridRef.current) return;
5883
+ e.preventDefault();
5884
+ e.stopPropagation();
5885
+ isResizingRef.current = true;
5886
+ resizeStartXRef.current = e.clientX;
5887
+ var tableGridEl = tableGridRef.current;
5888
+ var headerTitleEl = tableGridEl.querySelector('.custom-event-tl-table__cell-cushion-headertitle');
5889
+ if (headerTitleEl) {
5890
+ resizeStartWidthRef.current = headerTitleEl.clientWidth;
5891
+ }
5892
+ document.addEventListener('mousemove', handleHeaderResizeMove);
5893
+ document.addEventListener('mouseup', handleHeaderResizeEnd);
5894
+ }, [ENABLE_HEADER_RESIZE, handleHeaderResizeMove, handleHeaderResizeEnd]);
5895
+ var handleHeaderResizeTouchStart = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)(function (e) {
5896
+ if (!ENABLE_HEADER_RESIZE || !tableGridRef.current) return;
5897
+ e.preventDefault();
5898
+ e.stopPropagation();
5899
+ isResizingRef.current = true;
5900
+ var touch = e.touches[0];
5901
+ if (touch) {
5902
+ resizeStartXRef.current = touch.clientX;
5903
+ }
5904
+ var tableGridEl = tableGridRef.current;
5905
+ var headerTitleEl = tableGridEl.querySelector('.custom-event-tl-table__cell-cushion-headertitle');
5906
+ if (headerTitleEl) {
5907
+ resizeStartWidthRef.current = headerTitleEl.clientWidth;
5908
+ }
5909
+ document.addEventListener('touchmove', handleHeaderResizeMove, {
5910
+ passive: false
5911
+ });
5912
+ document.addEventListener('touchend', handleHeaderResizeEnd);
5913
+ }, [ENABLE_HEADER_RESIZE, handleHeaderResizeMove, handleHeaderResizeEnd]);
5914
+
5915
+ // Cleanup on unmount
5916
+ (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
5917
+ return function () {
5918
+ document.removeEventListener('mousemove', handleHeaderResizeMove);
5919
+ document.removeEventListener('mouseup', handleHeaderResizeEnd);
5920
+ document.removeEventListener('touchmove', handleHeaderResizeMove);
5921
+ document.removeEventListener('touchend', handleHeaderResizeEnd);
5922
+ };
5923
+ }, [handleHeaderResizeMove, handleHeaderResizeEnd]);
5835
5924
  return /*#__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", {
5836
5925
  className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_7__.combinedCls)("custom-event-tl__wrapper custom-event-tl__wrapper--".concat(appearanceMode), calendarWrapperClassName)
5837
5926
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
@@ -5977,7 +6066,13 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
5977
6066
  className: "custom-event-tl-table__cell-cushion custom-event-tl-table__cell-cushion-headertitle"
5978
6067
  }, tableListSectionTitle || ''))))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("th", {
5979
6068
  role: "presentation",
5980
- className: "custom-event-tl-table__timeline-divider"
6069
+ className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_7__.combinedCls)('custom-event-tl-table__timeline-divider', ENABLE_HEADER_RESIZE ? 'custom-event-tl-table__timeline-divider--resizable' : ''),
6070
+ onMouseDown: ENABLE_HEADER_RESIZE ? handleHeaderResizeStart : undefined,
6071
+ onTouchStart: ENABLE_HEADER_RESIZE ? handleHeaderResizeTouchStart : undefined,
6072
+ style: ENABLE_HEADER_RESIZE ? {
6073
+ cursor: 'col-resize',
6074
+ userSelect: 'none'
6075
+ } : undefined
5981
6076
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", null)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("th", {
5982
6077
  role: "presentation"
5983
6078
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
@@ -6016,7 +6111,13 @@ var EventCalendarTimeline = function EventCalendarTimeline(props) {
6016
6111
  role: "presentation"
6017
6112
  }, generateListSectionUi()))))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("td", {
6018
6113
  role: "presentation",
6019
- className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_7__.combinedCls)('custom-event-tl-table__timeline-divider', tableListDividerClassName)
6114
+ className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_7__.combinedCls)('custom-event-tl-table__timeline-divider', tableListDividerClassName, ENABLE_HEADER_RESIZE ? 'custom-event-tl-table__timeline-divider--resizable' : ''),
6115
+ onMouseDown: ENABLE_HEADER_RESIZE ? handleHeaderResizeStart : undefined,
6116
+ onTouchStart: ENABLE_HEADER_RESIZE ? handleHeaderResizeTouchStart : undefined,
6117
+ style: ENABLE_HEADER_RESIZE ? {
6118
+ cursor: 'col-resize',
6119
+ userSelect: 'none'
6120
+ } : undefined
6020
6121
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", null)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("td", {
6021
6122
  role: "presentation",
6022
6123
  className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_7__.combinedCls)(tableListEndClassName)
@@ -0,0 +1,5 @@
1
+ declare type VisibilityCallback = () => void;
2
+ declare type UsePageVisibility = (onVisible?: VisibilityCallback, onHidden?: VisibilityCallback, onPageInit?: VisibilityCallback) => void;
3
+ declare const usePageVisibility: UsePageVisibility;
4
+ export default usePageVisibility;
5
+ export { usePageVisibility };
@@ -0,0 +1,166 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory(require("react"));
4
+ else if(typeof define === 'function' && define.amd)
5
+ define(["react"], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["RPB"] = factory(require("react"));
8
+ else
9
+ root["RPB"] = factory(root["React"]);
10
+ })(this, (__WEBPACK_EXTERNAL_MODULE__787__) => {
11
+ return /******/ (() => { // webpackBootstrap
12
+ /******/ "use strict";
13
+ /******/ var __webpack_modules__ = ({
14
+
15
+ /***/ 787:
16
+ /***/ ((module) => {
17
+
18
+ module.exports = __WEBPACK_EXTERNAL_MODULE__787__;
19
+
20
+ /***/ })
21
+
22
+ /******/ });
23
+ /************************************************************************/
24
+ /******/ // The module cache
25
+ /******/ var __webpack_module_cache__ = {};
26
+ /******/
27
+ /******/ // The require function
28
+ /******/ function __webpack_require__(moduleId) {
29
+ /******/ // Check if module is in cache
30
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
31
+ /******/ if (cachedModule !== undefined) {
32
+ /******/ return cachedModule.exports;
33
+ /******/ }
34
+ /******/ // Create a new module (and put it into the cache)
35
+ /******/ var module = __webpack_module_cache__[moduleId] = {
36
+ /******/ // no module.id needed
37
+ /******/ // no module.loaded needed
38
+ /******/ exports: {}
39
+ /******/ };
40
+ /******/
41
+ /******/ // Execute the module function
42
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
43
+ /******/
44
+ /******/ // Return the exports of the module
45
+ /******/ return module.exports;
46
+ /******/ }
47
+ /******/
48
+ /************************************************************************/
49
+ /******/ /* webpack/runtime/compat get default export */
50
+ /******/ (() => {
51
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
52
+ /******/ __webpack_require__.n = (module) => {
53
+ /******/ var getter = module && module.__esModule ?
54
+ /******/ () => (module['default']) :
55
+ /******/ () => (module);
56
+ /******/ __webpack_require__.d(getter, { a: getter });
57
+ /******/ return getter;
58
+ /******/ };
59
+ /******/ })();
60
+ /******/
61
+ /******/ /* webpack/runtime/define property getters */
62
+ /******/ (() => {
63
+ /******/ // define getter functions for harmony exports
64
+ /******/ __webpack_require__.d = (exports, definition) => {
65
+ /******/ for(var key in definition) {
66
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
67
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
68
+ /******/ }
69
+ /******/ }
70
+ /******/ };
71
+ /******/ })();
72
+ /******/
73
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
74
+ /******/ (() => {
75
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
76
+ /******/ })();
77
+ /******/
78
+ /******/ /* webpack/runtime/make namespace object */
79
+ /******/ (() => {
80
+ /******/ // define __esModule on exports
81
+ /******/ __webpack_require__.r = (exports) => {
82
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
83
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
84
+ /******/ }
85
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
86
+ /******/ };
87
+ /******/ })();
88
+ /******/
89
+ /************************************************************************/
90
+ var __webpack_exports__ = {};
91
+ // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
92
+ (() => {
93
+ __webpack_require__.r(__webpack_exports__);
94
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
95
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
96
+ /* harmony export */ "usePageVisibility": () => (/* binding */ usePageVisibility)
97
+ /* harmony export */ });
98
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(787);
99
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
100
+ /**
101
+ * Watch for to know when a document becomes visible or hidden
102
+ * @param onVisible
103
+ * @param onHidden
104
+ * @param onPageInit executed once when the page first loads visibly
105
+ */
106
+ /*
107
+ @usage:
108
+
109
+ const App = () => {
110
+ usePageVisibility(
111
+ () => console.log("🍏 Page is now visible — current tab is active."),
112
+ () => console.log("🍎 Page is hidden — switched to another tab or minimized."),
113
+ () => console.log("🎬 Page initialized while visible.")
114
+ );
115
+
116
+ return <div>Try switching tabs to see the console output.</div>;
117
+ };
118
+
119
+ */
120
+
121
+ var usePageVisibility = function usePageVisibility(onVisible, onHidden, onPageInit) {
122
+ var visibleRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(document.visibilityState === "visible");
123
+ var onVisibleRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(onVisible);
124
+ var onHiddenRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(onHidden);
125
+ var initialVisibleTriggeredRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(false);
126
+ var onPageInitRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(onPageInit);
127
+ (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
128
+ onVisibleRef.current = onVisible;
129
+ }, [onVisible]);
130
+ (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
131
+ onHiddenRef.current = onHidden;
132
+ }, [onHidden]);
133
+ (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
134
+ onPageInitRef.current = onPageInit;
135
+ }, [onPageInit]);
136
+ (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
137
+ var handleVisibilityChange = function handleVisibilityChange() {
138
+ var isVisible = document.visibilityState === "visible";
139
+ if (isVisible && !visibleRef.current) {
140
+ onVisibleRef.current && onVisibleRef.current();
141
+ }
142
+ if (!isVisible && visibleRef.current) {
143
+ onHiddenRef.current && onHiddenRef.current();
144
+ }
145
+ visibleRef.current = isVisible;
146
+ };
147
+
148
+ // It retains the original switching monitor, and can ensure that onPageInit will run when the first screen is loaded.
149
+ if (visibleRef.current && !initialVisibleTriggeredRef.current) {
150
+ initialVisibleTriggeredRef.current = true;
151
+ onPageInitRef.current && onPageInitRef.current();
152
+ }
153
+ document.addEventListener("visibilitychange", handleVisibilityChange);
154
+ return function () {
155
+ document.removeEventListener("visibilitychange", handleVisibilityChange);
156
+ };
157
+ }, []);
158
+ };
159
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (usePageVisibility);
160
+
161
+ })();
162
+
163
+ /******/ return __webpack_exports__;
164
+ /******/ })()
165
+ ;
166
+ });