tycho-components 0.0.4 → 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.
Files changed (139) hide show
  1. package/dist/AppColorpicker/AppColorpicker.d.ts +10 -0
  2. package/dist/AppColorpicker/AppColorpicker.js +21 -0
  3. package/{src/AppColorpicker/index.tsx → dist/AppColorpicker/index.d.ts} +0 -1
  4. package/dist/AppColorpicker/index.js +2 -0
  5. package/dist/AppEditable/AppEditable.d.ts +14 -0
  6. package/dist/AppEditable/AppEditable.js +80 -0
  7. package/dist/AppEditable/AppEditableField.d.ts +7 -0
  8. package/dist/AppEditable/AppEditableField.js +1 -0
  9. package/dist/AppEditable/FormField.d.ts +14 -0
  10. package/dist/AppEditable/FormField.js +8 -0
  11. package/dist/AppEditable/FormFieldOption.d.ts +7 -0
  12. package/dist/AppEditable/FormFieldOption.js +20 -0
  13. package/{src/AppEditable/index.tsx → dist/AppEditable/index.d.ts} +0 -1
  14. package/dist/AppEditable/index.js +2 -0
  15. package/dist/AppModal/AppModal.d.ts +20 -0
  16. package/dist/AppModal/AppModal.js +22 -0
  17. package/dist/AppModal/AppModalConfirm.d.ts +11 -0
  18. package/dist/AppModal/AppModalConfirm.js +20 -0
  19. package/dist/AppModal/AppModalRemove.d.ts +9 -0
  20. package/dist/AppModal/AppModalRemove.js +20 -0
  21. package/{src/AppModal/index.tsx → dist/AppModal/index.d.ts} +0 -1
  22. package/dist/AppModal/index.js +2 -0
  23. package/dist/AppToast/AppToast.d.ts +2 -0
  24. package/dist/AppToast/AppToast.js +78 -0
  25. package/dist/AppToast/ToastMessage.d.ts +8 -0
  26. package/dist/AppToast/ToastMessage.js +4 -0
  27. package/{src/AppToast/index.tsx → dist/AppToast/index.d.ts} +0 -1
  28. package/dist/AppToast/index.js +2 -0
  29. package/dist/Dummy/Dummy.d.ts +9 -0
  30. package/dist/Dummy/Dummy.js +8 -0
  31. package/{src/Dummy/index.tsx → dist/Dummy/index.d.ts} +0 -1
  32. package/dist/Dummy/index.js +2 -0
  33. package/dist/Participants/ParticipantCreate/ParticipantCreate.d.ts +9 -0
  34. package/dist/Participants/ParticipantCreate/ParticipantCreate.js +41 -0
  35. package/{src/Participants/ParticipantCreate/index.tsx → dist/Participants/ParticipantCreate/index.d.ts} +0 -1
  36. package/dist/Participants/ParticipantCreate/index.js +2 -0
  37. package/dist/Participants/ParticipantRemove/ParticipantRemove.d.ts +11 -0
  38. package/dist/Participants/ParticipantRemove/ParticipantRemove.js +26 -0
  39. package/{src/Participants/ParticipantRemove/index.tsx → dist/Participants/ParticipantRemove/index.d.ts} +0 -1
  40. package/dist/Participants/ParticipantRemove/index.js +2 -0
  41. package/dist/Participants/Participants.d.ts +9 -0
  42. package/dist/Participants/Participants.js +57 -0
  43. package/{src/Participants/index.tsx → dist/Participants/index.d.ts} +0 -1
  44. package/dist/Participants/index.js +2 -0
  45. package/dist/Participants/types/Participant.d.ts +27 -0
  46. package/dist/Participants/types/Participant.js +17 -0
  47. package/dist/Participants/types/ParticipantService.d.ts +11 -0
  48. package/dist/Participants/types/ParticipantService.js +12 -0
  49. package/dist/configs/CommonContext.d.ts +10 -0
  50. package/dist/configs/CommonContext.js +10 -0
  51. package/dist/configs/CookieStorage.d.ts +10 -0
  52. package/dist/configs/CookieStorage.js +28 -0
  53. package/dist/configs/Localization.d.ts +64 -0
  54. package/dist/configs/Localization.js +28 -0
  55. package/dist/configs/MessageUtils.d.ts +20 -0
  56. package/dist/configs/MessageUtils.js +30 -0
  57. package/dist/configs/Storage.d.ts +9 -0
  58. package/dist/configs/Storage.js +16 -0
  59. package/dist/configs/api.d.ts +2 -0
  60. package/dist/configs/api.js +38 -0
  61. package/dist/configs/localization/CommonTexts.d.ts +27 -0
  62. package/dist/configs/localization/CommonTexts.js +27 -0
  63. package/dist/configs/localization/ParticipantsTexts.d.ts +34 -0
  64. package/dist/configs/localization/ParticipantsTexts.js +34 -0
  65. package/dist/configs/store/actions.d.ts +4 -0
  66. package/dist/configs/store/actions.js +9 -0
  67. package/dist/configs/store/reducer.d.ts +3 -0
  68. package/dist/configs/store/reducer.js +19 -0
  69. package/dist/configs/store/store.d.ts +3 -0
  70. package/dist/configs/store/store.js +6 -0
  71. package/dist/configs/store/types.d.ts +13 -0
  72. package/dist/configs/store/types.js +4 -0
  73. package/dist/index.js +9 -0
  74. package/package.json +33 -24
  75. package/.eslintignore +0 -2
  76. package/.eslintrc.cjs +0 -28
  77. package/.eslintrc.json +0 -31
  78. package/.gitlab-ci.yml +0 -14
  79. package/.storybook/main.ts +0 -32
  80. package/.storybook/preview-head.html +0 -4
  81. package/.storybook/preview.css +0 -6
  82. package/.storybook/preview.tsx +0 -29
  83. package/src/AppColorpicker/AppColorpicker.tsx +0 -69
  84. package/src/AppEditable/AppEditable.tsx +0 -280
  85. package/src/AppEditable/AppEditableField.ts +0 -7
  86. package/src/AppEditable/FormField.ts +0 -26
  87. package/src/AppEditable/FormFieldOption.ts +0 -38
  88. package/src/AppModal/AppModal.tsx +0 -93
  89. package/src/AppModal/AppModalConfirm.tsx +0 -62
  90. package/src/AppModal/AppModalRemove.tsx +0 -51
  91. package/src/AppToast/AppToast.tsx +0 -94
  92. package/src/AppToast/ToastMessage.ts +0 -9
  93. package/src/Dummy/Dummy.stories.tsx +0 -21
  94. package/src/Dummy/Dummy.tsx +0 -16
  95. package/src/Participants/ParticipantCreate/ParticipantCreate.tsx +0 -83
  96. package/src/Participants/ParticipantRemove/ParticipantRemove.tsx +0 -51
  97. package/src/Participants/Participants.stories.tsx +0 -45
  98. package/src/Participants/Participants.tsx +0 -145
  99. package/src/Participants/types/Participant.ts +0 -43
  100. package/src/Participants/types/ParticipantService.ts +0 -18
  101. package/src/configs/CommonContext.tsx +0 -23
  102. package/src/configs/CookieStorage.ts +0 -36
  103. package/src/configs/Localization.ts +0 -30
  104. package/src/configs/MessageUtils.ts +0 -60
  105. package/src/configs/Storage.ts +0 -21
  106. package/src/configs/api.ts +0 -49
  107. package/src/configs/localization/CommonTexts.ts +0 -27
  108. package/src/configs/localization/ParticipantsTexts.ts +0 -40
  109. package/src/configs/store/actions.ts +0 -12
  110. package/src/configs/store/reducer.ts +0 -22
  111. package/src/configs/store/store.ts +0 -9
  112. package/src/configs/store/types.ts +0 -16
  113. package/src/react-app-env.d.ts +0 -5
  114. package/src/vite-env.d.ts +0 -13
  115. package/stories/Configure.mdx +0 -171
  116. package/stories/StorybookUtils.tsx +0 -40
  117. package/tsconfig.json +0 -31
  118. package/tsconfig.node.json +0 -10
  119. package/vite.config.ts +0 -26
  120. /package/{src → dist}/AppColorpicker/style.scss +0 -0
  121. /package/{src → dist}/AppEditable/style.scss +0 -0
  122. /package/{src → dist}/AppModal/style.scss +0 -0
  123. /package/{src → dist}/AppToast/style.scss +0 -0
  124. /package/{src → dist}/Dummy/styles.scss +0 -0
  125. /package/{src → dist}/Participants/ParticipantCreate/style.scss +0 -0
  126. /package/{src → dist}/Participants/ParticipantRemove/style.scss +0 -0
  127. /package/{src → dist}/Participants/style.scss +0 -0
  128. /package/{src/index.ts → dist/index.d.ts} +0 -0
  129. /package/{src → dist}/new-styles/base/_borders.scss +0 -0
  130. /package/{src → dist}/new-styles/base/_colors.scss +0 -0
  131. /package/{src → dist}/new-styles/base/_displays.scss +0 -0
  132. /package/{src → dist}/new-styles/base/_margins.css +0 -0
  133. /package/{src → dist}/new-styles/base/_spacing.scss +0 -0
  134. /package/{src → dist}/new-styles/base/_tokens.scss +0 -0
  135. /package/{src → dist}/new-styles/base/_typographs.scss +0 -0
  136. /package/{src → dist}/new-styles/main.scss +0 -0
  137. /package/{src → dist}/styles/_variables.scss +0 -0
  138. /package/{src → dist}/styles/bootstrap.min.css +0 -0
  139. /package/{src → dist}/styles/main.scss +0 -0
