@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,7 +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"> & {
48
+ export declare const StripeInput: ({ field, value, onChange, setCustomerId, enduserId, form, responses, enduser }: FormInputProps<"Stripe"> & {
49
49
  setCustomerId: React.Dispatch<React.SetStateAction<string | undefined>>;
50
50
  }) => JSX.Element;
51
51
  export declare const Progress: ({ numerator, denominator, style }: {
@@ -65,7 +65,7 @@ export declare const CanvasMedicationsInput: ({ field, value, onChange }: FormIn
65
65
  export declare const MedicationsInput: ({ field, value, onChange, ...props }: FormInputProps<'Medications'>) => JSX.Element;
66
66
  export declare const BelugaPatientPreferenceInput: ({ field, value: _value, onChange }: FormInputProps<'Beluga Patient Preference'>) => JSX.Element;
67
67
  export declare const contact_is_valid: (e: Partial<Enduser>) => "Email is invalid" | "Phone is invalid" | "Date of birth should be MM-DD-YYYY" | undefined;
68
- export declare const RelatedContactsInput: ({ field, value: _value, onChange, ...props }: FormInputProps<'Related Contacts'>) => JSX.Element;
68
+ export declare const RelatedContactsInput: ({ field, value: _value, onChange, error: parentError, ...props }: FormInputProps<'Related Contacts'>) => JSX.Element;
69
69
  export declare const AppointmentBookingInput: ({ formResponseId, field, value, onChange, form, responses, goToPreviousField, isPreviousDisabled, enduserId, ...props }: FormInputProps<'Appointment Booking'>) => JSX.Element;
70
70
  export declare const HeightInput: ({ field, value, onChange, ...props }: FormInputProps<'Height'>) => JSX.Element;
71
71
  export declare const include_current_url_parameters_if_templated: (url: string) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../../src/Forms/inputs.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;AA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;AAED,eAAO,MAAM,gBAAgB,4FAA6F,eAAe,OAAO,CAAC,gBA+ChJ,CAAA;AAED,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"}
@@ -75,7 +75,7 @@ import axios from "axios";
75
75
  import { Autocomplete, Box, Button, Checkbox, Chip, Collapse, Divider, FormControl, FormControlLabel, FormLabel, Grid, IconButton as MuiIconButton, InputLabel, MenuItem, Radio, 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, format_stripe_subscription_interval, getLocalTimezone, getPublicFileURL, mm_dd_yyyy, object_is_empty, replace_enduser_template_values, responses_satisfy_conditions, 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';
@@ -808,20 +808,59 @@ export var MultipleChoiceInput = function (_a) {
808
808
  ? __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);
809
809
  } }) }))] })));
810
810
  };
