@buerokratt-ria/common-gui-components 0.0.1

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 (122) hide show
  1. package/.eslintrc.json +18 -0
  2. package/CHANGELOG.md +7 -0
  3. package/MAKING_CHANGES.md +8 -0
  4. package/README.md +49 -0
  5. package/assets/ding.mp3 +0 -0
  6. package/assets/logo-white.svg +29 -0
  7. package/assets/logo.svg +31 -0
  8. package/assets/newMessageSound.mp3 +0 -0
  9. package/constants/config.ts +12 -0
  10. package/constants/index.ts +1 -0
  11. package/context/index.ts +1 -0
  12. package/context/toastContext.tsx +60 -0
  13. package/hooks/index.ts +3 -0
  14. package/hooks/useAudio.tsx +30 -0
  15. package/hooks/useDocumentEscapeListener.tsx +17 -0
  16. package/hooks/useToast.tsx +5 -0
  17. package/i18n.ts +26 -0
  18. package/index.ts +6 -0
  19. package/package.json +122 -0
  20. package/project.json +52 -0
  21. package/services/api.ts +74 -0
  22. package/services/index.ts +3 -0
  23. package/services/sse-service.ts +30 -0
  24. package/services/users.ts +58 -0
  25. package/store/index.ts +253 -0
  26. package/templates/history-page/index.ts +1 -0
  27. package/templates/history-page/src/History.scss +47 -0
  28. package/templates/history-page/src/index.tsx +998 -0
  29. package/templates/history-page/src/unfiyDate.tsx +7 -0
  30. package/translations/en/common.json +467 -0
  31. package/translations/et/common.json +467 -0
  32. package/tsconfig.base.json +21 -0
  33. package/tsconfig.json +17 -0
  34. package/tsconfig.spec.json +19 -0
  35. package/types/authorities.ts +8 -0
  36. package/types/botConfig.ts +7 -0
  37. package/types/chat.ts +126 -0
  38. package/types/customerSupportActivity.ts +5 -0
  39. package/types/deleteChatSettings.ts +9 -0
  40. package/types/emergencyNotice.ts +10 -0
  41. package/types/establishment.ts +4 -0
  42. package/types/index.ts +18 -0
  43. package/types/mainNavigation.ts +11 -0
  44. package/types/message.ts +74 -0
  45. package/types/organizationWorkingTime.ts +27 -0
  46. package/types/router.ts +4 -0
  47. package/types/service.ts +6 -0
  48. package/types/session.ts +7 -0
  49. package/types/skmConfig.ts +8 -0
  50. package/types/user.ts +40 -0
  51. package/types/userInfo.ts +16 -0
  52. package/types/userProfileSettings.ts +10 -0
  53. package/types/widgetConfig.ts +8 -0
  54. package/ui-components/Button/Button.scss +150 -0
  55. package/ui-components/Button/index.tsx +41 -0
  56. package/ui-components/ButtonMessage/ButtonMessage.scss +16 -0
  57. package/ui-components/ButtonMessage/index.tsx +19 -0
  58. package/ui-components/Card/Card.scss +69 -0
  59. package/ui-components/Card/index.tsx +39 -0
  60. package/ui-components/Chat/Chat.scss +447 -0
  61. package/ui-components/Chat/ChatMessage.tsx +270 -0
  62. package/ui-components/Chat/ChatTextArea.scss +110 -0
  63. package/ui-components/Chat/ChatTextArea.tsx +97 -0
  64. package/ui-components/Chat/LoaderOverlay.tsx +39 -0
  65. package/ui-components/Chat/Markdownify.tsx +49 -0
  66. package/ui-components/Chat/PreviewMessage.tsx +39 -0
  67. package/ui-components/Chat/Typing.scss +46 -0
  68. package/ui-components/Chat/index.tsx +1111 -0
  69. package/ui-components/ChatEvent/Chat.scss +40 -0
  70. package/ui-components/ChatEvent/index.tsx +216 -0
  71. package/ui-components/DataTable/CloseIcon.tsx +22 -0
  72. package/ui-components/DataTable/DataTable.scss +188 -0
  73. package/ui-components/DataTable/DeboucedInput.scss +11 -0
  74. package/ui-components/DataTable/DebouncedInput.tsx +54 -0
  75. package/ui-components/DataTable/Filter.tsx +121 -0
  76. package/ui-components/DataTable/index.tsx +432 -0
  77. package/ui-components/Dialog/Dialog.scss +63 -0
  78. package/ui-components/Dialog/index.tsx +44 -0
  79. package/ui-components/Drawer/Drawer.scss +40 -0
  80. package/ui-components/Drawer/index.tsx +42 -0
  81. package/ui-components/FormElements/FormCheckbox/FormCheckbox.scss +57 -0
  82. package/ui-components/FormElements/FormCheckbox/index.tsx +39 -0
  83. package/ui-components/FormElements/FormCheckboxes/FormCheckboxes.scss +63 -0
  84. package/ui-components/FormElements/FormCheckboxes/index.tsx +44 -0
  85. package/ui-components/FormElements/FormDatepicker/FormDatepicker.scss +154 -0
  86. package/ui-components/FormElements/FormDatepicker/index.tsx +123 -0
  87. package/ui-components/FormElements/FormInput/FormInput.scss +90 -0
  88. package/ui-components/FormElements/FormInput/index.tsx +47 -0
  89. package/ui-components/FormElements/FormRadios/FormRadios.scss +72 -0
  90. package/ui-components/FormElements/FormRadios/index.tsx +36 -0
  91. package/ui-components/FormElements/FormSelect/FormMultiselect.tsx +124 -0
  92. package/ui-components/FormElements/FormSelect/FormSelect.scss +121 -0
  93. package/ui-components/FormElements/FormSelect/index.tsx +100 -0
  94. package/ui-components/FormElements/FormTextarea/FormTextarea.scss +109 -0
  95. package/ui-components/FormElements/FormTextarea/index.tsx +154 -0
  96. package/ui-components/FormElements/Switch/Switch.scss +69 -0
  97. package/ui-components/FormElements/Switch/index.tsx +65 -0
  98. package/ui-components/FormElements/SwitchBox/SwitchBox.scss +45 -0
  99. package/ui-components/FormElements/SwitchBox/index.tsx +44 -0
  100. package/ui-components/FormElements/index.tsx +23 -0
  101. package/ui-components/HistoricalChat/ChatMessage.tsx +67 -0
  102. package/ui-components/HistoricalChat/HistoricalChat.scss +225 -0
  103. package/ui-components/HistoricalChat/index.tsx +282 -0
  104. package/ui-components/Icon/Icon.scss +17 -0
  105. package/ui-components/Icon/index.tsx +26 -0
  106. package/ui-components/Label/Label.scss +76 -0
  107. package/ui-components/Label/index.tsx +40 -0
  108. package/ui-components/OptionMessage/OptionMessage.scss +16 -0
  109. package/ui-components/OptionMessage/index.tsx +16 -0
  110. package/ui-components/Toast/Toast.scss +73 -0
  111. package/ui-components/Toast/index.tsx +54 -0
  112. package/ui-components/Tooltip/Tooltip.scss +17 -0
  113. package/ui-components/Tooltip/index.tsx +28 -0
  114. package/ui-components/Track/index.tsx +57 -0
  115. package/ui-components/index.tsx +53 -0
  116. package/utils/constants.ts +19 -0
  117. package/utils/format-bytes.ts +8 -0
  118. package/utils/generateUEID.ts +8 -0
  119. package/utils/local-storage-utils.ts +17 -0
  120. package/utils/parse-utils.ts +23 -0
  121. package/utils/state-management-utils.ts +13 -0
  122. package/vite.config.ts +67 -0
