tycho-components 0.0.10-SNAPSHOT-7 → 0.0.11-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 (52) hide show
  1. package/dist/AppLoading/AppLoading.d.ts +3 -0
  2. package/dist/AppLoading/AppLoading.js +7 -0
  3. package/dist/AppLoading/index.d.ts +2 -0
  4. package/dist/AppLoading/index.js +2 -0
  5. package/dist/AppLoading/style.scss +8 -0
  6. package/dist/AppPlaceholder/AppPlaceholder.d.ts +8 -0
  7. package/dist/AppPlaceholder/AppPlaceholder.js +5 -0
  8. package/dist/AppPlaceholder/index.d.ts +2 -0
  9. package/dist/AppPlaceholder/index.js +2 -0
  10. package/dist/AppPlaceholder/style.scss +18 -0
  11. package/dist/Comments/Comments.d.ts +9 -0
  12. package/dist/Comments/Comments.js +110 -0
  13. package/dist/Comments/HeaderNotifications/HeaderNotifications.d.ts +6 -0
  14. package/dist/Comments/HeaderNotifications/HeaderNotifications.js +39 -0
  15. package/dist/Comments/HeaderNotifications/index.d.ts +2 -0
  16. package/dist/Comments/HeaderNotifications/index.js +2 -0
  17. package/dist/Comments/HeaderNotifications/style.scss +104 -0
  18. package/dist/Comments/index.d.ts +2 -0
  19. package/dist/Comments/index.js +2 -0
  20. package/dist/Comments/style.scss +136 -0
  21. package/dist/Comments/types/Comment.d.ts +28 -0
  22. package/dist/Comments/types/Comment.js +13 -0
  23. package/dist/Comments/types/CommentService.d.ts +21 -0
  24. package/dist/Comments/types/CommentService.js +44 -0
  25. package/dist/VirtualKeyboard/KeyboardCustomLayout.d.ts +8 -0
  26. package/dist/VirtualKeyboard/KeyboardCustomLayout.js +25 -0
  27. package/dist/VirtualKeyboard/VirtualKeyboard.d.ts +9 -0
  28. package/dist/VirtualKeyboard/VirtualKeyboard.js +68 -0
  29. package/dist/VirtualKeyboard/index.d.ts +2 -0
  30. package/dist/VirtualKeyboard/index.js +2 -0
  31. package/dist/VirtualKeyboard/style.scss +33 -0
  32. package/dist/configs/Localization.d.ts +56 -0
  33. package/dist/configs/Localization.js +4 -1
  34. package/dist/configs/User.d.ts +16 -0
  35. package/dist/configs/User.js +7 -0
  36. package/dist/configs/localization/CommentsTexts.d.ts +58 -0
  37. package/dist/configs/localization/CommentsTexts.js +58 -0
  38. package/dist/configs/store/actions.d.ts +2 -0
  39. package/dist/configs/store/actions.js +4 -0
  40. package/dist/configs/store/reducer.js +5 -0
  41. package/dist/configs/store/store.js +1 -0
  42. package/dist/configs/store/types.d.ts +4 -1
  43. package/dist/configs/store/types.js +1 -0
  44. package/dist/functions/DateUtils.d.ts +9 -0
  45. package/dist/functions/DateUtils.js +42 -0
  46. package/dist/functions/FormUtils.d.ts +11 -0
  47. package/dist/functions/FormUtils.js +56 -0
  48. package/dist/functions/SecurityUtils.d.ts +6 -0
  49. package/dist/functions/SecurityUtils.js +28 -0
  50. package/dist/index.d.ts +9 -1
  51. package/dist/index.js +8 -1
  52. package/package.json +5 -2
