@bigbinary/neeto-image-uploader-frontend 2.3.33 → 2.3.35

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 (64) hide show
  1. package/app/javascript/src/translations/ar.json +7 -3
  2. package/app/javascript/src/translations/bg.json +7 -3
  3. package/app/javascript/src/translations/ca.json +7 -3
  4. package/app/javascript/src/translations/cs.json +7 -3
  5. package/app/javascript/src/translations/da.json +7 -3
  6. package/app/javascript/src/translations/de.json +7 -3
  7. package/app/javascript/src/translations/es-MX.json +7 -3
  8. package/app/javascript/src/translations/es.json +7 -3
  9. package/app/javascript/src/translations/et.json +7 -3
  10. package/app/javascript/src/translations/fi.json +7 -3
  11. package/app/javascript/src/translations/fil.json +7 -3
  12. package/app/javascript/src/translations/fr.json +7 -3
  13. package/app/javascript/src/translations/he.json +7 -3
  14. package/app/javascript/src/translations/hi.json +7 -3
  15. package/app/javascript/src/translations/hr.json +7 -3
  16. package/app/javascript/src/translations/id.json +7 -3
  17. package/app/javascript/src/translations/it.json +7 -3
  18. package/app/javascript/src/translations/ja.json +7 -3
  19. package/app/javascript/src/translations/ko.json +7 -3
  20. package/app/javascript/src/translations/nl.json +7 -3
  21. package/app/javascript/src/translations/pl.json +7 -3
  22. package/app/javascript/src/translations/pt-BR.json +7 -3
  23. package/app/javascript/src/translations/pt.json +7 -3
  24. package/app/javascript/src/translations/ro.json +7 -3
  25. package/app/javascript/src/translations/ru.json +7 -3
  26. package/app/javascript/src/translations/sk.json +7 -3
  27. package/app/javascript/src/translations/sl.json +7 -3
  28. package/app/javascript/src/translations/sv.json +7 -3
  29. package/app/javascript/src/translations/th.json +7 -3
  30. package/app/javascript/src/translations/tr.json +7 -3
  31. package/app/javascript/src/translations/uk.json +7 -3
  32. package/app/javascript/src/translations/vi.json +7 -3
  33. package/app/javascript/src/translations/zh-CN.json +7 -3
  34. package/app/javascript/src/translations/zh-TW.json +7 -3
  35. package/dist/AssetLibrary.js +2 -2
  36. package/dist/BasicImageUploader.js +4 -4
  37. package/dist/BasicImageUploader.js.map +1 -1
  38. package/dist/ImageForm.js +13 -13
  39. package/dist/ImageForm.js.map +1 -1
  40. package/dist/ImageUploader.js +7 -7
  41. package/dist/ImageUploader.js.map +1 -1
  42. package/dist/cjs/AssetLibrary.js +2 -2
  43. package/dist/cjs/BasicImageUploader.js +4 -4
  44. package/dist/cjs/BasicImageUploader.js.map +1 -1
  45. package/dist/cjs/ImageForm.js +13 -13
  46. package/dist/cjs/ImageForm.js.map +1 -1
  47. package/dist/cjs/ImageUploader.js +7 -7
  48. package/dist/cjs/ImageUploader.js.map +1 -1
  49. package/dist/cjs/index.js +2 -2
  50. package/dist/{index-ph4UeLLc.js → index-Bd796sPX.js} +28 -18
  51. package/dist/index-Bd796sPX.js.map +1 -0
  52. package/dist/{index-BH0wqq_n.js → index-oS3UYUfo.js} +28 -18
  53. package/dist/index-oS3UYUfo.js.map +1 -0
  54. package/dist/index.js +2 -2
  55. package/dist/{utils-DMz4D2SB.js → utils-BjNaSuOu.js} +13 -9
  56. package/dist/utils-BjNaSuOu.js.map +1 -0
  57. package/dist/{utils-CVOvfMWy.js → utils-Um4BP0zx.js} +13 -9
  58. package/dist/utils-Um4BP0zx.js.map +1 -0
  59. package/package.json +15 -15
  60. package/types.d.ts +1 -1
  61. package/dist/index-BH0wqq_n.js.map +0 -1
  62. package/dist/index-ph4UeLLc.js.map +0 -1
  63. package/dist/utils-CVOvfMWy.js.map +0 -1
  64. package/dist/utils-DMz4D2SB.js.map +0 -1
