@tellescope/react-components 1.153.1 → 1.155.0

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 (61) hide show
  1. package/lib/cjs/CMS/components.d.ts +0 -1
  2. package/lib/cjs/CMS/components.d.ts.map +1 -1
  3. package/lib/cjs/Forms/form_responses.d.ts +0 -1
  4. package/lib/cjs/Forms/form_responses.d.ts.map +1 -1
  5. package/lib/cjs/Forms/forms.d.ts +6 -0
  6. package/lib/cjs/Forms/forms.d.ts.map +1 -1
  7. package/lib/cjs/Forms/forms.js +6 -5
  8. package/lib/cjs/Forms/forms.js.map +1 -1
  9. package/lib/cjs/Forms/hooks.d.ts +0 -1
  10. package/lib/cjs/Forms/hooks.d.ts.map +1 -1
  11. package/lib/cjs/Forms/hooks.js +3 -0
  12. package/lib/cjs/Forms/hooks.js.map +1 -1
  13. package/lib/cjs/Forms/inputs.d.ts +1 -1
  14. package/lib/cjs/Forms/inputs.d.ts.map +1 -1
  15. package/lib/cjs/Forms/inputs.js +103 -38
  16. package/lib/cjs/Forms/inputs.js.map +1 -1
  17. package/lib/cjs/controls.d.ts +2 -2
  18. package/lib/cjs/inputs.native.d.ts +0 -1
  19. package/lib/cjs/inputs.native.d.ts.map +1 -1
  20. package/lib/cjs/inputs_shared.d.ts +4 -1
  21. package/lib/cjs/inputs_shared.d.ts.map +1 -1
  22. package/lib/cjs/inputs_shared.js +7 -1
  23. package/lib/cjs/inputs_shared.js.map +1 -1
  24. package/lib/cjs/state.d.ts +36 -0
  25. package/lib/cjs/state.d.ts.map +1 -1
  26. package/lib/cjs/state.js +19 -3
  27. package/lib/cjs/state.js.map +1 -1
  28. package/lib/esm/CMS/components.d.ts +0 -1
  29. package/lib/esm/CMS/components.d.ts.map +1 -1
  30. package/lib/esm/Forms/form_responses.d.ts +0 -1
  31. package/lib/esm/Forms/form_responses.d.ts.map +1 -1
  32. package/lib/esm/Forms/forms.d.ts +6 -0
  33. package/lib/esm/Forms/forms.d.ts.map +1 -1
  34. package/lib/esm/Forms/forms.js +2 -2
  35. package/lib/esm/Forms/forms.js.map +1 -1
  36. package/lib/esm/Forms/hooks.d.ts +0 -1
  37. package/lib/esm/Forms/hooks.d.ts.map +1 -1
  38. package/lib/esm/Forms/hooks.js +3 -0
  39. package/lib/esm/Forms/hooks.js.map +1 -1
  40. package/lib/esm/Forms/inputs.d.ts +1 -1
  41. package/lib/esm/Forms/inputs.d.ts.map +1 -1
  42. package/lib/esm/Forms/inputs.js +104 -39
  43. package/lib/esm/Forms/inputs.js.map +1 -1
  44. package/lib/esm/controls.d.ts +2 -2
  45. package/lib/esm/inputs.native.d.ts +0 -1
  46. package/lib/esm/inputs.native.d.ts.map +1 -1
  47. package/lib/esm/inputs_shared.d.ts +4 -1
  48. package/lib/esm/inputs_shared.d.ts.map +1 -1
  49. package/lib/esm/inputs_shared.js +6 -1
  50. package/lib/esm/inputs_shared.js.map +1 -1
  51. package/lib/esm/state.d.ts +36 -0
  52. package/lib/esm/state.d.ts.map +1 -1
  53. package/lib/esm/state.js +15 -0
  54. package/lib/esm/state.js.map +1 -1
  55. package/lib/tsconfig.tsbuildinfo +1 -1
  56. package/package.json +9 -9
  57. package/src/Forms/forms.tsx +2 -2
  58. package/src/Forms/hooks.tsx +3 -0
  59. package/src/Forms/inputs.tsx +127 -32
  60. package/src/inputs_shared.tsx +13 -2
  61. package/src/state.tsx +21 -0
