@qrvey/utils 1.15.0-2 → 1.15.0-20

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.
Files changed (115) hide show
  1. package/dist/cjs/elements/helpers/fixed.d.ts +85 -0
  2. package/dist/cjs/elements/helpers/fixed.js +188 -0
  3. package/dist/cjs/elements/helpers/gridStrategy.d.ts +28 -0
  4. package/dist/cjs/elements/helpers/gridStrategy.js +81 -0
  5. package/dist/cjs/elements/helpers/index.d.ts +1 -0
  6. package/dist/cjs/elements/helpers/index.js +17 -0
  7. package/dist/cjs/elements/helpers/responsive.d.ts +87 -0
  8. package/dist/cjs/elements/helpers/responsive.js +166 -0
  9. package/dist/cjs/elements/index.d.ts +2 -0
  10. package/dist/cjs/elements/index.js +18 -0
  11. package/dist/cjs/elements/interfaces/ICanvasGrid.d.ts +5 -0
  12. package/dist/cjs/elements/interfaces/ICanvasGrid.js +9 -0
  13. package/dist/cjs/elements/interfaces/IFixedPosition.d.ts +5 -0
  14. package/dist/cjs/elements/interfaces/IFixedPosition.js +2 -0
  15. package/dist/cjs/elements/interfaces/IVemCore.d.ts +29 -0
  16. package/dist/cjs/elements/interfaces/IVemCore.js +3 -0
  17. package/dist/cjs/elements/interfaces/IVemPosition.d.ts +44 -0
  18. package/dist/cjs/elements/interfaces/IVemPosition.js +8 -0
  19. package/dist/cjs/elements/interfaces/index.d.ts +4 -0
  20. package/dist/cjs/elements/interfaces/index.js +20 -0
  21. package/dist/cjs/elements/utils/element.d.ts +4 -0
  22. package/dist/cjs/elements/utils/element.js +28 -0
  23. package/dist/cjs/elements/utils/general.d.ts +15 -0
  24. package/dist/cjs/elements/utils/general.js +20 -0
  25. package/dist/cjs/elements/utils/overlap.d.ts +63 -0
  26. package/dist/cjs/elements/utils/overlap.js +99 -0
  27. package/dist/cjs/elements/utils/position.d.ts +4 -0
  28. package/dist/cjs/elements/utils/position.js +5 -0
  29. package/dist/cjs/filters/adapters/FDToLogic.js +2 -1
  30. package/dist/cjs/filters/helpers/backend/buildFilters.d.ts +5 -0
  31. package/dist/cjs/filters/helpers/backend/buildFilters.js +23 -1
  32. package/dist/cjs/filters/helpers/common/getDateProperties.d.ts +6 -0
  33. package/dist/cjs/filters/helpers/common/getDateProperties.js +2 -1
  34. package/dist/cjs/filters/helpers/settings/getFilterSettings.js +1 -1
  35. package/dist/cjs/filters/interfaces/common/IFSScopeID.d.ts +4 -0
  36. package/dist/cjs/general/array/howManyByParam.d.ts +8 -0
  37. package/dist/cjs/general/array/howManyByParam.js +21 -0
  38. package/dist/cjs/general/array/index.d.ts +2 -0
  39. package/dist/cjs/general/array/index.js +2 -0
  40. package/dist/cjs/general/string/index.d.ts +4 -0
  41. package/dist/cjs/general/string/index.js +4 -0
  42. package/dist/cjs/general/string/secureHTML.d.ts +8 -0
  43. package/dist/cjs/general/string/secureHTML.js +13 -0
  44. package/dist/cjs/general/string/strategies/XSSEstrictedSanitizer.d.ts +8 -0
  45. package/dist/cjs/general/string/strategies/XSSEstrictedSanitizer.js +23 -0
  46. package/dist/cjs/general/string/strategies/XSSSanitizer.d.ts +8 -0
  47. package/dist/cjs/general/string/strategies/XSSSanitizer.js +19 -0
  48. package/dist/cjs/general/string/urlValidator.d.ts +10 -0
  49. package/dist/cjs/general/string/urlValidator.js +38 -0
  50. package/dist/cjs/globalization/interfaces/export/II18nExportingModal.d.ts +20 -0
  51. package/dist/cjs/globalization/interfaces/filters/II18nFilterDisplay.d.ts +1 -0
  52. package/dist/cjs/globalization/labels/export/I18N_EXPORT_MODAL.js +20 -0
  53. package/dist/cjs/globalization/labels/filters/I18N_FILTER_DISPLAY.js +1 -0
  54. package/dist/cjs/index.d.ts +1 -0
  55. package/dist/cjs/index.js +1 -0
  56. package/dist/cjs/interfaces/SatinizerStrategy.d.ts +3 -0
  57. package/dist/cjs/interfaces/SatinizerStrategy.js +2 -0
  58. package/dist/elements/helpers/fixed.d.ts +85 -0
  59. package/dist/elements/helpers/fixed.js +177 -0
  60. package/dist/elements/helpers/gridStrategy.d.ts +28 -0
  61. package/dist/elements/helpers/gridStrategy.js +76 -0
  62. package/dist/elements/helpers/index.d.ts +1 -0
  63. package/dist/elements/helpers/index.js +1 -0
  64. package/dist/elements/helpers/responsive.d.ts +87 -0
  65. package/dist/elements/helpers/responsive.js +155 -0
  66. package/dist/elements/index.d.ts +2 -0
  67. package/dist/elements/index.js +2 -0
  68. package/dist/elements/interfaces/ICanvasGrid.d.ts +5 -0
  69. package/dist/elements/interfaces/ICanvasGrid.js +6 -0
  70. package/dist/elements/interfaces/IFixedPosition.d.ts +5 -0
  71. package/dist/elements/interfaces/IFixedPosition.js +1 -0
  72. package/dist/elements/interfaces/IVemCore.d.ts +29 -0
  73. package/dist/elements/interfaces/IVemCore.js +1 -0
  74. package/dist/elements/interfaces/IVemPosition.d.ts +44 -0
  75. package/dist/elements/interfaces/IVemPosition.js +5 -0
  76. package/dist/elements/interfaces/index.d.ts +4 -0
  77. package/dist/elements/interfaces/index.js +4 -0
  78. package/dist/elements/utils/element.d.ts +4 -0
  79. package/dist/elements/utils/element.js +24 -0
  80. package/dist/elements/utils/general.d.ts +15 -0
  81. package/dist/elements/utils/general.js +16 -0
  82. package/dist/elements/utils/overlap.d.ts +63 -0
  83. package/dist/elements/utils/overlap.js +95 -0
  84. package/dist/elements/utils/position.d.ts +4 -0
  85. package/dist/elements/utils/position.js +1 -0
  86. package/dist/filters/adapters/FDToLogic.js +2 -1
  87. package/dist/filters/helpers/backend/buildFilters.d.ts +5 -0
  88. package/dist/filters/helpers/backend/buildFilters.js +23 -1
  89. package/dist/filters/helpers/common/getDateProperties.d.ts +6 -0
  90. package/dist/filters/helpers/common/getDateProperties.js +1 -1
  91. package/dist/filters/helpers/settings/getFilterSettings.js +1 -1
  92. package/dist/filters/interfaces/common/IFSScopeID.d.ts +4 -0
  93. package/dist/general/array/howManyByParam.d.ts +8 -0
  94. package/dist/general/array/howManyByParam.js +17 -0
  95. package/dist/general/array/index.d.ts +2 -0
  96. package/dist/general/array/index.js +2 -0
  97. package/dist/general/string/index.d.ts +4 -0
  98. package/dist/general/string/index.js +4 -0
  99. package/dist/general/string/secureHTML.d.ts +8 -0
  100. package/dist/general/string/secureHTML.js +9 -0
  101. package/dist/general/string/strategies/XSSEstrictedSanitizer.d.ts +8 -0
  102. package/dist/general/string/strategies/XSSEstrictedSanitizer.js +19 -0
  103. package/dist/general/string/strategies/XSSSanitizer.d.ts +8 -0
  104. package/dist/general/string/strategies/XSSSanitizer.js +15 -0
  105. package/dist/general/string/urlValidator.d.ts +10 -0
  106. package/dist/general/string/urlValidator.js +34 -0
  107. package/dist/globalization/interfaces/export/II18nExportingModal.d.ts +20 -0
  108. package/dist/globalization/interfaces/filters/II18nFilterDisplay.d.ts +1 -0
  109. package/dist/globalization/labels/export/I18N_EXPORT_MODAL.js +20 -0
  110. package/dist/globalization/labels/filters/I18N_FILTER_DISPLAY.js +1 -0
  111. package/dist/index.d.ts +1 -0
  112. package/dist/index.js +1 -0
  113. package/dist/interfaces/SatinizerStrategy.d.ts +3 -0
  114. package/dist/interfaces/SatinizerStrategy.js +1 -0
  115. package/package.json +3 -2
