@awell-health/ui-library 0.1.146 → 0.1.147

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.
Files changed (2) hide show
  1. package/dist/index.js +27 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -47352,29 +47352,36 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
47352
47352
  });
47353
47353
 
47354
47354
  var optionsToSelectItems = function (options) {
47355
- return options.map(function (option) {return {
47356
- value: String(option.value),
47355
+ return options.map(function (option) {
47356
+ var _a;
47357
+ return {
47358
+ value: String((_a = option.id) !== null && _a !== void 0 ? _a : option.value),
47357
47359
  label: option.label,
47358
47360
  metadata: option };
47361
+
47359
47362
  });
47360
47363
  };
47361
47364
  var multiValueToSelectItems = function (value) {
47362
47365
  if (!value || !Array.isArray(value))
47363
47366
  return [];
47364
- return value.map(function (option) {return {
47365
- value: String(option.value),
47367
+ return value.map(function (option) {
47368
+ var _a;
47369
+ return {
47370
+ value: String((_a = option.id) !== null && _a !== void 0 ? _a : option.value),
47366
47371
  label: option.label,
47367
47372
  metadata: option };
47373
+
47368
47374
  });
47369
47375
  };
47370
47376
  var singleValueToSelectItem = function (value, options) {
47377
+ var _a;
47371
47378
  if (value === undefined || value === '')
47372
47379
  return undefined;
47373
47380
  var option = options.find(function (opt) {return opt.value === value;});
47374
47381
  if (!option)
47375
47382
  return undefined;
47376
47383
  return {
47377
- value: String(option.value),
47384
+ value: String((_a = option.id) !== null && _a !== void 0 ? _a : option.value),
47378
47385
  label: option.label,
47379
47386
  metadata: option };
47380
47387
 
@@ -51533,6 +51540,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
51533
51540
  var notifyAnswerChange = function (value) {
51534
51541
  onAnswerChange({ questionId: question.id, value: value });
51535
51542
  };
51543
+ var lastSingleSelectRef = React.useRef(undefined);
51536
51544
  var _r = useICDClassificationList(question.id),icdClassificationOptions = _r.options,optionsLoading = _r.loading,onIcdClassificationSearchChange = _r.onIcdClassificationSearchChange;
51537
51545
  var getAcceptedFileTypes = function () {
51538
51546
  var _a, _b, _c, _d;
@@ -51592,14 +51600,24 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
51592
51600
  } });
51593
51601
  case exports.UserQuestionType.MultipleChoice:
51594
51602
  return jsxRuntime.exports.jsx(Controller, { name: question.id, control: control, rules: { required: config === null || config === void 0 ? void 0 : config.mandatory }, render: function (_a) {
51595
- var _b, _c, _d;
51596
- var _e = _a.field,onChange = _e.onChange,value = _e.value;
51603
+ var _b, _c, _d, _e;
51604
+ var _f = _a.field,onChange = _f.onChange,value = _f.value;
51597
51605
  if ((config === null || config === void 0 ? void 0 : config.use_select) === true) {
51598
- return jsxRuntime.exports.jsx(hf, { label: question.title, value: singleValueToSelectItem(value, (_b = question.options) !== null && _b !== void 0 ? _b : []), placeholder: (_c = labels.select) === null || _c === void 0 ? void 0 : _c.search_placeholder, onChange: function (selected) {
51606
+ var lastSelected = lastSingleSelectRef.current;
51607
+ var displayValue = !lodash.exports.isNil(value) &&
51608
+ value !== '' &&
51609
+ ((_b = lastSelected === null || lastSelected === void 0 ? void 0 : lastSelected.metadata) === null || _b === void 0 ? void 0 : _b.value) === value ?
51610
+ lastSelected :
51611
+ singleValueToSelectItem(value, (_c = question.options) !== null && _c !== void 0 ? _c : []);
51612
+ return jsxRuntime.exports.jsx(hf, { label: question.title, value: displayValue, placeholder: (_d = labels.select) === null || _d === void 0 ? void 0 : _d.search_placeholder, onChange: function (selected) {
51613
+ var _a;
51614
+ lastSingleSelectRef.current = Array.isArray(selected) ?
51615
+ undefined :
51616
+ (_a = selected) !== null && _a !== void 0 ? _a : undefined;
51599
51617
  var mapped = selectValueToSingleValue(selected);
51600
51618
  onChange(mapped);
51601
51619
  notifyAnswerChange(mapped);
51602
- }, options: optionsToSelectItems((_d = question.options) !== null && _d !== void 0 ? _d : []), required: config === null || config === void 0 ? void 0 : config.mandatory, isSearchable: true, menuPosition: "fixed" });
51620
+ }, options: optionsToSelectItems((_e = question.options) !== null && _e !== void 0 ? _e : []), required: config === null || config === void 0 ? void 0 : config.mandatory, isSearchable: true, menuPosition: "fixed" });
51603
51621
  }
51604
51622
  return jsxRuntime.exports.jsx(SingleChoiceQuestion, { label: question.title, options: question.options || [], onChange: function (data) {
51605
51623
  onChange(data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awell-health/ui-library",
3
- "version": "0.1.146",
3
+ "version": "0.1.147",
4
4
  "description": "UI components to integrate with Awell Health",
5
5
  "repository": {
6
6
  "type": "git",