@@ -72,7 +72,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
72
72
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
73
73
  import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
74
74
  import axios from "axios";
75
- import { Autocomplete, Box, Button, Checkbox, Divider, FormControl, FormControlLabel, FormLabel, Grid, InputLabel, MenuItem, Radio, RadioGroup, Select, TextField, Typography } from "@mui/material";
75
+ import { Autocomplete, Box, Button, Checkbox, Chip, Divider, FormControl, FormControlLabel, FormLabel, Grid, InputLabel, MenuItem, Radio, RadioGroup, Select, TextField, Typography } from "@mui/material";
76
76
  import { useDropzone } from "react-dropzone";
77
77
  import { CANVAS_TITLE, EMOTII_TITLE, INSURANCE_RELATIONSHIPS, INSURANCE_RELATIONSHIPS_CANVAS, PRIMARY_HEX, RELATIONSHIP_TYPES, TELLESCOPE_GENDERS } from "@tellescope/constants";
78
78
  import { MM_DD_YYYY_to_YYYY_MM_DD, capture_is_supported, downloadFile, first_letter_capitalized, form_response_value_to_string, getLocalTimezone, getPublicFileURL, mm_dd_yyyy, replace_enduser_template_values, truncate_string, user_display_name } from "@tellescope/utilities";
@@ -624,6 +624,7 @@ export var StripeInput = function (_a) {
624
624
  var _g = useState(false), isCheckout = _g[0], setIsCheckout = _g[1];
625
625
  var _h = useState(), stripePromise = _h[0], setStripePromise = _h[1];
626
626
  var _j = useProducts({ dontFetch: true }), findProduct = _j[1].findById;
627
+ var _k = useState(''), answertext = _k[0], setAnswertext = _k[1];
627
628
  var fetchRef = useRef(false);
628
629
  useEffect(function () {
629
630
  var _a;
@@ -635,12 +636,13 @@ export var StripeInput = function (_a) {
635
636
  fetchRef.current = true;
636
637
  session.api.form_responses.stripe_details({ fieldId: field.id })
637
638
  .then(function (_a) {
638
- var clientSecret = _a.clientSecret, publishableKey = _a.publishableKey, stripeAccount = _a.stripeAccount, businessName = _a.businessName, customerId = _a.customerId, isCheckout = _a.isCheckout;
639
+ var clientSecret = _a.clientSecret, publishableKey = _a.publishableKey, stripeAccount = _a.stripeAccount, businessName = _a.businessName, customerId = _a.customerId, isCheckout = _a.isCheckout, answerText = _a.answerText;
639
640
  setIsCheckout(!!isCheckout);
640
641
  setClientSecret(clientSecret);
641
642
  setStripePromise(loadStripe(publishableKey, { stripeAccount: stripeAccount }));
642
643
  setBusinessName(businessName);
643
644
  setCustomerId(customerId);
645
+ setAnswertext(answerText || '');
644
646
  })
645
647
  .catch(console.error);
646
648
  }, [session, value, field.id]);
@@ -654,11 +656,11 @@ export var StripeInput = function (_a) {
654
656
  if (isCheckout && stripePromise)
655
657
  return (_jsx(EmbeddedCheckoutProvider, __assign({ stripe: stripePromise, options: {
656
658
  clientSecret: clientSecret,
657
- onComplete: function () { return onChange('Completed checkout', field.id); },
659
+ onComplete: function () { return onChange(answertext || 'Completed checkout', field.id); },
658
660
  } }, { children: _jsx(EmbeddedCheckout, {}) })));
659
661
  return (_jsx(Elements, __assign({ stripe: stripePromise, options: {
660
662
  clientSecret: clientSecret,
661
- } }, { children: _jsx(StripeForm, { businessName: businessName, onSuccess: function () { return onChange('Saved card details', field.id); }, cost: cost, field: field }) })));
663
+ } }, { children: _jsx(StripeForm, { businessName: businessName, onSuccess: function () { return onChange(answertext || 'Saved card details', field.id); }, cost: cost, field: field }) })));
662
664
  };
