@namphuongtechnologi/np-hub 0.1.10 → 0.1.12
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 +68 -43
- package/dist/{chunk-LH3GOL37.js → chunk-6POQSLKL.js} +310 -67
- package/dist/chunk-6POQSLKL.js.map +1 -0
- package/dist/index.cjs +309 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/np-hub.min.global.js +431 -12
- package/dist/react.cjs +313 -68
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +3 -2
- package/dist/react.d.ts +3 -2
- package/dist/react.js +5 -3
- package/dist/react.js.map +1 -1
- package/dist/register.cjs +309 -66
- package/dist/register.cjs.map +1 -1
- package/dist/register.js +1 -1
- package/dist/{support-widget.element-DjptQgh_.d.cts → support-widget.element-DIcCiCwK.d.cts} +11 -2
- package/dist/{support-widget.element-DjptQgh_.d.ts → support-widget.element-DIcCiCwK.d.ts} +11 -2
- package/docs/DEVELOPER_GUIDE.md +17 -2
- package/docs/USAGE_STATIC_REACT.md +26 -0
- package/package.json +1 -1
- package/dist/chunk-LH3GOL37.js.map +0 -1
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ Floating support widget for Nam Phương So applications. Drop it into any stati
|
|
|
13
13
|
- **React wrapper** — typed `SupportWidget` component
|
|
14
14
|
- **Drag-and-drop launcher** — position persists in `localStorage`
|
|
15
15
|
- **Form prefill** — optional user / content / attachment seeding; required fields still validated on submit
|
|
16
|
+
- **Submit feedback toast** — centered popup on success or API error; auto-closes or user can dismiss
|
|
16
17
|
- **Environment switch** — Production by default; Development via `isDev` / `is-dev`
|
|
17
18
|
|
|
18
19
|
---
|
|
@@ -120,20 +121,21 @@ export default function App() {
|
|
|
120
121
|
|
|
121
122
|
### `setConfig` / React props
|
|
122
123
|
|
|
123
|
-
| Name | Required | Default
|
|
124
|
-
| --------------- | -------- |
|
|
125
|
-
| `projectId` | No | —
|
|
126
|
-
| `isDev` | No | `false`
|
|
127
|
-
| `priority` | No | `0`
|
|
128
|
-
| `coordinators` | No | `[]`
|
|
129
|
-
| `emailContacts` | No | `[]`
|
|
124
|
+
| Name | Required | Default | Description |
|
|
125
|
+
| --------------- | -------- | ------- | ---------------------------------------------- |
|
|
126
|
+
| `projectId` | No | — | Project code forwarded to the API |
|
|
127
|
+
| `isDev` | No | `false` | `true` → Development API; otherwise Production |
|
|
128
|
+
| `priority` | No | `0` | Request priority |
|
|
129
|
+
| `coordinators` | No | `[]` | Coordinator email list |
|
|
130
|
+
| `emailContacts` | No | `[]` | Contact emails that receive the notification |
|
|
131
|
+
| `toastDuration` | No | `4000` | Toast auto-close delay in milliseconds |
|
|
130
132
|
|
|
131
133
|
### Prefill (optional)
|
|
132
134
|
|
|
133
|
-
| Name
|
|
134
|
-
|
|
|
135
|
-
| User
|
|
136
|
-
| Form content
|
|
135
|
+
| Name | Method / prop | Description |
|
|
136
|
+
| ------------ | -------------------------------- | --------------------------------------------------------------------------- |
|
|
137
|
+
| User | `setUser` / `user` | Prefills name, email, phone. Form UI still requires these fields on submit. |
|
|
138
|
+
| Form content | `setFormPrefill` / `formPrefill` | Prefills `content` and `attachments`. |
|
|
137
139
|
|
|
138
140
|
```js
|
|
139
141
|
// Web Component
|
|
@@ -169,11 +171,11 @@ widget.setFormPrefill({
|
|
|
169
171
|
|
|
170
172
|
Default: **65×65px**, anchored **20px** from the bottom-right corner.
|
|
171
173
|
|
|
172
|
-
| Attribute / prop
|
|
173
|
-
|
|
|
174
|
-
| `width` / `height`
|
|
175
|
-
| `right` / `bottom`
|
|
176
|
-
| `left` / `top`
|
|
174
|
+
| Attribute / prop | Description |
|
|
175
|
+
| ------------------ | --------------------------------------------------- |
|
|
176
|
+
| `width` / `height` | Launcher size (default `65`) |
|
|
177
|
+
| `right` / `bottom` | Offset from bottom-right (default `20`) |
|
|
178
|
+
| `left` / `top` | Use instead of `right` / `bottom` for other corners |
|
|
177
179
|
|
|
178
180
|
Numeric values from React props are treated as pixels. After the user drags the launcher, the stored `localStorage` position takes precedence.
|
|
179
181
|
|
|
@@ -186,59 +188,82 @@ widget.setAttribute("bottom", "24");
|
|
|
186
188
|
<SupportWidget projectId="NPP" right={24} bottom={24} />
|
|
187
189
|
```
|
|
188
190
|
|
|
191
|
+
### Submit feedback toast
|
|
192
|
+
|
|
193
|
+
After a successful API submit or an API/exception failure, the widget shows a **centered toast** with the result message.
|
|
194
|
+
|
|
195
|
+
| Behavior | Detail |
|
|
196
|
+
| ----------------- | -------------------------------------------------------- |
|
|
197
|
+
| When shown | Submit success, or API / runtime error |
|
|
198
|
+
| When hidden | Missing required fields (only inline field highlighting) |
|
|
199
|
+
| Auto-close | After `toastDuration` ms (default `4000`) |
|
|
200
|
+
| Manual close | User can dismiss via the `×` button |
|
|
201
|
+
| Success follow-up | Modal closes automatically ~1.2s after success |
|
|
202
|
+
|
|
203
|
+
```js
|
|
204
|
+
widget.setConfig({
|
|
205
|
+
projectId: "NPP",
|
|
206
|
+
toastDuration: 6000, // auto-close after 6 seconds
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
```tsx
|
|
211
|
+
<SupportWidget projectId="NPP" toastDuration={6000} />
|
|
212
|
+
```
|
|
213
|
+
|
|
189
214
|
---
|
|
190
215
|
|
|
191
216
|
## Events & methods
|
|
192
217
|
|
|
193
218
|
### Events (Web Component)
|
|
194
219
|
|
|
195
|
-
| Event | When
|
|
196
|
-
| ----------------------- |
|
|
197
|
-
| `np-hub-open` | Modal opens
|
|
198
|
-
| `np-hub-close` | Modal closes
|
|
199
|
-
| `np-hub-submit-success` | API accepted the support request
|
|
200
|
-
| `np-hub-submit-error` | Validation or API failure
|
|
220
|
+
| Event | When |
|
|
221
|
+
| ----------------------- | -------------------------------- |
|
|
222
|
+
| `np-hub-open` | Modal opens |
|
|
223
|
+
| `np-hub-close` | Modal closes |
|
|
224
|
+
| `np-hub-submit-success` | API accepted the support request |
|
|
225
|
+
| `np-hub-submit-error` | Validation or API failure |
|
|
201
226
|
|
|
202
227
|
React equivalent props: `onOpen`, `onClose`, `onSubmitSuccess`, `onSubmitError`.
|
|
203
228
|
|
|
204
229
|
### Methods (Web Component)
|
|
205
230
|
|
|
206
|
-
| Method | Description
|
|
207
|
-
| ---------------------- |
|
|
208
|
-
| `setConfig(config)` | Apply project / API settings
|
|
209
|
-
| `setUser(user)` | Prefill requester fields
|
|
210
|
-
| `setFormPrefill(data)` | Prefill content / attachments
|
|
211
|
-
| `open()` / `close()` | Open or close the modal
|
|
231
|
+
| Method | Description |
|
|
232
|
+
| ---------------------- | ----------------------------- |
|
|
233
|
+
| `setConfig(config)` | Apply project / API settings |
|
|
234
|
+
| `setUser(user)` | Prefill requester fields |
|
|
235
|
+
| `setFormPrefill(data)` | Prefill content / attachments |
|
|
236
|
+
| `open()` / `close()` | Open or close the modal |
|
|
212
237
|
|
|
213
238
|
---
|
|
214
239
|
|
|
215
240
|
## API environments
|
|
216
241
|
|
|
217
|
-
| Environment
|
|
218
|
-
|
|
|
219
|
-
| Production (default)
|
|
220
|
-
| Development (`isDev` / `is-dev`)
|
|
242
|
+
| Environment | Base URL |
|
|
243
|
+
| -------------------------------- | --------------------------------------------- |
|
|
244
|
+
| Production (default) | `https://namphuong-api.azurewebsites.net` |
|
|
245
|
+
| Development (`isDev` / `is-dev`) | `https://namphuong-api-dev.azurewebsites.net` |
|
|
221
246
|
|
|
222
247
|
---
|
|
223
248
|
|
|
224
249
|
## Troubleshooting
|
|
225
250
|
|
|
226
|
-
| Error
|
|
227
|
-
|
|
|
228
|
-
| `projectId cannot be empty.`
|
|
229
|
-
| `user.name/email/phoneNumber is required.`
|
|
230
|
-
| `Content is required.`
|
|
231
|
-
| API call fails in local testing
|
|
251
|
+
| Error | Resolution |
|
|
252
|
+
| ------------------------------------------ | ------------------------------------------------------------------ |
|
|
253
|
+
| `projectId cannot be empty.` | If provided, `projectId` / `project-id` must be a non-empty string |
|
|
254
|
+
| `user.name/email/phoneNumber is required.` | Requester fields are required on submit; `user` only prefills |
|
|
255
|
+
| `Content is required.` | User must enter message content before submit |
|
|
256
|
+
| API call fails in local testing | Set `isDev` / `is-dev` when targeting the Development environment |
|
|
232
257
|
|
|
233
258
|
---
|
|
234
259
|
|
|
235
260
|
## Documentation
|
|
236
261
|
|
|
237
|
-
| Document
|
|
238
|
-
|
|
|
239
|
-
| [Usage (static & React)](./docs/USAGE_STATIC_REACT.md) | Integrators
|
|
240
|
-
| [Developer guide](./docs/DEVELOPER_GUIDE.md)
|
|
241
|
-
| [Public release](./docs/PUBLIC_RELEASE.md)
|
|
262
|
+
| Document | Audience |
|
|
263
|
+
| ------------------------------------------------------ | ------------ |
|
|
264
|
+
| [Usage (static & React)](./docs/USAGE_STATIC_REACT.md) | Integrators |
|
|
265
|
+
| [Developer guide](./docs/DEVELOPER_GUIDE.md) | Contributors |
|
|
266
|
+
| [Public release](./docs/PUBLIC_RELEASE.md) | Maintainers |
|
|
242
267
|
|
|
243
268
|
---
|
|
244
269
|
|