@addev-be/ui 0.11.7 → 0.12.0

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 (186) hide show
  1. package/assets/icons/arrow-down-1-9.svg +1 -1
  2. package/assets/icons/arrow-down-a-z.svg +1 -1
  3. package/assets/icons/arrow-up-z-a.svg +1 -1
  4. package/assets/icons/check.svg +1 -1
  5. package/assets/icons/circle-check.svg +1 -1
  6. package/assets/icons/down.svg +1 -1
  7. package/assets/icons/filter-full.svg +1 -1
  8. package/assets/icons/filter.svg +1 -1
  9. package/assets/icons/hashtag.svg +1 -1
  10. package/assets/icons/image-slash.svg +1 -1
  11. package/assets/icons/left.svg +1 -1
  12. package/assets/icons/magnifier.svg +1 -1
  13. package/assets/icons/phone.svg +1 -1
  14. package/assets/icons/right.svg +1 -1
  15. package/assets/icons/sort-calendar-ascending.svg +5 -5
  16. package/assets/icons/spinner-third.svg +1 -1
  17. package/assets/icons/table-columns.svg +1 -1
  18. package/assets/icons/table-footer-slash.svg +4 -4
  19. package/assets/icons/table-footer.svg +3 -3
  20. package/assets/icons/up.svg +1 -1
  21. package/assets/icons/user-tie.svg +1 -1
  22. package/assets/icons/x-bar.svg +3 -3
  23. package/dist/components/auth/LoginForm.js +0 -1
  24. package/dist/components/data/DataGrid/AdvancedRequestDataGrid.d.ts +10 -0
  25. package/dist/components/data/DataGrid/AdvancedRequestDataGrid.js +173 -0
  26. package/dist/components/data/DataGrid/FilterValuesScroller.d.ts +13 -0
  27. package/dist/components/data/DataGrid/FilterValuesScroller.js +73 -0
  28. package/dist/components/data/DataGrid/VirtualScroller.d.ts +11 -0
  29. package/dist/components/data/DataGrid/VirtualScroller.js +41 -0
  30. package/dist/components/data/DataGrid/helpers/advancedRequests.d.ts +12 -0
  31. package/dist/components/data/DataGrid/helpers/advancedRequests.js +53 -0
  32. package/dist/components/data/DataGrid/helpers.d.ts +28 -0
  33. package/dist/components/data/DataGrid/helpers.js +436 -0
  34. package/dist/config/types.d.ts +11 -0
  35. package/dist/config/types.js +2 -0
  36. package/dist/providers/AuthenticationProvider/index.d.ts +0 -1
  37. package/dist/providers/AuthenticationProvider/index.js +14 -28
  38. package/dist/services/advancedRequests.d.ts +1 -1
  39. package/dist/services/requests/userPermissions.d.ts +4 -0
  40. package/dist/services/requests/userPermissions.js +20 -0
  41. package/dist/services/sqlRequests.d.ts +1 -1
  42. package/package.json +1 -1
  43. package/src/Icons.tsx +128 -128
  44. package/src/components/auth/LoginForm.tsx +84 -84
  45. package/src/components/auth/LoginPage.tsx +32 -32
  46. package/src/components/auth/PasswordRecoveryForm.tsx +52 -52
  47. package/src/components/auth/PasswordResetForm.tsx +112 -112
  48. package/src/components/auth/index.ts +4 -4
  49. package/src/components/auth/styles.ts +14 -14
  50. package/src/components/data/AdvancedRequestDataGrid/helpers/advancedRequests.ts +93 -93
  51. package/src/components/data/AdvancedRequestDataGrid/helpers/columns.tsx +262 -262
  52. package/src/components/data/AdvancedRequestDataGrid/helpers/index.ts +2 -2
  53. package/src/components/data/AdvancedRequestDataGrid/index.tsx +267 -267
  54. package/src/components/data/AdvancedRequestDataGrid/types.ts +47 -47
  55. package/src/components/data/DataGrid/DataGridCell.tsx +76 -76
  56. package/src/components/data/DataGrid/DataGridColumnsModal/helpers.ts +14 -14
  57. package/src/components/data/DataGrid/DataGridColumnsModal/hooks.tsx +59 -59
  58. package/src/components/data/DataGrid/DataGridColumnsModal/index.tsx +181 -181
  59. package/src/components/data/DataGrid/DataGridColumnsModal/styles.ts +104 -104
  60. package/src/components/data/DataGrid/DataGridEditableCell.tsx +43 -43
  61. package/src/components/data/DataGrid/DataGridFilterMenu/FilterValuesScroller.tsx +131 -131
  62. package/src/components/data/DataGrid/DataGridFilterMenu/hooks.tsx +78 -78
  63. package/src/components/data/DataGrid/DataGridFilterMenu/index.tsx +378 -378
  64. package/src/components/data/DataGrid/DataGridFilterMenu/styles.ts +97 -97
  65. package/src/components/data/DataGrid/DataGridFooter.tsx +43 -43
  66. package/src/components/data/DataGrid/DataGridHeader.tsx +128 -128
  67. package/src/components/data/DataGrid/DataGridHeaderCell.tsx +101 -101
  68. package/src/components/data/DataGrid/DataGridRowTemplate.tsx +70 -70
  69. package/src/components/data/DataGrid/FilterModalContent/index.tsx +136 -136
  70. package/src/components/data/DataGrid/FilterModalContent/styles.ts +22 -22
  71. package/src/components/data/DataGrid/constants.ts +6 -6
  72. package/src/components/data/DataGrid/helpers/columns.tsx +319 -319
  73. package/src/components/data/DataGrid/helpers/filters.ts +287 -287
  74. package/src/components/data/DataGrid/helpers/index.ts +2 -2
  75. package/src/components/data/DataGrid/hooks/index.ts +30 -30
  76. package/src/components/data/DataGrid/hooks/useDataGrid.tsx +338 -338
  77. package/src/components/data/DataGrid/hooks/useDataGridCopy.ts +175 -175
  78. package/src/components/data/DataGrid/hooks/useDataGridSettings.ts +48 -48
  79. package/src/components/data/DataGrid/index.tsx +110 -110
  80. package/src/components/data/DataGrid/styles.ts +336 -336
  81. package/src/components/data/DataGrid/types.ts +283 -283
  82. package/src/components/data/SmartQueryDataGrid/helpers/columns.tsx +333 -0
  83. package/src/components/data/SmartQueryDataGrid/helpers/hooks.ts +41 -0
  84. package/src/components/data/SmartQueryDataGrid/helpers/index.ts +2 -0
  85. package/src/components/data/SmartQueryDataGrid/helpers/smartQueries.ts +17 -0
  86. package/src/components/data/SmartQueryDataGrid/hooks.ts +75 -0
  87. package/src/components/data/SmartQueryDataGrid/index.tsx +338 -0
  88. package/src/components/data/SmartQueryDataGrid/types.ts +45 -0
  89. package/src/components/data/SqlRequestDataGrid/helpers/columns.tsx +306 -306
  90. package/src/components/data/SqlRequestDataGrid/helpers/index.ts +2 -2
  91. package/src/components/data/SqlRequestDataGrid/helpers/sqlRequests.ts +16 -16
  92. package/src/components/data/SqlRequestDataGrid/index.tsx +387 -387
  93. package/src/components/data/SqlRequestDataGrid/types.ts +48 -48
  94. package/src/components/data/SqlRequestGrid/filters/FiltersSidebar.tsx +106 -106
  95. package/src/components/data/SqlRequestGrid/filters/styles.ts +88 -88
  96. package/src/components/data/SqlRequestGrid/helpers/index.ts +1 -1
  97. package/src/components/data/SqlRequestGrid/helpers/sqlRequests.ts +16 -16
  98. package/src/components/data/SqlRequestGrid/index.tsx +310 -310
  99. package/src/components/data/SqlRequestGrid/styles.ts +20 -20
  100. package/src/components/data/SqlRequestGrid/types.ts +53 -53
  101. package/src/components/data/VirtualScroller/hooks.ts +71 -71
  102. package/src/components/data/VirtualScroller/index.tsx +89 -89
  103. package/src/components/data/VirtualScroller/styles.ts +58 -58
  104. package/src/components/data/VirtualScroller/types.ts +12 -12
  105. package/src/components/data/index.ts +21 -17
  106. package/src/components/forms/AutoTextArea.tsx +41 -41
  107. package/src/components/forms/Button.tsx +133 -133
  108. package/src/components/forms/IconButton.tsx +57 -57
  109. package/src/components/forms/IndeterminateCheckbox.tsx +46 -46
  110. package/src/components/forms/Select.tsx +40 -40
  111. package/src/components/forms/VerticalLabel.tsx +20 -20
  112. package/src/components/forms/index.ts +6 -6
  113. package/src/components/forms/styles.ts +31 -31
  114. package/src/components/index.ts +6 -6
  115. package/src/components/layout/Dropdown/index.tsx +112 -112
  116. package/src/components/layout/Dropdown/styles.ts +45 -45
  117. package/src/components/layout/Loading/index.tsx +29 -29
  118. package/src/components/layout/Loading/styles.ts +29 -29
  119. package/src/components/layout/Modal/index.tsx +51 -51
  120. package/src/components/layout/Modal/styles.ts +121 -121
  121. package/src/components/layout/index.ts +3 -3
  122. package/src/components/search/HighlightedText.tsx +37 -37
  123. package/src/components/search/QuickSearchBar.tsx +86 -86
  124. package/src/components/search/QuickSearchResults.tsx +86 -86
  125. package/src/components/search/index.ts +9 -9
  126. package/src/components/search/styles.ts +96 -96
  127. package/src/components/search/types.ts +26 -26
  128. package/src/components/ui/Avatar/index.tsx +54 -54
  129. package/src/components/ui/Card/index.tsx +14 -14
  130. package/src/components/ui/Card/styles.ts +37 -37
  131. package/src/components/ui/ContextMenu/index.tsx +79 -79
  132. package/src/components/ui/ContextMenu/styles.ts +119 -119
  133. package/src/components/ui/Label.tsx +90 -90
  134. package/src/components/ui/Message/index.tsx +57 -57
  135. package/src/components/ui/Message/styles.ts +40 -40
  136. package/src/components/ui/index.ts +5 -5
  137. package/src/config/index.ts +14 -14
  138. package/src/helpers/dates.ts +17 -17
  139. package/src/helpers/getScrollbarSize.ts +14 -14
  140. package/src/helpers/index.ts +3 -3
  141. package/src/helpers/numbers.ts +26 -26
  142. package/src/helpers/text.ts +13 -13
  143. package/src/hooks/index.ts +3 -3
  144. package/src/hooks/useElementSize.ts +24 -24
  145. package/src/hooks/useShowArchived.ts +28 -28
  146. package/src/hooks/useWindowSize.ts +20 -20
  147. package/src/index.ts +9 -9
  148. package/src/providers/AuthenticationProvider/helpers.ts +3 -3
  149. package/src/providers/AuthenticationProvider/index.tsx +243 -243
  150. package/src/providers/LoadingProvider/index.tsx +47 -47
  151. package/src/providers/PortalsProvider/index.tsx +54 -54
  152. package/src/providers/PortalsProvider/styles.ts +31 -31
  153. package/src/providers/SettingsProvider/index.tsx +70 -70
  154. package/src/providers/ThemeProvider/ThemeProvider.ts +63 -63
  155. package/src/providers/ThemeProvider/defaultTheme.ts +457 -457
  156. package/src/providers/ThemeProvider/index.ts +4 -4
  157. package/src/providers/ThemeProvider/types.ts +131 -131
  158. package/src/providers/TrackingProvider/index.tsx +71 -71
  159. package/src/providers/UiProviders/index.tsx +68 -68
  160. package/src/providers/UiProviders/styles.ts +10 -10
  161. package/src/providers/hooks.ts +12 -12
  162. package/src/providers/index.ts +8 -8
  163. package/src/services/HttpService.ts +92 -92
  164. package/src/services/WebSocketService.ts +137 -137
  165. package/src/services/advancedRequests.ts +102 -102
  166. package/src/services/base.ts +23 -23
  167. package/src/services/globalSearch.ts +29 -29
  168. package/src/services/hooks.ts +44 -44
  169. package/src/services/index.ts +20 -19
  170. package/src/services/requests/auth.ts +44 -44
  171. package/src/services/requests/generic.ts +62 -62
  172. package/src/services/requests/tracking.ts +12 -12
  173. package/src/services/requests/userProfiles.ts +35 -35
  174. package/src/services/requests/users.ts +28 -28
  175. package/src/services/smartQueries.ts +122 -0
  176. package/src/services/sqlRequests.ts +111 -111
  177. package/src/services/types/auth.ts +131 -131
  178. package/src/services/types/base.ts +10 -10
  179. package/src/services/types/generic.ts +92 -92
  180. package/src/services/types/tracking.ts +39 -39
  181. package/src/services/types/userProfiles.ts +107 -107
  182. package/src/services/types/users.ts +106 -106
  183. package/src/styles/animations.scss +30 -30
  184. package/src/styles/index.scss +42 -42
  185. package/src/typings.d.ts +13 -13
  186. package/tsconfig.json +18 -18
