@awell-health/ui-library 0.1.51 → 0.1.53
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 +449 -87
- package/dist/types/hooks/useForm/helpers.d.ts +10 -1
- package/dist/types/hooks/useForm/types.d.ts +5 -0
- package/dist/types/hooks/useValidate/useValidate.d.ts +11 -0
- package/dist/types/molecules/question/helpers/getMaxValueForDateInput.d.ts +2 -0
- package/dist/types/molecules/question/helpers/getMaxValueForNumberInput.d.ts +2 -0
- package/dist/types/molecules/question/helpers/getMinValueForDateInput.d.ts +2 -0
- package/dist/types/molecules/question/helpers/getMinValueForNumberInput.d.ts +2 -0
- package/dist/types/types/generated/types-orchestration.d.ts +117 -8
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -9916,6 +9916,43 @@ Check the top-level render call using <` + t + ">.");
|
|
|
9916
9916
|
}
|
|
9917
9917
|
}
|
|
9918
9918
|
|
|
9919
|
+
/**
|
|
9920
|
+
* @name addDays
|
|
9921
|
+
* @category Day Helpers
|
|
9922
|
+
* @summary Add the specified number of days to the given date.
|
|
9923
|
+
*
|
|
9924
|
+
* @description
|
|
9925
|
+
* Add the specified number of days to the given date.
|
|
9926
|
+
*
|
|
9927
|
+
* @param {Date|Number} date - the date to be changed
|
|
9928
|
+
* @param {Number} amount - the amount of days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
|
|
9929
|
+
* @returns {Date} - the new date with the days added
|
|
9930
|
+
* @throws {TypeError} - 2 arguments required
|
|
9931
|
+
*
|
|
9932
|
+
* @example
|
|
9933
|
+
* // Add 10 days to 1 September 2014:
|
|
9934
|
+
* const result = addDays(new Date(2014, 8, 1), 10)
|
|
9935
|
+
* //=> Thu Sep 11 2014 00:00:00
|
|
9936
|
+
*/
|
|
9937
|
+
|
|
9938
|
+
function addDays(dirtyDate, dirtyAmount) {
|
|
9939
|
+
requiredArgs(2, arguments);
|
|
9940
|
+
var date = toDate(dirtyDate);
|
|
9941
|
+
var amount = toInteger(dirtyAmount);
|
|
9942
|
+
|
|
9943
|
+
if (isNaN(amount)) {
|
|
9944
|
+
return new Date(NaN);
|
|
9945
|
+
}
|
|
9946
|
+
|
|
9947
|
+
if (!amount) {
|
|
9948
|
+
// If 0 days, no-op to avoid changing times in the hour before end of DST
|
|
9949
|
+
return date;
|
|
9950
|
+
}
|
|
9951
|
+
|
|
9952
|
+
date.setDate(date.getDate() + amount);
|
|
9953
|
+
return date;
|
|
9954
|
+
}
|
|
9955
|
+
|
|
9919
9956
|
/**
|
|
9920
9957
|
* @name addMilliseconds
|
|
9921
9958
|
* @category Millisecond Helpers
|
|
@@ -9964,6 +10001,32 @@ Check the top-level render call using <` + t + ">.");
|
|
|
9964
10001
|
return date.getTime() - utcDate.getTime();
|
|
9965
10002
|
}
|
|
9966
10003
|
|
|
10004
|
+
/**
|
|
10005
|
+
* @name startOfDay
|
|
10006
|
+
* @category Day Helpers
|
|
10007
|
+
* @summary Return the start of a day for the given date.
|
|
10008
|
+
*
|
|
10009
|
+
* @description
|
|
10010
|
+
* Return the start of a day for the given date.
|
|
10011
|
+
* The result will be in the local timezone.
|
|
10012
|
+
*
|
|
10013
|
+
* @param {Date|Number} date - the original date
|
|
10014
|
+
* @returns {Date} the start of a day
|
|
10015
|
+
* @throws {TypeError} 1 argument required
|
|
10016
|
+
*
|
|
10017
|
+
* @example
|
|
10018
|
+
* // The start of a day for 2 September 2014 11:55:00:
|
|
10019
|
+
* const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
|
|
10020
|
+
* //=> Tue Sep 02 2014 00:00:00
|
|
10021
|
+
*/
|
|
10022
|
+
|
|
10023
|
+
function startOfDay(dirtyDate) {
|
|
10024
|
+
requiredArgs(1, arguments);
|
|
10025
|
+
var date = toDate(dirtyDate);
|
|
10026
|
+
date.setHours(0, 0, 0, 0);
|
|
10027
|
+
return date;
|
|
10028
|
+
}
|
|
10029
|
+
|
|
9967
10030
|
/**
|
|
9968
10031
|
* Days in 1 week.
|
|
9969
10032
|
*
|
|
@@ -10003,6 +10066,42 @@ Check the top-level render call using <` + t + ">.");
|
|
|
10003
10066
|
|
|
10004
10067
|
var millisecondsInSecond = 1000;
|
|
10005
10068
|
|
|
10069
|
+
/**
|
|
10070
|
+
* @name isSameDay
|
|
10071
|
+
* @category Day Helpers
|
|
10072
|
+
* @summary Are the given dates in the same day (and year and month)?
|
|
10073
|
+
*
|
|
10074
|
+
* @description
|
|
10075
|
+
* Are the given dates in the same day (and year and month)?
|
|
10076
|
+
*
|
|
10077
|
+
* @param {Date|Number} dateLeft - the first date to check
|
|
10078
|
+
* @param {Date|Number} dateRight - the second date to check
|
|
10079
|
+
* @returns {Boolean} the dates are in the same day (and year and month)
|
|
10080
|
+
* @throws {TypeError} 2 arguments required
|
|
10081
|
+
*
|
|
10082
|
+
* @example
|
|
10083
|
+
* // Are 4 September 06:00:00 and 4 September 18:00:00 in the same day?
|
|
10084
|
+
* const result = isSameDay(new Date(2014, 8, 4, 6, 0), new Date(2014, 8, 4, 18, 0))
|
|
10085
|
+
* //=> true
|
|
10086
|
+
*
|
|
10087
|
+
* @example
|
|
10088
|
+
* // Are 4 September and 4 October in the same day?
|
|
10089
|
+
* const result = isSameDay(new Date(2014, 8, 4), new Date(2014, 9, 4))
|
|
10090
|
+
* //=> false
|
|
10091
|
+
*
|
|
10092
|
+
* @example
|
|
10093
|
+
* // Are 4 September, 2014 and 4 September, 2015 in the same day?
|
|
10094
|
+
* const result = isSameDay(new Date(2014, 8, 4), new Date(2015, 8, 4))
|
|
10095
|
+
* //=> false
|
|
10096
|
+
*/
|
|
10097
|
+
|
|
10098
|
+
function isSameDay(dirtyDateLeft, dirtyDateRight) {
|
|
10099
|
+
requiredArgs(2, arguments);
|
|
10100
|
+
var dateLeftStartOfDay = startOfDay(dirtyDateLeft);
|
|
10101
|
+
var dateRightStartOfDay = startOfDay(dirtyDateRight);
|
|
10102
|
+
return dateLeftStartOfDay.getTime() === dateRightStartOfDay.getTime();
|
|
10103
|
+
}
|
|
10104
|
+
|
|
10006
10105
|
/**
|
|
10007
10106
|
* @name isDate
|
|
10008
10107
|
* @category Common Helpers
|
|
@@ -14090,6 +14189,58 @@ Check the top-level render call using <` + t + ">.");
|
|
|
14090
14189
|
t: new TimestampSecondsParser(),
|
|
14091
14190
|
T: new TimestampMillisecondsParser() });
|
|
14092
14191
|
|
|
14192
|
+
/**
|
|
14193
|
+
* @name isToday
|
|
14194
|
+
* @category Day Helpers
|
|
14195
|
+
* @summary Is the given date today?
|
|
14196
|
+
* @pure false
|
|
14197
|
+
*
|
|
14198
|
+
* @description
|
|
14199
|
+
* Is the given date today?
|
|
14200
|
+
*
|
|
14201
|
+
* > ⚠️ Please note that this function is not present in the FP submodule as
|
|
14202
|
+
* > it uses `Date.now()` internally hence impure and can't be safely curried.
|
|
14203
|
+
*
|
|
14204
|
+
* @param {Date|Number} date - the date to check
|
|
14205
|
+
* @returns {Boolean} the date is today
|
|
14206
|
+
* @throws {TypeError} 1 argument required
|
|
14207
|
+
*
|
|
14208
|
+
* @example
|
|
14209
|
+
* // If today is 6 October 2014, is 6 October 14:00:00 today?
|
|
14210
|
+
* const result = isToday(new Date(2014, 9, 6, 14, 0))
|
|
14211
|
+
* //=> true
|
|
14212
|
+
*/
|
|
14213
|
+
|
|
14214
|
+
function isToday(dirtyDate) {
|
|
14215
|
+
requiredArgs(1, arguments);
|
|
14216
|
+
return isSameDay(dirtyDate, Date.now());
|
|
14217
|
+
}
|
|
14218
|
+
|
|
14219
|
+
/**
|
|
14220
|
+
* @name subDays
|
|
14221
|
+
* @category Day Helpers
|
|
14222
|
+
* @summary Subtract the specified number of days from the given date.
|
|
14223
|
+
*
|
|
14224
|
+
* @description
|
|
14225
|
+
* Subtract the specified number of days from the given date.
|
|
14226
|
+
*
|
|
14227
|
+
* @param {Date|Number} date - the date to be changed
|
|
14228
|
+
* @param {Number} amount - the amount of days to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
|
|
14229
|
+
* @returns {Date} the new date with the days subtracted
|
|
14230
|
+
* @throws {TypeError} 2 arguments required
|
|
14231
|
+
*
|
|
14232
|
+
* @example
|
|
14233
|
+
* // Subtract 10 days from 1 September 2014:
|
|
14234
|
+
* const result = subDays(new Date(2014, 8, 1), 10)
|
|
14235
|
+
* //=> Fri Aug 22 2014 00:00:00
|
|
14236
|
+
*/
|
|
14237
|
+
|
|
14238
|
+
function subDays(dirtyDate, dirtyAmount) {
|
|
14239
|
+
requiredArgs(2, arguments);
|
|
14240
|
+
var amount = toInteger(dirtyAmount);
|
|
14241
|
+
return addDays(dirtyDate, -amount);
|
|
14242
|
+
}
|
|
14243
|
+
|
|
14093
14244
|
var DatePicker = function (_a) {
|
|
14094
14245
|
var id = _a.id,label = _a.label,onChange = _a.onChange,value = _a.value,mandatory = _a.mandatory;
|
|
14095
14246
|
var wrapperRef = /*#__PURE__*/React.createRef();
|
|
@@ -15954,6 +16105,12 @@ Check the top-level render call using <` + t + ">.");
|
|
|
15954
16105
|
ActivitySubjectType["Stakeholder"] = "STAKEHOLDER";
|
|
15955
16106
|
ActivitySubjectType["User"] = "USER";
|
|
15956
16107
|
})(exports.ActivitySubjectType || (exports.ActivitySubjectType = {}));
|
|
16108
|
+
exports.AllowedDatesOptions = void 0;
|
|
16109
|
+
(function (AllowedDatesOptions) {
|
|
16110
|
+
AllowedDatesOptions["All"] = "ALL";
|
|
16111
|
+
AllowedDatesOptions["Future"] = "FUTURE";
|
|
16112
|
+
AllowedDatesOptions["Past"] = "PAST";
|
|
16113
|
+
})(exports.AllowedDatesOptions || (exports.AllowedDatesOptions = {}));
|
|
15957
16114
|
exports.ApiCallRequestMethod = void 0;
|
|
15958
16115
|
(function (ApiCallRequestMethod) {
|
|
15959
16116
|
ApiCallRequestMethod["Get"] = "GET";
|
|
@@ -16011,6 +16168,7 @@ Check the top-level render call using <` + t + ">.");
|
|
|
16011
16168
|
DataPointSourceType["ExtensionWebhook"] = "EXTENSION_WEBHOOK";
|
|
16012
16169
|
DataPointSourceType["Form"] = "FORM";
|
|
16013
16170
|
DataPointSourceType["Pathway"] = "PATHWAY";
|
|
16171
|
+
DataPointSourceType["PatientIdentifier"] = "PATIENT_IDENTIFIER";
|
|
16014
16172
|
DataPointSourceType["PatientProfile"] = "PATIENT_PROFILE";
|
|
16015
16173
|
DataPointSourceType["Step"] = "STEP";
|
|
16016
16174
|
DataPointSourceType["Track"] = "TRACK";
|
|
@@ -16049,7 +16207,9 @@ Check the top-level render call using <` + t + ">.");
|
|
|
16049
16207
|
ExtensionActionFieldType["Html"] = "HTML";
|
|
16050
16208
|
ExtensionActionFieldType["Json"] = "JSON";
|
|
16051
16209
|
ExtensionActionFieldType["Numeric"] = "NUMERIC";
|
|
16210
|
+
ExtensionActionFieldType["NumericArray"] = "NUMERIC_ARRAY";
|
|
16052
16211
|
ExtensionActionFieldType["String"] = "STRING";
|
|
16212
|
+
ExtensionActionFieldType["StringArray"] = "STRING_ARRAY";
|
|
16053
16213
|
ExtensionActionFieldType["Text"] = "TEXT";
|
|
16054
16214
|
})(exports.ExtensionActionFieldType || (exports.ExtensionActionFieldType = {}));
|
|
16055
16215
|
exports.FormDisplayMode = void 0;
|
|
@@ -36885,6 +37045,214 @@ Check the top-level render call using <` + t + ">.");
|
|
|
36885
37045
|
};
|
|
36886
37046
|
PhoneInputField.displayName = 'PhoneInputField';
|
|
36887
37047
|
|
|
37048
|
+
var handleUSException = function (number, originalValidation) {
|
|
37049
|
+
var _a;
|
|
37050
|
+
var areaCodes = (_a = originalValidation.country) === null || _a === void 0 ? void 0 : _a.areaCodes;
|
|
37051
|
+
var providedAreaCode = number.slice(2, 5);
|
|
37052
|
+
if (providedAreaCode.length === 3 && (areaCodes === null || areaCodes === void 0 ? void 0 : areaCodes.includes(providedAreaCode))) {
|
|
37053
|
+
return originalValidation;
|
|
37054
|
+
}
|
|
37055
|
+
var USValidation = build.exports.validatePhone(number, {
|
|
37056
|
+
countries: getDefaultCountries(['us'], undefined),
|
|
37057
|
+
charAfterDialCode: '',
|
|
37058
|
+
prefix: '+' });
|
|
37059
|
+
|
|
37060
|
+
return USValidation;
|
|
37061
|
+
};
|
|
37062
|
+
var useValidate = function () {
|
|
37063
|
+
var validatePhoneNumber = function (number, availableCountries) {
|
|
37064
|
+
var validation = build.exports.validatePhone(number, {
|
|
37065
|
+
countries: getDefaultCountries(availableCountries, undefined),
|
|
37066
|
+
charAfterDialCode: '',
|
|
37067
|
+
prefix: '+' });
|
|
37068
|
+
|
|
37069
|
+
if (number.startsWith('+1') && validation.isValid === false) {
|
|
37070
|
+
return handleUSException(number, validation);
|
|
37071
|
+
}
|
|
37072
|
+
return validation;
|
|
37073
|
+
};
|
|
37074
|
+
var isValidE164Number = function (number, availableCountries) {
|
|
37075
|
+
var validation = build.exports.validatePhone(number, {
|
|
37076
|
+
countries: getDefaultCountries(availableCountries, undefined),
|
|
37077
|
+
charAfterDialCode: '',
|
|
37078
|
+
prefix: '+' });
|
|
37079
|
+
|
|
37080
|
+
if (number.startsWith('+1') && validation.isValid === false) {
|
|
37081
|
+
return handleUSException(number, validation).isValid;
|
|
37082
|
+
}
|
|
37083
|
+
return validation.isValid;
|
|
37084
|
+
};
|
|
37085
|
+
var numberMatchesAvailableCountries = function (number, availableCountries) {
|
|
37086
|
+
var _a;
|
|
37087
|
+
try {
|
|
37088
|
+
var validation = build.exports.validatePhone(number, {
|
|
37089
|
+
countries: getDefaultCountries(availableCountries, undefined),
|
|
37090
|
+
charAfterDialCode: '',
|
|
37091
|
+
prefix: '+' });
|
|
37092
|
+
|
|
37093
|
+
if (number.startsWith('+1') && validation.isValid === false) {
|
|
37094
|
+
validation = handleUSException(number, validation);
|
|
37095
|
+
}
|
|
37096
|
+
if (!validation.country) {
|
|
37097
|
+
return false;
|
|
37098
|
+
}
|
|
37099
|
+
if (typeof availableCountries === 'string') {
|
|
37100
|
+
return (_a = availableCountries === validation.country.iso2) !== null && _a !== void 0 ? _a : false;
|
|
37101
|
+
}
|
|
37102
|
+
return availableCountries.includes(validation.country.iso2);
|
|
37103
|
+
}
|
|
37104
|
+
catch (_b) {
|
|
37105
|
+
return false;
|
|
37106
|
+
}
|
|
37107
|
+
};
|
|
37108
|
+
var isPossibleE164Number = function (number) {
|
|
37109
|
+
return /^\+?[1-9]\d{1,14}$/.test(number);
|
|
37110
|
+
};
|
|
37111
|
+
var validateDateResponse = function (questionConfig, value) {
|
|
37112
|
+
var inputRequired = questionConfig === null || questionConfig === void 0 ? void 0 : questionConfig.mandatory;
|
|
37113
|
+
if (inputRequired === false && lodash.exports.isEmpty(value)) {
|
|
37114
|
+
return {
|
|
37115
|
+
isValid: true };
|
|
37116
|
+
|
|
37117
|
+
}
|
|
37118
|
+
if (!questionConfig || !questionConfig.date) {
|
|
37119
|
+
return {
|
|
37120
|
+
isValid: true };
|
|
37121
|
+
|
|
37122
|
+
}
|
|
37123
|
+
var parsedDate = new Date(value);
|
|
37124
|
+
var dateIsToday = isToday(parsedDate);
|
|
37125
|
+
var _a = questionConfig.date,allowed_dates = _a.allowed_dates,_b = _a.include_date_of_response,include_date_of_response = _b === void 0 ? false : _b;
|
|
37126
|
+
if (allowed_dates === exports.AllowedDatesOptions.All) {
|
|
37127
|
+
return {
|
|
37128
|
+
isValid: true };
|
|
37129
|
+
|
|
37130
|
+
}
|
|
37131
|
+
if (dateIsToday) {
|
|
37132
|
+
if (include_date_of_response === true) {
|
|
37133
|
+
return {
|
|
37134
|
+
isValid: true };
|
|
37135
|
+
|
|
37136
|
+
} else
|
|
37137
|
+
{
|
|
37138
|
+
return {
|
|
37139
|
+
isValid: false,
|
|
37140
|
+
errorType: 'DATE_CANNOT_BE_TODAY' };
|
|
37141
|
+
|
|
37142
|
+
}
|
|
37143
|
+
}
|
|
37144
|
+
if (allowed_dates === exports.AllowedDatesOptions.Past &&
|
|
37145
|
+
parsedDate >= new Date()) {
|
|
37146
|
+
return {
|
|
37147
|
+
isValid: false,
|
|
37148
|
+
errorType: 'DATE_CANNOT_BE_IN_THE_FUTURE' };
|
|
37149
|
+
|
|
37150
|
+
}
|
|
37151
|
+
if (allowed_dates === exports.AllowedDatesOptions.Future &&
|
|
37152
|
+
parsedDate <= new Date()) {
|
|
37153
|
+
return {
|
|
37154
|
+
isValid: false,
|
|
37155
|
+
errorType: 'DATE_CANNOT_BE_IN_THE_PAST' };
|
|
37156
|
+
|
|
37157
|
+
}
|
|
37158
|
+
return {
|
|
37159
|
+
isValid: true };
|
|
37160
|
+
|
|
37161
|
+
};
|
|
37162
|
+
var validateNumberResponse = function (questionConfig, value) {
|
|
37163
|
+
var _a, _b, _c, _d;
|
|
37164
|
+
var inputRequired = questionConfig === null || questionConfig === void 0 ? void 0 : questionConfig.mandatory;
|
|
37165
|
+
if (inputRequired === false && lodash.exports.isEmpty(value)) {
|
|
37166
|
+
return {
|
|
37167
|
+
isValid: true };
|
|
37168
|
+
|
|
37169
|
+
}
|
|
37170
|
+
var isNumber = !isNaN(Number(value));
|
|
37171
|
+
if (!isNumber) {
|
|
37172
|
+
return {
|
|
37173
|
+
isValid: false,
|
|
37174
|
+
errorType: 'NOT_A_NUMBER' };
|
|
37175
|
+
|
|
37176
|
+
}
|
|
37177
|
+
if (!questionConfig || !questionConfig.number) {
|
|
37178
|
+
return {
|
|
37179
|
+
isValid: true };
|
|
37180
|
+
|
|
37181
|
+
}
|
|
37182
|
+
var isRangeEnabled = !lodash.exports.isNil((_a = questionConfig === null || questionConfig === void 0 ? void 0 : questionConfig.number) === null || _a === void 0 ? void 0 : _a.range) &&
|
|
37183
|
+
questionConfig.number.range.enabled === true;
|
|
37184
|
+
if (isRangeEnabled) {
|
|
37185
|
+
var range = (_b = questionConfig.number) === null || _b === void 0 ? void 0 : _b.range;
|
|
37186
|
+
var min = (_c = range === null || range === void 0 ? void 0 : range.min) !== null && _c !== void 0 ? _c : 0;
|
|
37187
|
+
var max = (_d = range === null || range === void 0 ? void 0 : range.max) !== null && _d !== void 0 ? _d : 0;
|
|
37188
|
+
var number = Number(value);
|
|
37189
|
+
if (number < min || number > max) {
|
|
37190
|
+
return {
|
|
37191
|
+
isValid: false,
|
|
37192
|
+
errorType: 'OUT_OF_RANGE' };
|
|
37193
|
+
|
|
37194
|
+
}
|
|
37195
|
+
}
|
|
37196
|
+
return {
|
|
37197
|
+
isValid: true };
|
|
37198
|
+
|
|
37199
|
+
};
|
|
37200
|
+
return {
|
|
37201
|
+
isValidE164Number: isValidE164Number,
|
|
37202
|
+
isPossibleE164Number: isPossibleE164Number,
|
|
37203
|
+
validatePhoneNumber: validatePhoneNumber,
|
|
37204
|
+
numberMatchesAvailableCountries: numberMatchesAvailableCountries,
|
|
37205
|
+
validateDateResponse: validateDateResponse,
|
|
37206
|
+
validateNumberResponse: validateNumberResponse };
|
|
37207
|
+
|
|
37208
|
+
};
|
|
37209
|
+
|
|
37210
|
+
var getMinValueForDateInput = function (dateConfig) {
|
|
37211
|
+
if (lodash.exports.isNil(dateConfig)) {
|
|
37212
|
+
return undefined;
|
|
37213
|
+
}
|
|
37214
|
+
if (dateConfig.allowed_dates === exports.AllowedDatesOptions.Future) {
|
|
37215
|
+
if (dateConfig.include_date_of_response === true) {
|
|
37216
|
+
return format(new Date(), 'yyyy-MM-dd');
|
|
37217
|
+
}
|
|
37218
|
+
var datePlusOneDay = addDays(new Date(), 1);
|
|
37219
|
+
return format(datePlusOneDay, 'yyyy-MM-dd');
|
|
37220
|
+
}
|
|
37221
|
+
return undefined;
|
|
37222
|
+
};
|
|
37223
|
+
|
|
37224
|
+
var getMaxValueForDateInput = function (dateConfig) {
|
|
37225
|
+
if (lodash.exports.isNil(dateConfig)) {
|
|
37226
|
+
return undefined;
|
|
37227
|
+
}
|
|
37228
|
+
if (dateConfig.allowed_dates === exports.AllowedDatesOptions.Past) {
|
|
37229
|
+
if (dateConfig.include_date_of_response === true) {
|
|
37230
|
+
return format(new Date(), 'yyyy-MM-dd');
|
|
37231
|
+
}
|
|
37232
|
+
var dateMinusOneDay = subDays(new Date(), 1);
|
|
37233
|
+
return format(dateMinusOneDay, 'yyyy-MM-dd');
|
|
37234
|
+
}
|
|
37235
|
+
return undefined;
|
|
37236
|
+
};
|
|
37237
|
+
|
|
37238
|
+
var getMinValueForNumberInput = function (numberConfig) {
|
|
37239
|
+
if (numberConfig &&
|
|
37240
|
+
numberConfig.range &&
|
|
37241
|
+
numberConfig.range.enabled === true) {
|
|
37242
|
+
return numberConfig.range.min;
|
|
37243
|
+
}
|
|
37244
|
+
return undefined;
|
|
37245
|
+
};
|
|
37246
|
+
|
|
37247
|
+
var getMaxValueForNumberInput = function (numberConfig) {
|
|
37248
|
+
if (numberConfig &&
|
|
37249
|
+
numberConfig.range &&
|
|
37250
|
+
numberConfig.range.enabled === true) {
|
|
37251
|
+
return numberConfig.range.max;
|
|
37252
|
+
}
|
|
37253
|
+
return undefined;
|
|
37254
|
+
};
|
|
37255
|
+
|
|
36888
37256
|
var AUTO_PROGRESS_DELAY = 850;
|
|
36889
37257
|
var QuestionData = function (_a) {
|
|
36890
37258
|
var _b, _c, _d, _e, _f;
|
|
@@ -36980,7 +37348,7 @@ Check the top-level render call using <` + t + ">.");
|
|
|
36980
37348
|
return jsxRuntime.exports.jsx(InputField, { autoFocus: inputAutoFocus, type: "number", onChange: function (e) {
|
|
36981
37349
|
onChange(e.target.value);
|
|
36982
37350
|
onAnswerChange();
|
|
36983
|
-
}, label: question.title, id: question.id, value: value, mandatory: config === null || config === void 0 ? void 0 : config.mandatory });
|
|
37351
|
+
}, 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) });
|
|
36984
37352
|
} });
|
|
36985
37353
|
case exports.UserQuestionType.ShortText:
|
|
36986
37354
|
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) {
|
|
@@ -37021,12 +37389,14 @@ Check the top-level render call using <` + t + ">.");
|
|
|
37021
37389
|
}, touchTooltipLabel: (_b = labels.slider) === null || _b === void 0 ? void 0 : _b.tooltip_guide, id: question.id, sliderConfig: config === null || config === void 0 ? void 0 : config.slider, value: value === '' ? undefined : value, mandatory: config === null || config === void 0 ? void 0 : config.mandatory });
|
|
37022
37390
|
} });
|
|
37023
37391
|
case exports.UserQuestionType.Date:
|
|
37024
|
-
return jsxRuntime.exports.jsx(Controller, { name: question.id, control: control, rules: {
|
|
37392
|
+
return jsxRuntime.exports.jsx(Controller, { name: question.id, control: control, rules: {
|
|
37393
|
+
required: config === null || config === void 0 ? void 0 : config.mandatory },
|
|
37394
|
+
render: function (_a) {
|
|
37025
37395
|
var _b = _a.field,onChange = _b.onChange,value = _b.value;
|
|
37026
37396
|
return jsxRuntime.exports.jsx(InputField, { autoFocus: inputAutoFocus, type: "date", label: question.title, onChange: function (e) {
|
|
37027
37397
|
onChange(e.target.value);
|
|
37028
37398
|
onAnswerChange();
|
|
37029
|
-
}, id: question.id, value: value, mandatory: config === null || config === void 0 ? void 0 : config.mandatory });
|
|
37399
|
+
}, id: question.id, value: value, mandatory: config === null || config === void 0 ? void 0 : config.mandatory, min: getMinValueForDateInput(config === null || config === void 0 ? void 0 : config.date), max: getMaxValueForDateInput(config === null || config === void 0 ? void 0 : config.date) });
|
|
37030
37400
|
} });
|
|
37031
37401
|
case exports.UserQuestionType.Description:
|
|
37032
37402
|
return jsxRuntime.exports.jsx(Description, { content: question.title });
|
|
@@ -37165,77 +37535,6 @@ Check the top-level render call using <` + t + ">.");
|
|
|
37165
37535
|
}, [ref, clickOutsideHandler]);
|
|
37166
37536
|
};
|
|
37167
37537
|
|
|
37168
|
-
var handleUSException = function (number, originalValidation) {
|
|
37169
|
-
var _a;
|
|
37170
|
-
var areaCodes = (_a = originalValidation.country) === null || _a === void 0 ? void 0 : _a.areaCodes;
|
|
37171
|
-
var providedAreaCode = number.slice(2, 5);
|
|
37172
|
-
if (providedAreaCode.length === 3 && (areaCodes === null || areaCodes === void 0 ? void 0 : areaCodes.includes(providedAreaCode))) {
|
|
37173
|
-
return originalValidation;
|
|
37174
|
-
}
|
|
37175
|
-
var USValidation = build.exports.validatePhone(number, {
|
|
37176
|
-
countries: getDefaultCountries(['us'], undefined),
|
|
37177
|
-
charAfterDialCode: '',
|
|
37178
|
-
prefix: '+' });
|
|
37179
|
-
|
|
37180
|
-
return USValidation;
|
|
37181
|
-
};
|
|
37182
|
-
var useValidate = function () {
|
|
37183
|
-
var validatePhoneNumber = function (number, availableCountries) {
|
|
37184
|
-
var validation = build.exports.validatePhone(number, {
|
|
37185
|
-
countries: getDefaultCountries(availableCountries, undefined),
|
|
37186
|
-
charAfterDialCode: '',
|
|
37187
|
-
prefix: '+' });
|
|
37188
|
-
|
|
37189
|
-
if (number.startsWith('+1') && validation.isValid === false) {
|
|
37190
|
-
return handleUSException(number, validation);
|
|
37191
|
-
}
|
|
37192
|
-
return validation;
|
|
37193
|
-
};
|
|
37194
|
-
var isValidE164Number = function (number, availableCountries) {
|
|
37195
|
-
var validation = build.exports.validatePhone(number, {
|
|
37196
|
-
countries: getDefaultCountries(availableCountries, undefined),
|
|
37197
|
-
charAfterDialCode: '',
|
|
37198
|
-
prefix: '+' });
|
|
37199
|
-
|
|
37200
|
-
if (number.startsWith('+1') && validation.isValid === false) {
|
|
37201
|
-
return handleUSException(number, validation).isValid;
|
|
37202
|
-
}
|
|
37203
|
-
return validation.isValid;
|
|
37204
|
-
};
|
|
37205
|
-
var numberMatchesAvailableCountries = function (number, availableCountries) {
|
|
37206
|
-
var _a;
|
|
37207
|
-
try {
|
|
37208
|
-
var validation = build.exports.validatePhone(number, {
|
|
37209
|
-
countries: getDefaultCountries(availableCountries, undefined),
|
|
37210
|
-
charAfterDialCode: '',
|
|
37211
|
-
prefix: '+' });
|
|
37212
|
-
|
|
37213
|
-
if (number.startsWith('+1') && validation.isValid === false) {
|
|
37214
|
-
validation = handleUSException(number, validation);
|
|
37215
|
-
}
|
|
37216
|
-
if (!validation.country) {
|
|
37217
|
-
return false;
|
|
37218
|
-
}
|
|
37219
|
-
if (typeof availableCountries === 'string') {
|
|
37220
|
-
return (_a = availableCountries === validation.country.iso2) !== null && _a !== void 0 ? _a : false;
|
|
37221
|
-
}
|
|
37222
|
-
return availableCountries.includes(validation.country.iso2);
|
|
37223
|
-
}
|
|
37224
|
-
catch (_b) {
|
|
37225
|
-
return false;
|
|
37226
|
-
}
|
|
37227
|
-
};
|
|
37228
|
-
var isPossibleE164Number = function (number) {
|
|
37229
|
-
return /^\+?[1-9]\d{1,14}$/.test(number);
|
|
37230
|
-
};
|
|
37231
|
-
return {
|
|
37232
|
-
isValidE164Number: isValidE164Number,
|
|
37233
|
-
isPossibleE164Number: isPossibleE164Number,
|
|
37234
|
-
validatePhoneNumber: validatePhoneNumber,
|
|
37235
|
-
numberMatchesAvailableCountries: numberMatchesAvailableCountries };
|
|
37236
|
-
|
|
37237
|
-
};
|
|
37238
|
-
|
|
37239
37538
|
var getDefaultValue = function (question) {
|
|
37240
37539
|
switch (question.userQuestionType) {
|
|
37241
37540
|
case exports.UserQuestionType.MultipleSelect:
|
|
@@ -37316,7 +37615,7 @@ Check the top-level render call using <` + t + ">.");
|
|
|
37316
37615
|
}
|
|
37317
37616
|
return Math.round((currentQuestionIndex + 1) / allQuestions.length * 100);
|
|
37318
37617
|
};
|
|
37319
|
-
var getErrorsForQuestion = function (currentQuestion, formMethods, errorLabels, isValidE164Number) {
|
|
37618
|
+
var getErrorsForQuestion = function (currentQuestion, formMethods, errorLabels, isValidE164Number, validateDateResponse, validateNumberResponse) {
|
|
37320
37619
|
var _a;
|
|
37321
37620
|
if ((currentQuestion === null || currentQuestion === void 0 ? void 0 : currentQuestion.userQuestionType) === exports.UserQuestionType.Description) {
|
|
37322
37621
|
return [];
|
|
@@ -37340,8 +37639,71 @@ Check the top-level render call using <` + t + ">.");
|
|
|
37340
37639
|
}
|
|
37341
37640
|
}
|
|
37342
37641
|
}
|
|
37642
|
+
if ((currentQuestion === null || currentQuestion === void 0 ? void 0 : currentQuestion.userQuestionType) === exports.UserQuestionType.Date) {
|
|
37643
|
+
var error = validateDateResponse(currentQuestion === null || currentQuestion === void 0 ? void 0 : currentQuestion.questionConfig, valueOfCurrentQuestion);
|
|
37644
|
+
if (error.isValid === false) {
|
|
37645
|
+
switch (error.errorType) {
|
|
37646
|
+
case 'DATE_CANNOT_BE_IN_THE_FUTURE':
|
|
37647
|
+
return [
|
|
37648
|
+
{
|
|
37649
|
+
id: currentQuestion.id,
|
|
37650
|
+
error: errorLabels.dateCannotBeInTheFuture ||
|
|
37651
|
+
'Date cannot be in the future' }];
|
|
37652
|
+
|
|
37653
|
+
|
|
37654
|
+
case 'DATE_CANNOT_BE_IN_THE_PAST':
|
|
37655
|
+
return [
|
|
37656
|
+
{
|
|
37657
|
+
id: currentQuestion.id,
|
|
37658
|
+
error: errorLabels.dateCannotBeInThePast ||
|
|
37659
|
+
'Date cannot be in the past' }];
|
|
37660
|
+
|
|
37661
|
+
|
|
37662
|
+
case 'DATE_CANNOT_BE_TODAY':
|
|
37663
|
+
return [
|
|
37664
|
+
{
|
|
37665
|
+
id: currentQuestion.id,
|
|
37666
|
+
error: errorLabels.dateCannotBeToday || 'Date cannot be today' }];}
|
|
37667
|
+
|
|
37668
|
+
|
|
37669
|
+
|
|
37670
|
+
}
|
|
37671
|
+
}
|
|
37672
|
+
if ((currentQuestion === null || currentQuestion === void 0 ? void 0 : currentQuestion.userQuestionType) === exports.UserQuestionType.Number) {
|
|
37673
|
+
var error = validateNumberResponse(currentQuestion === null || currentQuestion === void 0 ? void 0 : currentQuestion.questionConfig, valueOfCurrentQuestion);
|
|
37674
|
+
if (error.isValid === false) {
|
|
37675
|
+
switch (error.errorType) {
|
|
37676
|
+
case 'NOT_A_NUMBER':
|
|
37677
|
+
return [
|
|
37678
|
+
{
|
|
37679
|
+
id: currentQuestion.id,
|
|
37680
|
+
error: errorLabels.notANumber || 'Value must be a valid number' }];
|
|
37681
|
+
|
|
37682
|
+
|
|
37683
|
+
case 'OUT_OF_RANGE':
|
|
37684
|
+
return [
|
|
37685
|
+
{
|
|
37686
|
+
id: currentQuestion.id,
|
|
37687
|
+
error: errorLabels.numberOutOfRange ||
|
|
37688
|
+
'The number cannot be out of range' }];}
|
|
37689
|
+
|
|
37690
|
+
|
|
37691
|
+
|
|
37692
|
+
}
|
|
37693
|
+
}
|
|
37343
37694
|
return [];
|
|
37344
37695
|
};
|
|
37696
|
+
var getDirtyFieldValues = function (formMethods) {
|
|
37697
|
+
var dirtyFields = formMethods.formState.dirtyFields,getValues = formMethods.getValues;
|
|
37698
|
+
var allValues = getValues();
|
|
37699
|
+
var dirtyValues = Object.keys(dirtyFields).reduce(function (acc, key) {
|
|
37700
|
+
if (dirtyFields[key]) {
|
|
37701
|
+
acc[key] = allValues[key];
|
|
37702
|
+
}
|
|
37703
|
+
return acc;
|
|
37704
|
+
}, {});
|
|
37705
|
+
return dirtyValues;
|
|
37706
|
+
};
|
|
37345
37707
|
|
|
37346
37708
|
var useTraditionalForm = function (_a) {
|
|
37347
37709
|
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;
|
|
@@ -37359,13 +37721,13 @@ Check the top-level render call using <` + t + ">.");
|
|
|
37359
37721
|
var _d = React.useState([]),errors = _d[0],setErrors = _d[1];
|
|
37360
37722
|
var _e = React.useState(false),formHasErrors = _e[0],setFormHasErrors = _e[1];
|
|
37361
37723
|
var _f = React.useState(false),isSubmittingForm = _f[0],setIsSubmittingForm = _f[1];
|
|
37362
|
-
var
|
|
37724
|
+
var _g = useValidate(),isValidE164Number = _g.isValidE164Number,validateDateResponse = _g.validateDateResponse,validateNumberResponse = _g.validateNumberResponse;
|
|
37363
37725
|
var updateQuestionVisibility = React.useCallback(function () {return __awaiter(void 0, void 0, void 0, function () {
|
|
37364
37726
|
var formValuesInput, evaluationResults, updatedQuestions;
|
|
37365
37727
|
return __generator(this, function (_a) {
|
|
37366
37728
|
switch (_a.label) {
|
|
37367
37729
|
case 0:
|
|
37368
|
-
formValuesInput = convertToAwellInput(formMethods
|
|
37730
|
+
formValuesInput = convertToAwellInput(getDirtyFieldValues(formMethods));
|
|
37369
37731
|
return [4, evaluateDisplayConditions(formValuesInput)];
|
|
37370
37732
|
case 1:
|
|
37371
37733
|
evaluationResults = _a.sent();
|
|
@@ -37411,7 +37773,7 @@ Check the top-level render call using <` + t + ">.");
|
|
|
37411
37773
|
case 1:
|
|
37412
37774
|
_a.sent();
|
|
37413
37775
|
errors = visibleQuestions.flatMap(function (vq) {
|
|
37414
|
-
return getErrorsForQuestion(vq, formMethods, errorLabels, isValidE164Number);
|
|
37776
|
+
return getErrorsForQuestion(vq, formMethods, errorLabels, isValidE164Number, validateDateResponse, validateNumberResponse);
|
|
37415
37777
|
});
|
|
37416
37778
|
setErrors(errors);
|
|
37417
37779
|
if (errors.length == 0) {
|
|
@@ -37439,7 +37801,7 @@ Check the top-level render call using <` + t + ">.");
|
|
|
37439
37801
|
var useConversationalForm = function (_a) {
|
|
37440
37802
|
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;
|
|
37441
37803
|
var initialValues = convertToFormFormat(storedAnswers, questions);
|
|
37442
|
-
var
|
|
37804
|
+
var _c = useValidate(),isValidE164Number = _c.isValidE164Number,validateDateResponse = _c.validateDateResponse,validateNumberResponse = _c.validateNumberResponse;
|
|
37443
37805
|
var defaultValues = !isEmpty(initialValues) && autosaveAnswers ?
|
|
37444
37806
|
initialValues :
|
|
37445
37807
|
getInitialValues(questions);
|
|
@@ -37449,19 +37811,19 @@ Check the top-level render call using <` + t + ">.");
|
|
|
37449
37811
|
shouldFocusError: true,
|
|
37450
37812
|
mode: 'all' });
|
|
37451
37813
|
|
|
37452
|
-
var
|
|
37453
|
-
var
|
|
37454
|
-
var
|
|
37455
|
-
var
|
|
37456
|
-
var
|
|
37457
|
-
var
|
|
37814
|
+
var _d = React.useState([]),visibleQuestions = _d[0],setVisibleQuestions = _d[1];
|
|
37815
|
+
var _e = React.useState([]),errors = _e[0],setErrors = _e[1];
|
|
37816
|
+
var _f = React.useState(0),current = _f[0],setCurrent = _f[1];
|
|
37817
|
+
var _g = React.useState(true),isEvaluatingQuestionVisibility = _g[0],setIsEvaluatingQuestionVisibility = _g[1];
|
|
37818
|
+
var _h = React.useState(0),percentageCompleted = _h[0],setPercentageCompleted = _h[1];
|
|
37819
|
+
var _j = React.useState(false),isSubmittingForm = _j[0],setIsSubmittingForm = _j[1];
|
|
37458
37820
|
var updateQuestionVisibility = React.useCallback(function () {return __awaiter(void 0, void 0, void 0, function () {
|
|
37459
37821
|
var formValuesInput, evaluationResults, updatedQuestions;
|
|
37460
37822
|
return __generator(this, function (_a) {
|
|
37461
37823
|
switch (_a.label) {
|
|
37462
37824
|
case 0:
|
|
37463
37825
|
setIsEvaluatingQuestionVisibility(true);
|
|
37464
|
-
formValuesInput = convertToAwellInput(formMethods
|
|
37826
|
+
formValuesInput = convertToAwellInput(getDirtyFieldValues(formMethods));
|
|
37465
37827
|
return [4, evaluateDisplayConditions(formValuesInput)];
|
|
37466
37828
|
case 1:
|
|
37467
37829
|
evaluationResults = _a.sent();
|
|
@@ -37494,7 +37856,7 @@ Check the top-level render call using <` + t + ">.");
|
|
|
37494
37856
|
}, [updateQuestionVisibility]);
|
|
37495
37857
|
var handleCheckForErrors = function (currentQuestion) {
|
|
37496
37858
|
var errorsWithoutCurrent = errors.filter(function (err) {return err.id !== (currentQuestion === null || currentQuestion === void 0 ? void 0 : currentQuestion.id);});
|
|
37497
|
-
var existingErrors = getErrorsForQuestion(currentQuestion, formMethods, errorLabels, isValidE164Number);
|
|
37859
|
+
var existingErrors = getErrorsForQuestion(currentQuestion, formMethods, errorLabels, isValidE164Number, validateDateResponse, validateNumberResponse);
|
|
37498
37860
|
setErrors(__spreadArray(__spreadArray([], errorsWithoutCurrent, true), existingErrors, true));
|
|
37499
37861
|
return existingErrors.length > 0;
|
|
37500
37862
|
};
|
|
@@ -2,6 +2,8 @@ import { UseFormReturn } from 'react-hook-form';
|
|
|
2
2
|
import { Question, QuestionWithVisibility, FormError } from '../../types';
|
|
3
3
|
import { AnswerValue, ErrorLabels, QuestionRuleResult } from './types';
|
|
4
4
|
import { CountryIso2 } from 'react-international-phone';
|
|
5
|
+
import { Maybe, QuestionConfig } from '../../types/generated/types-orchestration';
|
|
6
|
+
import { DateValidationErrorType, NumberValidationErrorType } from '../useValidate/useValidate';
|
|
5
7
|
export declare const getDefaultValue: (question: Question) => AnswerValue;
|
|
6
8
|
export declare const getInitialValues: (questions: Array<Question>) => Record<string, AnswerValue>;
|
|
7
9
|
export declare const convertToAwellInput: (formResponse: any) => {
|
|
@@ -16,5 +18,12 @@ interface CalculatePercentageCompletedProps {
|
|
|
16
18
|
allQuestions: Question[];
|
|
17
19
|
}
|
|
18
20
|
export declare const calculatePercentageCompleted: ({ currentQuestionId, allQuestions, }: CalculatePercentageCompletedProps) => number;
|
|
19
|
-
export declare const getErrorsForQuestion: (currentQuestion: QuestionWithVisibility, formMethods: UseFormReturn<Record<string, AnswerValue>, any>, errorLabels: ErrorLabels, isValidE164Number: (number: string, availableCountries?: Array<CountryIso2>) => boolean) =>
|
|
21
|
+
export declare const getErrorsForQuestion: (currentQuestion: QuestionWithVisibility, formMethods: UseFormReturn<Record<string, AnswerValue>, any>, errorLabels: ErrorLabels, isValidE164Number: (number: string, availableCountries?: Array<CountryIso2>) => boolean, validateDateResponse: (questionConfig: Maybe<QuestionConfig> | undefined, value: string) => {
|
|
22
|
+
isValid: boolean;
|
|
23
|
+
errorType?: DateValidationErrorType;
|
|
24
|
+
}, validateNumberResponse: (questionConfig: Maybe<QuestionConfig> | undefined, value: string) => {
|
|
25
|
+
isValid: boolean;
|
|
26
|
+
errorType?: NumberValidationErrorType;
|
|
27
|
+
}) => Array<FormError>;
|
|
28
|
+
export declare const getDirtyFieldValues: (formMethods: UseFormReturn) => Record<string, AnswerValue>;
|
|
20
29
|
export {};
|
|
@@ -20,6 +20,11 @@ export declare type ErrorLabels = {
|
|
|
20
20
|
sliderNotTouched: string;
|
|
21
21
|
invalidPhoneNumber: string;
|
|
22
22
|
formHasErrors: string;
|
|
23
|
+
dateCannotBeInTheFuture?: string;
|
|
24
|
+
dateCannotBeInThePast?: string;
|
|
25
|
+
dateCannotBeToday?: string;
|
|
26
|
+
notANumber?: string;
|
|
27
|
+
numberOutOfRange?: string;
|
|
23
28
|
};
|
|
24
29
|
export declare type AnswerValue = string | number | number[] | undefined;
|
|
25
30
|
export interface FormSettingsContextProps {
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { ValidatePhoneReturn, CountryIso2 } from './types';
|
|
2
|
+
import { Maybe, QuestionConfig } from '../../types/generated/types-orchestration';
|
|
3
|
+
export declare type DateValidationErrorType = 'DATE_CANNOT_BE_IN_THE_FUTURE' | 'DATE_CANNOT_BE_IN_THE_PAST' | 'DATE_CANNOT_BE_TODAY';
|
|
4
|
+
export declare type NumberValidationErrorType = 'NOT_A_NUMBER' | 'OUT_OF_RANGE';
|
|
2
5
|
export interface UseValidateHook {
|
|
3
6
|
validatePhoneNumber: (number: string, availableCountries?: Array<CountryIso2>) => ValidatePhoneReturn;
|
|
4
7
|
isValidE164Number: (number: string, availableCountries?: Array<CountryIso2>) => boolean;
|
|
5
8
|
isPossibleE164Number: (number: string) => boolean;
|
|
6
9
|
numberMatchesAvailableCountries: (number: string, availableCountries: Array<CountryIso2>) => boolean;
|
|
10
|
+
validateDateResponse: (questionConfig: Maybe<QuestionConfig> | undefined, value: string) => {
|
|
11
|
+
isValid: boolean;
|
|
12
|
+
errorType?: DateValidationErrorType;
|
|
13
|
+
};
|
|
14
|
+
validateNumberResponse: (questionConfig: Maybe<QuestionConfig> | undefined, value: string) => {
|
|
15
|
+
isValid: boolean;
|
|
16
|
+
errorType?: NumberValidationErrorType;
|
|
17
|
+
};
|
|
7
18
|
}
|
|
8
19
|
export declare const handleUSException: (number: string, originalValidation: ValidatePhoneReturn) => ValidatePhoneReturn;
|
|
9
20
|
export declare const useValidate: () => UseValidateHook;
|
|
@@ -164,6 +164,16 @@ export declare type ActivityTrack = {
|
|
|
164
164
|
id?: Maybe<Scalars['String']>;
|
|
165
165
|
title: Scalars['String'];
|
|
166
166
|
};
|
|
167
|
+
export declare type AddIdentifierToPatientInput = {
|
|
168
|
+
identifier: IdentifierInput;
|
|
169
|
+
patient_id: Scalars['String'];
|
|
170
|
+
};
|
|
171
|
+
export declare type AddIdentifierToPatientPayload = Payload & {
|
|
172
|
+
__typename?: 'AddIdentifierToPatientPayload';
|
|
173
|
+
code: Scalars['String'];
|
|
174
|
+
patient?: Maybe<User>;
|
|
175
|
+
success: Scalars['Boolean'];
|
|
176
|
+
};
|
|
167
177
|
export declare type AddTrackInput = {
|
|
168
178
|
pathway_id: Scalars['String'];
|
|
169
179
|
track_id: Scalars['String'];
|
|
@@ -188,8 +198,14 @@ export declare type AddressInput = {
|
|
|
188
198
|
street?: InputMaybe<Scalars['String']>;
|
|
189
199
|
zip?: InputMaybe<Scalars['String']>;
|
|
190
200
|
};
|
|
201
|
+
export declare enum AllowedDatesOptions {
|
|
202
|
+
All = "ALL",
|
|
203
|
+
Future = "FUTURE",
|
|
204
|
+
Past = "PAST"
|
|
205
|
+
}
|
|
191
206
|
export declare type Answer = {
|
|
192
207
|
__typename?: 'Answer';
|
|
208
|
+
label?: Maybe<Scalars['String']>;
|
|
193
209
|
question_id: Scalars['String'];
|
|
194
210
|
value: Scalars['String'];
|
|
195
211
|
value_type: DataPointValueType;
|
|
@@ -284,6 +300,7 @@ export declare enum BooleanOperator {
|
|
|
284
300
|
export declare type BrandingSettings = {
|
|
285
301
|
__typename?: 'BrandingSettings';
|
|
286
302
|
accent_color?: Maybe<Scalars['String']>;
|
|
303
|
+
custom_theme?: Maybe<Scalars['String']>;
|
|
287
304
|
hosted_page_auto_progress?: Maybe<Scalars['Boolean']>;
|
|
288
305
|
hosted_page_autosave?: Maybe<Scalars['Boolean']>;
|
|
289
306
|
hosted_page_title?: Maybe<Scalars['String']>;
|
|
@@ -315,6 +332,12 @@ export declare type ChecklistPayload = Payload & {
|
|
|
315
332
|
code: Scalars['String'];
|
|
316
333
|
success: Scalars['Boolean'];
|
|
317
334
|
};
|
|
335
|
+
export declare type ChoiceRangeConfig = {
|
|
336
|
+
__typename?: 'ChoiceRangeConfig';
|
|
337
|
+
enabled?: Maybe<Scalars['Boolean']>;
|
|
338
|
+
max?: Maybe<Scalars['Float']>;
|
|
339
|
+
min?: Maybe<Scalars['Float']>;
|
|
340
|
+
};
|
|
318
341
|
export declare type ClinicalNotePayload = Payload & {
|
|
319
342
|
__typename?: 'ClinicalNotePayload';
|
|
320
343
|
clinical_note: GeneratedClinicalNote;
|
|
@@ -371,6 +394,7 @@ export declare type CreatePatientInput = {
|
|
|
371
394
|
birth_date?: InputMaybe<Scalars['String']>;
|
|
372
395
|
email?: InputMaybe<Scalars['String']>;
|
|
373
396
|
first_name?: InputMaybe<Scalars['String']>;
|
|
397
|
+
identifier?: InputMaybe<Array<IdentifierInput>>;
|
|
374
398
|
last_name?: InputMaybe<Scalars['String']>;
|
|
375
399
|
mobile_phone?: InputMaybe<Scalars['String']>;
|
|
376
400
|
national_registry_number?: InputMaybe<Scalars['String']>;
|
|
@@ -385,6 +409,19 @@ export declare type CreatePatientPayload = Payload & {
|
|
|
385
409
|
patient?: Maybe<User>;
|
|
386
410
|
success: Scalars['Boolean'];
|
|
387
411
|
};
|
|
412
|
+
export declare type CurrentUser = {
|
|
413
|
+
__typename?: 'CurrentUser';
|
|
414
|
+
id: Scalars['ID'];
|
|
415
|
+
profile?: Maybe<UserProfile>;
|
|
416
|
+
tenant: Tenant;
|
|
417
|
+
tenant_id: Scalars['String'];
|
|
418
|
+
};
|
|
419
|
+
export declare type CurrentUserPayload = Payload & {
|
|
420
|
+
__typename?: 'CurrentUserPayload';
|
|
421
|
+
code: Scalars['String'];
|
|
422
|
+
success: Scalars['Boolean'];
|
|
423
|
+
user: CurrentUser;
|
|
424
|
+
};
|
|
388
425
|
export declare type DataPointDefinition = {
|
|
389
426
|
__typename?: 'DataPointDefinition';
|
|
390
427
|
category: DataPointSourceType;
|
|
@@ -422,6 +459,7 @@ export declare enum DataPointSourceType {
|
|
|
422
459
|
ExtensionWebhook = "EXTENSION_WEBHOOK",
|
|
423
460
|
Form = "FORM",
|
|
424
461
|
Pathway = "PATHWAY",
|
|
462
|
+
PatientIdentifier = "PATIENT_IDENTIFIER",
|
|
425
463
|
PatientProfile = "PATIENT_PROFILE",
|
|
426
464
|
Step = "STEP",
|
|
427
465
|
Track = "TRACK"
|
|
@@ -435,6 +473,11 @@ export declare enum DataPointValueType {
|
|
|
435
473
|
StringsArray = "STRINGS_ARRAY",
|
|
436
474
|
Telephone = "TELEPHONE"
|
|
437
475
|
}
|
|
476
|
+
export declare type DateConfig = {
|
|
477
|
+
__typename?: 'DateConfig';
|
|
478
|
+
allowed_dates?: Maybe<AllowedDatesOptions>;
|
|
479
|
+
include_date_of_response?: Maybe<Scalars['Boolean']>;
|
|
480
|
+
};
|
|
438
481
|
export declare type DateFilter = {
|
|
439
482
|
gte?: InputMaybe<Scalars['String']>;
|
|
440
483
|
lte?: InputMaybe<Scalars['String']>;
|
|
@@ -518,6 +561,11 @@ export declare type EvaluateFormRulesPayload = Payload & {
|
|
|
518
561
|
results: Array<QuestionRuleResult>;
|
|
519
562
|
success: Scalars['Boolean'];
|
|
520
563
|
};
|
|
564
|
+
export declare type ExclusiveOptionConfig = {
|
|
565
|
+
__typename?: 'ExclusiveOptionConfig';
|
|
566
|
+
enabled?: Maybe<Scalars['Boolean']>;
|
|
567
|
+
option_id?: Maybe<Scalars['String']>;
|
|
568
|
+
};
|
|
521
569
|
export declare type ExtensionActionField = {
|
|
522
570
|
__typename?: 'ExtensionActionField';
|
|
523
571
|
id: Scalars['ID'];
|
|
@@ -531,7 +579,9 @@ export declare enum ExtensionActionFieldType {
|
|
|
531
579
|
Html = "HTML",
|
|
532
580
|
Json = "JSON",
|
|
533
581
|
Numeric = "NUMERIC",
|
|
582
|
+
NumericArray = "NUMERIC_ARRAY",
|
|
534
583
|
String = "STRING",
|
|
584
|
+
StringArray = "STRING_ARRAY",
|
|
535
585
|
Text = "TEXT"
|
|
536
586
|
}
|
|
537
587
|
export declare type ExtensionActivityRecord = {
|
|
@@ -712,6 +762,21 @@ export declare enum HostedSessionStatus {
|
|
|
712
762
|
export declare type IdFilter = {
|
|
713
763
|
eq?: InputMaybe<Scalars['String']>;
|
|
714
764
|
};
|
|
765
|
+
export declare type Identifier = {
|
|
766
|
+
__typename?: 'Identifier';
|
|
767
|
+
system: Scalars['String'];
|
|
768
|
+
value: Scalars['String'];
|
|
769
|
+
};
|
|
770
|
+
export declare type IdentifierInput = {
|
|
771
|
+
system: Scalars['String'];
|
|
772
|
+
value: Scalars['String'];
|
|
773
|
+
};
|
|
774
|
+
export declare type IdentifierSystem = {
|
|
775
|
+
__typename?: 'IdentifierSystem';
|
|
776
|
+
display_name: Scalars['String'];
|
|
777
|
+
name: Scalars['String'];
|
|
778
|
+
system: Scalars['String'];
|
|
779
|
+
};
|
|
715
780
|
export declare type MarkMessageAsReadInput = {
|
|
716
781
|
activity_id: Scalars['String'];
|
|
717
782
|
};
|
|
@@ -751,8 +816,14 @@ export declare type MessagePayload = Payload & {
|
|
|
751
816
|
message?: Maybe<Message>;
|
|
752
817
|
success: Scalars['Boolean'];
|
|
753
818
|
};
|
|
819
|
+
export declare type MultipleSelectConfig = {
|
|
820
|
+
__typename?: 'MultipleSelectConfig';
|
|
821
|
+
exclusive_option?: Maybe<ExclusiveOptionConfig>;
|
|
822
|
+
range?: Maybe<ChoiceRangeConfig>;
|
|
823
|
+
};
|
|
754
824
|
export declare type Mutation = {
|
|
755
825
|
__typename?: 'Mutation';
|
|
826
|
+
addIdentifierToPatient: AddIdentifierToPatientPayload;
|
|
756
827
|
addTrack: AddTrackPayload;
|
|
757
828
|
completeExtensionActivity: CompleteExtensionActivityPayload;
|
|
758
829
|
createPatient: CreatePatientPayload;
|
|
@@ -777,6 +848,7 @@ export declare type Mutation = {
|
|
|
777
848
|
startHostedPathwaySession: StartHostedPathwaySessionPayload;
|
|
778
849
|
startHostedPathwaySessionFromLink: StartHostedPathwaySessionFromLinkPayload;
|
|
779
850
|
startPathway: StartPathwayPayload;
|
|
851
|
+
startPathwayWithPatientIdentifier: StartPathwayWithPatientIdentifierPayload;
|
|
780
852
|
stopPathway: EmptyPayload;
|
|
781
853
|
stopTrack: StopTrackPayload;
|
|
782
854
|
submitChecklist: SubmitChecklistPayload;
|
|
@@ -787,6 +859,9 @@ export declare type Mutation = {
|
|
|
787
859
|
updatePatientDemographicsQuery: UpdatePatientDemographicsQueryPayload;
|
|
788
860
|
updatePatientLanguage: UpdatePatientLanguagePayload;
|
|
789
861
|
};
|
|
862
|
+
export declare type MutationAddIdentifierToPatientArgs = {
|
|
863
|
+
input: AddIdentifierToPatientInput;
|
|
864
|
+
};
|
|
790
865
|
export declare type MutationAddTrackArgs = {
|
|
791
866
|
input: AddTrackInput;
|
|
792
867
|
};
|
|
@@ -860,6 +935,9 @@ export declare type MutationStartHostedPathwaySessionFromLinkArgs = {
|
|
|
860
935
|
export declare type MutationStartPathwayArgs = {
|
|
861
936
|
input: StartPathwayInput;
|
|
862
937
|
};
|
|
938
|
+
export declare type MutationStartPathwayWithPatientIdentifierArgs = {
|
|
939
|
+
input: StartPathwayWithPatientIdentifierInput;
|
|
940
|
+
};
|
|
863
941
|
export declare type MutationStopPathwayArgs = {
|
|
864
942
|
input: StopPathwayInput;
|
|
865
943
|
};
|
|
@@ -893,6 +971,10 @@ export declare type MyCareOptions = {
|
|
|
893
971
|
export declare type NumberArrayFilter = {
|
|
894
972
|
in?: InputMaybe<Array<Scalars['Float']>>;
|
|
895
973
|
};
|
|
974
|
+
export declare type NumberConfig = {
|
|
975
|
+
__typename?: 'NumberConfig';
|
|
976
|
+
range?: Maybe<RangeConfig>;
|
|
977
|
+
};
|
|
896
978
|
export declare type Operand = {
|
|
897
979
|
__typename?: 'Operand';
|
|
898
980
|
type: ConditionOperandType;
|
|
@@ -1075,6 +1157,7 @@ export declare type PatientProfileInput = {
|
|
|
1075
1157
|
birth_date?: InputMaybe<Scalars['String']>;
|
|
1076
1158
|
email?: InputMaybe<Scalars['String']>;
|
|
1077
1159
|
first_name?: InputMaybe<Scalars['String']>;
|
|
1160
|
+
identifier?: InputMaybe<Array<IdentifierInput>>;
|
|
1078
1161
|
last_name?: InputMaybe<Scalars['String']>;
|
|
1079
1162
|
mobile_phone?: InputMaybe<Scalars['String']>;
|
|
1080
1163
|
national_registry_number?: InputMaybe<Scalars['String']>;
|
|
@@ -1178,6 +1261,7 @@ export declare type Query = {
|
|
|
1178
1261
|
pathwayStepActivities: ActivitiesPayload;
|
|
1179
1262
|
pathways: PathwaysPayload;
|
|
1180
1263
|
patient: PatientPayload;
|
|
1264
|
+
patientByIdentifier: PatientPayload;
|
|
1181
1265
|
patientDemographicsQueryConfiguration: PatientDemographicsQueryConfigurationPayload;
|
|
1182
1266
|
patientPathways: PatientPathwaysPayload;
|
|
1183
1267
|
patients: PatientsPayload;
|
|
@@ -1194,7 +1278,7 @@ export declare type Query = {
|
|
|
1194
1278
|
webhookCalls: WebhookCallsPayload;
|
|
1195
1279
|
webhookCallsForPathwayDefinition: WebhookCallsPayload;
|
|
1196
1280
|
webhookCallsForTenant: WebhookCallsPayload;
|
|
1197
|
-
whoami:
|
|
1281
|
+
whoami: CurrentUserPayload;
|
|
1198
1282
|
};
|
|
1199
1283
|
export declare type QueryActivitiesArgs = {
|
|
1200
1284
|
filters?: InputMaybe<FilterActivitiesParams>;
|
|
@@ -1299,6 +1383,10 @@ export declare type QueryPathwaysArgs = {
|
|
|
1299
1383
|
export declare type QueryPatientArgs = {
|
|
1300
1384
|
id: Scalars['String'];
|
|
1301
1385
|
};
|
|
1386
|
+
export declare type QueryPatientByIdentifierArgs = {
|
|
1387
|
+
system: Scalars['String'];
|
|
1388
|
+
value: Scalars['String'];
|
|
1389
|
+
};
|
|
1302
1390
|
export declare type QueryPatientPathwaysArgs = {
|
|
1303
1391
|
filters?: InputMaybe<FilterPatientPathways>;
|
|
1304
1392
|
patient_id: Scalars['String'];
|
|
@@ -1359,7 +1447,10 @@ export declare type Question = {
|
|
|
1359
1447
|
};
|
|
1360
1448
|
export declare type QuestionConfig = {
|
|
1361
1449
|
__typename?: 'QuestionConfig';
|
|
1450
|
+
date?: Maybe<DateConfig>;
|
|
1362
1451
|
mandatory: Scalars['Boolean'];
|
|
1452
|
+
multiple_select?: Maybe<MultipleSelectConfig>;
|
|
1453
|
+
number?: Maybe<NumberConfig>;
|
|
1363
1454
|
phone?: Maybe<PhoneConfig>;
|
|
1364
1455
|
recode_enabled?: Maybe<Scalars['Boolean']>;
|
|
1365
1456
|
slider?: Maybe<SliderConfig>;
|
|
@@ -1385,6 +1476,12 @@ export declare type Range = {
|
|
|
1385
1476
|
max?: Maybe<Scalars['Float']>;
|
|
1386
1477
|
min?: Maybe<Scalars['Float']>;
|
|
1387
1478
|
};
|
|
1479
|
+
export declare type RangeConfig = {
|
|
1480
|
+
__typename?: 'RangeConfig';
|
|
1481
|
+
enabled?: Maybe<Scalars['Boolean']>;
|
|
1482
|
+
max?: Maybe<Scalars['Float']>;
|
|
1483
|
+
min?: Maybe<Scalars['Float']>;
|
|
1484
|
+
};
|
|
1388
1485
|
export declare type RetryActivityInput = {
|
|
1389
1486
|
activity_id: Scalars['String'];
|
|
1390
1487
|
};
|
|
@@ -1556,6 +1653,7 @@ export declare type StartHostedActivitySessionViaHostedPagesLinkInput = {
|
|
|
1556
1653
|
};
|
|
1557
1654
|
export declare type StartHostedPathwaySessionFromLinkInput = {
|
|
1558
1655
|
id: Scalars['String'];
|
|
1656
|
+
patient_identifier?: InputMaybe<IdentifierInput>;
|
|
1559
1657
|
};
|
|
1560
1658
|
export declare type StartHostedPathwaySessionFromLinkPayload = Payload & {
|
|
1561
1659
|
__typename?: 'StartHostedPathwaySessionFromLinkPayload';
|
|
@@ -1569,6 +1667,7 @@ export declare type StartHostedPathwaySessionInput = {
|
|
|
1569
1667
|
language?: InputMaybe<Scalars['String']>;
|
|
1570
1668
|
pathway_definition_id: Scalars['String'];
|
|
1571
1669
|
patient_id?: InputMaybe<Scalars['String']>;
|
|
1670
|
+
patient_identifier?: InputMaybe<IdentifierInput>;
|
|
1572
1671
|
success_url?: InputMaybe<Scalars['String']>;
|
|
1573
1672
|
};
|
|
1574
1673
|
export declare type StartHostedPathwaySessionPayload = Payload & {
|
|
@@ -1584,6 +1683,7 @@ export declare type StartPathwayInput = {
|
|
|
1584
1683
|
data_points?: InputMaybe<Array<DataPointInput>>;
|
|
1585
1684
|
pathway_definition_id: Scalars['String'];
|
|
1586
1685
|
patient_id: Scalars['String'];
|
|
1686
|
+
release_id?: InputMaybe<Scalars['String']>;
|
|
1587
1687
|
};
|
|
1588
1688
|
export declare type StartPathwayPayload = Payload & {
|
|
1589
1689
|
__typename?: 'StartPathwayPayload';
|
|
@@ -1592,6 +1692,20 @@ export declare type StartPathwayPayload = Payload & {
|
|
|
1592
1692
|
stakeholders: Array<Stakeholder>;
|
|
1593
1693
|
success: Scalars['Boolean'];
|
|
1594
1694
|
};
|
|
1695
|
+
export declare type StartPathwayWithPatientIdentifierInput = {
|
|
1696
|
+
data_points?: InputMaybe<Array<DataPointInput>>;
|
|
1697
|
+
pathway_definition_id: Scalars['String'];
|
|
1698
|
+
patient_identifier: IdentifierInput;
|
|
1699
|
+
release_id?: InputMaybe<Scalars['String']>;
|
|
1700
|
+
};
|
|
1701
|
+
export declare type StartPathwayWithPatientIdentifierPayload = Payload & {
|
|
1702
|
+
__typename?: 'StartPathwayWithPatientIdentifierPayload';
|
|
1703
|
+
code: Scalars['String'];
|
|
1704
|
+
pathway_id: Scalars['String'];
|
|
1705
|
+
patient_id: Scalars['String'];
|
|
1706
|
+
stakeholders: Array<Stakeholder>;
|
|
1707
|
+
success: Scalars['Boolean'];
|
|
1708
|
+
};
|
|
1595
1709
|
export declare type StopPathwayInput = {
|
|
1596
1710
|
pathway_id: Scalars['String'];
|
|
1597
1711
|
reason?: InputMaybe<Scalars['String']>;
|
|
@@ -1765,6 +1879,7 @@ export declare type Tenant = {
|
|
|
1765
1879
|
__typename?: 'Tenant';
|
|
1766
1880
|
accent_color: Scalars['String'];
|
|
1767
1881
|
hosted_page_title: Scalars['String'];
|
|
1882
|
+
identifier_systems?: Maybe<Array<IdentifierSystem>>;
|
|
1768
1883
|
is_default: Scalars['Boolean'];
|
|
1769
1884
|
logo_path: Scalars['String'];
|
|
1770
1885
|
name: Scalars['String'];
|
|
@@ -1835,21 +1950,15 @@ export declare type User = {
|
|
|
1835
1950
|
__typename?: 'User';
|
|
1836
1951
|
id: Scalars['ID'];
|
|
1837
1952
|
profile?: Maybe<UserProfile>;
|
|
1838
|
-
tenant: Tenant;
|
|
1839
1953
|
tenant_id: Scalars['String'];
|
|
1840
1954
|
};
|
|
1841
|
-
export declare type UserPayload = Payload & {
|
|
1842
|
-
__typename?: 'UserPayload';
|
|
1843
|
-
code: Scalars['String'];
|
|
1844
|
-
success: Scalars['Boolean'];
|
|
1845
|
-
user: User;
|
|
1846
|
-
};
|
|
1847
1955
|
export declare type UserProfile = {
|
|
1848
1956
|
__typename?: 'UserProfile';
|
|
1849
1957
|
address?: Maybe<Address>;
|
|
1850
1958
|
birth_date?: Maybe<Scalars['String']>;
|
|
1851
1959
|
email?: Maybe<Scalars['String']>;
|
|
1852
1960
|
first_name?: Maybe<Scalars['String']>;
|
|
1961
|
+
identifier?: Maybe<Array<Identifier>>;
|
|
1853
1962
|
last_name?: Maybe<Scalars['String']>;
|
|
1854
1963
|
mobile_phone?: Maybe<Scalars['String']>;
|
|
1855
1964
|
name?: Maybe<Scalars['String']>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awell-health/ui-library",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.53",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "UI components to integrate with Awell Health",
|
|
6
6
|
"repository": {
|
|
@@ -193,4 +193,4 @@
|
|
|
193
193
|
]
|
|
194
194
|
},
|
|
195
195
|
"homepage": "https://github.com/awell-health/ui-library#readme"
|
|
196
|
-
}
|
|
196
|
+
}
|