@@ -0,0 +1,57 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { faPlus, faTrash } from '@fortawesome/free-solid-svg-icons';
3
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4
+ import { useContext, useEffect, useState } from 'react';
5
+ import { Button, Form } from 'react-bootstrap';
6
+ import { useTranslation } from 'react-i18next';
7
+ import AppEditable from '../AppEditable';
8
+ import CommonContext from '../configs/CommonContext';
9
+ import { dispatchMessage } from '../configs/MessageUtils';
10
+ import ParticipantCreate from './ParticipantCreate';
11
+ import ParticipantRemove from './ParticipantRemove';
12
+ import './style.scss';
13
+ import { PARTICIPANT_FIELDS } from './types/Participant';
14
+ import ParticipantService from './types/ParticipantService';
15
+ export default function Participants({ document, participants, onChange, }) {
16
+ const { t } = useTranslation('participants');
17
+ const { dispatch } = useContext(CommonContext);
18
+ const [participant, setParticipant] = useState();
19
+ const [openRemove, setOpenRemove] = useState(false);
20
+ const [openCreate, setOpenCreate] = useState(false);
21
+ const handleSave = (field) => {
22
+ if (!field.ref)
23
+ return;
24
+ ParticipantService.update(field)
25
+ .then(() => {
26
+ dispatchMessage({ key: 'update.success', dispatch, t });
27
+ const { name, value } = field;
28
+ const thisParticipants = participants;
29
+ const idx = participants.findIndex((p) => p.code === field.ref);
30
+ // updates the participant
31
+ const thisParticipant = { ...thisParticipants[idx], [name]: value };
32
+ thisParticipants[idx] = { ...thisParticipant };
33
+ setParticipant(thisParticipant);
34
+ onChange(thisParticipants);
35
+ })
36
+ .catch((err) => {
37
+ console.log(err);
38
+ });
39
+ };
40
+ useEffect(() => {
41
+ if (participants.length > 0)
42
+ setParticipant(participants[0]);
43
+ }, []);
44
+ return (_jsxs("div", { className: "participants-container", children: [_jsxs("div", { className: "header", children: [_jsx("h3", { children: t('label.title') }), _jsx("div", { className: "actions", children: _jsxs("button", { type: "button", className: "action", onClick: () => setOpenCreate(true), children: [_jsx(FontAwesomeIcon, { icon: faPlus, title: t('button.label.add') }), _jsx("span", { className: "ms-2", children: t('button.label.add') })] }) })] }), _jsx("div", { className: "body", children: participant && (_jsxs(_Fragment, { children: [_jsx(Form.Select, { onChange: (e) => setParticipant(participants[Number(e.target.value)]), children: participants.map((el, idx) => (_jsx("option", { value: idx, children: `${el.code} - ${el.name}` }, idx))) }), _jsx(AppEditable, { translation: "participants", group: "participant", save: handleSave, item: { ...participant, uid: document }, fields: PARTICIPANT_FIELDS, className: "fields", reference: "code" }), _jsx("div", { className: "footer", children: _jsxs(Button, { variant: "danger", onClick: () => {
45
+ setParticipant(participant);
46
+ setOpenRemove(true);
47
+ }, children: [_jsx(FontAwesomeIcon, { icon: faTrash }), _jsx("span", { className: "ms-1", children: t('common:button.remove') })] }) })] })) }), participant && openRemove && (_jsx(ParticipantRemove, { document: document, onChange: (list) => {
48
+ onChange(list);
49
+ setParticipant(participants.length > 0 ? participants[0] : undefined);
50
+ setOpenRemove(false);
51
+ }, participant: participant, participants: participants, onClose: () => setOpenRemove(false) })), openCreate && (_jsx(ParticipantCreate, { document: document, onCreate: (p) => {
52
+ const thisParticipants = participants ? [...participants, p] : [p];
53
+ onChange(thisParticipants);
54
+ setParticipant(p);
55
+ setOpenCreate(false);
56
+ }, onClose: () => setOpenCreate(false) }))] }));
57
+ }
@@ -1,3 +1,2 @@
1
1
  import Participants from './Participants';
