@squiz/resource-browser 1.32.1-alpha.14 → 1.32.1-alpha.16

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 (90) hide show
  1. package/jest.config.ts +12 -1
  2. package/lib/Hooks/useCategorisedSources.d.ts +14 -0
  3. package/lib/Hooks/useCategorisedSources.js +38 -0
  4. package/lib/Hooks/useChildResources.d.ts +19 -0
  5. package/lib/Hooks/useChildResources.js +35 -0
  6. package/lib/Hooks/useResourcePath.d.ts +16 -0
  7. package/lib/Hooks/useResourcePath.js +64 -0
  8. package/lib/Hooks/useSources.d.ts +16 -0
  9. package/lib/Hooks/useSources.js +29 -0
  10. package/lib/Icons/Icon.d.ts +7 -7
  11. package/lib/Icons/Icon.js +7 -9
  12. package/lib/Icons/MatrixResources/Audio.js +1 -1
  13. package/lib/Icons/MatrixResources/Excel.js +1 -1
  14. package/lib/Icons/MatrixResources/MatrixResourceMap.d.ts +6 -6
  15. package/lib/Icons/MatrixResources/MatrixResourceMap.js +6 -6
  16. package/lib/Icons/MatrixResources/Pdf.js +1 -1
  17. package/lib/Icons/MatrixResources/Powerpoint.js +1 -1
  18. package/lib/Icons/MatrixResources/Video.js +1 -1
  19. package/lib/Icons/MatrixResources/Word.js +1 -1
  20. package/lib/Modal/Modal.js +1 -1
  21. package/lib/PreviewPanel/PreviewModal.js +1 -1
  22. package/lib/PreviewPanel/PreviewPanel.d.ts +4 -6
  23. package/lib/PreviewPanel/PreviewPanel.js +11 -39
  24. package/lib/PreviewPanel/details/MatrixResource.d.ts +4 -9
  25. package/lib/PreviewPanel/details/MatrixResource.js +20 -16
  26. package/lib/ResourceBreadcrumb/ResourceBreadcrumb.d.ts +5 -5
  27. package/lib/ResourceBreadcrumb/ResourceBreadcrumb.js +3 -3
  28. package/lib/ResourceItem/ResourceItem.d.ts +6 -8
  29. package/lib/ResourceItem/ResourceItem.js +3 -3
  30. package/lib/ResourceList/ResourceList.d.ts +5 -4
  31. package/lib/ResourceList/ResourceList.js +3 -3
  32. package/lib/ResourcePickerContainer/ResourcePickerContainer.d.ts +4 -5
  33. package/lib/ResourcePickerContainer/ResourcePickerContainer.js +34 -89
  34. package/lib/SourceDropdown/SourceDropdown.d.ts +5 -5
  35. package/lib/SourceDropdown/SourceDropdown.js +19 -27
  36. package/lib/SourceList/SourceList.d.ts +4 -4
  37. package/lib/SourceList/SourceList.js +7 -5
  38. package/lib/index.css +6 -0
  39. package/lib/index.d.ts +6 -29
  40. package/lib/index.js +2 -3
  41. package/lib/uuid.js +1 -3
  42. package/package.json +3 -2
  43. package/src/Hooks/useCategorisedSources.spec.ts +39 -0
  44. package/src/Hooks/useCategorisedSources.ts +46 -0
  45. package/src/Hooks/useChildResources.spec.ts +49 -0
  46. package/src/Hooks/useChildResources.ts +43 -0
  47. package/src/Hooks/useResourcePath.spec.ts +124 -0
  48. package/src/Hooks/useResourcePath.ts +76 -0
  49. package/src/Hooks/useSources.spec.ts +33 -0
  50. package/src/Hooks/useSources.ts +33 -0
  51. package/src/Icons/Icon.stories.tsx +7 -7
  52. package/src/Icons/Icon.tsx +9 -14
  53. package/src/Icons/MatrixResources/Audio.tsx +1 -1
  54. package/src/Icons/MatrixResources/Excel.tsx +1 -1
  55. package/src/Icons/MatrixResources/MatrixResourceMap.ts +7 -7
  56. package/src/Icons/MatrixResources/Pdf.tsx +1 -1
  57. package/src/Icons/MatrixResources/Powerpoint.tsx +1 -1
  58. package/src/Icons/MatrixResources/Video.tsx +1 -1
  59. package/src/Icons/MatrixResources/Word.tsx +1 -1
  60. package/src/Modal/Modal.tsx +1 -1
  61. package/src/PreviewPanel/PreviewModal.tsx +1 -1
  62. package/src/PreviewPanel/PreviewPanel.spec.tsx +20 -62
  63. package/src/PreviewPanel/PreviewPanel.stories.tsx +16 -24
  64. package/src/PreviewPanel/PreviewPanel.tsx +15 -51
  65. package/src/PreviewPanel/details/MatrixResource.tsx +23 -19
  66. package/src/ResourceBreadcrumb/ResourceBreadcrumb.spec.tsx +13 -23
  67. package/src/ResourceBreadcrumb/ResourceBreadcrumb.stories.tsx +1 -1
  68. package/src/ResourceBreadcrumb/ResourceBreadcrumb.tsx +8 -9
  69. package/src/ResourceBreadcrumb/sample-hierarchy.json +15 -25
  70. package/src/ResourceItem/ResourceItem.tsx +10 -12
  71. package/src/ResourceList/ResourceList.spec.tsx +8 -53
  72. package/src/ResourceList/ResourceList.stories.tsx +2 -2
  73. package/src/ResourceList/ResourceList.tsx +12 -10
  74. package/src/ResourceList/sample-resources.json +551 -49
  75. package/src/ResourcePickerContainer/ResourcePickerContainer.spec.tsx +196 -315
  76. package/src/ResourcePickerContainer/ResourcePickerContainer.stories.tsx +7 -29
  77. package/src/ResourcePickerContainer/ResourcePickerContainer.tsx +63 -127
  78. package/src/SourceDropdown/SourceDropdown.spec.tsx +63 -60
  79. package/src/SourceDropdown/SourceDropdown.stories.tsx +4 -7
  80. package/src/SourceDropdown/SourceDropdown.tsx +34 -41
  81. package/src/SourceList/SourceList.spec.tsx +38 -32
  82. package/src/SourceList/SourceList.tsx +17 -19
  83. package/src/SourceList/sample-sources.json +186 -77
  84. package/src/__mocks__/MockModels.ts +30 -0
  85. package/src/__mocks__/StorybookHelpers.ts +46 -0
  86. package/src/index.stories.tsx +13 -38
  87. package/src/index.tsx +5 -29
  88. package/src/types.d.ts +71 -0
  89. package/src/uuid.ts +2 -4
  90. package/src/SourceDropdown/sample-sources.json +0 -110
