@tellescope/react-components 1.178.0 → 1.179.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellescope/react-components",
3
- "version": "1.178.0",
3
+ "version": "1.179.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.178.0",
51
- "@tellescope/sdk": "^1.178.0",
52
- "@tellescope/types-client": "^1.178.0",
53
- "@tellescope/types-models": "^1.178.0",
54
- "@tellescope/types-utilities": "^1.178.0",
55
- "@tellescope/utilities": "^1.178.0",
56
- "@tellescope/validation": "^1.178.0",
50
+ "@tellescope/constants": "^1.179.0",
51
+ "@tellescope/sdk": "^1.179.0",
52
+ "@tellescope/types-client": "^1.179.0",
53
+ "@tellescope/types-models": "^1.179.0",
54
+ "@tellescope/types-utilities": "^1.179.0",
55
+ "@tellescope/utilities": "^1.179.0",
56
+ "@tellescope/validation": "^1.179.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": "3a19783254252a6a5f81188049d32b519ad47648",
87
+ "gitHead": "cc716897524deede0b46f0c1d32cd29e844aa747",
88
88
  "publishConfig": {
89
89
  "access": "public"
90
90
  }
@@ -636,7 +636,9 @@ export const useTellescopeForm = ({ isPublicForm, form, urlLogicValue, customiza
636
636
  ? parseInt(f.options.default)
637
637
  : (f.options?.from || 1)
638
638
  )
639
- : '' as any // null flag that the response was not filled out
639
+ : f.type === 'Related Contacts'
640
+ ? (f.isOptional ? [] : [{}])
641
+ : '' as any // null flag that the response was not filled out
640
642
  )
641
643
  ),
642
644
  } as FormResponseValueAnswer,
@@ -924,6 +926,9 @@ export const useTellescopeForm = ({ isPublicForm, form, urlLogicValue, customiza
924
926
  if (errorMessage) {
925
927
  return `Contact ${i+1}: ${errorMessage}`
926
928
  }
929
+ if (Object.values(contact).every(v => !v)) {
930
+ return `Contact ${i+1}: At least one field is required`
931
+ }
927
932
  }
928
933
  }
929
934
 
@@ -2573,7 +2573,12 @@ export const RelatedContactsInput = ({ field, value: _value, onChange, ...props
2573
2573
  // safeguard against any rogue values like empty string
2574
2574
  const value = Array.isArray(_value) ? _value : []
2575
2575
 
2576
- const [editing, setEditing] = useState(-1)
2576
+ const [editing, setEditing] = useState(value.length === 1 ? 0 : -1)
2577
+
2578
+ const handleAddContact = useCallback(() => {
2579
+ onChange([...value, {}], field.id, true)
2580
+ setEditing(value.length)
2581
+ }, [onChange, value, field?.id])
2577
2582
 
2578
2583
  if (value[editing]) {
2579
2584
  const { fname, lname, email, phone, fields={}, dateOfBirth='', relationships } = value[editing]
@@ -2644,8 +2649,8 @@ export const RelatedContactsInput = ({ field, value: _value, onChange, ...props
2644
2649
  {(field.options?.tableChoices || []).length > 0 &&
2645
2650
  <Grid item>
2646
2651
  <Grid container spacing={1}>
2647
- {(field.options?.tableChoices || []).map(({ info, label, type}) => (
2648
- <Grid item xs={6}>
2652
+ {(field.options?.tableChoices || []).map(({ info, label, type}, i) => (
2653
+ <Grid item xs={6} key={i}>
2649
2654
  {type === 'Text'
2650
2655
  ? (
2651
2656
  <TextField label={label} size="small" fullWidth
@@ -2656,7 +2661,7 @@ export const RelatedContactsInput = ({ field, value: _value, onChange, ...props
2656
2661
  )
2657
2662
  : type === 'Date' ? (
2658
2663
  <DateStringInput label={label} size="small" fullWidth
2659
- field={field}
2664
+ field={{ ...field, isOptional: true }}
2660
2665
  value={fields[label] as string || ''}
2661
2666
  onChange={(e='') => onChange(value.map((v, i) => i === editing ? { ...v, fields: { ...fields, [label]: e } } : v), field.id)}
2662
2667
  />
@@ -2729,10 +2734,7 @@ export const RelatedContactsInput = ({ field, value: _value, onChange, ...props
2729
2734
  </Grid>
2730
2735
 
2731
2736
  <Grid item>
2732
- <Button variant="contained" onClick={() => {
2733
- onChange([...value, {}], field.id, true)
2734
- setEditing(value.length)
2735
- }}>
2737
+ <Button variant="contained" onClick={handleAddContact}>
2736
2738
  Add Contact
2737
2739
  </Button>
2738
2740
  </Grid>