@addev-be/ui 0.2.16 → 0.2.19

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 (236) hide show
  1. package/eslint.config.js +28 -0
  2. package/package.json +13 -20
  3. package/{dist/Icons.d.ts → src/Icons.tsx} +69 -6
  4. package/src/components/data/AdvancedRequestDataGrid/helpers/advancedRequests.ts +93 -0
  5. package/src/components/data/AdvancedRequestDataGrid/helpers/columns.tsx +262 -0
  6. package/src/components/data/AdvancedRequestDataGrid/index.tsx +267 -0
  7. package/src/components/data/AdvancedRequestDataGrid/types.ts +47 -0
  8. package/src/components/data/DataGrid/DataGridCell.tsx +73 -0
  9. package/src/components/data/DataGrid/DataGridColumnsModal/helpers.ts +14 -0
  10. package/src/components/data/DataGrid/DataGridColumnsModal/hooks.tsx +59 -0
  11. package/src/components/data/DataGrid/DataGridColumnsModal/index.tsx +181 -0
  12. package/src/components/data/DataGrid/DataGridColumnsModal/styles.ts +104 -0
  13. package/src/components/data/DataGrid/DataGridEditableCell.tsx +43 -0
  14. package/src/components/data/DataGrid/DataGridFilterMenu/FilterValuesScroller.tsx +120 -0
  15. package/src/components/data/DataGrid/DataGridFilterMenu/hooks.tsx +75 -0
  16. package/src/components/data/DataGrid/DataGridFilterMenu/index.tsx +360 -0
  17. package/src/components/data/DataGrid/DataGridFilterMenu/styles.ts +96 -0
  18. package/src/components/data/DataGrid/DataGridFooter.tsx +42 -0
  19. package/src/components/data/DataGrid/DataGridHeader.tsx +126 -0
  20. package/src/components/data/DataGrid/DataGridHeaderCell.tsx +132 -0
  21. package/src/components/data/DataGrid/FilterModalContent/index.tsx +136 -0
  22. package/src/components/data/DataGrid/FilterModalContent/styles.ts +22 -0
  23. package/src/components/data/DataGrid/VirtualScroller.tsx +46 -0
  24. package/src/components/data/DataGrid/helpers/columns.tsx +295 -0
  25. package/src/components/data/DataGrid/helpers/filters.ts +287 -0
  26. package/src/components/data/DataGrid/hooks/index.ts +30 -0
  27. package/src/components/data/DataGrid/hooks/useDataGrid.tsx +306 -0
  28. package/src/components/data/DataGrid/hooks/useDataGridCopy.ts +175 -0
  29. package/src/components/data/DataGrid/hooks/useDataGridSettings.ts +48 -0
  30. package/src/components/data/DataGrid/index.tsx +140 -0
  31. package/src/components/data/DataGrid/styles.ts +323 -0
  32. package/src/components/data/DataGrid/types.ts +267 -0
  33. package/src/components/data/SqlRequestDataGrid/helpers/columns.tsx +277 -0
  34. package/src/components/data/SqlRequestDataGrid/helpers/sqlRequests.ts +16 -0
  35. package/src/components/data/SqlRequestDataGrid/index.tsx +347 -0
  36. package/src/components/data/SqlRequestDataGrid/types.ts +47 -0
  37. package/src/components/forms/Button.tsx +99 -0
  38. package/src/components/forms/IconButton.tsx +56 -0
  39. package/src/components/forms/IndeterminateCheckbox.tsx +46 -0
  40. package/src/components/forms/Select.tsx +40 -0
  41. package/src/components/forms/styles.ts +20 -0
  42. package/src/components/layout/Dropdown/index.tsx +79 -0
  43. package/src/components/layout/Dropdown/styles.ts +44 -0
  44. package/src/components/layout/Loading/index.tsx +29 -0
  45. package/src/components/layout/Loading/styles.ts +29 -0
  46. package/src/components/layout/Modal/index.tsx +51 -0
  47. package/src/components/layout/Modal/styles.ts +110 -0
  48. package/src/components/ui/ContextMenu/index.tsx +79 -0
  49. package/src/components/ui/ContextMenu/styles.ts +119 -0
  50. package/src/config/index.ts +14 -0
  51. package/src/helpers/dates.ts +9 -0
  52. package/src/helpers/getScrollbarSize.ts +14 -0
  53. package/src/helpers/numbers.ts +26 -0
  54. package/src/hooks/useElementSize.ts +24 -0
  55. package/src/hooks/useWindowSize.ts +20 -0
  56. package/{dist/index.d.ts → src/index.ts} +2 -0
  57. package/src/providers/PortalsProvider/index.tsx +54 -0
  58. package/src/providers/PortalsProvider/styles.ts +27 -0
  59. package/src/providers/SettingsProvider/index.tsx +70 -0
  60. package/src/providers/ThemeProvider/ThemeProvider.ts +55 -0
  61. package/src/providers/ThemeProvider/defaultTheme.ts +444 -0
  62. package/{dist/providers/ThemeProvider/index.d.ts → src/providers/ThemeProvider/index.ts} +1 -0
  63. package/src/providers/ThemeProvider/types.ts +123 -0
  64. package/src/providers/UiProviders/index.tsx +65 -0
  65. package/src/providers/UiProviders/styles.ts +10 -0
  66. package/src/providers/hooks.ts +8 -0
  67. package/{dist/providers/index.d.ts → src/providers/index.ts} +1 -0
  68. package/src/services/HttpService.ts +80 -0
  69. package/src/services/WebSocketService.ts +147 -0
  70. package/src/services/advancedRequests.ts +101 -0
  71. package/src/services/base.ts +31 -0
  72. package/src/services/globalSearch.ts +27 -0
  73. package/src/services/hooks.ts +23 -0
  74. package/src/services/sqlRequests.ts +110 -0
  75. package/src/styles/animations.scss +30 -0
  76. package/src/styles/index.scss +42 -0
  77. package/src/typings.d.ts +6 -0
  78. package/tsconfig.json +18 -0
  79. package/dist/Icons.js +0 -120
  80. package/dist/components/data/AdvancedRequestDataGrid/helpers/advancedRequests.d.ts +0 -14
  81. package/dist/components/data/AdvancedRequestDataGrid/helpers/advancedRequests.js +0 -76
  82. package/dist/components/data/AdvancedRequestDataGrid/helpers/columns.d.ts +0 -22
  83. package/dist/components/data/AdvancedRequestDataGrid/helpers/columns.js +0 -156
  84. package/dist/components/data/AdvancedRequestDataGrid/helpers/index.js +0 -18
  85. package/dist/components/data/AdvancedRequestDataGrid/index.d.ts +0 -2
  86. package/dist/components/data/AdvancedRequestDataGrid/index.js +0 -215
  87. package/dist/components/data/AdvancedRequestDataGrid/types.d.ts +0 -21
  88. package/dist/components/data/AdvancedRequestDataGrid/types.js +0 -2
  89. package/dist/components/data/DataGrid/DataGridCell.d.ts +0 -2
  90. package/dist/components/data/DataGrid/DataGridCell.js +0 -59
  91. package/dist/components/data/DataGrid/DataGridColumnsModal/helpers.d.ts +0 -2
  92. package/dist/components/data/DataGrid/DataGridColumnsModal/helpers.js +0 -24
  93. package/dist/components/data/DataGrid/DataGridColumnsModal/hooks.d.ts +0 -6
  94. package/dist/components/data/DataGrid/DataGridColumnsModal/hooks.js +0 -38
  95. package/dist/components/data/DataGrid/DataGridColumnsModal/index.d.ts +0 -15
  96. package/dist/components/data/DataGrid/DataGridColumnsModal/index.js +0 -111
  97. package/dist/components/data/DataGrid/DataGridColumnsModal/styles.d.ts +0 -22
  98. package/dist/components/data/DataGrid/DataGridColumnsModal/styles.js +0 -54
  99. package/dist/components/data/DataGrid/DataGridEditableCell.d.ts +0 -2
  100. package/dist/components/data/DataGrid/DataGridEditableCell.js +0 -27
  101. package/dist/components/data/DataGrid/DataGridFilterMenu/FilterValuesScroller.d.ts +0 -13
  102. package/dist/components/data/DataGrid/DataGridFilterMenu/FilterValuesScroller.js +0 -71
  103. package/dist/components/data/DataGrid/DataGridFilterMenu/hooks.d.ts +0 -9
  104. package/dist/components/data/DataGrid/DataGridFilterMenu/hooks.js +0 -52
  105. package/dist/components/data/DataGrid/DataGridFilterMenu/index.d.ts +0 -9
  106. package/dist/components/data/DataGrid/DataGridFilterMenu/index.js +0 -221
  107. package/dist/components/data/DataGrid/DataGridFilterMenu/styles.d.ts +0 -18
  108. package/dist/components/data/DataGrid/DataGridFilterMenu/styles.js +0 -31
  109. package/dist/components/data/DataGrid/DataGridFooter.d.ts +0 -4
  110. package/dist/components/data/DataGrid/DataGridFooter.js +0 -44
  111. package/dist/components/data/DataGrid/DataGridHeader.d.ts +0 -4
  112. package/dist/components/data/DataGrid/DataGridHeader.js +0 -119
  113. package/dist/components/data/DataGrid/DataGridHeaderCell.d.ts +0 -2
  114. package/dist/components/data/DataGrid/DataGridHeaderCell.js +0 -84
  115. package/dist/components/data/DataGrid/FilterModalContent/index.d.ts +0 -7
  116. package/dist/components/data/DataGrid/FilterModalContent/index.js +0 -117
  117. package/dist/components/data/DataGrid/FilterModalContent/styles.d.ts +0 -3
  118. package/dist/components/data/DataGrid/FilterModalContent/styles.js +0 -15
  119. package/dist/components/data/DataGrid/VirtualScroller.d.ts +0 -11
  120. package/dist/components/data/DataGrid/VirtualScroller.js +0 -41
  121. package/dist/components/data/DataGrid/helpers/columns.d.ts +0 -13
  122. package/dist/components/data/DataGrid/helpers/columns.js +0 -169
  123. package/dist/components/data/DataGrid/helpers/filters.d.ts +0 -18
  124. package/dist/components/data/DataGrid/helpers/filters.js +0 -334
  125. package/dist/components/data/DataGrid/helpers/index.js +0 -18
  126. package/dist/components/data/DataGrid/hooks/index.d.ts +0 -7
  127. package/dist/components/data/DataGrid/hooks/index.js +0 -34
  128. package/dist/components/data/DataGrid/hooks/useDataGrid.d.ts +0 -2
  129. package/dist/components/data/DataGrid/hooks/useDataGrid.js +0 -252
  130. package/dist/components/data/DataGrid/hooks/useDataGridCopy.d.ts +0 -4
  131. package/dist/components/data/DataGrid/hooks/useDataGridCopy.js +0 -163
  132. package/dist/components/data/DataGrid/hooks/useDataGridSettings.d.ts +0 -16
  133. package/dist/components/data/DataGrid/hooks/useDataGridSettings.js +0 -43
  134. package/dist/components/data/DataGrid/index.d.ts +0 -4
  135. package/dist/components/data/DataGrid/index.js +0 -108
  136. package/dist/components/data/DataGrid/styles.d.ts +0 -60
  137. package/dist/components/data/DataGrid/styles.js +0 -128
  138. package/dist/components/data/DataGrid/types.d.ts +0 -165
  139. package/dist/components/data/DataGrid/types.js +0 -34
  140. package/dist/components/data/SqlRequestDataGrid/helpers/columns.d.ts +0 -16
  141. package/dist/components/data/SqlRequestDataGrid/helpers/columns.js +0 -125
  142. package/dist/components/data/SqlRequestDataGrid/helpers/index.js +0 -18
  143. package/dist/components/data/SqlRequestDataGrid/helpers/sqlRequests.d.ts +0 -3
  144. package/dist/components/data/SqlRequestDataGrid/helpers/sqlRequests.js +0 -18
  145. package/dist/components/data/SqlRequestDataGrid/index.d.ts +0 -2
  146. package/dist/components/data/SqlRequestDataGrid/index.js +0 -296
  147. package/dist/components/data/SqlRequestDataGrid/types.d.ts +0 -21
  148. package/dist/components/data/SqlRequestDataGrid/types.js +0 -2
  149. package/dist/components/data/index.js +0 -24
  150. package/dist/components/forms/Button.d.ts +0 -10
  151. package/dist/components/forms/Button.js +0 -70
  152. package/dist/components/forms/IconButton.d.ts +0 -7
  153. package/dist/components/forms/IconButton.js +0 -64
  154. package/dist/components/forms/IndeterminateCheckbox.d.ts +0 -8
  155. package/dist/components/forms/IndeterminateCheckbox.js +0 -41
  156. package/dist/components/forms/Select.d.ts +0 -10
  157. package/dist/components/forms/Select.js +0 -49
  158. package/dist/components/forms/index.js +0 -23
  159. package/dist/components/forms/styles.d.ts +0 -2
  160. package/dist/components/forms/styles.js +0 -34
  161. package/dist/components/index.js +0 -19
  162. package/dist/components/layout/Dropdown/index.d.ts +0 -11
  163. package/dist/components/layout/Dropdown/index.js +0 -85
  164. package/dist/components/layout/Dropdown/styles.d.ts +0 -11
  165. package/dist/components/layout/Dropdown/styles.js +0 -45
  166. package/dist/components/layout/Loading/index.d.ts +0 -6
  167. package/dist/components/layout/Loading/index.js +0 -42
  168. package/dist/components/layout/Loading/styles.d.ts +0 -6
  169. package/dist/components/layout/Loading/styles.js +0 -18
  170. package/dist/components/layout/Modal/index.d.ts +0 -16
  171. package/dist/components/layout/Modal/index.js +0 -67
  172. package/dist/components/layout/Modal/styles.d.ts +0 -32
  173. package/dist/components/layout/Modal/styles.js +0 -52
  174. package/dist/components/layout/index.js +0 -19
  175. package/dist/components/ui/ContextMenu/index.d.ts +0 -11
  176. package/dist/components/ui/ContextMenu/index.js +0 -63
  177. package/dist/components/ui/ContextMenu/styles.d.ts +0 -18
  178. package/dist/components/ui/ContextMenu/styles.js +0 -56
  179. package/dist/config/index.d.ts +0 -10
  180. package/dist/config/index.js +0 -2
  181. package/dist/helpers/dates.d.ts +0 -2
  182. package/dist/helpers/dates.js +0 -13
  183. package/dist/helpers/getScrollbarSize.d.ts +0 -1
  184. package/dist/helpers/getScrollbarSize.js +0 -17
  185. package/dist/helpers/numbers.d.ts +0 -4
  186. package/dist/helpers/numbers.js +0 -39
  187. package/dist/hooks/index.js +0 -18
  188. package/dist/hooks/useElementSize.d.ts +0 -4
  189. package/dist/hooks/useElementSize.js +0 -23
  190. package/dist/hooks/useWindowSize.d.ts +0 -4
  191. package/dist/hooks/useWindowSize.js +0 -19
  192. package/dist/index.js +0 -21
  193. package/dist/providers/PortalsProvider/index.d.ts +0 -10
  194. package/dist/providers/PortalsProvider/index.js +0 -46
  195. package/dist/providers/PortalsProvider/styles.d.ts +0 -9
  196. package/dist/providers/PortalsProvider/styles.js +0 -21
  197. package/dist/providers/SettingsProvider/index.d.ts +0 -8
  198. package/dist/providers/SettingsProvider/index.js +0 -54
  199. package/dist/providers/ThemeProvider/ThemeProvider.d.ts +0 -7
  200. package/dist/providers/ThemeProvider/ThemeProvider.js +0 -51
  201. package/dist/providers/ThemeProvider/defaultTheme.d.ts +0 -2
  202. package/dist/providers/ThemeProvider/defaultTheme.js +0 -417
  203. package/dist/providers/ThemeProvider/index.js +0 -5
  204. package/dist/providers/ThemeProvider/types.d.ts +0 -24
  205. package/dist/providers/ThemeProvider/types.js +0 -2
  206. package/dist/providers/UiProviders/index.d.ts +0 -12
  207. package/dist/providers/UiProviders/index.js +0 -62
  208. package/dist/providers/UiProviders/styles.d.ts +0 -3
  209. package/dist/providers/UiProviders/styles.js +0 -13
  210. package/dist/providers/hooks.d.ts +0 -3
  211. package/dist/providers/hooks.js +0 -13
  212. package/dist/providers/index.js +0 -20
  213. package/dist/services/HttpService.d.ts +0 -10
  214. package/dist/services/HttpService.js +0 -117
  215. package/dist/services/WebSocketService.d.ts +0 -24
  216. package/dist/services/WebSocketService.js +0 -136
  217. package/dist/services/advancedRequests.d.ts +0 -41
  218. package/dist/services/advancedRequests.js +0 -13
  219. package/dist/services/base.d.ts +0 -19
  220. package/dist/services/base.js +0 -10
  221. package/dist/services/globalSearch.d.ts +0 -13
  222. package/dist/services/globalSearch.js +0 -8
  223. package/dist/services/hooks.d.ts +0 -2
  224. package/dist/services/hooks.js +0 -18
  225. package/dist/services/index.js +0 -18
  226. package/dist/services/sqlRequests.d.ts +0 -45
  227. package/dist/services/sqlRequests.js +0 -11
  228. /package/{dist/components/data/AdvancedRequestDataGrid/helpers/index.d.ts → src/components/data/AdvancedRequestDataGrid/helpers/index.ts} +0 -0
  229. /package/{dist/components/data/DataGrid/helpers/index.d.ts → src/components/data/DataGrid/helpers/index.ts} +0 -0
  230. /package/{dist/components/data/SqlRequestDataGrid/helpers/index.d.ts → src/components/data/SqlRequestDataGrid/helpers/index.ts} +0 -0
  231. /package/{dist/components/data/index.d.ts → src/components/data/index.ts} +0 -0
  232. /package/{dist/components/forms/index.d.ts → src/components/forms/index.ts} +0 -0
  233. /package/{dist/components/index.d.ts → src/components/index.ts} +0 -0
  234. /package/{dist/components/layout/index.d.ts → src/components/layout/index.ts} +0 -0
  235. /package/{dist/hooks/index.d.ts → src/hooks/index.ts} +0 -0
  236. /package/{dist/services/index.d.ts → src/services/index.ts} +0 -0