663
665
  var StripeForm = function (_a) {
664
666
  var _b, _d, _e;
@@ -904,7 +906,7 @@ export var DatabaseSelectInput = function (_a) {
904
906
  }, [field, filteredChoicesWithPotentialDuplicates]);
905
907
  if (!doneLoading)
906
908
  return _jsx(LinearProgress, {});
907
- return (_jsx(Autocomplete, { id: field.id, freeSolo: false, options: filteredChoices, multiple: true, getOptionLabel: function (o) { return (Array.isArray(o) // edge case
909
+ return (_jsx(Autocomplete, { id: field.id, freeSolo: false, componentsProps: { popper: { sx: { wordBreak: "break-word" } } }, options: filteredChoices, multiple: true, getOptionLabel: function (o) { return (Array.isArray(o) // edge case
908
910
  ? ''
909
911
  : label_for_database_record(field, o)); }, value: value, onChange: function (_, v) {
910
912
  var _a, _b, _d, _e;
@@ -925,7 +927,11 @@ export var DatabaseSelectInput = function (_a) {
925
927
  recordId: (_e = (_d = v[v.length - 1]) === null || _d === void 0 ? void 0 : _d.id) !== null && _e !== void 0 ? _e : '',
926
928
  text: label_for_database_record(field, v[v.length - 1]),
927
929
  }]), field.id);
928
- }, inputValue: typing, onInputChange: function (e, v) { return e && setTyping(v); }, renderInput: function (params) { return _jsx(TextField, __assign({}, params, { InputProps: __assign(__assign({}, params.InputProps), { sx: defaultInputProps.sx }) })); } }));
930
+ }, inputValue: typing, onInputChange: function (e, v) { return e && setTyping(v); }, renderInput: function (params) { return _jsx(TextField, __assign({}, params, { InputProps: __assign(__assign({}, params.InputProps), { sx: defaultInputProps.sx }) })); },
931
+ // use custom Chip to ensure very long entries break properly (whitespace: normal)
932
+ renderTags: function (value, getTagProps) {
933
+ return value.map(function (value, index) { return (_jsx(Chip, __assign({ label: _jsx(Typography, __assign({ style: { whiteSpace: 'normal' } }, { children: Array.isArray(value) ? '' : label_for_database_record(field, value) })) }, getTagProps({ index: index }), { sx: { height: "100%", py: 0.5 } }))); });
934
+ } }));
929
935
  };
930
936
  var displayTermsCache = undefined;
931
937
  var DRUGS_FOR_DISPLAY_TERM = {};
@@ -1412,13 +1418,30 @@ export var HeightInput = function (_a) {
1412
1418
  return (_jsxs(Grid, __assign({ container: true, alignItems: 'center', wrap: "nowrap", spacing: 1, style: { marginTop: 5 } }, { children: [_jsx(Grid, __assign({ item: true, sx: { width: '100%' } }, { children: _jsx(TextField, { fullWidth: true, size: "small", label: "Feet", type: "number", value: (value === null || value === void 0 ? void 0 : value.feet) || '', onChange: function (e) { return onChange(__assign(__assign({}, value), { feet: parseInt(e.target.value) }), field.id); } }) })), _jsx(Grid, __assign({ item: true, sx: { width: '100%' } }, { children: _jsx(TextField, { fullWidth: true, size: "small", label: "Inches", type: "number", value: (_b = value === null || value === void 0 ? void 0 : value.inches) !== null && _b !== void 0 ? _b : '', onChange: function (e) { return onChange(__assign(__assign({}, value), { inches: parseInt(e.target.value) }), field.id); } }) }))] })));
1413
1419
  };
