@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.
- package/eslint.config.js +28 -0
- package/package.json +13 -20
- package/{dist/Icons.d.ts → src/Icons.tsx} +69 -6
- package/src/components/data/AdvancedRequestDataGrid/helpers/advancedRequests.ts +93 -0
- package/src/components/data/AdvancedRequestDataGrid/helpers/columns.tsx +262 -0
- package/src/components/data/AdvancedRequestDataGrid/index.tsx +267 -0
- package/src/components/data/AdvancedRequestDataGrid/types.ts +47 -0
- package/src/components/data/DataGrid/DataGridCell.tsx +73 -0
- package/src/components/data/DataGrid/DataGridColumnsModal/helpers.ts +14 -0
- package/src/components/data/DataGrid/DataGridColumnsModal/hooks.tsx +59 -0
- package/src/components/data/DataGrid/DataGridColumnsModal/index.tsx +181 -0
- package/src/components/data/DataGrid/DataGridColumnsModal/styles.ts +104 -0
- package/src/components/data/DataGrid/DataGridEditableCell.tsx +43 -0
- package/src/components/data/DataGrid/DataGridFilterMenu/FilterValuesScroller.tsx +120 -0
- package/src/components/data/DataGrid/DataGridFilterMenu/hooks.tsx +75 -0
- package/src/components/data/DataGrid/DataGridFilterMenu/index.tsx +360 -0
- package/src/components/data/DataGrid/DataGridFilterMenu/styles.ts +96 -0
- package/src/components/data/DataGrid/DataGridFooter.tsx +42 -0
- package/src/components/data/DataGrid/DataGridHeader.tsx +126 -0
- package/src/components/data/DataGrid/DataGridHeaderCell.tsx +132 -0
- package/src/components/data/DataGrid/FilterModalContent/index.tsx +136 -0
- package/src/components/data/DataGrid/FilterModalContent/styles.ts +22 -0
- package/src/components/data/DataGrid/VirtualScroller.tsx +46 -0
- package/src/components/data/DataGrid/helpers/columns.tsx +295 -0
- package/src/components/data/DataGrid/helpers/filters.ts +287 -0
- package/src/components/data/DataGrid/hooks/index.ts +30 -0
- package/src/components/data/DataGrid/hooks/useDataGrid.tsx +306 -0
- package/src/components/data/DataGrid/hooks/useDataGridCopy.ts +175 -0
- package/src/components/data/DataGrid/hooks/useDataGridSettings.ts +48 -0
- package/src/components/data/DataGrid/index.tsx +140 -0
- package/src/components/data/DataGrid/styles.ts +323 -0
- package/src/components/data/DataGrid/types.ts +267 -0
- package/src/components/data/SqlRequestDataGrid/helpers/columns.tsx +277 -0
- package/src/components/data/SqlRequestDataGrid/helpers/sqlRequests.ts +16 -0
- package/src/components/data/SqlRequestDataGrid/index.tsx +347 -0
- package/src/components/data/SqlRequestDataGrid/types.ts +47 -0
- package/src/components/forms/Button.tsx +99 -0
- package/src/components/forms/IconButton.tsx +56 -0
- package/src/components/forms/IndeterminateCheckbox.tsx +46 -0
- package/src/components/forms/Select.tsx +40 -0
- package/src/components/forms/styles.ts +20 -0
- package/src/components/layout/Dropdown/index.tsx +79 -0
- package/src/components/layout/Dropdown/styles.ts +44 -0
- package/src/components/layout/Loading/index.tsx +29 -0
- package/src/components/layout/Loading/styles.ts +29 -0
- package/src/components/layout/Modal/index.tsx +51 -0
- package/src/components/layout/Modal/styles.ts +110 -0
- package/src/components/ui/ContextMenu/index.tsx +79 -0
- package/src/components/ui/ContextMenu/styles.ts +119 -0
- package/src/config/index.ts +14 -0
- package/src/helpers/dates.ts +9 -0
- package/src/helpers/getScrollbarSize.ts +14 -0
- package/src/helpers/numbers.ts +26 -0
- package/src/hooks/useElementSize.ts +24 -0
- package/src/hooks/useWindowSize.ts +20 -0
- package/{dist/index.d.ts → src/index.ts} +2 -0
- package/src/providers/PortalsProvider/index.tsx +54 -0
- package/src/providers/PortalsProvider/styles.ts +27 -0
- package/src/providers/SettingsProvider/index.tsx +70 -0
- package/src/providers/ThemeProvider/ThemeProvider.ts +55 -0
- package/src/providers/ThemeProvider/defaultTheme.ts +444 -0
- package/{dist/providers/ThemeProvider/index.d.ts → src/providers/ThemeProvider/index.ts} +1 -0
- package/src/providers/ThemeProvider/types.ts +123 -0
- package/src/providers/UiProviders/index.tsx +65 -0
- package/src/providers/UiProviders/styles.ts +10 -0
- package/src/providers/hooks.ts +8 -0
- package/{dist/providers/index.d.ts → src/providers/index.ts} +1 -0
- package/src/services/HttpService.ts +80 -0
- package/src/services/WebSocketService.ts +147 -0
- package/src/services/advancedRequests.ts +101 -0
- package/src/services/base.ts +31 -0
- package/src/services/globalSearch.ts +27 -0
- package/src/services/hooks.ts +23 -0
- package/src/services/sqlRequests.ts +110 -0
- package/src/styles/animations.scss +30 -0
- package/src/styles/index.scss +42 -0
- package/src/typings.d.ts +6 -0
- package/tsconfig.json +18 -0
- package/dist/Icons.js +0 -120
- package/dist/components/data/AdvancedRequestDataGrid/helpers/advancedRequests.d.ts +0 -14
- package/dist/components/data/AdvancedRequestDataGrid/helpers/advancedRequests.js +0 -76
- package/dist/components/data/AdvancedRequestDataGrid/helpers/columns.d.ts +0 -22
- package/dist/components/data/AdvancedRequestDataGrid/helpers/columns.js +0 -156
- package/dist/components/data/AdvancedRequestDataGrid/helpers/index.js +0 -18
- package/dist/components/data/AdvancedRequestDataGrid/index.d.ts +0 -2
- package/dist/components/data/AdvancedRequestDataGrid/index.js +0 -215
- package/dist/components/data/AdvancedRequestDataGrid/types.d.ts +0 -21
- package/dist/components/data/AdvancedRequestDataGrid/types.js +0 -2
- package/dist/components/data/DataGrid/DataGridCell.d.ts +0 -2
- package/dist/components/data/DataGrid/DataGridCell.js +0 -59
- package/dist/components/data/DataGrid/DataGridColumnsModal/helpers.d.ts +0 -2
- package/dist/components/data/DataGrid/DataGridColumnsModal/helpers.js +0 -24
- package/dist/components/data/DataGrid/DataGridColumnsModal/hooks.d.ts +0 -6
- package/dist/components/data/DataGrid/DataGridColumnsModal/hooks.js +0 -38
- package/dist/components/data/DataGrid/DataGridColumnsModal/index.d.ts +0 -15
- package/dist/components/data/DataGrid/DataGridColumnsModal/index.js +0 -111
- package/dist/components/data/DataGrid/DataGridColumnsModal/styles.d.ts +0 -22
- package/dist/components/data/DataGrid/DataGridColumnsModal/styles.js +0 -54
- package/dist/components/data/DataGrid/DataGridEditableCell.d.ts +0 -2
- package/dist/components/data/DataGrid/DataGridEditableCell.js +0 -27
- package/dist/components/data/DataGrid/DataGridFilterMenu/FilterValuesScroller.d.ts +0 -13
- package/dist/components/data/DataGrid/DataGridFilterMenu/FilterValuesScroller.js +0 -71
- package/dist/components/data/DataGrid/DataGridFilterMenu/hooks.d.ts +0 -9
- package/dist/components/data/DataGrid/DataGridFilterMenu/hooks.js +0 -52
- package/dist/components/data/DataGrid/DataGridFilterMenu/index.d.ts +0 -9
- package/dist/components/data/DataGrid/DataGridFilterMenu/index.js +0 -221
- package/dist/components/data/DataGrid/DataGridFilterMenu/styles.d.ts +0 -18
- package/dist/components/data/DataGrid/DataGridFilterMenu/styles.js +0 -31
- package/dist/components/data/DataGrid/DataGridFooter.d.ts +0 -4
- package/dist/components/data/DataGrid/DataGridFooter.js +0 -44
- package/dist/components/data/DataGrid/DataGridHeader.d.ts +0 -4
- package/dist/components/data/DataGrid/DataGridHeader.js +0 -119
- package/dist/components/data/DataGrid/DataGridHeaderCell.d.ts +0 -2
- package/dist/components/data/DataGrid/DataGridHeaderCell.js +0 -84
- package/dist/components/data/DataGrid/FilterModalContent/index.d.ts +0 -7
- package/dist/components/data/DataGrid/FilterModalContent/index.js +0 -117
- package/dist/components/data/DataGrid/FilterModalContent/styles.d.ts +0 -3
- package/dist/components/data/DataGrid/FilterModalContent/styles.js +0 -15
- package/dist/components/data/DataGrid/VirtualScroller.d.ts +0 -11
- package/dist/components/data/DataGrid/VirtualScroller.js +0 -41
- package/dist/components/data/DataGrid/helpers/columns.d.ts +0 -13
- package/dist/components/data/DataGrid/helpers/columns.js +0 -169
- package/dist/components/data/DataGrid/helpers/filters.d.ts +0 -18
- package/dist/components/data/DataGrid/helpers/filters.js +0 -334
- package/dist/components/data/DataGrid/helpers/index.js +0 -18
- package/dist/components/data/DataGrid/hooks/index.d.ts +0 -7
- package/dist/components/data/DataGrid/hooks/index.js +0 -34
- package/dist/components/data/DataGrid/hooks/useDataGrid.d.ts +0 -2
- package/dist/components/data/DataGrid/hooks/useDataGrid.js +0 -252
- package/dist/components/data/DataGrid/hooks/useDataGridCopy.d.ts +0 -4
- package/dist/components/data/DataGrid/hooks/useDataGridCopy.js +0 -163
- package/dist/components/data/DataGrid/hooks/useDataGridSettings.d.ts +0 -16
- package/dist/components/data/DataGrid/hooks/useDataGridSettings.js +0 -43
- package/dist/components/data/DataGrid/index.d.ts +0 -4
- package/dist/components/data/DataGrid/index.js +0 -108
- package/dist/components/data/DataGrid/styles.d.ts +0 -60
- package/dist/components/data/DataGrid/styles.js +0 -128
- package/dist/components/data/DataGrid/types.d.ts +0 -165
- package/dist/components/data/DataGrid/types.js +0 -34
- package/dist/components/data/SqlRequestDataGrid/helpers/columns.d.ts +0 -16
- package/dist/components/data/SqlRequestDataGrid/helpers/columns.js +0 -125
- package/dist/components/data/SqlRequestDataGrid/helpers/index.js +0 -18
- package/dist/components/data/SqlRequestDataGrid/helpers/sqlRequests.d.ts +0 -3
- package/dist/components/data/SqlRequestDataGrid/helpers/sqlRequests.js +0 -18
- package/dist/components/data/SqlRequestDataGrid/index.d.ts +0 -2
- package/dist/components/data/SqlRequestDataGrid/index.js +0 -296
- package/dist/components/data/SqlRequestDataGrid/types.d.ts +0 -21
- package/dist/components/data/SqlRequestDataGrid/types.js +0 -2
- package/dist/components/data/index.js +0 -24
- package/dist/components/forms/Button.d.ts +0 -10
- package/dist/components/forms/Button.js +0 -70
- package/dist/components/forms/IconButton.d.ts +0 -7
- package/dist/components/forms/IconButton.js +0 -64
- package/dist/components/forms/IndeterminateCheckbox.d.ts +0 -8
- package/dist/components/forms/IndeterminateCheckbox.js +0 -41
- package/dist/components/forms/Select.d.ts +0 -10
- package/dist/components/forms/Select.js +0 -49
- package/dist/components/forms/index.js +0 -23
- package/dist/components/forms/styles.d.ts +0 -2
- package/dist/components/forms/styles.js +0 -34
- package/dist/components/index.js +0 -19
- package/dist/components/layout/Dropdown/index.d.ts +0 -11
- package/dist/components/layout/Dropdown/index.js +0 -85
- package/dist/components/layout/Dropdown/styles.d.ts +0 -11
- package/dist/components/layout/Dropdown/styles.js +0 -45
- package/dist/components/layout/Loading/index.d.ts +0 -6
- package/dist/components/layout/Loading/index.js +0 -42
- package/dist/components/layout/Loading/styles.d.ts +0 -6
- package/dist/components/layout/Loading/styles.js +0 -18
- package/dist/components/layout/Modal/index.d.ts +0 -16
- package/dist/components/layout/Modal/index.js +0 -67
- package/dist/components/layout/Modal/styles.d.ts +0 -32
- package/dist/components/layout/Modal/styles.js +0 -52
- package/dist/components/layout/index.js +0 -19
- package/dist/components/ui/ContextMenu/index.d.ts +0 -11
- package/dist/components/ui/ContextMenu/index.js +0 -63
- package/dist/components/ui/ContextMenu/styles.d.ts +0 -18
- package/dist/components/ui/ContextMenu/styles.js +0 -56
- package/dist/config/index.d.ts +0 -10
- package/dist/config/index.js +0 -2
- package/dist/helpers/dates.d.ts +0 -2
- package/dist/helpers/dates.js +0 -13
- package/dist/helpers/getScrollbarSize.d.ts +0 -1
- package/dist/helpers/getScrollbarSize.js +0 -17
- package/dist/helpers/numbers.d.ts +0 -4
- package/dist/helpers/numbers.js +0 -39
- package/dist/hooks/index.js +0 -18
- package/dist/hooks/useElementSize.d.ts +0 -4
- package/dist/hooks/useElementSize.js +0 -23
- package/dist/hooks/useWindowSize.d.ts +0 -4
- package/dist/hooks/useWindowSize.js +0 -19
- package/dist/index.js +0 -21
- package/dist/providers/PortalsProvider/index.d.ts +0 -10
- package/dist/providers/PortalsProvider/index.js +0 -46
- package/dist/providers/PortalsProvider/styles.d.ts +0 -9
- package/dist/providers/PortalsProvider/styles.js +0 -21
- package/dist/providers/SettingsProvider/index.d.ts +0 -8
- package/dist/providers/SettingsProvider/index.js +0 -54
- package/dist/providers/ThemeProvider/ThemeProvider.d.ts +0 -7
- package/dist/providers/ThemeProvider/ThemeProvider.js +0 -51
- package/dist/providers/ThemeProvider/defaultTheme.d.ts +0 -2
- package/dist/providers/ThemeProvider/defaultTheme.js +0 -417
- package/dist/providers/ThemeProvider/index.js +0 -5
- package/dist/providers/ThemeProvider/types.d.ts +0 -24
- package/dist/providers/ThemeProvider/types.js +0 -2
- package/dist/providers/UiProviders/index.d.ts +0 -12
- package/dist/providers/UiProviders/index.js +0 -62
- package/dist/providers/UiProviders/styles.d.ts +0 -3
- package/dist/providers/UiProviders/styles.js +0 -13
- package/dist/providers/hooks.d.ts +0 -3
- package/dist/providers/hooks.js +0 -13
- package/dist/providers/index.js +0 -20
- package/dist/services/HttpService.d.ts +0 -10
- package/dist/services/HttpService.js +0 -117
- package/dist/services/WebSocketService.d.ts +0 -24
- package/dist/services/WebSocketService.js +0 -136
- package/dist/services/advancedRequests.d.ts +0 -41
- package/dist/services/advancedRequests.js +0 -13
- package/dist/services/base.d.ts +0 -19
- package/dist/services/base.js +0 -10
- package/dist/services/globalSearch.d.ts +0 -13
- package/dist/services/globalSearch.js +0 -8
- package/dist/services/hooks.d.ts +0 -2
- package/dist/services/hooks.js +0 -18
- package/dist/services/index.js +0 -18
- package/dist/services/sqlRequests.d.ts +0 -45
- package/dist/services/sqlRequests.js +0 -11
- /package/{dist/components/data/AdvancedRequestDataGrid/helpers/index.d.ts → src/components/data/AdvancedRequestDataGrid/helpers/index.ts} +0 -0
- /package/{dist/components/data/DataGrid/helpers/index.d.ts → src/components/data/DataGrid/helpers/index.ts} +0 -0
- /package/{dist/components/data/SqlRequestDataGrid/helpers/index.d.ts → src/components/data/SqlRequestDataGrid/helpers/index.ts} +0 -0
- /package/{dist/components/data/index.d.ts → src/components/data/index.ts} +0 -0
- /package/{dist/components/forms/index.d.ts → src/components/forms/index.ts} +0 -0
- /package/{dist/components/index.d.ts → src/components/index.ts} +0 -0
- /package/{dist/components/layout/index.d.ts → src/components/layout/index.ts} +0 -0
- /package/{dist/hooks/index.d.ts → src/hooks/index.ts} +0 -0
- /package/{dist/services/index.d.ts → src/services/index.ts} +0 -0
package/eslint.config.js
ADDED
|
@@ -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.
|
|
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
|
-
"
|
|
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
|
-
|
|
41
|
-
|
|
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
|
+
};
|