@tellescope/react-components 1.230.2 → 1.232.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 (50) hide show
  1. package/lib/cjs/Forms/forms.js +2 -2
  2. package/lib/cjs/Forms/forms.js.map +1 -1
  3. package/lib/cjs/Forms/forms.v2.js +4 -4
  4. package/lib/cjs/Forms/forms.v2.js.map +1 -1
  5. package/lib/cjs/Forms/hooks.d.ts +111 -3
  6. package/lib/cjs/Forms/hooks.d.ts.map +1 -1
  7. package/lib/cjs/Forms/hooks.js +30 -38
  8. package/lib/cjs/Forms/hooks.js.map +1 -1
  9. package/lib/cjs/Forms/inputs.d.ts +2 -2
  10. package/lib/cjs/Forms/inputs.d.ts.map +1 -1
  11. package/lib/cjs/Forms/inputs.js +71 -18
  12. package/lib/cjs/Forms/inputs.js.map +1 -1
  13. package/lib/cjs/Forms/inputs.v2.d.ts +2 -4
  14. package/lib/cjs/Forms/inputs.v2.d.ts.map +1 -1
  15. package/lib/cjs/Forms/inputs.v2.js +13 -242
  16. package/lib/cjs/Forms/inputs.v2.js.map +1 -1
  17. package/lib/esm/CMS/components.d.ts +1 -0
  18. package/lib/esm/CMS/components.d.ts.map +1 -1
  19. package/lib/esm/Forms/form_responses.d.ts +1 -0
  20. package/lib/esm/Forms/form_responses.d.ts.map +1 -1
  21. package/lib/esm/Forms/forms.d.ts +3 -3
  22. package/lib/esm/Forms/forms.js +2 -2
  23. package/lib/esm/Forms/forms.js.map +1 -1
  24. package/lib/esm/Forms/forms.v2.d.ts +3 -3
  25. package/lib/esm/Forms/forms.v2.js +4 -4
  26. package/lib/esm/Forms/forms.v2.js.map +1 -1
  27. package/lib/esm/Forms/hooks.d.ts +112 -3
  28. package/lib/esm/Forms/hooks.d.ts.map +1 -1
  29. package/lib/esm/Forms/hooks.js +31 -39
  30. package/lib/esm/Forms/hooks.js.map +1 -1
  31. package/lib/esm/Forms/inputs.d.ts +3 -3
  32. package/lib/esm/Forms/inputs.d.ts.map +1 -1
  33. package/lib/esm/Forms/inputs.js +72 -19
  34. package/lib/esm/Forms/inputs.js.map +1 -1
  35. package/lib/esm/Forms/inputs.v2.d.ts +3 -5
  36. package/lib/esm/Forms/inputs.v2.d.ts.map +1 -1
  37. package/lib/esm/Forms/inputs.v2.js +15 -244
  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/inputs.native.d.ts +1 -0
  42. package/lib/esm/inputs.native.d.ts.map +1 -1
  43. package/lib/esm/state.d.ts +315 -315
  44. package/lib/tsconfig.tsbuildinfo +1 -1
  45. package/package.json +9 -9
  46. package/src/Forms/forms.tsx +2 -2
  47. package/src/Forms/forms.v2.tsx +12 -12
  48. package/src/Forms/hooks.tsx +49 -62
  49. package/src/Forms/inputs.tsx +73 -6
  50. package/src/Forms/inputs.v2.tsx +23 -404
