@tellescope/react-components 1.230.1 → 1.231.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 (48) hide show
  1. package/lib/cjs/Forms/forms.d.ts.map +1 -1
  2. package/lib/cjs/Forms/forms.js +30 -28
  3. package/lib/cjs/Forms/forms.js.map +1 -1
  4. package/lib/cjs/Forms/forms.v2.d.ts.map +1 -1
  5. package/lib/cjs/Forms/forms.v2.js +32 -30
  6. package/lib/cjs/Forms/forms.v2.js.map +1 -1
  7. package/lib/cjs/Forms/hooks.d.ts +111 -3
  8. package/lib/cjs/Forms/hooks.d.ts.map +1 -1
  9. package/lib/cjs/Forms/hooks.js +26 -8
  10. package/lib/cjs/Forms/hooks.js.map +1 -1
  11. package/lib/cjs/Forms/inputs.d.ts +1 -0
  12. package/lib/cjs/Forms/inputs.d.ts.map +1 -1
  13. package/lib/cjs/Forms/inputs.js +28 -1
  14. package/lib/cjs/Forms/inputs.js.map +1 -1
  15. package/lib/cjs/Forms/inputs.v2.d.ts +1 -0
  16. package/lib/cjs/Forms/inputs.v2.d.ts.map +1 -1
  17. package/lib/cjs/Forms/inputs.v2.js +32 -32
  18. package/lib/cjs/Forms/inputs.v2.js.map +1 -1
  19. package/lib/esm/Forms/forms.d.ts +3 -3
  20. package/lib/esm/Forms/forms.d.ts.map +1 -1
  21. package/lib/esm/Forms/forms.js +31 -29
  22. package/lib/esm/Forms/forms.js.map +1 -1
  23. package/lib/esm/Forms/forms.v2.d.ts +3 -3
  24. package/lib/esm/Forms/forms.v2.d.ts.map +1 -1
  25. package/lib/esm/Forms/forms.v2.js +33 -31
  26. package/lib/esm/Forms/forms.v2.js.map +1 -1
  27. package/lib/esm/Forms/hooks.d.ts +111 -3
  28. package/lib/esm/Forms/hooks.d.ts.map +1 -1
  29. package/lib/esm/Forms/hooks.js +28 -10
  30. package/lib/esm/Forms/hooks.js.map +1 -1
  31. package/lib/esm/Forms/inputs.d.ts +2 -1
  32. package/lib/esm/Forms/inputs.d.ts.map +1 -1
  33. package/lib/esm/Forms/inputs.js +26 -0
  34. package/lib/esm/Forms/inputs.js.map +1 -1
  35. package/lib/esm/Forms/inputs.v2.d.ts +2 -1
  36. package/lib/esm/Forms/inputs.v2.d.ts.map +1 -1
  37. package/lib/esm/Forms/inputs.v2.js +32 -33
  38. package/lib/esm/Forms/inputs.v2.js.map +1 -1
  39. package/lib/esm/controls.d.ts +2 -2
  40. package/lib/esm/inputs.d.ts +1 -1
  41. package/lib/esm/state.d.ts +319 -319
  42. package/lib/tsconfig.tsbuildinfo +1 -1
  43. package/package.json +9 -9
  44. package/src/Forms/forms.tsx +6 -2
  45. package/src/Forms/forms.v2.tsx +16 -12
  46. package/src/Forms/hooks.tsx +46 -12
  47. package/src/Forms/inputs.tsx +158 -0
  48. package/src/Forms/inputs.v2.tsx +179 -65
@@ -1,6 +1,6 @@
1
1
  import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react"
2
2
  import axios from "axios"
3
- import { Autocomplete, Box, Button, Checkbox, Chip, Collapse, Divider, FormControl, FormControlLabel, FormLabel, Grid, IconButton as MuiIconButton, InputLabel, MenuItem, Radio, RadioGroup, Select, SxProps, TextField, TextFieldProps, Typography } from "@mui/material"
3
+ import { Autocomplete, Box, Button, Checkbox, Chip, Divider, FormControl, FormControlLabel, FormLabel, Grid, InputLabel, MenuItem, Radio, RadioGroup, Select, SxProps, TextField, TextFieldProps, Typography } from "@mui/material"
4
4
  import { FormInputProps } from "./types"
5
5
  import { useDropzone } from "react-dropzone"
6
6
  import { CANVAS_TITLE, EMOTII_TITLE, INSURANCE_RELATIONSHIPS, INSURANCE_RELATIONSHIPS_CANVAS, PRIMARY_HEX, RELATIONSHIP_TYPES, TELLESCOPE_GENDERS } from "@tellescope/constants"
