@pushwoosh/smart-components-kit 2.6.1 → 2.7.1
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/ExportCSV/ExportCsvBanner/ExportCsvBanner.js +11 -6
- package/ExportCSV/ExportCsvBanner/exportFileName.d.ts +3 -0
- package/ExportCSV/ExportCsvBanner/exportFileName.js +5 -0
- package/Table/components/DataTable/DataTable.js +2 -1
- package/Table/components/DataTable/types.d.ts +3 -0
- package/Table/components/DataTableList/DataTableList.d.ts +1 -1
- package/Table/components/DataTableList/DataTableList.js +5 -30
- package/Table/components/DataTableList/types.d.ts +2 -0
- package/Table/components/TableEmptyState/TableEmptyState.d.ts +7 -0
- package/Table/components/TableEmptyState/TableEmptyState.js +42 -0
- package/Table/components/TableEmptyState/index.d.ts +1 -0
- package/Table/components/TableEmptyState/index.js +1 -0
- package/Table/index.d.ts +1 -0
- package/Table/index.js +1 -0
- package/package.json +3 -3
|
@@ -7,6 +7,7 @@ import { DangerTriangleIcon, DownloadIcon } from '@pushwoosh/kit-icons';
|
|
|
7
7
|
import { Text } from '@pushwoosh/kit-typography';
|
|
8
8
|
import { useLang } from '../polyglot';
|
|
9
9
|
import { useExportService } from '../useExportService';
|
|
10
|
+
import { exportFileName } from './exportFileName';
|
|
10
11
|
import { useExportVisibility } from './hooks/useExportVisibility';
|
|
11
12
|
export const ExportCsvBanner = ({
|
|
12
13
|
exportTask,
|
|
@@ -44,9 +45,12 @@ export const ExportCsvBanner = ({
|
|
|
44
45
|
}, [clearExport, exportTask, getStatus, show]);
|
|
45
46
|
useEffect(() => {
|
|
46
47
|
if (taskResult) {
|
|
47
|
-
|
|
48
|
+
const filename = exportFileName(taskResult);
|
|
49
|
+
updateExportTask(filename ? {
|
|
48
50
|
status: 'STATUS_SUCCESS',
|
|
49
|
-
filename
|
|
51
|
+
filename
|
|
52
|
+
} : {
|
|
53
|
+
status: 'STATUS_FAILED'
|
|
50
54
|
});
|
|
51
55
|
}
|
|
52
56
|
}, [taskResult, updateExportTask]);
|
|
@@ -67,13 +71,14 @@ export const ExportCsvBanner = ({
|
|
|
67
71
|
status,
|
|
68
72
|
args
|
|
69
73
|
} = res[0];
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
const filename = exportFileName(result);
|
|
75
|
+
if (status === 'STATUS_SUCCESS' && !filename) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
73
78
|
updateExportTask({
|
|
74
79
|
id,
|
|
75
80
|
status,
|
|
76
|
-
filename
|
|
81
|
+
filename,
|
|
77
82
|
args,
|
|
78
83
|
progressTitle: lang({
|
|
79
84
|
message: 'SMART.EXPORT_CSV.PROGRESS_TITLE'
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type ResultResponse_result, type TaskInfo_result } from '@pushwoosh/rpc-v2-http-api-data/pushwoosh_export_messages_v2';
|
|
2
|
+
/** File of a finished export task; a running task has no `data` in its result yet. */
|
|
3
|
+
export declare const exportFileName: (result: ResultResponse_result | TaskInfo_result | undefined) => string | undefined;
|
|
@@ -67,7 +67,8 @@ export function DataTable(props) {
|
|
|
67
67
|
children: [renderTableTop?.(context), renderHead(), 'renderList' in props ? props.renderList(context) : _jsx(DataTableList, {
|
|
68
68
|
renderItem: props.renderItem,
|
|
69
69
|
selection: selection,
|
|
70
|
-
expansion: expansion
|
|
70
|
+
expansion: expansion,
|
|
71
|
+
emptyState: props.emptyState
|
|
71
72
|
}), !hidePagination && _jsxs(DataTablePagination, {
|
|
72
73
|
allLimits: allLimits ?? [10, 20, 50, 100],
|
|
73
74
|
padding: paginationPadding,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { DataTableParams, DataTableContextType } from '../../types';
|
|
3
|
+
import type { TableEmptyStateProps } from '../TableEmptyState';
|
|
3
4
|
export type DataTableListProps<I, P extends DataTableParams> = {
|
|
4
5
|
columns: string;
|
|
5
6
|
width?: string | number;
|
|
@@ -49,5 +50,7 @@ export type DataTableItemProps<I, P extends DataTableParams> = {
|
|
|
49
50
|
selection?: DataTableSelection<I>;
|
|
50
51
|
/** Turns on row expansion; ignored while `selection` is set (names go plain), the open rows come back when bulk mode ends. */
|
|
51
52
|
expansion?: DataTableExpansion<I>;
|
|
53
|
+
/** Own title/description for the empty list; the error and no-match states stay generic. */
|
|
54
|
+
emptyState?: TableEmptyStateProps;
|
|
52
55
|
};
|
|
53
56
|
export type DataTableProps<I, P extends DataTableParams> = DataTableListProps<I, P> | DataTableItemProps<I, P>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { DataTableListProps } from './types';
|
|
2
|
-
export declare function DataTableList<T>({ renderItem, selection, expansion }: DataTableListProps<T>): import("react").JSX.Element;
|
|
2
|
+
export declare function DataTableList<T>({ renderItem, selection, expansion, emptyState }: DataTableListProps<T>): import("react").JSX.Element;
|
|
@@ -2,7 +2,6 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { useContext } from 'react';
|
|
3
3
|
import { FontSize, FontWeight } from '@pushwoosh/kit-constants';
|
|
4
4
|
import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
5
|
-
import Box from '../../assets/box.svg?url';
|
|
6
5
|
import Error from '../../assets/error.svg?url';
|
|
7
6
|
import NotFound from '../../assets/notfound.svg?url';
|
|
8
7
|
import { DataTableContext } from '../../context';
|
|
@@ -11,10 +10,12 @@ import { useLang } from '../../polyglot';
|
|
|
11
10
|
import { LockedText } from '../../styles';
|
|
12
11
|
import { Loading } from '../Loading';
|
|
13
12
|
import { SelectableRow } from '../SelectionRow';
|
|
13
|
+
import { TableEmptyState } from '../TableEmptyState';
|
|
14
14
|
export function DataTableList({
|
|
15
15
|
renderItem,
|
|
16
16
|
selection,
|
|
17
|
-
expansion
|
|
17
|
+
expansion,
|
|
18
|
+
emptyState
|
|
18
19
|
}) {
|
|
19
20
|
const {
|
|
20
21
|
data,
|
|
@@ -131,33 +132,7 @@ export function DataTableList({
|
|
|
131
132
|
})]
|
|
132
133
|
})]
|
|
133
134
|
})
|
|
134
|
-
}) : _jsx(
|
|
135
|
-
|
|
136
|
-
"$padding": 64,
|
|
137
|
-
children: _jsxs(Horizontal, {
|
|
138
|
-
"$gap": 16,
|
|
139
|
-
children: [_jsx("img", {
|
|
140
|
-
src: Box,
|
|
141
|
-
alt: lang({
|
|
142
|
-
message: 'SMART.TABLE.EMPTY_IMG_ALT'
|
|
143
|
-
})
|
|
144
|
-
}), _jsxs(Vertical, {
|
|
145
|
-
"$alignContent": "center",
|
|
146
|
-
"$gap": 8,
|
|
147
|
-
children: [_jsx(LockedText, {
|
|
148
|
-
"$fontWeight": FontWeight.MEDIUM,
|
|
149
|
-
"$maxWidth": "250px",
|
|
150
|
-
children: lang({
|
|
151
|
-
message: 'SMART.TABLE.EMPTY_TITLE'
|
|
152
|
-
})
|
|
153
|
-
}), _jsx(LockedText, {
|
|
154
|
-
"$fontSize": FontSize.SMALL,
|
|
155
|
-
"$maxWidth": "250px",
|
|
156
|
-
children: lang({
|
|
157
|
-
message: 'SMART.TABLE.EMPTY_DESCRIPTION'
|
|
158
|
-
})
|
|
159
|
-
})]
|
|
160
|
-
})]
|
|
161
|
-
})
|
|
135
|
+
}) : _jsx(TableEmptyState, {
|
|
136
|
+
...emptyState
|
|
162
137
|
});
|
|
163
138
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { DataTableExpansion, DataTableSelection } from '../DataTable/types';
|
|
3
|
+
import type { TableEmptyStateProps } from '../TableEmptyState';
|
|
3
4
|
export type DataTableListProps<T> = {
|
|
4
5
|
renderItem: (item: T) => ReactNode;
|
|
5
6
|
selection?: DataTableSelection<T>;
|
|
6
7
|
expansion?: DataTableExpansion<T>;
|
|
8
|
+
emptyState?: TableEmptyStateProps;
|
|
7
9
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
export type TableEmptyStateProps = {
|
|
3
|
+
title?: ReactNode;
|
|
4
|
+
description?: ReactNode;
|
|
5
|
+
};
|
|
6
|
+
/** Empty-list placeholder of {@link DataTable}; without props it shows the generic "This list is empty" copy. */
|
|
7
|
+
export declare function TableEmptyState({ title, description }: TableEmptyStateProps): ReactElement;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FontSize, FontWeight } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import Box from '../../assets/box.svg?url';
|
|
5
|
+
import { useLang } from '../../polyglot';
|
|
6
|
+
import { LockedText } from '../../styles';
|
|
7
|
+
/** Empty-list placeholder of {@link DataTable}; without props it shows the generic "This list is empty" copy. */
|
|
8
|
+
export function TableEmptyState({
|
|
9
|
+
title,
|
|
10
|
+
description
|
|
11
|
+
}) {
|
|
12
|
+
const lang = useLang();
|
|
13
|
+
return _jsx(Horizontal, {
|
|
14
|
+
"$placeItems": "center",
|
|
15
|
+
"$padding": 64,
|
|
16
|
+
children: _jsxs(Horizontal, {
|
|
17
|
+
"$gap": 16,
|
|
18
|
+
children: [_jsx("img", {
|
|
19
|
+
src: Box,
|
|
20
|
+
alt: lang({
|
|
21
|
+
message: 'SMART.TABLE.EMPTY_IMG_ALT'
|
|
22
|
+
})
|
|
23
|
+
}), _jsxs(Vertical, {
|
|
24
|
+
"$alignContent": "center",
|
|
25
|
+
"$gap": 8,
|
|
26
|
+
children: [_jsx(LockedText, {
|
|
27
|
+
"$fontWeight": FontWeight.MEDIUM,
|
|
28
|
+
"$maxWidth": "250px",
|
|
29
|
+
children: title ?? lang({
|
|
30
|
+
message: 'SMART.TABLE.EMPTY_TITLE'
|
|
31
|
+
})
|
|
32
|
+
}), _jsx(LockedText, {
|
|
33
|
+
"$fontSize": FontSize.SMALL,
|
|
34
|
+
"$maxWidth": "250px",
|
|
35
|
+
children: description ?? lang({
|
|
36
|
+
message: 'SMART.TABLE.EMPTY_DESCRIPTION'
|
|
37
|
+
})
|
|
38
|
+
})]
|
|
39
|
+
})]
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TableEmptyState, type TableEmptyStateProps } from './TableEmptyState';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TableEmptyState } from './TableEmptyState';
|
package/Table/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { DataTablePagination } from './components/DataTablePagination';
|
|
|
5
5
|
export { DataTableSearchInput } from './components/DataTableSearchInput';
|
|
6
6
|
export { DataTableSortableCell } from './components/DataTableSortableCell';
|
|
7
7
|
export { Loading } from './components/Loading';
|
|
8
|
+
export { TableEmptyState, type TableEmptyStateProps } from './components/TableEmptyState';
|
|
8
9
|
export { TablePagination } from './components/TablePagination';
|
|
9
10
|
export { useDataTableContext, useDataTableGetParams, useBulkSelection, useRowExpansion, type BulkSelection, type BulkSelectionPageCheckbox, type RowExpansion, } from './hooks';
|
|
10
11
|
export { Table, Td, Tr, Th, ElementHover, ItemName, LockedText, Description, } from './styles';
|
package/Table/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { DataTablePagination } from './components/DataTablePagination';
|
|
|
5
5
|
export { DataTableSearchInput } from './components/DataTableSearchInput';
|
|
6
6
|
export { DataTableSortableCell } from './components/DataTableSortableCell';
|
|
7
7
|
export { Loading } from './components/Loading';
|
|
8
|
+
export { TableEmptyState } from './components/TableEmptyState';
|
|
8
9
|
export { TablePagination } from './components/TablePagination';
|
|
9
10
|
export { useDataTableContext, useDataTableGetParams, useBulkSelection, useRowExpansion } from './hooks';
|
|
10
11
|
export { Table, Td, Tr, Th, ElementHover, ItemName, LockedText, Description } from './styles';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/smart-components-kit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"description": "Stateful, data-connected React components shared by Pushwoosh micro-frontends",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"@pushwoosh/kit-helpers": "^4.18.0",
|
|
32
32
|
"@pushwoosh/kit-icons": "^3.0.2",
|
|
33
33
|
"@pushwoosh/kit-typography": "^2.2.0",
|
|
34
|
-
"@pushwoosh/rpc-v2-http-api-data": "^0.2.
|
|
34
|
+
"@pushwoosh/rpc-v2-http-api-data": "^0.2.564",
|
|
35
35
|
"jwt-decode": "^4.0.0",
|
|
36
36
|
"react-hook-form": "^7.91.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@pushwoosh/frontend-builder-engine": "^5.6.0",
|
|
40
|
-
"@pushwoosh/spa-context": "^3.
|
|
40
|
+
"@pushwoosh/spa-context": "^3.13.1",
|
|
41
41
|
"@svgr/webpack": "^8.1.0",
|
|
42
42
|
"@testing-library/dom": "^10.4.2",
|
|
43
43
|
"@testing-library/react": "^16.3.3",
|