@@ -0,0 +1,68 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // https://github.com/simple-keyboard/simple-keyboard-layouts/wiki/Adding-a-Layout
3
+ import { MenuItem, Select, ThemeProvider, useTheme } from '@mui/material';
4
+ import { useEffect, useState } from 'react';
5
+ import Draggable from 'react-draggable';
6
+ import Keyboard from 'react-simple-keyboard';
7
+ import 'react-simple-keyboard/build/css/index.css';
8
+ import KeyboardLayouts from 'simple-keyboard-layouts';
9
+ import { Button, getCurrentInput, getCurrentOnChange, removeCurrentInput, selectFieldTheme, } from 'tycho-storybook';
10
+ import { KeyboardCustomLayouts } from './KeyboardCustomLayout';
11
+ import './style.scss';
12
+ export default function VirtualKeyboard({ onClose, defaultLayout, closeLabel = 'Close', }) {
13
+ const outerTheme = useTheme();
14
+ const layouts = new KeyboardLayouts();
15
+ const layoutNames = [
16
+ ...Object.keys(layouts.get()),
17
+ ...Object.keys(KeyboardCustomLayouts),
18
+ ].sort((a, b) => a.localeCompare(b));
19
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
20
+ const [layout, setLayout] = useState();
21
+ const [layoutName, setLayoutName] = useState('default');
22
+ const [selected, setSelected] = useState(defaultLayout);
23
+ const getLayoutByName = (name) => layouts.get(name) || KeyboardCustomLayouts[name];
24
+ const handleChangeLayout = (lang) => {
25
+ setSelected(lang);
26
+ setLayoutName('default');
27
+ const layoutObject = getLayoutByName(lang);
28
+ setLayout(layoutObject?.layout || layoutObject);
29
+ };
30
+ const handleShift = () => {
31
+ const newLayoutName = layoutName === 'default' ? 'shift' : 'default';
32
+ setLayoutName(newLayoutName);
33
+ };
34
+ const onKeyPress = (button) => {
35
+ if (button === '{shift}' || button === '{lock}') {
36
+ handleShift();
37
+ return;
38
+ }
39
+ if (button === '{space}') {
40
+ button = ' ';
41
+ }
42
+ const input = getCurrentInput();
43
+ const onChange = getCurrentOnChange();
44
+ if (input && onChange) {
45
+ const start = input.selectionStart || 0;
46
+ const end = input.selectionEnd || 0;
47
+ const value = input.value;
48
+ const newValue = button === '{bksp}'
49
+ ? value.slice(0, -1)
50
+ : value.slice(0, start) + button + value.slice(end);
51
+ input.value = newValue;
52
+ input.setSelectionRange(start + 1, start + 1);
53
+ input.focus();
54
+ onChange({ target: input });
55
+ }
56
+ };
57
+ useEffect(() => {
58
+ setLayout(getLayoutByName(defaultLayout)?.layout);
59
+ }, []);
60
+ return (_jsx(Draggable, { children: _jsxs("div", { className: "keyboard-container", children: [_jsx("div", { className: "body", children: _jsx(Keyboard, { onKeyPress: onKeyPress, layoutName: layoutName,
61
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
62
+ layout: layout }) }), _jsxs("div", { className: "footer", children: [_jsx(ThemeProvider, { theme: selectFieldTheme(outerTheme), children: _jsx(Select, { value: selected, fullWidth: true, variant: "filled", color: "primary", className: "select-layout", onChange: (e) => {
63
+ handleChangeLayout(e.target.value);
64
+ }, children: layoutNames.map((option, idx) => (_jsx(MenuItem, { value: option, children: option }, idx.valueOf()))) }) }), _jsx(Button, { onClick: () => {
65
+ removeCurrentInput();
66
+ onClose();
67
+ }, text: closeLabel, color: "danger", size: "small" })] })] }) }));
68
+ }
@@ -0,0 +1,2 @@
1
+ import VirtualKeyboard from './VirtualKeyboard';
2
+ export default VirtualKeyboard;
@@ -0,0 +1,2 @@
1
+ import VirtualKeyboard from './VirtualKeyboard';
2
+ export default VirtualKeyboard;
@@ -0,0 +1,33 @@
1
+ .keyboard-container {
2
+ display: flex;
3
+ flex-direction: column;
4
+ position: fixed;
5
+ bottom: 16px;
6
+ right: 16px;
7
+ background-color: var(--accent-100);
8
+ border: 1px solid var(--border-subtle-1);
9
+ border-radius: var(--radius-200);
10
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
11
+ padding: 12px;
12
+ gap: 8px;
13
+ z-index: 1000;
14
+ min-width: 20vw;
15
+
16
+ > .footer {
17
+ display: flex;
18
+ justify-content: end;
19
+ gap: 8px;
20
+ padding-top: var(--spacing-050);
21
+
22
+ .select-layout {
23
+ > .MuiSelect-select {
24
+ padding: 0px 16px !important;
25
+ }
26
+ }
27
+
28
+ .dropdown-menu {
29
+ max-height: 30vh;
30
+ overflow-y: auto;
31
+ }
32
+ }
33
+ }
@@ -39,6 +39,34 @@ export declare const commonResources: {
39
39
  'modal.select.transfer': string;
40
40
  'participant.code.exists': string;
41
41
  };
