@omniumretail/component-library 1.2.71 → 1.2.72
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 +12 -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,69 +0,0 @@
|
|
|
1
|
-
.title {
|
|
2
|
-
font-size: var(--font-size-body-4);
|
|
3
|
-
font-weight: 600;
|
|
4
|
-
line-height: 100%;
|
|
5
|
-
color: var(--color-blue);
|
|
6
|
-
text-transform: uppercase;
|
|
7
|
-
margin-bottom: 32px;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.categoryNameContainer {
|
|
11
|
-
display: flex;
|
|
12
|
-
gap: 32px;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.categoryName {
|
|
16
|
-
width: 100%;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.uncheckedCategory {
|
|
20
|
-
font-size: var(--font-size-body-2);
|
|
21
|
-
color: var(--color-black);
|
|
22
|
-
font-weight: 700;
|
|
23
|
-
text-transform: uppercase;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.formHeader {
|
|
27
|
-
display: grid;
|
|
28
|
-
grid-template-columns: minmax(200px, 1fr) auto auto auto auto;
|
|
29
|
-
gap: 46px;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.questionsWrapper {
|
|
33
|
-
margin-top: 16px;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
Label {
|
|
37
|
-
margin-bottom: 8px;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.selectResponseType {
|
|
41
|
-
min-width: 200px;
|
|
42
|
-
|
|
43
|
-
@media(max-width: 768px) {
|
|
44
|
-
min-width: 150px;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.categoryContent {
|
|
49
|
-
:global {
|
|
50
|
-
.ant-select {
|
|
51
|
-
width: 100%;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.ant-select-selector {
|
|
55
|
-
border-color: rgba(var(--color-black-rgb), .5) !important;
|
|
56
|
-
height: 35px !important;
|
|
57
|
-
display: flex;
|
|
58
|
-
align-items: center;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.ant-select-arrow {
|
|
62
|
-
color: var(--color-black);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.ant-switch {
|
|
66
|
-
width: 30px;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,344 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { Tree } from 'antd';
|
|
3
|
-
import type { TreeProps } from 'antd/es/tree';
|
|
4
|
-
import styles from './styles.module.scss';
|
|
5
|
-
import { MinusOutlined, PlusOutlined } from '@ant-design/icons';
|
|
6
|
-
import { Button } from '../../Button';
|
|
7
|
-
import { t } from 'i18next';
|
|
8
|
-
|
|
9
|
-
export interface Questions {
|
|
10
|
-
grade: string;
|
|
11
|
-
question: string;
|
|
12
|
-
info: string;
|
|
13
|
-
responseType?: string;
|
|
14
|
-
}
|
|
15
|
-
export interface Data {
|
|
16
|
-
categoryName: string;
|
|
17
|
-
generalEvaluationLevel: string;
|
|
18
|
-
grade: string;
|
|
19
|
-
openAnswer: boolean;
|
|
20
|
-
questions: Questions[];
|
|
21
|
-
}
|
|
22
|
-
export interface DataNode {
|
|
23
|
-
title: string;
|
|
24
|
-
key: string;
|
|
25
|
-
data?: Data;
|
|
26
|
-
children?: DataNode[];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface SidebarProps {
|
|
30
|
-
categoryContentData: any;
|
|
31
|
-
categorySidebarInfo: any;
|
|
32
|
-
categoryContentFinalData: any;
|
|
33
|
-
data: DataNode[];
|
|
34
|
-
hasHeader?: boolean;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function get_element_by_index(data: DataNode[], index: string | number): DataNode | null {
|
|
38
|
-
for (const item of data) {
|
|
39
|
-
if (item.key === index) {
|
|
40
|
-
return item;
|
|
41
|
-
} else if (item.children) {
|
|
42
|
-
const result = get_element_by_index(item.children, index);
|
|
43
|
-
if (result !== null) {
|
|
44
|
-
return result;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function addPropertyByIndex(data: DataNode[], index: string | number, property: string, value: any): DataNode[] {
|
|
52
|
-
return data.map((item: DataNode) => {
|
|
53
|
-
if (item.key === index) {
|
|
54
|
-
return { ...item, [property]: value };
|
|
55
|
-
}
|
|
56
|
-
else if (item.children) {
|
|
57
|
-
return { ...item, children: addPropertyByIndex(item.children, index, property, value) };
|
|
58
|
-
}
|
|
59
|
-
return item;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function remove_element_by_index(data: DataNode[], index: string | number): DataNode[] {
|
|
64
|
-
return data.filter((item) => item.key !== index);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function remove_nested_element(data: DataNode[], index: string | number): DataNode[] {
|
|
68
|
-
let newData = [...data] as DataNode[];
|
|
69
|
-
|
|
70
|
-
for (let i = 0; i < newData.length; i++) {
|
|
71
|
-
if (newData[i].key === index) {
|
|
72
|
-
newData = remove_element_by_index(newData, index);
|
|
73
|
-
break;
|
|
74
|
-
} else if (newData[i].children && (newData[i] as any).children.length > 0) {
|
|
75
|
-
newData[i].children = remove_nested_element((newData[i].children as any), index);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return newData;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export const CategorySidebar = (props: SidebarProps) => {
|
|
83
|
-
const {
|
|
84
|
-
categoryContentData,
|
|
85
|
-
data,
|
|
86
|
-
hasHeader
|
|
87
|
-
} = props;
|
|
88
|
-
|
|
89
|
-
const [sidebarInfo, setSidebarInfo] = useState<any>(hasHeader ? ["0"] : undefined);
|
|
90
|
-
const [gData, setGData] = useState<DataNode[]>(() => {
|
|
91
|
-
// Adiciona a categoria "Header" se hasHeader for true
|
|
92
|
-
if (hasHeader && data?.length === 0) {
|
|
93
|
-
const headerCategory: DataNode = {
|
|
94
|
-
title: t('components.category.header'),
|
|
95
|
-
key: '0',
|
|
96
|
-
data: {
|
|
97
|
-
categoryName: t('components.category.header'),
|
|
98
|
-
generalEvaluationLevel: '',
|
|
99
|
-
grade: '',
|
|
100
|
-
openAnswer: false,
|
|
101
|
-
questions: [
|
|
102
|
-
{
|
|
103
|
-
grade: '',
|
|
104
|
-
question: t('components.category.store'),
|
|
105
|
-
info: '',
|
|
106
|
-
responseType: '-1'
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
grade: '',
|
|
110
|
-
question: t('components.category.date'),
|
|
111
|
-
info: '',
|
|
112
|
-
responseType: 'CD8D0F30-6229-4BA9-9888-4398CB333392'
|
|
113
|
-
}
|
|
114
|
-
]
|
|
115
|
-
},
|
|
116
|
-
children: []
|
|
117
|
-
};
|
|
118
|
-
return [headerCategory, ...data];
|
|
119
|
-
}
|
|
120
|
-
return data;
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
const [expandedKeys] = useState([]);
|
|
124
|
-
|
|
125
|
-
const onDragEnter: TreeProps['onDragEnter'] = (info) => {
|
|
126
|
-
// drag entered
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const onDrop: TreeProps['onDrop'] = (info) => {
|
|
130
|
-
const dropKey = info.node.key;
|
|
131
|
-
const dragKey = info.dragNode.key;
|
|
132
|
-
const dropPos = info.node.pos.split('-');
|
|
133
|
-
const dropPosition = info.dropPosition - Number(dropPos[dropPos.length - 1]);
|
|
134
|
-
const { data: nodeData } = info.node as DataNode;
|
|
135
|
-
const questions: Questions[] | undefined = nodeData?.questions;
|
|
136
|
-
|
|
137
|
-
if (hasHeader && (dragKey === '0' || dropKey === '0')) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (questions && questions.length > 0) {
|
|
142
|
-
// console.log('you cant add a subcategory to a category with questions');
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (dropPos.length > 4) {
|
|
147
|
-
// console.log('cant have more than 3 levels');
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const loop = (
|
|
152
|
-
data: DataNode[],
|
|
153
|
-
key: React.Key,
|
|
154
|
-
callback: (node: DataNode, i: number, data: DataNode[]) => void,
|
|
155
|
-
) => {
|
|
156
|
-
for (let i = 0; i < data.length; i++) {
|
|
157
|
-
if (data[i].key === key) {
|
|
158
|
-
return callback(data[i], i, data);
|
|
159
|
-
}
|
|
160
|
-
if (data[i].children) {
|
|
161
|
-
loop(data[i].children!, key, callback);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
const data = [...gData];
|
|
166
|
-
|
|
167
|
-
// Find dragObject
|
|
168
|
-
let dragObj: DataNode;
|
|
169
|
-
loop(data, dragKey, (item, index, arr) => {
|
|
170
|
-
arr.splice(index, 1);
|
|
171
|
-
dragObj = item;
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
if (!info.dropToGap) {
|
|
175
|
-
// Drop on the content
|
|
176
|
-
loop(data, dropKey, (item) => {
|
|
177
|
-
item.children = item.children || [];
|
|
178
|
-
// where to insert
|
|
179
|
-
item.children.unshift(dragObj);
|
|
180
|
-
});
|
|
181
|
-
} else if (
|
|
182
|
-
((info.node as any).props.children || []).length > 0 && // Has children
|
|
183
|
-
(info.node as any).props.expanded && // Is expanded
|
|
184
|
-
dropPosition === 1 // On the bottom gap
|
|
185
|
-
) {
|
|
186
|
-
loop(data, dropKey, (item) => {
|
|
187
|
-
item.children = item.children || [];
|
|
188
|
-
// where to insert
|
|
189
|
-
item.children.unshift(dragObj);
|
|
190
|
-
// in previous version, we use item.children.push(dragObj) to insert the
|
|
191
|
-
// item to the tail of the children
|
|
192
|
-
});
|
|
193
|
-
} else {
|
|
194
|
-
let ar: DataNode[] = [];
|
|
195
|
-
let i: number;
|
|
196
|
-
loop(data, dropKey, (_item, index, arr) => {
|
|
197
|
-
ar = arr;
|
|
198
|
-
i = index;
|
|
199
|
-
});
|
|
200
|
-
if (dropPosition === -1) {
|
|
201
|
-
ar.splice(i!, 0, dragObj!);
|
|
202
|
-
} else {
|
|
203
|
-
ar.splice(i! + 1, 0, dragObj!);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function generateCategoryKeys(categories: DataNode[], parentKey: string = ''): DataNode[] {
|
|
208
|
-
return categories.map((category, index) => {
|
|
209
|
-
const categoryKey = parentKey ? `${parentKey}.${index + 1}` : `${index + 1}`; // Cria hierarquia 1.1, 1.1.1 etc.
|
|
210
|
-
|
|
211
|
-
let children: DataNode[] = [];
|
|
212
|
-
if (category.children) {
|
|
213
|
-
children = generateCategoryKeys(category.children, categoryKey); // Recursivamente atualiza os filhos
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
return { ...category, key: categoryKey, children };
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
setGData(generateCategoryKeys(data));
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
const onSelect: TreeProps['onSelect'] = (selectedKeys, info) => {
|
|
224
|
-
setSidebarInfo(selectedKeys);
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
const addCategory = () => {
|
|
228
|
-
// Função para obter a maior chave em gData
|
|
229
|
-
const getNextKey = (categories: DataNode[]): string => {
|
|
230
|
-
let maxKey = 0;
|
|
231
|
-
|
|
232
|
-
const traverse = (nodes: DataNode[]) => {
|
|
233
|
-
nodes.forEach((node) => {
|
|
234
|
-
const key = parseFloat(node.key as string); // Converte a chave para número
|
|
235
|
-
if (key > maxKey) {
|
|
236
|
-
maxKey = key;
|
|
237
|
-
}
|
|
238
|
-
if (node.children) {
|
|
239
|
-
traverse(node.children); // Recorre para os filhos
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
traverse(categories);
|
|
245
|
-
return `${Math.floor(maxKey) + 1}`; // Retorna a próxima chave como um número inteiro
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
const newKey = getNextKey(gData); // Calcula a próxima chave disponível
|
|
249
|
-
|
|
250
|
-
setGData((prevCategories: DataNode[]) => [
|
|
251
|
-
...prevCategories,
|
|
252
|
-
{ title: t('components.category.newCategory'), key: newKey },
|
|
253
|
-
]);
|
|
254
|
-
|
|
255
|
-
setSidebarInfo([newKey]); // Atualiza o estado do sidebar
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
const removeCategory = () => {
|
|
260
|
-
if (sidebarInfo) {
|
|
261
|
-
// Update the state with the new array
|
|
262
|
-
setGData(remove_nested_element(gData, sidebarInfo[0]));
|
|
263
|
-
setSidebarInfo(undefined);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
useEffect(() => {
|
|
268
|
-
props.categorySidebarInfo({
|
|
269
|
-
selectKey: sidebarInfo,
|
|
270
|
-
data: get_element_by_index(gData, sidebarInfo && sidebarInfo[0]),
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
}, [sidebarInfo]);
|
|
274
|
-
|
|
275
|
-
function updateCategoryTitles(categories: any[]): any[] {
|
|
276
|
-
return categories.map((category: any, index: number) => {
|
|
277
|
-
if (category?.data) {
|
|
278
|
-
const titleWithoutCounts = category.title.replace(/\(Q: \d+\)/g, '').replace(/\(G: \d+\)/g, '').trim();
|
|
279
|
-
const updatedTitle = `${category?.data.categoryName ? category?.data.categoryName : titleWithoutCounts} ${category.data.questions ? '(Q: ' + category.data.questions.length + ')' : ''} ${category.data.grade ? '(G: ' + category.data.grade + ')' : ''}`;
|
|
280
|
-
const updatedChildren = category.children ? updateCategoryTitles(category.children) : null;
|
|
281
|
-
|
|
282
|
-
return { ...category, title: updatedTitle, categoryName: updatedTitle, children: updatedChildren };
|
|
283
|
-
}
|
|
284
|
-
return category;
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
useEffect(() => {
|
|
289
|
-
if (hasHeader) {
|
|
290
|
-
if (categoryContentData?.categoryName) {
|
|
291
|
-
const newGData = addPropertyByIndex(gData, sidebarInfo && sidebarInfo[0], "data", categoryContentData);
|
|
292
|
-
const updatedGData: any[] = updateCategoryTitles(newGData);
|
|
293
|
-
|
|
294
|
-
setGData(updatedGData);
|
|
295
|
-
}
|
|
296
|
-
} else {
|
|
297
|
-
const newGData = addPropertyByIndex(gData, sidebarInfo && sidebarInfo[0], "data", categoryContentData);
|
|
298
|
-
const updatedGData: any[] = updateCategoryTitles(newGData);
|
|
299
|
-
|
|
300
|
-
setGData(updatedGData);
|
|
301
|
-
}
|
|
302
|
-
}, [categoryContentData]);
|
|
303
|
-
|
|
304
|
-
useEffect(() => {
|
|
305
|
-
props.categorySidebarInfo({
|
|
306
|
-
selectKey: sidebarInfo,
|
|
307
|
-
data: get_element_by_index(gData, sidebarInfo && sidebarInfo[0])
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
props.categoryContentFinalData(gData);
|
|
311
|
-
}, [gData]);
|
|
312
|
-
|
|
313
|
-
return (
|
|
314
|
-
<div className={styles.categorySidebar}>
|
|
315
|
-
<div className={styles.title}>{t('components.categorySidBar.categories')}</div>
|
|
316
|
-
<Button icon={<PlusOutlined />} onClick={addCategory}>
|
|
317
|
-
{t('components.categorySidBar.addCategory')}
|
|
318
|
-
</Button>
|
|
319
|
-
|
|
320
|
-
{
|
|
321
|
-
sidebarInfo && (hasHeader ? sidebarInfo[0] !== '0' : true) && (
|
|
322
|
-
<Button icon={<MinusOutlined />} onClick={removeCategory}>
|
|
323
|
-
{t('components.categorySidBar.removeCategory')}
|
|
324
|
-
</Button>
|
|
325
|
-
)}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
<div className={styles.categoryViewer}>
|
|
329
|
-
<Tree
|
|
330
|
-
defaultSelectedKeys={hasHeader ? ["0"] : undefined}
|
|
331
|
-
className="draggable-tree"
|
|
332
|
-
defaultExpandedKeys={expandedKeys}
|
|
333
|
-
draggable
|
|
334
|
-
blockNode
|
|
335
|
-
onDragEnter={onDragEnter}
|
|
336
|
-
onDrop={onDrop}
|
|
337
|
-
treeData={gData}
|
|
338
|
-
onSelect={onSelect}
|
|
339
|
-
selectedKeys={sidebarInfo}
|
|
340
|
-
/>
|
|
341
|
-
</div>
|
|
342
|
-
</div>
|
|
343
|
-
);
|
|
344
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
.categorySidebar {
|
|
2
|
-
:global {
|
|
3
|
-
.ant-tree-title {
|
|
4
|
-
font-weight: var(--font-weight-semibold);
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
button {
|
|
9
|
-
margin-top: 32px;
|
|
10
|
-
width: 100%;
|
|
11
|
-
|
|
12
|
-
&:nth-child(3) {
|
|
13
|
-
margin-top: 12px;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.title {
|
|
19
|
-
font-size: var(--font-size-body-4);
|
|
20
|
-
font-weight: 600;
|
|
21
|
-
line-height: 100%;
|
|
22
|
-
color: var(--color-blue);
|
|
23
|
-
text-transform: uppercase;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.categoryViewer {
|
|
27
|
-
margin-top: 20px;
|
|
28
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import styles from './styles.module.scss';
|
|
2
|
-
import { CategorySidebar, DataNode } from './CategorySidebar';
|
|
3
|
-
import { useEffect, useState } from 'react';
|
|
4
|
-
import { CategoryContent } from './CategoryContent';
|
|
5
|
-
|
|
6
|
-
interface Category {
|
|
7
|
-
data: DataNode[];
|
|
8
|
-
serverReadyData: any;
|
|
9
|
-
chooseResponse?: boolean;
|
|
10
|
-
responseTypeOptions?: any;
|
|
11
|
-
hasHeader?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const Category = (props: Category) => {
|
|
15
|
-
const {
|
|
16
|
-
data,
|
|
17
|
-
chooseResponse,
|
|
18
|
-
responseTypeOptions,
|
|
19
|
-
hasHeader
|
|
20
|
-
} = props;
|
|
21
|
-
|
|
22
|
-
const [categoryContentInfo, setCategoryContentInfo] = useState<any>();
|
|
23
|
-
const [categorySidebarInfo, setCategorySidebarInfo] = useState<any>();
|
|
24
|
-
const [showContent, setShowContent] = useState<boolean>(false);
|
|
25
|
-
const [finalData, setFinalData] = useState<any>();
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
props.serverReadyData(finalData)
|
|
29
|
-
}, [finalData]);
|
|
30
|
-
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
setShowContent(categorySidebarInfo?.selectKey?.length);
|
|
33
|
-
}, [categorySidebarInfo]);
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<div className={styles.category}>
|
|
37
|
-
<div className={styles.sidebarWrapper}>
|
|
38
|
-
<CategorySidebar
|
|
39
|
-
categorySidebarInfo={setCategorySidebarInfo}
|
|
40
|
-
categoryContentData={categoryContentInfo}
|
|
41
|
-
data={data}
|
|
42
|
-
categoryContentFinalData={setFinalData}
|
|
43
|
-
hasHeader={hasHeader}
|
|
44
|
-
/>
|
|
45
|
-
</div>
|
|
46
|
-
<div className={styles.contentWrapper}>
|
|
47
|
-
<CategoryContent
|
|
48
|
-
chooseResponseType={chooseResponse}
|
|
49
|
-
responseTypeOptions={responseTypeOptions}
|
|
50
|
-
categoryContentInfo={setCategoryContentInfo}
|
|
51
|
-
categoryContentShow={showContent}
|
|
52
|
-
categorySidebarData={categorySidebarInfo}
|
|
53
|
-
hasHeader={hasHeader}
|
|
54
|
-
/>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
)
|
|
58
|
-
};
|