@bigbinary/neeto-image-uploader-frontend 1.4.11 → 1.4.13

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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { createContext, PureComponent, useState, useRef, useMemo, useReducer, useEffect, useCallback, forwardRef, useImperativeHandle, Fragment } from 'react';
2
- import { mergeRight, isNil, isEmpty, equals, mergeLeft, concat, __, inc, not } from 'ramda';
2
+ import { mergeRight, isNil, isEmpty, equals, mergeLeft, concat, __, inc, pipe, values, flatten as flatten$1, join, not } from 'ramda';
3
3
  import { noop as noop$1, isNotEmpty, keysToCamelCase, findBy } from '@bigbinary/neeto-cist';
4
4
  import { Checkbox, Typography, Input, Button, Toastr, Spinner, Modal as Modal$1, Tab } from '@bigbinary/neetoui';
5
5
  import { useTranslation, Trans } from 'react-i18next';
@@ -2653,8 +2653,8 @@ var directUploadsApi = {
2653
2653
  };
2654
2654
 
2655
2655
  var QUERY_KEYS = {
2656
- ASSETS_LSIT: "assets-list",
2657
- UNSPLASH_LIST: "unsplash-list"
2656
+ ASSETS_LIST: "neeto-image-uploader-assets-list",
2657
+ UNSPLASH_LIST: "neeto-image-uploader-unsplash-list"
2658
2658
  };
2659
2659
  var ASSETS_STALE_TIME = 900000; // 15 mins
2660
2660
 
@@ -4946,12 +4946,11 @@ var assetsApi = {
4946
4946
  fetch: fetch
4947
4947
  };
4948
4948
 
4949
- var ASSETS_LIST = QUERY_KEYS.ASSETS_LIST;
4950
4949
  var useFetchAssets = function useFetchAssets(_ref) {
4951
4950
  var search = _ref.search,
4952
4951
  url = _ref.url;
4953
4952
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4954
- return useQuery([ASSETS_LIST, search], function () {
4953
+ return useQuery([QUERY_KEYS.ASSETS_LIST, search], function () {
4955
4954
  return assetsApi.fetch({
4956
4955
  search: search,
4957
4956
  url: url
@@ -6182,6 +6181,10 @@ var Modal = function Modal(_ref) {
6182
6181
  })), /*#__PURE__*/React.createElement("input", getInputProps()));
6183
6182
  };
6184
6183
 
6184
+ var getAllowedTypes = function getAllowedTypes(uploadConfig) {
6185
+ return pipe(values, flatten$1, join(", "))(uploadConfig.allowedImageTypes);
6186
+ };
6187
+
6185
6188
  var ImageUpload = function ImageUpload(_ref) {
6186
6189
  var getRootProps = _ref.getRootProps,
6187
6190
  getInputProps = _ref.getInputProps,
@@ -6201,7 +6204,8 @@ var ImageUpload = function ImageUpload(_ref) {
6201
6204
  i18nKey: "neetoImageUploader.imageUpload.dragAndDropOrBrowseFile",
6202
6205
  components: {
6203
6206
  span: /*#__PURE__*/React.createElement("span", {
6204
- className: "neeto-ui-text-primary-500"
6207
+ className: "neeto-ui-text-primary-500",
6208
+ "data-cy": "upload-button"
6205
6209
  })
6206
6210
  }
6207
6211
  })), /*#__PURE__*/React.createElement(Typography, {
@@ -6218,13 +6222,16 @@ var ImageUpload = function ImageUpload(_ref) {
6218
6222
  className: "neeto-ui-text-primary-500"
6219
6223
  })
6220
6224
  }
6221
- })), /*#__PURE__*/React.createElement("input", getInputProps()), /*#__PURE__*/React.createElement(Typography, {
6225
+ })), /*#__PURE__*/React.createElement("input", _extends$1({}, getInputProps(), {
6226
+ "data-cy": "image-upload-input"
6227
+ })), /*#__PURE__*/React.createElement(Typography, {
6222
6228
  className: "text-center leading-4",
6223
6229
  style: "body3"
6224
6230
  }, /*#__PURE__*/React.createElement(Trans, {
6225
- i18nKey: "neetoImageUploader.imageUpload.maxAllowedSize",
6231
+ i18nKey: "neetoImageUploader.imageUpload.allowedConfig",
6226
6232
  values: {
6227
- size: uploadConfig === null || uploadConfig === void 0 ? void 0 : uploadConfig.maxImageSize
6233
+ size: uploadConfig === null || uploadConfig === void 0 ? void 0 : uploadConfig.maxImageSize,
6234
+ fileTypes: getAllowedTypes(uploadConfig)
6228
6235
  }
6229
6236
  }))));
6230
6237
  };
@@ -6360,8 +6367,7 @@ var ImageUploader = function ImageUploader(_ref) {
6360
6367
  }),
6361
6368
  getRootProps = _useDropzoneWithValid.getRootProps,
6362
6369
  getInputProps = _useDropzoneWithValid.getInputProps,
6363
- uploadProgress = _useDropzoneWithValid.uploadProgress,
6364
- inputRef = _useDropzoneWithValid.inputRef;
6370
+ uploadProgress = _useDropzoneWithValid.uploadProgress;
6365
6371
  if (isUploading) {
6366
6372
  return /*#__PURE__*/React.createElement("div", {
6367
6373
  className: className
@@ -6386,15 +6392,6 @@ var ImageUploader = function ImageUploader(_ref) {
6386
6392
  })), /*#__PURE__*/React.createElement("div", {
6387
6393
  className: "flex items-stretch justify-center gap-2"
6388
6394
  }, /*#__PURE__*/React.createElement(Button, {
6389
- label: t("neetoImageUploader.imageUpload.change"),
6390
- style: "link",
6391
- onClick: function onClick() {
6392
- var _inputRef$current;
6393
- return (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.click();
6394
- }
6395
- }), /*#__PURE__*/React.createElement("div", {
6396
- className: "neeto-ui-bg-gray-300 w-px"
6397
- }), /*#__PURE__*/React.createElement(Button, {
6398
6395
  label: t("neetoImageUploader.imageUpload.assets"),
6399
6396
  style: "link",
6400
6397
  onClick: setIsAssetLibraryOpen
@@ -6402,6 +6399,7 @@ var ImageUploader = function ImageUploader(_ref) {
6402
6399
  className: "neeto-ui-bg-gray-300 w-px"
6403
6400
  }), /*#__PURE__*/React.createElement(Button, {
6404
6401
  className: "bg-transparent p-0",
6402
+ "data-cy": "attachment-remove-button",
6405
6403
  label: t("neetoImageUploader.imageUpload.delete"),
6406
6404
  style: "danger-text",
6407
6405
  onClick: handleDelete