@webority/insights-react 0.129.0 → 0.130.0
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/dist/guidance.json +1 -1
- package/dist/insights-react.js +1 -1
- package/package.json +4 -4
package/dist/guidance.json
CHANGED
package/dist/insights-react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AppAlert as e,AppButton as t,AppCard as n,AppDrawer as r,AppScoreScale as i,AppTextarea as a}from"@webority/ui-react";import{createContext as o,useContext as s,useEffect as c,useMemo as l,useRef as u,useState as d}from"react";import{Fragment as f,jsx as p,jsxs as m}from"react/jsx-runtime";var h=`/api/insights/feedback`,g=`Something went wrong. Please try again.`,_={headers:{"X-Webority-Surface":`Web`}},v=class extends Error{constructor(e,t,n){super(t),this.name=`InsightsFeedbackApiError`,this.code=e,this.status=n}};async function y(e){if(e&&typeof Blob<`u`&&e instanceof Blob)try{return JSON.parse(await e.text())}catch{return null}if(typeof e==`string`)try{return JSON.parse(e)}catch{return null}return e??null}async function b(e){if(e instanceof v)return e;let t=e?.response;if(!t)return new v(`network`,g);let n=await y(t.data);return new v(typeof n?.code==`string`&&n.code?n.code:`unknown`,typeof n?.message==`string`&&n.message?n.message:g,t.status)}async function x(e){try{return(await e()).data}catch(e){throw await b(e)}}function S(e,t={}){let n=(t.prefix??h).replace(/\/+$/,``);return{getNps:()=>x(()=>e.get(`${n}/nps`)),answerNps:t=>x(()=>e.post(`${n}/nps`,t,_)),leaveComment:t=>x(()=>e.post(`${n}/comments`,t,_))}}var C=o(null);function w(){let e=s(C);if(!e)throw Error(`InsightsFeedbackProvider is missing.`);return e.client}var T=1e3;function E({label:n=`Feedback`,title:i=`Send us feedback`,placeholder:o=`Tell us what works and what does not`,sendLabel:s=`Send`,thanks:c=`Thanks, we read every message.`,pagePath:l}){let u=w(),[h,g]=d(!1),[_,v]=d(``),[y,b]=d(!1),[x,S]=d(!1),[C,E]=d(null);function D(){S(!1),E(null),g(!0)}async function O(){b(!0),E(null);try{await u.leaveComment({comment:_.trim(),pagePath:l??window.location.pathname}),v(``),S(!0)}catch(e){E(e)}finally{b(!1)}}let k=x?null:/* @__PURE__ */ p(`div`,{className:`d-flex justify-content-end w-100`,children:/* @__PURE__ */ p(t,{
|
|
1
|
+
import{AppAlert as e,AppButton as t,AppCard as n,AppDrawer as r,AppScoreScale as i,AppTextarea as a}from"@webority/ui-react";import{createContext as o,useContext as s,useEffect as c,useMemo as l,useRef as u,useState as d}from"react";import{Fragment as f,jsx as p,jsxs as m}from"react/jsx-runtime";var h=`/api/insights/feedback`,g=`Something went wrong. Please try again.`,_={headers:{"X-Webority-Surface":`Web`}},v=class extends Error{constructor(e,t,n){super(t),this.name=`InsightsFeedbackApiError`,this.code=e,this.status=n}};async function y(e){if(e&&typeof Blob<`u`&&e instanceof Blob)try{return JSON.parse(await e.text())}catch{return null}if(typeof e==`string`)try{return JSON.parse(e)}catch{return null}return e??null}async function b(e){if(e instanceof v)return e;let t=e?.response;if(!t)return new v(`network`,g);let n=await y(t.data);return new v(typeof n?.code==`string`&&n.code?n.code:`unknown`,typeof n?.message==`string`&&n.message?n.message:g,t.status)}async function x(e){try{return(await e()).data}catch(e){throw await b(e)}}function S(e,t={}){let n=(t.prefix??h).replace(/\/+$/,``);return{getNps:()=>x(()=>e.get(`${n}/nps`)),answerNps:t=>x(()=>e.post(`${n}/nps`,t,_)),leaveComment:t=>x(()=>e.post(`${n}/comments`,t,_))}}var C=o(null);function w(){let e=s(C);if(!e)throw Error(`InsightsFeedbackProvider is missing.`);return e.client}var T=1e3;function E({label:n=`Feedback`,title:i=`Send us feedback`,placeholder:o=`Tell us what works and what does not`,sendLabel:s=`Send`,thanks:c=`Thanks, we read every message.`,pagePath:l}){let u=w(),[h,g]=d(!1),[_,v]=d(``),[y,b]=d(!1),[x,S]=d(!1),[C,E]=d(null);function D(){S(!1),E(null),g(!0)}async function O(){b(!0),E(null);try{await u.leaveComment({comment:_.trim(),pagePath:l??window.location.pathname}),v(``),S(!0)}catch(e){E(e)}finally{b(!1)}}let k=x?null:/* @__PURE__ */ p(`div`,{className:`d-flex justify-content-end w-100`,children:/* @__PURE__ */ p(t,{onClick:O,disabled:_.trim()===``||y,loading:y,children:s})});return/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(t,{variant:`outline`,onClick:D,children:n}),/* @__PURE__ */ p(r,{open:h,onClose:()=>g(!1),title:i,footer:k,children:x?/* @__PURE__ */ p(`p`,{role:`status`,className:`mb-0`,children:c}):/* @__PURE__ */ m(f,{children:[/* @__PURE__ */ p(a,{"aria-label":i,placeholder:o,rows:5,maxLength:T,value:_,disabled:y,onChange:e=>v(e.target.value)}),C&&/* @__PURE__ */ p(e,{tone:`danger`,children:C.message})]})})]})}function D({client:e,children:t}){let n=l(()=>({client:e}),[e]);return/* @__PURE__ */ p(C.Provider,{value:n,children:t})}var O=1e3;function k({question:r=`How likely are you to recommend us to a colleague?`,lowLabel:o=`Not likely`,highLabel:s=`Very likely`,commentLabel:l=`What is the main reason for your score? (optional)`,sendLabel:f=`Send`,notNowLabel:h=`Not now`,thanks:g=`Thanks for your feedback.`}){let _=w(),[v,y]=d(`loading`),[b,x]=d(null),[S,C]=d(null),[T,E]=d(``),[D,k]=d(!1),[A,j]=d(null),M=u(!1);c(()=>{M.current||(M.current=!0,_.getNps().then(e=>{e?.due?(x(e.trigger),y(`asking`)):y(`closed`)},()=>y(`closed`)))},[_]);async function N(e){k(!0),j(null);try{return await _.answerNps({trigger:b,...e}),!0}catch(e){return j(e),!1}finally{k(!1)}}async function P(){let e=T.trim();await N({score:S,comment:e||null})&&y(`thanked`)}async function F(){await N({score:null})&&y(`closed`)}return v===`loading`||v===`closed`?null:v===`thanked`?/* @__PURE__ */ p(n,{children:/* @__PURE__ */ p(`p`,{role:`status`,className:`mb-0`,children:g})}):/* @__PURE__ */ m(n,{children:[/* @__PURE__ */ p(i,{name:`nps-score`,value:S,onChange:C,min:0,max:10,label:r,lowLabel:o,highLabel:s,disabled:D}),S!==null&&/* @__PURE__ */ p(a,{label:l,rows:2,maxLength:O,value:T,disabled:D,onChange:e=>E(e.target.value)}),A&&/* @__PURE__ */ p(e,{tone:`danger`,children:A.message}),/* @__PURE__ */ m(`div`,{className:`d-flex gap-2 mt-3`,children:[/* @__PURE__ */ p(t,{onClick:P,disabled:S===null||D,loading:D,children:f}),/* @__PURE__ */ p(t,{variant:`soft`,onClick:F,disabled:D,children:h})]})]})}export{E as FeedbackButton,v as InsightsFeedbackApiError,D as InsightsFeedbackProvider,k as NpsPrompt,S as createInsightsFeedbackClient};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/insights-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.130.0",
|
|
4
4
|
"description": "Webority product feedback for React portals: the NPS question and a feedback button that post to the product's Webority.Insights feedback API, built on @webority/ui-react.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@webority/ui-react": "0.
|
|
30
|
+
"@webority/ui-react": "0.130.0",
|
|
31
31
|
"bootstrap": "5.3.3",
|
|
32
32
|
"react": "^19.0.0",
|
|
33
33
|
"react-bootstrap": "^2.10.0",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"@types/react": "^19.2.17",
|
|
42
42
|
"@vitejs/plugin-react": "^6.0.1",
|
|
43
43
|
"@vitest/coverage-v8": "5.0.1",
|
|
44
|
-
"@webority/canvas-kit": "0.
|
|
45
|
-
"@webority/ui-react": "0.
|
|
44
|
+
"@webority/canvas-kit": "0.130.0",
|
|
45
|
+
"@webority/ui-react": "0.130.0",
|
|
46
46
|
"bootstrap": "5.3.3",
|
|
47
47
|
"jsdom": "30.1.1",
|
|
48
48
|
"react": "^19.2.6",
|