source: trip-planner-front/node_modules/primeng/fesm2015/primeng-utils.mjs@ 6fe77af

Last change on this file since 6fe77af was 59329aa, checked in by Ema <ema_spirova@…>, 3 years ago

adding photos

  • Property mode set to 100644
File size: 6.5 KB
Line 
1class ObjectUtils {
2 static equals(obj1, obj2, field) {
3 if (field)
4 return (this.resolveFieldData(obj1, field) === this.resolveFieldData(obj2, field));
5 else
6 return this.equalsByValue(obj1, obj2);
7 }
8 static equalsByValue(obj1, obj2) {
9 if (obj1 === obj2)
10 return true;
11 if (obj1 && obj2 && typeof obj1 == 'object' && typeof obj2 == 'object') {
12 var arrA = Array.isArray(obj1), arrB = Array.isArray(obj2), i, length, key;
13 if (arrA && arrB) {
14 length = obj1.length;
15 if (length != obj2.length)
16 return false;
17 for (i = length; i-- !== 0;)
18 if (!this.equalsByValue(obj1[i], obj2[i]))
19 return false;
20 return true;
21 }
22 if (arrA != arrB)
23 return false;
24 var dateA = obj1 instanceof Date, dateB = obj2 instanceof Date;
25 if (dateA != dateB)
26 return false;
27 if (dateA && dateB)
28 return obj1.getTime() == obj2.getTime();
29 var regexpA = obj1 instanceof RegExp, regexpB = obj2 instanceof RegExp;
30 if (regexpA != regexpB)
31 return false;
32 if (regexpA && regexpB)
33 return obj1.toString() == obj2.toString();
34 var keys = Object.keys(obj1);
35 length = keys.length;
36 if (length !== Object.keys(obj2).length)
37 return false;
38 for (i = length; i-- !== 0;)
39 if (!Object.prototype.hasOwnProperty.call(obj2, keys[i]))
40 return false;
41 for (i = length; i-- !== 0;) {
42 key = keys[i];
43 if (!this.equalsByValue(obj1[key], obj2[key]))
44 return false;
45 }
46 return true;
47 }
48 return obj1 !== obj1 && obj2 !== obj2;
49 }
50 static resolveFieldData(data, field) {
51 if (data && field) {
52 if (this.isFunction(field)) {
53 return field(data);
54 }
55 else if (field.indexOf('.') == -1) {
56 return data[field];
57 }
58 else {
59 let fields = field.split('.');
60 let value = data;
61 for (let i = 0, len = fields.length; i < len; ++i) {
62 if (value == null) {
63 return null;
64 }
65 value = value[fields[i]];
66 }
67 return value;
68 }
69 }
70 else {
71 return null;
72 }
73 }
74 static isFunction(obj) {
75 return !!(obj && obj.constructor && obj.call && obj.apply);
76 }
77 static reorderArray(value, from, to) {
78 let target;
79 if (value && from !== to) {
80 if (to >= value.length) {
81 to %= value.length;
82 from %= value.length;
83 }
84 value.splice(to, 0, value.splice(from, 1)[0]);
85 }
86 }
87 static insertIntoOrderedArray(item, index, arr, sourceArr) {
88 if (arr.length > 0) {
89 let injected = false;
90 for (let i = 0; i < arr.length; i++) {
91 let currentItemIndex = this.findIndexInList(arr[i], sourceArr);
92 if (currentItemIndex > index) {
93 arr.splice(i, 0, item);
94 injected = true;
95 break;
96 }
97 }
98 if (!injected) {
99 arr.push(item);
100 }
101 }
102 else {
103 arr.push(item);
104 }
105 }
106 static findIndexInList(item, list) {
107 let index = -1;
108 if (list) {
109 for (let i = 0; i < list.length; i++) {
110 if (list[i] == item) {
111 index = i;
112 break;
113 }
114 }
115 }
116 return index;
117 }
118 static contains(value, list) {
119 if (value != null && list && list.length) {
120 for (let val of list) {
121 if (this.equals(value, val))
122 return true;
123 }
124 }
125 return false;
126 }
127 static removeAccents(str) {
128 if (str && str.search(/[\xC0-\xFF]/g) > -1) {
129 str = str
130 .replace(/[\xC0-\xC5]/g, "A")
131 .replace(/[\xC6]/g, "AE")
132 .replace(/[\xC7]/g, "C")
133 .replace(/[\xC8-\xCB]/g, "E")
134 .replace(/[\xCC-\xCF]/g, "I")
135 .replace(/[\xD0]/g, "D")
136 .replace(/[\xD1]/g, "N")
137 .replace(/[\xD2-\xD6\xD8]/g, "O")
138 .replace(/[\xD9-\xDC]/g, "U")
139 .replace(/[\xDD]/g, "Y")
140 .replace(/[\xDE]/g, "P")
141 .replace(/[\xE0-\xE5]/g, "a")
142 .replace(/[\xE6]/g, "ae")
143 .replace(/[\xE7]/g, "c")
144 .replace(/[\xE8-\xEB]/g, "e")
145 .replace(/[\xEC-\xEF]/g, "i")
146 .replace(/[\xF1]/g, "n")
147 .replace(/[\xF2-\xF6\xF8]/g, "o")
148 .replace(/[\xF9-\xFC]/g, "u")
149 .replace(/[\xFE]/g, "p")
150 .replace(/[\xFD\xFF]/g, "y");
151 }
152 return str;
153 }
154}
155
156var lastId = 0;
157function UniqueComponentId() {
158 let prefix = 'pr_id_';
159 lastId++;
160 return `${prefix}${lastId}`;
161}
162
163function ZIndexUtils() {
164 let zIndexes = [];
165 const generateZIndex = (key, baseZIndex) => {
166 let lastZIndex = zIndexes.length > 0 ? zIndexes[zIndexes.length - 1] : { key, value: baseZIndex };
167 let newZIndex = lastZIndex.value + (lastZIndex.key === key ? 0 : baseZIndex) + 1;
168 zIndexes.push({ key, value: newZIndex });
169 return newZIndex;
170 };
171 const revertZIndex = (zIndex) => {
172 zIndexes = zIndexes.filter(obj => obj.value !== zIndex);
173 };
174 const getCurrentZIndex = () => {
175 return zIndexes.length > 0 ? zIndexes[zIndexes.length - 1].value : 0;
176 };
177 const getZIndex = (el) => {
178 return el ? parseInt(el.style.zIndex, 10) || 0 : 0;
179 };
180 return {
181 get: getZIndex,
182 set: (key, el, baseZIndex) => {
183 if (el) {
184 el.style.zIndex = String(generateZIndex(key, baseZIndex));
185 }
186 },
187 clear: (el) => {
188 if (el) {
189 revertZIndex(getZIndex(el));
190 el.style.zIndex = '';
191 }
192 },
193 getCurrent: () => getCurrentZIndex()
194 };
195}
196var zindexutils = ZIndexUtils();
197
198/**
199 * Generated bundle index. Do not edit.
200 */
201
202export { ObjectUtils, UniqueComponentId, zindexutils as ZIndexUtils };
Note: See TracBrowser for help on using the repository browser.