@roqua/quby-frontend 0.11.1 → 0.12.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/components/AnswerPage.d.ts +1 -2
- package/dist/components/Footer.d.ts +1 -0
- package/dist/components/QuestionDescription.d.ts +3 -4
- package/dist/components/TranslationCurlies.d.ts +4 -0
- package/dist/core/calculations.d.ts +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/quby_context.d.ts +2 -1
- package/dist/core/questionnaire.d.ts +9 -3
- package/dist/core/questionnaire_json.d.ts +11 -23
- package/dist/core/questionnaire_translations_curlies.d.ts +21 -0
- package/dist/core/response.d.ts +9 -1
- package/dist/logic/index.d.ts +1 -0
- package/dist/logic/use_translation_curlies_for.d.ts +2 -0
- package/dist/quby-frontend.es.js +392 -374
- package/dist/stories/_helpers.d.ts +14 -2
- package/package.json +3 -1
- package/dist/components/questions/OldSliderQuestion.d.ts +0 -9
- package/dist/core/curlies_interpolator.d.ts +0 -9
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { IDisplayOptions,
|
|
3
|
-
export declare const InterpolateCurliesContext: React.Context<IInterpolateTextvars>;
|
|
2
|
+
import { IDisplayOptions, Questionnaire, Response } from '../core';
|
|
4
3
|
interface Props {
|
|
5
4
|
questionnaire: Questionnaire;
|
|
6
5
|
response: Response;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Footer: () => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
interface HasDescription {
|
|
3
|
-
description?: string;
|
|
4
|
-
}
|
|
5
2
|
interface Props {
|
|
6
|
-
question:
|
|
3
|
+
question: {
|
|
4
|
+
key: string;
|
|
5
|
+
};
|
|
7
6
|
}
|
|
8
7
|
export declare const QuestionDescription: React.FunctionComponent<Props>;
|
|
9
8
|
export {};
|
|
@@ -12,7 +12,7 @@ export declare class Calculations {
|
|
|
12
12
|
};
|
|
13
13
|
constructor(sexpVariables: ISexpVariables, response: Response);
|
|
14
14
|
getResult(key: string): string | number | boolean | null;
|
|
15
|
-
handleValueChanged(
|
|
15
|
+
handleValueChanged(questionKey: string): string[];
|
|
16
16
|
calculate(calculation: ICalculation): string | number | null | boolean;
|
|
17
17
|
calculateNumber: (calculation: INumberCalculation) => number | null;
|
|
18
18
|
calculateBoolean: (calculation: IBooleanCalculation) => boolean | null;
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './questionnaire_json';
|
|
2
2
|
export * from './questionnaire';
|
|
3
3
|
export * from './response';
|
|
4
|
+
export * from './questionnaire_translations_curlies';
|
|
4
5
|
export * from './quby_context';
|
|
5
6
|
export * from './validators';
|
|
6
7
|
export * from './response_json';
|
|
7
|
-
export * from './curlies_interpolator';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import { Response, Questionnaire, IDisplayOptions } from '.';
|
|
2
|
+
import { Response, Questionnaire, IDisplayOptions, QuestionnaireTranslationsCurlies } from '.';
|
|
3
3
|
export type SetQuestionRef = (key: string, ref: React.RefObject<HTMLElement | null>) => void;
|
|
4
4
|
export interface IQubyContext {
|
|
5
5
|
questionnaire: Questionnaire;
|
|
6
6
|
response: Response;
|
|
7
7
|
setQuestionRef: SetQuestionRef;
|
|
8
8
|
displayOptions: IDisplayOptions;
|
|
9
|
+
translationsCurlies: QuestionnaireTranslationsCurlies;
|
|
9
10
|
}
|
|
10
11
|
export declare const QubyContext: React.Context<IQubyContext>;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { IQuestionnaire, IQuestion, IPanel, ITextvar, IValidation, IQuestions, ISexpVariables, ISelectOption, IRadioOption } from './questionnaire_json';
|
|
1
|
+
import { IQuestionnaire, IQuestion, IPanel, ITextvar, IValidation, IQuestions, ISexpVariables, ISelectOption, IRadioOption, ICheckBoxOption } from './questionnaire_json';
|
|
2
2
|
import { VisibilityRule } from './visibility_rules';
|
|
3
3
|
export declare class Questionnaire {
|
|
4
4
|
#private;
|
|
5
5
|
key: string;
|
|
6
6
|
panels: IPanel[];
|
|
7
|
-
footer?: string;
|
|
8
7
|
questions: IQuestions;
|
|
9
8
|
validations: IValidation[];
|
|
10
9
|
visibilityRules: VisibilityRule[];
|
|
@@ -15,9 +14,16 @@ export declare class Questionnaire {
|
|
|
15
14
|
[key: string]: string | number;
|
|
16
15
|
} | undefined;
|
|
17
16
|
layoutVersion: "v1" | "v2";
|
|
17
|
+
defaultLanguage: string;
|
|
18
|
+
translations: {
|
|
19
|
+
[language: string]: {
|
|
20
|
+
[key: string]: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
18
23
|
constructor(data: IQuestionnaire);
|
|
19
24
|
getField(key: string): IQuestion;
|
|
20
25
|
getQuestionsInSameGroup(questionKey: string): IQuestion[];
|
|
21
|
-
|
|
26
|
+
getChildQuestionKeys(questionKey: string): string[];
|
|
27
|
+
getFlatOptions(questionKey: string): (ISelectOption | IRadioOption | ICheckBoxOption)[];
|
|
22
28
|
getOptionNumberValue(questionKey: string, optionKey: string): number | null;
|
|
23
29
|
}
|
|
@@ -78,10 +78,7 @@ export interface IMinimumCheckedRequiredValidation {
|
|
|
78
78
|
}
|
|
79
79
|
interface IBaseField {
|
|
80
80
|
key: string;
|
|
81
|
-
|
|
82
|
-
description?: string;
|
|
83
|
-
contextDescription?: string;
|
|
84
|
-
presentation: "horizontal" | "vertical";
|
|
81
|
+
presentation?: "horizontal" | "vertical";
|
|
85
82
|
questionGroup?: string | null;
|
|
86
83
|
as?: string | null;
|
|
87
84
|
parentKey?: string;
|
|
@@ -130,9 +127,9 @@ export interface IFloatQuestion extends IBaseField, INumberQuestion {
|
|
|
130
127
|
export interface ISliderQuestion extends IBaseField {
|
|
131
128
|
type: "float" | "integer";
|
|
132
129
|
as: "slider";
|
|
130
|
+
labelsI18nKey?: string;
|
|
133
131
|
step: number;
|
|
134
132
|
defaultPosition: number;
|
|
135
|
-
labels: string[];
|
|
136
133
|
startThumbHidden: boolean;
|
|
137
134
|
valueTooltip: boolean;
|
|
138
135
|
minimum: number;
|
|
@@ -150,7 +147,6 @@ export interface ISelectQuestion extends IBaseField {
|
|
|
150
147
|
type: "select";
|
|
151
148
|
as: "select";
|
|
152
149
|
children: (ISelectOption | IOptgroup)[];
|
|
153
|
-
placeholder: string;
|
|
154
150
|
}
|
|
155
151
|
export interface IRadioQuestion extends IBaseField {
|
|
156
152
|
type: "radio";
|
|
@@ -180,35 +176,22 @@ export interface IOption {
|
|
|
180
176
|
}
|
|
181
177
|
export interface ICheckBoxOption extends IOption {
|
|
182
178
|
questions: IQuestion[];
|
|
183
|
-
label?: string;
|
|
184
|
-
description?: string;
|
|
185
179
|
}
|
|
186
180
|
export interface IRadioOption extends IOption {
|
|
187
181
|
value: number;
|
|
188
182
|
questions: IQuestion[];
|
|
189
|
-
label?: string;
|
|
190
|
-
description?: string;
|
|
191
183
|
}
|
|
192
184
|
export interface IOptgroup {
|
|
193
185
|
type: "optgroup";
|
|
194
186
|
key: string;
|
|
195
|
-
label: string;
|
|
196
187
|
options: ISelectOption[];
|
|
197
188
|
}
|
|
198
189
|
export interface ISelectOption extends IOption {
|
|
199
190
|
value: number;
|
|
200
|
-
label?: string;
|
|
201
|
-
description?: string;
|
|
202
191
|
}
|
|
203
192
|
export interface IHtmlOption {
|
|
204
193
|
type: "html";
|
|
205
194
|
key: string;
|
|
206
|
-
html: string;
|
|
207
|
-
}
|
|
208
|
-
export interface IPlaceholderOption {
|
|
209
|
-
type: "placeholder";
|
|
210
|
-
key: string;
|
|
211
|
-
description: string;
|
|
212
195
|
}
|
|
213
196
|
export type IQuestion = IDatePartsQuestion | IStringQuestion | ITextareaQuestion | IIntegerQuestion | IFloatQuestion | ISliderQuestion | ISplitToUnitsQuestion | IRadioQuestion | IScaleQuestion | ISelectQuestion | ICheckBoxQuestion;
|
|
214
197
|
export interface IQuestions {
|
|
@@ -216,7 +199,7 @@ export interface IQuestions {
|
|
|
216
199
|
}
|
|
217
200
|
export interface IHtmlItem {
|
|
218
201
|
type: 'html';
|
|
219
|
-
|
|
202
|
+
key: string;
|
|
220
203
|
}
|
|
221
204
|
export interface IQuestionItem {
|
|
222
205
|
type: "question";
|
|
@@ -227,14 +210,14 @@ export interface ITableItem {
|
|
|
227
210
|
}
|
|
228
211
|
export interface IInfoItem {
|
|
229
212
|
type: "info";
|
|
213
|
+
subtype?: "info" | "question-bar";
|
|
230
214
|
key: string;
|
|
231
|
-
html: string;
|
|
232
215
|
startOpen: boolean;
|
|
233
216
|
items: Array<IHtmlItem | IQuestionItem>;
|
|
234
217
|
}
|
|
235
218
|
export type IPanelItem = IHtmlItem | IQuestionItem | ITableItem | IInfoItem;
|
|
236
219
|
export interface IPanel {
|
|
237
|
-
|
|
220
|
+
key: string;
|
|
238
221
|
items: IPanelItem[];
|
|
239
222
|
questionKeys: string[];
|
|
240
223
|
}
|
|
@@ -331,10 +314,14 @@ export type ISexpVariables = {
|
|
|
331
314
|
calculation: ICalculation;
|
|
332
315
|
};
|
|
333
316
|
};
|
|
317
|
+
export type ITranslations = {
|
|
318
|
+
[language: string]: {
|
|
319
|
+
[key: string]: string;
|
|
320
|
+
};
|
|
321
|
+
};
|
|
334
322
|
export interface IQuestionnaire {
|
|
335
323
|
key: string;
|
|
336
324
|
title: string;
|
|
337
|
-
footer?: string;
|
|
338
325
|
language: string;
|
|
339
326
|
panels: IPanel[];
|
|
340
327
|
questions: IQuestions;
|
|
@@ -349,6 +336,7 @@ export interface IQuestionnaire {
|
|
|
349
336
|
[key: string]: string;
|
|
350
337
|
};
|
|
351
338
|
layoutVersion?: "v1" | "v2";
|
|
339
|
+
translations: ITranslations;
|
|
352
340
|
}
|
|
353
341
|
export interface IDisplayOptions {
|
|
354
342
|
displayMode: "paged" | "single_page" | "bulk";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Questionnaire } from './questionnaire';
|
|
2
|
+
import { Response } from './response';
|
|
3
|
+
export declare class QuestionnaireTranslationsCurlies {
|
|
4
|
+
response: Response;
|
|
5
|
+
questionnaire: Questionnaire;
|
|
6
|
+
keyToInterpolatedString: Map<string, string>;
|
|
7
|
+
keyToInterpolatedStringArray: Map<string, string[]>;
|
|
8
|
+
variableToKeys: Map<string, string[]>;
|
|
9
|
+
language: string;
|
|
10
|
+
translations: {
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
};
|
|
13
|
+
callbacks: Map<string, Set<() => void>>;
|
|
14
|
+
subscribeMethods: Map<string, (callback: () => void) => () => void>;
|
|
15
|
+
constructor(response: Response, questionnaire: Questionnaire, language: string);
|
|
16
|
+
subscribeToKey(key: string): (cb: () => void) => () => void;
|
|
17
|
+
fetch(key: string): string | undefined;
|
|
18
|
+
fetchArray(key: string): string[];
|
|
19
|
+
private interpolateCurlies;
|
|
20
|
+
private buildVariableToKeys;
|
|
21
|
+
}
|
package/dist/core/response.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export interface IVisibility {
|
|
|
32
32
|
hidden: boolean;
|
|
33
33
|
}
|
|
34
34
|
export interface IValidated {
|
|
35
|
+
key: string;
|
|
35
36
|
showErrors: boolean;
|
|
36
37
|
valid: boolean;
|
|
37
38
|
errors: IError[];
|
|
@@ -50,7 +51,7 @@ export interface IValidationFieldState<T extends IValue> {
|
|
|
50
51
|
value: T;
|
|
51
52
|
addError: (error: IError) => void;
|
|
52
53
|
}
|
|
53
|
-
export type IChangeCallback = (response: Response, type
|
|
54
|
+
export type IChangeCallback = (response: Response, type: "valueChanged" | "visibilityChanged" | "textvarChanged" | "sexpVariableChanged", key?: string) => void;
|
|
54
55
|
export declare class Response {
|
|
55
56
|
questionnaire: Questionnaire;
|
|
56
57
|
values: IValues;
|
|
@@ -59,6 +60,9 @@ export declare class Response {
|
|
|
59
60
|
errors: Map<string, IError[]>;
|
|
60
61
|
visibility: Map<string, IVisibility>;
|
|
61
62
|
changeHandlers: IChangeCallback[];
|
|
63
|
+
questionCallbacks: Map<string, () => void>;
|
|
64
|
+
subscribeMethods: Map<string, (callback: () => void) => () => void>;
|
|
65
|
+
fieldStates: Map<string, IFieldState<IValue>>;
|
|
62
66
|
flags: IFlags;
|
|
63
67
|
textvars: ITextvars;
|
|
64
68
|
activeQuestionKey: string | null;
|
|
@@ -68,11 +72,15 @@ export declare class Response {
|
|
|
68
72
|
cleanValues(): IValues;
|
|
69
73
|
onChange(callback: IChangeCallback): void;
|
|
70
74
|
offChange(callback: IChangeCallback): void;
|
|
75
|
+
subscribeToQuestion(questionKey: string): (callback: () => void) => () => void;
|
|
71
76
|
getFieldState<T extends IValue>(key: string): IFieldState<T>;
|
|
72
77
|
getValidationFieldState<T extends IValue>(key: string): IValidationFieldState<T>;
|
|
78
|
+
getVisibilityFieldState(key: string): Pick<IFieldState<IValue>, "value" | "hidden" | "disabled">;
|
|
73
79
|
setTextvar(key: string, value: string | null): void;
|
|
74
80
|
initTextvars(fromServer: ITextvars): Map<string, string>;
|
|
75
81
|
setValue<T extends IValue>(key: string, value: T | null): void;
|
|
82
|
+
handleCalculations(questionKey: string): void;
|
|
83
|
+
fieldStateChanged(key: string): void;
|
|
76
84
|
setActiveQuestion(key: string | null): void;
|
|
77
85
|
addError(key: string, error: IError): void;
|
|
78
86
|
valueHasChanged(): boolean;
|
package/dist/logic/index.d.ts
CHANGED