@webority/insights-react 0.149.0 → 0.152.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/dist/types/FeedbackButton.d.ts +8 -14
- package/dist/types/FeedbackButton.meta.d.ts +2 -66
- package/dist/types/InsightsFeedbackProvider.d.ts +8 -8
- package/dist/types/NpsPrompt.d.ts +9 -16
- package/dist/types/NpsPrompt.meta.d.ts +2 -68
- package/dist/types/client.d.ts +17 -53
- package/dist/types/context.d.ts +4 -6
- package/dist/types/index.d.ts +8 -4
- package/package.json +9 -8
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
|
|
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{code;status;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}function b(e){if(typeof e!=`object`||!e||!(`response`in e))return null;let t=e.response;return typeof t!=`object`||!t?null:{data:`data`in t?t.data:void 0,status:`status`in t&&typeof t.status==`number`?t.status:void 0}}function x(e,t){if(typeof e!=`object`||!e||!(t in e))return null;let n=Reflect.get(e,t);return typeof n==`string`&&n?n:null}async function S(e){if(e instanceof v)return e;let t=b(e);if(!t)return new v(`network`,g);let n=await y(t.data);return new v(x(n,`code`)??`unknown`,x(n,`message`)??g,t.status)}async function C(e){try{return(await e()).data}catch(e){throw await S(e)}}function w(e,t={}){let n=(t.prefix??h).replace(/\/+$/,``);return{getNps:()=>C(()=>e.get(`${n}/nps`)),answerNps:t=>C(()=>e.post(`${n}/nps`,t,_)),leaveComment:t=>C(()=>e.post(`${n}/comments`,t,_))}}var T=o(null);function E(){let e=s(T);if(!e)throw Error(`InsightsFeedbackProvider is missing.`);return e.client}var D=1e3;function O({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=E(),[h,g]=d(!1),[_,v]=d(``),[y,b]=d(!1),[x,S]=d(!1),[C,w]=d(null);function T(){S(!1),w(null),g(!0)}async function O(){b(!0),w(null);try{await u.leaveComment({comment:_.trim(),pagePath:l??window.location.pathname}),v(``),S(!0)}catch(e){w(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:T,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:D,value:_,disabled:y,onChange:e=>v(e.target.value)}),C instanceof Error&&/* @__PURE__ */ p(e,{tone:`danger`,children:C.message})]})})]})}function k({client:e,children:t}){let n=l(()=>({client:e}),[e]);return/* @__PURE__ */ p(T.Provider,{value:n,children:t})}var A=1e3;function j({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 _=E(),[v,y]=d({kind:`loading`}),[b,x]=d(null),[S,C]=d(``),[w,T]=d(!1),[D,O]=d(null),k=u(!1);c(()=>{k.current||(k.current=!0,_.getNps().then(e=>{e?.due?y({kind:`asking`,trigger:e.trigger}):y({kind:`closed`})},()=>y({kind:`closed`})))},[_]);async function j(e,t){T(!0),O(null);try{return await _.answerNps({trigger:e,...t}),!0}catch(e){return O(e),!1}finally{T(!1)}}async function M(e){let t=S.trim();await j(e,{score:b,comment:t||null})&&y({kind:`thanked`})}async function N(e){await j(e,{score:null})&&y({kind:`closed`})}return v.kind===`loading`||v.kind===`closed`?null:v.kind===`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:b,onChange:x,min:0,max:10,label:r,lowLabel:o,highLabel:s,disabled:w}),b!==null&&/* @__PURE__ */ p(a,{label:l,rows:2,maxLength:A,value:S,disabled:w,onChange:e=>C(e.target.value)}),D instanceof Error&&/* @__PURE__ */ p(e,{tone:`danger`,children:D.message}),/* @__PURE__ */ m(`div`,{className:`d-flex gap-2 mt-3`,children:[/* @__PURE__ */ p(t,{onClick:()=>M(v.trigger),disabled:b===null||w,loading:w,children:f}),/* @__PURE__ */ p(t,{variant:`soft`,onClick:()=>N(v.trigger),disabled:w,children:h})]})]})}export{O as FeedbackButton,v as InsightsFeedbackApiError,k as InsightsFeedbackProvider,j as NpsPrompt,w as createInsightsFeedbackClient};
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* page path, unless `pagePath` is given.
|
|
4
|
-
*
|
|
5
|
-
* @param {object} props
|
|
6
|
-
* @param {string} [props.label]
|
|
7
|
-
* @param {string} [props.title]
|
|
8
|
-
* @param {string} [props.placeholder]
|
|
9
|
-
* @param {string} [props.sendLabel]
|
|
10
|
-
* @param {string} [props.thanks]
|
|
11
|
-
* @param {string|null} [props.pagePath]
|
|
12
|
-
*/
|
|
13
|
-
export default function FeedbackButton({ label, title, placeholder, sendLabel, thanks, pagePath, }: {
|
|
1
|
+
import { type JSX } from "react";
|
|
2
|
+
export interface FeedbackButtonProps {
|
|
14
3
|
label?: string;
|
|
15
4
|
title?: string;
|
|
16
5
|
placeholder?: string;
|
|
17
6
|
sendLabel?: string;
|
|
18
7
|
thanks?: string;
|
|
19
8
|
pagePath?: string | null;
|
|
20
|
-
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A button that opens a drawer with one box for a comment. The comment is sent with the current
|
|
12
|
+
* page path, unless `pagePath` is given.
|
|
13
|
+
*/
|
|
14
|
+
export default function FeedbackButton({ label, title, placeholder, sendLabel, thanks, pagePath, }: FeedbackButtonProps): JSX.Element;
|
|
@@ -1,66 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
readonly marker: null;
|
|
4
|
-
readonly platforms: readonly ["web"];
|
|
5
|
-
readonly acceptsChildren: false;
|
|
6
|
-
readonly props: {
|
|
7
|
-
readonly label: {
|
|
8
|
-
readonly type: "string";
|
|
9
|
-
readonly default: "Feedback";
|
|
10
|
-
readonly description: "The text on the button that opens the drawer.";
|
|
11
|
-
};
|
|
12
|
-
readonly title: {
|
|
13
|
-
readonly type: "string";
|
|
14
|
-
readonly default: "Send us feedback";
|
|
15
|
-
readonly description: "The drawer's heading. It also names the comment box.";
|
|
16
|
-
};
|
|
17
|
-
readonly placeholder: {
|
|
18
|
-
readonly type: "string";
|
|
19
|
-
readonly default: "Tell us what works and what does not";
|
|
20
|
-
readonly description: "The hint shown in the empty comment box.";
|
|
21
|
-
};
|
|
22
|
-
readonly sendLabel: {
|
|
23
|
-
readonly type: "string";
|
|
24
|
-
readonly default: "Send";
|
|
25
|
-
readonly description: "The text on the button that sends the comment.";
|
|
26
|
-
};
|
|
27
|
-
readonly thanks: {
|
|
28
|
-
readonly type: "string";
|
|
29
|
-
readonly default: "Thanks, we read every message.";
|
|
30
|
-
readonly description: "The message shown in the drawer after the comment is sent.";
|
|
31
|
-
};
|
|
32
|
-
readonly pagePath: {
|
|
33
|
-
readonly type: "string";
|
|
34
|
-
readonly description: "The page the comment is about. It defaults to the current path, read when the comment is sent. Null is accepted.";
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
readonly omit: readonly [];
|
|
38
|
-
readonly examples: readonly [{
|
|
39
|
-
readonly id: "FeedbackButton";
|
|
40
|
-
readonly title: "Default";
|
|
41
|
-
readonly props: {};
|
|
42
|
-
}, {
|
|
43
|
-
readonly id: "FeedbackButton.pagePath";
|
|
44
|
-
readonly title: "Fixed page";
|
|
45
|
-
readonly props: {
|
|
46
|
-
readonly pagePath: "/billing";
|
|
47
|
-
};
|
|
48
|
-
}, {
|
|
49
|
-
readonly id: "FeedbackButton.labels";
|
|
50
|
-
readonly title: "Custom labels";
|
|
51
|
-
readonly props: {
|
|
52
|
-
readonly label: "Give feedback";
|
|
53
|
-
readonly title: "Tell us more";
|
|
54
|
-
readonly placeholder: "What should change?";
|
|
55
|
-
readonly sendLabel: "Post";
|
|
56
|
-
readonly thanks: "Got it.";
|
|
57
|
-
};
|
|
58
|
-
}];
|
|
59
|
-
readonly usage: {
|
|
60
|
-
readonly when: readonly ["A portal lets a person send a free comment from any page.", "The comment goes with the page it was written on, unless pagePath names another page."];
|
|
61
|
-
readonly whenNot: readonly [];
|
|
62
|
-
readonly do: readonly [];
|
|
63
|
-
readonly dont: readonly [];
|
|
64
|
-
readonly a11y: readonly ["The button is a native button that opens the drawer, a dialog named by its title.", "The comment box takes the drawer title as its accessible name.", "Send stays disabled while the comment is empty or only spaces.", "The thanks message is a status region."];
|
|
65
|
-
};
|
|
66
|
-
};
|
|
1
|
+
import { type ComponentMeta } from "@webority/canvas-kit/meta";
|
|
2
|
+
export declare const meta: ComponentMeta;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { type JSX, type ReactNode } from "react";
|
|
2
|
+
import type { InsightsFeedbackClient } from "./client.ts";
|
|
3
|
+
export interface InsightsFeedbackProviderProps {
|
|
4
|
+
/** From `createInsightsFeedbackClient(http)`. */
|
|
5
|
+
client: InsightsFeedbackClient;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
1
8
|
/**
|
|
2
9
|
* Makes a feedback client available to the NPS question and the feedback button below it.
|
|
3
|
-
*
|
|
4
|
-
* @param {object} props
|
|
5
|
-
* @param {import('./client.js').InsightsFeedbackClient} props.client From `createInsightsFeedbackClient(http)`.
|
|
6
|
-
* @param {import('react').ReactNode} props.children
|
|
7
10
|
*/
|
|
8
|
-
export default function InsightsFeedbackProvider({ client, children }:
|
|
9
|
-
client: import('./client.js').InsightsFeedbackClient;
|
|
10
|
-
children: import('react').ReactNode;
|
|
11
|
-
}): import("react").JSX.Element;
|
|
11
|
+
export default function InsightsFeedbackProvider({ client, children }: InsightsFeedbackProviderProps): JSX.Element;
|
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* the server says it is due. Send posts the score and an optional comment; Not now is a permanent
|
|
4
|
-
* answer the server records, so the question does not come back.
|
|
5
|
-
*
|
|
6
|
-
* @param {object} props
|
|
7
|
-
* @param {string} [props.question]
|
|
8
|
-
* @param {string} [props.lowLabel]
|
|
9
|
-
* @param {string} [props.highLabel]
|
|
10
|
-
* @param {string} [props.commentLabel]
|
|
11
|
-
* @param {string} [props.sendLabel]
|
|
12
|
-
* @param {string} [props.notNowLabel]
|
|
13
|
-
* @param {string} [props.thanks]
|
|
14
|
-
*/
|
|
15
|
-
export default function NpsPrompt({ question, lowLabel, highLabel, commentLabel, sendLabel, notNowLabel, thanks, }: {
|
|
1
|
+
import { type JSX } from "react";
|
|
2
|
+
export interface NpsPromptProps {
|
|
16
3
|
question?: string;
|
|
17
4
|
lowLabel?: string;
|
|
18
5
|
highLabel?: string;
|
|
@@ -20,4 +7,10 @@ export default function NpsPrompt({ question, lowLabel, highLabel, commentLabel,
|
|
|
20
7
|
sendLabel?: string;
|
|
21
8
|
notNowLabel?: string;
|
|
22
9
|
thanks?: string;
|
|
23
|
-
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The one "how likely are you to recommend us" question. It asks once per mount, and only when
|
|
13
|
+
* the server says it is due. Send posts the score and an optional comment; Not now is a permanent
|
|
14
|
+
* answer the server records, so the question does not come back.
|
|
15
|
+
*/
|
|
16
|
+
export default function NpsPrompt({ question, lowLabel, highLabel, commentLabel, sendLabel, notNowLabel, thanks, }: NpsPromptProps): JSX.Element | null;
|
|
@@ -1,68 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
readonly marker: null;
|
|
4
|
-
readonly platforms: readonly ["web"];
|
|
5
|
-
readonly acceptsChildren: false;
|
|
6
|
-
readonly props: {
|
|
7
|
-
readonly question: {
|
|
8
|
-
readonly type: "string";
|
|
9
|
-
readonly default: "How likely are you to recommend us to a colleague?";
|
|
10
|
-
readonly description: "The question asked above the score scale.";
|
|
11
|
-
};
|
|
12
|
-
readonly lowLabel: {
|
|
13
|
-
readonly type: "string";
|
|
14
|
-
readonly default: "Not likely";
|
|
15
|
-
readonly description: "The label under the lowest score.";
|
|
16
|
-
};
|
|
17
|
-
readonly highLabel: {
|
|
18
|
-
readonly type: "string";
|
|
19
|
-
readonly default: "Very likely";
|
|
20
|
-
readonly description: "The label under the highest score.";
|
|
21
|
-
};
|
|
22
|
-
readonly commentLabel: {
|
|
23
|
-
readonly type: "string";
|
|
24
|
-
readonly default: "What is the main reason for your score? (optional)";
|
|
25
|
-
readonly description: "The label of the optional comment box that appears once a score is chosen.";
|
|
26
|
-
};
|
|
27
|
-
readonly sendLabel: {
|
|
28
|
-
readonly type: "string";
|
|
29
|
-
readonly default: "Send";
|
|
30
|
-
readonly description: "The text on the button that sends the score and comment.";
|
|
31
|
-
};
|
|
32
|
-
readonly notNowLabel: {
|
|
33
|
-
readonly type: "string";
|
|
34
|
-
readonly default: "Not now";
|
|
35
|
-
readonly description: "The text on the button that dismisses the question for good.";
|
|
36
|
-
};
|
|
37
|
-
readonly thanks: {
|
|
38
|
-
readonly type: "string";
|
|
39
|
-
readonly default: "Thanks for your feedback.";
|
|
40
|
-
readonly description: "The message shown after the score is sent.";
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
readonly omit: readonly [];
|
|
44
|
-
readonly examples: readonly [{
|
|
45
|
-
readonly id: "NpsPrompt";
|
|
46
|
-
readonly title: "Default";
|
|
47
|
-
readonly props: {};
|
|
48
|
-
}, {
|
|
49
|
-
readonly id: "NpsPrompt.labels";
|
|
50
|
-
readonly title: "Custom labels";
|
|
51
|
-
readonly props: {
|
|
52
|
-
readonly question: "Would you recommend us?";
|
|
53
|
-
readonly lowLabel: "Never";
|
|
54
|
-
readonly highLabel: "Always";
|
|
55
|
-
readonly commentLabel: "Why?";
|
|
56
|
-
readonly sendLabel: "Go";
|
|
57
|
-
readonly notNowLabel: "Later";
|
|
58
|
-
readonly thanks: "Cheers.";
|
|
59
|
-
};
|
|
60
|
-
}];
|
|
61
|
-
readonly usage: {
|
|
62
|
-
readonly when: readonly ["A portal asks the one question of how likely a person is to recommend the product.", "It asks once per mount, and only when the server says the question is due.", "Send posts the score and an optional comment; Not now is a permanent answer the server records."];
|
|
63
|
-
readonly whenNot: readonly [];
|
|
64
|
-
readonly do: readonly [];
|
|
65
|
-
readonly dont: readonly [];
|
|
66
|
-
readonly a11y: readonly ["The score scale is a radio group named by the question, with one control per score.", "The comment box appears only after a score is chosen.", "Send stays disabled until a score is chosen.", "The thanks message is a status region."];
|
|
67
|
-
};
|
|
68
|
-
};
|
|
1
|
+
import { type ComponentMeta } from "@webority/canvas-kit/meta";
|
|
2
|
+
export declare const meta: ComponentMeta;
|
package/dist/types/client.d.ts
CHANGED
|
@@ -5,46 +5,38 @@ export declare class InsightsFeedbackApiError extends Error {
|
|
|
5
5
|
code: string;
|
|
6
6
|
status: number | undefined;
|
|
7
7
|
/**
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
8
|
+
* @param code Machine-readable reason from the API, or "network" when no response arrived.
|
|
9
|
+
* @param message The sentence to show the person.
|
|
10
|
+
* @param status HTTP status, when a response arrived.
|
|
11
11
|
*/
|
|
12
12
|
constructor(code: string, message: string, status?: number);
|
|
13
13
|
}
|
|
14
|
+
/** An axios-like HTTP client that already carries the bearer token. */
|
|
14
15
|
export type InsightsHttp = {
|
|
15
|
-
get
|
|
16
|
-
data:
|
|
16
|
+
get<T>(url: string, config?: object): Promise<{
|
|
17
|
+
data: T;
|
|
17
18
|
}>;
|
|
18
|
-
post
|
|
19
|
-
data:
|
|
19
|
+
post<T>(url: string, data?: unknown, config?: object): Promise<{
|
|
20
|
+
data: T;
|
|
20
21
|
}>;
|
|
21
22
|
};
|
|
23
|
+
/** What the server says about the question for this person. */
|
|
22
24
|
export type NpsState = {
|
|
23
|
-
/**
|
|
24
|
-
* Whether the question should be asked now.
|
|
25
|
-
*/
|
|
25
|
+
/** Whether the question should be asked now. */
|
|
26
26
|
due: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* The server's reason for asking; sent back with the answer.
|
|
29
|
-
*/
|
|
27
|
+
/** The server's reason for asking; sent back with the answer. */
|
|
30
28
|
trigger: string;
|
|
31
29
|
};
|
|
32
30
|
export type NpsAnswer = {
|
|
33
|
-
/**
|
|
34
|
-
* The `trigger` the question was asked with.
|
|
35
|
-
*/
|
|
31
|
+
/** The `trigger` the question was asked with. */
|
|
36
32
|
trigger: string;
|
|
37
|
-
/**
|
|
38
|
-
* 0 to 10, or null for a permanent "not now".
|
|
39
|
-
*/
|
|
33
|
+
/** 0 to 10, or null for a permanent "not now". */
|
|
40
34
|
score: number | null;
|
|
41
35
|
comment?: string | null;
|
|
42
36
|
};
|
|
43
37
|
export type CommentInput = {
|
|
44
38
|
comment: string;
|
|
45
|
-
/**
|
|
46
|
-
* The page the comment is about; the component sends the current path.
|
|
47
|
-
*/
|
|
39
|
+
/** The page the comment is about; the component sends the current path. */
|
|
48
40
|
pagePath?: string | null;
|
|
49
41
|
};
|
|
50
42
|
export type InsightsFeedbackClient = {
|
|
@@ -52,40 +44,12 @@ export type InsightsFeedbackClient = {
|
|
|
52
44
|
answerNps: (body: NpsAnswer) => Promise<void>;
|
|
53
45
|
leaveComment: (body: CommentInput) => Promise<void>;
|
|
54
46
|
};
|
|
55
|
-
/**
|
|
56
|
-
* @typedef {object} InsightsHttp An axios-like HTTP client that already carries the bearer token.
|
|
57
|
-
* @property {(url: string, config?: object) => Promise<{ data: any }>} get
|
|
58
|
-
* @property {(url: string, data?: any, config?: object) => Promise<{ data: any }>} post
|
|
59
|
-
*/
|
|
60
|
-
/**
|
|
61
|
-
* @typedef {object} NpsState What the server says about the question for this person.
|
|
62
|
-
* @property {boolean} due Whether the question should be asked now.
|
|
63
|
-
* @property {string} trigger The server's reason for asking; sent back with the answer.
|
|
64
|
-
*/
|
|
65
|
-
/**
|
|
66
|
-
* @typedef {object} NpsAnswer
|
|
67
|
-
* @property {string} trigger The `trigger` the question was asked with.
|
|
68
|
-
* @property {number|null} score 0 to 10, or null for a permanent "not now".
|
|
69
|
-
* @property {string|null} [comment]
|
|
70
|
-
*/
|
|
71
|
-
/**
|
|
72
|
-
* @typedef {object} CommentInput
|
|
73
|
-
* @property {string} comment
|
|
74
|
-
* @property {string|null} [pagePath] The page the comment is about; the component sends the current path.
|
|
75
|
-
*/
|
|
76
|
-
/**
|
|
77
|
-
* @typedef {object} InsightsFeedbackClient
|
|
78
|
-
* @property {() => Promise<NpsState>} getNps
|
|
79
|
-
* @property {(body: NpsAnswer) => Promise<void>} answerNps
|
|
80
|
-
* @property {(body: CommentInput) => Promise<void>} leaveComment
|
|
81
|
-
*/
|
|
82
47
|
/**
|
|
83
48
|
* Binds the feedback HTTP contract to the product's own authenticated client.
|
|
84
49
|
*
|
|
85
|
-
* @param
|
|
86
|
-
* @param
|
|
87
|
-
* @returns {InsightsFeedbackClient}
|
|
50
|
+
* @param http The product's signed-in axios client (web-core userClient).
|
|
51
|
+
* @param options `prefix` overrides the API prefix, which defaults to /api/insights/feedback.
|
|
88
52
|
*/
|
|
89
|
-
export declare function createInsightsFeedbackClient(http:
|
|
53
|
+
export declare function createInsightsFeedbackClient(http: InsightsHttp, options?: {
|
|
90
54
|
prefix?: string;
|
|
91
55
|
}): InsightsFeedbackClient;
|
package/dist/types/context.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const InsightsFeedbackContext: import(
|
|
3
|
-
client:
|
|
1
|
+
import type { InsightsFeedbackClient } from "./client.ts";
|
|
2
|
+
export declare const InsightsFeedbackContext: import("react").Context<{
|
|
3
|
+
client: InsightsFeedbackClient;
|
|
4
4
|
} | null>;
|
|
5
5
|
/**
|
|
6
6
|
* The feedback client the nearest InsightsFeedbackProvider holds. Internal to the package.
|
|
7
|
-
*
|
|
8
|
-
* @returns {import('./client.js').InsightsFeedbackClient}
|
|
9
7
|
*/
|
|
10
|
-
export declare function useInsightsFeedbackClient():
|
|
8
|
+
export declare function useInsightsFeedbackClient(): InsightsFeedbackClient;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { default as
|
|
1
|
+
export type { CommentInput, InsightsFeedbackClient, InsightsHttp, NpsAnswer, NpsState } from "./client.ts";
|
|
2
|
+
export { createInsightsFeedbackClient, InsightsFeedbackApiError } from "./client.ts";
|
|
3
|
+
export type { FeedbackButtonProps } from "./FeedbackButton.tsx";
|
|
4
|
+
export { default as FeedbackButton } from "./FeedbackButton.tsx";
|
|
5
|
+
export type { InsightsFeedbackProviderProps } from "./InsightsFeedbackProvider.tsx";
|
|
6
|
+
export { default as InsightsFeedbackProvider } from "./InsightsFeedbackProvider.tsx";
|
|
7
|
+
export type { NpsPromptProps } from "./NpsPrompt.tsx";
|
|
8
|
+
export { default as NpsPrompt } from "./NpsPrompt.tsx";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/insights-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.152.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,10 +27,8 @@
|
|
|
27
27
|
},
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@webority/ui-react": "0.
|
|
31
|
-
"bootstrap": "5.3.8",
|
|
30
|
+
"@webority/ui-react": "0.152.0",
|
|
32
31
|
"react": "^19.0.0",
|
|
33
|
-
"react-bootstrap": "^2.10.0",
|
|
34
32
|
"react-dom": "^19.0.0"
|
|
35
33
|
},
|
|
36
34
|
"devDependencies": {
|
|
@@ -38,11 +36,13 @@
|
|
|
38
36
|
"@testing-library/jest-dom": "7.0.1",
|
|
39
37
|
"@testing-library/react": "^16.3.0",
|
|
40
38
|
"@testing-library/user-event": "^14.6.1",
|
|
41
|
-
"@types/
|
|
39
|
+
"@types/node": "25.6.0",
|
|
40
|
+
"@types/react": "^19.3.0",
|
|
42
41
|
"@vitejs/plugin-react": "^6.0.1",
|
|
43
42
|
"@vitest/coverage-v8": "5.1.0",
|
|
44
|
-
"@webority/canvas-kit": "0.
|
|
45
|
-
"@webority/
|
|
43
|
+
"@webority/canvas-kit": "0.152.0",
|
|
44
|
+
"@webority/biome-config": "0.152.0",
|
|
45
|
+
"@webority/ui-react": "0.152.0",
|
|
46
46
|
"bootstrap": "5.3.8",
|
|
47
47
|
"jsdom": "30.1.1",
|
|
48
48
|
"react": "^19.3.1",
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
"vitest": "5.1.0"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
|
-
"build": "vite build && tsc -p tsconfig.json && node ../canvas-kit/dist/cli.js guidance --config canvas-kit.json --out dist/guidance.json",
|
|
56
|
+
"build": "tsc -p tsconfig.json && vite build && tsc -p tsconfig.build.json && node ../canvas-kit/dist/cli.js guidance --config canvas-kit.json --out dist/guidance.json",
|
|
57
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
57
58
|
"test": "vitest run",
|
|
58
59
|
"test:watch": "vitest",
|
|
59
60
|
"test:coverage": "vitest run --coverage"
|