@tellescope/react-components 1.123.1 → 1.125.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/forms.d.ts +2 -1
- package/lib/cjs/Forms/forms.d.ts.map +1 -1
- package/lib/cjs/Forms/forms.js +47 -45
- package/lib/cjs/Forms/forms.js.map +1 -1
- package/lib/cjs/Forms/hooks.d.ts.map +1 -1
- package/lib/cjs/Forms/hooks.js +3 -1
- package/lib/cjs/Forms/hooks.js.map +1 -1
- package/lib/cjs/Forms/inputs.d.ts +2 -1
- package/lib/cjs/Forms/inputs.d.ts.map +1 -1
- package/lib/cjs/Forms/inputs.js +27 -5
- package/lib/cjs/Forms/inputs.js.map +1 -1
- package/lib/cjs/Forms/types.d.ts +1 -0
- package/lib/cjs/Forms/types.d.ts.map +1 -1
- package/lib/esm/Forms/forms.d.ts +2 -1
- package/lib/esm/Forms/forms.d.ts.map +1 -1
- package/lib/esm/Forms/forms.js +48 -46
- package/lib/esm/Forms/forms.js.map +1 -1
- package/lib/esm/Forms/hooks.d.ts.map +1 -1
- package/lib/esm/Forms/hooks.js +3 -1
- package/lib/esm/Forms/hooks.js.map +1 -1
- package/lib/esm/Forms/inputs.d.ts +2 -1
- package/lib/esm/Forms/inputs.d.ts.map +1 -1
- package/lib/esm/Forms/inputs.js +26 -5
- package/lib/esm/Forms/inputs.js.map +1 -1
- package/lib/esm/Forms/types.d.ts +1 -0
- package/lib/esm/Forms/types.d.ts.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/Forms/forms.tsx +9 -3
- package/src/Forms/hooks.tsx +3 -2
- package/src/Forms/inputs.tsx +25 -4
- package/src/Forms/types.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tellescope/react-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.125.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"@reduxjs/toolkit": "^1.6.2",
|
|
48
48
|
"@stripe/react-stripe-js": "^2.1.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.
|
|
50
|
+
"@tellescope/constants": "^1.125.0",
|
|
51
|
+
"@tellescope/sdk": "^1.125.0",
|
|
52
|
+
"@tellescope/types-client": "^1.125.0",
|
|
53
|
+
"@tellescope/types-models": "^1.125.0",
|
|
54
54
|
"@tellescope/types-utilities": "^1.69.3",
|
|
55
|
-
"@tellescope/utilities": "^1.
|
|
55
|
+
"@tellescope/utilities": "^1.125.0",
|
|
56
56
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
57
57
|
"@typescript-eslint/parser": "^4.33.0",
|
|
58
58
|
"css-to-react-native": "^3.0.0",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
80
80
|
"react-native": "^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.71.0"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "3b7b9e360ded51b4ae485be67060ffbc3897a3c6",
|
|
83
83
|
"publishConfig": {
|
|
84
84
|
"access": "public"
|
|
85
85
|
}
|
package/src/Forms/forms.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useMemo, useState } from "react"
|
|
|
2
2
|
import { Button, CircularProgress, Flex, LoadingButton, Modal, Paper, Styled, Typography, form_display_text_for_language, useFileUpload, useFormResponses, useSession } from "../index"
|
|
3
3
|
import { useListForFormFields, useOrganizationTheme, useTellescopeForm, WithOrganizationTheme, Response, FileResponse } from "./hooks"
|
|
4
4
|
import { ChangeHandler, FormInputs } from "./types"
|
|
5
|
-
import { AddressInput, AppointmentBookingInput, DatabaseSelectInput, DateInput, DateStringInput, DropdownInput, EmailInput, FileInput, FilesInput, HeightInput, HiddenValueInput, InsuranceInput, LanguageSelect, MedicationsInput, MultipleChoiceInput, NumberInput, PhoneInput, Progress, RankingInput, RatingInput, RedirectInput, RelatedContactsInput, SignatureInput, StringInput, StringLongInput, StripeInput, TableInput, TimeInput, defaultButtonStyles } from "./inputs"
|
|
5
|
+
import { AddressInput, AppointmentBookingInput, DatabaseSelectInput, DateInput, DateStringInput, DropdownInput, EmailInput, EmotiiInput, FileInput, FilesInput, HeightInput, HiddenValueInput, InsuranceInput, LanguageSelect, MedicationsInput, MultipleChoiceInput, NumberInput, PhoneInput, Progress, RankingInput, RatingInput, RedirectInput, RelatedContactsInput, SignatureInput, StringInput, StringLongInput, StripeInput, TableInput, TimeInput, defaultButtonStyles } from "./inputs"
|
|
6
6
|
import { PRIMARY_HEX } from "@tellescope/constants"
|
|
7
7
|
import { FormResponse, FormField, Form, Enduser } from "@tellescope/types-client"
|
|
8
8
|
import { FormResponseAnswerFileValue, OrganizationTheme } from "@tellescope/types-models"
|
|
@@ -131,6 +131,7 @@ export const QuestionForField = ({
|
|
|
131
131
|
groupInstance,
|
|
132
132
|
goToNextField,
|
|
133
133
|
spacing,
|
|
134
|
+
isSinglePage,
|
|
134
135
|
} : {
|
|
135
136
|
spacing?: number,
|
|
136
137
|
form?: Form,
|
|
@@ -140,6 +141,7 @@ export const QuestionForField = ({
|
|
|
140
141
|
file: FileResponse,
|
|
141
142
|
field: FormField,
|
|
142
143
|
setCustomerId: React.Dispatch<React.SetStateAction<string | undefined>>,
|
|
144
|
+
isSinglePage?: boolean,
|
|
143
145
|
} & Pick<TellescopeFormProps, "goToNextField" | "groupId" | "groupInstance" | "submit" | "formResponseId" | 'enduserId' | 'isPreviousDisabled' | 'goToPreviousField' | 'enduser' | 'handleDatabaseSelect' | 'onAddFile' | 'onFieldChange' | 'fields' | 'customInputs' | 'responses' | 'selectedFiles' | 'validateField'>) => {
|
|
144
146
|
const String = customInputs?.['string'] ?? StringInput
|
|
145
147
|
const StringLong = customInputs?.['stringLong'] ?? StringLongInput
|
|
@@ -165,6 +167,7 @@ export const QuestionForField = ({
|
|
|
165
167
|
const Height = customInputs?.['Height'] ?? HeightInput
|
|
166
168
|
const Redirect = customInputs?.['Redirect'] ?? RedirectInput
|
|
167
169
|
const HiddenValue = customInputs?.['Hidden Value'] ?? HiddenValueInput
|
|
170
|
+
const Emotii = customInputs?.['Emotii'] ?? EmotiiInput
|
|
168
171
|
|
|
169
172
|
const validationMessage = validateField(field)
|
|
170
173
|
|
|
@@ -231,11 +234,14 @@ export const QuestionForField = ({
|
|
|
231
234
|
<DateStringInput field={field} disabled={value.disabled} value={value.answer.value as string} onChange={onFieldChange as ChangeHandler<'string'>} form={form} />
|
|
232
235
|
)
|
|
233
236
|
: field.type === 'Hidden Value' ? (
|
|
234
|
-
<HiddenValue goToNextField={goToNextField} goToPreviousField={goToPreviousField} field={field} value={value.answer.value as string} onChange={onFieldChange as ChangeHandler<any>} form={form} />
|
|
237
|
+
<HiddenValue isSinglePage={isSinglePage} goToNextField={goToNextField} goToPreviousField={goToPreviousField} field={field} value={value.answer.value as string} onChange={onFieldChange as ChangeHandler<any>} form={form} />
|
|
235
238
|
)
|
|
236
239
|
: field.type === 'Address' ? (
|
|
237
240
|
<Address field={field} disabled={value.disabled} value={value.answer.value as any} onChange={onFieldChange as ChangeHandler<any>} form={form} />
|
|
238
241
|
)
|
|
242
|
+
: field.type === 'Emotii' ? (
|
|
243
|
+
<Emotii field={field} disabled={value.disabled} value={value.answer.value as any} onChange={onFieldChange as ChangeHandler<any>} form={form} />
|
|
244
|
+
)
|
|
239
245
|
: field.type === 'Height' ? (
|
|
240
246
|
<Height field={field} disabled={value.disabled} value={value.answer.value as any} onChange={onFieldChange as ChangeHandler<any>} form={form} />
|
|
241
247
|
)
|
|
@@ -964,7 +970,7 @@ export const TellescopeSinglePageForm: React.JSXElementConstructor<TellescopeFor
|
|
|
964
970
|
return (
|
|
965
971
|
<Flex key={activeField.id} style={{ marginBottom: 5 }}>
|
|
966
972
|
<Flex column flex={1}>
|
|
967
|
-
<QuestionForField fields={fields} field={activeField} handleDatabaseSelect={handleDatabaseSelect}
|
|
973
|
+
<QuestionForField isSinglePage fields={fields} field={activeField} handleDatabaseSelect={handleDatabaseSelect}
|
|
968
974
|
enduserId={props.enduserId} formResponseId={props.formResponseId} submit={submit}
|
|
969
975
|
enduser={enduser} goToPreviousField={goToPreviousField} isPreviousDisabled={isPreviousDisabled} goToNextField={goToNextField}
|
|
970
976
|
repeats={repeats} onRepeatsChange={setRepeats} setCustomerId={setCustomerId}
|
package/src/Forms/hooks.tsx
CHANGED
|
@@ -9,7 +9,7 @@ import { WithTheme, contact_is_valid, useFileUpload, useFormFields, useFormRespo
|
|
|
9
9
|
import ReactGA from "react-ga4";
|
|
10
10
|
|
|
11
11
|
import isEmail from "validator/lib/isEmail"
|
|
12
|
-
import { append_current_utm_params, field_can_autoadvance, getLocalTimezone, get_time_values, get_utm_params, object_is_empty, responses_satisfy_conditions } from "@tellescope/utilities"
|
|
12
|
+
import { append_current_utm_params, field_can_autoadvance, getLocalTimezone, get_time_values, get_utm_params, is_object, object_is_empty, responses_satisfy_conditions } from "@tellescope/utilities"
|
|
13
13
|
|
|
14
14
|
export const useFlattenedTree = (root?: FormFieldNode) => {
|
|
15
15
|
const flat: FormField[] = []
|
|
@@ -909,6 +909,7 @@ export const useTellescopeForm = ({ form, urlLogicValue, customization, carePlan
|
|
|
909
909
|
return
|
|
910
910
|
}
|
|
911
911
|
|
|
912
|
+
if (value.answer.type === 'Hidden Value') return
|
|
912
913
|
if (!value.answer.value) {
|
|
913
914
|
return "A response is required"
|
|
914
915
|
}
|
|
@@ -1308,7 +1309,7 @@ export const useTellescopeForm = ({ form, urlLogicValue, customization, carePlan
|
|
|
1308
1309
|
},
|
|
1309
1310
|
// keep consistent with initialize existing responses
|
|
1310
1311
|
computedValueKey: (
|
|
1311
|
-
field?.intakeField === 'height'
|
|
1312
|
+
field?.intakeField === 'height'
|
|
1312
1313
|
? 'Height'
|
|
1313
1314
|
: field?.intakeField === 'weight' && typeof value === 'number'
|
|
1314
1315
|
? 'Weight'
|
package/src/Forms/inputs.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import axios from "axios"
|
|
|
3
3
|
import { Autocomplete, Box, Button, Checkbox, 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
|
-
import { INSURANCE_RELATIONSHIPS, INSURANCE_RELATIONSHIPS_CANVAS, PRIMARY_HEX, RELATIONSHIP_TYPES, TELLESCOPE_GENDERS } from "@tellescope/constants"
|
|
6
|
+
import { EMOTII_TITLE, INSURANCE_RELATIONSHIPS, INSURANCE_RELATIONSHIPS_CANVAS, PRIMARY_HEX, RELATIONSHIP_TYPES, TELLESCOPE_GENDERS } from "@tellescope/constants"
|
|
7
7
|
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"
|
|
8
8
|
import { Enduser, EnduserRelationship, FormResponseValue, InsuranceRelationship, MultipleChoiceOptions, TellescopeGender } from "@tellescope/types-models"
|
|
9
9
|
import { VALID_STATES, emailValidator, phoneValidator } from "@tellescope/validation"
|
|
@@ -2649,7 +2649,7 @@ export const HeightInput = ({ field, value={} as any, onChange, ...props }: Form
|
|
|
2649
2649
|
</Grid>
|
|
2650
2650
|
<Grid item sx={{ width: '100%' }}>
|
|
2651
2651
|
<TextField fullWidth size="small" label="Inches" type="number"
|
|
2652
|
-
value={value?.inches
|
|
2652
|
+
value={value?.inches ?? ''}
|
|
2653
2653
|
onChange={e => onChange({ ...value, inches: parseInt(e.target.value) }, field.id)}
|
|
2654
2654
|
/>
|
|
2655
2655
|
</Grid>
|
|
@@ -2719,20 +2719,41 @@ export const RedirectInput = ({ groupId, groupInsance, formResponseId, field, su
|
|
|
2719
2719
|
return null
|
|
2720
2720
|
}
|
|
2721
2721
|
|
|
2722
|
-
export const HiddenValueInput = ({ goToNextField, goToPreviousField, field, value, onChange, form,
|
|
2722
|
+
export const HiddenValueInput = ({ goToNextField, goToPreviousField, field, value, onChange, form, isSinglePage, }: FormInputProps<'email'>) => {
|
|
2723
2723
|
let lastRef = useRef(0)
|
|
2724
2724
|
useEffect(() => {
|
|
2725
2725
|
if (lastRef.current > Date.now() - 1000) return
|
|
2726
2726
|
lastRef.current = Date.now()
|
|
2727
2727
|
|
|
2728
2728
|
if (value) {
|
|
2729
|
+
if (isSinglePage) return
|
|
2729
2730
|
onChange('', field.id)
|
|
2730
2731
|
goToPreviousField?.()
|
|
2731
2732
|
} else {
|
|
2732
2733
|
onChange(field.title, field.id)
|
|
2733
2734
|
goToNextField?.()
|
|
2734
2735
|
}
|
|
2735
|
-
}, [value, onChange, field, goToNextField, goToPreviousField])
|
|
2736
|
+
}, [value, onChange, field, goToNextField, goToPreviousField, isSinglePage])
|
|
2736
2737
|
|
|
2737
2738
|
return <></>
|
|
2739
|
+
}
|
|
2740
|
+
|
|
2741
|
+
export const EmotiiInput = ({ goToNextField, goToPreviousField, field, value, onChange, form, formResponseId, ...props }: FormInputProps<'email'>) => {
|
|
2742
|
+
const session = useResolvedSession()
|
|
2743
|
+
const [data, setData] = useState<{ surveyRequestId: string, surveyUrl: string }>()
|
|
2744
|
+
|
|
2745
|
+
useEffect(() => {
|
|
2746
|
+
session.api.integrations
|
|
2747
|
+
.proxy_read({
|
|
2748
|
+
integration: EMOTII_TITLE,
|
|
2749
|
+
type: 'get_survey',
|
|
2750
|
+
query: `${field.id}-${formResponseId || Date.now()}`,
|
|
2751
|
+
})
|
|
2752
|
+
.then(r => setData(r.data))
|
|
2753
|
+
}, [session])
|
|
2754
|
+
|
|
2755
|
+
if (!data) { return <LinearProgress /> }
|
|
2756
|
+
return (
|
|
2757
|
+
<iframe src={data.surveyUrl} style={{ border: 'none', height: 400, width: '100%' }} />
|
|
2758
|
+
)
|
|
2738
2759
|
}
|