box-ui-elements 24.0.0-beta.6 → 24.0.0-beta.8

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 (62) hide show
  1. package/dist/explorer.js +1 -1
  2. package/dist/picker.js +1 -1
  3. package/es/elements/content-explorer/ContentExplorer.js +1 -1
  4. package/es/elements/content-explorer/ContentExplorer.js.map +1 -1
  5. package/es/elements/content-explorer/MetadataQueryAPIHelper.js +3 -11
  6. package/es/elements/content-explorer/MetadataQueryAPIHelper.js.map +1 -1
  7. package/es/elements/content-explorer/MetadataQueryBuilder.js +37 -8
  8. package/es/elements/content-explorer/MetadataQueryBuilder.js.map +1 -1
  9. package/es/elements/content-explorer/constants.js +3 -2
  10. package/es/elements/content-explorer/constants.js.map +1 -1
  11. package/es/elements/content-explorer/utils.js +7 -0
  12. package/es/elements/content-explorer/utils.js.map +1 -1
  13. package/es/src/elements/content-explorer/constants.d.ts +3 -2
  14. package/es/src/elements/content-explorer/utils.d.ts +1 -0
  15. package/i18n/bn-IN.js +1 -1
  16. package/i18n/bn-IN.properties +1 -1
  17. package/i18n/da-DK.js +1 -1
  18. package/i18n/da-DK.properties +1 -1
  19. package/i18n/de-DE.js +2 -2
  20. package/i18n/de-DE.properties +2 -2
  21. package/i18n/es-419.js +2 -2
  22. package/i18n/es-419.properties +2 -2
  23. package/i18n/es-ES.js +2 -2
  24. package/i18n/es-ES.properties +2 -2
  25. package/i18n/fi-FI.js +1 -1
  26. package/i18n/fi-FI.properties +1 -1
  27. package/i18n/fr-CA.js +1 -1
  28. package/i18n/fr-CA.properties +1 -1
  29. package/i18n/fr-FR.js +1 -1
  30. package/i18n/fr-FR.properties +1 -1
  31. package/i18n/hi-IN.js +1 -1
  32. package/i18n/hi-IN.properties +1 -1
  33. package/i18n/it-IT.js +1 -1
  34. package/i18n/it-IT.properties +1 -1
  35. package/i18n/ko-KR.js +1 -1
  36. package/i18n/ko-KR.properties +1 -1
  37. package/i18n/nb-NO.js +1 -1
  38. package/i18n/nb-NO.properties +1 -1
  39. package/i18n/nl-NL.js +1 -1
  40. package/i18n/nl-NL.properties +1 -1
  41. package/i18n/pl-PL.js +1 -1
  42. package/i18n/pl-PL.properties +1 -1
  43. package/i18n/pt-BR.js +1 -1
  44. package/i18n/pt-BR.properties +1 -1
  45. package/i18n/ru-RU.js +2 -2
  46. package/i18n/ru-RU.properties +2 -2
  47. package/i18n/sv-SE.js +1 -1
  48. package/i18n/sv-SE.properties +1 -1
  49. package/i18n/tr-TR.js +2 -2
  50. package/i18n/tr-TR.properties +2 -2
  51. package/i18n/zh-CN.js +1 -1
  52. package/i18n/zh-CN.properties +1 -1
  53. package/i18n/zh-TW.js +1 -1
  54. package/i18n/zh-TW.properties +1 -1
  55. package/package.json +1 -1
  56. package/src/elements/content-explorer/ContentExplorer.tsx +1 -1
  57. package/src/elements/content-explorer/MetadataQueryAPIHelper.ts +3 -9
  58. package/src/elements/content-explorer/MetadataQueryBuilder.ts +41 -18
  59. package/src/elements/content-explorer/__tests__/MetadataQueryAPIHelper.test.ts +49 -16
  60. package/src/elements/content-explorer/__tests__/MetadataQueryBuilder.test.ts +168 -39
  61. package/src/elements/content-explorer/constants.ts +37 -2
  62. package/src/elements/content-explorer/utils.ts +8 -0
@@ -6,6 +6,7 @@ import {
6
6
  getSelectFilter,
7
7
  getMimeTypeFilter,
8
8
  } from '../MetadataQueryBuilder';
9
+ import { getFileExtensions } from '../utils';
9
10
 