1414
1420
  export var RedirectInput = function (_a) {
1415
- var groupId = _a.groupId, groupInsance = _a.groupInsance, formResponseId = _a.formResponseId, field = _a.field, submit = _a.submit, _b = _a.value, value = _b === void 0 ? {} : _b, onChange = _a.onChange, props = __rest(_a, ["groupId", "groupInsance", "formResponseId", "field", "submit", "value", "onChange"]);
1421
+ var _b, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
1422
+ var groupId = _a.groupId, groupInsance = _a.groupInsance, formResponseId = _a.formResponseId, field = _a.field, submit = _a.submit, _u = _a.value, value = _u === void 0 ? {} : _u, onChange = _a.onChange, responses = _a.responses, enduser = _a.enduser, props = __rest(_a, ["groupId", "groupInsance", "formResponseId", "field", "submit", "value", "onChange", "responses", "enduser"]);
1416
1423
  var session = useResolvedSession();
1417
1424
  var eId = '';
1418
1425
  try {
1419
1426
  eId = new URL(window.location.href).searchParams.get('eId') || '';
1420
1427
  }
1421
1428
  catch (err) { }
1429
+ var email = (((_d = (_b = responses === null || responses === void 0 ? void 0 : responses.find(function (r) { return r.intakeField === 'email'; })) === null || _b === void 0 ? void 0 : _b.answer) === null || _d === void 0 ? void 0 : _d.value)
1430
+ || (enduser === null || enduser === void 0 ? void 0 : enduser.email)
1431
+ || session.userInfo.email);
1432
+ var phone = (((_f = (_e = responses === null || responses === void 0 ? void 0 : responses.find(function (r) { return r.intakeField === 'phone'; })) === null || _e === void 0 ? void 0 : _e.answer) === null || _f === void 0 ? void 0 : _f.value)
1433
+ || (enduser === null || enduser === void 0 ? void 0 : enduser.phone)
1434
+ || session.userInfo.phone);
1435
+ var fname = (((_h = (_g = responses === null || responses === void 0 ? void 0 : responses.find(function (r) { return r.intakeField === 'fname'; })) === null || _g === void 0 ? void 0 : _g.answer) === null || _h === void 0 ? void 0 : _h.value)
1436
+ || (enduser === null || enduser === void 0 ? void 0 : enduser.fname)
1437
+ || ((_j = session.userInfo) === null || _j === void 0 ? void 0 : _j.fname));
1438
+ var lname = (((_l = (_k = responses === null || responses === void 0 ? void 0 : responses.find(function (r) { return r.intakeField === 'lname'; })) === null || _k === void 0 ? void 0 : _k.answer) === null || _l === void 0 ? void 0 : _l.value)
1439
+ || (enduser === null || enduser === void 0 ? void 0 : enduser.lname)
1440
+ || ((_m = session.userInfo) === null || _m === void 0 ? void 0 : _m.lname));
1441
+ var state = (((_p = (_o = responses === null || responses === void 0 ? void 0 : responses.find(function (r) { return r.intakeField === 'state'; })) === null || _o === void 0 ? void 0 : _o.answer) === null || _p === void 0 ? void 0 : _p.value)
1442
+ || ((_s = (_r = (_q = responses === null || responses === void 0 ? void 0 : responses.find(function (r) { return r.intakeField === 'Address'; })) === null || _q === void 0 ? void 0 : _q.answer) === null || _r === void 0 ? void 0 : _r.value) === null || _s === void 0 ? void 0 : _s.state)
1443
+ || (enduser === null || enduser === void 0 ? void 0 : enduser.state)
1444
+ || ((_t = session.userInfo) === null || _t === void 0 ? void 0 : _t.state));
1422
1445
  useEffect(function () {
1423
1446
  var _a, _b;
1424
1447
  if (session.type === 'user') {
@@ -1430,7 +1453,7 @@ export var RedirectInput = function (_a) {
1430
1453
  if (!((_a = field.options) === null || _a === void 0 ? void 0 : _a.redirectExternalUrl)) {
1431
1454
  return;
1432
1455
  }
1433
- window.location.href = replace_enduser_template_values(field.options.redirectExternalUrl, session.userInfo);
1456
+ window.location.href = (replace_enduser_template_values(field.options.redirectExternalUrl, __assign(__assign({}, session.userInfo), { email: email, fname: fname, lname: lname, state: state, phone: phone })));
1434
1457
  }).catch(console.error);
1435
1458
  return;
1436
1459
  }
@@ -1464,7 +1487,7 @@ export var RedirectInput = function (_a) {
1464
1487
  }));
