tycho-components 0.0.3 → 0.0.5-SNAPSHOT
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/dist/AppColorpicker/AppColorpicker.d.ts +10 -0
- package/dist/AppColorpicker/AppColorpicker.js +21 -0
- package/{src/AppColorpicker/index.tsx → dist/AppColorpicker/index.d.ts} +0 -1
- package/dist/AppColorpicker/index.js +2 -0
- package/dist/AppEditable/AppEditable.d.ts +14 -0
- package/dist/AppEditable/AppEditable.js +80 -0
- package/dist/AppEditable/AppEditableField.d.ts +7 -0
- package/dist/AppEditable/AppEditableField.js +1 -0
- package/dist/AppEditable/FormField.d.ts +14 -0
- package/dist/AppEditable/FormField.js +8 -0
- package/dist/AppEditable/FormFieldOption.d.ts +7 -0
- package/dist/AppEditable/FormFieldOption.js +20 -0
- package/{src/AppEditable/index.tsx → dist/AppEditable/index.d.ts} +0 -1
- package/dist/AppEditable/index.js +2 -0
- package/dist/AppModal/AppModal.d.ts +20 -0
- package/dist/AppModal/AppModal.js +22 -0
- package/dist/AppModal/AppModalConfirm.d.ts +11 -0
- package/dist/AppModal/AppModalConfirm.js +20 -0
- package/dist/AppModal/AppModalRemove.d.ts +9 -0
- package/dist/AppModal/AppModalRemove.js +20 -0
- package/{src/AppModal/index.tsx → dist/AppModal/index.d.ts} +0 -1
- package/dist/AppModal/index.js +2 -0
- package/dist/AppToast/AppToast.d.ts +2 -0
- package/dist/AppToast/AppToast.js +78 -0
- package/dist/AppToast/ToastMessage.d.ts +8 -0
- package/dist/AppToast/ToastMessage.js +4 -0
- package/{src/AppToast/index.tsx → dist/AppToast/index.d.ts} +0 -1
- package/dist/AppToast/index.js +2 -0
- package/dist/Dummy/Dummy.d.ts +9 -0
- package/dist/Dummy/Dummy.js +8 -0
- package/{src/Dummy/index.tsx → dist/Dummy/index.d.ts} +0 -1
- package/dist/Dummy/index.js +2 -0
- package/dist/Participants/ParticipantCreate/ParticipantCreate.d.ts +9 -0
- package/dist/Participants/ParticipantCreate/ParticipantCreate.js +41 -0
- package/{src/Participants/ParticipantCreate/index.tsx → dist/Participants/ParticipantCreate/index.d.ts} +0 -1
- package/dist/Participants/ParticipantCreate/index.js +2 -0
- package/dist/Participants/ParticipantRemove/ParticipantRemove.d.ts +11 -0
- package/dist/Participants/ParticipantRemove/ParticipantRemove.js +26 -0
- package/{src/Participants/ParticipantRemove/index.tsx → dist/Participants/ParticipantRemove/index.d.ts} +0 -1
- package/dist/Participants/ParticipantRemove/index.js +2 -0
- package/dist/Participants/Participants.d.ts +9 -0
- package/dist/Participants/Participants.js +57 -0
- package/{src/Participants/index.tsx → dist/Participants/index.d.ts} +0 -1
- package/dist/Participants/index.js +2 -0
- package/dist/Participants/types/Participant.d.ts +27 -0
- package/dist/Participants/types/Participant.js +17 -0
- package/dist/Participants/types/ParticipantService.d.ts +11 -0
- package/dist/Participants/types/ParticipantService.js +12 -0
- package/dist/configs/CommonContext.d.ts +10 -0
- package/dist/configs/CommonContext.js +10 -0
- package/dist/configs/CookieStorage.d.ts +10 -0
- package/dist/configs/CookieStorage.js +28 -0
- package/dist/configs/Localization.d.ts +64 -0
- package/dist/configs/Localization.js +28 -0
- package/dist/configs/MessageUtils.d.ts +20 -0
- package/dist/configs/MessageUtils.js +30 -0
- package/dist/configs/Storage.d.ts +9 -0
- package/dist/configs/Storage.js +16 -0
- package/dist/configs/api.d.ts +2 -0
- package/dist/configs/api.js +38 -0
- package/dist/configs/localization/CommonTexts.d.ts +27 -0
- package/dist/configs/localization/CommonTexts.js +27 -0
- package/dist/configs/localization/ParticipantsTexts.d.ts +34 -0
- package/dist/configs/localization/ParticipantsTexts.js +34 -0
- package/dist/configs/store/actions.d.ts +4 -0
- package/dist/configs/store/actions.js +9 -0
- package/dist/configs/store/reducer.d.ts +3 -0
- package/dist/configs/store/reducer.js +19 -0
- package/dist/configs/store/store.d.ts +3 -0
- package/dist/configs/store/store.js +6 -0
- package/dist/configs/store/types.d.ts +13 -0
- package/dist/configs/store/types.js +4 -0
- package/{src/index.ts → dist/index.d.ts} +2 -1
- package/dist/index.js +9 -0
- package/package.json +34 -23
- package/.eslintignore +0 -2
- package/.eslintrc.cjs +0 -28
- package/.eslintrc.json +0 -31
- package/.gitlab-ci.yml +0 -14
- package/.storybook/main.ts +0 -32
- package/.storybook/preview-head.html +0 -4
- package/.storybook/preview.css +0 -6
- package/.storybook/preview.tsx +0 -29
- package/src/AppColorpicker/AppColorpicker.tsx +0 -69
- package/src/AppEditable/AppEditable.tsx +0 -280
- package/src/AppEditable/AppEditableField.ts +0 -7
- package/src/AppEditable/FormField.ts +0 -26
- package/src/AppEditable/FormFieldOption.ts +0 -38
- package/src/AppModal/AppModal.tsx +0 -95
- package/src/AppModal/AppModalConfirm.tsx +0 -61
- package/src/AppModal/AppModalRemove.tsx +0 -56
- package/src/AppToast/AppToast.tsx +0 -94
- package/src/AppToast/ToastMessage.ts +0 -9
- package/src/Dummy/Dummy.stories.tsx +0 -21
- package/src/Dummy/Dummy.tsx +0 -16
- package/src/Participants/ParticipantCreate/ParticipantCreate.tsx +0 -83
- package/src/Participants/ParticipantRemove/ParticipantRemove.tsx +0 -51
- package/src/Participants/Participants.stories.tsx +0 -45
- package/src/Participants/Participants.tsx +0 -145
- package/src/Participants/types/Participant.ts +0 -43
- package/src/Participants/types/ParticipantService.ts +0 -18
- package/src/TextField/TextField.stories.tsx +0 -54
- package/src/TextField/TextField.tsx +0 -172
- package/src/TextField/TextFieldTheme.ts +0 -70
- package/src/TextField/index.tsx +0 -3
- package/src/TextField/inputRefManager.ts +0 -24
- package/src/TextField/styles.scss +0 -36
- package/src/configs/CommonContext.tsx +0 -23
- package/src/configs/CookieStorage.ts +0 -36
- package/src/configs/Localization.ts +0 -28
- package/src/configs/MessageUtils.ts +0 -60
- package/src/configs/Storage.ts +0 -21
- package/src/configs/api.ts +0 -49
- package/src/configs/localization/CommonTexts.ts +0 -27
- package/src/configs/localization/ParticipantsTexts.ts +0 -40
- package/src/configs/store/actions.ts +0 -12
- package/src/configs/store/reducer.ts +0 -22
- package/src/configs/store/store.ts +0 -9
- package/src/configs/store/types.ts +0 -16
- package/src/react-app-env.d.ts +0 -5
- package/src/vite-env.d.ts +0 -13
- package/stories/Configure.mdx +0 -171
- package/stories/StorybookUtils.tsx +0 -40
- package/tsconfig.json +0 -31
- package/tsconfig.node.json +0 -10
- package/vite.config.ts +0 -26
- /package/{src → dist}/AppColorpicker/style.scss +0 -0
- /package/{src → dist}/AppEditable/style.scss +0 -0
- /package/{src → dist}/AppModal/style.scss +0 -0
- /package/{src → dist}/AppToast/style.scss +0 -0
- /package/{src → dist}/Dummy/styles.scss +0 -0
- /package/{src → dist}/Participants/ParticipantCreate/style.scss +0 -0
- /package/{src → dist}/Participants/ParticipantRemove/style.scss +0 -0
- /package/{src → dist}/Participants/style.scss +0 -0
- /package/{src → dist}/new-styles/base/_borders.scss +0 -0
- /package/{src → dist}/new-styles/base/_colors.scss +0 -0
- /package/{src → dist}/new-styles/base/_displays.scss +0 -0
- /package/{src → dist}/new-styles/base/_margins.css +0 -0
- /package/{src → dist}/new-styles/base/_spacing.scss +0 -0
- /package/{src → dist}/new-styles/base/_tokens.scss +0 -0
- /package/{src → dist}/new-styles/base/_typographs.scss +0 -0
- /package/{src → dist}/new-styles/main.scss +0 -0
- /package/{src → dist}/styles/_variables.scss +0 -0
- /package/{src → dist}/styles/bootstrap.min.css +0 -0
- /package/{src → dist}/styles/main.scss +0 -0
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import FormField from '../../AppEditable/FormField';
|
|
2
|
-
|
|
3
|
-
type Participant = {
|
|
4
|
-
order: number;
|
|
5
|
-
code: string;
|
|
6
|
-
name: string;
|
|
7
|
-
color?: string;
|
|
8
|
-
role?: string;
|
|
9
|
-
ses?: string;
|
|
10
|
-
education?: string;
|
|
11
|
-
gender?: string;
|
|
12
|
-
custom?: string;
|
|
13
|
-
corpus?: string;
|
|
14
|
-
language?: string;
|
|
15
|
-
age?: string;
|
|
16
|
-
group?: string;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type ParticipantCreateRequest = {
|
|
20
|
-
code: string;
|
|
21
|
-
name: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const EMPTY_PARTICIPANT = {
|
|
25
|
-
order: 1,
|
|
26
|
-
code: '',
|
|
27
|
-
name: '',
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const PARTICIPANT_FIELDS: FormField[] = [
|
|
31
|
-
{ name: 'order', type: 'text', required: true },
|
|
32
|
-
{ name: 'code', type: 'text', required: true },
|
|
33
|
-
{ name: 'name', type: 'text', required: false },
|
|
34
|
-
{ name: 'separator', type: 'text', required: false },
|
|
35
|
-
{
|
|
36
|
-
name: 'color',
|
|
37
|
-
type: 'color',
|
|
38
|
-
required: false,
|
|
39
|
-
tooltip: 'field.color.tooltip',
|
|
40
|
-
},
|
|
41
|
-
];
|
|
42
|
-
|
|
43
|
-
export default Participant;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import AppEditableField from '../../AppEditable/AppEditableField';
|
|
2
|
-
import api from '../../configs/api';
|
|
3
|
-
import Participant, { ParticipantCreateRequest } from './Participant';
|
|
4
|
-
|
|
5
|
-
function add(uid: string, request: ParticipantCreateRequest) {
|
|
6
|
-
return api.post<Participant>(`/participant/${uid}`, request);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function update(field: AppEditableField) {
|
|
10
|
-
return api.patch('/participant/update', field);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function remove(document: string, code: string) {
|
|
14
|
-
return api.delete(`/participant/${document}/${code}`);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const ParticipantService = { add, update, remove };
|
|
18
|
-
export default ParticipantService;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { useForm } from 'react-hook-form';
|
|
3
|
-
import TextField from './TextField';
|
|
4
|
-
|
|
5
|
-
const meta = {
|
|
6
|
-
title: 'Components/TextField',
|
|
7
|
-
component: TextField,
|
|
8
|
-
parameters: {
|
|
9
|
-
layout: 'padded',
|
|
10
|
-
},
|
|
11
|
-
tags: ['autodocs'],
|
|
12
|
-
argTypes: {
|
|
13
|
-
label: { control: 'text' },
|
|
14
|
-
attr: { control: 'text' },
|
|
15
|
-
createdForm: { control: false },
|
|
16
|
-
className: { control: 'text' },
|
|
17
|
-
title: { control: 'text' },
|
|
18
|
-
placeholder: { control: 'text' },
|
|
19
|
-
disabled: { control: 'boolean' },
|
|
20
|
-
multiline: { control: 'boolean' },
|
|
21
|
-
maxChars: { control: 'text' },
|
|
22
|
-
showEndAdornment: { control: 'boolean' },
|
|
23
|
-
onChange: { action: 'changed' },
|
|
24
|
-
},
|
|
25
|
-
} satisfies Meta<typeof TextField>;
|
|
26
|
-
|
|
27
|
-
export default meta;
|
|
28
|
-
type Story = StoryObj<typeof meta>;
|
|
29
|
-
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
-
const template = (args: any) => {
|
|
32
|
-
const createdForm = useForm({
|
|
33
|
-
defaultValues: {
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
35
|
-
[args.attr]: '',
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
-
const handleChange = (attr: string, value: any) => {
|
|
41
|
-
console.log(`Attribute: ${attr}, Value: ${String(value)}`);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<TextField {...args} createdForm={createdForm} onChange={handleChange} />
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const Default = template.bind({});
|
|
50
|
-
// @ts-expect-error: Suppress error for args property assignment
|
|
51
|
-
Default.args = {
|
|
52
|
-
attr: 'title',
|
|
53
|
-
label: 'Title',
|
|
54
|
-
};
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
|
|
2
|
-
import { InputAdornment, TextField as MuiTextField } from '@mui/material';
|
|
3
|
-
import { ThemeProvider, useTheme } from '@mui/material/styles';
|
|
4
|
-
import cx from 'classnames';
|
|
5
|
-
import { useEffect, useState } from 'react';
|
|
6
|
-
import { Controller, UseFormReturn } from 'react-hook-form';
|
|
7
|
-
import { textFieldTheme } from './TextFieldTheme';
|
|
8
|
-
import { setCurrentInput } from './inputRefManager';
|
|
9
|
-
import './styles.scss';
|
|
10
|
-
|
|
11
|
-
type Props = {
|
|
12
|
-
attr: string;
|
|
13
|
-
label: string;
|
|
14
|
-
createdForm: UseFormReturn<any, any, any>;
|
|
15
|
-
className?: string;
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
multiline?: boolean;
|
|
18
|
-
title?: string;
|
|
19
|
-
placeholder?: string;
|
|
20
|
-
maxChars?: number;
|
|
21
|
-
required?: boolean;
|
|
22
|
-
showEndAdornment?: boolean;
|
|
23
|
-
startAdornment?: React.ReactNode;
|
|
24
|
-
onChange?: (attr: string, value: any) => void;
|
|
25
|
-
onFocus?: (
|
|
26
|
-
e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement, Element>
|
|
27
|
-
) => void;
|
|
28
|
-
onRemove?: () => void;
|
|
29
|
-
password?: boolean;
|
|
30
|
-
rows?: number;
|
|
31
|
-
hideInfoIcon?: boolean;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export default function TextField({
|
|
35
|
-
className,
|
|
36
|
-
attr,
|
|
37
|
-
label,
|
|
38
|
-
createdForm,
|
|
39
|
-
disabled,
|
|
40
|
-
title,
|
|
41
|
-
placeholder,
|
|
42
|
-
multiline,
|
|
43
|
-
maxChars,
|
|
44
|
-
required,
|
|
45
|
-
startAdornment,
|
|
46
|
-
showEndAdornment = true,
|
|
47
|
-
onChange,
|
|
48
|
-
onFocus,
|
|
49
|
-
onRemove,
|
|
50
|
-
password,
|
|
51
|
-
rows = 4,
|
|
52
|
-
hideInfoIcon,
|
|
53
|
-
}: Props) {
|
|
54
|
-
const outerTheme = useTheme();
|
|
55
|
-
const [showPassword, setShowPassword] = useState(false);
|
|
56
|
-
const [active, setActive] = useState(false);
|
|
57
|
-
const [focus, setFocus] = useState(false);
|
|
58
|
-
const [mouseOver, setMouseOver] = useState(false);
|
|
59
|
-
|
|
60
|
-
const hasError = () => createdForm.formState.errors[attr];
|
|
61
|
-
|
|
62
|
-
const getClassNames = cx('ds-input-text', className, {
|
|
63
|
-
disabled: disabled,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
if (focus || mouseOver) {
|
|
68
|
-
setActive(true);
|
|
69
|
-
} else {
|
|
70
|
-
setActive(false);
|
|
71
|
-
}
|
|
72
|
-
}, [focus, mouseOver]);
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<div className={getClassNames}>
|
|
76
|
-
<Controller
|
|
77
|
-
name={attr}
|
|
78
|
-
control={createdForm.control}
|
|
79
|
-
render={({ field }) => (
|
|
80
|
-
<ThemeProvider theme={textFieldTheme(outerTheme)}>
|
|
81
|
-
<MuiTextField
|
|
82
|
-
{...field}
|
|
83
|
-
label={label}
|
|
84
|
-
value={field.value || ''}
|
|
85
|
-
type={
|
|
86
|
-
password === undefined
|
|
87
|
-
? 'text'
|
|
88
|
-
: showPassword
|
|
89
|
-
? 'text'
|
|
90
|
-
: 'password'
|
|
91
|
-
}
|
|
92
|
-
fullWidth
|
|
93
|
-
required={required}
|
|
94
|
-
disabled={disabled}
|
|
95
|
-
variant="filled"
|
|
96
|
-
placeholder={!focus ? placeholder : ''}
|
|
97
|
-
color="error"
|
|
98
|
-
multiline={multiline}
|
|
99
|
-
minRows={rows}
|
|
100
|
-
slotProps={{
|
|
101
|
-
inputLabel: {
|
|
102
|
-
shrink: true,
|
|
103
|
-
},
|
|
104
|
-
}}
|
|
105
|
-
onFocus={(e) => {
|
|
106
|
-
setCurrentInput(e.target, (e: any) => {
|
|
107
|
-
field.onChange(e);
|
|
108
|
-
onChange && onChange(attr, e.target.value);
|
|
109
|
-
});
|
|
110
|
-
setFocus(true);
|
|
111
|
-
onFocus && onFocus(e);
|
|
112
|
-
}}
|
|
113
|
-
onBlur={() => setFocus(false)}
|
|
114
|
-
onMouseOver={() => setMouseOver(true)}
|
|
115
|
-
onMouseOut={() => setMouseOver(false)}
|
|
116
|
-
onChange={(event) => {
|
|
117
|
-
field.onChange(event);
|
|
118
|
-
onChange && onChange(attr, event.target.value);
|
|
119
|
-
}}
|
|
120
|
-
sx={{
|
|
121
|
-
borderColor: disabled
|
|
122
|
-
? '#BEBFC1'
|
|
123
|
-
: hasError()
|
|
124
|
-
? '#C6080A'
|
|
125
|
-
: active
|
|
126
|
-
? '#1C83F4'
|
|
127
|
-
: '#BEBFC1',
|
|
128
|
-
'.MuiInputLabel-root': {
|
|
129
|
-
color: disabled
|
|
130
|
-
? '#BEBFC1'
|
|
131
|
-
: hasError()
|
|
132
|
-
? '#C6080A'
|
|
133
|
-
: active
|
|
134
|
-
? '#1C83F4'
|
|
135
|
-
: '#000000',
|
|
136
|
-
},
|
|
137
|
-
'.MuiInputBase-root': {
|
|
138
|
-
paddingTop: multiline ? '12px' : '4px',
|
|
139
|
-
height: multiline ? 'auto' : '48px',
|
|
140
|
-
},
|
|
141
|
-
'& .MuiInputBase-inputMultiline': {
|
|
142
|
-
paddingTop: '24px',
|
|
143
|
-
paddingBottom: '16px',
|
|
144
|
-
},
|
|
145
|
-
'& .MuiInputBase-input': {
|
|
146
|
-
paddingTop: multiline ? 'none' : '16px',
|
|
147
|
-
},
|
|
148
|
-
'& .MuiInputAdornment-positionEnd': {
|
|
149
|
-
paddingTop: multiline ? '12px' : '0px',
|
|
150
|
-
},
|
|
151
|
-
}}
|
|
152
|
-
/>
|
|
153
|
-
|
|
154
|
-
{maxChars && (
|
|
155
|
-
<div className="character-counter">
|
|
156
|
-
{field.value?.length || 0}/{maxChars}
|
|
157
|
-
</div>
|
|
158
|
-
)}
|
|
159
|
-
|
|
160
|
-
{title && !hasError() && <div className="helper">{title}</div>}
|
|
161
|
-
|
|
162
|
-
{hasError() && (
|
|
163
|
-
<div className="helper error">
|
|
164
|
-
{String(createdForm.formState.errors[attr]?.message)}
|
|
165
|
-
</div>
|
|
166
|
-
)}
|
|
167
|
-
</ThemeProvider>
|
|
168
|
-
)}
|
|
169
|
-
/>
|
|
170
|
-
</div>
|
|
171
|
-
);
|
|
172
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { createTheme, Theme } from '@mui/material/styles';
|
|
2
|
-
|
|
3
|
-
export const textFieldTheme = (outerTheme: Theme) =>
|
|
4
|
-
createTheme({
|
|
5
|
-
...outerTheme,
|
|
6
|
-
components: {
|
|
7
|
-
MuiTextField: {
|
|
8
|
-
styleOverrides: {
|
|
9
|
-
root: {
|
|
10
|
-
backgroundColor: 'white',
|
|
11
|
-
padding: '0px',
|
|
12
|
-
border: '1px solid #EAEAEB',
|
|
13
|
-
borderRadius: '4px',
|
|
14
|
-
'& .MuiInputBase-root': {
|
|
15
|
-
padding: '0px!important',
|
|
16
|
-
backgroundColor: 'white',
|
|
17
|
-
borderBottomLeftRadius: '4px',
|
|
18
|
-
borderBottomRightRadius: '4px',
|
|
19
|
-
},
|
|
20
|
-
'& .MuiFilledInput-root::before': {
|
|
21
|
-
content: 'none',
|
|
22
|
-
},
|
|
23
|
-
'& .MuiFilledInput-root::after': {
|
|
24
|
-
content: 'none',
|
|
25
|
-
},
|
|
26
|
-
'& .MuiInputLabel-root': {
|
|
27
|
-
paddingLeft: '4px',
|
|
28
|
-
color: '#000000',
|
|
29
|
-
textTransform: 'uppercase',
|
|
30
|
-
// helper-medium-1
|
|
31
|
-
fontSize: '12px',
|
|
32
|
-
fontWeight: '400',
|
|
33
|
-
lineHeight: '100%',
|
|
34
|
-
letterSpacing: '0.16px',
|
|
35
|
-
fontFamily: 'Work Sans, sans-serif',
|
|
36
|
-
},
|
|
37
|
-
'& .MuiInputAdornment-root': {
|
|
38
|
-
height: '100%',
|
|
39
|
-
maxHeight: '100%',
|
|
40
|
-
},
|
|
41
|
-
'& .MuiInputAdornment-positionStart': {
|
|
42
|
-
margin: '0px!important',
|
|
43
|
-
padding: '0px!important',
|
|
44
|
-
},
|
|
45
|
-
'& .MuiInputAdornment-positionEnd': {
|
|
46
|
-
margin: '0px 16px auto!important',
|
|
47
|
-
},
|
|
48
|
-
'& .MuiInputBase-input': {
|
|
49
|
-
padding: '0px 16px',
|
|
50
|
-
height: '48px',
|
|
51
|
-
// label-medium-1
|
|
52
|
-
fontSize: '16px',
|
|
53
|
-
fontWeight: '400',
|
|
54
|
-
lineHeight: '120%',
|
|
55
|
-
letterSpacing: '0px',
|
|
56
|
-
fontFamily: 'Work Sans, sans-serif',
|
|
57
|
-
'&::placeholder': {
|
|
58
|
-
color: '#707276',
|
|
59
|
-
},
|
|
60
|
-
'&:-webkit-autofill': {
|
|
61
|
-
WebkitBoxShadow: '0 0 0px 1000px transparent inset !important',
|
|
62
|
-
WebkitTextFillColor: '#000 !important',
|
|
63
|
-
transition: 'background-color 5000s ease-in-out 0s', // Prevents flashing
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
});
|
package/src/TextField/index.tsx
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
let currentInput: HTMLInputElement | HTMLTextAreaElement | null = null;
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3
|
-
let currentOnChange: ((e: any) => void) | null = null;
|
|
4
|
-
|
|
5
|
-
export function removeCurrentInput() {
|
|
6
|
-
currentInput = null;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function setCurrentInput(
|
|
10
|
-
input: HTMLInputElement | HTMLTextAreaElement | null,
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
-
onChange: (e: any) => void
|
|
13
|
-
) {
|
|
14
|
-
currentInput = input;
|
|
15
|
-
currentOnChange = onChange;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function getCurrentInput() {
|
|
19
|
-
return currentInput;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function getCurrentOnChange() {
|
|
23
|
-
return currentOnChange;
|
|
24
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
@use '../new-styles/main' as *;
|
|
2
|
-
|
|
3
|
-
.ds-input-text {
|
|
4
|
-
width: 100%;
|
|
5
|
-
position: relative;
|
|
6
|
-
|
|
7
|
-
> .helper {
|
|
8
|
-
@include helper-small-1;
|
|
9
|
-
margin-top: 4px;
|
|
10
|
-
|
|
11
|
-
&.error {
|
|
12
|
-
color: var(--text-error);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.icon-info {
|
|
17
|
-
color: var(--icon-tertiary);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
&.disabled {
|
|
21
|
-
color: var(--text-on-disabled);
|
|
22
|
-
cursor: not-allowed;
|
|
23
|
-
|
|
24
|
-
input {
|
|
25
|
-
cursor: not-allowed;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.character-counter {
|
|
30
|
-
@include helper-small-1;
|
|
31
|
-
color: var(--text-placeholder);
|
|
32
|
-
position: absolute;
|
|
33
|
-
bottom: 12px;
|
|
34
|
-
left: 16px;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { createContext, useReducer } from 'react';
|
|
2
|
-
import reducer from './store/reducer';
|
|
3
|
-
import store from './store/store';
|
|
4
|
-
import { StoreAction, UserStore } from './store/types';
|
|
5
|
-
|
|
6
|
-
type ContextType = {
|
|
7
|
-
state: UserStore;
|
|
8
|
-
dispatch: React.Dispatch<StoreAction>;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const CommonContext = createContext<ContextType>({} as ContextType);
|
|
12
|
-
|
|
13
|
-
export function CommonProvider({ children }: { children: React.ReactNode }) {
|
|
14
|
-
const [state, dispatch] = useReducer(reducer, store);
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<CommonContext.Provider value={{ state, dispatch }}>
|
|
18
|
-
{children}
|
|
19
|
-
</CommonContext.Provider>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default CommonContext;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import Cookies from 'js-cookie';
|
|
2
|
-
|
|
3
|
-
const REDIRECT_URI = 'redirect_uri_tycho';
|
|
4
|
-
const JWT_TOKEN = 'jwt_token_tycho';
|
|
5
|
-
const expireDays = 7;
|
|
6
|
-
|
|
7
|
-
const setJwtToken = (jwtToken: string) => {
|
|
8
|
-
Cookies.set(JWT_TOKEN, jwtToken, { expires: expireDays });
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const getJwtToken = () => {
|
|
12
|
-
const cookie = Cookies.get(JWT_TOKEN);
|
|
13
|
-
return cookie === 'undefined' ? '' : cookie;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const removeJwtToken = () => {
|
|
17
|
-
return Cookies.remove(JWT_TOKEN);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
function setRedirectUri(uri: string) {
|
|
21
|
-
Cookies.set(REDIRECT_URI, uri);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function removeRedirectUri() {
|
|
25
|
-
Cookies.remove(REDIRECT_URI);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const CookieStorage = {
|
|
29
|
-
setJwtToken,
|
|
30
|
-
getJwtToken,
|
|
31
|
-
removeJwtToken,
|
|
32
|
-
setRedirectUri,
|
|
33
|
-
removeRedirectUri,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default CookieStorage;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import i18n from 'i18next';
|
|
2
|
-
import languageDetector from 'i18next-browser-languagedetector';
|
|
3
|
-
import { initReactI18next } from 'react-i18next';
|
|
4
|
-
import { ParticipantsTexts } from './localization/ParticipantsTexts';
|
|
5
|
-
import { CommonTexts } from './localization/CommonTexts';
|
|
6
|
-
|
|
7
|
-
export default function commonLocalization() {
|
|
8
|
-
i18n
|
|
9
|
-
.use(initReactI18next)
|
|
10
|
-
.use(languageDetector)
|
|
11
|
-
.init({
|
|
12
|
-
resources: {
|
|
13
|
-
en: {
|
|
14
|
-
common: CommonTexts.en,
|
|
15
|
-
participants: ParticipantsTexts.en,
|
|
16
|
-
},
|
|
17
|
-
'pt-BR': {
|
|
18
|
-
common: CommonTexts['pt-BR'],
|
|
19
|
-
participants: ParticipantsTexts['pt-BR'],
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
fallbackLng: 'en',
|
|
23
|
-
defaultNS: 'message',
|
|
24
|
-
interpolation: {
|
|
25
|
-
escapeValue: false,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { message } from '../configs/store/actions';
|
|
2
|
-
import { StoreAction } from '../configs/store/types';
|
|
3
|
-
import { TFunction } from 'i18next';
|
|
4
|
-
|
|
5
|
-
type MessageDispatcher = {
|
|
6
|
-
key: string;
|
|
7
|
-
ns?: string;
|
|
8
|
-
dispatch: React.Dispatch<StoreAction>;
|
|
9
|
-
t: TFunction;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
type ErrorDispatcher = {
|
|
13
|
-
err: any;
|
|
14
|
-
dispatch: React.Dispatch<StoreAction>;
|
|
15
|
-
t: TFunction;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// TODO: improve
|
|
19
|
-
export const dispatchError = ({ err, dispatch, t }: ErrorDispatcher) => {
|
|
20
|
-
if (!err.response) {
|
|
21
|
-
dispatch(message({ value: t(err), type: 'error' }));
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (err.response.status && err.response.status === 403) {
|
|
26
|
-
dispatch(
|
|
27
|
-
message({
|
|
28
|
-
value: t('error.access.authorization'),
|
|
29
|
-
type: 'error',
|
|
30
|
-
})
|
|
31
|
-
);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
let errorKey = 'generic.error.message';
|
|
36
|
-
if (err.response.data && err.response.data.description)
|
|
37
|
-
errorKey = err.response.data.description;
|
|
38
|
-
|
|
39
|
-
if (err.response.data.errors && err.response.data.errors.length > 0)
|
|
40
|
-
errorKey = err.response.data.errors[0].description;
|
|
41
|
-
|
|
42
|
-
dispatch(message({ value: t(`message:${errorKey}`), type: 'error' }));
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const dispatchMessage = ({
|
|
46
|
-
key,
|
|
47
|
-
ns,
|
|
48
|
-
dispatch,
|
|
49
|
-
t,
|
|
50
|
-
}: MessageDispatcher) => {
|
|
51
|
-
const entry = ns ? `${ns}:${key}` : `message:${key}`;
|
|
52
|
-
dispatch(message({ value: t(entry), type: 'success' }));
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const MessageUtils = {
|
|
56
|
-
dispatchError,
|
|
57
|
-
dispatchMessage,
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export default MessageUtils;
|
package/src/configs/Storage.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const ACTIVE_CORPUS = '@Tycho:corpus';
|
|
2
|
-
|
|
3
|
-
function getActiveCorpus() {
|
|
4
|
-
return localStorage.getItem(ACTIVE_CORPUS);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
function setActiveCorpus(corpus: string) {
|
|
8
|
-
localStorage.setItem(ACTIVE_CORPUS, corpus);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function removeActiveCorpus() {
|
|
12
|
-
localStorage.removeItem(ACTIVE_CORPUS);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const Storage = {
|
|
16
|
-
getActiveCorpus,
|
|
17
|
-
setActiveCorpus,
|
|
18
|
-
removeActiveCorpus,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default Storage;
|
package/src/configs/api.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import axios, { AxiosError } from 'axios';
|
|
2
|
-
import CookieStorage from './CookieStorage';
|
|
3
|
-
|
|
4
|
-
const api = axios.create({
|
|
5
|
-
headers: {
|
|
6
|
-
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
7
|
-
Pragma: 'no-cache',
|
|
8
|
-
'Content-Type': 'application/json',
|
|
9
|
-
Accept: 'application/json',
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
baseURL: import.meta.env.VITE_APP_URL_API,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
api.interceptors.response.use(
|
|
16
|
-
(response) => response,
|
|
17
|
-
async (error: AxiosError) => {
|
|
18
|
-
if (error.response?.status === 401) {
|
|
19
|
-
CookieStorage.removeJwtToken();
|
|
20
|
-
sessionStorage.clear();
|
|
21
|
-
localStorage.clear();
|
|
22
|
-
window.location.replace(import.meta.env.VITE_APP_AUTH_URL as string);
|
|
23
|
-
} else if (error.response?.status === 403) {
|
|
24
|
-
window.location.href = `${
|
|
25
|
-
import.meta.env.VITE_APP_PUBLIC_URL
|
|
26
|
-
}/unauthorized`;
|
|
27
|
-
} else if (error.status === null) {
|
|
28
|
-
console.log(JSON.stringify(error));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return Promise.reject(error);
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
api.interceptors.request.use((config) => {
|
|
36
|
-
if (!config?.headers) {
|
|
37
|
-
throw new Error('no header available');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const token = CookieStorage.getJwtToken();
|
|
41
|
-
if (!token) return config;
|
|
42
|
-
|
|
43
|
-
// eslint-disable-next-line no-param-reassign
|
|
44
|
-
config.headers.Authorization = `Bearer ${token}`;
|
|
45
|
-
|
|
46
|
-
return config;
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
export default api;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export const CommonTexts = {
|
|
2
|
-
en: {
|
|
3
|
-
'button.confirm': 'Confirm',
|
|
4
|
-
'button.cancel': 'Cancel',
|
|
5
|
-
'button.remove': 'Remove',
|
|
6
|
-
'pagination.label.showing': 'Showing',
|
|
7
|
-
'pagination.label.results': 'results per page',
|
|
8
|
-
'pagination.label.total': 'Total',
|
|
9
|
-
'generic.placeholder': 'Type here',
|
|
10
|
-
'generic.placeholder.select': 'Select one here',
|
|
11
|
-
'validation.required': 'Required field.',
|
|
12
|
-
'placeholder.check': 'click to choose',
|
|
13
|
-
'placeholder.input': 'click to add',
|
|
14
|
-
},
|
|
15
|
-
'pt-BR': {
|
|
16
|
-
'button.confirm': 'Confirmar',
|
|
17
|
-
'button.cancel': 'Cancelar',
|
|
18
|
-
'pagination.label.showing': 'Exibindo',
|
|
19
|
-
'pagination.label.results': 'resultados por página',
|
|
20
|
-
'pagination.label.total': 'Total',
|
|
21
|
-
'generic.placeholder': 'Digite aqui',
|
|
22
|
-
'generic.placeholder.select': 'Selecione um aqui',
|
|
23
|
-
'validation.required': 'Campo obrigatório.',
|
|
24
|
-
'placeholder.check': 'clique para selecionar',
|
|
25
|
-
'placeholder.input': 'clique para adicionar',
|
|
26
|
-
},
|
|
27
|
-
};
|