@enact/ui 4.7.10 → 4.7.12

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  The following is a curated list of changes in the Enact ui module, newest changes on the top.
4
4
 
5
+ ## [4.7.12] - 2024-09-05
6
+
7
+ No significant changes.
8
+
9
+ ## [4.7.11] - 2024-05-13
10
+
11
+ No significant changes.
12
+
5
13
  ## [4.7.10] - 2024-03-05
6
14
 
7
15
  No significant changes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/ui",
3
- "version": "4.7.10",
3
+ "version": "4.7.12",
4
4
  "description": "A collection of simplified unstyled cross-platform UI components for Enact",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,7 +31,7 @@
31
31
  }
32
32
  },
33
33
  "dependencies": {
34
- "@enact/core": "^4.7.10",
34
+ "@enact/core": "^4.7.12",
35
35
  "classnames": "^2.3.2",
36
36
  "direction": "^1.0.4",
37
37
  "invariant": "^2.2.4",
@@ -25,30 +25,514 @@ describe('Resolution Specs', function () {
25
25
  pxPerRem: 24,
26
26
  width: 1920,
27
27
  height: 1080,
28
- aspectRatioName: 'hdtv',
29
- base: true
28
+ aspectRatioName: 'hdtv'
30
29
  }, {
31
30
  name: 'uw-uxga',
32
31
  pxPerRem: 24,
33
32
  width: 2560,
34
33
  height: 1080,
35
34
  aspectRatioName: 'cinema'
35
+ }, {
36
+ name: 'qhd',
37
+ pxPerRem: 32,
38
+ width: 2560,
39
+ height: 1440,
40
+ aspectRatioName: 'hdtv'
41
+ }, {
42
+ name: 'wqhd',
43
+ pxPerRem: 32,
44
+ width: 3440,
45
+ height: 1440,
46
+ aspectRatioName: 'cinema'
36
47
  }, {
37
48
  name: 'uhd',
38
49
  pxPerRem: 48,
39
50
  width: 3840,
40
51
  height: 2160,
52
+ aspectRatioName: 'hdtv',
53
+ base: true
54
+ }, {
55
+ name: 'uhd2',
56
+ pxPerRem: 96,
57
+ width: 7680,
58
+ height: 4320,
41
59
  aspectRatioName: 'hdtv'
42
60
  }];
43
- test('should select screen type whose dimensions are greater than but nearest to the screen', function () {
44
- var overHD = {
45
- height: 721,
46
- width: 1281
47
- };
48
- (0, _resolution.defineScreenTypes)(screenTypes);
49
- var expected = 'fhd';
50
- var actual = (0, _resolution.getScreenType)(overHD);
51
- expect(actual).toBe(expected);
61
+ var VGA = {
62
+ width: 640,
63
+ height: 480
64
+ };
65
+ var XGA = {
66
+ width: 1024,
67
+ height: 768
68
+ };
69
+ var HD = {
70
+ width: 1280,
71
+ height: 720
72
+ };
73
+ var FHD = {
74
+ width: 1920,
75
+ height: 1080
76
+ };
77
+ var UWUXGA = {
78
+ width: 2560,
79
+ height: 1080
80
+ };
81
+ var QHD = {
82
+ width: 2560,
83
+ height: 1440
84
+ };
85
+ var WQHD = {
86
+ width: 3440,
87
+ height: 1440
88
+ };
89
+ var UHD = {
90
+ width: 3840,
91
+ height: 2160
92
+ };
93
+ var UHD2 = {
94
+ width: 7680,
95
+ height: 4320
96
+ };
97
+ (0, _resolution.defineScreenTypes)(screenTypes);
98
+ describe('Matching Screen Types', function () {
99
+ test('should select screen type whose dimensions are same with the screen if exist', function () {
100
+ expect((0, _resolution.getScreenType)(VGA)).toBe('vga');
101
+ expect((0, _resolution.getScreenType)(XGA)).toBe('xga');
102
+ expect((0, _resolution.getScreenType)(HD)).toBe('hd');
103
+ expect((0, _resolution.getScreenType)(FHD)).toBe('fhd');
104
+ expect((0, _resolution.getScreenType)(UWUXGA)).toBe('uw-uxga');
105
+ expect((0, _resolution.getScreenType)(QHD)).toBe('qhd');
106
+ expect((0, _resolution.getScreenType)(WQHD)).toBe('wqhd');
107
+ expect((0, _resolution.getScreenType)(UHD)).toBe('uhd');
108
+ expect((0, _resolution.getScreenType)(UHD2)).toBe('uhd2');
109
+ });
110
+ test('should select screen type whose height and width are both smaller than or same with the screen if `matchSmallerScreenType` true', function () {
111
+ _resolution.config.matchSmallerScreenType = true;
112
+
113
+ // if width or height of screen is smaller than the smallest screen type, select the smallest screen type
114
+ expect((0, _resolution.getScreenType)({
115
+ width: VGA.width - 1,
116
+ height: VGA.height - 1
117
+ })).toBe('vga');
118
+ expect((0, _resolution.getScreenType)({
119
+ width: VGA.width + 1,
120
+ height: VGA.height - 1
121
+ })).toBe('vga');
122
+ expect((0, _resolution.getScreenType)({
123
+ width: VGA.width - 1,
124
+ height: VGA.height + 1
125
+ })).toBe('vga');
126
+
127
+ // VGA
128
+ expect((0, _resolution.getScreenType)({
129
+ width: VGA.width + 1,
130
+ height: VGA.height + 1
131
+ })).toBe('vga');
132
+ expect((0, _resolution.getScreenType)({
133
+ width: XGA.width - 1,
134
+ height: XGA.height - 1
135
+ })).toBe('vga');
136
+ expect((0, _resolution.getScreenType)({
137
+ width: XGA.width + 1,
138
+ height: XGA.height - 1
139
+ })).toBe('vga');
140
+ expect((0, _resolution.getScreenType)({
141
+ width: XGA.width - 1,
142
+ height: XGA.height + 1
143
+ })).toBe('vga');
144
+ expect((0, _resolution.getScreenType)({
145
+ width: HD.width - 1,
146
+ height: HD.height - 1
147
+ })).toBe('vga');
148
+ expect((0, _resolution.getScreenType)({
149
+ width: HD.width + 1,
150
+ height: HD.height - 1
151
+ })).toBe('vga');
152
+ expect((0, _resolution.getScreenType)({
153
+ width: HD.width - 1,
154
+ height: HD.height + 1
155
+ })).toBe('vga');
156
+ expect((0, _resolution.getScreenType)({
157
+ width: XGA.width,
158
+ height: HD.height
159
+ })).toBe('vga');
160
+ expect((0, _resolution.getScreenType)({
161
+ width: XGA.width - 1,
162
+ height: HD.height - 1
163
+ })).toBe('vga');
164
+ expect((0, _resolution.getScreenType)({
165
+ width: XGA.width + 1,
166
+ height: HD.height - 1
167
+ })).toBe('vga');
168
+ expect((0, _resolution.getScreenType)({
169
+ width: XGA.width - 1,
170
+ height: HD.height + 1
171
+ })).toBe('vga');
172
+ expect((0, _resolution.getScreenType)({
173
+ width: XGA.width + 1,
174
+ height: HD.height + 1
175
+ })).toBe('vga');
176
+ expect((0, _resolution.getScreenType)({
177
+ width: HD.width - 1,
178
+ height: XGA.height - 1
179
+ })).toBe('vga');
180
+
181
+ // XGA
182
+ expect((0, _resolution.getScreenType)({
183
+ width: XGA.width + 1,
184
+ height: XGA.height + 1
185
+ })).toBe('xga');
186
+ expect((0, _resolution.getScreenType)({
187
+ width: HD.width - 1,
188
+ height: XGA.height + 1
189
+ })).toBe('xga');
190
+
191
+ // HD
192
+ expect((0, _resolution.getScreenType)({
193
+ width: HD.width + 1,
194
+ height: HD.height + 1
195
+ })).toBe('hd');
196
+ expect((0, _resolution.getScreenType)({
197
+ width: HD.width,
198
+ height: XGA.height
199
+ })).toBe('hd');
200
+ expect((0, _resolution.getScreenType)({
201
+ width: HD.width + 1,
202
+ height: XGA.height - 1
203
+ })).toBe('hd');
204
+ expect((0, _resolution.getScreenType)({
205
+ width: HD.width + 1,
206
+ height: XGA.height + 1
207
+ })).toBe('hd');
208
+ expect((0, _resolution.getScreenType)({
209
+ width: FHD.width - 1,
210
+ height: FHD.height - 1
211
+ })).toBe('hd');
212
+ expect((0, _resolution.getScreenType)({
213
+ width: FHD.width + 1,
214
+ height: FHD.height - 1
215
+ })).toBe('hd');
216
+ expect((0, _resolution.getScreenType)({
217
+ width: FHD.width - 1,
218
+ height: FHD.height + 1
219
+ })).toBe('hd');
220
+ expect((0, _resolution.getScreenType)({
221
+ width: UWUXGA.width - 1,
222
+ height: UWUXGA.height - 1
223
+ })).toBe('hd'); // {height: FHD.height - 1, width: UWUXGA.width - 1}
224
+ expect((0, _resolution.getScreenType)({
225
+ width: UWUXGA.width + 1,
226
+ height: UWUXGA.height - 1
227
+ })).toBe('hd'); // {height: FHD.height - 1, width: UWUXGA.width + 1}
228
+
229
+ // FHD
230
+ expect((0, _resolution.getScreenType)({
231
+ width: FHD.width + 1,
232
+ height: FHD.height + 1
233
+ })).toBe('fhd');
234
+ expect((0, _resolution.getScreenType)({
235
+ width: UWUXGA.width - 1,
236
+ height: UWUXGA.height + 1
237
+ })).toBe('fhd'); // {height: FHD.height + 1, width: UWUXGA.width - 1}
238
+
239
+ expect((0, _resolution.getScreenType)({
240
+ width: QHD.width - 1,
241
+ height: QHD.height - 1
242
+ })).toBe('fhd'); // {height: QHD.height - 1, width: UWUXGA.width - 1}
243
+ expect((0, _resolution.getScreenType)({
244
+ width: QHD.width - 1,
245
+ height: QHD.height + 1
246
+ })).toBe('fhd'); // {height: QHD.height + 1, width: UWUXGA.width - 1}
247
+
248
+ // UWUXGA
249
+ expect((0, _resolution.getScreenType)({
250
+ width: UWUXGA.width + 1,
251
+ height: UWUXGA.height + 1
252
+ })).toBe('uw-uxga'); // {height: FHD.height + 1, width: UWUXGA.width + 1}
253
+
254
+ expect((0, _resolution.getScreenType)({
255
+ width: QHD.width + 1,
256
+ height: QHD.height - 1
257
+ })).toBe('uw-uxga'); // {height: QHD.height - 1, width: UWUXGA.width + 1}
258
+
259
+ expect((0, _resolution.getScreenType)({
260
+ width: WQHD.width - 1,
261
+ height: WQHD.height - 1
262
+ })).toBe('uw-uxga'); // {height: QHD.height - 1, width: WQHD.width - 1}
263
+ expect((0, _resolution.getScreenType)({
264
+ width: WQHD.width + 1,
265
+ height: WQHD.height - 1
266
+ })).toBe('uw-uxga'); // {height: QHD.height - 1, width: WQHD.width + 1}
267
+
268
+ // QHD
269
+ expect((0, _resolution.getScreenType)({
270
+ width: QHD.width + 1,
271
+ height: QHD.height + 1
272
+ })).toBe('qhd'); // {height: QHD.height + 1, width: UWUXGA.width + 1}
273
+
274
+ expect((0, _resolution.getScreenType)({
275
+ width: WQHD.width - 1,
276
+ height: WQHD.height + 1
277
+ })).toBe('qhd'); // {height: QHD.height + 1, width: WQHD.width - 1}
278
+
279
+ // WQHD
280
+ expect((0, _resolution.getScreenType)({
281
+ width: WQHD.width + 1,
282
+ height: WQHD.height + 1
283
+ })).toBe('wqhd'); // {height: QHD.height + 1, width: WQHD.width + 1}
284
+
285
+ expect((0, _resolution.getScreenType)({
286
+ width: UHD.width - 1,
287
+ height: UHD.height - 1
288
+ })).toBe('wqhd');
289
+ expect((0, _resolution.getScreenType)({
290
+ width: UHD.width + 1,
291
+ height: UHD.height - 1
292
+ })).toBe('wqhd');
293
+ expect((0, _resolution.getScreenType)({
294
+ width: UHD.width - 1,
295
+ height: UHD.height + 1
296
+ })).toBe('wqhd');
297
+
298
+ // UHD
299
+ expect((0, _resolution.getScreenType)({
300
+ width: UHD.width + 1,
301
+ height: UHD.height + 1
302
+ })).toBe('uhd');
303
+ expect((0, _resolution.getScreenType)({
304
+ width: UHD2.width - 1,
305
+ height: UHD2.height - 1
306
+ })).toBe('uhd');
307
+ expect((0, _resolution.getScreenType)({
308
+ width: UHD2.width + 1,
309
+ height: UHD2.height - 1
310
+ })).toBe('uhd');
311
+ expect((0, _resolution.getScreenType)({
312
+ width: UHD2.width - 1,
313
+ height: UHD2.height + 1
314
+ })).toBe('uhd');
315
+
316
+ // UHD2
317
+ expect((0, _resolution.getScreenType)({
318
+ width: UHD2.width + 1,
319
+ height: UHD2.height + 1
320
+ })).toBe('uhd2');
321
+ });
322
+ test('should select screen type whose height and width are both bigger than or same with the screen if `matchSmallerScreenType` false', function () {
323
+ _resolution.config.matchSmallerScreenType = false;
324
+
325
+ // VGA
326
+ expect((0, _resolution.getScreenType)({
327
+ width: VGA.width - 1,
328
+ height: VGA.height - 1
329
+ })).toBe('vga');
330
+
331
+ // XGA
332
+ expect((0, _resolution.getScreenType)({
333
+ width: VGA.width + 1,
334
+ height: VGA.height - 1
335
+ })).toBe('xga');
336
+ expect((0, _resolution.getScreenType)({
337
+ width: VGA.width - 1,
338
+ height: VGA.height + 1
339
+ })).toBe('xga');
340
+ expect((0, _resolution.getScreenType)({
341
+ width: VGA.width + 1,
342
+ height: VGA.height + 1
343
+ })).toBe('xga');
344
+ expect((0, _resolution.getScreenType)({
345
+ width: XGA.width - 1,
346
+ height: XGA.height - 1
347
+ })).toBe('xga');
348
+ expect((0, _resolution.getScreenType)({
349
+ width: XGA.width,
350
+ height: HD.height
351
+ })).toBe('xga');
352
+ expect((0, _resolution.getScreenType)({
353
+ width: XGA.width - 1,
354
+ height: HD.height - 1
355
+ })).toBe('xga');
356
+ expect((0, _resolution.getScreenType)({
357
+ width: XGA.width - 1,
358
+ height: HD.height + 1
359
+ })).toBe('xga');
360
+
361
+ // HD
362
+ expect((0, _resolution.getScreenType)({
363
+ width: XGA.width + 1,
364
+ height: HD.height - 1
365
+ })).toBe('hd');
366
+ expect((0, _resolution.getScreenType)({
367
+ width: HD.width - 1,
368
+ height: HD.height - 1
369
+ })).toBe('hd');
370
+
371
+ // FHD
372
+ expect((0, _resolution.getScreenType)({
373
+ width: XGA.width + 1,
374
+ height: XGA.height - 1
375
+ })).toBe('fhd');
376
+ expect((0, _resolution.getScreenType)({
377
+ width: XGA.width - 1,
378
+ height: XGA.height + 1
379
+ })).toBe('fhd');
380
+ expect((0, _resolution.getScreenType)({
381
+ width: XGA.width + 1,
382
+ height: XGA.height + 1
383
+ })).toBe('fhd');
384
+ expect((0, _resolution.getScreenType)({
385
+ width: HD.width,
386
+ height: XGA.height
387
+ })).toBe('fhd');
388
+ expect((0, _resolution.getScreenType)({
389
+ width: HD.width - 1,
390
+ height: XGA.height - 1
391
+ })).toBe('fhd');
392
+ expect((0, _resolution.getScreenType)({
393
+ width: HD.width + 1,
394
+ height: XGA.height - 1
395
+ })).toBe('fhd');
396
+ expect((0, _resolution.getScreenType)({
397
+ width: HD.width - 1,
398
+ height: XGA.height + 1
399
+ })).toBe('fhd');
400
+ expect((0, _resolution.getScreenType)({
401
+ width: HD.width + 1,
402
+ height: XGA.height + 1
403
+ })).toBe('fhd');
404
+ expect((0, _resolution.getScreenType)({
405
+ width: XGA.width + 1,
406
+ height: HD.height + 1
407
+ })).toBe('fhd');
408
+ expect((0, _resolution.getScreenType)({
409
+ width: HD.width + 1,
410
+ height: HD.height - 1
411
+ })).toBe('fhd');
412
+ expect((0, _resolution.getScreenType)({
413
+ width: HD.width - 1,
414
+ height: HD.height + 1
415
+ })).toBe('fhd');
416
+ expect((0, _resolution.getScreenType)({
417
+ width: HD.width + 1,
418
+ height: HD.height + 1
419
+ })).toBe('fhd');
420
+ expect((0, _resolution.getScreenType)({
421
+ width: FHD.width - 1,
422
+ height: FHD.height - 1
423
+ })).toBe('fhd');
424
+
425
+ // UWUXGA
426
+ expect((0, _resolution.getScreenType)({
427
+ width: UWUXGA.width - 1,
428
+ height: UWUXGA.height - 1
429
+ })).toBe('uw-uxga'); // {height: FHD.height - 1, width: UWUXGA.width - 1}
430
+
431
+ expect((0, _resolution.getScreenType)({
432
+ width: FHD.width + 1,
433
+ height: FHD.height - 1
434
+ })).toBe('uw-uxga');
435
+
436
+ // QHD
437
+ expect((0, _resolution.getScreenType)({
438
+ width: UWUXGA.width - 1,
439
+ height: UWUXGA.height + 1
440
+ })).toBe('qhd'); // {height: FHD.height + 1, width: UWUXGA.width - 1}
441
+
442
+ expect((0, _resolution.getScreenType)({
443
+ width: QHD.width - 1,
444
+ height: QHD.height - 1
445
+ })).toBe('qhd'); // {height: QHD.height - 1, width: UWUXGA.width - 1}
446
+
447
+ expect((0, _resolution.getScreenType)({
448
+ width: FHD.width - 1,
449
+ height: FHD.height + 1
450
+ })).toBe('qhd');
451
+ expect((0, _resolution.getScreenType)({
452
+ width: FHD.width + 1,
453
+ height: FHD.height + 1
454
+ })).toBe('qhd');
455
+
456
+ // WQHD
457
+ expect((0, _resolution.getScreenType)({
458
+ width: UWUXGA.width + 1,
459
+ height: UWUXGA.height - 1
460
+ })).toBe('wqhd'); // {height: FHD.height - 1, width: UWUXGA.width + 1}
461
+ expect((0, _resolution.getScreenType)({
462
+ width: UWUXGA.width + 1,
463
+ height: UWUXGA.height + 1
464
+ })).toBe('wqhd'); // {height: FHD.height + 1, width: UWUXGA.width + 1}
465
+
466
+ expect((0, _resolution.getScreenType)({
467
+ width: QHD.width + 1,
468
+ height: QHD.height - 1
469
+ })).toBe('wqhd'); // {height: QHD.height - 1, width: UWUXGA.width + 1}
470
+
471
+ expect((0, _resolution.getScreenType)({
472
+ width: WQHD.width - 1,
473
+ height: WQHD.height - 1
474
+ })).toBe('wqhd'); // {height: QHD.height - 1, width: WQHD.width - 1}
475
+
476
+ // UHD
477
+ expect((0, _resolution.getScreenType)({
478
+ width: QHD.width - 1,
479
+ height: QHD.height + 1
480
+ })).toBe('uhd'); // {height: QHD.height + 1, width: UWUXGA.width - 1}
481
+ expect((0, _resolution.getScreenType)({
482
+ width: QHD.width + 1,
483
+ height: QHD.height + 1
484
+ })).toBe('uhd'); // {height: QHD.height + 1, width: UWUXGA.width + 1}
485
+
486
+ expect((0, _resolution.getScreenType)({
487
+ width: WQHD.width + 1,
488
+ height: WQHD.height - 1
489
+ })).toBe('uhd'); // {height: QHD.height - 1, width: WQHD.width + 1}
490
+ expect((0, _resolution.getScreenType)({
491
+ width: WQHD.width - 1,
492
+ height: WQHD.height + 1
493
+ })).toBe('uhd'); // {height: QHD.height + 1, width: WQHD.width - 1}
494
+ expect((0, _resolution.getScreenType)({
495
+ width: WQHD.width + 1,
496
+ height: WQHD.height + 1
497
+ })).toBe('uhd'); // {height: QHD.height + 1, width: WQHD.width + 1}
498
+
499
+ expect((0, _resolution.getScreenType)({
500
+ width: UHD.width - 1,
501
+ height: UHD.height - 1
502
+ })).toBe('uhd');
503
+
504
+ // UHD2
505
+ expect((0, _resolution.getScreenType)({
506
+ width: UHD.width + 1,
507
+ height: UHD.height - 1
508
+ })).toBe('uhd2');
509
+ expect((0, _resolution.getScreenType)({
510
+ width: UHD.width - 1,
511
+ height: UHD.height + 1
512
+ })).toBe('uhd2');
513
+ expect((0, _resolution.getScreenType)({
514
+ width: UHD.width + 1,
515
+ height: UHD.height + 1
516
+ })).toBe('uhd2');
517
+ expect((0, _resolution.getScreenType)({
518
+ width: UHD2.width - 1,
519
+ height: UHD2.height - 1
520
+ })).toBe('uhd2');
521
+
522
+ // if width or height of screen is bigger than the biggest screen type, select the biggest screen type
523
+ expect((0, _resolution.getScreenType)({
524
+ width: UHD2.width + 1,
525
+ height: UHD2.height - 1
526
+ })).toBe('uhd2');
527
+ expect((0, _resolution.getScreenType)({
528
+ width: UHD2.width - 1,
529
+ height: UHD2.height + 1
530
+ })).toBe('uhd2');
531
+ expect((0, _resolution.getScreenType)({
532
+ width: UHD2.width + 1,
533
+ height: UHD2.height + 1
534
+ })).toBe('uhd2');
535
+ });
52
536
  });
53
537
  test('should detect portrait orientation', function () {
54
538
  var fhdPortrait = {
@@ -61,17 +545,23 @@ describe('Resolution Specs', function () {
61
545
  expect(actual).toBe(expected);
62
546
  });
63
547
  test('should calculate the base font size for the given screen type', function () {
548
+ var expectedUHD = '48px';
549
+ var actualUHD = (0, _resolution.calculateFontSize)('uhd');
550
+ var expectedQHD = '32px';
551
+ var actualQHD = (0, _resolution.calculateFontSize)('qhd');
64
552
  var expectedFHD = '24px';
65
553
  var actualFHD = (0, _resolution.calculateFontSize)('fhd');
66
554
  var expectedHD = '16px';
67
555
  var actualHD = (0, _resolution.calculateFontSize)('hd');
556
+ expect(actualUHD).toBe(expectedUHD);
557
+ expect(actualQHD).toBe(expectedQHD);
68
558
  expect(actualFHD).toBe(expectedFHD);
69
559
  expect(actualHD).toBe(expectedHD);
70
560
  });
71
561
  test('should scale pixel measurements for the current screen', function () {
72
- var expectedFHD = 24 / 3;
562
+ var expectedFHD = 24 / 6;
73
563
  var actualFHD = (0, _resolution.scale)(24);
74
- var expectedHD = 16 / 3;
564
+ var expectedHD = 16 / 6;
75
565
  var actualHD = (0, _resolution.scale)(16);
76
566
  expect(actualFHD).toBe(expectedFHD);
77
567
  expect(actualHD).toBe(expectedHD);