1465
1488
  })
1466
1489
  .catch(console.error);
1467
- }, [session]);
1490
+ }, [session, email, fname, lname, state, phone]);
1468
1491
  if (session.type === 'user') {
1469
1492
  return (_jsx(Typography, { children: "Redirect is for patient-facing forms only" }));
1470
1493
  }
@@ -1529,10 +1552,16 @@ export var EmotiiInput = function (_a) {
1529
1552
  return (_jsx("iframe", { src: data.surveyUrl, style: { border: 'none', height: 650, width: '100%' }, onLoad: function () { return setLoadCount(function (l) { return l + 1; }); } }));
1530
1553
  };
1531
1554
  export var AllergiesInput = function (_a) {
1555
+ var _b;
1532
1556
  var goToNextField = _a.goToNextField, goToPreviousField = _a.goToPreviousField, field = _a.field, value = _a.value, onChange = _a.onChange, form = _a.form, formResponseId = _a.formResponseId, props = __rest(_a, ["goToNextField", "goToPreviousField", "field", "value", "onChange", "form", "formResponseId"]);
1533
1557
  var session = useResolvedSession();
1534
- var _b = useState(''), query = _b[0], setQuery = _b[1];
1535
- var _d = useState([]), results = _d[0], setResults = _d[1];
1558
+ var _d = useState(''), query = _d[0], setQuery = _d[1];
1559
+ var _e = useState([]), results = _e[0], setResults = _e[1];
1560
+ // if two allergy questions shown in a row, reset state
1561
+ useEffect(function () {
1562
+ setQuery('');
1563
+ setResults([]);
1564
+ }, [field.id]);
1536
1565
  var fetchRef = useRef(query);
1537
1566
  useEffect(function () {
1538
1567
  if (fetchRef.current === query)
@@ -1541,34 +1570,62 @@ export var AllergiesInput = function (_a) {
1541
1570
  if (!query)
1542
1571
  return;
1543
1572
  var t = setTimeout(function () {
1544
- session.api.integrations
1545
- .proxy_read({
1546
- integration: CANVAS_TITLE,
1547
- type: 'allergies',
1548
- query: query,
1549
- })
1550
- .then(function (r) {
1551
- var deduped = [];
1552
- var totalResults = ((r.data.entry || [])
1553
- .flatMap(function (v) { var _a, _b; return ((_b = (_a = v === null || v === void 0 ? void 0 : v.resource) === null || _a === void 0 ? void 0 : _a.code) === null || _b === void 0 ? void 0 : _b.coding) || []; })
1554
- .filter(function (v) { return v.system.includes('fdbhealth'); })
1555
- .map(function (v) { return ({ code: v.code, display: v.display, system: v.system }); }));
1556
- var _loop_2 = function (v) {
1557
- if (deduped.find(function (d) { return d.display === v.display; })) {
1558
- return "continue";
1573
+ var _a;
1574
+ if (((_a = field.options) === null || _a === void 0 ? void 0 : _a.dataSource) === CANVAS_TITLE) {
1575
+ session.api.integrations
1576
+ .proxy_read({
1577
+ integration: CANVAS_TITLE,
1578
+ type: 'allergies',
1579
+ query: query,
1580
+ })
1581
+ .then(function (r) {
1582
+ var deduped = [];
1583
+ var totalResults = ((r.data.entry || [])
1584
+ .flatMap(function (v) { var _a, _b; return ((_b = (_a = v === null || v === void 0 ? void 0 : v.resource) === null || _a === void 0 ? void 0 : _a.code) === null || _b === void 0 ? void 0 : _b.coding) || []; })
1585
+ .filter(function (v) { return v.system.includes('fdbhealth'); })
1586
+ .map(function (v) { return ({ code: v.code, display: v.display, system: v.system }); }));
1587
+ var _loop_2 = function (v) {
1588
+ if (deduped.find(function (d) { return d.display === v.display; })) {
1589
+ return "continue";
1590
+ }
1591
+ deduped.push(v);
1592
+ };
1593
+ for (var _a = 0, totalResults_1 = totalResults; _a < totalResults_1.length; _a++) {
1594
+ var v = totalResults_1[_a];
1595
+ _loop_2(v);
1559
1596
  }
1560
- deduped.push(v);
1561
- };
1562
- for (var _a = 0, totalResults_1 = totalResults; _a < totalResults_1.length; _a++) {
1563
- var v = totalResults_1[_a];
1564
- _loop_2(v);
1565
- }
1566
- setResults(deduped);
1567
- });
1597
+ setResults(deduped);
1598
+ });
1599
+ }
1600
+ else {
1601
+ session.api.allergy_codes.getSome({ search: { query: query } })
1602
+ .then(function (results) {
1603
+ var deduped = [];
1604
+ var _loop_3 = function (v) {
1605
+ if (deduped.find(function (d) { return d.display === v.display; })) {
1606
+ return "continue";
1607
+ }
1608
+ deduped.push(v);
1609
+ };
1610
+ for (var _a = 0, results_1 = results; _a < results_1.length; _a++) {
1611
+ var v = results_1[_a];
1612
+ _loop_3(v);
1613
+ }
1614
+ setResults(deduped);
1615
+ });
1616
+ }
1568
1617
  }, 200);
1569
1618
  return function () { clearTimeout(t); };
1570
- }, [session, query]);
1571
- return (_jsx(Autocomplete, { multiple: true, value: value || [], options: __spreadArray(__spreadArray([], results, true), (value || []), true), style: { marginTop: 5 }, noOptionsText: query.length ? 'No results found' : 'Type to start search', onChange: function (e, v) { return v && onChange(v, field.id); }, getOptionLabel: function (v) { return first_letter_capitalized(v.display); }, filterOptions: function (o) { return o; }, inputValue: query, onInputChange: function (e, v) { return e && setQuery(v); }, renderInput: function (params) { return (_jsx(TextField, __assign({}, params, { InputProps: __assign(__assign({}, params.InputProps), { sx: defaultInputProps.sx }), required: !field.isOptional, size: "small", label: "", placeholder: "Search allergies..." }))); } }));
1619
+ }, [session, query, (_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.dataSource]);
1620
+ return (_jsx(Autocomplete, { multiple: true, value: value || [], options: results, style: { marginTop: 5 }, noOptionsText: query.length ? 'No results found' : 'Type to start search', onChange: function (e, v) {
1621
+ if (!v) {
1622
+ return;
1623
+ }
1624
+ onChange(v, field.id);
1625
+ setResults([]);
1626
+ }, getOptionLabel: function (v) { return first_letter_capitalized(v.display); }, filterOptions: function (o) { return o; }, inputValue: query, onInputChange: function (e, v) { return e && setQuery(v); }, renderInput: function (params) { return (_jsx(TextField, __assign({}, params, { InputProps: __assign(__assign({}, params.InputProps), { sx: defaultInputProps.sx }), required: !field.isOptional, size: "small", label: "", placeholder: "Search allergies..." }))); }, renderTags: function (value, getTagProps) {
1627
+ return value.map(function (value, index) { return (_jsx(Chip, __assign({ label: _jsx(Typography, __assign({ style: { whiteSpace: 'normal' } }, { children: value.display })) }, getTagProps({ index: index }), { sx: { height: "100%", py: 0.5 } }))); });
1628
+ } }));
1572
1629
  };
1573
1630
  export var ConditionsInput = function (_a) {
1574
1631
  var goToNextField = _a.goToNextField, goToPreviousField = _a.goToPreviousField, field = _a.field, value = _a.value, onChange = _a.onChange, form = _a.form, formResponseId = _a.formResponseId, props = __rest(_a, ["goToNextField", "goToPreviousField", "field", "value", "onChange", "form", "formResponseId"]);
@@ -1586,7 +1643,7 @@ export var ConditionsInput = function (_a) {
1586
1643
  session.api.diagnosis_codes.getSome({ search: { query: query } })
1587
1644
  .then(function (codes) {
1588
1645
  var deduped = [];
1589
- var _loop_3 = function (v) {
1646
+ var _loop_4 = function (v) {
1590
1647
  if (deduped.find(function (d) { return d.display === v.display; })) {
1591
1648
  return "continue";
1592
1649
  }
@@ -1594,14 +1651,22 @@ export var ConditionsInput = function (_a) {
1594
1651
  };
1595
1652
  for (var _a = 0, codes_1 = codes; _a < codes_1.length; _a++) {
1596
1653
  var v = codes_1[_a];
1597
- _loop_3(v);
1654
+ _loop_4(v);
1598
1655
  }
1599
1656
  setResults(deduped);
1600
1657
  });
1601
1658
  }, 200);
1602
1659
  return function () { clearTimeout(t); };
1603
1660
  }, [session, query]);
1604
- return (_jsx(Autocomplete, { multiple: true, value: value || [], options: __spreadArray(__spreadArray([], results, true), (value || []), true), style: { marginTop: 5 }, noOptionsText: query.length ? 'No results found' : 'Type to start search', onChange: function (e, v) { return v && onChange(v, field.id); }, getOptionLabel: function (v) { return first_letter_capitalized(v.display); }, filterOptions: function (o) { return o; }, inputValue: query, onInputChange: function (e, v) { return e && setQuery(v); }, renderInput: function (params) { return (_jsx(TextField, __assign({}, params, { InputProps: __assign(__assign({}, params.InputProps), { sx: defaultInputProps.sx }), required: !field.isOptional, size: "small", label: "", placeholder: "Search conditions..." }))); } }));
1661
+ return (_jsx(Autocomplete, { multiple: true, value: value || [], options: results, style: { marginTop: 5 }, noOptionsText: query.length ? 'No results found' : 'Type to start search', onChange: function (e, v) {
1662
+ if (!v) {
1663
+ return;
1664
+ }
1665
+ onChange(v, field.id);
1666
+ setResults([]);
1667
+ }, getOptionLabel: function (v) { return first_letter_capitalized(v.display); }, filterOptions: function (o) { return o; }, inputValue: query, onInputChange: function (e, v) { return e && setQuery(v); }, renderInput: function (params) { return (_jsx(TextField, __assign({}, params, { InputProps: __assign(__assign({}, params.InputProps), { sx: defaultInputProps.sx }), required: !field.isOptional, size: "small", label: "", placeholder: "Search conditions..." }))); }, renderTags: function (value, getTagProps) {
1668
+ return value.map(function (value, index) { return (_jsx(Chip, __assign({ label: _jsx(Typography, __assign({ style: { whiteSpace: 'normal' } }, { children: value.display })) }, getTagProps({ index: index }), { sx: { height: "100%", py: 0.5 } }))); });
1669
+ } }));
1605
1670
  };
1606
1671
  var templateObject_1, templateObject_2;
1607
1672
  //# sourceMappingURL=inputs.js.map