@micromag/media-gallery 0.2.378 → 0.2.391

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.js +32 -18
  2. package/lib/index.js +32 -18
  3. package/package.json +4 -4
package/es/index.js CHANGED
@@ -5,7 +5,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
5
  import React, { useState, useCallback, useMemo, useRef, useEffect } from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import classNames from 'classnames';
8
- import { useMediasRecentSearches, useMediaTags, useApi, useMediaUpdate, useMedias, useMediaCreate } from '@micromag/data';
8
+ import { useMediasRecentSearches, useMediaTags, useMediaAuthors, useMediaUpdate, useMedias, useMediaCreate } from '@micromag/data';
9
9
  import { PropTypes as PropTypes$1 } from '@micromag/core';
10
10
  import { Button, Card, Spinner, UploadModal } from '@micromag/core/components';
11
11
  import { FormattedMessage, useIntl } from 'react-intl';
@@ -13,9 +13,9 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
13
13
  import { faSearch, faTimes, faChevronLeft, faPlus, faInfoCircle, faTimesCircle, faPlayCircle, faHeadphonesAlt } from '@fortawesome/free-solid-svg-icons';
14
14
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
15
15
  import { useResizeObserver } from '@micromag/core/hooks';
16
- import prettyBytes from 'pretty-bytes';
16
+ import { useStory, useFieldComponent } from '@micromag/core/contexts';
17
17
  import uniqBy from 'lodash/uniqBy';
18
- import { useFieldComponent } from '@micromag/core/contexts';
18
+ import prettyBytes from 'pretty-bytes';
19
19
 
20
20
  var styles$8 = {"container":"micromag-media-gallery-forms-dropdown-section-container","dropdownToggle":"micromag-media-gallery-forms-dropdown-section-dropdownToggle","label":"micromag-media-gallery-forms-dropdown-section-label"};
21
21
 
