pixelize-design-library 2.2.196 → 2.2.198
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.
|
@@ -70,6 +70,7 @@ var OverflowTooltipText_1 = __importDefault(require("../SideBar/components/Overf
|
|
|
70
70
|
var Button_1 = __importDefault(require("../Button/Button"));
|
|
71
71
|
/** Narrow rail width when a column is horizontally collapsed. */
|
|
72
72
|
var COLLAPSED_KANBAN_COLUMN_WIDTH = "2.75rem";
|
|
73
|
+
var KANBAN_CARD_GAP = 12;
|
|
73
74
|
var KanbanRow = react_1.default.memo(function (_a) {
|
|
74
75
|
var index = _a.index, style = _a.style, data = _a.data;
|
|
75
76
|
var items = data.items, colId = data.colId, canDrag = data.canDrag, expanded = data.expanded, onDelete = data.onDelete, onOpen = data.onOpen, canDelete = data.canDelete, setSize = data.setSize, toggleExpand = data.toggleExpand;
|
|
@@ -78,8 +79,8 @@ var KanbanRow = react_1.default.memo(function (_a) {
|
|
|
78
79
|
return react_1.default.createElement("div", { style: style });
|
|
79
80
|
}
|
|
80
81
|
return (react_1.default.createElement("div", { style: style },
|
|
81
|
-
react_1.default.createElement(
|
|
82
|
-
react_1.default.createElement(
|
|
82
|
+
react_1.default.createElement("div", { style: { paddingBottom: KANBAN_CARD_GAP } },
|
|
83
|
+
react_1.default.createElement(MeasuredItem_1.default, { index: index, setSize: function (i, h) { return setSize(i, h, colId); } },
|
|
83
84
|
react_1.default.createElement(dnd_1.Draggable, { draggableId: account.id.toString(), index: index, key: account.id, isDragDisabled: !canDrag }, function (provided) {
|
|
84
85
|
var _a;
|
|
85
86
|
return (react_1.default.createElement("div", __assign({ ref: provided.innerRef }, provided.draggableProps, provided.dragHandleProps, { style: provided.draggableProps.style }), (account === null || account === void 0 ? void 0 : account.customNode) ? (_a = account === null || account === void 0 ? void 0 : account.customNode) === null || _a === void 0 ? void 0 : _a.call(account) : (react_1.default.createElement(AccountCard_1.default, { key: account.id, account: account, index: index, onDelete: onDelete, onOpen: onOpen, isExpanded: expanded[account.id], onToggleExpand: function () {
|
|
@@ -247,7 +248,8 @@ var KanbanBoard = function (_a) {
|
|
|
247
248
|
return changed ? pruned : prev;
|
|
248
249
|
});
|
|
249
250
|
}, [columns]);
|
|
250
|
-
|
|
251
|
+
// AccountCard's minHeight floor — kept tight so unmeasured rows don't reserve excess space; KANBAN_CARD_GAP is added below.
|
|
252
|
+
var DEFAULT_ITEM_HEIGHT = 80;
|
|
251
253
|
// update height for an item
|
|
252
254
|
var setSize = (0, react_1.useCallback)(function (index, size, colId) {
|
|
253
255
|
var key = "".concat(colId, "-").concat(index);
|
|
@@ -263,7 +265,7 @@ var KanbanBoard = function (_a) {
|
|
|
263
265
|
}, []);
|
|
264
266
|
var getItemSize = (0, react_1.useCallback)(function (index, _items, colId) {
|
|
265
267
|
var key = "".concat(colId, "-").concat(index);
|
|
266
|
-
return (sizes[key] || DEFAULT_ITEM_HEIGHT) +
|
|
268
|
+
return (sizes[key] || DEFAULT_ITEM_HEIGHT) + KANBAN_CARD_GAP;
|
|
267
269
|
}, [sizes]);
|
|
268
270
|
// Calculate container height
|
|
269
271
|
(0, react_1.useEffect)(function () {
|
|
@@ -360,7 +362,7 @@ var KanbanBoard = function (_a) {
|
|
|
360
362
|
var renderColumnDroppable = function (colId, column, columnDragHandleProps, isColCollapsed) { return (react_1.default.createElement(dnd_1.Droppable, { droppableId: colId, key: colId, mode: virtualization ? "virtual" : "standard", renderClone: function (provided, _snapshot, rubric) {
|
|
361
363
|
var _a;
|
|
362
364
|
var item = column.items[rubric.source.index];
|
|
363
|
-
return (react_1.default.createElement("div", __assign({ ref: provided.innerRef }, provided.draggableProps, provided.dragHandleProps, { style: __assign(__assign({}, provided.draggableProps.style), { width: columnWidth,
|
|
365
|
+
return (react_1.default.createElement("div", __assign({ ref: provided.innerRef }, provided.draggableProps, provided.dragHandleProps, { style: __assign(__assign({}, provided.draggableProps.style), { width: columnWidth, paddingBottom: KANBAN_CARD_GAP }) }), (item === null || item === void 0 ? void 0 : item.customNode) ? (_a = item === null || item === void 0 ? void 0 : item.customNode) === null || _a === void 0 ? void 0 : _a.call(item) : (react_1.default.createElement(AccountCard_1.default, { key: item.id, account: item, index: rubric.source.index, onDelete: onDelete, onOpen: onOpen, isExpanded: expanded[item.id], onToggleExpand: function () {
|
|
364
366
|
return toggleExpand(item.id, colId, rubric.source.index);
|
|
365
367
|
}, isDeletable: canDelete }))));
|
|
366
368
|
} }, function (provided, snapshot) {
|
|
@@ -439,7 +441,7 @@ var KanbanBoard = function (_a) {
|
|
|
439
441
|
(snapshot.isUsingPlaceholder ? 1 : 0), itemSize: function (index) {
|
|
440
442
|
return getItemSize(index, column.items, colId);
|
|
441
443
|
}, width: "100%", itemData: __assign(__assign({}, rowBaseProps), { items: column.items, colId: colId }) }, KanbanRow)) : (react_1.default.createElement(react_2.Box, null,
|
|
442
|
-
column.items.map(function (account, index) { return (react_1.default.createElement("div", { key: account.id, style: {
|
|
444
|
+
column.items.map(function (account, index) { return (react_1.default.createElement("div", { key: account.id, style: { paddingBottom: KANBAN_CARD_GAP } },
|
|
443
445
|
react_1.default.createElement(dnd_1.Draggable, { draggableId: account.id.toString(), index: index, key: account.id, isDragDisabled: !canDrag }, function (dragProvided) {
|
|
444
446
|
var _a;
|
|
445
447
|
return (react_1.default.createElement("div", __assign({ ref: dragProvided.innerRef }, dragProvided.draggableProps, dragProvided.dragHandleProps, { style: dragProvided.draggableProps.style }), (account === null || account === void 0 ? void 0 : account.customNode) ? (_a = account === null || account === void 0 ? void 0 : account.customNode) === null || _a === void 0 ? void 0 : _a.call(account) : (react_1.default.createElement(AccountCard_1.default, { account: account, index: index, onDelete: onDelete, onOpen: onOpen, isExpanded: expanded[account.id], onToggleExpand: function () {
|
|
@@ -38,19 +38,26 @@ var MeasuredItem = function (_a) {
|
|
|
38
38
|
var index = _a.index, setSize = _a.setSize, children = _a.children;
|
|
39
39
|
var ref = (0, react_1.useRef)(null);
|
|
40
40
|
var prevHeight = (0, react_1.useRef)(null);
|
|
41
|
+
// Stable ref to the latest setSize so we don't tear down the ResizeObserver on every render.
|
|
42
|
+
var setSizeRef = (0, react_1.useRef)(setSize);
|
|
43
|
+
setSizeRef.current = setSize;
|
|
44
|
+
var indexRef = (0, react_1.useRef)(index);
|
|
45
|
+
indexRef.current = index;
|
|
41
46
|
var measure = function () {
|
|
42
47
|
if (ref.current) {
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
// offsetHeight is the integer border-box layout height — more reliable than getBoundingClientRect for our purposes.
|
|
49
|
+
var height = ref.current.offsetHeight;
|
|
50
|
+
if (height > 0 && prevHeight.current !== height) {
|
|
45
51
|
prevHeight.current = height;
|
|
46
|
-
|
|
52
|
+
setSizeRef.current(indexRef.current, height);
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
55
|
};
|
|
50
56
|
(0, react_1.useLayoutEffect)(function () {
|
|
51
|
-
var element = ref.current;
|
|
52
|
-
// Initial measure
|
|
57
|
+
var element = ref.current;
|
|
53
58
|
measure();
|
|
59
|
+
// A second measure after paint catches any layout that finishes after the synchronous tick (font loads, async CSS, etc).
|
|
60
|
+
var raf = requestAnimationFrame(measure);
|
|
54
61
|
var ro;
|
|
55
62
|
if (typeof ResizeObserver !== "undefined" && element) {
|
|
56
63
|
ro = new ResizeObserver(function () {
|
|
@@ -59,18 +66,24 @@ var MeasuredItem = function (_a) {
|
|
|
59
66
|
ro.observe(element);
|
|
60
67
|
}
|
|
61
68
|
else {
|
|
62
|
-
// Fallback for browsers without ResizeObserver
|
|
63
69
|
window.addEventListener("resize", measure);
|
|
64
70
|
}
|
|
65
71
|
return function () {
|
|
66
|
-
|
|
72
|
+
cancelAnimationFrame(raf);
|
|
67
73
|
if (ro && element)
|
|
68
74
|
ro.unobserve(element);
|
|
69
75
|
if (!ro)
|
|
70
76
|
window.removeEventListener("resize", measure);
|
|
71
77
|
};
|
|
78
|
+
// Intentionally empty deps — setSize/index are read through refs so the observer is set up exactly once per mount.
|
|
72
79
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
73
|
-
}, [
|
|
80
|
+
}, []);
|
|
81
|
+
// If index changes for the same DOM node (item shuffled), re-report the cached size under the new index.
|
|
82
|
+
(0, react_1.useEffect)(function () {
|
|
83
|
+
if (prevHeight.current != null) {
|
|
84
|
+
setSizeRef.current(indexRef.current, prevHeight.current);
|
|
85
|
+
}
|
|
86
|
+
}, [index]);
|
|
74
87
|
return react_1.default.createElement("div", { ref: ref }, children);
|
|
75
88
|
};
|
|
76
89
|
exports.default = MeasuredItem;
|