@tellescope/react-components 1.172.1 → 1.173.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 (47) hide show
  1. package/lib/cjs/Forms/forms.d.ts.map +1 -1
  2. package/lib/cjs/Forms/forms.js +1 -1
  3. package/lib/cjs/Forms/forms.js.map +1 -1
  4. package/lib/cjs/Forms/hooks.d.ts +6 -2
  5. package/lib/cjs/Forms/hooks.d.ts.map +1 -1
  6. package/lib/cjs/Forms/hooks.js +6 -1
  7. package/lib/cjs/Forms/hooks.js.map +1 -1
  8. package/lib/cjs/Forms/inputs.d.ts +1 -1
  9. package/lib/cjs/Forms/inputs.d.ts.map +1 -1
  10. package/lib/cjs/Forms/inputs.js +14 -4
  11. package/lib/cjs/Forms/inputs.js.map +1 -1
  12. package/lib/cjs/table.d.ts +5 -2
  13. package/lib/cjs/table.d.ts.map +1 -1
  14. package/lib/cjs/table.js +7 -7
  15. package/lib/cjs/table.js.map +1 -1
  16. package/lib/esm/CMS/components.d.ts +1 -0
  17. package/lib/esm/CMS/components.d.ts.map +1 -1
  18. package/lib/esm/Forms/forms.d.ts +3 -3
  19. package/lib/esm/Forms/forms.d.ts.map +1 -1
  20. package/lib/esm/Forms/forms.js +1 -1
  21. package/lib/esm/Forms/forms.js.map +1 -1
  22. package/lib/esm/Forms/hooks.d.ts +6 -2
  23. package/lib/esm/Forms/hooks.d.ts.map +1 -1
  24. package/lib/esm/Forms/hooks.js +6 -1
  25. package/lib/esm/Forms/hooks.js.map +1 -1
  26. package/lib/esm/Forms/inputs.d.ts +2 -2
  27. package/lib/esm/Forms/inputs.d.ts.map +1 -1
  28. package/lib/esm/Forms/inputs.js +14 -4
  29. package/lib/esm/Forms/inputs.js.map +1 -1
  30. package/lib/esm/Forms/inputs.native.d.ts +1 -0
  31. package/lib/esm/Forms/inputs.native.d.ts.map +1 -1
  32. package/lib/esm/controls.d.ts +2 -2
  33. package/lib/esm/inputs.d.ts +1 -1
  34. package/lib/esm/layout.d.ts +1 -1
  35. package/lib/esm/state.d.ts +264 -264
  36. package/lib/esm/table.d.ts +5 -2
  37. package/lib/esm/table.d.ts.map +1 -1
  38. package/lib/esm/table.js +7 -7
  39. package/lib/esm/table.js.map +1 -1
  40. package/lib/esm/theme.native.d.ts +1 -0
  41. package/lib/esm/theme.native.d.ts.map +1 -1
  42. package/lib/tsconfig.tsbuildinfo +1 -1
  43. package/package.json +9 -9
  44. package/src/Forms/forms.tsx +4 -1
  45. package/src/Forms/hooks.tsx +7 -2
  46. package/src/Forms/inputs.tsx +25 -3
  47. package/src/table.tsx +8 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellescope/react-components",
3
- "version": "1.172.1",
3
+ "version": "1.173.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.172.0",
51
- "@tellescope/sdk": "^1.172.0",
52
- "@tellescope/types-client": "^1.172.0",
53
- "@tellescope/types-models": "^1.172.0",
54
- "@tellescope/types-utilities": "^1.172.0",
55
- "@tellescope/utilities": "^1.172.0",
56
- "@tellescope/validation": "^1.172.0",
50
+ "@tellescope/constants": "^1.173.0",
51
+ "@tellescope/sdk": "^1.173.0",
52
+ "@tellescope/types-client": "^1.173.0",
53
+ "@tellescope/types-models": "^1.173.0",
54
+ "@tellescope/types-utilities": "^1.173.0",
55
+ "@tellescope/utilities": "^1.173.0",
56
+ "@tellescope/validation": "^1.173.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",
@@ -84,7 +84,7 @@
84
84
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
85
85
  "react-native": "^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.71.0"
86
86
  },
87
- "gitHead": "91a22b59bb059b03006713f1c20d9746850bfe53",
87
+ "gitHead": "0239f40d9a62d16c2d94830a5f65db54aee48e1f",
88
88
  "publishConfig": {
89
89
  "access": "public"
90
90
  }
@@ -967,7 +967,10 @@ export const TellescopeSinglePageForm: React.JSXElementConstructor<TellescopeFor
967
967
  const list = useListForFormFields(fields, responses, { form: props.form, gender: enduser?.gender })
