@pega/lists-react 9.0.0-build.6.8 → 9.0.0-build.7.0
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/lib/Core/Components/AggregateMenu.d.ts +1 -0
- package/lib/Core/Components/AggregateMenu.d.ts.map +1 -1
- package/lib/Core/Components/AggregateMenu.js +26 -16
- package/lib/Core/Components/AggregateMenu.js.map +1 -1
- package/lib/Core/Components/ContextMenu/ContextMenuContainer.d.ts.map +1 -1
- package/lib/Core/Components/ContextMenu/ContextMenuContainer.js +4 -2
- package/lib/Core/Components/ContextMenu/ContextMenuContainer.js.map +1 -1
- package/lib/Core/Components/GroupRenderer.d.ts +16 -0
- package/lib/Core/Components/GroupRenderer.d.ts.map +1 -1
- package/lib/Core/Components/GroupRenderer.js +112 -4
- package/lib/Core/Components/GroupRenderer.js.map +1 -1
- package/lib/Core/Components/Grouping/GroupingMenu.js +1 -1
- package/lib/Core/Components/Grouping/GroupingMenu.js.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/DateFunctionSelector.js +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/DateFunctionSelector.js.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/GroupRenderer.js +1 -1
- package/lib/Core/Components/Toolbar/hooks/useGroup/GroupRenderer.js.map +1 -1
- package/lib/Core/Components/Toolbar/hooks/useSort/Row.js +1 -1
- package/lib/Core/Components/Toolbar/hooks/useSort/Row.js.map +1 -1
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.d.ts +97 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.js +249 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/VariableHeightVirtualizer.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useChildrenHeightResizeObserver.d.ts +22 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useChildrenHeightResizeObserver.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useChildrenHeightResizeObserver.js +38 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useChildrenHeightResizeObserver.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useLoaderPositioning.d.ts +22 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useLoaderPositioning.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useLoaderPositioning.js +45 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useLoaderPositioning.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/usePagination.d.ts +49 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/usePagination.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/usePagination.js +55 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/usePagination.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useScroll.d.ts +21 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useScroll.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useScroll.js +39 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useScroll.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useVirtualizerItemCount.d.ts +38 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useVirtualizerItemCount.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useVirtualizerItemCount.js +62 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/useVirtualizerItemCount.js.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/utils.d.ts +112 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/utils.d.ts.map +1 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/utils.js +213 -0
- package/lib/Core/Components/Virtualise/VariableHeightVirtualizer/utils.js.map +1 -0
- package/lib/Core/Components/Virtualise/utility.d.ts +1 -1
- package/lib/Core/Components/Virtualise/utility.d.ts.map +1 -1
- package/lib/Core/Components/Virtualise/utility.js +3 -2
- package/lib/Core/Components/Virtualise/utility.js.map +1 -1
- package/lib/Core/Hooks/useDragDrop.d.ts.map +1 -1
- package/lib/Core/Hooks/useDragDrop.js +2 -0
- package/lib/Core/Hooks/useDragDrop.js.map +1 -1
- package/lib/Core/Localization/defaultTranslations.d.ts +1 -0
- package/lib/Core/Localization/defaultTranslations.d.ts.map +1 -1
- package/lib/Core/Localization/defaultTranslations.js +2 -1
- package/lib/Core/Localization/defaultTranslations.js.map +1 -1
- package/lib/Core/Views/Table/Row.d.ts +3 -1
- package/lib/Core/Views/Table/Row.d.ts.map +1 -1
- package/lib/Core/Views/Table/Row.js +5 -3
- package/lib/Core/Views/Table/Row.js.map +1 -1
- package/lib/Core/Views/Table/StyledTableContainer.d.ts.map +1 -1
- package/lib/Core/Views/Table/StyledTableContainer.js +4 -0
- package/lib/Core/Views/Table/StyledTableContainer.js.map +1 -1
- package/lib/Core/Views/Table/VirtualizeWrapper.d.ts +3 -1
- package/lib/Core/Views/Table/VirtualizeWrapper.d.ts.map +1 -1
- package/lib/Core/Views/Table/VirtualizeWrapper.js +18 -2
- package/lib/Core/Views/Table/VirtualizeWrapper.js.map +1 -1
- package/lib/Core/Views/Table/index.d.ts.map +1 -1
- package/lib/Core/Views/Table/index.js +2 -2
- package/lib/Core/Views/Table/index.js.map +1 -1
- package/lib/Core/Views/Table/useCountChange.d.ts +10 -0
- package/lib/Core/Views/Table/useCountChange.d.ts.map +1 -0
- package/lib/Core/Views/Table/useCountChange.js +39 -0
- package/lib/Core/Views/Table/useCountChange.js.map +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { getScrollbarWidth } from 'pega-repeating-structures-core';
|
|
2
|
+
/**
|
|
3
|
+
* Calculates the start and end indices for virtualized pagination in a variable-height list.
|
|
4
|
+
*
|
|
5
|
+
* @returns {{ startIndex: number, endIndex: number }} Object containing the calculated start and end indices for rendering (inclusive both indices).
|
|
6
|
+
*/
|
|
7
|
+
export const getVirtualizedPaginationIndices = (param) => {
|
|
8
|
+
const { totalItemCount, buffer, itemContainerRef, scrollTop, containerRef, itemsHeight, defaultItemHeight, endIndexLimit, isInfiniteMode } = param;
|
|
9
|
+
const minimumItemsToFetchOnTop = buffer * 4;
|
|
10
|
+
if (totalItemCount === 0 || itemContainerRef.current?.childElementCount === 0) {
|
|
11
|
+
return { startIndex: 0, endIndex: minimumItemsToFetchOnTop };
|
|
12
|
+
}
|
|
13
|
+
const viewportHeight = containerRef.current?.clientHeight || 0;
|
|
14
|
+
// Find the first visible item index for the current scroll position
|
|
15
|
+
let aboveTheFoldItemsHeight = 0;
|
|
16
|
+
let visibleStartIndex = 0;
|
|
17
|
+
while (visibleStartIndex < totalItemCount &&
|
|
18
|
+
aboveTheFoldItemsHeight + (itemsHeight[visibleStartIndex] ?? defaultItemHeight) < scrollTop) {
|
|
19
|
+
aboveTheFoldItemsHeight += itemsHeight[visibleStartIndex] ?? defaultItemHeight;
|
|
20
|
+
visibleStartIndex += 1;
|
|
21
|
+
}
|
|
22
|
+
// Find the last visible item index for the current scroll position
|
|
23
|
+
let inViewItemsHeight = 0;
|
|
24
|
+
let visibleEndIndex = visibleStartIndex;
|
|
25
|
+
while (visibleEndIndex < totalItemCount && inViewItemsHeight < viewportHeight) {
|
|
26
|
+
inViewItemsHeight += itemsHeight[visibleEndIndex] ?? defaultItemHeight;
|
|
27
|
+
visibleEndIndex += 1;
|
|
28
|
+
}
|
|
29
|
+
const startIndex = Math.max(0, visibleStartIndex - buffer);
|
|
30
|
+
let endIndex = Math.min(visibleEndIndex + buffer, endIndexLimit - 1);
|
|
31
|
+
if (isInfiniteMode) {
|
|
32
|
+
endIndex = Math.max(endIndex, minimumItemsToFetchOnTop);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// In cases where the count is very less due to filters, we would fetch more items to avoid unnecessary API calls if the count after the filter removed is more
|
|
36
|
+
endIndex = Math.max(Math.min(totalItemCount - 1, endIndex), minimumItemsToFetchOnTop);
|
|
37
|
+
}
|
|
38
|
+
return { startIndex, endIndex };
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Calculates the total buffer height for a list of items, using their individual heights if available,
|
|
42
|
+
* or a default height otherwise.
|
|
43
|
+
*
|
|
44
|
+
* @param totalItemCount - The total number of items in the list.
|
|
45
|
+
* @param itemsHeight - An object or array containing the heights of individual items, indexed by item position.
|
|
46
|
+
* @param defaultItemHeight - The default height to use for items whose height is not specified in `itemsHeight`.
|
|
47
|
+
* @returns The sum of all item heights, using the default height for any missing values.
|
|
48
|
+
*/
|
|
49
|
+
export const calculateTotalBufferHeight = (totalItemCount, itemsHeight, defaultItemHeight) => {
|
|
50
|
+
let totalBufferHeight = 0;
|
|
51
|
+
for (let i = 0; i < totalItemCount; i += 1) {
|
|
52
|
+
totalBufferHeight += itemsHeight[i] || defaultItemHeight;
|
|
53
|
+
}
|
|
54
|
+
return totalBufferHeight;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Returns a CSS-compatible max-height value based on the input.
|
|
58
|
+
*
|
|
59
|
+
* @param viewMaxHeight - The maximum height value, which can be a number (pixels), a string (CSS value), or `null`.
|
|
60
|
+
* @returns A string representing the CSS max-height value.
|
|
61
|
+
*/
|
|
62
|
+
export const getMaxHeight = (viewMaxHeight) => {
|
|
63
|
+
if (!viewMaxHeight)
|
|
64
|
+
return 'none';
|
|
65
|
+
return typeof viewMaxHeight === 'number' ? `${viewMaxHeight}px` : viewMaxHeight;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Calculates the vertical offset for a given item index in a list with variable item heights.
|
|
69
|
+
*
|
|
70
|
+
* @param index - The index of the item for which to calculate the offset.
|
|
71
|
+
* @param itemsHeight - Mapping of item indices and their actual height.
|
|
72
|
+
* @param defaultItemHeight - The default height to use for items not present in the cache.
|
|
73
|
+
* @returns The total offset (in pixels) from the top of the list to the specified index.
|
|
74
|
+
*/
|
|
75
|
+
export const getOffsetForIndex = (index, itemsHeight, defaultItemHeight) => {
|
|
76
|
+
let offset = 0;
|
|
77
|
+
for (let i = 0; i < index; i += 1) {
|
|
78
|
+
offset += itemsHeight[i] ?? defaultItemHeight;
|
|
79
|
+
}
|
|
80
|
+
return offset;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Determines whether the viewable area of a virtualized list is not fully filled with rendered items.
|
|
84
|
+
*
|
|
85
|
+
* @param totalItemCount - The total number of items that should be rendered.
|
|
86
|
+
* @param itemContainer - The HTML element containing the rendered items.
|
|
87
|
+
* @param parentContainer - The parent HTML element that contains the items and possibly the header.
|
|
88
|
+
* @param renderHeader - Indicates whether a header is rendered at the top of the parent container.
|
|
89
|
+
* @returns `true` if the view is not filled with all items, `false` otherwise.
|
|
90
|
+
*/
|
|
91
|
+
export const isViewNotFilled = (totalItemCount, itemContainer, parentContainer, renderHeader) => {
|
|
92
|
+
const parentContainerPosition = parentContainer.getBoundingClientRect();
|
|
93
|
+
let headerHeight = 0;
|
|
94
|
+
if (renderHeader && parentContainer.childElementCount > 1) {
|
|
95
|
+
const firstChild = parentContainer.children[0];
|
|
96
|
+
if (firstChild instanceof HTMLElement) {
|
|
97
|
+
headerHeight = firstChild.offsetHeight;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const scrollbarWidth = getScrollbarWidth();
|
|
101
|
+
const items = Array.from(itemContainer.children).filter((el) => el instanceof HTMLElement);
|
|
102
|
+
if (!items.length && !totalItemCount)
|
|
103
|
+
return false;
|
|
104
|
+
if (!items.length && totalItemCount)
|
|
105
|
+
return true;
|
|
106
|
+
return (!!totalItemCount &&
|
|
107
|
+
items.length !== totalItemCount &&
|
|
108
|
+
(Math.floor(items[items.length - 1].getBoundingClientRect().bottom) <
|
|
109
|
+
Math.floor(parentContainerPosition.bottom - scrollbarWidth) ||
|
|
110
|
+
Math.floor(items[0].getBoundingClientRect().top) >
|
|
111
|
+
Math.floor(parentContainerPosition.top + headerHeight) ||
|
|
112
|
+
items.length === 0));
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Retrieves the numeric data index from the `data-index` attribute of a given Element.
|
|
116
|
+
*
|
|
117
|
+
* @param element - The Element from which to extract the data index.
|
|
118
|
+
* @returns The parsed integer value of the `data-index` attribute, or `null` if the attribute is not present.
|
|
119
|
+
*/
|
|
120
|
+
export const getDataIndex = (element) => {
|
|
121
|
+
const dataIndexStr = element?.getAttribute('data-index');
|
|
122
|
+
if (!dataIndexStr)
|
|
123
|
+
return null;
|
|
124
|
+
const parsedDataIndex = parseInt(dataIndexStr, 10);
|
|
125
|
+
return Number.isNaN(parsedDataIndex) ? null : parsedDataIndex;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Calculates and returns an object containing the heights of items whose heights have changed
|
|
129
|
+
* compared to their previous values.
|
|
130
|
+
*
|
|
131
|
+
* @param itemContainer - The container HTMLElement whose child nodes represent items to measure.
|
|
132
|
+
* @param itemsHeight - An object mapping item indices to their measured heights.
|
|
133
|
+
* @param defaultItemHeight - The default height to use for items not present in `itemsHeight`.
|
|
134
|
+
* @returns An object mapping item indices to their new heights for items whose heights have changed.
|
|
135
|
+
*/
|
|
136
|
+
export function getChangedItemsHeight(itemContainer, itemsHeight, defaultItemHeight) {
|
|
137
|
+
if (!itemContainer)
|
|
138
|
+
return {};
|
|
139
|
+
const newHeights = {};
|
|
140
|
+
const nodes = Array.from(itemContainer.children);
|
|
141
|
+
nodes.forEach(node => {
|
|
142
|
+
const itemDataIndex = getDataIndex(node);
|
|
143
|
+
if (itemDataIndex === null)
|
|
144
|
+
return;
|
|
145
|
+
const measuredHeight = node.getBoundingClientRect().height;
|
|
146
|
+
const prevHeight = itemsHeight[itemDataIndex] ?? defaultItemHeight;
|
|
147
|
+
if (measuredHeight !== prevHeight) {
|
|
148
|
+
newHeights[itemDataIndex] = measuredHeight;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return newHeights;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Calculates the cumulative change in item heights between two sets of item height data,
|
|
155
|
+
* for a range of items starting from `startIndex` up to (but not including) `previousFirstItemDataIndex`.
|
|
156
|
+
*
|
|
157
|
+
* This function compares the current heights (`itemsHeight`) with the previous heights (`previousItemsHeight`)
|
|
158
|
+
* for each item in the specified range, using `defaultItemHeight` as a fallback if a previous height is missing.
|
|
159
|
+
* The result is the sum of the differences in height for all items in the range.
|
|
160
|
+
*
|
|
161
|
+
* @param startIndex - The index at which to start calculating the cumulative height change.
|
|
162
|
+
* @param previousFirstItemDataIndex - The index up to which to calculate (exclusive). If `null` or less than or equal to 0, returns 0.
|
|
163
|
+
* @param itemsHeight - An object mapping item indices to their measured heights.
|
|
164
|
+
* @param previousItemsHeight - An object mapping item indices of previously rendered items to their heights.
|
|
165
|
+
* @param defaultItemHeight - The default height to use if a previous height is not available.
|
|
166
|
+
* @returns The cumulative change in item heights for the specified range, or 0 if the result is not finite.
|
|
167
|
+
*/
|
|
168
|
+
export const calculateCumulativeItemSizeChange = (startIndex, previousFirstItemDataIndex, itemsHeight, previousItemsHeight, defaultItemHeight) => {
|
|
169
|
+
if (previousFirstItemDataIndex === null || previousFirstItemDataIndex <= 0) {
|
|
170
|
+
return 0;
|
|
171
|
+
}
|
|
172
|
+
let delta = 0;
|
|
173
|
+
for (let i = startIndex; i < previousFirstItemDataIndex; i += 1) {
|
|
174
|
+
const actualHeight = itemsHeight[i];
|
|
175
|
+
const previousHeight = previousItemsHeight[i] ?? defaultItemHeight;
|
|
176
|
+
if (actualHeight !== null && actualHeight !== undefined) {
|
|
177
|
+
delta += actualHeight - previousHeight;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return Number.isFinite(delta) ? delta : 0;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Updates the position styles of child items within a container element to enable virtualized rendering.
|
|
184
|
+
* Sets the container's top offset and positions each child absolutely based on their calculated heights.
|
|
185
|
+
*
|
|
186
|
+
* @param itemContainer - The HTML element containing the list items to be positioned.
|
|
187
|
+
* @param itemsHeight - An object mapping item indices to their measured heights.
|
|
188
|
+
* @param defaultItemHeight - The default height to use for items without a specified height.
|
|
189
|
+
* @returns The total height of all items within the container, rounded down to the nearest integer.
|
|
190
|
+
*/
|
|
191
|
+
export const updateItemPositionStyles = (itemContainer, itemsHeight, defaultItemHeight) => {
|
|
192
|
+
const items = itemContainer.children;
|
|
193
|
+
if (!items?.length) {
|
|
194
|
+
return 0;
|
|
195
|
+
}
|
|
196
|
+
const firstItemDataIndex = getDataIndex(items[0]);
|
|
197
|
+
if (firstItemDataIndex === null)
|
|
198
|
+
return 0;
|
|
199
|
+
const offset = getOffsetForIndex(firstItemDataIndex, itemsHeight, defaultItemHeight);
|
|
200
|
+
itemContainer.style.top = `${offset}px`;
|
|
201
|
+
let itemContainerCurrentHeight = 0;
|
|
202
|
+
let currentItemIndex = firstItemDataIndex;
|
|
203
|
+
Array.from(items).forEach((item) => {
|
|
204
|
+
if (!(item instanceof HTMLElement))
|
|
205
|
+
return;
|
|
206
|
+
item.style.position = 'absolute';
|
|
207
|
+
item.style.top = `${itemContainerCurrentHeight}px`;
|
|
208
|
+
itemContainerCurrentHeight += itemsHeight[currentItemIndex] ?? defaultItemHeight;
|
|
209
|
+
currentItemIndex += 1;
|
|
210
|
+
});
|
|
211
|
+
return Math.floor(itemContainerCurrentHeight);
|
|
212
|
+
};
|
|
213
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../Core/Components/Virtualise/VariableHeightVirtualizer/utils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AG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,IAAI,kBAAkB,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC;IAE1C,MAAM,MAAM,GAAG,iBAAiB,CAAC,kBAAkB,EAAE,WAAW,EAAE,iBAAiB,CAAC,CAAC;IACrF,aAAa,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,MAAM,IAAI,CAAC;IAExC,IAAI,0BAA0B,GAAG,CAAC,CAAC;IACnC,IAAI,gBAAgB,GAAG,kBAAkB,CAAC;IAC1C,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,IAAa,EAAE,EAAE;QAC1C,IAAI,CAAC,CAAC,IAAI,YAAY,WAAW,CAAC;YAAE,OAAO;QAE3C,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC;QACjC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,0BAA0B,IAAI,CAAC;QACnD,0BAA0B,IAAI,WAAW,CAAC,gBAAgB,CAAC,IAAI,iBAAiB,CAAC;QACjF,gBAAgB,IAAI,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAChD,CAAC,CAAC","sourcesContent":["import type { RefObject } from 'react';\n\nimport { getScrollbarWidth } from 'pega-repeating-structures-core';\n\nimport type { ItemsHeight } from './VariableHeightVirtualizer';\n\ninterface GetVirtualizedPaginationIndicesParams {\n /** Current vertical scroll offset of the container. */\n scrollTop: number;\n /** Ref to the scrolling container element */\n containerRef: RefObject<HTMLElement>;\n /** Ref to the container holding the list items */\n itemContainerRef: RefObject<HTMLElement>;\n\n /** Total number of items. */\n totalItemCount: number;\n /** Mapping of item indices and their actual height. */\n itemsHeight: ItemsHeight;\n /** Default height for items if not measured. */\n defaultItemHeight: number;\n\n /** Number of extra items to render above and below the visible viewport for smooth scrolling. */\n buffer: number;\n /** Maximum allowed end index (exclusive). */\n endIndexLimit: number;\n /** If true, allows indices to exceed totalCount for infinite scrolling by including buffer. */\n isInfiniteMode?: boolean;\n}\n\n/**\n * Calculates the start and end indices for virtualized pagination in a variable-height list.\n *\n * @returns {{ startIndex: number, endIndex: number }} Object containing the calculated start and end indices for rendering (inclusive both indices).\n */\nexport const getVirtualizedPaginationIndices = (\n param: GetVirtualizedPaginationIndicesParams\n): { startIndex: number; endIndex: number } => {\n const {\n totalItemCount,\n buffer,\n itemContainerRef,\n scrollTop,\n containerRef,\n itemsHeight,\n defaultItemHeight,\n endIndexLimit,\n isInfiniteMode\n } = param;\n\n const minimumItemsToFetchOnTop = buffer * 4;\n if (totalItemCount === 0 || itemContainerRef.current?.childElementCount === 0) {\n return { startIndex: 0, endIndex: minimumItemsToFetchOnTop };\n }\n\n const viewportHeight = containerRef.current?.clientHeight || 0;\n\n // Find the first visible item index for the current scroll position\n let aboveTheFoldItemsHeight = 0;\n let visibleStartIndex = 0;\n while (\n visibleStartIndex < totalItemCount &&\n aboveTheFoldItemsHeight + (itemsHeight[visibleStartIndex] ?? defaultItemHeight) < scrollTop\n ) {\n aboveTheFoldItemsHeight += itemsHeight[visibleStartIndex] ?? defaultItemHeight;\n visibleStartIndex += 1;\n }\n\n // Find the last visible item index for the current scroll position\n let inViewItemsHeight = 0;\n let visibleEndIndex = visibleStartIndex;\n while (visibleEndIndex < totalItemCount && inViewItemsHeight < viewportHeight) {\n inViewItemsHeight += itemsHeight[visibleEndIndex] ?? defaultItemHeight;\n visibleEndIndex += 1;\n }\n\n const startIndex = Math.max(0, visibleStartIndex - buffer);\n let endIndex = Math.min(visibleEndIndex + buffer, endIndexLimit - 1);\n if (isInfiniteMode) {\n endIndex = Math.max(endIndex, minimumItemsToFetchOnTop);\n } else {\n // In cases where the count is very less due to filters, we would fetch more items to avoid unnecessary API calls if the count after the filter removed is more\n endIndex = Math.max(Math.min(totalItemCount - 1, endIndex), minimumItemsToFetchOnTop);\n }\n return { startIndex, endIndex };\n};\n\n/**\n * Calculates the total buffer height for a list of items, using their individual heights if available,\n * or a default height otherwise.\n *\n * @param totalItemCount - The total number of items in the list.\n * @param itemsHeight - An object or array containing the heights of individual items, indexed by item position.\n * @param defaultItemHeight - The default height to use for items whose height is not specified in `itemsHeight`.\n * @returns The sum of all item heights, using the default height for any missing values.\n */\nexport const calculateTotalBufferHeight = (\n totalItemCount: number,\n itemsHeight: ItemsHeight,\n defaultItemHeight: number\n): number => {\n let totalBufferHeight = 0;\n for (let i = 0; i < totalItemCount; i += 1) {\n totalBufferHeight += itemsHeight[i] || defaultItemHeight;\n }\n\n return totalBufferHeight;\n};\n\n/**\n * Returns a CSS-compatible max-height value based on the input.\n *\n * @param viewMaxHeight - The maximum height value, which can be a number (pixels), a string (CSS value), or `null`.\n * @returns A string representing the CSS max-height value.\n */\nexport const getMaxHeight = (viewMaxHeight: number | string | null): string => {\n if (!viewMaxHeight) return 'none';\n return typeof viewMaxHeight === 'number' ? `${viewMaxHeight}px` : viewMaxHeight;\n};\n\n/**\n * Calculates the vertical offset for a given item index in a list with variable item heights.\n *\n * @param index - The index of the item for which to calculate the offset.\n * @param itemsHeight - Mapping of item indices and their actual height.\n * @param defaultItemHeight - The default height to use for items not present in the cache.\n * @returns The total offset (in pixels) from the top of the list to the specified index.\n */\nexport const getOffsetForIndex = (\n index: number,\n itemsHeight: ItemsHeight,\n defaultItemHeight: number\n): number => {\n let offset = 0;\n\n for (let i = 0; i < index; i += 1) {\n offset += itemsHeight[i] ?? defaultItemHeight;\n }\n return offset;\n};\n\n/**\n * Determines whether the viewable area of a virtualized list is not fully filled with rendered items.\n *\n * @param totalItemCount - The total number of items that should be rendered.\n * @param itemContainer - The HTML element containing the rendered items.\n * @param parentContainer - The parent HTML element that contains the items and possibly the header.\n * @param renderHeader - Indicates whether a header is rendered at the top of the parent container.\n * @returns `true` if the view is not filled with all items, `false` otherwise.\n */\nexport const isViewNotFilled = (\n totalItemCount: number,\n itemContainer: HTMLElement,\n parentContainer: HTMLElement,\n renderHeader: boolean\n): boolean => {\n const parentContainerPosition = parentContainer.getBoundingClientRect();\n let headerHeight = 0;\n if (renderHeader && parentContainer.childElementCount > 1) {\n const firstChild = parentContainer.children[0];\n if (firstChild instanceof HTMLElement) {\n headerHeight = firstChild.offsetHeight;\n }\n }\n\n const scrollbarWidth = getScrollbarWidth();\n const items = Array.from(itemContainer.children).filter(\n (el): el is HTMLElement => el instanceof HTMLElement\n );\n\n if (!items.length && !totalItemCount) return false;\n if (!items.length && totalItemCount) return true;\n\n return (\n !!totalItemCount &&\n items.length !== totalItemCount &&\n (Math.floor(items[items.length - 1].getBoundingClientRect().bottom) <\n Math.floor(parentContainerPosition.bottom - scrollbarWidth) ||\n Math.floor(items[0].getBoundingClientRect().top) >\n Math.floor(parentContainerPosition.top + headerHeight) ||\n items.length === 0)\n );\n};\n\n/**\n * Retrieves the numeric data index from the `data-index` attribute of a given Element.\n *\n * @param element - The Element from which to extract the data index.\n * @returns The parsed integer value of the `data-index` attribute, or `null` if the attribute is not present.\n */\nexport const getDataIndex = (element: Element): number | null => {\n const dataIndexStr = element?.getAttribute('data-index');\n if (!dataIndexStr) return null;\n const parsedDataIndex = parseInt(dataIndexStr, 10);\n return Number.isNaN(parsedDataIndex) ? null : parsedDataIndex;\n};\n\n/**\n * Calculates and returns an object containing the heights of items whose heights have changed\n * compared to their previous values.\n *\n * @param itemContainer - The container HTMLElement whose child nodes represent items to measure.\n * @param itemsHeight - An object mapping item indices to their measured heights.\n * @param defaultItemHeight - The default height to use for items not present in `itemsHeight`.\n * @returns An object mapping item indices to their new heights for items whose heights have changed.\n */\nexport function getChangedItemsHeight(\n itemContainer: HTMLElement,\n itemsHeight: ItemsHeight,\n defaultItemHeight: number\n): ItemsHeight {\n if (!itemContainer) return {};\n\n const newHeights: ItemsHeight = {};\n const nodes = Array.from(itemContainer.children);\n\n nodes.forEach(node => {\n const itemDataIndex = getDataIndex(node);\n if (itemDataIndex === null) return;\n\n const measuredHeight = node.getBoundingClientRect().height;\n const prevHeight = itemsHeight[itemDataIndex] ?? defaultItemHeight;\n if (measuredHeight !== prevHeight) {\n newHeights[itemDataIndex] = measuredHeight;\n }\n });\n\n return newHeights;\n}\n\n/**\n * Calculates the cumulative change in item heights between two sets of item height data,\n * for a range of items starting from `startIndex` up to (but not including) `previousFirstItemDataIndex`.\n *\n * This function compares the current heights (`itemsHeight`) with the previous heights (`previousItemsHeight`)\n * for each item in the specified range, using `defaultItemHeight` as a fallback if a previous height is missing.\n * The result is the sum of the differences in height for all items in the range.\n *\n * @param startIndex - The index at which to start calculating the cumulative height change.\n * @param previousFirstItemDataIndex - The index up to which to calculate (exclusive). If `null` or less than or equal to 0, returns 0.\n * @param itemsHeight - An object mapping item indices to their measured heights.\n * @param previousItemsHeight - An object mapping item indices of previously rendered items to their heights.\n * @param defaultItemHeight - The default height to use if a previous height is not available.\n * @returns The cumulative change in item heights for the specified range, or 0 if the result is not finite.\n */\nexport const calculateCumulativeItemSizeChange = (\n startIndex: number,\n previousFirstItemDataIndex: number | null,\n itemsHeight: ItemsHeight,\n previousItemsHeight: ItemsHeight,\n defaultItemHeight: number\n): number => {\n if (previousFirstItemDataIndex === null || previousFirstItemDataIndex <= 0) {\n return 0;\n }\n\n let delta = 0;\n\n for (let i = startIndex; i < previousFirstItemDataIndex; i += 1) {\n const actualHeight = itemsHeight[i];\n const previousHeight = previousItemsHeight[i] ?? defaultItemHeight;\n\n if (actualHeight !== null && actualHeight !== undefined) {\n delta += actualHeight - previousHeight;\n }\n }\n\n return Number.isFinite(delta) ? delta : 0;\n};\n\n/**\n * Updates the position styles of child items within a container element to enable virtualized rendering.\n * Sets the container's top offset and positions each child absolutely based on their calculated heights.\n *\n * @param itemContainer - The HTML element containing the list items to be positioned.\n * @param itemsHeight - An object mapping item indices to their measured heights.\n * @param defaultItemHeight - The default height to use for items without a specified height.\n * @returns The total height of all items within the container, rounded down to the nearest integer.\n */\nexport const updateItemPositionStyles = (\n itemContainer: HTMLElement,\n itemsHeight: ItemsHeight,\n defaultItemHeight: number\n): number => {\n const items = itemContainer.children;\n if (!items?.length) {\n return 0;\n }\n\n const firstItemDataIndex = getDataIndex(items[0]);\n if (firstItemDataIndex === null) return 0;\n\n const offset = getOffsetForIndex(firstItemDataIndex, itemsHeight, defaultItemHeight);\n itemContainer.style.top = `${offset}px`;\n\n let itemContainerCurrentHeight = 0;\n let currentItemIndex = firstItemDataIndex;\n Array.from(items).forEach((item: Element) => {\n if (!(item instanceof HTMLElement)) return;\n\n item.style.position = 'absolute';\n item.style.top = `${itemContainerCurrentHeight}px`;\n itemContainerCurrentHeight += itemsHeight[currentItemIndex] ?? defaultItemHeight;\n currentItemIndex += 1;\n });\n\n return Math.floor(itemContainerCurrentHeight);\n};\n"]}
|
|
@@ -5,7 +5,7 @@ export declare function isPaginationRequestCompleted(requestedIndexes?: {
|
|
|
5
5
|
}, receivedIndexes?: {
|
|
6
6
|
startIndex: number;
|
|
7
7
|
endIndex: number;
|
|
8
|
-
}): boolean | undefined;
|
|
8
|
+
}): number | boolean | undefined;
|
|
9
9
|
export declare function isViewNotFilled(totalRecordCount: number, vi: {
|
|
10
10
|
rContainer: HTMLDivElement;
|
|
11
11
|
}, pContainer: HTMLDivElement, renderHeader: boolean): boolean | 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../../../../Core/Components/Virtualise/utility.ts"],"names":[],"mappings":"AAOA,wBAAgB,4BAA4B,CAAC,gBAAgB,EAAE,MAAM,UAEpE;AAID,wBAAgB,4BAA4B,CAC1C,gBAAgB,CAAC,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC3D,eAAe,CAAC,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../../../../Core/Components/Virtual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gB,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH,EACD,gBAAgB,EAAE,MAAM,EACxB,KAAK,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAC7B,UAAU,EAAE,cAAc,EAC1B,SAAS,EAAE,MAAM,QAuClB;AAGD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC/C,UAAU,EAAE,WAAW,QAKxB;AAED,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,WAAW,sBAU/D;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAClC,YAAY,EAAE,MAAM,GAAG,MAAM,GAC5B,MAAM,GAAG,MAAM,CAMjB;AAED,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAG/E"}
|
|
@@ -12,8 +12,9 @@ export function isPaginationRequestCompleted(requestedIndexes, receivedIndexes)
|
|
|
12
12
|
// about updated index though pagination is really not required.
|
|
13
13
|
return (receivedIndexes &&
|
|
14
14
|
requestedIndexes &&
|
|
15
|
-
receivedIndexes.startIndex === requestedIndexes.startIndex &&
|
|
16
|
-
|
|
15
|
+
((receivedIndexes.startIndex === requestedIndexes.startIndex &&
|
|
16
|
+
receivedIndexes.endIndex === requestedIndexes.endIndex) ||
|
|
17
|
+
(Object.keys(requestedIndexes).length === 0 && receivedIndexes.endIndex)));
|
|
17
18
|
}
|
|
18
19
|
export function isViewNotFilled(totalRecordCount, vi, pContainer, renderHeader) {
|
|
19
20
|
const parentContainerPosition = pContainer.getBoundingClientRect();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utility.js","sourceRoot":"","sources":["../../../../Core/Components/Virtualise/utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gC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ClF,CAAC","sourcesContent":["import { getScrollbarWidth } from 'pega-repeating-structures-core';\n\nimport { StickyGroupHeader } from './Pagination';\n\n// TODO: in future, take this count in meta\nconst MAX_SCROLLABLE_ROW_COUNT = 5000;\n\nexport function getRecordCountForLayoutPaint(totalRecordCount: number) {\n return totalRecordCount > MAX_SCROLLABLE_ROW_COUNT ? MAX_SCROLLABLE_ROW_COUNT : totalRecordCount;\n}\n\n// State should be communicated back from consumer to know\n// if pagination last request completed or not.\nexport function isPaginationRequestCompleted(\n requestedIndexes?: { startIndex: number; endIndex: number },\n receivedIndexes?: { startIndex: number; endIndex: number }\n) {\n // this is required when there is a pagination request which is raised just to update consumer\n // about updated index though pagination is really not required.\n return (\n receivedIndexes &&\n requestedIndexes &&\n receivedIndexes.startIndex === requestedIndexes.startIndex &&\n receivedIndexes.endIndex === requestedIndexes.endIndex\n );\n}\n\nexport function isViewNotFilled(\n totalRecordCount: number,\n vi: { rContainer: HTMLDivElement },\n pContainer: HTMLDivElement,\n renderHeader: boolean\n) {\n const parentContainerPosition = pContainer.getBoundingClientRect();\n // This is required to accommodate header height.\n // TODO: Need to find a better solution to pull out header out of this.\n const headerRowHeight =\n renderHeader && pContainer.childElementCount > 1\n ? (pContainer.childNodes[0] as HTMLElement).offsetHeight\n : 0;\n const scrollbarWidth = getScrollbarWidth();\n return (\n totalRecordCount &&\n vi.rContainer.childElementCount !== totalRecordCount &&\n (Math.floor(vi.rContainer.getBoundingClientRect().bottom) <\n Math.floor(parentContainerPosition.bottom - scrollbarWidth) ||\n Math.floor(vi.rContainer.getBoundingClientRect().top) >\n Math.floor(parentContainerPosition.top + headerRowHeight) ||\n vi.rContainer.childElementCount === 0)\n );\n}\n\nfunction getItemCountPerRow(rows: Element[]) {\n const itemsCountPerRow: {\n [key: string]: { count: number; height: number; isStickyGroupHeader: boolean };\n } = {};\n rows.forEach(item => {\n const itemBoundary = item.getBoundingClientRect();\n // isStickyGroupHeader flag helps in including the overlapped sticky-group-header for getting correct averages\n const isStickyGroupHeader = item.classList.contains(StickyGroupHeader);\n if (itemsCountPerRow[itemBoundary.top]) {\n itemsCountPerRow[itemBoundary.top].count += 1;\n if (itemsCountPerRow[itemBoundary.top].height < itemBoundary.height) {\n itemsCountPerRow[itemBoundary.top].height = itemBoundary.height;\n }\n } else {\n itemsCountPerRow[itemBoundary.top] = {\n count: 1,\n height: itemBoundary.height,\n isStickyGroupHeader\n };\n }\n });\n return itemsCountPerRow;\n}\n\n// Based on row container size, get estimated count,\n// average height and no of items in a row.\nexport function getCurrentEstimation(rContainer: HTMLDivElement, includeRowsOnly = false) {\n const rContainerChildren = Array.from(rContainer.children || []);\n const filteredRowsContainer = includeRowsOnly\n ? rContainerChildren.filter(r => r.hasAttribute('data-key'))\n : rContainerChildren;\n\n const itemsCountPerRow = getItemCountPerRow(filteredRowsContainer);\n const itemCount = filteredRowsContainer.length || 0;\n // TODO FIXME: #virtualizer Remove dependency on sticky-group-header class and try to make the key of ItemsCountPerRow unique which will work for overlapping scenarios\n // BUG-740809 handling the rowCount in case of overlapped sticky-group-header\n // If we have sticky-group-headers, add overlapped sticky-group-headers to rowCount.\n // So, that averageNumberOfItemsInARow will be 1 for grid. That's why adding the complete count.\n const rowCount = Object.values(itemsCountPerRow).reduce(\n (acc: number, o: { isStickyGroupHeader: boolean; count: number }) => {\n if (o.isStickyGroupHeader) {\n return acc + o.count;\n }\n return acc + 1;\n },\n 0\n );\n const averageNumberOfItemsInARow = rowCount > 0 ? itemCount / rowCount : 0;\n const height = Object.values(itemsCountPerRow).reduce(\n (acc: number, o: { isStickyGroupHeader: boolean; height: number; count: number }) => {\n if (o.isStickyGroupHeader) {\n return acc + o.height * o.count;\n }\n return acc + o.height;\n },\n 0\n );\n const averageRowHeight = rowCount > 0 ? height / rowCount : 0;\n const rowContainerHeight = rContainer.offsetHeight || 0;\n return { itemCount, rowContainerHeight, averageNumberOfItemsInARow, averageRowHeight };\n}\n\n// Calculate top which needs to set on row container when component rerender.\n// component can rerender many times though pagination is in progress.\nfunction calculateTop(\n vi: {\n rContainer: HTMLDivElement;\n pInfo?: {\n view?: { startIndex: number; endIndex: number };\n };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n },\n scrollTop: number\n) {\n let top = 0;\n if (vi.pInfo && vi.pInfo?.view?.startIndex !== 0) {\n // slide row container for current view based on previous estimated value.\n const estimatedNoOfItemsPushedUp =\n scrollTop * (vi.currentEstimation.itemCount / vi.currentEstimation.rowContainerHeight);\n // estimated start view index of current view based on scroll top.\n\n const estimatedStartIndexInView = estimatedNoOfItemsPushedUp + 1;\n // estimated number of buffer records.\n\n const noOfBufferRecords = estimatedStartIndexInView - (vi.pInfo?.view?.startIndex ?? 0);\n const noOfBufferRecordsHeight =\n (noOfBufferRecords / vi.currentEstimation.averageNumberOfItemsInARow) *\n vi.currentEstimation.averageRowHeight;\n // calculated top of row container.\n top = scrollTop - noOfBufferRecordsHeight;\n if (top < 0) top = 0;\n }\n return top;\n}\n\nfunction adjustTopRowContainerToAvoidDrift(\n vi: {\n rContainer: HTMLDivElement;\n pInfo: {\n view: { startIndex: number; endIndex: number };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n existingItemBoundingBox: { y: number };\n currentRowIndex: number;\n bufferNewCords: { top: number };\n bufferOldCords: { top: number };\n };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n },\n existingTop: number\n) {\n // Adjust top if element was viewable when user stop scrolling and pagination trigger.\n // existing item should be viewable are at time of calculation\n // as we allow user to scroll even pagination request triggered.\n let effectiveTop = existingTop;\n const { existingItemBoundingBox, currentRowIndex } = vi.pInfo;\n // As safari does elastic scroll, we need this check to avoid any space on top.\n const safariIsFirstItem = currentRowIndex === 0;\n if (existingItemBoundingBox && !safariIsFirstItem) {\n const currentRowIndexItem = vi.rContainer.querySelector(\n `[data-index='${vi.pInfo.currentRowIndex}']`\n );\n if (currentRowIndexItem) {\n // scrollNodeTopChange - change in scroll while pagination is in progress.\n const scrollNodeTopChange = vi.pInfo.bufferNewCords.top - vi.pInfo.bufferOldCords.top;\n const newItemBoundingBox = currentRowIndexItem.getBoundingClientRect();\n const top = newItemBoundingBox.y - existingItemBoundingBox.y - scrollNodeTopChange;\n effectiveTop = existingTop - top;\n }\n }\n // As of now, we are making top to zero if it goes in negative, which is not right way.\n // -ve is possible value for it as scroll top is just approximation. Check when\n // gallery view gives you 0 to index result after some scroll.\n // scroll top is 0 as it is top row index based.\n // TODO: can go negative as bottom to top paint strategy is pending.\n // This check and expression is not required after that. This will be handled in next release.\n // Gallery issue wil also be handled in that. As of for first attempt we have to either scroll more.\n // or make buffer size more in that to avoid 0 to index number in next repaint.\n if (effectiveTop < 0 && vi.pInfo.view.startIndex === 0) effectiveTop = 0;\n if (effectiveTop !== existingTop) vi.rContainer.style.top = `${effectiveTop}px`;\n}\n\nexport function updateRowContainerTop(\n vi: {\n rContainer: HTMLDivElement;\n pInfo: {\n view: { startIndex: number; endIndex: number };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n existingItemBoundingBox: { y: number };\n currentRowIndex: number;\n bufferNewCords: { top: number };\n bufferOldCords: { top: number };\n };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n },\n totalRecordCount: number,\n state: { [key: string]: any },\n pContainer: HTMLDivElement,\n scrollTop: number\n) {\n // if you get last record , put row container to bottom always to Avoid\n // any space left because of estimation otherwise calculate top.\n // if next rerender you get less records,\n if (\n (vi.pInfo?.view?.startIndex === 0 && vi.pInfo?.view?.endIndex < totalRecordCount) ||\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.view?.startIndex + 1 > totalRecordCount ||\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.view?.endIndex - vi.pInfo?.view?.startIndex >= totalRecordCount\n ) {\n // This is a case when you scroll to top or say after filter your items count reduce to such level\n // it doesn't fit in current start and end index and put container top and fill view\n // will consider if empty.\n vi.rContainer.style.removeProperty('bottom');\n vi.rContainer.style.top = '0px';\n // Any action which makes indexes out of range to total record count,\n // scroll to top as a default behavior.\n if (vi.pInfo.view.startIndex + 1 > totalRecordCount) pContainer.scrollTop = 0;\n\n // commenting below line as it can cause white space on top sometime.\n // Commenting this line might cause a small flicker only when you reach at top.\n // We will solve this in 8.6 release.\n // else if (vi.pInfo?.topRowIndex > 0) adjustTopRowContainerToAvoidDrift(vi, 0);\n } else if (\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.view?.endIndex + 1 >= totalRecordCount &&\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.view?.startIndex + 1 <= totalRecordCount\n ) {\n vi.rContainer.style.removeProperty('top');\n vi.rContainer.style.bottom = '0px';\n } else {\n vi.rContainer.style.removeProperty('bottom');\n const top = calculateTop(vi, scrollTop);\n vi.rContainer.style.top = `${top}px`;\n adjustTopRowContainerToAvoidDrift(vi, top);\n }\n}\n\n// index attrs required to estimate next set.\nexport function setAttributesOnItems(\n state: { startIndex: number; endIndex: number },\n rContainer: HTMLElement\n) {\n rContainer.childNodes.forEach((r, index) => {\n (r as HTMLElement).setAttribute('data-index', `${state.startIndex + index}`);\n });\n}\n\nexport function getPContainerClientWidth(pContainer: HTMLElement) {\n if (!pContainer) return;\n\n const { width: pContainerWidth } = pContainer.getBoundingClientRect();\n\n let pContainerClientWidth = Math.floor(pContainerWidth);\n if (pContainer.offsetWidth > pContainer.clientWidth) {\n pContainerClientWidth -= getScrollbarWidth();\n }\n return pContainerClientWidth;\n}\n\nexport function getValueWithUnit(\n value: string | number | undefined,\n defaultValue: string | number\n): string | number {\n if (!value) return defaultValue;\n if (!value.toString().includes('px') && !value.toString().includes('%')) {\n return `${value}px`;\n }\n return `${value}`;\n}\n\nexport function getMaxHeight(viewMaxHeight: number | string | undefined): string {\n if (!viewMaxHeight) return 'none';\n return typeof viewMaxHeight === 'number' ? `${viewMaxHeight}px` : viewMaxHeight;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utility.js","sourceRoot":"","sources":["../../../../Core/Components/Virtualise/utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,2CAA2C;AAC3C,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAEtC,MAAM,UAAU,4BAA4B,CAAC,gBAAwB;IACnE,OAAO,gBAAgB,GAAG,wBAAwB,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,gBAAgB,CAAC;AACnG,CAAC;AAED,0DAA0D;AAC1D,+CAA+C;AAC/C,MAAM,UAAU,4BAA4B,CAC1C,gBAA2D,EAC3D,eAA0D;IAE1D,8FAA8F;IAC9F,gEAAgE;IAChE,OAAO,CACL,eAAe;QACf,gBAAgB;QAChB,CAAC,CAAC,eAAe,CAAC,UAAU,KAAK,gBAAgB,CAAC,UAAU;YAC1D,eAAe,CAAC,QAAQ,KAAK,gBAAgB,CAAC,QAAQ,CAAC;YACvD,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,eAAe,CAAC,QAAQ,CAAC,CAAC,CAC5E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,gBAAwB,EACxB,EAAkC,EAClC,UAA0B,EAC1B,YAAqB;IAErB,MAAM,uBAAuB,GAAG,UAAU,CAAC,qBAAqB,EAAE,CAAC;IACnE,iDAAiD;IACjD,uEAAuE;IACvE,MAAM,eAAe,GACnB,YAAY,IAAI,UAAU,CAAC,iBAAiB,GAAG,CAAC;QAC9C,CAAC,CAAE,UAAU,CAAC,UAAU,CAAC,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EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACxE,OAAO,GAAG,KAAK,IAAI,CAAC;IACtB,CAAC;IACD,OAAO,GAAG,KAAK,EAAE,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,aAA0C;IACrE,IAAI,CAAC,aAAa;QAAE,OAAO,MAAM,CAAC;IAClC,OAAO,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,aAAa,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC;AAClF,CAAC","sourcesContent":["import { getScrollbarWidth } from 'pega-repeating-structures-core';\n\nimport { StickyGroupHeader } from './Pagination';\n\n// TODO: in future, take this count in meta\nconst MAX_SCROLLABLE_ROW_COUNT = 5000;\n\nexport function getRecordCountForLayoutPaint(totalRecordCount: number) {\n return totalRecordCount > MAX_SCROLLABLE_ROW_COUNT ? MAX_SCROLLABLE_ROW_COUNT : totalRecordCount;\n}\n\n// State should be communicated back from consumer to know\n// if pagination last request completed or not.\nexport function isPaginationRequestCompleted(\n requestedIndexes?: { startIndex: number; endIndex: number },\n receivedIndexes?: { startIndex: number; endIndex: number }\n) {\n // this is required when there is a pagination request which is raised just to update consumer\n // about updated index though pagination is really not required.\n return (\n receivedIndexes &&\n requestedIndexes &&\n ((receivedIndexes.startIndex === requestedIndexes.startIndex &&\n receivedIndexes.endIndex === requestedIndexes.endIndex) ||\n (Object.keys(requestedIndexes).length === 0 && receivedIndexes.endIndex))\n );\n}\n\nexport function isViewNotFilled(\n totalRecordCount: number,\n vi: { rContainer: HTMLDivElement },\n pContainer: HTMLDivElement,\n renderHeader: boolean\n) {\n const parentContainerPosition = pContainer.getBoundingClientRect();\n // This is required to accommodate header height.\n // TODO: Need to find a better solution to pull out header out of this.\n const headerRowHeight =\n renderHeader && pContainer.childElementCount > 1\n ? (pContainer.childNodes[0] as HTMLElement).offsetHeight\n : 0;\n const scrollbarWidth = getScrollbarWidth();\n return (\n totalRecordCount &&\n vi.rContainer.childElementCount !== totalRecordCount &&\n (Math.floor(vi.rContainer.getBoundingClientRect().bottom) <\n Math.floor(parentContainerPosition.bottom - scrollbarWidth) ||\n Math.floor(vi.rContainer.getBoundingClientRect().top) >\n Math.floor(parentContainerPosition.top + headerRowHeight) ||\n vi.rContainer.childElementCount === 0)\n );\n}\n\nfunction getItemCountPerRow(rows: Element[]) {\n const itemsCountPerRow: {\n [key: string]: { count: number; height: number; isStickyGroupHeader: boolean };\n } = {};\n rows.forEach(item => {\n const itemBoundary = item.getBoundingClientRect();\n // isStickyGroupHeader flag helps in including the overlapped sticky-group-header for getting correct averages\n const isStickyGroupHeader = item.classList.contains(StickyGroupHeader);\n if (itemsCountPerRow[itemBoundary.top]) {\n itemsCountPerRow[itemBoundary.top].count += 1;\n if (itemsCountPerRow[itemBoundary.top].height < itemBoundary.height) {\n itemsCountPerRow[itemBoundary.top].height = itemBoundary.height;\n }\n } else {\n itemsCountPerRow[itemBoundary.top] = {\n count: 1,\n height: itemBoundary.height,\n isStickyGroupHeader\n };\n }\n });\n return itemsCountPerRow;\n}\n\n// Based on row container size, get estimated count,\n// average height and no of items in a row.\nexport function getCurrentEstimation(rContainer: HTMLDivElement, includeRowsOnly = false) {\n const rContainerChildren = Array.from(rContainer.children || []);\n const filteredRowsContainer = includeRowsOnly\n ? rContainerChildren.filter(r => r.hasAttribute('data-key'))\n : rContainerChildren;\n\n const itemsCountPerRow = getItemCountPerRow(filteredRowsContainer);\n const itemCount = filteredRowsContainer.length || 0;\n // TODO FIXME: #virtualizer Remove dependency on sticky-group-header class and try to make the key of ItemsCountPerRow unique which will work for overlapping scenarios\n // BUG-740809 handling the rowCount in case of overlapped sticky-group-header\n // If we have sticky-group-headers, add overlapped sticky-group-headers to rowCount.\n // So, that averageNumberOfItemsInARow will be 1 for grid. That's why adding the complete count.\n const rowCount = Object.values(itemsCountPerRow).reduce(\n (acc: number, o: { isStickyGroupHeader: boolean; count: number }) => {\n if (o.isStickyGroupHeader) {\n return acc + o.count;\n }\n return acc + 1;\n },\n 0\n );\n const averageNumberOfItemsInARow = rowCount > 0 ? itemCount / rowCount : 0;\n const height = Object.values(itemsCountPerRow).reduce(\n (acc: number, o: { isStickyGroupHeader: boolean; height: number; count: number }) => {\n if (o.isStickyGroupHeader) {\n return acc + o.height * o.count;\n }\n return acc + o.height;\n },\n 0\n );\n const averageRowHeight = rowCount > 0 ? height / rowCount : 0;\n const rowContainerHeight = rContainer.offsetHeight || 0;\n return { itemCount, rowContainerHeight, averageNumberOfItemsInARow, averageRowHeight };\n}\n\n// Calculate top which needs to set on row container when component rerender.\n// component can rerender many times though pagination is in progress.\nfunction calculateTop(\n vi: {\n rContainer: HTMLDivElement;\n pInfo?: {\n view?: { startIndex: number; endIndex: number };\n };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n },\n scrollTop: number\n) {\n let top = 0;\n if (vi.pInfo && vi.pInfo?.view?.startIndex !== 0) {\n // slide row container for current view based on previous estimated value.\n const estimatedNoOfItemsPushedUp =\n scrollTop * (vi.currentEstimation.itemCount / vi.currentEstimation.rowContainerHeight);\n // estimated start view index of current view based on scroll top.\n\n const estimatedStartIndexInView = estimatedNoOfItemsPushedUp + 1;\n // estimated number of buffer records.\n\n const noOfBufferRecords = estimatedStartIndexInView - (vi.pInfo?.view?.startIndex ?? 0);\n const noOfBufferRecordsHeight =\n (noOfBufferRecords / vi.currentEstimation.averageNumberOfItemsInARow) *\n vi.currentEstimation.averageRowHeight;\n // calculated top of row container.\n top = scrollTop - noOfBufferRecordsHeight;\n if (top < 0) top = 0;\n }\n return top;\n}\n\nfunction adjustTopRowContainerToAvoidDrift(\n vi: {\n rContainer: HTMLDivElement;\n pInfo: {\n view: { startIndex: number; endIndex: number };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n existingItemBoundingBox: { y: number };\n currentRowIndex: number;\n bufferNewCords: { top: number };\n bufferOldCords: { top: number };\n };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n },\n existingTop: number\n) {\n // Adjust top if element was viewable when user stop scrolling and pagination trigger.\n // existing item should be viewable are at time of calculation\n // as we allow user to scroll even pagination request triggered.\n let effectiveTop = existingTop;\n const { existingItemBoundingBox, currentRowIndex } = vi.pInfo;\n // As safari does elastic scroll, we need this check to avoid any space on top.\n const safariIsFirstItem = currentRowIndex === 0;\n if (existingItemBoundingBox && !safariIsFirstItem) {\n const currentRowIndexItem = vi.rContainer.querySelector(\n `[data-index='${vi.pInfo.currentRowIndex}']`\n );\n if (currentRowIndexItem) {\n // scrollNodeTopChange - change in scroll while pagination is in progress.\n const scrollNodeTopChange = vi.pInfo.bufferNewCords.top - vi.pInfo.bufferOldCords.top;\n const newItemBoundingBox = currentRowIndexItem.getBoundingClientRect();\n const top = newItemBoundingBox.y - existingItemBoundingBox.y - scrollNodeTopChange;\n effectiveTop = existingTop - top;\n }\n }\n // As of now, we are making top to zero if it goes in negative, which is not right way.\n // -ve is possible value for it as scroll top is just approximation. Check when\n // gallery view gives you 0 to index result after some scroll.\n // scroll top is 0 as it is top row index based.\n // TODO: can go negative as bottom to top paint strategy is pending.\n // This check and expression is not required after that. This will be handled in next release.\n // Gallery issue wil also be handled in that. As of for first attempt we have to either scroll more.\n // or make buffer size more in that to avoid 0 to index number in next repaint.\n if (effectiveTop < 0 && vi.pInfo.view.startIndex === 0) effectiveTop = 0;\n if (effectiveTop !== existingTop) vi.rContainer.style.top = `${effectiveTop}px`;\n}\n\nexport function updateRowContainerTop(\n vi: {\n rContainer: HTMLDivElement;\n pInfo: {\n view: { startIndex: number; endIndex: number };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n existingItemBoundingBox: { y: number };\n currentRowIndex: number;\n bufferNewCords: { top: number };\n bufferOldCords: { top: number };\n };\n currentEstimation: {\n itemCount: number;\n rowContainerHeight: number;\n averageNumberOfItemsInARow: number;\n averageRowHeight: number;\n };\n },\n totalRecordCount: number,\n state: { [key: string]: any },\n pContainer: HTMLDivElement,\n scrollTop: number\n) {\n // if you get last record , put row container to bottom always to Avoid\n // any space left because of estimation otherwise calculate top.\n // if next rerender you get less records,\n if (\n (vi.pInfo?.view?.startIndex === 0 && vi.pInfo?.view?.endIndex < totalRecordCount) ||\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.view?.startIndex + 1 > totalRecordCount ||\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.view?.endIndex - vi.pInfo?.view?.startIndex >= totalRecordCount\n ) {\n // This is a case when you scroll to top or say after filter your items count reduce to such level\n // it doesn't fit in current start and end index and put container top and fill view\n // will consider if empty.\n vi.rContainer.style.removeProperty('bottom');\n vi.rContainer.style.top = '0px';\n // Any action which makes indexes out of range to total record count,\n // scroll to top as a default behavior.\n if (vi.pInfo.view.startIndex + 1 > totalRecordCount) pContainer.scrollTop = 0;\n\n // commenting below line as it can cause white space on top sometime.\n // Commenting this line might cause a small flicker only when you reach at top.\n // We will solve this in 8.6 release.\n // else if (vi.pInfo?.topRowIndex > 0) adjustTopRowContainerToAvoidDrift(vi, 0);\n } else if (\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.view?.endIndex + 1 >= totalRecordCount &&\n // eslint-disable-next-line no-unsafe-optional-chaining\n vi.pInfo?.view?.startIndex + 1 <= totalRecordCount\n ) {\n vi.rContainer.style.removeProperty('top');\n vi.rContainer.style.bottom = '0px';\n } else {\n vi.rContainer.style.removeProperty('bottom');\n const top = calculateTop(vi, scrollTop);\n vi.rContainer.style.top = `${top}px`;\n adjustTopRowContainerToAvoidDrift(vi, top);\n }\n}\n\n// index attrs required to estimate next set.\nexport function setAttributesOnItems(\n state: { startIndex: number; endIndex: number },\n rContainer: HTMLElement\n) {\n rContainer.childNodes.forEach((r, index) => {\n (r as HTMLElement).setAttribute('data-index', `${state.startIndex + index}`);\n });\n}\n\nexport function getPContainerClientWidth(pContainer: HTMLElement) {\n if (!pContainer) return;\n\n const { width: pContainerWidth } = pContainer.getBoundingClientRect();\n\n let pContainerClientWidth = Math.floor(pContainerWidth);\n if (pContainer.offsetWidth > pContainer.clientWidth) {\n pContainerClientWidth -= getScrollbarWidth();\n }\n return pContainerClientWidth;\n}\n\nexport function getValueWithUnit(\n value: string | number | undefined,\n defaultValue: string | number\n): string | number {\n if (!value) return defaultValue;\n if (!value.toString().includes('px') && !value.toString().includes('%')) {\n return `${value}px`;\n }\n return `${value}`;\n}\n\nexport function getMaxHeight(viewMaxHeight: number | string | undefined): string {\n if (!viewMaxHeight) return 'none';\n return typeof viewMaxHeight === 'number' ? `${viewMaxHeight}px` : viewMaxHeight;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDragDrop.d.ts","sourceRoot":"","sources":["../../../Core/Hooks/useDragDrop.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAe,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE5F;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,OAAO,EACP,WAAuB,EACvB,SAAqB,EACrB,WAAuB,EACvB,WAAuB,EACvB,MAAM,EACN,gBAAuB,EACvB,oBAAoB,EACpB,iBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EACjB,EAAE,gBAAgB,GAAG,iBAAiB,
|
|
1
|
+
{"version":3,"file":"useDragDrop.d.ts","sourceRoot":"","sources":["../../../Core/Hooks/useDragDrop.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAe,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE5F;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,OAAO,EACP,WAAuB,EACvB,SAAqB,EACrB,WAAuB,EACvB,WAAuB,EACvB,MAAM,EACN,gBAAuB,EACvB,oBAAoB,EACpB,iBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EACjB,EAAE,gBAAgB,GAAG,iBAAiB,CAgStC"}
|
|
@@ -126,6 +126,8 @@ export default function useDragDrop({ context, onDragStart = undefined, onDragEn
|
|
|
126
126
|
ref.contextDragOverCb = contextDragOverCb;
|
|
127
127
|
setGhostImage(ev);
|
|
128
128
|
ev.dataTransfer.effectAllowed = 'move';
|
|
129
|
+
// Setting up some dummy data to make drag drop work in firefox. Refer https://medium.com/%40reiberdatschi/common-pitfalls-with-html5-drag-n-drop-api-9f011a09ee6c
|
|
130
|
+
ev.dataTransfer.setData('text/plain', 'RS_Dragged_Item');
|
|
129
131
|
// fail safe reset drag target.
|
|
130
132
|
if (ref.dragTarget)
|
|
131
133
|
ref.dragTarget = undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDragDrop.js","sourceRoot":"","sources":["../../../Core/Hooks/useDragDrop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAIrD;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,OAAO,EACP,WAAW,GAAG,SAAS,EACvB,SAAS,GAAG,SAAS,EACrB,WAAW,GAAG,SAAS,EACvB,WAAW,GAAG,SAAS,EACvB,MAAM,EACN,gBAAgB,GAAG,IAAI,EACvB,oBAAoB,EACpB,iBAAiB,GAAG,IAAI,EACxB,qBAAqB,EACrB,gBAAgB,EACC;IACjB,6FAA6F;IAC7F,MAAM,GAAG,GAAG,MAAM,CAAc;QAC9B,UAAU,EAAE,EAAE;QACd,eAAe,EAAE,IAAI;QACrB,UAAU,EAAE,SAAS;KACtB,CAAC,CAAC,OAAO,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a,EACnC,CAAC;YACD,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC9B,CAAC;IACH,CAAC,EACD,CAAC,GAAG,EAAE,gBAAgB,EAAE,WAAW,CAAC,CACrC,CAAC;IAEF,MAAM,SAAS,GAAG,OAAO,CACvB,GAAG,EAAE,CAAC,CAAC;QACL,SAAS,EAAE,IAAI;QACf,WAAW,EAAE,WAAW;QACxB,SAAS,EAAE,SAAS;KACrB,CAAC,EACF,CAAC,WAAW,EAAE,SAAS,CAAC,CACzB,CAAC;IAEF,MAAM,SAAS,GAAG,OAAO,CACvB,GAAG,EAAE,CAAC,CAAC;QACL,WAAW,EAAE,WAAW;QACxB,WAAW,EAAE,WAAW;QACxB,WAAW,EAAE,UAAU;KACxB,CAAC,EACF,CAAC,WAAW,EAAE,WAAW,CAAC,CAC3B,CAAC;IAEF,OAAO;QACL,SAAS;QACT,SAAS;KACV,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo, useRef } from 'react';\n\nimport type { DragDropRef, UseDragDropProps, UseDragDropReturn } from './useDragDrop.types';\n\n/**\n * A custom React hook to handle drag-and-drop functionality with support for animations,\n * ghost images, and collision detection.\n *\n * @param {UseDragDropProps} params - The parameters for configuring the drag-and-drop behavior.\n * See {@link UseDragDropProps} for details.\n * @returns {UseDragDropReturn} An object containing `dragProps` and `dropProps` to be spread onto draggable and droppable elements.\n * See {@link UseDragDropReturn} for details.\n */\nexport default function useDragDrop({\n context,\n onDragStart = undefined,\n onDragEnd = undefined,\n onDragEnter = undefined,\n onDragLeave = undefined,\n onDrop,\n defaultAnimation = true,\n getAnimationSelector,\n defaultGhostImage = true,\n getGhostImageSelector,\n getDraggedObject\n}: UseDragDropProps): UseDragDropReturn {\n // A way to fire dragleave when we actually come out of drop target not only a child of that.\n const ref = useRef<DragDropRef>({\n dropTarget: [],\n dropTargetCoord: null,\n dragTarget: undefined\n }).current;\n\n const addDragEffect = useCallback(\n (target: Element) => {\n if (defaultAnimation) {\n const t = getAnimationSelector ? getAnimationSelector(target) : target;\n const elms = Array.isArray(t) ? t : [t];\n elms.forEach(elm => {\n elm.style.opacity = '0.5';\n });\n }\n },\n [defaultAnimation, getAnimationSelector]\n );\n\n const removeDragEffect = useCallback(\n (target: Element) => {\n if (defaultAnimation) {\n const t = getAnimationSelector ? getAnimationSelector(target) : target;\n const elms = Array.isArray(t) ? t : [t];\n elms.forEach(elm => {\n elm.style.opacity = '1';\n });\n }\n },\n [defaultAnimation, getAnimationSelector]\n );\n\n const setGhostImage = useCallback(\n (e: React.DragEvent<Element>) => {\n if (defaultGhostImage) {\n const elem = (\n getGhostImageSelector ? getGhostImageSelector(e.currentTarget) : e.currentTarget\n ) as HTMLElement;\n const ghostElement = elem.cloneNode(true) as HTMLElement;\n if (ghostElement) {\n ghostElement.style.height = `${elem.style.height}px`;\n ghostElement.style.width = `${elem.style.width}px`;\n ghostElement.style.position = 'absolute';\n ghostElement.style.top = '-1000000px';\n ghostElement.style.left = '-10000000px';\n ghostElement.style.zIndex = '-1';\n }\n context.current?.appendChild(ghostElement);\n e.dataTransfer?.setDragImage(ghostElement, 0, 0);\n\n setTimeout(() => {\n ghostElement.parentNode?.removeChild(ghostElement);\n }, 1000);\n }\n },\n [getGhostImageSelector, context, defaultGhostImage]\n );\n\n const isColliding = useCallback((x: number, y: number, coord: DOMRect): boolean => {\n const smallBuffer = 2;\n return !(\n x < coord.left - smallBuffer ||\n x > coord.right + smallBuffer ||\n y > coord.bottom + smallBuffer ||\n y < coord.top - smallBuffer\n );\n }, []);\n\n const addDropEffect = useCallback(\n (target: Element) => {\n if (defaultAnimation) {\n const t = getAnimationSelector ? getAnimationSelector(target) : target;\n const elms = Array.isArray(t) ? t : [t];\n elms.forEach(elm => {\n // Need to handle this in better way.TODO: need clean up as well.\n elm.style.transition = 'transform 0.25s';\n elm.style.transform = 'translate(20px)';\n });\n }\n },\n [defaultAnimation, getAnimationSelector]\n );\n\n const removeDropEffect = useCallback(\n (target: Element) => {\n if (defaultAnimation) {\n const t = getAnimationSelector ? getAnimationSelector(target) : target;\n const elms = Array.isArray(t) ? t : [t];\n elms.forEach(elm => {\n elm.style.transform = 'translate(0px)';\n });\n }\n },\n [defaultAnimation, getAnimationSelector]\n );\n\n const contextDragOverCb = useCallback(\n (e: DragEvent) => {\n e.stopPropagation();\n e.preventDefault();\n if (\n ref.dragLeaveSkipped &&\n ref.dropTarget &&\n ref.dropTarget[ref.dropTarget.length - 1] &&\n ref.dropTargetCoord &&\n !isColliding(e.clientX, e.clientY, ref.dropTargetCoord)\n ) {\n ref.forcedDragLeave = true;\n ref.dragLeaveSkipped = false;\n const elm = ref.dropTarget.shift();\n ref.dropTarget = [...ref.dropTarget];\n elm?.dispatchEvent(\n new MouseEvent('dragleave', {\n bubbles: true,\n cancelable: true,\n view: window\n })\n );\n }\n },\n [isColliding, ref]\n );\n\n const contextDropCb = useCallback(\n (ev: DragEvent) => {\n ev.stopPropagation();\n ev.preventDefault();\n const elm = ref.dropTarget[ref.dropTarget.length - 1] as HTMLElement;\n if (\n ref.dropTargetCoord &&\n elm !== ref.dragTarget &&\n isColliding(ev.clientX, ev.clientY, ref.dropTargetCoord)\n ) {\n removeDropEffect(elm);\n elm.classList.remove('dragEnter');\n if (onDrop && ref.dragTarget) onDrop(elm, ref.dragTarget);\n ref.dragTarget = undefined;\n ref.dropTargetCoord = null;\n ref.dropTarget = [];\n }\n },\n [ref, isColliding, removeDropEffect, onDrop]\n );\n\n const dragStartCb = useCallback(\n (ev: React.DragEvent<HTMLElement>) => {\n document.addEventListener('dragover', contextDragOverCb);\n context.current?.addEventListener('drop', contextDropCb);\n\n // clear the drag operation's data store when drag starts as its the only time when drag data is writable\n if (ev.dataTransfer) ev.dataTransfer.clearData();\n\n // We have to keep event handler in reference so that we can remove right handler when drag ends.\n // Handler might change in between because of deps.\n ref.contextDropCb = contextDropCb;\n ref.contextDragOverCb = contextDragOverCb;\n\n setGhostImage(ev);\n ev.dataTransfer.effectAllowed = 'move';\n // fail safe reset drag target.\n if (ref.dragTarget) ref.dragTarget = undefined;\n ref.dragTarget = getDraggedObject ? getDraggedObject(ev.currentTarget) : ev.currentTarget;\n ev.currentTarget.classList.add('dragStart');\n addDragEffect(ev.currentTarget);\n if (onDragStart) onDragStart(ev);\n },\n [\n contextDragOverCb,\n context,\n contextDropCb,\n setGhostImage,\n ref,\n getDraggedObject,\n addDragEffect,\n onDragStart\n ]\n );\n\n const dragEndCb = useCallback(\n (ev: React.DragEvent<HTMLElement>) => {\n if (ref.contextDragOverCb) document.removeEventListener('dragover', ref.contextDragOverCb);\n if (ref.contextDropCb) context.current?.removeEventListener('drop', ref.contextDropCb);\n ref.dropTarget = [];\n ref.dropTargetCoord = null;\n ref.forcedDragLeave = false;\n ref.dragLeaveSkipped = false;\n ev.currentTarget.classList.remove('dragStart');\n removeDragEffect(ev.currentTarget);\n if (onDragEnd) onDragEnd(ev);\n },\n [onDragEnd, removeDragEffect, context, ref]\n );\n\n const isValidDragEnter = useCallback(\n (e: React.DragEvent<Element>) => {\n let isValid = true;\n if (ref.dragTarget === e.currentTarget) isValid = false;\n else if (ref.dropTarget[ref.dropTarget.length - 1] === e.currentTarget) isValid = false;\n else if (\n ref.dropTarget[ref.dropTarget.length - 1] &&\n ref.dropTarget[ref.dropTarget.length - 1] !== e.currentTarget\n ) {\n const currentTargetCoord = e.currentTarget.getBoundingClientRect();\n const dropTargetCoord = ref.dropTarget[ref.dropTarget.length - 1].getBoundingClientRect();\n if (\n !isColliding(e.clientX, e.clientY, currentTargetCoord) &&\n isColliding(e.clientX, e.clientY, dropTargetCoord)\n )\n isValid = false;\n }\n return isValid;\n },\n [ref, isColliding]\n );\n\n const dragEnterCb = useCallback(\n (ev: React.DragEvent<HTMLElement>) => {\n ev.stopPropagation();\n if (isValidDragEnter(ev)) {\n ref.dropTarget = ref.dropTarget.length ? [...ref.dropTarget] : [];\n ref.dropTarget.push(ev.currentTarget);\n ev.currentTarget.classList.add('dragEnter');\n ev.dataTransfer.dropEffect = 'move';\n ref.dropTargetCoord = ev.currentTarget.getBoundingClientRect();\n addDropEffect(ev.currentTarget);\n if (onDragEnter) onDragEnter(ev);\n\n if (ref.dropTarget.length > 1) {\n const elm = ref.dropTarget.shift();\n ref.dropTarget = [...ref.dropTarget];\n ref.forcedDragLeave = true;\n elm?.dispatchEvent(\n new MouseEvent('dragleave', {\n bubbles: true,\n cancelable: true,\n view: window\n })\n );\n }\n }\n },\n [onDragEnter, addDropEffect, ref, isValidDragEnter]\n );\n\n const dragLeaveCb = useCallback(\n (ev: React.DragEvent<HTMLElement>) => {\n ev.stopPropagation();\n if (ref.forcedDragLeave) {\n ref.forcedDragLeave = false;\n ev.currentTarget.classList.remove('dragEnter');\n removeDropEffect(ev.currentTarget);\n if (onDragLeave) onDragLeave(ev);\n } else if (\n !ev.currentTarget.contains(ev.relatedTarget as Element) &&\n ref.dragTarget !== ev.currentTarget\n ) {\n ref.dragLeaveSkipped = true;\n }\n },\n [ref, removeDropEffect, onDragLeave]\n );\n\n const dragProps = useMemo(\n () => ({\n draggable: true,\n onDragStart: dragStartCb,\n onDragEnd: dragEndCb\n }),\n [dragStartCb, dragEndCb]\n );\n\n const dropProps = useMemo(\n () => ({\n onDragEnter: dragEnterCb,\n onDragLeave: dragLeaveCb,\n 'data-drop': 'dropzone'\n }),\n [dragEnterCb, dragLeaveCb]\n );\n\n return {\n dragProps,\n dropProps\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useDragDrop.js","sourceRoot":"","sources":["../../../Core/Hooks/useDragDrop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAIrD;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,OAAO,EACP,WAAW,GAAG,SAAS,EACvB,SAAS,GAAG,SAAS,EACrB,WAAW,GAAG,SAAS,EACvB,WAAW,GAAG,SAAS,EACvB,MAAM,EACN,gBAAgB,GA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AC;YAC5B,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YAC/C,gBAAgB,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;YACnC,IAAI,WAAW;gBAAE,WAAW,CAAC,EAAE,CAAC,CAAC;QACnC,CAAC;aAAM,IACL,CAAC,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,aAAwB,CAAC;YACvD,GAAG,CAAC,UAAU,KAAK,EAAE,CAAC,aAAa,EACnC,CAAC;YACD,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC9B,CAAC;IACH,CAAC,EACD,CAAC,GAAG,EAAE,gBAAgB,EAAE,WAAW,CAAC,CACrC,CAAC;IAEF,MAAM,SAAS,GAAG,OAAO,CACvB,GAAG,EAAE,CAAC,CAAC;QACL,SAAS,EAAE,IAAI;QACf,WAAW,EAAE,WAAW;QACxB,SAAS,EAAE,SAAS;KACrB,CAAC,EACF,CAAC,WAAW,EAAE,SAAS,CAAC,CACzB,CAAC;IAEF,MAAM,SAAS,GAAG,OAAO,CACvB,GAAG,EAAE,CAAC,CAAC;QACL,WAAW,EAAE,WAAW;QACxB,WAAW,EAAE,WAAW;QACxB,WAAW,EAAE,UAAU;KACxB,CAAC,EACF,CAAC,WAAW,EAAE,WAAW,CAAC,CAC3B,CAAC;IAEF,OAAO;QACL,SAAS;QACT,SAAS;KACV,CAAC;AACJ,CAAC","sourcesContent":["import { useCallback, useMemo, useRef } from 'react';\n\nimport type { DragDropRef, UseDragDropProps, UseDragDropReturn } from './useDragDrop.types';\n\n/**\n * A custom React hook to handle drag-and-drop functionality with support for animations,\n * ghost images, and collision detection.\n *\n * @param {UseDragDropProps} params - The parameters for configuring the drag-and-drop behavior.\n * See {@link UseDragDropProps} for details.\n * @returns {UseDragDropReturn} An object containing `dragProps` and `dropProps` to be spread onto draggable and droppable elements.\n * See {@link UseDragDropReturn} for details.\n */\nexport default function useDragDrop({\n context,\n onDragStart = undefined,\n onDragEnd = undefined,\n onDragEnter = undefined,\n onDragLeave = undefined,\n onDrop,\n defaultAnimation = true,\n getAnimationSelector,\n defaultGhostImage = true,\n getGhostImageSelector,\n getDraggedObject\n}: UseDragDropProps): UseDragDropReturn {\n // A way to fire dragleave when we actually come out of drop target not only a child of that.\n const ref = useRef<DragDropRef>({\n dropTarget: [],\n dropTargetCoord: null,\n dragTarget: undefined\n }).current;\n\n const addDragEffect = useCallback(\n (target: Element) => {\n if (defaultAnimation) {\n const t = getAnimationSelector ? getAnimationSelector(target) : target;\n const elms = Array.isArray(t) ? t : [t];\n elms.forEach(elm => {\n elm.style.opacity = '0.5';\n });\n }\n },\n [defaultAnimation, getAnimationSelector]\n );\n\n const removeDragEffect = useCallback(\n (target: Element) => {\n if (defaultAnimation) {\n const t = getAnimationSelector ? getAnimationSelector(target) : target;\n const elms = Array.isArray(t) ? t : [t];\n elms.forEach(elm => {\n elm.style.opacity = '1';\n });\n }\n },\n [defaultAnimation, getAnimationSelector]\n );\n\n const setGhostImage = useCallback(\n (e: React.DragEvent<Element>) => {\n if (defaultGhostImage) {\n const elem = (\n getGhostImageSelector ? getGhostImageSelector(e.currentTarget) : e.currentTarget\n ) as HTMLElement;\n const ghostElement = elem.cloneNode(true) as HTMLElement;\n if (ghostElement) {\n ghostElement.style.height = `${elem.style.height}px`;\n ghostElement.style.width = `${elem.style.width}px`;\n ghostElement.style.position = 'absolute';\n ghostElement.style.top = '-1000000px';\n ghostElement.style.left = '-10000000px';\n ghostElement.style.zIndex = '-1';\n }\n context.current?.appendChild(ghostElement);\n e.dataTransfer?.setDragImage(ghostElement, 0, 0);\n\n setTimeout(() => {\n ghostElement.parentNode?.removeChild(ghostElement);\n }, 1000);\n }\n },\n [getGhostImageSelector, context, defaultGhostImage]\n );\n\n const isColliding = useCallback((x: number, y: number, coord: DOMRect): boolean => {\n const smallBuffer = 2;\n return !(\n x < coord.left - smallBuffer ||\n x > coord.right + smallBuffer ||\n y > coord.bottom + smallBuffer ||\n y < coord.top - smallBuffer\n );\n }, []);\n\n const addDropEffect = useCallback(\n (target: Element) => {\n if (defaultAnimation) {\n const t = getAnimationSelector ? getAnimationSelector(target) : target;\n const elms = Array.isArray(t) ? t : [t];\n elms.forEach(elm => {\n // Need to handle this in better way.TODO: need clean up as well.\n elm.style.transition = 'transform 0.25s';\n elm.style.transform = 'translate(20px)';\n });\n }\n },\n [defaultAnimation, getAnimationSelector]\n );\n\n const removeDropEffect = useCallback(\n (target: Element) => {\n if (defaultAnimation) {\n const t = getAnimationSelector ? getAnimationSelector(target) : target;\n const elms = Array.isArray(t) ? t : [t];\n elms.forEach(elm => {\n elm.style.transform = 'translate(0px)';\n });\n }\n },\n [defaultAnimation, getAnimationSelector]\n );\n\n const contextDragOverCb = useCallback(\n (e: DragEvent) => {\n e.stopPropagation();\n e.preventDefault();\n if (\n ref.dragLeaveSkipped &&\n ref.dropTarget &&\n ref.dropTarget[ref.dropTarget.length - 1] &&\n ref.dropTargetCoord &&\n !isColliding(e.clientX, e.clientY, ref.dropTargetCoord)\n ) {\n ref.forcedDragLeave = true;\n ref.dragLeaveSkipped = false;\n const elm = ref.dropTarget.shift();\n ref.dropTarget = [...ref.dropTarget];\n elm?.dispatchEvent(\n new MouseEvent('dragleave', {\n bubbles: true,\n cancelable: true,\n view: window\n })\n );\n }\n },\n [isColliding, ref]\n );\n\n const contextDropCb = useCallback(\n (ev: DragEvent) => {\n ev.stopPropagation();\n ev.preventDefault();\n const elm = ref.dropTarget[ref.dropTarget.length - 1] as HTMLElement;\n if (\n ref.dropTargetCoord &&\n elm !== ref.dragTarget &&\n isColliding(ev.clientX, ev.clientY, ref.dropTargetCoord)\n ) {\n removeDropEffect(elm);\n elm.classList.remove('dragEnter');\n if (onDrop && ref.dragTarget) onDrop(elm, ref.dragTarget);\n ref.dragTarget = undefined;\n ref.dropTargetCoord = null;\n ref.dropTarget = [];\n }\n },\n [ref, isColliding, removeDropEffect, onDrop]\n );\n\n const dragStartCb = useCallback(\n (ev: React.DragEvent<HTMLElement>) => {\n document.addEventListener('dragover', contextDragOverCb);\n context.current?.addEventListener('drop', contextDropCb);\n\n // clear the drag operation's data store when drag starts as its the only time when drag data is writable\n if (ev.dataTransfer) ev.dataTransfer.clearData();\n\n // We have to keep event handler in reference so that we can remove right handler when drag ends.\n // Handler might change in between because of deps.\n ref.contextDropCb = contextDropCb;\n ref.contextDragOverCb = contextDragOverCb;\n\n setGhostImage(ev);\n ev.dataTransfer.effectAllowed = 'move';\n // Setting up some dummy data to make drag drop work in firefox. Refer https://medium.com/%40reiberdatschi/common-pitfalls-with-html5-drag-n-drop-api-9f011a09ee6c\n ev.dataTransfer.setData('text/plain', 'RS_Dragged_Item');\n // fail safe reset drag target.\n if (ref.dragTarget) ref.dragTarget = undefined;\n ref.dragTarget = getDraggedObject ? getDraggedObject(ev.currentTarget) : ev.currentTarget;\n ev.currentTarget.classList.add('dragStart');\n addDragEffect(ev.currentTarget);\n if (onDragStart) onDragStart(ev);\n },\n [\n contextDragOverCb,\n context,\n contextDropCb,\n setGhostImage,\n ref,\n getDraggedObject,\n addDragEffect,\n onDragStart\n ]\n );\n\n const dragEndCb = useCallback(\n (ev: React.DragEvent<HTMLElement>) => {\n if (ref.contextDragOverCb) document.removeEventListener('dragover', ref.contextDragOverCb);\n if (ref.contextDropCb) context.current?.removeEventListener('drop', ref.contextDropCb);\n ref.dropTarget = [];\n ref.dropTargetCoord = null;\n ref.forcedDragLeave = false;\n ref.dragLeaveSkipped = false;\n ev.currentTarget.classList.remove('dragStart');\n removeDragEffect(ev.currentTarget);\n if (onDragEnd) onDragEnd(ev);\n },\n [onDragEnd, removeDragEffect, context, ref]\n );\n\n const isValidDragEnter = useCallback(\n (e: React.DragEvent<Element>) => {\n let isValid = true;\n if (ref.dragTarget === e.currentTarget) isValid = false;\n else if (ref.dropTarget[ref.dropTarget.length - 1] === e.currentTarget) isValid = false;\n else if (\n ref.dropTarget[ref.dropTarget.length - 1] &&\n ref.dropTarget[ref.dropTarget.length - 1] !== e.currentTarget\n ) {\n const currentTargetCoord = e.currentTarget.getBoundingClientRect();\n const dropTargetCoord = ref.dropTarget[ref.dropTarget.length - 1].getBoundingClientRect();\n if (\n !isColliding(e.clientX, e.clientY, currentTargetCoord) &&\n isColliding(e.clientX, e.clientY, dropTargetCoord)\n )\n isValid = false;\n }\n return isValid;\n },\n [ref, isColliding]\n );\n\n const dragEnterCb = useCallback(\n (ev: React.DragEvent<HTMLElement>) => {\n ev.stopPropagation();\n if (isValidDragEnter(ev)) {\n ref.dropTarget = ref.dropTarget.length ? [...ref.dropTarget] : [];\n ref.dropTarget.push(ev.currentTarget);\n ev.currentTarget.classList.add('dragEnter');\n ev.dataTransfer.dropEffect = 'move';\n ref.dropTargetCoord = ev.currentTarget.getBoundingClientRect();\n addDropEffect(ev.currentTarget);\n if (onDragEnter) onDragEnter(ev);\n\n if (ref.dropTarget.length > 1) {\n const elm = ref.dropTarget.shift();\n ref.dropTarget = [...ref.dropTarget];\n ref.forcedDragLeave = true;\n elm?.dispatchEvent(\n new MouseEvent('dragleave', {\n bubbles: true,\n cancelable: true,\n view: window\n })\n );\n }\n }\n },\n [onDragEnter, addDropEffect, ref, isValidDragEnter]\n );\n\n const dragLeaveCb = useCallback(\n (ev: React.DragEvent<HTMLElement>) => {\n ev.stopPropagation();\n if (ref.forcedDragLeave) {\n ref.forcedDragLeave = false;\n ev.currentTarget.classList.remove('dragEnter');\n removeDropEffect(ev.currentTarget);\n if (onDragLeave) onDragLeave(ev);\n } else if (\n !ev.currentTarget.contains(ev.relatedTarget as Element) &&\n ref.dragTarget !== ev.currentTarget\n ) {\n ref.dragLeaveSkipped = true;\n }\n },\n [ref, removeDropEffect, onDragLeave]\n );\n\n const dragProps = useMemo(\n () => ({\n draggable: true,\n onDragStart: dragStartCb,\n onDragEnd: dragEndCb\n }),\n [dragStartCb, dragEndCb]\n );\n\n const dropProps = useMemo(\n () => ({\n onDragEnter: dragEnterCb,\n onDragLeave: dragLeaveCb,\n 'data-drop': 'dropzone'\n }),\n [dragEnterCb, dragLeaveCb]\n );\n\n return {\n dragProps,\n dropProps\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultTranslations.d.ts","sourceRoot":"","sources":["../../../Core/Localization/defaultTranslations.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"defaultTranslations.d.ts","sourceRoot":"","sources":["../../../Core/Localization/defaultTranslations.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0KxB,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -161,7 +161,8 @@ const defaultTranslations = {
|
|
|
161
161
|
'Show/Hide modified': 'Show/Hide modified',
|
|
162
162
|
'Freeze applied': 'Freeze applied',
|
|
163
163
|
'Freeze modified': 'Freeze modified',
|
|
164
|
-
'Freeze removed': 'Freeze removed'
|
|
164
|
+
'Freeze removed': 'Freeze removed',
|
|
165
|
+
Count: 'Count'
|
|
165
166
|
};
|
|
166
167
|
export default defaultTranslations;
|
|
167
168
|
//# sourceMappingURL=defaultTranslations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultTranslations.js","sourceRoot":"","sources":["../../../Core/Localization/defaultTranslations.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,MAAM,mBAAmB,GAAG;IAC1B,MAAM,EAAE,QAAQ;IAChB,mBAAmB,EAAE,mBAAmB;IACxC,cAAc,EAAE,cAAc;IAC9B,WAAW,EAAE,WAAW;IACxB,cAAc,EAAE,cAAc;IAC9B,eAAe,EAAE,eAAe;IAChC,IAAI,EA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IAClD,0CAA0C,EAAE,sCAAsC;IAClF,aAAa,EAAE,0BAA0B;IACzC,0BAA0B,EAAE,qDAAqD;IACjF,mBAAmB,EAAE,iCAAiC;IACtD,uBAAuB,EAAE,qCAAqC;IAC9D,YAAY,EAAE,oBAAoB;IAClC,yBAAyB,EAAE,+CAA+C;IAC1E,YAAY,EAAE,oBAAoB;IAClC,4BAA4B,EAAE,qDAAqD;IACnF,oBAAoB,EAAE,oBAAoB;IAC1C,gBAAgB,EAAE,gBAAgB;IAClC,iBAAiB,EAAE,iBAAiB;IACpC,gBAAgB,EAAE,gBAAgB;CACnC,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["// FIXME: Move this file to Demo folder once the typings are available from cosmos translations pack\nconst defaultTranslations = {\n Submit: 'Submit',\n 'Hide header icons': 'Hide header icons',\n 'Column name:': 'Column name:',\n 'Template:': 'Template:',\n 'Hide columns': 'Hide columns',\n 'Remove filter': 'Remove filter',\n Year: 'Year',\n Quarter: 'Quarter',\n Month: 'Month',\n Week: 'Week',\n Day: 'Day',\n Hour: 'Hour',\n Minute: 'Minute',\n 'Month of year': 'Month of year',\n 'Day of month': 'Day of month',\n 'Day of week': 'Day of week',\n 'Hour of day': 'Hour of day',\n Add: 'Add',\n Aggregate: 'Aggregate',\n Cancel: 'Cancel',\n Ok: 'Ok',\n 'has unsaved changes, do you want to discard and proceed?':\n 'has unsaved changes, do you want to discard and proceed?',\n Actions: 'Actions',\n actions: 'actions',\n 'Edit details': 'Edit details',\n 'Change stage': 'Change stage',\n Preview: 'Preview',\n 'Open in a new tab': 'Open in a new tab',\n Edit: 'Edit',\n 'Copy text': 'Copy text',\n 'Paste text': 'Paste text',\n 'Filter by this': 'Filter by this',\n 'Open link in new tab': 'Open link in new tab',\n default: 'default',\n Grouping: 'Grouping',\n to: 'to',\n Filter: 'Filter',\n Freeze: 'Freeze',\n Hide: 'Hide',\n Summarize: 'Summarize',\n 'Combine with left': 'Combine with left',\n 'Combine with right': 'Combine with right',\n Delete: 'Delete',\n Format: 'Format',\n Alias: 'Alias',\n 'Enter alias': 'Enter alias',\n 'Filter by': 'Filter by',\n Group: 'Group',\n 'Group by': 'Group by',\n Sort: 'Sort',\n 'Sort by': 'Sort by',\n 'Row density': 'Row density',\n 'Show/hide columns': 'Show/hide columns',\n 'Freeze columns': 'Freeze columns',\n 'Save view as..': 'Save view as..',\n 'Save changes': 'Save changes',\n 'View as...': 'View as...',\n 'Edit view': 'Edit view',\n 'Set as default': 'Set as default',\n 'Mark as default?': 'Mark as default?',\n 'Mark as app default': 'Mark as app default',\n 'Delete view': 'Delete view',\n 'Reset column widths': 'Reset column widths',\n 'Auto size columns': 'Auto size columns',\n ShowHeaderIcons: 'ShowHeaderIcons',\n 'Query info': 'Query info',\n 'Export to Excel': 'Export to Excel',\n 'Export to CSV': 'Export to CSV',\n Class: 'Class',\n 'Data page': 'Data page',\n 'Data source': 'Data source',\n 'Time taken': 'Time taken',\n 'Insight ID': 'Insight ID',\n 'Undo hierarchy': 'Undo hierarchy',\n Normal: 'Normal',\n Hierarchical: 'Hierarchical',\n Display: 'Display',\n table: 'table',\n 'Use arrow keys or Shift plus Alt plus arrow keys to navigate':\n 'Use arrow keys or Shift plus Alt plus arrow keys to navigate',\n 'No actions available': 'No actions available',\n 'Use Enter to open header menu': 'Use Enter to open header menu',\n 'Loading more results': 'Loading more results',\n Sorted: 'Sorted',\n 'Sort priority': 'Sort priority',\n 'Filtered column': 'Filtered column',\n Ascending: 'Ascending',\n Descending: 'Descending',\n Select: 'Select',\n 'Select all': 'Select all',\n 'Collapse all groups': 'Collapse all groups',\n 'Expand all groups': 'Expand all groups',\n Sum: 'Sum',\n Min: 'Min',\n Max: 'Max',\n Avg: 'Avg',\n 'Aggregate options': 'Aggregate options',\n 'Select two or more items to enable bulk actions':\n 'Select two or more items to enable bulk actions',\n 'Bulk actions': 'Bulk actions',\n 'Group applied': 'Group applied',\n 'Group modified': 'Group modified',\n 'Group removed': 'Group removed',\n Loading: 'Loading',\n 'Loading completed': 'Loading completed',\n 'name is reserved for non Personalized view and cannot be used.':\n 'name is reserved for non Personalized view and cannot be used.',\n 'This view is already present.': 'This view is already present.',\n 'This view name cannot be empty.': 'This view name cannot be empty.',\n 'View name must contain less than 65 characters.':\n 'View name must contain less than 65 characters.',\n 'Sort order': 'Sort order',\n Field: 'Field',\n 'Column name cannot be empty.': 'Column name cannot be empty.',\n 'Sort ascending': 'Sort ascending',\n 'Sort descending': 'Sort descending',\n 'Remove sort': 'Remove sort',\n 'No records found.': 'No records found.',\n 'Clear filter': 'Clear filter',\n Equals: 'Equals',\n 'Not equals': 'Not equals',\n After: 'After',\n Before: 'Before',\n 'On or after': 'On or after',\n 'On or before': 'On or before',\n 'Greater than': 'Greater than',\n 'Less than': 'Less than',\n 'Greater than or equals': 'Greater than or equals',\n 'Less than or equals': 'Less than or equals',\n 'Starts with': 'Starts with',\n 'Not starts with': 'Not starts with',\n 'Ends with': 'Ends with',\n 'Not ends with': 'Not ends with',\n Contains: 'Contains',\n 'Not contains': 'Not contains',\n 'Is any of': 'Is any of',\n 'Is not any of': 'Is not any of',\n 'Is null': 'Is null',\n 'Is not null': 'Is not null',\n true: 'true',\n false: 'false',\n 'Interactive content': 'Interactive content',\n 'Filter value': 'Filter value',\n 'Filter comparison': 'Filter comparison',\n state: 'state',\n 'Filter column': 'Filter column',\n Refresh: 'Refresh',\n table_a11y_intro: 'Tab or click into the grid to use key commands.',\n table_a11y_instructions_arrow_keys_label: 'Arrow keys or Shift+Alt+Arrow keys',\n table_a11y_instructions_arrow_keys_description: 'navigate cells',\n table_a11y_instructions_enter_label: 'Enter key',\n table_a11y_instructions_enter_description:\n 'when on a cell with editable controls, switches to Tab navigation mode. Tab key now navigates between all interactive controls in the grid',\n table_a11y_instructions_escape_label: 'Escape key',\n table_a11y_instructions_escape_description: 'restores arrow-based grid navigation',\n saved_changes: '\"{0}\" saved with changes',\n saved_changes_with_default: '\"{0}\" saved with changes and marked as default view',\n view_marked_default: '\"{0}\" view is marked as Default',\n view_marked_app_default: '\"{0}\" view is marked as App Default',\n created_view: 'Created view \"{0}\"',\n created_view_with_default: 'Created view \"{0}\" and marked as default view',\n deleted_view: 'Deleted view \"{0}\"',\n view_navigation_instructions: '{0}, Refer to keyboard instructions for navigation.',\n 'Show/Hide modified': 'Show/Hide modified',\n 'Freeze applied': 'Freeze applied',\n 'Freeze modified': 'Freeze modified',\n 'Freeze removed': 'Freeze removed'\n};\n\nexport default defaultTranslations;\n"]}
|
|
1
|
+
{"version":3,"file":"defaultTranslations.js","sourceRoot":"","sources":["../../../Core/Localization/defaultTranslations.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,MAAM,mBAAmB,GAAG;IAC1B,MAAM,EAAE,QAAQ;IAChB,mBAAmB,EAAE,mBAAmB;IACxC,cAAc,EAAE,cAAc;IAC9B,WAAW,EAAE,WAAW;IACxB,cAAc,EAAE,cAAc;IAC9B,eAAe,EAAE,eAAe;IAChC,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,eAAe,EAAE,eAAe;IAChC,cAAc,EAAE,cAAc;IAC9B,aAAa,EAAE,aAAa;IAC5B,aAAa,EAAE,aAAa;IAC5B,GAAG,EAAE,KAAK;IACV,SAAS,EAAE,WAAW;IACtB,MAAM,EAAE,QAAQ;IAChB,EAAE,EAAE,IAAI;IACR,0DAA0D,EACxD,0DAA0D;IAC5D,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,cAAc,EAAE,cAAc;IAC9B,cAAc,EAAE,cAAc;IAC9B,OAAO,EAAE,SAAS;IAClB,mBAAmB,EAAE,mBAAmB;IACxC,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,WAAW;IACxB,YAAY,EAAE,YAAY;IAC1B,gBAAgB,EAAE,gB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,aAAa;IAC5B,iBAAiB,EAAE,iBAAiB;IACpC,WAAW,EAAE,WAAW;IACxB,eAAe,EAAE,eAAe;IAChC,QAAQ,EAAE,UAAU;IACpB,cAAc,EAAE,cAAc;IAC9B,WAAW,EAAE,WAAW;IACxB,eAAe,EAAE,eAAe;IAChC,SAAS,EAAE,SAAS;IACpB,aAAa,EAAE,aAAa;IAC5B,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,qBAAqB,EAAE,qBAAqB;IAC5C,cAAc,EAAE,cAAc;IAC9B,mBAAmB,EAAE,mBAAmB;IACxC,KAAK,EAAE,OAAO;IACd,eAAe,EAAE,eAAe;IAChC,OAAO,EAAE,SAAS;IAClB,gBAAgB,EAAE,iDAAiD;IACnE,wCAAwC,EAAE,oCAAoC;IAC9E,8CAA8C,EAAE,gBAAgB;IAChE,mCAAmC,EAAE,WAAW;IAChD,yCAAyC,EACvC,4IAA4I;IAC9I,oCAAoC,EAAE,YAAY;IAClD,0CAA0C,EAAE,sCAAsC;IAClF,aAAa,EAAE,0BAA0B;IACzC,0BAA0B,EAAE,qDAAqD;IACjF,mBAAmB,EAAE,iCAAiC;IACtD,uBAAuB,EAAE,qCAAqC;IAC9D,YAAY,EAAE,oBAAoB;IAClC,yBAAyB,EAAE,+CAA+C;IAC1E,YAAY,EAAE,oBAAoB;IAClC,4BAA4B,EAAE,qDAAqD;IACnF,oBAAoB,EAAE,oBAAoB;IAC1C,gBAAgB,EAAE,gBAAgB;IAClC,iBAAiB,EAAE,iBAAiB;IACpC,gBAAgB,EAAE,gBAAgB;IAClC,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["// FIXME: Move this file to Demo folder once the typings are available from cosmos translations pack\nconst defaultTranslations = {\n Submit: 'Submit',\n 'Hide header icons': 'Hide header icons',\n 'Column name:': 'Column name:',\n 'Template:': 'Template:',\n 'Hide columns': 'Hide columns',\n 'Remove filter': 'Remove filter',\n Year: 'Year',\n Quarter: 'Quarter',\n Month: 'Month',\n Week: 'Week',\n Day: 'Day',\n Hour: 'Hour',\n Minute: 'Minute',\n 'Month of year': 'Month of year',\n 'Day of month': 'Day of month',\n 'Day of week': 'Day of week',\n 'Hour of day': 'Hour of day',\n Add: 'Add',\n Aggregate: 'Aggregate',\n Cancel: 'Cancel',\n Ok: 'Ok',\n 'has unsaved changes, do you want to discard and proceed?':\n 'has unsaved changes, do you want to discard and proceed?',\n Actions: 'Actions',\n actions: 'actions',\n 'Edit details': 'Edit details',\n 'Change stage': 'Change stage',\n Preview: 'Preview',\n 'Open in a new tab': 'Open in a new tab',\n Edit: 'Edit',\n 'Copy text': 'Copy text',\n 'Paste text': 'Paste text',\n 'Filter by this': 'Filter by this',\n 'Open link in new tab': 'Open link in new tab',\n default: 'default',\n Grouping: 'Grouping',\n to: 'to',\n Filter: 'Filter',\n Freeze: 'Freeze',\n Hide: 'Hide',\n Summarize: 'Summarize',\n 'Combine with left': 'Combine with left',\n 'Combine with right': 'Combine with right',\n Delete: 'Delete',\n Format: 'Format',\n Alias: 'Alias',\n 'Enter alias': 'Enter alias',\n 'Filter by': 'Filter by',\n Group: 'Group',\n 'Group by': 'Group by',\n Sort: 'Sort',\n 'Sort by': 'Sort by',\n 'Row density': 'Row density',\n 'Show/hide columns': 'Show/hide columns',\n 'Freeze columns': 'Freeze columns',\n 'Save view as..': 'Save view as..',\n 'Save changes': 'Save changes',\n 'View as...': 'View as...',\n 'Edit view': 'Edit view',\n 'Set as default': 'Set as default',\n 'Mark as default?': 'Mark as default?',\n 'Mark as app default': 'Mark as app default',\n 'Delete view': 'Delete view',\n 'Reset column widths': 'Reset column widths',\n 'Auto size columns': 'Auto size columns',\n ShowHeaderIcons: 'ShowHeaderIcons',\n 'Query info': 'Query info',\n 'Export to Excel': 'Export to Excel',\n 'Export to CSV': 'Export to CSV',\n Class: 'Class',\n 'Data page': 'Data page',\n 'Data source': 'Data source',\n 'Time taken': 'Time taken',\n 'Insight ID': 'Insight ID',\n 'Undo hierarchy': 'Undo hierarchy',\n Normal: 'Normal',\n Hierarchical: 'Hierarchical',\n Display: 'Display',\n table: 'table',\n 'Use arrow keys or Shift plus Alt plus arrow keys to navigate':\n 'Use arrow keys or Shift plus Alt plus arrow keys to navigate',\n 'No actions available': 'No actions available',\n 'Use Enter to open header menu': 'Use Enter to open header menu',\n 'Loading more results': 'Loading more results',\n Sorted: 'Sorted',\n 'Sort priority': 'Sort priority',\n 'Filtered column': 'Filtered column',\n Ascending: 'Ascending',\n Descending: 'Descending',\n Select: 'Select',\n 'Select all': 'Select all',\n 'Collapse all groups': 'Collapse all groups',\n 'Expand all groups': 'Expand all groups',\n Sum: 'Sum',\n Min: 'Min',\n Max: 'Max',\n Avg: 'Avg',\n 'Aggregate options': 'Aggregate options',\n 'Select two or more items to enable bulk actions':\n 'Select two or more items to enable bulk actions',\n 'Bulk actions': 'Bulk actions',\n 'Group applied': 'Group applied',\n 'Group modified': 'Group modified',\n 'Group removed': 'Group removed',\n Loading: 'Loading',\n 'Loading completed': 'Loading completed',\n 'name is reserved for non Personalized view and cannot be used.':\n 'name is reserved for non Personalized view and cannot be used.',\n 'This view is already present.': 'This view is already present.',\n 'This view name cannot be empty.': 'This view name cannot be empty.',\n 'View name must contain less than 65 characters.':\n 'View name must contain less than 65 characters.',\n 'Sort order': 'Sort order',\n Field: 'Field',\n 'Column name cannot be empty.': 'Column name cannot be empty.',\n 'Sort ascending': 'Sort ascending',\n 'Sort descending': 'Sort descending',\n 'Remove sort': 'Remove sort',\n 'No records found.': 'No records found.',\n 'Clear filter': 'Clear filter',\n Equals: 'Equals',\n 'Not equals': 'Not equals',\n After: 'After',\n Before: 'Before',\n 'On or after': 'On or after',\n 'On or before': 'On or before',\n 'Greater than': 'Greater than',\n 'Less than': 'Less than',\n 'Greater than or equals': 'Greater than or equals',\n 'Less than or equals': 'Less than or equals',\n 'Starts with': 'Starts with',\n 'Not starts with': 'Not starts with',\n 'Ends with': 'Ends with',\n 'Not ends with': 'Not ends with',\n Contains: 'Contains',\n 'Not contains': 'Not contains',\n 'Is any of': 'Is any of',\n 'Is not any of': 'Is not any of',\n 'Is null': 'Is null',\n 'Is not null': 'Is not null',\n true: 'true',\n false: 'false',\n 'Interactive content': 'Interactive content',\n 'Filter value': 'Filter value',\n 'Filter comparison': 'Filter comparison',\n state: 'state',\n 'Filter column': 'Filter column',\n Refresh: 'Refresh',\n table_a11y_intro: 'Tab or click into the grid to use key commands.',\n table_a11y_instructions_arrow_keys_label: 'Arrow keys or Shift+Alt+Arrow keys',\n table_a11y_instructions_arrow_keys_description: 'navigate cells',\n table_a11y_instructions_enter_label: 'Enter key',\n table_a11y_instructions_enter_description:\n 'when on a cell with editable controls, switches to Tab navigation mode. Tab key now navigates between all interactive controls in the grid',\n table_a11y_instructions_escape_label: 'Escape key',\n table_a11y_instructions_escape_description: 'restores arrow-based grid navigation',\n saved_changes: '\"{0}\" saved with changes',\n saved_changes_with_default: '\"{0}\" saved with changes and marked as default view',\n view_marked_default: '\"{0}\" view is marked as Default',\n view_marked_app_default: '\"{0}\" view is marked as App Default',\n created_view: 'Created view \"{0}\"',\n created_view_with_default: 'Created view \"{0}\" and marked as default view',\n deleted_view: 'Deleted view \"{0}\"',\n view_navigation_instructions: '{0}, Refer to keyboard instructions for navigation.',\n 'Show/Hide modified': 'Show/Hide modified',\n 'Freeze applied': 'Freeze applied',\n 'Freeze modified': 'Freeze modified',\n 'Freeze removed': 'Freeze removed',\n Count: 'Count'\n};\n\nexport default defaultTranslations;\n"]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
declare const _default: import("react").MemoExoticComponent<typeof Row>;
|
|
2
2
|
export default _default;
|
|
3
|
-
declare function Row({ row, columns, level }: {
|
|
3
|
+
declare function Row({ row, columns, level, dataIndex }: {
|
|
4
4
|
row: any;
|
|
5
5
|
columns: any;
|
|
6
6
|
level?: number | undefined;
|
|
7
|
+
dataIndex: any;
|
|
7
8
|
}): import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
declare namespace Row {
|
|
9
10
|
namespace propTypes {
|
|
@@ -12,6 +13,7 @@ declare namespace Row {
|
|
|
12
13
|
[x: string]: any;
|
|
13
14
|
}>;
|
|
14
15
|
let level: PropTypes.Requireable<number>;
|
|
16
|
+
let dataIndex: PropTypes.Requireable<number>;
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
import PropTypes from 'prop-types';
|