@awell-health/ui-library 0.1.140 → 0.1.141
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 +64 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -52373,15 +52373,44 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
52373
52373
|
var _f = React.useState(false),isSubmittingForm = _f[0],setIsSubmittingForm = _f[1];
|
|
52374
52374
|
var _g = useValidate(),isValidE164Number = _g.isValidE164Number,validateDateResponse = _g.validateDateResponse,validateNumberResponse = _g.validateNumberResponse,validateEmailResponse = _g.validateEmailResponse,validateAttachmentsResponse = _g.validateAttachmentsResponse,validateInputValidationResponse = _g.validateInputValidationResponse;
|
|
52375
52375
|
var updateQuestionVisibility = React.useCallback(function () {return __awaiter(void 0, void 0, void 0, function () {
|
|
52376
|
-
var formValuesInput, evaluationResults, updatedQuestions;
|
|
52376
|
+
var questionsWithVisibility, attempt, formValuesInput, evaluationResults, didResetHiddenAnswer, updatedQuestions;
|
|
52377
52377
|
return __generator(this, function (_a) {
|
|
52378
52378
|
switch (_a.label) {
|
|
52379
52379
|
case 0:
|
|
52380
|
+
questionsWithVisibility = [];
|
|
52381
|
+
attempt = 0;
|
|
52382
|
+
_a.label = 1;
|
|
52383
|
+
case 1:
|
|
52384
|
+
if (!(attempt <= questions.length)) return [3, 4];
|
|
52380
52385
|
formValuesInput = convertToAwellInput(getDirtyFieldValues(formMethods));
|
|
52381
52386
|
return [4, evaluateDisplayConditions(formValuesInput)];
|
|
52382
|
-
case
|
|
52387
|
+
case 2:
|
|
52383
52388
|
evaluationResults = _a.sent();
|
|
52384
|
-
|
|
52389
|
+
questionsWithVisibility = updateVisibilityForTraditionalForm(questions, evaluationResults);
|
|
52390
|
+
didResetHiddenAnswer = questionsWithVisibility.
|
|
52391
|
+
filter(function (question) {return !question.visible;}).
|
|
52392
|
+
reduce(function (didReset, question) {
|
|
52393
|
+
var defaultValue = getDefaultValue(question);
|
|
52394
|
+
var currentValue = formMethods.getValues(question.id);
|
|
52395
|
+
var fieldState = formMethods.getFieldState(question.id);
|
|
52396
|
+
var hasNonDefaultValue = JSON.stringify(currentValue) !== JSON.stringify(defaultValue);
|
|
52397
|
+
if (!fieldState.isDirty &&
|
|
52398
|
+
!fieldState.isTouched &&
|
|
52399
|
+
!hasNonDefaultValue) {
|
|
52400
|
+
return didReset;
|
|
52401
|
+
}
|
|
52402
|
+
formMethods.resetField(question.id, { defaultValue: defaultValue });
|
|
52403
|
+
return true;
|
|
52404
|
+
}, false);
|
|
52405
|
+
if (!didResetHiddenAnswer) {
|
|
52406
|
+
return [3, 4];
|
|
52407
|
+
}
|
|
52408
|
+
_a.label = 3;
|
|
52409
|
+
case 3:
|
|
52410
|
+
attempt += 1;
|
|
52411
|
+
return [3, 1];
|
|
52412
|
+
case 4:
|
|
52413
|
+
updatedQuestions = questionsWithVisibility.filter(function (e) {return e.visible;});
|
|
52385
52414
|
setVisibleQuestions(updatedQuestions);
|
|
52386
52415
|
return [2, updatedQuestions];}
|
|
52387
52416
|
|
|
@@ -52509,16 +52538,45 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
52509
52538
|
var _h = React.useState(0),percentageCompleted = _h[0],setPercentageCompleted = _h[1];
|
|
52510
52539
|
var _j = React.useState(false),isSubmittingForm = _j[0],setIsSubmittingForm = _j[1];
|
|
52511
52540
|
var updateQuestionVisibility = React.useCallback(function () {return __awaiter(void 0, void 0, void 0, function () {
|
|
52512
|
-
var formValuesInput, evaluationResults, updatedQuestions;
|
|
52541
|
+
var questionsWithVisibility, attempt, formValuesInput, evaluationResults, didResetHiddenAnswer, updatedQuestions;
|
|
52513
52542
|
return __generator(this, function (_a) {
|
|
52514
52543
|
switch (_a.label) {
|
|
52515
52544
|
case 0:
|
|
52516
52545
|
setIsEvaluatingQuestionVisibility(true);
|
|
52546
|
+
questionsWithVisibility = [];
|
|
52547
|
+
attempt = 0;
|
|
52548
|
+
_a.label = 1;
|
|
52549
|
+
case 1:
|
|
52550
|
+
if (!(attempt <= questions.length)) return [3, 4];
|
|
52517
52551
|
formValuesInput = convertToAwellInput(getDirtyFieldValues(formMethods));
|
|
52518
52552
|
return [4, evaluateDisplayConditions(formValuesInput)];
|
|
52519
|
-
case
|
|
52553
|
+
case 2:
|
|
52520
52554
|
evaluationResults = _a.sent();
|
|
52521
|
-
|
|
52555
|
+
questionsWithVisibility = updateVisibility(questions, evaluationResults);
|
|
52556
|
+
didResetHiddenAnswer = questionsWithVisibility.
|
|
52557
|
+
filter(function (question) {return !question.visible;}).
|
|
52558
|
+
reduce(function (didReset, question) {
|
|
52559
|
+
var defaultValue = getDefaultValue(question);
|
|
52560
|
+
var currentValue = formMethods.getValues(question.id);
|
|
52561
|
+
var fieldState = formMethods.getFieldState(question.id);
|
|
52562
|
+
var hasNonDefaultValue = JSON.stringify(currentValue) !== JSON.stringify(defaultValue);
|
|
52563
|
+
if (!fieldState.isDirty &&
|
|
52564
|
+
!fieldState.isTouched &&
|
|
52565
|
+
!hasNonDefaultValue) {
|
|
52566
|
+
return didReset;
|
|
52567
|
+
}
|
|
52568
|
+
formMethods.resetField(question.id, { defaultValue: defaultValue });
|
|
52569
|
+
return true;
|
|
52570
|
+
}, false);
|
|
52571
|
+
if (!didResetHiddenAnswer) {
|
|
52572
|
+
return [3, 4];
|
|
52573
|
+
}
|
|
52574
|
+
_a.label = 3;
|
|
52575
|
+
case 3:
|
|
52576
|
+
attempt += 1;
|
|
52577
|
+
return [3, 1];
|
|
52578
|
+
case 4:
|
|
52579
|
+
updatedQuestions = questionsWithVisibility.filter(function (e) {return e.visible;});
|
|
52522
52580
|
setVisibleQuestions(updatedQuestions);
|
|
52523
52581
|
setIsEvaluatingQuestionVisibility(false);
|
|
52524
52582
|
return [2, updatedQuestions];}
|