42
+ comments: {
43
+ 'label.title.comments': string;
44
+ 'placeholder.comment.text': string;
45
+ 'placeholder.comment.title': string;
46
+ 'placeholder.comment.person': string;
47
+ 'label.button.add': string;
48
+ 'label.button.update': string;
49
+ 'label.requested.to': string;
50
+ 'label.posted.on': string;
51
+ 'placeholder.comments.empty': string;
52
+ 'tooltip.edit': string;
53
+ 'tooltip.delete': string;
54
+ 'tooltip.read': string;
55
+ 'modal.title.footnote': string;
56
+ 'placeholder.footnote.text': string;
57
+ 'modal.title.footnote.remove': string;
58
+ 'modal.text.footnote.remove': string;
59
+ 'button.add': string;
60
+ 'input.value': string;
61
+ 'input.title': string;
62
+ 'input.user': string;
63
+ 'button.discard': string;
64
+ 'notification.title': string;
65
+ 'notification.unread': string;
66
+ 'notification.all': string;
67
+ 'notification.empty': string;
68
+ 'notification.text': string;
69
+ };
42
70
  };
43
71
  'pt-BR': {
44
72
  common: {
@@ -78,6 +106,34 @@ export declare const commonResources: {
78
106
  'modal.input.name': string;
79
107
  'participant.code.exists': string;
80
108
  };
109
+ comments: {
110
+ 'label.title.comments': string;
111
+ 'placeholder.comment.text': string;
112
+ 'placeholder.comment.title': string;
113
+ 'placeholder.comment.person': string;
114
+ 'label.button.add': string;
115
+ 'label.button.update': string;
116
+ 'label.requested.to': string;
117
+ 'label.posted.on': string;
118
+ 'placeholder.comments.empty': string;
119
+ 'tooltip.edit': string;
120
+ 'tooltip.delete': string;
121
+ 'tooltip.read': string;
122
+ 'modal.title.footnote': string;
123
+ 'placeholder.footnote.text': string;
124
+ 'modal.title.footnote.remove': string;
125
+ 'modal.text.footnote.remove': string;
126
+ 'button.add': string;
127
+ 'input.value': string;
128
+ 'input.title': string;
129
+ 'input.user': string;
130
+ 'button.discard': string;
131
+ 'notification.title': string;
132
+ 'notification.unread': string;
133
+ 'notification.all': string;
134
+ 'notification.empty': string;
135
+ 'notification.text': string;
136
+ };
81
137
  };
82
138
  };
83
139
  export default function commonLocalization(): void;
@@ -3,14 +3,17 @@ import languageDetector from 'i18next-browser-languagedetector';
3
3
  import { initReactI18next } from 'react-i18next';
4
4
  import { ParticipantsTexts } from './localization/ParticipantsTexts';
5
5
  import { CommonTexts } from './localization/CommonTexts';
