@qrvey/utils 1.17.1 → 1.17.2
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/README.md +1 -1
- package/dist/cjs/elements/helpers/fixed.js +10 -1
- package/dist/cjs/elements/helpers/gridStrategy.js +23 -9
- package/dist/cjs/elements/helpers/responsive.js +10 -1
- package/dist/cjs/elements/helpers/vem-element/constants/vem.constants.js +33 -0
- package/dist/cjs/elements/helpers/vem-element/definitions/main.definitions.js +263 -0
- package/dist/cjs/elements/helpers/vem-element/helpers/vem.helpers.js +76 -0
- package/dist/cjs/elements/helpers/vem-element/models/vem.models.js +3 -0
- package/dist/cjs/elements/interfaces/IVemCore.js +12 -0
- package/dist/cjs/elements/utils/element.js +23 -2
- package/dist/elements/helpers/fixed.d.ts +3 -2
- package/dist/elements/helpers/fixed.js +9 -1
- package/dist/elements/helpers/gridStrategy.d.ts +8 -1
- package/dist/elements/helpers/gridStrategy.js +24 -12
- package/dist/elements/helpers/responsive.d.ts +3 -2
- package/dist/elements/helpers/responsive.js +9 -1
- package/dist/elements/helpers/vem-element/constants/vem.constants.d.ts +24 -0
- package/dist/elements/helpers/vem-element/constants/vem.constants.js +30 -0
- package/dist/elements/helpers/vem-element/definitions/main.definitions.d.ts +9 -0
- package/dist/elements/helpers/vem-element/definitions/main.definitions.js +260 -0
- package/dist/elements/helpers/vem-element/helpers/vem.helpers.d.ts +8 -0
- package/dist/elements/helpers/vem-element/helpers/vem.helpers.js +70 -0
- package/dist/elements/helpers/vem-element/models/vem.models.d.ts +85 -0
- package/dist/elements/helpers/vem-element/models/vem.models.js +1 -0
- package/dist/elements/interfaces/ICanvasGrid.d.ts +24 -0
- package/dist/elements/interfaces/IVemCore.d.ts +14 -0
- package/dist/elements/interfaces/IVemCore.js +11 -0
- package/dist/elements/utils/element.d.ts +5 -1
- package/dist/elements/utils/element.js +21 -1
- package/package.json +4 -1
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { findFixedAvailablePositions, getFixedGridElementsBottomLimit, recalculatePreservingPositions, sortElementsFromReferencePoint, updateFixedElementDimensions, } from "./fixed";
|
|
2
|
-
import { findResponsiveAvailablePositions, getResponsiveGridElementsBottomLimit, sortResponsiveElements, updateResponsiveElementDimensions, } from "./responsive";
|
|
1
|
+
import { convertResponsiveElementsToFixed, findFixedAvailablePositions, getFixedGridElementsBottomLimit, recalculatePreservingPositions, sortElementsFromReferencePoint, updateFixedElementDimensions, } from "./fixed";
|
|
2
|
+
import { convertFixedElementsToResponsive, findResponsiveAvailablePositions, getResponsiveGridElementsBottomLimit, sortResponsiveElements, updateResponsiveElementDimensions, } from "./responsive";
|
|
3
3
|
import { CanvasDevice, VemPositionType, } from "../interfaces";
|
|
4
|
-
import { copyDesktopPositionToDevice } from "../utils/element";
|
|
4
|
+
import { copyDesktopPositionToDevice, normalizeElements, } from "../utils/element";
|
|
5
|
+
const normalizePositionStrategies = {
|
|
6
|
+
[VemPositionType.FIXED]: (canvasConfig, elements, device) => convertResponsiveElementsToFixed(canvasConfig, elements, device),
|
|
7
|
+
[VemPositionType.RESPONSIVE]: (canvasConfig, elements, device) => convertFixedElementsToResponsive(canvasConfig, elements, device),
|
|
8
|
+
};
|
|
5
9
|
const applyDynamicSizeStrategies = {
|
|
6
10
|
fixed: (containerItem, scopeElements, device) => {
|
|
7
11
|
return updateFixedElementDimensions(containerItem, device, scopeElements);
|
|
@@ -10,12 +14,18 @@ const applyDynamicSizeStrategies = {
|
|
|
10
14
|
return updateResponsiveElementDimensions(containerItem, device, scopeElements, gap);
|
|
11
15
|
},
|
|
12
16
|
};
|
|
17
|
+
export const normalizeElementPositions = ({ elements, canvasConfig, target, canvasDevice, }) => {
|
|
18
|
+
const _canvasDevice = canvasDevice ?? CanvasDevice.DESKTOP;
|
|
19
|
+
return normalizePositionStrategies[target](canvasConfig, elements, _canvasDevice);
|
|
20
|
+
};
|
|
13
21
|
const recalculateStrategies = {
|
|
14
22
|
fixed: (elements, currentElements, canvasWidth, device, options) => {
|
|
15
|
-
const
|
|
23
|
+
const { newElements, scopeElements } = normalizeElements(currentElements, device, VemPositionType.FIXED);
|
|
24
|
+
const elementsToCalculate = [...newElements, ...elements];
|
|
25
|
+
const isSorted = !scopeElements.length;
|
|
16
26
|
const changedElements = (options.allowCopy
|
|
17
|
-
? copyDesktopPositionToDevice(
|
|
18
|
-
:
|
|
27
|
+
? copyDesktopPositionToDevice(elementsToCalculate, device, VemPositionType.FIXED)
|
|
28
|
+
: elementsToCalculate);
|
|
19
29
|
const orderedElements = isSorted
|
|
20
30
|
? sortElementsFromReferencePoint(changedElements, options.sort, {
|
|
21
31
|
x: 0,
|
|
@@ -23,18 +33,20 @@ const recalculateStrategies = {
|
|
|
23
33
|
})
|
|
24
34
|
: changedElements;
|
|
25
35
|
return options.keepPosition
|
|
26
|
-
? recalculatePreservingPositions(orderedElements,
|
|
27
|
-
: findFixedAvailablePositions(canvasWidth, orderedElements,
|
|
36
|
+
? recalculatePreservingPositions(orderedElements, scopeElements, device, canvasWidth, options.canvasHeight)
|
|
37
|
+
: findFixedAvailablePositions(canvasWidth, orderedElements, scopeElements, device, false, false, options?.canvasHeight);
|
|
28
38
|
},
|
|
29
39
|
responsive: (elements, currentElements, canvasWidth, device, options) => {
|
|
30
|
-
const
|
|
40
|
+
const { scopeElements, newElements } = normalizeElements(currentElements, device, VemPositionType.RESPONSIVE);
|
|
41
|
+
const elementsToCalculate = [...newElements, ...elements];
|
|
42
|
+
const isSorted = !scopeElements.length;
|
|
31
43
|
const changedElements = (options.allowCopy
|
|
32
|
-
? copyDesktopPositionToDevice(
|
|
33
|
-
:
|
|
44
|
+
? copyDesktopPositionToDevice(elementsToCalculate, device, VemPositionType.RESPONSIVE)
|
|
45
|
+
: elementsToCalculate);
|
|
34
46
|
const orderedElements = isSorted
|
|
35
47
|
? sortResponsiveElements(changedElements, options.sort)
|
|
36
48
|
: changedElements;
|
|
37
|
-
return findResponsiveAvailablePositions(canvasWidth, orderedElements,
|
|
49
|
+
return findResponsiveAvailablePositions(canvasWidth, orderedElements, scopeElements, device);
|
|
38
50
|
},
|
|
39
51
|
};
|
|
40
52
|
const calculateCanvasHeightStrategies = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CanvasDevice } from "../interfaces/ICanvasGrid";
|
|
2
|
-
import { VemFixed, VemResponsive } from "../interfaces/IVemCore";
|
|
1
|
+
import { CanvasDevice, CanvasGridConfig, CanvasGridConfigResponsive } from "../interfaces/ICanvasGrid";
|
|
2
|
+
import { Vem, VemFixed, VemResponsive } from "../interfaces/IVemCore";
|
|
3
3
|
import { VemPositionResponsive } from "../interfaces/IVemPosition";
|
|
4
4
|
export declare function findAvailablePosition(canvasWidth: number, newElement: VemResponsive, elements: VemResponsive[], device: CanvasDevice): {
|
|
5
5
|
colStart: number;
|
|
@@ -25,3 +25,4 @@ export declare const sortByDistanceInResponsiveFunction: (a: {
|
|
|
25
25
|
}, _device: CanvasDevice) => number;
|
|
26
26
|
export declare const sortResponsiveElements: (elements: VemResponsive<unknown>[], sortByDevice?: CanvasDevice) => VemResponsive<unknown>[];
|
|
27
27
|
export declare const updateResponsiveElementDimensions: (containerItem: VemResponsive<unknown>, device: CanvasDevice, scopeElements: VemFixed<unknown>[], rowGapSize: number) => VemResponsive<unknown>;
|
|
28
|
+
export declare const convertFixedElementsToResponsive: (config: CanvasGridConfig<CanvasGridConfigResponsive>, elements: Vem[], canvasDevice?: CanvasDevice) => VemResponsive[];
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { objectCopy } from "../../general";
|
|
2
|
-
import { CanvasDevice } from "../interfaces/ICanvasGrid";
|
|
2
|
+
import { CanvasDevice, } from "../interfaces/ICanvasGrid";
|
|
3
3
|
import { VemPositionType, } from "../interfaces/IVemPosition";
|
|
4
4
|
import { dxGetFixedGridItemsBottomLimit } from "../utils/fixed.position";
|
|
5
5
|
import { OverlapIntervalTree } from "../utils/overlap";
|
|
6
6
|
import { setElementPosition } from "../utils/position";
|
|
7
|
+
import { updateDimension } from "./vem-element/helpers/vem.helpers";
|
|
7
8
|
const SPACE_DELTA = 1;
|
|
8
9
|
const HEIGHT_DELTA = 32;
|
|
9
10
|
const CANVAS_EXTRA_ROW = 1;
|
|
@@ -119,3 +120,10 @@ export const updateResponsiveElementDimensions = (containerItem, device, scopeEl
|
|
|
119
120
|
}, device);
|
|
120
121
|
return { ...currentElement };
|
|
121
122
|
};
|
|
123
|
+
export const convertFixedElementsToResponsive = (config, elements, canvasDevice = CanvasDevice.DESKTOP) => {
|
|
124
|
+
const newElements = elements.filter((element) => !element.position?.responsive);
|
|
125
|
+
const currentElements = elements.filter((element) => element.position?.responsive);
|
|
126
|
+
let recalculatedElements = newElements.map((baseElem) => updateDimension(baseElem, config, VemPositionType.RESPONSIVE));
|
|
127
|
+
recalculatedElements = findResponsiveAvailablePositions(config[canvasDevice].columns.count, recalculatedElements, currentElements, canvasDevice);
|
|
128
|
+
return [...currentElements, ...recalculatedElements];
|
|
129
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CanvasDevice } from "../../../interfaces/ICanvasGrid";
|
|
2
|
+
export declare const DEFAULT_CUSTOM_HEIGHT_IN_FIXED = 30;
|
|
3
|
+
export declare const DEFAULT_CUSTOM_HEIGHT_IN_RESPONSIVE = 32;
|
|
4
|
+
export declare const DEFAULT_MIN_FONT_TO_AUTO_RESIZE = 18;
|
|
5
|
+
export declare const DEFAULT_DELTA_RESIZE_IN_FIXED = 1.5;
|
|
6
|
+
export declare const DEFAULT_DELTA_RESIZE_IN_RESPONSIVE = 2.8;
|
|
7
|
+
export declare const DEFAULT_WIDTH_IN_FIXED = 415;
|
|
8
|
+
export declare const MIN_WIDTH_IN_FIXED = 275;
|
|
9
|
+
export declare const DEFAULT_HEIGHT_IN_FIXED = 76;
|
|
10
|
+
export declare const DEFAULT_WIDTH_IN_RESPONSIVE = 4;
|
|
11
|
+
export declare const MIN_WIDTH_IN_RESPONSIVE = 3;
|
|
12
|
+
export declare const DEFAULT_HEIGHT_IN_RESPONSIVE = 2;
|
|
13
|
+
export declare const DEFAULT_HEIGHT_IN_LIST = 245;
|
|
14
|
+
export declare enum FILTER_LIST_TYPE {
|
|
15
|
+
DROPDOWN = "DROPDOWN",
|
|
16
|
+
LIST = "LIST"
|
|
17
|
+
}
|
|
18
|
+
export declare enum FILTER_TRIGGER_TYPE {
|
|
19
|
+
AUTOMATIC = "AUTOMATIC",
|
|
20
|
+
BUTTON = "BUTTON",
|
|
21
|
+
DROPDOWN = "DROPDOWN",
|
|
22
|
+
LIST = "LIST"
|
|
23
|
+
}
|
|
24
|
+
export declare const DEVICE_LIST: CanvasDevice[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CanvasDevice } from "../../../interfaces/ICanvasGrid";
|
|
2
|
+
export const DEFAULT_CUSTOM_HEIGHT_IN_FIXED = 30;
|
|
3
|
+
export const DEFAULT_CUSTOM_HEIGHT_IN_RESPONSIVE = 32;
|
|
4
|
+
export const DEFAULT_MIN_FONT_TO_AUTO_RESIZE = 18;
|
|
5
|
+
export const DEFAULT_DELTA_RESIZE_IN_FIXED = 1.5;
|
|
6
|
+
export const DEFAULT_DELTA_RESIZE_IN_RESPONSIVE = 2.8;
|
|
7
|
+
export const DEFAULT_WIDTH_IN_FIXED = 415;
|
|
8
|
+
export const MIN_WIDTH_IN_FIXED = 275;
|
|
9
|
+
export const DEFAULT_HEIGHT_IN_FIXED = 76;
|
|
10
|
+
export const DEFAULT_WIDTH_IN_RESPONSIVE = 4;
|
|
11
|
+
export const MIN_WIDTH_IN_RESPONSIVE = 3;
|
|
12
|
+
export const DEFAULT_HEIGHT_IN_RESPONSIVE = 2;
|
|
13
|
+
export const DEFAULT_HEIGHT_IN_LIST = 245;
|
|
14
|
+
export var FILTER_LIST_TYPE;
|
|
15
|
+
(function (FILTER_LIST_TYPE) {
|
|
16
|
+
FILTER_LIST_TYPE["DROPDOWN"] = "DROPDOWN";
|
|
17
|
+
FILTER_LIST_TYPE["LIST"] = "LIST";
|
|
18
|
+
})(FILTER_LIST_TYPE || (FILTER_LIST_TYPE = {}));
|
|
19
|
+
export var FILTER_TRIGGER_TYPE;
|
|
20
|
+
(function (FILTER_TRIGGER_TYPE) {
|
|
21
|
+
FILTER_TRIGGER_TYPE["AUTOMATIC"] = "AUTOMATIC";
|
|
22
|
+
FILTER_TRIGGER_TYPE["BUTTON"] = "BUTTON";
|
|
23
|
+
FILTER_TRIGGER_TYPE["DROPDOWN"] = "DROPDOWN";
|
|
24
|
+
FILTER_TRIGGER_TYPE["LIST"] = "LIST";
|
|
25
|
+
})(FILTER_TRIGGER_TYPE || (FILTER_TRIGGER_TYPE = {}));
|
|
26
|
+
export const DEVICE_LIST = [
|
|
27
|
+
CanvasDevice.DESKTOP,
|
|
28
|
+
CanvasDevice.TABLET,
|
|
29
|
+
CanvasDevice.MOBILE,
|
|
30
|
+
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { VemAnalytics, VemButton, VemDefinition, VemImage, VemText } from "../models/vem.models";
|
|
2
|
+
export declare const IMAGE_ITEM_DEFINITION: VemDefinition<VemImage>;
|
|
3
|
+
export declare const BUTTON_ITEM_DEFINITION: VemDefinition<VemButton>;
|
|
4
|
+
export declare const TEXT_ITEM_DEFINITION: VemDefinition<VemText>;
|
|
5
|
+
export declare const ANALYTICS_ITEM_DEFINITION: VemDefinition<VemAnalytics>;
|
|
6
|
+
export declare const FILTER_INPUT_ITEM_DEFINITION: VemDefinition<unknown>;
|
|
7
|
+
export declare const FILTER_LIST_ITEM_DEFINITION: VemDefinition<unknown>;
|
|
8
|
+
export declare const FILTER_DATE_ITEM_DEFINITION: VemDefinition<unknown>;
|
|
9
|
+
export declare const CONTAINER_ITEM_DEFINITION: VemDefinition<unknown>;
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { DEFAULT_DELTA_RESIZE_IN_FIXED, DEFAULT_DELTA_RESIZE_IN_RESPONSIVE, DEFAULT_HEIGHT_IN_FIXED, DEFAULT_HEIGHT_IN_RESPONSIVE, DEFAULT_MIN_FONT_TO_AUTO_RESIZE, DEFAULT_WIDTH_IN_FIXED, DEFAULT_WIDTH_IN_RESPONSIVE, FILTER_LIST_TYPE, FILTER_TRIGGER_TYPE, } from "../constants/vem.constants";
|
|
2
|
+
export const IMAGE_ITEM_DEFINITION = {
|
|
3
|
+
behavior: {
|
|
4
|
+
addingConfig: {
|
|
5
|
+
defaultDimensions: {
|
|
6
|
+
responsive: {
|
|
7
|
+
colSpan: 2,
|
|
8
|
+
rowSpan: 6,
|
|
9
|
+
},
|
|
10
|
+
fixed: {
|
|
11
|
+
width: 100,
|
|
12
|
+
height: 100,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
defaultItemData: {
|
|
16
|
+
aspect: "cover",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
export const BUTTON_ITEM_DEFINITION = {
|
|
22
|
+
behavior: {
|
|
23
|
+
addingConfig: {
|
|
24
|
+
defaultDimensions: {
|
|
25
|
+
responsive: {
|
|
26
|
+
colSpan: 1,
|
|
27
|
+
rowSpan: 1,
|
|
28
|
+
},
|
|
29
|
+
fixed: {
|
|
30
|
+
width: 100,
|
|
31
|
+
height: 30,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
defaultItemData: () => ({
|
|
35
|
+
background: "#FF5300",
|
|
36
|
+
color: "#ffffff",
|
|
37
|
+
fontFamily: "Inter, serif",
|
|
38
|
+
fontSize: "12px",
|
|
39
|
+
url: "",
|
|
40
|
+
label: "",
|
|
41
|
+
}),
|
|
42
|
+
minSize: {
|
|
43
|
+
fixed: {
|
|
44
|
+
height: 30,
|
|
45
|
+
width: 30,
|
|
46
|
+
customSize: (itemData) => {
|
|
47
|
+
const fontSizeValue = parseInt(itemData.fontSize.replace("px", ""), 10);
|
|
48
|
+
const minHeight = fontSizeValue > DEFAULT_MIN_FONT_TO_AUTO_RESIZE
|
|
49
|
+
? fontSizeValue * DEFAULT_DELTA_RESIZE_IN_FIXED
|
|
50
|
+
: 30;
|
|
51
|
+
return {
|
|
52
|
+
height: minHeight,
|
|
53
|
+
width: 30,
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
responsive: {
|
|
58
|
+
height: 1,
|
|
59
|
+
width: 1,
|
|
60
|
+
customSize: (itemData) => {
|
|
61
|
+
const fontSizeValue = parseInt(itemData.fontSize.replace("px", ""), 10);
|
|
62
|
+
const minHeightPx = fontSizeValue > DEFAULT_MIN_FONT_TO_AUTO_RESIZE
|
|
63
|
+
? fontSizeValue * DEFAULT_DELTA_RESIZE_IN_RESPONSIVE
|
|
64
|
+
: 30;
|
|
65
|
+
return {
|
|
66
|
+
height: Math.round(minHeightPx / 32),
|
|
67
|
+
width: 1,
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
export const TEXT_ITEM_DEFINITION = {
|
|
76
|
+
behavior: {
|
|
77
|
+
addingConfig: {
|
|
78
|
+
defaultDimensions: {
|
|
79
|
+
responsive: {
|
|
80
|
+
colSpan: 2,
|
|
81
|
+
rowSpan: 6,
|
|
82
|
+
},
|
|
83
|
+
fixed: {
|
|
84
|
+
width: 200,
|
|
85
|
+
height: 100,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
defaultItemData: {
|
|
89
|
+
backgroundColor: "rgba(0,0,0,0)",
|
|
90
|
+
borderColor: "#000000",
|
|
91
|
+
borderWidth: "1px",
|
|
92
|
+
borderStyle: "none",
|
|
93
|
+
fontFamily: "Inter, serif",
|
|
94
|
+
fontSize: "12px",
|
|
95
|
+
fontColor: "#000000",
|
|
96
|
+
paddingTop: 5,
|
|
97
|
+
paddingBottom: 5,
|
|
98
|
+
paddingLeft: 5,
|
|
99
|
+
paddingRight: 5,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
export const ANALYTICS_ITEM_DEFINITION = {
|
|
105
|
+
behavior: {
|
|
106
|
+
addingConfig: {
|
|
107
|
+
defaultDimensions: {
|
|
108
|
+
responsive: {
|
|
109
|
+
colSpan: 4,
|
|
110
|
+
rowSpan: 10,
|
|
111
|
+
},
|
|
112
|
+
fixed: {
|
|
113
|
+
width: 400,
|
|
114
|
+
height: 400,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
export const FILTER_INPUT_ITEM_DEFINITION = {
|
|
121
|
+
behavior: {
|
|
122
|
+
addingConfig: {
|
|
123
|
+
defaultDimensions: {
|
|
124
|
+
responsive: {
|
|
125
|
+
colSpan: DEFAULT_WIDTH_IN_RESPONSIVE,
|
|
126
|
+
rowSpan: DEFAULT_HEIGHT_IN_RESPONSIVE,
|
|
127
|
+
},
|
|
128
|
+
fixed: {
|
|
129
|
+
width: DEFAULT_WIDTH_IN_FIXED,
|
|
130
|
+
height: DEFAULT_HEIGHT_IN_FIXED,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
minSize: {
|
|
134
|
+
fixed: {
|
|
135
|
+
height: 76,
|
|
136
|
+
width: 200,
|
|
137
|
+
customSize: () => {
|
|
138
|
+
return {
|
|
139
|
+
height: 76,
|
|
140
|
+
width: 200,
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
responsive: {
|
|
145
|
+
height: 1,
|
|
146
|
+
width: 1,
|
|
147
|
+
customSize: () => {
|
|
148
|
+
return {
|
|
149
|
+
height: 1,
|
|
150
|
+
width: 1,
|
|
151
|
+
};
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
export const FILTER_LIST_ITEM_DEFINITION = {
|
|
159
|
+
behavior: {
|
|
160
|
+
addingConfig: {
|
|
161
|
+
defaultDimensions: {
|
|
162
|
+
responsive: {
|
|
163
|
+
colSpan: DEFAULT_WIDTH_IN_RESPONSIVE,
|
|
164
|
+
rowSpan: 2,
|
|
165
|
+
},
|
|
166
|
+
fixed: {
|
|
167
|
+
width: DEFAULT_WIDTH_IN_FIXED,
|
|
168
|
+
height: DEFAULT_HEIGHT_IN_FIXED,
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
minSize: {
|
|
172
|
+
fixed: {
|
|
173
|
+
height: 30,
|
|
174
|
+
width: 130,
|
|
175
|
+
customSize: (itemData) => {
|
|
176
|
+
const minHeight = itemData.type === FILTER_LIST_TYPE.LIST ? 100 : 30;
|
|
177
|
+
return {
|
|
178
|
+
height: minHeight,
|
|
179
|
+
width: 130,
|
|
180
|
+
};
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
responsive: {
|
|
184
|
+
height: 1,
|
|
185
|
+
width: 1,
|
|
186
|
+
customSize: () => {
|
|
187
|
+
return {
|
|
188
|
+
height: 1,
|
|
189
|
+
width: 1,
|
|
190
|
+
};
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
export const FILTER_DATE_ITEM_DEFINITION = {
|
|
198
|
+
behavior: {
|
|
199
|
+
addingConfig: {
|
|
200
|
+
defaultDimensions: {
|
|
201
|
+
responsive: {
|
|
202
|
+
colSpan: DEFAULT_WIDTH_IN_RESPONSIVE,
|
|
203
|
+
rowSpan: DEFAULT_HEIGHT_IN_RESPONSIVE,
|
|
204
|
+
},
|
|
205
|
+
fixed: {
|
|
206
|
+
width: DEFAULT_WIDTH_IN_FIXED,
|
|
207
|
+
height: DEFAULT_HEIGHT_IN_FIXED,
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
defaultItemData: {
|
|
211
|
+
validators: [],
|
|
212
|
+
trigger: FILTER_TRIGGER_TYPE.BUTTON,
|
|
213
|
+
selectorColor: "#FF5300",
|
|
214
|
+
buttonBackgroundColor: "#FF5300",
|
|
215
|
+
buttonTextColor: "#ffffff",
|
|
216
|
+
buttonBorderColor: "#FF5300",
|
|
217
|
+
borderColor: "#e3e3e3",
|
|
218
|
+
fontColor: "#5F5F5F",
|
|
219
|
+
},
|
|
220
|
+
minSize: {
|
|
221
|
+
fixed: {
|
|
222
|
+
height: 30,
|
|
223
|
+
width: 100,
|
|
224
|
+
customSize: () => {
|
|
225
|
+
return {
|
|
226
|
+
height: 30,
|
|
227
|
+
width: 100,
|
|
228
|
+
};
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
responsive: {
|
|
232
|
+
height: 1,
|
|
233
|
+
width: 1,
|
|
234
|
+
customSize: () => {
|
|
235
|
+
return {
|
|
236
|
+
height: 1,
|
|
237
|
+
width: 1,
|
|
238
|
+
};
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
export const CONTAINER_ITEM_DEFINITION = {
|
|
246
|
+
behavior: {
|
|
247
|
+
addingConfig: {
|
|
248
|
+
defaultDimensions: {
|
|
249
|
+
responsive: {
|
|
250
|
+
colSpan: 10,
|
|
251
|
+
rowSpan: 10,
|
|
252
|
+
},
|
|
253
|
+
fixed: {
|
|
254
|
+
width: 900,
|
|
255
|
+
height: 500,
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CanvasDevice, CanvasGridConfig, CanvasGridConfigFixed, CanvasGridConfigResponsive } from "../../../interfaces/ICanvasGrid";
|
|
2
|
+
import { Vem, VemFixed, VemResponsive } from "../../../interfaces/IVemCore";
|
|
3
|
+
import { VemPositionFixed, VemPositionResponsive, VemPositionType } from "../../../interfaces/IVemPosition";
|
|
4
|
+
import { VemDefinitionConfig } from "../models/vem.models";
|
|
5
|
+
export declare const VEM_DEFINITIONS: VemDefinitionConfig;
|
|
6
|
+
export declare const updateDimension: (element: VemFixed | VemResponsive, canvasConfig: CanvasGridConfig<CanvasGridConfigResponsive | CanvasGridConfigFixed>, positionType: VemPositionType, deviceList?: CanvasDevice[]) => VemResponsive;
|
|
7
|
+
export declare const getDefaultDimensions: (item: Vem, positionType: VemPositionType) => VemPositionFixed | VemPositionResponsive;
|
|
8
|
+
export declare const validateDimension: (baseElem: VemResponsive, columnsCount: number, canvasDevice: CanvasDevice) => VemResponsive;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { CanvasDevice, } from "../../../interfaces/ICanvasGrid";
|
|
2
|
+
import { VemPositionType, } from "../../../interfaces/IVemPosition";
|
|
3
|
+
import { setElementPosition } from "../../../utils/position";
|
|
4
|
+
import { DEVICE_LIST } from "../constants/vem.constants";
|
|
5
|
+
import { ANALYTICS_ITEM_DEFINITION, BUTTON_ITEM_DEFINITION, CONTAINER_ITEM_DEFINITION, FILTER_DATE_ITEM_DEFINITION, FILTER_INPUT_ITEM_DEFINITION, FILTER_LIST_ITEM_DEFINITION, IMAGE_ITEM_DEFINITION, TEXT_ITEM_DEFINITION, } from "../definitions/main.definitions";
|
|
6
|
+
export const VEM_DEFINITIONS = {
|
|
7
|
+
image: IMAGE_ITEM_DEFINITION,
|
|
8
|
+
button: BUTTON_ITEM_DEFINITION,
|
|
9
|
+
text: TEXT_ITEM_DEFINITION,
|
|
10
|
+
analytics: ANALYTICS_ITEM_DEFINITION,
|
|
11
|
+
filterInput: FILTER_INPUT_ITEM_DEFINITION,
|
|
12
|
+
filterDate: FILTER_DATE_ITEM_DEFINITION,
|
|
13
|
+
filterList: FILTER_LIST_ITEM_DEFINITION,
|
|
14
|
+
container: CONTAINER_ITEM_DEFINITION,
|
|
15
|
+
};
|
|
16
|
+
export const updateDimension = (element, canvasConfig, positionType, deviceList = DEVICE_LIST) => {
|
|
17
|
+
const position = getDefaultDimensions(element, positionType);
|
|
18
|
+
let newElement = element;
|
|
19
|
+
deviceList.forEach((device) => {
|
|
20
|
+
const isForceAddField = device !== CanvasDevice.DESKTOP;
|
|
21
|
+
const newPosition = {
|
|
22
|
+
...position,
|
|
23
|
+
...(isForceAddField && { preCalculated: true }),
|
|
24
|
+
};
|
|
25
|
+
const updatedElement = setElementPosition(newElement, positionType, device, newPosition);
|
|
26
|
+
if (positionType === VemPositionType.RESPONSIVE) {
|
|
27
|
+
const columns = canvasConfig[device]
|
|
28
|
+
.columns.count;
|
|
29
|
+
newElement = validateDimension(updatedElement, columns, device);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
newElement = updatedElement;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return newElement;
|
|
36
|
+
};
|
|
37
|
+
const normalizeSize = (item, positionType) => {
|
|
38
|
+
const vemDefinition = VEM_DEFINITIONS[item.type];
|
|
39
|
+
const rawSize = vemDefinition.behavior.addingConfig.defaultDimensions[positionType];
|
|
40
|
+
const customSizeResolver = vemDefinition?.behavior.addingConfig.minSize?.[positionType]?.customSize;
|
|
41
|
+
const baseHeight = "height" in rawSize ? rawSize.height : rawSize.rowSpan;
|
|
42
|
+
const baseWidth = "width" in rawSize ? rawSize.width : rawSize.colSpan;
|
|
43
|
+
if (!customSizeResolver)
|
|
44
|
+
return { height: baseHeight, width: baseWidth };
|
|
45
|
+
const customSize = customSizeResolver(item.itemData);
|
|
46
|
+
return {
|
|
47
|
+
height: Math.max(customSize.height, baseHeight),
|
|
48
|
+
width: Math.max(customSize.width, baseWidth),
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export const getDefaultDimensions = (item, positionType) => {
|
|
52
|
+
const { height, width } = normalizeSize(item, positionType);
|
|
53
|
+
if (positionType === VemPositionType.FIXED) {
|
|
54
|
+
return { x: 0, y: 0, height, width, z: 1 };
|
|
55
|
+
}
|
|
56
|
+
return { colSpan: width, rowSpan: height, colStart: 1, rowStart: 1 };
|
|
57
|
+
};
|
|
58
|
+
export const validateDimension = (baseElem, columnsCount, canvasDevice) => {
|
|
59
|
+
const currentPosition = baseElem.position.responsive[canvasDevice];
|
|
60
|
+
if (!currentPosition)
|
|
61
|
+
return baseElem;
|
|
62
|
+
const fixedColSpan = currentPosition.colSpan <= columnsCount
|
|
63
|
+
? currentPosition?.colSpan
|
|
64
|
+
: columnsCount;
|
|
65
|
+
const position = {
|
|
66
|
+
...currentPosition,
|
|
67
|
+
colSpan: fixedColSpan,
|
|
68
|
+
};
|
|
69
|
+
return setElementPosition(baseElem, VemPositionType.RESPONSIVE, canvasDevice, position);
|
|
70
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { VemCreation, VemType } from "../../../interfaces/IVemCore";
|
|
2
|
+
import { VemPositionType, VemSizeConfig } from "../../../interfaces/IVemPosition";
|
|
3
|
+
export interface VemDefinition<T = unknown> {
|
|
4
|
+
behavior: VemItemBehavior<T>;
|
|
5
|
+
}
|
|
6
|
+
interface VemItemBehavior<T> {
|
|
7
|
+
addingConfig: VemAddingConfig<T>;
|
|
8
|
+
}
|
|
9
|
+
export interface VemActionManager {
|
|
10
|
+
checkAutoLinks: (data: unknown) => unknown[] | undefined;
|
|
11
|
+
}
|
|
12
|
+
interface VemAddingConfig<T> {
|
|
13
|
+
defaultDimensions: VemSizeConfig;
|
|
14
|
+
defaultActionData?: ((item: VemCreation, actionManager: VemActionManager) => unknown[] | undefined) | unknown[];
|
|
15
|
+
defaultItemData?: ((item: VemCreation) => T) | T;
|
|
16
|
+
minSize?: VemMinSize;
|
|
17
|
+
}
|
|
18
|
+
export interface VemMinSizeConfig {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
customSize: (item: Record<string, unknown>) => {
|
|
22
|
+
height: number;
|
|
23
|
+
width: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface VemMinSize {
|
|
27
|
+
[VemPositionType.FIXED]: VemMinSizeConfig;
|
|
28
|
+
[VemPositionType.RESPONSIVE]: VemMinSizeConfig;
|
|
29
|
+
}
|
|
30
|
+
export type VemDefinitionConfig = Record<VemType, VemDefinition>;
|
|
31
|
+
export type VemImageAspect = "cover" | "fill" | "contain";
|
|
32
|
+
export interface VemImage {
|
|
33
|
+
image?: string;
|
|
34
|
+
aspect?: VemImageAspect;
|
|
35
|
+
fromFile?: boolean;
|
|
36
|
+
fileName?: string;
|
|
37
|
+
linkUrl?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface VemButton {
|
|
40
|
+
label: string;
|
|
41
|
+
background: string;
|
|
42
|
+
color: string;
|
|
43
|
+
url?: string;
|
|
44
|
+
targetLink?: boolean;
|
|
45
|
+
fontFamily?: string;
|
|
46
|
+
fontSize?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface VemText {
|
|
49
|
+
text?: string;
|
|
50
|
+
link?: string;
|
|
51
|
+
fontFamily?: string;
|
|
52
|
+
fontSize?: string;
|
|
53
|
+
fontColor?: string;
|
|
54
|
+
fontWeight?: string;
|
|
55
|
+
backgroundColor?: string;
|
|
56
|
+
alignText?: string;
|
|
57
|
+
textDecoration?: string;
|
|
58
|
+
verticalAlign?: string;
|
|
59
|
+
textWrapping?: string;
|
|
60
|
+
borderStyle?: string;
|
|
61
|
+
borderColor?: string;
|
|
62
|
+
borderWidth?: string;
|
|
63
|
+
paddingLeft?: number;
|
|
64
|
+
paddingTop?: number;
|
|
65
|
+
paddingRight?: number;
|
|
66
|
+
paddingBottom?: number;
|
|
67
|
+
format?: string;
|
|
68
|
+
whiteSpace?: string;
|
|
69
|
+
orderedList?: boolean;
|
|
70
|
+
bulletList?: boolean;
|
|
71
|
+
textWrap?: string;
|
|
72
|
+
textExpanded?: boolean;
|
|
73
|
+
selectedFormat?: Record<string, unknown>;
|
|
74
|
+
}
|
|
75
|
+
export interface VemAnalytics {
|
|
76
|
+
filters?: unknown[];
|
|
77
|
+
qrveyId: string;
|
|
78
|
+
chartType: string;
|
|
79
|
+
metricId?: string;
|
|
80
|
+
chartId?: string;
|
|
81
|
+
summaryId?: string;
|
|
82
|
+
showOriginal?: string;
|
|
83
|
+
originalData?: unknown;
|
|
84
|
+
}
|
|
85
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { VemPositionType, } from "../../../interfaces/IVemPosition";
|
|
@@ -1,5 +1,29 @@
|
|
|
1
|
+
export interface CanvasGridConfigDetailResponsive {
|
|
2
|
+
count: number;
|
|
3
|
+
gap: number;
|
|
4
|
+
autoCount?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface CanvasGridConfigResponsive {
|
|
7
|
+
columns: CanvasGridConfigDetailResponsive;
|
|
8
|
+
rows: CanvasGridConfigDetailResponsive;
|
|
9
|
+
autoPosition?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface CanvasGridConfigFixed {
|
|
12
|
+
height: number;
|
|
13
|
+
width: number;
|
|
14
|
+
autoHeight: boolean;
|
|
15
|
+
}
|
|
16
|
+
type CanvasGridConfigGeneric = CanvasGridConfigFixed | CanvasGridConfigResponsive;
|
|
17
|
+
export interface CanvasGridConfig<TGridConfig extends CanvasGridConfigGeneric = CanvasGridConfigGeneric> {
|
|
18
|
+
desktop: TGridConfig;
|
|
19
|
+
tablet?: TGridConfig;
|
|
20
|
+
mobile?: TGridConfig;
|
|
21
|
+
snapToGrid?: boolean;
|
|
22
|
+
gridLines?: boolean;
|
|
23
|
+
}
|
|
1
24
|
export declare enum CanvasDevice {
|
|
2
25
|
DESKTOP = "desktop",
|
|
3
26
|
TABLET = "tablet",
|
|
4
27
|
MOBILE = "mobile"
|
|
5
28
|
}
|
|
29
|
+
export {};
|
|
@@ -23,4 +23,18 @@ export interface VemElementMap<T = unknown> {
|
|
|
23
23
|
[VemPositionType.FIXED]: VemFixed<T>;
|
|
24
24
|
[VemPositionType.RESPONSIVE]: VemResponsive<T>;
|
|
25
25
|
}
|
|
26
|
+
export type VemCreation<T = unknown> = Omit<Vem<T>, "elementId"> & {
|
|
27
|
+
baseData?: T;
|
|
28
|
+
elementId?: string;
|
|
29
|
+
};
|
|
30
|
+
export declare enum VemType {
|
|
31
|
+
IMAGE = "image",
|
|
32
|
+
BUTTON = "button",
|
|
33
|
+
TEXT = "text",
|
|
34
|
+
ANALYTICS = "analytics",
|
|
35
|
+
FILTER_INPUT = "filterInput",
|
|
36
|
+
FILTER_LIST = "filterList",
|
|
37
|
+
FILTER_DATE = "filterDate",
|
|
38
|
+
CONTAINER = "container"
|
|
39
|
+
}
|
|
26
40
|
export {};
|
|
@@ -1 +1,12 @@
|
|
|
1
1
|
import { VemPositionType, } from "./IVemPosition";
|
|
2
|
+
export var VemType;
|
|
3
|
+
(function (VemType) {
|
|
4
|
+
VemType["IMAGE"] = "image";
|
|
5
|
+
VemType["BUTTON"] = "button";
|
|
6
|
+
VemType["TEXT"] = "text";
|
|
7
|
+
VemType["ANALYTICS"] = "analytics";
|
|
8
|
+
VemType["FILTER_INPUT"] = "filterInput";
|
|
9
|
+
VemType["FILTER_LIST"] = "filterList";
|
|
10
|
+
VemType["FILTER_DATE"] = "filterDate";
|
|
11
|
+
VemType["CONTAINER"] = "container";
|
|
12
|
+
})(VemType || (VemType = {}));
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { CanvasDevice } from "../interfaces/ICanvasGrid";
|
|
2
2
|
import { Vem } from "../interfaces/IVemCore";
|
|
3
3
|
import { VemPositionType } from "../interfaces/IVemPosition";
|
|
4
|
-
export declare const copyDesktopPositionToDevice: (elements: Vem[], newCanvasDevice: CanvasDevice, canvasType: VemPositionType) => Vem[];
|
|
4
|
+
export declare const copyDesktopPositionToDevice: (elements: Vem[], newCanvasDevice: CanvasDevice, canvasType: VemPositionType) => Vem<unknown, VemPositionType>[];
|
|
5
|
+
export declare const normalizeElements: (elements: Vem[], newCanvasDevice: CanvasDevice, canvasType: VemPositionType) => {
|
|
6
|
+
scopeElements: Vem[];
|
|
7
|
+
newElements: Vem[];
|
|
8
|
+
};
|