@tellescope/react-components 1.231.0 → 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.
@@ -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":"","s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kBAAkB,CAAC,gBAiLxI,CAAA;AAED,eAAO,MAAM,uBAAuB,4HAA6H,eAAe,qBAAqB,CAAC,gBAyOrM,CAAA;AAED,eAAO,MAAM,WAAW,yCAAoD,eAAe,QAAQ,CAAC,gBAenG,CAAA;AAED,eAAO,MAAM,2CAA2C,QAAS,MAAM,WAetE,CAAA;AAED,eAAO,MAAM,aAAa,uIAAkJ,eAAe,UAAU,CAAC,uBAkGrM,CAAA;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"}
@@ -118,8 +118,6 @@ var 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) {
@@ -858,212 +856,12 @@ var MultipleChoiceInput = function (_a) {
858
856
  } }) }))] })));
859
857
  };
860
858
  exports.MultipleChoiceInput = MultipleChoiceInput;
861
- var StripeInput = function (_a) {
862
- var _b, _d;
863
- var field = _a.field, value = _a.value, onChange = _a.onChange, setCustomerId = _a.setCustomerId, enduserId = _a.enduserId;
864
- var session = (0, __1.useResolvedSession)();
865
- var _e = (0, react_1.useState)(''), clientSecret = _e[0], setClientSecret = _e[1];
866
- var _f = (0, react_1.useState)(''), businessName = _f[0], setBusinessName = _f[1];
867
- var _g = (0, react_1.useState)(false), isCheckout = _g[0], setIsCheckout = _g[1];
868
- var _h = (0, react_1.useState)(), stripePromise = _h[0], setStripePromise = _h[1];
869
- var _j = (0, react_1.useState)(''), answertext = _j[0], setAnswertext = _j[1];
870
- var _k = (0, react_1.useState)(''), error = _k[0], setError = _k[1];
871
- var _l = (0, react_1.useState)([]), selectedProducts = _l[0], setSelectedProducts = _l[1];
872
- var _m = (0, react_1.useState)(false), showProductSelection = _m[0], setShowProductSelection = _m[1];
873
- var _o = (0, react_1.useState)([]), availableProducts = _o[0], setAvailableProducts = _o[1];
874
- var _p = (0, react_1.useState)(false), loadingProducts = _p[0], setLoadingProducts = _p[1];
875
- var fetchRef = (0, react_1.useRef)(false);
876
- (0, react_1.useEffect)(function () {
877
- var _a, _b, _d;
878
- if (fetchRef.current)
879
- return;
880
- if (value && ((_a = session.userInfo) === null || _a === void 0 ? void 0 : _a.stripeCustomerId)) {
881
- 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
882
- }
883
- // Check if product selection mode is enabled
884
- 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) {
885
- setShowProductSelection(true);
886
- setLoadingProducts(true);
887
- // Fetch product data with real-time Stripe pricing via proxy_read
888
- var productIds = (field.options.productIds || []).join(',');
889
- session.api.integrations.proxy_read({
890
- integration: 'Stripe',
891
- type: 'product-prices',
892
- id: productIds,
893
- query: field.options.stripeKey
894
- })
895
- .then(function (_a) {
896
- var data = _a.data;
897
- setAvailableProducts(data.products || []);
898
- setLoadingProducts(false);
899
- })
900
- .catch(function (e) {
901
- var _a, _b;
902
- console.error('Error loading product data:', e);
903
- 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:'))
904
- ? e.message.replace('Stripe pricing error: ', '')
905
- : 'Failed to load product information from Stripe';
906
- setError("Product configuration error: ".concat(errorMessage));
907
- setLoadingProducts(false);
908
- });
909
- return;
910
- }
911
- fetchRef.current = true;
912
- session.api.form_responses.stripe_details({ fieldId: field.id, enduserId: enduserId })
913
- .then(function (_a) {
914
- var clientSecret = _a.clientSecret, publishableKey = _a.publishableKey, stripeAccount = _a.stripeAccount, businessName = _a.businessName, customerId = _a.customerId, isCheckout = _a.isCheckout, answerText = _a.answerText;
915
- setAnswertext(answerText || '');
916
- setIsCheckout(!!isCheckout);
917
- setClientSecret(clientSecret);
918
- setStripePromise((0, stripe_js_1.loadStripe)(publishableKey, { stripeAccount: stripeAccount }));
919
- setBusinessName(businessName);
920
- setCustomerId(customerId);
921
- })
922
- .catch(function (e) {
923
- console.error(e);
924
- if (typeof (e === null || e === void 0 ? void 0 : e.message) === 'string') {
925
- setError(e.message);
926
- }
927
- });
928
- }, [session, value, field.id, enduserId]);
929
- var cost = (showProductSelection
930
- ? selectedProducts.reduce(function (total, productId) {
931
- var _a;
932
- var product = availableProducts.find(function (p) { return p._id === productId; });
933
- if (product === null || product === void 0 ? void 0 : product.currentPrice) {
934
- return total + (product.currentPrice.amount || 0);
935
- }
936
- return total + (((_a = product === null || product === void 0 ? void 0 : product.cost) === null || _a === void 0 ? void 0 : _a.amount) || 0);
937
- }, 0)
938
- : 0 // Will be calculated by existing Stripe flow when not in selection mode
939
- );
940
- // Handle product selection step
941
- if (showProductSelection) {
942
- if (error) {
943
- 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 })) }))] })));
944
- }
945
- if (loadingProducts) {
946
- 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..." }) }))] })));
947
- }
948
- var isSingleSelection_1 = ((_b = field.options) === null || _b === void 0 ? void 0 : _b.radio) === true;
949
- var handleProductSelection_1 = function (productId) {
950
- if (isSingleSelection_1) {
951
- setSelectedProducts([productId]);
952
- }
953
- else {
954
- setSelectedProducts(function (prev) {
955
- return prev.includes(productId)
956
- ? prev.filter(function (id) { return id !== productId; })
957
- : __spreadArray(__spreadArray([], prev, true), [productId], false);
958
- });
959
- }
960
- };
961
- var handleContinueToPayment = function () {
962
- if (selectedProducts.length === 0)
963
- return;
964
- setShowProductSelection(false);
965
- fetchRef.current = true;
966
- // Now fetch Stripe details with selected products
967
- session.api.form_responses.stripe_details(__assign({ fieldId: field.id, enduserId: enduserId }, (selectedProducts.length > 0 && { selectedProductIds: selectedProducts }) // Pass selected products to Stripe checkout
968
- ))
969
- .then(function (_a) {
970
- var clientSecret = _a.clientSecret, publishableKey = _a.publishableKey, stripeAccount = _a.stripeAccount, businessName = _a.businessName, customerId = _a.customerId, isCheckout = _a.isCheckout, answerText = _a.answerText;
971
- setAnswertext(answerText || '');
972
- setIsCheckout(!!isCheckout);
973
- setClientSecret(clientSecret);
974
- setStripePromise((0, stripe_js_1.loadStripe)(publishableKey, { stripeAccount: stripeAccount }));
975
- setBusinessName(businessName);
976
- setCustomerId(customerId);
977
- })
978
- .catch(function (e) {
979
- console.error(e);
980
- if (typeof (e === null || e === void 0 ? void 0 : e.message) === 'string') {
981
- setError(e.message);
982
- }
983
- });
984
- };
985
- 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) {
986
- var _a, _b, _d;
987
- // Use real-time Stripe pricing if available, fallback to Tellescope pricing
988
- var price = product.currentPrice || product.cost;
989
- var priceAmount = (price === null || price === void 0 ? void 0 : price.amount) || 0;
990
- var priceCurrency = (price === null || price === void 0 ? void 0 : price.currency) || 'USD';
991
- 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));
992
- }), (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" })) }))] })));
993
- }
994
- if (error) {
995
- return ((0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ color: "error" }, { children: error })));
996
- }
997
- if (value) {
998
- 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!" }))] })));
999
- }
1000
- if (!(clientSecret && stripePromise))
1001
- return (0, jsx_runtime_1.jsx)(LinearProgress_1.default, {});
1002
- if (isCheckout && stripePromise)
1003
- return ((0, jsx_runtime_1.jsx)(react_stripe_js_1.EmbeddedCheckoutProvider, __assign({ stripe: stripePromise, options: {
1004
- clientSecret: clientSecret,
1005
- onComplete: function () { return onChange(answertext || 'Completed checkout', field.id); },
1006
- } }, { children: (0, jsx_runtime_1.jsx)(react_stripe_js_1.EmbeddedCheckout, {}) })));
1007
- return ((0, jsx_runtime_1.jsx)(react_stripe_js_1.Elements, __assign({ stripe: stripePromise, options: {
1008
- clientSecret: clientSecret,
1009
- } }, { children: (0, jsx_runtime_1.jsx)(StripeForm, { businessName: businessName, onSuccess: function () { return onChange(answertext || 'Saved card details', field.id); }, cost: cost, field: field }) })));
1010
- };
1011
- exports.StripeInput = StripeInput;
1012
- var StripeForm = function (_a) {
1013
- var _b, _d, _e;
1014
- var businessName = _a.businessName, onSuccess = _a.onSuccess, field = _a.field, cost = _a.cost;
1015
- var stripe = (0, react_stripe_js_1.useStripe)();
1016
- var elements = (0, react_stripe_js_1.useElements)();
1017
- var _f = (0, react_1.useState)(false), ready = _f[0], setReady = _f[1];
1018
- var _g = (0, react_1.useState)(''), errorMessage = _g[0], setErrorMessage = _g[1];
1019
- var handleSubmit = function (event) { return __awaiter(void 0, void 0, void 0, function () {
1020
- var error;
1021
- var _a, _b;
1022
- return __generator(this, function (_d) {
1023
- switch (_d.label) {
1024
- case 0:
1025
- // We don't want to let default form submission happen here,
1026
- // which would refresh the page.
1027
- event === null || event === void 0 ? void 0 : event.preventDefault();
1028
- if (!stripe || !elements) {
1029
- // Stripe.js hasn't yet loaded.
1030
- // Make sure to disable form submission until Stripe.js has loaded.
1031
- return [2 /*return*/, null];
1032
- }
1033
- return [4 /*yield*/, (((_a = field.options) === null || _a === void 0 ? void 0 : _a.chargeImmediately) ? stripe.confirmPayment : stripe.confirmSetup)({
1034
- //`Elements` instance that was used to create the Payment Element
1035
- elements: elements,
1036
- confirmParams: {
1037
- return_url: window.location.href,
1038
- },
1039
- redirect: 'if_required', // ensures the redirect url won't be used, unless the Bank redirect payment type is enabled (it's not, just card)
1040
- })];
1041
- case 1:
1042
- error = (_d.sent()).error;
1043
- if (error) {
1044
- // This point will only be reached if there is an immediate error when
1045
- // confirming the payment. Show error to your customer (for example, payment
1046
- // details incomplete)
1047
- setErrorMessage((_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : '');
1048
- }
1049
- else {
1050
- onSuccess();
1051
- // Your customer will be redirected to your `return_url`. For some payment
1052
- // methods like iDEAL, your customer will be redirected to an intermediate
1053
- // site first to authorize the payment, then redirected to the `return_url`.
1054
- }
1055
- return [2 /*return*/];
1056
- }
1057
- });
1058
- }); };
1059
- 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: {
1060
- business: { name: businessName },
1061
- } }), (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 &&
1062
- (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)
1063
- ? field.options.customPriceMessage.replaceAll('{{PRICE}}', "$".concat((cost / 100).toFixed(2)))
1064
- : "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 &&
1065
- (0, jsx_runtime_1.jsx)(material_1.Typography, __assign({ color: "error", sx: { mt: 0.5 } }, { children: errorMessage }))] })));
1066
- };
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; } });
1067
865
  var Progress = function (_a) {
1068
866
  var numerator = _a.numerator, denominator = _a.denominator, style = _a.style, color = _a.color;
1069
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 ? {
@@ -1724,7 +1522,7 @@ var contact_is_valid = function (e) {
1724
1522
  exports.contact_is_valid = contact_is_valid;
1725
1523
  var RelatedContactsInput = function (_a) {
1726
1524
  var _b, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _w, _x;
1727
- 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"]);
1728
1526
  // safeguard against any rogue values like empty string
1729
1527
  var value = Array.isArray(_value) ? _value : [];
1730
1528
  var _y = (0, react_1.useState)(value.length === 1 ? 0 : -1), editing = _y[0], setEditing = _y[1];
@@ -1743,7 +1541,7 @@ var RelatedContactsInput = function (_a) {
1743
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')) &&
1744
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')) &&
1745
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')) &&
1746
- (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 &&
1747
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) {
1748
1546
  var info = _a.info, label = _a.label, type = _a.type;
1749
1547
  return ((0, jsx_runtime_1.jsx)(material_1.Grid, __assign({ item: true, xs: 6 }, { children: type === 'Text'
@@ -1763,7 +1561,7 @@ var RelatedContactsInput = function (_a) {
1763
1561
  return i === editing ? __assign(__assign({}, v), { fields: __assign(__assign({}, fields_1), (_a = {}, _a[label] = e.target.value, _a)) }) : v;
1764
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)); })] }))] })))
1765
1563
  : null }), i));
1766
- }) })) })), (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 &&
1767
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 })) }))] })));
1768
1566
  }
1769
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" })) }))] })));