@scaleflex/widget-pixaforge 0.0.1

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 (33) hide show
  1. package/CHANGELOG.md +7423 -0
  2. package/LICENSE +21 -0
  3. package/README.md +124 -0
  4. package/dist/style.css +260 -0
  5. package/dist/style.min.css +1 -0
  6. package/lib/api.service.js +93 -0
  7. package/lib/common.slice.js +77 -0
  8. package/lib/components/CategoriesCards/CategoryCard.js +33 -0
  9. package/lib/components/CategoriesCards/index.js +48 -0
  10. package/lib/components/CategoriesCards/index.scss +27 -0
  11. package/lib/components/CustomizeIcons/ColorCustomization.js +159 -0
  12. package/lib/components/CustomizeIcons/index.js +105 -0
  13. package/lib/components/CustomizeIcons/index.scss +33 -0
  14. package/lib/components/GalleryViewsOptionsMenu.js +97 -0
  15. package/lib/components/IconsGallery/SingleIcon.js +49 -0
  16. package/lib/components/IconsGallery/index.js +153 -0
  17. package/lib/components/IconsGallery/index.scss +53 -0
  18. package/lib/components/ImagesGallery/ImageCell.js +59 -0
  19. package/lib/components/ImagesGallery/LandscapesContainer.js +28 -0
  20. package/lib/components/ImagesGallery/PortraitsColumns.js +72 -0
  21. package/lib/components/ImagesGallery/index.js +183 -0
  22. package/lib/components/ImagesGallery/index.scss +120 -0
  23. package/lib/components/MainView.js +102 -0
  24. package/lib/components/TagsAndFoundLabel/TagItem.js +23 -0
  25. package/lib/components/TagsAndFoundLabel/index.js +72 -0
  26. package/lib/components/TagsAndFoundLabel/index.scss +25 -0
  27. package/lib/components/TopBar.js +113 -0
  28. package/lib/components/index.scss +48 -0
  29. package/lib/constants.js +19 -0
  30. package/lib/defaultLocale.js +22 -0
  31. package/lib/index.js +327 -0
  32. package/lib/style.scss +8 -0
  33. package/package.json +35 -0
