@awell-health/ui-library 0.1.100 → 0.1.102
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/index.js
CHANGED
|
@@ -16245,6 +16245,7 @@ Check the top-level render call using <` + t + ">.");
|
|
|
16245
16245
|
exports.ElementType = void 0;
|
|
16246
16246
|
(function (ElementType) {
|
|
16247
16247
|
ElementType["Action"] = "ACTION";
|
|
16248
|
+
ElementType["Agent"] = "AGENT";
|
|
16248
16249
|
ElementType["Pathway"] = "PATHWAY";
|
|
16249
16250
|
ElementType["Step"] = "STEP";
|
|
16250
16251
|
ElementType["Track"] = "TRACK";
|
|
@@ -48233,10 +48234,10 @@ var Kr=[{
|
|
|
48233
48234
|
|
|
48234
48235
|
var AUTO_PROGRESS_DELAY = 850;
|
|
48235
48236
|
var QuestionData = function (_a) {
|
|
48236
|
-
var _b, _c, _d, _e, _f;
|
|
48237
|
-
var question = _a.question,control = _a.control,getValues = _a.getValues,labels = _a.labels,
|
|
48237
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
48238
|
+
var question = _a.question,control = _a.control,getValues = _a.getValues,labels = _a.labels,_o = _a.inputAutoFocus,inputAutoFocus = _o === void 0 ? false : _o,_p = _a.submitAndMoveToNextQuestion,submitAndMoveToNextQuestion = _p === void 0 ? lodash.exports.noop : _p,_q = _a.onAnswerChange,onAnswerChange = _q === void 0 ? lodash.exports.noop : _q,_r = _a.shouldAutoProgress,shouldAutoProgress = _r === void 0 ? function () {return false;} : _r,onFileUpload = _a.onFileUpload;
|
|
48238
48239
|
var config = question === null || question === void 0 ? void 0 : question.questionConfig;
|
|
48239
|
-
var
|
|
48240
|
+
var _s = useICDClassificationList(question.id),icdClassificationOptions = _s.options,optionsLoading = _s.loading,onIcdClassificationSearchChange = _s.onIcdClassificationSearchChange;
|
|
48240
48241
|
switch (question.userQuestionType) {
|
|
48241
48242
|
case exports.UserQuestionType.YesNo:
|
|
48242
48243
|
return jsxRuntime.exports.jsx(Controller, { name: question.id, control: control, defaultValue: "", rules: { required: config === null || config === void 0 ? void 0 : config.mandatory }, render: function (_a) {
|
|
@@ -48329,19 +48330,28 @@ var Kr=[{
|
|
|
48329
48330
|
onAnswerChange();
|
|
48330
48331
|
}, label: question.title, id: question.id, value: value, mandatory: config === null || config === void 0 ? void 0 : config.mandatory, min: getMinValueForNumberInput(config === null || config === void 0 ? void 0 : config.number), max: getMaxValueForNumberInput(config === null || config === void 0 ? void 0 : config.number) });
|
|
48331
48332
|
} });
|
|
48332
|
-
case exports.UserQuestionType.ShortText:
|
|
48333
|
-
|
|
48334
|
-
|
|
48335
|
-
|
|
48336
|
-
|
|
48337
|
-
|
|
48338
|
-
|
|
48339
|
-
|
|
48333
|
+
case exports.UserQuestionType.ShortText:{
|
|
48334
|
+
var hasValidInputValidation = !!(config === null || config === void 0 ? void 0 : config.input_validation) &&
|
|
48335
|
+
typeof ((_b = config === null || config === void 0 ? void 0 : config.input_validation) === null || _b === void 0 ? void 0 : _b.pattern) === 'string' &&
|
|
48336
|
+
((_c = config === null || config === void 0 ? void 0 : config.input_validation) === null || _c === void 0 ? void 0 : _c.pattern.length) > 0;
|
|
48337
|
+
return jsxRuntime.exports.jsx(Controller, { name: question.id, control: control, defaultValue: "", rules: __assign({ required: config === null || config === void 0 ? void 0 : config.mandatory }, hasValidInputValidation && {
|
|
48338
|
+
pattern: {
|
|
48339
|
+
value: new RegExp((_e = (_d = config === null || config === void 0 ? void 0 : config.input_validation) === null || _d === void 0 ? void 0 : _d.pattern) !== null && _e !== void 0 ? _e : ''),
|
|
48340
|
+
message: (_g = (_f = config === null || config === void 0 ? void 0 : config.input_validation) === null || _f === void 0 ? void 0 : _f.helper_text) !== null && _g !== void 0 ? _g : 'The input value is invalid.' } }),
|
|
48341
|
+
|
|
48342
|
+
render: function (_a) {
|
|
48343
|
+
var _b = _a.field,onChange = _b.onChange,value = _b.value,error = _a.fieldState.error;
|
|
48344
|
+
return jsxRuntime.exports.jsxs(jsxRuntime.exports.Fragment, { children: [jsxRuntime.exports.jsx(InputField, { autoFocus: inputAutoFocus, type: "text", onChange: function (e) {
|
|
48345
|
+
onChange(e.target.value);
|
|
48346
|
+
onAnswerChange();
|
|
48347
|
+
}, label: question.title, id: question.id, value: value, mandatory: config === null || config === void 0 ? void 0 : config.mandatory }), error && jsxRuntime.exports.jsx(Text, __assign({ variant: "textSmall", color: "var(--awell-signalError100)" }, { children: error.message }))] });
|
|
48348
|
+
} });
|
|
48349
|
+
}
|
|
48340
48350
|
case exports.UserQuestionType.Telephone:
|
|
48341
|
-
var availableCountries_1 = ((
|
|
48351
|
+
var availableCountries_1 = ((_j = (_h = config === null || config === void 0 ? void 0 : config.phone) === null || _h === void 0 ? void 0 : _h.available_countries) !== null && _j !== void 0 ? _j : []).
|
|
48342
48352
|
map(function (c) {return c === null || c === void 0 ? void 0 : c.toLocaleLowerCase();}).
|
|
48343
48353
|
filter(function (x) {return !lodash.exports.isNil(x);});
|
|
48344
|
-
var initialCountry_1 = (
|
|
48354
|
+
var initialCountry_1 = (_m = (_l = (_k = config === null || config === void 0 ? void 0 : config.phone) === null || _k === void 0 ? void 0 : _k.default_country) === null || _l === void 0 ? void 0 : _l.toLocaleLowerCase()) !== null && _m !== void 0 ? _m : 'gb';
|
|
48345
48355
|
return jsxRuntime.exports.jsx(Controller, { name: question.id, control: control, defaultValue: "", render: function (_a) {
|
|
48346
48356
|
var _b;
|
|
48347
48357
|
var _c = _a.field,onChange = _c.onChange,value = _c.value;
|
|
@@ -48779,6 +48789,26 @@ var Kr=[{
|
|
|
48779
48789
|
return {
|
|
48780
48790
|
isValid: true };
|
|
48781
48791
|
|
|
48792
|
+
};
|
|
48793
|
+
var validateInputValidationResponse = function (questionConfig, value) {
|
|
48794
|
+
if (!questionConfig || !questionConfig.input_validation) {
|
|
48795
|
+
return {
|
|
48796
|
+
isValid: true };
|
|
48797
|
+
|
|
48798
|
+
}
|
|
48799
|
+
var pattern = questionConfig.input_validation.pattern;
|
|
48800
|
+
if (pattern) {
|
|
48801
|
+
var regex = new RegExp(pattern);
|
|
48802
|
+
if (!regex.test(value)) {
|
|
48803
|
+
return {
|
|
48804
|
+
isValid: false,
|
|
48805
|
+
errorType: 'INVALID_FORMAT' };
|
|
48806
|
+
|
|
48807
|
+
}
|
|
48808
|
+
}
|
|
48809
|
+
return {
|
|
48810
|
+
isValid: true };
|
|
48811
|
+
|
|
48782
48812
|
};
|
|
48783
48813
|
return {
|
|
48784
48814
|
isValidE164Number: isValidE164Number,
|
|
@@ -48788,7 +48818,8 @@ var Kr=[{
|
|
|
48788
48818
|
validateDateResponse: validateDateResponse,
|
|
48789
48819
|
validateNumberResponse: validateNumberResponse,
|
|
48790
48820
|
validateEmailResponse: validateEmailResponse,
|
|
48791
|
-
validateAttachmentsResponse: validateAttachmentsResponse
|
|
48821
|
+
validateAttachmentsResponse: validateAttachmentsResponse,
|
|
48822
|
+
validateInputValidationResponse: validateInputValidationResponse };
|
|
48792
48823
|
|
|
48793
48824
|
};
|
|
48794
48825
|
|
|
@@ -48872,8 +48903,8 @@ var Kr=[{
|
|
|
48872
48903
|
}
|
|
48873
48904
|
return Math.round((currentQuestionIndex + 1) / allQuestions.length * 100);
|
|
48874
48905
|
};
|
|
48875
|
-
var getErrorsForQuestion = function (currentQuestion, formMethods, errorLabels, isValidE164Number, validateDateResponse, validateNumberResponse, validateEmailResponse, validateAttachmentsResponse) {
|
|
48876
|
-
var _a;
|
|
48906
|
+
var getErrorsForQuestion = function (currentQuestion, formMethods, errorLabels, isValidE164Number, validateDateResponse, validateNumberResponse, validateEmailResponse, validateAttachmentsResponse, validateInputValidationResponse) {
|
|
48907
|
+
var _a, _b, _c;
|
|
48877
48908
|
if ((currentQuestion === null || currentQuestion === void 0 ? void 0 : currentQuestion.userQuestionType) === exports.UserQuestionType.Description) {
|
|
48878
48909
|
return [];
|
|
48879
48910
|
}
|
|
@@ -48976,6 +49007,20 @@ var Kr=[{
|
|
|
48976
49007
|
|
|
48977
49008
|
|
|
48978
49009
|
|
|
49010
|
+
}
|
|
49011
|
+
}
|
|
49012
|
+
if ((currentQuestion === null || currentQuestion === void 0 ? void 0 : currentQuestion.userQuestionType) === exports.UserQuestionType.ShortText) {
|
|
49013
|
+
var error = validateInputValidationResponse(currentQuestion === null || currentQuestion === void 0 ? void 0 : currentQuestion.questionConfig, valueOfCurrentQuestion);
|
|
49014
|
+
if (error.isValid === false) {
|
|
49015
|
+
switch (error.errorType) {
|
|
49016
|
+
case 'INVALID_FORMAT':
|
|
49017
|
+
return [
|
|
49018
|
+
{
|
|
49019
|
+
id: currentQuestion.id,
|
|
49020
|
+
error: ((_c = (_b = currentQuestion === null || currentQuestion === void 0 ? void 0 : currentQuestion.questionConfig) === null || _b === void 0 ? void 0 : _b.input_validation) === null || _c === void 0 ? void 0 : _c.helper_text) || 'The input value is invalid.' }];}
|
|
49021
|
+
|
|
49022
|
+
|
|
49023
|
+
|
|
48979
49024
|
}
|
|
48980
49025
|
}
|
|
48981
49026
|
return [];
|
|
@@ -49015,7 +49060,7 @@ var Kr=[{
|
|
|
49015
49060
|
var _d = React.useState([]),errors = _d[0],setErrors = _d[1];
|
|
49016
49061
|
var _e = React.useState(false),formHasErrors = _e[0],setFormHasErrors = _e[1];
|
|
49017
49062
|
var _f = React.useState(false),isSubmittingForm = _f[0],setIsSubmittingForm = _f[1];
|
|
49018
|
-
var _g = useValidate(),isValidE164Number = _g.isValidE164Number,validateDateResponse = _g.validateDateResponse,validateNumberResponse = _g.validateNumberResponse,validateEmailResponse = _g.validateEmailResponse,validateAttachmentsResponse = _g.validateAttachmentsResponse;
|
|
49063
|
+
var _g = useValidate(),isValidE164Number = _g.isValidE164Number,validateDateResponse = _g.validateDateResponse,validateNumberResponse = _g.validateNumberResponse,validateEmailResponse = _g.validateEmailResponse,validateAttachmentsResponse = _g.validateAttachmentsResponse,validateInputValidationResponse = _g.validateInputValidationResponse;
|
|
49019
49064
|
var updateQuestionVisibility = React.useCallback(function () {return __awaiter(void 0, void 0, void 0, function () {
|
|
49020
49065
|
var formValuesInput, evaluationResults, updatedQuestions;
|
|
49021
49066
|
return __generator(this, function (_a) {
|
|
@@ -49084,7 +49129,7 @@ var Kr=[{
|
|
|
49084
49129
|
case 1:
|
|
49085
49130
|
_a.sent();
|
|
49086
49131
|
formErrors = visibleQuestions.flatMap(function (vq) {
|
|
49087
|
-
return getErrorsForQuestion(vq, formMethods, errorLabels, isValidE164Number, validateDateResponse, validateNumberResponse, validateEmailResponse, validateAttachmentsResponse);
|
|
49132
|
+
return getErrorsForQuestion(vq, formMethods, errorLabels, isValidE164Number, validateDateResponse, validateNumberResponse, validateEmailResponse, validateAttachmentsResponse, validateInputValidationResponse);
|
|
49088
49133
|
});
|
|
49089
49134
|
setErrors(formErrors);
|
|
49090
49135
|
if (formErrors.length === 0) {
|
|
@@ -49112,7 +49157,7 @@ var Kr=[{
|
|
|
49112
49157
|
var useConversationalForm = function (_a) {
|
|
49113
49158
|
var questions = _a.questions,evaluateDisplayConditions = _a.evaluateDisplayConditions,onSubmit = _a.onSubmit,errorLabels = _a.errorLabels,storedAnswers = _a.storedAnswers,_b = _a.autosaveAnswers,autosaveAnswers = _b === void 0 ? true : _b,onAnswersChange = _a.onAnswersChange;
|
|
49114
49159
|
var initialValues = convertToFormFormat(storedAnswers, questions);
|
|
49115
|
-
var _c = useValidate(),isValidE164Number = _c.isValidE164Number,validateDateResponse = _c.validateDateResponse,validateNumberResponse = _c.validateNumberResponse,validateEmailResponse = _c.validateEmailResponse,validateAttachmentsResponse = _c.validateAttachmentsResponse;
|
|
49160
|
+
var _c = useValidate(),isValidE164Number = _c.isValidE164Number,validateDateResponse = _c.validateDateResponse,validateNumberResponse = _c.validateNumberResponse,validateEmailResponse = _c.validateEmailResponse,validateAttachmentsResponse = _c.validateAttachmentsResponse,validateInputValidationResponse = _c.validateInputValidationResponse;
|
|
49116
49161
|
var formMethods = useForm({
|
|
49117
49162
|
defaultValues: getInitialValues(questions),
|
|
49118
49163
|
shouldUnregister: false,
|
|
@@ -49181,7 +49226,7 @@ var Kr=[{
|
|
|
49181
49226
|
}, []);
|
|
49182
49227
|
var handleCheckForErrors = function (currentQuestion) {
|
|
49183
49228
|
var errorsWithoutCurrent = errors.filter(function (err) {return err.id !== (currentQuestion === null || currentQuestion === void 0 ? void 0 : currentQuestion.id);});
|
|
49184
|
-
var existingErrors = getErrorsForQuestion(currentQuestion, formMethods, errorLabels, isValidE164Number, validateDateResponse, validateNumberResponse, validateEmailResponse, validateAttachmentsResponse);
|
|
49229
|
+
var existingErrors = getErrorsForQuestion(currentQuestion, formMethods, errorLabels, isValidE164Number, validateDateResponse, validateNumberResponse, validateEmailResponse, validateAttachmentsResponse, validateInputValidationResponse);
|
|
49185
49230
|
setErrors(__spreadArray(__spreadArray([], errorsWithoutCurrent, true), existingErrors, true));
|
|
49186
49231
|
return existingErrors.length > 0;
|
|
49187
49232
|
};
|
|
@@ -3,7 +3,7 @@ import { Question, QuestionWithVisibility, FormError } from '../../types';
|
|
|
3
3
|
import { AnswerValue, ErrorLabels, QuestionRuleResult } from './types';
|
|
4
4
|
import { CountryIso2 } from 'react-international-phone';
|
|
5
5
|
import { Maybe, QuestionConfig } from '../../types/generated/types-orchestration';
|
|
6
|
-
import { AttachmentsValidationErrorType, DateValidationErrorType, EmailValidationErrorType, NumberValidationErrorType } from '../useValidate/useValidate';
|
|
6
|
+
import { AttachmentsValidationErrorType, DateValidationErrorType, EmailValidationErrorType, InputValidationErrorType, NumberValidationErrorType } from '../useValidate/useValidate';
|
|
7
7
|
export declare const getDefaultValue: (question: Question) => AnswerValue;
|
|
8
8
|
export declare const getInitialValues: (questions: Array<Question>) => Record<string, AnswerValue>;
|
|
9
9
|
export declare const convertToAwellInput: (formResponse: any) => {
|
|
@@ -30,6 +30,9 @@ export declare const getErrorsForQuestion: (currentQuestion: QuestionWithVisibil
|
|
|
30
30
|
}, validateAttachmentsResponse: (questionConfig: Maybe<QuestionConfig> | undefined, value: string) => {
|
|
31
31
|
isValid: boolean;
|
|
32
32
|
errorType?: AttachmentsValidationErrorType;
|
|
33
|
+
}, validateInputValidationResponse: (questionConfig: Maybe<QuestionConfig> | undefined, value: string) => {
|
|
34
|
+
isValid: boolean;
|
|
35
|
+
errorType?: InputValidationErrorType;
|
|
33
36
|
}) => Array<FormError>;
|
|
34
37
|
export declare const getDirtyFieldValues: (formMethods: UseFormReturn) => Record<string, AnswerValue>;
|
|
35
38
|
export declare const markInitialValuesAsDirty: ({ formMethods, defaultValues, initialValues, }: {
|
|
@@ -4,6 +4,7 @@ export declare type DateValidationErrorType = 'DATE_CANNOT_BE_IN_THE_FUTURE' | '
|
|
|
4
4
|
export declare type NumberValidationErrorType = 'NOT_A_NUMBER' | 'OUT_OF_RANGE';
|
|
5
5
|
export declare type EmailValidationErrorType = 'INVALID_FORMAT';
|
|
6
6
|
export declare type AttachmentsValidationErrorType = 'REQUIRED' | 'INVALID_FORMAT';
|
|
7
|
+
export declare type InputValidationErrorType = 'INVALID_FORMAT';
|
|
7
8
|
export interface UseValidateHook {
|
|
8
9
|
validatePhoneNumber: (number: string, availableCountries?: Array<CountryIso2>) => ValidatePhoneReturn;
|
|
9
10
|
isValidE164Number: (number: string, availableCountries?: Array<CountryIso2>) => boolean;
|
|
@@ -25,6 +26,10 @@ export interface UseValidateHook {
|
|
|
25
26
|
isValid: boolean;
|
|
26
27
|
errorType?: AttachmentsValidationErrorType;
|
|
27
28
|
};
|
|
29
|
+
validateInputValidationResponse: (questionConfig: Maybe<QuestionConfig> | undefined, value: string) => {
|
|
30
|
+
isValid: boolean;
|
|
31
|
+
errorType?: InputValidationErrorType;
|
|
32
|
+
};
|
|
28
33
|
}
|
|
29
34
|
export declare const handleUSException: (number: string, originalValidation: ValidatePhoneReturn) => ValidatePhoneReturn;
|
|
30
35
|
export declare const useValidate: () => UseValidateHook;
|
|
@@ -603,6 +603,7 @@ export declare enum ElementStatus {
|
|
|
603
603
|
}
|
|
604
604
|
export declare enum ElementType {
|
|
605
605
|
Action = "ACTION",
|
|
606
|
+
Agent = "AGENT",
|
|
606
607
|
Pathway = "PATHWAY",
|
|
607
608
|
Step = "STEP",
|
|
608
609
|
Track = "TRACK",
|
|
@@ -902,6 +903,25 @@ export declare type IdentityVerificationPayload = Payload & {
|
|
|
902
903
|
is_verified: Scalars['Boolean'];
|
|
903
904
|
success: Scalars['Boolean'];
|
|
904
905
|
};
|
|
906
|
+
export declare type InputValidationAllowed = {
|
|
907
|
+
__typename?: 'InputValidationAllowed';
|
|
908
|
+
letters?: Maybe<Scalars['Boolean']>;
|
|
909
|
+
numbers?: Maybe<Scalars['Boolean']>;
|
|
910
|
+
special?: Maybe<Scalars['Boolean']>;
|
|
911
|
+
whitespace?: Maybe<Scalars['Boolean']>;
|
|
912
|
+
};
|
|
913
|
+
export declare type InputValidationConfig = {
|
|
914
|
+
__typename?: 'InputValidationConfig';
|
|
915
|
+
helper_text?: Maybe<Scalars['String']>;
|
|
916
|
+
mode?: Maybe<Scalars['String']>;
|
|
917
|
+
pattern?: Maybe<Scalars['String']>;
|
|
918
|
+
simpleConfig?: Maybe<InputValidationSimpleConfig>;
|
|
919
|
+
};
|
|
920
|
+
export declare type InputValidationSimpleConfig = {
|
|
921
|
+
__typename?: 'InputValidationSimpleConfig';
|
|
922
|
+
allowed?: Maybe<InputValidationAllowed>;
|
|
923
|
+
exactLength?: Maybe<Scalars['Float']>;
|
|
924
|
+
};
|
|
905
925
|
export declare type MarkMessageAsReadInput = {
|
|
906
926
|
activity_id: Scalars['String'];
|
|
907
927
|
};
|
|
@@ -915,7 +935,7 @@ export declare type Message = {
|
|
|
915
935
|
__typename?: 'Message';
|
|
916
936
|
attachments?: Maybe<Array<MessageAttachment>>;
|
|
917
937
|
body: Scalars['String'];
|
|
918
|
-
format
|
|
938
|
+
format?: Maybe<MessageFormat>;
|
|
919
939
|
id: Scalars['ID'];
|
|
920
940
|
subject?: Maybe<Scalars['String']>;
|
|
921
941
|
};
|
|
@@ -1182,6 +1202,8 @@ export declare type Pathway = {
|
|
|
1182
1202
|
export declare type PathwayContext = {
|
|
1183
1203
|
__typename?: 'PathwayContext';
|
|
1184
1204
|
action_id?: Maybe<Scalars['String']>;
|
|
1205
|
+
agent_id?: Maybe<Scalars['String']>;
|
|
1206
|
+
agent_thread_id?: Maybe<Scalars['String']>;
|
|
1185
1207
|
instance_id: Scalars['String'];
|
|
1186
1208
|
pathway_id: Scalars['String'];
|
|
1187
1209
|
step_id?: Maybe<Scalars['String']>;
|
|
@@ -1636,6 +1658,7 @@ export declare type QuestionConfig = {
|
|
|
1636
1658
|
__typename?: 'QuestionConfig';
|
|
1637
1659
|
date?: Maybe<DateConfig>;
|
|
1638
1660
|
file_storage?: Maybe<FileStorageQuestionConfig>;
|
|
1661
|
+
input_validation?: Maybe<InputValidationConfig>;
|
|
1639
1662
|
mandatory: Scalars['Boolean'];
|
|
1640
1663
|
multiple_select?: Maybe<MultipleSelectConfig>;
|
|
1641
1664
|
number?: Maybe<NumberConfig>;
|