@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
@@ -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,cAAc,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAanF,eAAO,MAAM,cAAc;WAAkC,MAAM;kBAAgB,MAAM,KAAK,IAAI;iBAgBjG,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE;IAAE,EAAE,EAAE,OAAO,CAAA;CAgB3C,CAAA;AACF,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,aAEvC,CAAA;AAED,eAAO,MAAM,SAAS;SAAiC,MAAM;;iBAoE5D,CAAA;AAED,eAAO,MAAM,WAAW,+BAAgC,eAAe,QAAQ,CAAC,gBA0B/E,CAAA;AAkCD,eAAO,MAAM,YAAY,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DragIndicator_1 = __importDefault(require("@mui/icons-material/DragIndicator
118
118
  var heic2any_1 = __importDefault(require("heic2any"));
119
119
  var AddPhotoAlternate_1 = __importDefault(require("@mui/icons-material/AddPhotoAlternate"));
120
120
  var Language_1 = __importDefault(require("@mui/icons-material/Language"));
121
- var react_stripe_js_1 = require("@stripe/react-stripe-js");
122
- var stripe_js_1 = require("@stripe/stripe-js");
123
121
  var icons_material_1 = require("@mui/icons-material");
124
122
  var wysiwyg_1 = require("./wysiwyg");
125
123
  var LanguageSelect = function (_a) {
@@ -793,7 +791,6 @@ var MultipleChoiceInput = function (_a) {
793
791
  var field = _a.field, form = _a.form, _value = _a.value, onChange = _a.onChange;
794
792
  var value = typeof _value === 'string' ? [_value] : _value; // if loading existingResponses, allows them to be a string
795
793
  var _f = field.options, choices = _f.choices, radio = _f.radio, other = _f.other, optionDetails = _f.optionDetails;
796
- var _g = (0, react_1.useState)({}), expandedDescriptions = _g[0], setExpandedDescriptions = _g[1];
797
794
  // current other string
798
795
  var enteringOtherStringRef = react_1.default.useRef(''); // if typing otherString as prefix of a checkbox value, don't auto-select
799
796
  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 : '';
@@ -803,19 +800,12 @@ var MultipleChoiceInput = function (_a) {
803
800
  var _a;
804
801
  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;
805
802
  }, [optionDetails]);
806
- var toggleDescription = (0, react_1.useCallback)(function (index) {
807
- setExpandedDescriptions(function (prev) {
808
- var _a;
809
- return (__assign(__assign({}, prev), (_a = {}, _a[index] = !prev[index], _a)));
810
- });
811
- }, []);
812
803
  return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, alignItems: "center", rowGap: 1.5 }, { children: [radio
813
804
  ? ((0, jsx_runtime_1.jsx)(material_1.FormControl, __assign({ fullWidth: true }, { children: (0, jsx_runtime_1.jsx)(material_1.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) {
814
805
  var description = getDescriptionForChoice(c);
815
806
  var hasDescription = !!description;
816
- var isExpanded = expandedDescriptions[i];
817
807
  var isSelected = !!(value === null || value === void 0 ? void 0 : value.includes(c)) && c !== otherString;
818
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { width: '100%' } }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: {
808
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { width: '100%' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, __assign({ sx: {
819
809
  display: 'flex',
820
810
  alignItems: 'center',
821
811
  width: '100%',
@@ -823,25 +813,17 @@ var MultipleChoiceInput = function (_a) {
823
813
  borderColor: 'primary.main',
824
814
  borderRadius: 1,
825
815
  padding: '16px 16px',
826
- marginBottom: '12px',
816
+ marginBottom: hasDescription ? '8px' : '12px',
827
817
  cursor: 'pointer',
828
818
  backgroundColor: 'transparent',
829
819
  boxSizing: 'border-box',
830
820
  '&:hover': {
831
821
  backgroundColor: function (theme) { return "".concat(theme.palette.primary.main, "14"); },
832
822
  },
833
- }, onClick: function () { return onChange((value === null || value === void 0 ? void 0 : value.includes(c)) ? [] : [c], field.id); } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ component: "span", sx: { flex: 1, color: 'primary.main', fontSize: 13, fontWeight: 600 } }, { children: c })), hasDescription && ((0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ className: "expand-button", size: "small", onClick: function (e) {
834
- e.stopPropagation();
835
- toggleDescription(i);
836
- }, sx: {
837
- transform: isExpanded ? 'rotate(180deg)' : 'rotate(0deg)',
838
- transition: 'transform 0.2s',
839
- ml: 1
840
- } }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ExpandMore, { fontSize: "small" }) })))] })), hasDescription && ((0, jsx_runtime_1.jsx)(material_1.Collapse, __assign({ in: isExpanded }, { children: (0, jsx_runtime_1.jsx)(material_1.Box, __assign({ sx: { pl: 2, pr: 2, pb: 1, pt: 1 } }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: description })) })) })))] }), i));
823
+ }, onClick: function () { return onChange((value === null || value === void 0 ? void 0 : value.includes(c)) ? [] : [c], field.id); } }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ component: "span", sx: { flex: 1, color: 'primary.main', fontSize: 13, fontWeight: 600 } }, { children: c })) })), hasDescription && ((0, jsx_runtime_1.jsx)(material_1.Box, __assign({ sx: { pl: 2, pr: 2, pb: 1, mb: 1 } }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ style: { fontSize: 14, color: '#00000099' } }, { children: description })) })))] }), i));
841
824
  }) })) }))) : ((choices !== null && choices !== void 0 ? choices : []).map(function (c, i) {
842
825
  var description = getDescriptionForChoice(c);
843
826
  var hasDescription = !!description;
844
- var isExpanded = expandedDescriptions[i];
845
827
  return ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ xs: 12 }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: { width: '100%' } }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ sx: {
846
828
  display: 'flex',
847
829
  alignItems: 'center',
@@ -850,10 +832,6 @@ var MultipleChoiceInput = function (_a) {
850
832
  boxSizing: 'border-box'
851
833
  }, onClick: function (e) {
852
834
  var _a, _b, _d, _e;
853
- // Don't trigger selection if clicking on the expand button
854
- if (e.target.closest('.expand-button')) {
855
- return;
856
- }
857
835
  onChange(((value === null || value === void 0 ? void 0 : value.includes(c))
858
836
  ? ((radio || ((_b = (_a = field.options) === null || _a === void 0 ? void 0 : _a.radioChoices) === null || _b === void 0 ? void 0 : _b.includes(c)))
859
837
  ? []
@@ -861,14 +839,7 @@ var MultipleChoiceInput = function (_a) {
861
839
  : ((radio || ((_e = (_d = field.options) === null || _d === void 0 ? void 0 : _d.radioChoices) === null || _e === void 0 ? void 0 : _e.includes(c)))
862
840
  ? [c]
863
841
  : __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);
864
- } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Checkbox, { color: "primary", checked: !!(value === null || value === void 0 ? void 0 : value.includes(c)) && c !== otherString, inputProps: { 'aria-label': 'primary checkbox' } }), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ component: "span", sx: { flex: 1 } }, { children: c })), hasDescription && ((0, jsx_runtime_1.jsx)(material_1.IconButton, __assign({ className: "expand-button", size: "small", onClick: function (e) {
865
- e.stopPropagation();
866
- toggleDescription(i);
867
- }, sx: {
868
- transform: isExpanded ? 'rotate(180deg)' : 'rotate(0deg)',
869
- transition: 'transform 0.2s',
870
- ml: 1
871
- } }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ExpandMore, { fontSize: "small" }) })))] })), hasDescription && ((0, jsx_runtime_1.jsx)(material_1.Collapse, __assign({ in: isExpanded }, { children: (0, jsx_runtime_1.jsx)(material_1.Box, __assign({ sx: { pl: '42px', pr: 2, pb: 1 } }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "text.secondary" }, { children: description })) })) })))] })) }), i));
842
+ } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Checkbox, { color: "primary", checked: !!(value === null || value === void 0 ? void 0 : value.includes(c)) && c !== otherString, inputProps: { 'aria-label': 'primary checkbox' } }), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ component: "span", sx: { flex: 1 } }, { children: c }))] })), hasDescription && ((0, jsx_runtime_1.jsx)(material_1.Box, __assign({ sx: { pl: '42px', pr: 2, pb: 1 } }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ style: { fontSize: 14, color: '#00000099' } }, { children: description })) })))] })) }), i));
872
843
  })), other &&
