summaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-ui/src/app/paletx/core/overlay/overlay-position-map.ts
blob: 8ce53850fd58c426ed1be149b6b679a2e3fef2ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* tslint:disable:array-type member-access variable-name typedef
 only-arrow-functions directive-class-suffix component-class-suffix
 component-selector one-variable-per-declaration
 no-attribute-parameter-decorator*/
import {ConnectionPositionPair} from './index';

export const POSITION_MAP: any = {
  'top': {
	originX: 'center',
	originY: 'top',
	overlayX: 'center',
	overlayY: 'bottom'
  },
  'topCenter': {
	originX: 'center',
	originY: 'top',
	overlayX: 'center',
	overlayY: 'bottom'
  },
  'topLeft':
		{originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom'},
  'topRight':
		{originX: 'end', originY: 'top', overlayX: 'end', overlayY: 'bottom'},
  'right': {
	originX: 'end',
	originY: 'center',
	overlayX: 'start',
	overlayY: 'center',
  },
  'rightTop': {
	originX: 'end',
	originY: 'top',
	overlayX: 'start',
	overlayY: 'top',
  },
  'rightBottom': {
	originX: 'end',
	originY: 'bottom',
	overlayX: 'start',
	overlayY: 'bottom',
  },
  'bottom': {
	originX: 'center',
	originY: 'bottom',
	overlayX: 'center',
	overlayY: 'top',
  },
  'bottomCenter': {
	originX: 'center',
	originY: 'bottom',
	overlayX: 'center',
	overlayY: 'top',
  },
  'bottomLeft': {
	originX: 'start',
	originY: 'bottom',
	overlayX: 'start',
	overlayY: 'top',
  },
  'bottomRight': {
	originX: 'end',
	originY: 'bottom',
	overlayX: 'end',
	overlayY: 'top',
  },
  'left': {
	originX: 'start',
	originY: 'center',
	overlayX: 'end',
	overlayY: 'center',
  },
  'leftTop': {
	originX: 'start',
	originY: 'top',
	overlayX: 'end',
	overlayY: 'top',
  },
  'leftBottom': {
	originX: 'start',
	originY: 'bottom',
	overlayX: 'end',
	overlayY: 'bottom',
  },
};
export const DEFAULT_4_POSITIONS = _objectValues([
  POSITION_MAP['top'], POSITION_MAP['right'], POSITION_MAP['bottom'],
  POSITION_MAP['left']
]);
export const DEFAULT_DROPDOWN_POSITIONS =
	_objectValues([POSITION_MAP['bottomLeft'], POSITION_MAP['topLeft']]);
export const DEFAULT_DATEPICKER_POSITIONS = [
  {
	originX: 'start',
	originY: 'top',
	overlayX: 'start',
	overlayY: 'top',
  },
  {
	originX: 'start',
	originY: 'bottom',
	overlayX: 'start',
	overlayY: 'bottom',
  }
] as ConnectionPositionPair[];

function arrayMap(array: any, iteratee: any) {
  let index = -1;
  const length = array === null ? 0 : array.length, result = Array(length);

  while (++index < length) {
	result[index] = iteratee(array[index], index, array);
  }
  return result;
}

function baseValues(object: any, props: any) {
  return arrayMap(props, function(key: any) {
	return object[key];
  });
}

function _objectValues(object: any) {
  return object === null ? [] : baseValues(object, Object.keys(object));
}