@@ -1,9 +1,9 @@
1
- export * from './QuickSearchBar';
2
- export * from './QuickSearchResults';
3
- export * from './HighlightedText';
4
- export * from './types';
5
- export {
6
- QuickSearchResultDetailsTitle,
7
- QuickSearchResultsDetailsList,
8
- QuickSearchResultsDetailsTerm,
9
- } from './styles';
1
+ export * from './QuickSearchBar';
2
+ export * from './QuickSearchResults';
3
+ export * from './HighlightedText';
4
+ export * from './types';
5
+ export {
6
+ QuickSearchResultDetailsTitle,
7
+ QuickSearchResultsDetailsList,
8
+ QuickSearchResultsDetailsTerm,
9
+ } from './styles';
@@ -1,96 +1,96 @@
1
- import styled from 'styled-components';
2
-
3
- export const QuickSearchDropdownContainer = styled.div.attrs({
4
- className: 'QuickSearchDropdownContainer',
5
- })`
6
- display: flex;
7
- flex-direction: column;
8
- height: 100%;
9
- `;
10
-
11
- export const QuickSearchResultsContainer = styled.div.attrs({
12
- className: 'QuickSearchResultsContainer',
13
- })`
14
- display: flex;
15
- flex-direction: row;
16
- height: 100%;
17
- flex: 1;
18
- padding: var(--space-2) 0;
19
- overflow: hidden;
20
- `;
21
-
22
- export const QuickSearchResultsListContainer = styled.div.attrs({
23
- className: 'QuickSearchResultsListContainer',
24
- })`
25
- display: flex;
26
- flex-direction: column;
27
- padding: var(--space-2);
28
- border-right: 1px solid var(--color-neutral-200);
29
- flex: 1;
30
- overflow: auto;
31
- `;
32
-
33
- export const QuickSearchResultsTitle = styled.div.attrs({
34
- className: 'QuickSearchResultsTitle',
35
- })`
36
- margin: 0;
37
- margin-bottom: var(--space-1);
38
- &:not(:first-child) {
39
- margin-top: var(--space-2);
40
- }
41
- font-weight: bold;
42
- font-size: var(--text-sm);
43
- text-transform: uppercase;
44
- letter-spacing: 120%;
45
- color: var(--color-neutral-500);
46
- `;
47
-
48
- export const QuickSearchResultsItem = styled.div.attrs({
49
- className: 'QuickSearchResultsItem',
50
- })`
51
- padding: var(--space-2) var(--space-3);
52
- cursor: pointer;
53
- border-radius: 4px;
54
- &:hover {
55
- background-color: var(--color-neutral-100);
56
- }
57
- `;
58
-
59
- export const QuickSearchResultsDetailsContainer = styled.div.attrs({
60
- className: 'QuickSearchResultsDetailsContainer',
61
- })`
62
- display: flex;
63
- flex-direction: column;
64
- padding: var(--space-2);
65
- flex: 1;
66
- `;
67
-
68
- export const QuickSearchResultsDetailsDivider = styled.hr`
69
- margin: var(--space-2) 0;
70
- height: 1px;
71
- border: none;
72
- background-color: var(--color-neutral-200);
73
- `;
74
-
75
- export const QuickSearchResultDetailsTitle = styled.div.attrs({
76
- className: 'QuickSearchResultDetailsTitle',
77
- })`
78
- margin: 0;
79
- `;
80
-
81
- export const QuickSearchResultsDetailsList = styled.dl.attrs({
82
- className: 'QuickSearchResultsDetailsList',
83
- })`
84
- display: grid;
85
- grid-template-columns: 1fr 3fr;
86
- grid-gap: var(--space-2);
87
- `;
88
-
89
- export const QuickSearchResultsDetailsTerm = styled.dt.attrs({
90
- className: 'QuickSearchResultsDetailsTerm',
91
- })`
92
- text-transform: uppercase;
93
- font-size: var(--text-sm);
94
- font-weight: bold;
95
- color: var(--color-neutral-500);
96
- `;
1
+ import styled from 'styled-components';
2
+
3
+ export const QuickSearchDropdownContainer = styled.div.attrs({
4
+ className: 'QuickSearchDropdownContainer',
5
+ })`
6
+ display: flex;
7
+ flex-direction: column;
8
+ height: 100%;
9
+ `;
10
+
11
+ export const QuickSearchResultsContainer = styled.div.attrs({
12
+ className: 'QuickSearchResultsContainer',
13
+ })`
14
+ display: flex;
15
+ flex-direction: row;
16
+ height: 100%;
17
+ flex: 1;
18
+ padding: var(--space-2) 0;
19
+ overflow: hidden;
20
+ `;
21
+
22
+ export const QuickSearchResultsListContainer = styled.div.attrs({
23
+ className: 'QuickSearchResultsListContainer',
24
+ })`
25
+ display: flex;
26
+ flex-direction: column;
27
+ padding: var(--space-2);
28
+ border-right: 1px solid var(--color-neutral-200);
29
+ flex: 1;
30
+ overflow: auto;
31
+ `;
32
+
33
+ export const QuickSearchResultsTitle = styled.div.attrs({
34
+ className: 'QuickSearchResultsTitle',
35
+ })`
36
+ margin: 0;
37
+ margin-bottom: var(--space-1);
38
+ &:not(:first-child) {
39
+ margin-top: var(--space-2);
40
+ }
41
+ font-weight: bold;
42
+ font-size: var(--text-sm);
43
+ text-transform: uppercase;
44
+ letter-spacing: 120%;
45
+ color: var(--color-neutral-500);
46
+ `;
47
+
48
+ export const QuickSearchResultsItem = styled.div.attrs({
49
+ className: 'QuickSearchResultsItem',
50
+ })`
51
+ padding: var(--space-2) var(--space-3);
52
+ cursor: pointer;
53
+ border-radius: 4px;
54
+ &:hover {
55
+ background-color: var(--color-neutral-100);
56
+ }
57
+ `;
58
+
59
+ export const QuickSearchResultsDetailsContainer = styled.div.attrs({
60
+ className: 'QuickSearchResultsDetailsContainer',
61
+ })`
62
+ display: flex;
63
+ flex-direction: column;
64
+ padding: var(--space-2);
65
+ flex: 1;
66
+ `;
67
+
68
+ export const QuickSearchResultsDetailsDivider = styled.hr`
69
+ margin: var(--space-2) 0;
70
+ height: 1px;
71
+ border: none;
72
+ background-color: var(--color-neutral-200);
73
+ `;
74
+
75
+ export const QuickSearchResultDetailsTitle = styled.div.attrs({
76
+ className: 'QuickSearchResultDetailsTitle',
77
+ })`
78
+ margin: 0;
79
+ `;
80
+
81
+ export const QuickSearchResultsDetailsList = styled.dl.attrs({
82
+ className: 'QuickSearchResultsDetailsList',
83
+ })`
84
+ display: grid;
85
+ grid-template-columns: 1fr 3fr;
86
+ grid-gap: var(--space-2);
87
+ `;
88
+
89
+ export const QuickSearchResultsDetailsTerm = styled.dt.attrs({
90
+ className: 'QuickSearchResultsDetailsTerm',
91
+ })`
92
+ text-transform: uppercase;
93
+ font-size: var(--text-sm);
94
+ font-weight: bold;
95
+ color: var(--color-neutral-500);
96
+ `;
@@ -1,26 +1,26 @@
1
- import { FC, ReactNode } from 'react';
2
-
3
- export type SearchTypeDefinition<T> = {
4
- title: string;
5
- quickRenderer: (result: T, term: string) => ReactNode;
6
- titleRenderer: (result: T, term: string) => ReactNode;
7
- detailsRenderer: (result: T, term: string) => ReactNode;
8
- onClick?: (result: T) => void;
9
- };
10
-
11
- export type SearchTypeDefinitions<R> = {
12
- [K in keyof R]: SearchTypeDefinition<R[K]>;
13
- };
14
-
15
- export type SearchResults<R> = {
16
- [K in keyof R]: Array<R[K]>;
17
- };
18
-
19
- export type SearchDetailsFC<T> = FC<{
20
- searchResult: T;
21
- }>;
22
-
23
- export type ResultArray<R> = {
24
- result: R[keyof R];
25
- type: keyof R;
26
- }[];
1
+ import { FC, ReactNode } from 'react';
2
+
3
+ export type SearchTypeDefinition<T> = {
4
+ title: string;
5
+ quickRenderer: (result: T, term: string) => ReactNode;
6
+ titleRenderer: (result: T, term: string) => ReactNode;
7
+ detailsRenderer: (result: T, term: string) => ReactNode;
8
+ onClick?: (result: T) => void;
9
+ };
10
+
11
+ export type SearchTypeDefinitions<R> = {
12
+ [K in keyof R]: SearchTypeDefinition<R[K]>;
13
+ };
14
+
15
+ export type SearchResults<R> = {
16
+ [K in keyof R]: Array<R[K]>;
17
+ };
18
+
19
+ export type SearchDetailsFC<T> = FC<{
20
+ searchResult: T;
21
+ }>;
22
+
23
+ export type ResultArray<R> = {
24
+ result: R[keyof R];
25
+ type: keyof R;
26
+ }[];
@@ -1,54 +1,54 @@
1
- import * as styles from './styles';
2
-
3
- import { FC, PropsWithChildren, useMemo } from 'react';
4
-
5
- import { ThemeColorWithIntensity } from '../../../providers';
6
- import { sha256 } from 'hash.js';
7
-
8
- type AvatarProps = PropsWithChildren<
9
- {
10
- className?: string;
11
- name?: string;
12
- color?: ThemeColorWithIntensity;
13
- } & styles.AvatarContainerProps
14
- >;
15
-
16
- const getInitials = (name: string) => {
17
- const matches = name.matchAll(/(?:^|\s+)([A-Z0-9])/g);
18
- return Array.from(matches)
19
- .slice(0, 2)
20
- .map((m) => m[1])
21
- .join('');
22
- };
23
-
24
- export const Avatar: FC<AvatarProps> = ({
25
- children,
26
- className,
27
- color,
28
- name,
29
- size = 'md',
30
- }) => {
31
- const initials = useMemo(() => getInitials(name || ''), [name]);
32
- const backgroundColor = useMemo(() => {
33
- if (color) return `var(--color-${color})`;
34
- const h =
35
- parseInt(
36
- sha256()
37
- .update(name || '')
38
- .digest('hex')
39
- .substring(0, 4),
40
- 16
41
- ) % 360;
42
- return `hsl(${h}, 50%, 50%)`;
43
- }, [color, name]);
44
-
45
- return (
46
- <styles.AvatarContainer
47
- size={size}
48
- className={className}
49
- style={{ backgroundColor }}
50
- >
51
- {initials || children}
52
- </styles.AvatarContainer>
53
- );
54
- };
1
+ import * as styles from './styles';
2
+
3
+ import { FC, PropsWithChildren, useMemo } from 'react';
4
+
5
+ import { ThemeColorWithIntensity } from '../../../providers';
6
+ import { sha256 } from 'hash.js';
7
+
8
+ type AvatarProps = PropsWithChildren<
9
+ {
10
+ className?: string;
11
+ name?: string;
12
+ color?: ThemeColorWithIntensity;
13
+ } & styles.AvatarContainerProps
14
+ >;
15
+
16
+ const getInitials = (name: string) => {
17
+ const matches = name.matchAll(/(?:^|\s+)([A-Z0-9])/g);
18
+ return Array.from(matches)
19
+ .slice(0, 2)
20
+ .map((m) => m[1])
21
+ .join('');
22
+ };
23
+
24
+ export const Avatar: FC<AvatarProps> = ({
25
+ children,
26
+ className,
27
+ color,
28
+ name,
29
+ size = 'md',
30
+ }) => {
31
+ const initials = useMemo(() => getInitials(name || ''), [name]);
32
+ const backgroundColor = useMemo(() => {
33
+ if (color) return `var(--color-${color})`;
34
+ const h =
35
+ parseInt(
36
+ sha256()
37
+ .update(name || '')
38
+ .digest('hex')
39
+ .substring(0, 4),
40
+ 16
41
+ ) % 360;
42
+ return `hsl(${h}, 50%, 50%)`;
43
+ }, [color, name]);
44
+
45
+ return (
46
+ <styles.AvatarContainer
47
+ size={size}
48
+ className={className}
49
+ style={{ backgroundColor }}
50
+ >
51
+ {initials || children}
52
+ </styles.AvatarContainer>
53
+ );
54
+ };
@@ -1,14 +1,14 @@
1
- import { CardContainer, CardFooter, CardHeader } from './styles';
2
- import { FC, HTMLAttributes } from 'react';
3
-
4
- type CardFC = FC<HTMLAttributes<HTMLDivElement>> & {
5
- Header: typeof CardHeader;
6
- Footer: typeof CardFooter;
7
- };
8
-
9
- export const Card: CardFC = ({ children, ...props }) => {
10
- return <CardContainer {...props}>{children}</CardContainer>;
11
- };
12
-
13
- Card.Header = CardHeader;
14
- Card.Footer = CardFooter;
1
+ import { CardContainer, CardFooter, CardHeader } from './styles';
2
+ import { FC, HTMLAttributes } from 'react';
3
+
4
+ type CardFC = FC<HTMLAttributes<HTMLDivElement>> & {
5
+ Header: typeof CardHeader;
6
+ Footer: typeof CardFooter;
7
+ };
8
+
9
+ export const Card: CardFC = ({ children, ...props }) => {
10
+ return <CardContainer {...props}>{children}</CardContainer>;
11
+ };
12
+
13
+ Card.Header = CardHeader;
14
+ Card.Footer = CardFooter;
@@ -1,37 +1,37 @@
1
- import styled from 'styled-components';
2
-
3
- export const CardContainer = styled.div.attrs({
4
- className: 'CardContainer',
5
- })`
6
- display: flex;
7
- flex-direction: column;
8
- background-color: var(--color-neutral-0);
9
- border-radius: var(--rounded-md);
10
- box-shadow: var(--shadow-md);
11
- padding: var(--space-4);
12
- border: 1px solid var(--color-neutral-100);
13
- `;
14
-
15
- export const CardHeader = styled.div.attrs({
16
- className: 'CardHeader',
17
- })`
18
- display: flex;
19
- flex-direction: row;
20
- align-items: center;
21
- padding-bottom: var(--space-2);
22
- border-bottom: 1px solid var(--color-neutral-200);
23
- margin-bottom: var(--space-2);
24
- gap: var(--space-2);
25
- `;
26
-
27
- export const CardFooter = styled.div.attrs({
28
- className: 'CardFooter',
29
- })`
30
- display: flex;
31
- flex-direction: row;
32
- align-items: center;
33
- padding-top: var(--space-2);
34
- border-top: 1px solid var(--color-neutral-200);
35
- margin-top: var(--space-2);
36
- gap: var(--space-2);
37
- `;
1
+ import styled from 'styled-components';
2
+
3
+ export const CardContainer = styled.div.attrs({
4
+ className: 'CardContainer',
5
+ })`
6
+ display: flex;
7
+ flex-direction: column;
8
+ background-color: var(--color-neutral-0);
9
+ border-radius: var(--rounded-md);
10
+ box-shadow: var(--shadow-md);
11
+ padding: var(--space-4);
12
+ border: 1px solid var(--color-neutral-100);
13
+ `;
14
+
15
+ export const CardHeader = styled.div.attrs({
16
+ className: 'CardHeader',
17
+ })`
18
+ display: flex;
19
+ flex-direction: row;
20
+ align-items: center;
21
+ padding-bottom: var(--space-2);
22
+ border-bottom: 1px solid var(--color-neutral-200);
23
+ margin-bottom: var(--space-2);
24
+ gap: var(--space-2);
25
+ `;
26
+
27
+ export const CardFooter = styled.div.attrs({
28
+ className: 'CardFooter',
29
+ })`
30
+ display: flex;
31
+ flex-direction: row;
32
+ align-items: center;
33
+ padding-top: var(--space-2);
34
+ border-top: 1px solid var(--color-neutral-200);
35
+ margin-top: var(--space-2);
36
+ gap: var(--space-2);
37
+ `;
@@ -1,79 +1,79 @@
1
- import { Divider, MenuContainer, MenuItemContainer, SubMenu } from './styles';
2
- import {
3
- FC,
4
- HTMLAttributes,
5
- PropsWithChildren,
6
- useCallback,
7
- useRef,
8
- useState,
9
- } from 'react';
10
-
11
- type ContextMenuFC = FC<PropsWithChildren<HTMLAttributes<HTMLDivElement>>> & {
12
- Item: typeof MenuItemContainer;
13
- ParentItem: typeof ParentMenuItem;
14
- Divider: typeof Divider;
15
- SubMenu: typeof SubMenu;
16
- };
17
-
18
- export const ContextMenu: ContextMenuFC = ({ children }) => {
19
- return (
20
- <MenuContainer onClick={(e) => e.stopPropagation()}>
21
- {children}
22
- </MenuContainer>
23
- );
24
- };
25
-
26
- export const ParentMenuItem: FC<HTMLAttributes<HTMLDivElement>> = ({
27
- children,
28
- ...props
29
- }) => {
30
- const [isOpened, setIsOpened] = useState(false);
31
- const [isSubMenuLeft, setIsSubMenuLeft] = useState(false);
32
- const [currentTimeout, setCurrentTimeout] = useState<number | null>(null);
33
- const containerRef = useRef<HTMLDivElement | null>(null);
34
-
35
- const stopTimeout = useCallback(() => {
36
- if (currentTimeout) {
37
- clearTimeout(currentTimeout);
38
- }
39
- setCurrentTimeout(null);
40
- }, [currentTimeout]);
41
-
42
- const startTimeout = useCallback(
43
- (open: boolean) => {
44
- stopTimeout();
45
- setCurrentTimeout(
46
- window.setTimeout(
47
- () => {
48
- const rect = containerRef.current?.getBoundingClientRect();
49
- setIsSubMenuLeft(!!rect && rect.right + 280 > window.innerWidth);
50
- setIsOpened(open);
51
- },
52
- open ? 100 : 300
53
- )
54
- );
55
- },
56
- [stopTimeout]
57
- );
58
-
59
- const open = useCallback(() => startTimeout(true), [startTimeout]);
60
- const close = useCallback(() => startTimeout(false), [startTimeout]);
61
-
62
- return (
63
- <MenuItemContainer
64
- ref={containerRef}
65
- {...props}
66
- className={`${isOpened ? 'opened' : ''} ${isSubMenuLeft ? 'left' : ''}`}
67
- onMouseEnter={open}
68
- onMouseLeave={close}
69
- $withArrow
70
- >
71
- {children}
72
- </MenuItemContainer>
73
- );
74
- };
75
-
76
- ContextMenu.Item = MenuItemContainer;
77
- ContextMenu.ParentItem = ParentMenuItem;
78
- ContextMenu.Divider = Divider;
79
- ContextMenu.SubMenu = SubMenu;
1
+ import { Divider, MenuContainer, MenuItemContainer, SubMenu } from './styles';
2
+ import {
3
+ FC,
4
+ HTMLAttributes,
5
+ PropsWithChildren,
6
+ useCallback,
7
+ useRef,
8
+ useState,
9
+ } from 'react';
10
+
11
+ type ContextMenuFC = FC<PropsWithChildren<HTMLAttributes<HTMLDivElement>>> & {
12
+ Item: typeof MenuItemContainer;
13
+ ParentItem: typeof ParentMenuItem;
14
+ Divider: typeof Divider;
15
+ SubMenu: typeof SubMenu;
16
+ };
17
+
18
+ export const ContextMenu: ContextMenuFC = ({ children }) => {
19
+ return (
20
+ <MenuContainer onClick={(e) => e.stopPropagation()}>
21
+ {children}
22
+ </MenuContainer>
23
+ );
24
+ };
25
+
26
+ export const ParentMenuItem: FC<HTMLAttributes<HTMLDivElement>> = ({
27
+ children,
28
+ ...props
29
+ }) => {
30
+ const [isOpened, setIsOpened] = useState(false);
31
+ const [isSubMenuLeft, setIsSubMenuLeft] = useState(false);
32
+ const [currentTimeout, setCurrentTimeout] = useState<number | null>(null);
33
+ const containerRef = useRef<HTMLDivElement | null>(null);
34
+
35
+ const stopTimeout = useCallback(() => {
36
+ if (currentTimeout) {
37
+ clearTimeout(currentTimeout);
38
+ }
39
+ setCurrentTimeout(null);
40
+ }, [currentTimeout]);
41
+
42
+ const startTimeout = useCallback(
43
+ (open: boolean) => {
44
+ stopTimeout();
45
+ setCurrentTimeout(
46
+ window.setTimeout(
47
+ () => {
48
+ const rect = containerRef.current?.getBoundingClientRect();
49
+ setIsSubMenuLeft(!!rect && rect.right + 280 > window.innerWidth);
50
+ setIsOpened(open);
51
+ },
52
+ open ? 100 : 300
53
+ )
54
+ );
55
+ },
56
+ [stopTimeout]
57
+ );
58
+
59
+ const open = useCallback(() => startTimeout(true), [startTimeout]);
60
+ const close = useCallback(() => startTimeout(false), [startTimeout]);
61
+
62
+ return (
63
+ <MenuItemContainer
64
+ ref={containerRef}
65
+ {...props}
66
+ className={`${isOpened ? 'opened' : ''} ${isSubMenuLeft ? 'left' : ''}`}
67
+ onMouseEnter={open}
68
+ onMouseLeave={close}
69
+ $withArrow
70
+ >
71
+ {children}
72
+ </MenuItemContainer>
73
+ );
74
+ };
75
+
76
+ ContextMenu.Item = MenuItemContainer;
77
+ ContextMenu.ParentItem = ParentMenuItem;
78
+ ContextMenu.Divider = Divider;
79
+ ContextMenu.SubMenu = SubMenu;