@qrvey/utils 1.15.0-9 → 1.15.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/dist/cjs/columns/constants/COLUMN_ICON.js +32 -32
- package/dist/cjs/columns/helpers/index.d.ts +1 -0
- package/dist/cjs/columns/helpers/index.js +1 -0
- package/dist/cjs/columns/helpers/isNumericalColumn.d.ts +1 -1
- package/dist/cjs/columns/helpers/isNumericalColumn.js +1 -1
- package/dist/cjs/columns/helpers/isStringColumn.d.ts +7 -0
- package/dist/cjs/columns/helpers/isStringColumn.js +19 -0
- package/dist/cjs/dates/relative/RelativeStatementAdapter.js +2 -1
- package/dist/cjs/elements/helpers/fixed.d.ts +96 -0
- package/dist/cjs/elements/helpers/fixed.js +248 -0
- package/dist/cjs/elements/helpers/gridStrategy.d.ts +29 -0
- package/dist/cjs/elements/helpers/gridStrategy.js +83 -0
- package/dist/cjs/elements/helpers/index.d.ts +3 -0
- package/dist/cjs/elements/helpers/index.js +22 -0
- package/dist/cjs/elements/helpers/responsive.d.ts +87 -0
- package/dist/cjs/elements/helpers/responsive.js +166 -0
- package/dist/cjs/elements/index.d.ts +2 -0
- package/dist/cjs/elements/index.js +18 -0
- package/dist/cjs/elements/interfaces/ICanvasGrid.d.ts +5 -0
- package/dist/cjs/elements/interfaces/ICanvasGrid.js +9 -0
- package/dist/cjs/elements/interfaces/IFixedPosition.d.ts +5 -0
- package/dist/cjs/elements/interfaces/IFixedPosition.js +2 -0
- package/dist/cjs/elements/interfaces/IVemCore.d.ts +29 -0
- package/dist/cjs/elements/interfaces/IVemCore.js +3 -0
- package/dist/cjs/elements/interfaces/IVemPosition.d.ts +44 -0
- package/dist/cjs/elements/interfaces/IVemPosition.js +8 -0
- package/dist/cjs/elements/interfaces/index.d.ts +4 -0
- package/dist/cjs/elements/interfaces/index.js +20 -0
- package/dist/cjs/elements/utils/element.d.ts +4 -0
- package/dist/cjs/elements/utils/element.js +28 -0
- package/dist/cjs/elements/utils/fixed.position.d.ts +12 -0
- package/dist/cjs/elements/utils/fixed.position.js +86 -0
- package/dist/cjs/elements/utils/general.d.ts +15 -0
- package/dist/cjs/elements/utils/general.js +20 -0
- package/dist/cjs/elements/utils/overlap.d.ts +63 -0
- package/dist/cjs/elements/utils/overlap.js +99 -0
- package/dist/cjs/elements/utils/position.d.ts +4 -0
- package/dist/cjs/elements/utils/position.js +5 -0
- package/dist/cjs/filters/adapters/FDToLogic.js +2 -1
- package/dist/cjs/filters/helpers/backend/buildExpression.js +1 -0
- package/dist/cjs/filters/helpers/backend/buildFilters.d.ts +5 -0
- package/dist/cjs/filters/helpers/backend/buildFilters.js +23 -1
- package/dist/cjs/filters/helpers/backend/getBackendValues.js +4 -1
- package/dist/cjs/filters/helpers/getAvailableScopesIDsByConfig.js +1 -0
- package/dist/cjs/filters/interfaces/backend/IFBExpression.js +0 -1
- package/dist/cjs/general/array/getUniqueSimpleArray.d.ts +6 -0
- package/dist/cjs/general/array/getUniqueSimpleArray.js +14 -0
- package/dist/cjs/general/array/index.d.ts +1 -0
- package/dist/cjs/general/array/index.js +1 -0
- package/dist/cjs/general/string/index.d.ts +4 -0
- package/dist/cjs/general/string/index.js +4 -0
- package/dist/cjs/general/string/secureHTML.d.ts +8 -0
- package/dist/cjs/general/string/secureHTML.js +13 -0
- package/dist/cjs/general/string/strategies/XSSEstrictedSanitizer.d.ts +8 -0
- package/dist/cjs/general/string/strategies/XSSEstrictedSanitizer.js +23 -0
- package/dist/cjs/general/string/strategies/XSSSanitizer.d.ts +8 -0
- package/dist/cjs/general/string/strategies/XSSSanitizer.js +19 -0
- package/dist/cjs/general/string/urlValidator.d.ts +10 -0
- package/dist/cjs/general/string/urlValidator.js +38 -0
- package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderSorting.d.ts +2 -0
- package/dist/cjs/globalization/interfaces/export/II18nExportingModal.d.ts +6 -0
- package/dist/cjs/globalization/interfaces/export/II18nExportingModalApplyButtonLabel.d.ts +1 -0
- package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL_OPTIONS.js +2 -0
- package/dist/cjs/globalization/labels/export/I18N_EXPORT_MODAL.js +10 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/interfaces/SatinizerStrategy.d.ts +3 -0
- package/dist/cjs/interfaces/SatinizerStrategy.js +2 -0
- package/dist/cjs/themes/constants/AUTOMATIC_GLOBAL_CSS_VARIABLES_FOR_LIGHT.js +3 -3
- package/dist/columns/constants/COLUMN_ICON.js +32 -32
- package/dist/columns/helpers/index.d.ts +1 -0
- package/dist/columns/helpers/index.js +1 -0
- package/dist/columns/helpers/isNumericalColumn.d.ts +1 -1
- package/dist/columns/helpers/isNumericalColumn.js +1 -1
- package/dist/columns/helpers/isStringColumn.d.ts +7 -0
- package/dist/columns/helpers/isStringColumn.js +15 -0
- package/dist/dates/relative/RelativeStatementAdapter.js +2 -1
- package/dist/elements/helpers/fixed.d.ts +96 -0
- package/dist/elements/helpers/fixed.js +236 -0
- package/dist/elements/helpers/gridStrategy.d.ts +29 -0
- package/dist/elements/helpers/gridStrategy.js +78 -0
- package/dist/elements/helpers/index.d.ts +3 -0
- package/dist/elements/helpers/index.js +3 -0
- package/dist/elements/helpers/responsive.d.ts +87 -0
- package/dist/elements/helpers/responsive.js +155 -0
- package/dist/elements/index.d.ts +2 -0
- package/dist/elements/index.js +2 -0
- package/dist/elements/interfaces/ICanvasGrid.d.ts +5 -0
- package/dist/elements/interfaces/ICanvasGrid.js +6 -0
- package/dist/elements/interfaces/IFixedPosition.d.ts +5 -0
- package/dist/elements/interfaces/IFixedPosition.js +1 -0
- package/dist/elements/interfaces/IVemCore.d.ts +29 -0
- package/dist/elements/interfaces/IVemCore.js +1 -0
- package/dist/elements/interfaces/IVemPosition.d.ts +44 -0
- package/dist/elements/interfaces/IVemPosition.js +5 -0
- package/dist/elements/interfaces/index.d.ts +4 -0
- package/dist/elements/interfaces/index.js +4 -0
- package/dist/elements/utils/element.d.ts +4 -0
- package/dist/elements/utils/element.js +24 -0
- package/dist/elements/utils/fixed.position.d.ts +12 -0
- package/dist/elements/utils/fixed.position.js +72 -0
- package/dist/elements/utils/general.d.ts +15 -0
- package/dist/elements/utils/general.js +16 -0
- package/dist/elements/utils/overlap.d.ts +63 -0
- package/dist/elements/utils/overlap.js +95 -0
- package/dist/elements/utils/position.d.ts +4 -0
- package/dist/elements/utils/position.js +1 -0
- package/dist/filters/adapters/FDToLogic.js +2 -1
- package/dist/filters/helpers/backend/buildExpression.js +1 -0
- package/dist/filters/helpers/backend/buildFilters.d.ts +5 -0
- package/dist/filters/helpers/backend/buildFilters.js +23 -1
- package/dist/filters/helpers/backend/getBackendValues.js +4 -1
- package/dist/filters/helpers/getAvailableScopesIDsByConfig.js +1 -0
- package/dist/filters/interfaces/backend/IFBExpression.js +0 -1
- package/dist/general/array/getUniqueSimpleArray.d.ts +6 -0
- package/dist/general/array/getUniqueSimpleArray.js +10 -0
- package/dist/general/array/index.d.ts +1 -0
- package/dist/general/array/index.js +1 -0
- package/dist/general/string/index.d.ts +4 -0
- package/dist/general/string/index.js +4 -0
- package/dist/general/string/secureHTML.d.ts +8 -0
- package/dist/general/string/secureHTML.js +9 -0
- package/dist/general/string/strategies/XSSEstrictedSanitizer.d.ts +8 -0
- package/dist/general/string/strategies/XSSEstrictedSanitizer.js +19 -0
- package/dist/general/string/strategies/XSSSanitizer.d.ts +8 -0
- package/dist/general/string/strategies/XSSSanitizer.js +15 -0
- package/dist/general/string/urlValidator.d.ts +10 -0
- package/dist/general/string/urlValidator.js +34 -0
- package/dist/globalization/interfaces/chart_builder/II18nChartBuilderSorting.d.ts +2 -0
- package/dist/globalization/interfaces/export/II18nExportingModal.d.ts +6 -0
- package/dist/globalization/interfaces/export/II18nExportingModalApplyButtonLabel.d.ts +1 -0
- package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL_OPTIONS.js +2 -0
- package/dist/globalization/labels/export/I18N_EXPORT_MODAL.js +10 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/SatinizerStrategy.d.ts +3 -0
- package/dist/interfaces/SatinizerStrategy.js +1 -0
- package/dist/themes/constants/AUTOMATIC_GLOBAL_CSS_VARIABLES_FOR_LIGHT.js +3 -3
- package/package.json +3 -2
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { CanvasDevice } from "../interfaces/ICanvasGrid";
|
|
2
|
+
import { VemResponsive } from "../interfaces/IVemCore";
|
|
3
|
+
import { VemPositionResponsive } from "../interfaces/IVemPosition";
|
|
4
|
+
/**
|
|
5
|
+
* Finds the first available position for a new responsive element within a canvas.
|
|
6
|
+
* @param canvasWidth - The width of the canvas in terms of columns.
|
|
7
|
+
* @param newElement - The new responsive element to place on the canvas.
|
|
8
|
+
* @param elements - The existing elements on the canvas.
|
|
9
|
+
* @param device - The target device type (e.g., desktop, tablet, mobile) to calculate responsive positions.
|
|
10
|
+
* @returns - The column and row start positions for the new element, or `undefined` if no valid position is found.
|
|
11
|
+
*/
|
|
12
|
+
export declare function findAvailablePosition(canvasWidth: number, newElement: VemResponsive, elements: VemResponsive[], device: CanvasDevice): {
|
|
13
|
+
colStart: number;
|
|
14
|
+
rowStart: number;
|
|
15
|
+
} | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Updates the responsive position of a given element for a specified device.
|
|
18
|
+
* @param element - The responsive element to update.
|
|
19
|
+
* @param newPosition - The new position values to update for the element.
|
|
20
|
+
* @param device - The target device type (e.g., desktop, tablet, mobile) for which the position is updated.
|
|
21
|
+
* @returns - A new `VemResponsive` object with the updated responsive position for the specified device.
|
|
22
|
+
*/
|
|
23
|
+
export declare function updateResponsivePosition(element: VemResponsive, newPosition: Partial<VemPositionResponsive>, device: CanvasDevice): VemResponsive;
|
|
24
|
+
/**
|
|
25
|
+
* Finds available positions for a list of responsive elements on a canvas and updates their positions.
|
|
26
|
+
* @param canvasWidth - The width of the canvas in grid columns.
|
|
27
|
+
* @param newElements - The list of new responsive elements to position.
|
|
28
|
+
* @param elements - The list of existing responsive elements already positioned on the canvas.
|
|
29
|
+
* @param device - The target device type (e.g., desktop, tablet, mobile) for which positions are calculated.
|
|
30
|
+
* @returns - A list of responsive elements with updated positions for the specified device.
|
|
31
|
+
*/
|
|
32
|
+
export declare function findResponsiveAvailablePositions(canvasWidth: number, newElements: VemResponsive[], elements: VemResponsive[], device: CanvasDevice): VemResponsive[];
|
|
33
|
+
/**
|
|
34
|
+
* Adjusts the `colSpan` of a responsive element to fit within the specified canvas width and updates its position.
|
|
35
|
+
* @param element - The responsive element to adjust.
|
|
36
|
+
* @param canvasWidth - The width of the canvas in grid columns.
|
|
37
|
+
* @param canvasDevice - The target device type (e.g., desktop, tablet, mobile).
|
|
38
|
+
* @returns - The updated responsive element with an adjusted `colSpan`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function updateResponsiveElementColSpan(element: VemResponsive, canvasWidth: number, canvasDevice: CanvasDevice): VemResponsive;
|
|
41
|
+
export declare const getResponsiveGridElementsBottomLimit: (elements: VemResponsive[], device: CanvasDevice, rowGap: number) => number;
|
|
42
|
+
/**
|
|
43
|
+
* Calculates the distances of elements from a reference point and returns a list of objects
|
|
44
|
+
* containing the calculated distance and the corresponding element.
|
|
45
|
+
* @param elements - An array of `VemResponsive` objects. Each object represents an element with
|
|
46
|
+
* a `position` property that contains responsive positions for various devices.
|
|
47
|
+
* @param device - The specific device type (key of `CanvasDevice`) to determine the responsive position.
|
|
48
|
+
* @param referencePoint - An object representing the reference point with `x` and `y` coordinates.
|
|
49
|
+
* @param referencePoint.x
|
|
50
|
+
* @param referencePoint.y
|
|
51
|
+
* @returns - An array of objects, where each object contains:
|
|
52
|
+
* - `distance`: The squared Euclidean distance from the reference point.
|
|
53
|
+
* - `element`: The corresponding `VemResponsive` object.
|
|
54
|
+
*/
|
|
55
|
+
export declare const calculateDistancesToReferencePoint: (elements: VemResponsive[], device: CanvasDevice, referencePoint: {
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
}) => {
|
|
59
|
+
distance: number;
|
|
60
|
+
element: VemResponsive;
|
|
61
|
+
}[];
|
|
62
|
+
/**
|
|
63
|
+
/**
|
|
64
|
+
Sorts objects containing a `distance` and `element` by distance in ascending order.
|
|
65
|
+
If two objects have the same distance, it resolves the tie by comparing the `colStart` property
|
|
66
|
+
of their responsive positions for the `DESKTOP` device.
|
|
67
|
+
* @param a - An object containing:
|
|
68
|
+
* - `distance`: The calculated distance from a reference point.
|
|
69
|
+
* - `element`: A `VemResponsive` object with responsive position data.
|
|
70
|
+
* @param b - Another object with the same structure as `a`.
|
|
71
|
+
* @param a.element
|
|
72
|
+
* @param a.distance
|
|
73
|
+
* @param _device - The device type (of type `CanvasDevice`). Currently unused in this function.
|
|
74
|
+
* @param b.distance
|
|
75
|
+
* @param b.element
|
|
76
|
+
* @returns - A negative number if `a` should come before `b`,
|
|
77
|
+
* a positive number if `a` should come after `b`,
|
|
78
|
+
* or 0 if they have the same distance and `colStart` values.
|
|
79
|
+
*/
|
|
80
|
+
export declare const sortByDistanceInResponsiveFunction: (a: {
|
|
81
|
+
distance: number;
|
|
82
|
+
element: VemResponsive;
|
|
83
|
+
}, b: {
|
|
84
|
+
distance: number;
|
|
85
|
+
element: VemResponsive;
|
|
86
|
+
}, _device: CanvasDevice) => number;
|
|
87
|
+
export declare const sortResponsiveElements: (elements: VemResponsive<unknown>[], sortByDevice?: CanvasDevice) => VemResponsive<unknown>[];
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortResponsiveElements = exports.sortByDistanceInResponsiveFunction = exports.calculateDistancesToReferencePoint = exports.getResponsiveGridElementsBottomLimit = exports.updateResponsiveElementColSpan = exports.findResponsiveAvailablePositions = exports.updateResponsivePosition = exports.findAvailablePosition = void 0;
|
|
4
|
+
const ICanvasGrid_1 = require("../interfaces/ICanvasGrid");
|
|
5
|
+
const IVemPosition_1 = require("../interfaces/IVemPosition");
|
|
6
|
+
const overlap_1 = require("../utils/overlap");
|
|
7
|
+
const position_1 = require("../utils/position");
|
|
8
|
+
const SPACE_DELTA = 1;
|
|
9
|
+
const HEIGHT_DELTA = 32;
|
|
10
|
+
/**
|
|
11
|
+
* Finds the first available position for a new responsive element within a canvas.
|
|
12
|
+
* @param canvasWidth - The width of the canvas in terms of columns.
|
|
13
|
+
* @param newElement - The new responsive element to place on the canvas.
|
|
14
|
+
* @param elements - The existing elements on the canvas.
|
|
15
|
+
* @param device - The target device type (e.g., desktop, tablet, mobile) to calculate responsive positions.
|
|
16
|
+
* @returns - The column and row start positions for the new element, or `undefined` if no valid position is found.
|
|
17
|
+
*/
|
|
18
|
+
function findAvailablePosition(canvasWidth, newElement, elements, device) {
|
|
19
|
+
const { colSpan: newWidth, rowSpan: newHeight } = newElement.position.responsive[device];
|
|
20
|
+
const sortedElements = elements
|
|
21
|
+
.slice()
|
|
22
|
+
.sort((a, b) => a.position.responsive[device].rowStart -
|
|
23
|
+
b.position.responsive[device].rowStart);
|
|
24
|
+
const intervalTree = new overlap_1.OverlapIntervalTree();
|
|
25
|
+
for (const element of sortedElements) {
|
|
26
|
+
const elemPosition = element.position.responsive[device];
|
|
27
|
+
const colEnd = elemPosition.colStart + (elemPosition.colSpan - 1);
|
|
28
|
+
const rowEnd = elemPosition.rowStart + elemPosition.rowSpan - 1;
|
|
29
|
+
if (!intervalTree.overlaps(elemPosition.colStart, colEnd, elemPosition.rowStart, rowEnd)) {
|
|
30
|
+
intervalTree.insert(elemPosition.colStart, colEnd, elemPosition.rowStart, rowEnd);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
for (let rowStart = 1; rowStart <= Infinity - newHeight; rowStart += SPACE_DELTA) {
|
|
34
|
+
// height iteration will be until it finds a result
|
|
35
|
+
for (let colStart = 1; colStart <= canvasWidth - newWidth + 1; colStart += SPACE_DELTA) {
|
|
36
|
+
if (!intervalTree.overlaps(colStart, colStart + newWidth - 1, rowStart, rowStart + newHeight - 1)) {
|
|
37
|
+
const col = colStart === 0 ? 1 : colStart;
|
|
38
|
+
const row = rowStart === 0 ? 1 : rowStart;
|
|
39
|
+
return { colStart: col, rowStart: row };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
exports.findAvailablePosition = findAvailablePosition;
|
|
46
|
+
/**
|
|
47
|
+
* Updates the responsive position of a given element for a specified device.
|
|
48
|
+
* @param element - The responsive element to update.
|
|
49
|
+
* @param newPosition - The new position values to update for the element.
|
|
50
|
+
* @param device - The target device type (e.g., desktop, tablet, mobile) for which the position is updated.
|
|
51
|
+
* @returns - A new `VemResponsive` object with the updated responsive position for the specified device.
|
|
52
|
+
*/
|
|
53
|
+
function updateResponsivePosition(element, newPosition, device) {
|
|
54
|
+
var _a;
|
|
55
|
+
return Object.assign(Object.assign({}, element), { position: Object.assign(Object.assign({}, element.position), { responsive: Object.assign(Object.assign({}, element.position.responsive), { [device]: Object.assign(Object.assign({}, (_a = element.position.responsive) === null || _a === void 0 ? void 0 : _a[device]), newPosition) }) }) });
|
|
56
|
+
}
|
|
57
|
+
exports.updateResponsivePosition = updateResponsivePosition;
|
|
58
|
+
/**
|
|
59
|
+
* Finds available positions for a list of responsive elements on a canvas and updates their positions.
|
|
60
|
+
* @param canvasWidth - The width of the canvas in grid columns.
|
|
61
|
+
* @param newElements - The list of new responsive elements to position.
|
|
62
|
+
* @param elements - The list of existing responsive elements already positioned on the canvas.
|
|
63
|
+
* @param device - The target device type (e.g., desktop, tablet, mobile) for which positions are calculated.
|
|
64
|
+
* @returns - A list of responsive elements with updated positions for the specified device.
|
|
65
|
+
*/
|
|
66
|
+
function findResponsiveAvailablePositions(canvasWidth, newElements, elements, device) {
|
|
67
|
+
const processedElements = elements.slice();
|
|
68
|
+
const resultElems = [];
|
|
69
|
+
newElements.forEach((nElement) => {
|
|
70
|
+
const newElement = updateResponsiveElementColSpan(nElement, canvasWidth, device);
|
|
71
|
+
const availablePosition = findAvailablePosition(canvasWidth, newElement, processedElements, device);
|
|
72
|
+
const newElemWithPosition = updateResponsivePosition(newElement, availablePosition, device);
|
|
73
|
+
resultElems.push(newElemWithPosition);
|
|
74
|
+
processedElements.push(newElemWithPosition);
|
|
75
|
+
});
|
|
76
|
+
return resultElems;
|
|
77
|
+
}
|
|
78
|
+
exports.findResponsiveAvailablePositions = findResponsiveAvailablePositions;
|
|
79
|
+
/**
|
|
80
|
+
* Adjusts the `colSpan` of a responsive element to fit within the specified canvas width and updates its position.
|
|
81
|
+
* @param element - The responsive element to adjust.
|
|
82
|
+
* @param canvasWidth - The width of the canvas in grid columns.
|
|
83
|
+
* @param canvasDevice - The target device type (e.g., desktop, tablet, mobile).
|
|
84
|
+
* @returns - The updated responsive element with an adjusted `colSpan`.
|
|
85
|
+
*/
|
|
86
|
+
function updateResponsiveElementColSpan(element, canvasWidth, canvasDevice) {
|
|
87
|
+
const currentPosition = element.position.responsive[canvasDevice];
|
|
88
|
+
const fixedColSpan = Math.min(currentPosition.colSpan, canvasWidth);
|
|
89
|
+
const position = Object.assign(Object.assign({}, currentPosition), { colSpan: fixedColSpan });
|
|
90
|
+
return (0, position_1.setElementPosition)(element, IVemPosition_1.VemPositionType.RESPONSIVE, canvasDevice, position);
|
|
91
|
+
}
|
|
92
|
+
exports.updateResponsiveElementColSpan = updateResponsiveElementColSpan;
|
|
93
|
+
const getResponsiveGridElementsBottomLimit = (elements, device, rowGap) => {
|
|
94
|
+
if (!elements.length)
|
|
95
|
+
return 0;
|
|
96
|
+
const mappedElements = elements.map((element) => {
|
|
97
|
+
const elementPosition = element.position.responsive;
|
|
98
|
+
const maxRows = elementPosition[device].rowStart + elementPosition[device].rowSpan;
|
|
99
|
+
return maxRows * HEIGHT_DELTA + (maxRows - 1) * rowGap;
|
|
100
|
+
});
|
|
101
|
+
return Math.max(...mappedElements);
|
|
102
|
+
};
|
|
103
|
+
exports.getResponsiveGridElementsBottomLimit = getResponsiveGridElementsBottomLimit;
|
|
104
|
+
/**
|
|
105
|
+
* Calculates the distances of elements from a reference point and returns a list of objects
|
|
106
|
+
* containing the calculated distance and the corresponding element.
|
|
107
|
+
* @param elements - An array of `VemResponsive` objects. Each object represents an element with
|
|
108
|
+
* a `position` property that contains responsive positions for various devices.
|
|
109
|
+
* @param device - The specific device type (key of `CanvasDevice`) to determine the responsive position.
|
|
110
|
+
* @param referencePoint - An object representing the reference point with `x` and `y` coordinates.
|
|
111
|
+
* @param referencePoint.x
|
|
112
|
+
* @param referencePoint.y
|
|
113
|
+
* @returns - An array of objects, where each object contains:
|
|
114
|
+
* - `distance`: The squared Euclidean distance from the reference point.
|
|
115
|
+
* - `element`: The corresponding `VemResponsive` object.
|
|
116
|
+
*/
|
|
117
|
+
const calculateDistancesToReferencePoint = (elements, device, referencePoint) => {
|
|
118
|
+
return elements.map((element) => {
|
|
119
|
+
var _a, _b;
|
|
120
|
+
const position = (_b = (_a = element.position) === null || _a === void 0 ? void 0 : _a.responsive) === null || _b === void 0 ? void 0 : _b[device];
|
|
121
|
+
if (!position) {
|
|
122
|
+
throw new Error(`Position for device ${device} is undefined for element with Id ${element.elementId}.`);
|
|
123
|
+
}
|
|
124
|
+
const distance = Math.pow(referencePoint.x - position.colStart, 2) +
|
|
125
|
+
Math.pow(referencePoint.y - position.rowStart, 2);
|
|
126
|
+
return {
|
|
127
|
+
distance,
|
|
128
|
+
element,
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
exports.calculateDistancesToReferencePoint = calculateDistancesToReferencePoint;
|
|
133
|
+
/**
|
|
134
|
+
/**
|
|
135
|
+
Sorts objects containing a `distance` and `element` by distance in ascending order.
|
|
136
|
+
If two objects have the same distance, it resolves the tie by comparing the `colStart` property
|
|
137
|
+
of their responsive positions for the `DESKTOP` device.
|
|
138
|
+
* @param a - An object containing:
|
|
139
|
+
* - `distance`: The calculated distance from a reference point.
|
|
140
|
+
* - `element`: A `VemResponsive` object with responsive position data.
|
|
141
|
+
* @param b - Another object with the same structure as `a`.
|
|
142
|
+
* @param a.element
|
|
143
|
+
* @param a.distance
|
|
144
|
+
* @param _device - The device type (of type `CanvasDevice`). Currently unused in this function.
|
|
145
|
+
* @param b.distance
|
|
146
|
+
* @param b.element
|
|
147
|
+
* @returns - A negative number if `a` should come before `b`,
|
|
148
|
+
* a positive number if `a` should come after `b`,
|
|
149
|
+
* or 0 if they have the same distance and `colStart` values.
|
|
150
|
+
*/
|
|
151
|
+
const sortByDistanceInResponsiveFunction = (a, b, _device) => {
|
|
152
|
+
if (a.distance === b.distance) {
|
|
153
|
+
return (a.element.position.responsive[ICanvasGrid_1.CanvasDevice.DESKTOP].colStart -
|
|
154
|
+
b.element.position.responsive[ICanvasGrid_1.CanvasDevice.DESKTOP].colStart);
|
|
155
|
+
}
|
|
156
|
+
return a.distance - b.distance;
|
|
157
|
+
};
|
|
158
|
+
exports.sortByDistanceInResponsiveFunction = sortByDistanceInResponsiveFunction;
|
|
159
|
+
const sortResponsiveElements = (elements, sortByDevice) => {
|
|
160
|
+
const sortedElements = (0, exports.calculateDistancesToReferencePoint)(elements, sortByDevice, {
|
|
161
|
+
x: 1,
|
|
162
|
+
y: 1,
|
|
163
|
+
}).sort((a, b) => (0, exports.sortByDistanceInResponsiveFunction)(a, b, sortByDevice));
|
|
164
|
+
return sortedElements.map((element) => element.element);
|
|
165
|
+
};
|
|
166
|
+
exports.sortResponsiveElements = sortResponsiveElements;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./helpers/index"), exports);
|
|
18
|
+
__exportStar(require("./interfaces/index"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CanvasDevice = void 0;
|
|
4
|
+
var CanvasDevice;
|
|
5
|
+
(function (CanvasDevice) {
|
|
6
|
+
CanvasDevice["DESKTOP"] = "desktop";
|
|
7
|
+
CanvasDevice["TABLET"] = "tablet";
|
|
8
|
+
CanvasDevice["MOBILE"] = "mobile";
|
|
9
|
+
})(CanvasDevice || (exports.CanvasDevice = CanvasDevice = {}));
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { VemPositionConfigFixed, VemPositionConfigMap, VemPositionConfigResponsive, VemPositionType } from "./IVemPosition";
|
|
2
|
+
interface VemBase {
|
|
3
|
+
elementId: string;
|
|
4
|
+
type: string;
|
|
5
|
+
contentId?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface VemCorePosition {
|
|
8
|
+
fixed?: VemPositionConfigFixed;
|
|
9
|
+
responsive?: VemPositionConfigResponsive;
|
|
10
|
+
}
|
|
11
|
+
interface VemCore<TPosition extends VemPositionType | unknown, TItemData = unknown> extends VemBase {
|
|
12
|
+
itemData: TItemData;
|
|
13
|
+
/** Indicates if its a personalized Vem */
|
|
14
|
+
isEup?: boolean;
|
|
15
|
+
/** Data to be saved in the client chart when it's saved by EUP (Only applies for VemAnalytics) */
|
|
16
|
+
chartBody?: unknown;
|
|
17
|
+
/** Dashboard Actions in the element */
|
|
18
|
+
actions?: unknown[];
|
|
19
|
+
position: TPosition extends VemPositionType ? VemCorePosition & Record<TPosition, VemPositionConfigMap[TPosition]> : VemCorePosition;
|
|
20
|
+
}
|
|
21
|
+
export type Vem<T = unknown, TPosition extends VemPositionType = VemPositionType> = VemCore<TPosition, T>;
|
|
22
|
+
export type VemPos<TPosition extends VemPositionType> = VemCore<TPosition>;
|
|
23
|
+
export type VemResponsive<T = unknown> = VemCore<VemPositionType.RESPONSIVE, T>;
|
|
24
|
+
export type VemFixed<T = unknown> = VemCore<VemPositionType.FIXED, T>;
|
|
25
|
+
export interface VemElementMap<T = unknown> {
|
|
26
|
+
[VemPositionType.FIXED]: VemFixed<T>;
|
|
27
|
+
[VemPositionType.RESPONSIVE]: VemResponsive<T>;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface VemSizeFixed {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
}
|
|
5
|
+
export interface VemSizeResponsive {
|
|
6
|
+
colSpan: number;
|
|
7
|
+
rowSpan: number;
|
|
8
|
+
}
|
|
9
|
+
export interface VemPositionFixed extends VemSizeFixed {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
z: number;
|
|
13
|
+
}
|
|
14
|
+
export interface VemPositionResponsive extends VemSizeResponsive {
|
|
15
|
+
colStart: number;
|
|
16
|
+
rowStart: number;
|
|
17
|
+
}
|
|
18
|
+
export type VemPosition = VemPositionFixed | VemPositionResponsive;
|
|
19
|
+
export interface VemPositionMap {
|
|
20
|
+
[VemPositionType.FIXED]: VemPositionFixed;
|
|
21
|
+
[VemPositionType.RESPONSIVE]: VemPositionResponsive;
|
|
22
|
+
}
|
|
23
|
+
export declare enum VemPositionType {
|
|
24
|
+
FIXED = "fixed",
|
|
25
|
+
RESPONSIVE = "responsive"
|
|
26
|
+
}
|
|
27
|
+
interface VemPositionBase<TPosition extends VemPosition> {
|
|
28
|
+
desktop: TPosition;
|
|
29
|
+
tablet?: TPosition;
|
|
30
|
+
mobile?: TPosition;
|
|
31
|
+
}
|
|
32
|
+
export type VemPositionConfigFixed = VemPositionBase<VemPositionFixed>;
|
|
33
|
+
export type VemPositionConfigResponsive = VemPositionBase<VemPositionResponsive>;
|
|
34
|
+
export type VemPositionConfig = VemPositionConfigFixed | VemPositionConfigResponsive;
|
|
35
|
+
export interface VemPositionConfigMap {
|
|
36
|
+
[VemPositionType.FIXED]: VemPositionConfigFixed;
|
|
37
|
+
[VemPositionType.RESPONSIVE]: VemPositionConfigResponsive;
|
|
38
|
+
}
|
|
39
|
+
export type VemSize = VemSizeFixed | VemSizeResponsive;
|
|
40
|
+
export interface VemSizeConfig {
|
|
41
|
+
[VemPositionType.FIXED]: VemSizeFixed;
|
|
42
|
+
[VemPositionType.RESPONSIVE]: VemSizeResponsive;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VemPositionType = void 0;
|
|
4
|
+
var VemPositionType;
|
|
5
|
+
(function (VemPositionType) {
|
|
6
|
+
VemPositionType["FIXED"] = "fixed";
|
|
7
|
+
VemPositionType["RESPONSIVE"] = "responsive";
|
|
8
|
+
})(VemPositionType || (exports.VemPositionType = VemPositionType = {}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ICanvasGrid"), exports);
|
|
18
|
+
__exportStar(require("./IFixedPosition"), exports);
|
|
19
|
+
__exportStar(require("./IVemCore"), exports);
|
|
20
|
+
__exportStar(require("./IVemPosition"), exports);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CanvasDevice } from "../interfaces/ICanvasGrid";
|
|
2
|
+
import { Vem } from "../interfaces/IVemCore";
|
|
3
|
+
import { VemPositionType } from "../interfaces/IVemPosition";
|
|
4
|
+
export declare const copyDesktopPositionToDevice: (elements: Vem[], newCanvasDevice: CanvasDevice, canvasType: VemPositionType) => Vem[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.copyDesktopPositionToDevice = void 0;
|
|
4
|
+
const position_1 = require("./position");
|
|
5
|
+
const ICanvasGrid_1 = require("../interfaces/ICanvasGrid");
|
|
6
|
+
const IVemPosition_1 = require("../interfaces/IVemPosition");
|
|
7
|
+
const copyDesktopPositionToDevice = (elements, newCanvasDevice, canvasType) => {
|
|
8
|
+
const defaultPositionMap = {
|
|
9
|
+
[IVemPosition_1.VemPositionType.FIXED]: {
|
|
10
|
+
x: 0,
|
|
11
|
+
y: 0,
|
|
12
|
+
},
|
|
13
|
+
[IVemPosition_1.VemPositionType.RESPONSIVE]: {
|
|
14
|
+
colStart: 1,
|
|
15
|
+
rowStart: 1,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
return elements.map((element) => {
|
|
19
|
+
var _a;
|
|
20
|
+
if (!((_a = element.position[canvasType]) === null || _a === void 0 ? void 0 : _a[newCanvasDevice])) {
|
|
21
|
+
const desktopViewPosition = element.position[canvasType][ICanvasGrid_1.CanvasDevice.DESKTOP];
|
|
22
|
+
const newDevicePosition = Object.assign(Object.assign(Object.assign({}, desktopViewPosition), defaultPositionMap[canvasType]), { preCalculated: true });
|
|
23
|
+
return (0, position_1.setElementPosition)(element, canvasType, newCanvasDevice, newDevicePosition);
|
|
24
|
+
}
|
|
25
|
+
return element;
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
exports.copyDesktopPositionToDevice = copyDesktopPositionToDevice;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CanvasDevice, VemFixed, VemPositionFixed } from "../interfaces";
|
|
2
|
+
export declare const hasOverflow: (element: VemFixed, device: CanvasDevice, resolution: number, canvasHeight?: number) => boolean;
|
|
3
|
+
export declare const hasOverlap: (element: VemFixed, elements: VemFixed[], device: CanvasDevice) => number;
|
|
4
|
+
export declare const itemXOverflow: (item: VemFixed, device: CanvasDevice, resolution: number) => boolean;
|
|
5
|
+
export declare const itemYOverflow: (item: VemFixed, device: CanvasDevice, canvasHeight: number) => boolean;
|
|
6
|
+
export declare const checkFixedGridItemsOverlap: (item: VemPositionFixed, itemToCompare: VemPositionFixed) => boolean;
|
|
7
|
+
export declare const dxGetFixedGridItemDevice: (element: VemFixed, device: CanvasDevice) => VemPositionFixed;
|
|
8
|
+
export declare const dxGetFixedGridItemX: (element: VemFixed, device: CanvasDevice, allowNegative?: boolean) => number;
|
|
9
|
+
export declare const dxGetFixedGridItemY: (element: VemFixed, device: CanvasDevice, allowNegative?: boolean) => number;
|
|
10
|
+
export declare const dxGetFixedGridItemZ: (element: VemFixed, device: CanvasDevice) => number;
|
|
11
|
+
export declare const dxGetFixedGridItemHeight: (element: VemFixed, device: CanvasDevice) => number;
|
|
12
|
+
export declare const dxGetFixedGridItemWidth: (element: VemFixed, device: CanvasDevice) => number;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dxGetFixedGridItemWidth = exports.dxGetFixedGridItemHeight = exports.dxGetFixedGridItemZ = exports.dxGetFixedGridItemY = exports.dxGetFixedGridItemX = exports.dxGetFixedGridItemDevice = exports.checkFixedGridItemsOverlap = exports.itemYOverflow = exports.itemXOverflow = exports.hasOverlap = exports.hasOverflow = void 0;
|
|
4
|
+
const hasOverflow = (element, device, resolution, canvasHeight) => {
|
|
5
|
+
const hasXOverflow = (0, exports.itemXOverflow)(element, device, resolution);
|
|
6
|
+
const hasYOverflow = canvasHeight
|
|
7
|
+
? (0, exports.itemYOverflow)(element, device, canvasHeight)
|
|
8
|
+
: false;
|
|
9
|
+
return hasXOverflow || hasYOverflow;
|
|
10
|
+
};
|
|
11
|
+
exports.hasOverflow = hasOverflow;
|
|
12
|
+
const hasOverlap = (element, elements, device) => {
|
|
13
|
+
const elementPosition = element.position.fixed[device];
|
|
14
|
+
if (!elementPosition)
|
|
15
|
+
return;
|
|
16
|
+
const overlappingElements = elements.filter((cElement) => (0, exports.checkFixedGridItemsOverlap)(elementPosition, cElement.position.fixed[device]));
|
|
17
|
+
return overlappingElements.length;
|
|
18
|
+
};
|
|
19
|
+
exports.hasOverlap = hasOverlap;
|
|
20
|
+
const itemXOverflow = (item, device, resolution) => {
|
|
21
|
+
const fixedPosition = item.position.fixed;
|
|
22
|
+
return (!!fixedPosition[device] &&
|
|
23
|
+
fixedPosition[device].x + fixedPosition[device].width > resolution);
|
|
24
|
+
};
|
|
25
|
+
exports.itemXOverflow = itemXOverflow;
|
|
26
|
+
const itemYOverflow = (item, device, canvasHeight) => {
|
|
27
|
+
const fixedPosition = item.position.fixed;
|
|
28
|
+
return (!!fixedPosition[device] &&
|
|
29
|
+
fixedPosition[device].y + fixedPosition[device].height > canvasHeight);
|
|
30
|
+
};
|
|
31
|
+
exports.itemYOverflow = itemYOverflow;
|
|
32
|
+
const checkFixedGridItemsOverlap = (item, itemToCompare) => {
|
|
33
|
+
return !(item.x + item.width < itemToCompare.x ||
|
|
34
|
+
item.x > itemToCompare.x + itemToCompare.width ||
|
|
35
|
+
item.y + item.height < itemToCompare.y ||
|
|
36
|
+
item.y > itemToCompare.y + itemToCompare.height);
|
|
37
|
+
};
|
|
38
|
+
exports.checkFixedGridItemsOverlap = checkFixedGridItemsOverlap;
|
|
39
|
+
const dxGetFixedGridItemDevice = (element, device) => {
|
|
40
|
+
return {
|
|
41
|
+
x: (0, exports.dxGetFixedGridItemX)(element, device),
|
|
42
|
+
y: (0, exports.dxGetFixedGridItemY)(element, device),
|
|
43
|
+
z: (0, exports.dxGetFixedGridItemZ)(element, device),
|
|
44
|
+
height: (0, exports.dxGetFixedGridItemHeight)(element, device),
|
|
45
|
+
width: (0, exports.dxGetFixedGridItemWidth)(element, device),
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
exports.dxGetFixedGridItemDevice = dxGetFixedGridItemDevice;
|
|
49
|
+
const dxGetFixedGridItemX = (element, device, allowNegative = false) => {
|
|
50
|
+
var _a;
|
|
51
|
+
const position = element.position.fixed[device];
|
|
52
|
+
const itemX = (_a = position === null || position === void 0 ? void 0 : position.x) !== null && _a !== void 0 ? _a : 0;
|
|
53
|
+
if (!allowNegative) {
|
|
54
|
+
return itemX >= 0 ? itemX : 0;
|
|
55
|
+
}
|
|
56
|
+
return itemX;
|
|
57
|
+
};
|
|
58
|
+
exports.dxGetFixedGridItemX = dxGetFixedGridItemX;
|
|
59
|
+
const dxGetFixedGridItemY = (element, device, allowNegative = false) => {
|
|
60
|
+
var _a;
|
|
61
|
+
const position = element.position.fixed[device];
|
|
62
|
+
const itemY = (_a = position === null || position === void 0 ? void 0 : position.y) !== null && _a !== void 0 ? _a : 0;
|
|
63
|
+
if (!allowNegative) {
|
|
64
|
+
return itemY >= 0 ? itemY : 0;
|
|
65
|
+
}
|
|
66
|
+
return itemY;
|
|
67
|
+
};
|
|
68
|
+
exports.dxGetFixedGridItemY = dxGetFixedGridItemY;
|
|
69
|
+
const dxGetFixedGridItemZ = (element, device) => {
|
|
70
|
+
var _a;
|
|
71
|
+
const position = element.position.fixed[device];
|
|
72
|
+
return (_a = position === null || position === void 0 ? void 0 : position.z) !== null && _a !== void 0 ? _a : 1;
|
|
73
|
+
};
|
|
74
|
+
exports.dxGetFixedGridItemZ = dxGetFixedGridItemZ;
|
|
75
|
+
const dxGetFixedGridItemHeight = (element, device) => {
|
|
76
|
+
var _a;
|
|
77
|
+
const position = element.position.fixed[device];
|
|
78
|
+
return (_a = position === null || position === void 0 ? void 0 : position.height) !== null && _a !== void 0 ? _a : 400;
|
|
79
|
+
};
|
|
80
|
+
exports.dxGetFixedGridItemHeight = dxGetFixedGridItemHeight;
|
|
81
|
+
const dxGetFixedGridItemWidth = (element, device) => {
|
|
82
|
+
var _a;
|
|
83
|
+
const position = element.position.fixed[device];
|
|
84
|
+
return (_a = position === null || position === void 0 ? void 0 : position.width) !== null && _a !== void 0 ? _a : 400;
|
|
85
|
+
};
|
|
86
|
+
exports.dxGetFixedGridItemWidth = dxGetFixedGridItemWidth;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compares two objects based on their `distance` property and determines their relative order.
|
|
3
|
+
* @param a - An object with a `distance` property (number).
|
|
4
|
+
* @param b - Another object with a `distance` property (number).
|
|
5
|
+
* @param a.distance
|
|
6
|
+
* @param b.distance
|
|
7
|
+
* @returns - A negative number if `a` has a smaller distance than `b`,
|
|
8
|
+
* a positive number if `a` has a larger distance than `b`,
|
|
9
|
+
* or 0 if both have equal distances.
|
|
10
|
+
*/
|
|
11
|
+
export declare const sortByDistanceFunction: (a: {
|
|
12
|
+
distance: number;
|
|
13
|
+
}, b: {
|
|
14
|
+
distance: number;
|
|
15
|
+
}) => 0 | 1 | -1;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortByDistanceFunction = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Compares two objects based on their `distance` property and determines their relative order.
|
|
6
|
+
* @param a - An object with a `distance` property (number).
|
|
7
|
+
* @param b - Another object with a `distance` property (number).
|
|
8
|
+
* @param a.distance
|
|
9
|
+
* @param b.distance
|
|
10
|
+
* @returns - A negative number if `a` has a smaller distance than `b`,
|
|
11
|
+
* a positive number if `a` has a larger distance than `b`,
|
|
12
|
+
* or 0 if both have equal distances.
|
|
13
|
+
*/
|
|
14
|
+
const sortByDistanceFunction = (a, b) => {
|
|
15
|
+
if (a.distance === b.distance) {
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
18
|
+
return a.distance < b.distance ? -1 : 1;
|
|
19
|
+
};
|
|
20
|
+
exports.sortByDistanceFunction = sortByDistanceFunction;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
interface OverlapNode {
|
|
2
|
+
startX: number;
|
|
3
|
+
endX: number;
|
|
4
|
+
startY: number;
|
|
5
|
+
endY: number;
|
|
6
|
+
maxEndX: number;
|
|
7
|
+
maxEndY: number;
|
|
8
|
+
left?: OverlapNode;
|
|
9
|
+
right?: OverlapNode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
export declare class OverlapIntervalTree {
|
|
15
|
+
root?: OverlapNode;
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
constructor();
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param startX
|
|
23
|
+
* @param endX
|
|
24
|
+
* @param startY
|
|
25
|
+
* @param endY
|
|
26
|
+
*/
|
|
27
|
+
insert(startX: number, endX: number, startY: number, endY: number): void;
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param startX
|
|
31
|
+
* @param endX
|
|
32
|
+
* @param startY
|
|
33
|
+
* @param endY
|
|
34
|
+
*/
|
|
35
|
+
private _initNode;
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @param node
|
|
39
|
+
* @param startX
|
|
40
|
+
* @param endX
|
|
41
|
+
* @param startY
|
|
42
|
+
* @param endY
|
|
43
|
+
*/
|
|
44
|
+
private _insert;
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @param startX
|
|
48
|
+
* @param endX
|
|
49
|
+
* @param startY
|
|
50
|
+
* @param endY
|
|
51
|
+
*/
|
|
52
|
+
overlaps(startX: number, endX: number, startY: number, endY: number): boolean;
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @param node
|
|
56
|
+
* @param startX
|
|
57
|
+
* @param endX
|
|
58
|
+
* @param startY
|
|
59
|
+
* @param endY
|
|
60
|
+
*/
|
|
61
|
+
private _overlaps;
|
|
62
|
+
}
|
|
63
|
+
export {};
|