@@ -1051,27 +1051,41 @@ var MediaMetadata = function MediaMetadata(_ref) {
1051
1051
  _ref3$description = _ref3.description,
1052
1052
  mediaDescription = _ref3$description === void 0 ? null : _ref3$description,
1053
1053
  _ref3$tags = _ref3.tags,
1054
- mediaTags = _ref3$tags === void 0 ? [] : _ref3$tags;
1054
+ mediaTags = _ref3$tags === void 0 ? [] : _ref3$tags; // const api = useApi();
1055
+
1056
+
1057
+ var story = useStory();
1055
1058
 
1056
- var api = useApi();
1059
+ var _ref4 = story || {},
1060
+ _ref4$id = _ref4.id,
1061
+ documentId = _ref4$id === void 0 ? null : _ref4$id;
1057
1062
 
1058
1063
  var _useMediaTags = useMediaTags(),
1059
1064
  usedTags = _useMediaTags.tags;
1060
1065
 
1066
+ var _useMediaAuthors = useMediaAuthors();
1067
+ _useMediaAuthors.authors;
1068
+
1061
1069
  var _useMediaUpdate = useMediaUpdate(),
1062
1070
  update = _useMediaUpdate.update;
1063
1071
 
1064
- var loadTags = useCallback(function (input) {
1065
- return api.medias.getTags({
1066
- search: input
1067
- }, 5);
1068
- }, [api]);
1069
- var getOptionLabel = useCallback(function (_ref4) {
1070
- var name = _ref4.name;
1072
+ console.log(story, documentId); // const loadTags = useCallback(
1073
+ // (input) =>
1074
+ // api.medias.getTags(
1075
+ // {
1076
+ // search: input,
1077
+ // },
1078
+ // 5,
1079
+ // ),
1080
+ // [api],
1081
+ // );
1082
+
1083
+ var getOptionLabel = useCallback(function (_ref5) {
1084
+ var name = _ref5.name;
1071
1085
  return name;
1072
1086
  }, []);
1073
- var getOptionValue = useCallback(function (_ref5) {
1074
- var name = _ref5.name;
1087
+ var getOptionValue = useCallback(function (_ref6) {
1088
+ var name = _ref6.name;
1075
1089
  return name;
1076
1090
  }, []);
1077
1091
  var getNewOptionData = useCallback(function (inputValue) {
@@ -1080,8 +1094,8 @@ var MediaMetadata = function MediaMetadata(_ref) {
1080
1094
  };
1081
1095
  }, []);
1082
1096
  var allTags = useMemo(function () {
1083
- return usedTags !== null ? uniqBy(mediaTags.concat(usedTags), function (_ref6) {
1084
- var id = _ref6.id;
1097
+ return usedTags !== null ? uniqBy(mediaTags.concat(usedTags), function (_ref7) {
1098
+ var id = _ref7.id;
1085
1099
  return id;
1086
1100
  }) : mediaTags;
1087
1101
  }, [mediaTags, usedTags]);
@@ -1209,8 +1223,8 @@ var MediaMetadata = function MediaMetadata(_ref) {
1209
1223
  }]
1210
1224
  })), /*#__PURE__*/React.createElement(TokensField, {
1211
1225
  value: tags,
1212
- options: allTags,
1213
- loadOptions: loadTags,
1226
+ options: allTags // loadOptions={loadTags}
1227
+ ,
1214
1228
  getOptionLabel: getOptionLabel,
1215
1229
  getOptionValue: getOptionValue,
1216
1230
  getNewOptionData: getNewOptionData,
package/lib/index.js CHANGED
@@ -15,9 +15,9 @@ var reactFontawesome = require('@fortawesome/react-fontawesome');
15
15
  var freeSolidSvgIcons = require('@fortawesome/free-solid-svg-icons');
16
16
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
17
17
  var hooks = require('@micromag/core/hooks');
18
- var prettyBytes = require('pretty-bytes');
19
- var uniqBy = require('lodash/uniqBy');
20
18
  var contexts = require('@micromag/core/contexts');
19
+ var uniqBy = require('lodash/uniqBy');
20
+ var prettyBytes = require('pretty-bytes');
21
21
 
22
22
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
23
23
 
@@ -29,8 +29,8 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
29
29
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
30
30
  var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
31
31
  var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
32
- var prettyBytes__default = /*#__PURE__*/_interopDefaultLegacy(prettyBytes);
33
32
  var uniqBy__default = /*#__PURE__*/_interopDefaultLegacy(uniqBy);
33
+ var prettyBytes__default = /*#__PURE__*/_interopDefaultLegacy(prettyBytes);
34
34
 
35
35
  var styles$8 = {"container":"micromag-media-gallery-forms-dropdown-section-container","dropdownToggle":"micromag-media-gallery-forms-dropdown-section-dropdownToggle","label":"micromag-media-gallery-forms-dropdown-section-label"};
36
36
 
@@ -1066,27 +1066,41 @@ var MediaMetadata = function MediaMetadata(_ref) {
1066
1066
  _ref3$description = _ref3.description,
1067
1067
  mediaDescription = _ref3$description === void 0 ? null : _ref3$description,
1068
1068
  _ref3$tags = _ref3.tags,
1069
- mediaTags = _ref3$tags === void 0 ? [] : _ref3$tags;
1069
+ mediaTags = _ref3$tags === void 0 ? [] : _ref3$tags; // const api = useApi();
1070
1070
 
1071
- var api = data.useApi();
1071
+
1072
+ var story = contexts.useStory();
1073
+
1074
+ var _ref4 = story || {},
1075
+ _ref4$id = _ref4.id,
1076
+ documentId = _ref4$id === void 0 ? null : _ref4$id;
1072
1077
 
1073
1078
  var _useMediaTags = data.useMediaTags(),
1074
1079
  usedTags = _useMediaTags.tags;
1075
1080
 
1081
+ var _useMediaAuthors = data.useMediaAuthors();
1082
+ _useMediaAuthors.authors;
1083
+
1076
1084
  var _useMediaUpdate = data.useMediaUpdate(),
1077
1085
  update = _useMediaUpdate.update;
1078
1086
 
1079
- var loadTags = React.useCallback(function (input) {
1080
- return api.medias.getTags({
1081
- search: input
1082
- }, 5);
1083
- }, [api]);
1084
- var getOptionLabel = React.useCallback(function (_ref4) {
1085
- var name = _ref4.name;
1087
+ console.log(story, documentId); // const loadTags = useCallback(
1088
+ // (input) =>
1089
+ // api.medias.getTags(
1090
+ // {
1091
+ // search: input,
1092
+ // },
1093
+ // 5,
1094
+ // ),
1095
+ // [api],
1096
+ // );
1097
+
1098
+ var getOptionLabel = React.useCallback(function (_ref5) {
1099
+ var name = _ref5.name;
1086
1100
  return name;
1087
1101
  }, []);
1088
- var getOptionValue = React.useCallback(function (_ref5) {
1089
- var name = _ref5.name;
1102
+ var getOptionValue = React.useCallback(function (_ref6) {
1103
+ var name = _ref6.name;
1090
1104
  return name;
1091
1105
  }, []);
1092
1106
  var getNewOptionData = React.useCallback(function (inputValue) {
@@ -1095,8 +1109,8 @@ var MediaMetadata = function MediaMetadata(_ref) {
1095
1109
  };
1096
1110
  }, []);
1097
1111
  var allTags = React.useMemo(function () {
1098
- return usedTags !== null ? uniqBy__default["default"](mediaTags.concat(usedTags), function (_ref6) {
1099
- var id = _ref6.id;
1112
+ return usedTags !== null ? uniqBy__default["default"](mediaTags.concat(usedTags), function (_ref7) {
1113
+ var id = _ref7.id;
1100
1114
  return id;
1101
1115
  }) : mediaTags;
1102
1116
  }, [mediaTags, usedTags]);
@@ -1224,8 +1238,8 @@ var MediaMetadata = function MediaMetadata(_ref) {
1224
1238
  }]
1225
1239
  })), /*#__PURE__*/React__default["default"].createElement(TokensField, {
1226
1240
  value: tags,
1227
- options: allTags,
1228
- loadOptions: loadTags,
1241
+ options: allTags // loadOptions={loadTags}
1242
+ ,
1229
1243
  getOptionLabel: getOptionLabel,
1230
1244
  getOptionValue: getOptionValue,
1231
1245
  getNewOptionData: getNewOptionData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/media-gallery",
3
- "version": "0.2.378",
3
+ "version": "0.2.391",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -54,8 +54,8 @@
54
54
  "@fortawesome/fontawesome-svg-core": "^1.2.32",
55
55
  "@fortawesome/free-solid-svg-icons": "^5.15.1",
56
56
  "@fortawesome/react-fontawesome": "^0.1.13",
57
- "@micromag/core": "^0.2.375",
58
- "@micromag/data": "^0.2.375",
57
+ "@micromag/core": "^0.2.391",
58
+ "@micromag/data": "^0.2.391",
59
59
  "bootstrap": "^4.5.3",
60
60
  "bootstrap.native": "^3.0.14",
61
61
  "change-case": "^4.1.2",
@@ -69,5 +69,5 @@
69
69
  "publishConfig": {
70
70
  "access": "public"
71
71
  },
72
- "gitHead": "238b7d66e352b610b80f09af858ba95d1fabb249"
72
+ "gitHead": "8136754d570e4fc8c1bb9c89f8635279f252e89f"
73
73
  }