@@ -0,0 +1,28 @@
1
+ import js from '@eslint/js'
2
+ import globals from 'globals'
3
+ import reactHooks from 'eslint-plugin-react-hooks'
4
+ import reactRefresh from 'eslint-plugin-react-refresh'
5
+ import tseslint from 'typescript-eslint'
6
+
7
+ export default tseslint.config(
8
+ { ignores: ['dist'] },
9
+ {
10
+ extends: [js.configs.recommended, ...tseslint.configs.recommended],
11
+ files: ['**/*.{ts,tsx}'],
12
+ languageOptions: {
13
+ ecmaVersion: 2020,
14
+ globals: globals.browser,
15
+ },
16
+ plugins: {
17
+ 'react-hooks': reactHooks,
18
+ 'react-refresh': reactRefresh,
19
+ },
20
+ rules: {
21
+ ...reactHooks.configs.recommended.rules,
22
+ 'react-refresh/only-export-components': [
23
+ 'warn',
24
+ { allowConstantExport: true },
25
+ ],
26
+ },
27
+ },
28
+ )
package/package.json CHANGED
@@ -1,34 +1,19 @@
1
1
  {
2
2
  "name": "@addev-be/ui",
3
- "version": "0.2.16",
3
+ "version": "0.2.19",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "watch": "tsc -b --watch",
7
7
  "build": "tsc -b",
8
- "build:vite": "vite build",
9
8
  "lint": "eslint .",
10
9
  "publish": "yarn npm publish"
11
10
  },