968
968
 
969
969
  const includedFieldIds = (
970
- Array.from(new Set([...list.map(f => f.id), ...(existingResponses ?? []).map(e => e.fieldId)]))
970
+ Array.from(new Set([
971
+ ...list.map(f => f.id),
972
+ ...(existingResponses ?? []).filter(e => !e.isPrepopulatedFromEnduserField).map(e => e.fieldId)
973
+ ]))
971
974
  )
972
975
 
973
976
  const handleSubmit = useCallback(async () => {
@@ -348,7 +348,7 @@ interface UseTellescopeFormOptions {
348
348
  automationStepId?: string,
349
349
  form?: Form,
350
350
  fields: FormField[],
351
- existingResponses?: FormResponse['responses'],
351
+ existingResponses?: (FormResponseValue & { isPrepopulatedFromEnduserField?: boolean })[],
352
352
  formResponseId?: string,
353
353
  isInternalNote?: boolean,
354
354
  formTitle?: string,
@@ -1213,7 +1213,12 @@ export const useTellescopeForm = ({ isPublicForm, form, urlLogicValue, customiza
1213
1213
  responses: [
1214
1214
  ...responsesToSubmit,
1215
1215
  // include existing responses in case previously saved as draft
1216
- ...(existingResponses ?? []).filter(r => !responsesToSubmit.find(_r => r.fieldId === _r.fieldId)),
1216
+ ...(existingResponses ?? []).filter(r =>
1217
+ !responsesToSubmit.find(_r => r.fieldId === _r.fieldId)
1218
+ // but don't include responses which were populated from a patient field and not a prior response
1219
+ // if these are edited, they would be included in responsesToSubmit
1220
+ && !r.isPrepopulatedFromEnduserField
1221
+ ),
1217
1222
  ],
1218
1223
  automationStepId,
1219
1224
  customerId,
@@ -355,6 +355,23 @@ export const TableInput = ({ field, value=[], onChange, ...props }: FormInputPro
355
355
  </Select>
356
356
  </FormControl>
357
357
  )
358
+ : (v.type === 'Database' && v.info.databaseId && v.info.databaseLabel) ? (
359
+ <DatabaseSelectInput responses={[]} size="small"
360
+ field={{
361
+ ...field,
362
+ options: { databaseId: v.info.databaseId, databaseLabel: v.info.databaseLabel },
363
+ title: v.label,
364
+ }}
365
+ value={row.find((_, _i) => columnIndex === _i)?.entry ? [{
366
+ text: JSON.parse(row.find((_, _i) => columnIndex === _i)?.entry || '{}').text || '',
367
+ databaseId: JSON.parse(row.find((_, _i) => columnIndex === _i)?.entry || '{}').databaseId || '',
368
+ recordId: JSON.parse(row.find((_, _i) => columnIndex === _i)?.entry || '{}').recordId || '',
369
+ }] : []}
370
+ onChange={
371
+ (records) => handleChange(i, columnIndex, { label: v.label, entry: JSON.stringify(records?.[0] ?? '') })
372
+ }
373
+ />
374
+ )
358
375
  : null
359
376
  }
360
377
  </Grid>
@@ -1761,6 +1778,7 @@ const choicesForDatabase: {
1761
1778
  lastId?: string,
1762
1779
  }
1763
1780
  } = {}
1781
+ const preventRefetch: Record<string, boolean> = {}
1764
1782
 
1765
1783
  const LOAD_CHOICES_LIMIT = 500
1766
1784
  const useDatabaseChoices = ({ databaseId='', field, otherAnswers } : { databaseId?: string, field: FormField, otherAnswers?: DatabaseSelectResponse[] }) => {
@@ -1774,11 +1792,14 @@ const useDatabaseChoices = ({ databaseId='', field, otherAnswers } : { databaseI
1774
1792
  const choices = choicesForDatabase[databaseId]?.records ?? []
1775
1793
  const lastId = choicesForDatabase[databaseId]?.lastId
1776
1794
 
1795
+ if (preventRefetch[databaseId + field.id + lastId]) return
1796
+ preventRefetch[databaseId + field.id + lastId] = true
1797
+
1777
1798
  session.api.form_fields.load_choices_from_database({
1778
1799
  fieldId: field.id,
1779
1800
  lastId,
1780
1801
  limit: LOAD_CHOICES_LIMIT,
1781
- databaseId, // doesn't do anything now, but avoids cache hit when editing to change databaseId for same field
1802
+ databaseId, // overrides fieldId, supports using Database question in Table Input
1782
1803
  })
1783
1804
  .then(({ choices: newChoices }) => {
1784
1805
  choicesForDatabase[databaseId] = {
@@ -1795,6 +1816,7 @@ const useDatabaseChoices = ({ databaseId='', field, otherAnswers } : { databaseI
1795
1816
  })
1796
1817
  .catch(err => {
1797
1818
  console.error(err)
1819
+ preventRefetch[databaseId + field.id + lastId] = false
1798
1820
  })
1799
1821
  }, [session, field, databaseId, renderCount])
1800
1822
 
@@ -1849,7 +1871,7 @@ const get_other_answers = (_value?: DatabaseSelectResponse[], typing?: string) =
1849
1871
  return []
1850
1872
  }
1851
1873
 
1852
- export const DatabaseSelectInput = ({ field, value: _value, onChange, onDatabaseSelect, responses }: FormInputProps<'Database Select'> & {
1874
+ export const DatabaseSelectInput = ({ field, value: _value, onChange, onDatabaseSelect, responses, size }: FormInputProps<'Database Select'> & {
1853
1875
  responses: FormResponseValue[],
1854
1876
  }) => {
1855
1877
  const [typing, setTyping] = useState('')
@@ -1944,7 +1966,7 @@ export const DatabaseSelectInput = ({ field, value: _value, onChange, onDatabase
1944
1966
 
1945
1967
  if (!doneLoading) return <LinearProgress />
1946
1968
  return (
1947
- <Autocomplete id={field.id} freeSolo={false}
1969
+ <Autocomplete id={field.id} freeSolo={false} size={size}
1948
1970
  componentsProps={{ popper: { sx: { wordBreak: "break-word" } } } }
1949
1971
  options={filteredChoices} multiple={true}
1950
1972
  getOptionLabel={o => (
package/src/table.tsx CHANGED
@@ -132,6 +132,7 @@ export type TableField <T> = {
132
132
  filterIsActive?: boolean,
133
133
  filterComponent?: React.ReactNode,
134
134
  allowWidthAdjustment?: boolean,
135
+ columnResizeZIndex?: number,
135
136
  }
136
137
  export interface TableHeaderProps<T extends Item> extends Styled, HorizontalPadded, SelectionPropsOptional {
137
138
  fields: TableField<T>[],
@@ -147,6 +148,7 @@ export interface TableHeaderProps<T extends Item> extends Styled, HorizontalPadd
147
148
  setLocalFilters: React.Dispatch<React.SetStateAction<LocalFilter[]>>,
148
149
  filterSuggestions: Record<string, string[]>,
149
150
  minColumnWidth?: number,
151
+ columnResizeZIndex?: number,
150
152
  }
151
153
  export const TableHeader = <T extends Item>({
152
154
  fields,
@@ -167,6 +169,7 @@ export const TableHeader = <T extends Item>({
167
169
  setLocalFilters,
168
170
  filterSuggestions,
169
171
  minColumnWidth=75,
172
+ columnResizeZIndex=1000,
170
173
  } : TableHeaderProps<T>) => {
171
174
  const [openFilter, setOpenFilter] = useState(-1)
172
175
  const [startX, setStartX] = useState(0)
@@ -341,7 +344,7 @@ export const TableHeader = <T extends Item>({
341
344
  height: '30px',
342
345
  backgroundColor: '#22222266',
343
346
  cursor: 'col-resize',
344
- zIndex: 1000,
347
+ zIndex: columnResizeZIndex,
345
348
  position: 'relative', right: '6px',
346
349
  }} />
347
350
  </Draggable>
@@ -725,6 +728,7 @@ export interface TableProps<T extends Item> extends WithTitle, WithHeader<T>, Wi
725
728
  loadMoreOptions?: LoadMoreOptions<T>,
726
729
  refreshFilterSuggestionsKey?: number,
727
730
  minColumnWidth?: number,
731
+ columnResizeZIndex?: number,
728
732
  }
729
733
  export const Table = <T extends Item>({
730
734
  items,
@@ -775,10 +779,11 @@ export const Table = <T extends Item>({
775
779
  onReorder,
776
780
  virtualization,
777
781
  onExport,
778
-
782
+
779
783
  sort,
780
784
  refreshFilterSuggestionsKey,
781
785
  minColumnWidth,
786
+ columnResizeZIndex,
782
787
  }: TableProps<T> & Styled) => {
783
788
  const sortingStorageKey = (memoryId ?? '') + 'sorting'
784
789
  const cachedSortString = read_local_storage(sortingStorageKey)
@@ -1045,6 +1050,7 @@ export const Table = <T extends Item>({
1045
1050
  : undefined
1046
1051
  }
1047
1052
  minColumnWidth={minColumnWidth}
1053
+ columnResizeZIndex={columnResizeZIndex}
1048
1054
  />
1049
1055
  )}
1050
1056