@@ -20,7 +20,7 @@ export declare const RatingInput: ({ field, value, onChange }: FormInputProps<'r
20
20
  export declare const RankingInput: ({ field, value, onChange }: FormInputProps<'ranking'>) => JSX.Element;
21
21
  export declare const DateInput: ({ field, value, onChange, placement, ...props }: {
22
22
  field: FormField;
23
- placement?: "left" | "right" | "bottom" | "top" | undefined;
23
+ placement?: "bottom" | "left" | "right" | "top" | undefined;
24
24
  } & FormInputProps<"date"> & Styled) => JSX.Element;
25
25
  export declare const TableInput: ({ field, value, onChange, ...props }: FormInputProps<'Input Table'>) => JSX.Element;
26
26
  export declare const AutoFocusTextField: (props: TextFieldProps) => JSX.Element;
@@ -45,9 +45,7 @@ export declare const FilesInput: ({ value, onChange, field, existingFileName, up
45
45
  existingFileName?: string | undefined;
46
46
  }) => JSX.Element;
47
47
  export declare const MultipleChoiceInput: ({ field, form, value: _value, onChange }: FormInputProps<'multiple_choice'>) => JSX.Element;
48
- export declare const StripeInput: ({ field, value, onChange, setCustomerId, enduserId }: FormInputProps<"Stripe"> & {
49
- setCustomerId: React.Dispatch<React.SetStateAction<string | undefined>>;
50
- }) => JSX.Element;
48
+ export { StripeInput } from './inputs';
51
49
  export declare const Progress: ({ numerator, denominator, style, color }: {
52
50
  numerator: number;
53
51
  denominator: number;
@@ -66,7 +64,7 @@ export declare const CanvasMedicationsInput: ({ field, value, onChange }: FormIn
66
64
  export declare const MedicationsInput: ({ field, value, onChange, ...props }: FormInputProps<'Medications'>) => JSX.Element;
67
65
  export declare const BelugaPatientPreferenceInput: ({ field, value: _value, onChange }: FormInputProps<'Beluga Patient Preference'>) => JSX.Element;
68
66
  export declare const contact_is_valid: (e: Partial<Enduser>) => "Email is invalid" | "Phone is invalid" | "Date of birth should be MM-DD-YYYY" | undefined;
69
- export declare const RelatedContactsInput: ({ field, value: _value, onChange, ...props }: FormInputProps<'Related Contacts'>) => JSX.Element;
67
+ export declare const RelatedContactsInput: ({ field, value: _value, onChange, error: parentError, ...props }: FormInputProps<'Related Contacts'>) => JSX.Element;
70
68
  export declare const AppointmentBookingInput: ({ formResponseId, field, value, onChange, form, responses, goToPreviousField, isPreviousDisabled, enduserId, ...props }: FormInputProps<'Appointment Booking'>) => JSX.Element;
71
69
  export declare const HeightInput: ({ field, value, onChange, ...props }: FormInputProps<'Height'>) => JSX.Element;
72
70
  export declare const include_current_url_parameters_if_templated: (url: string) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"inputs.v2.d.ts","sourceRoot":"","sources":["../../../src/Forms/inputs.v2.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwE,MAAM,OAAO,CAAA;AAE5F,OAAO,EAA8L,OAAO,EAAa,cAAc,EAAc,MAAM,eAAe,CAAA;AAC1Q,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAIxC,OAAO,EAAmC,OAAO,EAAuB,iBAAiB,EAA6H,MAAM,0BAA0B,CAAA;AAOtP,OAAO,EAAc,QAAQ,EAAgD,MAAM,EAAiF,MAAM,IAAI,CAAA;AAC9K,OAAO,EAAiB,cA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AED,eAAO,MAAM,WAAW,iGAAkG,eAAe,OAAO,CAAC,gBA8ChJ,CAAA;AAMD,eAAO,MAAM,cAAc,iGAAkG,eAAe,WAAW,CAAC,gBAqHvJ,CAAA;AAGD,eAAO,MAAM,eAAe,iGAAkG,eAAe,YAAY,CAAC,gBAsDzJ,CAAA;AAED,eAAO,MAAM,aAAa,+BAAgC,eAAe,WAAW,CAAC,gBAEpF,CAAA;AAED,eAAO,MAAM,eAAe;mBACX,MAAM,QAAQ,CAAC,MAAM,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;iBA6CxE,CAAA"}
@@ -72,10 +72,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
72
72
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
73
73
  import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
74
74
  import axios from "axios";
75
- import { Autocomplete, Box, Button, Checkbox, Chip, Collapse, Divider, FormControl, FormControlLabel, Grid, IconButton as MuiIconButton, InputLabel, MenuItem, Radio, RadioGroup, Select, TextField, Typography } from "@mui/material";
75
+ import { Autocomplete, Box, Button, Checkbox, Chip, Divider, FormControl, Grid, InputLabel, MenuItem, RadioGroup, Select, TextField, Typography } from "@mui/material";
76
76
  import { useDropzone } from "react-dropzone";
77
77
  import { CANVAS_TITLE, EMOTII_TITLE, INSURANCE_RELATIONSHIPS, INSURANCE_RELATIONSHIPS_CANVAS, PRIMARY_HEX, RELATIONSHIP_TYPES, TELLESCOPE_GENDERS } from "@tellescope/constants";
78
- import { MM_DD_YYYY_to_YYYY_MM_DD, capture_is_supported, downloadFile, emit_gtm_event, first_letter_capitalized, form_response_value_to_string, format_stripe_subscription_interval, getLocalTimezone, getPublicFileURL, mm_dd_yyyy, replace_enduser_template_values, truncate_string, update_local_storage, user_display_name } from "@tellescope/utilities";
78
+ import { MM_DD_YYYY_to_YYYY_MM_DD, capture_is_supported, downloadFile, emit_gtm_event, first_letter_capitalized, form_response_value_to_string, getLocalTimezone, getPublicFileURL, mm_dd_yyyy, replace_enduser_template_values, truncate_string, update_local_storage, user_display_name } from "@tellescope/utilities";
79
79
  import { TIMEZONES_USA } from "@tellescope/types-models";
80
80
  import { VALID_STATES, emailValidator, phoneValidator } from "@tellescope/validation";
81
81
  import Slider from '@mui/material/Slider';
@@ -89,9 +89,7 @@ import DragIndicatorIcon from '@mui/icons-material/DragIndicator';
89
89
  import heic2any from "heic2any";
90
90
  import AddPhotoAlternateIcon from '@mui/icons-material/AddPhotoAlternate';
91
91
  import LanguageIcon from '@mui/icons-material/Language';
92
- import { Elements, PaymentElement, useStripe, useElements, EmbeddedCheckout, EmbeddedCheckoutProvider } from '@stripe/react-stripe-js';
93
- import { loadStripe } from '@stripe/stripe-js';
94
- import { CheckCircleOutline, Delete, Edit, ExpandMore, UploadFile } from "@mui/icons-material";
92
+ import { CheckCircleOutline, Delete, Edit, UploadFile } from "@mui/icons-material";
95
93
  import { WYSIWYG } from "./wysiwyg";
96
94
  export var LanguageSelect = function (_a) {
97
95
  var value = _a.value, props = __rest(_a, ["value"]);
@@ -741,7 +739,6 @@ export var MultipleChoiceInput = function (_a) {
741
739
  var field = _a.field, form = _a.form, _value = _a.value, onChange = _a.onChange;
742
740
  var value = typeof _value === 'string' ? [_value] : _value; // if loading existingResponses, allows them to be a string
743
741
  var _f = field.options, choices = _f.choices, radio = _f.radio, other = _f.other, optionDetails = _f.optionDetails;
744
- var _g = useState({}), expandedDescriptions = _g[0], setExpandedDescriptions = _g[1];
745
742
  // current other string
746
743
  var enteringOtherStringRef = React.useRef(''); // if typing otherString as prefix of a checkbox value, don't auto-select
747
744
  var otherString = (_b = value === null || value === void 0 ? void 0 : value.find(function (v) { var _a; return v === enteringOtherStringRef.current || !((_a = (choices !== null && choices !== void 0 ? choices : [])) === null || _a === void 0 ? void 0 : _a.find(function (c) { return c === v; })); })) !== null && _b !== void 0 ? _b : '';
@@ -751,19 +748,12 @@ export var MultipleChoiceInput = function (_a) {
751
748
  var _a;
752
749
  return (_a = optionDetails === null || optionDetails === void 0 ? void 0 : optionDetails.find(function (detail) { return detail.option === choice; })) === null || _a === void 0 ? void 0 : _a.description;
753
750
  }, [optionDetails]);
754
- var toggleDescription = useCallback(function (index) {
755
- setExpandedDescriptions(function (prev) {
756
- var _a;
757
- return (__assign(__assign({}, prev), (_a = {}, _a[index] = !prev[index], _a)));
758
- });
759
- }, []);
760
751
  return (_jsxs(Grid, __assign({ container: true, alignItems: "center", rowGap: 1.5 }, { children: [radio
761
752
  ? (_jsx(FormControl, __assign({ fullWidth: true }, { children: _jsx(RadioGroup, __assign({ "aria-labelledby": "radio-group-".concat(field.id, "-label"), defaultValue: "female", name: "radio-group-".concat(field.id) }, { children: (choices !== null && choices !== void 0 ? choices : []).map(function (c, i) {
762
753
  var description = getDescriptionForChoice(c);
763
754
  var hasDescription = !!description;
764
- var isExpanded = expandedDescriptions[i];
765
755
  var isSelected = !!(value === null || value === void 0 ? void 0 : value.includes(c)) && c !== otherString;
766
- return (_jsxs(Box, __assign({ sx: { width: '100%' } }, { children: [_jsxs(Box, __assign({ sx: {
756
+ return (_jsxs(Box, __assign({ sx: { width: '100%' } }, { children: [_jsx(Box, __assign({ sx: {
767
757
  display: 'flex',
768
758
  alignItems: 'center',
769
759
  width: '100%',
@@ -771,25 +761,17 @@ export var MultipleChoiceInput = function (_a) {
771
761
  borderColor: 'primary.main',
772
762
  borderRadius: 1,
773
763
  padding: '16px 16px',
774
- marginBottom: '12px',
764
+ marginBottom: hasDescription ? '8px' : '12px',
775
765
  cursor: 'pointer',
776
766
  backgroundColor: 'transparent',
777
767
  boxSizing: 'border-box',
778
768
  '&:hover': {
779
769
  backgroundColor: function (theme) { return "".concat(theme.palette.primary.main, "14"); },
780
770
  },
781
- }, onClick: function () { return onChange((value === null || value === void 0 ? void 0 : value.includes(c)) ? [] : [c], field.id); } }, { children: [_jsx(Typography, __assign({ component: "span", sx: { flex: 1, color: 'primary.main', fontSize: 13, fontWeight: 600 } }, { children: c })), hasDescription && (_jsx(MuiIconButton, __assign({ className: "expand-button", size: "small", onClick: function (e) {
782
- e.stopPropagation();
783
- toggleDescription(i);
784
- }, sx: {
785
- transform: isExpanded ? 'rotate(180deg)' : 'rotate(0deg)',
786
- transition: 'transform 0.2s',
787
- ml: 1
788
- } }, { children: _jsx(ExpandMore, { fontSize: "small" }) })))] })), hasDescription && (_jsx(Collapse, __assign({ in: isExpanded }, { children: _jsx(Box, __assign({ sx: { pl: 2, pr: 2, pb: 1, pt: 1 } }, { children: _jsx(Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: description })) })) })))] }), i));
771
+ }, onClick: function () { return onChange((value === null || value === void 0 ? void 0 : value.includes(c)) ? [] : [c], field.id); } }, { children: _jsx(Typography, __assign({ component: "span", sx: { flex: 1, color: 'primary.main', fontSize: 13, fontWeight: 600 } }, { children: c })) })), hasDescription && (_jsx(Box, __assign({ sx: { pl: 2, pr: 2, pb: 1, mb: 1 } }, { children: _jsx(Typography, __assign({ style: { fontSize: 14, color: '#00000099' } }, { children: description })) })))] }), i));
789
772
  }) })) }))) : ((choices !== null && choices !== void 0 ? choices : []).map(function (c, i) {
790
773
  var description = getDescriptionForChoice(c);
791
774
  var hasDescription = !!description;
792
- var isExpanded = expandedDescriptions[i];
793
775
  return (_jsx(Grid, __assign({ xs: 12 }, { children: _jsxs(Box, __assign({ sx: { width: '100%' } }, { children: [_jsxs(Box, __assign({ sx: {
794
776
  display: 'flex',
795
777
  alignItems: 'center',
@@ -798,10 +780,6 @@ export var MultipleChoiceInput = function (_a) {
798
780
  boxSizing: 'border-box'
799
781
  }, onClick: function (e) {
800
782
  var _a, _b, _d, _e;
801
- // Don't trigger selection if clicking on the expand button
802
- if (e.target.closest('.expand-button')) {
803
- return;
804
- }
805
783
  onChange(((value === null || value === void 0 ? void 0 : value.includes(c))
806
784
  ? ((radio || ((_b = (_a = field.options) === null || _a === void 0 ? void 0 : _a.radioChoices) === null || _b === void 0 ? void 0 : _b.includes(c)))
807
785
  ? []
@@ -809,14 +787,7 @@ export var MultipleChoiceInput = function (_a) {
809
787
  : ((radio || ((_e = (_d = field.options) === null || _d === void 0 ? void 0 : _d.radioChoices) === null || _e === void 0 ? void 0 : _e.includes(c)))
810
788
  ? [c]
811
789
  : __spreadArray(__spreadArray([], (value !== null && value !== void 0 ? value : []).filter(function (x) { var _a, _b; return !((_b = (_a = field.options) === null || _a === void 0 ? void 0 : _a.radioChoices) === null || _b === void 0 ? void 0 : _b.includes(x)); }), true), [c], false))), field.id);
812
- } }, { children: [_jsx(Checkbox, { color: "primary", checked: !!(value === null || value === void 0 ? void 0 : value.includes(c)) && c !== otherString, inputProps: { 'aria-label': 'primary checkbox' } }), _jsx(Typography, __assign({ component: "span", sx: { flex: 1 } }, { children: c })), hasDescription && (_jsx(MuiIconButton, __assign({ className: "expand-button", size: "small", onClick: function (e) {
813
- e.stopPropagation();
814
- toggleDescription(i);
815
- }, sx: {
816
- transform: isExpanded ? 'rotate(180deg)' : 'rotate(0deg)',
817
- transition: 'transform 0.2s',
818
- ml: 1
819
- } }, { children: _jsx(ExpandMore, { fontSize: "small" }) })))] })), hasDescription && (_jsx(Collapse, __assign({ in: isExpanded }, { children: _jsx(Box, __assign({ sx: { pl: '42px', pr: 2, pb: 1 } }, { children: _jsx(Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: description })) })) })))] })) }), i));
790
+ } }, { children: [_jsx(Checkbox, { color: "primary", checked: !!(value === null || value === void 0 ? void 0 : value.includes(c)) && c !== otherString, inputProps: { 'aria-label': 'primary checkbox' } }), _jsx(Typography, __assign({ component: "span", sx: { flex: 1 } }, { children: c }))] })), hasDescription && (_jsx(Box, __assign({ sx: { pl: '42px', pr: 2, pb: 1 } }, { children: _jsx(Typography, __assign({ style: { fontSize: 14, color: '#00000099' } }, { children: description })) })))] })) }), i));
820
791
  })), other &&