12
11
  "types": "src/index.ts",
13
12
  "exports": {
14
13
  ".": {
15
- "types": "./src/index.d.ts",
16
- "import": "./src/index.js"
14
+ "import": "./src/index.ts"
17
15
  }
18
16
  },
19
- "files": [
20
- "dist",
21
- "assets"
22
- ],
23
- "dependencies": {
24
- "fp-ts": "^2.16.9",
25
- "io-ts": "^2.2.21",
26
- "lodash": "^4.17.21",
27
- "moment": "^2.30.1",
28
- "styled-components": "^6.1.13",
29
- "uuid": "^10.0.0",
30
- "vite-plugin-svgr": "^4.2.0"
31
- },
32
17
  "devDependencies": {
33
18
  "@eslint/js": "^8.57.0",
34
19
  "@types/lodash": "^4",
@@ -47,11 +32,19 @@
47
32
  "eslint-plugin-react-refresh": "^0.4.9",
48
33
  "globals": "^15.9.0",
49
34
  "typescript": "^5.5.3",
50
- "typescript-eslint": "^8.6.0",
51
- "vite": "^5.4.10"
35
+ "typescript-eslint": "^8.6.0"
52
36
  },
53
37
  "peerDependencies": {
54
38
  "react": "^18.3.1",
55
- "react-dom": "^18.3.1"
39
+ "react-dom": "^18.3.1",
40
+ "styled-components": "^6.1.13",
41
+ "vite-plugin-svgr": "^4.2.0"
42
+ },
43
+ "dependencies": {
44
+ "fp-ts": "^2.16.9",
45
+ "io-ts": "^2.2.21",
46
+ "lodash": "^4.17.21",
47
+ "moment": "^2.30.1",
48
+ "uuid": "^10.0.0"
56
49
  }
