@attabot/complaint-app 1.0.10 → 1.0.11
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 +159 -159
- package/dist/complaint-app.js +4415 -2950
- package/dist/complaint-app.js.map +1 -1
- package/dist/complaint-app.umd.js +9 -9
- package/dist/complaint-app.umd.js.map +1 -1
- package/dist/index.d.ts +217 -217
- package/dist/style.css +1 -1
- package/package.json +65 -65
package/README.md
CHANGED
|
@@ -1,159 +1,159 @@
|
|
|
1
|
-
# @attabot/complaint-app
|
|
2
|
-
|
|
3
|
-
Complaint Management UI as an npm package. Built with **atomic design** (atoms → molecules → organisms) so the parent app can mount a ready dashboard that uses the **parent’s auth token and API base URL**.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @attabot/complaint-app
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Peer dependencies:
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm install react react-dom react-redux @reduxjs/toolkit
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Usage
|
|
18
|
-
|
|
19
|
-
```jsx
|
|
20
|
-
import ComplaintApp from '@attabot/complaint-app';
|
|
21
|
-
import '@attabot/complaint-app/style.css';
|
|
22
|
-
import brandTheme from './brandTheme.json'; // static theme file
|
|
23
|
-
|
|
24
|
-
function App() {
|
|
25
|
-
const [darkMode, setDarkMode] = useState(false); // owned by parent
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<ComplaintApp
|
|
29
|
-
apiUrl="https://your-api.example.com"
|
|
30
|
-
authToken={sessionToken}
|
|
31
|
-
theme={brandTheme}
|
|
32
|
-
darkMode={darkMode}
|
|
33
|
-
systemsEndpoint="/api/v1/complaint-systems"
|
|
34
|
-
onCreateForm={() => navigate('/forms/new')}
|
|
35
|
-
onConfigure={(system) => navigate(`/systems/${system.id}`)}
|
|
36
|
-
/>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Theme & dark mode (parent-controlled)
|
|
42
|
-
|
|
43
|
-
Pass a static theme file (JSON/JS) and toggle `darkMode` from the parent. The package applies CSS variables across the whole UI.
|
|
44
|
-
|
|
45
|
-
```jsx
|
|
46
|
-
import brandTheme from './brandTheme.json';
|
|
47
|
-
|
|
48
|
-
<ComplaintApp theme={brandTheme} darkMode={isDark} />
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Theme file shape:
|
|
52
|
-
|
|
53
|
-
```json
|
|
54
|
-
{
|
|
55
|
-
"light": { "colors": { "primary": "#2D64B8", "background": "#F5F5F5" } },
|
|
56
|
-
"dark": { "colors": { "primary": "#5B8DEF", "background": "#0F1115" } }
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Or pass flat overrides (merged into both modes):
|
|
61
|
-
|
|
62
|
-
```jsx
|
|
63
|
-
<ComplaintApp theme={{ colors: { primary: '#0F766E' } }} darkMode={false} />
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Helpers / defaults are exported: `lightTheme`, `darkTheme`, `defaultThemeFile`, `useTheme`.
|
|
67
|
-
|
|
68
|
-
### Pass data from the parent (no fetch)
|
|
69
|
-
|
|
70
|
-
```jsx
|
|
71
|
-
<ComplaintApp
|
|
72
|
-
apiUrl={apiUrl}
|
|
73
|
-
authToken={authToken}
|
|
74
|
-
useDemoData={false}
|
|
75
|
-
systems={[
|
|
76
|
-
{
|
|
77
|
-
id: 'qms',
|
|
78
|
-
title: 'QMS - Query Management System',
|
|
79
|
-
status: 'active',
|
|
80
|
-
description: 'Description of the template',
|
|
81
|
-
departments: 3,
|
|
82
|
-
workflows: 12,
|
|
83
|
-
fields: 55,
|
|
84
|
-
formsFilled: 234,
|
|
85
|
-
updatedOn: '12 Mar 2024',
|
|
86
|
-
titleAsLink: true,
|
|
87
|
-
},
|
|
88
|
-
]}
|
|
89
|
-
onCreateForm={handleCreate}
|
|
90
|
-
onConfigure={handleConfigure}
|
|
91
|
-
/>
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## Props
|
|
95
|
-
|
|
96
|
-
| Prop | Type | Default | Description |
|
|
97
|
-
|------|------|---------|-------------|
|
|
98
|
-
| `apiUrl` | `string` | env `VITE_API_URL` | Base URL for axios requests |
|
|
99
|
-
| `authToken` | `string` | — | Bearer token stored for API calls |
|
|
100
|
-
| `theme` | `object` | built-in light/dark | Static theme file or token overrides |
|
|
101
|
-
| `darkMode` | `boolean` | `false` | Parent-controlled dark mode |
|
|
102
|
-
| `basePath` | `string` | `'/'` | React Router basename when nested |
|
|
103
|
-
| `systems` | `array` | — | Parent-controlled system list |
|
|
104
|
-
| `systemsEndpoint` | `string` | — | GET path relative to `apiUrl` |
|
|
105
|
-
| `useDemoData` | `boolean` | `true` | Show design demo cards when no data |
|
|
106
|
-
| `title` | `string` | `'Complaint Management'` | Page title |
|
|
107
|
-
| `description` | `string` | lorem placeholder | Page subtitle |
|
|
108
|
-
| `createLabel` | `string` | `'Create New Form'` | Primary CTA label |
|
|
109
|
-
| `onCreateForm` | `fn` | — | Create button handler |
|
|
110
|
-
| `onConfigure` | `fn(system)` | — | Configure button handler |
|
|
111
|
-
| `onTitleClick` | `fn(system)` | — | Title link click |
|
|
112
|
-
| `onDescriptionClick` | `fn` | — | Description link click |
|
|
113
|
-
| `onSearch` | `fn(query)` | — | Search change callback |
|
|
114
|
-
| `onPublish` | `fn` | — | Review & Publish handler |
|
|
115
|
-
| `onStepChange` | `fn` | — | Settings step change callback |
|
|
116
|
-
|
|
117
|
-
## Atomic structure
|
|
118
|
-
|
|
119
|
-
```
|
|
120
|
-
src/components/
|
|
121
|
-
atoms/ Button, Input, Typography, StatusBadge, Divider, Icons, Loading
|
|
122
|
-
molecules/ SearchBar, DataPoint, CardHeader, CardFooter
|
|
123
|
-
organisms/ PageHeader, SystemCard, SystemCardGrid
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
Named exports are available for reuse in the parent:
|
|
127
|
-
|
|
128
|
-
```jsx
|
|
129
|
-
import { Button, SearchBar, SystemCard, api } from '@attabot/complaint-app';
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
## Auth & API
|
|
133
|
-
|
|
134
|
-
1. Parent passes `apiUrl` + `authToken` into `ComplaintApp` / `ApiProvider`.
|
|
135
|
-
2. Package axios client (`api`) keeps the passed token in memory and attaches `Authorization: Bearer …` immediately before every request. It does not overwrite the parent app's auth cookie.
|
|
136
|
-
3. Optional token refresh against `POST /api/v1/auth/refresh` when a `refreshToken` cookie exists.
|
|
137
|
-
4. No product/business APIs are hardcoded — provide `systems` or `systemsEndpoint`.
|
|
138
|
-
|
|
139
|
-
## Redux and router integration
|
|
140
|
-
|
|
141
|
-
When mounted inside a parent `react-redux` Provider, `ComplaintApp` automatically
|
|
142
|
-
reuses that Provider instead of adding a second competing Redux context. When used
|
|
143
|
-
standalone it falls back to its own store. Pass the `store` prop only when you
|
|
144
|
-
explicitly want an isolated store.
|
|
145
|
-
|
|
146
|
-
The same rule applies to React Router: an existing parent router is reused; a
|
|
147
|
-
`BrowserRouter` is only created for standalone use.
|
|
148
|
-
|
|
149
|
-
## Development
|
|
150
|
-
|
|
151
|
-
```bash
|
|
152
|
-
npm install
|
|
153
|
-
npm run dev # preview Complaint Management UI
|
|
154
|
-
npm run build # emit dist/ for publishing
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## License
|
|
158
|
-
|
|
159
|
-
MIT
|
|
1
|
+
# @attabot/complaint-app
|
|
2
|
+
|
|
3
|
+
Complaint Management UI as an npm package. Built with **atomic design** (atoms → molecules → organisms) so the parent app can mount a ready dashboard that uses the **parent’s auth token and API base URL**.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @attabot/complaint-app
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install react react-dom react-redux @reduxjs/toolkit
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```jsx
|
|
20
|
+
import ComplaintApp from '@attabot/complaint-app';
|
|
21
|
+
import '@attabot/complaint-app/style.css';
|
|
22
|
+
import brandTheme from './brandTheme.json'; // static theme file
|
|
23
|
+
|
|
24
|
+
function App() {
|
|
25
|
+
const [darkMode, setDarkMode] = useState(false); // owned by parent
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<ComplaintApp
|
|
29
|
+
apiUrl="https://your-api.example.com"
|
|
30
|
+
authToken={sessionToken}
|
|
31
|
+
theme={brandTheme}
|
|
32
|
+
darkMode={darkMode}
|
|
33
|
+
systemsEndpoint="/api/v1/complaint-systems"
|
|
34
|
+
onCreateForm={() => navigate('/forms/new')}
|
|
35
|
+
onConfigure={(system) => navigate(`/systems/${system.id}`)}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Theme & dark mode (parent-controlled)
|
|
42
|
+
|
|
43
|
+
Pass a static theme file (JSON/JS) and toggle `darkMode` from the parent. The package applies CSS variables across the whole UI.
|
|
44
|
+
|
|
45
|
+
```jsx
|
|
46
|
+
import brandTheme from './brandTheme.json';
|
|
47
|
+
|
|
48
|
+
<ComplaintApp theme={brandTheme} darkMode={isDark} />
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Theme file shape:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"light": { "colors": { "primary": "#2D64B8", "background": "#F5F5F5" } },
|
|
56
|
+
"dark": { "colors": { "primary": "#5B8DEF", "background": "#0F1115" } }
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or pass flat overrides (merged into both modes):
|
|
61
|
+
|
|
62
|
+
```jsx
|
|
63
|
+
<ComplaintApp theme={{ colors: { primary: '#0F766E' } }} darkMode={false} />
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Helpers / defaults are exported: `lightTheme`, `darkTheme`, `defaultThemeFile`, `useTheme`.
|
|
67
|
+
|
|
68
|
+
### Pass data from the parent (no fetch)
|
|
69
|
+
|
|
70
|
+
```jsx
|
|
71
|
+
<ComplaintApp
|
|
72
|
+
apiUrl={apiUrl}
|
|
73
|
+
authToken={authToken}
|
|
74
|
+
useDemoData={false}
|
|
75
|
+
systems={[
|
|
76
|
+
{
|
|
77
|
+
id: 'qms',
|
|
78
|
+
title: 'QMS - Query Management System',
|
|
79
|
+
status: 'active',
|
|
80
|
+
description: 'Description of the template',
|
|
81
|
+
departments: 3,
|
|
82
|
+
workflows: 12,
|
|
83
|
+
fields: 55,
|
|
84
|
+
formsFilled: 234,
|
|
85
|
+
updatedOn: '12 Mar 2024',
|
|
86
|
+
titleAsLink: true,
|
|
87
|
+
},
|
|
88
|
+
]}
|
|
89
|
+
onCreateForm={handleCreate}
|
|
90
|
+
onConfigure={handleConfigure}
|
|
91
|
+
/>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Props
|
|
95
|
+
|
|
96
|
+
| Prop | Type | Default | Description |
|
|
97
|
+
|------|------|---------|-------------|
|
|
98
|
+
| `apiUrl` | `string` | env `VITE_API_URL` | Base URL for axios requests |
|
|
99
|
+
| `authToken` | `string` | — | Bearer token stored for API calls |
|
|
100
|
+
| `theme` | `object` | built-in light/dark | Static theme file or token overrides |
|
|
101
|
+
| `darkMode` | `boolean` | `false` | Parent-controlled dark mode |
|
|
102
|
+
| `basePath` | `string` | `'/'` | React Router basename when nested |
|
|
103
|
+
| `systems` | `array` | — | Parent-controlled system list |
|
|
104
|
+
| `systemsEndpoint` | `string` | — | GET path relative to `apiUrl` |
|
|
105
|
+
| `useDemoData` | `boolean` | `true` | Show design demo cards when no data |
|
|
106
|
+
| `title` | `string` | `'Complaint Management'` | Page title |
|
|
107
|
+
| `description` | `string` | lorem placeholder | Page subtitle |
|
|
108
|
+
| `createLabel` | `string` | `'Create New Form'` | Primary CTA label |
|
|
109
|
+
| `onCreateForm` | `fn` | — | Create button handler |
|
|
110
|
+
| `onConfigure` | `fn(system)` | — | Configure button handler |
|
|
111
|
+
| `onTitleClick` | `fn(system)` | — | Title link click |
|
|
112
|
+
| `onDescriptionClick` | `fn` | — | Description link click |
|
|
113
|
+
| `onSearch` | `fn(query)` | — | Search change callback |
|
|
114
|
+
| `onPublish` | `fn` | — | Review & Publish handler |
|
|
115
|
+
| `onStepChange` | `fn` | — | Settings step change callback |
|
|
116
|
+
|
|
117
|
+
## Atomic structure
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
src/components/
|
|
121
|
+
atoms/ Button, Input, Typography, StatusBadge, Divider, Icons, Loading
|
|
122
|
+
molecules/ SearchBar, DataPoint, CardHeader, CardFooter
|
|
123
|
+
organisms/ PageHeader, SystemCard, SystemCardGrid
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Named exports are available for reuse in the parent:
|
|
127
|
+
|
|
128
|
+
```jsx
|
|
129
|
+
import { Button, SearchBar, SystemCard, api } from '@attabot/complaint-app';
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Auth & API
|
|
133
|
+
|
|
134
|
+
1. Parent passes `apiUrl` + `authToken` into `ComplaintApp` / `ApiProvider`.
|
|
135
|
+
2. Package axios client (`api`) keeps the passed token in memory and attaches `Authorization: Bearer …` immediately before every request. It does not overwrite the parent app's auth cookie.
|
|
136
|
+
3. Optional token refresh against `POST /api/v1/auth/refresh` when a `refreshToken` cookie exists.
|
|
137
|
+
4. No product/business APIs are hardcoded — provide `systems` or `systemsEndpoint`.
|
|
138
|
+
|
|
139
|
+
## Redux and router integration
|
|
140
|
+
|
|
141
|
+
When mounted inside a parent `react-redux` Provider, `ComplaintApp` automatically
|
|
142
|
+
reuses that Provider instead of adding a second competing Redux context. When used
|
|
143
|
+
standalone it falls back to its own store. Pass the `store` prop only when you
|
|
144
|
+
explicitly want an isolated store.
|
|
145
|
+
|
|
146
|
+
The same rule applies to React Router: an existing parent router is reused; a
|
|
147
|
+
`BrowserRouter` is only created for standalone use.
|
|
148
|
+
|
|
149
|
+
## Development
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
npm install
|
|
153
|
+
npm run dev # preview Complaint Management UI
|
|
154
|
+
npm run build # emit dist/ for publishing
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
MIT
|