811
+ // Helper to emit GTM purchase event for Stripe payments (single source of truth)
812
+ var emitStripePurchaseEvent = function (field, cost) {
813
+ var _a;
814
+ emit_gtm_event({
815
+ event: 'form_purchase',
816
+ productIds: ((_a = field.options) === null || _a === void 0 ? void 0 : _a.productIds) || [],
817
+ fieldId: field.id,
818
+ value: cost / 100,
819
+ currency: 'USD',
820
+ });
821
+ };
811
822
  export var StripeInput = function (_a) {
812
- var _b, _d;
813
- var field = _a.field, value = _a.value, onChange = _a.onChange, setCustomerId = _a.setCustomerId, enduserId = _a.enduserId;
823
+ var _b, _d, _e;
824
+ var field = _a.field, value = _a.value, onChange = _a.onChange, setCustomerId = _a.setCustomerId, enduserId = _a.enduserId, form = _a.form, responses = _a.responses, enduser = _a.enduser;
814
825
  var session = useResolvedSession();
815
- var _e = useState(''), clientSecret = _e[0], setClientSecret = _e[1];
816
- var _f = useState(''), businessName = _f[0], setBusinessName = _f[1];
817
- var _g = useState(false), isCheckout = _g[0], setIsCheckout = _g[1];
818
- var _h = useState(), stripePromise = _h[0], setStripePromise = _h[1];
819
- var _j = useState(''), answertext = _j[0], setAnswertext = _j[1];
820
- var _k = useState(''), error = _k[0], setError = _k[1];
821
- var _l = useState([]), selectedProducts = _l[0], setSelectedProducts = _l[1];
822
- var _m = useState(false), showProductSelection = _m[0], setShowProductSelection = _m[1];
823
- var _o = useState([]), availableProducts = _o[0], setAvailableProducts = _o[1];
824
- var _p = useState(false), loadingProducts = _p[0], setLoadingProducts = _p[1];
826
+ var _f = useState(''), clientSecret = _f[0], setClientSecret = _f[1];
827
+ var _g = useState(''), businessName = _g[0], setBusinessName = _g[1];
828
+ var _h = useState(false), isCheckout = _h[0], setIsCheckout = _h[1];
829
+ var _j = useState(), stripePromise = _j[0], setStripePromise = _j[1];
830
+ var _k = useState(''), answertext = _k[0], setAnswertext = _k[1];
831
+ var _l = useState(''), error = _l[0], setError = _l[1];
832
+ var _m = useState([]), selectedProducts = _m[0], setSelectedProducts = _m[1];
833
+ var _o = useState(false), showProductSelection = _o[0], setShowProductSelection = _o[1];
834
+ var _p = useState([]), availableProducts = _p[0], setAvailableProducts = _p[1];
835
+ var _q = useState(false), loadingProducts = _q[0], setLoadingProducts = _q[1];
836
+ // Compute visible products based on conditional logic
837
+ var visibleProducts = useMemo(function () {
838
+ if (!showProductSelection || availableProducts.length === 0) {
839
+ return availableProducts;
840
+ }
841
+ return availableProducts.filter(function (product) {
842
+ var _a, _b;
843
+ // Find condition for this product
844
+ var productCondition = (_b = (_a = field.options) === null || _a === void 0 ? void 0 : _a.productConditions) === null || _b === void 0 ? void 0 : _b.find(function (c) { return c.productId === product._id; });
845
+ // If no condition defined, show by default
846
+ if (!(productCondition === null || productCondition === void 0 ? void 0 : productCondition.showCondition) || object_is_empty(productCondition.showCondition)) {
847
+ return true;
848
+ }
849
+ // Evaluate condition against current form responses
850
+ return responses_satisfy_conditions(responses || [], productCondition.showCondition, {
851
+ dateOfBirth: enduser === null || enduser === void 0 ? void 0 : enduser.dateOfBirth,
852
+ gender: enduser === null || enduser === void 0 ? void 0 : enduser.gender,
853
+ state: enduser === null || enduser === void 0 ? void 0 : enduser.state,
854
+ form: form,
855
+ activeResponses: responses,
856
+ });
857
+ });
858
+ }, [availableProducts, (_b = field.options) === null || _b === void 0 ? void 0 : _b.productConditions, responses, showProductSelection, enduser, form]);
859
+ // Automatically deselect products that become hidden
860
+ useEffect(function () {
861
+ var visibleProductIds = visibleProducts.map(function (p) { return p._id; });
862
+ setSelectedProducts(function (prev) { return prev.filter(function (id) { return visibleProductIds.includes(id); }); });
863
+ }, [visibleProducts]);
825
864
  var fetchRef = useRef(false);
826
865
  useEffect(function () {
827
866
  var _a, _b, _d;
@@ -887,6 +926,16 @@ export var StripeInput = function (_a) {
887
926
  }, 0)
888
927
  : 0 // Will be calculated by existing Stripe flow when not in selection mode
889
928
  );
929
+ // Emit GTM purchase event once when success screen is displayed
930
+ var purchaseEmittedRef = useRef(false);
931
+ useEffect(function () {
932
+ var _a;
933
+ // Only emit for actual purchases (chargeImmediately), not for saving card details
934
+ if (value && ((_a = field.options) === null || _a === void 0 ? void 0 : _a.chargeImmediately) && !purchaseEmittedRef.current) {
935
+ emitStripePurchaseEvent(field, cost);
936
+ purchaseEmittedRef.current = true;
937
+ }
938
+ }, [value, field, cost]);
890
939
  // Handle product selection step
891
940
  if (showProductSelection) {
892
941
  if (error) {
@@ -895,7 +944,11 @@ export var StripeInput = function (_a) {
895
944
  if (loadingProducts) {
896
945
  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..." }) }))] })));
897
946
  }
898
- var isSingleSelection_1 = ((_b = field.options) === null || _b === void 0 ? void 0 : _b.radio) === true;
947
+ // Check if all products are filtered out by conditional logic
948
+ if (visibleProducts.length === 0) {
949
+ return (_jsx(Grid, __assign({ container: true, direction: "column", spacing: 2, alignItems: "center" }, { children: _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ color: "textSecondary" }, { children: "No products are available based on your previous answers." })) })) })));
950
+ }
951
+ var isSingleSelection_1 = ((_d = field.options) === null || _d === void 0 ? void 0 : _d.radio) === true;
899
952
  var handleProductSelection_1 = function (productId) {
900
953
  if (isSingleSelection_1) {
901
954
  setSelectedProducts([productId]);
@@ -932,7 +985,7 @@ export var StripeInput = function (_a) {
932
985
  }
933
986
  });