821
792
  _jsx(Grid, __assign({ item: true, xs: 12 }, { children: _jsx(TextField // className={classes.textField}
822
793
  , { InputProps: { sx: { borderRadius: 2.5 } }, sx: { width: radio ? "calc(100% - 15px)" : '100%' }, size: "small", "aria-label": form_display_text_for_language(form, "Other"), value: otherString, placeholder: form_display_text_for_language(form, "Other"), variant: "outlined",
@@ -832,211 +803,11 @@ export var MultipleChoiceInput = function (_a) {
832
803
  ? __spreadArray(__spreadArray([], (value !== null && value !== void 0 ? value : []).filter(function (v) { return v !== otherString; }), true), [e.target.value], false) : value === null || value === void 0 ? void 0 : value.filter(function (v) { return v !== otherString; }))), field.id);
833
804
  } }) }))] })));
834
805
  };
835
- export var StripeInput = function (_a) {
836
- var _b, _d;
837
- var field = _a.field, value = _a.value, onChange = _a.onChange, setCustomerId = _a.setCustomerId, enduserId = _a.enduserId;
838
- var session = useResolvedSession();
839
- var _e = useState(''), clientSecret = _e[0], setClientSecret = _e[1];
840
- var _f = useState(''), businessName = _f[0], setBusinessName = _f[1];
841
- var _g = useState(false), isCheckout = _g[0], setIsCheckout = _g[1];
842
- var _h = useState(), stripePromise = _h[0], setStripePromise = _h[1];
843
- var _j = useState(''), answertext = _j[0], setAnswertext = _j[1];
844
- var _k = useState(''), error = _k[0], setError = _k[1];
845
- var _l = useState([]), selectedProducts = _l[0], setSelectedProducts = _l[1];
846
- var _m = useState(false), showProductSelection = _m[0], setShowProductSelection = _m[1];
847
- var _o = useState([]), availableProducts = _o[0], setAvailableProducts = _o[1];
848
- var _p = useState(false), loadingProducts = _p[0], setLoadingProducts = _p[1];
849
- var fetchRef = useRef(false);
850
- useEffect(function () {
851
- var _a, _b, _d;
852
- if (fetchRef.current)
853
- return;
854
- if (value && ((_a = session.userInfo) === null || _a === void 0 ? void 0 : _a.stripeCustomerId)) {
855
- return setCustomerId(function (c) { var _a; return c ? c : (_a = session.userInfo) === null || _a === void 0 ? void 0 : _a.stripeCustomerId; }); // already paid or saved card
856
- }
857
- // Check if product selection mode is enabled
858
- if (((_b = field.options) === null || _b === void 0 ? void 0 : _b.stripeProductSelectionMode) && (((_d = field.options) === null || _d === void 0 ? void 0 : _d.productIds) || []).length > 1) {
859
- setShowProductSelection(true);
860
- setLoadingProducts(true);
861
- // Fetch product data with real-time Stripe pricing via proxy_read
862
- var productIds = (field.options.productIds || []).join(',');
863
- session.api.integrations.proxy_read({
864
- integration: 'Stripe',
865
- type: 'product-prices',
866
- id: productIds,
867
- query: field.options.stripeKey
868
- })
869
- .then(function (_a) {
870
- var data = _a.data;
871
- setAvailableProducts(data.products || []);
872
- setLoadingProducts(false);
873
- })
874
- .catch(function (e) {
875
- var _a, _b;
876
- console.error('Error loading product data:', e);
877
- var errorMessage = ((_b = (_a = e === null || e === void 0 ? void 0 : e.message) === null || _a === void 0 ? void 0 : _a.includes) === null || _b === void 0 ? void 0 : _b.call(_a, 'Stripe pricing error:'))
878
- ? e.message.replace('Stripe pricing error: ', '')
879
- : 'Failed to load product information from Stripe';
880
- setError("Product configuration error: ".concat(errorMessage));
881
- setLoadingProducts(false);
882
- });
883
- return;
884
- }
885
- fetchRef.current = true;
886
- session.api.form_responses.stripe_details({ fieldId: field.id, enduserId: enduserId })
887
- .then(function (_a) {
888
- var clientSecret = _a.clientSecret, publishableKey = _a.publishableKey, stripeAccount = _a.stripeAccount, businessName = _a.businessName, customerId = _a.customerId, isCheckout = _a.isCheckout, answerText = _a.answerText;
889
- setAnswertext(answerText || '');
890
- setIsCheckout(!!isCheckout);
891
- setClientSecret(clientSecret);
892
- setStripePromise(loadStripe(publishableKey, { stripeAccount: stripeAccount }));
893
- setBusinessName(businessName);
894
- setCustomerId(customerId);
895
- })
896
- .catch(function (e) {
897
- console.error(e);
898
- if (typeof (e === null || e === void 0 ? void 0 : e.message) === 'string') {
899
- setError(e.message);
900
- }
901
- });
902
- }, [session, value, field.id, enduserId]);
903
- var cost = (showProductSelection
904
- ? selectedProducts.reduce(function (total, productId) {
905
- var _a;
906
- var product = availableProducts.find(function (p) { return p._id === productId; });
907
- if (product === null || product === void 0 ? void 0 : product.currentPrice) {
908
- return total + (product.currentPrice.amount || 0);
909
- }
910
- return total + (((_a = product === null || product === void 0 ? void 0 : product.cost) === null || _a === void 0 ? void 0 : _a.amount) || 0);
911
- }, 0)
912
- : 0 // Will be calculated by existing Stripe flow when not in selection mode
913
- );
914
- // Handle product selection step
915
- if (showProductSelection) {
916
- if (error) {
917
- return (_jsxs(Grid, __assign({ container: true, direction: "column", spacing: 2, alignItems: "center" }, { children: [_jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ color: "error", variant: "h6" }, { children: "Product Configuration Error" })) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ color: "error", sx: { textAlign: 'center' } }, { children: error })) }))] })));
918
- }
919
- if (loadingProducts) {
920
- return (_jsxs(Grid, __assign({ container: true, direction: "column", spacing: 2, alignItems: "center" }, { children: [_jsx(Grid, __assign({ item: true }, { children: _jsx(LinearProgress, {}) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, { children: "Loading product information..." }) }))] })));
921
- }
922
- var isSingleSelection_1 = ((_b = field.options) === null || _b === void 0 ? void 0 : _b.radio) === true;
923
- var handleProductSelection_1 = function (productId) {
924
- if (isSingleSelection_1) {
925
- setSelectedProducts([productId]);
926
- }
927
- else {
928
- setSelectedProducts(function (prev) {
929
- return prev.includes(productId)
930
- ? prev.filter(function (id) { return id !== productId; })
931
- : __spreadArray(__spreadArray([], prev, true), [productId], false);
932
- });
933
- }
934
- };
935
- var handleContinueToPayment = function () {
936
- if (selectedProducts.length === 0)
937
- return;
938
- setShowProductSelection(false);
939
- fetchRef.current = true;
940
- // Now fetch Stripe details with selected products
941
- session.api.form_responses.stripe_details(__assign({ fieldId: field.id, enduserId: enduserId }, (selectedProducts.length > 0 && { selectedProductIds: selectedProducts }) // Pass selected products to Stripe checkout
942
- ))
943
- .then(function (_a) {
944
- var clientSecret = _a.clientSecret, publishableKey = _a.publishableKey, stripeAccount = _a.stripeAccount, businessName = _a.businessName, customerId = _a.customerId, isCheckout = _a.isCheckout, answerText = _a.answerText;
945
- setAnswertext(answerText || '');
946
- setIsCheckout(!!isCheckout);
947
- setClientSecret(clientSecret);
948
- setStripePromise(loadStripe(publishableKey, { stripeAccount: stripeAccount }));
949
- setBusinessName(businessName);
950
- setCustomerId(customerId);
951
- })
952
- .catch(function (e) {
953
- console.error(e);
954
- if (typeof (e === null || e === void 0 ? void 0 : e.message) === 'string') {
955
- setError(e.message);
956
- }
957
- });
958
- };
959
- return (_jsxs(Grid, __assign({ container: true, direction: "column", spacing: 2 }, { children: [_jsx(Grid, __assign({ item: true }, { children: _jsxs(Typography, __assign({ variant: "h6" }, { children: ["Select Product", isSingleSelection_1 ? '' : 's'] })) })), availableProducts.map(function (product) {
960
- var _a, _b, _d;
961
- // Use real-time Stripe pricing if available, fallback to Tellescope pricing
962
- var price = product.currentPrice || product.cost;
963
- var priceAmount = (price === null || price === void 0 ? void 0 : price.amount) || 0;
964
- var priceCurrency = (price === null || price === void 0 ? void 0 : price.currency) || 'USD';
965
- return (_jsx(Grid, __assign({ item: true }, { children: _jsx(FormControlLabel, { control: isSingleSelection_1 ? (_jsx(Radio, { checked: selectedProducts.includes(product._id), onChange: function () { return handleProductSelection_1(product._id); } })) : (_jsx(Checkbox, { checked: selectedProducts.includes(product._id), onChange: function () { return handleProductSelection_1(product._id); } })), label: _jsxs(Box, { children: [_jsx(Typography, __assign({ variant: "body1", fontWeight: "bold" }, { children: product.title })), product.description && (_jsx(Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: product.description }))), _jsxs(Typography, __assign({ variant: "body2", color: "primary" }, { children: ["$", (priceAmount / 100).toFixed(2), " ", priceCurrency.toUpperCase(), ((_a = product.currentPrice) === null || _a === void 0 ? void 0 : _a.isSubscription) && (_jsx(Typography, __assign({ component: "span", variant: "caption", sx: { ml: 0.5 } }, { children: format_stripe_subscription_interval((_b = product.currentPrice) === null || _b === void 0 ? void 0 : _b.interval, (_d = product.currentPrice) === null || _d === void 0 ? void 0 : _d.interval_count) })))] }))] }) }) }), product._id));
966
- }), _jsx(Grid, __assign({ item: true }, { children: _jsx(Button, __assign({ variant: "contained", onClick: handleContinueToPayment, disabled: selectedProducts.length === 0, sx: { mt: 2 } }, { children: "Continue to Payment" })) }))] })));
967
- }
968
- if (error) {
969
- return (_jsx(Typography, __assign({ color: "error" }, { children: error })));
970
- }
971
- if (value) {
972
- return (_jsxs(Grid, __assign({ container: true, alignItems: "center", wrap: "nowrap" }, { children: [_jsx(CheckCircleOutline, { color: "success" }), _jsx(Typography, __assign({ sx: { ml: 1, fontSize: 20 } }, { children: ((_d = field.options) === null || _d === void 0 ? void 0 : _d.chargeImmediately) ? 'Your purchase was successful' : "Your payment details have been saved!" }))] })));
973
- }
974
- if (!(clientSecret && stripePromise))
975
- return _jsx(LinearProgress, {});
976
- if (isCheckout && stripePromise)
977
- return (_jsx(EmbeddedCheckoutProvider, __assign({ stripe: stripePromise, options: {
978
- clientSecret: clientSecret,
979
- onComplete: function () { return onChange(answertext || 'Completed checkout', field.id); },
980
- } }, { children: _jsx(EmbeddedCheckout, {}) })));
981
- return (_jsx(Elements, __assign({ stripe: stripePromise, options: {
982
- clientSecret: clientSecret,
983
- } }, { children: _jsx(StripeForm, { businessName: businessName, onSuccess: function () { return onChange(answertext || 'Saved card details', field.id); }, cost: cost, field: field }) })));
984
- };
985
- var StripeForm = function (_a) {
986
- var _b, _d, _e;
987
- var businessName = _a.businessName, onSuccess = _a.onSuccess, field = _a.field, cost = _a.cost;
988
- var stripe = useStripe();
989
- var elements = useElements();
990
- var _f = useState(false), ready = _f[0], setReady = _f[1];
991
- var _g = useState(''), errorMessage = _g[0], setErrorMessage = _g[1];
992
- var handleSubmit = function (event) { return __awaiter(void 0, void 0, void 0, function () {
993
- var error;
994
- var _a, _b;
995
- return __generator(this, function (_d) {
996
- switch (_d.label) {
997
- case 0:
998
- // We don't want to let default form submission happen here,
999
- // which would refresh the page.
1000
- event === null || event === void 0 ? void 0 : event.preventDefault();
1001
- if (!stripe || !elements) {
1002
- // Stripe.js hasn't yet loaded.
1003
- // Make sure to disable form submission until Stripe.js has loaded.
1004
- return [2 /*return*/, null];
1005
- }
1006
- return [4 /*yield*/, (((_a = field.options) === null || _a === void 0 ? void 0 : _a.chargeImmediately) ? stripe.confirmPayment : stripe.confirmSetup)({
1007
- //`Elements` instance that was used to create the Payment Element
1008
- elements: elements,
1009
- confirmParams: {
1010
- return_url: window.location.href,
1011
- },
1012
- redirect: 'if_required', // ensures the redirect url won't be used, unless the Bank redirect payment type is enabled (it's not, just card)
1013
- })];
1014
- case 1:
1015
- error = (_d.sent()).error;
1016
- if (error) {
1017
- // This point will only be reached if there is an immediate error when
1018
- // confirming the payment. Show error to your customer (for example, payment
1019
- // details incomplete)
1020
- setErrorMessage((_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : '');
1021
- }
1022
- else {
1023
- onSuccess();
1024
- // Your customer will be redirected to your `return_url`. For some payment
1025
- // methods like iDEAL, your customer will be redirected to an intermediate
1026
- // site first to authorize the payment, then redirected to the `return_url`.
1027
- }
1028
- return [2 /*return*/];
1029
- }
1030
- });
1031
- }); };
1032
- return (_jsxs("form", __assign({ onSubmit: handleSubmit }, { children: [_jsx(PaymentElement, { onReady: function () { return setReady(true); }, options: {
1033
- business: { name: businessName },
1034
- } }), _jsx(Button, __assign({ variant: "contained", color: "primary", type: "submit", sx: { mt: 1 }, disabled: !(stripe && ready) }, { children: ((_b = field.options) === null || _b === void 0 ? void 0 : _b.chargeImmediately) ? 'Make Payment' : 'Save Payment Details' })), cost > 0 &&
1035
- _jsx(Typography, __assign({ sx: { mt: 0.5 } }, { children: ((_d = field.options) === null || _d === void 0 ? void 0 : _d.customPriceMessage)
1036
- ? field.options.customPriceMessage.replaceAll('{{PRICE}}', "$".concat((cost / 100).toFixed(2)))
1037
- : "You will be charged $".concat((cost / 100).toFixed(2), " ").concat(((_e = field.options) === null || _e === void 0 ? void 0 : _e.chargeImmediately) ? '' : 'on form submission') })), errorMessage &&
1038
- _jsx(Typography, __assign({ color: "error", sx: { mt: 0.5 } }, { children: errorMessage }))] })));
1039
- };
806
+ // StripeInput is shared between v1 and v2 forms
807
+ // Both versions use the same implementation from inputs.tsx to ensure consistent behavior
808
+ // and avoid code duplication. Re-exporting here maintains the pattern where forms.v2.tsx
809
+ // only imports from inputs.v2.tsx
810
+ export { StripeInput } from './inputs';
1040
811
  export var Progress = function (_a) {
1041
812
  var numerator = _a.numerator, denominator = _a.denominator, style = _a.style, color = _a.color;
1042
813
  return (_jsx(Box, __assign({ sx: __assign({ display: 'flex', alignItems: 'center' }, style) }, { children: _jsx(Box, __assign({ sx: { width: '100%' } }, { children: _jsx(LinearProgress, { variant: "determinate", value: (numerator / (denominator || 1)) * 100, sx: color ? {
@@ -1690,7 +1461,7 @@ export var contact_is_valid = function (e) {
1690
1461
  };
1691
1462
  export var RelatedContactsInput = function (_a) {
1692
1463
  var _b, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _w, _x;
1693
- var field = _a.field, _value = _a.value, onChange = _a.onChange, props = __rest(_a, ["field", "value", "onChange"]);
1464
+ var field = _a.field, _value = _a.value, onChange = _a.onChange, parentError = _a.error, props = __rest(_a, ["field", "value", "onChange", "error"]);
1694
1465
  // safeguard against any rogue values like empty string
1695
1466
  var value = Array.isArray(_value) ? _value : [];
1696
1467
  var _y = useState(value.length === 1 ? 0 : -1), editing = _y[0], setEditing = _y[1];
@@ -1709,7 +1480,7 @@ export var RelatedContactsInput = function (_a) {
1709
1480
  _jsx(Grid, __assign({ item: true, xs: 4 }, { children: _jsx(TextField, { label: "Last Name", size: "small", fullWidth: true, InputProps: defaultInputProps, value: lname, onChange: function (e) { return onChange(value.map(function (v, i) { return i === editing ? __assign(__assign({}, v), { lname: e.target.value }) : v; }), field.id); } }) })), _jsx(Grid, __assign({ item: true, xs: 4 }, { children: _jsx(StringSelector, { options: ((_j = (_h = field.options) === null || _h === void 0 ? void 0 : _h.relatedContactTypes) === null || _j === void 0 ? void 0 : _j.length) ? field.options.relatedContactTypes : RELATIONSHIP_TYPES, label: "Relationship", size: "small", disabled: ((_l = (_k = field === null || field === void 0 ? void 0 : field.options) === null || _k === void 0 ? void 0 : _k.relatedContactTypes) === null || _l === void 0 ? void 0 : _l.length) === 1, value: (_o = (_m = relationships === null || relationships === void 0 ? void 0 : relationships[0]) === null || _m === void 0 ? void 0 : _m.type) !== null && _o !== void 0 ? _o : '', onChange: function (type) { return onChange(value.map(function (v, i) { return i === editing ? __assign(__assign({}, v), { relationships: [{ type: type, id: '' /* to be filled on server-side */ }] }) : v; }), field.id); } }) }))] })) })), _jsx(Grid, __assign({ item: true }, { children: _jsxs(Grid, __assign({ container: true, alignItems: "center", wrap: "nowrap", spacing: 1 }, { children: [!((_q = (_p = field.options) === null || _p === void 0 ? void 0 : _p.hiddenDefaultFields) === null || _q === void 0 ? void 0 : _q.includes('Date of Birth')) &&
1710
1481
  _jsx(Grid, __assign({ item: true, xs: 4 }, { children: _jsx(DateStringInput, { value: dateOfBirth, field: __assign(__assign({}, field), { isOptional: true }), size: "small", label: "Date of Birth (MM-DD-YYYY)", onChange: function (dateOfBirth) { return onChange(value.map(function (v, i) { return i === editing ? __assign(__assign({}, v), { dateOfBirth: dateOfBirth }) : v; }), field.id); } }) })), !((_s = (_r = field.options) === null || _r === void 0 ? void 0 : _r.hiddenDefaultFields) === null || _s === void 0 ? void 0 : _s.includes('Email')) &&
1711
1482
  _jsx(Grid, __assign({ item: true, xs: 4 }, { children: _jsx(TextField, { label: "Email", size: "small", fullWidth: true, type: "email", InputProps: defaultInputProps, value: email, onChange: function (e) { return onChange(value.map(function (v, i) { return i === editing ? __assign(__assign({}, v), { email: e.target.value }) : v; }), field.id); } }) })), !((_u = (_t = field.options) === null || _t === void 0 ? void 0 : _t.hiddenDefaultFields) === null || _u === void 0 ? void 0 : _u.includes('Phone Number')) &&
1712
- _jsx(Grid, __assign({ item: true, xs: 4 }, { children: _jsx(TextField, { label: "Phone Number", size: "small", fullWidth: true, InputProps: defaultInputProps, value: phone, onChange: function (e) { return onChange(value.map(function (v, i) { return i === editing ? __assign(__assign({}, v), { phone: e.target.value }) : v; }), field.id); } }) }))] })) })), (((_w = field.options) === null || _w === void 0 ? void 0 : _w.tableChoices) || []).length > 0 &&
1483
+ _jsx(Grid, __assign({ item: true, xs: 4 }, { children: _jsx(TextField, { label: "Phone Number", size: "small", fullWidth: true, InputProps: defaultInputProps, value: phone, onChange: function (e) { return onChange(value.map(function (v, i) { return i === editing ? __assign(__assign({}, v), { phone: e.target.value.trim() }) : v; }), field.id); } }) }))] })) })), (((_w = field.options) === null || _w === void 0 ? void 0 : _w.tableChoices) || []).length > 0 &&
1713
1484
  _jsx(Grid, __assign({ item: true }, { children: _jsx(Grid, __assign({ container: true, spacing: 1 }, { children: (((_x = field.options) === null || _x === void 0 ? void 0 : _x.tableChoices) || []).map(function (_a, i) {
1714
1485
  var info = _a.info, label = _a.label, type = _a.type;
1715
1486
  return (_jsx(Grid, __assign({ item: true, xs: 6 }, { children: type === 'Text'
@@ -1729,7 +1500,7 @@ export var RelatedContactsInput = function (_a) {
1729
1500
  return i === editing ? __assign(__assign({}, v), { fields: __assign(__assign({}, fields_1), (_a = {}, _a[label] = e.target.value, _a)) }) : v;
1730
1501
  }), field.id); } }, { children: [_jsx(MenuItem, __assign({ value: "" }, { children: _jsx("em", { children: "None" }) })), info.choices.map(function (c) { return (_jsx(MenuItem, __assign({ value: c }, { children: c }), c)); })] }))] })))
1731
1502
  : null }), i));
