@micromag/media-gallery 0.4.100 → 0.4.102

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 +179 -170
  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
@@ -3,9 +3,9 @@ import classNames from 'classnames';
3
3
  import isArray from 'lodash-es/isArray';
4
4
  import isObject from 'lodash-es/isObject';
5
5
  import isString from 'lodash-es/isString';
6
- import { MediasPickerContainer, MediasBrowserContainer } from '@panneau/medias';
6
+ import { useMediasApi, 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(64);
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,105 @@ 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
+ const mediasApi = useMediasApi();
724
+ let t20;
725
+ if ($[28] !== createMedia || $[29] !== mediasApi?.create) {
726
+ t20 = newMedias => Promise.all(newMedias.map(mediasApi?.create ?? createMedia)).then(_temp4);
727
+ $[28] = createMedia;
728
+ $[29] = mediasApi?.create;
729
+ $[30] = t20;
721
730
  } else {
722
- t21 = $[15];
731
+ t20 = $[30];
723
732
  }
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
733
+ const onMediaUploaded = t20;
734
+ const t21 = fileTypes !== null && fileTypes.length > 0 ? fileTypes : null;
735
+ let t22;
736
+ if ($[31] !== t21) {
737
+ t22 = {
738
+ allowedFileTypes: t21
730
739
  };
731
- $[16] = t22;
732
- $[17] = t23;
740
+ $[31] = t21;
741
+ $[32] = t22;
733
742
  } else {
734
- t23 = $[17];
743
+ t22 = $[32];
735
744
  }
736
- const uppyConfig = t23;
737
- let t24;
738
- if ($[18] !== source) {
739
- t24 = source !== null ? {
745
+ const uppyConfig = t22;
746
+ let t23;
747
+ if ($[33] !== source) {
748
+ t23 = source !== null ? {
740
749
  source
741
750
  } : null;
742
- $[18] = source;
743
- $[19] = t24;
751
+ $[33] = source;
752
+ $[34] = t23;
744
753
  } else {
745
- t24 = $[19];
754
+ t23 = $[34];
746
755
  }
747
- let t25;
748
- if ($[20] !== query || $[21] !== t24) {
749
- t25 = {
756
+ let t24;
757
+ if ($[35] !== query || $[36] !== t23) {
758
+ t24 = {
750
759
  ...query,
751
- ...t24
760
+ ...t23
752
761
  };
753
- $[20] = query;
754
- $[21] = t24;
755
- $[22] = t25;
762
+ $[35] = query;
763
+ $[36] = t23;
764
+ $[37] = t24;
756
765
  } else {
757
- t25 = $[22];
766
+ t24 = $[37];
758
767
  }
759
- const finalQuery = t25;
760
- let t26;
761
- if ($[23] !== value) {
762
- t26 = isObject(value) ? [value] : value;
763
- $[23] = value;
764
- $[24] = t26;
768
+ const finalQuery = t24;
769
+ let t25;
770
+ if ($[38] !== value) {
771
+ t25 = isObject(value) && !isArray(value) ? [value] : value;
772
+ $[38] = value;
773
+ $[39] = t25;
765
774
  } else {
766
- t26 = $[24];
775
+ t25 = $[39];
767
776
  }
768
- const pickerValue = t26;
769
- let t27;
770
- if ($[25] !== multiple || $[26] !== onChange) {
771
- t27 = newValue => {
777
+ const pickerValue = t25;
778
+ let t26;
779
+ if ($[40] !== multiple || $[41] !== onChange) {
780
+ t26 = newValue => {
772
781
  if (onChange !== null) {
773
782
  onChange(!multiple && isArray(newValue) ? newValue?.[0] ?? null : newValue);
774
783
  }
775
784
  };
776
- $[25] = multiple;
777
- $[26] = onChange;
778
- $[27] = t27;
785
+ $[40] = multiple;
786
+ $[41] = onChange;
787
+ $[42] = t26;
779
788
  } else {
780
- t27 = $[27];
789
+ t26 = $[42];
781
790
  }
782
- const onPickerChange = t27;
783
- let t28;
784
- if ($[28] !== className) {
785
- t28 = classNames([styles.container, className]);
786
- $[28] = className;
787
- $[29] = t28;
791
+ const onPickerChange = t26;
792
+ let t27;
793
+ if ($[43] !== className) {
794
+ t27 = classNames([styles.container, className]);
795
+ $[43] = className;
796
+ $[44] = t27;
788
797
  } else {
789
- t28 = $[29];
798
+ t27 = $[44];
790
799
  }
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, {
800
+ let t28;
801
+ if ($[45] !== columns || $[46] !== fields || $[47] !== filters || $[48] !== finalQuery || $[49] !== finalTypes || $[50] !== initialMedias || $[51] !== isPicker || $[52] !== multiple || $[53] !== onMediaFormClose || $[54] !== onMediaFormOpen || $[55] !== onMediaUploaded || $[56] !== onPickerChange || $[57] !== pickerValue || $[58] !== props || $[59] !== uppyConfig) {
802
+ t28 = isPicker ? /*#__PURE__*/jsx(MediasPickerContainer, {
794
803
  className: styles.browser,
795
- api: mediasApi,
796
804
  value: pickerValue,
797
805
  types: finalTypes,
798
806
  query: finalQuery,
@@ -807,10 +815,10 @@ function MediaGallery(t0) {
807
815
  onMediaFormOpen: onMediaFormOpen,
808
816
  onMediaFormClose: onMediaFormClose,
809
817
  withStickySelection: true,
810
- withTrash: true
818
+ withTrash: true,
819
+ ...props
811
820
  }) : /*#__PURE__*/jsx(MediasBrowserContainer, {
812
821
  className: styles.browser,
813
- api: mediasApi,
814
822
  types: finalTypes,
815
823
  query: finalQuery,
816
824
  items: initialMedias,
@@ -822,40 +830,41 @@ function MediaGallery(t0) {
822
830
  multipleSelection: true,
823
831
  withStickySelection: true,
824
832
  withTrash: true,
825
- withReplace: true
833
+ withReplace: true,
834
+ ...props
826
835
  });
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;
836
+ $[45] = columns;
837
+ $[46] = fields;
838
+ $[47] = filters;
839
+ $[48] = finalQuery;
840
+ $[49] = finalTypes;
841
+ $[50] = initialMedias;
842
+ $[51] = isPicker;
843
+ $[52] = multiple;
844
+ $[53] = onMediaFormClose;
845
+ $[54] = onMediaFormOpen;
846
+ $[55] = onMediaUploaded;
847
+ $[56] = onPickerChange;
848
+ $[57] = pickerValue;
849
+ $[58] = props;
850
+ $[59] = uppyConfig;
851
+ $[60] = t28;
843
852
  } else {
844
- t29 = $[45];
853
+ t28 = $[60];
845
854
  }
846
- let t30;
847
- if ($[46] !== t28 || $[47] !== t29) {
848
- t30 = /*#__PURE__*/jsx("div", {
849
- className: t28,
850
- children: t29
855
+ let t29;
856
+ if ($[61] !== t27 || $[62] !== t28) {
857
+ t29 = /*#__PURE__*/jsx("div", {
858
+ className: t27,
859
+ children: t28
851
860
  });
852
- $[46] = t28;
853
- $[47] = t29;
854
- $[48] = t30;
861
+ $[61] = t27;
862
+ $[62] = t28;
863
+ $[63] = t29;
855
864
  } else {
856
- t30 = $[48];
865
+ t29 = $[63];
857
866
  }
858
- return t30;
867
+ return t29;
859
868
  }
860
869
  function _temp4(newAddedMedias) {
861
870
  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.102",
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": "aeb2771dba059008d2a9228798118c798d532b93"
88
89
  }