934
987
  };
935
- 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) {
988
+ 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'] })) })), visibleProducts.map(function (product) {
936
989
  var _a, _b, _d;
937
990
  // Use real-time Stripe pricing if available, fallback to Tellescope pricing
938
991
  var price = product.currentPrice || product.cost;
@@ -945,7 +998,7 @@ export var StripeInput = function (_a) {
945
998
  return (_jsx(Typography, __assign({ color: "error" }, { children: error })));
946
999
  }
947
1000
  if (value) {
948
- 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!" }))] })));
1001
+ return (_jsxs(Grid, __assign({ container: true, alignItems: "center", wrap: "nowrap" }, { children: [_jsx(CheckCircleOutline, { color: "success" }), _jsx(Typography, __assign({ sx: { ml: 1, fontSize: 20 } }, { children: ((_e = field.options) === null || _e === void 0 ? void 0 : _e.chargeImmediately) ? 'Your purchase was successful' : "Your payment details have been saved!" }))] })));
949
1002
  }
950
1003
  if (!(clientSecret && stripePromise))
951
1004
  return _jsx(LinearProgress, {});
@@ -1652,7 +1705,7 @@ export var contact_is_valid = function (e) {
1652
1705
  };
1653
1706
  export var RelatedContactsInput = function (_a) {
1654
1707
  var _b, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _w, _x;
1655
- var field = _a.field, _value = _a.value, onChange = _a.onChange, props = __rest(_a, ["field", "value", "onChange"]);
1708
+ var field = _a.field, _value = _a.value, onChange = _a.onChange, parentError = _a.error, props = __rest(_a, ["field", "value", "onChange", "error"]);
1656
1709
  // safeguard against any rogue values like empty string
1657
1710
  var value = Array.isArray(_value) ? _value : [];
1658
1711
  var _y = useState(value.length === 1 ? 0 : -1), editing = _y[0], setEditing = _y[1];
@@ -1671,7 +1724,7 @@ export var RelatedContactsInput = function (_a) {
1671
1724
  _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')) &&
1672
1725
  _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')) &&
1673
1726
  _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')) &&
1674
- _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 &&
1727
+ _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 &&
1675
1728
  _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) {
1676
1729
  var info = _a.info, label = _a.label, type = _a.type;
1677
1730
  return (_jsx(Grid, __assign({ item: true, xs: 6 }, { children: type === 'Text'
@@ -1691,7 +1744,7 @@ export var RelatedContactsInput = function (_a) {
1691
1744
  return i === editing ? __assign(__assign({}, v), { fields: __assign(__assign({}, fields_1), (_a = {}, _a[label] = e.target.value, _a)) }) : v;
1692
1745
  }), 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)); })] }))] })))
1693
1746
  : null }), i));
1694
- }) })) })), _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 &&
1747
+ }) })) })), _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 &&
1695
1748
  _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ color: "error" }, { children: errorMessage })) }))] })));
1696
1749
  }
1697
1750
  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" })) }))] })));