@magicfeedback/native 2.1.7-alpha.8 → 2.1.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.
Files changed (31) hide show
  1. package/README.md +315 -467
  2. package/dist/magicfeedback-sdk.browser.js +1 -1
  3. package/dist/magicfeedback-sdk.node.js +1 -1
  4. package/dist/styles/magicfeedback-default.css +268 -148
  5. package/dist/types/src/models/pageGraphs.d.ts +52 -0
  6. package/dist/types/src/models/types.d.ts +92 -3
  7. package/dist/types/src/render/helpers.d.ts +3 -0
  8. package/dist/types/src/render/ratingHelpers.d.ts +3 -0
  9. package/dist/types/src/render/registry.d.ts +3 -0
  10. package/dist/types/src/render/renderBoolean.d.ts +2 -0
  11. package/dist/types/src/render/renderChoice.d.ts +2 -0
  12. package/dist/types/src/render/renderConsent.d.ts +2 -0
  13. package/dist/types/src/render/renderDate.d.ts +2 -0
  14. package/dist/types/src/render/renderEmail.d.ts +2 -0
  15. package/dist/types/src/render/renderInfoPage.d.ts +2 -0
  16. package/dist/types/src/render/renderLongText.d.ts +2 -0
  17. package/dist/types/src/render/renderMatrix.d.ts +2 -0
  18. package/dist/types/src/render/renderMultipleChoiceImage.d.ts +2 -0
  19. package/dist/types/src/render/renderNumber.d.ts +2 -0
  20. package/dist/types/src/render/renderPassword.d.ts +2 -0
  21. package/dist/types/src/render/renderPointSystem.d.ts +2 -0
  22. package/dist/types/src/render/renderPriorityList.d.ts +2 -0
  23. package/dist/types/src/render/renderRatingEmoji.d.ts +2 -0
  24. package/dist/types/src/render/renderRatingNumber.d.ts +2 -0
  25. package/dist/types/src/render/renderRatingStar.d.ts +2 -0
  26. package/dist/types/src/render/renderSelect.d.ts +2 -0
  27. package/dist/types/src/render/renderText.d.ts +2 -0
  28. package/dist/types/src/render/renderUploadFile.d.ts +2 -0
  29. package/dist/types/src/render/renderUploadImage.d.ts +2 -0
  30. package/dist/types/src/render/types.d.ts +20 -0
  31. package/package.json +1 -1
@@ -0,0 +1,52 @@
1
+ import { Page } from "./page";
2
+ import { PageNode } from "./pageNode";
3
+ import { NativeAnswer } from "./types";
4
+ export declare class PageGraph {
5
+ private nodes;
6
+ constructor(pages: Page[]);
7
+ /**
8
+ * Build the graph from the list of pages
9
+ * @param pages
10
+ * @private
11
+ * */
12
+ private buildGraph;
13
+ getNodeById(id: string): PageNode | undefined;
14
+ /**
15
+ * Get the next page position of the graph given the current page and the answer
16
+ * @param node
17
+ */
18
+ getNextEdgeByDefault(node: PageNode): string | undefined;
19
+ /**
20
+ * Get the first page of the graph
21
+ * @returns first page
22
+ **/
23
+ getFirstPage(): PageNode | undefined;
24
+ /**
25
+ * Get the next page of the graph given the current page and the answer
26
+ * @param currentNode
27
+ * @param answer - answer to the question in the current page
28
+ * @returns page
29
+ **/
30
+ getNextPage(currentNode: PageNode, answer: NativeAnswer[]): PageNode | undefined;
31
+ /**
32
+ * Get the number deep (DFS) of this node
33
+ * @param id - node id
34
+ * @returns DFS number
35
+ */
36
+ findDepth(id: string): number;
37
+ /**
38
+ * Get the max depth of the graph
39
+ * @param n - node
40
+ * @returns max depth
41
+ */
42
+ findMaxDepth(n?: PageNode): number;
43
+ /**
44
+ * A function used by DFS
45
+ * @param v - node
46
+ * @param visited - set of visited nodes
47
+ * @param depth - current depth
48
+ */
49
+ DFSUtil(v: PageNode, visited: Set<PageNode>, depth: number): number;
50
+ private parseMatrixAnswer;
51
+ private evaluateMatrixCondition;
52
+ }
@@ -2,6 +2,7 @@ export type Key = string;
2
2
  export type InitOptions = {
3
3
  env?: 'dev' | 'prod';
4
4
  debug?: boolean;
5
+ dryRun?: boolean;
5
6
  };
