@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.
- package/README.md +315 -467
- package/dist/magicfeedback-sdk.browser.js +1 -1
- package/dist/magicfeedback-sdk.node.js +1 -1
- package/dist/styles/magicfeedback-default.css +268 -148
- package/dist/types/src/models/pageGraphs.d.ts +52 -0
- package/dist/types/src/models/types.d.ts +92 -3
- package/dist/types/src/render/helpers.d.ts +3 -0
- package/dist/types/src/render/ratingHelpers.d.ts +3 -0
- package/dist/types/src/render/registry.d.ts +3 -0
- package/dist/types/src/render/renderBoolean.d.ts +2 -0
- package/dist/types/src/render/renderChoice.d.ts +2 -0
- package/dist/types/src/render/renderConsent.d.ts +2 -0
- package/dist/types/src/render/renderDate.d.ts +2 -0
- package/dist/types/src/render/renderEmail.d.ts +2 -0
- package/dist/types/src/render/renderInfoPage.d.ts +2 -0
- package/dist/types/src/render/renderLongText.d.ts +2 -0
- package/dist/types/src/render/renderMatrix.d.ts +2 -0
- package/dist/types/src/render/renderMultipleChoiceImage.d.ts +2 -0
- package/dist/types/src/render/renderNumber.d.ts +2 -0
- package/dist/types/src/render/renderPassword.d.ts +2 -0
- package/dist/types/src/render/renderPointSystem.d.ts +2 -0
- package/dist/types/src/render/renderPriorityList.d.ts +2 -0
- package/dist/types/src/render/renderRatingEmoji.d.ts +2 -0
- package/dist/types/src/render/renderRatingNumber.d.ts +2 -0
- package/dist/types/src/render/renderRatingStar.d.ts +2 -0
- package/dist/types/src/render/renderSelect.d.ts +2 -0
- package/dist/types/src/render/renderText.d.ts +2 -0
- package/dist/types/src/render/renderUploadFile.d.ts +2 -0
- package/dist/types/src/render/renderUploadImage.d.ts +2 -0
- package/dist/types/src/render/types.d.ts +20 -0
- 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
|
|
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:
|
|
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:
|
|
143
|
+
assets: QuestionAssetsFor<T>;
|
|
55
144
|
refMetric: string;
|
|
56
145
|
integrationId: string;
|
|
57
146
|
integrationPageId: string;
|
|
@@ -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,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;
|