@awell-health/ui-library 0.1.86 → 0.1.89

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
@@ -34770,9 +34770,10 @@ Check the top-level render call using <` + t + ">.");
34770
34770
  return value;
34771
34771
  }
34772
34772
  if (type === 'single') {
34773
- return [
34773
+ var matchingOption = [
34774
34774
  (_a = options.find(function (option) {return value === option.value;})) !== null && _a !== void 0 ? _a : undefined].
34775
34775
  filter(function (option) {return option !== undefined;});
34776
+ return matchingOption;
34776
34777
  }
34777
34778
  return [];
34778
34779
  };
@@ -34815,6 +34816,13 @@ Check the top-level render call using <` + t + ">.");
34815
34816
  };
34816
34817
  }, [isOpen, handleClickOutside]);
34817
34818
  React.useEffect(function () {
34819
+ var _a;
34820
+ if (!lodash.exports.isNil(onSearch) &&
34821
+ allowSearchAfterSelect &&
34822
+ searchValue === ((_a = selected[0]) === null || _a === void 0 ? void 0 : _a.label)) {
34823
+ setIsOpen(false);
34824
+ return;
34825
+ }
34818
34826
  if (!lodash.exports.isNil(onSearch) && options.length > 0) {
34819
34827
  setIsOpen(true);
34820
34828
  setFilteredOptions(options);
@@ -34823,6 +34831,12 @@ Check the top-level render call using <` + t + ">.");
34823
34831
  setFilteredOptions(options);
34824
34832
  }
34825
34833
  }, [options]);
34834
+ React.useEffect(function () {
34835
+ var _a, _b;
34836
+ if (allowSearchAfterSelect && selected.length > 0 && lodash.exports.isEmpty(searchValue)) {
34837
+ setSearchValue((_b = (_a = selected[0]) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : '');
34838
+ }
34839
+ }, [selected, allowSearchAfterSelect, searchValue]);
34826
34840
  React.useEffect(function () {
34827
34841
  if (isOpen) {
34828
34842
  var container = document.getElementById('ahp_main_content_with_scroll_hint');
@@ -34869,16 +34883,19 @@ Check the top-level render call using <` + t + ">.");
34869
34883
  return jsxRuntime.exports.jsxs("div", __assign({ className: classes$g.option, id: "option-".concat(option.value), style: style, onClick: function (event) {return handleSelect(event, option);}, onKeyUp: function (e) {return handleKeyUpOnOption(e, option);}, onKeyDown: function (e) {return handleKeyDownOnOption(e, option);}, role: "button", tabIndex: 0 }, { children: [option.label, type === 'multiple' && jsxRuntime.exports.jsx("div", __assign({ className: classes$g.checkbox }, { children: jsxRuntime.exports.jsx("input", { type: "checkbox", id: "checkbox-".concat(option.value), checked: selected === null || selected === void 0 ? void 0 : selected.some(function (item) {return item.value === option.value;}), readOnly: true, tabIndex: -1 }) }))] }), (_b = option.id) !== null && _b !== void 0 ? _b : option.value);
34870
34884
  };
34871
34885
  var getDisplayValue = function () {
34872
- var _a, _b, _c, _d;
34886
+ var _a, _b, _c, _d, _e, _f;
34873
34887
  if (filtering) {
34874
34888
  if (allowSearchAfterSelect) {
34889
+ if (lodash.exports.isEmpty(searchValue) && selected.length > 0) {
34890
+ return (_b = (_a = selected[0]) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : '';
34891
+ }
34875
34892
  return searchValue !== null && searchValue !== void 0 ? searchValue : '';
34876
34893
  } else
34877
34894
  if (selected.length === 0) {
34878
34895
  return searchValue !== null && searchValue !== void 0 ? searchValue : '';
34879
34896
  } else
34880
34897
  if (type === 'single') {
34881
- return (_b = (_a = selected[0]) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : '';
34898
+ return (_d = (_c = selected[0]) === null || _c === void 0 ? void 0 : _c.label) !== null && _d !== void 0 ? _d : '';
34882
34899
  } else
34883
34900
  if (type === 'multiple') {
34884
34901
  return selected.length > 0 ?
@@ -34889,7 +34906,7 @@ Check the top-level render call using <` + t + ">.");
34889
34906
  }
34890
34907
  } else
34891
34908
  if (type === 'single') {
34892
- return (_d = (_c = selected[0]) === null || _c === void 0 ? void 0 : _c.label) !== null && _d !== void 0 ? _d : '';
34909
+ return (_f = (_e = selected[0]) === null || _e === void 0 ? void 0 : _e.label) !== null && _f !== void 0 ? _f : '';
34893
34910
  } else
34894
34911
  if (type === 'multiple') {
34895
34912
  return selected.length > 0 ?
@@ -37394,7 +37411,7 @@ Check the top-level render call using <` + t + ">.");
37394
37411
  };
37395
37412
 
37396
37413
  var isValidEmail = function (email) {
37397
- var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
37414
+ var emailRegex = /^[\w-+.]+@([\w-]+\.)+[\w-]{2,4}$/;
37398
37415
  return emailRegex.test(email);
37399
37416
  };
37400
37417
 
@@ -41123,8 +41140,11 @@ Check the top-level render call using <` + t + ">.");
41123
41140
  axios.default = axios;
41124
41141
 
41125
41142
  var ICD_10_CLASSIFICATION_ENDPOINT = "https://clinicaltables.nlm.nih.gov/api/icd10cm/v3/search";
41126
- var useICDClassificationList = function () {
41127
- var _a = React.useState([]),options = _a[0],setOptions = _a[1];
41143
+ var useICDClassificationList = function (questionId) {
41144
+ var _a = React.useState(function () {
41145
+ var savedOptions = localStorage.getItem("icdOptions-".concat(questionId));
41146
+ return savedOptions ? JSON.parse(savedOptions) : [];
41147
+ }),options = _a[0],setOptions = _a[1];
41128
41148
  var _b = React.useState(false),loading = _b[0],setLoading = _b[1];
41129
41149
  var _c = React.useState(null),error = _c[0],setError = _c[1];
41130
41150
  var _d = React.useState(''),searchValue = _d[0],setSearchValue = _d[1];
@@ -41157,6 +41177,7 @@ Check the top-level render call using <` + t + ">.");
41157
41177
 
41158
41178
  });
41159
41179
  setOptions(icdOptions);
41180
+ localStorage.setItem("icdOptions-".concat(questionId), JSON.stringify(icdOptions));
41160
41181
  return [3, 5];
41161
41182
  case 3:
41162
41183
  _b.sent();
@@ -41185,6 +41206,7 @@ Check the top-level render call using <` + t + ">.");
41185
41206
  }, [searchValue]);
41186
41207
  var onIcdClassificationSearchChange = function (val) {
41187
41208
  setSearchValue(val);
41209
+ localStorage.setItem("icdSearchValue-".concat(questionId), val);
41188
41210
  };
41189
41211
  return { options: options, loading: loading, error: error, onIcdClassificationSearchChange: onIcdClassificationSearchChange };
41190
41212
  };
@@ -41194,7 +41216,7 @@ Check the top-level render call using <` + t + ">.");
41194
41216
  var _b, _c, _d, _e, _f;