6
7
  export type NativeFeedbackAnswer = {
7
8
  id: string;
@@ -38,10 +39,98 @@ export declare enum FEEDBACKAPPANSWERTYPE {
38
39
  export declare class QuestionType {
39
40
  conf: any;
40
41
  }
41
- export type NativeQuestion = {
42
+ export type QuestionAssetsBase = {
43
+ [key: string]: any;
44
+ placeholder?: string;
45
+ subtitle?: string | Record<string, string>;
46
+ subtitleStyle?: string | string[];
47
+ titleSize?: string;
48
+ titleAlign?: string;
49
+ titleStyle?: string | string[];
50
+ maxCharacters?: number;
51
+ randomPosition?: boolean;
52
+ direction?: "row" | "column" | string;
53
+ order?: "ltr" | "rtl" | string;
54
+ min?: number;
55
+ max?: number;
56
+ minPlaceholder?: string;
57
+ maxPlaceholder?: string;
58
+ extraOption?: boolean;
59
+ extraOptionText?: string;
60
+ extraOptionPlaceholder?: string;
61
+ };
62
+ export type QuestionAssetsByType = {
63
+ [FEEDBACKAPPANSWERTYPE.TEXT]: QuestionAssetsBase;
64
+ [FEEDBACKAPPANSWERTYPE.LONGTEXT]: QuestionAssetsBase & {
65
+ maxCharacters?: number;
66
+ };
67
+ [FEEDBACKAPPANSWERTYPE.NUMBER]: QuestionAssetsBase;
68
+ [FEEDBACKAPPANSWERTYPE.RADIO]: QuestionAssetsBase & {
69
+ exclusiveAnswers?: string[];
70
+ maxOptions?: number;
71
+ extraOption?: boolean;
72
+ extraOptionText?: string;
73
+ extraOptionPlaceholder?: string;
74
+ };
75
+ [FEEDBACKAPPANSWERTYPE.MULTIPLECHOICE]: QuestionAssetsByType[FEEDBACKAPPANSWERTYPE.RADIO];
76
+ [FEEDBACKAPPANSWERTYPE.SELECT]: QuestionAssetsBase;
77
+ [FEEDBACKAPPANSWERTYPE.DATE]: QuestionAssetsBase;
78
+ [FEEDBACKAPPANSWERTYPE.EMAIL]: QuestionAssetsBase;
79
+ [FEEDBACKAPPANSWERTYPE.PASSWORD]: QuestionAssetsBase;
80
+ [FEEDBACKAPPANSWERTYPE.BOOLEAN]: QuestionAssetsBase & {
81
+ addIcon?: boolean;
82
+ };
83
+ [FEEDBACKAPPANSWERTYPE.CONSENT]: QuestionAssetsBase;
84
+ [FEEDBACKAPPANSWERTYPE.RATING_EMOJI]: QuestionAssetsBase & {
85
+ min?: number;
86
+ max?: number;
87
+ minPlaceholder?: string;
88
+ maxPlaceholder?: string;
89
+ extraOption?: boolean;
90
+ extraOptionText?: string;
91
+ };
92
+ [FEEDBACKAPPANSWERTYPE.RATING_NUMBER]: QuestionAssetsBase & {
93
+ min?: number;
94
+ max?: number;
95
+ minPlaceholder?: string;
96
+ maxPlaceholder?: string;
97
+ numberPlaceholders?: Record<number, string>;
98
+ extraOption?: boolean;
99
+ extraOptionText?: string;
100
+ ariaLabel?: string;
101
+ };
102
+ [FEEDBACKAPPANSWERTYPE.RATING_STAR]: QuestionAssetsBase & {
103
+ minPlaceholder?: string;
104
+ maxPlaceholder?: string;
105
+ };
106
+ [FEEDBACKAPPANSWERTYPE.MULTIPLECHOISE_IMAGE]: QuestionAssetsBase & {
107
+ addTitle?: boolean;
108
+ multiOption?: boolean;
109
+ extraOption?: boolean;
110
+ extraOptionValue?: any[];
111
+ };
112
+ [FEEDBACKAPPANSWERTYPE.MULTI_QUESTION_MATRIX]: QuestionAssetsBase & {
113
+ options?: string[];
114
+ exclusiveAnswers?: string[];
115
+ };
116
+ [FEEDBACKAPPANSWERTYPE.PRIORITY_LIST]: QuestionAssetsBase & {
117
+ limitPriority?: boolean;
118
+ maxPriority?: number;
119
+ };
120
+ [FEEDBACKAPPANSWERTYPE.POINT_SYSTEM]: QuestionAssetsBase;
121
+ [FEEDBACKAPPANSWERTYPE.INFO_PAGE]: QuestionAssetsBase;
122
+ [FEEDBACKAPPANSWERTYPE.UPLOAD_FILE]: QuestionAssetsBase & {
123
+ multiple?: boolean;
124
+ maxFiles?: number;
125
+ };
126
+ [FEEDBACKAPPANSWERTYPE.UPLOAD_IMAGE]: QuestionAssetsByType[FEEDBACKAPPANSWERTYPE.UPLOAD_FILE];
127
+ [FEEDBACKAPPANSWERTYPE.CONTACT]: QuestionAssetsBase;
128
+ };
129
+ export type QuestionAssetsFor<T extends FEEDBACKAPPANSWERTYPE | string> = T extends FEEDBACKAPPANSWERTYPE ? QuestionAssetsByType[T] & QuestionAssetsBase : QuestionAssetsBase;
130
+ export type NativeQuestion<T extends FEEDBACKAPPANSWERTYPE | string = FEEDBACKAPPANSWERTYPE | string> = {
42
131
  id: string;
43
132
  title: string;
44
- type: FEEDBACKAPPANSWERTYPE | string;
133
+ type: T;
45
134
  questionType: QuestionType;
46
135
  ref: string;
47
136
  require: boolean;
@@ -51,7 +140,7 @@ export type NativeQuestion = {
51
140
  appId?: string;
52
141
  followup: boolean;
53
142
  position: number;
54
- assets: any;
143
+ assets: QuestionAssetsFor<T>;
55
144
  refMetric: string;
56
145
  integrationId: string;
57
146
  integrationPageId: string;
@@ -0,0 +1,3 @@
1
+ export declare function parseTitle(title: string | Record<string, string> | undefined, lang: string): string;
2
+ export declare function getBooleanOptions(lang: string): string[];
3
+ export declare function getUrlParam(key: string): string | null;
@@ -0,0 +1,3 @@
1
+ export declare function createRatingPlaceholder(min: number, max: number, minPlaceholder?: string, maxPlaceholder?: string, extraOption?: boolean, mobile?: boolean, order?: string, direction?: string): HTMLDivElement;
2
+ export declare function createStarRating(ref: string, minPlaceholder?: string, maxPlaceholder?: string, send?: () => void, urlParamValue?: string | null): HTMLDivElement;
3
+ export declare function createRatingNumberElement(ref: string, assets: any, order: string, direction: string, isPhone: boolean, elementTypeClass: string, send?: () => void, urlParamValue?: string | null): HTMLElement;
@@ -0,0 +1,3 @@
1
+ import { FEEDBACKAPPANSWERTYPE } from "../models/types";
2
+ import { QuestionRenderer } from "./types";
3
+ export declare function getQuestionRenderer(type: FEEDBACKAPPANSWERTYPE | string): QuestionRenderer | undefined;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderBoolean: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderChoice: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderConsent: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderDate: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderEmail: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderInfoPage: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderLongText: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderMatrix: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderMultipleChoiceImage: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderNumber: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderPassword: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderPointSystem: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderPriorityList: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderRatingEmoji: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderRatingNumber: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderRatingStar: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderSelect: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderText: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderUploadFile: QuestionRenderer;
@@ -0,0 +1,2 @@
1
+ import { QuestionRenderer } from "./types";
2
+ export declare const renderUploadImage: QuestionRenderer;
@@ -0,0 +1,20 @@
1
+ import { NativeQuestion } from "../models/types";
2
+ export type RenderContext = {
3
+ question: NativeQuestion;
4
+ format: string;
5
+ language: string;
6
+ url: string;
7
+ send?: () => void;
8
+ isPhone: boolean;
9
+ urlParamValue: string | null;
10
+ placeholderText?: string;
11
+ maxCharacters: number;
12
+ randomPosition: boolean;
13
+ direction: string;
14
+ order: string;
15
+ };
16
+ export type RenderResult = {
17
+ element: HTMLElement;
18
+ elementTypeClass: string;
19
+ };
20
+ export type QuestionRenderer = (ctx: RenderContext) => RenderResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magicfeedback/native",
3
- "version": "2.1.7-alpha.8",
3
+ "version": "2.1.11",
4
4
  "main": "./dist/magicfeedback-sdk.node.js",
5
5
  "browser": "./dist/magicfeedback-sdk.browser.js",
6
6
  "types": "./dist/types/src/index.d.ts",