funda-ui 4.7.711 → 4.7.730
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/DragDropList/index.d.ts +1 -0
- package/DragDropList/index.js +143 -52
- package/DynamicFields/index.d.ts +1 -0
- package/DynamicFields/index.js +108 -8
- package/EventCalendarTimeline/index.css +12 -1
- package/EventCalendarTimeline/index.d.ts +1 -0
- package/EventCalendarTimeline/index.js +99 -6
- package/MultipleSelect/index.js +162 -71
- package/Table/index.css +5 -1
- package/Table/index.js +410 -90
- package/Utils/useBoundedDrag.d.ts +1 -0
- package/Utils/useBoundedDrag.js +124 -39
- package/lib/cjs/DragDropList/index.d.ts +1 -0
- package/lib/cjs/DragDropList/index.js +143 -52
- package/lib/cjs/DynamicFields/index.d.ts +1 -0
- package/lib/cjs/DynamicFields/index.js +108 -8
- package/lib/cjs/EventCalendarTimeline/index.d.ts +1 -0
- package/lib/cjs/EventCalendarTimeline/index.js +99 -6
- package/lib/cjs/MultipleSelect/index.js +162 -71
- package/lib/cjs/Table/index.js +410 -90
- package/lib/cjs/Utils/useBoundedDrag.d.ts +1 -0
- package/lib/cjs/Utils/useBoundedDrag.js +124 -39
- package/lib/css/EventCalendarTimeline/index.css +12 -1
- package/lib/css/Table/index.css +5 -1
- package/lib/esm/DragDropList/index.tsx +23 -16
- package/lib/esm/DynamicFields/index.tsx +107 -8
- package/lib/esm/EventCalendarTimeline/index.scss +15 -1
- package/lib/esm/EventCalendarTimeline/index.tsx +130 -11
- package/lib/esm/ModalDialog/index.tsx +0 -1
- package/lib/esm/Table/Table.tsx +9 -7
- package/lib/esm/Table/TableRow.tsx +9 -3
- package/lib/esm/Table/index.scss +8 -2
- package/lib/esm/Table/utils/DragHandleSprite.tsx +6 -2
- package/lib/esm/Table/utils/func.ts +12 -1
- package/lib/esm/Table/utils/hooks/useTableDraggable.tsx +401 -93
- package/lib/esm/Utils/hooks/useBoundedDrag.tsx +142 -39
- package/package.json +1 -1
package/DragDropList/index.d.ts
CHANGED
package/DragDropList/index.js
CHANGED
|
@@ -895,6 +895,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
895
895
|
dragHandleSelector = _options$dragHandleSe === void 0 ? '.custom-draggable-list__handle' : _options$dragHandleSe,
|
|
896
896
|
onDragStart = options.onDragStart,
|
|
897
897
|
onDragOver = options.onDragOver,
|
|
898
|
+
onDragUpdate = options.onDragUpdate,
|
|
898
899
|
onDragEnd = options.onDragEnd;
|
|
899
900
|
var _useState = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)(false),
|
|
900
901
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -903,11 +904,35 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
903
904
|
var dragItem = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
|
|
904
905
|
var dragOverItem = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
|
|
905
906
|
var dragNode = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
|
|
907
|
+
var draggedElement = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
|
|
908
|
+
var boundaryElement = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
|
|
906
909
|
var touchOffset = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)({
|
|
907
910
|
x: 0,
|
|
908
911
|
y: 0
|
|
909
912
|
});
|
|
910
913
|
var currentHoverItem = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
|
|
914
|
+
var rafId = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
|
|
915
|
+
var lastUpdateDragIndex = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
|
|
916
|
+
var lastUpdateDropIndex = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* Performance Note:
|
|
920
|
+
*
|
|
921
|
+
* Drag-over events can fire at a very high frequency, especially on touch devices
|
|
922
|
+
* or when dragging quickly. Directly performing DOM read/write operations in the
|
|
923
|
+
* event handler (e.g. `getBoundingClientRect`, `classList` changes, style updates)
|
|
924
|
+
* can easily cause layout thrashing and frame drops when there are many items.
|
|
925
|
+
*
|
|
926
|
+
* To mitigate this, we:
|
|
927
|
+
* - Collect the pointer coordinates synchronously in the event handler.
|
|
928
|
+
* - Schedule all DOM-intensive work inside `requestAnimationFrame`, so the browser
|
|
929
|
+
* batches these operations before the next paint.
|
|
930
|
+
* - Cancel any pending frame (`cancelAnimationFrame`) before scheduling a new one,
|
|
931
|
+
* ensuring there is at most one pending DOM update per frame.
|
|
932
|
+
*
|
|
933
|
+
* This keeps drag interactions smooth even with large lists.
|
|
934
|
+
*/
|
|
935
|
+
|
|
911
936
|
var handleDragStart = function handleDragStart(e, position) {
|
|
912
937
|
var isTouch = ('touches' in e);
|
|
913
938
|
var target = e.target;
|
|
@@ -960,69 +985,127 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
960
985
|
opacity: '0.9'
|
|
961
986
|
});
|
|
962
987
|
document.body.appendChild(dragNode.current);
|
|
988
|
+
|
|
989
|
+
// Keep track of the original element (acts as a placeholder inside the list)
|
|
990
|
+
draggedElement.current = listItem;
|
|
991
|
+
boundaryElement.current = boundary;
|
|
963
992
|
setIsDragging(true);
|
|
964
993
|
listItem.classList.add('dragging-placeholder');
|
|
965
994
|
} else {
|
|
966
|
-
//
|
|
995
|
+
// Desktop: use native drag image, but still record dragged element / boundary
|
|
996
|
+
draggedElement.current = listItem;
|
|
997
|
+
boundaryElement.current = boundary;
|
|
998
|
+
setIsDragging(true);
|
|
999
|
+
var dragEvent = e;
|
|
1000
|
+
if (dragEvent.dataTransfer) {
|
|
1001
|
+
dragEvent.dataTransfer.effectAllowed = 'move';
|
|
1002
|
+
// Optional: customize drag preview if needed
|
|
1003
|
+
dragEvent.dataTransfer.setData('text/plain', '');
|
|
1004
|
+
}
|
|
1005
|
+
listItem.classList.add('dragging-placeholder');
|
|
967
1006
|
}
|
|
968
1007
|
};
|
|
969
1008
|
var handleDragOver = function handleDragOver(e) {
|
|
1009
|
+
// Always prevent default synchronously
|
|
970
1010
|
e.preventDefault();
|
|
971
1011
|
var isTouch = ('touches' in e);
|
|
972
1012
|
if (!isTouch) {
|
|
973
1013
|
e.dataTransfer.dropEffect = 'move';
|
|
974
1014
|
}
|
|
975
1015
|
|
|
976
|
-
//
|
|
977
|
-
var
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1016
|
+
// Extract primitive coordinates synchronously to avoid using pooled events in async callbacks
|
|
1017
|
+
var clientX;
|
|
1018
|
+
var clientY;
|
|
1019
|
+
if (isTouch) {
|
|
1020
|
+
var touch = e.touches[0];
|
|
1021
|
+
clientX = touch.clientX;
|
|
1022
|
+
clientY = touch.clientY;
|
|
1023
|
+
} else {
|
|
1024
|
+
clientX = e.clientX;
|
|
1025
|
+
clientY = e.clientY;
|
|
1026
|
+
}
|
|
981
1027
|
|
|
982
|
-
//
|
|
983
|
-
if (
|
|
984
|
-
|
|
985
|
-
dragNode.current.style.top = "".concat(point.clientY - touchOffset.current.y, "px");
|
|
1028
|
+
// Cancel any pending frame to avoid stacking DOM operations
|
|
1029
|
+
if (rafId.current !== null) {
|
|
1030
|
+
cancelAnimationFrame(rafId.current);
|
|
986
1031
|
}
|
|
1032
|
+
rafId.current = requestAnimationFrame(function () {
|
|
1033
|
+
// Update dragged element position for touch events
|
|
1034
|
+
if (isTouch && isDragging && dragNode.current) {
|
|
1035
|
+
dragNode.current.style.left = "".concat(clientX - touchOffset.current.x, "px");
|
|
1036
|
+
dragNode.current.style.top = "".concat(clientY - touchOffset.current.y, "px");
|
|
1037
|
+
}
|
|
987
1038
|
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1039
|
+
// Find the element below the pointer/touch
|
|
1040
|
+
var elemBelow = document.elementFromPoint(clientX, clientY);
|
|
1041
|
+
if (!elemBelow) return;
|
|
991
1042
|
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1043
|
+
// Find the closest list item
|
|
1044
|
+
var listItem = elemBelow.closest(itemSelector);
|
|
1045
|
+
if (!listItem) return;
|
|
995
1046
|
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1047
|
+
// Check boundary
|
|
1048
|
+
var boundary = boundaryElement.current || listItem.closest(boundarySelector);
|
|
1049
|
+
if (!boundary) return;
|
|
999
1050
|
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
listItem.
|
|
1018
|
-
|
|
1019
|
-
|
|
1051
|
+
// Update hover states
|
|
1052
|
+
if (currentHoverItem.current && currentHoverItem.current !== listItem) {
|
|
1053
|
+
currentHoverItem.current.classList.remove('drag-over', 'drag-over-top', 'drag-over-bottom');
|
|
1054
|
+
}
|
|
1055
|
+
currentHoverItem.current = listItem;
|
|
1056
|
+
listItem.classList.add('drag-over');
|
|
1057
|
+
var dragEl = draggedElement.current;
|
|
1058
|
+
if (!dragEl || !dragEl.parentNode) return;
|
|
1059
|
+
var container = boundary;
|
|
1060
|
+
|
|
1061
|
+
// Collect current ordered items in the container
|
|
1062
|
+
var children = Array.from(container.querySelectorAll(itemSelector));
|
|
1063
|
+
var currentIndex = children.indexOf(dragEl);
|
|
1064
|
+
var targetIndex = children.indexOf(listItem);
|
|
1065
|
+
if (currentIndex === -1 || targetIndex === -1) return;
|
|
1066
|
+
|
|
1067
|
+
// Determine drop position (top/bottom)
|
|
1068
|
+
var rect = listItem.getBoundingClientRect();
|
|
1069
|
+
var middleY = rect.top + rect.height / 2;
|
|
1070
|
+
listItem.classList.remove('drag-over-top', 'drag-over-bottom');
|
|
1071
|
+
var insertBefore = clientY < middleY ? listItem : listItem.nextElementSibling;
|
|
1072
|
+
if (clientY < middleY) {
|
|
1073
|
+
listItem.classList.add('drag-over-top');
|
|
1074
|
+
} else {
|
|
1075
|
+
listItem.classList.add('drag-over-bottom');
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
// Only move in DOM when the effective position changes
|
|
1079
|
+
if (insertBefore !== dragEl && container.contains(dragEl)) {
|
|
1080
|
+
container.insertBefore(dragEl, insertBefore);
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
// Recompute index after DOM move
|
|
1084
|
+
var reorderedChildren = Array.from(container.querySelectorAll(itemSelector));
|
|
1085
|
+
var newIndex = reorderedChildren.indexOf(dragEl);
|
|
1086
|
+
dragOverItem.current = newIndex;
|
|
1087
|
+
onDragOver === null || onDragOver === void 0 ? void 0 : onDragOver(dragItem.current, dragOverItem.current);
|
|
1088
|
+
|
|
1089
|
+
// Only fire onDragUpdate when the (dragIndex, dropIndex) pair actually changes.
|
|
1090
|
+
if (onDragUpdate && (dragItem.current !== lastUpdateDragIndex.current || dragOverItem.current !== lastUpdateDropIndex.current)) {
|
|
1091
|
+
lastUpdateDragIndex.current = dragItem.current;
|
|
1092
|
+
lastUpdateDropIndex.current = dragOverItem.current;
|
|
1093
|
+
onDragUpdate(dragItem.current, dragOverItem.current);
|
|
1094
|
+
}
|
|
1095
|
+
rafId.current = null;
|
|
1096
|
+
});
|
|
1020
1097
|
};
|
|
1021
1098
|
var handleDragEnd = function handleDragEnd(e) {
|
|
1022
1099
|
var isTouch = ('touches' in e);
|
|
1023
1100
|
if (isTouch && !isDragging) return;
|
|
1024
1101
|
onDragEnd === null || onDragEnd === void 0 ? void 0 : onDragEnd(dragItem.current, dragOverItem.current);
|
|
1025
1102
|
|
|
1103
|
+
// Cancel any pending animation frame
|
|
1104
|
+
if (rafId.current !== null) {
|
|
1105
|
+
cancelAnimationFrame(rafId.current);
|
|
1106
|
+
rafId.current = null;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1026
1109
|
// Cleanup
|
|
1027
1110
|
if (dragNode.current) {
|
|
1028
1111
|
dragNode.current.remove();
|
|
@@ -1036,6 +1119,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
1036
1119
|
currentHoverItem.current = null;
|
|
1037
1120
|
dragItem.current = null;
|
|
1038
1121
|
dragOverItem.current = null;
|
|
1122
|
+
draggedElement.current = null;
|
|
1123
|
+
boundaryElement.current = null;
|
|
1039
1124
|
};
|
|
1040
1125
|
return {
|
|
1041
1126
|
isDragging: isDragging,
|
|
@@ -1366,6 +1451,9 @@ var DragDropList = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef
|
|
|
1366
1451
|
onDragOver: function onDragOver(dragIndex, dropIndex) {
|
|
1367
1452
|
// Additional drag over logic if needed
|
|
1368
1453
|
},
|
|
1454
|
+
onDragUpdate: function onDragUpdate(dragIndex, dropIndex) {
|
|
1455
|
+
// console.log(dragIndex, dropIndex);
|
|
1456
|
+
},
|
|
1369
1457
|
onDragEnd: function onDragEnd(dragIndex, dropIndex) {
|
|
1370
1458
|
if (dragIndex !== null && dropIndex !== null && dragIndex !== dropIndex) {
|
|
1371
1459
|
var _newItems$dragIndex, _newItems$dragIndex2, _newItems$dropIndex;
|
|
@@ -1398,12 +1486,12 @@ var DragDropList = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef
|
|
|
1398
1486
|
});
|
|
1399
1487
|
|
|
1400
1488
|
// Calculate new insert position
|
|
1489
|
+
// Directly use dropIndex as the insertion position to avoid items snapping back
|
|
1490
|
+
// when dragging an item from above to directly below its neighbor.
|
|
1401
1491
|
var insertIndex = dropIndex;
|
|
1402
|
-
if (dropIndex > dragIndex) {
|
|
1403
|
-
insertIndex -= itemsToMove.length;
|
|
1404
|
-
}
|
|
1405
1492
|
|
|
1406
|
-
// Insert all items
|
|
1493
|
+
// Insert all items (remove first, then insert at the target index;
|
|
1494
|
+
// JavaScript's splice will handle index shifting automatically).
|
|
1407
1495
|
newItems.splice.apply(newItems, [insertIndex, 0].concat(_toConsumableArray(itemsBeingMoved)));
|
|
1408
1496
|
|
|
1409
1497
|
// Rebuild tree structure
|
|
@@ -1516,6 +1604,9 @@ var DragDropList = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef
|
|
|
1516
1604
|
// If the item should be hidden, the rendering is skipped
|
|
1517
1605
|
if (!shouldShowItem(item)) return null;
|
|
1518
1606
|
|
|
1607
|
+
// Item level draggable control, default true when not specified
|
|
1608
|
+
var isItemDraggable = draggable && item.itemDraggable !== false;
|
|
1609
|
+
|
|
1519
1610
|
// collapse
|
|
1520
1611
|
var hasChildItems = hasChildren(item.id);
|
|
1521
1612
|
var isCollapsed = collapsedItems.has(item.id);
|
|
@@ -1529,30 +1620,30 @@ var DragDropList = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef
|
|
|
1529
1620
|
"data-listitemlabel": item.listItemLabel,
|
|
1530
1621
|
className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.combinedCls)("".concat(prefix, "-draggable-list__item"), (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_2__.clsWrite)(dragMode, 'handle'), {
|
|
1531
1622
|
'disabled': item.disabled,
|
|
1532
|
-
'draggable':
|
|
1623
|
+
'draggable': isItemDraggable,
|
|
1533
1624
|
'editing': editingItem === item.id,
|
|
1534
1625
|
// collapse
|
|
1535
1626
|
'has-children': hasChildItems,
|
|
1536
1627
|
'collapsed': isCollapsed
|
|
1537
1628
|
}),
|
|
1538
|
-
draggable: !
|
|
1539
|
-
onDragStart: !
|
|
1629
|
+
draggable: !isItemDraggable ? undefined : editingItem !== item.id && "true",
|
|
1630
|
+
onDragStart: !isItemDraggable ? undefined : function (e) {
|
|
1540
1631
|
return dragHandlers.handleDragStart(e, index);
|
|
1541
1632
|
},
|
|
1542
|
-
onDragOver: !
|
|
1543
|
-
onDragEnd: !
|
|
1544
|
-
onTouchStart: !
|
|
1633
|
+
onDragOver: !isItemDraggable ? undefined : dragHandlers.handleDragOver,
|
|
1634
|
+
onDragEnd: !isItemDraggable ? undefined : dragHandlers.handleDragEnd,
|
|
1635
|
+
onTouchStart: !isItemDraggable ? undefined : function (e) {
|
|
1545
1636
|
return dragHandlers.handleDragStart(e, index);
|
|
1546
1637
|
},
|
|
1547
|
-
onTouchMove: !
|
|
1548
|
-
onTouchEnd: !
|
|
1638
|
+
onTouchMove: !isItemDraggable ? undefined : dragHandlers.handleDragOver,
|
|
1639
|
+
onTouchEnd: !isItemDraggable ? undefined : dragHandlers.handleDragEnd,
|
|
1549
1640
|
style: itemStyle,
|
|
1550
1641
|
onDoubleClick: function onDoubleClick() {
|
|
1551
1642
|
return handleDoubleClick(item);
|
|
1552
1643
|
}
|
|
1553
1644
|
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1554
1645
|
className: "".concat(prefix, "-draggable-list__itemcontent")
|
|
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,
|
|
1646
|
+
}, renderOption ? renderOption(item, isItemDraggable ? "".concat(prefix, "-draggable-list__handle") : '', index) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, isItemDraggable && !handleHide ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("span", {
|
|
1556
1647
|
className: "".concat(prefix, "-draggable-list__handle ").concat(handlePos !== null && handlePos !== void 0 ? handlePos : 'left'),
|
|
1557
1648
|
draggable: dragMode === 'handle',
|
|
1558
1649
|
dangerouslySetInnerHTML: {
|
package/DynamicFields/index.d.ts
CHANGED
|
@@ -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;
|
package/DynamicFields/index.js
CHANGED
|
@@ -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
|
|
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(
|
|
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'),
|
|
@@ -235,7 +235,7 @@
|
|
|
235
235
|
}
|
|
236
236
|
*/
|
|
237
237
|
/* cell */
|
|
238
|
-
/* header */
|
|
238
|
+
/* The width of the left column header */
|
|
239
239
|
/* event container */
|
|
240
240
|
/* days container */
|
|
241
241
|
/* remove empty cells */
|
|
@@ -466,10 +466,21 @@
|
|
|
466
466
|
background-color: var(--custom-event-tl-table-divider-bg);
|
|
467
467
|
border-left: var(--custom-event-tl-table-divider-border);
|
|
468
468
|
border-right: var(--custom-event-tl-table-divider-border);
|
|
469
|
+
position: relative;
|
|
469
470
|
}
|
|
470
471
|
.custom-event-tl-table__timeline-table__wrapper .custom-event-tl-table__timeline-divider > div {
|
|
471
472
|
width: var(--custom-event-tl-table-divider-w);
|
|
472
473
|
}
|
|
474
|
+
.custom-event-tl-table__timeline-table__wrapper .custom-event-tl-table__timeline-divider--resizable {
|
|
475
|
+
cursor: col-resize;
|
|
476
|
+
user-select: none;
|
|
477
|
+
}
|
|
478
|
+
.custom-event-tl-table__timeline-table__wrapper .custom-event-tl-table__timeline-divider--resizable:hover {
|
|
479
|
+
background-color: rgba(0, 0, 0, 0.05);
|
|
480
|
+
}
|
|
481
|
+
.custom-event-tl-table__timeline-table__wrapper .custom-event-tl-table__timeline-divider--resizable:active {
|
|
482
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
483
|
+
}
|
|
473
484
|
.custom-event-tl-table__timeline-table__wrapper .custom-event-tl-table__cell-cushion {
|
|
474
485
|
padding: var(--custom-event-tl-table-cell-padding);
|
|
475
486
|
}
|
|
@@ -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;
|