@addev-be/ui 3.2.9 → 3.3.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 (265) 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/table.svg +1 -1
  21. package/assets/icons/up.svg +1 -1
  22. package/assets/icons/user-tie.svg +1 -1
  23. package/assets/icons/x-bar.svg +3 -3
  24. package/dist/components/auth/PasswordResetForm.js +7 -2
  25. package/dist/components/common/Accordion/Accordion.d.ts +14 -0
  26. package/dist/components/common/Accordion/Accordion.js +81 -0
  27. package/dist/components/common/Accordion/index.d.ts +2 -0
  28. package/dist/components/common/PropertiesList/PropertyInput.d.ts +7 -0
  29. package/dist/components/common/PropertiesList/PropertyInput.js +142 -0
  30. package/dist/components/common/PropertiesList/index.d.ts +8 -0
  31. package/dist/components/common/PropertiesList/index.js +28 -0
  32. package/dist/components/common/PropertiesList/types.d.ts +44 -0
  33. package/dist/components/common/TabsView/styles.js +10 -8
  34. package/dist/components/common/TreeView/TreeContext.d.ts +55 -0
  35. package/dist/components/common/TreeView/TreeContext.js +172 -0
  36. package/dist/components/common/TreeView/TreeView.d.ts +19 -0
  37. package/dist/components/common/TreeView/TreeView.js +202 -0
  38. package/dist/components/common/TreeView/index.d.ts +3 -0
  39. package/dist/components/common/index.d.ts +3 -0
  40. package/dist/components/common/index.js +25 -16
  41. package/dist/components/grid/DataGrid/DataGridCell.js +30 -29
  42. package/dist/components/grid/DataGrid/DataGridEditableCell/index.d.ts +1 -1
  43. package/dist/components/grid/DataGrid/DataGridEditableCell/index.js +37 -27
  44. package/dist/components/grid/DataGrid/DataGridRowTemplate.js +71 -56
  45. package/dist/components/layout/ContextMenu/ContextMenu.d.ts +42 -0
  46. package/dist/components/layout/ContextMenu/ContextMenu.js +252 -0
  47. package/dist/components/layout/ContextMenu/index.d.ts +2 -0
  48. package/dist/components/layout/LeftMenu/LeftMenu.d.ts +22 -0
  49. package/dist/components/layout/LeftMenu/LeftMenu.js +43 -0
  50. package/dist/components/layout/LeftMenu/index.d.ts +2 -0
  51. package/dist/components/layout/PanelContainer/PanelContainer.d.ts +16 -0
  52. package/dist/components/layout/PanelContainer/PanelContainer.js +121 -0
  53. package/dist/components/layout/PanelContainer/index.d.ts +2 -0
  54. package/dist/components/layout/index.d.ts +3 -0
  55. package/dist/components/layout/index.js +30 -15
  56. package/dist/helpers/cn.d.ts +2 -0
  57. package/dist/helpers/cn.js +8 -0
  58. package/dist/helpers/index.d.ts +1 -0
  59. package/dist/helpers/index.js +33 -31
  60. package/eslint.config.js +3 -3
  61. package/package.json +5 -3
  62. package/src/components/auth/LoginForm.tsx +92 -92
  63. package/src/components/auth/LoginPage.tsx +32 -32
  64. package/src/components/auth/PasswordRecoveryForm.tsx +53 -53
  65. package/src/components/auth/PasswordResetForm.tsx +114 -114
  66. package/src/components/auth/index.ts +4 -4
  67. package/src/components/auth/styles.ts +14 -14
  68. package/src/components/common/Accordion/Accordion.tsx +140 -0
  69. package/src/components/common/Accordion/index.ts +2 -0
  70. package/src/components/common/Avatar/index.tsx +54 -54
  71. package/src/components/common/Avatar/styles.ts +61 -61
  72. package/src/components/common/Card/index.tsx +17 -17
  73. package/src/components/common/Card/styles.ts +38 -38
  74. package/src/components/common/ContextMenu/index.tsx +79 -79
  75. package/src/components/common/ContextMenu/styles.ts +119 -119
  76. package/src/components/common/Ellipsis.tsx +33 -33
  77. package/src/components/common/Label.tsx +93 -93
  78. package/src/components/common/Message/index.tsx +57 -57
  79. package/src/components/common/Message/styles.ts +44 -44
  80. package/src/components/common/PropertiesList/PropertyInput.tsx +173 -0
  81. package/src/components/common/PropertiesList/index.tsx +48 -0
  82. package/src/components/common/PropertiesList/types.ts +60 -0
  83. package/src/components/common/TabsView/TabsList.tsx +49 -49
  84. package/src/components/common/TabsView/TabsView.tsx +42 -42
  85. package/src/components/common/TabsView/index.ts +3 -3
  86. package/src/components/common/TabsView/styles.ts +83 -83
  87. package/src/components/common/TabsView/types.ts +12 -12
  88. package/src/components/common/TreeView/TreeContext.tsx +379 -0
  89. package/src/components/common/TreeView/TreeView.tsx +281 -0
  90. package/src/components/common/TreeView/index.ts +3 -0
  91. package/src/components/common/index.ts +10 -7
  92. package/src/components/forms/AutoTextArea.tsx +48 -48
  93. package/src/components/forms/BillitIdentifier/index.tsx +78 -78
  94. package/src/components/forms/BillitIdentifier/styles.tsx +43 -43
  95. package/src/components/forms/Button.tsx +130 -130
  96. package/src/components/forms/Form/Checkbox.tsx +12 -12
  97. package/src/components/forms/Form/CustomSelect.tsx +86 -86
  98. package/src/components/forms/Form/FormGroup.tsx +33 -33
  99. package/src/components/forms/Form/Input.tsx +16 -16
  100. package/src/components/forms/Form/Row.tsx +28 -28
  101. package/src/components/forms/Form/Select.tsx +99 -99
  102. package/src/components/forms/Form/TextArea.tsx +17 -17
  103. package/src/components/forms/Form/index.tsx +48 -48
  104. package/src/components/forms/Form/styles.ts +148 -148
  105. package/src/components/forms/IconButton.tsx +61 -61
  106. package/src/components/forms/IndeterminateCheckbox.tsx +46 -46
  107. package/src/components/forms/NumberInput.tsx +53 -53
  108. package/src/components/forms/Select.tsx +34 -34
  109. package/src/components/forms/VerticalLabel.tsx +20 -20
  110. package/src/components/forms/index.ts +11 -11
  111. package/src/components/forms/styles.ts +42 -42
  112. package/src/components/grid/DataGrid/DataGridCell.tsx +82 -81
  113. package/src/components/grid/DataGrid/DataGridColumnsModal/helpers.ts +9 -9
  114. package/src/components/grid/DataGrid/DataGridColumnsModal/hooks.tsx +59 -59
  115. package/src/components/grid/DataGrid/DataGridColumnsModal/index.tsx +182 -182
  116. package/src/components/grid/DataGrid/DataGridColumnsModal/styles.ts +104 -104
  117. package/src/components/grid/DataGrid/DataGridEditableCell/CheckboxEditableCell.tsx +37 -37
  118. package/src/components/grid/DataGrid/DataGridEditableCell/DateEditableCell.tsx +38 -38
  119. package/src/components/grid/DataGrid/DataGridEditableCell/NumberEditableCell.tsx +71 -71
  120. package/src/components/grid/DataGrid/DataGridEditableCell/TextEditableCell.tsx +37 -37
  121. package/src/components/grid/DataGrid/DataGridEditableCell/index.tsx +112 -106
  122. package/src/components/grid/DataGrid/DataGridEditableCell/styles.ts +35 -35
  123. package/src/components/grid/DataGrid/DataGridEditableCell/types.ts +18 -18
  124. package/src/components/grid/DataGrid/DataGridFilterMenu/FilterValuesScroller.tsx +129 -129
  125. package/src/components/grid/DataGrid/DataGridFilterMenu/helpers.ts +23 -23
  126. package/src/components/grid/DataGrid/DataGridFilterMenu/hooks.tsx +81 -81
  127. package/src/components/grid/DataGrid/DataGridFilterMenu/index.tsx +370 -370
  128. package/src/components/grid/DataGrid/DataGridFilterMenu/styles.ts +97 -97
  129. package/src/components/grid/DataGrid/DataGridFooter.tsx +48 -48
  130. package/src/components/grid/DataGrid/DataGridHeader.tsx +74 -74
  131. package/src/components/grid/DataGrid/DataGridHeaderCell.tsx +112 -112
  132. package/src/components/grid/DataGrid/DataGridRowTemplate.tsx +90 -83
  133. package/src/components/grid/DataGrid/DataGridToolbar.tsx +134 -134
  134. package/src/components/grid/DataGrid/FilterModalContent/index.tsx +137 -137
  135. package/src/components/grid/DataGrid/FilterModalContent/styles.ts +22 -22
  136. package/src/components/grid/DataGrid/constants.ts +6 -6
  137. package/src/components/grid/DataGrid/helpers/columns.tsx +452 -452
  138. package/src/components/grid/DataGrid/helpers/filters.ts +287 -287
  139. package/src/components/grid/DataGrid/helpers/index.ts +2 -2
  140. package/src/components/grid/DataGrid/hooks/index.ts +29 -29
  141. package/src/components/grid/DataGrid/hooks/useDataGrid.tsx +383 -383
  142. package/src/components/grid/DataGrid/hooks/useDataGridChangedRows.ts +97 -97
  143. package/src/components/grid/DataGrid/hooks/useDataGridCopy.ts +174 -174
  144. package/src/components/grid/DataGrid/hooks/useDataGridSettings.ts +48 -48
  145. package/src/components/grid/DataGrid/hooks/useRefreshModal.tsx +48 -48
  146. package/src/components/grid/DataGrid/index.tsx +111 -111
  147. package/src/components/grid/DataGrid/styles.ts +446 -446
  148. package/src/components/grid/DataGrid/types.ts +380 -380
  149. package/src/components/grid/SqlRequestDataGrid/helpers/columns.tsx +526 -526
  150. package/src/components/grid/SqlRequestDataGrid/helpers/index.ts +2 -2
  151. package/src/components/grid/SqlRequestDataGrid/helpers/rows.ts +24 -24
  152. package/src/components/grid/SqlRequestDataGrid/helpers/sqlRequests.ts +17 -17
  153. package/src/components/grid/SqlRequestDataGrid/index.tsx +417 -417
  154. package/src/components/grid/SqlRequestDataGrid/styles.ts +15 -15
  155. package/src/components/grid/SqlRequestDataGrid/types.ts +74 -74
  156. package/src/components/grid/SqlRequestForeignList/index.tsx +254 -254
  157. package/src/components/grid/SqlRequestForeignList/styles.ts +43 -43
  158. package/src/components/grid/SqlRequestForeignList/types.ts +32 -32
  159. package/src/components/grid/SqlRequestGrid/filters/FiltersSidebar.tsx +108 -108
  160. package/src/components/grid/SqlRequestGrid/filters/styles.ts +88 -88
  161. package/src/components/grid/SqlRequestGrid/helpers/index.ts +1 -1
  162. package/src/components/grid/SqlRequestGrid/helpers/sqlRequests.ts +16 -16
  163. package/src/components/grid/SqlRequestGrid/index.tsx +304 -304
  164. package/src/components/grid/SqlRequestGrid/styles.ts +20 -20
  165. package/src/components/grid/SqlRequestGrid/types.ts +73 -73
  166. package/src/components/grid/VirtualScroller/hooks.ts +71 -71
  167. package/src/components/grid/VirtualScroller/index.tsx +89 -89
  168. package/src/components/grid/VirtualScroller/styles.ts +57 -57
  169. package/src/components/grid/VirtualScroller/types.ts +10 -10
  170. package/src/components/grid/index.ts +11 -11
  171. package/src/components/layout/Columns.ts +28 -28
  172. package/src/components/layout/ContextMenu/ContextMenu.tsx +471 -0
  173. package/src/components/layout/ContextMenu/index.ts +23 -0
  174. package/src/components/layout/Dropdown/index.tsx +113 -113
  175. package/src/components/layout/Dropdown/styles.ts +53 -53
  176. package/src/components/layout/Flexbox.ts +21 -21
  177. package/src/components/layout/Grid/index.tsx +8 -8
  178. package/src/components/layout/Grid/styles.ts +34 -34
  179. package/src/components/layout/LeftMenu/LeftMenu.tsx +89 -0
  180. package/src/components/layout/LeftMenu/index.ts +2 -0
  181. package/src/components/layout/Loading/index.tsx +29 -29
  182. package/src/components/layout/Loading/styles.ts +29 -29
  183. package/src/components/layout/Masonry/index.tsx +29 -29
  184. package/src/components/layout/Masonry/styles.ts +20 -20
  185. package/src/components/layout/Modal/index.tsx +51 -51
  186. package/src/components/layout/Modal/styles.ts +125 -125
  187. package/src/components/layout/PanelContainer/PanelContainer.tsx +198 -0
  188. package/src/components/layout/PanelContainer/index.ts +2 -0
  189. package/src/components/layout/index.ts +10 -7
  190. package/src/components/search/HighlightedText.tsx +41 -41
  191. package/src/components/search/QuickSearchBar.tsx +125 -125
  192. package/src/components/search/QuickSearchResults.tsx +90 -90
  193. package/src/components/search/index.ts +5 -5
  194. package/src/components/search/styles.ts +96 -96
  195. package/src/components/search/types.ts +29 -29
  196. package/src/config/index.ts +10 -10
  197. package/src/helpers/cn.ts +6 -0
  198. package/src/helpers/components.ts +9 -9
  199. package/src/helpers/dates.ts +17 -17
  200. package/src/helpers/getScrollbarSize.ts +14 -14
  201. package/src/helpers/index.ts +8 -7
  202. package/src/helpers/numbers.ts +63 -63
  203. package/src/helpers/responsive.ts +83 -83
  204. package/src/helpers/styled/size.ts +24 -24
  205. package/src/helpers/styled/space.ts +111 -111
  206. package/src/helpers/styled/typography.ts +25 -25
  207. package/src/helpers/text.ts +13 -13
  208. package/src/helpers/types.ts +9 -9
  209. package/src/hooks/index.ts +9 -9
  210. package/src/hooks/providers.ts +14 -14
  211. package/src/hooks/useContainerMediaQuery.ts +7 -7
  212. package/src/hooks/useElementSize.ts +24 -24
  213. package/src/hooks/useMediaQuery.ts +9 -9
  214. package/src/hooks/useMediaQueryForWidth.ts +35 -35
  215. package/src/hooks/useMutableState.test.ts +410 -410
  216. package/src/hooks/useMutableState.ts +39 -39
  217. package/src/hooks/useShowArchived.ts +28 -28
  218. package/src/hooks/useWindowSize.ts +20 -20
  219. package/src/icons/index.tsx +138 -138
  220. package/src/providers/AuthenticationProvider/helpers.ts +3 -3
  221. package/src/providers/AuthenticationProvider/index.tsx +303 -303
  222. package/src/providers/LoadingProvider/index.tsx +47 -47
  223. package/src/providers/PortalsProvider/index.tsx +54 -54
  224. package/src/providers/PortalsProvider/styles.ts +31 -31
  225. package/src/providers/SettingsProvider/index.tsx +70 -70
  226. package/src/providers/ToastProvider/index.tsx +93 -93
  227. package/src/providers/TrackingProvider/hooks.ts +14 -14
  228. package/src/providers/TrackingProvider/index.tsx +71 -71
  229. package/src/providers/UiProviders/index.tsx +74 -74
  230. package/src/providers/UiProviders/styles.ts +10 -10
  231. package/src/providers/index.ts +6 -6
  232. package/src/services/HttpService.ts +92 -92
  233. package/src/services/WebSocketService.ts +155 -155
  234. package/src/services/advancedRequests.ts +102 -102
  235. package/src/services/base.ts +23 -23
  236. package/src/services/globalSearch.ts +32 -32
  237. package/src/services/hooks.ts +92 -92
  238. package/src/services/index.ts +20 -20
  239. package/src/services/requests/auth.ts +44 -44
  240. package/src/services/requests/generic.ts +76 -76
  241. package/src/services/requests/printing.ts +12 -12
  242. package/src/services/requests/tracking.ts +12 -12
  243. package/src/services/requests/userProfiles.ts +35 -35
  244. package/src/services/requests/users.ts +28 -28
  245. package/src/services/smartQueries.ts +122 -122
  246. package/src/services/sqlRequests.ts +119 -119
  247. package/src/services/types/auth.ts +98 -98
  248. package/src/services/types/base.ts +10 -10
  249. package/src/services/types/generic.ts +102 -102
  250. package/src/services/types/printing.ts +10 -10
  251. package/src/services/types/tracking.ts +29 -29
  252. package/src/services/types/userProfiles.ts +79 -79
  253. package/src/services/types/users.ts +74 -74
  254. package/src/services/updateSqlRequests.ts +32 -32
  255. package/src/styles/animations.scss +30 -30
  256. package/src/styles/index.scss +42 -42
  257. package/src/theme/ThemeProvider.ts +73 -73
  258. package/src/theme/defaultTheme.ts +471 -471
  259. package/src/theme/helpers.ts +89 -89
  260. package/src/theme/index.ts +4 -4
  261. package/src/theme/types.ts +139 -139
  262. package/src/types/index.ts +8 -8
  263. package/src/typings.d.ts +2 -2
  264. package/tsconfig.json +41 -41
  265. package/tsconfig.tsbuildinfo +0 -1