@@ -23,7 +23,7 @@ import LanguageIcon from '@mui/icons-material/Language';
23
23
 
24
24
  import { Elements, PaymentElement, useStripe, useElements, EmbeddedCheckout, EmbeddedCheckoutProvider } from '@stripe/react-stripe-js';
25
25
  import { loadStripe } from '@stripe/stripe-js';
26
- import { CheckCircleOutline, Delete, Edit, ExpandMore, UploadFile } from "@mui/icons-material"
26
+ import { CheckCircleOutline, Delete, Edit, UploadFile } from "@mui/icons-material"
27
27
  import { WYSIWYG } from "./wysiwyg"
28
28
 
29
29
  export const LanguageSelect = ({ value, ...props }: { value: string, onChange: (s: string) => void}) => (
@@ -1511,7 +1511,6 @@ export const FilesInput = ({ value, onChange, field, existingFileName, uploading
1511
1511
  export const MultipleChoiceInput = ({ field, form, value: _value, onChange }: FormInputProps<'multiple_choice'>) => {
1512
1512
  const value = typeof _value === 'string' ? [_value] : _value // if loading existingResponses, allows them to be a string
1513
1513
  const { choices, radio, other, optionDetails } = field.options as MultipleChoiceOptions
1514
- const [expandedDescriptions, setExpandedDescriptions] = useState<Record<number, boolean>>({})
1515
1514
 
1516
1515
  // current other string
1517
1516
  const enteringOtherStringRef = React.useRef('') // if typing otherString as prefix of a checkbox value, don't auto-select
@@ -1524,13 +1523,6 @@ export const MultipleChoiceInput = ({ field, form, value: _value, onChange }: Fo
1524
1523
  return optionDetails?.find(detail => detail.option === choice)?.description
1525
1524
  }, [optionDetails])
1526
1525
 
1527
- const toggleDescription = useCallback((index: number) => {
1528
- setExpandedDescriptions(prev => ({
1529
- ...prev,
1530
- [index]: !prev[index]
1531
- }))
1532
- }, [])
1533
-
1534
1526
  return (
1535
1527
  <Grid container alignItems="center" rowGap={1.5}>
1536
1528
  {radio
@@ -1544,7 +1536,6 @@ export const MultipleChoiceInput = ({ field, form, value: _value, onChange }: Fo
1544
1536
  {(choices ?? []).map((c, i) => {
1545
1537
  const description = getDescriptionForChoice(c)
1546
1538
  const hasDescription = !!description
1547
- const isExpanded = expandedDescriptions[i]
1548
1539
  const isSelected = !!value?.includes(c) && c !== otherString
1549
1540
 
1550
1541
  return (
@@ -1558,7 +1549,7 @@ export const MultipleChoiceInput = ({ field, form, value: _value, onChange }: Fo
1558
1549
  borderColor: 'primary.main',
1559
1550
  borderRadius: 1,
1560
1551
  padding: '16px 16px',
1561
- marginBottom: '12px',
1552
+ marginBottom: hasDescription ? '8px' : '12px',
1562
1553
  cursor: 'pointer',
1563
1554
  backgroundColor: 'transparent',
1564
1555
  boxSizing: 'border-box',
@@ -1569,32 +1560,13 @@ export const MultipleChoiceInput = ({ field, form, value: _value, onChange }: Fo
1569
1560
  onClick={() => onChange(value?.includes(c) ? [] : [c], field.id)}
1570
1561
  >
1571
1562
  <Typography component="span" sx={{ flex: 1, color: 'primary.main', fontSize: 13, fontWeight: 600 }}>{c}</Typography>
1572
- {hasDescription && (
1573
- <MuiIconButton
1574
- className="expand-button"
1575
- size="small"
1576
- onClick={(e: React.MouseEvent) => {
1577
- e.stopPropagation()
1578
- toggleDescription(i)
1579
- }}
1580
- sx={{
1581
- transform: isExpanded ? 'rotate(180deg)' : 'rotate(0deg)',
1582
- transition: 'transform 0.2s',
1583
- ml: 1
1584
- }}
1585
- >
1586
- <ExpandMore fontSize="small" />
1587
- </MuiIconButton>
1588
- )}
1589
1563
  </Box>
1590
1564
  {hasDescription && (
1591
- <Collapse in={isExpanded}>
1592
- <Box sx={{ pl: 2, pr: 2, pb: 1, pt: 1 }}>
1593
- <Typography variant="body2" color="text.secondary">
1594
- {description}
1595
- </Typography>
1596
- </Box>
1597
- </Collapse>
1565
+ <Box sx={{ pl: 2, pr: 2, pb: 1, mb: 1 }}>
1566
+ <Typography style={{ fontSize: 14, color: '#00000099' }}>
1567
+ {description}
1568
+ </Typography>
1569
+ </Box>
1598
1570
  )}
1599
1571
  </Box>
1600
1572
  )
@@ -1605,7 +1577,6 @@ export const MultipleChoiceInput = ({ field, form, value: _value, onChange }: Fo
1605
1577
  (choices ?? []).map((c, i) => {
1606
1578
  const description = getDescriptionForChoice(c)
1607
1579
  const hasDescription = !!description
1608
- const isExpanded = expandedDescriptions[i]
1609
1580
 
1610
1581
  return (
1611
1582
  <Grid xs={12} key={i}>
@@ -1619,10 +1590,6 @@ export const MultipleChoiceInput = ({ field, form, value: _value, onChange }: Fo
1619
1590
  boxSizing: 'border-box'
1620
1591
  }}
1621
1592
  onClick={(e) => {
1622
- // Don't trigger selection if clicking on the expand button
1623
- if ((e.target as HTMLElement).closest('.expand-button')) {
1624
- return
1625
- }
1626
1593
  onChange(
1627
1594
  (
1628
1595
  value?.includes(c)
@@ -1647,32 +1614,13 @@ export const MultipleChoiceInput = ({ field, form, value: _value, onChange }: Fo
1647
1614
  inputProps={{ 'aria-label': 'primary checkbox' }}
1648
1615
  />
1649
1616
  <Typography component="span" sx={{ flex: 1 }}>{c}</Typography>
1650
- {hasDescription && (
1651
- <MuiIconButton
1652
- className="expand-button"
1653
- size="small"
1654
- onClick={(e: React.MouseEvent) => {
1655
- e.stopPropagation()
1656
- toggleDescription(i)
1657
- }}
1658
- sx={{
1659
- transform: isExpanded ? 'rotate(180deg)' : 'rotate(0deg)',
1660
- transition: 'transform 0.2s',
1661
- ml: 1
1662
- }}
1663
- >
1664
- <ExpandMore fontSize="small" />
1665
- </MuiIconButton>
1666
- )}
1667
1617
  </Box>
1668
1618
  {hasDescription && (
1669
- <Collapse in={isExpanded}>
1670
- <Box sx={{ pl: '42px', pr: 2, pb: 1 }}>
1671
- <Typography variant="body2" color="text.secondary">
1672
- {description}
1673
- </Typography>
1674
- </Box>
1675
- </Collapse>
1619
+ <Box sx={{ pl: '42px', pr: 2, pb: 1 }}>
1620
+ <Typography style={{ fontSize: 14, color: '#00000099' }}>
1621
+ {description}
1622
+ </Typography>
1623
+ </Box>
1676
1624
  )}
1677
1625
  </Box>
1678
1626
  </Grid>
@@ -2973,6 +2921,172 @@ export const MedicationsInput = ({ field, value, onChange, ...props }: FormInput
2973
2921
  )
2974
2922
  }
2975
2923
 
2924
+ export const BelugaPatientPreferenceInput = ({ field, value: _value, onChange }: FormInputProps<'Beluga Patient Preference'>) => {
2925
+ const value = Array.isArray(_value) ? _value : []
2926
+
2927
+ return (
2928
+ <Grid container direction="column" sx={{ mt: 2 }}>
2929
+ {value.map((v, i) => (
2930
+ <>
2931
+ <Grid item key={i}>
2932
+ <Grid container alignItems="center" wrap="nowrap">
2933
+ <Grid item sx={{ width: '100%'}}>
2934
+ <Grid container direction="column" spacing={1.5}>
2935
+ <Grid item>
2936
+ <TextField label="Medication Name" size="small" fullWidth required
2937
+ InputProps={defaultInputProps}
2938
+ value={v.name ?? ''}
2939
+ onChange={e =>
2940
+ onChange(
2941
+ value.map((_v, _i) => (
2942
+ i === _i ? { ..._v, name: e.target.value } : _v
2943
+ )),
2944
+ field.id,
2945
+ )
2946
+ }
2947
+ />
2948
+ </Grid>
2949
+
2950
+ <Grid item>
2951
+ <Grid container spacing={1}>
2952
+ <Grid item xs={12} md={6}>
2953
+ <TextField label="Strength" size="small" fullWidth required
2954
+ InputProps={defaultInputProps}
2955
+ value={v.strength ?? ''}
2956
+ onChange={e =>
2957
+ onChange(
2958
+ value.map((_v, _i) => (
2959
+ i === _i ? { ..._v, strength: e.target.value } : _v
2960
+ )),
2961
+ field.id,
2962
+ )
2963
+ }
2964
+ />
2965
+ </Grid>
2966
+ <Grid item xs={12} md={6}>
2967
+ <TextField label="Dispense Unit" size="small" fullWidth required
2968
+ InputProps={defaultInputProps}
2969
+ value={v.dispenseUnit ?? ''}
2970
+ onChange={e =>
2971
+ onChange(
2972
+ value.map((_v, _i) => (
2973
+ i === _i ? { ..._v, dispenseUnit: e.target.value } : _v
2974
+ )),
2975
+ field.id,
2976
+ )
2977
+ }
2978
+ />
2979
+ </Grid>
2980
+ </Grid>
2981
+ </Grid>
2982
+
2983
+ <Grid item>
2984
+ <Grid container spacing={1}>
2985
+ <Grid item xs={12} md={4}>
2986
+ <TextField label="Quantity" size="small" fullWidth required
2987
+ InputProps={defaultInputProps}
2988
+ value={v.quantity ?? ''}
2989
+ onChange={e =>
2990
+ onChange(
2991
+ value.map((_v, _i) => (
2992
+ i === _i ? { ..._v, quantity: e.target.value } : _v
2993
+ )),
2994
+ field.id,
2995
+ )
2996
+ }
2997
+ />
2998
+ </Grid>
2999
+ <Grid item xs={12} md={4}>
3000
+ <TextField label="Refills" size="small" fullWidth required
3001
+ InputProps={defaultInputProps}
3002
+ value={v.refills ?? ''}
3003
+ onChange={e =>
3004
+ onChange(
3005
+ value.map((_v, _i) => (
3006
+ i === _i ? { ..._v, refills: e.target.value } : _v
3007
+ )),
3008
+ field.id,
3009
+ )
3010
+ }
3011
+ />
3012
+ </Grid>
3013
+ <Grid item xs={12} md={4}>
3014
+ <TextField label="Days Supply" size="small" fullWidth required
3015
+ InputProps={defaultInputProps}
3016
+ value={v.daysSupply ?? ''}
3017
+ onChange={e =>
3018
+ onChange(
3019
+ value.map((_v, _i) => (
3020
+ i === _i ? { ..._v, daysSupply: e.target.value } : _v
3021
+ )),
3022
+ field.id,
3023
+ )
3024
+ }
3025
+ />
3026
+ </Grid>
3027
+ </Grid>
3028
+ </Grid>
3029
+
3030
+ <Grid item>
3031
+ <TextField label="Sig (Instructions)" size="small" fullWidth required multiline rows={2}
3032
+ InputProps={defaultInputProps}
3033
+ value={v.sig ?? ''}
3034
+ onChange={e =>
3035
+ onChange(
3036
+ value.map((_v, _i) => (
3037
+ i === _i ? { ..._v, sig: e.target.value } : _v
3038
+ )),
3039
+ field.id,
3040
+ )
3041
+ }
3042
+ />
3043
+ </Grid>
3044
+
3045
+ <Grid item>
3046
+ <TextField label="Med ID (NDC11)" size="small" fullWidth required
3047
+ InputProps={defaultInputProps}
3048
+ value={v.medId ?? ''}
3049
+ onChange={e =>
3050
+ onChange(
3051
+ value.map((_v, _i) => (
3052
+ i === _i ? { ..._v, medId: e.target.value } : _v
3053
+ )),
3054
+ field.id,
3055
+ )
3056
+ }
3057
+ />
3058
+ </Grid>
3059
+
3060
+ <Grid item>
3061
+ <Typography color="primary" sx={{ textDecoration: 'underline', cursor: 'pointer' }}
3062
+ onClick={() => onChange(value.filter((_, _i) => i !== _i), field.id)}
3063
+ >
3064
+ Remove medication
3065
+ </Typography>
3066
+ </Grid>
3067
+ </Grid>
3068
+ </Grid>
3069
+ </Grid>
3070
+ </Grid>
3071
+
3072
+ <Grid item><Divider flexItem sx={{ my: 1 }} /></Grid>
3073
+ </>
3074
+ ))}
3075
+
3076
+ <Grid item>
3077
+ <Button color="primary" variant="outlined"
3078
+ onClick={() => onChange([
3079
+ ...value,
3080
+ { name: '', strength: '', quantity: '', refills: '', daysSupply: '', sig: '', dispenseUnit: '', medId: '' }
3081
+ ], field.id)}
3082
+ >
3083
+ Add Medication
3084
+ </Button>
3085
+ </Grid>
3086
+ </Grid>
3087
+ )
3088
+ }
3089
+
2976
3090
  export const contact_is_valid = (e: Partial<Enduser>) => {
2977
3091
  if (e.email) {
2978
3092
  try {