@@ -1,75 +1,577 @@
1
1
  [
2
2
  {
3
- "id": {
4
- "id": "11",
5
- "source": "1"
3
+ "id": "10",
4
+ "type": {
5
+ "code": "folder",
6
+ "name": "Folder"
6
7
  },
7
- "type": "page",
8
- "selected": true,
9
- "label": "About us",
8
+ "status": {
9
+ "code": "live",
10
+ "name": "Live"
11
+ },
12
+ "name": "Asset types",
13
+ "childCount": 100,
14
+ "_children": [
15
+ {
16
+ "id": "100",
17
+ "type": {
18
+ "code": "unknown",
19
+ "name": "Unknown type"
20
+ },
21
+ "status": {
22
+ "code": "live",
23
+ "name": "Live"
24
+ },
25
+ "name": "Unknown",
26
+ "childCount": 0
27
+ },
28
+ {
29
+ "id": "101",
30
+ "type": {
31
+ "code": "audio_file",
32
+ "name": "Audio File"
33
+ },
34
+ "status": {
35
+ "code": "live",
36
+ "name": "Live"
37
+ },
38
+ "name": "Audio file",
39
+ "childCount": 0
40
+ },
41
+ {
42
+ "id": "102",
43
+ "type": {
44
+ "code": "excel_doc",
45
+ "name": "MS Excel Document"
46
+ },
47
+ "status": {
48
+ "code": "live",
49
+ "name": "Live"
50
+ },
51
+ "name": "Excel document",
52
+ "childCount": 0
53
+ },
54
+ {
55
+ "id": "103",
56
+ "type": {
57
+ "code": "folder",
58
+ "name": "Folder"
59
+ },
60
+ "status": {
61
+ "code": "live",
62
+ "name": "Live"
63
+ },
64
+ "name": "Folder",
65
+ "childCount": 0
66
+ },
67
+ {
68
+ "id": "104",
69
+ "type": {
70
+ "code": "image",
71
+ "name": "Image"
72
+ },
73
+ "status": {
74
+ "code": "live",
75
+ "name": "Live"
76
+ },
77
+ "name": "Image",
78
+ "childCount": 0
79
+ },
80
+ {
81
+ "id": "105",
82
+ "type": {
83
+ "code": "page_standard",
84
+ "name": "Standard Page"
85
+ },
86
+ "status": {
87
+ "code": "live",
88
+ "name": "Live"
89
+ },
90
+ "name": "Page",
91
+ "childCount": 0
92
+ },
93
+ {
94
+ "id": "106",
95
+ "type": {
96
+ "code": "pdf_file",
97
+ "name": "PDF File"
98
+ },
99
+ "status": {
100
+ "code": "live",
101
+ "name": "Live"
102
+ },
103
+ "name": "PDF file",
104
+ "childCount": 0
105
+ },
106
+ {
107
+ "id": "107",
108
+ "type": {
109
+ "code": "powerpoint_doc",
110
+ "name": "MS PowerPoint Document"
111
+ },
112
+ "status": {
113
+ "code": "live",
114
+ "name": "Live"
115
+ },
116
+ "name": "Powerpoint presentation",
117
+ "childCount": 0
118
+ },
119
+ {
120
+ "id": "108",
121
+ "type": {
122
+ "code": "site",
123
+ "name": "Site"
124
+ },
125
+ "status": {
126
+ "code": "live",
127
+ "name": "Live"
128
+ },
129
+ "name": "Site",
130
+ "childCount": 0
131
+ },
132
+ {
133
+ "id": "109",
134
+ "type": {
135
+ "code": "video_file",
136
+ "name": "Video File"
137
+ },
138
+ "status": {
139
+ "code": "live",
140
+ "name": "Live"
141
+ },
142
+ "name": "Video file",
143
+ "childCount": 0
144
+ },
145
+ {
146
+ "id": "110",
147
+ "type": {
148
+ "code": "word_doc",
149
+ "name": "MS Word Document"
150
+ },
151
+ "status": {
152
+ "code": "live",
153
+ "name": "Live"
154
+ },
155
+ "name": "Word document",
156
+ "childCount": 0
157
+ }
158
+ ]
159
+ },
160
+ {
161
+ "id": "20",
162
+ "type": {
163
+ "code": "folder",
164
+ "name": "Folder"
165
+ },
166
+ "status": {
167
+ "code": "live",
168
+ "name": "Live"
169
+ },
170
+ "name": "Asset status",
171
+ "childCount": 100,
172
+ "_children": [
173
+ {
174
+ "id": "200",
175
+ "type": {
176
+ "code": "physical_file",
177
+ "name": "Physical File"
178
+ },
179
+ "status": {
180
+ "code": "unknown",
181
+ "name": "Unknown"
182
+ },
183
+ "name": "Unknown",
184
+ "childCount": 0
185
+ },
186
+ {
187
+ "id": "201",
188
+ "type": {
189
+ "code": "physical_file",
190
+ "name": "Physical File"
191
+ },
192
+ "status": {
193
+ "code": "archived",
194
+ "name": "Archived"
195
+ },
196
+ "name": "Archived",
197
+ "childCount": 0
198
+ },
199
+ {
200
+ "id": "202",
201
+ "type": {
202
+ "code": "physical_file",
203
+ "name": "Physical File"
204
+ },
205
+ "status": {
206
+ "code": "under_construction",
207
+ "name": "Under Construction"
208
+ },
209
+ "name": "Under construction",
210
+ "childCount": 0
211
+ },
212
+ {
213
+ "id": "203",
214
+ "type": {
215
+ "code": "physical_file",
216
+ "name": "Physical File"
217
+ },
218
+ "status": {
219
+ "code": "pending_approval",
220
+ "name": "Pending Approval"
221
+ },
222
+ "name": "Pending approval",
223
+ "childCount": 0
224
+ },
225
+ {
226
+ "id": "204",
227
+ "type": {
228
+ "code": "physical_file",
229
+ "name": "Physical File"
230
+ },
231
+ "status": {
232
+ "code": "approved_to_go_live",
233
+ "name": "Approved To Go Live"
234
+ },
235
+ "name": "Approved to go live",
236
+ "childCount": 0
237
+ },
238
+ {
239
+ "id": "205",
240
+ "type": {
241
+ "code": "physical_file",
242
+ "name": "Physical File"
243
+ },
244
+ "status": {
245
+ "code": "live",
246
+ "name": "Live"
247
+ },
248
+ "name": "Live",
249
+ "childCount": 0
250
+ },
251
+ {
252
+ "id": "206",
253
+ "type": {
254
+ "code": "physical_file",
255
+ "name": "Physical File"
256
+ },
257
+ "status": {
258
+ "code": "up_for_review",
259
+ "name": "Up For Review"
260
+ },
261
+ "name": "Up for review",
262
+ "childCount": 0
263
+ },
264
+ {
265
+ "id": "207",
266
+ "type": {
267
+ "code": "physical_file",
268
+ "name": "Physical File"
269
+ },
270
+ "status": {
271
+ "code": "safe_editing",
272
+ "name": "Safe Editing"
273
+ },
274
+ "name": "Safe editing",
275
+ "childCount": 0
276
+ },
277
+ {
278
+ "id": "208",
279
+ "type": {
280
+ "code": "physical_file",
281
+ "name": "Physical File"
282
+ },
283
+ "status": {
284
+ "code": "safe_editing_pending_approval",
285
+ "name": "Safe Editing Pending Approval"
286
+ },
287
+ "name": "Safe editing pending approval",
288
+ "childCount": 0
289
+ },
290
+ {
291
+ "id": "209",
292
+ "type": {
293
+ "code": "physical_file",
294
+ "name": "Physical File"
295
+ },
296
+ "status": {
297
+ "code": "safe_edit_approved_to_go_live",
298
+ "name": "Safe Edit Approved To Go Live"
299
+ },
300
+ "name": "Safe edit approved to go live",
301
+ "childCount": 0
302
+ }
303
+ ]
304
+ },
305
+ {
306
+ "id": "30",
307
+ "type": {
308
+ "code": "folder",
309
+ "name": "Folder"
310
+ },
311
+ "status": {
312
+ "code": "live",
313
+ "name": "Live"
314
+ },
315
+ "name": "Deeply nested asset",
316
+ "childCount": "1",
317
+ "_children": [
318
+ {
319
+ "id": "31",
320
+ "type": {
321
+ "code": "folder",
322
+ "name": "Folder"
323
+ },
324
+ "status": {
325
+ "code": "live",
326
+ "name": "Live"
327
+ },
328
+ "name": "Level 2",
329
+ "childCount": "1",
330
+ "_children": [
331
+ {
332
+ "id": "32",
333
+ "type": {
334
+ "code": "folder",
335
+ "name": "Folder"
336
+ },
337
+ "status": {
338
+ "code": "live",
339
+ "name": "Live"
340
+ },
341
+ "name": "Level 3",
342
+ "childCount": "1",
343
+ "_children": [
344
+ {
345
+ "id": "33",
346
+ "type": {
347
+ "code": "folder",
348
+ "name": "Folder"
349
+ },
350
+ "status": {
351
+ "code": "live",
352
+ "name": "Live"
353
+ },
354
+ "name": "Level 4",
355
+ "childCount": "1",
356
+ "_children": [
357
+ {
358
+ "id": "34",
359
+ "type": {
360
+ "code": "folder",
361
+ "name": "Folder"
362
+ },
363
+ "status": {
364
+ "code": "live",
365
+ "name": "Live"
366
+ },
367
+ "name": "Level 5",
368
+ "childCount": "1",
369
+ "_children": [
370
+ {
371
+ "id": "35",
372
+ "type": {
373
+ "code": "folder",
374
+ "name": "Folder"
375
+ },
376
+ "status": {
377
+ "code": "live",
378
+ "name": "Live"
379
+ },
380
+ "name": "Level 6",
381
+ "childCount": "1",
382
+ "_children": [
383
+ {
384
+ "id": "32",
385
+ "type": {
386
+ "code": "page_standard",
387
+ "name": "Standard Page"
388
+ },
389
+ "status": {
390
+ "code": "live",
391
+ "name": "Live"
392
+ },
393
+ "name": "You made it!",
394
+ "childCount": "0"
395
+ }
396
+ ]
397
+ }
398
+ ]
399
+ }
400
+ ]
401
+ }
402
+ ]
403
+ }
404
+ ]
405
+ }
406
+ ]
407
+ },
408
+ {
409
+ "id": "900",
410
+ "type": {
411
+ "code": "page",
412
+ "name": "Standard Page"
413
+ },
414
+ "status": {
415
+ "code": "live",
416
+ "name": "Live"
417
+ },
418
+ "name": "About us",
10
419
  "childCount": 0
11
420
  },
12
421
  {
13
- "id": {
14
- "id": "12",
15
- "source": "1"
422
+ "id": "901",
423
+ "type": {
424
+ "code": "folder",
425
+ "name": "Folder"
426
+ },
427
+ "status": {
428
+ "code": "live",
429
+ "name": "Live"
16
430
  },
17
- "type": "page",
18
- "selected": false,
19
- "label": "Asset manager",
431
+ "name": "So many images",
432
+ "childCount": 123456
433
+ },
434
+ {
435
+ "id": "902",
436
+ "type": {
437
+ "code": "page_standard",
438
+ "name": "Standard Page"
439
+ },
440
+ "status": {
441
+ "code": "live",
442
+ "name": "Live"
443
+ },
444
+ "name": "Asset with a slightly long long title to make it wrap over multiple lines, it take a bit of text to that",
20
445
  "childCount": 0
21
446
  },
22
447
  {
23
- "id": {
24
- "id": "13",
25
- "source": "1"
448
+ "id": "903",
449
+ "type": {
450
+ "code": "site",
451
+ "name": "Site"
452
+ },
453
+ "status": {
454
+ "code": "live",
455
+ "name": "Live"
26
456
  },
27
- "type": "folder",
28
- "selected": false,
29
- "label": "Products",
30
- "childCount": 31
457
+ "name": "Asset with an even longer title to make it is so long that it causes the container to grow in size. It is truly really just so long and I don't know what else I could possibly say about it to express just how long it is.",
458
+ "childCount": 456
31
459
  },
32
460
  {
33
- "id": {
34
- "id": "14",
35
- "source": "1"
461
+ "id": "904",
462
+ "type": {
463
+ "code": "physical_file",
464
+ "name": "Physical File"
465
+ },
466
+ "status": {
467
+ "code": "live",
468
+ "name": "Live"
36
469
  },
37
- "type": "folder",
38
- "selected": false,
39
- "label": "All images",
40
- "childCount": 55
470
+ "name": "Placeholder file",
471
+ "childCount": 0
41
472
  },
42
473
  {
43
- "id": {
44
- "id": "15",
45
- "source": "1"
474
+ "id": "905",
475
+ "type": {
476
+ "code": "physical_file",
477
+ "name": "Physical File"
478
+ },
479
+ "status": {
480
+ "code": "live",
481
+ "name": "Live"
46
482
  },
47
- "type": "docx",
48
- "selected": false,
49
- "label": "Some Word file",
483
+ "name": "Placeholder file 2",
50
484
  "childCount": 0
51
485
  },
52
-
53
486
  {
54
- "id": {
55
- "id": "16",
56
- "source": "1"
487
+ "id": "906",
488
+ "type": {
489
+ "code": "physical_file",
490
+ "name": "Physical File"
57
491
  },
58
- "source": "1",
59
- "type": "folder",
60
- "selected": false,
61
- "label": "So many images",
62
- "childCount": 123456
492
+ "status": {
493
+ "code": "live",
494
+ "name": "Live"
495
+ },
496
+ "name": "Placeholder file 3",
497
+ "childCount": 0
63
498
  },
64
499
  {
65
- "id": {
66
- "id": "17",
67
- "source": "1"
500
+ "id": "907",
501
+ "type": {
502
+ "code": "physical_file",
503
+ "name": "Physical File"
504
+ },
505
+ "status": {
506
+ "code": "live",
507
+ "name": "Live"
68
508
  },
69
- "source": "1",
70
- "type": "site",
71
- "selected": false,
72
- "label": "Some site asset",
73
- "childCount": 1234
509
+ "name": "Placeholder file 4",
510
+ "childCount": 0
511
+ },
512
+ {
513
+ "id": "908",
514
+ "type": {
515
+ "code": "physical_file",
516
+ "name": "Physical File"
517
+ },
518
+ "status": {
519
+ "code": "live",
520
+ "name": "Live"
521
+ },
522
+ "name": "Placeholder file 5",
523
+ "childCount": 0
524
+ },
525
+ {
526
+ "id": "909",
527
+ "type": {
528
+ "code": "physical_file",
529
+ "name": "Physical File"
530
+ },
531
+ "status": {
532
+ "code": "live",
533
+ "name": "Live"
534
+ },
535
+ "name": "Placeholder file 6",
536
+ "childCount": 0
537
+ },
538
+ {
539
+ "id": "910",
540
+ "type": {
541
+ "code": "physical_file",
542
+ "name": "Physical File"
543
+ },
544
+ "status": {
545
+ "code": "live",
546
+ "name": "Live"
547
+ },
548
+ "name": "Placeholder file 7",
549
+ "childCount": 0
550
+ },
551
+ {
552
+ "id": "911",
553
+ "type": {
554
+ "code": "physical_file",
555
+ "name": "Physical File"
556
+ },
557
+ "status": {
558
+ "code": "live",
559
+ "name": "Live"
560
+ },
561
+ "name": "Placeholder file 8",
562
+ "childCount": 0
563
+ },
564
+ {
565
+ "id": "912",
566
+ "type": {
567
+ "code": "physical_file",
568
+ "name": "Physical File"
569
+ },
570
+ "status": {
571
+ "code": "live",
572
+ "name": "Live"
573
+ },
574
+ "name": "Placeholder file 9",
575
+ "childCount": 0
74
576
  }
75
577
  ]