@campxdev/react-blueprint 1.6.4 → 1.6.6
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/.storybook/preview.tsx +1 -2
- package/package.json +1 -1
- package/src/App.tsx +71 -46
- package/src/components/Assets/Icons/IconComponents/PrinterIcon.tsx +42 -0
- package/src/components/Assets/Icons/Icons.tsx +2 -0
- package/src/components/DataDisplay/ActivityLogView/ActivityLogView.tsx +228 -0
- package/src/components/DataDisplay/ActivityLogView/Icons.tsx +65 -0
- package/src/components/DataDisplay/ActivityLogView/service.tsx +101 -0
- package/src/components/DataDisplay/ActivityLogView/styles.tsx +52 -0
- package/src/components/DataDisplay/Card/Card.tsx +1 -1
- package/src/components/DataDisplay/DataTable/TablePagination.tsx +4 -0
- package/src/components/DataDisplay/EditableDataTable/EditableDataTable.tsx +32 -21
- package/src/components/DataDisplay/export.ts +1 -0
- package/src/components/Feedback/Tooltip/ToolTipContent.tsx +15 -0
- package/src/components/Feedback/Tooltip/Tooltip.tsx +3 -17
- package/src/components/Feedback/export.ts +1 -0
- package/src/components/Input/SingleSelect/SingleSelect.tsx +22 -5
- package/src/components/Layout/PageHeader/PageHeader.tsx +52 -42
- package/src/components/Layout/PageHeader/components/DensitySelector/DensitySelector.tsx +2 -2
- package/src/components/Layout/PageHeader/components/SearchBar.tsx +66 -0
- package/src/components/Layout/PageHeader/components/TableColumnsSelector/TableColumnsSelector.tsx +14 -4
- package/src/components/Navigation/ConfirmDialog/ConfirmDialog.tsx +2 -2
- package/src/hooks/usePageHeader.ts +51 -12
- package/src/redux/slices/pageHeaderSlice.ts +71 -9
- package/src/stories/DataDisplay/ActivityLogView.stories.tsx +96 -0
- package/src/stories/Feedback/Tooltip.stories.tsx +2 -6
- package/src/stories/Input/TextField.stories.tsx +2 -2
|
@@ -1,33 +1,95 @@
|
|
|
1
1
|
import { GridColumnVisibilityModel, GridDensity } from '@mui/x-data-grid';
|
|
2
2
|
import { createSlice } from '@reduxjs/toolkit';
|
|
3
3
|
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export type PageHeaderSingleState = {
|
|
5
|
+
density: GridDensity;
|
|
6
|
+
columnVisibilityModel: GridColumnVisibilityModel;
|
|
7
|
+
filters: {
|
|
8
|
+
search?: string;
|
|
9
|
+
limit: number;
|
|
10
|
+
offset: number;
|
|
11
|
+
skip: number;
|
|
12
|
+
[x: string]: any;
|
|
8
13
|
};
|
|
9
14
|
};
|
|
10
15
|
|
|
16
|
+
export type PageHeaderState = {
|
|
17
|
+
[uniqueId: string]: PageHeaderSingleState;
|
|
18
|
+
};
|
|
19
|
+
|
|
11
20
|
const initialState: PageHeaderState = {};
|
|
12
21
|
|
|
13
22
|
export const pageHeaderSlice = createSlice({
|
|
14
23
|
name: 'pageHeader',
|
|
15
24
|
initialState,
|
|
16
25
|
reducers: {
|
|
17
|
-
|
|
26
|
+
setColumnVisibilityModelForUniqueId: (state, action) => {
|
|
18
27
|
const { uniqueId, columnVisibilityModel } = action.payload;
|
|
19
28
|
state[uniqueId] = { ...state[uniqueId], columnVisibilityModel };
|
|
20
29
|
},
|
|
21
|
-
|
|
30
|
+
setDensityForUniqueId: (state, action) => {
|
|
22
31
|
const { uniqueId, density } = action.payload;
|
|
23
32
|
state[uniqueId] = { ...state[uniqueId], density };
|
|
24
33
|
},
|
|
34
|
+
setSearchForUniqueId: (state, action) => {
|
|
35
|
+
const { uniqueId, search } = action.payload;
|
|
36
|
+
state[uniqueId] = {
|
|
37
|
+
...state[uniqueId],
|
|
38
|
+
filters: {
|
|
39
|
+
...state[uniqueId]?.filters,
|
|
40
|
+
search: search,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
},
|
|
25
44
|
resetStateForUniqueId: (state, action) => {
|
|
26
45
|
const { uniqueId } = action.payload;
|
|
27
|
-
state[uniqueId] = {
|
|
46
|
+
state[uniqueId] = {
|
|
47
|
+
density: 'standard',
|
|
48
|
+
columnVisibilityModel: {},
|
|
49
|
+
filters: {
|
|
50
|
+
limit: 10,
|
|
51
|
+
offset: 0,
|
|
52
|
+
skip: 0,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
setLimitForUniqueId: (state, action) => {
|
|
57
|
+
const { uniqueId, limit } = action.payload;
|
|
58
|
+
state[uniqueId] = {
|
|
59
|
+
...state[uniqueId],
|
|
60
|
+
filters: {
|
|
61
|
+
...state[uniqueId].filters,
|
|
62
|
+
limit: limit,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
setOffsetForUniqueId: (state, action) => {
|
|
67
|
+
const { uniqueId, offset } = action.payload;
|
|
68
|
+
state[uniqueId] = {
|
|
69
|
+
...state[uniqueId],
|
|
70
|
+
filters: {
|
|
71
|
+
...state[uniqueId].filters,
|
|
72
|
+
offset: offset,
|
|
73
|
+
skip: offset,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
setDefaultFiltersForUniqueId: (state, action) => {
|
|
78
|
+
const { uniqueId, defaultFilters } = action.payload;
|
|
79
|
+
state[uniqueId] = {
|
|
80
|
+
...state[uniqueId],
|
|
81
|
+
filters: defaultFilters,
|
|
82
|
+
};
|
|
28
83
|
},
|
|
29
84
|
},
|
|
30
85
|
});
|
|
31
86
|
|
|
32
|
-
export const {
|
|
33
|
-
|
|
87
|
+
export const {
|
|
88
|
+
setColumnVisibilityModelForUniqueId,
|
|
89
|
+
setDensityForUniqueId,
|
|
90
|
+
resetStateForUniqueId,
|
|
91
|
+
setSearchForUniqueId,
|
|
92
|
+
setDefaultFiltersForUniqueId,
|
|
93
|
+
setLimitForUniqueId,
|
|
94
|
+
setOffsetForUniqueId,
|
|
95
|
+
} = pageHeaderSlice.actions;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { LocalizationProvider } from '@mui/x-date-pickers';
|
|
2
|
+
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFnsV3';
|
|
3
|
+
import { action } from '@storybook/addon-actions';
|
|
4
|
+
import { Meta, StoryObj } from '@storybook/react/*';
|
|
5
|
+
import { Activity, ActivityLogView } from '../../components/export';
|
|
6
|
+
|
|
7
|
+
// Mock data for the story with diverse timestamps and actions
|
|
8
|
+
const activitiesData: Activity[] = [
|
|
9
|
+
{
|
|
10
|
+
userName: 'John Doe',
|
|
11
|
+
action: 'create',
|
|
12
|
+
message: "created 'Student Registration'",
|
|
13
|
+
timestamp: new Date().toISOString(), // Today
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
userName: 'Jane Smith',
|
|
17
|
+
action: 'update',
|
|
18
|
+
message: `updated 'Employee Record'
|
|
19
|
+
• 'Position' has been changed from 'Junior Developer' to 'Senior Developer'
|
|
20
|
+
• 'Salary' has been changed from '$50,000' to '$70,000'
|
|
21
|
+
• 'Department' has been changed from 'IT Support' to 'Software Development'
|
|
22
|
+
• 'Supervisor' has been changed from 'Mr. Adams' to 'Ms. Johnson'
|
|
23
|
+
• 'Work Hours' have been changed from '40' to '45'`,
|
|
24
|
+
timestamp: new Date(Date.now() - 2 * 24 * 60 * 60 * 1000).toISOString(), // 2 days ago (Past Week)
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
userName: 'Admin',
|
|
28
|
+
action: 'delete',
|
|
29
|
+
message: "deleted 'Annual Report'",
|
|
30
|
+
timestamp: new Date(Date.now() - 10 * 24 * 60 * 60 * 1000).toISOString(), // 10 days ago (Older)
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
userName: 'Alice Johnson',
|
|
34
|
+
action: 'create',
|
|
35
|
+
message: "created 'Course Outline'",
|
|
36
|
+
timestamp: new Date(Date.now() - 5 * 24 * 60 * 60 * 1000).toISOString(), // 5 days ago (Past Week)
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
userName: 'Bob Brown',
|
|
40
|
+
action: 'update',
|
|
41
|
+
message: `updated 'Project Details'
|
|
42
|
+
• 'Project Name' has been changed from 'Website Revamp' to 'Mobile App Launch'
|
|
43
|
+
• 'Deadline' has been changed from 'June 2023' to 'August 2023'
|
|
44
|
+
• 'Team Members' have been changed from '5' to '8'
|
|
45
|
+
• 'Budget' has been changed from '$20,000' to '$35,000'
|
|
46
|
+
• 'Client Contact' has been changed from 'Mr. Lee' to 'Mrs. Gomez'`,
|
|
47
|
+
timestamp: new Date(Date.now() - 1 * 24 * 60 * 60 * 1000).toISOString(), // Yesterday (Past Week)
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
userName: 'Charlie Green',
|
|
51
|
+
action: 'delete',
|
|
52
|
+
message: "deleted 'Temporary Files'",
|
|
53
|
+
timestamp: new Date(Date.now() - 15 * 24 * 60 * 60 * 1000).toISOString(), // 15 days ago (Older)
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
userName: 'Emily White',
|
|
57
|
+
action: 'update',
|
|
58
|
+
message: `updated 'Client Information'
|
|
59
|
+
• 'Client Name' has been changed from 'Acme Corp' to 'Globex Inc.'
|
|
60
|
+
• 'Contact Number' has been changed from '123-456-7890' to '987-654-3210'
|
|
61
|
+
• 'Address' has been changed from '123 Main St' to '456 Elm St'
|
|
62
|
+
• 'Email' has been changed from 'info@acme.com' to 'contact@globex.com'
|
|
63
|
+
• 'Account Manager' has been changed from 'John Smith' to 'Laura Adams'`,
|
|
64
|
+
timestamp: new Date(Date.now() - 3 * 24 * 60 * 60 * 1000).toISOString(), // 3 days ago (Past Week)
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
const meta: Meta<typeof ActivityLogView> = {
|
|
69
|
+
title: 'DataDisplay/ActivityLog',
|
|
70
|
+
component: ActivityLogView,
|
|
71
|
+
decorators: [
|
|
72
|
+
(Story) => (
|
|
73
|
+
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
|
74
|
+
<Story />
|
|
75
|
+
</LocalizationProvider>
|
|
76
|
+
),
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export default meta;
|
|
81
|
+
|
|
82
|
+
type Story = StoryObj<typeof ActivityLogView>;
|
|
83
|
+
|
|
84
|
+
export const Default: Story = {
|
|
85
|
+
args: {
|
|
86
|
+
activitiesData,
|
|
87
|
+
isFetchingNextPage: false,
|
|
88
|
+
fetchNextPage: action('fetchNextPage'),
|
|
89
|
+
hasNextPage: true,
|
|
90
|
+
fromDate: null,
|
|
91
|
+
toDate: null,
|
|
92
|
+
setFromDate: action('setFromDate'),
|
|
93
|
+
setToDate: action('setToDate'),
|
|
94
|
+
isLoading: false,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
Icons,
|
|
5
|
-
Tooltip,
|
|
6
|
-
ToolTipContent,
|
|
7
|
-
} from '../../components/export';
|
|
2
|
+
import { Button, Icons, Tooltip } from '../../components/export';
|
|
3
|
+
import { ToolTipContent } from '../../components/Feedback/Tooltip/ToolTipContent';
|
|
8
4
|
|
|
9
5
|
export default {
|
|
10
6
|
title: 'Feedback/Tooltip',
|
|
@@ -5,8 +5,8 @@ import { Meta } from '@storybook/react';
|
|
|
5
5
|
import { InputAdornment as MuiInputAdornment } from '@mui/material';
|
|
6
6
|
import { Icons } from '../../components/Assets/Icons/Icons';
|
|
7
7
|
|
|
8
|
-
import { TextField, TextFieldProps, Tooltip
|
|
9
|
-
|
|
8
|
+
import { TextField, TextFieldProps, Tooltip } from '../../components/export';
|
|
9
|
+
import { ToolTipContent } from '../../components/Feedback/Tooltip/ToolTipContent';
|
|
10
10
|
|
|
11
11
|
// Define the default export with Meta type including the component type
|
|
12
12
|
export default {
|