@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 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 | Description |
124
- | --------------- | -------- | ------------- | ------------------------------------------------ |
125
- | `projectId` | No | — | Project code forwarded to the API |
126
- | `isDev` | No | `false` | `true` → Development API; otherwise Production |
127
- | `priority` | No | `0` | Request priority |
128
- | `coordinators` | No | `[]` | Coordinator email list |
129
- | `emailContacts` | No | `[]` | Contact emails that receive the notification |
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 | Method / prop | Description |
134
- | ------------- | ----------------- | --------------------------------------------------------------------------- |
135
- | User | `setUser` / `user` | Prefills name, email, phone. Form UI still requires these fields on submit. |
136
- | Form content | `setFormPrefill` / `formPrefill` | Prefills `content` and `attachments`. |
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 | Description |
173
- | ---------------------- | ------------------------------------------------ |
174
- | `width` / `height` | Launcher size (default `65`) |
175
- | `right` / `bottom` | Offset from bottom-right (default `20`) |
176
- | `left` / `top` | Use instead of `right` / `bottom` for other corners |
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 | Base URL |
218
- | ----------------------------------- | ------------------------------------------------- |
219
- | Production (default) | `https://namphuong-api.azurewebsites.net` |
220
- | Development (`isDev` / `is-dev`) | `https://namphuong-api-dev.azurewebsites.net` |
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 | Resolution |
227
- | ---------------------------------------------- | -------------------------------------------------------------------------- |
228
- | `projectId cannot be empty.` | If provided, `projectId` / `project-id` must be a non-empty string |
229
- | `user.name/email/phoneNumber is required.` | Requester fields are required on submit; `user` only prefills |
230
- | `Content is required.` | User must enter message content before submit |
231
- | API call fails in local testing | Set `isDev` / `is-dev` when targeting the Development environment |
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 | Audience |
238
- | -------- | -------- |
239
- | [Usage (static & React)](./docs/USAGE_STATIC_REACT.md) | Integrators |
240
- | [Developer guide](./docs/DEVELOPER_GUIDE.md) | Contributors |
241
- | [Public release](./docs/PUBLIC_RELEASE.md) | Maintainers |
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