873
844
  (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField // className={classes.textField}
874
845
  , { InputProps: { sx: { borderRadius: 2.5 } }, sx: { width: radio ? "calc(100% - 15px)" : '100%' }, size: "small", "aria-label": (0, __1.form_display_text_for_language)(form, "Other"), value: otherString, placeholder: (0, __1.form_display_text_for_language)(form, "Other"), variant: "outlined",
@@ -885,212 +856,12 @@ var MultipleChoiceInput = function (_a) {
885
856
  } }) }))] })));
886
857
  };
887
858
  exports.MultipleChoiceInput = MultipleChoiceInput;
888
- var StripeInput = function (_a) {
889
- var _b, _d;
890
- var field = _a.field, value = _a.value, onChange = _a.onChange, setCustomerId = _a.setCustomerId, enduserId = _a.enduserId;
891
- var session = (0, __1.useResolvedSession)();
892
- var _e = (0, react_1.useState)(''), clientSecret = _e[0], setClientSecret = _e[1];
893
- var _f = (0, react_1.useState)(''), businessName = _f[0], setBusinessName = _f[1];
894
- var _g = (0, react_1.useState)(false), isCheckout = _g[0], setIsCheckout = _g[1];
895
- var _h = (0, react_1.useState)(), stripePromise = _h[0], setStripePromise = _h[1];
896
- var _j = (0, react_1.useState)(''), answertext = _j[0], setAnswertext = _j[1];
897
- var _k = (0, react_1.useState)(''), error = _k[0], setError = _k[1];
898
- var _l = (0, react_1.useState)([]), selectedProducts = _l[0], setSelectedProducts = _l[1];
899
- var _m = (0, react_1.useState)(false), showProductSelection = _m[0], setShowProductSelection = _m[1];
900
- var _o = (0, react_1.useState)([]), availableProducts = _o[0], setAvailableProducts = _o[1];
901
- var _p = (0, react_1.useState)(false), loadingProducts = _p[0], setLoadingProducts = _p[1];
902
- var fetchRef = (0, react_1.useRef)(false);
903
- (0, react_1.useEffect)(function () {
904
- var _a, _b, _d;
905
- if (fetchRef.current)
906
- return;
907
- if (value && ((_a = session.userInfo) === null || _a === void 0 ? void 0 : _a.stripeCustomerId)) {
908
- 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
909
- }
910
- // Check if product selection mode is enabled
911
- 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) {
912
- setShowProductSelection(true);
913
- setLoadingProducts(true);
914
- // Fetch product data with real-time Stripe pricing via proxy_read
915
- var productIds = (field.options.productIds || []).join(',');
916
- session.api.integrations.proxy_read({
917
- integration: 'Stripe',
918
- type: 'product-prices',
919
- id: productIds,
920
- query: field.options.stripeKey
921
- })
922
- .then(function (_a) {
923
- var data = _a.data;
924
- setAvailableProducts(data.products || []);
925
- setLoadingProducts(false);
926
- })
927
- .catch(function (e) {
928
- var _a, _b;
929
- console.error('Error loading product data:', e);
930
- 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:'))
931
- ? e.message.replace('Stripe pricing error: ', '')
932
- : 'Failed to load product information from Stripe';
933
- setError("Product configuration error: ".concat(errorMessage));
934
- setLoadingProducts(false);
935
- });
936
- return;
937
- }
938
- fetchRef.current = true;
939
- session.api.form_responses.stripe_details({ fieldId: field.id, enduserId: enduserId })
940
- .then(function (_a) {
941
- var clientSecret = _a.clientSecret, publishableKey = _a.publishableKey, stripeAccount = _a.stripeAccount, businessName = _a.businessName, customerId = _a.customerId, isCheckout = _a.isCheckout, answerText = _a.answerText;
942
- setAnswertext(answerText || '');
943
- setIsCheckout(!!isCheckout);
944
- setClientSecret(clientSecret);
945
- setStripePromise((0, stripe_js_1.loadStripe)(publishableKey, { stripeAccount: stripeAccount }));
946
- setBusinessName(businessName);
947
- setCustomerId(customerId);
948
- })
949
- .catch(function (e) {
950
- console.error(e);
951
- if (typeof (e === null || e === void 0 ? void 0 : e.message) === 'string') {
952
- setError(e.message);
953
- }
954
- });
955
- }, [session, value, field.id, enduserId]);
956
- var cost = (showProductSelection
957
- ? selectedProducts.reduce(function (total, productId) {
958
- var _a;
959
- var product = availableProducts.find(function (p) { return p._id === productId; });
960
- if (product === null || product === void 0 ? void 0 : product.currentPrice) {
961
- return total + (product.currentPrice.amount || 0);
962
- }
963
- return total + (((_a = product === null || product === void 0 ? void 0 : product.cost) === null || _a === void 0 ? void 0 : _a.amount) || 0);
964
- }, 0)
965
- : 0 // Will be calculated by existing Stripe flow when not in selection mode
966
- );
967
- // Handle product selection step
968
- if (showProductSelection) {
969
- if (error) {
970
- return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, direction: "column", spacing: 2, alignItems: "center" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ color: "error", variant: "h6" }, { children: "Product Configuration Error" })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ color: "error", sx: { textAlign: 'center' } }, { children: error })) }))] })));
971
- }
972
- if (loadingProducts) {
973
- return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, direction: "column", spacing: 2, alignItems: "center" }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(LinearProgress_1.default, {}) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, { children: "Loading product information..." }) }))] })));
974
- }
975
- var isSingleSelection_1 = ((_b = field.options) === null || _b === void 0 ? void 0 : _b.radio) === true;
976
- var handleProductSelection_1 = function (productId) {
977
- if (isSingleSelection_1) {
978
- setSelectedProducts([productId]);
979
- }
980
- else {
981
- setSelectedProducts(function (prev) {
982
- return prev.includes(productId)
983
- ? prev.filter(function (id) { return id !== productId; })
984
- : __spreadArray(__spreadArray([], prev, true), [productId], false);
985
- });
986
- }
987
- };
988
- var handleContinueToPayment = function () {
989
- if (selectedProducts.length === 0)
990
- return;
991
- setShowProductSelection(false);
992
- fetchRef.current = true;
993
- // Now fetch Stripe details with selected products
994
- session.api.form_responses.stripe_details(__assign({ fieldId: field.id, enduserId: enduserId }, (selectedProducts.length > 0 && { selectedProductIds: selectedProducts }) // Pass selected products to Stripe checkout
995
- ))
996
- .then(function (_a) {
997
- var clientSecret = _a.clientSecret, publishableKey = _a.publishableKey, stripeAccount = _a.stripeAccount, businessName = _a.businessName, customerId = _a.customerId, isCheckout = _a.isCheckout, answerText = _a.answerText;
998
- setAnswertext(answerText || '');
999
- setIsCheckout(!!isCheckout);
1000
- setClientSecret(clientSecret);
1001
- setStripePromise((0, stripe_js_1.loadStripe)(publishableKey, { stripeAccount: stripeAccount }));
1002
- setBusinessName(businessName);
1003
- setCustomerId(customerId);
1004
- })
1005
- .catch(function (e) {
1006
- console.error(e);
1007
- if (typeof (e === null || e === void 0 ? void 0 : e.message) === 'string') {
1008
- setError(e.message);
1009
- }
1010
- });
1011
- };
1012
- return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, direction: "column", spacing: 2 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "h6" }, { children: ["Select Product", isSingleSelection_1 ? '' : 's'] })) })), availableProducts.map(function (product) {
1013
- var _a, _b, _d;
1014
- // Use real-time Stripe pricing if available, fallback to Tellescope pricing
1015
- var price = product.currentPrice || product.cost;
1016
- var priceAmount = (price === null || price === void 0 ? void 0 : price.amount) || 0;
1017
- var priceCurrency = (price === null || price === void 0 ? void 0 : price.currency) || 'USD';
1018
- return ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: isSingleSelection_1 ? ((0, jsx_runtime_1.jsx)(material_1.Radio, { checked: selectedProducts.includes(product._id), onChange: function () { return handleProductSelection_1(product._id); } })) : ((0, jsx_runtime_1.jsx)(material_1.Checkbox, { checked: selectedProducts.includes(product._id), onChange: function () { return handleProductSelection_1(product._id); } })), label: (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body1", fontWeight: "bold" }, { children: product.title })), product.description && ((0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: product.description }))), (0, jsx_runtime_1.jsxs)(material_1.Typography, __assign({ variant: "body2", color: "primary" }, { children: ["$", (priceAmount / 100).toFixed(2), " ", priceCurrency.toUpperCase(), ((_a = product.currentPrice) === null || _a === void 0 ? void 0 : _a.isSubscription) && ((0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ component: "span", variant: "caption", sx: { ml: 0.5 } }, { children: (0, utilities_1.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));
1019
- }), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ variant: "contained", onClick: handleContinueToPayment, disabled: selectedProducts.length === 0, sx: { mt: 2 } }, { children: "Continue to Payment" })) }))] })));
1020
- }
1021
- if (error) {
1022
- return ((0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ color: "error" }, { children: error })));
1023
- }
1024
- if (value) {
1025
- return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, alignItems: "center", wrap: "nowrap" }, { children: [(0, jsx_runtime_1.jsx)(icons_material_1.CheckCircleOutline, { color: "success" }), (0, jsx_runtime_1.jsx)(material_1.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!" }))] })));
1026
- }
1027
- if (!(clientSecret && stripePromise))
1028
- return (0, jsx_runtime_1.jsx)(LinearProgress_1.default, {});
1029
- if (isCheckout && stripePromise)
1030
- return ((0, jsx_runtime_1.jsx)(react_stripe_js_1.EmbeddedCheckoutProvider, __assign({ stripe: stripePromise, options: {
1031
- clientSecret: clientSecret,
1032
- onComplete: function () { return onChange(answertext || 'Completed checkout', field.id); },
1033
- } }, { children: (0, jsx_runtime_1.jsx)(react_stripe_js_1.EmbeddedCheckout, {}) })));
1034
- return ((0, jsx_runtime_1.jsx)(react_stripe_js_1.Elements, __assign({ stripe: stripePromise, options: {
1035
- clientSecret: clientSecret,
1036
- } }, { children: (0, jsx_runtime_1.jsx)(StripeForm, { businessName: businessName, onSuccess: function () { return onChange(answertext || 'Saved card details', field.id); }, cost: cost, field: field }) })));
1037
- };
1038
- exports.StripeInput = StripeInput;
1039
- var StripeForm = function (_a) {
1040
- var _b, _d, _e;
1041
- var businessName = _a.businessName, onSuccess = _a.onSuccess, field = _a.field, cost = _a.cost;
1042
- var stripe = (0, react_stripe_js_1.useStripe)();
1043
- var elements = (0, react_stripe_js_1.useElements)();
1044
- var _f = (0, react_1.useState)(false), ready = _f[0], setReady = _f[1];
1045
- var _g = (0, react_1.useState)(''), errorMessage = _g[0], setErrorMessage = _g[1];
1046
- var handleSubmit = function (event) { return __awaiter(void 0, void 0, void 0, function () {
1047
- var error;
1048
- var _a, _b;
1049
- return __generator(this, function (_d) {
1050
- switch (_d.label) {
1051
- case 0:
1052
- // We don't want to let default form submission happen here,
1053
- // which would refresh the page.
1054
- event === null || event === void 0 ? void 0 : event.preventDefault();
1055
- if (!stripe || !elements) {
1056
- // Stripe.js hasn't yet loaded.
1057
- // Make sure to disable form submission until Stripe.js has loaded.
1058
- return [2 /*return*/, null];
1059
- }
1060
- return [4 /*yield*/, (((_a = field.options) === null || _a === void 0 ? void 0 : _a.chargeImmediately) ? stripe.confirmPayment : stripe.confirmSetup)({
1061
- //`Elements` instance that was used to create the Payment Element
1062
- elements: elements,
1063
- confirmParams: {
1064
- return_url: window.location.href,
1065
- },
1066
- redirect: 'if_required', // ensures the redirect url won't be used, unless the Bank redirect payment type is enabled (it's not, just card)
1067
- })];
1068
- case 1:
1069
- error = (_d.sent()).error;
1070
- if (error) {
1071
- // This point will only be reached if there is an immediate error when
1072
- // confirming the payment. Show error to your customer (for example, payment
1073
- // details incomplete)
1074
- setErrorMessage((_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : '');
1075
- }
1076
- else {
1077
- onSuccess();
1078
- // Your customer will be redirected to your `return_url`. For some payment
1079
- // methods like iDEAL, your customer will be redirected to an intermediate
1080
- // site first to authorize the payment, then redirected to the `return_url`.
1081
- }
1082
- return [2 /*return*/];
1083
- }
1084
- });
1085
- }); };
1086
- return ((0, jsx_runtime_1.jsxs)("form", __assign({ onSubmit: handleSubmit }, { children: [(0, jsx_runtime_1.jsx)(react_stripe_js_1.PaymentElement, { onReady: function () { return setReady(true); }, options: {
1087
- business: { name: businessName },
1088
- } }), (0, jsx_runtime_1.jsx)(material_1.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 &&
1089
- (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ sx: { mt: 0.5 } }, { children: ((_d = field.options) === null || _d === void 0 ? void 0 : _d.customPriceMessage)
1090
- ? field.options.customPriceMessage.replaceAll('{{PRICE}}', "$".concat((cost / 100).toFixed(2)))
1091
- : "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 &&
1092
- (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ color: "error", sx: { mt: 0.5 } }, { children: errorMessage }))] })));
1093
- };
859
+ // StripeInput is shared between v1 and v2 forms
860
+ // Both versions use the same implementation from inputs.tsx to ensure consistent behavior
861
+ // and avoid code duplication. Re-exporting here maintains the pattern where forms.v2.tsx
862
+ // only imports from inputs.v2.tsx
863
+ var inputs_1 = require("./inputs");
864
+ Object.defineProperty(exports, "StripeInput", { enumerable: true, get: function () { return inputs_1.StripeInput; } });
1094
865
  var Progress = function (_a) {
1095
866
  var numerator = _a.numerator, denominator = _a.denominator, style = _a.style, color = _a.color;
1096
867
  return ((0, jsx_runtime_1.jsx)(material_1.Box, __assign({ sx: __assign({ display: 'flex', alignItems: 'center' }, style) }, { children: (0, jsx_runtime_1.jsx)(material_1.Box, __assign({ sx: { width: '100%' } }, { children: (0, jsx_runtime_1.jsx)(LinearProgress_1.default, { variant: "determinate", value: (numerator / (denominator || 1)) * 100, sx: color ? {
@@ -1751,7 +1522,7 @@ var contact_is_valid = function (e) {
1751
1522
  exports.contact_is_valid = contact_is_valid;
1752
1523
  var RelatedContactsInput = function (_a) {
1753
1524
  var _b, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _w, _x;
1754
- var field = _a.field, _value = _a.value, onChange = _a.onChange, props = __rest(_a, ["field", "value", "onChange"]);
1525
+ var field = _a.field, _value = _a.value, onChange = _a.onChange, parentError = _a.error, props = __rest(_a, ["field", "value", "onChange", "error"]);
1755
1526
  // safeguard against any rogue values like empty string
1756
1527
  var value = Array.isArray(_value) ? _value : [];
1757
1528
  var _y = (0, react_1.useState)(value.length === 1 ? 0 : -1), editing = _y[0], setEditing = _y[1];
@@ -1770,7 +1541,7 @@ var RelatedContactsInput = function (_a) {
1770
1541
  (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 4 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Last Name", size: "small", fullWidth: true, InputProps: exports.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); } }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 4 }, { children: (0, jsx_runtime_1.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 : constants_1.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); } }) }))] })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsxs)(material_1.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')) &&
1771
1542
  (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 4 }, { children: (0, jsx_runtime_1.jsx)(exports.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')) &&
1772
1543
  (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 4 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Email", size: "small", fullWidth: true, type: "email", InputProps: exports.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')) &&
1773
- (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 4 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Phone Number", size: "small", fullWidth: true, InputProps: exports.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 &&
1544
+ (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 4 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { label: "Phone Number", size: "small", fullWidth: true, InputProps: exports.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 &&
1774
1545
  (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ container: true, spacing: 1 }, { children: (((_x = field.options) === null || _x === void 0 ? void 0 : _x.tableChoices) || []).map(function (_a, i) {
1775
1546
  var info = _a.info, label = _a.label, type = _a.type;
1776
1547
  return ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: type === 'Text'
@@ -1790,7 +1561,7 @@ var RelatedContactsInput = function (_a) {
1790
1561
  return i === editing ? __assign(__assign({}, v), { fields: __assign(__assign({}, fields_1), (_a = {}, _a[label] = e.target.value, _a)) }) : v;
1791
1562
  }), field.id); } }, { children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: "" }, { children: (0, jsx_runtime_1.jsx)("em", { children: "None" }) })), info.choices.map(function (c) { return ((0, jsx_runtime_1.jsx)(material_1.MenuItem, __assign({ value: c }, { children: c }), c)); })] }))] })))
1792
1563
  : null }), i));
1793
- }) })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, sx: { my: 0.75 } }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ variant: "outlined", onClick: function () { return setEditing(-1); }, size: "small" }, { children: "Save Contact" })) })), errorMessage &&
1564
+ }) })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, sx: { my: 0.75 } }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ variant: "outlined", onClick: function () { return setEditing(-1); }, size: "small", disabled: !!errorMessage || !!parentError }, { children: "Save Contact" })) })), errorMessage &&
1794
1565
  (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ color: "error" }, { children: errorMessage })) }))] })));
1795
1566
  }
1796
1567
  return ((0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, direction: "column", spacing: 1 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: value.map(function (contact, i) { return ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, alignItems: "center", justifyContent: "space-between", wrap: "nowrap", spacing: 1 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsxs)(material_1.Grid, __assign({ container: true, alignItems: "center" }, { children: [(0, jsx_runtime_1.jsx)(__1.IconButton, __assign({ onClick: function () { return setEditing(i); }, color: "primary", size: "small" }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.Edit, {}) })), (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ noWrap: true }, { children: (0, utilities_1.user_display_name)(contact) || "Unnamed Contact ".concat(i + 1) }))] })) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(__1.LabeledIconButton, { Icon: icons_material_1.Delete, label: "Remove", onClick: function () { return onChange(value.filter(function (v, _i) { return i !== _i; }), field.id); } }) }))] })) }), i)); }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, __assign({ variant: "contained", onClick: handleAddContact }, { children: "Add Contact" })) }))] })));