41195
41217
  var question = _a.question,control = _a.control,getValues = _a.getValues,labels = _a.labels,_g = _a.inputAutoFocus,inputAutoFocus = _g === void 0 ? false : _g,_h = _a.submitAndMoveToNextQuestion,submitAndMoveToNextQuestion = _h === void 0 ? lodash.exports.noop : _h,_j = _a.onAnswerChange,onAnswerChange = _j === void 0 ? lodash.exports.noop : _j,_k = _a.shouldAutoProgress,shouldAutoProgress = _k === void 0 ? function () {return false;} : _k;
41196
41218
  var config = question === null || question === void 0 ? void 0 : question.questionConfig;
41197
- var _l = useICDClassificationList(),icdClassificationOptions = _l.options,optionsLoading = _l.loading,onIcdClassificationSearchChange = _l.onIcdClassificationSearchChange;
41219
+ var _l = useICDClassificationList(question.id),icdClassificationOptions = _l.options,optionsLoading = _l.loading,onIcdClassificationSearchChange = _l.onIcdClassificationSearchChange;
41198
41220
  switch (question.userQuestionType) {
41199
41221
  case exports.UserQuestionType.YesNo:
41200
41222
  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) {
@@ -41578,7 +41600,7 @@ Check the top-level render call using <` + t + ">.");
41578
41600
  isValid: true };
41579
41601
 
41580
41602
  }
41581
- var parsedDate = new Date(value);
41603
+ var parsedDate = new Date("".concat(value, "T00:00:00"));
41582
41604
  var dateIsToday = isToday(parsedDate);
41583
41605
  var _a = questionConfig.date,allowed_dates = _a.allowed_dates,_b = _a.include_date_of_response,include_date_of_response = _b === void 0 ? false : _b;
41584
41606
  if (allowed_dates === exports.AllowedDatesOptions.All) {
@@ -1,5 +1,5 @@
1
1
  import { Option } from '../../types';
2
- export declare const useICDClassificationList: () => {
2
+ export declare const useICDClassificationList: (questionId: string) => {
3
3
  options: Option[];
4
4
  loading: boolean;
5
5
  error: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awell-health/ui-library",
3
- "version": "0.1.86",
3
+ "version": "0.1.89",
4
4
  "description": "UI components to integrate with Awell Health",
5
5
  "repository": {
6
6
  "type": "git",