@@ -0,0 +1,110 @@
1
+ @import 'src/styles/tools/spacing';
2
+ @import 'src/styles/tools/color';
3
+ @import 'src/styles/settings/variables/other';
4
+ @import 'src/styles/settings/variables/typography';
5
+
6
+ .textarea {
7
+ $self: &;
8
+ display: flex;
9
+ align-items: center;
10
+ gap: get-spacing(paldiski);
11
+ width: 100%;
12
+
13
+ &__label {
14
+ flex: 0 0 185px;
15
+ font-size: $veera-font-size-100;
16
+ line-height: 24px;
17
+ }
18
+
19
+ &__wrapper {
20
+ flex: 1;
21
+ display: flex;
22
+ flex-direction: column;
23
+ gap: 7px;
24
+ position: relative;
25
+ }
26
+
27
+ &__error {
28
+ width: 100%;
29
+ margin-right: 6px;
30
+ display: flex;
31
+ align-items: center;
32
+ gap: get-spacing(paldiski);
33
+ color: get-color(black-coral-20);
34
+ border-radius: $veera-radius-s;
35
+ background-color: get-color(jasper-3);
36
+ font-size: 13px;
37
+ line-height: 20px;
38
+ box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
39
+
40
+ &::before {
41
+ content: '';
42
+ display: block;
43
+ background-color: get-color(jasper-3);
44
+ border-left: 16px solid transparent;
45
+ border-right: 16px solid transparent;
46
+ border-bottom: 25px;
47
+ }
48
+ }
49
+
50
+ &__max-length-top {
51
+ position: absolute;
52
+ top: 10px;
53
+ right: 8px;
54
+ font-size: $veera-font-size-80;
55
+ color: get-color(black-coral-12);
56
+ pointer-events: none;
57
+ }
58
+
59
+ &__max-length-bottom {
60
+ position: absolute;
61
+ bottom: 10px;
62
+ right: 8px;
63
+ font-size: $veera-font-size-80;
64
+ color: get-color(black-coral-12);
65
+ pointer-events: none;
66
+ }
67
+
68
+ textarea {
69
+ width: 100%;
70
+ display: block;
71
+ appearance: none;
72
+ background-color: get-color(white);
73
+ border: 1px solid get-color(black-coral-6);
74
+ border-radius: $veera-radius-s;
75
+ color: var(--color-black);
76
+ font-size: $veera-font-size-100;
77
+ line-height: $veera-line-height-500;
78
+ height: 40px;
79
+ min-height: 40px;
80
+ resize: none;
81
+ padding: get-spacing(paldiski);
82
+
83
+ &::placeholder {
84
+ color: get-color(black-coral-6);
85
+ }
86
+
87
+ &:focus {
88
+ outline: none;
89
+ border-color: get-color(sapphire-blue-10);
90
+ }
91
+ }
92
+
93
+ &--error {
94
+ input {
95
+ border-color: get-color(jasper-10);
96
+ }
97
+ }
98
+
99
+ &--disabled & {
100
+ input {
101
+ background-color: get-color(black-coral-0);
102
+ }
103
+ }
104
+
105
+ &--maxlength-shown {
106
+ textarea {
107
+ padding-right: 70px;
108
+ }
109
+ }
110
+ }
@@ -0,0 +1,97 @@
1
+ import React, { ChangeEvent, forwardRef, useId, useState } from 'react';
2
+ import TextareaAutosize, {
3
+ TextareaAutosizeProps,
4
+ } from 'react-textarea-autosize';
5
+ import clsx from 'clsx';
6
+
7
+ import './ChatTextArea.scss';
8
+
9
+ type TextareaProps = TextareaAutosizeProps & {
10
+ label: string;
11
+ name: string;
12
+ hideLabel?: boolean;
13
+ showMaxLength?: boolean;
14
+ maxLengthBottom?: boolean;
15
+ };
16
+
17
+ const ChatTextArea = forwardRef<HTMLTextAreaElement, TextareaProps>(
18
+ (
19
+ {
20
+ label,
21
+ name,
22
+ maxLength = 2000,
23
+ minRows = 3,
24
+ maxRows = 3,
25
+ disabled,
26
+ hideLabel,
27
+ showMaxLength,
28
+ maxLengthBottom,
29
+ defaultValue,
30
+ onChange,
31
+ onSubmit,
32
+ ...rest
33
+ },
34
+ ref
35
+ ) => {
36
+ const id = useId();
37
+ const [currentLength, setCurrentLength] = useState(
38
+ (typeof defaultValue === 'string' && defaultValue.length) || 0
39
+ );
40
+ const textareaClasses = clsx(
41
+ 'textarea',
42
+ disabled && 'textarea--disabled',
43
+ showMaxLength && 'textarea--maxlength-shown'
44
+ );
45
+
46
+ const handleOnChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
47
+ if (showMaxLength) {
48
+ setCurrentLength(e.target.value.length);
49
+ }
50
+ };
51
+
52
+ return (
53
+ <div className={textareaClasses}>
54
+ {label && !hideLabel && (
55
+ <label htmlFor={id} className="textarea__label">
56
+ {label}
57
+ </label>
58
+ )}
59
+ <div className="textarea__wrapper">
60
+ <TextareaAutosize
61
+ id={id}
62
+ maxLength={maxLength}
63
+ minRows={minRows}
64
+ maxRows={maxRows}
65
+ ref={ref}
66
+ onKeyDownCapture={(e) => {
67
+ if (e.key === 'Enter') {
68
+ e.preventDefault();
69
+ if (onSubmit) onSubmit(e);
70
+ }
71
+ }}
72
+ defaultValue={defaultValue}
73
+ aria-label={hideLabel ? label : undefined}
74
+ onChange={(e) => {
75
+ if (onChange) onChange(e);
76
+ handleOnChange(e);
77
+ }}
78
+ {...rest}
79
+ />
80
+ {showMaxLength && (
81
+ <div
82
+ className={
83
+ maxLengthBottom
84
+ ? 'textarea__max-length-bottom'
85
+ : 'textarea__max-length-top'
86
+ }
87
+ >
88
+ {currentLength}/{maxLength}
89
+ </div>
90
+ )}
91
+ </div>
92
+ </div>
93
+ );
94
+ }
95
+ );
96
+
97
+ export default ChatTextArea;
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+
3
+ interface LoaderOverlayProps {
4
+ maxPercent: number;
5
+ currentPercent: number;
6
+ }
7
+
8
+ const LoaderOverlay: React.FC<LoaderOverlayProps> = ({
9
+ maxPercent,
10
+ currentPercent,
11
+ }) => {
12
+ const overlayStyle: React.CSSProperties = {
13
+ position: 'absolute',
14
+ top: 0,
15
+ left: 0,
16
+ height: '100%',
17
+ width: `${((maxPercent - currentPercent) / maxPercent) * 100}%`, // Modified: Deduct from the full width
18
+ maxWidth: '100%',
19
+ backgroundColor: 'rgba(211, 211, 211, 0.7)',
20
+ transition: 'width 1s linear',
21
+ visibility: currentPercent > 0 ? 'visible' : 'hidden',
22
+ borderRadius: '30px 0px 0px 30px',
23
+ };
24
+
25
+ return (
26
+ <div style={overlayStyle}>
27
+ <div
28
+ style={{
29
+ position: 'absolute',
30
+ top: '50%',
31
+ left: '50%',
32
+ transform: 'translate(-50%, -50%)',
33
+ }}
34
+ ></div>
35
+ </div>
36
+ );
37
+ };
38
+
39
+ export default LoaderOverlay;
@@ -0,0 +1,49 @@
1
+ import React, { useState } from 'react';
2
+ import Markdown from 'markdown-to-jsx';
3
+ import './Chat.scss';
4
+
5
+ interface MarkdownifyProps {
6
+ message: string | undefined;
7
+ }
8
+
9
+ const LinkPreview: React.FC<{ href: string; children: React.ReactNode }> = ({ href, children }) => {
10
+ const [hasError, setHasError] = useState(false);
11
+ const basicAuthPattern = /^[a-zA-Z][a-zA-Z\d+\-.]*:\/\/[^@]+@/;
12
+
13
+ if (basicAuthPattern.test(href)) {
14
+ return null;
15
+ }
16
+
17
+ return !hasError ? (
18
+ <img
19
+ src={href}
20
+ alt={typeof children === "string" ? children : "Preview"}
21
+ style={{ maxWidth: "100%", height: "auto", borderRadius: "20px" }}
22
+ onError={() => setHasError(true)}
23
+ />
24
+ ) : (
25
+ <a href={href} target="_blank" rel="noopener noreferrer">
26
+ {children}
27
+ </a>
28
+ );
29
+ };
30
+
31
+ const Markdownify: React.FC<MarkdownifyProps> = ({ message }) => (
32
+ <div className={'reset'}>
33
+ <Markdown
34
+ options={{
35
+ enforceAtxHeadings: true,
36
+ overrides: {
37
+ a: {
38
+ component: LinkPreview,
39
+ },
40
+ },
41
+ disableParsingRawHTML: true,
42
+ }}
43
+ >
44
+ {message ?? ''}
45
+ </Markdown>
46
+ </div>
47
+ );
48
+
49
+ export default Markdownify;
@@ -0,0 +1,39 @@
1
+ import { FC } from 'react';
2
+ import clsx from 'clsx';
3
+ import Track from '../Track';
4
+ import './Typing.scss';
5
+
6
+ type PreviewMessageProps = {
7
+ preview: string | undefined;
8
+ };
9
+
10
+ const PreviewMessage: FC<PreviewMessageProps> = ({ preview }) => {
11
+ return (
12
+ <div className={clsx('active-chat__messageContainer')}>
13
+ <Track gap={10}>
14
+ {!!preview && preview && (
15
+ <div className={clsx('active-chat__message-preview')}>
16
+ {!!preview && (
17
+ <Track>
18
+ {/* Commented out as per request in task -1024- */}
19
+ {/* <Markdownify message={preview ?? ''} /> */}
20
+ <div className="typing">
21
+ <span></span>
22
+ <span></span>
23
+ <span></span>
24
+ </div>
25
+ </Track>
26
+ )}
27
+ </div>
28
+ )}
29
+ <label
30
+ className="active-chat__message-date"
31
+ >
32
+ {'00:00:00'}
33
+ </label>
34
+ </Track>
35
+ </div>
36
+ );
37
+ };
38
+
39
+ export default PreviewMessage;
@@ -0,0 +1,46 @@
1
+ $dot-width: 6px;
2
+ $dot-color: #3b5998;
3
+ $speed: 1.5s;
4
+
5
+ .typing {
6
+ text-align: center;
7
+
8
+ span {
9
+ content: '';
10
+ animation: blink $speed infinite;
11
+ animation-fill-mode: both;
12
+ height: $dot-width;
13
+ width: $dot-width;
14
+ background: $dot-color;
15
+ display: inline-block;
16
+ margin: 0 $dot-width * 0.2;
17
+ border-radius: 50%;
18
+
19
+ &:nth-child(1) {
20
+ animation-delay: .2s;
21
+ margin-left: 6px;
22
+ }
23
+
24
+ &:nth-child(2) {
25
+ animation-delay: .2s;
26
+ }
27
+
28
+ &:nth-child(3) {
29
+ animation-delay: .4s;
30
+ }
31
+ }
32
+ }
33
+
34
+ @keyframes blink {
35
+ 0% {
36
+ opacity: .1;
37
+ }
38
+
39
+ 20% {
40
+ opacity: 1;
41
+ }
42
+
43
+ 100% {
44
+ opacity: .1;
45
+ }
46
+ }