10
11
  describe('elements/content-explorer/MetadataQueryBuilder', () => {
11
12
  describe('mergeQueryParams', () => {
@@ -228,19 +229,6 @@ describe('elements/content-explorer/MetadataQueryBuilder', () => {
228
229
  });
229
230
  });
230
231
 
231
- test('should handle mimetype-filter field key specially', () => {
232
- const filterValue = ['pdf', 'doc'];
233
- const result = getSelectFilter(filterValue, 'mimetype-filter', 0);
234
- expect(result).toEqual({
235
- queryParams: {
236
- arg_mimetype_filter_1: 'pdf',
237
- arg_mimetype_filter_2: 'doc',
238
- },
239
- queries: ['(item.extension HASANY (:arg_mimetype_filter_1, :arg_mimetype_filter_2))'],
240
- keysGenerated: 2,
241
- });
242
- });
243
-
244
232
  test('should handle single value array', () => {
245
233
  const filterValue = ['single_value'];
246
234
  const result = getSelectFilter(filterValue, 'field_name', 0);
@@ -309,44 +297,51 @@ describe('elements/content-explorer/MetadataQueryBuilder', () => {
309
297
  });
310
298
 
311
299
  describe('getMimeTypeFilter', () => {
312
- test('should generate mime type filter and remove "Type" suffix', () => {
313
- const filterValue = ['pdfType', 'docType', 'txtType'];
300
+ test('should generate mime type filter using mapFileTypes', () => {
301
+ const filterValue = ['pdfType', 'documentType'];
314
302
  const result = getMimeTypeFilter(filterValue, 'mimetype', 0);
315
303
  expect(result).toEqual({
316
304
  queryParams: {
317
305
  arg_mimetype_1: 'pdf',
318
306
  arg_mimetype_2: 'doc',
319
- arg_mimetype_3: 'txt',
307
+ arg_mimetype_3: 'docx',
308
+ arg_mimetype_4: 'gdoc',
309
+ arg_mimetype_5: 'rtf',
310
+ arg_mimetype_6: 'txt',
320
311
  },
321
- queries: ['(item.extension IN (:arg_mimetype_1, :arg_mimetype_2, :arg_mimetype_3))'],
322
- keysGenerated: 3,
312
+ queries: [
313
+ '(item.extension IN (:arg_mimetype_1, :arg_mimetype_2, :arg_mimetype_3, :arg_mimetype_4, :arg_mimetype_5, :arg_mimetype_6))',
314
+ ],
315
+ keysGenerated: 6,
323
316
  });
324
317
  });
325
318
 
326
- test('should handle values without "Type" suffix', () => {
319
+ test('should handle values that are not in FILE_FOLDER_TYPES_MAP', () => {
327
320
  const filterValue = ['pdf', 'doc'];
328
321
  const result = getMimeTypeFilter(filterValue, 'mimetype', 0);
329
322
  expect(result).toEqual({
330
- queryParams: {
331
- arg_mimetype_1: 'pdf',
332
- arg_mimetype_2: 'doc',
333
- },
334
- queries: ['(item.extension IN (:arg_mimetype_1, :arg_mimetype_2))'],
335
- keysGenerated: 2,
323
+ queryParams: {},
324
+ queries: [],
325
+ keysGenerated: 0,
336
326
  });
337
327
  });
338
328
 
339
- test('should handle mixed values with and without "Type" suffix', () => {
340
- const filterValue = ['pdfType', 'doc', 'txtType'];
329
+ test('should handle mixed valid and invalid values', () => {
330
+ const filterValue = ['pdfType', 'doc', 'documentType'];
341
331
  const result = getMimeTypeFilter(filterValue, 'mimetype', 0);
342
332
  expect(result).toEqual({
343
333
  queryParams: {
344
334
  arg_mimetype_1: 'pdf',
345
335
  arg_mimetype_2: 'doc',
346
- arg_mimetype_3: 'txt',
336
+ arg_mimetype_3: 'docx',
337
+ arg_mimetype_4: 'gdoc',
338
+ arg_mimetype_5: 'rtf',
339
+ arg_mimetype_6: 'txt',
347
340
  },
348
- queries: ['(item.extension IN (:arg_mimetype_1, :arg_mimetype_2, :arg_mimetype_3))'],
349
- keysGenerated: 3,
341
+ queries: [
342
+ '(item.extension IN (:arg_mimetype_1, :arg_mimetype_2, :arg_mimetype_3, :arg_mimetype_4, :arg_mimetype_5, :arg_mimetype_6))',
343
+ ],
344
+ keysGenerated: 6,
350
345
  });
351
346
  });
352
347
 
@@ -360,16 +355,13 @@ describe('elements/content-explorer/MetadataQueryBuilder', () => {
360
355
  });
361
356
  });
362
357
 
363
- test('should handle numeric values converted to strings', () => {
358
+ test('should handle numeric values that are not in FILE_FOLDER_TYPES_MAP', () => {
364
359
  const filterValue = ['123', '456'];
365
360
  const result = getMimeTypeFilter(filterValue, 'mimetype', 0);
366
361
  expect(result).toEqual({
367
- queryParams: {
368
- arg_mimetype_1: '123',
369
- arg_mimetype_2: '456',
370
- },
371
- queries: ['(item.extension IN (:arg_mimetype_1, :arg_mimetype_2))'],
372
- keysGenerated: 2,
362
+ queryParams: {},
363
+ queries: [],
364
+ keysGenerated: 0,
373
365
  });
374
366
  });
375
367
 
@@ -402,18 +394,155 @@ describe('elements/content-explorer/MetadataQueryBuilder', () => {
402
394
  });
403
395
 
404
396
  test('should handle field names with special characters', () => {
405
- const filterValue = ['pdfType', 'docType'];
397
+ const filterValue = ['pdfType', 'documentType'];
406
398
  const result = getMimeTypeFilter(filterValue, 'mime-type.with/special_chars', 0);
407
399
  expect(result).toEqual({
408
400
  queryParams: {
409
401
  arg_mime_type_with_special_chars_1: 'pdf',
410
402
  arg_mime_type_with_special_chars_2: 'doc',
403
+ arg_mime_type_with_special_chars_3: 'docx',
404
+ arg_mime_type_with_special_chars_4: 'gdoc',
405
+ arg_mime_type_with_special_chars_5: 'rtf',
406
+ arg_mime_type_with_special_chars_6: 'txt',
407
+ },
408
+ queries: [
409
+ '(item.extension IN (:arg_mime_type_with_special_chars_1, :arg_mime_type_with_special_chars_2, :arg_mime_type_with_special_chars_3, :arg_mime_type_with_special_chars_4, :arg_mime_type_with_special_chars_5, :arg_mime_type_with_special_chars_6))',
410
+ ],
411
+ keysGenerated: 6,
412
+ });
413
+ });
414
+
415
+ // New tests for folderType functionality
416
+ test('should handle folderType only', () => {
417
+ const filterValue = ['folderType'];
418
+ const result = getMimeTypeFilter(filterValue, 'mimetype', 0);
419
+ expect(result).toEqual({
420
+ queryParams: {
421
+ arg_mime_folderType_1: 'folder',
422
+ },
423
+ queries: ['(item.type = :arg_mime_folderType_1)'],
424
+ keysGenerated: 1,
425
+ });
426
+ });
427
+
428
+ test('should handle folderType with file types', () => {
429
+ const filterValue = ['folderType', 'pdfType', 'documentType'];
430
+ const result = getMimeTypeFilter(filterValue, 'mimetype', 0);
431
+ expect(result).toEqual({
432
+ queryParams: {
433
+ arg_mime_folderType_1: 'folder',
434
+ arg_mimetype_2: 'pdf',
435
+ arg_mimetype_3: 'doc',
436
+ arg_mimetype_4: 'docx',
437
+ arg_mimetype_5: 'gdoc',
438
+ arg_mimetype_6: 'rtf',
439
+ arg_mimetype_7: 'txt',
440
+ },
441
+ queries: [
442
+ '((item.type = :arg_mime_folderType_1) OR (item.extension IN (:arg_mimetype_2, :arg_mimetype_3, :arg_mimetype_4, :arg_mimetype_5, :arg_mimetype_6, :arg_mimetype_7)))',
443
+ ],
444
+ keysGenerated: 7,
445
+ });
446
+ });
447
+
448
+ test('should handle folderType with mixed valid and invalid file types', () => {
449
+ const filterValue = ['folderType', 'pdfType', 'doc', 'documentType'];
450
+ const result = getMimeTypeFilter(filterValue, 'mimetype', 0);
451
+ expect(result).toEqual({
452
+ queryParams: {
453
+ arg_mime_folderType_1: 'folder',
454
+ arg_mimetype_2: 'pdf',
455
+ arg_mimetype_3: 'doc',
456
+ arg_mimetype_4: 'docx',
457
+ arg_mimetype_5: 'gdoc',
458
+ arg_mimetype_6: 'rtf',
459
+ arg_mimetype_7: 'txt',
460
+ },
461
+ queries: [
462
+ '((item.type = :arg_mime_folderType_1) OR (item.extension IN (:arg_mimetype_2, :arg_mimetype_3, :arg_mimetype_4, :arg_mimetype_5, :arg_mimetype_6, :arg_mimetype_7)))',
463
+ ],
464
+ keysGenerated: 7,
465
+ });
466
+ });
467
+
468
+ test('should handle folderType with single file type', () => {
469
+ const filterValue = ['folderType', 'pdfType'];
470
+ const result = getMimeTypeFilter(filterValue, 'mimetype', 0);
471
+ expect(result).toEqual({
472
+ queryParams: {
473
+ arg_mime_folderType_1: 'folder',
474
+ arg_mimetype_2: 'pdf',
475
+ },
476
+ queries: ['((item.type = :arg_mime_folderType_1) OR (item.extension IN (:arg_mimetype_2)))'],
477
+ keysGenerated: 2,
478
+ });
479
+ });
480
+
481
+ test('should handle folderType with file types using correct arg index', () => {
482
+ const filterValue = ['folderType', 'pdfType', 'documentType'];
483
+ const result = getMimeTypeFilter(filterValue, 'mimetype', 5);
484
+ expect(result).toEqual({
485
+ queryParams: {
486
+ arg_mime_folderType_6: 'folder',
487
+ arg_mimetype_7: 'pdf',
488
+ arg_mimetype_8: 'doc',
489
+ arg_mimetype_9: 'docx',
490
+ arg_mimetype_10: 'gdoc',
491
+ arg_mimetype_11: 'rtf',
492
+ arg_mimetype_12: 'txt',
411
493
  },
412
494
  queries: [
413
- '(item.extension IN (:arg_mime_type_with_special_chars_1, :arg_mime_type_with_special_chars_2))',
495
+ '((item.type = :arg_mime_folderType_6) OR (item.extension IN (:arg_mimetype_7, :arg_mimetype_8, :arg_mimetype_9, :arg_mimetype_10, :arg_mimetype_11, :arg_mimetype_12)))',
496
+ ],
497
+ keysGenerated: 7,
498
+ });
499
+ });
500
+
501
+ test('should handle multiple folderType entries (should only process one)', () => {
502
+ const filterValue = ['folderType', 'pdfType', 'folderType', 'documentType'];
503
+ const result = getMimeTypeFilter(filterValue, 'mimetype', 0);
504
+ expect(result).toEqual({
505
+ queryParams: {
506
+ arg_mime_folderType_1: 'folder',
507
+ arg_mimetype_2: 'pdf',
508
+ arg_mimetype_3: 'doc',
509
+ arg_mimetype_4: 'docx',
510
+ arg_mimetype_5: 'gdoc',
511
+ arg_mimetype_6: 'rtf',
512
+ arg_mimetype_7: 'txt',
513
+ },
514
+ queries: [
515
+ '((item.type = :arg_mime_folderType_1) OR (item.extension IN (:arg_mimetype_2, :arg_mimetype_3, :arg_mimetype_4, :arg_mimetype_5, :arg_mimetype_6, :arg_mimetype_7)))',
516
+ ],
517
+ keysGenerated: 7,
518
+ });
519
+ });
520
+
521
+ test('should handle folderType with field names containing special characters', () => {
522
+ const filterValue = ['folderType', 'pdfType'];
523
+ const result = getMimeTypeFilter(filterValue, 'mime-type.with/special_chars', 0);
524
+ expect(result).toEqual({
525
+ queryParams: {
526
+ arg_mime_folderType_1: 'folder',
527
+ arg_mime_type_with_special_chars_2: 'pdf',
528
+ },
529
+ queries: [
530
+ '((item.type = :arg_mime_folderType_1) OR (item.extension IN (:arg_mime_type_with_special_chars_2)))',
414
531
  ],
415
532
  keysGenerated: 2,
416
533
  });
417
534
  });
418
535
  });
536
+
537
+ describe('getFileExtensions', () => {
538
+ test('should return actual file extensions for single file type', () => {
539
+ const result = getFileExtensions('documentType');
540
+ expect(result).toEqual(['doc', 'docx', 'gdoc', 'rtf', 'txt']);
541
+ });
542
+
543
+ test('should handle empty array input', () => {
544
+ const result = getFileExtensions('');
545
+ expect(result).toEqual([]);
546
+ });
547
+ });
419
548
  });
@@ -2,7 +2,7 @@ import { FIELD_FILE_VERSION, FIELD_SHA1, FIELD_SHARED_LINK, FIELD_WATERMARK_INFO
2
2
  import { FOLDER_FIELDS_TO_FETCH } from '../../utils/fields';
3
3
 
4
4
  // Fields needed for Content Explorer folder requests
5
- const CONTENT_EXPLORER_FOLDER_FIELDS_TO_FETCH = [
5
+ export const CONTENT_EXPLORER_FOLDER_FIELDS_TO_FETCH = [
6
6
  ...FOLDER_FIELDS_TO_FETCH,
7
7
  FIELD_FILE_VERSION,
8
8
  FIELD_SHA1,
@@ -10,4 +10,39 @@ const CONTENT_EXPLORER_FOLDER_FIELDS_TO_FETCH = [
10
10
  FIELD_WATERMARK_INFO,
11
11
  ];
12
12
 
13
- export default CONTENT_EXPLORER_FOLDER_FIELDS_TO_FETCH;
13
+ export const NON_FOLDER_FILE_TYPES_MAP = new Map([
14
+ ['boxnoteType', ['boxnote']],
15
+ ['boxcanvasType', ['boxcanvas']],
16
+ ['pdfType', ['pdf']],
17
+ ['documentType', ['doc', 'docx', 'gdoc', 'rtf', 'txt']],
18
+ ['spreadsheetType', ['xls', 'xlsx', 'xlsm', 'csv', 'gsheet']],
19
+ ['presentationType', ['ppt', 'pptx', 'odp']],
20
+ ['imageType', ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'tif', 'tiff']],
21
+ ['audioType', ['mp3', 'm4a', 'm4p', 'wav', 'mid', 'wma']],
22
+ [
23
+ 'videoType',
24
+ [
25
+ 'mp4',
26
+ 'mpeg',
27
+ 'mpg',
28
+ 'wmv',
29
+ '3g2',
30
+ '3gp',
31
+ 'avi',
32
+ 'm2v',
33
+ 'm4v',
34
+ 'mkv',
35
+ 'mov',
36
+ 'ogg',
37
+ 'mts',
38
+ 'qt',
39
+ 'ts',
40
+ 'flv',
41
+ 'rm',
42
+ ],
43
+ ],
44
+ ['drawingType', ['dwg', 'dxf']],
45
+ ['threedType', ['obj', 'fbx', 'stl', 'amf', 'iges']],
46
+ ]);
47
+
48
+ export const NON_FOLDER_FILE_TYPES = Array.from(NON_FOLDER_FILE_TYPES_MAP.keys());
@@ -14,6 +14,7 @@ import type { Selection } from 'react-aria-components';
14
14
  import type { BoxItem, Collection } from '../../common/types/core';
15
15
 
16
16
  import messages from '../common/messages';
17
+ import { NON_FOLDER_FILE_TYPES_MAP } from './constants';
17
18
 
18
19
  // Specific type for metadata field value in the item
19
20
  // Note: Item doesn't have field value in metadata object if that field is not set, so the value will be undefined in this case
@@ -193,3 +194,10 @@ export function useTemplateInstance(metadataTemplate: MetadataTemplate, selected
193
194
  type,
194
195
  };
195
196
  }
197
+
198
+ export const getFileExtensions = (selectedFileType: string) => {
199
+ if (NON_FOLDER_FILE_TYPES_MAP.has(selectedFileType)) {
200
+ return NON_FOLDER_FILE_TYPES_MAP.get(selectedFileType).flat();
201
+ }
202
+ return [];
203
+ };