2
-
3
2
  export default Participants;
@@ -0,0 +1,2 @@
1
+ import Participants from './Participants';
2
+ export default Participants;
@@ -0,0 +1,27 @@
1
+ import FormField from '../../AppEditable/FormField';
2
+ type Participant = {
3
+ order: number;
4
+ code: string;
5
+ name: string;
6
+ color?: string;
7
+ role?: string;
8
+ ses?: string;
9
+ education?: string;
10
+ gender?: string;
11
+ custom?: string;
12
+ corpus?: string;
13
+ language?: string;
14
+ age?: string;
15
+ group?: string;
16
+ };
17
+ export type ParticipantCreateRequest = {
18
+ code: string;
19
+ name: string;
20
+ };
21
+ export declare const EMPTY_PARTICIPANT: {
22
+ order: number;
23
+ code: string;
24
+ name: string;
25
+ };
26
+ export declare const PARTICIPANT_FIELDS: FormField[];
27
+ export default Participant;
@@ -0,0 +1,17 @@
1
+ export const EMPTY_PARTICIPANT = {
2
+ order: 1,
3
+ code: '',
4
+ name: '',
5
+ };
6
+ export const PARTICIPANT_FIELDS = [
7
+ { name: 'order', type: 'text', required: true },
8
+ { name: 'code', type: 'text', required: true },
9
+ { name: 'name', type: 'text', required: false },
10
+ { name: 'separator', type: 'text', required: false },
11
+ {
12
+ name: 'color',
13
+ type: 'color',
14
+ required: false,
15
+ tooltip: 'field.color.tooltip',
16
+ },
17
+ ];
@@ -0,0 +1,11 @@
1
+ import AppEditableField from '../../AppEditable/AppEditableField';
2
+ import Participant, { ParticipantCreateRequest } from './Participant';
3
+ declare function add(uid: string, request: ParticipantCreateRequest): Promise<import("axios").AxiosResponse<Participant, any>>;
4
+ declare function update(field: AppEditableField): Promise<import("axios").AxiosResponse<any, any>>;
5
+ declare function remove(document: string, code: string): Promise<import("axios").AxiosResponse<any, any>>;
6
+ declare const ParticipantService: {
7
+ add: typeof add;
8
+ update: typeof update;
9
+ remove: typeof remove;
10
+ };
11
+ export default ParticipantService;
@@ -0,0 +1,12 @@
1
+ import api from '../../configs/api';
2
+ function add(uid, request) {
3
+ return api.post(`/participant/${uid}`, request);
4
+ }
5
+ function update(field) {
6
+ return api.patch('/participant/update', field);
7
+ }
8
+ function remove(document, code) {
9
+ return api.delete(`/participant/${document}/${code}`);
10
+ }
11
+ const ParticipantService = { add, update, remove };
12
+ export default ParticipantService;
@@ -0,0 +1,10 @@
1
+ import { StoreAction, UserStore } from './store/types';
2
+ type ContextType = {
3
+ state: UserStore;
4
+ dispatch: React.Dispatch<StoreAction>;
5
+ };
6
+ declare const CommonContext: import("react").Context<ContextType>;
7
+ export declare function CommonProvider({ children }: {
8
+ children: React.ReactNode;
9
+ }): import("react/jsx-runtime").JSX.Element;
10
+ export default CommonContext;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useReducer } from 'react';
3
+ import reducer from './store/reducer';
4
+ import store from './store/store';
5
+ const CommonContext = createContext({});
6
+ export function CommonProvider({ children }) {
7
+ const [state, dispatch] = useReducer(reducer, store);
8
+ return (_jsx(CommonContext.Provider, { value: { state, dispatch }, children: children }));
9
+ }
10
+ export default CommonContext;
@@ -0,0 +1,10 @@
1
+ declare function setRedirectUri(uri: string): void;
2
+ declare function removeRedirectUri(): void;
3
+ declare const CookieStorage: {
4
+ setJwtToken: (jwtToken: string) => void;
5
+ getJwtToken: () => string | undefined;
6
+ removeJwtToken: () => void;
7
+ setRedirectUri: typeof setRedirectUri;
8
+ removeRedirectUri: typeof removeRedirectUri;
9
+ };
10
+ export default CookieStorage;
@@ -0,0 +1,28 @@
1
+ import Cookies from 'js-cookie';
2
+ const REDIRECT_URI = 'redirect_uri_tycho';
3
+ const JWT_TOKEN = 'jwt_token_tycho';
4
+ const expireDays = 7;
5
+ const setJwtToken = (jwtToken) => {
6
+ Cookies.set(JWT_TOKEN, jwtToken, { expires: expireDays });
7
+ };
8
+ const getJwtToken = () => {
9
+ const cookie = Cookies.get(JWT_TOKEN);
10
+ return cookie === 'undefined' ? '' : cookie;
11
+ };
12
+ const removeJwtToken = () => {
13
+ return Cookies.remove(JWT_TOKEN);
14
+ };
15
+ function setRedirectUri(uri) {
16
+ Cookies.set(REDIRECT_URI, uri);
17
+ }
18
+ function removeRedirectUri() {
19
+ Cookies.remove(REDIRECT_URI);
20
+ }
21
+ const CookieStorage = {
22
+ setJwtToken,
23
+ getJwtToken,
24
+ removeJwtToken,
25
+ setRedirectUri,
26
+ removeRedirectUri,
27
+ };
28
+ export default CookieStorage;
@@ -0,0 +1,64 @@
1
+ export declare const commonResources: {
2
+ en: {
3
+ common: {
4
+ 'button.confirm': string;
5
+ 'button.cancel': string;
6
+ 'button.remove': string;
7
+ 'pagination.label.showing': string;
8
+ 'pagination.label.results': string;
9
+ 'pagination.label.total': string;
10
+ 'generic.placeholder': string;
11
+ 'generic.placeholder.select': string;
12
+ 'validation.required': string;
13
+ 'placeholder.check': string;
14
+ 'placeholder.input': string;
15
+ };
16
+ participants: {
17
+ 'label.title': string;
18
+ 'button.label.add': string;
19
+ 'participant.field.order': string;
20
+ 'participant.field.code': string;
21
+ 'participant.field.name': string;
22
+ 'participant.field.color': string;
23
+ 'participant.field.separator': string;
24
+ 'participant.field.color.tooltip': string;
25
+ 'modal.remove.title': string;
26
+ 'modal.remove.description': string;
27
+ 'modal.remove.participant': string;
28
+ 'modal.add.title': string;
29
+ 'modal.input.code': string;
30
+ 'modal.input.name': string;
31
+ };
32
+ };
33
+ 'pt-BR': {
34
+ common: {
35
+ 'button.confirm': string;
36
+ 'button.cancel': string;
37
+ 'pagination.label.showing': string;
38
+ 'pagination.label.results': string;
39
+ 'pagination.label.total': string;
40
+ 'generic.placeholder': string;
41
+ 'generic.placeholder.select': string;
42
+ 'validation.required': string;
43
+ 'placeholder.check': string;
44
+ 'placeholder.input': string;
45
+ };
46
+ participants: {
47
+ 'label.title': string;
48
+ 'button.label.add': string;
49
+ 'participant.field.order': string;
50
+ 'participant.field.code': string;
51
+ 'participant.field.name': string;
52
+ 'participant.field.color': string;
53
+ 'participant.field.separator': string;
54
+ 'participant.field.color.tooltip': string;
55
+ 'modal.remove.title': string;
56
+ 'modal.remove.description': string;
57
+ 'modal.remove.participant': string;
58
+ 'modal.add.title': string;
59
+ 'modal.input.code': string;
60
+ 'modal.input.name': string;
61
+ };
62
+ };
63
+ };
64
+ export default function commonLocalization(): void;
@@ -0,0 +1,28 @@
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
+ export const commonResources = {
7
+ en: {
8
+ common: CommonTexts.en,
9
+ participants: ParticipantsTexts.en,
10
+ },
11
+ 'pt-BR': {
12
+ common: CommonTexts['pt-BR'],
13
+ participants: ParticipantsTexts['pt-BR'],
14
+ },
15
+ };
16
+ export default function commonLocalization() {
17
+ i18n
18
+ .use(initReactI18next)
19
+ .use(languageDetector)
20
+ .init({
21
+ resources: commonResources,
22
+ fallbackLng: 'en',
23
+ defaultNS: 'message',
24
+ interpolation: {
25
+ escapeValue: false,
26
+ },
27
+ });
28
+ }
@@ -0,0 +1,20 @@
1
+ import { StoreAction } from '../configs/store/types';
2
+ import { TFunction } from 'i18next';
3
+ type MessageDispatcher = {
4
+ key: string;
5
+ ns?: string;
6
+ dispatch: React.Dispatch<StoreAction>;
7
+ t: TFunction;
8
+ };
9
+ type ErrorDispatcher = {
10
+ err: any;
11
+ dispatch: React.Dispatch<StoreAction>;
12
+ t: TFunction;
13
+ };
14
+ export declare const dispatchError: ({ err, dispatch, t }: ErrorDispatcher) => void;
15
+ export declare const dispatchMessage: ({ key, ns, dispatch, t, }: MessageDispatcher) => void;
16
+ declare const MessageUtils: {
17
+ dispatchError: ({ err, dispatch, t }: ErrorDispatcher) => void;
18
+ dispatchMessage: ({ key, ns, dispatch, t, }: MessageDispatcher) => void;
19
+ };
20
+ export default MessageUtils;
@@ -0,0 +1,30 @@
1
+ import { message } from '../configs/store/actions';
2
+ // TODO: improve
3
+ export const dispatchError = ({ err, dispatch, t }) => {
4
+ if (!err.response) {
5
+ dispatch(message({ value: t(err), type: 'error' }));
6
+ return;
7
+ }
8
+ if (err.response.status && err.response.status === 403) {
9
+ dispatch(message({
10
+ value: t('error.access.authorization'),
11
+ type: 'error',
12
+ }));
13
+ return;
14
+ }
15
+ let errorKey = 'generic.error.message';
16
+ if (err.response.data && err.response.data.description)
17
+ errorKey = err.response.data.description;
18
+ if (err.response.data.errors && err.response.data.errors.length > 0)
19
+ errorKey = err.response.data.errors[0].description;
20
+ dispatch(message({ value: t(`message:${errorKey}`), type: 'error' }));
21
+ };
22
+ export const dispatchMessage = ({ key, ns, dispatch, t, }) => {
23
+ const entry = ns ? `${ns}:${key}` : `message:${key}`;
24
+ dispatch(message({ value: t(entry), type: 'success' }));
25
+ };
26
+ const MessageUtils = {
27
+ dispatchError,
28
+ dispatchMessage,
29
+ };
30
+ export default MessageUtils;
@@ -0,0 +1,9 @@
1
+ declare function getActiveCorpus(): string | null;
2
+ declare function setActiveCorpus(corpus: string): void;
3
+ declare function removeActiveCorpus(): void;
4
+ declare const Storage: {
5
+ getActiveCorpus: typeof getActiveCorpus;
6
+ setActiveCorpus: typeof setActiveCorpus;
7
+ removeActiveCorpus: typeof removeActiveCorpus;
8
+ };
9
+ export default Storage;
@@ -0,0 +1,16 @@
1
+ const ACTIVE_CORPUS = '@Tycho:corpus';
2
+ function getActiveCorpus() {
3
+ return localStorage.getItem(ACTIVE_CORPUS);
4
+ }
5
+ function setActiveCorpus(corpus) {
6
+ localStorage.setItem(ACTIVE_CORPUS, corpus);
7
+ }
8
+ function removeActiveCorpus() {
9
+ localStorage.removeItem(ACTIVE_CORPUS);
10
+ }
11
+ const Storage = {
12
+ getActiveCorpus,
13
+ setActiveCorpus,
14
+ removeActiveCorpus,
15
+ };
16
+ export default Storage;
@@ -0,0 +1,2 @@
1
+ declare const api: import("axios").AxiosInstance;
2
+ export default api;
@@ -0,0 +1,38 @@
1
+ import axios from 'axios';
2
+ import CookieStorage from './CookieStorage';
3
+ const api = axios.create({
4
+ headers: {
5
+ 'Cache-Control': 'no-cache, no-store, must-revalidate',
6
+ Pragma: 'no-cache',
7
+ 'Content-Type': 'application/json',
8
+ Accept: 'application/json',
9
+ },
10
+ baseURL: import.meta.env.VITE_APP_URL_API,
11
+ });
12
+ api.interceptors.response.use((response) => response, async (error) => {
13
+ if (error.response?.status === 401) {
14
+ CookieStorage.removeJwtToken();
15
+ sessionStorage.clear();
16
+ localStorage.clear();
17
+ window.location.replace(import.meta.env.VITE_APP_AUTH_URL);
18
+ }
19
+ else if (error.response?.status === 403) {
20
+ window.location.href = `${import.meta.env.VITE_APP_PUBLIC_URL}/unauthorized`;
21
+ }
22
+ else if (error.status === null) {
23
+ console.log(JSON.stringify(error));
24
+ }
25
+ return Promise.reject(error);
26
+ });
27
+ api.interceptors.request.use((config) => {
28
+ if (!config?.headers) {
29
+ throw new Error('no header available');
30
+ }
31
+ const token = CookieStorage.getJwtToken();
32
+ if (!token)
33
+ return config;
34
+ // eslint-disable-next-line no-param-reassign
35
+ config.headers.Authorization = `Bearer ${token}`;
36
+ return config;
37
+ });
38
+ export default api;
@@ -0,0 +1,27 @@
1
+ export declare const CommonTexts: {
2
+ en: {
3
+ 'button.confirm': string;
4
+ 'button.cancel': string;
5
+ 'button.remove': string;
6
+ 'pagination.label.showing': string;
7
+ 'pagination.label.results': string;
8
+ 'pagination.label.total': string;
9
+ 'generic.placeholder': string;
10
+ 'generic.placeholder.select': string;
11
+ 'validation.required': string;
12
+ 'placeholder.check': string;
13
+ 'placeholder.input': string;
14
+ };
15
+ 'pt-BR': {
16
+ 'button.confirm': string;
17
+ 'button.cancel': string;
18
+ 'pagination.label.showing': string;
19
+ 'pagination.label.results': string;
20
+ 'pagination.label.total': string;
21
+ 'generic.placeholder': string;
22
+ 'generic.placeholder.select': string;
23
+ 'validation.required': string;
24
+ 'placeholder.check': string;
25
+ 'placeholder.input': string;
26
+ };
27
+ };
@@ -0,0 +1,27 @@
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
+ };
@@ -0,0 +1,34 @@
1
+ export declare const ParticipantsTexts: {
2
+ en: {
3
+ 'label.title': string;
4
+ 'button.label.add': string;
5
+ 'participant.field.order': string;
6
+ 'participant.field.code': string;
7
+ 'participant.field.name': string;
8
+ 'participant.field.color': string;
9
+ 'participant.field.separator': string;
10
+ 'participant.field.color.tooltip': string;
11
+ 'modal.remove.title': string;
12
+ 'modal.remove.description': string;
13
+ 'modal.remove.participant': string;
14
+ 'modal.add.title': string;
15
+ 'modal.input.code': string;
16
+ 'modal.input.name': string;
17
+ };
18
+ 'pt-BR': {
19
+ 'label.title': string;
20
+ 'button.label.add': string;
21
+ 'participant.field.order': string;
22
+ 'participant.field.code': string;
23
+ 'participant.field.name': string;
24
+ 'participant.field.color': string;
25
+ 'participant.field.separator': string;
26
+ 'participant.field.color.tooltip': string;
27
+ 'modal.remove.title': string;
28
+ 'modal.remove.description': string;
29
+ 'modal.remove.participant': string;
30
+ 'modal.add.title': string;
31
+ 'modal.input.code': string;
32
+ 'modal.input.name': string;
33
+ };
34
+ };
@@ -0,0 +1,34 @@
1
+ export const ParticipantsTexts = {
2
+ en: {
3
+ 'label.title': 'Participants',
4
+ 'button.label.add': 'add new participant',
5
+ 'participant.field.order': 'Order',
6
+ 'participant.field.code': 'Code',
7
+ 'participant.field.name': 'Name',
8
+ 'participant.field.color': 'Color',
9
+ 'participant.field.separator': 'Separator',
10
+ 'participant.field.color.tooltip': 'A color for transcription visual identifier',
11
+ 'modal.remove.title': 'Remove participant',
12
+ 'modal.remove.description': 'Are you sure you want to delete this participant? This action is irreversible, but the sentences are not deleted.',
13
+ 'modal.remove.participant': 'You can choose a participant to transfer sentences related to ',
14
+ 'modal.add.title': 'Add new participant',
15
+ 'modal.input.code': 'ID',
16
+ 'modal.input.name': 'Name',
17
+ },
18
+ 'pt-BR': {
19
+ 'label.title': 'Participantes',
20
+ 'button.label.add': 'Adicionar participante',
21
+ 'participant.field.order': 'Ordem',
22
+ 'participant.field.code': 'Código',
23
+ 'participant.field.name': 'Nome',
24
+ 'participant.field.color': 'Cor',
25
+ 'participant.field.separator': 'Separador',
26
+ 'participant.field.color.tooltip': 'Cor para identificação visual da sentença na transcrição',
27
+ 'modal.remove.title': 'Remover participante',
28
+ 'modal.remove.description': 'Você tem certeza que deseja remover este participante? Esta ação é irreversível, porém as sentenças não serão excluídas.',
29
+ 'modal.remove.participant': 'Você pode escolher um participante para transferir frases relacionadas a ',
30
+ 'modal.add.title': 'Adicionar novo participante',
31
+ 'modal.input.code': 'ID',
32
+ 'modal.input.name': 'Nome',
33
+ },
34
+ };
@@ -0,0 +1,4 @@
1
+ import ToastMessage from '../../AppToast/ToastMessage';
2
+ import { StoreAction } from './types';
3
+ export declare const message: (data: ToastMessage) => StoreAction;
4
+ export declare const toastLoading: (data: boolean) => StoreAction;
@@ -0,0 +1,9 @@
1
+ import { types } from './types';
2
+ export const message = (data) => ({
3
+ type: types.MESSAGE,
4
+ payload: data,
5
+ });
6
+ export const toastLoading = (data) => ({
7
+ type: types.TOAST_LOADING,
8
+ payload: data,
9
+ });
@@ -0,0 +1,3 @@
1
+ import { UserStore } from './types';
2
+ declare function reducer(state: UserStore, action: any): UserStore;
3
+ export default reducer;
@@ -0,0 +1,19 @@
1
+ /* eslint-disable */
2
+ import { types } from './types';
3
+ function reducer(state, action) {
4
+ switch (action.type) {
5
+ case types.MESSAGE:
6
+ return {
7
+ ...state,
8
+ message: action.payload,
9
+ };
10
+ case types.TOAST_LOADING:
11
+ return {
12
+ ...state,
13
+ toastLoading: action.payload,
14
+ };
15
+ default:
16
+ return state;
17
+ }
18
+ }
19
+ export default reducer;
@@ -0,0 +1,3 @@
1
+ import { UserStore } from './types';
2
+ declare const store: UserStore;
3
+ export default store;
@@ -0,0 +1,6 @@
1
+ import { EMPTY_TOAST } from '../../AppToast/ToastMessage';
2
+ const store = {
3
+ message: EMPTY_TOAST,
4
+ toastLoading: false,
5
+ };
6
+ export default store;
@@ -0,0 +1,13 @@
1
+ import ToastMessage from '../../AppToast/ToastMessage';
2
+ export type UserStore = {
3
+ message: ToastMessage;
4
+ toastLoading: boolean;
5
+ };
6
+ export type StoreAction = {
7
+ type: string;
8
+ payload?: ToastMessage | boolean;
9
+ };
10
+ export declare const types: {
11
+ MESSAGE: string;
12
+ TOAST_LOADING: string;
13
+ };
@@ -0,0 +1,4 @@
1
+ export const types = {
2
+ MESSAGE: 'MESSAGE',
3
+ TOAST_LOADING: 'TOAST_LOADING',
4
+ };
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export { default as AppEditable } from './AppEditable';
2
+ export { default as AppToast } from './AppToast';
3
+ export { default as AppColorpicker } from './AppColorpicker';
4
+ export { default as Participants } from './Participants';
5
+ export { default as AppModal } from './AppModal';
6
+ export { default as AppModalConfirm } from './AppModal/AppModalConfirm';
7
+ export { default as AppModalRemove } from './AppModal/AppModalRemove';
8
+ export { commonResources } from './configs/Localization';
9
+ export { CommonProvider } from './configs/CommonContext';