@@ -10,7 +10,7 @@ import Toastr from '@bigbinary/neetoui/Toastr';
10
10
  import Typography from '@bigbinary/neetoui/Typography';
11
11
  import { mergeRight, identity, prop, equals } from 'ramda';
12
12
  import { useTranslation, Trans } from 'react-i18next';
13
- import { i as isNilOrEmpty, c as DEFAULT_CROP_CONFIG, g as getAspectRatio, d as getPixels, e as getHeightFromAspectRatio, f as getWidthFromAspectRatio, h as getInitialCropSize, j as getPercentage, k as isItemsCenter, l as getWrapperRefStyles, m as getCloudFlareCroppedURL, n as getImageKitCroppedURL, o as getCropValues, p as IMAGES_PER_PAGE, q as INFINITE_SCROLLER_SIZES, r as INFINITE_SCROLLER_STYLE, T as TABS, A as ASSETS_DESTROY_URL, s as ASSETS_FETCH_URL, U as UNSPLASH_DEFAULT_NAME, t as UNSPLASH_DEFAULT_REQUEST_CONFIG, D as DEFAULT_UPLOAD_CONFIG, u as useUploadDropzone, v as UNSPLASH_URL, b as ImageDirectUpload } from './utils-DMz4D2SB.js';
13
+ import { i as isNilOrEmpty, c as DEFAULT_CROP_CONFIG, g as getAspectRatio, d as getPixels, e as getHeightFromAspectRatio, f as getWidthFromAspectRatio, h as getInitialCropSize, j as getPercentage, k as isItemsCenter, l as getWrapperRefStyles, m as getCloudFlareCroppedURL, n as getImageKitCroppedURL, o as getCropValues, p as IMAGES_PER_PAGE, q as INFINITE_SCROLLER_SIZES, r as INFINITE_SCROLLER_STYLE, T as TABS, A as ASSETS_DESTROY_URL, s as ASSETS_FETCH_URL, U as UNSPLASH_DEFAULT_NAME, t as UNSPLASH_DEFAULT_REQUEST_CONFIG, D as DEFAULT_UPLOAD_CONFIG, u as useUploadDropzone, v as UNSPLASH_URL, b as ImageDirectUpload } from './utils-BjNaSuOu.js';
14
14
  import { u as useImageUploader, a as useCreateBlob, g as generateASCIIFileName } from './useImageUploader-BhXn2rPO.js';
15
15
  import { I as IS_DEVELOPMENT_OR_HEROKU_ENV, C as CLOUD_FLARE } from './index-1joql7CE.js';
16
16
  import classnames from 'classnames';
@@ -523,7 +523,7 @@ var Controls = withT(function (_ref) {
523
523
  })]
