@tellescope/react-components 1.156.0 → 1.158.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/Forms/hooks.d.ts +1 -0
- package/lib/cjs/Forms/hooks.d.ts.map +1 -1
- package/lib/cjs/Forms/hooks.js +11 -3
- package/lib/cjs/Forms/hooks.js.map +1 -1
- package/lib/cjs/Forms/inputs.d.ts.map +1 -1
- package/lib/cjs/Forms/inputs.js +6 -5
- package/lib/cjs/Forms/inputs.js.map +1 -1
- package/lib/cjs/errors.d.ts.map +1 -1
- package/lib/cjs/errors.js +9 -1
- package/lib/cjs/errors.js.map +1 -1
- package/lib/cjs/state.js +1 -1
- package/lib/cjs/state.js.map +1 -1
- package/lib/cjs/table.d.ts +6 -3
- package/lib/cjs/table.d.ts.map +1 -1
- package/lib/cjs/table.js +11 -11
- package/lib/cjs/table.js.map +1 -1
- package/lib/esm/Forms/hooks.d.ts +1 -0
- package/lib/esm/Forms/hooks.d.ts.map +1 -1
- package/lib/esm/Forms/hooks.js +11 -3
- package/lib/esm/Forms/hooks.js.map +1 -1
- package/lib/esm/Forms/inputs.d.ts.map +1 -1
- package/lib/esm/Forms/inputs.js +6 -5
- package/lib/esm/Forms/inputs.js.map +1 -1
- package/lib/esm/errors.d.ts.map +1 -1
- package/lib/esm/errors.js +9 -1
- package/lib/esm/errors.js.map +1 -1
- package/lib/esm/state.js +1 -1
- package/lib/esm/state.js.map +1 -1
- package/lib/esm/table.d.ts +6 -3
- package/lib/esm/table.d.ts.map +1 -1
- package/lib/esm/table.js +11 -11
- package/lib/esm/table.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/Forms/hooks.tsx +8 -0
- package/src/Forms/inputs.tsx +8 -6
- package/src/errors.tsx +8 -1
- package/src/state.tsx +1 -1
- package/src/table.tsx +11 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tellescope/react-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.158.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"@reduxjs/toolkit": "^1.6.2",
|
|
48
48
|
"@stripe/react-stripe-js": "^2.9.0",
|
|
49
49
|
"@stripe/stripe-js": "^1.52.1",
|
|
50
|
-
"@tellescope/constants": "^1.
|
|
51
|
-
"@tellescope/sdk": "^1.
|
|
52
|
-
"@tellescope/types-client": "^1.
|
|
53
|
-
"@tellescope/types-models": "^1.
|
|
54
|
-
"@tellescope/types-utilities": "^1.
|
|
55
|
-
"@tellescope/utilities": "^1.
|
|
56
|
-
"@tellescope/validation": "^1.
|
|
50
|
+
"@tellescope/constants": "^1.158.0",
|
|
51
|
+
"@tellescope/sdk": "^1.158.0",
|
|
52
|
+
"@tellescope/types-client": "^1.158.0",
|
|
53
|
+
"@tellescope/types-models": "^1.158.0",
|
|
54
|
+
"@tellescope/types-utilities": "^1.158.0",
|
|
55
|
+
"@tellescope/utilities": "^1.158.0",
|
|
56
|
+
"@tellescope/validation": "^1.158.0",
|
|
57
57
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
58
58
|
"@typescript-eslint/parser": "^4.33.0",
|
|
59
59
|
"css-to-react-native": "^3.0.0",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
81
81
|
"react-native": "^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.71.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "0ed357b60dd15c474a84c6eb595eead1b4c33847",
|
|
84
84
|
"publishConfig": {
|
|
85
85
|
"access": "public"
|
|
86
86
|
}
|
package/src/Forms/hooks.tsx
CHANGED
|
@@ -198,6 +198,7 @@ export const getNextField = (activeField: FormFieldNode, currentValue: Response,
|
|
|
198
198
|
urlLogicValue?: string,
|
|
199
199
|
dateOfBirth?: string,
|
|
200
200
|
gender?: string,
|
|
201
|
+
state?: string,
|
|
201
202
|
form?: Form,
|
|
202
203
|
activeResponses?: FormResponseValue[], // current and previous answers (not future answers)
|
|
203
204
|
}) => {
|
|
@@ -600,6 +601,7 @@ export const useTellescopeForm = ({ form, urlLogicValue, customization, carePlan
|
|
|
600
601
|
disabled: !!(existingResponses?.find(r => r.fieldId === f.id)?.answer?.value && f.disabledWhenPrepopulated),
|
|
601
602
|
// keep consistent with onFieldChange
|
|
602
603
|
computedValueKey: (
|
|
604
|
+
// the height typeof is unnecessary (no actual type comparison), but don't change without testing both number and height question types
|
|
603
605
|
f?.intakeField === 'height' && typeof existingResponses?.find(r => r.fieldId === f.id)?.answer?.value
|
|
604
606
|
? 'Height'
|
|
605
607
|
: f?.intakeField === 'weight' && typeof existingResponses?.find(r => r.fieldId === f.id)?.answer?.value === 'number'
|
|
@@ -608,6 +610,8 @@ export const useTellescopeForm = ({ form, urlLogicValue, customization, carePlan
|
|
|
608
610
|
? 'Date of Birth'
|
|
609
611
|
: f?.intakeField === 'gender' && ['multiple_choice', 'Dropdown'].includes(existingResponses?.find(r => r.fieldId === f.id)?.answer?.type || '')
|
|
610
612
|
? 'Gender'
|
|
613
|
+
: f?.intakeField === 'Address' && existingResponses?.find(r => r.fieldId === f.id && r.answer.type === 'Address')
|
|
614
|
+
? 'State'
|
|
611
615
|
: undefined
|
|
612
616
|
) as any,
|
|
613
617
|
answer: {
|
|
@@ -1060,6 +1064,7 @@ export const useTellescopeForm = ({ form, urlLogicValue, customization, carePlan
|
|
|
1060
1064
|
activeResponses: responses.filter(r => r.includeInSubmit),
|
|
1061
1065
|
dateOfBirth: enduser?.dateOfBirth,
|
|
1062
1066
|
gender: enduser?.gender,
|
|
1067
|
+
state: enduser?.state,
|
|
1063
1068
|
})
|
|
1064
1069
|
)
|
|
1065
1070
|
)
|
|
@@ -1275,6 +1280,7 @@ export const useTellescopeForm = ({ form, urlLogicValue, customization, carePlan
|
|
|
1275
1280
|
activeResponses: responses.filter(r => r.includeInSubmit),
|
|
1276
1281
|
dateOfBirth: enduser?.dateOfBirth,
|
|
1277
1282
|
gender: enduser?.gender,
|
|
1283
|
+
state: enduser?.state,
|
|
1278
1284
|
})
|
|
1279
1285
|
|
|
1280
1286
|
// when autoadvancing, prevent adding duplicates by checking whether already on stack
|
|
@@ -1341,6 +1347,8 @@ export const useTellescopeForm = ({ form, urlLogicValue, customization, carePlan
|
|
|
1341
1347
|
? 'Date of Birth'
|
|
1342
1348
|
: field?.intakeField === 'gender' && (r.answer.type === 'Dropdown' || r.answer.type === 'multiple_choice')
|
|
1343
1349
|
? 'Gender'
|
|
1350
|
+
: field?.intakeField === 'Address' && r.answer.type === 'Address'
|
|
1351
|
+
? 'State'
|
|
1344
1352
|
: undefined
|
|
1345
1353
|
)
|
|
1346
1354
|
})))
|
package/src/Forms/inputs.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import LinearProgress from '@mui/material/LinearProgress';
|
|
|
13
13
|
import DatePicker from "react-datepicker";
|
|
14
14
|
import { datepickerCSS } from "./css/react-datepicker" // avoids build issue with RN
|
|
15
15
|
import { CancelIcon, FileBlob, IconButton, LabeledIconButton, LoadingButton, Styled, form_display_text_for_language, isDateString, useProducts, useResolvedSession } from ".."
|
|
16
|
-
import { CalendarEvent, DatabaseRecord, FormField } from "@tellescope/types-client"
|
|
16
|
+
import { AllergyCode, CalendarEvent, DatabaseRecord, FormField } from "@tellescope/types-client"
|
|
17
17
|
import { css } from '@emotion/css'
|
|
18
18
|
import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd";
|
|
19
19
|
import DragIndicatorIcon from '@mui/icons-material/DragIndicator';
|
|
@@ -1758,7 +1758,6 @@ export const DatabaseSelectInput = ({ field, value: _value, onChange, onDatabase
|
|
|
1758
1758
|
otherAnswers: get_other_answers(_value, field?.options?.other ? typing : undefined),
|
|
1759
1759
|
})
|
|
1760
1760
|
|
|
1761
|
-
console.log(choices, _value)
|
|
1762
1761
|
const value = React.useMemo(() => {
|
|
1763
1762
|
try {
|
|
1764
1763
|
// if the value is a string (some single answer that was save), make sure we coerce to array
|
|
@@ -1794,13 +1793,15 @@ export const DatabaseSelectInput = ({ field, value: _value, onChange, onDatabase
|
|
|
1794
1793
|
const v = c.values.find(_v => _v.label === field.options?.databaseFilter?.databaseLabel)?.value
|
|
1795
1794
|
if (!v) return true
|
|
1796
1795
|
|
|
1796
|
+
// use .text on r values to handle Database Select types as filter source (in addition to basic text and list of text)
|
|
1797
|
+
|
|
1797
1798
|
if (typeof v === 'object') {
|
|
1798
1799
|
return !!(
|
|
1799
1800
|
Object.values(v).find(oVal => (
|
|
1800
1801
|
typeof oVal === 'string' || typeof oVal === 'number'
|
|
1801
1802
|
? (
|
|
1802
1803
|
Array.isArray(filterResponse)
|
|
1803
|
-
? (filterResponse as any[]).find(r => r === oVal.toString())
|
|
1804
|
+
? (filterResponse as any[]).find(r => r === oVal.toString() || (typeof r === 'object' && r.text === oVal))
|
|
1804
1805
|
: (typeof filterResponse === 'string' || typeof filterResponse === 'number')
|
|
1805
1806
|
? filterResponse.toString() === oVal.toString()
|
|
1806
1807
|
: false
|
|
@@ -1813,7 +1814,7 @@ export const DatabaseSelectInput = ({ field, value: _value, onChange, onDatabase
|
|
|
1813
1814
|
if (typeof v === 'string' || typeof v === 'number') {
|
|
1814
1815
|
return !!(
|
|
1815
1816
|
Array.isArray(filterResponse)
|
|
1816
|
-
? (filterResponse as any[]).find(r => r === v.toString())
|
|
1817
|
+
? (filterResponse as any[]).find(r => r === v.toString() || (typeof r === 'object' && r.text === v))
|
|
1817
1818
|
: (typeof filterResponse === 'string' || typeof filterResponse === 'number')
|
|
1818
1819
|
? filterResponse.toString() === v.toString()
|
|
1819
1820
|
: false
|
|
@@ -2991,6 +2992,7 @@ export const AllergiesInput = ({ goToNextField, goToPreviousField, field, value,
|
|
|
2991
2992
|
/>
|
|
2992
2993
|
)
|
|
2993
2994
|
}
|
|
2995
|
+
const display_with_code = (v: { code: string, display: string }) => `${v.code}: ${first_letter_capitalized(v.display)}`
|
|
2994
2996
|
|
|
2995
2997
|
export const ConditionsInput = ({ goToNextField, goToPreviousField, field, value, onChange, form, formResponseId, ...props }: FormInputProps<'Conditions'>) => {
|
|
2996
2998
|
const session = useResolvedSession()
|
|
@@ -3028,7 +3030,7 @@ export const ConditionsInput = ({ goToNextField, goToPreviousField, field, value
|
|
|
3028
3030
|
onChange(v, field.id)
|
|
3029
3031
|
setResults([])
|
|
3030
3032
|
}}
|
|
3031
|
-
getOptionLabel={
|
|
3033
|
+
getOptionLabel={display_with_code} filterOptions={o => o}
|
|
3032
3034
|
inputValue={query} onInputChange={(e, v) => e && setQuery(v) }
|
|
3033
3035
|
renderInput={(params) => (
|
|
3034
3036
|
<TextField {...params} InputProps={{ ...params.InputProps, sx: defaultInputProps.sx }}
|
|
@@ -3038,7 +3040,7 @@ export const ConditionsInput = ({ goToNextField, goToPreviousField, field, value
|
|
|
3038
3040
|
renderTags={(value, getTagProps) =>
|
|
3039
3041
|
value.map((value, index) => (
|
|
3040
3042
|
<Chip
|
|
3041
|
-
label={<Typography style={{whiteSpace: 'normal'}}>{value
|
|
3043
|
+
label={<Typography style={{whiteSpace: 'normal'}}>{display_with_code(value)}</Typography>}
|
|
3042
3044
|
{...getTagProps({ index })}
|
|
3043
3045
|
sx={{height:"100%", py: 0.5 }}
|
|
3044
3046
|
/>
|
package/src/errors.tsx
CHANGED
|
@@ -30,7 +30,14 @@ export class ErrorBoundary extends React.Component<{ errorMessage?: string }, {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export const stringForError = (err: any) =>
|
|
33
|
+
export const stringForError = (err: any) => {
|
|
34
|
+
const toReturn = (err as APIError)?.message ?? err?.toString() ?? 'An unexpected error occurred'
|
|
35
|
+
|
|
36
|
+
// if ?.message isn't a string (by mistake), handle gracefully
|
|
37
|
+
if (typeof toReturn === 'object') { return JSON.stringify(toReturn, null, 2)}
|
|
38
|
+
|
|
39
|
+
return toReturn
|
|
40
|
+
}
|
|
34
41
|
|
|
35
42
|
export const parseUniquenessError = (err: any, uniquenessMessage: string) => {
|
|
36
43
|
const message = stringForError(err)
|
package/src/state.tsx
CHANGED
|
@@ -1985,7 +1985,7 @@ export const useTemplates = (options={} as HookOptions<Template>) => {
|
|
|
1985
1985
|
)
|
|
1986
1986
|
}
|
|
1987
1987
|
export const useForms = (options={} as HookOptions<Form>) => {
|
|
1988
|
-
const session =
|
|
1988
|
+
const session = useResolvedSession()
|
|
1989
1989
|
return useListStateHook(
|
|
1990
1990
|
'forms', useTypedSelector(s => s.forms), session, formsSlice,
|
|
1991
1991
|
{
|
package/src/table.tsx
CHANGED
|
@@ -146,6 +146,7 @@ export interface TableHeaderProps<T extends Item> extends Styled, HorizontalPadd
|
|
|
146
146
|
localFilters: LocalFilter[],
|
|
147
147
|
setLocalFilters: React.Dispatch<React.SetStateAction<LocalFilter[]>>,
|
|
148
148
|
filterSuggestions: Record<string, string[]>,
|
|
149
|
+
minColumnWidth?: number,
|
|
149
150
|
}
|
|
150
151
|
export const TableHeader = <T extends Item>({
|
|
151
152
|
fields,
|
|
@@ -165,6 +166,7 @@ export const TableHeader = <T extends Item>({
|
|
|
165
166
|
localFilters,
|
|
166
167
|
setLocalFilters,
|
|
167
168
|
filterSuggestions,
|
|
169
|
+
minColumnWidth=75,
|
|
168
170
|
} : TableHeaderProps<T>) => {
|
|
169
171
|
const [openFilter, setOpenFilter] = useState(-1)
|
|
170
172
|
const [startX, setStartX] = useState(0)
|
|
@@ -249,7 +251,7 @@ export const TableHeader = <T extends Item>({
|
|
|
249
251
|
justifyContent: textAlign === 'right' ? 'flex-end' : 'flex-start',
|
|
250
252
|
width: (
|
|
251
253
|
typeof width === 'number'
|
|
252
|
-
? Math.max(
|
|
254
|
+
? Math.max(minColumnWidth, width + (widthOffsets[key] || 0))
|
|
253
255
|
: (width ?? defaultWidthForFields(fields.length))
|
|
254
256
|
),
|
|
255
257
|
alignItems: 'center',
|
|
@@ -384,6 +386,7 @@ export interface TableRowProps<T extends Item> extends Styled, HorizontalPadded,
|
|
|
384
386
|
fontSize?: CSSProperties['fontSize']
|
|
385
387
|
textStyle?: CSSProperties,
|
|
386
388
|
widthOffsets: Record<string, number>,
|
|
389
|
+
minColumnWidth?: number,
|
|
387
390
|
}
|
|
388
391
|
export const TableRow = <T extends Item>({
|
|
389
392
|
item, indices, fields, onClick, onPress, hover,
|
|
@@ -400,6 +403,7 @@ export const TableRow = <T extends Item>({
|
|
|
400
403
|
widthOffsets,
|
|
401
404
|
allowUnselectItemsAfterSelectAll,
|
|
402
405
|
setAllSelected,
|
|
406
|
+
minColumnWidth=75,
|
|
403
407
|
} : TableRowProps<T>) => (
|
|
404
408
|
<WithHover hoveredColor={hoveredColor ?? GRAY} notHoveredColor={notHoveredColor} disabled={!hover} flex>
|
|
405
409
|
<Flex flex={1} alignItems="center"
|
|
@@ -442,7 +446,7 @@ export const TableRow = <T extends Item>({
|
|
|
442
446
|
textAlign, fontSize,
|
|
443
447
|
width: (
|
|
444
448
|
typeof width === 'number'
|
|
445
|
-
? Math.max(
|
|
449
|
+
? Math.max(minColumnWidth, width + (widthOffsets[key] || 0))
|
|
446
450
|
: (width ?? defaultWidthForFields(fields.length))
|
|
447
451
|
),
|
|
448
452
|
// display: flex ? 'flex' : undefined,
|
|
@@ -453,7 +457,7 @@ export const TableRow = <T extends Item>({
|
|
|
453
457
|
{get_display_value(item, key, indices, render, {
|
|
454
458
|
adjustedWidth: (
|
|
455
459
|
typeof width === 'number'
|
|
456
|
-
? Math.max(
|
|
460
|
+
? Math.max(minColumnWidth, width + (widthOffsets[key] || 0))
|
|
457
461
|
: undefined
|
|
458
462
|
)
|
|
459
463
|
})}
|
|
@@ -720,6 +724,7 @@ export interface TableProps<T extends Item> extends WithTitle, WithHeader<T>, Wi
|
|
|
720
724
|
sort?: SortingField[],
|
|
721
725
|
loadMoreOptions?: LoadMoreOptions<T>,
|
|
722
726
|
refreshFilterSuggestionsKey?: number,
|
|
727
|
+
minColumnWidth?: number,
|
|
723
728
|
}
|
|
724
729
|
export const Table = <T extends Item>({
|
|
725
730
|
items,
|
|
@@ -773,6 +778,7 @@ export const Table = <T extends Item>({
|
|
|
773
778
|
|
|
774
779
|
sort,
|
|
775
780
|
refreshFilterSuggestionsKey,
|
|
781
|
+
minColumnWidth,
|
|
776
782
|
}: TableProps<T> & Styled) => {
|
|
777
783
|
const sortingStorageKey = (memoryId ?? '') + 'sorting'
|
|
778
784
|
const cachedSortString = read_local_storage(sortingStorageKey)
|
|
@@ -1038,6 +1044,7 @@ export const Table = <T extends Item>({
|
|
|
1038
1044
|
}
|
|
1039
1045
|
: undefined
|
|
1040
1046
|
}
|
|
1047
|
+
minColumnWidth={minColumnWidth}
|
|
1041
1048
|
/>
|
|
1042
1049
|
)}
|
|
1043
1050
|
|
|
@@ -1078,6 +1085,7 @@ export const Table = <T extends Item>({
|
|
|
1078
1085
|
: undefined,
|
|
1079
1086
|
}}
|
|
1080
1087
|
onClick={onClick} onPress={onPress}
|
|
1088
|
+
minColumnWidth={minColumnWidth}
|
|
1081
1089
|
/>
|
|
1082
1090
|
)
|
|
1083
1091
|
} />
|