@tellescope/react-components 1.171.0 → 1.172.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.map +1 -1
- package/lib/cjs/Forms/forms.js +58 -56
- package/lib/cjs/Forms/forms.js.map +1 -1
- package/lib/cjs/Forms/hooks.d.ts +1 -1
- package/lib/cjs/Forms/hooks.d.ts.map +1 -1
- package/lib/cjs/Forms/hooks.js +2 -2
- package/lib/cjs/Forms/hooks.js.map +1 -1
- package/lib/cjs/Forms/inputs.d.ts +3 -0
- package/lib/cjs/Forms/inputs.d.ts.map +1 -1
- package/lib/cjs/Forms/inputs.js +41 -2
- package/lib/cjs/Forms/inputs.js.map +1 -1
- package/lib/cjs/Forms/types.d.ts +2 -2
- package/lib/cjs/Forms/types.d.ts.map +1 -1
- package/lib/cjs/controls.d.ts +2 -0
- package/lib/cjs/controls.d.ts.map +1 -1
- package/lib/cjs/controls.js.map +1 -1
- package/lib/esm/CMS/components.d.ts +1 -0
- package/lib/esm/CMS/components.d.ts.map +1 -1
- package/lib/esm/Forms/form_responses.d.ts +1 -0
- package/lib/esm/Forms/form_responses.d.ts.map +1 -1
- package/lib/esm/Forms/forms.d.ts +3 -3
- package/lib/esm/Forms/forms.d.ts.map +1 -1
- package/lib/esm/Forms/forms.js +59 -57
- package/lib/esm/Forms/forms.js.map +1 -1
- package/lib/esm/Forms/hooks.d.ts +1 -1
- package/lib/esm/Forms/hooks.d.ts.map +1 -1
- package/lib/esm/Forms/hooks.js +2 -2
- package/lib/esm/Forms/hooks.js.map +1 -1
- package/lib/esm/Forms/inputs.d.ts +4 -1
- package/lib/esm/Forms/inputs.d.ts.map +1 -1
- package/lib/esm/Forms/inputs.js +39 -1
- package/lib/esm/Forms/inputs.js.map +1 -1
- package/lib/esm/Forms/inputs.native.d.ts +1 -0
- package/lib/esm/Forms/inputs.native.d.ts.map +1 -1
- package/lib/esm/Forms/types.d.ts +2 -2
- package/lib/esm/Forms/types.d.ts.map +1 -1
- package/lib/esm/controls.d.ts +4 -2
- package/lib/esm/controls.d.ts.map +1 -1
- package/lib/esm/controls.js.map +1 -1
- package/lib/esm/inputs.d.ts +1 -1
- package/lib/esm/layout.d.ts +1 -1
- package/lib/esm/state.d.ts +264 -264
- package/lib/esm/theme.native.d.ts +1 -0
- package/lib/esm/theme.native.d.ts.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/Forms/forms.tsx +5 -1
- package/src/Forms/hooks.tsx +5 -2
- package/src/Forms/inputs.tsx +52 -2
- package/src/Forms/types.ts +2 -3
- package/src/controls.tsx +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tellescope/react-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.172.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.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",
|
|
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": "
|
|
87
|
+
"gitHead": "b415f876ba14e2e77c7ff8d0265e5667b68c6335",
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
}
|
package/src/Forms/forms.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
|
|
2
2
|
import { Button, CircularProgress, FileBlob, FileUploadHandler, Flex, LinearProgress, LoadingButton, Modal, Paper, Styled, Typography, form_display_text_for_language, useFileUpload, useFormResponses, useSession } from "../index"
|
|
3
3
|
import { useListForFormFields, useOrganizationTheme, useTellescopeForm, WithOrganizationTheme, Response, FileResponse, NextFieldLogicOptions } from "./hooks"
|
|
4
4
|
import { ChangeHandler, FormInputs } from "./types"
|
|
5
|
-
import { AddressInput, AllergiesInput, AppointmentBookingInput, ConditionsInput, DatabaseSelectInput, DateInput, DateStringInput, DropdownInput, EmailInput, EmotiiInput, FileInput, FilesInput, HeightInput, HiddenValueInput, InsuranceInput, LanguageSelect, MedicationsInput, MultipleChoiceInput, NumberInput, PhoneInput, Progress, RankingInput, RatingInput, RedirectInput, RelatedContactsInput, RichTextInput, SignatureInput, StringInput, StringLongInput, StripeInput, TableInput, TimeInput, defaultButtonStyles } from "./inputs"
|
|
5
|
+
import { AddressInput, AllergiesInput, AppointmentBookingInput, ChargeebeeInput, ConditionsInput, DatabaseSelectInput, DateInput, DateStringInput, DropdownInput, EmailInput, EmotiiInput, FileInput, FilesInput, HeightInput, HiddenValueInput, InsuranceInput, LanguageSelect, MedicationsInput, MultipleChoiceInput, NumberInput, PhoneInput, Progress, RankingInput, RatingInput, RedirectInput, RelatedContactsInput, RichTextInput, 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"
|
|
@@ -161,6 +161,7 @@ export const QuestionForField = ({
|
|
|
161
161
|
const Signature = customInputs?.['signature'] ?? SignatureInput
|
|
162
162
|
const MultipleChoice = customInputs?.['multiple_choice'] ?? MultipleChoiceInput
|
|
163
163
|
const Stripe = customInputs?.['Stripe'] ?? StripeInput
|
|
164
|
+
const Chargebee = customInputs?.['Chargebee'] ?? ChargeebeeInput
|
|
164
165
|
const File = customInputs?.['file'] ?? FileInput
|
|
165
166
|
const Files = customInputs?.['files'] ?? FilesInput
|
|
166
167
|
const Ranking = customInputs?.['ranking'] ?? RankingInput
|
|
@@ -287,6 +288,9 @@ export const QuestionForField = ({
|
|
|
287
288
|
: field.type === 'Stripe' ? (
|
|
288
289
|
<Stripe field={field} value={value.answer.value as string} onChange={onFieldChange as ChangeHandler<any>} setCustomerId={setCustomerId} form={form} />
|
|
289
290
|
)
|
|
291
|
+
: field.type === 'Chargebee' ? (
|
|
292
|
+
<Chargebee field={field} value={value.answer.value as any} onChange={onFieldChange as ChangeHandler<'Chargebee'>} setCustomerId={setCustomerId} form={form} />
|
|
293
|
+
)
|
|
290
294
|
: field.type === 'stringLong' ? (
|
|
291
295
|
<StringLong field={field} disabled={value.disabled} value={value.answer.value as string} onChange={onFieldChange as ChangeHandler<'string' | 'stringLong'>} form={form} />
|
|
292
296
|
)
|
package/src/Forms/hooks.tsx
CHANGED
|
@@ -1290,7 +1290,7 @@ export const useTellescopeForm = ({ isPublicForm, form, urlLogicValue, customiza
|
|
|
1290
1290
|
}, [activeField, validateField, uploadingFiles])
|
|
1291
1291
|
|
|
1292
1292
|
const autoAdvanceRef = useRef(false)
|
|
1293
|
-
const goToNextField = useCallback(() => {
|
|
1293
|
+
const goToNextField = useCallback((answer?: FormResponseValue['answer']) => {
|
|
1294
1294
|
if (!currentValue) return
|
|
1295
1295
|
if (isNextDisabled() && currentValue?.answer.type !== 'Hidden Value') return
|
|
1296
1296
|
|
|
@@ -1313,7 +1313,10 @@ export const useTellescopeForm = ({ isPublicForm, form, urlLogicValue, customiza
|
|
|
1313
1313
|
session.api.form_responses.save_field_response({
|
|
1314
1314
|
accessCode,
|
|
1315
1315
|
formResponseId,
|
|
1316
|
-
response:
|
|
1316
|
+
response: {
|
|
1317
|
+
...currentValue,
|
|
1318
|
+
answer: answer || currentValue.answer
|
|
1319
|
+
},
|
|
1317
1320
|
})
|
|
1318
1321
|
.catch(console.error)
|
|
1319
1322
|
}
|
package/src/Forms/inputs.tsx
CHANGED
|
@@ -3073,7 +3073,9 @@ export const HiddenValueInput = ({ goToNextField, goToPreviousField, field, valu
|
|
|
3073
3073
|
goToPreviousField?.()
|
|
3074
3074
|
} else {
|
|
3075
3075
|
onChange(field.title, field.id)
|
|
3076
|
-
goToNextField
|
|
3076
|
+
console.log('going to next field for hidden value', field.title, !!goToNextField)
|
|
3077
|
+
// pass value that is set after above onChange
|
|
3078
|
+
goToNextField?.({ type: 'Hidden Value', value: field.title })
|
|
3077
3079
|
}
|
|
3078
3080
|
}, [value, onChange, field, goToNextField, goToPreviousField, isSinglePage])
|
|
3079
3081
|
|
|
@@ -3310,4 +3312,52 @@ export const ConditionsInput = ({ goToNextField, goToPreviousField, field, value
|
|
|
3310
3312
|
|
|
3311
3313
|
export const RichTextInput = ({ field, value, onChange }: FormInputProps<'Rich Text'>) => (
|
|
3312
3314
|
<WYSIWYG initialHTML={value} onChange={v => onChange(v, field.id)} style={{ width: '100%' }} editorStyle={{ width: '100%' }} />
|
|
3313
|
-
)
|
|
3315
|
+
)
|
|
3316
|
+
|
|
3317
|
+
export const ChargeebeeInput = ({ field, value, onChange, setCustomerId }: FormInputProps<'Chargebee'> & {
|
|
3318
|
+
setCustomerId: React.Dispatch<React.SetStateAction<string | undefined>>,
|
|
3319
|
+
}) => {
|
|
3320
|
+
const session = useResolvedSession()
|
|
3321
|
+
const [url, setUrl] = useState('')
|
|
3322
|
+
const [error, setError] = useState('')
|
|
3323
|
+
|
|
3324
|
+
const [loadCount, setLoadCount] = useState(0)
|
|
3325
|
+
|
|
3326
|
+
const fetchRef = useRef(false)
|
|
3327
|
+
useEffect(() => {
|
|
3328
|
+
if (fetchRef.current) return
|
|
3329
|
+
fetchRef.current = true
|
|
3330
|
+
|
|
3331
|
+
session.api.form_responses.chargebee_details({ fieldId: field.id })
|
|
3332
|
+
.then(({ url }) => setUrl(url))
|
|
3333
|
+
.catch(setError)
|
|
3334
|
+
}, [session])
|
|
3335
|
+
|
|
3336
|
+
const loadAnswerRef = useRef(false)
|
|
3337
|
+
useEffect(() => {
|
|
3338
|
+
if (loadCount !== 2) return
|
|
3339
|
+
if (loadAnswerRef.current) return
|
|
3340
|
+
loadAnswerRef.current = true
|
|
3341
|
+
|
|
3342
|
+
onChange({ url }, field.id)
|
|
3343
|
+
}, [loadCount, url])
|
|
3344
|
+
|
|
3345
|
+
if (error && typeof error === 'string') return <Typography color="error">{error}</Typography>
|
|
3346
|
+
if (!url) return <LinearProgress />
|
|
3347
|
+
if (loadCount === 2) {
|
|
3348
|
+
return (
|
|
3349
|
+
<Grid container alignItems="center" wrap="nowrap">
|
|
3350
|
+
<CheckCircleOutline color="success" />
|
|
3351
|
+
|
|
3352
|
+
<Typography sx={{ ml: 1, fontSize: 20 }}>
|
|
3353
|
+
Your purchase was successful
|
|
3354
|
+
</Typography>
|
|
3355
|
+
</Grid>
|
|
3356
|
+
)
|
|
3357
|
+
}
|
|
3358
|
+
return (
|
|
3359
|
+
<iframe src={url} title="Checkout" style={{ border: 'none', width: '100%', height: 700 }}
|
|
3360
|
+
onLoad={() => setLoadCount(l => l + 1)}
|
|
3361
|
+
/>
|
|
3362
|
+
)
|
|
3363
|
+
}
|
package/src/Forms/types.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { AnswerForType } from "@tellescope/types-models";
|
|
1
|
+
import { AnswerForType, FormResponseValue } from "@tellescope/types-models";
|
|
2
2
|
import { DatabaseRecord, Enduser, Form, FormField } from "@tellescope/types-client";
|
|
3
3
|
import { FileBlob, TreeNode } from "@tellescope/types-utilities";
|
|
4
4
|
import { JSXElementConstructor } from "react";
|
|
5
5
|
import { Response } from "./hooks";
|
|
6
|
-
import { FileUploadHandler } from "../inputs";
|
|
7
6
|
|
|
8
7
|
export type FormFieldNode = TreeNode<FormField>
|
|
9
8
|
|
|
@@ -24,7 +23,7 @@ export interface FormInputProps<K extends keyof AnswerForType> {
|
|
|
24
23
|
enduserId?: string,
|
|
25
24
|
enduser?: Partial<Enduser>
|
|
26
25
|
goToPreviousField?: () => void,
|
|
27
|
-
goToNextField?: () => void,
|
|
26
|
+
goToNextField?: (response?: FormResponseValue['answer']) => void,
|
|
28
27
|
isPreviousDisabled?: () => boolean,
|
|
29
28
|
formResponseId?: string,
|
|
30
29
|
rootResponseId?: string,
|
package/src/controls.tsx
CHANGED
|
@@ -206,6 +206,8 @@ interface DownloadButton {
|
|
|
206
206
|
Icon?: typeof DownloadIcon
|
|
207
207
|
label?: string,
|
|
208
208
|
preferInBrowser?: boolean,
|
|
209
|
+
offsetX?: number,
|
|
210
|
+
offsetY?: number,
|
|
209
211
|
}
|
|
210
212
|
|
|
211
213
|
export const DownloadFileIconButton = ({ preferInBrowser, publicURL, secureName, label="Download File", Icon=DownloadIcon, onDownload, onError, ...props }: DownloadButton) => {
|