57
50
  }
@@ -1,4 +1,5 @@
1
- import { FC, SVGProps } from 'react';
1
+ import { FC, SVGProps, useEffect, useState } from 'react';
2
+
2
3
  import ArrowDown19Icon from '../assets/icons/arrow-down-1-9.svg?react';
3
4
  import ArrowDownAZIcon from '../assets/icons/arrow-down-a-z.svg?react';
4
5
  import ArrowDownBigSmallIcon from '../assets/icons/arrow-down-big-small.svg?react';
@@ -34,12 +35,74 @@ import TallyIcon from '../assets/icons/tally.svg?react';
34
35
  import UpIcon from '../assets/icons/up.svg?react';
35
36
  import UserTieIcon from '../assets/icons/user-tie.svg?react';
36
37
  import XBarIcon from '../assets/icons/x-bar.svg?react';
38
+
37
39
  type IconFCProps = SVGProps<SVGSVGElement>;
38
40
  export type IconFC = FC<IconFCProps>;
41
+
39
42
  type AnimatedIconProps = {
40
- icons: FC[];
41
- speed?: number;
43
+ icons: FC[];
44
+ speed?: number;
45
+ };
46
+
47
+ export const AnimatedIcon: FC<AnimatedIconProps & IconFCProps> = ({
48
+ icons,
49
+ speed = 150,
50
+ ...props
51
+ }) => {
52
+ const [currentIcon, setCurrentIcon] = useState(0);
53
+
54
+ useEffect(() => {
55
+ const interval = setInterval(() => {
56
+ setCurrentIcon((currentIcon) => (currentIcon + 1) % icons.length);
57
+ }, speed);
58
+
59
+ return () => {
60
+ clearInterval(interval);
61
+ };
62
+ }, [icons.length, speed]);
63
+
64
+ const Icon = icons[currentIcon];
65
+ return <Icon {...props} />;
66
+ };
67
+
68
+ export const LoadingIcon: FC<IconFCProps> = ({ className, ...props }) => (
69
+ <SpinnerIcon className={`animate-spin ${className}`} {...props} />
70
+ );
71
+
72
+ export {
73
+ ArrowDownAZIcon,
74
+ ArrowDown19Icon,
75
+ ArrowDownBigSmallIcon,
76
+ ArrowUpZAIcon,
77
+ ArrowUpBigSmallIcon,
78
+ ArrowUp91Icon,
79
+ ArrowsRotateIcon,
80
+ ArrowsUpDownIcon,
81
+ CheckIcon,
82
+ ChevronDownIcon,
83
+ CopyIcon,
84
+ DownIcon,
85
+ EllipsisIcon,
86
+ FilterFullIcon,
87
+ FilterIcon,
88
+ FilterSlashIcon,
89
+ HashtagIcon,
90
+ ImageSlashIcon,
91
+ LeftIcon,
92
+ MagnifierIcon,
93
+ PhoneIcon,
94
+ PlusIcon,
95
+ RightIcon,
96
+ SigmaIcon,
97
+ SortCalendarAscendingIcon,
98
+ SortCalendarDescendingIcon,
99
+ SpinnerIcon,
100
+ TableColumnsIcon,
101
+ TableFooterIcon,
102
+ TableFooterSlashIcon,
103
+ TableIcon,
104
+ TallyIcon,
105
+ UpIcon,
106
+ UserTieIcon,
107
+ XBarIcon,
42
108
  };