524
524
  }), /*#__PURE__*/jsx(Button, {
525
525
  className: "mt-6 self-start",
526
- "data-cy": "neeto-image-uploader-crop-submit-button",
526
+ "data-testid": "neeto-image-uploader-crop-submit-button",
527
527
  label: t("neetoImageUploader.labels.done"),
528
528
  disabled: isNilOrEmpty(imageRef.current) && (crop.width <= 0 || crop.height <= 0),
529
529
  onClick: handleSubmit
@@ -700,6 +700,14 @@ var useImageControls = function useImageControls(_ref) {
700
700
  var imageWidth = image.naturalWidth,
701
701
  imageHeight = image.naturalHeight;
702
702
  var maxCropWidth = (_defaultImageSize$wid = defaultImageSize.width) !== null && _defaultImageSize$wid !== void 0 ? _defaultImageSize$wid : imageWidth;
703
+ var aspectRatio = getAspectRatio({
704
+ fixedAspectRatio: fixedAspectRatio,
705
+ imageSize: {
706
+ width: imageWidth,
707
+ height: imageHeight
708
+ }
709
+ });
710
+ var aspectRatioFactor = aspectRatio.width / aspectRatio.height;
703
711
  var _getInitialCropSize = getInitialCropSize({
704
712
  image: image,
705
713
  aspectRatioFactor: aspectRatioFactor,
@@ -711,8 +719,10 @@ var useImageControls = function useImageControls(_ref) {
711
719
  cropWidth: cropWidth,
712
720
  cropHeight: cropHeight,
713
721
  width: imageWidth,
714
- height: imageHeight
722
+ height: imageHeight,
723
+ aspectRatio: aspectRatioFactor
715
724
  });
725
+ setAspectRatio(aspectRatio);
716
726
  setCrop(crop);
717
727
  setHeight(getPixels(crop.height, imageHeight));
718
728
  setWidth(getPixels(crop.width, imageWidth));
@@ -815,7 +825,7 @@ var ImageEditor = function ImageEditor(_ref) {
815
825
  className: "flex h-full flex-col gap-4 px-8 py-12",
816
826
  children: [/*#__PURE__*/jsx(Button, {
817
827
  className: "self-start",
818
- "data-cy": "image-editor-back-button",
828
+ "data-testid": "image-editor-back-button",
819
829
  icon: LeftArrow,
820
830
  iconPosition: "left",
821
831
  style: "text",
@@ -840,12 +850,12 @@ var ImageEditor = function ImageEditor(_ref) {
840
850
  onComplete: handleCropChange,
841
851
  children: [/*#__PURE__*/jsx("img", {
842
852
  alt: t("neetoImageUploader.common.image"),
843
- "data-cy": "image-editor-uploaded-image",
853
+ "data-testid": "image-editor-uploaded-image",
844
854
  ref: imageRef,
845
855
  src: image === null || image === void 0 ? void 0 : image.url,
846
856
  onLoad: handleImageLoad
847
857
  }), /*#__PURE__*/jsxs(Typography, {
848
- className: "neeto-ui-typography neeto-ui-text-nano neeto-ui-bg-gray-500 absolute bottom-0 right-0 z-10",
858
+ className: "neeto-ui-typography neeto-ui-text-nano neeto-ui-bg-gray-500 absolute bottom-0 end-0 z-10",
849
859
  style: "nano",
850
860
  children: [imageWidth, "x", imageHeight]
851
861
  })]
@@ -1866,7 +1876,7 @@ var InfiniteScroller = function InfiniteScroller(_ref) {
1866
1876
  children: /*#__PURE__*/jsx(Spinner, {})
1867
1877
  });
1868
1878
  return /*#__PURE__*/jsxs("div", {
1869
- className: "niu-unsplash-container mr-2 max-w-full overflow-x-hidden overflow-y-scroll",
1879
+ className: "niu-unsplash-container me-2 max-w-full overflow-x-hidden overflow-y-scroll",
1870
1880
  children: [/*#__PURE__*/jsx(_default, {
1871
1881
  hasMore: hasMore,
1872
1882
  loadMore: loadMore,
@@ -1880,7 +1890,7 @@ var InfiniteScroller = function InfiniteScroller(_ref) {
1880
1890
  children: images.map(function (image, index) {
1881
1891
  var _image$urls, _image$user, _image$user2;
1882
1892
  return /*#__PURE__*/jsx("div", {
1883
- className: "float-left w-1/2 pb-4 pr-4 md:w-1/4",
1893
+ className: "float-start w-1/2 pb-4 pe-4 md:w-1/4",
1884
1894
  children: /*#__PURE__*/jsx("div", {
1885
1895
  className: "relative w-full",
1886
1896
  style: {
@@ -1888,17 +1898,17 @@ var InfiniteScroller = function InfiniteScroller(_ref) {
1888
1898
  },
1889
1899
  children: /*#__PURE__*/jsxs("div", {
1890
1900
  className: "neeto-ui-rounded-sm neeto-ui-bg-gray-100 group absolute h-full w-full",
1891
- "data-cy": "library-image-card",
1901
+ "data-testid": "library-image-card",
1892
1902
  id: "unsplashImage".concat(image.id),
1893
1903
  children: [tab === TABS[2].key && /*#__PURE__*/jsxs(Fragment, {
1894
1904
  children: [/*#__PURE__*/jsx("img", {
1895
- "data-cy": "niu-unsplash-image-".concat(index),
1905
+ "data-testid": "niu-unsplash-image-".concat(index),
1896
1906
  src: image === null || image === void 0 || (_image$urls = image.urls) === null || _image$urls === void 0 ? void 0 : _image$urls.regular,
1897
1907
  onClick: function onClick() {
1898
1908
  return handleUnsplashImageSelect(image);
1899
1909
  }
1900
1910
  }), /*#__PURE__*/jsxs("a", {
1901
- className: "neeto-ui-text-gray-100 absolute bottom-2 left-2 m-auto text-xs underline opacity-0 group-hover:opacity-100",
1911
+ className: "neeto-ui-text-gray-100 absolute bottom-2 start-2 m-auto text-xs underline opacity-0 group-hover:opacity-100",
1902
1912
  href: "https://unsplash.com/@".concat(image === null || image === void 0 || (_image$user = image.user) === null || _image$user === void 0 ? void 0 : _image$user.username),
1903
1913
  rel: "noreferrer",
1904
1914
  target: "_blank",
@@ -1908,16 +1918,16 @@ var InfiniteScroller = function InfiniteScroller(_ref) {
1908
1918
  children: [hasPermission(VIEW_ROLES_PERMISSION) && isMenuButtonEnabled && /*#__PURE__*/jsx(Dropdown, {
1909
1919
  buttonSize: "small",
1910
1920
  buttonStyle: "tertiary",
1911
- "data-cy": "image-library-image-options-".concat(index),
1921
+ "data-testid": "image-library-image-options-".concat(index),
1912
1922
  icon: MenuHorizontal,
1913
1923
  buttonProps: {
1914
1924
  className:
1915
1925
  // eslint-disable-next-line @bigbinary/neeto/use-neetoui-classes
1916
- "absolute right-2 top-2 z-1 rounded-full"
1926
+ "absolute end-2 top-2 z-1 rounded-full"
1917
1927
  },
1918
1928
  children: /*#__PURE__*/jsx(Menu, {
1919
1929
  children: /*#__PURE__*/jsx(MenuItem.Button, {
1920
- "data-cy": "image-library-image-delete",
1930
+ "data-testid": "image-library-image-delete",
1921
1931
  onClick: function onClick() {
1922
1932
  return setDeleteConfirmation({
1923
1933
  isOpen: true,
@@ -1928,7 +1938,7 @@ var InfiniteScroller = function InfiniteScroller(_ref) {
1928
1938
  })
1929
1939
  })
1930
1940
  }), /*#__PURE__*/jsx("img", {
1931
- "data-cy": "niu-library-image-".concat(index),
1941
+ "data-testid": "niu-library-image-".concat(index),
1932
1942
  src: image === null || image === void 0 ? void 0 : image.url,
1933
1943
  onClick: function onClick() {
1934
1944
  return setSelectedImage(image);
@@ -2153,7 +2163,7 @@ var ImageLibrary = function ImageLibrary(_ref) {
2153
2163
  children: [/*#__PURE__*/jsx(Input, {
2154
2164
  autoFocus: true,
2155
2165
  className: "mb-4",
2156
- "data-cy": "niu-unsplash-image-picker-search-input",
2166
+ "data-testid": "niu-unsplash-image-picker-search-input",
2157
2167
  name: "text",
2158
2168
  placeholder: inputPlaceHolder,
2159
2169
  value: query,
@@ -2339,7 +2349,7 @@ var Modal = function Modal(_ref) {
2339
2349
  children: TABS.map(function (tab) {
2340
2350
  return /*#__PURE__*/jsx(Tab.Item, {
2341
2351
  active: activeTab === tab.key,
2342
- "data-cy": tab.dataCy,
2352
+ "data-testid": tab.dataTestid,
2343
2353
  onClick: function onClick() {
2344
2354
  return setActiveTab(tab.key);
2345
2355
  },
@@ -2368,4 +2378,4 @@ var Modal = function Modal(_ref) {
2368
2378
  };
2369
2379
 
2370
2380
  export { Modal as M, constructCloudflareImageURL as c };
2371
- //# sourceMappingURL=index-BH0wqq_n.js.map
2381
+ //# sourceMappingURL=index-oS3UYUfo.js.map