@@ -1,113 +1,113 @@
1
- import * as styles from './styles';
2
-
3
- import {
4
- CSSProperties,
5
- FC,
6
- PropsWithChildren,
7
- useCallback,
8
- useEffect,
9
- useMemo,
10
- useRef,
11
- } from 'react';
12
-
13
- import { usePortals } from '@hooks';
14
-
15
- type DropdownProps = PropsWithChildren<
16
- styles.DropdownContainerProps & {
17
- $sourceRect: DOMRect;
18
- $autoPositionX?: boolean;
19
- $autoPositionY?: boolean;
20
- onClose?: () => void;
21
- usePortal?: boolean;
22
- style?: CSSProperties;
23
- }
24
- >;
25
-
26
- const getDropdownStyle = (dropdown: DropdownProps): CSSProperties => {
27
- const minHeight = Array.isArray(dropdown.$height)
28
- ? dropdown.$height[0]
29
- : dropdown.$height;
30
- const maxHeight = Array.isArray(dropdown.$height)
31
- ? dropdown.$height[1]
32
- : dropdown.$height;
33
- const bottomSpace = document.body.scrollHeight - dropdown.$sourceRect.bottom;
34
- const topSpace = dropdown.$sourceRect.top;
35
- const isDropdownBelow =
36
- !dropdown.$autoPositionY ||
37
- bottomSpace > topSpace ||
38
- bottomSpace >= minHeight;
39
- const height = Math.max(
40
- Math.min(maxHeight, isDropdownBelow ? bottomSpace : topSpace),
41
- minHeight
42
- );
43
-
44
- const rightSpace = document.body.scrollWidth - dropdown.$sourceRect.right;
45
- const leftSpace = dropdown.$sourceRect.left;
46
- const isDropdownRight =
47
- !dropdown.$autoPositionX ||
48
- rightSpace > leftSpace ||
49
- rightSpace >= dropdown.$width;
50
-
51
- const dropdownStyle: CSSProperties = {
52
- ...(isDropdownBelow
53
- ? { top: topSpace + dropdown.$sourceRect.height }
54
- : { bottom: bottomSpace + dropdown.$sourceRect.height }),
55
- ...(isDropdownRight ? { left: leftSpace } : { right: rightSpace }),
56
- width: dropdown.$width,
57
- height,
58
- minHeight,
59
- maxHeight,
60
- boxSizing: 'border-box',
61
- ...dropdown.style,
62
- };
63
- return dropdownStyle;
64
- };
65
-
66
- export const Dropdown: FC<DropdownProps> = ({
67
- children,
68
- onClose,
69
- usePortal = true,
70
- ...props
71
- }) => {
72
- const { createPortal } = usePortals();
73
-
74
- const firstClick = useRef(true);
75
- const containerRef = useRef<HTMLDivElement | null>(null);
76
- const style = useMemo(() => getDropdownStyle(props), [props]);
77
-
78
- const onDocumentClick = useCallback(
79
- (ev: MouseEvent) => {
80
- if (firstClick.current) {
81
- firstClick.current = false;
82
- return;
83
- }
84
- if (
85
- containerRef.current &&
86
- !containerRef.current.contains(ev.target as Node)
87
- ) {
88
- return onClose?.();
89
- }
90
- },
91
- [onClose]
92
- );
93
-
94
- useEffect(() => {
95
- if (containerRef.current) {
96
- document.addEventListener('click', onDocumentClick);
97
- return () => {
98
- document.removeEventListener('click', onDocumentClick);
99
- };
100
- }
101
- }, [onDocumentClick]);
102
-
103
- const modalPortal = useMemo(() => {
104
- const content = (
105
- <styles.DropdownContainer ref={containerRef} {...props} style={style}>
106
- {children}
107
- </styles.DropdownContainer>
108
- );
109
- return usePortal ? createPortal(content) : content;
110
- }, [children, createPortal, props, style, usePortal]);
111
-
112
- return <>{modalPortal}</>;
113
- };
1
+ import * as styles from './styles';
2
+
3
+ import {
4
+ CSSProperties,
5
+ FC,
6
+ PropsWithChildren,
7
+ useCallback,
8
+ useEffect,
9
+ useMemo,
10
+ useRef,
11
+ } from 'react';
12
+
13
+ import { usePortals } from '@hooks';
14
+
15
+ type DropdownProps = PropsWithChildren<
16
+ styles.DropdownContainerProps & {
17
+ $sourceRect: DOMRect;
18
+ $autoPositionX?: boolean;
19
+ $autoPositionY?: boolean;
20
+ onClose?: () => void;
21
+ usePortal?: boolean;
22
+ style?: CSSProperties;
23
+ }
24
+ >;
25
+
26
+ const getDropdownStyle = (dropdown: DropdownProps): CSSProperties => {
27
+ const minHeight = Array.isArray(dropdown.$height)
28
+ ? dropdown.$height[0]
29
+ : dropdown.$height;
30
+ const maxHeight = Array.isArray(dropdown.$height)
31
+ ? dropdown.$height[1]
32
+ : dropdown.$height;
33
+ const bottomSpace = document.body.scrollHeight - dropdown.$sourceRect.bottom;
34
+ const topSpace = dropdown.$sourceRect.top;
35
+ const isDropdownBelow =
36
+ !dropdown.$autoPositionY ||
37
+ bottomSpace > topSpace ||
38
+ bottomSpace >= minHeight;
39
+ const height = Math.max(
40
+ Math.min(maxHeight, isDropdownBelow ? bottomSpace : topSpace),
41
+ minHeight
42
+ );
43
+
44
+ const rightSpace = document.body.scrollWidth - dropdown.$sourceRect.right;
45
+ const leftSpace = dropdown.$sourceRect.left;
46
+ const isDropdownRight =
47
+ !dropdown.$autoPositionX ||
48
+ rightSpace > leftSpace ||
49
+ rightSpace >= dropdown.$width;
50
+
51
+ const dropdownStyle: CSSProperties = {
52
+ ...(isDropdownBelow
53
+ ? { top: topSpace + dropdown.$sourceRect.height }
54
+ : { bottom: bottomSpace + dropdown.$sourceRect.height }),
55
+ ...(isDropdownRight ? { left: leftSpace } : { right: rightSpace }),
56
+ width: dropdown.$width,
57
+ height,
58
+ minHeight,
59
+ maxHeight,
60
+ boxSizing: 'border-box',
61
+ ...dropdown.style,
62
+ };
63
+ return dropdownStyle;
64
+ };
65
+
66
+ export const Dropdown: FC<DropdownProps> = ({
67
+ children,
68
+ onClose,
69
+ usePortal = true,
70
+ ...props
71
+ }) => {
72
+ const { createPortal } = usePortals();
73
+
74
+ const firstClick = useRef(true);
75
+ const containerRef = useRef<HTMLDivElement | null>(null);
76
+ const style = useMemo(() => getDropdownStyle(props), [props]);
77
+
78
+ const onDocumentClick = useCallback(
79
+ (ev: MouseEvent) => {
80
+ if (firstClick.current) {
81
+ firstClick.current = false;
82
+ return;
83
+ }
84
+ if (
85
+ containerRef.current &&
86
+ !containerRef.current.contains(ev.target as Node)
87
+ ) {
88
+ return onClose?.();
89
+ }
90
+ },
91
+ [onClose]
92
+ );
93
+
94
+ useEffect(() => {
95
+ if (containerRef.current) {
96
+ document.addEventListener('click', onDocumentClick);
97
+ return () => {
98
+ document.removeEventListener('click', onDocumentClick);
99
+ };
100
+ }
101
+ }, [onDocumentClick]);
102
+
103
+ const modalPortal = useMemo(() => {
104
+ const content = (
105
+ <styles.DropdownContainer ref={containerRef} {...props} style={style}>
106
+ {children}
107
+ </styles.DropdownContainer>
108
+ );
109
+ return usePortal ? createPortal(content) : content;
110
+ }, [children, createPortal, props, style, usePortal]);
111
+
112
+ return <>{modalPortal}</>;
113
+ };
@@ -1,53 +1,53 @@
1
- import styled, { css } from 'styled-components';
2
-
3
- export const DropdownBackdrop = styled.div.attrs<{ $alpha?: number }>({
4
- className: 'DropdownBackdrop',
5
- })`
6
- position: absolute;
7
- z-index: 1000;
8
- top: 0;
9
- left: 0;
10
- right: 0;
11
- bottom: 0;
12
- background: rgba(0, 0, 0, ${({ $alpha = 0.5 }) => $alpha});
13
- display: flex;
14
- justify-content: center;
15
- align-items: center;
16
- `;
17
-
18
- export type DropdownContainerProps = {
19
- $width: number;
20
- $height: number | number[];
21
- $zIndex?: number;
22
- $backdropAlpha?: number;
23
- $withBackground?: boolean;
24
- };
25
-
26
- export const DropdownContainer = styled.div.attrs({
27
- className: 'DropdownContainer',
28
- })<DropdownContainerProps>`
29
- background: var(--color-base-0);
30
- border-radius: var(--rounded-md);
31
- box-shadow: var(--shadow-lg);
32
- outline: 1px solid var(--color-base-200);
33
-
34
- position: absolute;
35
- z-index: 1001;
36
- ${({ $width }) => ($width ? `${$width}px` : 'auto')};
37
- ${({ $height }) =>
38
- Array.isArray($height)
39
- ? css`
40
- min-height: ${$height[0]}px;
41
- max-height: ${$height[1]}px;
42
- `
43
- : css`
44
- height: ${$height ? `${$height}px` : 'auto'};
45
- `}
46
- ${({ $withBackground }) =>
47
- $withBackground &&
48
- css`
49
- background: none;
50
- box-shadow: none;
51
- outline: none;
52
- `}
53
- `;
1
+ import styled, { css } from 'styled-components';
2
+
3
+ export const DropdownBackdrop = styled.div.attrs<{ $alpha?: number }>({
4
+ className: 'DropdownBackdrop',
5
+ })`
6
+ position: absolute;
7
+ z-index: 1000;
8
+ top: 0;
9
+ left: 0;
10
+ right: 0;
11
+ bottom: 0;
12
+ background: rgba(0, 0, 0, ${({ $alpha = 0.5 }) => $alpha});
13
+ display: flex;
14
+ justify-content: center;
15
+ align-items: center;
16
+ `;
17
+
18
+ export type DropdownContainerProps = {
19
+ $width: number;
20
+ $height: number | number[];
21
+ $zIndex?: number;
22
+ $backdropAlpha?: number;
23
+ $withBackground?: boolean;
24
+ };
25
+
26
+ export const DropdownContainer = styled.div.attrs({
27
+ className: 'DropdownContainer',
28
+ })<DropdownContainerProps>`
29
+ background: var(--color-base-0);
30
+ border-radius: var(--rounded-md);
31
+ box-shadow: var(--shadow-lg);
32
+ outline: 1px solid var(--color-base-200);
33
+
34
+ position: absolute;
35
+ z-index: 1001;
36
+ ${({ $width }) => ($width ? `${$width}px` : 'auto')};
37
+ ${({ $height }) =>
38
+ Array.isArray($height)
39
+ ? css`
40
+ min-height: ${$height[0]}px;
41
+ max-height: ${$height[1]}px;
42
+ `
43
+ : css`
44
+ height: ${$height ? `${$height}px` : 'auto'};
45
+ `}
46
+ ${({ $withBackground }) =>
47
+ $withBackground &&
48
+ css`
49
+ background: none;
50
+ box-shadow: none;
51
+ outline: none;
52
+ `}
53
+ `;
@@ -1,21 +1,21 @@
1
- import { SpaceProps, space } from '../../helpers/styled/space';
2
-
3
- import { CSSProperties } from 'react';
4
- import { ThemeSpace } from '@theme';
5
- import styled from 'styled-components';
6
-
7
- type FlexboxProps = {
8
- direction?: CSSProperties['flexDirection'];
9
- justifyContent?: CSSProperties['justifyContent'];
10
- alignItems?: CSSProperties['alignItems'];
11
- gap?: ThemeSpace;
12
- } & SpaceProps;
13
-
14
- export const Flexbox = styled.div<FlexboxProps>`
15
- display: flex;
16
- flex-direction: ${({ direction }) => direction};
17
- justify-content: ${({ justifyContent }) => justifyContent};
18
- align-items: ${({ alignItems }) => alignItems};
19
- gap: ${({ gap }) => (gap ? `var(--s-${gap})` : undefined)};
20
- ${space}
21
- `;
1
+ import { SpaceProps, space } from '../../helpers/styled/space';
2
+
3
+ import { CSSProperties } from 'react';
4
+ import { ThemeSpace } from '@theme';
5
+ import styled from 'styled-components';
6
+
7
+ type FlexboxProps = {
8
+ direction?: CSSProperties['flexDirection'];
9
+ justifyContent?: CSSProperties['justifyContent'];
10
+ alignItems?: CSSProperties['alignItems'];
11
+ gap?: ThemeSpace;
12
+ } & SpaceProps;
13
+
14
+ export const Flexbox = styled.div<FlexboxProps>`
15
+ display: flex;
16
+ flex-direction: ${({ direction }) => direction};
17
+ justify-content: ${({ justifyContent }) => justifyContent};
18
+ align-items: ${({ alignItems }) => alignItems};
19
+ gap: ${({ gap }) => (gap ? `var(--s-${gap})` : undefined)};
20
+ ${space}
21
+ `;
@@ -1,8 +1,8 @@
1
- import { GridContainer, GridItemContainer } from './styles';
2
-
3
- type GridFC = typeof GridContainer & {
4
- Item: typeof GridItemContainer;
5
- };
6
-
7
- export const Grid = GridContainer as GridFC;
8
- Grid.Item = GridItemContainer;
1
+ import { GridContainer, GridItemContainer } from './styles';
2
+
3
+ type GridFC = typeof GridContainer & {
4
+ Item: typeof GridItemContainer;
5
+ };
6
+
7
+ export const Grid = GridContainer as GridFC;
8
+ Grid.Item = GridItemContainer;
@@ -1,34 +1,34 @@
1
- import styled from 'styled-components';
2
-
3
- type GridProps = {
4
- columns?: number;
5
- };
6
-
7
- export const GridContainer = styled.div<GridProps>`
8
- display: grid;
9
- grid-template-columns: repeat(
10
- ${({ columns = 12 }) => columns},
11
- minmax(0, 1fr)
12
- );
13
- grid-template-rows: masonry;
14
- `;
15
-
16
- type GridItemProps = {
17
- row?: number;
18
- col?: number;
19
- rowSpan?: number;
20
- colSpan?: number;
21
- };
22
-
23
- export const GridItemContainer = styled.div.attrs<GridItemProps>(
24
- ({ col, colSpan, row, rowSpan }) => ({
25
- style: {
26
- gridColumn: [col, !!colSpan && `span ${colSpan}`]
27
- .filter(Boolean)
28
- .join(' / '),
29
- gridRow: [row, !!rowSpan && `span ${rowSpan}`]
30
- .filter(Boolean)
31
- .join(' / '),
32
- },
33
- })
34
- )``;
1
+ import styled from 'styled-components';
2
+
3
+ type GridProps = {
4
+ columns?: number;
5
+ };
6
+
7
+ export const GridContainer = styled.div<GridProps>`
8
+ display: grid;
9
+ grid-template-columns: repeat(
10
+ ${({ columns = 12 }) => columns},
11
+ minmax(0, 1fr)
12
+ );
13
+ grid-template-rows: masonry;
14
+ `;
15
+
16
+ type GridItemProps = {
17
+ row?: number;
18
+ col?: number;
19
+ rowSpan?: number;
20
+ colSpan?: number;
21
+ };
22
+
23
+ export const GridItemContainer = styled.div.attrs<GridItemProps>(
24
+ ({ col, colSpan, row, rowSpan }) => ({
25
+ style: {
26
+ gridColumn: [col, !!colSpan && `span ${colSpan}`]
27
+ .filter(Boolean)
28
+ .join(' / '),
29
+ gridRow: [row, !!rowSpan && `span ${rowSpan}`]
30
+ .filter(Boolean)
31
+ .join(' / '),
32
+ },
33
+ })
34
+ )``;
@@ -0,0 +1,89 @@
1
+ import { IconFC } from '../../../icons';
2
+ import { cn } from '@helpers/cn';
3
+
4
+ export interface LeftMenuItem {
5
+ id: string;
6
+ label: string;
7
+ icon?: IconFC;
8
+ onClick?: () => void;
9
+ }
10
+
11
+ export interface LeftMenuGroup {
12
+ title?: string;
13
+ items: LeftMenuItem[];
14
+ }
15
+
16
+ export interface LeftMenuProps {
17
+ header?: {
18
+ title: string;
19
+ subtitle?: string;
20
+ };
21
+ groups: LeftMenuGroup[];
22
+ activeItemId?: string;
23
+ onItemClick?: (itemId: string) => void;
24
+ className?: string;
25
+ }
26
+
27
+ export function LeftMenu({
28
+ header,
29
+ groups,
30
+ activeItemId,
31
+ onItemClick,
32
+ className,
33
+ }: LeftMenuProps) {
34
+ const handleItemClick = (item: LeftMenuItem) => {
35
+ if (item.onClick) {
36
+ item.onClick();
37
+ }
38
+ if (onItemClick) {
39
+ onItemClick(item.id);
40
+ }
41
+ };
42
+
43
+ return (
44
+ <aside className={cn('h-full w-full bg-card flex flex-col', className)}>
45
+ {header && (
46
+ <div className="p-6 border-b border-border">
47
+ <h1 className="text-xl font-bold text-foreground">{header.title}</h1>
48
+ {header.subtitle && (
49
+ <p className="text-sm text-muted-foreground mt-1">
50
+ {header.subtitle}
51
+ </p>
52
+ )}
53
+ </div>
54
+ )}
55
+
56
+ <nav className="flex-1 overflow-y-auto p-4">
57
+ {groups.map((group, groupIndex) => (
58
+ <div key={groupIndex} className={cn(groupIndex > 0 && 'mt-6')}>
59
+ {group.title && (
60
+ <h3 className="px-4 text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2">
61
+ {group.title}
62
+ </h3>
63
+ )}
64
+ <div className="space-y-1">
65
+ {group.items.map((item) => {
66
+ const Icon = item.icon;
67
+ return (
68
+ <button
69
+ key={item.id}
70
+ onClick={() => handleItemClick(item)}
71
+ className={cn(
72
+ 'w-full flex items-center gap-3 px-4 py-2.5 rounded-lg text-sm font-medium transition-colors',
73
+ activeItemId === item.id
74
+ ? 'bg-primary text-primary-foreground'
75
+ : 'text-foreground hover:bg-accent hover:text-accent-foreground'
76
+ )}
77
+ >
78
+ {Icon && <Icon className="w-4 h-4" />}
79
+ {item.label}
80
+ </button>
81
+ );
82
+ })}
83
+ </div>
84
+ </div>
85
+ ))}
86
+ </nav>
87
+ </aside>
88
+ );
89
+ }
@@ -0,0 +1,2 @@
1
+ export { LeftMenu } from './LeftMenu';
2
+ export type { LeftMenuProps, LeftMenuItem, LeftMenuGroup } from './LeftMenu';
@@ -1,29 +1,29 @@
1
- import * as styles from './styles';
2
-
3
- import { FC, PropsWithChildren, useMemo } from 'react';
4
-
5
- import { LoadingIcon } from '@icons';
6
- import { usePortals } from '@hooks';
7
-
8
- type LoadingProps = PropsWithChildren<{
9
- visible?: boolean;
10
- }>;
11
-
12
- export const Loading: FC<LoadingProps> = ({ visible, children }) => {
13
- const { createPortal } = usePortals();
14
- const loadingPortal = useMemo(
15
- () =>
16
- visible
17
- ? createPortal(
18
- <styles.LoadingBackdrop>
19
- <LoadingIcon />
20
- <styles.LoadingContainer>
21
- {children || 'Loading ...'}
22
- </styles.LoadingContainer>
23
- </styles.LoadingBackdrop>
24
- )
25
- : null,
26
- [children, createPortal, visible]
27
- );
28
- return <>{loadingPortal}</>;
29
- };
1
+ import * as styles from './styles';
2
+
3
+ import { FC, PropsWithChildren, useMemo } from 'react';
4
+
5
+ import { LoadingIcon } from '@icons';
6
+ import { usePortals } from '@hooks';
7
+
8
+ type LoadingProps = PropsWithChildren<{
9
+ visible?: boolean;
10
+ }>;
11
+
12
+ export const Loading: FC<LoadingProps> = ({ visible, children }) => {
13
+ const { createPortal } = usePortals();
14
+ const loadingPortal = useMemo(
15
+ () =>
16
+ visible
17
+ ? createPortal(
18
+ <styles.LoadingBackdrop>
19
+ <LoadingIcon />
20
+ <styles.LoadingContainer>
21
+ {children || 'Loading ...'}
22
+ </styles.LoadingContainer>
23
+ </styles.LoadingBackdrop>
24
+ )
25
+ : null,
26
+ [children, createPortal, visible]
27
+ );
28
+ return <>{loadingPortal}</>;
29
+ };
@@ -1,29 +1,29 @@
1
- import styled from 'styled-components';
2
-
3
- export const LoadingContainer = styled.div.attrs({
4
- className: 'LoadingContent',
5
- })`
6
- padding: var(--space-4);
7
- `;
8
-
9
- export const LoadingBackdrop = styled.div.attrs({
10
- className: 'LoadingBackdrop',
11
- })`
12
- position: fixed;
13
- z-index: 1100;
14
- top: 0;
15
- left: 0;
16
- right: 0;
17
- bottom: 0;
18
- background-color: rgba(0, 0, 0, 0.5);
19
- display: flex;
20
- flex-direction: column;
21
- justify-content: center;
22
- align-items: center;
23
- color: var(--color-gray-50);
24
- fill: var(--color-gray-50);
25
- & > svg {
26
- width: var(--space-8);
27
- height: var(--space-8);
28
- }
29
- `;
1
+ import styled from 'styled-components';
2
+
3
+ export const LoadingContainer = styled.div.attrs({
4
+ className: 'LoadingContent',
5
+ })`
6
+ padding: var(--space-4);
7
+ `;
8
+
9
+ export const LoadingBackdrop = styled.div.attrs({
10
+ className: 'LoadingBackdrop',
11
+ })`
12
+ position: fixed;
13
+ z-index: 1100;
14
+ top: 0;
15
+ left: 0;
16
+ right: 0;
17
+ bottom: 0;
18
+ background-color: rgba(0, 0, 0, 0.5);
19
+ display: flex;
20
+ flex-direction: column;
21
+ justify-content: center;
22
+ align-items: center;
23
+ color: var(--color-gray-50);
24
+ fill: var(--color-gray-50);
25
+ & > svg {
26
+ width: var(--space-8);
27
+ height: var(--space-8);
28
+ }
29
+ `;