43
- export declare const AnimatedIcon: FC<AnimatedIconProps & IconFCProps>;
44
- export declare const LoadingIcon: FC<IconFCProps>;
45
- export { ArrowDownAZIcon, ArrowDown19Icon, ArrowDownBigSmallIcon, ArrowUpZAIcon, ArrowUpBigSmallIcon, ArrowUp91Icon, ArrowsRotateIcon, ArrowsUpDownIcon, CheckIcon, ChevronDownIcon, CopyIcon, DownIcon, EllipsisIcon, FilterFullIcon, FilterIcon, FilterSlashIcon, HashtagIcon, ImageSlashIcon, LeftIcon, MagnifierIcon, PhoneIcon, PlusIcon, RightIcon, SigmaIcon, SortCalendarAscendingIcon, SortCalendarDescendingIcon, SpinnerIcon, TableColumnsIcon, TableFooterIcon, TableFooterSlashIcon, TableIcon, TallyIcon, UpIcon, UserTieIcon, XBarIcon, };
@@ -0,0 +1,93 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+
3
+ import {
4
+ AdvancedRequestDTO,
5
+ ConditionDTO,
6
+ FieldDTO,
7
+ OrderByDTO,
8
+ } from '../../../../services/advancedRequests';
9
+ import {
10
+ AdvancedRequestDataGridColumns,
11
+ AdvancedRequestDataGridFilters,
12
+ } from '../types';
13
+
14
+ import _ from 'lodash';
15
+
16
+ export const getAdvancedRequestDto = <R>({
17
+ type,
18
+ columns,
19
+ conditions = [],
20
+ orderBy = [],
21
+ start = 0,
22
+ length = 100,
23
+ getTotal = false,
24
+ idField = { fieldName: 'Id' },
25
+ }: {
26
+ type: string;
27
+ columns: AdvancedRequestDataGridColumns<R>;
28
+ conditions?: ConditionDTO[];
29
+ orderBy?: OrderByDTO[];
30
+ start?: number;
31
+ length?: number;
32
+ getTotal?: boolean;
33
+ idField?: FieldDTO | null;
34
+ }): AdvancedRequestDTO => ({
35
+ fields: [
36
+ ...(idField === null ? [] : [idField]),
37
+ ...Object.keys(columns).map((key) =>
38
+ columns[key].field
39
+ ? {
40
+ ...columns[key].field,
41
+ fieldName: columns[key].field?.fieldName ?? key,
42
+ fieldAlias: key,
43
+ }
44
+ : {
45
+ fieldName: key,
46
+ fieldAlias: key,
47
+ }
48
+ ),
49
+ ],
50
+ conditions,
51
+ orderBy,
52
+ type,
53
+ start,
54
+ length,
55
+ getTotal,
56
+ });
57
+
58
+ export const convertFiltersToConditions = <R>(
59
+ filters: AdvancedRequestDataGridFilters,
60
+ columns: AdvancedRequestDataGridColumns<R>
61
+ ): Record<string, ConditionDTO> =>
62
+ _.mapValues(filters, (filter, columnKey) => ({
63
+ field:
64
+ columns[columnKey].filterField ??
65
+ columns[columnKey].field?.fieldAlias ??
66
+ columns[columnKey].field?.fieldName ??
67
+ columnKey,
68
+ operator: filter.operator as any,
69
+ value: ['inArray', 'inRange'].includes(filter.operator)
70
+ ? filter.values
71
+ : _.castArray<string | number | null>(filter.values)[0],
72
+ }));
73
+
74
+ export const parseJsonObjectFields = <R>(
75
+ rows: any[],
76
+ columns: AdvancedRequestDataGridColumns<R>,
77
+ parser?: (row: any) => R
78
+ ): R[] => {
79
+ const jsonColumns = Object.keys(columns).filter(
80
+ (key) => columns[key].field?.operator === 'jsonObject'
81
+ );
82
+ const parsedRows =
83
+ jsonColumns.length === 0
84
+ ? rows
85
+ : rows.map((row) => {
86
+ const parsedRow = { ...row };
87
+ jsonColumns.forEach((key) => {
88
+ parsedRow[key] = JSON.parse(parsedRow[key] ?? '{}');
89
+ });
90
+ return parsedRow;
91
+ });
92
+ return parser ? parsedRows.map(parser) : parsedRows;
93
+ };
@@ -0,0 +1,262 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+
3
+ import {
4
+ AdvancedRequestDataGridColumn,
5
+ AdvancedRequestDataGridColumns,
6
+ } from '../types';
7
+ import {
8
+ formatMoney,
9
+ formatNumber,
10
+ formatPercentage,
11
+ } from '../../../../helpers/numbers';
12
+ import { numberFilter, textFilter } from '../../DataGrid/helpers';
13
+
14
+ import { FieldDTO } from '../../../../services/advancedRequests';
15
+ import _ from 'lodash';
16
+ import moment from 'moment';
17
+
18
+ export const withGroupBy = <R extends Record<string, any>>(
19
+ columns: AdvancedRequestDataGridColumns<R>
20
+ ): AdvancedRequestDataGridColumns<R> =>
21
+ _.mapValues(columns, (column, key) => ({
22
+ ...column,
23
+ field: {
24
+ ...(column.field ?? { fieldName: key }),
25
+ groupBy: true,
26
+ },
27
+ }));
28
+
29
+ export const advancedTextColumn = <R extends Record<string, any>>(
30
+ key: string,
31
+ title: string,
32
+ options?: Partial<AdvancedRequestDataGridColumn<R>>
33
+ ): AdvancedRequestDataGridColumns<R> => ({
34
+ [key]: {
35
+ name: title,
36
+ render: (row) => row[key] ?? '',
37
+ getter: (row) => row[key] ?? '',
38
+ sortGetter: (row) => row[key] ?? '',
39
+ filter: { ...textFilter(key), getter: (value) => value[key] ?? '' },
40
+ ...options,
41
+ },
42
+ });
43
+
44
+ /**
45
+ * Creates a column with a composed value from multiple fields,
46
+ * and filtered by a text filter on the first field
47
+ */
48
+ export const advancedComposedColumn = <R extends Record<string, any>>(
49
+ key: string,
50
+ title: string,
51
+ fields: string[],
52
+ options?: Partial<AdvancedRequestDataGridColumn<R>>
53
+ ): AdvancedRequestDataGridColumns<R> => ({
54
+ [key]: {
55
+ field: {
56
+ fieldAlias: key,
57
+ operator: 'jsonObject',
58
+ operands: fields.flatMap((field) => [
59
+ { constantValue: field },
60
+ { fieldName: field },
61
+ ]),
62
+ },
63
+ name: title,
64
+ render: (row) => row[key] ?? '',
65
+ getter: (row) => row[key] ?? '',
66
+ sortGetter: (row) => row[key] ?? '',
67
+ filter: {
68
+ ...textFilter(fields[0]),
69
+ getter: (value) => value[fields[0]] ?? 0,
70
+ },
71
+ filterField: fields[0],
72
+ sortField: fields[0],
73
+ ...options,
74
+ },
75
+ });
76
+
77
+ export const advancedMailColumn = <R extends Record<string, any>>(
78
+ key: string,
79
+ title: string,
80
+ options?: Partial<AdvancedRequestDataGridColumn<R>>
81
+ ): AdvancedRequestDataGridColumns<R> => ({
82
+ [key]: {
83
+ name: title,
84
+ render: (row) => <a href={`mailto:${row[key]}`}>{row[key] ?? ''}</a>,
85
+ getter: (row) => row[key] ?? '',
86
+ sortGetter: (row) => row[key] ?? '',
87
+ filter: { ...textFilter(key), getter: (value) => value[key] ?? '' },
88
+ ...options,
89
+ },
90
+ });
91
+
92
+ export const advancedPhoneColumn = <R extends Record<string, any>>(
93
+ key: string,
94
+ title: string,
95
+ options?: Partial<AdvancedRequestDataGridColumn<R>>
96
+ ): AdvancedRequestDataGridColumns<R> => ({
97
+ [key]: {
98
+ name: title,
99
+ render: (row) => <a href={`tel:${row[key]}`}>{row[key] ?? ''}</a>,
100
+ getter: (row) => row[key] ?? '',
101
+ sortGetter: (row) => row[key] ?? '',
102
+ filter: { ...textFilter(key), getter: (value) => value[key] ?? '' },
103
+ ...options,
104
+ },
105
+ });
106
+
107
+ export const advancedDateColumn = <R extends Record<string, any>>(
108
+ key: string,
109
+ title: string,
110
+ options?: Partial<AdvancedRequestDataGridColumn<R>>
111
+ ): AdvancedRequestDataGridColumns<R> => ({
112
+ [key]: {
113
+ name: title,
114
+ render: (row) => moment(row[key]).format('DD/MM/YYYY') ?? '',
115
+ getter: (row) => row[key] ?? '',
116
+ sortGetter: (row) => row[key] ?? '',
117
+ filter: { ...textFilter(key), getter: (value) => value[key] ?? '' },
118
+ ...options,
119
+ },
120
+ });
121
+
122
+ export const advancedMonthColumn = <R extends Record<string, any>>(
123
+ key: string,
124
+ title: string,
125
+ options?: Partial<AdvancedRequestDataGridColumn<R>>
126
+ ): AdvancedRequestDataGridColumns<R> => ({
127
+ [key]: {
128
+ name: title,
129
+ render: (row) => (row[key] ? `${row[key]} mois ` : ''),
130
+ getter: (row) => row[key] ?? '',
131
+ sortGetter: (row) => row[key] ?? '',
132
+ filter: { ...textFilter(key), getter: (value) => value[key] ?? '' },
133
+ ...options,
134
+ },
135
+ });
136
+
137
+ export const advancedNumberColumn = <R extends Record<string, any>>(
138
+ key: string,
139
+ title: string,
140
+ decimals = 2,
141
+ options?: Partial<AdvancedRequestDataGridColumn<R>>
142
+ ): AdvancedRequestDataGridColumns<R> => ({
143
+ [key]: {
144
+ name: title,
145
+ render: (row) => formatNumber(row[key], decimals) ?? '',
146
+ excelFormatter: () => '#',
147
+ getter: (row) => row[key] ?? '',
148
+ sortGetter: (row) => row[key] ?? '',
149
+ filter: { ...numberFilter(key), getter: (value) => value[key] ?? 0 },
150
+ ...options,
151
+ },
152
+ });
153
+
154
+ export const advancedMoneyColumn = <R extends Record<string, any>>(
155
+ key: string,
156
+ title: string,
157
+ decimals = 2,
158
+ options?: Partial<AdvancedRequestDataGridColumn<R>>
159
+ ): AdvancedRequestDataGridColumns<R> => ({
160
+ [key]: {
161
+ name: title,
162
+ render: (row) => formatMoney(row[key], decimals) ?? '',
163
+ excelFormatter: () => '#0.00',
164
+ getter: (row) => row[key] ?? '',
165
+ sortGetter: (row) => row[key] ?? '',
166
+ filter: { ...numberFilter(key), getter: (value) => value[key] ?? 0 },
167
+ ...options,
168
+ },
169
+ });
170
+
171
+ export const advancedPercentageColumn = <R extends Record<string, any>>(
172
+ key: string,
173
+ title: string,
174
+ options?: Partial<AdvancedRequestDataGridColumn<R>>
175
+ ): AdvancedRequestDataGridColumns<R> => ({
176
+ [key]: {
177
+ name: title,
178
+ render: (row) => formatPercentage(row[key]) ?? '',
179
+ excelFormatter: () => '#0.00',
180
+ getter: (row) => row[key] ?? '',
181
+ sortGetter: (row) => row[key] ?? '',
182
+ filter: { ...numberFilter(key), getter: (value) => value[key] ?? 0 },
183
+ ...options,
184
+ },
185
+ });
186
+
187
+ export const advancedCheckboxColumn = <R extends Record<string, any>>(
188
+ key: string,
189
+ title: string,
190
+ options?: Partial<AdvancedRequestDataGridColumn<R>>
191
+ ): AdvancedRequestDataGridColumns<R> => ({
192
+ [key]: {
193
+ name: title,
194
+ render: (row) => (
195
+ <>
196
+ <input type="checkbox" checked={row[key]} />
197
+ <span>{row[key] ? ' Oui' : ' Non'}</span>
198
+ </>
199
+ ),
200
+ getter: (row) => row[key] ?? '',
201
+ sortGetter: (row) => row[key] ?? '',
202
+ filter: { ...numberFilter(key), getter: (value) => value[key] ?? 0 },
203
+ ...options,
204
+ },
205
+ });
206
+
207
+ export const advancedColorColumn = <R extends Record<string, any>>(
208
+ key: string,
209
+ title: string,
210
+ options?: Partial<AdvancedRequestDataGridColumn<R>>
211
+ ): AdvancedRequestDataGridColumns<R> => ({
212
+ [key]: {
213
+ name: title,
214
+ render: (row) => (
215
+ <div style={{ backgroundColor: row[key] }}>{row[key] ?? ''}</div>
216
+ ),
217
+ getter: (row) => row[key] ?? '',
218
+ sortGetter: (row) => row[key] ?? '',
219
+ filter: { ...textFilter(key), getter: (value) => value[key] ?? '' },
220
+ ...options,
221
+ },
222
+ });
223
+
224
+ export const getColumnField = <R,>(
225
+ columns: AdvancedRequestDataGridColumns<R>,
226
+ columnKey: string
227
+ ): FieldDTO => {
228
+ return columns[columnKey].field
229
+ ? {
230
+ fieldName: columns[columnKey].field?.fieldName ?? columnKey,
231
+ fieldAlias: columnKey,
232
+ }
233
+ : {
234
+ fieldName: columnKey,
235
+ fieldAlias: columnKey,
236
+ };
237
+ };
238
+ export const getColumnSortField = <R,>(
239
+ columns: AdvancedRequestDataGridColumns<R>,
240
+ columnKey: string
241
+ ): FieldDTO => {
242
+ return columns[columnKey].sortField
243
+ ? {
244
+ fieldName: columns[columnKey].sortField ?? columnKey,
245
+ fieldAlias: columnKey,
246
+ }
247
+ : {
248
+ fieldName: columnKey,
249
+ fieldAlias: columnKey,
250
+ };
251
+ };
252
+ export const getFirstColumnField = <R,>(
253
+ columns: AdvancedRequestDataGridColumns<R>
254
+ ): FieldDTO => {
255
+ return getColumnField(columns, Object.keys(columns)[0]);
256
+ };
257
+
258
+ export const getFirstColumnSortField = <R,>(
259
+ columns: AdvancedRequestDataGridColumns<R>
260
+ ): FieldDTO => {
261
+ return getColumnSortField(columns, Object.keys(columns)[0]);
262
+ };