@omniumretail/component-library 1.0.73 → 1.0.74
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/.storybook/main.js +16 -16
- package/.storybook/preview-head.html +20 -20
- package/.storybook/preview.js +27 -27
- package/NPMPUBLISH.md +29 -29
- package/README.md +54 -54
- package/bitbucket-pipelines.yml +94 -94
- package/dist/bundle.js +290 -246
- package/dist/main.css +5 -5
- package/dist/types/components/AnalyticsBar/AnalyticsBar.stories.d.ts +5 -5
- package/dist/types/components/AnalyticsBar/helpers/codeMutation.d.ts +4 -4
- package/dist/types/components/AnalyticsBar/index.d.ts +2 -2
- package/dist/types/components/AnalyticsBar/interfaces/analyticsBar.d.ts +12 -12
- package/dist/types/components/Button/Button.stories.d.ts +6 -6
- package/dist/types/components/Button/index.d.ts +7 -7
- package/dist/types/components/Category/Category.stories.d.ts +4 -4
- package/dist/types/components/Category/CategoryContent/index.d.ts +7 -7
- package/dist/types/components/Category/CategorySidebar/index.d.ts +26 -26
- package/dist/types/components/Category/index.d.ts +7 -7
- package/dist/types/components/CategoryReadOnly/CategoryReadOnly.stories.d.ts +4 -4
- package/dist/types/components/CategoryReadOnly/evaluationOptions.d.ts +10 -10
- package/dist/types/components/CategoryReadOnly/index.d.ts +9 -9
- package/dist/types/components/CategoryResponse/CategoryResponse.stories.d.ts +4 -4
- package/dist/types/components/CategoryResponse/evaluationOptions.d.ts +10 -10
- package/dist/types/components/CategoryResponse/index.d.ts +9 -9
- package/dist/types/components/DatePicker/DatePicker.stories.d.ts +5 -5
- package/dist/types/components/DatePicker/index.d.ts +8 -8
- package/dist/types/components/DatePickerTag/DatePickerTag.stories.d.ts +5 -5
- package/dist/types/components/DatePickerTag/index.d.ts +6 -6
- package/dist/types/components/Footer/Footer.stories.d.ts +5 -5
- package/dist/types/components/Footer/index.d.ts +4 -4
- package/dist/types/components/Input/Input.stories.d.ts +5 -5
- package/dist/types/components/Input/index.d.ts +10 -10
- package/dist/types/components/InputCountryCode/index.d.ts +10 -10
- package/dist/types/components/InputCountryCode/inputCountryCode.stories.d.ts +5 -5
- package/dist/types/components/Label/Label.stories.d.ts +6 -6
- package/dist/types/components/Label/index.d.ts +7 -7
- package/dist/types/components/Link/Link.stories.d.ts +7 -7
- package/dist/types/components/Link/index.d.ts +7 -7
- package/dist/types/components/Menu/Menu.stories.d.ts +5 -5
- package/dist/types/components/Menu/helpers/codeMutation.d.ts +4 -4
- package/dist/types/components/Menu/index.d.ts +2 -3
- package/dist/types/components/ModalConfirmation/ModalConfirmation.stories.d.ts +5 -5
- package/dist/types/components/ModalConfirmation/ModalStatusList.d.ts +5 -5
- package/dist/types/components/ModalConfirmation/index.d.ts +9 -9
- package/dist/types/components/ModalWithTable/ModalWithTable.stories.d.ts +5 -5
- package/dist/types/components/ModalWithTable/index.d.ts +13 -13
- package/dist/types/components/Navigation/Navigation.stories.d.ts +5 -5
- package/dist/types/components/Navigation/index.d.ts +10 -10
- package/dist/types/components/Notification/Notification.stories.d.ts +5 -5
- package/dist/types/components/Notification/index.d.ts +9 -9
- package/dist/types/components/Questions/Questions.stories.d.ts +4 -4
- package/dist/types/components/Questions/SingleQuestion/index.d.ts +1 -1
- package/dist/types/components/Questions/index.d.ts +5 -5
- package/dist/types/components/Radio/Radio.stories.d.ts +5 -5
- package/dist/types/components/Radio/index.d.ts +10 -10
- package/dist/types/components/Select/Select.stories.d.ts +6 -6
- package/dist/types/components/Select/index.d.ts +5 -5
- package/dist/types/components/Separator/Separator.stories.d.ts +6 -6
- package/dist/types/components/Separator/index.d.ts +11 -11
- package/dist/types/components/Sidebar/Sidebar.stories.d.ts +6 -6
- package/dist/types/components/Sidebar/index.d.ts +15 -15
- package/dist/types/components/Switch/Switch.stories.d.ts +5 -5
- package/dist/types/components/Switch/index.d.ts +2 -2
- package/dist/types/components/Table/Table.stories.d.ts +9 -9
- package/dist/types/components/Table/index.d.ts +37 -37
- package/dist/types/components/Tag/Tag.stories.d.ts +5 -5
- package/dist/types/components/Tag/index.d.ts +8 -8
- package/dist/types/components/Upload/Upload.stories.d.ts +4 -4
- package/dist/types/components/Upload/index.d.ts +8 -8
- package/dist/types/components/UserInfo/UserInfo.stories.d.ts +4 -4
- package/dist/types/components/UserInfo/index.d.ts +8 -8
- package/dist/types/components/index.d.ts +25 -25
- package/dist/types/constants/i18n.d.ts +1 -1
- package/dist/types/constants/translationHelper.d.ts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/package.json +198 -198
- package/src/assets/scss/_global.scss +89 -89
- package/src/assets/scss/index.scss +2 -2
- package/src/components/AnalyticsBar/AnalyticsBar.stories.tsx +236 -236
- package/src/components/AnalyticsBar/helpers/codeMutation.tsx +19 -19
- package/src/components/AnalyticsBar/index.tsx +76 -76
- package/src/components/AnalyticsBar/interfaces/analyticsBar.tsx +13 -13
- package/src/components/AnalyticsBar/styles.module.scss +108 -108
- package/src/components/Button/Button.stories.tsx +26 -26
- package/src/components/Button/index.tsx +24 -24
- package/src/components/Button/styles.module.scss +65 -65
- package/src/components/Category/Category.stories.tsx +88 -88
- package/src/components/Category/CategoryContent/index.tsx +188 -188
- package/src/components/Category/CategoryContent/styles.module.scss +51 -51
- package/src/components/Category/CategorySidebar/index.tsx +268 -268
- package/src/components/Category/CategorySidebar/styles.module.scss +28 -28
- package/src/components/Category/index.tsx +76 -76
- package/src/components/Category/styles.module.scss +13 -13
- package/src/components/CategoryReadOnly/CategoryReadOnly.stories.tsx +270 -270
- package/src/components/CategoryReadOnly/evaluationOptions.tsx +81 -81
- package/src/components/CategoryReadOnly/index.tsx +254 -254
- package/src/components/CategoryReadOnly/styles.module.scss +184 -184
- package/src/components/CategoryResponse/CategoryResponse.stories.tsx +251 -251
- package/src/components/CategoryResponse/evaluationOptions.tsx +81 -81
- package/src/components/CategoryResponse/index.tsx +277 -277
- package/src/components/CategoryResponse/styles.module.scss +180 -180
- package/src/components/DatePicker/DatePicker.stories.tsx +16 -16
- package/src/components/DatePicker/index.tsx +38 -38
- package/src/components/DatePicker/styles.module.scss +3 -3
- package/src/components/DatePickerTag/DatePickerTag.stories.tsx +19 -19
- package/src/components/DatePickerTag/index.tsx +89 -89
- package/src/components/DatePickerTag/styles.module.scss +31 -31
- package/src/components/Footer/Footer.stories.tsx +14 -14
- package/src/components/Footer/index.tsx +38 -38
- package/src/components/Footer/styles.module.scss +38 -38
- package/src/components/Input/Input.stories.tsx +13 -13
- package/src/components/Input/index.tsx +31 -31
- package/src/components/Input/styles.module.scss +8 -8
- package/src/components/InputCountryCode/index.tsx +75 -75
- package/src/components/InputCountryCode/inputCountryCode.stories.tsx +55 -55
- package/src/components/InputCountryCode/styles.module.scss +3 -3
- package/src/components/Label/Label.stories.tsx +21 -21
- package/src/components/Label/index.tsx +19 -19
- package/src/components/Label/styles.module.scss +16 -16
- package/src/components/Link/Link.stories.tsx +30 -30
- package/src/components/Link/index.tsx +21 -21
- package/src/components/Link/styles.module.scss +24 -24
- package/src/components/Menu/Menu.stories.tsx +178 -178
- package/src/components/Menu/helpers/codeMutation.tsx +19 -19
- package/src/components/Menu/index.tsx +23 -23
- package/src/components/ModalConfirmation/ModalConfirmation.stories.tsx +40 -40
- package/src/components/ModalConfirmation/ModalStatusList.tsx +5 -5
- package/src/components/ModalConfirmation/index.tsx +70 -70
- package/src/components/ModalConfirmation/styles.module.scss +62 -62
- package/src/components/ModalWithTable/ModalWithTable.stories.tsx +96 -96
- package/src/components/ModalWithTable/index.tsx +232 -232
- package/src/components/ModalWithTable/styles.module.scss +77 -77
- package/src/components/Navigation/Navigation.stories.tsx +17 -17
- package/src/components/Navigation/index.tsx +33 -33
- package/src/components/Navigation/styles.module.scss +59 -58
- package/src/components/Notification/Notification.stories.tsx +29 -29
- package/src/components/Notification/index.tsx +21 -21
- package/src/components/Questions/Questions.stories.tsx +37 -37
- package/src/components/Questions/SingleQuestion/index.tsx +84 -84
- package/src/components/Questions/SingleQuestion/styles.module.scss +81 -81
- package/src/components/Questions/index.tsx +78 -78
- package/src/components/Radio/Radio.stories.tsx +43 -43
- package/src/components/Radio/index.tsx +26 -26
- package/src/components/Radio/styles.module.scss +23 -23
- package/src/components/Select/Select.stories.tsx +39 -39
- package/src/components/Select/index.tsx +27 -27
- package/src/components/Select/styles.module.scss +13 -13
- package/src/components/Separator/Separator.stories.tsx +22 -22
- package/src/components/Separator/index.tsx +27 -27
- package/src/components/Separator/styles.module.scss +25 -25
- package/src/components/Sidebar/Sidebar.stories.tsx +85 -85
- package/src/components/Sidebar/index.tsx +103 -103
- package/src/components/Sidebar/styles.module.scss +85 -85
- package/src/components/Switch/Switch.stories.tsx +14 -14
- package/src/components/Switch/index.tsx +8 -8
- package/src/components/Switch/styles.module.scss +7 -7
- package/src/components/Table/Table.stories.tsx +222 -222
- package/src/components/Table/index.tsx +275 -275
- package/src/components/Table/styles.module.scss +75 -75
- package/src/components/Tag/Tag.stories.tsx +22 -22
- package/src/components/Tag/index.tsx +189 -189
- package/src/components/Tag/styles.module.scss +60 -60
- package/src/components/Upload/Upload.stories.tsx +45 -45
- package/src/components/Upload/index.tsx +91 -91
- package/src/components/UserInfo/UserInfo.stories.tsx +37 -37
- package/src/components/UserInfo/index.tsx +62 -62
- package/src/components/UserInfo/styles.module.scss +29 -29
- package/src/components/index.tsx +25 -25
- package/src/constants/i18n.ts +25 -25
- package/src/constants/translationHelper.ts +7 -7
- package/src/index.ts +2 -2
- package/src/locales/en.json +86 -86
- package/src/locales/es.json +86 -86
- package/src/locales/pt.json +86 -86
- package/src/types/Global.d.ts +4 -4
- package/tsconfig.json +29 -29
- package/webpack.config.js +51 -51
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
.tagfield {
|
|
2
|
-
contain: inline-size;
|
|
3
|
-
|
|
4
|
-
&__creator {
|
|
5
|
-
height: 50px;
|
|
6
|
-
display: flex;
|
|
7
|
-
align-items: center;
|
|
8
|
-
gap: 12px;
|
|
9
|
-
padding: 16px;
|
|
10
|
-
margin-inline-end: 0;
|
|
11
|
-
|
|
12
|
-
:global {
|
|
13
|
-
.ant-input {
|
|
14
|
-
height: 50px;
|
|
15
|
-
padding-left: 40px;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
&__input {
|
|
21
|
-
height: 50px;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
&__new {
|
|
25
|
-
:global {
|
|
26
|
-
.ant-tag {
|
|
27
|
-
background-color: var(--color-orange);
|
|
28
|
-
color: var(--color-white);
|
|
29
|
-
padding: 6px 16px;
|
|
30
|
-
max-width: 240px;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.anticon-close {
|
|
34
|
-
color: var(--color-white);
|
|
35
|
-
font-size: 12px;
|
|
36
|
-
|
|
37
|
-
&:hover {
|
|
38
|
-
color: var(--color-black);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.advancedTagsWrapper {
|
|
45
|
-
display: flex;
|
|
46
|
-
gap: 12px;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.advancedTags {
|
|
50
|
-
display: flex;
|
|
51
|
-
flex-direction: row;
|
|
52
|
-
gap: 12px;
|
|
53
|
-
font-family: "SilkaBold";
|
|
54
|
-
text-decoration: underline;
|
|
55
|
-
|
|
56
|
-
div {
|
|
57
|
-
cursor: pointer;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
1
|
+
.tagfield {
|
|
2
|
+
contain: inline-size;
|
|
3
|
+
|
|
4
|
+
&__creator {
|
|
5
|
+
height: 50px;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
gap: 12px;
|
|
9
|
+
padding: 16px;
|
|
10
|
+
margin-inline-end: 0;
|
|
11
|
+
|
|
12
|
+
:global {
|
|
13
|
+
.ant-input {
|
|
14
|
+
height: 50px;
|
|
15
|
+
padding-left: 40px;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&__input {
|
|
21
|
+
height: 50px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&__new {
|
|
25
|
+
:global {
|
|
26
|
+
.ant-tag {
|
|
27
|
+
background-color: var(--color-orange);
|
|
28
|
+
color: var(--color-white);
|
|
29
|
+
padding: 6px 16px;
|
|
30
|
+
max-width: 240px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.anticon-close {
|
|
34
|
+
color: var(--color-white);
|
|
35
|
+
font-size: 12px;
|
|
36
|
+
|
|
37
|
+
&:hover {
|
|
38
|
+
color: var(--color-black);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.advancedTagsWrapper {
|
|
45
|
+
display: flex;
|
|
46
|
+
gap: 12px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.advancedTags {
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-direction: row;
|
|
52
|
+
gap: 12px;
|
|
53
|
+
font-family: "SilkaBold";
|
|
54
|
+
text-decoration: underline;
|
|
55
|
+
|
|
56
|
+
div {
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { Meta, Story } from "@storybook/react";
|
|
2
|
-
import { Form, UploadFile } from "antd";
|
|
3
|
-
import { Button } from "components/Button";
|
|
4
|
-
import { Upload } from '.';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Upload',
|
|
8
|
-
component: Upload,
|
|
9
|
-
} as Meta;
|
|
10
|
-
|
|
11
|
-
const Template: Story<any> = (args) => {
|
|
12
|
-
const [form] = Form.useForm();
|
|
13
|
-
|
|
14
|
-
const handleSubmit = (values: any) => {
|
|
15
|
-
console.log('Form values:', values);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const handleImageChange = (file: UploadFile | null) => {
|
|
19
|
-
form.setFieldsValue({ image: file?.originFileObj });
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const initialValue = {
|
|
23
|
-
uid: '-1',
|
|
24
|
-
name: 'image.png',
|
|
25
|
-
status: 'done',
|
|
26
|
-
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
27
|
-
}
|
|
28
|
-
return (
|
|
29
|
-
<Form form={form} onFinish={handleSubmit}>
|
|
30
|
-
<Form.Item name="image" valuePropName="file" initialValue={initialValue}>
|
|
31
|
-
<Upload {...args} onImageChange={handleImageChange} initialFileList={[initialValue]}></Upload>
|
|
32
|
-
</Form.Item>
|
|
33
|
-
<Form.Item>
|
|
34
|
-
<Button type="primary" htmlType="submit">
|
|
35
|
-
Submit
|
|
36
|
-
</Button>
|
|
37
|
-
</Form.Item>
|
|
38
|
-
</Form>
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export const Primary = Template.bind({});
|
|
44
|
-
Primary.args = {
|
|
45
|
-
};
|
|
1
|
+
import { Meta, Story } from "@storybook/react";
|
|
2
|
+
import { Form, UploadFile } from "antd";
|
|
3
|
+
import { Button } from "components/Button";
|
|
4
|
+
import { Upload } from '.';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Upload',
|
|
8
|
+
component: Upload,
|
|
9
|
+
} as Meta;
|
|
10
|
+
|
|
11
|
+
const Template: Story<any> = (args) => {
|
|
12
|
+
const [form] = Form.useForm();
|
|
13
|
+
|
|
14
|
+
const handleSubmit = (values: any) => {
|
|
15
|
+
console.log('Form values:', values);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const handleImageChange = (file: UploadFile | null) => {
|
|
19
|
+
form.setFieldsValue({ image: file?.originFileObj });
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const initialValue = {
|
|
23
|
+
uid: '-1',
|
|
24
|
+
name: 'image.png',
|
|
25
|
+
status: 'done',
|
|
26
|
+
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
27
|
+
}
|
|
28
|
+
return (
|
|
29
|
+
<Form form={form} onFinish={handleSubmit}>
|
|
30
|
+
<Form.Item name="image" valuePropName="file" initialValue={initialValue}>
|
|
31
|
+
<Upload {...args} onImageChange={handleImageChange} initialFileList={[initialValue]}></Upload>
|
|
32
|
+
</Form.Item>
|
|
33
|
+
<Form.Item>
|
|
34
|
+
<Button type="primary" htmlType="submit">
|
|
35
|
+
Submit
|
|
36
|
+
</Button>
|
|
37
|
+
</Form.Item>
|
|
38
|
+
</Form>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
export const Primary = Template.bind({});
|
|
44
|
+
Primary.args = {
|
|
45
|
+
};
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
import { Upload as UploadAntd } from 'antd';
|
|
2
|
-
import ImgCrop from 'antd-img-crop';
|
|
3
|
-
import type { RcFile, UploadFile, UploadProps } from 'antd/es/upload/interface';
|
|
4
|
-
import { useEffect, useState } from 'react';
|
|
5
|
-
|
|
6
|
-
interface UploadPropsExtended extends UploadProps {
|
|
7
|
-
onImageChange?: (file: UploadFile | null) => void;
|
|
8
|
-
initialFileList?: UploadFile[];
|
|
9
|
-
initialImageUrl?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function generateRandomString() {
|
|
13
|
-
return Math.random().toString(36).substring(2, 14);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const Upload = (props: UploadPropsExtended) => {
|
|
17
|
-
const {
|
|
18
|
-
onImageChange,
|
|
19
|
-
initialFileList,
|
|
20
|
-
initialImageUrl
|
|
21
|
-
} = props;
|
|
22
|
-
const [fileList, setFileList] = useState<UploadFile[]>(initialFileList || []);
|
|
23
|
-
|
|
24
|
-
// when component mounts or initialImageUrl changes, update fileList
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
if (initialImageUrl) {
|
|
27
|
-
const newFile: UploadFile = {
|
|
28
|
-
uid: generateRandomString(), // use any unique string
|
|
29
|
-
name: initialImageUrl, // use the URL as the name
|
|
30
|
-
status: 'done',
|
|
31
|
-
url: initialImageUrl, // this is used for preview
|
|
32
|
-
};
|
|
33
|
-
setFileList((prevFileList) => [...prevFileList, newFile]);
|
|
34
|
-
}
|
|
35
|
-
}, [initialImageUrl]);
|
|
36
|
-
|
|
37
|
-
const beforeUpload: UploadProps['beforeUpload'] = async (file: RcFile) => {
|
|
38
|
-
const newFile: UploadFile = {
|
|
39
|
-
uid: file.uid,
|
|
40
|
-
name: file.name,
|
|
41
|
-
type: file.type,
|
|
42
|
-
size: file.size,
|
|
43
|
-
originFileObj: file,
|
|
44
|
-
status: 'done',
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
setFileList((prevFileList) => [...prevFileList, newFile]);
|
|
48
|
-
if (onImageChange) {
|
|
49
|
-
onImageChange(newFile);
|
|
50
|
-
}
|
|
51
|
-
return false;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const onChange: UploadProps['onChange'] = ({ file, fileList: newFileList }) => {
|
|
55
|
-
if (file.status === 'removed') {
|
|
56
|
-
setFileList(newFileList);
|
|
57
|
-
if (onImageChange) {
|
|
58
|
-
onImageChange(newFileList[0] || null);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const onPreview = async (file: UploadFile) => {
|
|
64
|
-
let src = file.url as string;
|
|
65
|
-
if (!src) {
|
|
66
|
-
src = await new Promise((resolve) => {
|
|
67
|
-
const reader = new FileReader();
|
|
68
|
-
reader.readAsDataURL(file.originFileObj as RcFile);
|
|
69
|
-
reader.onload = () => resolve(reader.result as string);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
const image = new Image();
|
|
73
|
-
image.src = src;
|
|
74
|
-
const imgWindow = window.open(src);
|
|
75
|
-
imgWindow?.document.write(image.outerHTML);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<ImgCrop rotationSlider>
|
|
80
|
-
<UploadAntd
|
|
81
|
-
listType="picture-card"
|
|
82
|
-
fileList={fileList}
|
|
83
|
-
beforeUpload={beforeUpload}
|
|
84
|
-
onChange={onChange}
|
|
85
|
-
onPreview={onPreview}
|
|
86
|
-
>
|
|
87
|
-
{fileList.length < 1 && '+ Upload'}
|
|
88
|
-
</UploadAntd>
|
|
89
|
-
</ImgCrop>
|
|
90
|
-
);
|
|
91
|
-
};
|
|
1
|
+
import { Upload as UploadAntd } from 'antd';
|
|
2
|
+
import ImgCrop from 'antd-img-crop';
|
|
3
|
+
import type { RcFile, UploadFile, UploadProps } from 'antd/es/upload/interface';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
interface UploadPropsExtended extends UploadProps {
|
|
7
|
+
onImageChange?: (file: UploadFile | null) => void;
|
|
8
|
+
initialFileList?: UploadFile[];
|
|
9
|
+
initialImageUrl?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function generateRandomString() {
|
|
13
|
+
return Math.random().toString(36).substring(2, 14);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const Upload = (props: UploadPropsExtended) => {
|
|
17
|
+
const {
|
|
18
|
+
onImageChange,
|
|
19
|
+
initialFileList,
|
|
20
|
+
initialImageUrl
|
|
21
|
+
} = props;
|
|
22
|
+
const [fileList, setFileList] = useState<UploadFile[]>(initialFileList || []);
|
|
23
|
+
|
|
24
|
+
// when component mounts or initialImageUrl changes, update fileList
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (initialImageUrl) {
|
|
27
|
+
const newFile: UploadFile = {
|
|
28
|
+
uid: generateRandomString(), // use any unique string
|
|
29
|
+
name: initialImageUrl, // use the URL as the name
|
|
30
|
+
status: 'done',
|
|
31
|
+
url: initialImageUrl, // this is used for preview
|
|
32
|
+
};
|
|
33
|
+
setFileList((prevFileList) => [...prevFileList, newFile]);
|
|
34
|
+
}
|
|
35
|
+
}, [initialImageUrl]);
|
|
36
|
+
|
|
37
|
+
const beforeUpload: UploadProps['beforeUpload'] = async (file: RcFile) => {
|
|
38
|
+
const newFile: UploadFile = {
|
|
39
|
+
uid: file.uid,
|
|
40
|
+
name: file.name,
|
|
41
|
+
type: file.type,
|
|
42
|
+
size: file.size,
|
|
43
|
+
originFileObj: file,
|
|
44
|
+
status: 'done',
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
setFileList((prevFileList) => [...prevFileList, newFile]);
|
|
48
|
+
if (onImageChange) {
|
|
49
|
+
onImageChange(newFile);
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const onChange: UploadProps['onChange'] = ({ file, fileList: newFileList }) => {
|
|
55
|
+
if (file.status === 'removed') {
|
|
56
|
+
setFileList(newFileList);
|
|
57
|
+
if (onImageChange) {
|
|
58
|
+
onImageChange(newFileList[0] || null);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const onPreview = async (file: UploadFile) => {
|
|
64
|
+
let src = file.url as string;
|
|
65
|
+
if (!src) {
|
|
66
|
+
src = await new Promise((resolve) => {
|
|
67
|
+
const reader = new FileReader();
|
|
68
|
+
reader.readAsDataURL(file.originFileObj as RcFile);
|
|
69
|
+
reader.onload = () => resolve(reader.result as string);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const image = new Image();
|
|
73
|
+
image.src = src;
|
|
74
|
+
const imgWindow = window.open(src);
|
|
75
|
+
imgWindow?.document.write(image.outerHTML);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<ImgCrop rotationSlider>
|
|
80
|
+
<UploadAntd
|
|
81
|
+
listType="picture-card"
|
|
82
|
+
fileList={fileList}
|
|
83
|
+
beforeUpload={beforeUpload}
|
|
84
|
+
onChange={onChange}
|
|
85
|
+
onPreview={onPreview}
|
|
86
|
+
>
|
|
87
|
+
{fileList.length < 1 && '+ Upload'}
|
|
88
|
+
</UploadAntd>
|
|
89
|
+
</ImgCrop>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { Meta, Story } from "@storybook/react";
|
|
2
|
-
import { UserInfo } from '.';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
title: 'UserInfo',
|
|
6
|
-
component: UserInfo,
|
|
7
|
-
} as Meta;
|
|
8
|
-
|
|
9
|
-
const Template: Story<any> = (args) => {
|
|
10
|
-
|
|
11
|
-
const data = {
|
|
12
|
-
Date: "946080000",
|
|
13
|
-
"Store": [
|
|
14
|
-
"ola",
|
|
15
|
-
"adeus"
|
|
16
|
-
],
|
|
17
|
-
"Team": "Delivery Team",
|
|
18
|
-
"Supervisor": "Jane Dõe Lórd Rings",
|
|
19
|
-
"TypeOfContract": "Omnium.APE.Services.API.Models.Users.ContractStateDto",
|
|
20
|
-
"Nationality": "PT",
|
|
21
|
-
"CivilStatus": "single",
|
|
22
|
-
"IdentificationDocument": "55613145664",
|
|
23
|
-
"NTaxpayer": "14244",
|
|
24
|
-
"NIB": "12312331",
|
|
25
|
-
"SocialSecurity": "123123132",
|
|
26
|
-
"NChildren": "2",
|
|
27
|
-
"Workload": "2 horas",
|
|
28
|
-
"Description": "One Desccription",
|
|
29
|
-
"Comments": "One CommentsdwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwOne CommentsdwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwOne CommentsdwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwOne CommentsdwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwOne CommentsdwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwOne CommentsdwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwOne Commentsdwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
return <UserInfo {...args} userData={data} userName={ "Diogo Carvalho" } userCode={ "121212" } userInfoTranslationsKey={'userInfoColumn'}></UserInfo>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const Primary = Template.bind({});
|
|
36
|
-
Primary.args = {
|
|
37
|
-
};
|
|
1
|
+
import { Meta, Story } from "@storybook/react";
|
|
2
|
+
import { UserInfo } from '.';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'UserInfo',
|
|
6
|
+
component: UserInfo,
|
|
7
|
+
} as Meta;
|
|
8
|
+
|
|
9
|
+
const Template: Story<any> = (args) => {
|
|
10
|
+
|
|
11
|
+
const data = {
|
|
12
|
+
Date: "946080000",
|
|
13
|
+
"Store": [
|
|
14
|
+
"ola",
|
|
15
|
+
"adeus"
|
|
16
|
+
],
|
|
17
|
+
"Team": "Delivery Team",
|
|
18
|
+
"Supervisor": "Jane Dõe Lórd Rings",
|
|
19
|
+
"TypeOfContract": "Omnium.APE.Services.API.Models.Users.ContractStateDto",
|
|
20
|
+
"Nationality": "PT",
|
|
21
|
+
"CivilStatus": "single",
|
|
22
|
+
"IdentificationDocument": "55613145664",
|
|
23
|
+
"NTaxpayer": "14244",
|
|
24
|
+
"NIB": "12312331",
|
|
25
|
+
"SocialSecurity": "123123132",
|
|
26
|
+
"NChildren": "2",
|
|
27
|
+
"Workload": "2 horas",
|
|
28
|
+
"Description": "One Desccription",
|
|
29
|
+
"Comments": "One CommentsdwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwOne CommentsdwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwOne CommentsdwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwOne CommentsdwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwOne CommentsdwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwOne CommentsdwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwOne Commentsdwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww"
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return <UserInfo {...args} userData={data} userName={ "Diogo Carvalho" } userCode={ "121212" } userInfoTranslationsKey={'userInfoColumn'}></UserInfo>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const Primary = Template.bind({});
|
|
36
|
+
Primary.args = {
|
|
37
|
+
};
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import styles from './styles.module.scss';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import { Label } from '../Label';
|
|
5
|
-
import { useTranslation } from 'react-i18next';
|
|
6
|
-
|
|
7
|
-
export interface UserInfoProps {
|
|
8
|
-
userData: any;
|
|
9
|
-
userName: string;
|
|
10
|
-
userCode: string;
|
|
11
|
-
userInfoTranslationsKey?: string;
|
|
12
|
-
customClass?: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const UserInfo = ({ userData, customClass, userName, userCode, userInfoTranslationsKey }: UserInfoProps) => {
|
|
16
|
-
const { t } = useTranslation();
|
|
17
|
-
|
|
18
|
-
const userInfoStyle = classNames({
|
|
19
|
-
[`${customClass}`]: customClass,
|
|
20
|
-
}, [styles.userInfo]);
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<div className={userInfoStyle}>
|
|
24
|
-
<Label customStyle={styles.userName}>
|
|
25
|
-
{userName}
|
|
26
|
-
</Label>
|
|
27
|
-
|
|
28
|
-
<h3 className={styles.userCode}>
|
|
29
|
-
{userCode}
|
|
30
|
-
</h3>
|
|
31
|
-
|
|
32
|
-
{Object.entries(userData)?.map(([key, value]: any) => {
|
|
33
|
-
if (key === 'Store') {
|
|
34
|
-
return (
|
|
35
|
-
<div key={key}>
|
|
36
|
-
<h3 className={styles.userInfoTitles}>
|
|
37
|
-
{userInfoTranslationsKey ? t(`${userInfoTranslationsKey}.${key}`) : key}
|
|
38
|
-
</h3>
|
|
39
|
-
{value?.map((store: string, index: number) => (
|
|
40
|
-
<h3 key={`${key}-${index}`} className={styles.userInfoDesc}>
|
|
41
|
-
{store}
|
|
42
|
-
</h3>
|
|
43
|
-
))}
|
|
44
|
-
</div>
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<div key={key}>
|
|
50
|
-
<h3 className={styles.userInfoTitles}>
|
|
51
|
-
{userInfoTranslationsKey ? t(`${userInfoTranslationsKey}.${key}`) : key}
|
|
52
|
-
</h3>
|
|
53
|
-
|
|
54
|
-
<h3 className={styles.userInfoDesc}>
|
|
55
|
-
{value as string}
|
|
56
|
-
</h3>
|
|
57
|
-
</div>
|
|
58
|
-
);
|
|
59
|
-
})}
|
|
60
|
-
</div>
|
|
61
|
-
);
|
|
62
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styles from './styles.module.scss';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { Label } from '../Label';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
|
|
7
|
+
export interface UserInfoProps {
|
|
8
|
+
userData: any;
|
|
9
|
+
userName: string;
|
|
10
|
+
userCode: string;
|
|
11
|
+
userInfoTranslationsKey?: string;
|
|
12
|
+
customClass?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const UserInfo = ({ userData, customClass, userName, userCode, userInfoTranslationsKey }: UserInfoProps) => {
|
|
16
|
+
const { t } = useTranslation();
|
|
17
|
+
|
|
18
|
+
const userInfoStyle = classNames({
|
|
19
|
+
[`${customClass}`]: customClass,
|
|
20
|
+
}, [styles.userInfo]);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div className={userInfoStyle}>
|
|
24
|
+
<Label customStyle={styles.userName}>
|
|
25
|
+
{userName}
|
|
26
|
+
</Label>
|
|
27
|
+
|
|
28
|
+
<h3 className={styles.userCode}>
|
|
29
|
+
{userCode}
|
|
30
|
+
</h3>
|
|
31
|
+
|
|
32
|
+
{Object.entries(userData)?.map(([key, value]: any) => {
|
|
33
|
+
if (key === 'Store') {
|
|
34
|
+
return (
|
|
35
|
+
<div key={key}>
|
|
36
|
+
<h3 className={styles.userInfoTitles}>
|
|
37
|
+
{userInfoTranslationsKey ? t(`${userInfoTranslationsKey}.${key}`) : key}
|
|
38
|
+
</h3>
|
|
39
|
+
{value?.map((store: string, index: number) => (
|
|
40
|
+
<h3 key={`${key}-${index}`} className={styles.userInfoDesc}>
|
|
41
|
+
{store}
|
|
42
|
+
</h3>
|
|
43
|
+
))}
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div key={key}>
|
|
50
|
+
<h3 className={styles.userInfoTitles}>
|
|
51
|
+
{userInfoTranslationsKey ? t(`${userInfoTranslationsKey}.${key}`) : key}
|
|
52
|
+
</h3>
|
|
53
|
+
|
|
54
|
+
<h3 className={styles.userInfoDesc}>
|
|
55
|
+
{value as string}
|
|
56
|
+
</h3>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
})}
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
.userInfo {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
background-color: var(--white-color);
|
|
5
|
-
padding: 24px;
|
|
6
|
-
color: var(--color-black);
|
|
7
|
-
width: 150px;
|
|
8
|
-
word-wrap: break-word;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.userName {
|
|
12
|
-
color: var(--color-blue) !important;
|
|
13
|
-
font-size: var(--font-size-body-5);
|
|
14
|
-
font-weight: var(--font-weight-bold);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.userCode {
|
|
18
|
-
font-weight: var(--font-weight-semibold);
|
|
19
|
-
font-size: var(--font-size-label);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.userInfoTitles {
|
|
23
|
-
font-weight: var(--font-weight-bold);
|
|
24
|
-
font-size: var(--font-size-body-base);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.userInfoDesc {
|
|
28
|
-
font-weight: var(--font-weight-regular);
|
|
29
|
-
font-size: var(--font-size-label);
|
|
1
|
+
.userInfo {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
background-color: var(--white-color);
|
|
5
|
+
padding: 24px;
|
|
6
|
+
color: var(--color-black);
|
|
7
|
+
width: 150px;
|
|
8
|
+
word-wrap: break-word;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.userName {
|
|
12
|
+
color: var(--color-blue) !important;
|
|
13
|
+
font-size: var(--font-size-body-5);
|
|
14
|
+
font-weight: var(--font-weight-bold);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.userCode {
|
|
18
|
+
font-weight: var(--font-weight-semibold);
|
|
19
|
+
font-size: var(--font-size-label);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.userInfoTitles {
|
|
23
|
+
font-weight: var(--font-weight-bold);
|
|
24
|
+
font-size: var(--font-size-body-base);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.userInfoDesc {
|
|
28
|
+
font-weight: var(--font-weight-regular);
|
|
29
|
+
font-size: var(--font-size-label);
|
|
30
30
|
}
|