@widergy/mobile-ui 0.40.1 → 1.1.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +921 -0
  2. package/lib/components/Button/index.js +10 -6
  3. package/lib/components/Button/styles.js +5 -5
  4. package/lib/components/Capture/index.js +3 -3
  5. package/lib/components/Carousel/components/CarouselComponent/index.js +2 -0
  6. package/lib/components/Carousel/components/CarouselContainer/index.js +2 -10
  7. package/lib/components/CheckList/components/CheckBoxRenderer/index.js +1 -0
  8. package/lib/components/CheckList/index.js +5 -3
  9. package/lib/components/CheckList/proptypes.js +2 -2
  10. package/lib/components/Checkbox/styles.js +3 -3
  11. package/lib/components/Dropdown/index.js +12 -10
  12. package/lib/components/FilePicker/utils.js +2 -2
  13. package/lib/components/Icon/constants.js +1 -0
  14. package/lib/components/Icon/index.js +11 -1
  15. package/lib/components/ImageIcon/index.js +8 -1
  16. package/lib/components/ImageRadio/index.js +21 -12
  17. package/lib/components/Loading/index.js +1 -0
  18. package/lib/components/Overlay/index.js +2 -10
  19. package/lib/components/PhotoAlbum/index.js +8 -9
  20. package/lib/components/Picker/index.js +2 -2
  21. package/lib/components/Portal/components/Manager/index.js +7 -4
  22. package/lib/components/RadioGroup/components/RadioButton/index.js +5 -5
  23. package/lib/components/RateChart/components/RateStagesGraph/components/Indicator/index.js +3 -3
  24. package/lib/components/RateChart/components/RateStagesGraph/components/Indicator/utils.js +1 -1
  25. package/lib/components/TransformView/constants.js +1 -1
  26. package/lib/components/TransformView/utils.js +674 -0
  27. package/lib/components/UTAutocomplete/index.js +4 -4
  28. package/lib/components/UTBanner/index.js +42 -0
  29. package/lib/components/UTBanner/styles.js +14 -0
  30. package/lib/components/UTCBUInput/index.js +2 -2
  31. package/lib/components/UTHeader/index.js +56 -0
  32. package/lib/components/UTHeader/styles.js +16 -0
  33. package/lib/components/UTMenu/components/ListView/index.js +4 -2
  34. package/lib/components/UTMenu/components/MenuOption/index.js +1 -0
  35. package/lib/components/UTMenu/index.js +3 -3
  36. package/lib/components/UTMenu/proptypes.js +2 -2
  37. package/lib/components/UTOnBoarding/components/CardContent/index.js +3 -3
  38. package/lib/components/UTOnBoarding/index.js +4 -4
  39. package/lib/components/UTPasswordField/components/PasswordValidations/index.js +2 -6
  40. package/lib/components/UTSelect/componentes/MultipleItem/index.js +1 -0
  41. package/lib/components/UTSelect/proptypes.js +1 -0
  42. package/lib/components/UTStepFeedback/components/CircleNumber/index.js +12 -10
  43. package/lib/components/UTStepFeedback/index.js +36 -37
  44. package/lib/components/UTStepper/components/Connectors/index.js +33 -0
  45. package/lib/components/UTStepper/components/Connectors/styles.js +26 -0
  46. package/lib/components/UTStepper/components/Step/index.js +50 -0
  47. package/lib/components/UTStepper/components/Step/styles.js +47 -0
  48. package/lib/components/UTStepper/index.js +34 -0
  49. package/lib/components/UTStepper/styles.js +12 -0
  50. package/lib/components/UTStepper/types.js +3 -0
  51. package/lib/components/UTSwitch/proptypes.js +1 -0
  52. package/lib/components/UTTextInput/components/BaseInput/index.js +10 -12
  53. package/lib/components/UTTextInput/proptypes.js +1 -0
  54. package/lib/components/UTTopbar/index.js +64 -0
  55. package/lib/components/UTTopbar/styles.js +16 -0
  56. package/lib/components/UTTopbar/types.js +8 -0
  57. package/lib/components/UTWorkflowContainer/index.js +10 -102
  58. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/BottomStepHandler/index.js +4 -4
  59. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/BottomStepHandler/styles.js +3 -3
  60. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/Header/index.js +9 -9
  61. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/Header/styles.js +3 -3
  62. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/components/ActionButton/index.js +2 -2
  63. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/components/ActionButton/styles.js +12 -12
  64. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/components/ActionButton/types.js +9 -9
  65. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/index.js +6 -6
  66. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/styles.js +3 -3
  67. package/lib/components/UTWorkflowContainer/versions/V0/index.js +108 -0
  68. package/lib/components/UTWorkflowContainer/{styles.js → versions/V0/styles.js} +4 -4
  69. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/components/ActionButton/index.js +35 -0
  70. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/components/ActionButton/styles.js +13 -0
  71. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/components/ActionButton/types.js +9 -0
  72. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/constants.js +2 -0
  73. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/index.js +110 -0
  74. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/styles.js +75 -0
  75. package/lib/components/UTWorkflowContainer/versions/V1/index.js +94 -0
  76. package/lib/components/UTWorkflowContainer/versions/V1/styles.js +14 -0
  77. package/lib/components/UTWorkflowContainer/versions/V1/types.js +24 -0
  78. package/lib/theming/DefaultTheme.js +1 -0
  79. package/lib/utils/fileUtils.js/index.js +20 -5
  80. package/package.json +47 -71
  81. /package/lib/components/UTWorkflowContainer/{README.md → versions/V0/README.md} +0 -0
  82. /package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/Header/utils.js +0 -0
  83. /package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/constants.js +0 -0
  84. /package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/utils.js +0 -0
