@roqua/quby-frontend 0.10.7 → 0.10.9

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.
@@ -7,6 +7,8 @@ interface Props {
7
7
  displayOptions: IDisplayOptions;
8
8
  allowSkipValidation?: boolean;
9
9
  onSave: () => void;
10
+ onAbort?: () => void;
11
+ onPreviousQuestionnaire?: () => void;
10
12
  }
11
13
  export declare const AnswerPage: React.FunctionComponent<Props>;
12
14
  export {};
@@ -14,6 +14,8 @@ type CanProceed = boolean;
14
14
  interface Props {
15
15
  beforeNext: (panelIndex: number) => CanProceed;
16
16
  panelLogic: PanelLogic;
17
+ onPreviousQuestionnaire?: () => void;
18
+ onAbort?: () => void;
17
19
  onDone: () => void;
18
20
  onFocus: () => void;
19
21
  nextSavePressWillOnlyRunMinimalValidations: boolean;
@@ -7,6 +7,8 @@ export interface Props {
7
7
  unsavedResponseWarning?: string;
8
8
  allowSkipValidation?: boolean;
9
9
  onSave: (response: Response) => void;
10
+ onAbort?: (response: Response) => void;
11
+ onPreviousQuestionnaire?: (response: Response) => void;
10
12
  newLayout?: boolean;
11
13
  darkMode?: boolean;
12
14
  }
@@ -1,4 +1,4 @@
1
- import { ICalculation, INumberCalculation, ISexpVariables } from './questionnaire_json';
1
+ import { IBooleanCalculation, ICalcBooleanReducer, ICalcComparer, ICalculation, INumberCalculation, ISexpVariables } from './questionnaire_json';
2
2
  import { Response } from './response';
3
3
  type INumberReducer = (acc: number, value: number) => number;
4
4
  export declare class Calculations {
@@ -8,17 +8,20 @@ export declare class Calculations {
8
8
  };
9
9
  response: Response;
10
10
  results: {
11
- [key: string]: string | number | null;
11
+ [key: string]: string | number | boolean | null;
12
12
  };
13
13
  constructor(sexpVariables: ISexpVariables, response: Response);
14
14
  handleValueChanged(key: string): void;
15
- calculate(calculation: ICalculation): string | number | null;
16
- calculateNumber(calculation: INumberCalculation): number | null;
15
+ calculate(calculation: ICalculation): string | number | null | boolean;
16
+ calculateNumber: (calculation: INumberCalculation) => number | null;
17
+ calculateBoolean: (calculation: IBooleanCalculation) => boolean | null;
17
18
  static numberReducers: {
18
19
  [key: string]: INumberReducer;
19
20
  };
20
21
  stringValue(key: string): string | null;
21
22
  reduce(calculations: INumberCalculation[], op: "sum" | "subtract" | "multiply" | "divide"): number | null;
23
+ compare: (calculation: ICalcComparer) => boolean | null;
24
+ booleanReduce: (calculation: ICalcBooleanReducer) => boolean | null;
22
25
  round(calculation: INumberCalculation, digits: number): number | null;
23
26
  }
24
27
  export {};
@@ -1,6 +1,7 @@
1
- import { IQuestionnaire, IQuestion, IPanel, ITextvar, IValidation, IQuestions, ISexpVariables } from "./questionnaire_json";
1
+ import { IQuestionnaire, IQuestion, IPanel, ITextvar, IValidation, IQuestions, ISexpVariables, ISelectOption, IRadioOption } from "./questionnaire_json";
2
2
  import { VisibilityRule } from "./visibility_rules";
3
3
  export declare class Questionnaire {
4
+ #private;
4
5
  key: string;
5
6
  panels: IPanel[];
6
7
  footer?: string;
@@ -17,5 +18,6 @@ export declare class Questionnaire {
17
18
  constructor(data: IQuestionnaire);
18
19
  getField(key: string): IQuestion;
19
20
  getQuestionsInSameGroup(questionKey: string): IQuestion[];
21
+ getFlatOptions(questionKey: string): (ISelectOption | IRadioOption)[];
20
22
  getOptionNumberValue(questionKey: string, optionKey: string): number | null;
21
23
  }
@@ -146,7 +146,7 @@ export interface ISplitToUnitsQuestion extends IBaseField, INumberQuestion {
146
146
  export interface ISelectQuestion extends IBaseField {
147
147
  type: "select";
148
148
  as: "select";
149
- children: (ISelectOption)[];
149
+ children: (ISelectOption | IOptgroup)[];
150
150
  placeholder: string;
151
151
  }
152
152
  export interface IRadioQuestion extends IBaseField {
@@ -186,6 +186,12 @@ export interface IRadioOption extends IOption {
186
186
  label?: string;
187
187
  description?: string;
188
188
  }
189
+ export interface IOptgroup {
190
+ type: "optgroup";
191
+ key: string;
192
+ label: string;
193
+ options: ISelectOption[];
194
+ }
189
195
  export interface ISelectOption extends IOption {
190
196
  value: number;
191
197
  label?: string;
@@ -292,13 +298,26 @@ interface ICalcNumberReducer {
292
298
  op: 'sum' | 'subtract' | 'multiply' | 'divide';
293
299
  values: INumberCalculation[];
294
300
  }
301
+ export declare const ICalcBooleanReducerOpsSchema: z.ZodEnum<["all", "some", "none"]>;
302
+ export declare const ICalcComparerOpsSchema: z.ZodEnum<["eq", "not_eq", "gt", "gteq", "lt", "lteq"]>;
303
+ export declare const ICalcBooleanOpsSchema: z.ZodEnum<["all", "some", "none", "eq", "not_eq", "gt", "gteq", "lt", "lteq"]>;
304
+ export interface ICalcBooleanReducer {
305
+ op: z.infer<typeof ICalcBooleanReducerOpsSchema>;
306
+ values: IBooleanCalculation[];
307
+ }
308
+ export interface ICalcComparer {
309
+ op: z.infer<typeof ICalcComparerOpsSchema>;
310
+ left: INumberCalculation;
311
+ right: INumberCalculation;
312
+ }
295
313
  interface ICalcRound {
296
314
  op: 'round';
297
315
  value: INumberCalculation;
298
316
  digits: number;
299
317
  }
300
318
  export type INumberCalculation = ICalcNumber | ICalcNumberValue | ICalcNumberReducer | ICalcRound;
301
- export type ICalculation = INumberCalculation | ICalcStringValue;
319
+ export type IBooleanCalculation = ICalcComparer | ICalcBooleanReducer;
320
+ export type ICalculation = INumberCalculation | IBooleanCalculation | ICalcStringValue;
302
321
  export type ISexpVariables = {
303
322
  [key: string]: {
304
323
  calculation: ICalculation;