1732
- }) })) })), _jsx(Grid, __assign({ item: true, sx: { my: 0.75 } }, { children: _jsx(Button, __assign({ variant: "outlined", onClick: function () { return setEditing(-1); }, size: "small" }, { children: "Save Contact" })) })), errorMessage &&
1503
+ }) })) })), _jsx(Grid, __assign({ item: true, sx: { my: 0.75 } }, { children: _jsx(Button, __assign({ variant: "outlined", onClick: function () { return setEditing(-1); }, size: "small", disabled: !!errorMessage || !!parentError }, { children: "Save Contact" })) })), errorMessage &&
1733
1504
  _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ color: "error" }, { children: errorMessage })) }))] })));
1734
1505
  }
1735
1506
  return (_jsxs(Grid, __assign({ container: true, direction: "column", spacing: 1 }, { children: [_jsx(Grid, __assign({ item: true }, { children: value.map(function (contact, i) { return (_jsx(Grid, __assign({ item: true }, { children: _jsxs(Grid, __assign({ container: true, alignItems: "center", justifyContent: "space-between", wrap: "nowrap", spacing: 1 }, { children: [_jsx(Grid, __assign({ item: true }, { children: _jsxs(Grid, __assign({ container: true, alignItems: "center" }, { children: [_jsx(IconButton, __assign({ onClick: function () { return setEditing(i); }, color: "primary", size: "small" }, { children: _jsx(Edit, {}) })), _jsx(Typography, __assign({ noWrap: true }, { children: user_display_name(contact) || "Unnamed Contact ".concat(i + 1) }))] })) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(LabeledIconButton, { Icon: Delete, label: "Remove", onClick: function () { return onChange(value.filter(function (v, _i) { return i !== _i; }), field.id); } }) }))] })) }), i)); }) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Button, __assign({ variant: "contained", onClick: handleAddContact }, { children: "Add Contact" })) }))] })));