@addev-be/ui 1.2.1 → 2.0.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.
- package/dist/components/auth/styles.d.ts +1 -3
- package/dist/components/data/DataGrid/DataGridColumnsModal/styles.d.ts +6 -18
- package/dist/components/data/DataGrid/DataGridEditableCell/CheckboxEditableCell.d.ts +1 -1
- package/dist/components/data/DataGrid/DataGridEditableCell/CheckboxEditableCell.js +3 -3
- package/dist/components/data/DataGrid/DataGridEditableCell/DateEditableCell.d.ts +1 -1
- package/dist/components/data/DataGrid/DataGridEditableCell/DateEditableCell.js +4 -4
- package/dist/components/data/DataGrid/DataGridEditableCell/NumberEditableCell.d.ts +2 -2
- package/dist/components/data/DataGrid/DataGridEditableCell/NumberEditableCell.js +4 -4
- package/dist/components/data/DataGrid/DataGridEditableCell/TextEditableCell.d.ts +1 -1
- package/dist/components/data/DataGrid/DataGridEditableCell/TextEditableCell.js +3 -3
- package/dist/components/data/DataGrid/DataGridEditableCell/types.d.ts +3 -3
- package/dist/components/data/DataGrid/DataGridFilterMenu/styles.d.ts +5 -15
- package/dist/components/data/DataGrid/FilterModalContent/styles.d.ts +1 -3
- package/dist/components/data/DataGrid/helpers/columns.d.ts +1 -1
- package/dist/components/data/DataGrid/helpers/columns.js +18 -4
- package/dist/components/data/DataGrid/index.d.ts +3 -44
- package/dist/components/data/DataGrid/index.js +4 -5
- package/dist/components/data/DataGrid/styles.d.ts +6 -18
- package/dist/components/data/SqlRequestDataGrid/SqlRequestForeignListEditableCell.d.ts +2 -1
- package/dist/components/data/SqlRequestDataGrid/SqlRequestForeignListEditableCell.js +2 -3
- package/dist/components/data/SqlRequestDataGrid/helpers/columns.d.ts +1 -1
- package/dist/components/data/SqlRequestDataGrid/helpers/columns.js +33 -22
- package/dist/components/data/SqlRequestDataGrid/helpers/rows.d.ts +2 -0
- package/dist/components/data/SqlRequestDataGrid/helpers/rows.js +17 -0
- package/dist/components/data/SqlRequestDataGrid/index.d.ts +4 -11
- package/dist/components/data/SqlRequestDataGrid/index.js +4 -5
- package/dist/components/data/SqlRequestForeignList/index.d.ts +4 -3
- package/dist/components/data/SqlRequestForeignList/index.js +4 -5
- package/dist/components/data/SqlRequestGrid/index.d.ts +4 -3
- package/dist/components/data/SqlRequestGrid/index.js +18 -18
- package/dist/components/data/SqlRequestGrid/styles.d.ts +1 -3
- package/dist/components/data/VirtualScroller/styles.d.ts +2 -6
- package/dist/components/forms/Button.d.ts +1 -1
- package/dist/components/forms/Form/CustomSelect.d.ts +1 -1
- package/dist/components/forms/Form/CustomSelect.js +3 -4
- package/dist/components/forms/Form/Select.d.ts +1 -1
- package/dist/components/forms/Form/Select.js +3 -4
- package/dist/components/forms/Form/index.d.ts +4 -4
- package/dist/components/forms/Form/styles.d.ts +1 -3
- package/dist/components/forms/Form/styles.js +1 -1
- package/dist/components/forms/IconButton.d.ts +2 -2
- package/dist/components/forms/IconButton.js +4 -4
- package/dist/components/forms/NumberInput.d.ts +2 -2
- package/dist/components/forms/styles.d.ts +1 -3
- package/dist/components/layout/Dropdown/styles.d.ts +2 -6
- package/dist/components/layout/Grid/styles.d.ts +1 -3
- package/dist/components/layout/Loading/styles.d.ts +2 -6
- package/dist/components/layout/Modal/styles.d.ts +8 -26
- package/dist/components/search/styles.d.ts +9 -27
- package/dist/components/ui/Card/styles.d.ts +3 -9
- package/dist/components/ui/ContextMenu/styles.d.ts +4 -12
- package/dist/components/ui/Ellipsis.d.ts +0 -1
- package/dist/components/ui/Label.d.ts +2 -2
- package/dist/components/ui/Label.js +4 -4
- package/dist/components/ui/Message/index.js +1 -1
- package/dist/components/ui/Message/styles.d.ts +3 -6
- package/dist/components/ui/Message/styles.js +3 -2
- package/dist/helpers/components.d.ts +1 -2
- package/dist/helpers/components.js +1 -8
- package/dist/helpers/react.d.ts +2 -0
- package/dist/helpers/react.js +8 -0
- package/dist/hooks/useMutableState.d.ts +7 -1
- package/dist/providers/PortalsProvider/styles.d.ts +3 -9
- package/dist/providers/ThemeProvider/helpers.d.ts +1 -1
- package/dist/providers/ThemeProvider/types.d.ts +1 -1
- package/dist/providers/UiProviders/styles.d.ts +1 -3
- package/dist/services/requests/auth.d.ts +4 -4
- package/dist/services/requests/tracking.d.ts +2 -2
- package/dist/services/requests/userProfiles.d.ts +4 -4
- package/dist/services/requests/users.d.ts +8 -8
- package/dist/services/types/auth.d.ts +4 -4
- package/dist/services/types/base.d.ts +1 -1
- package/dist/services/types/base.js +1 -1
- package/dist/services/types/tracking.d.ts +3 -3
- package/dist/services/types/userProfiles.d.ts +5 -5
- package/dist/services/types/users.d.ts +10 -10
- package/dist/types.d.ts +3 -0
- package/dist/types.js +2 -0
- package/package.json +4 -4
- package/src/components/data/DataGrid/DataGridEditableCell/CheckboxEditableCell.tsx +7 -8
- package/src/components/data/DataGrid/DataGridEditableCell/DateEditableCell.tsx +7 -8
- package/src/components/data/DataGrid/DataGridEditableCell/NumberEditableCell.tsx +17 -21
- package/src/components/data/DataGrid/DataGridEditableCell/TextEditableCell.tsx +7 -8
- package/src/components/data/DataGrid/DataGridEditableCell/types.ts +5 -6
- package/src/components/data/DataGrid/helpers/columns.tsx +7 -8
- package/src/components/data/DataGrid/index.tsx +9 -20
- package/src/components/data/SqlRequestDataGrid/helpers/columns.tsx +32 -54
- package/src/components/data/SqlRequestDataGrid/helpers/rows.ts +24 -0
- package/src/components/data/SqlRequestDataGrid/index.tsx +9 -12
- package/src/components/data/SqlRequestForeignList/index.tsx +20 -23
- package/src/components/data/SqlRequestGrid/index.tsx +7 -8
- package/src/components/forms/Form/CustomSelect.tsx +14 -22
- package/src/components/forms/Form/Select.tsx +14 -19
- package/src/components/forms/Form/styles.ts +1 -1
- package/src/components/forms/IconButton.tsx +11 -17
- package/src/components/ui/Ellipsis.tsx +0 -1
- package/src/components/ui/Label.tsx +11 -17
- package/src/components/ui/Message/index.tsx +1 -1
- package/src/components/ui/Message/styles.ts +4 -0
- package/src/helpers/components.ts +1 -15
- package/src/hooks/useMutableState.ts +9 -1
- package/src/providers/ThemeProvider/helpers.ts +1 -1
- package/src/providers/ThemeProvider/types.ts +1 -1
- package/src/services/types/base.ts +1 -1
- package/src/types.ts +8 -0
- package/src/typings.d.ts +0 -15
- package/tsconfig.tsbuildinfo +1 -1
- package/src/components/data/SqlRequestDataGrid/SqlRequestForeignListEditableCell.tsx +0 -16
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
export declare const userDtoSchema: z.ZodObject<{
|
|
3
|
-
id: z.
|
|
3
|
+
id: z.ZodUUID;
|
|
4
4
|
username: z.ZodString;
|
|
5
5
|
permissions: z.ZodArray<z.ZodString>;
|
|
6
6
|
isAdmin: z.ZodBoolean;
|
|
7
7
|
profile: z.ZodNullable<z.ZodObject<{
|
|
8
|
-
id: z.
|
|
8
|
+
id: z.ZodUUID;
|
|
9
9
|
name: z.ZodString;
|
|
10
10
|
permissions: z.ZodArray<z.ZodString>;
|
|
11
11
|
isAdmin: z.ZodBoolean;
|
|
@@ -22,12 +22,12 @@ export declare const getUserRequestDtoSchema: z.ZodObject<{
|
|
|
22
22
|
export declare const getUserResponseDtoSchema: z.ZodObject<{
|
|
23
23
|
status: z.ZodNumber;
|
|
24
24
|
data: z.ZodObject<{
|
|
25
|
-
id: z.
|
|
25
|
+
id: z.ZodUUID;
|
|
26
26
|
username: z.ZodString;
|
|
27
27
|
permissions: z.ZodArray<z.ZodString>;
|
|
28
28
|
isAdmin: z.ZodBoolean;
|
|
29
29
|
profile: z.ZodNullable<z.ZodObject<{
|
|
30
|
-
id: z.
|
|
30
|
+
id: z.ZodUUID;
|
|
31
31
|
name: z.ZodString;
|
|
32
32
|
permissions: z.ZodArray<z.ZodString>;
|
|
33
33
|
isAdmin: z.ZodBoolean;
|
|
@@ -44,12 +44,12 @@ export declare const getAllUsersRequestDtoSchema: z.ZodObject<{}, z.core.$strip>
|
|
|
44
44
|
export declare const getAllUsersResponseDtoSchema: z.ZodObject<{
|
|
45
45
|
status: z.ZodNumber;
|
|
46
46
|
data: z.ZodArray<z.ZodObject<{
|
|
47
|
-
id: z.
|
|
47
|
+
id: z.ZodUUID;
|
|
48
48
|
username: z.ZodString;
|
|
49
49
|
permissions: z.ZodArray<z.ZodString>;
|
|
50
50
|
isAdmin: z.ZodBoolean;
|
|
51
51
|
profile: z.ZodNullable<z.ZodObject<{
|
|
52
|
-
id: z.
|
|
52
|
+
id: z.ZodUUID;
|
|
53
53
|
name: z.ZodString;
|
|
54
54
|
permissions: z.ZodArray<z.ZodString>;
|
|
55
55
|
isAdmin: z.ZodBoolean;
|
|
@@ -64,12 +64,12 @@ export type GetAllUsersResponseDTO = z.infer<typeof getAllUsersResponseDtoSchema
|
|
|
64
64
|
/*****/
|
|
65
65
|
export declare const saveUserRequestDtoSchema: z.ZodObject<{
|
|
66
66
|
data: z.ZodObject<{
|
|
67
|
-
id: z.
|
|
67
|
+
id: z.ZodUUID;
|
|
68
68
|
username: z.ZodString;
|
|
69
69
|
permissions: z.ZodArray<z.ZodString>;
|
|
70
70
|
isAdmin: z.ZodBoolean;
|
|
71
71
|
profile: z.ZodNullable<z.ZodObject<{
|
|
72
|
-
id: z.
|
|
72
|
+
id: z.ZodUUID;
|
|
73
73
|
name: z.ZodString;
|
|
74
74
|
permissions: z.ZodArray<z.ZodString>;
|
|
75
75
|
isAdmin: z.ZodBoolean;
|
|
@@ -84,12 +84,12 @@ export declare const saveUserRequestDtoSchema: z.ZodObject<{
|
|
|
84
84
|
export declare const saveUserResponseDtoSchema: z.ZodObject<{
|
|
85
85
|
status: z.ZodNumber;
|
|
86
86
|
data: z.ZodObject<{
|
|
87
|
-
id: z.
|
|
87
|
+
id: z.ZodUUID;
|
|
88
88
|
username: z.ZodString;
|
|
89
89
|
permissions: z.ZodArray<z.ZodString>;
|
|
90
90
|
isAdmin: z.ZodBoolean;
|
|
91
91
|
profile: z.ZodNullable<z.ZodObject<{
|
|
92
|
-
id: z.
|
|
92
|
+
id: z.ZodUUID;
|
|
93
93
|
name: z.ZodString;
|
|
94
94
|
permissions: z.ZodArray<z.ZodString>;
|
|
95
95
|
isAdmin: z.ZodBoolean;
|
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@addev-be/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"watch": "tsc -b --watch",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"update-version": "../../node/update-version.mjs"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@addev-be/framework-utils": "^
|
|
23
|
+
"@addev-be/framework-utils": "^2.0.0",
|
|
24
24
|
"@types/lodash": "^4.17.20",
|
|
25
|
-
"@types/react": "^
|
|
26
|
-
"@types/react-dom": "^
|
|
25
|
+
"@types/react": "^19.1.13",
|
|
26
|
+
"@types/react-dom": "^19.1.9",
|
|
27
27
|
"@types/uuid": "^11.0.0",
|
|
28
28
|
"@vitejs/plugin-react-swc": "^4.1.0",
|
|
29
29
|
"eslint": "^9.36.0",
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { ForwardedRef, forwardRef, useCallback } from 'react';
|
|
2
|
-
|
|
3
1
|
import { DataGridEditableCellProps } from './types';
|
|
2
|
+
import { useCallback } from 'react';
|
|
4
3
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export const CheckboxEditableCell = <R,>({
|
|
5
|
+
value,
|
|
6
|
+
onChange,
|
|
7
|
+
onClose,
|
|
8
|
+
ref,
|
|
9
|
+
}: DataGridEditableCellProps<R, boolean>) => {
|
|
9
10
|
const onBlur = useCallback(() => {
|
|
10
11
|
onClose(true);
|
|
11
12
|
}, [onClose]);
|
|
@@ -34,5 +35,3 @@ const CheckboxEditableCellInner = <R,>(
|
|
|
34
35
|
/>
|
|
35
36
|
);
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
-
export const CheckboxEditableCell = forwardRef(CheckboxEditableCellInner);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { ForwardedRef, forwardRef, useCallback } from 'react';
|
|
2
|
-
|
|
3
1
|
import { DataGridEditableCellProps } from './types';
|
|
4
2
|
import moment from 'moment';
|
|
3
|
+
import { useCallback } from 'react';
|
|
5
4
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export const DateEditableCell = <R,>({
|
|
6
|
+
value,
|
|
7
|
+
onChange,
|
|
8
|
+
onClose,
|
|
9
|
+
ref,
|
|
10
|
+
}: DataGridEditableCellProps<R, string>) => {
|
|
10
11
|
const onBlur = useCallback(() => {
|
|
11
12
|
onClose(true);
|
|
12
13
|
}, [onClose]);
|
|
@@ -35,5 +36,3 @@ const DateEditableCellInner = <R,>(
|
|
|
35
36
|
/>
|
|
36
37
|
);
|
|
37
38
|
};
|
|
38
|
-
|
|
39
|
-
export const DateEditableCell = forwardRef(DateEditableCellInner);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ForwardedRef, forwardRef, useCallback } from 'react';
|
|
2
1
|
import {
|
|
3
2
|
decimalSeparator,
|
|
4
3
|
getCurrencySymbol,
|
|
@@ -7,25 +6,24 @@ import {
|
|
|
7
6
|
|
|
8
7
|
import { DataGridEditableCellProps } from './types';
|
|
9
8
|
import { NumericFormat } from 'react-number-format';
|
|
9
|
+
import { useCallback } from 'react';
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
ref: ForwardedRef<HTMLElement>
|
|
28
|
-
) => {
|
|
11
|
+
export const NumberEditableCell = <R,>({
|
|
12
|
+
decimals = 0,
|
|
13
|
+
currency,
|
|
14
|
+
prefix: prefixFromProps,
|
|
15
|
+
suffix: suffixFromProps,
|
|
16
|
+
row,
|
|
17
|
+
value,
|
|
18
|
+
onChange,
|
|
19
|
+
onClose,
|
|
20
|
+
ref,
|
|
21
|
+
}: DataGridEditableCellProps<R, number> & {
|
|
22
|
+
decimals?: number;
|
|
23
|
+
currency?: string | ((row: R) => string);
|
|
24
|
+
prefix?: string;
|
|
25
|
+
suffix?: string;
|
|
26
|
+
}) => {
|
|
29
27
|
const currencyName =
|
|
30
28
|
typeof currency === 'function' ? currency(row) : currency;
|
|
31
29
|
|
|
@@ -71,5 +69,3 @@ const NumberEditableCellInner = <R,>(
|
|
|
71
69
|
/>
|
|
72
70
|
);
|
|
73
71
|
};
|
|
74
|
-
|
|
75
|
-
export const NumberEditableCell = forwardRef(NumberEditableCellInner);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { Ref, forwardRef, useCallback } from 'react';
|
|
2
|
-
|
|
3
1
|
import { DataGridEditableCellProps } from './types';
|
|
2
|
+
import { useCallback } from 'react';
|
|
4
3
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export const TextEditableCell = <R,>({
|
|
5
|
+
value,
|
|
6
|
+
onChange,
|
|
7
|
+
onClose,
|
|
8
|
+
ref,
|
|
9
|
+
}: DataGridEditableCellProps<R, string>) => {
|
|
9
10
|
const onBlur = useCallback(() => {
|
|
10
11
|
onClose(true);
|
|
11
12
|
}, [onClose]);
|
|
@@ -34,5 +35,3 @@ const TextEditableCellInner = <R,>(
|
|
|
34
35
|
/>
|
|
35
36
|
);
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
-
export const TextEditableCell = forwardRef(TextEditableCellInner);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { FC, Ref } from 'react';
|
|
4
4
|
|
|
5
5
|
import { DataGridContext } from '../types';
|
|
6
6
|
|
|
@@ -8,12 +8,11 @@ export type DataGridEditableCellProps<R, T> = {
|
|
|
8
8
|
ref?: Ref<any>;
|
|
9
9
|
row: R;
|
|
10
10
|
value: T;
|
|
11
|
-
onChange: (value: T) => void;
|
|
11
|
+
onChange: (value: T | null) => void;
|
|
12
12
|
onClose: (save: boolean) => void;
|
|
13
13
|
context: DataGridContext<R>;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export type DataGridEditableCellFC<R, T = any> =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
) => ReactNode;
|
|
16
|
+
export type DataGridEditableCellFC<R, T = any> = FC<
|
|
17
|
+
DataGridEditableCellProps<R, T>
|
|
18
|
+
>;
|
|
@@ -21,16 +21,15 @@ import {
|
|
|
21
21
|
|
|
22
22
|
import { CheckboxEditableCell } from '../DataGridEditableCell/CheckboxEditableCell';
|
|
23
23
|
import { DateEditableCell } from '../DataGridEditableCell/DateEditableCell';
|
|
24
|
-
import { DeepPartial } from '../../../../
|
|
24
|
+
import { DeepPartial } from '../../../../types';
|
|
25
25
|
import { NumberEditableCell } from '../DataGridEditableCell/NumberEditableCell';
|
|
26
|
-
import { Ref } from 'react';
|
|
27
26
|
import { Select } from '../../../forms/Form/Select';
|
|
28
27
|
import { SqlRequestDataGridTextColumn } from '../../SqlRequestDataGrid/types';
|
|
29
28
|
import { StyledTypography } from '../../../../helpers/styled/typography';
|
|
30
29
|
import { TextEditableCell } from '../DataGridEditableCell/TextEditableCell';
|
|
31
|
-
import { forwardRefWithName } from '../../../../helpers/components';
|
|
32
30
|
import moment from 'moment';
|
|
33
31
|
import { repeat } from 'lodash';
|
|
32
|
+
import { withDisplayName } from '../../../../helpers/components';
|
|
34
33
|
|
|
35
34
|
export const isColumnVisible = <R,>(
|
|
36
35
|
obj: DataGridColumn<R> | DataGridSettings
|
|
@@ -236,13 +235,13 @@ export const numberColumn = <R extends Record<string, any>>(
|
|
|
236
235
|
...numberFilter(key),
|
|
237
236
|
renderer: (value) => formatNumber(value, decimals) ?? '',
|
|
238
237
|
},
|
|
239
|
-
editComponent:
|
|
240
|
-
(
|
|
238
|
+
editComponent: withDisplayName(
|
|
239
|
+
({ ref, ...otherProps }) => (
|
|
241
240
|
<NumberEditableCell<R>
|
|
242
241
|
ref={ref}
|
|
243
242
|
decimals={column.decimals}
|
|
244
243
|
currency={column.currency}
|
|
245
|
-
{...
|
|
244
|
+
{...otherProps}
|
|
246
245
|
/>
|
|
247
246
|
),
|
|
248
247
|
'NumberColumnEditComponent'
|
|
@@ -417,8 +416,8 @@ export const selectColumn = <R extends Record<string, any>, T>(
|
|
|
417
416
|
items,
|
|
418
417
|
itemKey,
|
|
419
418
|
itemLabel,
|
|
420
|
-
editComponent:
|
|
421
|
-
({ value, onChange, onClose
|
|
419
|
+
editComponent: withDisplayName(
|
|
420
|
+
({ value, onChange, onClose, ref }) => (
|
|
422
421
|
<Select<T>
|
|
423
422
|
ref={ref}
|
|
424
423
|
items={items}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import * as styles from './styles';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
Context,
|
|
5
|
-
ForwardedRef,
|
|
6
|
-
forwardRef,
|
|
7
|
-
useImperativeHandle,
|
|
8
|
-
useMemo,
|
|
9
|
-
useRef,
|
|
10
|
-
} from 'react';
|
|
3
|
+
import { Context, useImperativeHandle, useMemo, useRef } from 'react';
|
|
11
4
|
import {
|
|
12
5
|
DEFAULT_COLUMN_WIDTH,
|
|
13
6
|
DEFAULT_ROW_HEIGHT,
|
|
@@ -23,15 +16,13 @@ import { VirtualScroller } from '../VirtualScroller';
|
|
|
23
16
|
import { extractSpaceProps } from '../../../helpers/styled/space';
|
|
24
17
|
import { useDataGrid } from './hooks';
|
|
25
18
|
|
|
26
|
-
export const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
ref: ForwardedRef<DataGridRefProps<R>>
|
|
34
|
-
) => {
|
|
19
|
+
export const DataGrid = <R,>({
|
|
20
|
+
contextOverride,
|
|
21
|
+
...props
|
|
22
|
+
}: DataGridProps<R> & {
|
|
23
|
+
contextOverride?: Partial<DataGridContextProps<R>>;
|
|
24
|
+
ref: React.Ref<DataGridRefProps<R>>;
|
|
25
|
+
}) => {
|
|
35
26
|
const scrollableRef = useRef<HTMLDivElement>(null);
|
|
36
27
|
const { className } = props;
|
|
37
28
|
const spaceProps = extractSpaceProps(props);
|
|
@@ -55,7 +46,7 @@ export const DataGridInner = <R,>(
|
|
|
55
46
|
} = contextProps;
|
|
56
47
|
|
|
57
48
|
useImperativeHandle(
|
|
58
|
-
ref,
|
|
49
|
+
props.ref,
|
|
59
50
|
() => ({
|
|
60
51
|
refresh: refresh ?? (() => {}),
|
|
61
52
|
setSelectedKeys,
|
|
@@ -118,5 +109,3 @@ export const DataGridInner = <R,>(
|
|
|
118
109
|
</DataGridContext.Provider>
|
|
119
110
|
);
|
|
120
111
|
};
|
|
121
|
-
|
|
122
|
-
export const DataGrid = forwardRef(DataGridInner);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
/* eslint-disable react/display-name */
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
2
|
|
|
4
|
-
import { Ref, forwardRef, useContext } from 'react';
|
|
5
3
|
import { SqlImage, SqlImageWrapper } from '../styles';
|
|
6
4
|
import {
|
|
7
5
|
SqlRequestDataGridCheckboxColumn,
|
|
@@ -16,6 +14,7 @@ import {
|
|
|
16
14
|
numberFilter,
|
|
17
15
|
textFilter,
|
|
18
16
|
} from '../../DataGrid/helpers';
|
|
17
|
+
import { convertItemToPartialRow, convertRowToItem } from './rows';
|
|
19
18
|
import { formatDate, formatDateTime } from '../../../../helpers/dates';
|
|
20
19
|
import {
|
|
21
20
|
formatMoney,
|
|
@@ -23,17 +22,18 @@ import {
|
|
|
23
22
|
formatNumberInvariant,
|
|
24
23
|
formatPercentage,
|
|
25
24
|
} from '../../../../helpers/numbers';
|
|
26
|
-
import { mapKeys, merge } from 'lodash';
|
|
27
25
|
|
|
28
26
|
import { CheckboxEditableCell } from '../../DataGrid/DataGridEditableCell/CheckboxEditableCell';
|
|
29
27
|
import { DEFAULT_ROW_HEIGHT } from '../../DataGrid/constants';
|
|
30
28
|
import { DateEditableCell } from '../../DataGrid/DataGridEditableCell/DateEditableCell';
|
|
31
|
-
import { DeepPartial } from '../../../../
|
|
29
|
+
import { DeepPartial } from '../../../../types';
|
|
32
30
|
import { NumberEditableCell } from '../../DataGrid/DataGridEditableCell/NumberEditableCell';
|
|
33
31
|
import { SqlRequestForeignList } from '../../SqlRequestForeignList';
|
|
34
32
|
import { SqlRequestForeignListItemFC } from '../../SqlRequestForeignList/types';
|
|
35
33
|
import { StyledTypography } from '../../../../helpers/styled/typography';
|
|
36
34
|
import { TextEditableCell } from '../../DataGrid/DataGridEditableCell/TextEditableCell';
|
|
35
|
+
import { merge } from 'lodash';
|
|
36
|
+
import { useContext } from 'react';
|
|
37
37
|
|
|
38
38
|
export const sqlTextColumn = <R extends Record<string, any>>(
|
|
39
39
|
key: string,
|
|
@@ -237,16 +237,16 @@ export const sqlNumberColumn = <R extends Record<string, any>>(
|
|
|
237
237
|
max: null,
|
|
238
238
|
min: null,
|
|
239
239
|
},
|
|
240
|
-
editComponent:
|
|
240
|
+
editComponent: ({ ref, ...otherProps }) => (
|
|
241
241
|
<NumberEditableCell<R>
|
|
242
242
|
ref={ref}
|
|
243
243
|
decimals={column.decimals}
|
|
244
244
|
currency={column.currency}
|
|
245
245
|
prefix={column.prefix}
|
|
246
246
|
suffix={column.suffix}
|
|
247
|
-
{...
|
|
247
|
+
{...otherProps}
|
|
248
248
|
/>
|
|
249
|
-
)
|
|
249
|
+
),
|
|
250
250
|
};
|
|
251
251
|
return merge(column, options);
|
|
252
252
|
};
|
|
@@ -301,14 +301,14 @@ export const sqlMoneyColumn = <R extends Record<string, any>>(
|
|
|
301
301
|
max: null,
|
|
302
302
|
min: null,
|
|
303
303
|
},
|
|
304
|
-
editComponent:
|
|
304
|
+
editComponent: ({ ref, ...otherProps }) => (
|
|
305
305
|
<NumberEditableCell<R>
|
|
306
306
|
ref={ref}
|
|
307
307
|
decimals={column.decimals}
|
|
308
308
|
currency={column.currency}
|
|
309
|
-
{...
|
|
309
|
+
{...otherProps}
|
|
310
310
|
/>
|
|
311
|
-
)
|
|
311
|
+
),
|
|
312
312
|
};
|
|
313
313
|
return merge(column, options);
|
|
314
314
|
};
|
|
@@ -339,14 +339,14 @@ export const sqlPercentageColumn = <R extends Record<string, any>>(
|
|
|
339
339
|
getter: (value) => value[key] ?? 0,
|
|
340
340
|
renderer: (value) => formatPercentage(value, decimals) ?? '',
|
|
341
341
|
},
|
|
342
|
-
editComponent:
|
|
342
|
+
editComponent: ({ ref, ...otherProps }) => (
|
|
343
343
|
<NumberEditableCell<R>
|
|
344
344
|
ref={ref}
|
|
345
345
|
decimals={column.decimals}
|
|
346
346
|
currency={column.currency}
|
|
347
|
-
{...
|
|
347
|
+
{...otherProps}
|
|
348
348
|
/>
|
|
349
|
-
)
|
|
349
|
+
),
|
|
350
350
|
};
|
|
351
351
|
return merge(column, options);
|
|
352
352
|
};
|
|
@@ -444,27 +444,6 @@ export const sqlColorColumn = <R extends Record<string, any>>(
|
|
|
444
444
|
options
|
|
445
445
|
);
|
|
446
446
|
|
|
447
|
-
const convertRowToItem = <R extends Record<string, any>, T>(
|
|
448
|
-
row: R,
|
|
449
|
-
columnMapping: Record<string, keyof R>
|
|
450
|
-
) => mapKeys(row, (_, key) => columnMapping[key]) as T;
|
|
451
|
-
|
|
452
|
-
const convertItemToPartialRow = <
|
|
453
|
-
R extends Record<string, any>,
|
|
454
|
-
T extends Record<string, any>
|
|
455
|
-
>(
|
|
456
|
-
key: string,
|
|
457
|
-
row: R,
|
|
458
|
-
item: T | null,
|
|
459
|
-
columnMapping: Record<keyof R, keyof T>
|
|
460
|
-
): Partial<R> => {
|
|
461
|
-
const partialRow = { Id: key } as unknown as Partial<R>;
|
|
462
|
-
Object.entries(columnMapping).forEach(([key, value]: [keyof R, keyof T]) => {
|
|
463
|
-
partialRow[key] = (item?.[value] ?? null) as R[keyof R];
|
|
464
|
-
});
|
|
465
|
-
return partialRow;
|
|
466
|
-
};
|
|
467
|
-
|
|
468
447
|
export const sqlForeignListColumn = <
|
|
469
448
|
R extends Record<string, any>,
|
|
470
449
|
T extends Record<string, any>,
|
|
@@ -499,26 +478,25 @@ export const sqlForeignListColumn = <
|
|
|
499
478
|
idColumn: 'Id',
|
|
500
479
|
itemTemplate: ItemTemplate,
|
|
501
480
|
columns: Object.values(columnMapping),
|
|
502
|
-
editComponent:
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
),
|
|
481
|
+
editComponent: ({ row, onChange, onClose, context, ref }) => {
|
|
482
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
483
|
+
const { rowHeight = DEFAULT_ROW_HEIGHT } = useContext(context);
|
|
484
|
+
return (
|
|
485
|
+
<SqlRequestForeignList<T>
|
|
486
|
+
initialValue={convertRowToItem<R, T>(row, columnMapping)}
|
|
487
|
+
maxRows={10}
|
|
488
|
+
rowHeight={rowHeight - 2}
|
|
489
|
+
onItemChanged={onChange}
|
|
490
|
+
onBlur={() => onClose(true)}
|
|
491
|
+
ref={ref}
|
|
492
|
+
requestName={column.requestName}
|
|
493
|
+
idColumn={column.idColumn}
|
|
494
|
+
columns={column.columns}
|
|
495
|
+
itemTemplate={column.itemTemplate}
|
|
496
|
+
valueTemplate={column.valueTemplate}
|
|
497
|
+
/>
|
|
498
|
+
);
|
|
499
|
+
},
|
|
522
500
|
itemToPartialRow: (key, row, value) =>
|
|
523
501
|
convertItemToPartialRow(key, row, value, columnMapping),
|
|
524
502
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
3
|
+
import { mapKeys } from 'lodash';
|
|
4
|
+
|
|
5
|
+
export const convertRowToItem = <R extends Record<string, any>, T>(
|
|
6
|
+
row: R,
|
|
7
|
+
columnMapping: Record<string, keyof R>
|
|
8
|
+
) => mapKeys(row, (_, key) => columnMapping[key]) as T;
|
|
9
|
+
|
|
10
|
+
export const convertItemToPartialRow = <
|
|
11
|
+
R extends Record<string, any>,
|
|
12
|
+
T extends Record<string, any>
|
|
13
|
+
>(
|
|
14
|
+
key: string,
|
|
15
|
+
row: R,
|
|
16
|
+
item: T | null,
|
|
17
|
+
columnMapping: Record<keyof R, keyof T>
|
|
18
|
+
): Partial<R> => {
|
|
19
|
+
const partialRow = { Id: key } as unknown as Partial<R>;
|
|
20
|
+
Object.entries(columnMapping).forEach(([key, value]: [keyof R, keyof T]) => {
|
|
21
|
+
partialRow[key] = (item?.[value] ?? null) as R[keyof R];
|
|
22
|
+
});
|
|
23
|
+
return partialRow;
|
|
24
|
+
};
|
|
@@ -14,10 +14,9 @@ import {
|
|
|
14
14
|
} from '../DataGrid/types';
|
|
15
15
|
import {
|
|
16
16
|
Dispatch,
|
|
17
|
-
ForwardedRef,
|
|
18
17
|
ReactNode,
|
|
18
|
+
Ref,
|
|
19
19
|
SetStateAction,
|
|
20
|
-
forwardRef,
|
|
21
20
|
useCallback,
|
|
22
21
|
useEffect,
|
|
23
22
|
useImperativeHandle,
|
|
@@ -32,14 +31,14 @@ import { SqlRequestDataGridProps } from './types';
|
|
|
32
31
|
import { convertSqlFiltersToConditions } from './helpers';
|
|
33
32
|
import { isColumnVisible } from '../DataGrid/helpers';
|
|
34
33
|
|
|
35
|
-
export const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
ref
|
|
42
|
-
) => {
|
|
34
|
+
export const SqlRequestDataGrid = <R,>({
|
|
35
|
+
onSelectionChange: onSelectionChangeFromProps,
|
|
36
|
+
rowKey,
|
|
37
|
+
ref,
|
|
38
|
+
...props
|
|
39
|
+
}: SqlRequestDataGridProps<R> & {
|
|
40
|
+
ref?: Ref<DataGridRefProps<R>>;
|
|
41
|
+
}) => {
|
|
43
42
|
const currentRows = useRef<R[]>([]);
|
|
44
43
|
const [rows, setRows] = useState<R[]>([]);
|
|
45
44
|
const setRowsRef = useCallback<Dispatch<SetStateAction<R[]>>>((value) => {
|
|
@@ -416,5 +415,3 @@ export const SqlRequestDataGridInner = <R,>(
|
|
|
416
415
|
/>
|
|
417
416
|
);
|
|
418
417
|
};
|
|
419
|
-
|
|
420
|
-
export const SqlRequestDataGrid = forwardRef(SqlRequestDataGridInner);
|
|
@@ -6,9 +6,8 @@ import {
|
|
|
6
6
|
useSqlRequestHandler,
|
|
7
7
|
} from '../../../services';
|
|
8
8
|
import {
|
|
9
|
-
ForwardedRef,
|
|
10
9
|
MouseEvent,
|
|
11
|
-
|
|
10
|
+
Ref,
|
|
12
11
|
useCallback,
|
|
13
12
|
useEffect,
|
|
14
13
|
useImperativeHandle,
|
|
@@ -79,25 +78,25 @@ const createItemTemplate = <R extends Record<string, any>>(
|
|
|
79
78
|
);
|
|
80
79
|
}, 'SqlRequestForeignListCreateItemTemplate');
|
|
81
80
|
|
|
82
|
-
export const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
ref
|
|
100
|
-
) => {
|
|
81
|
+
export const SqlRequestForeignList = <T extends Record<string, any>>({
|
|
82
|
+
requestName,
|
|
83
|
+
idColumn,
|
|
84
|
+
columns = [],
|
|
85
|
+
initialValue = null,
|
|
86
|
+
onItemChanged,
|
|
87
|
+
onIdChanged,
|
|
88
|
+
onClosed,
|
|
89
|
+
onBlur,
|
|
90
|
+
itemTemplate,
|
|
91
|
+
valueTemplate,
|
|
92
|
+
rowHeight = DEFAULT_ROW_HEIGHT,
|
|
93
|
+
maxRows = 10,
|
|
94
|
+
orderBy = [],
|
|
95
|
+
conditions = [],
|
|
96
|
+
ref,
|
|
97
|
+
}: SqlRequestForeignListProps<T> & {
|
|
98
|
+
ref?: Ref<HTMLDivElement>;
|
|
99
|
+
}) => {
|
|
101
100
|
const [opened, setOpened] = useState(false);
|
|
102
101
|
const [rect, setRect] = useState<DOMRect | null>(null);
|
|
103
102
|
|
|
@@ -253,5 +252,3 @@ export const SqlRequestForeignListInner = <T extends Record<string, any>>(
|
|
|
253
252
|
</>
|
|
254
253
|
);
|
|
255
254
|
};
|
|
256
|
-
|
|
257
|
-
export const SqlRequestForeignList = forwardRef(SqlRequestForeignListInner);
|