@omniumretail/component-library 1.2.71 → 1.2.73
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 +6 -3
- package/NPMPUBLISH.md +0 -29
- package/bitbucket-pipelines.yml +0 -95
- package/dist/components/AnalyticsBar/AnalyticsBar.stories.d.ts +0 -5
- package/dist/components/BellNotifications/BellNotifications.stories.d.ts +0 -5
- package/dist/components/Button/Button.stories.d.ts +0 -6
- package/dist/components/Category/Category.stories.d.ts +0 -3
- package/dist/components/CategoryReadOnly/CategoryReadOnly.stories.d.ts +0 -3
- package/dist/components/CategoryResponse/CategoryResponse.stories.d.ts +0 -3
- package/dist/components/DatePicker/DatePicker.stories.d.ts +0 -5
- package/dist/components/DatePickerTag/DatePickerTag.stories.d.ts +0 -5
- package/dist/components/DropdownButton/DropdownButton.stories.d.ts +0 -5
- package/dist/components/ExportTableData/ExportTableData.stories.d.ts +0 -3
- package/dist/components/Footer/Footer.stories.d.ts +0 -5
- package/dist/components/Footer2/Footer.stories.d.ts +0 -6
- package/dist/components/Header/Header.stories.d.ts +0 -5
- package/dist/components/Input/Input.stories.d.ts +0 -5
- package/dist/components/InputCountryCode/inputCountryCode.stories.d.ts +0 -5
- package/dist/components/Label/Label.stories.d.ts +0 -6
- package/dist/components/Link/Link.stories.d.ts +0 -7
- package/dist/components/Menu/Menu.stories.d.ts +0 -5
- package/dist/components/MobileTable/MobileTable.stories.d.ts +0 -5
- package/dist/components/ModalConfirmation/ModalConfirmation.stories.d.ts +0 -5
- package/dist/components/ModalWithTable/ModalWithTable.stories.d.ts +0 -5
- package/dist/components/Navigation/Navigation.stories.d.ts +0 -5
- package/dist/components/Notification/Notification.stories.d.ts +0 -5
- package/dist/components/Questions/Questions.stories.d.ts +0 -3
- package/dist/components/Radio/Radio.stories.d.ts +0 -5
- package/dist/components/ResponseType/ResponseType.stories.d.ts +0 -3
- package/dist/components/ResponsiveTable/ResponsiveTable.stories.d.ts +0 -9
- package/dist/components/Select/Select.stories.d.ts +0 -6
- package/dist/components/Separator/Separator.stories.d.ts +0 -6
- package/dist/components/Sidebar/Sidebar.stories.d.ts +0 -6
- package/dist/components/Switch/Switch.stories.d.ts +0 -5
- package/dist/components/Table/Table.stories.d.ts +0 -9
- package/dist/components/Tag/Tag.stories.d.ts +0 -5
- package/dist/components/Upload/Upload.stories.d.ts +0 -3
- package/dist/components/UserInfo/UserInfo.stories.d.ts +0 -3
- package/dist/components/WebCam/WebCam.stories.d.ts +0 -3
- package/dist/types/index.d.ts +0 -2
- package/public/index.ts +0 -0
- package/src/assets/code-brackets.svg +0 -1
- package/src/assets/colors.svg +0 -1
- package/src/assets/comments.svg +0 -1
- package/src/assets/direction.svg +0 -1
- package/src/assets/flow.svg +0 -1
- package/src/assets/fonts/Silka-Bold.woff2 +0 -0
- package/src/assets/fonts/Silka-Regular.woff2 +0 -0
- package/src/assets/images/A2AI-logo.png +0 -0
- package/src/assets/images/omnium-retail-logo-white.png +0 -0
- package/src/assets/images/omnium-retail-logo.png +0 -0
- package/src/assets/images/omnium-retail_icon.png +0 -0
- package/src/assets/plugin.svg +0 -1
- package/src/assets/repo.svg +0 -1
- package/src/assets/scss/_combinations.scss +0 -0
- package/src/assets/scss/_global.scss +0 -89
- package/src/assets/scss/index.scss +0 -2
- package/src/assets/stackalt.svg +0 -1
- package/src/components/AnalyticsBar/AnalyticsBar.stories.tsx +0 -236
- package/src/components/AnalyticsBar/helpers/codeMutation.tsx +0 -19
- package/src/components/AnalyticsBar/index.tsx +0 -76
- package/src/components/AnalyticsBar/interfaces/analyticsBar.tsx +0 -13
- package/src/components/AnalyticsBar/styles.module.scss +0 -137
- package/src/components/BellNotifications/BellNotifications.stories.tsx +0 -200
- package/src/components/BellNotifications/index.tsx +0 -154
- package/src/components/BellNotifications/styles.module.scss +0 -239
- package/src/components/Button/Button.stories.tsx +0 -26
- package/src/components/Button/index.tsx +0 -24
- package/src/components/Button/styles.module.scss +0 -70
- package/src/components/Category/Category.stories.tsx +0 -371
- package/src/components/Category/CategoryContent/index.tsx +0 -255
- package/src/components/Category/CategoryContent/styles.module.scss +0 -69
- package/src/components/Category/CategorySidebar/index.tsx +0 -344
- package/src/components/Category/CategorySidebar/styles.module.scss +0 -28
- package/src/components/Category/index.tsx +0 -58
- package/src/components/Category/styles.module.scss +0 -13
- package/src/components/CategoryReadOnly/CategoryReadOnly.stories.tsx +0 -274
- package/src/components/CategoryReadOnly/evaluationOptions.tsx +0 -81
- package/src/components/CategoryReadOnly/index.tsx +0 -328
- package/src/components/CategoryReadOnly/styles.module.scss +0 -214
- package/src/components/CategoryResponse/CategoryResponse.stories.tsx +0 -311
- package/src/components/CategoryResponse/evaluationOptions.tsx +0 -81
- package/src/components/CategoryResponse/index.tsx +0 -502
- package/src/components/CategoryResponse/styles.module.scss +0 -365
- package/src/components/DatePicker/DatePicker.stories.tsx +0 -16
- package/src/components/DatePicker/index.tsx +0 -38
- package/src/components/DatePicker/styles.module.scss +0 -3
- package/src/components/DatePickerTag/DatePickerTag.stories.tsx +0 -19
- package/src/components/DatePickerTag/index.tsx +0 -91
- package/src/components/DatePickerTag/styles.module.scss +0 -32
- package/src/components/DropdownButton/DropdownButton.stories.tsx +0 -24
- package/src/components/DropdownButton/index.tsx +0 -36
- package/src/components/DropdownButton/styles.module.scss +0 -9
- package/src/components/ExportTableData/ExportTableData.stories.tsx +0 -43
- package/src/components/ExportTableData/index.tsx +0 -37
- package/src/components/ExportTableData/styles.module.scss +0 -4
- package/src/components/Footer/Footer.stories.tsx +0 -15
- package/src/components/Footer/index.tsx +0 -45
- package/src/components/Footer/styles.module.scss +0 -38
- package/src/components/Footer2/Footer.stories.tsx +0 -184
- package/src/components/Footer2/index.tsx +0 -322
- package/src/components/Footer2/styles.module.scss +0 -292
- package/src/components/Header/Header.data.ts +0 -26
- package/src/components/Header/Header.stories.tsx +0 -236
- package/src/components/Header/Header.types.ts +0 -32
- package/src/components/Header/README.md +0 -38
- package/src/components/Header/index.tsx +0 -200
- package/src/components/Header/styles.module.scss +0 -216
- package/src/components/Input/Input.stories.tsx +0 -13
- package/src/components/Input/index.tsx +0 -31
- package/src/components/Input/styles.module.scss +0 -8
- package/src/components/InputCountryCode/index.tsx +0 -79
- package/src/components/InputCountryCode/inputCountryCode.stories.tsx +0 -55
- package/src/components/InputCountryCode/styles.module.scss +0 -3
- package/src/components/Label/Label.stories.tsx +0 -21
- package/src/components/Label/index.tsx +0 -19
- package/src/components/Label/styles.module.scss +0 -17
- package/src/components/Link/Link.stories.tsx +0 -30
- package/src/components/Link/index.tsx +0 -21
- package/src/components/Link/styles.module.scss +0 -24
- package/src/components/Menu/Menu.stories.tsx +0 -178
- package/src/components/Menu/helpers/codeMutation.tsx +0 -19
- package/src/components/Menu/index.tsx +0 -24
- package/src/components/Menu/styles.module.scss +0 -0
- package/src/components/MobileTable/MobileTable.stories.tsx +0 -27
- package/src/components/MobileTable/index.tsx +0 -102
- package/src/components/MobileTable/styles.module.scss +0 -75
- package/src/components/ModalConfirmation/ModalConfirmation.stories.tsx +0 -40
- package/src/components/ModalConfirmation/ModalStatusList.tsx +0 -5
- package/src/components/ModalConfirmation/index.tsx +0 -71
- package/src/components/ModalConfirmation/styles.module.scss +0 -62
- package/src/components/ModalWithTable/ModalWithTable.stories.tsx +0 -99
- package/src/components/ModalWithTable/index.tsx +0 -238
- package/src/components/ModalWithTable/styles.module.scss +0 -77
- package/src/components/Navigation/Navigation.stories.tsx +0 -21
- package/src/components/Navigation/index.tsx +0 -91
- package/src/components/Navigation/styles.module.scss +0 -91
- package/src/components/Notification/Notification.stories.tsx +0 -32
- package/src/components/Notification/index.tsx +0 -28
- package/src/components/Questions/Questions.stories.tsx +0 -37
- package/src/components/Questions/SingleQuestion/index.tsx +0 -337
- package/src/components/Questions/SingleQuestion/styles.module.scss +0 -142
- package/src/components/Questions/index.tsx +0 -124
- package/src/components/Questions/styles.modules.scss +0 -0
- package/src/components/Radio/Radio.stories.tsx +0 -43
- package/src/components/Radio/index.tsx +0 -26
- package/src/components/Radio/styles.module.scss +0 -24
- package/src/components/ResponseType/ResponseType.stories.tsx +0 -393
- package/src/components/ResponseType/index.tsx +0 -100
- package/src/components/ResponseType/styles.module.scss +0 -31
- package/src/components/ResponsiveTable/ResponsiveTable.stories.tsx +0 -386
- package/src/components/ResponsiveTable/index.tsx +0 -389
- package/src/components/ResponsiveTable/styles.module.scss +0 -153
- package/src/components/Select/Select.stories.tsx +0 -39
- package/src/components/Select/index.tsx +0 -27
- package/src/components/Select/styles.module.scss +0 -19
- package/src/components/Separator/Separator.stories.tsx +0 -22
- package/src/components/Separator/index.tsx +0 -27
- package/src/components/Separator/styles.module.scss +0 -25
- package/src/components/Sidebar/Sidebar.stories.tsx +0 -85
- package/src/components/Sidebar/index.tsx +0 -127
- package/src/components/Sidebar/styles.module.scss +0 -141
- package/src/components/Switch/Switch.stories.tsx +0 -14
- package/src/components/Switch/index.tsx +0 -18
- package/src/components/Switch/styles.module.scss +0 -7
- package/src/components/Table/Table.stories.tsx +0 -337
- package/src/components/Table/index.tsx +0 -313
- package/src/components/Table/styles.module.scss +0 -97
- package/src/components/Tag/Tag.stories.tsx +0 -32
- package/src/components/Tag/index.tsx +0 -295
- package/src/components/Tag/styles.module.scss +0 -104
- package/src/components/Upload/Upload.stories.tsx +0 -45
- package/src/components/Upload/index.tsx +0 -112
- package/src/components/Upload/styles.module.scss +0 -29
- package/src/components/UserInfo/UserInfo.stories.tsx +0 -38
- package/src/components/UserInfo/index.tsx +0 -77
- package/src/components/UserInfo/styles.module.scss +0 -35
- package/src/components/WebCam/WebCam.stories.tsx +0 -24
- package/src/components/WebCam/index.tsx +0 -73
- package/src/components/WebCam/styles.module.scss +0 -37
- package/src/components/index.tsx +0 -34
- package/src/constants/i18n.ts +0 -25
- package/src/constants/logoCompanyHelper.ts +0 -52
- package/src/constants/translationHelper.ts +0 -7
- package/src/index.ts +0 -3
- package/src/locales/en.json +0 -142
- package/src/locales/es.json +0 -142
- package/src/locales/pt.json +0 -142
- package/src/types/Global.d.ts +0 -4
- package/tsconfig.json +0 -24
- package/vite.config.js +0 -51
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
.tableWrapper {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-wrap: wrap;
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
|
|
6
|
-
:global {
|
|
7
|
-
.ant-table-thead>tr>th {
|
|
8
|
-
background-color: transparent;
|
|
9
|
-
border: 0px;
|
|
10
|
-
color: var(--color-blue);
|
|
11
|
-
|
|
12
|
-
&:before {
|
|
13
|
-
display: none;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.ant-table-tbody {
|
|
18
|
-
>tr {
|
|
19
|
-
cursor: pointer;
|
|
20
|
-
|
|
21
|
-
&:last-child {
|
|
22
|
-
>td {
|
|
23
|
-
border-bottom: 1px solid var(--color-grey-light) !important;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
&:first-child {
|
|
28
|
-
>td {
|
|
29
|
-
border-top: 1px solid var(--color-blue) !important;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
&:hover {
|
|
34
|
-
td {
|
|
35
|
-
border-radius: 0 !important;
|
|
36
|
-
border-bottom-color: var(--color-grey-light) !important;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.ant-space {
|
|
43
|
-
align-self: flex-end;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.ant-select-selection-placeholder {
|
|
47
|
-
color: var(--color-black);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.ant-select-selector,
|
|
51
|
-
.ant-select-focused .ant-select-selection-search {
|
|
52
|
-
border: none !important;
|
|
53
|
-
box-shadow: none !important;
|
|
54
|
-
|
|
55
|
-
&:focus,
|
|
56
|
-
&:hover {
|
|
57
|
-
border: none !important;
|
|
58
|
-
box-shadow: none !important;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.ant-pagination {
|
|
63
|
-
max-width: calc(100% - 200px);
|
|
64
|
-
margin-left: auto !important;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
button[type="button"].ant-pagination-item-link {
|
|
68
|
-
margin-top: 0 !important;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
button[type="button"] {
|
|
73
|
-
margin-top: -50px;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
:global {
|
|
78
|
-
.ant-spin-dot-item {
|
|
79
|
-
background-color: var(--color-blue) !important;
|
|
80
|
-
opacity: 1 !important;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.ant-spin-dot-item:nth-child(2) {
|
|
84
|
-
background-color: var(--color-orange) !important;
|
|
85
|
-
opacity: 1;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.ant-spin-dot-item:nth-child(3) {
|
|
89
|
-
background-color: var(--color-blue) !important;
|
|
90
|
-
opacity: 1;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.ant-spin-dot-item:nth-child(4) {
|
|
94
|
-
background-color: var(--color-orange) !important;
|
|
95
|
-
opacity: 1;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryFn } from "@storybook/react-vite";
|
|
2
|
-
import { TagField } from '.';
|
|
3
|
-
import { TagProps } from 'antd';
|
|
4
|
-
import { useState } from "react";
|
|
5
|
-
import { t } from "i18next";
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
title: 'TagField',
|
|
9
|
-
component: TagField,
|
|
10
|
-
} as Meta;
|
|
11
|
-
|
|
12
|
-
const Template: StoryFn<TagProps> = (args: any) => {
|
|
13
|
-
const [tagsInfo, setTagsInfo] = useState<any>({});
|
|
14
|
-
const [advancedTagsInfo, setAdvancedTagsInfo] = useState<any>({});
|
|
15
|
-
const advancedsFilters = [{ display: t('components.tag.State'), value: "State" }, { display: t('components.tag.1'), value: "Olaaaaaa" }];
|
|
16
|
-
const [switchTest, setSwitchTest] = useState<boolean>(false);
|
|
17
|
-
|
|
18
|
-
return <TagField
|
|
19
|
-
disable={false}
|
|
20
|
-
{...args}
|
|
21
|
-
setInactiveUsersSwitch={setSwitchTest}
|
|
22
|
-
advancedTags={advancedsFilters}
|
|
23
|
-
tagsInfo={setTagsInfo}
|
|
24
|
-
advancedTagsInfo={setAdvancedTagsInfo}
|
|
25
|
-
inputPlacehold="ola"
|
|
26
|
-
>
|
|
27
|
-
</TagField>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const Primary = Template.bind({});
|
|
31
|
-
Primary.args = {
|
|
32
|
-
};
|
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { DownOutlined, SearchOutlined, UpOutlined } from '@ant-design/icons';
|
|
3
|
-
import type { InputRef } from 'antd';
|
|
4
|
-
import { Input, Tag, TagProps } from 'antd';
|
|
5
|
-
import { TweenOneGroup } from 'rc-tween-one';
|
|
6
|
-
import styles from './styles.module.scss';
|
|
7
|
-
import classNames from 'classnames';
|
|
8
|
-
import { t } from 'i18next';
|
|
9
|
-
import { Switch } from '../Switch';
|
|
10
|
-
|
|
11
|
-
export interface customTagProps extends TagProps {
|
|
12
|
-
customTags?: string[];
|
|
13
|
-
tagsInfo?: (tags: string[]) => void;
|
|
14
|
-
advancedTagsInfo?: (tags: string[]) => void;
|
|
15
|
-
advancedTags?: { display: string; value: string }[];
|
|
16
|
-
addExtraTags?: string;
|
|
17
|
-
disable?: boolean;
|
|
18
|
-
addSwitch?: boolean;
|
|
19
|
-
setInactiveUsersSwitch?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
20
|
-
hideAdvancedFilters?: boolean;
|
|
21
|
-
defaultAdvancedFilters?: { display: string; value: string }[];
|
|
22
|
-
inputPlacehold?: string;
|
|
23
|
-
inputDefaultAdvancedFilter?: string;
|
|
24
|
-
autoFocus?: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const TagField = (props: customTagProps) => {
|
|
28
|
-
const {
|
|
29
|
-
customTags = [],
|
|
30
|
-
advancedTags,
|
|
31
|
-
disable,
|
|
32
|
-
defaultAdvancedFilters = [],
|
|
33
|
-
hideAdvancedFilters = true,
|
|
34
|
-
inputPlacehold,
|
|
35
|
-
inputDefaultAdvancedFilter = "",
|
|
36
|
-
autoFocus = false
|
|
37
|
-
} = props;
|
|
38
|
-
|
|
39
|
-
const [tags, setTags] = useState<string[]>(customTags.filter(tag => !tag.includes('=')));
|
|
40
|
-
const [inputVisible, setInputVisible] = useState<boolean>(
|
|
41
|
-
inputDefaultAdvancedFilter !== "" || autoFocus
|
|
42
|
-
);
|
|
43
|
-
const [inputValue, setInputValue] = useState(
|
|
44
|
-
inputDefaultAdvancedFilter !== "" ? inputDefaultAdvancedFilter + '=' : ''
|
|
45
|
-
);
|
|
46
|
-
const inputRef = useRef<InputRef>(null);
|
|
47
|
-
const [advancedTagList, setAdvancedTagList] = useState<Array<{ display: string; value: string }>>(
|
|
48
|
-
defaultAdvancedFilters
|
|
49
|
-
);
|
|
50
|
-
const [allTags, setAllTags] = useState<string[]>([
|
|
51
|
-
...customTags.filter(tag => !tag.includes('=')),
|
|
52
|
-
...defaultAdvancedFilters.map((filter) => `${filter.display}`),
|
|
53
|
-
]);
|
|
54
|
-
const [showAdvancedFilters, setShowAdvancedFilters] = useState<boolean>(hideAdvancedFilters ? false : true);
|
|
55
|
-
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
if (defaultAdvancedFilters?.length > 0) {
|
|
58
|
-
setAdvancedTagList(defaultAdvancedFilters);
|
|
59
|
-
setAllTags(defaultAdvancedFilters.map((filter) => `${filter.display}`));
|
|
60
|
-
}
|
|
61
|
-
}, [defaultAdvancedFilters]);
|
|
62
|
-
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
if (inputVisible) {
|
|
65
|
-
inputRef.current?.focus();
|
|
66
|
-
}
|
|
67
|
-
}, [inputVisible]);
|
|
68
|
-
|
|
69
|
-
const handleClose = (removedTag: string) => {
|
|
70
|
-
const newAllTags = allTags.filter((tag) => tag !== removedTag);
|
|
71
|
-
setAllTags(newAllTags);
|
|
72
|
-
|
|
73
|
-
const newTags = tags.filter((tag) => tag !== removedTag);
|
|
74
|
-
setTags(newTags);
|
|
75
|
-
|
|
76
|
-
if (advancedTags && advancedTagList.some(tag => tag.display === removedTag)) {
|
|
77
|
-
const newAdvancedTags = advancedTagList.filter((tag) => tag.display !== removedTag);
|
|
78
|
-
setAdvancedTagList(newAdvancedTags);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const showInput = () => {
|
|
83
|
-
setInputVisible(true);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
87
|
-
setInputValue(e.target.value);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const handleInputConfirm = () => {
|
|
91
|
-
if (inputValue && allTags.indexOf(inputValue) === -1) {
|
|
92
|
-
const [, value] = inputValue.split('=');
|
|
93
|
-
|
|
94
|
-
if (props.addSwitch) {
|
|
95
|
-
const newTags = props.addSwitch ? [inputValue] : [...tags, inputValue];
|
|
96
|
-
setTags(newTags);
|
|
97
|
-
setAllTags([inputValue]);
|
|
98
|
-
} else {
|
|
99
|
-
setAllTags([...allTags, inputValue]);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const matchedFilter = advancedTags && advancedTags.find(filter => filter.display === inputValue.split('=')[0]);
|
|
103
|
-
|
|
104
|
-
if (matchedFilter && !advancedTagList.some(tag => tag.display === inputValue)) {
|
|
105
|
-
const newTag = {
|
|
106
|
-
display: inputValue,
|
|
107
|
-
value: `${matchedFilter.value}=${value}`
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
setAdvancedTagList([...advancedTagList, newTag]);
|
|
111
|
-
|
|
112
|
-
} else if (props.addSwitch) {
|
|
113
|
-
setTags([inputValue]);
|
|
114
|
-
|
|
115
|
-
} else {
|
|
116
|
-
setTags([...tags, inputValue]);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
setInputVisible(false);
|
|
121
|
-
setInputValue('');
|
|
122
|
-
|
|
123
|
-
const basicTags = tags.filter(tag => !advancedTagList.some(tagObj => tagObj.display === tag));
|
|
124
|
-
props.tagsInfo?.(basicTags);
|
|
125
|
-
props.advancedTagsInfo?.(advancedTagList.map(tagObj => tagObj.value));
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
129
|
-
const cursorPosition: any = e.currentTarget.selectionStart;
|
|
130
|
-
const advancedFilterMatch = advancedTags && advancedTags.find((filter: any) => inputValue.startsWith(`${filter}=`));
|
|
131
|
-
if (advancedFilterMatch) {
|
|
132
|
-
const filterLength = advancedFilterMatch.display.length;
|
|
133
|
-
if (cursorPosition <= filterLength && ![8, 46].includes(e.keyCode)) {
|
|
134
|
-
e.preventDefault();
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Prevent the input of '=' manually
|
|
139
|
-
if (e.key === "=") {
|
|
140
|
-
e.preventDefault();
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const doSomething = (e: any) => {
|
|
145
|
-
const tag = e.target.innerText;
|
|
146
|
-
if (!advancedTagList.map(tagObj => tagObj.display).includes(tag)) {
|
|
147
|
-
setInputValue(`${tag}=`);
|
|
148
|
-
setInputVisible(true);
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
useEffect(() => {
|
|
153
|
-
props.tagsInfo?.(tags);
|
|
154
|
-
props.advancedTagsInfo?.(advancedTagList.map(tag => tag.value));
|
|
155
|
-
}, [tags, advancedTagList]);
|
|
156
|
-
|
|
157
|
-
useEffect(() => {
|
|
158
|
-
// Adiciona a nova tag ao allTags usando a prop addExtraTags
|
|
159
|
-
if (props.addExtraTags && typeof props.addExtraTags === "string") {
|
|
160
|
-
const newTags = props.addSwitch ? [props.addExtraTags] : [...tags, props.addExtraTags];
|
|
161
|
-
|
|
162
|
-
if (props.addSwitch) {
|
|
163
|
-
setTags([props.addExtraTags]);
|
|
164
|
-
setAllTags([props.addExtraTags]);
|
|
165
|
-
} else {
|
|
166
|
-
setTags([...tags, props.addExtraTags]);
|
|
167
|
-
setAllTags([...allTags, props.addExtraTags]);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}, [props.addExtraTags, props.addSwitch]);
|
|
171
|
-
|
|
172
|
-
const forMap = (tag: string) => {
|
|
173
|
-
const tagElem = (
|
|
174
|
-
<Tag
|
|
175
|
-
closable
|
|
176
|
-
onClose={(e) => {
|
|
177
|
-
e.preventDefault();
|
|
178
|
-
handleClose(tag);
|
|
179
|
-
}}
|
|
180
|
-
>
|
|
181
|
-
{tag}
|
|
182
|
-
</Tag>
|
|
183
|
-
);
|
|
184
|
-
return (
|
|
185
|
-
<span key={tag} className={styles['tagfield__new']} style={{ display: 'inline-block' }}>
|
|
186
|
-
{tagElem}
|
|
187
|
-
</span>
|
|
188
|
-
);
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const advancedTagsMap = (tag: { display: string; value: string; }) => {
|
|
192
|
-
const disabled = advancedTagList.map(tag => tag.display.split('=')[0]).includes(tag.display);
|
|
193
|
-
return (
|
|
194
|
-
<div onClick={!disabled ? doSomething : undefined} key={tag.display} style={{ color: disabled ? 'gray' : undefined }}>
|
|
195
|
-
{tag.display}
|
|
196
|
-
</div>
|
|
197
|
-
);
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
const tagChild = allTags.map(forMap);
|
|
201
|
-
const advancedTagsChild = advancedTags && advancedTags.map(advancedTagsMap);
|
|
202
|
-
|
|
203
|
-
return (
|
|
204
|
-
<div className={styles.tagfield}>
|
|
205
|
-
<div className={styles.switchInputContainer}>
|
|
206
|
-
{inputVisible && (
|
|
207
|
-
<Input
|
|
208
|
-
ref={inputRef}
|
|
209
|
-
type="search"
|
|
210
|
-
enterKeyHint='done'
|
|
211
|
-
size="small"
|
|
212
|
-
value={inputValue}
|
|
213
|
-
onChange={handleInputChange}
|
|
214
|
-
onKeyDown={handleKeyDown}
|
|
215
|
-
onPressEnter={handleInputConfirm}
|
|
216
|
-
className={styles['tagfield__input']}
|
|
217
|
-
disabled={disable}
|
|
218
|
-
suffix={
|
|
219
|
-
hideAdvancedFilters ? (
|
|
220
|
-
showAdvancedFilters ? (
|
|
221
|
-
<UpOutlined onClick={() => setShowAdvancedFilters(false)} />
|
|
222
|
-
) : (
|
|
223
|
-
<DownOutlined onClick={() => setShowAdvancedFilters(true)} />
|
|
224
|
-
)
|
|
225
|
-
) : null
|
|
226
|
-
}
|
|
227
|
-
/>
|
|
228
|
-
)}
|
|
229
|
-
|
|
230
|
-
{!inputVisible && (
|
|
231
|
-
<Tag onClick={showInput} className={classNames(styles['tagfield__creator'], 'site-tag-plus')}>
|
|
232
|
-
{inputPlacehold ? inputPlacehold : (
|
|
233
|
-
<>
|
|
234
|
-
<SearchOutlined /> {t('components.tag.search')}
|
|
235
|
-
</>
|
|
236
|
-
)}
|
|
237
|
-
|
|
238
|
-
{hideAdvancedFilters && (
|
|
239
|
-
showAdvancedFilters ? (
|
|
240
|
-
<UpOutlined className={styles.tagIcon} onClick={() => setShowAdvancedFilters(false)} />
|
|
241
|
-
) : (
|
|
242
|
-
<DownOutlined className={styles.tagIcon} onClick={() => setShowAdvancedFilters(true)} />
|
|
243
|
-
)
|
|
244
|
-
)}
|
|
245
|
-
</Tag>
|
|
246
|
-
)}
|
|
247
|
-
</div>
|
|
248
|
-
|
|
249
|
-
{showAdvancedFilters && advancedTags && (
|
|
250
|
-
<div style={{ marginTop: 16, marginBottom: 16 }} className={styles.advancedTagsWrapper}>
|
|
251
|
-
<div className={styles.label}>
|
|
252
|
-
{t('components.tag.advancedFields')}:
|
|
253
|
-
</div>
|
|
254
|
-
<div className={styles.advancedTags}>
|
|
255
|
-
{advancedTagsChild}
|
|
256
|
-
</div>
|
|
257
|
-
</div>
|
|
258
|
-
)}
|
|
259
|
-
|
|
260
|
-
{props.setInactiveUsersSwitch &&
|
|
261
|
-
<div className={styles.switchContainer}>
|
|
262
|
-
<div className={styles.inactiveLabel}>
|
|
263
|
-
{t('components.tag.inactiveSwitch')}:
|
|
264
|
-
</div>
|
|
265
|
-
|
|
266
|
-
<Switch
|
|
267
|
-
size={"small"}
|
|
268
|
-
customClass={styles.inactiveSwitchStyle}
|
|
269
|
-
onChange={(checked) => props?.setInactiveUsersSwitch!(checked)}
|
|
270
|
-
/>
|
|
271
|
-
</div>
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
<div className={`${styles.tagsContainer} ${disable ? styles.disabled : ''}`}>
|
|
275
|
-
<TweenOneGroup
|
|
276
|
-
enter={{
|
|
277
|
-
scale: 0.8,
|
|
278
|
-
opacity: 0,
|
|
279
|
-
type: 'from',
|
|
280
|
-
duration: 100,
|
|
281
|
-
}}
|
|
282
|
-
onEnd={(e: any) => {
|
|
283
|
-
if (e.type === 'appear' || e.type === 'enter') {
|
|
284
|
-
(e.target as any).style = 'display: inline-block';
|
|
285
|
-
}
|
|
286
|
-
}}
|
|
287
|
-
leave={{ opacity: 0, width: 0, scale: 0, duration: 200 }}
|
|
288
|
-
appear={false}
|
|
289
|
-
>
|
|
290
|
-
{tagChild}
|
|
291
|
-
</TweenOneGroup>
|
|
292
|
-
</div>
|
|
293
|
-
</div>
|
|
294
|
-
);
|
|
295
|
-
};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
.tagfield {
|
|
2
|
-
contain: inline-size;
|
|
3
|
-
|
|
4
|
-
.tagsContainer {
|
|
5
|
-
margin-top: 16px;
|
|
6
|
-
|
|
7
|
-
&.disabled {
|
|
8
|
-
pointer-events: none;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
&__creator {
|
|
13
|
-
height: 50px;
|
|
14
|
-
display: flex;
|
|
15
|
-
align-items: center;
|
|
16
|
-
gap: 12px;
|
|
17
|
-
padding: 16px;
|
|
18
|
-
margin-inline-end: 0;
|
|
19
|
-
width: 100%;
|
|
20
|
-
|
|
21
|
-
:global {
|
|
22
|
-
.ant-input {
|
|
23
|
-
height: 50px;
|
|
24
|
-
padding-left: 40px;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&__input {
|
|
30
|
-
height: 50px;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
&__new {
|
|
34
|
-
:global {
|
|
35
|
-
.ant-tag {
|
|
36
|
-
background-color: var(--color-orange);
|
|
37
|
-
color: var(--color-white);
|
|
38
|
-
padding: 6px 16px;
|
|
39
|
-
max-width: 240px;
|
|
40
|
-
overflow: hidden;
|
|
41
|
-
text-overflow: ellipsis;
|
|
42
|
-
white-space: nowrap;
|
|
43
|
-
position: relative;
|
|
44
|
-
padding-right: 24px;
|
|
45
|
-
min-height: 34px;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.anticon-close {
|
|
49
|
-
color: var(--color-white);
|
|
50
|
-
font-size: 12px;
|
|
51
|
-
position: absolute;
|
|
52
|
-
right: 4px;
|
|
53
|
-
top: 10px;
|
|
54
|
-
|
|
55
|
-
&:hover {
|
|
56
|
-
color: var(--color-black);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.switchInputContainer {
|
|
63
|
-
display: flex;
|
|
64
|
-
align-items: center;
|
|
65
|
-
gap: 32px;
|
|
66
|
-
width: calc(100% - 40px);
|
|
67
|
-
|
|
68
|
-
@media (max-width: 768px) {
|
|
69
|
-
gap: 12px;
|
|
70
|
-
width: calc(100% - 20px);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.advancedTagsWrapper {
|
|
75
|
-
display: flex;
|
|
76
|
-
gap: 12px;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.advancedTags {
|
|
80
|
-
display: flex;
|
|
81
|
-
flex-direction: row;
|
|
82
|
-
gap: 12px;
|
|
83
|
-
text-decoration: underline;
|
|
84
|
-
font-weight: 700;
|
|
85
|
-
|
|
86
|
-
div {
|
|
87
|
-
cursor: pointer;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.switchContainer {
|
|
92
|
-
display: flex;
|
|
93
|
-
gap: 20px;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.inactiveSwitchStyle {
|
|
97
|
-
margin-top: 2px;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.tagIcon {
|
|
101
|
-
width: 100%;
|
|
102
|
-
justify-content: flex-end;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryFn } from "@storybook/react-vite";
|
|
2
|
-
import { Form, UploadFile } from "antd";
|
|
3
|
-
import { Button } from "../Button";
|
|
4
|
-
import { Upload } from '.';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Upload',
|
|
8
|
-
component: Upload,
|
|
9
|
-
} as Meta;
|
|
10
|
-
|
|
11
|
-
const Template: StoryFn<any> = (args: any) => {
|
|
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]} disable={true}></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,112 +0,0 @@
|
|
|
1
|
-
import styles from './styles.module.scss';
|
|
2
|
-
import { Upload as UploadAntd } from 'antd';
|
|
3
|
-
import ImgCrop from 'antd-img-crop';
|
|
4
|
-
import type { RcFile, UploadFile, UploadProps } from 'antd/es/upload/interface';
|
|
5
|
-
import { Button } from '../Button';
|
|
6
|
-
import { Dispatch, SetStateAction, useEffect, useState } from 'react';
|
|
7
|
-
import { useTranslation } from 'react-i18next';
|
|
8
|
-
|
|
9
|
-
interface UploadPropsExtended extends UploadProps {
|
|
10
|
-
onImageChange?: (file: UploadFile | null) => void;
|
|
11
|
-
initialFileList?: UploadFile[];
|
|
12
|
-
initialImageUrl?: string;
|
|
13
|
-
disable?: boolean;
|
|
14
|
-
file?: boolean;
|
|
15
|
-
setFiles?: Dispatch<SetStateAction<UploadFile<any>[]>> | any;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function generateRandomString() {
|
|
19
|
-
return Math.random().toString(36).substring(2, 14);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const Upload = (props: UploadPropsExtended) => {
|
|
23
|
-
const {
|
|
24
|
-
onImageChange,
|
|
25
|
-
initialFileList,
|
|
26
|
-
initialImageUrl,
|
|
27
|
-
disable,
|
|
28
|
-
setFiles
|
|
29
|
-
} = props;
|
|
30
|
-
|
|
31
|
-
const { t } = useTranslation();
|
|
32
|
-
const [fileList, setFileList] = useState<UploadFile[]>(initialFileList || []);
|
|
33
|
-
|
|
34
|
-
// when component mounts or initialImageUrl changes, update fileList
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
if (initialImageUrl) {
|
|
37
|
-
const newFile: UploadFile = {
|
|
38
|
-
uid: generateRandomString(), // use any unique string
|
|
39
|
-
name: initialImageUrl, // use the URL as the name
|
|
40
|
-
status: 'done',
|
|
41
|
-
url: initialImageUrl, // this is used for preview
|
|
42
|
-
};
|
|
43
|
-
setFileList((prevFileList) => [...prevFileList, newFile]);
|
|
44
|
-
}
|
|
45
|
-
}, [initialImageUrl]);
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
if (setFiles) {
|
|
49
|
-
setFiles(fileList);
|
|
50
|
-
}
|
|
51
|
-
}, [fileList, setFiles]);
|
|
52
|
-
|
|
53
|
-
const beforeUpload: UploadProps['beforeUpload'] = async (file: RcFile) => {
|
|
54
|
-
const newFile: UploadFile = {
|
|
55
|
-
uid: file.uid,
|
|
56
|
-
name: file.name,
|
|
57
|
-
type: file.type,
|
|
58
|
-
size: file.size,
|
|
59
|
-
originFileObj: file,
|
|
60
|
-
status: 'done',
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
setFileList((prevFileList) => [...prevFileList, newFile]);
|
|
64
|
-
if (onImageChange) {
|
|
65
|
-
onImageChange(newFile);
|
|
66
|
-
}
|
|
67
|
-
return false;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const onChange: UploadProps['onChange'] = ({ file, fileList: newFileList }) => {
|
|
71
|
-
if (file.status === 'removed') {
|
|
72
|
-
setFileList(newFileList);
|
|
73
|
-
if (onImageChange) {
|
|
74
|
-
onImageChange(newFileList[0] || null);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const onPreview = async (file: UploadFile) => {
|
|
80
|
-
let src = file.url as string;
|
|
81
|
-
if (!src) {
|
|
82
|
-
src = await new Promise((resolve) => {
|
|
83
|
-
const reader = new FileReader();
|
|
84
|
-
reader.readAsDataURL(file.originFileObj as RcFile);
|
|
85
|
-
reader.onload = () => resolve(reader.result as string);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
const image = new Image();
|
|
89
|
-
image.src = src;
|
|
90
|
-
const imgWindow = window.open(src);
|
|
91
|
-
imgWindow?.document.write(image.outerHTML);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<ImgCrop rotationSlider>
|
|
96
|
-
<UploadAntd
|
|
97
|
-
listType={props.file ? "text" : "picture-card"}
|
|
98
|
-
fileList={fileList}
|
|
99
|
-
beforeUpload={beforeUpload}
|
|
100
|
-
onChange={onChange}
|
|
101
|
-
onPreview={onPreview}
|
|
102
|
-
disabled={disable}
|
|
103
|
-
>
|
|
104
|
-
{props.file
|
|
105
|
-
? <Button customClass={styles.loadFile}>{t('components.upload.loadFile')}</Button>
|
|
106
|
-
|
|
107
|
-
: fileList.length < 1 && '+ Upload'
|
|
108
|
-
}
|
|
109
|
-
</UploadAntd>
|
|
110
|
-
</ImgCrop>
|
|
111
|
-
);
|
|
112
|
-
};
|