@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,37 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryFn } from "@storybook/react-vite";
|
|
2
|
-
import { Questions } from '.';
|
|
3
|
-
import { SearchOutlined } from '@ant-design/icons';
|
|
4
|
-
import { Button, Form, Input } from "antd";
|
|
5
|
-
import { useForm } from 'antd/lib/form/Form';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
title: 'Questions',
|
|
9
|
-
component: Questions,
|
|
10
|
-
} as Meta;
|
|
11
|
-
|
|
12
|
-
const Template: StoryFn<any> = (args: any) => {
|
|
13
|
-
const [form] = useForm();
|
|
14
|
-
|
|
15
|
-
const onFinish = (values: any) => {
|
|
16
|
-
console.log('Received values of form:', values);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<>
|
|
21
|
-
<Form
|
|
22
|
-
name="dynamic_form_nest_item"
|
|
23
|
-
onFinish={onFinish}
|
|
24
|
-
autoComplete="off"
|
|
25
|
-
form={form}
|
|
26
|
-
>
|
|
27
|
-
<Questions {...args}></Questions>
|
|
28
|
-
</Form>
|
|
29
|
-
<div style={{marginTop: '60px'}}></div>
|
|
30
|
-
<Button onClick={() => form.submit()}>Submit</Button>
|
|
31
|
-
</>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const Primary = Template.bind({});
|
|
36
|
-
Primary.args = {
|
|
37
|
-
};
|
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
import { DeleteOutlined, DownOutlined, HolderOutlined, InfoCircleOutlined } from '@ant-design/icons';
|
|
2
|
-
import { Checkbox, ColorPicker, Form, Input, Select, Space, Dropdown } from 'antd';
|
|
3
|
-
import { t } from 'i18next';
|
|
4
|
-
import styles from './styles.module.scss';
|
|
5
|
-
import { useEffect, useState } from 'react';
|
|
6
|
-
import classnames from 'classnames';
|
|
7
|
-
|
|
8
|
-
export const SingleQuestion = ({
|
|
9
|
-
key,
|
|
10
|
-
provided,
|
|
11
|
-
snapshot,
|
|
12
|
-
remove,
|
|
13
|
-
name,
|
|
14
|
-
showGrade,
|
|
15
|
-
handleChanges,
|
|
16
|
-
showCheckbox,
|
|
17
|
-
responseTypeOptions,
|
|
18
|
-
hasHeader,
|
|
19
|
-
isTheHeader,
|
|
20
|
-
responseTypeComponent,
|
|
21
|
-
form,
|
|
22
|
-
...restField
|
|
23
|
-
}: any) => {
|
|
24
|
-
|
|
25
|
-
const responseTypeCurrentValue = form?.getFieldsValue()?.questions?.[name]?.responseType;
|
|
26
|
-
const initialEmphasisValue = form?.getFieldsValue()?.questions?.[name]?.emphasis;
|
|
27
|
-
|
|
28
|
-
const [mandatoryCheckbox, setMandatoryCheckbox] = useState<boolean>(false);
|
|
29
|
-
const [emphasisCheckbox, setEmphasisCheckbox] = useState<boolean>(initialEmphasisValue ? initialEmphasisValue : true);
|
|
30
|
-
const [multipleChoiseCheckbox, setMultipleChoiseCheckbox] = useState<boolean>(false);
|
|
31
|
-
const [flaggedOptions, setFlaggedOptions] = useState([]);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const filteredResponsesMultiple = responseTypeOptions
|
|
35
|
-
?.filter((item: { IsMultipleChoise: any; }) => item.IsMultipleChoise)
|
|
36
|
-
?.map((item: { Id: any; }) => item.Id);
|
|
37
|
-
|
|
38
|
-
const filteredResponsesEmphasised = responseTypeOptions
|
|
39
|
-
?.filter((item: { IsEmphasis: any; }) => item.IsEmphasis)
|
|
40
|
-
?.map((item: { Id: any; }) => item.Id);
|
|
41
|
-
|
|
42
|
-
const sortedAnswerTypeOptions = responseTypeOptions?.sort((a: any, b: any) => {
|
|
43
|
-
return Number(a.IsMultipleChoise) - Number(b.IsMultipleChoise);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const answerTypeOptions = sortedAnswerTypeOptions?.map((answerType: any) => {
|
|
47
|
-
const formattedOptions = answerType.Options?.map((option: any, idx: number) => {
|
|
48
|
-
const flag = option.NeedsAction ? "🚩" : "";
|
|
49
|
-
return (
|
|
50
|
-
<span key={idx} style={{ color: option.Color }}>
|
|
51
|
-
{option.Value} ({option.Grade}) {flag}
|
|
52
|
-
</span>
|
|
53
|
-
);
|
|
54
|
-
}).reduce((acc: any[], curr: any, idx: number, arr: any[]) => {
|
|
55
|
-
if (idx === arr.length - 1) {
|
|
56
|
-
return acc.concat(curr);
|
|
57
|
-
} else {
|
|
58
|
-
return acc.concat(curr, ', ');
|
|
59
|
-
}
|
|
60
|
-
}, []);
|
|
61
|
-
|
|
62
|
-
return {
|
|
63
|
-
value: answerType.Id,
|
|
64
|
-
label: (
|
|
65
|
-
<div>{!answerType?.UseName ? formattedOptions : answerType.Name}</div>
|
|
66
|
-
),
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const handleResponseType = () => {
|
|
71
|
-
handleChanges();
|
|
72
|
-
setEmphasisCheckbox(true);
|
|
73
|
-
form.setFieldsValue({
|
|
74
|
-
questions: {
|
|
75
|
-
[name]: {
|
|
76
|
-
emphasis: true,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const onCheckboxMultipeChoiseHandler = (checked: boolean) => {
|
|
83
|
-
setMultipleChoiseCheckbox(checked);
|
|
84
|
-
handleChanges();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const onCheckboxMandatoryHandler = (checked: boolean) => {
|
|
88
|
-
setMandatoryCheckbox(checked);
|
|
89
|
-
handleChanges();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const onCheckboxEmphasisHandler = (checked: boolean) => {
|
|
93
|
-
setEmphasisCheckbox(checked);
|
|
94
|
-
handleChanges();
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
useEffect(() => {
|
|
98
|
-
const selectedResponseType = form?.getFieldValue(['questions', name, 'responseType']);
|
|
99
|
-
|
|
100
|
-
if (selectedResponseType) {
|
|
101
|
-
const selectedAnswerType = sortedAnswerTypeOptions.find(
|
|
102
|
-
(answerType: any) => answerType.Id === selectedResponseType
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
if (selectedAnswerType) {
|
|
106
|
-
const flagged = selectedAnswerType.Options?.filter((option: any) => option.NeedsAction) || [];
|
|
107
|
-
setFlaggedOptions(flagged);
|
|
108
|
-
}
|
|
109
|
-
} else {
|
|
110
|
-
setFlaggedOptions([]);
|
|
111
|
-
}
|
|
112
|
-
}, [responseTypeCurrentValue]);
|
|
113
|
-
|
|
114
|
-
const getFlaggedOptionsMenu = () => {
|
|
115
|
-
return flaggedOptions.map((option: any, idx) => ({
|
|
116
|
-
key: idx,
|
|
117
|
-
label: (
|
|
118
|
-
<span key={idx} style={{ color: option.Color }}>
|
|
119
|
-
{option.Value} ({option.Grade}) 🚩
|
|
120
|
-
</span>
|
|
121
|
-
),
|
|
122
|
-
}));
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const canDrag = !(restField.fieldKey === 0 && isTheHeader);
|
|
126
|
-
|
|
127
|
-
const questionStyle = classnames({
|
|
128
|
-
[styles.responseTypeQuestion]: responseTypeComponent
|
|
129
|
-
}, [styles.question]);
|
|
130
|
-
|
|
131
|
-
return (
|
|
132
|
-
<div
|
|
133
|
-
key={key}
|
|
134
|
-
ref={provided.innerRef}
|
|
135
|
-
snapshot={snapshot}
|
|
136
|
-
{...provided.draggableProps}
|
|
137
|
-
{...provided.dragHandleProps}
|
|
138
|
-
className={styles.dragItem}
|
|
139
|
-
>
|
|
140
|
-
<Space>
|
|
141
|
-
<div className={questionStyle}>
|
|
142
|
-
|
|
143
|
-
<div className={styles.drag}>
|
|
144
|
-
{canDrag &&
|
|
145
|
-
<HolderOutlined />
|
|
146
|
-
}
|
|
147
|
-
</div>
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
<div className={styles.content}>
|
|
151
|
-
<div className={styles.label}>
|
|
152
|
-
abc
|
|
153
|
-
</div>
|
|
154
|
-
|
|
155
|
-
<Form.Item
|
|
156
|
-
{...restField}
|
|
157
|
-
name={[name, 'question']}
|
|
158
|
-
rules={[{ required: true, message: t('components.category.answerNameIsMissing')! }]}
|
|
159
|
-
>
|
|
160
|
-
<Input
|
|
161
|
-
placeholder={!responseTypeComponent ? `${t('components.category.placeholderQuestion')}` : `${t('components.category.placeholderResponse')}`}
|
|
162
|
-
onMouseLeave={handleChanges}
|
|
163
|
-
/>
|
|
164
|
-
</Form.Item>
|
|
165
|
-
</div>
|
|
166
|
-
|
|
167
|
-
{canDrag &&
|
|
168
|
-
<div className={styles.actions}>
|
|
169
|
-
<div className={styles.delete}>
|
|
170
|
-
<DeleteOutlined onClick={() => remove(name)} />
|
|
171
|
-
</div>
|
|
172
|
-
</div>
|
|
173
|
-
}
|
|
174
|
-
</div>
|
|
175
|
-
|
|
176
|
-
{!responseTypeComponent &&
|
|
177
|
-
<div className={styles.information}>
|
|
178
|
-
<div className={styles.infoIcon}>
|
|
179
|
-
{!hasHeader && <InfoCircleOutlined />}
|
|
180
|
-
</div>
|
|
181
|
-
|
|
182
|
-
<div className={styles.content}>
|
|
183
|
-
<div className={styles.label}>
|
|
184
|
-
xpto
|
|
185
|
-
</div>
|
|
186
|
-
|
|
187
|
-
<Form.Item
|
|
188
|
-
{...restField}
|
|
189
|
-
name={[name, 'info']}
|
|
190
|
-
>
|
|
191
|
-
<Input placeholder={`${t('components.category.placeholderInfo')}`} onMouseLeave={handleChanges} />
|
|
192
|
-
</Form.Item>
|
|
193
|
-
</div>
|
|
194
|
-
|
|
195
|
-
{showGrade &&
|
|
196
|
-
<div className={styles.grade}>
|
|
197
|
-
<Form.Item
|
|
198
|
-
{...restField}
|
|
199
|
-
name={[name, 'grade']}
|
|
200
|
-
>
|
|
201
|
-
<Input placeholder={`${t('components.category.placeholderGrade')}`} onMouseLeave={handleChanges} />
|
|
202
|
-
</Form.Item>
|
|
203
|
-
</div>
|
|
204
|
-
}
|
|
205
|
-
</div>
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
{showCheckbox &&
|
|
209
|
-
<div className={styles.questionFooter}>
|
|
210
|
-
<div />
|
|
211
|
-
|
|
212
|
-
{!isTheHeader &&
|
|
213
|
-
<>
|
|
214
|
-
|
|
215
|
-
<div className={styles.checkboxContainer}>
|
|
216
|
-
<Form.Item
|
|
217
|
-
{...restField}
|
|
218
|
-
name={[name, 'mandatory']}
|
|
219
|
-
valuePropName='checked'
|
|
220
|
-
>
|
|
221
|
-
<Checkbox onChange={(e) => onCheckboxMandatoryHandler(e.target.checked)} checked={mandatoryCheckbox} />
|
|
222
|
-
</Form.Item>
|
|
223
|
-
|
|
224
|
-
<span>{t('components.category.mandatoryAnswer')}</span>
|
|
225
|
-
</div>
|
|
226
|
-
|
|
227
|
-
{filteredResponsesEmphasised?.includes(form?.getFieldsValue()?.questions?.[name]?.responseType) &&
|
|
228
|
-
<div className={styles.checkboxContainer}>
|
|
229
|
-
<Input
|
|
230
|
-
addonBefore={
|
|
231
|
-
<Form.Item
|
|
232
|
-
{...restField}
|
|
233
|
-
name={[name, 'emphasis']}
|
|
234
|
-
valuePropName='checked'
|
|
235
|
-
initialValue={initialEmphasisValue ? initialEmphasisValue : true}
|
|
236
|
-
>
|
|
237
|
-
<Checkbox
|
|
238
|
-
onChange={(e) => onCheckboxEmphasisHandler(e.target.checked)}
|
|
239
|
-
checked={emphasisCheckbox}
|
|
240
|
-
/>
|
|
241
|
-
</Form.Item>
|
|
242
|
-
}
|
|
243
|
-
addonAfter={
|
|
244
|
-
<Dropdown menu={{ items: getFlaggedOptionsMenu() }}>
|
|
245
|
-
<a>
|
|
246
|
-
<DownOutlined />
|
|
247
|
-
</a>
|
|
248
|
-
</Dropdown>
|
|
249
|
-
}
|
|
250
|
-
defaultValue={t('components.category.emphasisAnswer')!}
|
|
251
|
-
className={styles.emphasisInputStyle}
|
|
252
|
-
/>
|
|
253
|
-
</div>
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
{filteredResponsesMultiple?.includes(form?.getFieldsValue()?.questions?.[name]?.responseType) &&
|
|
257
|
-
< div className={styles.checkboxContainer}>
|
|
258
|
-
<Form.Item
|
|
259
|
-
{...restField}
|
|
260
|
-
name={[name, 'multipleChoise']}
|
|
261
|
-
valuePropName='checked'
|
|
262
|
-
>
|
|
263
|
-
<Checkbox onChange={(e) => onCheckboxMultipeChoiseHandler(e.target.checked)} checked={multipleChoiseCheckbox} />
|
|
264
|
-
</Form.Item>
|
|
265
|
-
|
|
266
|
-
<span>{t('components.category.multipleChoise')}</span>
|
|
267
|
-
</div>
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
</>
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
<div className={styles.checkboxContainer}>
|
|
274
|
-
<Form.Item
|
|
275
|
-
{...restField}
|
|
276
|
-
name={[name, 'responseType']}
|
|
277
|
-
initialValue={"-1"}
|
|
278
|
-
>
|
|
279
|
-
<Select
|
|
280
|
-
options={answerTypeOptions}
|
|
281
|
-
defaultValue={"-1"}
|
|
282
|
-
className={styles.selectResponseType}
|
|
283
|
-
onChange={handleResponseType}
|
|
284
|
-
dropdownStyle={{ minWidth: 500 }}
|
|
285
|
-
/>
|
|
286
|
-
</Form.Item>
|
|
287
|
-
<span>{t('components.category.responseType')}</span>
|
|
288
|
-
</div>
|
|
289
|
-
</div>
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
{
|
|
293
|
-
responseTypeComponent &&
|
|
294
|
-
<div className={styles.questionFooter}>
|
|
295
|
-
<div />
|
|
296
|
-
|
|
297
|
-
<div className={styles.checkboxContainer}>
|
|
298
|
-
<Form.Item
|
|
299
|
-
{...restField}
|
|
300
|
-
name={[name, 'color']}
|
|
301
|
-
>
|
|
302
|
-
<ColorPicker
|
|
303
|
-
size='small'
|
|
304
|
-
onChangeComplete={handleChanges}
|
|
305
|
-
defaultValue={"#00000"}
|
|
306
|
-
/>
|
|
307
|
-
</Form.Item>
|
|
308
|
-
|
|
309
|
-
<span>{t('components.category.color')}</span>
|
|
310
|
-
</div>
|
|
311
|
-
|
|
312
|
-
<div className={styles.checkboxContainer}>
|
|
313
|
-
<Form.Item
|
|
314
|
-
{...restField}
|
|
315
|
-
name={[name, 'flagged']}
|
|
316
|
-
valuePropName='checked'
|
|
317
|
-
>
|
|
318
|
-
<Checkbox onChange={handleChanges} />
|
|
319
|
-
</Form.Item>
|
|
320
|
-
|
|
321
|
-
<span>{t('components.category.flagged')}</span>
|
|
322
|
-
</div>
|
|
323
|
-
|
|
324
|
-
<div className={styles.checkboxContainer}>
|
|
325
|
-
<Form.Item
|
|
326
|
-
{...restField}
|
|
327
|
-
name={[name, 'score']}
|
|
328
|
-
>
|
|
329
|
-
<Input placeholder={`${t('components.category.placeholderScore')}`} onMouseLeave={handleChanges} />
|
|
330
|
-
</Form.Item>
|
|
331
|
-
</div>
|
|
332
|
-
</div>
|
|
333
|
-
}
|
|
334
|
-
</Space >
|
|
335
|
-
</div >
|
|
336
|
-
);
|
|
337
|
-
};
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
$actionsSpace: 90px;
|
|
2
|
-
$questionAndInformationGap: 20px;
|
|
3
|
-
|
|
4
|
-
.dragItem {
|
|
5
|
-
:global {
|
|
6
|
-
.ant-form-item {
|
|
7
|
-
margin-bottom: 0;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.ant-space {
|
|
11
|
-
display: flex;
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
gap: 12px;
|
|
14
|
-
border-bottom: 1px solid var(--color-blue);
|
|
15
|
-
padding: 16px 10px;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.ant-space-item {
|
|
19
|
-
width: 100%;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.label {
|
|
25
|
-
display: none;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.question {
|
|
29
|
-
display: grid;
|
|
30
|
-
grid-template-columns: minmax(18px, auto) 1fr $actionsSpace;
|
|
31
|
-
gap: $questionAndInformationGap;
|
|
32
|
-
color: var(--color-black);
|
|
33
|
-
font-size: var(--font-size-body-4);
|
|
34
|
-
line-height: 100%;
|
|
35
|
-
font-weight: var(--font-weight-medium);
|
|
36
|
-
align-items: center;
|
|
37
|
-
|
|
38
|
-
&.responseTypeQuestion {
|
|
39
|
-
max-width: 650px;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.information {
|
|
44
|
-
display: grid;
|
|
45
|
-
grid-template-columns: minmax(18px, auto) 1fr $actionsSpace;
|
|
46
|
-
gap: $questionAndInformationGap;
|
|
47
|
-
color: var(--color-grey-dark);
|
|
48
|
-
font-size: var(--font-size-body-3);
|
|
49
|
-
align-items: center;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.questionFooter {
|
|
53
|
-
display: flex;
|
|
54
|
-
gap: 40px;
|
|
55
|
-
font-size: var(--font-size-body-3);
|
|
56
|
-
align-items: center;
|
|
57
|
-
|
|
58
|
-
@media(max-width: 768px) {
|
|
59
|
-
gap: 12px;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.checkboxContainer {
|
|
64
|
-
display: flex;
|
|
65
|
-
align-items: center;
|
|
66
|
-
gap: 8px;
|
|
67
|
-
|
|
68
|
-
@media(max-width: 768px) {
|
|
69
|
-
width: 100%;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.actions {
|
|
74
|
-
display: flex;
|
|
75
|
-
align-items: center;
|
|
76
|
-
justify-content: flex-start;
|
|
77
|
-
gap: 20px;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.selectResponseType {
|
|
81
|
-
min-width: 200px;
|
|
82
|
-
max-width: 450px;
|
|
83
|
-
|
|
84
|
-
@media(max-width: 768px) {
|
|
85
|
-
min-width: 100px;
|
|
86
|
-
max-width: 250px;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.notEditing {
|
|
91
|
-
display: none;
|
|
92
|
-
align-items: center;
|
|
93
|
-
justify-content: center;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.editing {
|
|
97
|
-
display: flex;
|
|
98
|
-
align-items: center;
|
|
99
|
-
justify-content: center;
|
|
100
|
-
gap: 16px;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.drag,
|
|
104
|
-
.edit,
|
|
105
|
-
.delete {
|
|
106
|
-
font-size: var(--font-size-body-5);
|
|
107
|
-
cursor: pointer;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.addQuestion {
|
|
111
|
-
margin-top: 24px;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.emphasisInputStyle {
|
|
115
|
-
width: 150px;
|
|
116
|
-
pointer-events: none;
|
|
117
|
-
|
|
118
|
-
:global {
|
|
119
|
-
.ant-input-group-addon {
|
|
120
|
-
pointer-events: auto;
|
|
121
|
-
padding: 0 8px;
|
|
122
|
-
background: rgba(0, 0, 0, 0.01);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.ant-input {
|
|
126
|
-
height: 35px;
|
|
127
|
-
text-align: center;
|
|
128
|
-
padding: unset;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
:where(.css-dev-only-do-not-override-f7vrd6).ant-space-align-center {
|
|
132
|
-
padding: 0 2px;
|
|
133
|
-
border-bottom: unset;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
:global {
|
|
139
|
-
:where(.css-dev-only-do-not-override-f7vrd6).ant-cascader-dropdown .ant-cascader-menu-item-disabled {
|
|
140
|
-
color: unset;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { PlusOutlined } from '@ant-design/icons';
|
|
2
|
-
import { Form } from 'antd';
|
|
3
|
-
import { DragDropContext, Droppable, Draggable } from '@hello-pangea/dnd';
|
|
4
|
-
import { SingleQuestion } from "./SingleQuestion";
|
|
5
|
-
import { Link } from '../Link';
|
|
6
|
-
import { t } from 'i18next';
|
|
7
|
-
|
|
8
|
-
export interface QuestionsProps {
|
|
9
|
-
showGrade?: boolean;
|
|
10
|
-
showCheckbox?: boolean;
|
|
11
|
-
handleChanges: any;
|
|
12
|
-
responseTypeOptions: any;
|
|
13
|
-
hasHeader?: boolean;
|
|
14
|
-
isTheHeader?: boolean;
|
|
15
|
-
responseTypeComponent?: boolean;
|
|
16
|
-
form?: any
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const Questions = (props: QuestionsProps) => {
|
|
20
|
-
const {
|
|
21
|
-
showGrade = true,
|
|
22
|
-
showCheckbox,
|
|
23
|
-
handleChanges,
|
|
24
|
-
responseTypeOptions,
|
|
25
|
-
hasHeader,
|
|
26
|
-
responseTypeComponent,
|
|
27
|
-
isTheHeader
|
|
28
|
-
} = props;
|
|
29
|
-
|
|
30
|
-
const items = Form.useWatch('questions');
|
|
31
|
-
|
|
32
|
-
const onDragEnd = (result: any) => {
|
|
33
|
-
if (!result.destination) return; // Se o destino for inválido, não faz nada
|
|
34
|
-
|
|
35
|
-
const sourceIndex = result?.source?.index;
|
|
36
|
-
const destinationIndex = result?.destination?.index;
|
|
37
|
-
|
|
38
|
-
// Bloquear drag-and-drop apenas para os itens 0 e 1 quando isTheHeader for true
|
|
39
|
-
const isProtectedSource = (sourceIndex === 0 && isTheHeader);
|
|
40
|
-
const isProtectedDestination = (destinationIndex === 0 && isTheHeader);
|
|
41
|
-
|
|
42
|
-
if (isProtectedSource || isProtectedDestination) {
|
|
43
|
-
return; // Impede o drag-and-drop se for um dos itens protegidos
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const newItems: any = [...items];
|
|
47
|
-
|
|
48
|
-
const [removed] = newItems.splice(result?.source?.index, 1);
|
|
49
|
-
|
|
50
|
-
newItems.splice(result.destination?.index, 0, removed);
|
|
51
|
-
|
|
52
|
-
console.log(props?.form?.setFieldValue('questions', newItems), "props?.form?.setFieldValue('questions', newItems)");
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<Form.List name="questions">
|
|
57
|
-
{(fields, { add, remove }) => {
|
|
58
|
-
const customRemove = (name: number) => {
|
|
59
|
-
remove(name);
|
|
60
|
-
|
|
61
|
-
setTimeout(() => {
|
|
62
|
-
handleChanges();
|
|
63
|
-
}, 1);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const fieldsUpdated = fields?.map((field, index) => {
|
|
67
|
-
return field = { ...field, name: index, key: index, fieldKey: index };
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<>
|
|
72
|
-
<DragDropContext onDragEnd={onDragEnd}>
|
|
73
|
-
<Droppable droppableId="droppable">
|
|
74
|
-
{(provided) => (
|
|
75
|
-
<div {...provided.droppableProps} ref={provided.innerRef}>
|
|
76
|
-
<>
|
|
77
|
-
{fieldsUpdated?.map(({ key, name, ...restField }) => {
|
|
78
|
-
const cantDrag = (restField.fieldKey === 0 && isTheHeader);
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<Draggable isDragDisabled={cantDrag} key={key} draggableId={`${key}`} index={key}>
|
|
82
|
-
{(provided, snapshot) => (
|
|
83
|
-
<>
|
|
84
|
-
<SingleQuestion
|
|
85
|
-
provided={provided}
|
|
86
|
-
snapshot={snapshot}
|
|
87
|
-
item={name}
|
|
88
|
-
{...restField}
|
|
89
|
-
remove={customRemove}
|
|
90
|
-
name={name}
|
|
91
|
-
showGrade={showGrade}
|
|
92
|
-
showCheckbox={showCheckbox}
|
|
93
|
-
handleChanges={handleChanges}
|
|
94
|
-
responseTypeOptions={responseTypeOptions}
|
|
95
|
-
hasHeader={hasHeader}
|
|
96
|
-
isTheHeader={isTheHeader}
|
|
97
|
-
responseTypeComponent={responseTypeComponent}
|
|
98
|
-
form={props.form}
|
|
99
|
-
/>
|
|
100
|
-
</>
|
|
101
|
-
)}
|
|
102
|
-
</Draggable>
|
|
103
|
-
)
|
|
104
|
-
})}
|
|
105
|
-
</>
|
|
106
|
-
{provided.placeholder}
|
|
107
|
-
</div>
|
|
108
|
-
)}
|
|
109
|
-
</Droppable>
|
|
110
|
-
</DragDropContext>
|
|
111
|
-
<Form.Item>
|
|
112
|
-
<Link
|
|
113
|
-
icon={<PlusOutlined />}
|
|
114
|
-
onClick={() => add()}
|
|
115
|
-
>
|
|
116
|
-
{!responseTypeComponent ? `${t('components.category.addQuestion')}` : `${t('components.category.placeholderResponse')}`}
|
|
117
|
-
</Link>
|
|
118
|
-
</Form.Item>
|
|
119
|
-
</>
|
|
120
|
-
)
|
|
121
|
-
}}
|
|
122
|
-
</Form.List>
|
|
123
|
-
);
|
|
124
|
-
}
|
|
File without changes
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryFn } from "@storybook/react-vite";
|
|
2
|
-
import { Radio as RadioAntd, RadioChangeEvent, RadioProps } from "antd";
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import { Radio, RadioGroup } from '.';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Radio',
|
|
8
|
-
component: Radio,
|
|
9
|
-
} as Meta;
|
|
10
|
-
|
|
11
|
-
const Template: StoryFn<RadioProps> = (args: any) => {
|
|
12
|
-
const [value, setValue] = useState();
|
|
13
|
-
|
|
14
|
-
const onChange = (e: RadioChangeEvent) => {
|
|
15
|
-
console.log('radio checked', e.target.value);
|
|
16
|
-
setValue(e.target.value);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<div>
|
|
21
|
-
<RadioAntd.Group onChange={onChange} value={value} defaultValue={3}>
|
|
22
|
-
<Radio {...args} value={1}></Radio>
|
|
23
|
-
<Radio {...args} value={2}></Radio>
|
|
24
|
-
<Radio {...args} value={3}></Radio>
|
|
25
|
-
<Radio {...args} value={4}></Radio>
|
|
26
|
-
</RadioAntd.Group>
|
|
27
|
-
|
|
28
|
-
<RadioGroup
|
|
29
|
-
options={[
|
|
30
|
-
{ label: 'Option 1', value: '1' },
|
|
31
|
-
{ label: 'Option 2', value: '2' },
|
|
32
|
-
{ label: 'Option 3', value: '3' },
|
|
33
|
-
]}
|
|
34
|
-
onChange={onChange}
|
|
35
|
-
/>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
)
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const Primary = Template.bind({});
|
|
42
|
-
Primary.args = {
|
|
43
|
-
};
|