@@ -0,0 +1,155 @@
1
+ import { CanvasDevice } from "../interfaces/ICanvasGrid";
2
+ import { VemPositionType, } from "../interfaces/IVemPosition";
3
+ import { OverlapIntervalTree } from "../utils/overlap";
4
+ import { setElementPosition } from "../utils/position";
5
+ const SPACE_DELTA = 1;
6
+ const HEIGHT_DELTA = 32;
7
+ /**
8
+ * Finds the first available position for a new responsive element within a canvas.
9
+ * @param canvasWidth - The width of the canvas in terms of columns.
10
+ * @param newElement - The new responsive element to place on the canvas.
11
+ * @param elements - The existing elements on the canvas.
12
+ * @param device - The target device type (e.g., desktop, tablet, mobile) to calculate responsive positions.
13
+ * @returns - The column and row start positions for the new element, or `undefined` if no valid position is found.
14
+ */
15
+ export function findAvailablePosition(canvasWidth, newElement, elements, device) {
16
+ const { colSpan: newWidth, rowSpan: newHeight } = newElement.position.responsive[device];
17
+ const sortedElements = elements
18
+ .slice()
19
+ .sort((a, b) => a.position.responsive[device].rowStart -
20
+ b.position.responsive[device].rowStart);
21
+ const intervalTree = new OverlapIntervalTree();
22
+ for (const element of sortedElements) {
23
+ const elemPosition = element.position.responsive[device];
24
+ const colEnd = elemPosition.colStart + (elemPosition.colSpan - 1);
25
+ const rowEnd = elemPosition.rowStart + elemPosition.rowSpan - 1;
26
+ if (!intervalTree.overlaps(elemPosition.colStart, colEnd, elemPosition.rowStart, rowEnd)) {
27
+ intervalTree.insert(elemPosition.colStart, colEnd, elemPosition.rowStart, rowEnd);
28
+ }
29
+ }
30
+ for (let rowStart = 1; rowStart <= Infinity - newHeight; rowStart += SPACE_DELTA) {
31
+ // height iteration will be until it finds a result
32
+ for (let colStart = 1; colStart <= canvasWidth - newWidth + 1; colStart += SPACE_DELTA) {
33
+ if (!intervalTree.overlaps(colStart, colStart + newWidth - 1, rowStart, rowStart + newHeight - 1)) {
34
+ const col = colStart === 0 ? 1 : colStart;
35
+ const row = rowStart === 0 ? 1 : rowStart;
36
+ return { colStart: col, rowStart: row };
37
+ }
38
+ }
39
+ }
40
+ return undefined;
41
+ }
42
+ /**
43
+ * Updates the responsive position of a given element for a specified device.
44
+ * @param element - The responsive element to update.
45
+ * @param newPosition - The new position values to update for the element.
46
+ * @param device - The target device type (e.g., desktop, tablet, mobile) for which the position is updated.
47
+ * @returns - A new `VemResponsive` object with the updated responsive position for the specified device.
48
+ */
49
+ export function updateResponsivePosition(element, newPosition, device) {
50
+ var _a;
51
+ 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) }) }) });
52
+ }
53
+ /**
54
+ * Finds available positions for a list of responsive elements on a canvas and updates their positions.
55
+ * @param canvasWidth - The width of the canvas in grid columns.
56
+ * @param newElements - The list of new responsive elements to position.
57
+ * @param elements - The list of existing responsive elements already positioned on the canvas.
58
+ * @param device - The target device type (e.g., desktop, tablet, mobile) for which positions are calculated.
59
+ * @returns - A list of responsive elements with updated positions for the specified device.
60
+ */
61
+ export function findResponsiveAvailablePositions(canvasWidth, newElements, elements, device) {
62
+ const processedElements = elements.slice();
63
+ const resultElems = [];
64
+ newElements.forEach((nElement) => {
65
+ const newElement = calculateColSpan(nElement, canvasWidth, device);
66
+ const availablePosition = findAvailablePosition(canvasWidth, newElement, processedElements, device);
67
+ const newElemWithPosition = updateResponsivePosition(newElement, availablePosition, device);
68
+ resultElems.push(newElemWithPosition);
69
+ processedElements.push(newElemWithPosition);
70
+ });
71
+ return resultElems;
72
+ }
73
+ /**
74
+ * Adjusts the `colSpan` of a responsive element to fit within the specified canvas width and updates its position.
75
+ * @param element - The responsive element to adjust.
76
+ * @param canvasWidth - The width of the canvas in grid columns.
77
+ * @param canvasDevice - The target device type (e.g., desktop, tablet, mobile).
78
+ * @returns - The updated responsive element with an adjusted `colSpan`.
79
+ */
80
+ export function calculateColSpan(element, canvasWidth, canvasDevice) {
81
+ const currentPosition = element.position.responsive[canvasDevice];
82
+ const fixedColSpan = Math.min(currentPosition.colSpan, canvasWidth);
83
+ const position = Object.assign(Object.assign({}, currentPosition), { colSpan: fixedColSpan });
84
+ return setElementPosition(element, VemPositionType.RESPONSIVE, canvasDevice, position);
85
+ }
86
+ export const getResponsiveGridElementsBottomLimit = (elements, device, rowGap) => {
87
+ if (!elements.length)
88
+ return 0;
89
+ const mappedElements = elements.map((element) => {
90
+ const elementPosition = element.position.responsive;
91
+ const maxRows = elementPosition[device].rowStart + elementPosition[device].rowSpan;
92
+ return maxRows * HEIGHT_DELTA + (maxRows - 1) * rowGap;
93
+ });
94
+ return Math.max(...mappedElements);
95
+ };
96
+ /**
97
+ * Calculates the distances of elements from a reference point and returns a list of objects
98
+ * containing the calculated distance and the corresponding element.
99
+ * @param elements - An array of `VemResponsive` objects. Each object represents an element with
100
+ * a `position` property that contains responsive positions for various devices.
101
+ * @param device - The specific device type (key of `CanvasDevice`) to determine the responsive position.
102
+ * @param referencePoint - An object representing the reference point with `x` and `y` coordinates.
103
+ * @param referencePoint.x
104
+ * @param referencePoint.y
105
+ * @returns - An array of objects, where each object contains:
106
+ * - `distance`: The squared Euclidean distance from the reference point.
107
+ * - `element`: The corresponding `VemResponsive` object.
108
+ */
109
+ export const calculateDistancesToReferencePoint = (elements, device, referencePoint) => {
110
+ return elements.map((element) => {
111
+ var _a, _b;
112
+ const position = (_b = (_a = element.position) === null || _a === void 0 ? void 0 : _a.responsive) === null || _b === void 0 ? void 0 : _b[device];
113
+ if (!position) {
114
+ throw new Error(`Position for device ${device} is undefined for element with Id ${element.elementId}.`);
115
+ }
116
+ const distance = Math.pow(referencePoint.x - position.colStart, 2) +
117
+ Math.pow(referencePoint.y - position.rowStart, 2);
118
+ return {
119
+ distance,
120
+ element,
121
+ };
122
+ });
123
+ };
124
+ /**
125
+ /**
126
+ Sorts objects containing a `distance` and `element` by distance in ascending order.
127
+ If two objects have the same distance, it resolves the tie by comparing the `colStart` property
128
+ of their responsive positions for the `DESKTOP` device.
129
+ * @param a - An object containing:
130
+ * - `distance`: The calculated distance from a reference point.
131
+ * - `element`: A `VemResponsive` object with responsive position data.
132
+ * @param b - Another object with the same structure as `a`.
133
+ * @param a.element
134
+ * @param a.distance
135
+ * @param _device - The device type (of type `CanvasDevice`). Currently unused in this function.
136
+ * @param b.distance
137
+ * @param b.element
138
+ * @returns - A negative number if `a` should come before `b`,
139
+ * a positive number if `a` should come after `b`,
140
+ * or 0 if they have the same distance and `colStart` values.
141
+ */
142
+ export const sortByDistanceInResponsiveFunction = (a, b, _device) => {
143
+ if (a.distance === b.distance) {
144
+ return (a.element.position.responsive[CanvasDevice.DESKTOP].colStart -
145
+ b.element.position.responsive[CanvasDevice.DESKTOP].colStart);
146
+ }
147
+ return a.distance - b.distance;
148
+ };
149
+ export const sortResponsiveElements = (elements, sortByDevice) => {
150
+ const sortedElements = calculateDistancesToReferencePoint(elements, sortByDevice, {
151
+ x: 1,
152
+ y: 1,
153
+ }).sort((a, b) => sortByDistanceInResponsiveFunction(a, b, sortByDevice));
154
+ return sortedElements.map((element) => element.element);
155
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./helpers/index";
2
+ export * from "./interfaces/index";
@@ -0,0 +1,2 @@
1
+ export * from "./helpers/index";
2
+ export * from "./interfaces/index";
@@ -0,0 +1,5 @@
1
+ export declare enum CanvasDevice {
2
+ DESKTOP = "desktop",
3
+ TABLET = "tablet",
4
+ MOBILE = "mobile"
5
+ }
@@ -0,0 +1,6 @@
1
+ export var CanvasDevice;
2
+ (function (CanvasDevice) {
3
+ CanvasDevice["DESKTOP"] = "desktop";
4
+ CanvasDevice["TABLET"] = "tablet";
5
+ CanvasDevice["MOBILE"] = "mobile";
6
+ })(CanvasDevice || (CanvasDevice = {}));
@@ -0,0 +1,5 @@
1
+ export interface FindAvailablePositionOptions {
2
+ initialY?: number;
3
+ findRightToLeft?: boolean;
4
+ canvasHeight?: number;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -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 @@
1
+ import { VemPositionType, } from "./IVemPosition";
@@ -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,5 @@
1
+ export var VemPositionType;
2
+ (function (VemPositionType) {
3
+ VemPositionType["FIXED"] = "fixed";
4
+ VemPositionType["RESPONSIVE"] = "responsive";
5
+ })(VemPositionType || (VemPositionType = {}));
@@ -0,0 +1,4 @@
1
+ export * from "./ICanvasGrid";
2
+ export * from "./IFixedPosition";
3
+ export * from "./IVemCore";
4
+ export * from "./IVemPosition";
@@ -0,0 +1,4 @@
1
+ export * from "./ICanvasGrid";
2
+ export * from "./IFixedPosition";
3
+ export * from "./IVemCore";
4
+ export * from "./IVemPosition";
@@ -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,24 @@
1
+ import { setElementPosition } from "./position";
2
+ import { CanvasDevice } from "../interfaces/ICanvasGrid";
3
+ import { VemPositionType, } from "../interfaces/IVemPosition";
4
+ export const copyDesktopPositionToDevice = (elements, newCanvasDevice, canvasType) => {
5
+ const defaultPositionMap = {
6
+ [VemPositionType.FIXED]: {
7
+ x: 0,
8
+ y: 0,
9
+ },
10
+ [VemPositionType.RESPONSIVE]: {
11
+ colStart: 1,
12
+ rowStart: 1,
13
+ },
14
+ };
15
+ return elements.map((element) => {
16
+ var _a;
17
+ if (!((_a = element.position[canvasType]) === null || _a === void 0 ? void 0 : _a[newCanvasDevice])) {
18
+ const desktopViewPosition = element.position[canvasType][CanvasDevice.DESKTOP];
19
+ const newDevicePosition = Object.assign(Object.assign({}, desktopViewPosition), defaultPositionMap[canvasType]);
20
+ return setElementPosition(element, canvasType, newCanvasDevice, newDevicePosition);
21
+ }
22
+ return element;
23
+ });
24
+ };
@@ -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,16 @@
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 const sortByDistanceFunction = (a, b) => {
12
+ if (a.distance === b.distance) {
13
+ return 0;
14
+ }
15
+ return a.distance < b.distance ? -1 : 1;
16
+ };
@@ -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 {};
@@ -0,0 +1,95 @@
1
+ /**
2
+ *
3
+ */
4
+ export class OverlapIntervalTree {
5
+ /**
6
+ *
7
+ */
8
+ constructor() {
9
+ this.root = undefined;
10
+ }
11
+ /**
12
+ *
13
+ * @param startX
14
+ * @param endX
15
+ * @param startY
16
+ * @param endY
17
+ */
18
+ insert(startX, endX, startY, endY) {
19
+ this.root = this._insert(this.root, startX, endX, startY, endY);
20
+ }
21
+ /**
22
+ *
23
+ * @param startX
24
+ * @param endX
25
+ * @param startY
26
+ * @param endY
27
+ */
28
+ _initNode(startX, endX, startY, endY) {
29
+ return {
30
+ startX,
31
+ endX,
32
+ startY,
33
+ endY,
34
+ maxEndX: endX,
35
+ maxEndY: endY,
36
+ left: undefined,
37
+ right: undefined,
38
+ };
39
+ }
40
+ /**
41
+ *
42
+ * @param node
43
+ * @param startX
44
+ * @param endX
45
+ * @param startY
46
+ * @param endY
47
+ */
48
+ _insert(node, startX, endX, startY, endY) {
49
+ if (node === undefined) {
50
+ return this._initNode(startX, endX, startY, endY);
51
+ }
52
+ if (startY < node.startY) {
53
+ node.left = this._insert(node.left, startX, endX, startY, endY);
54
+ }
55
+ else {
56
+ node.right = this._insert(node.right, startX, endX, startY, endY);
57
+ }
58
+ node.maxEndX = Math.max(node.maxEndX, endX);
59
+ node.maxEndY = Math.max(node.maxEndY, endY);
60
+ return node;
61
+ }
62
+ /**
63
+ *
64
+ * @param startX
65
+ * @param endX
66
+ * @param startY
67
+ * @param endY
68
+ */
69
+ overlaps(startX, endX, startY, endY) {
70
+ return this._overlaps(this.root, startX, endX, startY, endY);
71
+ }
72
+ /**
73
+ *
74
+ * @param node
75
+ * @param startX
76
+ * @param endX
77
+ * @param startY
78
+ * @param endY
79
+ */
80
+ _overlaps(node, startX, endX, startY, endY) {
81
+ if (node === undefined) {
82
+ return false;
83
+ }
84
+ if (startX <= node.endX &&
85
+ endX >= node.startX &&
86
+ startY <= node.endY &&
87
+ endY >= node.startY) {
88
+ return true;
89
+ }
90
+ if (node.left !== undefined && node.left.maxEndY >= startY) {
91
+ return this._overlaps(node.left, startX, endX, startY, endY);
92
+ }
93
+ return this._overlaps(node.right, startX, endX, startY, endY);
94
+ }
95
+ }
@@ -0,0 +1,4 @@
1
+ import { CanvasDevice } from "../interfaces/ICanvasGrid";
2
+ import { Vem } from "../interfaces/IVemCore";
3
+ import { VemPosition, VemPositionType } from "../interfaces/IVemPosition";
4
+ export declare const setElementPosition: <T extends VemPositionType = VemPositionType>(baseElement: Vem<unknown, T>, type: T, device: CanvasDevice, position: VemPosition) => Vem<unknown, T>;
@@ -0,0 +1 @@
1
+ export const setElementPosition = (baseElement, type, device, position) => (Object.assign(Object.assign({}, baseElement), { position: Object.assign(Object.assign({}, baseElement.position), { [type]: Object.assign(Object.assign({}, baseElement.position[type]), { [device]: position }) }) }));
@@ -34,7 +34,8 @@ function getLogicBodyFromFD21(filterData) {
34
34
  filters = filters.concat(expressions);
35
35
  });
36
36
  }
