@mailstep/design-system 0.6.80-beta.1 → 0.6.80-beta.2
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/package.json +1 -1
- package/ui/Blocks/ImageList/ImageList.js +4 -2
- package/ui/Blocks/ImageList/components/ImageElement/index.d.ts +1 -0
- package/ui/Blocks/ImageList/components/ImageElement/index.js +4 -5
- package/ui/Blocks/ImageList/components/ImageElement/styles.d.ts +4 -1
- package/ui/Blocks/ImageList/components/ImageElement/styles.js +8 -3
- package/ui/Blocks/ImageList/hooks/useOnElementClick.d.ts +12 -0
- package/ui/Blocks/ImageList/hooks/useOnElementClick.js +20 -0
- package/ui/Blocks/ImageList/stories/ImageList.stories.d.ts +1 -0
- package/ui/Blocks/ImageList/stories/ImageList.stories.js +7 -1
- package/ui/Blocks/ImageList/types.d.ts +2 -1
- package/ui/Elements/Text/types.d.ts +1 -0
- package/ui/index.es.js +7069 -7030
- package/ui/index.umd.js +394 -385
package/package.json
CHANGED
|
@@ -15,15 +15,17 @@ import { useDraggable } from 'react-use-draggable-scroll';
|
|
|
15
15
|
import LightBox, { useLightBox } from '../LightBox';
|
|
16
16
|
import { AddPhoto } from './components/AddPhoto';
|
|
17
17
|
import { ImageElement } from './components/ImageElement';
|
|
18
|
+
import { useOnElementClick } from './hooks/useOnElementClick';
|
|
18
19
|
import { x } from '@xstyled/styled-components';
|
|
19
20
|
import { ImageListContainer } from './styles';
|
|
20
21
|
export var ImageList = function (_a) {
|
|
21
|
-
var onImageUpload = _a.onImageUpload, onImageRemove = _a.onImageRemove, onImageClick = _a.onImageClick, lightBoxAction = _a.lightBoxAction, lightBoxActionTitle = _a.lightBoxActionTitle, images = _a.images, isDisabled = _a.isDisabled;
|
|
22
|
+
var onImageUpload = _a.onImageUpload, onImageRemove = _a.onImageRemove, onImageClick = _a.onImageClick, lightBoxAction = _a.lightBoxAction, lightBoxActionTitle = _a.lightBoxActionTitle, images = _a.images, isDisabled = _a.isDisabled, selectable = _a.selectable;
|
|
22
23
|
var ref = useRef();
|
|
23
24
|
var events = useDraggable(ref, { isMounted: !!(images === null || images === void 0 ? void 0 : images.length) }).events;
|
|
24
25
|
var _b = useLightBox(), isLightBoxOpen = _b.isLightBoxOpen, onCloseLightBox = _b.onCloseLightBox, onOpenLightBox = _b.onOpenLightBox, lightBoxData = _b.lightBoxData;
|
|
26
|
+
var _c = useOnElementClick({ onImageClick: onImageClick, onOpenLightBox: onOpenLightBox, selectable: selectable }), handleOnClick = _c.handleOnClick, selected = _c.selected;
|
|
25
27
|
return (_jsxs(x.div, { display: "flex", alignItems: "flex-end", children: [_jsx(AddPhoto, { onImageUpload: onImageUpload, isDisabled: isDisabled }), images && (_jsx(ImageListContainer, __assign({ ref: ref }, events, { children: images.map(function (item, index) {
|
|
26
28
|
var _a, _b;
|
|
27
|
-
return (_jsx(ImageElement, { imageUrl: (_a = item.smallUrl) !== null && _a !== void 0 ? _a : item.url, onImageRemove: onImageRemove === null || onImageRemove === void 0 ? void 0 : onImageRemove(item.id), onClick:
|
|
29
|
+
return (_jsx(ImageElement, { imageUrl: (_a = item.smallUrl) !== null && _a !== void 0 ? _a : item.url, onImageRemove: onImageRemove === null || onImageRemove === void 0 ? void 0 : onImageRemove(item.id), onClick: handleOnClick(item, index), isDisabled: isDisabled, label: item === null || item === void 0 ? void 0 : item.label, selected: index === selected }, (_b = item.id) !== null && _b !== void 0 ? _b : index));
|
|
28
30
|
}) }))), _jsx(LightBox, { initialSlide: lightBoxData === null || lightBoxData === void 0 ? void 0 : lightBoxData.initialSlide, isLightBoxOpen: isLightBoxOpen, onCloseLightBox: onCloseLightBox, lightBoxAction: lightBoxAction, lightBoxActionTitle: lightBoxActionTitle, images: images })] }));
|
|
29
31
|
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Image } from './styles';
|
|
3
|
-
import { ImageTag } from '../ImageTag';
|
|
4
2
|
import { CloseButton } from '../CloseButton';
|
|
5
|
-
import {
|
|
3
|
+
import { ImageTag } from '../ImageTag';
|
|
4
|
+
import { Image, ImageWrapper } from './styles';
|
|
6
5
|
export var ImageElement = function (_a) {
|
|
7
|
-
var label = _a.label, onImageRemove = _a.onImageRemove, isDisabled = _a.isDisabled, onClick = _a.onClick, imageUrl = _a.imageUrl;
|
|
6
|
+
var label = _a.label, onImageRemove = _a.onImageRemove, isDisabled = _a.isDisabled, onClick = _a.onClick, imageUrl = _a.imageUrl, selected = _a.selected;
|
|
8
7
|
if (!imageUrl)
|
|
9
8
|
return null;
|
|
10
|
-
return (_jsxs(
|
|
9
|
+
return (_jsxs(ImageWrapper, { children: [_jsx(Image, { src: imageUrl, alt: "", width: "85px", height: "85px", onClick: onClick, selected: selected }), onImageRemove && _jsx(CloseButton, { onImageRemove: onImageRemove, isDisabled: isDisabled }), _jsx(ImageTag, { label: label })] }));
|
|
11
10
|
};
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export declare const Container: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
|
|
2
|
-
export declare const Image: import("styled-components").StyledComponent<"img", import("@xstyled/system").Theme, {
|
|
2
|
+
export declare const Image: import("styled-components").StyledComponent<"img", import("@xstyled/system").Theme, {
|
|
3
|
+
selected?: boolean | undefined;
|
|
4
|
+
}, never>;
|
|
5
|
+
export declare const ImageWrapper: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
|
|
@@ -2,7 +2,12 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
2
2
|
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
3
|
return cooked;
|
|
4
4
|
};
|
|
5
|
-
import styled
|
|
5
|
+
import styled from '@xstyled/styled-components';
|
|
6
|
+
import { th } from '@xstyled/system';
|
|
6
7
|
export var Container = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject([""], [""])));
|
|
7
|
-
export var Image = styled.img(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n border-radius: ", ";\n"], ["\n border-radius: ", ";\n"])), th.radius('lg'))
|
|
8
|
-
var
|
|
8
|
+
export var Image = styled.img(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n border-radius: ", ";\n border: ", ";\n border-color: red1;\n cursor: pointer;\n"], ["\n border-radius: ", ";\n border: ", ";\n border-color: red1;\n cursor: pointer;\n"])), th.radius('lg'), function (_a) {
|
|
9
|
+
var selected = _a.selected;
|
|
10
|
+
return (selected ? "3px solid" : '0');
|
|
11
|
+
});
|
|
12
|
+
export var ImageWrapper = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: relative;\n padding-right: 15px;\n padding-top: 15px;\n width: 100px;\n height: 100px;\n"], ["\n position: relative;\n padding-right: 15px;\n padding-top: 15px;\n width: 100px;\n height: 100px;\n"])));
|
|
13
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ImageData } from '../../LightBox';
|
|
2
|
+
type Props = {
|
|
3
|
+
onImageClick?: (item: ImageData) => void;
|
|
4
|
+
onOpenLightBox: (index: number) => void;
|
|
5
|
+
selectable?: boolean;
|
|
6
|
+
};
|
|
7
|
+
type HookType = (props: Props) => {
|
|
8
|
+
handleOnClick: (item: ImageData, index: number) => () => void;
|
|
9
|
+
selected: number;
|
|
10
|
+
};
|
|
11
|
+
export declare const useOnElementClick: HookType;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
export var useOnElementClick = function (_a) {
|
|
3
|
+
var onImageClick = _a.onImageClick, onOpenLightBox = _a.onOpenLightBox, selectable = _a.selectable;
|
|
4
|
+
var _b = useState(-1), selected = _b[0], setSelected = _b[1];
|
|
5
|
+
var handleOnClick = useCallback(function (item, index) { return function () {
|
|
6
|
+
if (onImageClick) {
|
|
7
|
+
onImageClick(item);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
onOpenLightBox(index);
|
|
11
|
+
}
|
|
12
|
+
if (selectable) {
|
|
13
|
+
setSelected(index);
|
|
14
|
+
}
|
|
15
|
+
}; }, [onImageClick, onOpenLightBox]);
|
|
16
|
+
return {
|
|
17
|
+
handleOnClick: handleOnClick,
|
|
18
|
+
selected: selected
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -19,7 +19,7 @@ var meta = {
|
|
|
19
19
|
export default meta;
|
|
20
20
|
var images = [
|
|
21
21
|
{ id: '1', smallUrl: 'https://picsum.photos/200/300', url: 'https://picsum.photos/400/400' },
|
|
22
|
-
{ id: '
|
|
22
|
+
{ id: '2', smallUrl: 'https://picsum.photos/200/300', url: 'https://picsum.photos/400/400' },
|
|
23
23
|
];
|
|
24
24
|
export var ImageListDefault = {
|
|
25
25
|
args: {
|
|
@@ -39,3 +39,9 @@ export var ImageListWithItemDescription = {
|
|
|
39
39
|
images: images.map(function (img) { return (__assign(__assign({}, img), { label: 'Lorem Ipsum', date: '24.12.2024', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur explicabo harum' })); }),
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
|
+
export var ImageListSelectable = {
|
|
43
|
+
args: {
|
|
44
|
+
images: images,
|
|
45
|
+
selectable: true,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -8,8 +8,9 @@ export interface ImageListProps {
|
|
|
8
8
|
images: ImageData[] | undefined;
|
|
9
9
|
onImageUpload?: (props: ImageUploadProps) => Promise<void>;
|
|
10
10
|
onImageRemove?: (id?: string) => () => void;
|
|
11
|
-
onImageClick?: (item
|
|
11
|
+
onImageClick?: (item: ImageData) => void;
|
|
12
12
|
lightBoxAction?: (id?: string) => () => Promise<void>;
|
|
13
13
|
lightBoxActionTitle?: string;
|
|
14
14
|
isDisabled?: boolean;
|
|
15
|
+
selectable?: boolean;
|
|
15
16
|
}
|