@tellescope/react-components 1.153.1 → 1.154.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.
- package/lib/cjs/CMS/components.d.ts +0 -1
- package/lib/cjs/CMS/components.d.ts.map +1 -1
- package/lib/cjs/Forms/form_responses.d.ts +0 -1
- package/lib/cjs/Forms/form_responses.d.ts.map +1 -1
- package/lib/cjs/Forms/hooks.d.ts +0 -1
- package/lib/cjs/Forms/hooks.d.ts.map +1 -1
- package/lib/cjs/Forms/inputs.d.ts.map +1 -1
- package/lib/cjs/Forms/inputs.js +83 -35
- package/lib/cjs/Forms/inputs.js.map +1 -1
- package/lib/cjs/controls.d.ts +2 -2
- package/lib/cjs/inputs.native.d.ts +0 -1
- package/lib/cjs/inputs.native.d.ts.map +1 -1
- package/lib/cjs/inputs_shared.d.ts +4 -1
- package/lib/cjs/inputs_shared.d.ts.map +1 -1
- package/lib/cjs/inputs_shared.js +7 -1
- package/lib/cjs/inputs_shared.js.map +1 -1
- package/lib/cjs/state.d.ts +36 -0
- package/lib/cjs/state.d.ts.map +1 -1
- package/lib/cjs/state.js +19 -3
- package/lib/cjs/state.js.map +1 -1
- package/lib/esm/Forms/forms.d.ts +3 -3
- package/lib/esm/Forms/inputs.d.ts +1 -1
- package/lib/esm/Forms/inputs.d.ts.map +1 -1
- package/lib/esm/Forms/inputs.js +84 -36
- package/lib/esm/Forms/inputs.js.map +1 -1
- package/lib/esm/controls.d.ts +2 -2
- package/lib/esm/inputs.d.ts +1 -1
- package/lib/esm/inputs_shared.d.ts +4 -1
- package/lib/esm/inputs_shared.d.ts.map +1 -1
- package/lib/esm/inputs_shared.js +6 -1
- package/lib/esm/inputs_shared.js.map +1 -1
- package/lib/esm/state.d.ts +88 -52
- package/lib/esm/state.d.ts.map +1 -1
- package/lib/esm/state.js +15 -0
- package/lib/esm/state.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/Forms/inputs.tsx +89 -29
- package/src/inputs_shared.tsx +13 -2
- package/src/state.tsx +21 -0
package/lib/esm/Forms/inputs.js
CHANGED
|
@@ -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 = {};
|
|
@@ -1529,10 +1535,16 @@ export var EmotiiInput = function (_a) {
|
|
|
1529
1535
|
return (_jsx("iframe", { src: data.surveyUrl, style: { border: 'none', height: 650, width: '100%' }, onLoad: function () { return setLoadCount(function (l) { return l + 1; }); } }));
|
|
1530
1536
|
};
|
|
1531
1537
|
export var AllergiesInput = function (_a) {
|
|
1538
|
+
var _b;
|
|
1532
1539
|
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
1540
|
var session = useResolvedSession();
|
|
1534
|
-
var
|
|
1535
|
-
var
|
|
1541
|
+
var _d = useState(''), query = _d[0], setQuery = _d[1];
|
|
1542
|
+
var _e = useState([]), results = _e[0], setResults = _e[1];
|
|
1543
|
+
// if two allergy questions shown in a row, reset state
|
|
1544
|
+
useEffect(function () {
|
|
1545
|
+
setQuery('');
|
|
1546
|
+
setResults([]);
|
|
1547
|
+
}, [field.id]);
|
|
1536
1548
|
var fetchRef = useRef(query);
|
|
1537
1549
|
useEffect(function () {
|
|
1538
1550
|
if (fetchRef.current === query)
|
|
@@ -1541,34 +1553,62 @@ export var AllergiesInput = function (_a) {
|
|
|
1541
1553
|
if (!query)
|
|
1542
1554
|
return;
|
|
1543
1555
|
var t = setTimeout(function () {
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1556
|
+
var _a;
|
|
1557
|
+
if (((_a = field.options) === null || _a === void 0 ? void 0 : _a.dataSource) === CANVAS_TITLE) {
|
|
1558
|
+
session.api.integrations
|
|
1559
|
+
.proxy_read({
|
|
1560
|
+
integration: CANVAS_TITLE,
|
|
1561
|
+
type: 'allergies',
|
|
1562
|
+
query: query,
|
|
1563
|
+
})
|
|
1564
|
+
.then(function (r) {
|
|
1565
|
+
var deduped = [];
|
|
1566
|
+
var totalResults = ((r.data.entry || [])
|
|
1567
|
+
.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) || []; })
|
|
1568
|
+
.filter(function (v) { return v.system.includes('fdbhealth'); })
|
|
1569
|
+
.map(function (v) { return ({ code: v.code, display: v.display, system: v.system }); }));
|
|
1570
|
+
var _loop_2 = function (v) {
|
|
1571
|
+
if (deduped.find(function (d) { return d.display === v.display; })) {
|
|
1572
|
+
return "continue";
|
|
1573
|
+
}
|
|
1574
|
+
deduped.push(v);
|
|
1575
|
+
};
|
|
1576
|
+
for (var _a = 0, totalResults_1 = totalResults; _a < totalResults_1.length; _a++) {
|
|
1577
|
+
var v = totalResults_1[_a];
|
|
1578
|
+
_loop_2(v);
|
|
1559
1579
|
}
|
|
1560
|
-
deduped
|
|
1561
|
-
};
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1580
|
+
setResults(deduped);
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
else {
|
|
1584
|
+
session.api.allergy_codes.getSome({ search: { query: query } })
|
|
1585
|
+
.then(function (results) {
|
|
1586
|
+
var deduped = [];
|
|
1587
|
+
var _loop_3 = 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, results_1 = results; _a < results_1.length; _a++) {
|
|
1594
|
+
var v = results_1[_a];
|
|
1595
|
+
_loop_3(v);
|
|
1596
|
+
}
|
|
1597
|
+
setResults(deduped);
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1568
1600
|
}, 200);
|
|
1569
1601
|
return function () { clearTimeout(t); };
|
|
1570
|
-
}, [session, query]);
|
|
1571
|
-
return (_jsx(Autocomplete, { multiple: true, value: value || [], options:
|
|
1602
|
+
}, [session, query, (_b = field === null || field === void 0 ? void 0 : field.options) === null || _b === void 0 ? void 0 : _b.dataSource]);
|
|
1603
|
+
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) {
|
|
1604
|
+
if (!v) {
|
|
1605
|
+
return;
|
|
1606
|
+
}
|
|
1607
|
+
onChange(v, field.id);
|
|
1608
|
+
setResults([]);
|
|
1609
|
+
}, 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) {
|
|
1610
|
+
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 } }))); });
|
|
1611
|
+
} }));
|
|
1572
1612
|
};
|
|
1573
1613
|
export var ConditionsInput = function (_a) {
|
|
1574
1614
|
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 +1626,7 @@ export var ConditionsInput = function (_a) {
|
|
|
1586
1626
|
session.api.diagnosis_codes.getSome({ search: { query: query } })
|
|
1587
1627
|
.then(function (codes) {
|
|
1588
1628
|
var deduped = [];
|
|
1589
|
-
var
|
|
1629
|
+
var _loop_4 = function (v) {
|
|
1590
1630
|
if (deduped.find(function (d) { return d.display === v.display; })) {
|
|
1591
1631
|
return "continue";
|
|
1592
1632
|
}
|
|
@@ -1594,14 +1634,22 @@ export var ConditionsInput = function (_a) {
|
|
|
1594
1634
|
};
|
|
1595
1635
|
for (var _a = 0, codes_1 = codes; _a < codes_1.length; _a++) {
|
|
1596
1636
|
var v = codes_1[_a];
|
|
1597
|
-
|
|
1637
|
+
_loop_4(v);
|
|
1598
1638
|
}
|
|
1599
1639
|
setResults(deduped);
|
|
1600
1640
|
});
|
|
1601
1641
|
}, 200);
|
|
1602
1642
|
return function () { clearTimeout(t); };
|
|
1603
1643
|
}, [session, query]);
|
|
1604
|
-
return (_jsx(Autocomplete, { multiple: true, value: value || [], options:
|
|
1644
|
+
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) {
|
|
1645
|
+
if (!v) {
|
|
1646
|
+
return;
|
|
1647
|
+
}
|
|
1648
|
+
onChange(v, field.id);
|
|
1649
|
+
setResults([]);
|
|
1650
|
+
}, 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) {
|
|
1651
|
+
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 } }))); });
|
|
1652
|
+
} }));
|
|
1605
1653
|
};
|
|
1606
1654
|
var templateObject_1, templateObject_2;
|
|
1607
1655
|
//# sourceMappingURL=inputs.js.map
|