37
- logics.push(Object.assign(Object.assign({}, logic), { filters }));
37
+ if (!isEmpty(filters))
38
+ logics.push(Object.assign(Object.assign({}, logic), { filters }));
38
39
  return logics;
39
40
  }, []);
40
41
  }
@@ -1,3 +1,8 @@
1
1
  import { IFBFilter } from "../../interfaces/backend/IFBFilter";
2
2
  import { IFSFilter } from "../../interfaces/common/IFSFilter";
3
+ /**
4
+ *
5
+ * @param filters
6
+ * @param groupColumns
7
+ */
3
8
  export declare function buildFilters(filters: IFSFilter[], groupColumns?: boolean): IFBFilter[];
@@ -1,7 +1,12 @@
1
+ import { buildExpression } from "./buildExpression";
1
2
  import { isEmpty } from "../../../general/mix/isEmpty";
2
3
  import { _hasProperty } from "../../../general/object/hasProperty";
3
4
  import { FILTER_OPERATOR } from "../../constants/common/FILTER_OPERATOR";
4
- import { buildExpression } from "./buildExpression";
5
+ /**
6
+ *
7
+ * @param filters
8
+ * @param groupColumns
9
+ */
5
10
  export function buildFilters(filters, groupColumns = false) {
6
11
  const expression = numericExpression(filters, groupColumns);
7
12
  const orOperators = expression.split("+");
@@ -25,6 +30,8 @@ export function buildFilters(filters, groupColumns = false) {
25
30
  return getColumnExpressions(group, getFilter);
26
31
  })
