@micromag/media-gallery 0.4.100 → 0.4.101

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 (3) hide show
  1. package/es/index.d.ts +7 -15
  2. package/es/index.js +176 -169
  3. package/package.json +5 -4
package/es/index.d.ts CHANGED
@@ -1,21 +1,13 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Media } from '@micromag/core';
1
+ import * as react from 'react';
3
2
  import { ForwardedRef } from 'react';
3
+ import { Media, MediaType } from '@panneau/core';
4
+ import { MediasBrowserContainerProps, MediasPickerContainerProps } from '@panneau/medias';
4
5
  import { DialogModalProps } from '@panneau/modal-dialog';
5
6
 
6
- interface MediaGalleryProps {
7
+ interface MediaGalleryProps extends Omit<Partial<MediasBrowserContainerProps>, 'value' | 'onChange' | 'types'>, Omit<Partial<MediasPickerContainerProps>, 'value' | 'onChange' | 'types'> {
7
8
  value?: Media | Media[] | null;
8
- types?: string | string[] | null;
9
+ types?: MediaType | MediaType[] | null;
9
10
  source?: string;
10
- filters?: {
11
- id?: string;
12
- }[] | null;
13
- fields?: {
14
- id?: string;
15
- }[] | null;
16
- columns?: {
17
- id?: string;
18
- }[];
19
11
  isPicker?: boolean;
20
12
  multiple?: boolean;
21
13
  medias?: Media[] | null;
@@ -25,7 +17,7 @@ interface MediaGalleryProps {
25
17
  onMediaFormClose?: ((...args: unknown[]) => void) | null;
26
18
  className?: string | null;
27
19
  }
28
- declare function MediaGallery({ value, types, source, filters: providedFilters, fields: providedFields, columns, isPicker, multiple, medias: initialMedias, query, onChange, onMediaFormOpen, onMediaFormClose, className, }: MediaGalleryProps): react_jsx_runtime.JSX.Element;
20
+ declare function MediaGallery({ value, types, source, filters: providedFilters, fields: providedFields, columns, isPicker, multiple, medias: initialMedias, query, onChange, onMediaFormOpen, onMediaFormClose, className, ...props }: MediaGalleryProps): react.JSX.Element;
29
21
 
30
22
  interface MediaGalleryModalProps extends Omit<DialogModalProps, 'id'>, MediaGalleryProps {
31
23
  id?: string | null;
@@ -33,6 +25,6 @@ interface MediaGalleryModalProps extends Omit<DialogModalProps, 'id'>, MediaGall
33
25
  withoutCloseOnComplete?: boolean;
34
26
  formRef?: ForwardedRef<HTMLFormElement> | null;
35
27
  }
36
- declare function MediaGalleryModal({ id, title, size, visible, autoClose, multiple, requestClose: customRequestClose, onClosed, className, value: initialValue, onChange, ...props }: MediaGalleryModalProps): react_jsx_runtime.JSX.Element;
28
+ declare function MediaGalleryModal({ id, title, size, visible, autoClose, multiple, requestClose: customRequestClose, onClosed, className, value: initialValue, onChange, ...props }: MediaGalleryModalProps): react.JSX.Element;
37
29
 
38
30
  export { MediaGallery, MediaGalleryModal, MediaGallery as default };
package/es/index.js CHANGED
@@ -5,7 +5,7 @@ import isObject from 'lodash-es/isObject';
5
5
  import isString from 'lodash-es/isString';
6
6
  import { MediasPickerContainer, MediasBrowserContainer } from '@panneau/medias';
7
7
  import { useStory } from '@micromag/core/contexts';
8
- import { useApi, useMediaCreate } from '@micromag/data';
8
+ import { useMediaCreate } from '@micromag/data';
9
9
  import { FormattedMessage } from 'react-intl';
10
10
  import { jsx } from 'react/jsx-runtime';
11
11
  import { useUrlGenerator } from '@folklore/routes';
@@ -552,23 +552,73 @@ function useDefaultFields() {
552
552
  var styles = {"container":"micromag-media-gallery-new-media-gallery-container","browser":"micromag-media-gallery-new-media-gallery-browser"};
553
553
 
554
554
  function MediaGallery(t0) {
555
- const $ = c(49);
556
- const {
557
- value: t1,
558
- types: t2,
559
- source: t3,
560
- filters: t4,
561
- fields: t5,
562
- columns: t6,
563
- isPicker: t7,
564
- multiple: t8,
565
- medias: t9,
566
- query: t10,
567
- onChange: t11,
568
- onMediaFormOpen: t12,
569
- onMediaFormClose: t13,
570
- className: t14
571
- } = t0;
555
+ const $ = c(63);
556
+ let props;
557
+ let t1;
558
+ let t10;
559
+ let t11;
560
+ let t12;
561
+ let t13;
562
+ let t14;
563
+ let t2;
564
+ let t3;
565
+ let t4;
566
+ let t5;
567
+ let t6;
568
+ let t7;
569
+ let t8;
570
+ let t9;
571
+ if ($[0] !== t0) {
572
+ ({
573
+ value: t1,
574
+ types: t2,
575
+ source: t3,
576
+ filters: t4,
577
+ fields: t5,
578
+ columns: t6,
579
+ isPicker: t7,
580
+ multiple: t8,
581
+ medias: t9,
582
+ query: t10,
583
+ onChange: t11,
584
+ onMediaFormOpen: t12,
585
+ onMediaFormClose: t13,
586
+ className: t14,
587
+ ...props
588
+ } = t0);
589
+ $[0] = t0;
590
+ $[1] = props;
591
+ $[2] = t1;
592
+ $[3] = t10;
593
+ $[4] = t11;
594
+ $[5] = t12;
595
+ $[6] = t13;
596
+ $[7] = t14;
597
+ $[8] = t2;
598
+ $[9] = t3;
599
+ $[10] = t4;
600
+ $[11] = t5;
601
+ $[12] = t6;
602
+ $[13] = t7;
603
+ $[14] = t8;
604
+ $[15] = t9;
605
+ } else {
606
+ props = $[1];
607
+ t1 = $[2];
608
+ t10 = $[3];
609
+ t11 = $[4];
610
+ t12 = $[5];
611
+ t13 = $[6];
612
+ t14 = $[7];
613
+ t2 = $[8];
614
+ t3 = $[9];
615
+ t4 = $[10];
616
+ t5 = $[11];
617
+ t6 = $[12];
618
+ t7 = $[13];
619
+ t8 = $[14];
620
+ t9 = $[15];
621
+ }
572
622
  const value = t1 === undefined ? null : t1;
573
623
  const types = t2 === undefined ? null : t2;
574
624
  const source = t3 === undefined ? null : t3;
@@ -583,15 +633,14 @@ function MediaGallery(t0) {
583
633
  const onMediaFormOpen = t12 === undefined ? null : t12;
584
634
  const onMediaFormClose = t13 === undefined ? null : t13;
585
635
  const className = t14 === undefined ? null : t14;
586
- const api = useApi();
587
636
  const story = useStory();
588
637
  let t15;
589
- if ($[0] !== story) {
638
+ if ($[16] !== story) {
590
639
  t15 = story || {};
591
- $[0] = story;
592
- $[1] = t15;
640
+ $[16] = story;
641
+ $[17] = t15;
593
642
  } else {
594
- t15 = $[1];
643
+ t15 = $[17];
595
644
  }
596
645
  const {
597
646
  id: t16
@@ -599,15 +648,15 @@ function MediaGallery(t0) {
599
648
  const storyId = t16 === undefined ? null : t16;
600
649
  let finalTypes;
601
650
  let t17;
602
- if ($[2] !== types) {
651
+ if ($[18] !== types) {
603
652
  finalTypes = isString(types) ? [types] : types;
604
653
  t17 = [...(finalTypes || []).map(_temp), (finalTypes || []).indexOf("video") !== -1 ? "image/gif" : null].filter(_temp2);
605
- $[2] = types;
606
- $[3] = finalTypes;
607
- $[4] = t17;
654
+ $[18] = types;
655
+ $[19] = finalTypes;
656
+ $[20] = t17;
608
657
  } else {
609
- finalTypes = $[3];
610
- t17 = $[4];
658
+ finalTypes = $[19];
659
+ t17 = $[20];
611
660
  }
612
661
  const fileTypes = t17;
613
662
  const defaultFields = useDefaultFields();
@@ -615,9 +664,9 @@ function MediaGallery(t0) {
615
664
  const fields = providedFields ?? defaultFields;
616
665
  const t18 = providedFilters ?? defaultFilters;
617
666
  let t19;
618
- if ($[5] !== finalTypes || $[6] !== storyId || $[7] !== t18) {
667
+ if ($[21] !== finalTypes || $[22] !== storyId || $[23] !== t18) {
619
668
  let t20;
620
- if ($[9] !== finalTypes || $[10] !== storyId) {
669
+ if ($[25] !== finalTypes || $[26] !== storyId) {
621
670
  t20 = filter => {
622
671
  const {
623
672
  id: t21,
@@ -626,7 +675,7 @@ function MediaGallery(t0) {
626
675
  const id = t21 === undefined ? null : t21;
627
676
  const options = t22 === undefined ? [] : t22;
628
677
  if (id === "types" && finalTypes !== null) {
629
- return false;
678
+ return null;
630
679
  }
631
680
  if (id === "source") {
632
681
  if (storyId === null) {
@@ -653,146 +702,103 @@ function MediaGallery(t0) {
653
702
  }
654
703
  return filter;
655
704
  };
656
- $[9] = finalTypes;
657
- $[10] = storyId;
658
- $[11] = t20;
705
+ $[25] = finalTypes;
706
+ $[26] = storyId;
707
+ $[27] = t20;
659
708
  } else {
660
- t20 = $[11];
709
+ t20 = $[27];
661
710
  }
662
711
  t19 = t18.map(t20).filter(_temp3);
663
- $[5] = finalTypes;
664
- $[6] = storyId;
665
- $[7] = t18;
666
- $[8] = t19;
712
+ $[21] = finalTypes;
713
+ $[22] = storyId;
714
+ $[23] = t18;
715
+ $[24] = t19;
667
716
  } else {
668
- t19 = $[8];
717
+ t19 = $[24];
669
718
  }
670
719
  const filters = t19;
671
- let t20;
672
- if ($[12] !== api) {
673
- t20 = {
674
- get: (...t21) => {
675
- const args = t21;
676
- return api.medias.get(...args);
677
- },
678
- getTrashed: (...t22) => {
679
- const args_0 = t22;
680
- return api.medias.getTrashed(...args_0);
681
- },
682
- find: (...t23) => {
683
- const args_1 = t23;
684
- return api.medias.find(...args_1);
685
- },
686
- create: (...t24) => {
687
- const args_2 = t24;
688
- return api.medias.create(...args_2);
689
- },
690
- update: (...t25) => {
691
- const args_3 = t25;
692
- return api.medias.update(...args_3);
693
- },
694
- delete: (...t26) => {
695
- const args_4 = t26;
696
- return typeof api.medias.forceDelete !== "undefined" ? api.medias.forceDelete(...args_4) : api.medias.delete(...args_4);
697
- },
698
- trash: (...t27) => {
699
- const args_5 = t27;
700
- return api.medias.delete(...args_5);
701
- },
702
- restore: (...t28) => {
703
- const args_6 = t28;
704
- return api.medias.restore(...args_6);
705
- }
706
- };
707
- $[12] = api;
708
- $[13] = t20;
709
- } else {
710
- t20 = $[13];
711
- }
712
- const mediasApi = t20;
713
720
  const {
714
721
  create: createMedia
715
722
  } = useMediaCreate();
716
- let t21;
717
- if ($[14] !== createMedia) {
718
- t21 = newMedias => Promise.all(newMedias.map(createMedia)).then(_temp4);
719
- $[14] = createMedia;
720
- $[15] = t21;
723
+ let t20;
724
+ if ($[28] !== createMedia) {
725
+ t20 = newMedias => Promise.all(newMedias.map(createMedia)).then(_temp4);
726
+ $[28] = createMedia;
727
+ $[29] = t20;
721
728
  } else {
722
- t21 = $[15];
729
+ t20 = $[29];
723
730
  }
724
- const onMediaUploaded = t21;
725
- const t22 = fileTypes !== null && fileTypes.length > 0 ? fileTypes : null;
726
- let t23;
727
- if ($[16] !== t22) {
728
- t23 = {
729
- allowedFileTypes: t22
731
+ const onMediaUploaded = t20;
732
+ const t21 = fileTypes !== null && fileTypes.length > 0 ? fileTypes : null;
733
+ let t22;
734
+ if ($[30] !== t21) {
735
+ t22 = {
736
+ allowedFileTypes: t21
730
737
  };
731
- $[16] = t22;
732
- $[17] = t23;
738
+ $[30] = t21;
739
+ $[31] = t22;
733
740
  } else {
734
- t23 = $[17];
741
+ t22 = $[31];
735
742
  }
736
- const uppyConfig = t23;
737
- let t24;
738
- if ($[18] !== source) {
739
- t24 = source !== null ? {
743
+ const uppyConfig = t22;
744
+ let t23;
745
+ if ($[32] !== source) {
746
+ t23 = source !== null ? {
740
747
  source
741
748
  } : null;
742
- $[18] = source;
743
- $[19] = t24;
749
+ $[32] = source;
750
+ $[33] = t23;
744
751
  } else {
745
- t24 = $[19];
752
+ t23 = $[33];
746
753
  }
747
- let t25;
748
- if ($[20] !== query || $[21] !== t24) {
749
- t25 = {
754
+ let t24;
755
+ if ($[34] !== query || $[35] !== t23) {
756
+ t24 = {
750
757
  ...query,
751
- ...t24
758
+ ...t23
752
759
  };
753
- $[20] = query;
754
- $[21] = t24;
755
- $[22] = t25;
760
+ $[34] = query;
761
+ $[35] = t23;
762
+ $[36] = t24;
756
763
  } else {
757
- t25 = $[22];
764
+ t24 = $[36];
758
765
  }
759
- const finalQuery = t25;
760
- let t26;
761
- if ($[23] !== value) {
762
- t26 = isObject(value) ? [value] : value;
763
- $[23] = value;
764
- $[24] = t26;
766
+ const finalQuery = t24;
767
+ let t25;
768
+ if ($[37] !== value) {
769
+ t25 = isObject(value) && !isArray(value) ? [value] : value;
770
+ $[37] = value;
771
+ $[38] = t25;
765
772
  } else {
766
- t26 = $[24];
773
+ t25 = $[38];
767
774
  }
768
- const pickerValue = t26;
769
- let t27;
770
- if ($[25] !== multiple || $[26] !== onChange) {
771
- t27 = newValue => {
775
+ const pickerValue = t25;
776
+ let t26;
777
+ if ($[39] !== multiple || $[40] !== onChange) {
778
+ t26 = newValue => {
772
779
  if (onChange !== null) {
773
780
  onChange(!multiple && isArray(newValue) ? newValue?.[0] ?? null : newValue);
774
781
  }
775
782
  };
776
- $[25] = multiple;
777
- $[26] = onChange;
778
- $[27] = t27;
783
+ $[39] = multiple;
784
+ $[40] = onChange;
785
+ $[41] = t26;
779
786
  } else {
780
- t27 = $[27];
787
+ t26 = $[41];
781
788
  }
782
- const onPickerChange = t27;
783
- let t28;
784
- if ($[28] !== className) {
785
- t28 = classNames([styles.container, className]);
786
- $[28] = className;
787
- $[29] = t28;
789
+ const onPickerChange = t26;
790
+ let t27;
791
+ if ($[42] !== className) {
792
+ t27 = classNames([styles.container, className]);
793
+ $[42] = className;
794
+ $[43] = t27;
788
795
  } else {
789
- t28 = $[29];
796
+ t27 = $[43];
790
797
  }
791
- let t29;
792
- if ($[30] !== columns || $[31] !== fields || $[32] !== filters || $[33] !== finalQuery || $[34] !== finalTypes || $[35] !== initialMedias || $[36] !== isPicker || $[37] !== mediasApi || $[38] !== multiple || $[39] !== onMediaFormClose || $[40] !== onMediaFormOpen || $[41] !== onMediaUploaded || $[42] !== onPickerChange || $[43] !== pickerValue || $[44] !== uppyConfig) {
793
- t29 = isPicker ? /*#__PURE__*/jsx(MediasPickerContainer, {
798
+ let t28;
799
+ if ($[44] !== columns || $[45] !== fields || $[46] !== filters || $[47] !== finalQuery || $[48] !== finalTypes || $[49] !== initialMedias || $[50] !== isPicker || $[51] !== multiple || $[52] !== onMediaFormClose || $[53] !== onMediaFormOpen || $[54] !== onMediaUploaded || $[55] !== onPickerChange || $[56] !== pickerValue || $[57] !== props || $[58] !== uppyConfig) {
800
+ t28 = isPicker ? /*#__PURE__*/jsx(MediasPickerContainer, {
794
801
  className: styles.browser,
795
- api: mediasApi,
796
802
  value: pickerValue,
797
803
  types: finalTypes,
798
804
  query: finalQuery,
@@ -807,10 +813,10 @@ function MediaGallery(t0) {
807
813
  onMediaFormOpen: onMediaFormOpen,
808
814
  onMediaFormClose: onMediaFormClose,
809
815
  withStickySelection: true,
810
- withTrash: true
816
+ withTrash: true,
817
+ ...props
811
818
  }) : /*#__PURE__*/jsx(MediasBrowserContainer, {
812
819
  className: styles.browser,
813
- api: mediasApi,
814
820
  types: finalTypes,
815
821
  query: finalQuery,
816
822
  items: initialMedias,
@@ -822,40 +828,41 @@ function MediaGallery(t0) {
822
828
  multipleSelection: true,
823
829
  withStickySelection: true,
824
830
  withTrash: true,
825
- withReplace: true
831
+ withReplace: true,
832
+ ...props
826
833
  });
827
- $[30] = columns;
828
- $[31] = fields;
829
- $[32] = filters;
830
- $[33] = finalQuery;
831
- $[34] = finalTypes;
832
- $[35] = initialMedias;
833
- $[36] = isPicker;
834
- $[37] = mediasApi;
835
- $[38] = multiple;
836
- $[39] = onMediaFormClose;
837
- $[40] = onMediaFormOpen;
838
- $[41] = onMediaUploaded;
839
- $[42] = onPickerChange;
840
- $[43] = pickerValue;
841
- $[44] = uppyConfig;
842
- $[45] = t29;
834
+ $[44] = columns;
835
+ $[45] = fields;
836
+ $[46] = filters;
837
+ $[47] = finalQuery;
838
+ $[48] = finalTypes;
839
+ $[49] = initialMedias;
840
+ $[50] = isPicker;
841
+ $[51] = multiple;
842
+ $[52] = onMediaFormClose;
843
+ $[53] = onMediaFormOpen;
844
+ $[54] = onMediaUploaded;
845
+ $[55] = onPickerChange;
846
+ $[56] = pickerValue;
847
+ $[57] = props;
848
+ $[58] = uppyConfig;
849
+ $[59] = t28;
843
850
  } else {
844
- t29 = $[45];
851
+ t28 = $[59];
845
852
  }
846
- let t30;
847
- if ($[46] !== t28 || $[47] !== t29) {
848
- t30 = /*#__PURE__*/jsx("div", {
849
- className: t28,
850
- children: t29
853
+ let t29;
854
+ if ($[60] !== t27 || $[61] !== t28) {
855
+ t29 = /*#__PURE__*/jsx("div", {
856
+ className: t27,
857
+ children: t28
851
858
  });
852
- $[46] = t28;
853
- $[47] = t29;
854
- $[48] = t30;
859
+ $[60] = t27;
860
+ $[61] = t28;
861
+ $[62] = t29;
855
862
  } else {
856
- t30 = $[48];
863
+ t29 = $[62];
857
864
  }
858
- return t30;
865
+ return t29;
859
866
  }
860
867
  function _temp4(newAddedMedias) {
861
868
  return newAddedMedias;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/media-gallery",
3
- "version": "0.4.100",
3
+ "version": "0.4.101",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -63,8 +63,9 @@
63
63
  "@fortawesome/free-solid-svg-icons": "^7.2.0",
64
64
  "@fortawesome/react-fontawesome": "^3.2.0",
65
65
  "@micromag/core": "^0.4.100",
66
- "@micromag/data": "^0.4.100",
67
- "@panneau/medias": "^4.0.55",
66
+ "@micromag/data": "^0.4.101",
67
+ "@panneau/core": "^4.0.58",
68
+ "@panneau/medias": "^4.0.60",
68
69
  "bootstrap": "^5.3.8",
69
70
  "classnames": "^2.2.6",
70
71
  "lodash-es": "^4.17.23",
@@ -84,5 +85,5 @@
84
85
  "access": "public",
85
86
  "registry": "https://registry.npmjs.org/"
86
87
  },
87
- "gitHead": "724328f428f29f4950850cf34adb68ef5f46669a"
88
+ "gitHead": "88aec42cff116b686d2331bf397ba2ada2fa393d"
88
89
  }