@micromag/media-gallery 0.4.101 → 0.4.103

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 (2) hide show
  1. package/es/index.js +57 -55
  2. package/package.json +2 -2
package/es/index.js CHANGED
@@ -3,7 +3,7 @@ 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
8
  import { useMediaCreate } from '@micromag/data';
9
9
  import { FormattedMessage } from 'react-intl';
@@ -552,7 +552,7 @@ 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(63);
555
+ const $ = c(64);
556
556
  let props;
557
557
  let t1;
558
558
  let t10;
@@ -720,83 +720,85 @@ function MediaGallery(t0) {
720
720
  const {
721
721
  create: createMedia
722
722
  } = useMediaCreate();
723
+ const mediasApi = useMediasApi();
723
724
  let t20;
724
- if ($[28] !== createMedia) {
725
- t20 = newMedias => Promise.all(newMedias.map(createMedia)).then(_temp4);
725
+ if ($[28] !== createMedia || $[29] !== mediasApi?.create) {
726
+ t20 = newMedias => Promise.all(newMedias.map(media => (mediasApi?.create ?? createMedia)(media))).then(_temp4);
726
727
  $[28] = createMedia;
727
- $[29] = t20;
728
+ $[29] = mediasApi?.create;
729
+ $[30] = t20;
728
730
  } else {
729
- t20 = $[29];
731
+ t20 = $[30];
730
732
  }
731
733
  const onMediaUploaded = t20;
732
734
  const t21 = fileTypes !== null && fileTypes.length > 0 ? fileTypes : null;
733
735
  let t22;
734
- if ($[30] !== t21) {
736
+ if ($[31] !== t21) {
735
737
  t22 = {
736
738
  allowedFileTypes: t21
737
739
  };
738
- $[30] = t21;
739
- $[31] = t22;
740
+ $[31] = t21;
741
+ $[32] = t22;
740
742
  } else {
741
- t22 = $[31];
743
+ t22 = $[32];
742
744
  }
743
745
  const uppyConfig = t22;
744
746
  let t23;
745
- if ($[32] !== source) {
747
+ if ($[33] !== source) {
746
748
  t23 = source !== null ? {
747
749
  source
748
750
  } : null;
749
- $[32] = source;
750
- $[33] = t23;
751
+ $[33] = source;
752
+ $[34] = t23;
751
753
  } else {
752
- t23 = $[33];
754
+ t23 = $[34];
753
755
  }
754
756
  let t24;
755
- if ($[34] !== query || $[35] !== t23) {
757
+ if ($[35] !== query || $[36] !== t23) {
756
758
  t24 = {
757
759
  ...query,
758
760
  ...t23
759
761
  };
760
- $[34] = query;
761
- $[35] = t23;
762
- $[36] = t24;
762
+ $[35] = query;
763
+ $[36] = t23;
764
+ $[37] = t24;
763
765
  } else {
764
- t24 = $[36];
766
+ t24 = $[37];
765
767
  }
766
768
  const finalQuery = t24;
767
769
  let t25;
768
- if ($[37] !== value) {
770
+ if ($[38] !== value) {
769
771
  t25 = isObject(value) && !isArray(value) ? [value] : value;
770
- $[37] = value;
771
- $[38] = t25;
772
+ $[38] = value;
773
+ $[39] = t25;
772
774
  } else {
773
- t25 = $[38];
775
+ t25 = $[39];
774
776
  }
775
777
  const pickerValue = t25;
776
778
  let t26;
777
- if ($[39] !== multiple || $[40] !== onChange) {
779
+ if ($[40] !== multiple || $[41] !== onChange) {
778
780
  t26 = newValue => {
779
781
  if (onChange !== null) {
780
782
  onChange(!multiple && isArray(newValue) ? newValue?.[0] ?? null : newValue);
781
783
  }
782
784
  };
783
- $[39] = multiple;
784
- $[40] = onChange;
785
- $[41] = t26;
785
+ $[40] = multiple;
786
+ $[41] = onChange;
787
+ $[42] = t26;
786
788
  } else {
787
- t26 = $[41];
789
+ t26 = $[42];
788
790
  }
789
791
  const onPickerChange = t26;
790
792
  let t27;
791
- if ($[42] !== className) {
793
+ if ($[43] !== className) {
792
794
  t27 = classNames([styles.container, className]);
793
- $[42] = className;
794
- $[43] = t27;
795
+ $[43] = className;
796
+ $[44] = t27;
795
797
  } else {
796
- t27 = $[43];
798
+ t27 = $[44];
797
799
  }
798
800
  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) {
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) {
800
802
  t28 = isPicker ? /*#__PURE__*/jsx(MediasPickerContainer, {
801
803
  className: styles.browser,
802
804
  value: pickerValue,
@@ -831,36 +833,36 @@ function MediaGallery(t0) {
831
833
  withReplace: true,
832
834
  ...props
833
835
  });
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;
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;
850
852
  } else {
851
- t28 = $[59];
853
+ t28 = $[60];
852
854
  }
853
855
  let t29;
854
- if ($[60] !== t27 || $[61] !== t28) {
856
+ if ($[61] !== t27 || $[62] !== t28) {
855
857
  t29 = /*#__PURE__*/jsx("div", {
856
858
  className: t27,
857
859
  children: t28
858
860
  });
859
- $[60] = t27;
860
- $[61] = t28;
861
- $[62] = t29;
861
+ $[61] = t27;
862
+ $[62] = t28;
863
+ $[63] = t29;
862
864
  } else {
863
- t29 = $[62];
865
+ t29 = $[63];
864
866
  }
865
867
  return t29;
866
868
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/media-gallery",
3
- "version": "0.4.101",
3
+ "version": "0.4.103",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -85,5 +85,5 @@
85
85
  "access": "public",
86
86
  "registry": "https://registry.npmjs.org/"
87
87
  },
88
- "gitHead": "88aec42cff116b686d2331bf397ba2ada2fa393d"
88
+ "gitHead": "34f38d1659ba862f2adfcdc2335babb91270f55e"
89
89
  }