27
32
  .filter(Boolean);
33
+ if (isEmpty(expressions))
34
+ return [];
28
35
  if (orOperators.length > 1) {
29
36
  return [
30
37
  {
@@ -38,6 +45,11 @@ export function buildFilters(filters, groupColumns = false) {
38
45
  }
39
46
  return [{ operator: FILTER_OPERATOR.AND, expressions }];
40
47
  }
48
+ /**
49
+ *
50
+ * @param group
51
+ * @param getFilter
52
+ */
41
53
  function getColumnExpressions(group, getFilter) {
42
54
  const columnOrOperators = group.split("/");
43
55
  if (columnOrOperators.length > 1) {
@@ -50,12 +62,22 @@ function getColumnExpressions(group, getFilter) {
50
62
  }
51
63
  return getFilter(group);
52
64
  }
65
+ /**
66
+ *
67
+ * @param operator
68
+ * @param priority
69
+ */
53
70
  function logicToNumeric(operator, priority = false) {
54
71
  if (operator === FILTER_OPERATOR.AND) {
55
72
  return "*";
56
73
  }
57
74
  return priority ? "/" : "+";
58
75
  }
76
+ /**
77
+ *
78
+ * @param filters
79
+ * @param groupColumns
80
+ */
59
81
  function numericExpression(filters, groupColumns = false) {
60
82
  let expression = "";
61
83
  filters.forEach((item, index) => {
@@ -8,3 +8,9 @@ import { IFValidator } from "../../interfaces/IFValidator";
8
8
  * @returns properties of the Date column
9
9
  */
10
10
  export declare function getDateProperties(column: IColumn, validator: IFValidator): IColumnPropertyInfo[];
11
+ /**
12
+ * Returns True or false when the output format in the date column exists and is a time type
13
+ * @param column Column prop
14
+ * @returns True if The Date Column has a time format, otherwise is false.
15
+ */
16
+ export declare function isDateColumnTimeFormat(column: IColumn): boolean;
@@ -36,7 +36,7 @@ export function getDateProperties(column, validator) {
36
36
  * @param column Column prop
37
37
  * @returns True if The Date Column has a time format, otherwise is false.
38
38
  */
39
- function isDateColumnTimeFormat(column) {
39
+ export function isDateColumnTimeFormat(column) {
40
40
  const formatDate = _get(column.outputFormat, "format");
41
41
  return !isEmpty(formatDate) && formatDate.split(" ").length > 1;
42
42
  }
@@ -16,7 +16,6 @@ import { getScopesToDisplay } from "./getScopesToDisplay";
16
16
  */
17
17
  export function getFilterSettings(filterSettings, allowedScopes = [], otherSettings) {
18
18
  let settings = mergeDeep(FILTER_SETTINGS_DEFAULT, objectCopy(filterSettings));
19
- settings = mergeDeep(settings, otherSettings);
20
19
  const scopesSettings = getScopesToDisplay(settings).filter((scope) => allowedScopes.includes(scope.id));
21
20
  if (scopesSettings.length > 1) {
22
21
  settings = getFilterSettingsByMultipleScopes(settings, allowedScopes);
@@ -27,6 +26,7 @@ export function getFilterSettings(filterSettings, allowedScopes = [], otherSetti
27
26
  else {
28
27
  settings = getFilterSettingsByNoScopes(settings);
29
28
  }
29
+ settings = mergeDeep(settings, otherSettings);
30
30
  return settings;
31
31
  }
32
32
  /**
@@ -2,4 +2,8 @@ import { IFScope } from "../IFScope";
2
2
  export interface IFSScopeID {
3
3
  label: IFScope;
4
4
  id?: string;
5
+ /**
6
+ * The ID of the dataset related to the filter
7
+ */
8
+ datasetId?: string;
5
9
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Gets the number of times that the param value exists into the object array
3
+ * @param array the given array
4
+ * @param param the param of the array object to compare
5
+ * @param value the value of the array object to compare
6
+ * @returns the number of times the parameter value exists
7
+ */
8
+ export declare function howManyByParam<T = Record<string, unknown>>(array: T[], param: keyof T, value: unknown): number;