6
+ import { CommentsTexts } from './localization/CommentsTexts';
6
7
  export const commonResources = {
7
8
  en: {
8
9
  common: CommonTexts.en,
9
10
  participants: ParticipantsTexts.en,
11
+ comments: CommentsTexts.en,
10
12
  },
11
13
  'pt-BR': {
12
14
  common: CommonTexts['pt-BR'],
13
15
  participants: ParticipantsTexts['pt-BR'],
16
+ comments: CommentsTexts['pt-BR'],
14
17
  },
15
18
  };
16
19
  export default function commonLocalization() {
@@ -20,7 +23,7 @@ export default function commonLocalization() {
20
23
  .init({
21
24
  resources: commonResources,
22
25
  fallbackLng: 'en',
23
- defaultNS: 'message',
26
+ defaultNS: 'common',
24
27
  interpolation: {
25
28
  escapeValue: false,
26
29
  },
@@ -0,0 +1,16 @@
1
+ export declare enum UserStatus {
2
+ ACTIVE = "ACTIVE",
3
+ INACTIVE = "INACTIVE",
4
+ SUPER = "SUPER",
5
+ VISITOR = "VISITOR"
6
+ }
7
+ type User = {
8
+ uid: string;
9
+ name: string;
10
+ sub: string;
11
+ picture: string;
12
+ lang: string;
13
+ status: UserStatus;
14
+ permissions: string[];
15
+ };
16
+ export default User;
@@ -0,0 +1,7 @@
1
+ export var UserStatus;
2
+ (function (UserStatus) {
3
+ UserStatus["ACTIVE"] = "ACTIVE";
4
+ UserStatus["INACTIVE"] = "INACTIVE";
5
+ UserStatus["SUPER"] = "SUPER";
6
+ UserStatus["VISITOR"] = "VISITOR";
7
+ })(UserStatus || (UserStatus = {}));
@@ -0,0 +1,58 @@
1
+ export declare const CommentsTexts: {
2
+ en: {
3
+ 'label.title.comments': string;
4
+ 'placeholder.comment.text': string;
5
+ 'placeholder.comment.title': string;
6
+ 'placeholder.comment.person': string;
7
+ 'label.button.add': string;
8
+ 'label.button.update': string;
9
+ 'label.requested.to': string;
10
+ 'label.posted.on': string;
11
+ 'placeholder.comments.empty': string;
12
+ 'tooltip.edit': string;
13
+ 'tooltip.delete': string;
14
+ 'tooltip.read': string;
15
+ 'modal.title.footnote': string;
16
+ 'placeholder.footnote.text': string;
17
+ 'modal.title.footnote.remove': string;
18
+ 'modal.text.footnote.remove': string;
19
+ 'button.add': string;
20
+ 'input.value': string;
21
+ 'input.title': string;
22
+ 'input.user': string;
23
+ 'button.discard': string;
24
+ 'notification.title': string;
25
+ 'notification.unread': string;
26
+ 'notification.all': string;
27
+ 'notification.empty': string;
28
+ 'notification.text': string;
29
+ };
30
+ 'pt-BR': {
31
+ 'label.title.comments': string;
32
+ 'placeholder.comment.text': string;
33
+ 'placeholder.comment.title': string;
34
+ 'placeholder.comment.person': string;
35
+ 'label.button.add': string;
36
+ 'label.button.update': string;
37
+ 'label.requested.to': string;
38
+ 'label.posted.on': string;
39
+ 'placeholder.comments.empty': string;
40
+ 'tooltip.edit': string;
41
+ 'tooltip.delete': string;
42
+ 'tooltip.read': string;
43
+ 'modal.title.footnote': string;
44
+ 'placeholder.footnote.text': string;
45
+ 'modal.title.footnote.remove': string;
46
+ 'modal.text.footnote.remove': string;
47
+ 'button.add': string;
48
+ 'input.value': string;
49
+ 'input.title': string;
50
+ 'input.user': string;
51
+ 'button.discard': string;
52
+ 'notification.title': string;
53
+ 'notification.unread': string;
54
+ 'notification.all': string;
55
+ 'notification.empty': string;
56
+ 'notification.text': string;
57
+ };
58
+ };
@@ -0,0 +1,58 @@
1
+ export const CommentsTexts = {
2
+ en: {
3
+ 'label.title.comments': 'Comments',
4
+ 'placeholder.comment.text': 'Your comment',
5
+ 'placeholder.comment.title': 'Title (optional)',
6
+ 'placeholder.comment.person': 'Select person',
7
+ 'label.button.add': 'Add comment',
8
+ 'label.button.update': 'Update comment',
9
+ 'label.requested.to': 'Sent to:',
10
+ 'label.posted.on': 'Posted on:',
11
+ 'placeholder.comments.empty': 'No comments available.',
12
+ 'tooltip.edit': 'Edit comment',
13
+ 'tooltip.delete': 'Remove comment',
14
+ 'tooltip.read': 'Mark as read',
15
+ 'modal.title.footnote': 'Edit footnote',
16
+ 'placeholder.footnote.text': 'Enter footnote',
17
+ 'modal.title.footnote.remove': 'Confirm footnote removal',
18
+ 'modal.text.footnote.remove': 'Are you sure you want to remove this footnote? This action is irreversible.',
19
+ 'button.add': 'Add comment',
20
+ 'input.value': 'Comment',
21
+ 'input.title': 'Title',
22
+ 'input.user': 'Send to user',
23
+ 'button.discard': 'Discard',
24
+ 'notification.title': 'Notifications',
25
+ 'notification.unread': 'Unread',
26
+ 'notification.all': 'Read',
27
+ 'notification.empty': 'No more notifications',
28
+ 'notification.text': '{{user}} added a comment to entry {{entry}}.',
29
+ },
30
+ 'pt-BR': {
31
+ 'label.title.comments': 'Comentários',
32
+ 'placeholder.comment.text': 'Seu comentário',
33
+ 'placeholder.comment.title': 'Título (opcional)',
34
+ 'placeholder.comment.person': 'Selecione a pessoa',
35
+ 'label.button.add': 'Adicionar comentário',
36
+ 'label.button.update': 'Atualizar comentário',
37
+ 'label.requested.to': 'Enviado para:',
38
+ 'label.posted.on': 'Postado em:',
39
+ 'placeholder.comments.empty': 'Nenhum comentário disponível.',
40
+ 'tooltip.edit': 'Editar commentário',
41
+ 'tooltip.delete': 'Remover commentário',
42
+ 'tooltip.read': 'Marcar como lido',
43
+ 'modal.title.footnote': 'Editar nota de rodapé',
44
+ 'placeholder.footnote.text': 'Entre o texto da nota de rodapé',
45
+ 'modal.title.footnote.remove': 'Confirmação de exclusão de nota de rodapé',
46
+ 'modal.text.footnote.remove': 'Tem certeza de que deseja remover esta nota de rodapé? Esta ação é irreversível.',
47
+ 'button.add': 'Adicionar comentário',
48
+ 'input.value': 'Comentário',
49
+ 'input.title': 'Título',
50
+ 'input.user': 'Enviar para usuário',
51
+ 'button.discard': 'Descartar',
52
+ 'notification.title': 'Notificações',
53
+ 'notification.unread': 'Não lidas',
54
+ 'notification.all': 'Lidas',
55
+ 'notification.empty': 'Não há notificações',
56
+ 'notification.text': '{{user}} adicionou um comentário na entrada {{entry}}.',
57
+ },
58
+ };
@@ -1,4 +1,6 @@
1
1
  import ToastMessage from '../../AppToast/ToastMessage';
2
+ import User from '../User';
2
3
  import { StoreAction } from './types';
4
+ export declare const logged: (data: User | undefined) => StoreAction;
3
5
  export declare const message: (data: ToastMessage) => StoreAction;
4
6
  export declare const toastLoading: (data: boolean) => StoreAction;
@@ -1,4 +1,8 @@
1
1
  import { types } from './types';
2
+ export const logged = (data) => ({
3
+ type: types.LOGGED,
4
+ payload: data,
5
+ });
2
6
  export const message = (data) => ({
3
7
  type: types.MESSAGE,
4
8
  payload: data,
@@ -2,6 +2,11 @@
2
2
  import { types } from './types';
3
3
  function reducer(state, action) {
4
4
  switch (action.type) {
5
+ case types.LOGGED:
6
+ return {
7
+ ...state,
8
+ logged: action.payload,
9
+ };
5
10
  case types.MESSAGE:
6
11
  return {
7
12
  ...state,
@@ -1,5 +1,6 @@
1
1
  import { EMPTY_TOAST } from '../../AppToast/ToastMessage';
2
2
  const store = {
3
+ logged: undefined,
3
4
  message: EMPTY_TOAST,
4
5
  toastLoading: false,
5
6
  };
@@ -1,13 +1,16 @@
1
1
  import ToastMessage from '../../AppToast/ToastMessage';
2
+ import User from '../User';
2
3
  export type UserStore = {
4
+ logged: User | undefined;
3
5
  message: ToastMessage;
4
6
  toastLoading: boolean;
5
7
  };
6
8
  export type StoreAction = {
7
9
  type: string;
8
- payload?: ToastMessage | boolean;
10
+ payload?: ToastMessage | boolean | User;
9
11
  };
10
12
  export declare const types: {
11
13
  MESSAGE: string;
12
14
  TOAST_LOADING: string;
15
+ LOGGED: string;
13
16
  };
@@ -1,4 +1,5 @@
1
1
  export const types = {
2
2
  MESSAGE: 'MESSAGE',
3
3
  TOAST_LOADING: 'TOAST_LOADING',
4
+ LOGGED: 'LOGGED',
4
5
  };
@@ -0,0 +1,9 @@
1
+ declare function extractDateFromMongoId(id: string, time?: boolean): string;
2
+ declare const DateUtils: {
3
+ millis: () => number;
4
+ formatDate: (date: Date | null, fmt: string) => string;
5
+ parseTime: (time: number) => string;
6
+ extractDateFromMongoId: typeof extractDateFromMongoId;
7
+ formatDateTime: (isoDateStr: string, outputFormat: string) => string;
8
+ };
9
+ export default DateUtils;
@@ -0,0 +1,42 @@
1
+ import { addSeconds, parseISO } from 'date-fns';
2
+ import { format } from 'date-fns-tz';
3
+ const millis = () => new Date().getTime();
4
+ const formatDateTime = (isoDateStr, outputFormat) => {
5
+ try {
6
+ const parsedDate = parseISO(isoDateStr);
7
+ return format(parsedDate, outputFormat);
8
+ }
9
+ catch (error) {
10
+ console.error('Invalid date or format:', error);
11
+ return '';
12
+ }
13
+ };
14
+ const formatDate = (date, fmt) => {
15
+ console.log(typeof date);
16
+ if (!date)
17
+ return '';
18
+ return format(date, fmt);
19
+ };
20
+ const parseTime = (time) => {
21
+ if (time == null || time <= 0)
22
+ return '00:00:00.000';
23
+ return new Date(time * 1000).toISOString().slice(11, 23);
24
+ };
25
+ function extractDateFromMongoId(id, time) {
26
+ const DATE_PATTERN = 'yyyy-MM-dd';
27
+ const TIME_PATTERN = 'HH:mm:ss';
28
+ const hexTimestamp = id.substring(0, 8);
29
+ const timestampInMilliseconds = parseInt(hexTimestamp, 16) * 1000;
30
+ const dtf = time ? `${DATE_PATTERN} ${TIME_PATTERN}` : DATE_PATTERN;
31
+ const date = addSeconds(new Date(0), timestampInMilliseconds / 1000);
32
+ const formattedDate = format(date, dtf);
33
+ return formattedDate;
34
+ }
35
+ const DateUtils = {
36
+ millis,
37
+ formatDate,
38
+ parseTime,
39
+ extractDateFromMongoId,
40
+ formatDateTime,
41
+ };
42
+ export default DateUtils;
@@ -0,0 +1,11 @@
1
+ import { TFunction } from 'i18next';
2
+ import { SelectItem } from 'tycho-storybook/dist/SelectField/SelectField';
3
+ declare const FormUtils: {
4
+ convertEnum: (values: Record<string, string>, t?: TFunction, prefix?: string) => SelectItem[];
5
+ convertList: (values: any, labelAttr: string, valueAttr: string) => SelectItem[];
6
+ convertStringArray: (values: string[]) => SelectItem[];
7
+ booleanOptions: (t: TFunction) => SelectItem[];
8
+ convertMap: (values: Record<string, any> | undefined) => SelectItem[];
9
+ sortByLabel: (items: SelectItem[]) => SelectItem[];
10
+ };
11
+ export default FormUtils;
@@ -0,0 +1,56 @@
1
+ const convertEnum = (values, t, prefix) => {
2
+ if (!t)
3
+ return Object.entries(values).map(([key, label]) => ({
4
+ value: key,
5
+ label,
6
+ }));
7
+ return Object.entries(values).map(([key, label]) => ({
8
+ value: key,
9
+ label: t(`${prefix}.${label}`),
10
+ }));
11
+ };
12
+ const sortByLabel = (items) => {
13
+ return [...items].sort((a, b) => a.label.localeCompare(b.label));
14
+ };
15
+ const convertList = (values, labelAttr, valueAttr) => {
16
+ if (!values)
17
+ return [];
18
+ let fields = [];
19
+ values.map((value) => {
20
+ fields = [...fields, { label: value[labelAttr], value: value[valueAttr] }];
21
+ });
22
+ return fields;
23
+ };
24
+ const convertMap = (values) => {
25
+ if (!values)
26
+ return [];
27
+ let fields = [];
28
+ Object.keys(values).map((key) => {
29
+ fields = [...fields, { label: values[key], value: key }];
30
+ });
31
+ return fields;
32
+ };
33
+ const convertStringArray = (values) => {
34
+ if (!values)
35
+ return [];
36
+ let fields = [];
37
+ values.map((value) => {
38
+ fields = [...fields, { label: value, value }];
39
+ });
40
+ return fields;
41
+ };
42
+ const booleanOptions = (t) => {
43
+ return [
44
+ { label: t('message:generic.option.true'), value: 'true' },
45
+ { label: t('message:generic.option.false'), value: 'false' },
46
+ ];
47
+ };
48
+ const FormUtils = {
49
+ convertEnum,
50
+ convertList,
51
+ convertStringArray,
52
+ booleanOptions,
53
+ convertMap,
54
+ sortByLabel,
55
+ };
56
+ export default FormUtils;
@@ -0,0 +1,6 @@
1
+ import User from '../configs/User';
2
+ declare const SecurityUtils: {
3
+ hasAccess: (uid: string, roles: string[]) => boolean;
4
+ parseJwt: (token: string) => User;
5
+ };
6
+ export default SecurityUtils;
@@ -0,0 +1,28 @@
1
+ import CookieStorage from '../configs/CookieStorage';
2
+ import { UserStatus } from '../configs/User';
3
+ const hasAccess = (uid, roles) => {
4
+ const token = CookieStorage.getJwtToken();
5
+ if (!token)
6
+ return false;
7
+ const logged = parseJwt(token);
8
+ if (logged.status && logged.status === UserStatus.SUPER)
9
+ return true;
10
+ return roles.some((role) => logged.permissions.includes(`ROLE_${role}_LEXICON_${uid}`));
11
+ };
12
+ const parseJwt = (token) => {
13
+ const base64Url = token.split('.')[1];
14
+ const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
15
+ const payload = decodeURIComponent(window
16
+ .atob(base64)
17
+ .split('')
18
+ .map(function (c) {
19
+ return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
20
+ })
21
+ .join(''));
22
+ return JSON.parse(payload);
23
+ };
24
+ const SecurityUtils = {
25
+ hasAccess,
26
+ parseJwt,
27
+ };
28
+ export default SecurityUtils;
package/dist/index.d.ts CHANGED
@@ -5,11 +5,19 @@ export { default as Participants } from './Participants';
5
5
  export { default as AppModal } from './AppModal';
6
6
  export { default as AppModalConfirm } from './AppModal/AppModalConfirm';
7
7
  export { default as AppModalRemove } from './AppModal/AppModalRemove';
8
- export { commonResources } from './configs/Localization';
8
+ export { default as VirtualKeyboard } from './VirtualKeyboard';
9
+ export { default as CommentComponent } from './Comments';
10
+ export { default as HeaderNotifications } from './Comments/HeaderNotifications';
9
11
  export { CommonProvider } from './configs/CommonContext';
10
12
  export { useMessageUtils } from './configs/useMessageUtils';
11
13
  export { validateFormField } from './AppEditable/FormField';
12
14
  export { convertEnum, convertList } from './AppEditable/FormFieldOption';
15
+ export { commonResources } from './configs/Localization';
16
+ export { KeyboardCustomLayouts } from './VirtualKeyboard/KeyboardCustomLayout';
17
+ export { default as DateUtils } from './functions/DateUtils';
18
+ export { default as FormUtils } from './functions/FormUtils';
19
+ export { default as SecurityUtils } from './functions/SecurityUtils';
13
20
  export type { FormFieldOption } from './AppEditable/FormFieldOption';
14
21
  export type { AppEditableField } from './AppEditable/AppEditableField';
15
22
  export type { FieldOperations, FormField } from './AppEditable/FormField';
23
+ export type { KeyboardLayout } from './VirtualKeyboard/KeyboardCustomLayout';
package/dist/index.js CHANGED
@@ -5,8 +5,15 @@ export { default as Participants } from './Participants';
5
5
  export { default as AppModal } from './AppModal';
6
6
  export { default as AppModalConfirm } from './AppModal/AppModalConfirm';
7
7
  export { default as AppModalRemove } from './AppModal/AppModalRemove';
8
- export { commonResources } from './configs/Localization';
8
+ export { default as VirtualKeyboard } from './VirtualKeyboard';
9
+ export { default as CommentComponent } from './Comments';
10
+ export { default as HeaderNotifications } from './Comments/HeaderNotifications';
9
11
  export { CommonProvider } from './configs/CommonContext';
10
12
  export { useMessageUtils } from './configs/useMessageUtils';
11
13
  export { validateFormField } from './AppEditable/FormField';
12
14
  export { convertEnum, convertList } from './AppEditable/FormFieldOption';
15
+ export { commonResources } from './configs/Localization';
16
+ export { KeyboardCustomLayouts } from './VirtualKeyboard/KeyboardCustomLayout';
17
+ export { default as DateUtils } from './functions/DateUtils';
18
+ export { default as FormUtils } from './functions/FormUtils';
19
+ export { default as SecurityUtils } from './functions/SecurityUtils';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.0.10-SNAPSHOT-7",
4
+ "version": "0.0.11-SNAPSHOT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -27,6 +27,8 @@
27
27
  "js-cookie": "^3.0.5",
28
28
  "react-colorful": "^5.6.1",
29
29
  "react-easy-edit": "^2.0.0",
30
+ "react-simple-keyboard": "^3.8.66",
31
+ "simple-keyboard-layouts": "^3.4.82",
30
32
  "react-loading": "^2.0.3",
31
33
  "react-switch": "^7.1.0",
32
34
  "react-toastify": "^9.1.3"
@@ -45,7 +47,8 @@
45
47
  "react-dom": ">=17 <19",
46
48
  "react-hook-form": "^7.45.2",
47
49
  "react-i18next": "^13.0.2",
48
- "tycho-storybook": "0.1.3",
50
+ "react-router-dom": "^6.14.2",
51
+ "tycho-storybook": "0.1.5-SNAPSHOT",
49
52
  "yup": "^1.2.0"
50
53
  },
51
54
  "devDependencies": {