@pagopa/selfcare-common-frontend 0.0.4 → 0.0.5
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/README.md +136 -0
- package/build.info +2 -2
- package/index.d.ts +10 -2
- package/index.js +10 -2
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Common components used to build pagopa/selfcare react projects
|
|
2
|
+
## Header
|
|
3
|
+
SelfCare Header component
|
|
4
|
+
|
|
5
|
+
| Prop | Type | Mandatory | Description |
|
|
6
|
+
|------|------|-----------|-------------|
|
|
7
|
+
| withSecondHeader | Y | boolean | if true, it will render an other toolbar under the Header |
|
|
8
|
+
| onExitAction | N | (() => void) | null | The function to be invoked when pressing the rendered logout button, if not defined it will redirect to the logout page, if setted to null it will no render the logout button. It's possible to modify the logout path changing the value in CONFIG.logout inside the index.tsx file |
|
|
9
|
+
| subHeaderChild | N | React.ReactNode | If withSecondHeader is true, this component will be rendered at the end of the secondary toolbar |
|
|
10
|
+
|
|
11
|
+
## Footer
|
|
12
|
+
SelfCare Footer component
|
|
13
|
+
|
|
14
|
+
| Prop | Type | Mandatory | Description |
|
|
15
|
+
|------|------|-----------|-------------|
|
|
16
|
+
| assistanceEmail | string | N | The email to which the assistance button will ask to send an email |
|
|
17
|
+
|
|
18
|
+
## CustomAvatar
|
|
19
|
+
Avatar to use to load Organization logo
|
|
20
|
+
|
|
21
|
+
| Prop | Type | Mandatory | Description |
|
|
22
|
+
|------|------|-----------|-------------|
|
|
23
|
+
| id | string | N | The id attribute added to the element |
|
|
24
|
+
| customSrc | string | N | The logo src |
|
|
25
|
+
| customAlt | string | N | The alt text showed instead of the image |
|
|
26
|
+
| customWidth | string | N | Logo width |
|
|
27
|
+
| customHeight | string | N | Logo height |
|
|
28
|
+
| loading | boolean | N | If true it will not display the component |
|
|
29
|
+
|
|
30
|
+
## CustomPagination
|
|
31
|
+
Selfcare custom table available pages component
|
|
32
|
+
|
|
33
|
+
| Prop | Type | Mandatory | Description |
|
|
34
|
+
|------|------|-----------|-------------|
|
|
35
|
+
| page | Page | Y | The actual page |
|
|
36
|
+
| sort | string | N | The actual sort applied |
|
|
37
|
+
| onPageRequest | (r: PageRequest) => void | Y | The function to be invoked if the user change page |
|
|
38
|
+
|
|
39
|
+
## FilterModal
|
|
40
|
+
Modal used to show a list of values from which to choose a single value
|
|
41
|
+
|
|
42
|
+
| Prop | Type | Mandatory | Description |
|
|
43
|
+
|------|------|-----------|-------------|
|
|
44
|
+
| open | boolean | Y | If the popup is to be displayed |
|
|
45
|
+
| handleClose | React.MouseEventHandler<HTMLButtonElement> | Y | The function to be invoked when clicking on exit button or selecting a value |
|
|
46
|
+
| title | string | Y | The popup title |
|
|
47
|
+
| filterModalConfig | FilterModalConfig<any, any> | N | See below |
|
|
48
|
+
| height | string | N | The popup height |
|
|
49
|
+
| minHeight | string | N | The popup minHeight |
|
|
50
|
+
|
|
51
|
+
FilterModalConfig fields:
|
|
52
|
+
| Field | Type | Mandatory | Description |
|
|
53
|
+
|-------|------|-----------|-------------|
|
|
54
|
+
| data | Array<T> | Y | The list of values between to which choose |
|
|
55
|
+
| getLabel | (e: T) => string | Y | A function that will select the label to show |
|
|
56
|
+
| getValue | (e: T) => V | Y | A function that will select the value to return when selecting an item |
|
|
57
|
+
| onFilterChange | (v: V) => void | Y | The function invoked when selecting a value |
|
|
58
|
+
|
|
59
|
+
## SessionModal
|
|
60
|
+
Selfcare's popup
|
|
61
|
+
|
|
62
|
+
| Prop | Type | Mandatory | Description |
|
|
63
|
+
|------|------|-----------|-------------|
|
|
64
|
+
| open | boolean | Y | If this component should be displayed or not |
|
|
65
|
+
| title | string | Y | The title to show in the popup |
|
|
66
|
+
| message | React.ReactNode | Y | The body to show in the popup |
|
|
67
|
+
| onConfirm | React.MouseEventHandler<HTMLButtonElement> | N | If defined, it will render a confirm button using this function as behavior |
|
|
68
|
+
| onConfirmLabel | string | N | The confirm label text |
|
|
69
|
+
| handleClose | React.MouseEventHandler<HTMLButtonElement> | Y | The function invoked when clicking on close button or in the showed X icon |
|
|
70
|
+
| handleExit | React.MouseEventHandler<HTMLButtonElement> | N | If defined, it allow to set a different behavior when clicking on X icon |
|
|
71
|
+
| onCloseLabel | string | N | Close button text |
|
|
72
|
+
| height | string | N | The popup height |
|
|
73
|
+
| minHeight | string | N | The popup minHeight |
|
|
74
|
+
| width | string | N | The popup width |
|
|
75
|
+
|
|
76
|
+
## TitleBox
|
|
77
|
+
Selfcare's page title
|
|
78
|
+
|
|
79
|
+
| Prop | Type | Mandatory | Description |
|
|
80
|
+
|------|------|-----------|-------------|
|
|
81
|
+
| title | string | Y | The title to show |
|
|
82
|
+
| subTitle | string | N | The subtitle to show |
|
|
83
|
+
| mbTitle | GridSize | N | The margin bottom of the title |
|
|
84
|
+
| mtGrid | number | N | The margin top of the title |
|
|
85
|
+
| mbSubTitle | number | N | The margin bottom of the subtitle |
|
|
86
|
+
| variantTitle | Variant | N | The variant of the Typografy used for the title |
|
|
87
|
+
| variantSubTitle | Variant | N | The variant of the Typografy used for the subtitle |
|
|
88
|
+
|
|
89
|
+
## Toast
|
|
90
|
+
Selfcare's toast
|
|
91
|
+
|
|
92
|
+
| Prop | Type | Mandatory | Description |
|
|
93
|
+
|------|------|-----------|-------------|
|
|
94
|
+
| title | string | Y | The toast title |
|
|
95
|
+
| message | React.ReactNode | Y | The toast body |
|
|
96
|
+
| closeToast | React.MouseEventHandler<HTMLButtonElement> | Y | The function to be invoked when closing the toast |
|
|
97
|
+
|
|
98
|
+
# Common decorators used in pagopa/selfcare react projects
|
|
99
|
+
## withLogin
|
|
100
|
+
This feature is based on react-redux library and require to register the reducer build in userSlice into the application's redux store.
|
|
101
|
+
This decorator has to be applied to components whose acces require an active session.
|
|
102
|
+
Accessing to the components decorated with it without a session will brought to the login page.
|
|
103
|
+
It's possible to modify the login path changing the value in CONFIG.login inside the index.tsx file
|
|
104
|
+
|
|
105
|
+
# Common features used in pagopa/selfcare react projects
|
|
106
|
+
## LoadingOverlay
|
|
107
|
+
This feature is based on react-redux library and require to register the reducer build in appStateSlice into the application's redux store.
|
|
108
|
+
It allows to draw a loader when an async task to wait is running.
|
|
109
|
+
|
|
110
|
+
To use this feature you have to put LoadingOverlay in your App as a child of a redux Provider component.
|
|
111
|
+
In order to register the start of an async task you have to use the custom hook useLoading passing the id of the task to await, which will return a setter function used to start and end the loading behavior.
|
|
112
|
+
|
|
113
|
+
## ErrorBoundary
|
|
114
|
+
This feature is based on react-redux library and require to register the reducer build in appStateSlice into the application's redux store.
|
|
115
|
+
It allows to dispatch errors in order to display a warning or the error page to the user.
|
|
116
|
+
Errors dispatched will be notified using errorService
|
|
117
|
+
|
|
118
|
+
To use this feature you have to put ErrorBOundary in your App as a child of a redux Provider component.
|
|
119
|
+
In order to dispatch an error you have to use the custom hook useErrorDispatcher which will return a fuction to be used to dispatch the error.
|
|
120
|
+
|
|
121
|
+
The error to be submitted has type AppError which has the following fields:
|
|
122
|
+
|
|
123
|
+
| Field | Type | Mandatory | Description |
|
|
124
|
+
|-------|------|-----------|-------------|
|
|
125
|
+
| id | string | Y | The identifier used to recognize the error: it cannot be possible to have the same error id at the same time |
|
|
126
|
+
| error | Error | Y | The Error thrown |
|
|
127
|
+
| errorInfo | ErrorInfo | N | |
|
|
128
|
+
| blocking | boolean | Y | If true, this error will show the error page, not allowing the user to do anything, otherwise it will show a closable popup |
|
|
129
|
+
| techDescription | string | Y | A description of the error to send when notifying the error |
|
|
130
|
+
| displayableTitle | string | N | A text to show as title of the popup when a not blocking error occurs |
|
|
131
|
+
| displayableDescription | string | N | A text to show as body of the popup when a not blocking error occurs |
|
|
132
|
+
| onRetry | () => void | N | If defined, in case of not blocking error, it will render a retry button which will execute this function |
|
|
133
|
+
| onClose | () => void | N | If defined, in case of not blocking error, it will be executed when closing the popup |
|
|
134
|
+
| toNotify | boolean | Y | If true, it will notify the error |
|
|
135
|
+
|
|
136
|
+
ASIS the notify consists just on the console.error invocation
|
package/build.info
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
20220119.
|
|
2
|
-
tags/v0.0.
|
|
1
|
+
20220119.6 - selfcare-common-frontend.deploy(17190)
|
|
2
|
+
tags/v0.0.5^0 930c8a6a4973ded1701d2842995282f893e56aba
|
package/index.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export * from './components/Header/Header';
|
|
2
|
+
export * from './components/Footer/Footer';
|
|
3
|
+
export * from './components/CustomAvatar';
|
|
4
|
+
export * from './components/CustomPagination';
|
|
5
|
+
export * from './components/FilterModal';
|
|
6
|
+
export * from './components/SessionModal';
|
|
7
|
+
export * from './components/TitleBox';
|
|
8
|
+
export * from './components/Toast';
|
|
9
|
+
export * from './components/ErrorBoundary/ErrorBoundary';
|
|
10
|
+
export * from './components/Loading/LoadingOverlay';
|
package/index.js
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export * from './components/Header/Header';
|
|
2
|
+
export * from './components/Footer/Footer';
|
|
3
|
+
export * from './components/CustomAvatar';
|
|
4
|
+
export * from './components/CustomPagination';
|
|
5
|
+
export * from './components/FilterModal';
|
|
6
|
+
export * from './components/SessionModal';
|
|
7
|
+
export * from './components/TitleBox';
|
|
8
|
+
export * from './components/Toast';
|
|
9
|
+
export * from './components/ErrorBoundary/ErrorBoundary';
|
|
10
|
+
export * from './components/Loading/LoadingOverlay';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagopa/selfcare-common-frontend",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"build": "yarn setTsConfigStart && react-scripts build",
|
|
53
53
|
"clean:build": "rimraf build",
|
|
54
54
|
"setTsConfigDist": "copyfiles tsconfigDist.json build && renamer --replace tsconfig.json build/tsconfigDist.json && copyfiles -u 1 build/tsconfig.json . && rimraf build/tsconfig.json",
|
|
55
|
-
"cpDistStatic": "copyfiles -u 2 src/lib/assets/** dist && copyfiles -u 2 src/lib/index.css dist && copyfiles package.json dist",
|
|
55
|
+
"cpDistStatic": "copyfiles -u 2 src/lib/assets/** dist && copyfiles -u 2 src/lib/index.css dist && copyfiles package.json README.md dist",
|
|
56
56
|
"dist": "yarn setTsConfigDist && tsc && yarn cpDistStatic",
|
|
57
57
|
"clean:dist": "rimraf dist",
|
|
58
58
|
"test": "yarn setTsConfigStart && react-scripts test --testPathIgnorePatterns src/lib/redux/__tests__/store -i",
|