@@ -0,0 +1,674 @@
1
+ /* eslint-disable consistent-return */
2
+ /* eslint-disable prefer-destructuring */
3
+ /* eslint-disable camelcase */
4
+ /**
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ *
10
+ * @format
11
+ * @noflow
12
+ */
13
+
14
+ const invariant = require('invariant');
15
+
16
+ /**
17
+ * Memory conservative (mutative) matrix math utilities. Uses "command"
18
+ * matrices, which are reusable.
19
+ */
20
+ const MatrixMath = {
21
+ createIdentityMatrix() {
22
+ return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
23
+ },
24
+
25
+ createCopy(m) {
26
+ return [
27
+ m[0],
28
+ m[1],
29
+ m[2],
30
+ m[3],
31
+ m[4],
32
+ m[5],
33
+ m[6],
34
+ m[7],
35
+ m[8],
36
+ m[9],
37
+ m[10],
38
+ m[11],
39
+ m[12],
40
+ m[13],
41
+ m[14],
42
+ m[15]
43
+ ];
44
+ },
45
+
46
+ createOrthographic(left, right, bottom, top, near, far) {
47
+ const a = 2 / (right - left);
48
+ const b = 2 / (top - bottom);
49
+ const c = -2 / (far - near);
50
+
51
+ const tx = -(right + left) / (right - left);
52
+ const ty = -(top + bottom) / (top - bottom);
53
+ const tz = -(far + near) / (far - near);
54
+
55
+ return [a, 0, 0, 0, 0, b, 0, 0, 0, 0, c, 0, tx, ty, tz, 1];
56
+ },
57
+
58
+ createFrustum(left, right, bottom, top, near, far) {
59
+ const r_width = 1 / (right - left);
60
+ const r_height = 1 / (top - bottom);
61
+ const r_depth = 1 / (near - far);
62
+ const x = 2 * (near * r_width);
63
+ const y = 2 * (near * r_height);
64
+ const A = (right + left) * r_width;
65
+ const B = (top + bottom) * r_height;
66
+ const C = (far + near) * r_depth;
67
+ const D = 2 * (far * near * r_depth);
68
+ return [x, 0, 0, 0, 0, y, 0, 0, A, B, C, -1, 0, 0, D, 0];
69
+ },
70
+
71
+ /**
72
+ * This create a perspective projection towards negative z
73
+ * Clipping the z range of [-near, -far]
74
+ *
75
+ * @param fovInRadians - field of view in radians
76
+ */
77
+ createPerspective(fovInRadians, aspect, near, far) {
78
+ const h = 1 / Math.tan(fovInRadians / 2);
79
+ const r_depth = 1 / (near - far);
80
+ const C = (far + near) * r_depth;
81
+ const D = 2 * (far * near * r_depth);
82
+ return [h / aspect, 0, 0, 0, 0, h, 0, 0, 0, 0, C, -1, 0, 0, D, 0];
83
+ },
84
+
85
+ createTranslate2d(x, y) {
86
+ const mat = MatrixMath.createIdentityMatrix();
87
+ MatrixMath.reuseTranslate2dCommand(mat, x, y);
88
+ return mat;
89
+ },
90
+
91
+ reuseTranslate2dCommand(matrixCommand, x, y) {
92
+ matrixCommand[12] = x;
93
+ matrixCommand[13] = y;
94
+ },
95
+
96
+ reuseTranslate3dCommand(matrixCommand, x, y, z) {
97
+ matrixCommand[12] = x;
98
+ matrixCommand[13] = y;
99
+ matrixCommand[14] = z;
100
+ },
101
+
102
+ createScale(factor) {
103
+ const mat = MatrixMath.createIdentityMatrix();
104
+ MatrixMath.reuseScaleCommand(mat, factor);
105
+ return mat;
106
+ },
107
+
108
+ reuseScaleCommand(matrixCommand, factor) {
109
+ matrixCommand[0] = factor;
110
+ matrixCommand[5] = factor;
111
+ },
112
+
113
+ reuseScale3dCommand(matrixCommand, x, y, z) {
114
+ matrixCommand[0] = x;
115
+ matrixCommand[5] = y;
116
+ matrixCommand[10] = z;
117
+ },
118
+
119
+ reusePerspectiveCommand(matrixCommand, p) {
120
+ matrixCommand[11] = -1 / p;
121
+ },
122
+
123
+ reuseScaleXCommand(matrixCommand, factor) {
124
+ matrixCommand[0] = factor;
125
+ },
126
+
127
+ reuseScaleYCommand(matrixCommand, factor) {
128
+ matrixCommand[5] = factor;
129
+ },
130
+
131
+ reuseScaleZCommand(matrixCommand, factor) {
132
+ matrixCommand[10] = factor;
133
+ },
134
+
135
+ reuseRotateXCommand(matrixCommand, radians) {
136
+ matrixCommand[5] = Math.cos(radians);
137
+ matrixCommand[6] = Math.sin(radians);
138
+ matrixCommand[9] = -Math.sin(radians);
139
+ matrixCommand[10] = Math.cos(radians);
140
+ },
141
+
142
+ reuseRotateYCommand(matrixCommand, amount) {
143
+ matrixCommand[0] = Math.cos(amount);
144
+ matrixCommand[2] = -Math.sin(amount);
145
+ matrixCommand[8] = Math.sin(amount);
146
+ matrixCommand[10] = Math.cos(amount);
147
+ },
148
+
149
+ // http://www.w3.org/TR/css3-transforms/#recomposing-to-a-2d-matrix
150
+ reuseRotateZCommand(matrixCommand, radians) {
151
+ matrixCommand[0] = Math.cos(radians);
152
+ matrixCommand[1] = Math.sin(radians);
153
+ matrixCommand[4] = -Math.sin(radians);
154
+ matrixCommand[5] = Math.cos(radians);
155
+ },
156
+
157
+ createRotateZ(radians) {
158
+ const mat = MatrixMath.createIdentityMatrix();
159
+ MatrixMath.reuseRotateZCommand(mat, radians);
160
+ return mat;
161
+ },
162
+
163
+ reuseSkewXCommand(matrixCommand, radians) {
164
+ matrixCommand[4] = Math.tan(radians);
165
+ },
166
+
167
+ reuseSkewYCommand(matrixCommand, radians) {
168
+ matrixCommand[1] = Math.tan(radians);
169
+ },
170
+
171
+ multiplyInto(out, a, b) {
172
+ const a00 = a[0];
173
+ const a01 = a[1];
174
+ const a02 = a[2];
175
+ const a03 = a[3];
176
+ const a10 = a[4];
177
+ const a11 = a[5];
178
+ const a12 = a[6];
179
+ const a13 = a[7];
180
+ const a20 = a[8];
181
+ const a21 = a[9];
182
+ const a22 = a[10];
183
+ const a23 = a[11];
184
+ const a30 = a[12];
185
+ const a31 = a[13];
186
+ const a32 = a[14];
187
+ const a33 = a[15];
188
+
189
+ let b0 = b[0];
190
+ let b1 = b[1];
191
+ let b2 = b[2];
192
+ let b3 = b[3];
193
+ out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
194
+ out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
195
+ out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
196
+ out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
197
+
198
+ b0 = b[4];
199
+ b1 = b[5];
200
+ b2 = b[6];
201
+ b3 = b[7];
202
+ out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
203
+ out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
204
+ out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
205
+ out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
206
+
207
+ b0 = b[8];
208
+ b1 = b[9];
209
+ b2 = b[10];
210
+ b3 = b[11];
211
+ out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
212
+ out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
213
+ out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
214
+ out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
215
+
216
+ b0 = b[12];
217
+ b1 = b[13];
218
+ b2 = b[14];
219
+ b3 = b[15];
220
+ out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
221
+ out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
222
+ out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
223
+ out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
224
+ },
225
+
226
+ determinant(matrix) {
227
+ const [m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33] = matrix;
228
+ return (
229
+ m03 * m12 * m21 * m30 -
230
+ m02 * m13 * m21 * m30 -
231
+ m03 * m11 * m22 * m30 +
232
+ m01 * m13 * m22 * m30 +
233
+ m02 * m11 * m23 * m30 -
234
+ m01 * m12 * m23 * m30 -
235
+ m03 * m12 * m20 * m31 +
236
+ m02 * m13 * m20 * m31 +
237
+ m03 * m10 * m22 * m31 -
238
+ m00 * m13 * m22 * m31 -
239
+ m02 * m10 * m23 * m31 +
240
+ m00 * m12 * m23 * m31 +
241
+ m03 * m11 * m20 * m32 -
242
+ m01 * m13 * m20 * m32 -
243
+ m03 * m10 * m21 * m32 +
244
+ m00 * m13 * m21 * m32 +
245
+ m01 * m10 * m23 * m32 -
246
+ m00 * m11 * m23 * m32 -
247
+ m02 * m11 * m20 * m33 +
248
+ m01 * m12 * m20 * m33 +
249
+ m02 * m10 * m21 * m33 -
250
+ m00 * m12 * m21 * m33 -
251
+ m01 * m10 * m22 * m33 +
252
+ m00 * m11 * m22 * m33
253
+ );
254
+ },
255
+
256
+ /**
257
+ * Inverse of a matrix. Multiplying by the inverse is used in matrix math
258
+ * instead of division.
259
+ *
260
+ * Formula from:
261
+ * http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
262
+ */
263
+ inverse(matrix) {
264
+ const det = MatrixMath.determinant(matrix);
265
+ if (!det) {
266
+ return matrix;
267
+ }
268
+ const [m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33] = matrix;
269
+ return [
270
+ (m12 * m23 * m31 -
271
+ m13 * m22 * m31 +
272
+ m13 * m21 * m32 -
273
+ m11 * m23 * m32 -
274
+ m12 * m21 * m33 +
275
+ m11 * m22 * m33) /
276
+ det,
277
+ (m03 * m22 * m31 -
278
+ m02 * m23 * m31 -
279
+ m03 * m21 * m32 +
280
+ m01 * m23 * m32 +
281
+ m02 * m21 * m33 -
282
+ m01 * m22 * m33) /
283
+ det,
284
+ (m02 * m13 * m31 -
285
+ m03 * m12 * m31 +
286
+ m03 * m11 * m32 -
287
+ m01 * m13 * m32 -
288
+ m02 * m11 * m33 +
289
+ m01 * m12 * m33) /
290
+ det,
291
+ (m03 * m12 * m21 -
292
+ m02 * m13 * m21 -
293
+ m03 * m11 * m22 +
294
+ m01 * m13 * m22 +
295
+ m02 * m11 * m23 -
296
+ m01 * m12 * m23) /
297
+ det,
298
+ (m13 * m22 * m30 -
299
+ m12 * m23 * m30 -
300
+ m13 * m20 * m32 +
301
+ m10 * m23 * m32 +
302
+ m12 * m20 * m33 -
303
+ m10 * m22 * m33) /
304
+ det,
305
+ (m02 * m23 * m30 -
306
+ m03 * m22 * m30 +
307
+ m03 * m20 * m32 -
308
+ m00 * m23 * m32 -
309
+ m02 * m20 * m33 +
310
+ m00 * m22 * m33) /
311
+ det,
312
+ (m03 * m12 * m30 -
313
+ m02 * m13 * m30 -
314
+ m03 * m10 * m32 +
315
+ m00 * m13 * m32 +
316
+ m02 * m10 * m33 -
317
+ m00 * m12 * m33) /
318
+ det,
319
+ (m02 * m13 * m20 -
320
+ m03 * m12 * m20 +
321
+ m03 * m10 * m22 -
322
+ m00 * m13 * m22 -
323
+ m02 * m10 * m23 +
324
+ m00 * m12 * m23) /
325
+ det,
326
+ (m11 * m23 * m30 -
327
+ m13 * m21 * m30 +
328
+ m13 * m20 * m31 -
329
+ m10 * m23 * m31 -
330
+ m11 * m20 * m33 +
331
+ m10 * m21 * m33) /
332
+ det,
333
+ (m03 * m21 * m30 -
334
+ m01 * m23 * m30 -
335
+ m03 * m20 * m31 +
336
+ m00 * m23 * m31 +
337
+ m01 * m20 * m33 -
338
+ m00 * m21 * m33) /
339
+ det,
340
+ (m01 * m13 * m30 -
341
+ m03 * m11 * m30 +
342
+ m03 * m10 * m31 -
343
+ m00 * m13 * m31 -
344
+ m01 * m10 * m33 +
345
+ m00 * m11 * m33) /
346
+ det,
347
+ (m03 * m11 * m20 -
348
+ m01 * m13 * m20 -
349
+ m03 * m10 * m21 +
350
+ m00 * m13 * m21 +
351
+ m01 * m10 * m23 -
352
+ m00 * m11 * m23) /
353
+ det,
354
+ (m12 * m21 * m30 -
355
+ m11 * m22 * m30 -
356
+ m12 * m20 * m31 +
357
+ m10 * m22 * m31 +
358
+ m11 * m20 * m32 -
359
+ m10 * m21 * m32) /
360
+ det,
361
+ (m01 * m22 * m30 -
362
+ m02 * m21 * m30 +
363
+ m02 * m20 * m31 -
364
+ m00 * m22 * m31 -
365
+ m01 * m20 * m32 +
366
+ m00 * m21 * m32) /
367
+ det,
368
+ (m02 * m11 * m30 -
369
+ m01 * m12 * m30 -
370
+ m02 * m10 * m31 +
371
+ m00 * m12 * m31 +
372
+ m01 * m10 * m32 -
373
+ m00 * m11 * m32) /
374
+ det,
375
+ (m01 * m12 * m20 -
376
+ m02 * m11 * m20 +
377
+ m02 * m10 * m21 -
378
+ m00 * m12 * m21 -
379
+ m01 * m10 * m22 +
380
+ m00 * m11 * m22) /
381
+ det
382
+ ];
383
+ },
384
+
385
+ /**
386
+ * Turns columns into rows and rows into columns.
387
+ */
388
+ transpose(m) {
389
+ return [
390
+ m[0],
391
+ m[4],
392
+ m[8],
393
+ m[12],
394
+ m[1],
395
+ m[5],
396
+ m[9],
397
+ m[13],
398
+ m[2],
399
+ m[6],
400
+ m[10],
401
+ m[14],
402
+ m[3],
403
+ m[7],
404
+ m[11],
405
+ m[15]
406
+ ];
407
+ },
408
+
409
+ /**
410
+ * Based on: http://tog.acm.org/resources/GraphicsGems/gemsii/unmatrix.c
411
+ */
412
+ multiplyVectorByMatrix(v, m) {
413
+ const [vx, vy, vz, vw] = v;
414
+ return [
415
+ vx * m[0] + vy * m[4] + vz * m[8] + vw * m[12],
416
+ vx * m[1] + vy * m[5] + vz * m[9] + vw * m[13],
417
+ vx * m[2] + vy * m[6] + vz * m[10] + vw * m[14],
418
+ vx * m[3] + vy * m[7] + vz * m[11] + vw * m[15]
419
+ ];
420
+ },
421
+
422
+ /**
423
+ * From: https://code.google.com/p/webgl-mjs/source/browse/mjs.js
424
+ */
425
+ v3Length(a) {
426
+ return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
427
+ },
428
+
429
+ /**
430
+ * Based on: https://code.google.com/p/webgl-mjs/source/browse/mjs.js
431
+ */
432
+ v3Normalize(vector, v3Length) {
433
+ const im = 1 / (v3Length || MatrixMath.v3Length(vector));
434
+ return [vector[0] * im, vector[1] * im, vector[2] * im];
435
+ },
436
+
437
+ /**
438
+ * The dot product of a and b, two 3-element vectors.
439
+ * From: https://code.google.com/p/webgl-mjs/source/browse/mjs.js
440
+ */
441
+ v3Dot(a, b) {
442
+ return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
443
+ },
444
+
445
+ /**
446
+ * From:
447
+ * http://www.opensource.apple.com/source/WebCore/WebCore-514/platform/graphics/transforms/TransformationMatrix.cpp
448
+ */
449
+ v3Combine(a, b, aScale, bScale) {
450
+ return [aScale * a[0] + bScale * b[0], aScale * a[1] + bScale * b[1], aScale * a[2] + bScale * b[2]];
451
+ },
452
+
453
+ /**
454
+ * From:
455
+ * http://www.opensource.apple.com/source/WebCore/WebCore-514/platform/graphics/transforms/TransformationMatrix.cpp
456
+ */
457
+ v3Cross(a, b) {
458
+ return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
459
+ },
460
+
461
+ /**
462
+ * Based on:
463
+ * http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/
464
+ * and:
465
+ * http://quat.zachbennett.com/
466
+ *
467
+ * Note that this rounds degrees to the thousandth of a degree, due to
468
+ * floating point errors in the creation of the quaternion.
469
+ *
470
+ * Also note that this expects the qw value to be last, not first.
471
+ *
472
+ * Also, when researching this, remember that:
473
+ * yaw === heading === z-axis
474
+ * pitch === elevation/attitude === y-axis
475
+ * roll === bank === x-axis
476
+ */
477
+ quaternionToDegreesXYZ(q) {
478
+ const [qx, qy, qz, qw] = q;
479
+ const qw2 = qw * qw;
480
+ const qx2 = qx * qx;
481
+ const qy2 = qy * qy;
482
+ const qz2 = qz * qz;
483
+ const test = qx * qy + qz * qw;
484
+ const unit = qw2 + qx2 + qy2 + qz2;
485
+ const conv = 180 / Math.PI;
486
+
487
+ if (test > 0.49999 * unit) {
488
+ return [0, 2 * Math.atan2(qx, qw) * conv, 90];
489
+ }
490
+ if (test < -0.49999 * unit) {
491
+ return [0, -2 * Math.atan2(qx, qw) * conv, -90];
492
+ }
493
+
494
+ return [
495
+ MatrixMath.roundTo3Places(Math.atan2(2 * qx * qw - 2 * qy * qz, 1 - 2 * qx2 - 2 * qz2) * conv),
496
+ MatrixMath.roundTo3Places(Math.atan2(2 * qy * qw - 2 * qx * qz, 1 - 2 * qy2 - 2 * qz2) * conv),
497
+ MatrixMath.roundTo3Places(Math.asin(2 * qx * qy + 2 * qz * qw) * conv)
498
+ ];
499
+ },
500
+
501
+ /**
502
+ * Based on:
503
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round
504
+ */
505
+ roundTo3Places(n) {
506
+ const arr = n.toString().split('e');
507
+ return Math.round(`${arr[0]}e${arr[1] ? +arr[1] - 3 : 3}`) * 0.001;
508
+ },
509
+
510
+ /**
511
+ * Decompose a matrix into separate transform values, for use on platforms
512
+ * where applying a precomposed matrix is not possible, and transforms are
513
+ * applied in an inflexible ordering (e.g. Android).
514
+ *
515
+ * Implementation based on
516
+ * http://www.w3.org/TR/css3-transforms/#decomposing-a-2d-matrix
517
+ * http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix
518
+ * which was based on
519
+ * http://tog.acm.org/resources/GraphicsGems/gemsii/unmatrix.c
520
+ */
521
+ decomposeMatrix(transformMatrix) {
522
+ invariant(
523
+ transformMatrix.length === 16,
524
+ 'Matrix decomposition needs a list of 3d matrix values, received %s',
525
+ transformMatrix
526
+ );
527
+
528
+ // output values
529
+ let perspective = [];
530
+ const quaternion = [];
531
+ const scale = [];
532
+ const skew = [];
533
+ const translation = [];
534
+
535
+ // create normalized, 2d array matrix
536
+ // and normalized 1d array perspectiveMatrix with redefined 4th column
537
+ if (!transformMatrix[15]) {
538
+ return;
539
+ }
540
+ const matrix = [];
541
+ const perspectiveMatrix = [];
542
+ // eslint-disable-next-line no-plusplus
543
+ for (let i = 0; i < 4; i++) {
544
+ matrix.push([]);
545
+ // eslint-disable-next-line no-plusplus
546
+ for (let j = 0; j < 4; j++) {
547
+ const value = transformMatrix[i * 4 + j] / transformMatrix[15];
548
+ matrix[i].push(value);
549
+ perspectiveMatrix.push(j === 3 ? 0 : value);
550
+ }
551
+ }
552
+ perspectiveMatrix[15] = 1;
553
+
554
+ // test for singularity of upper 3x3 part of the perspective matrix
555
+ if (!MatrixMath.determinant(perspectiveMatrix)) {
556
+ return;
557
+ }
558
+
559
+ // isolate perspective
560
+ if (matrix[0][3] !== 0 || matrix[1][3] !== 0 || matrix[2][3] !== 0) {
561
+ // rightHandSide is the right hand side of the equation.
562
+ // rightHandSide is a vector, or point in 3d space relative to the origin.
563
+ const rightHandSide = [matrix[0][3], matrix[1][3], matrix[2][3], matrix[3][3]];
564
+
565
+ // Solve the equation by inverting perspectiveMatrix and multiplying
566
+ // rightHandSide by the inverse.
567
+ const inversePerspectiveMatrix = MatrixMath.inverse(perspectiveMatrix);
568
+ const transposedInversePerspectiveMatrix = MatrixMath.transpose(inversePerspectiveMatrix);
569
+ perspective = MatrixMath.multiplyVectorByMatrix(rightHandSide, transposedInversePerspectiveMatrix);
570
+ } else {
571
+ // no perspective
572
+ // eslint-disable-next-line no-multi-assign
573
+ perspective[0] = perspective[1] = perspective[2] = 0;
574
+ perspective[3] = 1;
575
+ }
576
+
577
+ // translation is simple
578
+ // eslint-disable-next-line no-plusplus
579
+ for (let i = 0; i < 3; i++) {
580
+ translation[i] = matrix[3][i];
581
+ }
582
+
583
+ // Now get scale and shear.
584
+ // 'row' is a 3 element array of 3 component vectors
585
+ const row = [];
586
+ // eslint-disable-next-line no-plusplus
587
+ for (let i = 0; i < 3; i++) {
588
+ row[i] = [matrix[i][0], matrix[i][1], matrix[i][2]];
589
+ }
590
+
591
+ // Compute X scale factor and normalize first row.
592
+ scale[0] = MatrixMath.v3Length(row[0]);
593
+ row[0] = MatrixMath.v3Normalize(row[0], scale[0]);
594
+
595
+ // Compute XY shear factor and make 2nd row orthogonal to 1st.
596
+ skew[0] = MatrixMath.v3Dot(row[0], row[1]);
597
+ row[1] = MatrixMath.v3Combine(row[1], row[0], 1.0, -skew[0]);
598
+
599
+ // Now, compute Y scale and normalize 2nd row.
600
+ scale[1] = MatrixMath.v3Length(row[1]);
601
+ row[1] = MatrixMath.v3Normalize(row[1], scale[1]);
602
+ skew[0] /= scale[1];
603
+
604
+ // Compute XZ and YZ shears, orthogonalize 3rd row
605
+ skew[1] = MatrixMath.v3Dot(row[0], row[2]);
606
+ row[2] = MatrixMath.v3Combine(row[2], row[0], 1.0, -skew[1]);
607
+ skew[2] = MatrixMath.v3Dot(row[1], row[2]);
608
+ row[2] = MatrixMath.v3Combine(row[2], row[1], 1.0, -skew[2]);
609
+
610
+ // Next, get Z scale and normalize 3rd row.
611
+ scale[2] = MatrixMath.v3Length(row[2]);
612
+ row[2] = MatrixMath.v3Normalize(row[2], scale[2]);
613
+ skew[1] /= scale[2];
614
+ skew[2] /= scale[2];
615
+
616
+ // At this point, the matrix (in rows) is orthonormal.
617
+ // Check for a coordinate system flip. If the determinant
618
+ // is -1, then negate the matrix and the scaling factors.
619
+ const pdum3 = MatrixMath.v3Cross(row[1], row[2]);
620
+ if (MatrixMath.v3Dot(row[0], pdum3) < 0) {
621
+ // eslint-disable-next-line no-plusplus
622
+ for (let i = 0; i < 3; i++) {
623
+ scale[i] *= -1;
624
+ row[i][0] *= -1;
625
+ row[i][1] *= -1;
626
+ row[i][2] *= -1;
627
+ }
628
+ }
629
+
630
+ // Now, get the rotations out
631
+ quaternion[0] = 0.5 * Math.sqrt(Math.max(1 + row[0][0] - row[1][1] - row[2][2], 0));
632
+ quaternion[1] = 0.5 * Math.sqrt(Math.max(1 - row[0][0] + row[1][1] - row[2][2], 0));
633
+ quaternion[2] = 0.5 * Math.sqrt(Math.max(1 - row[0][0] - row[1][1] + row[2][2], 0));
634
+ quaternion[3] = 0.5 * Math.sqrt(Math.max(1 + row[0][0] + row[1][1] + row[2][2], 0));
635
+
636
+ if (row[2][1] > row[1][2]) {
637
+ quaternion[0] = -quaternion[0];
638
+ }
639
+ if (row[0][2] > row[2][0]) {
640
+ quaternion[1] = -quaternion[1];
641
+ }
642
+ if (row[1][0] > row[0][1]) {
643
+ quaternion[2] = -quaternion[2];
644
+ }
645
+
646
+ // correct for occasional, weird Euler synonyms for 2d rotation
647
+ let rotationDegrees;
648
+ if (quaternion[0] < 0.001 && quaternion[0] >= 0 && quaternion[1] < 0.001 && quaternion[1] >= 0) {
649
+ // this is a 2d rotation on the z-axis
650
+ rotationDegrees = [0, 0, MatrixMath.roundTo3Places((Math.atan2(row[0][1], row[0][0]) * 180) / Math.PI)];
651
+ } else {
652
+ rotationDegrees = MatrixMath.quaternionToDegreesXYZ(quaternion, matrix, row);
653
+ }
654
+
655
+ // expose both base data and convenience names
656
+ return {
657
+ rotationDegrees,
658
+ perspective,
659
+ quaternion,
660
+ scale,
661
+ skew,
662
+ translation,
663
+ rotate: rotationDegrees[2],
664
+ rotateX: rotationDegrees[0],
665
+ rotateY: rotationDegrees[1],
666
+ scaleX: scale[0],
667
+ scaleY: scale[1],
668
+ translateX: translation[0],
669
+ translateY: translation[1]
670
+ };
671
+ }
672
+ };
673
+
674
+ module.exports = MatrixMath;
@@ -9,10 +9,10 @@ import UTTextInput from '../UTTextInput';
9
9
  import styles from './styles';
10
10
 
11
11
  const UTAutocomplete = ({ input, options, disabled, label, error, variant, autoCompletePlaceholder }) => {
12
- const selectedOption = useMemo(() => options.find(option => option.value === input.value), [
13
- options,
14
- input.value
15
- ]);
12
+ const selectedOption = useMemo(
13
+ () => options.find(option => option.value === input.value),
14
+ [options, input.value]
15
+ );
16
16
 
17
17
  const handleOnPress = item => {
18
18
  input.onChange(item.value);