@squiz/resource-browser 1.69.1 → 2.1.8-rc.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.
- package/CHANGELOG.md +88 -35
- package/LICENSE.md +15 -0
- package/README.md +9 -0
- package/jest.config.ts +22 -21
- package/lib/Hooks/useSelectedState.d.ts +15 -0
- package/lib/Hooks/useSelectedState.js +16 -0
- package/lib/Hooks/useSources.d.ts +5 -4
- package/lib/Hooks/useSources.js +25 -1
- package/lib/MainContainer/MainContainer.d.ts +17 -0
- package/lib/MainContainer/MainContainer.js +61 -0
- package/lib/Plugin/Plugin.d.ts +13 -0
- package/lib/Plugin/Plugin.js +17 -0
- package/lib/ResourceBrowserContext/ResourceBrowserContext.d.ts +2 -3
- package/lib/ResourceBrowserContext/ResourceBrowserContext.js +4 -17
- package/lib/ResourceBrowserInput/ResourceBrowserInput.d.ts +24 -0
- package/lib/ResourceBrowserInput/ResourceBrowserInput.js +16 -0
- package/lib/ResourcePicker/ResourcePicker.d.ts +6 -4
- package/lib/ResourcePicker/ResourcePicker.js +14 -8
- package/lib/ResourcePicker/States/Selected.d.ts +10 -4
- package/lib/ResourcePicker/States/Selected.js +11 -32
- package/lib/SourceDropdown/SourceDropdown.d.ts +5 -11
- package/lib/SourceDropdown/SourceDropdown.js +20 -99
- package/lib/SourceList/SourceList.d.ts +5 -16
- package/lib/SourceList/SourceList.js +14 -75
- package/lib/index.css +42 -202
- package/lib/index.d.ts +7 -7
- package/lib/index.js +69 -13
- package/lib/types.d.ts +41 -59
- package/package.json +82 -80
- package/src/Hooks/useSelectedState.spec.ts +46 -0
- package/src/Hooks/useSelectedState.ts +22 -0
- package/src/Hooks/useSources.spec.ts +30 -12
- package/src/Hooks/useSources.ts +33 -4
- package/src/Icons/CircledLoopIcon.tsx +8 -8
- package/src/MainContainer/MainContainer.spec.tsx +203 -0
- package/src/MainContainer/MainContainer.stories.tsx +62 -0
- package/src/MainContainer/MainContainer.tsx +101 -0
- package/src/Plugin/Plugin.spec.tsx +46 -0
- package/src/Plugin/Plugin.tsx +20 -0
- package/src/ResourceBrowserContext/ResourceBrowserContext.spec.tsx +65 -106
- package/src/ResourceBrowserContext/ResourceBrowserContext.tsx +24 -39
- package/src/ResourceBrowserInput/ResourceBrowserInput.spec.tsx +192 -0
- package/src/ResourceBrowserInput/ResourceBrowserInput.tsx +81 -0
- package/src/ResourcePicker/ResourcePicker.spec.tsx +159 -116
- package/src/ResourcePicker/ResourcePicker.stories.tsx +28 -24
- package/src/ResourcePicker/ResourcePicker.tsx +79 -59
- package/src/ResourcePicker/States/Error.tsx +8 -8
- package/src/ResourcePicker/States/Loading.tsx +3 -3
- package/src/ResourcePicker/States/Selected.tsx +66 -73
- package/src/ResourcePicker/mock-image-resource.json +25 -47
- package/src/ResourcePicker/mock-resource.json +11 -13
- package/src/ResourcePicker/resource-picker.scss +13 -13
- package/src/SourceDropdown/SourceDropdown.spec.tsx +65 -391
- package/src/SourceDropdown/SourceDropdown.stories.tsx +21 -24
- package/src/SourceDropdown/SourceDropdown.tsx +80 -258
- package/src/SourceList/SourceList.spec.tsx +37 -430
- package/src/SourceList/SourceList.stories.tsx +17 -37
- package/src/SourceList/SourceList.tsx +28 -155
- package/src/__mocks__/MockModels.ts +56 -25
- package/src/__mocks__/PluginExample.tsx +98 -0
- package/src/__mocks__/StorybookHelpers.tsx +141 -0
- package/src/__mocks__/renderWithContext.tsx +14 -18
- package/src/__mocks__/sample-sources.json +32 -0
- package/src/index.scss +18 -8
- package/src/index.spec.tsx +277 -99
- package/src/index.stories.tsx +65 -39
- package/src/index.tsx +119 -57
- package/src/types.ts +54 -63
- package/tailwind.config.cjs +92 -92
- package/vite.config.js +12 -12
- package/lib/Hooks/useCategorisedSources.d.ts +0 -14
- package/lib/Hooks/useCategorisedSources.js +0 -38
- package/lib/Hooks/useChildResources.d.ts +0 -16
- package/lib/Hooks/useChildResources.js +0 -13
- package/lib/Hooks/usePreselectedResourcePath.d.ts +0 -20
- package/lib/Hooks/usePreselectedResourcePath.js +0 -31
- package/lib/Hooks/useRecentLocations.d.ts +0 -5
- package/lib/Hooks/useRecentLocations.js +0 -38
- package/lib/Hooks/useRecentResourcesPaths.d.ts +0 -20
- package/lib/Hooks/useRecentResourcesPaths.js +0 -30
- package/lib/Hooks/useResource.d.ts +0 -28
- package/lib/Hooks/useResource.js +0 -23
- package/lib/Hooks/useResourcePath.d.ts +0 -16
- package/lib/Hooks/useResourcePath.js +0 -64
- package/lib/Icons/HistoryIcon.d.ts +0 -4
- package/lib/Icons/HistoryIcon.js +0 -13
- package/lib/PreviewPanel/PreviewPanel.d.ts +0 -5
- package/lib/PreviewPanel/PreviewPanel.js +0 -8
- package/lib/PreviewPanel/details/MatrixResource.d.ts +0 -7
- package/lib/PreviewPanel/details/MatrixResource.js +0 -35
- package/lib/ResourceBreadcrumb/ResourceBreadcrumb.d.ts +0 -9
- package/lib/ResourceBreadcrumb/ResourceBreadcrumb.js +0 -54
- package/lib/ResourceList/ResourceList.d.ts +0 -18
- package/lib/ResourceList/ResourceList.js +0 -49
- package/lib/ResourcePickerContainer/ResourcePickerContainer.d.ts +0 -17
- package/lib/ResourcePickerContainer/ResourcePickerContainer.js +0 -166
- package/lib/StatusIndicator/StatusIndicator.d.ts +0 -8
- package/lib/StatusIndicator/StatusIndicator.js +0 -27
- package/lib/utils/findBestMatchLineage.d.ts +0 -2
- package/lib/utils/findBestMatchLineage.js +0 -28
- package/lib/utils/uuid.d.ts +0 -1
- package/lib/utils/uuid.js +0 -6
- package/src/Hooks/useCategorisedSources.spec.ts +0 -39
- package/src/Hooks/useCategorisedSources.ts +0 -46
- package/src/Hooks/useChildResources.spec.ts +0 -29
- package/src/Hooks/useChildResources.ts +0 -21
- package/src/Hooks/usePreselectedResourcePath.ts +0 -54
- package/src/Hooks/useRecentLocations.spec.ts +0 -81
- package/src/Hooks/useRecentLocations.ts +0 -44
- package/src/Hooks/useRecentResourcesPaths.ts +0 -54
- package/src/Hooks/useResource.spec.ts +0 -61
- package/src/Hooks/useResource.ts +0 -38
- package/src/Hooks/useResourcePath.spec.ts +0 -120
- package/src/Hooks/useResourcePath.ts +0 -76
- package/src/Icons/HistoryIcon.tsx +0 -17
- package/src/PreviewPanel/PreviewPanel.spec.tsx +0 -198
- package/src/PreviewPanel/PreviewPanel.stories.tsx +0 -76
- package/src/PreviewPanel/PreviewPanel.tsx +0 -6
- package/src/PreviewPanel/details/MatrixResource.tsx +0 -54
- package/src/PreviewPanel/details/matrix-resource.scss +0 -16
- package/src/ResourceBreadcrumb/ResourceBreadcrumb.spec.tsx +0 -133
- package/src/ResourceBreadcrumb/ResourceBreadcrumb.stories.tsx +0 -24
- package/src/ResourceBreadcrumb/ResourceBreadcrumb.tsx +0 -79
- package/src/ResourceBreadcrumb/resource-breadcrumb.scss +0 -28
- package/src/ResourceBreadcrumb/sample-hierarchy.json +0 -27
- package/src/ResourceList/ResourceList.spec.tsx +0 -202
- package/src/ResourceList/ResourceList.stories.tsx +0 -40
- package/src/ResourceList/ResourceList.tsx +0 -83
- package/src/ResourceList/sample-resources.json +0 -851
- package/src/ResourcePickerContainer/ResourcePickerContainer.spec.tsx +0 -780
- package/src/ResourcePickerContainer/ResourcePickerContainer.stories.tsx +0 -45
- package/src/ResourcePickerContainer/ResourcePickerContainer.tsx +0 -290
- package/src/SourceList/sample-sources.json +0 -251
- package/src/StatusIndicator/StatusIndicator.stories.tsx +0 -83
- package/src/StatusIndicator/StatusIndicator.tsx +0 -38
- package/src/__mocks__/JestHelpers.ts +0 -65
- package/src/__mocks__/StorybookHelpers.ts +0 -128
- package/src/__mocks__/jestHelpers.spec.ts +0 -38
- package/src/utils/findBestMatchLineage.spec.ts +0 -81
- package/src/utils/findBestMatchLineage.ts +0 -30
- package/src/utils/uuid.ts +0 -5
package/lib/index.css
CHANGED
@@ -354,12 +354,6 @@
|
|
354
354
|
white-space: nowrap;
|
355
355
|
border-width: 0;
|
356
356
|
}
|
357
|
-
.squiz-rb-scope .visible {
|
358
|
-
visibility: visible;
|
359
|
-
}
|
360
|
-
.squiz-rb-scope .collapse {
|
361
|
-
visibility: collapse;
|
362
|
-
}
|
363
357
|
.squiz-rb-scope .fixed {
|
364
358
|
position: fixed;
|
365
359
|
}
|
@@ -405,9 +399,6 @@
|
|
405
399
|
.squiz-rb-scope .top-\[calc\(100\%\+5px\)\] {
|
406
400
|
top: calc(100% + 5px);
|
407
401
|
}
|
408
|
-
.squiz-rb-scope .z-10 {
|
409
|
-
z-index: 10;
|
410
|
-
}
|
411
402
|
.squiz-rb-scope .z-50 {
|
412
403
|
z-index: 50;
|
413
404
|
}
|
@@ -435,10 +426,6 @@
|
|
435
426
|
.squiz-rb-scope .m-5 {
|
436
427
|
margin: 1.25rem;
|
437
428
|
}
|
438
|
-
.squiz-rb-scope .mx-2 {
|
439
|
-
margin-left: 0.5rem;
|
440
|
-
margin-right: 0.5rem;
|
441
|
-
}
|
442
429
|
.squiz-rb-scope .mx-20 {
|
443
430
|
margin-left: 5rem;
|
444
431
|
margin-right: 5rem;
|
@@ -451,18 +438,10 @@
|
|
451
438
|
margin-left: 1.25rem;
|
452
439
|
margin-right: 1.25rem;
|
453
440
|
}
|
454
|
-
.squiz-rb-scope .mx-6 {
|
455
|
-
margin-left: 1.5rem;
|
456
|
-
margin-right: 1.5rem;
|
457
|
-
}
|
458
441
|
.squiz-rb-scope .my-4 {
|
459
442
|
margin-top: 1rem;
|
460
443
|
margin-bottom: 1rem;
|
461
444
|
}
|
462
|
-
.squiz-rb-scope .my-5 {
|
463
|
-
margin-top: 1.25rem;
|
464
|
-
margin-bottom: 1.25rem;
|
465
|
-
}
|
466
445
|
.squiz-rb-scope .mb-1 {
|
467
446
|
margin-bottom: 0.25rem;
|
468
447
|
}
|
@@ -472,21 +451,18 @@
|
|
472
451
|
.squiz-rb-scope .ml-1 {
|
473
452
|
margin-left: 0.25rem;
|
474
453
|
}
|
454
|
+
.squiz-rb-scope .ml-4 {
|
455
|
+
margin-left: 1rem;
|
456
|
+
}
|
475
457
|
.squiz-rb-scope .ml-auto {
|
476
458
|
margin-left: auto;
|
477
459
|
}
|
478
|
-
.squiz-rb-scope .mr-1 {
|
479
|
-
margin-right: 0.25rem;
|
480
|
-
}
|
481
460
|
.squiz-rb-scope .mr-2 {
|
482
461
|
margin-right: 0.5rem;
|
483
462
|
}
|
484
463
|
.squiz-rb-scope .mr-2\.5 {
|
485
464
|
margin-right: 0.625rem;
|
486
465
|
}
|
487
|
-
.squiz-rb-scope .mr-3 {
|
488
|
-
margin-right: 0.75rem;
|
489
|
-
}
|
490
466
|
.squiz-rb-scope .mr-4 {
|
491
467
|
margin-right: 1rem;
|
492
468
|
}
|
@@ -505,9 +481,6 @@
|
|
505
481
|
.squiz-rb-scope .mt-1 {
|
506
482
|
margin-top: 0.25rem;
|
507
483
|
}
|
508
|
-
.squiz-rb-scope .mt-2 {
|
509
|
-
margin-top: 0.5rem;
|
510
|
-
}
|
511
484
|
.squiz-rb-scope .mt-20 {
|
512
485
|
margin-top: 5rem;
|
513
486
|
}
|
@@ -526,9 +499,6 @@
|
|
526
499
|
-webkit-box-orient: vertical;
|
527
500
|
-webkit-line-clamp: 2;
|
528
501
|
}
|
529
|
-
.squiz-rb-scope .block {
|
530
|
-
display: block;
|
531
|
-
}
|
532
502
|
.squiz-rb-scope .inline-block {
|
533
503
|
display: inline-block;
|
534
504
|
}
|
@@ -538,9 +508,6 @@
|
|
538
508
|
.squiz-rb-scope .grid {
|
539
509
|
display: grid;
|
540
510
|
}
|
541
|
-
.squiz-rb-scope .contents {
|
542
|
-
display: contents;
|
543
|
-
}
|
544
511
|
.squiz-rb-scope .hidden {
|
545
512
|
display: none;
|
546
513
|
}
|
@@ -553,9 +520,6 @@
|
|
553
520
|
.squiz-rb-scope .h-2 {
|
554
521
|
height: 0.5rem;
|
555
522
|
}
|
556
|
-
.squiz-rb-scope .h-3 {
|
557
|
-
height: 0.75rem;
|
558
|
-
}
|
559
523
|
.squiz-rb-scope .h-36 {
|
560
524
|
height: 9rem;
|
561
525
|
}
|
@@ -568,9 +532,6 @@
|
|
568
532
|
.squiz-rb-scope .h-9 {
|
569
533
|
height: 2.25rem;
|
570
534
|
}
|
571
|
-
.squiz-rb-scope .h-\[164px\] {
|
572
|
-
height: 164px;
|
573
|
-
}
|
574
535
|
.squiz-rb-scope .h-\[20px\] {
|
575
536
|
height: 20px;
|
576
537
|
}
|
@@ -592,9 +553,6 @@
|
|
592
553
|
.squiz-rb-scope .max-h-80 {
|
593
554
|
max-height: 20rem;
|
594
555
|
}
|
595
|
-
.squiz-rb-scope .max-h-full {
|
596
|
-
max-height: 100%;
|
597
|
-
}
|
598
556
|
.squiz-rb-scope .min-h-\[64px\] {
|
599
557
|
min-height: 64px;
|
600
558
|
}
|
@@ -613,9 +571,6 @@
|
|
613
571
|
.squiz-rb-scope .w-14 {
|
614
572
|
width: 3.5rem;
|
615
573
|
}
|
616
|
-
.squiz-rb-scope .w-3 {
|
617
|
-
width: 0.75rem;
|
618
|
-
}
|
619
574
|
.squiz-rb-scope .w-3\/4 {
|
620
575
|
width: 75%;
|
621
576
|
}
|
@@ -640,9 +595,6 @@
|
|
640
595
|
.squiz-rb-scope .w-\[56px\] {
|
641
596
|
width: 56px;
|
642
597
|
}
|
643
|
-
.squiz-rb-scope .w-\[60px\] {
|
644
|
-
width: 60px;
|
645
|
-
}
|
646
598
|
.squiz-rb-scope .w-\[calc\(100\%\+4px\)\] {
|
647
599
|
width: calc(100% + 4px);
|
648
600
|
}
|
@@ -655,12 +607,12 @@
|
|
655
607
|
.squiz-rb-scope .max-w-\[200px\] {
|
656
608
|
max-width: 200px;
|
657
609
|
}
|
610
|
+
.squiz-rb-scope .max-w-\[400px\] {
|
611
|
+
max-width: 400px;
|
612
|
+
}
|
658
613
|
.squiz-rb-scope .max-w-\[50rem\] {
|
659
614
|
max-width: 50rem;
|
660
615
|
}
|
661
|
-
.squiz-rb-scope .max-w-full {
|
662
|
-
max-width: 100%;
|
663
|
-
}
|
664
616
|
.squiz-rb-scope .flex-1 {
|
665
617
|
flex: 1 1 0%;
|
666
618
|
}
|
@@ -684,9 +636,6 @@
|
|
684
636
|
.squiz-rb-scope .cursor-not-allowed {
|
685
637
|
cursor: not-allowed;
|
686
638
|
}
|
687
|
-
.squiz-rb-scope .resize {
|
688
|
-
resize: both;
|
689
|
-
}
|
690
639
|
.squiz-rb-scope .grid-cols-\[24px_1fr_45px\] {
|
691
640
|
grid-template-columns: 24px 1fr 45px;
|
692
641
|
}
|
@@ -696,9 +645,6 @@
|
|
696
645
|
.squiz-rb-scope .flex-col {
|
697
646
|
flex-direction: column;
|
698
647
|
}
|
699
|
-
.squiz-rb-scope .flex-wrap {
|
700
|
-
flex-wrap: wrap;
|
701
|
-
}
|
702
648
|
.squiz-rb-scope .items-center {
|
703
649
|
align-items: center;
|
704
650
|
}
|
@@ -749,17 +695,6 @@
|
|
749
695
|
.squiz-rb-scope .rounded-lg {
|
750
696
|
border-radius: 0.5rem;
|
751
697
|
}
|
752
|
-
.squiz-rb-scope .rounded-b-lg {
|
753
|
-
border-bottom-right-radius: 0.5rem;
|
754
|
-
border-bottom-left-radius: 0.5rem;
|
755
|
-
}
|
756
|
-
.squiz-rb-scope .rounded-t-lg {
|
757
|
-
border-top-left-radius: 0.5rem;
|
758
|
-
border-top-right-radius: 0.5rem;
|
759
|
-
}
|
760
|
-
.squiz-rb-scope .border {
|
761
|
-
border-width: 1px;
|
762
|
-
}
|
763
698
|
.squiz-rb-scope .border-1 {
|
764
699
|
border-width: 1px;
|
765
700
|
}
|
@@ -784,10 +719,6 @@
|
|
784
719
|
.squiz-rb-scope .border-solid {
|
785
720
|
border-style: solid;
|
786
721
|
}
|
787
|
-
.squiz-rb-scope .border-black {
|
788
|
-
--tw-border-opacity: 1;
|
789
|
-
border-color: rgb(0 0 0 / var(--tw-border-opacity));
|
790
|
-
}
|
791
722
|
.squiz-rb-scope .border-current {
|
792
723
|
border-color: currentColor;
|
793
724
|
}
|
@@ -795,8 +726,9 @@
|
|
795
726
|
--tw-border-opacity: 1;
|
796
727
|
border-color: rgb(224 224 224 / var(--tw-border-opacity));
|
797
728
|
}
|
798
|
-
.squiz-rb-scope .border-
|
799
|
-
--tw-border-opacity:
|
729
|
+
.squiz-rb-scope .border-white {
|
730
|
+
--tw-border-opacity: 1;
|
731
|
+
border-color: rgb(255 255 255 / var(--tw-border-opacity));
|
800
732
|
}
|
801
733
|
.squiz-rb-scope .bg-black {
|
802
734
|
--tw-bg-opacity: 1;
|
@@ -883,17 +815,25 @@
|
|
883
815
|
padding-top: 0.5rem;
|
884
816
|
padding-bottom: 0.5rem;
|
885
817
|
}
|
886
|
-
.squiz-rb-scope .py-4 {
|
887
|
-
padding-top: 1rem;
|
888
|
-
padding-bottom: 1rem;
|
889
|
-
}
|
890
818
|
.squiz-rb-scope .py-8 {
|
891
819
|
padding-top: 2rem;
|
892
820
|
padding-bottom: 2rem;
|
893
821
|
}
|
822
|
+
.squiz-rb-scope .pb-0 {
|
823
|
+
padding-bottom: 0px;
|
824
|
+
}
|
894
825
|
.squiz-rb-scope .pb-4 {
|
895
826
|
padding-bottom: 1rem;
|
896
827
|
}
|
828
|
+
.squiz-rb-scope .pl-4 {
|
829
|
+
padding-left: 1rem;
|
830
|
+
}
|
831
|
+
.squiz-rb-scope .pr-4 {
|
832
|
+
padding-right: 1rem;
|
833
|
+
}
|
834
|
+
.squiz-rb-scope .pt-3 {
|
835
|
+
padding-top: 0.75rem;
|
836
|
+
}
|
897
837
|
.squiz-rb-scope .text-left {
|
898
838
|
text-align: left;
|
899
839
|
}
|
@@ -976,6 +916,14 @@
|
|
976
916
|
.squiz-rb-scope .opacity-40 {
|
977
917
|
opacity: 0.4;
|
978
918
|
}
|
919
|
+
.squiz-rb-scope .shadow-md {
|
920
|
+
--tw-shadow: 0 0 0 1px rgba(0,0,0,0.04), 0 1px 12px 4px rgba(0,0,0,0.12);
|
921
|
+
--tw-shadow-colored: 0 0 0 1px var(--tw-shadow-color), 0 1px 12px 4px var(--tw-shadow-color);
|
922
|
+
box-shadow:
|
923
|
+
var(--tw-ring-offset-shadow, 0 0 #0000),
|
924
|
+
var(--tw-ring-shadow, 0 0 #0000),
|
925
|
+
var(--tw-shadow);
|
926
|
+
}
|
979
927
|
.squiz-rb-scope .outline-0 {
|
980
928
|
outline-width: 0px;
|
981
929
|
}
|
@@ -986,44 +934,6 @@
|
|
986
934
|
.squiz-rb-scope .filter {
|
987
935
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
988
936
|
}
|
989
|
-
.squiz-rb-scope .resource-breadcrumb--collapsed .resource-breadcrumb__label {
|
990
|
-
max-width: 250px;
|
991
|
-
cursor: pointer;
|
992
|
-
overflow: hidden;
|
993
|
-
text-overflow: ellipsis;
|
994
|
-
white-space: nowrap;
|
995
|
-
}
|
996
|
-
.squiz-rb-scope .resource-breadcrumb--collapsed .resource-breadcrumb__label:hover {
|
997
|
-
text-decoration-line: underline;
|
998
|
-
}
|
999
|
-
.squiz-rb-scope .resource-breadcrumb--collapsed .resource-breadcrumb__label:focus {
|
1000
|
-
text-decoration-line: underline;
|
1001
|
-
}
|
1002
|
-
@media (min-width: 768px) {
|
1003
|
-
.squiz-rb-scope .resource-breadcrumb--collapsed .resource-breadcrumb__label {
|
1004
|
-
max-width: 90px;
|
1005
|
-
}
|
1006
|
-
}
|
1007
|
-
.squiz-rb-scope .resource-breadcrumb--collapsed .resource-breadcrumb__item:nth-child(n+3) {
|
1008
|
-
display: none;
|
1009
|
-
}
|
1010
|
-
.squiz-rb-scope .resource-breadcrumb--collapsed .resource-breadcrumb__item:nth-last-child(-n+2) {
|
1011
|
-
display: flex;
|
1012
|
-
}
|
1013
|
-
@media not all and (min-width: 768px) {
|
1014
|
-
.squiz-rb-scope .resource-breadcrumb--collapsed .resource-breadcrumb__item:nth-last-child(-n+2) {
|
1015
|
-
display: none;
|
1016
|
-
}
|
1017
|
-
}
|
1018
|
-
.squiz-rb-scope .resource-breadcrumb--collapsed .resource-breadcrumb__item:last-child {
|
1019
|
-
display: flex;
|
1020
|
-
}
|
1021
|
-
.squiz-rb-scope .resource-breadcrumb--expanded .resource-breadcrumb__expander {
|
1022
|
-
display: none;
|
1023
|
-
}
|
1024
|
-
.squiz-rb-scope .resource-breadcrumb--expanded .resource-breadcrumb__item:last-child {
|
1025
|
-
display: flex;
|
1026
|
-
}
|
1027
937
|
.squiz-rb-scope .resource-picker {
|
1028
938
|
display: grid;
|
1029
939
|
grid-template-columns: 24px 1fr;
|
@@ -1061,27 +971,6 @@
|
|
1061
971
|
--tw-bg-opacity: 1;
|
1062
972
|
background-color: rgb(247 247 247 / var(--tw-bg-opacity));
|
1063
973
|
}
|
1064
|
-
.squiz-rb-scope .checkered-bg {
|
1065
|
-
--tw-bg-opacity: 1;
|
1066
|
-
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
|
1067
|
-
background-size: 24px 24px;
|
1068
|
-
background-position: 0 0, 12px 12px;
|
1069
|
-
background-image:
|
1070
|
-
linear-gradient(
|
1071
|
-
45deg,
|
1072
|
-
#e0e0e0 25%,
|
1073
|
-
transparent 25%,
|
1074
|
-
transparent 75%,
|
1075
|
-
#e0e0e0 75%,
|
1076
|
-
#e0e0e0),
|
1077
|
-
linear-gradient(
|
1078
|
-
45deg,
|
1079
|
-
#e0e0e0 25%,
|
1080
|
-
transparent 25%,
|
1081
|
-
transparent 75%,
|
1082
|
-
#e0e0e0 75%,
|
1083
|
-
#e0e0e0);
|
1084
|
-
}
|
1085
974
|
.squiz-rb-scope .spinner {
|
1086
975
|
display: inline-block;
|
1087
976
|
border-radius: 9999px;
|
@@ -1146,6 +1035,15 @@
|
|
1146
1035
|
.squiz-rb-scope .p-4\.5 {
|
1147
1036
|
padding: 18px;
|
1148
1037
|
}
|
1038
|
+
.squiz-rb-scope .pl-4\.5 {
|
1039
|
+
padding-left: 18px;
|
1040
|
+
}
|
1041
|
+
.squiz-rb-scope .pr-4\.5 {
|
1042
|
+
padding-right: 18px;
|
1043
|
+
}
|
1044
|
+
.squiz-rb-scope .pb-4\.5 {
|
1045
|
+
padding-bottom: 18px;
|
1046
|
+
}
|
1149
1047
|
.squiz-rb-scope .break-word {
|
1150
1048
|
word-break: break-word;
|
1151
1049
|
overflow-wrap: anywhere;
|
@@ -1174,34 +1072,14 @@
|
|
1174
1072
|
content: var(--tw-content);
|
1175
1073
|
top: 0.375rem;
|
1176
1074
|
}
|
1177
|
-
.squiz-rb-scope .before\:top-2\/4::before {
|
1178
|
-
content: var(--tw-content);
|
1179
|
-
top: 50%;
|
1180
|
-
}
|
1181
|
-
.squiz-rb-scope .before\:z-0::before {
|
1182
|
-
content: var(--tw-content);
|
1183
|
-
z-index: 0;
|
1184
|
-
}
|
1185
1075
|
.squiz-rb-scope .before\:z-40::before {
|
1186
1076
|
content: var(--tw-content);
|
1187
1077
|
z-index: 40;
|
1188
1078
|
}
|
1189
|
-
.squiz-rb-scope .before\:mr-2::before {
|
1190
|
-
content: var(--tw-content);
|
1191
|
-
margin-right: 0.5rem;
|
1192
|
-
}
|
1193
1079
|
.squiz-rb-scope .before\:h-\[calc\(100\%-0\.75rem\)\]::before {
|
1194
1080
|
content: var(--tw-content);
|
1195
1081
|
height: calc(100% - 0.75rem);
|
1196
1082
|
}
|
1197
|
-
.squiz-rb-scope .before\:h-px::before {
|
1198
|
-
content: var(--tw-content);
|
1199
|
-
height: 1px;
|
1200
|
-
}
|
1201
|
-
.squiz-rb-scope .before\:w-full::before {
|
1202
|
-
content: var(--tw-content);
|
1203
|
-
width: 100%;
|
1204
|
-
}
|
1205
1083
|
.squiz-rb-scope .before\:w-px::before {
|
1206
1084
|
content: var(--tw-content);
|
1207
1085
|
width: 1px;
|
@@ -1216,34 +1094,17 @@
|
|
1216
1094
|
--tw-bg-opacity: 1;
|
1217
1095
|
background-color: rgb(237 237 237 / var(--tw-bg-opacity));
|
1218
1096
|
}
|
1219
|
-
.squiz-rb-scope .before\:bg-gray-300::before {
|
1220
|
-
content: var(--tw-content);
|
1221
|
-
--tw-bg-opacity: 1;
|
1222
|
-
background-color: rgb(224 224 224 / var(--tw-bg-opacity));
|
1223
|
-
}
|
1224
1097
|
.squiz-rb-scope .before\:bg-opacity-25::before {
|
1225
1098
|
content: var(--tw-content);
|
1226
1099
|
--tw-bg-opacity: 0.25;
|
1227
1100
|
}
|
1228
|
-
.squiz-rb-scope .before\:content-\[\'\/\'\]::before {
|
1229
|
-
--tw-content: "/";
|
1230
|
-
content: var(--tw-content);
|
1231
|
-
}
|
1232
1101
|
.squiz-rb-scope .first\:mt-0:first-child {
|
1233
1102
|
margin-top: 0px;
|
1234
1103
|
}
|
1235
|
-
.squiz-rb-scope .first\:rounded-t:first-child {
|
1236
|
-
border-top-left-radius: 4px;
|
1237
|
-
border-top-right-radius: 4px;
|
1238
|
-
}
|
1239
1104
|
.squiz-rb-scope .first\:rounded-t-lg:first-child {
|
1240
1105
|
border-top-left-radius: 0.5rem;
|
1241
1106
|
border-top-right-radius: 0.5rem;
|
1242
1107
|
}
|
1243
|
-
.squiz-rb-scope .last\:rounded-b:last-child {
|
1244
|
-
border-bottom-right-radius: 4px;
|
1245
|
-
border-bottom-left-radius: 4px;
|
1246
|
-
}
|
1247
1108
|
.squiz-rb-scope .last\:rounded-b-lg:last-child {
|
1248
1109
|
border-bottom-right-radius: 0.5rem;
|
1249
1110
|
border-bottom-left-radius: 0.5rem;
|
@@ -1251,14 +1112,14 @@
|
|
1251
1112
|
.squiz-rb-scope .last\:border-b:last-child {
|
1252
1113
|
border-bottom-width: 1px;
|
1253
1114
|
}
|
1115
|
+
.squiz-rb-scope .hover\:border-gray-300:hover {
|
1116
|
+
--tw-border-opacity: 1;
|
1117
|
+
border-color: rgb(224 224 224 / var(--tw-border-opacity));
|
1118
|
+
}
|
1254
1119
|
.squiz-rb-scope .hover\:bg-blue-100:hover {
|
1255
1120
|
--tw-bg-opacity: 1;
|
1256
1121
|
background-color: rgb(230 241 250 / var(--tw-bg-opacity));
|
1257
1122
|
}
|
1258
|
-
.squiz-rb-scope .hover\:bg-gray-100:hover {
|
1259
|
-
--tw-bg-opacity: 1;
|
1260
|
-
background-color: rgb(245 245 245 / var(--tw-bg-opacity));
|
1261
|
-
}
|
1262
1123
|
.squiz-rb-scope .hover\:bg-gray-50:hover {
|
1263
1124
|
--tw-bg-opacity: 1;
|
1264
1125
|
background-color: rgb(247 247 247 / var(--tw-bg-opacity));
|
@@ -1310,32 +1171,11 @@
|
|
1310
1171
|
animation: spin 1.5s linear infinite;
|
1311
1172
|
}
|
1312
1173
|
}
|
1313
|
-
@media not all and (min-width: 768px) {
|
1314
|
-
.squiz-rb-scope .max-md\:hidden {
|
1315
|
-
display: none;
|
1316
|
-
}
|
1317
|
-
}
|
1318
1174
|
@media not all and (min-width: 640px) {
|
1319
1175
|
.squiz-rb-scope .max-sm\:hidden {
|
1320
1176
|
display: none;
|
1321
1177
|
}
|
1322
1178
|
}
|
1323
|
-
@media (min-width: 640px) {
|
1324
|
-
.squiz-rb-scope .sm\:flex-1 {
|
1325
|
-
flex: 1 1 0%;
|
1326
|
-
}
|
1327
|
-
.squiz-rb-scope .sm\:grow-\[2\] {
|
1328
|
-
flex-grow: 2;
|
1329
|
-
}
|
1330
|
-
.squiz-rb-scope .sm\:overflow-y-scroll {
|
1331
|
-
overflow-y: scroll;
|
1332
|
-
}
|
1333
|
-
}
|
1334
|
-
@media (min-width: 768px) {
|
1335
|
-
.squiz-rb-scope .md\:font-semibold {
|
1336
|
-
font-weight: 600;
|
1337
|
-
}
|
1338
|
-
}
|
1339
1179
|
@media (min-width: 1024px) {
|
1340
1180
|
.squiz-rb-scope .lg\:h-\[calc\(100vh-9rem\)\] {
|
1341
1181
|
height: calc(100vh - 9rem);
|
package/lib/index.d.ts
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
export type { HydratedResourceReference, Resource, ResourceReference, Source, ResourceBrowserContextProps };
|
2
|
+
import { ResourceBrowserContext, ResourceBrowserContextProvider } from './ResourceBrowserContext/ResourceBrowserContext';
|
3
|
+
import { ResourceBrowserUnresolvedResource, ResourceBrowserResource } from './types';
|
5
4
|
export { ResourceBrowserContext, ResourceBrowserContextProvider };
|
6
|
-
export
|
5
|
+
export * from './types';
|
6
|
+
export type ResourceBrowserProps = {
|
7
7
|
modalTitle: string;
|
8
8
|
allowedTypes?: string[];
|
9
9
|
isDisabled?: boolean;
|
10
|
-
value:
|
11
|
-
onChange(resource:
|
10
|
+
value: ResourceBrowserUnresolvedResource | null;
|
11
|
+
onChange(resource: ResourceBrowserResource | null): void;
|
12
12
|
onClear?(): void;
|
13
13
|
};
|
14
|
-
export declare const
|
14
|
+
export declare const ResourceBrowser: (props: ResourceBrowserProps) => React.JSX.Element;
|
package/lib/index.js
CHANGED
@@ -22,24 +22,80 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
22
|
__setModuleDefault(result, mod);
|
23
23
|
return result;
|
24
24
|
};
|
25
|
-
var
|
26
|
-
|
25
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
26
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
exports.
|
29
|
+
exports.ResourceBrowser = exports.ResourceBrowserContextProvider = exports.ResourceBrowserContext = void 0;
|
30
30
|
const react_1 = __importStar(require("react"));
|
31
|
-
const ResourcePickerContainer_1 = __importDefault(require("./ResourcePickerContainer/ResourcePickerContainer"));
|
32
31
|
const ResourceBrowserContext_1 = require("./ResourceBrowserContext/ResourceBrowserContext");
|
33
32
|
Object.defineProperty(exports, "ResourceBrowserContext", { enumerable: true, get: function () { return ResourceBrowserContext_1.ResourceBrowserContext; } });
|
34
33
|
Object.defineProperty(exports, "ResourceBrowserContextProvider", { enumerable: true, get: function () { return ResourceBrowserContext_1.ResourceBrowserContextProvider; } });
|
35
|
-
const
|
36
|
-
const
|
37
|
-
|
38
|
-
|
39
|
-
const {
|
40
|
-
const
|
41
|
-
const
|
34
|
+
const useSources_1 = require("./Hooks/useSources");
|
35
|
+
const Plugin_1 = require("./Plugin/Plugin");
|
36
|
+
__exportStar(require("./types"), exports);
|
37
|
+
const ResourceBrowser = (props) => {
|
38
|
+
const { value } = props;
|
39
|
+
const [error, setError] = (0, react_1.useState)(null);
|
40
|
+
const { onRequestSources, plugins } = (0, react_1.useContext)(ResourceBrowserContext_1.ResourceBrowserContext);
|
41
|
+
const [isModalOpen, setIsModalOpen] = (0, react_1.useState)(false);
|
42
|
+
const [source, setSource] = (0, react_1.useState)(null);
|
43
|
+
const { data: sources, isLoading, error: sourcesError } = (0, useSources_1.useSources)({ onRequestSources, plugins });
|
44
|
+
const [plugin, setPlugin] = (0, react_1.useState)(null);
|
45
|
+
// MainContainer will render a list of sources of one is not provided to it, callback to allow it to set the source once a user selects
|
46
|
+
const handleSourceSelect = (0, react_1.useCallback)((source) => {
|
47
|
+
setSource(source);
|
48
|
+
}, [setSource]);
|
49
|
+
// Try to auto set the source
|
50
|
+
(0, react_1.useEffect)(() => {
|
51
|
+
let source = null;
|
52
|
+
setError(null);
|
53
|
+
// If there is a provided value try to use its source
|
54
|
+
if (value) {
|
55
|
+
// Search the sources for it matching against the value.source property
|
56
|
+
source = sources.find((source) => source.id === value?.sourceId) || null;
|
57
|
+
// If the source is null and we arent loading the sources
|
58
|
+
if (source === null && !isLoading) {
|
59
|
+
// Set an error as the passed in value's source wasnt returned by onRequestSources
|
60
|
+
setError(new Error('Unable to find resource source.'));
|
61
|
+
}
|
62
|
+
}
|
63
|
+
else if (sources?.length === 1) {
|
64
|
+
// If only one source is passed in select it automatically
|
65
|
+
source = sources[0];
|
66
|
+
}
|
67
|
+
setSource(source);
|
68
|
+
}, [value, isLoading, sources, setSource, setError]);
|
69
|
+
(0, react_1.useEffect)(() => {
|
70
|
+
if (source) {
|
71
|
+
const plugin = plugins.find((plugin) => {
|
72
|
+
return plugin.type === source.type;
|
73
|
+
});
|
74
|
+
setPlugin(plugin || null);
|
75
|
+
}
|
76
|
+
else {
|
77
|
+
setPlugin(null);
|
78
|
+
}
|
79
|
+
}, [plugins, source]);
|
80
|
+
const handleModalStateChange = (0, react_1.useCallback)((isOpen) => {
|
81
|
+
setIsModalOpen(isOpen);
|
82
|
+
}, [setIsModalOpen]);
|
83
|
+
(0, react_1.useEffect)(() => {
|
84
|
+
if (!isModalOpen && !value && sources?.length > 1) {
|
85
|
+
setSource(null);
|
86
|
+
}
|
87
|
+
}, [sources, isModalOpen]);
|
88
|
+
// Render a default "plugin" and one for each item in the plugins array. They are conditionally rendered based on what is selected
|
42
89
|
return (react_1.default.createElement("div", { className: "squiz-rb-scope" },
|
43
|
-
react_1.default.createElement(
|
90
|
+
react_1.default.createElement(Plugin_1.PluginRender, { key: "default", render: plugin === null, ...props, source: source, sources: sources, setSource: handleSourceSelect, isLoading: isLoading, error: sourcesError || error, plugin: plugin, useResource: () => {
|
91
|
+
return {
|
92
|
+
data: null,
|
93
|
+
error: null,
|
94
|
+
isLoading: false,
|
95
|
+
};
|
96
|
+
}, isModalOpen: isModalOpen, onModalStateChange: handleModalStateChange }),
|
97
|
+
plugins.map((thisPlugin) => {
|
98
|
+
return (react_1.default.createElement(Plugin_1.PluginRender, { key: thisPlugin.type, render: thisPlugin === plugin, ...props, source: source, sources: sources, setSource: handleSourceSelect, isLoading: isLoading, error: error, plugin: plugin, useResource: thisPlugin.useResolveResource, isModalOpen: isModalOpen, onModalStateChange: handleModalStateChange }));
|
99
|
+
})));
|
44
100
|
};
|
45
|
-
exports.
|
101
|
+
exports.ResourceBrowser = ResourceBrowser;
|