@@ -0,0 +1,53 @@
1
+ // packages/@scaleflex/widget-pixaforge/src/components/IconsGallery/index.jsx
2
+ @mixin hover-and-selected-effect {
3
+ background-color: $hover;
4
+
5
+ .filerobot-Pixaforge-overlay {
6
+ display: block;
7
+ }
8
+ }
9
+ .filerobot-Pixaforge-IconsGallery {
10
+ display: flex;
11
+ flex-direction: column;
12
+ overflow: auto;
13
+ }
14
+ .filerobot-Pixaforge-IconsGallery-icons {
15
+ display: flex;
16
+ padding: 8px;
17
+ overflow: auto;
18
+ flex-wrap: wrap;
19
+ }
20
+ .filerobot-Pixaforge-SingleIcon {
21
+ cursor: pointer;
22
+ position: relative;
23
+ width: 106px;
24
+ height: 106px;
25
+ display: flex;
26
+ justify-content: center;
27
+ align-items: center;
28
+ background-color: $background-primary;
29
+ margin: 4px;
30
+
31
+ &:hover {
32
+ @include hover-and-selected-effect;
33
+ }
34
+
35
+ }
36
+ .filerobot-Pixaforge-SingleIcon--selected {
37
+ @include hover-and-selected-effect;
38
+ }
39
+ .filerobot-Pixaforge-SingleIcon-icon {
40
+ width: 50px;
41
+ height: 50px;
42
+ max-width: 50px;
43
+ max-height: 50px;
44
+ display: flex;
45
+ align-items: center;
46
+ justify-content: center;
47
+ color: $active;
48
+
49
+ svg {
50
+ max-width: 100%;
51
+ max-height: 100%;
52
+ }
53
+ }
@@ -0,0 +1,59 @@
1
+ var _excluded = ["isSelected", "toggleImageSelection", "showImageInfo"];
2
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
3
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
+ import { memo } from 'react';
5
+ import { Checkbox, Image } from '@scaleflex/widget-common';
6
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
+ var ImageCell = function ImageCell(_ref) {
8
+ var _image$ratio, _image$preview;
9
+ var isSelected = _ref.isSelected,
10
+ toggleImageSelection = _ref.toggleImageSelection,
11
+ showImageInfo = _ref.showImageInfo,
12
+ image = _objectWithoutProperties(_ref, _excluded);
13
+ return /*#__PURE__*/_jsxs("div", {
14
+ className: "filerobot-Pixaforge-ImageCell".concat(isSelected ? ' filerobot-Pixaforge-ImageCell--selected' : ''),
15
+ onClick: function onClick() {
16
+ return toggleImageSelection(image, isSelected);
17
+ },
18
+ children: [/*#__PURE__*/_jsxs("div", {
19
+ className: "filerobot-Pixaforge-overlay",
20
+ children: [/*#__PURE__*/_jsx(Checkbox, {
21
+ checked: isSelected,
22
+ style: {
23
+ margin: 4
24
+ }
25
+ }), showImageInfo && /*#__PURE__*/_jsxs("div", {
26
+ className: "filerobot-Pixaforge-ImageCell-imageInfo",
27
+ children: [/*#__PURE__*/_jsxs("div", {
28
+ className: "filerobot-Pixaforge-ImageCell-authorAndTitle",
29
+ children: [/*#__PURE__*/_jsx("div", {
30
+ className: "filerobot-Pixaforge-ImageCell-author",
31
+ children: image.author
32
+ }), /*#__PURE__*/_jsx("div", {
33
+ className: "filerobot-Pixaforge-ImageCell-title",
34
+ children: image.title
35
+ })]
36
+ }), /*#__PURE__*/_jsxs("div", {
37
+ className: "filerobot-Pixaforge-ImageCell-imageMeta",
38
+ children: [/*#__PURE__*/_jsx("span", {
39
+ children: image.type
40
+ }), /*#__PURE__*/_jsx("span", {
41
+ children: image.size
42
+ }), /*#__PURE__*/_jsx("span", {
43
+ children: image.resolution
44
+ })]
45
+ })]
46
+ })]
47
+ }), /*#__PURE__*/_jsx("div", {
48
+ className: "filerobot-Pixaforge-ImageCell-imageWrapper",
49
+ style: {
50
+ aspectRatio: "".concat((_image$ratio = image.ratio) !== null && _image$ratio !== void 0 ? _image$ratio : 1)
51
+ },
52
+ children: /*#__PURE__*/_jsx(Image, {
53
+ src: (_image$preview = image.preview) !== null && _image$preview !== void 0 ? _image$preview : image.src,
54
+ alt: image.tags.join(', ')
55
+ })
56
+ })]
57
+ });
58
+ };
59
+ export default /*#__PURE__*/memo(ImageCell);
@@ -0,0 +1,28 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ import { useMemo } from 'react';
8
+ import ImageCell from './ImageCell';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ var LandscapesContainer = function LandscapesContainer(_ref) {
11
+ var images = _ref.images,
12
+ checkIsSelected = _ref.checkIsSelected,
13
+ toggleImageSelection = _ref.toggleImageSelection;
14
+ var renderImagesCells = useMemo(function () {
15
+ return images.map(function (image) {
16
+ return /*#__PURE__*/_jsx(ImageCell, _objectSpread({
17
+ toggleImageSelection: toggleImageSelection,
18
+ isSelected: checkIsSelected(image),
19
+ showImageInfo: true
20
+ }, image), image.id);
21
+ });
22
+ }, [images, checkIsSelected]);
23
+ return /*#__PURE__*/_jsx("div", {
24
+ className: "filerobot-Pixaforge-LandscapesContainer",
25
+ children: renderImagesCells
26
+ });
27
+ };
28
+ export default LandscapesContainer;
@@ -0,0 +1,72 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
10
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
13
+ import { useCallback, useEffect, useState } from 'react';
14
+ import mapArrayByStep from '@scaleflex/widget-utils/lib/mapArrayByStep';
15
+ import ImageCell from './ImageCell';
16
+ import { IMAGES_COLUMNS_WIDTH, IMAGES_GALLERY_VIEWS } from '../../constants';
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ var PortraitsColumns = function PortraitsColumns(_ref) {
19
+ var images = _ref.images,
20
+ toggleImageSelection = _ref.toggleImageSelection,
21
+ checkIsSelected = _ref.checkIsSelected,
22
+ galleryView = _ref.galleryView,
23
+ imagesWrapper = _ref.imagesWrapper,
24
+ listenToElementResize = _ref.listenToElementResize,
25
+ stopListeningToElementResize = _ref.stopListeningToElementResize;
26
+ var _useState = useState(2),
27
+ _useState2 = _slicedToArray(_useState, 2),
28
+ columnsNumber = _useState2[0],
29
+ setColumnsNumber = _useState2[1];
30
+ var _useState3 = useState(true),
31
+ _useState4 = _slicedToArray(_useState3, 2),
32
+ isFirstRender = _useState4[0],
33
+ setIsFirstRender = _useState4[1];
34
+ var showImageInfo = galleryView !== IMAGES_GALLERY_VIEWS.SMALL_PORTRAITS;
35
+ var updateColumnsNumber = useCallback(function (containerWidth, _containerHeight) {
36
+ setColumnsNumber(Math.floor(containerWidth / IMAGES_COLUMNS_WIDTH[galleryView]));
37
+ }, [galleryView]);
38
+ useEffect(function () {
39
+ listenToElementResize(imagesWrapper, updateColumnsNumber);
40
+ if (isFirstRender) {
41
+ setIsFirstRender(false);
42
+ }
43
+ return function () {
44
+ stopListeningToElementResize();
45
+ };
46
+ }, []);
47
+ useEffect(function () {
48
+ if (!isFirstRender && imagesWrapper) {
49
+ var _imagesWrapper$getBou = imagesWrapper.getBoundingClientRect(),
50
+ width = _imagesWrapper$getBou.width,
51
+ height = _imagesWrapper$getBou.height;
52
+ updateColumnsNumber(width, height);
53
+ }
54
+ }, [galleryView]);
55
+ var renderImageCell = useCallback(function (image) {
56
+ return /*#__PURE__*/_jsx(ImageCell, _objectSpread({
57
+ toggleImageSelection: toggleImageSelection,
58
+ isSelected: checkIsSelected(image),
59
+ showImageInfo: showImageInfo
60
+ }, image), image.id);
61
+ }, [checkIsSelected, showImageInfo]);
62
+ var renderImagesCells = useCallback(function (columnOrder) {
63
+ return mapArrayByStep(images, columnOrder, columnsNumber, renderImageCell);
64
+ }, [images, columnsNumber, renderImageCell]);
65
+ return Array.from(Array(columnsNumber)).map(function (_, index) {
66
+ return /*#__PURE__*/_jsx("div", {
67
+ className: "filerobot-Pixaforge-PortraitsColumn",
68
+ children: renderImagesCells(index)
69
+ }, index);
70
+ });
71
+ };
72
+ export default PortraitsColumns;
@@ -0,0 +1,183 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
8
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
10
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
11
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
12
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
14
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
15
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
17
+ import { useCallback, useEffect, useRef, useState } from 'react';
18
+ import { useDispatch, useSelector } from 'react-redux';
19
+ import { Spinner } from '@scaleflex/widget-common';
20
+ import { useCore } from '@scaleflex/widget-core/lib/hooks';
21
+ import { Button } from '@scaleflex/ui/core';
22
+ import { GoBack } from '@scaleflex/icons';
23
+ import { IMAGES_GALLERY_VIEWS } from '../../constants';
24
+ import { getImagesAndTags } from '../../api.service';
25
+ import TagsAndFoundLabel from '../TagsAndFoundLabel';
26
+ import PortraitsColumns from './PortraitsColumns';
27
+ import LandscapesContainer from './LandscapesContainer';
28
+ import { currentSelectionsUpdated, selectCurrentSelection, selectGalleryView } from '../../common.slice';
29
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
30
+ var _isScrollingFetchAvailable = true;
31
+ var spinnerStyles = {
32
+ height: 'auto',
33
+ bottom: 0,
34
+ position: 'absolute'
35
+ };
36
+ var ImagesGallery = function ImagesGallery(_ref) {
37
+ var category = _ref.category,
38
+ setIsLoading = _ref.setIsLoading,
39
+ i18n = _ref.i18n,
40
+ searchKeyword = _ref.searchKeyword,
41
+ listenToElementResize = _ref.listenToElementResize,
42
+ stopListeningToElementResize = _ref.stopListeningToElementResize,
43
+ resetSelectedCategory = _ref.resetSelectedCategory;
44
+ var dispatch = useDispatch();
45
+ var _useCore = useCore(),
46
+ isFileRestrictedToGetAdded = _useCore.isFileRestrictedToGetAdded;
47
+ var galleryView = useSelector(selectGalleryView);
48
+ var currentSelection = useSelector(selectCurrentSelection);
49
+ var _useState = useState(false),
50
+ _useState2 = _slicedToArray(_useState, 2),
51
+ isFetching = _useState2[0],
52
+ setIsFetching = _useState2[1];
53
+ var _useState3 = useState([]),
54
+ _useState4 = _slicedToArray(_useState3, 2),
55
+ tags = _useState4[0],
56
+ setTags = _useState4[1];
57
+ var _useState5 = useState([]),
58
+ _useState6 = _slicedToArray(_useState5, 2),
59
+ images = _useState6[0],
60
+ setImages = _useState6[1];
61
+ var _useState7 = useState(),
62
+ _useState8 = _slicedToArray(_useState7, 2),
63
+ totalCount = _useState8[0],
64
+ setTotalCount = _useState8[1];
65
+ var _useState9 = useState(true),
66
+ _useState10 = _slicedToArray(_useState9, 2),
67
+ isFirstRender = _useState10[0],
68
+ setIsFirstRender = _useState10[1];
69
+ var latestFilters = useRef();
70
+ var imagesWrapper = useRef();
71
+ var isLandscapesView = galleryView === IMAGES_GALLERY_VIEWS.STANDARD_LANDSCAPES;
72
+ var fetchImagesAndTags = useCallback(function (filters) {
73
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
74
+ if (!isFirstRender && offset !== 0) {
75
+ setIsFetching(true);
76
+ } else if (offset === 0) {
77
+ setIsLoading(true);
78
+ }
79
+ var category = filters[0];
80
+ getImagesAndTags(filters, offset).then(function (_ref2) {
81
+ var tags = _ref2.tags,
82
+ images = _ref2.images,
83
+ totalCount = _ref2.totalCount;
84
+ setTags(function (latestTags) {
85
+ return _toConsumableArray(new Set([].concat(_toConsumableArray(latestTags), _toConsumableArray(tags.map(function (t) {
86
+ return t.tag;
87
+ }).filter(function (t) {
88
+ return category !== t;
89
+ })))));
90
+ });
91
+ setImages(function (latestImages) {
92
+ return offset ? [].concat(_toConsumableArray(latestImages), _toConsumableArray(images)) : images;
93
+ });
94
+ setTotalCount(totalCount);
95
+ })["finally"](function () {
96
+ latestFilters.current = filters;
97
+ setIsLoading(false);
98
+ setIsFetching(false);
99
+ _isScrollingFetchAvailable = true;
100
+ });
101
+ }, [isFirstRender]);
102
+ var handleTagsChange = useCallback(function (tags) {
103
+ fetchImagesAndTags([searchKeyword !== null && searchKeyword !== void 0 ? searchKeyword : category].concat(_toConsumableArray(tags)));
104
+ }, [searchKeyword, category]);
105
+ var handleScroll = useCallback(function (e) {
106
+ var elem = e.currentTarget;
107
+ var imgsLength = images.length;
108
+ if (_isScrollingFetchAvailable && elem.scrollHeight - (elem.scrollTop + elem.offsetHeight) < 75 && imgsLength !== totalCount) {
109
+ _isScrollingFetchAvailable = false;
110
+ fetchImagesAndTags(latestFilters.current, imgsLength);
111
+ }
112
+ }, [images, totalCount]);
113
+ var toggleImageSelection = useCallback(function (image, isSelected) {
114
+ if (!isSelected && isFileRestrictedToGetAdded(currentSelection, image)) {
115
+ return;
116
+ }
117
+ dispatch(currentSelectionsUpdated(isSelected ? currentSelection.filter(function (selectedImg) {
118
+ return selectedImg.id !== image.id;
119
+ }) : [].concat(_toConsumableArray(currentSelection), [image])));
120
+ }, [currentSelection]);
121
+ var checkIsSelected = useCallback(function (image) {
122
+ return currentSelection.some(function (selectedImg) {
123
+ return selectedImg.id === image.id;
124
+ });
125
+ }, [currentSelection]);
126
+ useEffect(function () {
127
+ if (isFirstRender) {
128
+ setIsFirstRender(false);
129
+ }
130
+ }, []);
131
+ useEffect(function () {
132
+ var mainFilter = searchKeyword !== null && searchKeyword !== void 0 ? searchKeyword : category;
133
+ if (mainFilter) {
134
+ fetchImagesAndTags([mainFilter]);
135
+ }
136
+ }, [searchKeyword, category]);
137
+ var renderPortraitsColumns = useCallback(function () {
138
+ return /*#__PURE__*/_jsx(PortraitsColumns, {
139
+ images: images,
140
+ checkIsSelected: checkIsSelected,
141
+ toggleImageSelection: toggleImageSelection,
142
+ listenToElementResize: listenToElementResize,
143
+ stopListeningToElementResize: stopListeningToElementResize,
144
+ imagesWrapper: imagesWrapper.current || '.filerobot-Pixaforge-ImagesGallery-imagesWrapper',
145
+ galleryView: galleryView
146
+ });
147
+ }, [images, galleryView, checkIsSelected]);
148
+ var renderLandscapesContainer = useCallback(function () {
149
+ return /*#__PURE__*/_jsx(LandscapesContainer, {
150
+ images: images,
151
+ toggleImageSelection: toggleImageSelection,
152
+ checkIsSelected: checkIsSelected
153
+ });
154
+ }, [images, checkIsSelected]);
155
+ return /*#__PURE__*/_jsxs("div", {
156
+ className: "filerobot-Pixaforge-ImagesGallery",
157
+ children: [!isFirstRender && /*#__PURE__*/_jsx(TagsAndFoundLabel, {
158
+ tags: tags,
159
+ onChange: handleTagsChange,
160
+ foundLabelCount: totalCount,
161
+ i18n: i18n
162
+ }), /*#__PURE__*/_jsxs("div", {
163
+ className: "filerobot-Pixaforge-ImagesGallery-imagesWrapper",
164
+ ref: imagesWrapper,
165
+ onScroll: handleScroll,
166
+ children: [!isFirstRender && totalCount === 0 && images.length === 0 && /*#__PURE__*/_jsxs("div", {
167
+ className: "filerobot-c-empty",
168
+ children: [i18n('pixaforgeNoImagesFoundText'), /*#__PURE__*/_jsx(Button, {
169
+ size: "sm",
170
+ onClick: resetSelectedCategory,
171
+ startIcon: function startIcon(props) {
172
+ return /*#__PURE__*/_jsx(GoBack, _objectSpread({}, props));
173
+ },
174
+ children: i18n('pixaforgeBackToCategories')
175
+ })]
176
+ }), images.length > 0 && (isLandscapesView ? renderLandscapesContainer() : renderPortraitsColumns()), isFetching && /*#__PURE__*/_jsx(Spinner, {
177
+ style: spinnerStyles,
178
+ fillContainer: true
179
+ })]
180
+ })]
181
+ });
182
+ };
183
+ export default ImagesGallery;
@@ -0,0 +1,120 @@
1
+ // packages/@scaleflex/widget-pixaforge/src/components/TagsAndFoundLabel/index.jsx
2
+ @keyframes imgPlaceholderSkeleton {
3
+ 0% {
4
+ background-position: -468px 0;
5
+ }
6
+ 100% {
7
+ background-position: 468px 0;
8
+ }
9
+ }
10
+
11
+ .filerobot-Pixaforge-ImagesGallery {
12
+ display: flex;
13
+ flex-direction: column;
14
+ overflow: auto;
15
+ }
16
+ .filerobot-Pixaforge-ImagesGallery-imagesWrapper {
17
+ display: flex;
18
+ padding: 8px 8px 4px;
19
+ overflow: auto;
20
+ height: 100%;
21
+ width: 100%;
22
+
23
+ .filerobot-c-empty {
24
+ justify-content: center;
25
+ align-items: center;
26
+ gap: 16px;
27
+ font-size: 16px;
28
+ }
29
+ }
30
+ .filerobot-Pixaforge-PortraitsColumn {
31
+ margin: 0 4px;
32
+ flex-grow: 1;
33
+ }
34
+ .filerobot-Pixaforge-ImageCell {
35
+ margin-bottom: 8px;
36
+ position: relative;
37
+ cursor: pointer;
38
+
39
+ &.filerobot-Pixaforge-ImageCell--selected, &:hover {
40
+
41
+ .filerobot-Pixaforge-overlay {
42
+ display: block;
43
+ }
44
+
45
+ img {
46
+ filter: brightness(0.8);
47
+ }
48
+ }
49
+
50
+ &:hover .filerobot-Pixaforge-ImageCell-imageInfo {
51
+ display: block;
52
+ }
53
+ }
54
+ .filerobot-Pixaforge-ImageCell-imageWrapper {
55
+ width: 100%;
56
+ height: 100%;
57
+ animation-duration: 1s;
58
+ animation-fill-mode: forwards;
59
+ animation-iteration-count: infinite;
60
+ animation-name: imgPlaceholderSkeleton;
61
+ animation-timing-function: linear;
62
+ background: $background-primary;
63
+ background-image: linear-gradient(to right, $background-primary 0%, $gray-100--highlighted 30%, $background-primary 90%, $background-primary 100%);
64
+ background-repeat: no-repeat;
65
+
66
+ img {
67
+ border-radius: 2px;
68
+ max-width: 100%;
69
+ filter: drop-shadow(0px 1px 2px rgba(78, 77, 77, 0.15));
70
+ }
71
+ }
72
+ .filerobot-Pixaforge-ImageCell-imageInfo {
73
+ display: none;
74
+ }
75
+ .filerobot-Pixaforge-ImageCell-authorAndTitle {
76
+ text-align: right;
77
+ position: absolute;
78
+ width: 80%;
79
+ top: 0;
80
+ right: 0;
81
+
82
+ div {
83
+ font-size: 10px;
84
+ line-height: 12px;
85
+ }
86
+ }
87
+ .filerobot-Pixaforge-ImageCell-author {
88
+ font-weight: 700;
89
+ margin-bottom: 4px;
90
+ }
91
+ .filerobot-Pixaforge-ImageCell-imageMeta {
92
+ display: flex;
93
+ align-items: center;
94
+ justify-content: space-between;
95
+ position: absolute;
96
+ width: 100%;
97
+ bottom: 0;
98
+
99
+ span {
100
+ font-size: 11px;
101
+ line-height: 12px;
102
+ text-align: center;
103
+ }
104
+ }
105
+ .filerobot-Pixaforge-LandscapesContainer {
106
+ display: flex;
107
+ flex-wrap: wrap;
108
+ }
109
+ .filerobot-Pixaforge-LandscapesContainer .filerobot-Pixaforge-ImageCell {
110
+ margin: 4px;
111
+ flex-grow: 1;
112
+ height: 160px;
113
+ max-height: 160px;
114
+
115
+ img {
116
+ max-height: 100%;
117
+ width: 100%;
118
+ object-fit: cover;
119
+ }
120
+ }
@@ -0,0 +1,102 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
+ import { useCallback, useState } from 'react';
8
+ import { useDispatch, useSelector } from 'react-redux';
9
+ import { LoaderView, PoweredBy } from '@scaleflex/widget-common';
10
+ import { usePlugin } from '@scaleflex/widget-core/lib/hooks';
11
+ import { PLUGINS_IDS } from '@scaleflex/widget-utils/lib/constants';
12
+ import { GALLERIES } from '../constants';
13
+ import TopBar from './TopBar';
14
+ import CategoriesCards from './CategoriesCards';
15
+ import ImagesGallery from './ImagesGallery';
16
+ import IconsGallery from './IconsGallery';
17
+ import CustomizeIcons from './CustomizeIcons';
18
+ import { galleryChanged, selectCustomizedIcons, selectGallery, selectIsLoading } from '../common.slice';
19
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
20
+ var MainView = function MainView(_ref) {
21
+ var _usePlugin;
22
+ var i18n = _ref.i18n,
23
+ listenToElementResize = _ref.listenToElementResize,
24
+ stopListeningToElementResize = _ref.stopListeningToElementResize,
25
+ info = _ref.info,
26
+ clearSelection = _ref.clearSelection;
27
+ var dispatch = useDispatch();
28
+ var gallery = useSelector(selectGallery);
29
+ var customizedIcons = useSelector(selectCustomizedIcons);
30
+ var isPluginLoading = useSelector(selectIsLoading);
31
+ var _useState = useState(null),
32
+ _useState2 = _slicedToArray(_useState, 2),
33
+ selectedCategory = _useState2[0],
34
+ setSelectedCategory = _useState2[1];
35
+ var _useState3 = useState(null),
36
+ _useState4 = _slicedToArray(_useState3, 2),
37
+ searchKeyword = _useState4[0],
38
+ setSearchKeyword = _useState4[1];
39
+ var _useState5 = useState(true),
40
+ _useState6 = _slicedToArray(_useState5, 2),
41
+ isLoading = _useState6[0],
42
+ setIsLoading = _useState6[1];
43
+ var _usePlugin$opts = (_usePlugin = usePlugin(PLUGINS_IDS.PIXAFORGE)) === null || _usePlugin === void 0 ? void 0 : _usePlugin.opts,
44
+ noIconsGallery = _usePlugin$opts.noIconsGallery;
45
+ var selectCategory = useCallback(function (newCategory) {
46
+ if (newCategory !== selectedCategory) {
47
+ setIsLoading(true);
48
+ setSelectedCategory(newCategory);
49
+ dispatch(galleryChanged(GALLERIES.IMAGES));
50
+ }
51
+ }, [selectedCategory]);
52
+ var updateSearchKeyword = useCallback(function (newSearchKeyword) {
53
+ if (newSearchKeyword !== searchKeyword) {
54
+ setSearchKeyword(newSearchKeyword);
55
+ }
56
+ }, [searchKeyword]);
57
+ var renderImagesGallery = function renderImagesGallery() {
58
+ return selectedCategory || searchKeyword ? /*#__PURE__*/_jsx(ImagesGallery, {
59
+ setIsLoading: setIsLoading,
60
+ category: selectedCategory,
61
+ searchKeyword: searchKeyword,
62
+ i18n: i18n,
63
+ listenToElementResize: listenToElementResize,
64
+ stopListeningToElementResize: stopListeningToElementResize,
65
+ resetSelectedCategory: function resetSelectedCategory() {
66
+ return selectCategory(null);
67
+ }
68
+ }) : /*#__PURE__*/_jsx(CategoriesCards, {
69
+ setIsLoading: setIsLoading,
70
+ selectCategory: selectCategory
71
+ });
72
+ };
73
+ var renderIconsGallery = function renderIconsGallery() {
74
+ return /*#__PURE__*/_jsx(IconsGallery, {
75
+ setIsLoading: setIsLoading,
76
+ searchKeyword: searchKeyword,
77
+ info: info,
78
+ i18n: i18n
79
+ });
80
+ };
81
+ return /*#__PURE__*/_jsxs("div", {
82
+ className: "filerobot-Pixaforge-MainView",
83
+ children: [(isLoading || isPluginLoading) && /*#__PURE__*/_jsx(LoaderView, {
84
+ loaderLabel: i18n('loaderLoadingLabel')
85
+ }), customizedIcons.length > 0 ? /*#__PURE__*/_jsx(CustomizeIcons, {
86
+ icons: customizedIcons,
87
+ i18n: i18n
88
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
89
+ children: [/*#__PURE__*/_jsx(TopBar, {
90
+ submitSearch: updateSearchKeyword,
91
+ currentGallery: gallery,
92
+ isPluginLoading: isLoading,
93
+ clearSelection: clearSelection,
94
+ i18n: i18n
95
+ }), !noIconsGallery && gallery === GALLERIES.ICONS ? renderIconsGallery() : renderImagesGallery()]
96
+ }), /*#__PURE__*/_jsx(PoweredBy, {
97
+ normalText: i18n('mutualizedPoweredByText'),
98
+ strongText: "Pixaforge"
99
+ })]
100
+ });
101
+ };
102
+ export default MainView;
@@ -0,0 +1,23 @@
1
+ import { useMemo } from 'react';
2
+ import { Tag } from '@scaleflex/ui/core';
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ var TagItem = function TagItem(_ref) {
5
+ var name = _ref.name,
6
+ _ref$currentTags = _ref.currentTags,
7
+ currentTags = _ref$currentTags === void 0 ? [] : _ref$currentTags,
8
+ _ref$onClick = _ref.onClick,
9
+ _onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick;
10
+ var isSelected = useMemo(function () {
11
+ return currentTags.includes(name);
12
+ }, [currentTags, name]);
13
+ return /*#__PURE__*/_jsx(Tag, {
14
+ onClick: function onClick() {
15
+ return _onClick(name, isSelected);
16
+ },
17
+ size: "md",
18
+ className: "filerobot-Pixaforge-TagItem",
19
+ type: isSelected ? 'default' : 'suggested',
20
+ children: name
21
+ });
22
+ };
23
+ export default TagItem;