@bigbinary/neeto-molecules 5.1.18 → 5.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EmailForm.js +2 -0
- package/dist/EmailForm.js.map +1 -1
- package/dist/EmailPreview.js +1 -20
- package/dist/EmailPreview.js.map +1 -1
- package/dist/GoogleFontPicker.js +1 -449
- package/dist/GoogleFontPicker.js.map +1 -1
- package/dist/IconPicker.js +6 -914
- package/dist/IconPicker.js.map +1 -1
- package/dist/SendToFields.js +3 -1943
- package/dist/SendToFields.js.map +1 -1
- package/dist/ShareViaEmail.js +2 -0
- package/dist/ShareViaEmail.js.map +1 -1
- package/dist/avatar-placeholder-DEjUhVlU.js +23 -0
- package/dist/avatar-placeholder-DEjUhVlU.js.map +1 -0
- package/dist/cjs/EmailForm.js +2 -0
- package/dist/cjs/EmailForm.js.map +1 -1
- package/dist/cjs/EmailPreview.js +2 -39
- package/dist/cjs/EmailPreview.js.map +1 -1
- package/dist/cjs/GoogleFontPicker.js +9 -457
- package/dist/cjs/GoogleFontPicker.js.map +1 -1
- package/dist/cjs/IconPicker.js +6 -914
- package/dist/cjs/IconPicker.js.map +1 -1
- package/dist/cjs/SendToFields.js +4 -1944
- package/dist/cjs/SendToFields.js.map +1 -1
- package/dist/cjs/ShareViaEmail.js +2 -0
- package/dist/cjs/ShareViaEmail.js.map +1 -1
- package/dist/cjs/avatar-placeholder-CSJpe1V0.js +44 -0
- package/dist/cjs/avatar-placeholder-CSJpe1V0.js.map +1 -0
- package/dist/cjs/download-B53zeKGa.js +21 -0
- package/dist/cjs/download-B53zeKGa.js.map +1 -0
- package/dist/cjs/index.es-Bcx0v5Pd.js +454 -0
- package/dist/cjs/index.es-Bcx0v5Pd.js.map +1 -0
- package/dist/cjs/index.esm-Bb1Vtlp2.js +919 -0
- package/dist/cjs/index.esm-Bb1Vtlp2.js.map +1 -0
- package/dist/cjs/papaparse-B5u_uWB3.js +1948 -0
- package/dist/cjs/papaparse-B5u_uWB3.js.map +1 -0
- package/dist/cjs/upload-C5ZnN-d5.js +21 -0
- package/dist/cjs/upload-C5ZnN-d5.js.map +1 -0
- package/dist/cjs/v2/CalendarView.js +1 -0
- package/dist/cjs/v2/CalendarView.js.map +1 -1
- package/dist/cjs/v2/DeleteArchiveModal.js +91 -0
- package/dist/cjs/v2/DeleteArchiveModal.js.map +1 -0
- package/dist/cjs/v2/DownloadMobileAppCallout.js +43 -0
- package/dist/cjs/v2/DownloadMobileAppCallout.js.map +1 -0
- package/dist/cjs/v2/EmailForm.js +622 -0
- package/dist/cjs/v2/EmailForm.js.map +1 -0
- package/dist/cjs/v2/EmailPreview.js +138 -0
- package/dist/cjs/v2/EmailPreview.js.map +1 -0
- package/dist/cjs/v2/EmojiReactions.js +82 -0
- package/dist/cjs/v2/EmojiReactions.js.map +1 -0
- package/dist/cjs/v2/FileUpload.js +5 -19
- package/dist/cjs/v2/FileUpload.js.map +1 -1
- package/dist/cjs/v2/GoogleFontPicker.js +130 -0
- package/dist/cjs/v2/GoogleFontPicker.js.map +1 -0
- package/dist/cjs/v2/IconPicker.js +274 -0
- package/dist/cjs/v2/IconPicker.js.map +1 -0
- package/dist/cjs/v2/SendToFields.js +313 -0
- package/dist/cjs/v2/SendToFields.js.map +1 -0
- package/dist/cjs/v2/SubHeader.js +4 -18
- package/dist/cjs/v2/SubHeader.js.map +1 -1
- package/dist/download-CZ7Q6k7-.js +19 -0
- package/dist/download-CZ7Q6k7-.js.map +1 -0
- package/dist/index.es-BQ-dr8y1.js +451 -0
- package/dist/index.es-BQ-dr8y1.js.map +1 -0
- package/dist/index.esm-DLni3-hz.js +917 -0
- package/dist/index.esm-DLni3-hz.js.map +1 -0
- package/dist/papaparse-p7fkGgWo.js +1946 -0
- package/dist/papaparse-p7fkGgWo.js.map +1 -0
- package/dist/upload-BNvlRoRJ.js +19 -0
- package/dist/upload-BNvlRoRJ.js.map +1 -0
- package/dist/v2/CalendarView.js +1 -0
- package/dist/v2/CalendarView.js.map +1 -1
- package/dist/v2/DeleteArchiveModal.js +89 -0
- package/dist/v2/DeleteArchiveModal.js.map +1 -0
- package/dist/v2/DownloadMobileAppCallout.js +41 -0
- package/dist/v2/DownloadMobileAppCallout.js.map +1 -0
- package/dist/v2/EmailForm.js +596 -0
- package/dist/v2/EmailForm.js.map +1 -0
- package/dist/v2/EmailPreview.js +136 -0
- package/dist/v2/EmailPreview.js.map +1 -0
- package/dist/v2/EmojiReactions.js +80 -0
- package/dist/v2/EmojiReactions.js.map +1 -0
- package/dist/v2/FileUpload.js +4 -18
- package/dist/v2/FileUpload.js.map +1 -1
- package/dist/v2/GoogleFontPicker.js +128 -0
- package/dist/v2/GoogleFontPicker.js.map +1 -0
- package/dist/v2/IconPicker.js +272 -0
- package/dist/v2/IconPicker.js.map +1 -0
- package/dist/v2/SendToFields.js +311 -0
- package/dist/v2/SendToFields.js.map +1 -0
- package/dist/v2/SubHeader.js +3 -17
- package/dist/v2/SubHeader.js.map +1 -1
- package/package.json +5 -5
- package/types/v2/DeleteArchiveModal.d.ts +16 -0
- package/types/v2/DownloadMobileAppCallout.d.ts +7 -0
- package/types/v2/EmailForm.d.ts +88 -0
- package/types/v2/EmailFormProvider.d.ts +29 -0
- package/types/v2/EmailPreview.d.ts +16 -0
- package/types/v2/EmojiReactions.d.ts +22 -0
- package/types/v2/GoogleFontPicker.d.ts +19 -0
- package/types/v2/IconPicker.d.ts +11 -0
- package/types/v2/SendToFields.d.ts +25 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Callout } from '@bigbinary/neeto-atoms';
|
|
2
|
+
import { globalProps } from '@bigbinary/neeto-commons-frontend/v2/initializers';
|
|
3
|
+
import { Trans } from 'react-i18next';
|
|
4
|
+
import { useLocation } from 'react-router-dom';
|
|
5
|
+
import { U as UAParser } from '../ua-parser-OzUiuIwt.js';
|
|
6
|
+
import { jsx } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
var MOBILE_PLATFORMS = ["Android", "iOS", "Windows Phone"];
|
|
9
|
+
|
|
10
|
+
var DownloadMobileAppCallout = function DownloadMobileAppCallout(_ref) {
|
|
11
|
+
var _globalProps$appName;
|
|
12
|
+
var excludePathRegex = _ref.excludePathRegex;
|
|
13
|
+
var _useLocation = useLocation(),
|
|
14
|
+
pathname = _useLocation.pathname;
|
|
15
|
+
var parser = new UAParser(navigator.userAgent);
|
|
16
|
+
var result = parser.getResult();
|
|
17
|
+
var isMobilePlatform = MOBILE_PLATFORMS.includes(result.os.name);
|
|
18
|
+
if (!isMobilePlatform) return null;
|
|
19
|
+
var shouldExcludePath = excludePathRegex && excludePathRegex.test(pathname);
|
|
20
|
+
if (shouldExcludePath) return null;
|
|
21
|
+
var appName = (_globalProps$appName = globalProps.appName) === null || _globalProps$appName === void 0 ? void 0 : _globalProps$appName.toLowerCase();
|
|
22
|
+
var mobileAppDownloadUrl = "https://www.neeto.com/".concat(appName, "/mobile");
|
|
23
|
+
return /*#__PURE__*/jsx(Callout, {
|
|
24
|
+
className: "m-4",
|
|
25
|
+
variant: "warning",
|
|
26
|
+
children: /*#__PURE__*/jsx(Trans, {
|
|
27
|
+
i18nKey: "neetoMolecules.downloadMobileAppCallout.message",
|
|
28
|
+
components: {
|
|
29
|
+
a: /*#__PURE__*/jsx("a", {
|
|
30
|
+
className: "text-primary decoration-primary/40 hover:decoration-primary underline underline-offset-4",
|
|
31
|
+
href: mobileAppDownloadUrl,
|
|
32
|
+
rel: "noreferrer",
|
|
33
|
+
target: "_blank"
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { DownloadMobileAppCallout as default };
|
|
41
|
+
//# sourceMappingURL=DownloadMobileAppCallout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DownloadMobileAppCallout.js","sources":["../../src/v2/components/DownloadMobileAppCallout/constants.js","../../src/v2/components/DownloadMobileAppCallout/index.jsx"],"sourcesContent":["export const MOBILE_PLATFORMS = [\"Android\", \"iOS\", \"Windows Phone\"];\n","import { Callout } from \"@bigbinary/neeto-atoms\";\nimport { globalProps } from \"neetocommons/v2/initializers\";\nimport PropTypes from \"prop-types\";\nimport { Trans } from \"react-i18next\";\nimport { useLocation } from \"react-router-dom\";\nimport { UAParser } from \"ua-parser-js\";\n\nimport { MOBILE_PLATFORMS } from \"./constants\";\n\nconst DownloadMobileAppCallout = ({ excludePathRegex }) => {\n const { pathname } = useLocation();\n\n const parser = new UAParser(navigator.userAgent);\n const result = parser.getResult();\n const isMobilePlatform = MOBILE_PLATFORMS.includes(result.os.name);\n if (!isMobilePlatform) return null;\n\n const shouldExcludePath = excludePathRegex && excludePathRegex.test(pathname);\n if (shouldExcludePath) return null;\n\n const appName = globalProps.appName?.toLowerCase();\n const mobileAppDownloadUrl = `https://www.neeto.com/${appName}/mobile`;\n\n return (\n <Callout className=\"m-4\" variant=\"warning\">\n <Trans\n i18nKey=\"neetoMolecules.downloadMobileAppCallout.message\"\n components={{\n a: (\n <a\n className=\"text-primary decoration-primary/40 hover:decoration-primary underline underline-offset-4\"\n href={mobileAppDownloadUrl}\n rel=\"noreferrer\"\n target=\"_blank\"\n />\n ),\n }}\n />\n </Callout>\n );\n};\n\nDownloadMobileAppCallout.propTypes = {\n /**\n * To exclude specific paths where download mobile app callout should be hidden.\n */\n excludePathRegex: PropTypes.instanceOf(RegExp),\n};\n\nexport default DownloadMobileAppCallout;\n"],"names":["MOBILE_PLATFORMS","DownloadMobileAppCallout","_ref","_globalProps$appName","excludePathRegex","_useLocation","useLocation","pathname","parser","UAParser","navigator","userAgent","result","getResult","isMobilePlatform","includes","os","name","shouldExcludePath","test","appName","globalProps","toLowerCase","mobileAppDownloadUrl","concat","_jsx","Callout","className","variant","children","Trans","i18nKey","components","a","href","rel","target"],"mappings":";;;;;;;AAAO,IAAMA,gBAAgB,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,eAAe,CAAC;;ACSnE,IAAMC,wBAAwB,GAAG,SAA3BA,wBAAwBA,CAAAC,IAAA,EAA6B;AAAA,EAAA,IAAAC,oBAAA;AAAA,EAAA,IAAvBC,gBAAgB,GAAAF,IAAA,CAAhBE,gBAAgB;AAClD,EAAA,IAAAC,YAAA,GAAqBC,WAAW,EAAE;IAA1BC,QAAQ,GAAAF,YAAA,CAARE,QAAQ;EAEhB,IAAMC,MAAM,GAAG,IAAIC,QAAQ,CAACC,SAAS,CAACC,SAAS,CAAC;AAChD,EAAA,IAAMC,MAAM,GAAGJ,MAAM,CAACK,SAAS,EAAE;EACjC,IAAMC,gBAAgB,GAAGd,gBAAgB,CAACe,QAAQ,CAACH,MAAM,CAACI,EAAE,CAACC,IAAI,CAAC;AAClE,EAAA,IAAI,CAACH,gBAAgB,EAAE,OAAO,IAAI;EAElC,IAAMI,iBAAiB,GAAGd,gBAAgB,IAAIA,gBAAgB,CAACe,IAAI,CAACZ,QAAQ,CAAC;EAC7E,IAAIW,iBAAiB,EAAE,OAAO,IAAI;AAElC,EAAA,IAAME,OAAO,GAAA,CAAAjB,oBAAA,GAAGkB,WAAW,CAACD,OAAO,MAAA,IAAA,IAAAjB,oBAAA,KAAA,MAAA,GAAA,MAAA,GAAnBA,oBAAA,CAAqBmB,WAAW,EAAE;AAClD,EAAA,IAAMC,oBAAoB,GAAA,wBAAA,CAAAC,MAAA,CAA4BJ,OAAO,EAAA,SAAA,CAAS;EAEtE,oBACEK,GAAA,CAACC,OAAO,EAAA;AAACC,IAAAA,SAAS,EAAC,KAAK;AAACC,IAAAA,OAAO,EAAC,SAAS;IAAAC,QAAA,eACxCJ,GAAA,CAACK,KAAK,EAAA;AACJC,MAAAA,OAAO,EAAC,iDAAiD;AACzDC,MAAAA,UAAU,EAAE;AACVC,QAAAA,CAAC,eACCR,GAAA,CAAA,GAAA,EAAA;AACEE,UAAAA,SAAS,EAAC,0FAA0F;AACpGO,UAAAA,IAAI,EAAEX,oBAAqB;AAC3BY,UAAAA,GAAG,EAAC,YAAY;AAChBC,UAAAA,MAAM,EAAC;SACR;AAEL;KACD;AAAC,GACK,CAAC;AAEd;;;;"}
|
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import { createContext, useState, useContext, createElement } from 'react';
|
|
3
|
+
import { Input as Input$1, Button, Tooltip } from '@bigbinary/neeto-atoms';
|
|
4
|
+
import { Select, Input, RadioGroup, ActionBlock, BlockNavigation, Switch, Form } from '@bigbinary/neeto-atoms/formik';
|
|
5
|
+
import classnames from 'classnames';
|
|
6
|
+
import { useFormikContext, Field } from 'formik';
|
|
7
|
+
import { isPresent, isNotEmpty, notEqualsDeep, noop } from '@bigbinary/neeto-cist';
|
|
8
|
+
import { globalProps } from '@bigbinary/neeto-commons-frontend/v2/initializers';
|
|
9
|
+
import FormikEditor from '@bigbinary/neeto-editor/v2/FormikEditor';
|
|
10
|
+
import { prop, equals, pluck, isEmpty } from 'ramda';
|
|
11
|
+
import { useTranslation } from 'react-i18next';
|
|
12
|
+
import { t } from 'i18next';
|
|
13
|
+
import { isEditorEmpty } from '@bigbinary/neeto-editor/utils';
|
|
14
|
+
import * as yup from 'yup';
|
|
15
|
+
import _typeof from '@babel/runtime/helpers/typeof';
|
|
16
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
17
|
+
import SendToFields from './SendToFields.js';
|
|
18
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
19
|
+
import { withEventTargetValue } from '@bigbinary/neeto-commons-frontend/v2/utils/general';
|
|
20
|
+
import DynamicVariables from './DynamicVariables.js';
|
|
21
|
+
import Header from './Header.js';
|
|
22
|
+
import MobilePreviewHeader from './MobilePreviewHeader.js';
|
|
23
|
+
import EmailPreview from './EmailPreview.js';
|
|
24
|
+
import '@babel/runtime/helpers/toConsumableArray';
|
|
25
|
+
import 'react-dropzone';
|
|
26
|
+
import '@bigbinary/neeto-commons-frontend/v2/react-utils';
|
|
27
|
+
import '../download-CZ7Q6k7-.js';
|
|
28
|
+
import '../createLucideIcon-mNMhCCpf.js';
|
|
29
|
+
import '../upload-BNvlRoRJ.js';
|
|
30
|
+
import '../papaparse-p7fkGgWo.js';
|
|
31
|
+
import '../_commonjsHelpers-BFTU3MAI.js';
|
|
32
|
+
import 'stream';
|
|
33
|
+
import '@babel/runtime/helpers/objectWithoutProperties';
|
|
34
|
+
import './Breadcrumbs.js';
|
|
35
|
+
import '@bigbinary/neeto-atoms/primitives';
|
|
36
|
+
import 'react-router-dom';
|
|
37
|
+
import './HelpPopover.js';
|
|
38
|
+
import '../circle-question-mark-Dib48f5Z.js';
|
|
39
|
+
import './MoreDropdown.js';
|
|
40
|
+
import '../ellipsis-DpI9xqUK.js';
|
|
41
|
+
import './Search.js';
|
|
42
|
+
import '@bigbinary/neeto-commons-frontend/v2/react-utils/useFuncDebounce';
|
|
43
|
+
import '@bigbinary/neeto-commons-frontend/v2/react-utils/useQueryParams';
|
|
44
|
+
import '@bigbinary/neeto-commons-frontend/v2/react-utils/useUpdateEffect';
|
|
45
|
+
import '@bigbinary/neeto-commons-frontend/v2/utils';
|
|
46
|
+
import '../search-DCgpNjip.js';
|
|
47
|
+
import '@bigbinary/neeto-commons-frontend/react-utils';
|
|
48
|
+
import '../index-DAYCJu79.js';
|
|
49
|
+
import '@bigbinary/neeto-editor/EditorContent';
|
|
50
|
+
import '../avatar-placeholder-DEjUhVlU.js';
|
|
51
|
+
|
|
52
|
+
var INITIAL_FORM_VALUES = {
|
|
53
|
+
sendTo: [],
|
|
54
|
+
sendToId: "",
|
|
55
|
+
sendToCc: [],
|
|
56
|
+
sendToBcc: [],
|
|
57
|
+
replyTo: "",
|
|
58
|
+
showCopyEmails: false,
|
|
59
|
+
subject: "",
|
|
60
|
+
message: "",
|
|
61
|
+
isEnabled: false
|
|
62
|
+
};
|
|
63
|
+
var EMAIL_FORM_VALIDATION_SCHEMA = yup.object({
|
|
64
|
+
subject: yup.string().required(t("neetoMolecules.emailForm.errors.subjectRequired")),
|
|
65
|
+
message: yup.string().test("message", t("neetoMolecules.emailForm.errors.messageRequired"), function (value) {
|
|
66
|
+
return !isEditorEmpty(value);
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
var sendToFieldValidation = function sendToFieldValidation(maxEmails) {
|
|
70
|
+
var validation = yup.array().test("all-emails-valid", t("neetoMolecules.emailForm.errors.invalidEmailAddress"), function (emails) {
|
|
71
|
+
return emails === null || emails === void 0 ? void 0 : emails.every(prop("valid"));
|
|
72
|
+
}).test("max-email-count", t("neetoMolecules.emailForm.errors.maxEmails", {
|
|
73
|
+
count: maxEmails
|
|
74
|
+
}), function (emails) {
|
|
75
|
+
return (emails === null || emails === void 0 ? void 0 : emails.length) <= maxEmails;
|
|
76
|
+
});
|
|
77
|
+
return yup.object({
|
|
78
|
+
sendTo: validation.min(1, t("neetoMolecules.emailForm.errors.required", {
|
|
79
|
+
entity: t("neetoMolecules.emailForm.fields.sendToEmailAddress")
|
|
80
|
+
})).nullable(),
|
|
81
|
+
sendToCc: validation,
|
|
82
|
+
sendToBcc: validation
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
var SEND_TO_ID_FIELD_VALIDATION = yup.object({
|
|
86
|
+
sendToId: yup.string().required(t("neetoMolecules.emailForm.errors.required", {
|
|
87
|
+
entity: t("neetoMolecules.emailForm.labels.sendTo")
|
|
88
|
+
}))
|
|
89
|
+
});
|
|
90
|
+
var REPLY_TO_FIELD_VALIDATION = yup.object({
|
|
91
|
+
replyTo: yup.string().nullable().email(t("neetoMolecules.emailForm.errors.invalidEmailAddress")).required(t("neetoMolecules.emailForm.errors.required", {
|
|
92
|
+
entity: t("neetoMolecules.emailForm.fields.replyToEmailAddress")
|
|
93
|
+
}))
|
|
94
|
+
});
|
|
95
|
+
var EDITOR_ADDONS = ["highlight", "emoji", "code-block", "block-quote", "image-upload", "divider", "video-embed"];
|
|
96
|
+
|
|
97
|
+
/* eslint-disable @bigbinary/neeto/use-zustand-for-global-state-management */
|
|
98
|
+
var EmailFormContext = /*#__PURE__*/createContext({
|
|
99
|
+
showSendToField: false,
|
|
100
|
+
showSendToAsRadio: false,
|
|
101
|
+
showReplyToField: false,
|
|
102
|
+
showCcField: false,
|
|
103
|
+
showBccField: false
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
107
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
108
|
+
var getValidationSchema = function getValidationSchema(_ref) {
|
|
109
|
+
var showSendToField = _ref.showSendToField,
|
|
110
|
+
showReplyToField = _ref.showReplyToField,
|
|
111
|
+
showSendToAsRadio = _ref.showSendToAsRadio,
|
|
112
|
+
customValidations = _ref.customValidations,
|
|
113
|
+
maxEmails = _ref.maxEmails;
|
|
114
|
+
var schema = EMAIL_FORM_VALIDATION_SCHEMA.clone();
|
|
115
|
+
if (showSendToField) {
|
|
116
|
+
schema = schema.concat(showSendToAsRadio ? SEND_TO_ID_FIELD_VALIDATION : sendToFieldValidation(maxEmails));
|
|
117
|
+
}
|
|
118
|
+
if (showReplyToField) schema = schema.concat(REPLY_TO_FIELD_VALIDATION);
|
|
119
|
+
var isYupObject = customValidations.type === "object";
|
|
120
|
+
if (isYupObject) {
|
|
121
|
+
var customFields = customValidations.fields || {};
|
|
122
|
+
schema = schema.shape(customFields);
|
|
123
|
+
} else if (_typeof(customValidations) === "object") {
|
|
124
|
+
schema = schema.shape(customValidations);
|
|
125
|
+
}
|
|
126
|
+
return schema;
|
|
127
|
+
};
|
|
128
|
+
var getReplyToFieldLabelProps = function getReplyToFieldLabelProps(_ref2) {
|
|
129
|
+
var popoverProps = _ref2.popoverProps;
|
|
130
|
+
return {
|
|
131
|
+
helpIconProps: _objectSpread$3({
|
|
132
|
+
className: "reply-to-help-icon"
|
|
133
|
+
}, isPresent(popoverProps) ? {
|
|
134
|
+
popoverProps: _objectSpread$3(_objectSpread$3({}, popoverProps), {}, {
|
|
135
|
+
description: popoverProps.description || t("neetoMolecules.emailForm.tooltips.replyTo")
|
|
136
|
+
})
|
|
137
|
+
} : {
|
|
138
|
+
tooltipProps: {
|
|
139
|
+
content: t("neetoMolecules.emailForm.tooltips.replyTo")
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
var resolveContent = function resolveContent(content, func, variable) {
|
|
145
|
+
if (typeof func === "function") {
|
|
146
|
+
return func(content, variable);
|
|
147
|
+
}
|
|
148
|
+
return content;
|
|
149
|
+
};
|
|
150
|
+
var normalizeHtmlString = function normalizeHtmlString(str) {
|
|
151
|
+
if (typeof str !== "string") return str;
|
|
152
|
+
return str.replace(/\uFEFF/g, "").replace(/\r\n|\r/g, "\n").replace(/ /g, " ").replace(/[\t ]+/g, " ").replace(/\s*\n\s*/g, "\n").replace(/\n+/g, "\n").replace(/>\s+</g, "><").trim();
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
var ReplyToField = function ReplyToField(_ref) {
|
|
156
|
+
var _ref$options = _ref.options,
|
|
157
|
+
options = _ref$options === void 0 ? [] : _ref$options,
|
|
158
|
+
_ref$popoverProps = _ref.popoverProps,
|
|
159
|
+
popoverProps = _ref$popoverProps === void 0 ? {} : _ref$popoverProps;
|
|
160
|
+
var _useTranslation = useTranslation(),
|
|
161
|
+
t = _useTranslation.t;
|
|
162
|
+
var _useFormikContext = useFormikContext(),
|
|
163
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
164
|
+
var isDropdownField = isNotEmpty(options);
|
|
165
|
+
var labelProps = getReplyToFieldLabelProps({
|
|
166
|
+
popoverProps: popoverProps
|
|
167
|
+
});
|
|
168
|
+
if (isDropdownField) {
|
|
169
|
+
return /*#__PURE__*/jsx(Select, {
|
|
170
|
+
labelProps: labelProps,
|
|
171
|
+
options: options,
|
|
172
|
+
isClearable: true,
|
|
173
|
+
className: "w-full",
|
|
174
|
+
"data-testid": "reply-to-select-field",
|
|
175
|
+
label: t("neetoMolecules.emailForm.labels.replyTo"),
|
|
176
|
+
name: "replyTo",
|
|
177
|
+
onChange: function onChange(value) {
|
|
178
|
+
return setFieldValue("replyTo", value !== null && value !== void 0 ? value : "");
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
return /*#__PURE__*/jsx(Input, {
|
|
183
|
+
labelProps: labelProps,
|
|
184
|
+
autoFocus: true,
|
|
185
|
+
nakedInput: true,
|
|
186
|
+
required: true,
|
|
187
|
+
className: "w-full",
|
|
188
|
+
"data-testid": "reply-to-input-field",
|
|
189
|
+
label: t("neetoMolecules.emailForm.labels.replyTo"),
|
|
190
|
+
name: "replyTo",
|
|
191
|
+
placeholder: t("neetoMolecules.emailForm.placeholders.emailPlaceholder"),
|
|
192
|
+
size: "large",
|
|
193
|
+
onChange: function onChange(event) {
|
|
194
|
+
var _event$target$value;
|
|
195
|
+
return setFieldValue("replyTo", (_event$target$value = event.target.value) === null || _event$target$value === void 0 ? void 0 : _event$target$value.toLowerCase());
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
var SendToField = function SendToField(_ref) {
|
|
201
|
+
var showBccField = _ref.showBccField,
|
|
202
|
+
showCcField = _ref.showCcField,
|
|
203
|
+
showSendToTextField = _ref.showSendToTextField;
|
|
204
|
+
var _useTranslation = useTranslation(),
|
|
205
|
+
t = _useTranslation.t;
|
|
206
|
+
if (!showSendToTextField && !showBccField && !showCcField) return null;
|
|
207
|
+
return /*#__PURE__*/jsx(SendToFields, {
|
|
208
|
+
showCcBccButton: true,
|
|
209
|
+
showBccField: showSendToTextField ? false : showBccField,
|
|
210
|
+
showCcField: showSendToTextField ? false : showCcField,
|
|
211
|
+
showSendToField: showSendToTextField,
|
|
212
|
+
bccInputProps: {
|
|
213
|
+
label: t("neetoMolecules.emailForm.labels.bCc"),
|
|
214
|
+
name: "sendToBcc",
|
|
215
|
+
placeholder: t("neetoMolecules.emailForm.placeholders.commaSeparatedEmails")
|
|
216
|
+
},
|
|
217
|
+
ccInputProps: {
|
|
218
|
+
label: t("neetoMolecules.emailForm.labels.cc"),
|
|
219
|
+
name: "sendToCc",
|
|
220
|
+
placeholder: t("neetoMolecules.emailForm.placeholders.commaSeparatedEmails")
|
|
221
|
+
},
|
|
222
|
+
emailInputProps: {
|
|
223
|
+
id: "sendTo",
|
|
224
|
+
name: "sendTo",
|
|
225
|
+
label: t("neetoMolecules.emailForm.labels.sendTo"),
|
|
226
|
+
placeholder: t("neetoMolecules.emailForm.placeholders.commaSeparatedEmails"),
|
|
227
|
+
required: true
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
var SubjectField = function SubjectField(_ref) {
|
|
233
|
+
var name = _ref.name,
|
|
234
|
+
text = _ref.text,
|
|
235
|
+
updateText = _ref.updateText,
|
|
236
|
+
_ref$subjectVariables = _ref.subjectVariables,
|
|
237
|
+
subjectVariables = _ref$subjectVariables === void 0 ? [] : _ref$subjectVariables,
|
|
238
|
+
error = _ref.error,
|
|
239
|
+
_ref$required = _ref.required,
|
|
240
|
+
required = _ref$required === void 0 ? false : _ref$required,
|
|
241
|
+
onBlur = _ref.onBlur;
|
|
242
|
+
var _useState = useState(false),
|
|
243
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
244
|
+
isFieldFocusedOnce = _useState2[0],
|
|
245
|
+
setIsFieldFocusedOnce = _useState2[1];
|
|
246
|
+
var _useTranslation = useTranslation(),
|
|
247
|
+
t = _useTranslation.t;
|
|
248
|
+
var tagClickHandler = function tagClickHandler(_ref2) {
|
|
249
|
+
var slug = _ref2.key,
|
|
250
|
+
category = _ref2.category;
|
|
251
|
+
var textAreaElement = document.querySelector("textarea[name=".concat(name, "]"));
|
|
252
|
+
var splitIndex = isFieldFocusedOnce && textAreaElement ? textAreaElement.selectionEnd : text.length;
|
|
253
|
+
var variable = category ? "".concat(category, ".").concat(slug) : slug;
|
|
254
|
+
var updatedSubject = [text.slice(0, splitIndex), " {{".concat(variable, "}}"), text.slice(splitIndex)].join("");
|
|
255
|
+
updateText(updatedSubject);
|
|
256
|
+
};
|
|
257
|
+
return /*#__PURE__*/jsx(Input$1, {
|
|
258
|
+
error: error,
|
|
259
|
+
name: name,
|
|
260
|
+
onBlur: onBlur,
|
|
261
|
+
required: required,
|
|
262
|
+
nakedInput: true,
|
|
263
|
+
label: t("neetoMolecules.emailForm.labels.subject"),
|
|
264
|
+
placeholder: t("neetoMolecules.emailForm.placeholders.subject"),
|
|
265
|
+
value: text,
|
|
266
|
+
suffix: /*#__PURE__*/jsx(DynamicVariables, {
|
|
267
|
+
buttonProps: {
|
|
268
|
+
className: "m-1"
|
|
269
|
+
},
|
|
270
|
+
dropdownProps: {
|
|
271
|
+
className: "overflow-y-auto"
|
|
272
|
+
},
|
|
273
|
+
variables: subjectVariables,
|
|
274
|
+
onVariableClick: tagClickHandler
|
|
275
|
+
}),
|
|
276
|
+
onChange: withEventTargetValue(updateText),
|
|
277
|
+
onFocus: function onFocus() {
|
|
278
|
+
return setIsFieldFocusedOnce(true);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
284
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
285
|
+
var EmailForm = function EmailForm(_ref) {
|
|
286
|
+
var _globalProps$user;
|
|
287
|
+
var _ref$messageVariables = _ref.messageVariables,
|
|
288
|
+
messageVariables = _ref$messageVariables === void 0 ? [] : _ref$messageVariables,
|
|
289
|
+
_ref$subjectVariables = _ref.subjectVariables,
|
|
290
|
+
subjectVariables = _ref$subjectVariables === void 0 ? [] : _ref$subjectVariables,
|
|
291
|
+
handleCancel = _ref.handleCancel,
|
|
292
|
+
handleResetToDefault = _ref.handleResetToDefault,
|
|
293
|
+
isLoading = _ref.isLoading,
|
|
294
|
+
replyToFieldProps = _ref.replyToFieldProps,
|
|
295
|
+
sendToFieldProps = _ref.sendToFieldProps,
|
|
296
|
+
replyToOptions = _ref.replyToOptions,
|
|
297
|
+
_ref$sendToOptions = _ref.sendToOptions,
|
|
298
|
+
sendToOptions = _ref$sendToOptions === void 0 ? [] : _ref$sendToOptions,
|
|
299
|
+
_ref$isUpdating = _ref.isUpdating,
|
|
300
|
+
isUpdating = _ref$isUpdating === void 0 ? false : _ref$isUpdating,
|
|
301
|
+
_ref$isResetting = _ref.isResetting,
|
|
302
|
+
isResetting = _ref$isResetting === void 0 ? false : _ref$isResetting,
|
|
303
|
+
_ref$showFields = _ref.showFields,
|
|
304
|
+
showFields = _ref$showFields === void 0 ? true : _ref$showFields,
|
|
305
|
+
_ref$className = _ref.className,
|
|
306
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
307
|
+
_ref$editorAddons = _ref.editorAddons,
|
|
308
|
+
editorAddons = _ref$editorAddons === void 0 ? EDITOR_ADDONS : _ref$editorAddons,
|
|
309
|
+
showResetToDefaultButton = _ref.showResetToDefaultButton,
|
|
310
|
+
_ref$editorRef = _ref.editorRef,
|
|
311
|
+
editorRef = _ref$editorRef === void 0 ? null : _ref$editorRef,
|
|
312
|
+
_ref$defaultValues = _ref.defaultValues,
|
|
313
|
+
defaultValues = _ref$defaultValues === void 0 ? {} : _ref$defaultValues;
|
|
314
|
+
var _useTranslation = useTranslation(),
|
|
315
|
+
t = _useTranslation.t;
|
|
316
|
+
var _useContext = useContext(EmailFormContext),
|
|
317
|
+
showSendToField = _useContext.showSendToField,
|
|
318
|
+
showSendToAsRadio = _useContext.showSendToAsRadio,
|
|
319
|
+
showReplyToField = _useContext.showReplyToField,
|
|
320
|
+
showCcField = _useContext.showCcField,
|
|
321
|
+
showBccField = _useContext.showBccField;
|
|
322
|
+
var _useFormikContext = useFormikContext(),
|
|
323
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
324
|
+
values = _useFormikContext.values,
|
|
325
|
+
resetForm = _useFormikContext.resetForm;
|
|
326
|
+
var normalizedValues = _objectSpread$2(_objectSpread$2({}, values), {}, {
|
|
327
|
+
message: normalizeHtmlString(values.message)
|
|
328
|
+
});
|
|
329
|
+
var normalizedDefaultValues = _objectSpread$2(_objectSpread$2({}, defaultValues), {}, {
|
|
330
|
+
message: normalizeHtmlString(defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues.message)
|
|
331
|
+
});
|
|
332
|
+
normalizedDefaultValues.replyTo || (normalizedDefaultValues.replyTo = (_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.email);
|
|
333
|
+
var disabled = equals(normalizedValues, normalizedDefaultValues);
|
|
334
|
+
var sendToFieldOptions = (sendToFieldProps === null || sendToFieldProps === void 0 ? void 0 : sendToFieldProps.options) || sendToOptions;
|
|
335
|
+
var showSendToRadioField = showSendToField && showSendToAsRadio && isNotEmpty(sendToFieldOptions);
|
|
336
|
+
var showSendToTextField = showSendToField && !showSendToRadioField;
|
|
337
|
+
return /*#__PURE__*/jsxs("div", {
|
|
338
|
+
"data-testid": "email-form",
|
|
339
|
+
className: classnames("flex flex-1 flex-col items-start gap-2 !pb-0", _defineProperty({}, className, className)),
|
|
340
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
341
|
+
className: "w-full grow",
|
|
342
|
+
children: showFields && /*#__PURE__*/jsxs("div", {
|
|
343
|
+
className: "flex w-full flex-col items-start justify-start gap-5",
|
|
344
|
+
children: [showSendToRadioField && /*#__PURE__*/jsx(RadioGroup, {
|
|
345
|
+
className: "pb-2",
|
|
346
|
+
"data-testid": "send-to-id",
|
|
347
|
+
label: t("neetoMolecules.emailForm.labels.sendTo"),
|
|
348
|
+
labelProps: {
|
|
349
|
+
required: true
|
|
350
|
+
},
|
|
351
|
+
name: "sendToId",
|
|
352
|
+
children: sendToFieldOptions.map(function (_ref2) {
|
|
353
|
+
var label = _ref2.label,
|
|
354
|
+
value = _ref2.value;
|
|
355
|
+
return /*#__PURE__*/createElement(RadioGroup.Item, {
|
|
356
|
+
label: label,
|
|
357
|
+
value: value,
|
|
358
|
+
key: value
|
|
359
|
+
});
|
|
360
|
+
})
|
|
361
|
+
}), /*#__PURE__*/jsx(SendToField, {
|
|
362
|
+
showBccField: showBccField,
|
|
363
|
+
showCcField: showCcField,
|
|
364
|
+
showSendToTextField: showSendToTextField
|
|
365
|
+
}), showReplyToField && /*#__PURE__*/jsx("div", {
|
|
366
|
+
className: "border-border w-full border-b pb-1",
|
|
367
|
+
children: /*#__PURE__*/jsx(ReplyToField, _objectSpread$2({
|
|
368
|
+
options: replyToOptions
|
|
369
|
+
}, replyToFieldProps))
|
|
370
|
+
}), /*#__PURE__*/jsx(Field, {
|
|
371
|
+
name: "subject",
|
|
372
|
+
children: function children(_ref3) {
|
|
373
|
+
var _ref3$field = _ref3.field,
|
|
374
|
+
value = _ref3$field.value,
|
|
375
|
+
onBlur = _ref3$field.onBlur,
|
|
376
|
+
_ref3$meta = _ref3.meta,
|
|
377
|
+
error = _ref3$meta.error,
|
|
378
|
+
touched = _ref3$meta.touched;
|
|
379
|
+
return /*#__PURE__*/jsx("div", {
|
|
380
|
+
className: "border-border w-full border-b pb-1",
|
|
381
|
+
children: /*#__PURE__*/jsx(SubjectField, {
|
|
382
|
+
onBlur: onBlur,
|
|
383
|
+
subjectVariables: subjectVariables,
|
|
384
|
+
required: true,
|
|
385
|
+
error: touched && error ? t(error) : undefined,
|
|
386
|
+
name: "subject",
|
|
387
|
+
text: value,
|
|
388
|
+
updateText: function updateText(text) {
|
|
389
|
+
return setFieldValue("subject", text);
|
|
390
|
+
}
|
|
391
|
+
})
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
}), /*#__PURE__*/jsx("div", {
|
|
395
|
+
className: "w-full",
|
|
396
|
+
"data-testid": "message-input-container",
|
|
397
|
+
children: /*#__PURE__*/jsx(FormikEditor, {
|
|
398
|
+
required: true,
|
|
399
|
+
addons: editorAddons,
|
|
400
|
+
"data-testid": "message-input-field",
|
|
401
|
+
hideSlashCommands: false,
|
|
402
|
+
id: "form_message",
|
|
403
|
+
menuType: "fixed",
|
|
404
|
+
name: "message",
|
|
405
|
+
placeholder: t("neetoMolecules.emailForm.placeholders.message"),
|
|
406
|
+
ref: editorRef,
|
|
407
|
+
variables: messageVariables,
|
|
408
|
+
shouldUpdate: function shouldUpdate(nextProps, prevProps) {
|
|
409
|
+
return notEqualsDeep(nextProps.variables, prevProps.variables);
|
|
410
|
+
}
|
|
411
|
+
})
|
|
412
|
+
})]
|
|
413
|
+
})
|
|
414
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
415
|
+
className: "bg-background z-10 flex w-full justify-between py-6 lg:sticky lg:bottom-0",
|
|
416
|
+
children: [/*#__PURE__*/jsx(ActionBlock, {
|
|
417
|
+
cancelButtonProps: {
|
|
418
|
+
onClick: handleCancel
|
|
419
|
+
},
|
|
420
|
+
isSubmitting: isLoading || isUpdating
|
|
421
|
+
}), showResetToDefaultButton && /*#__PURE__*/jsx("div", {
|
|
422
|
+
children: /*#__PURE__*/jsx(Button, {
|
|
423
|
+
disabled: disabled,
|
|
424
|
+
"data-testid": "reset-to-default-button",
|
|
425
|
+
label: t("neetoMolecules.emailForm.labels.resetToDefault"),
|
|
426
|
+
loading: isResetting,
|
|
427
|
+
variant: "secondary",
|
|
428
|
+
onClick: function onClick() {
|
|
429
|
+
resetForm();
|
|
430
|
+
handleResetToDefault();
|
|
431
|
+
}
|
|
432
|
+
})
|
|
433
|
+
})]
|
|
434
|
+
})]
|
|
435
|
+
});
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
439
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
440
|
+
var EmailFormComponent = function EmailFormComponent(_ref) {
|
|
441
|
+
var _ref$onSubmit = _ref.onSubmit,
|
|
442
|
+
onSubmit = _ref$onSubmit === void 0 ? noop : _ref$onSubmit,
|
|
443
|
+
_ref$initialValues = _ref.initialValues,
|
|
444
|
+
initialValues = _ref$initialValues === void 0 ? INITIAL_FORM_VALUES : _ref$initialValues,
|
|
445
|
+
_children = _ref.children,
|
|
446
|
+
formikProps = _ref.formikProps,
|
|
447
|
+
validationSchema = _ref.validationSchema,
|
|
448
|
+
_ref$showSendToField = _ref.showSendToField,
|
|
449
|
+
showSendToField = _ref$showSendToField === void 0 ? false : _ref$showSendToField,
|
|
450
|
+
_ref$showReplyToField = _ref.showReplyToField,
|
|
451
|
+
showReplyToField = _ref$showReplyToField === void 0 ? false : _ref$showReplyToField,
|
|
452
|
+
_ref$showSendToAsRadi = _ref.showSendToAsRadio,
|
|
453
|
+
showSendToAsRadio = _ref$showSendToAsRadi === void 0 ? false : _ref$showSendToAsRadi,
|
|
454
|
+
_ref$blockNavigation = _ref.blockNavigation,
|
|
455
|
+
blockNavigation = _ref$blockNavigation === void 0 ? true : _ref$blockNavigation,
|
|
456
|
+
_ref$showCcField = _ref.showCcField,
|
|
457
|
+
showCcField = _ref$showCcField === void 0 ? false : _ref$showCcField,
|
|
458
|
+
_ref$showBccField = _ref.showBccField,
|
|
459
|
+
showBccField = _ref$showBccField === void 0 ? false : _ref$showBccField,
|
|
460
|
+
_ref$isLoading = _ref.isLoading,
|
|
461
|
+
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
|
|
462
|
+
_ref$maxEmails = _ref.maxEmails,
|
|
463
|
+
maxEmails = _ref$maxEmails === void 0 ? 10 : _ref$maxEmails,
|
|
464
|
+
_ref$emailFormProps = _ref.emailFormProps,
|
|
465
|
+
emailFormProps = _ref$emailFormProps === void 0 ? {} : _ref$emailFormProps,
|
|
466
|
+
_ref$emailPreviewProp = _ref.emailPreviewProps,
|
|
467
|
+
emailPreviewProps = _ref$emailPreviewProp === void 0 ? {} : _ref$emailPreviewProp,
|
|
468
|
+
_ref$headerProps = _ref.headerProps,
|
|
469
|
+
headerProps = _ref$headerProps === void 0 ? {} : _ref$headerProps,
|
|
470
|
+
_ref$tooltipProps = _ref.tooltipProps,
|
|
471
|
+
tooltipProps = _ref$tooltipProps === void 0 ? {} : _ref$tooltipProps,
|
|
472
|
+
_ref$switchProps = _ref.switchProps,
|
|
473
|
+
switchProps = _ref$switchProps === void 0 ? {} : _ref$switchProps,
|
|
474
|
+
_ref$mobilePreviewPro = _ref.mobilePreviewProps,
|
|
475
|
+
mobilePreviewProps = _ref$mobilePreviewPro === void 0 ? {} : _ref$mobilePreviewPro;
|
|
476
|
+
var formatBody = emailPreviewProps.formatBody,
|
|
477
|
+
formatSubject = emailPreviewProps.formatSubject,
|
|
478
|
+
bodyVariables = emailPreviewProps.bodyVariables,
|
|
479
|
+
subjectVariables = emailPreviewProps.subjectVariables;
|
|
480
|
+
var shouldShowFields = function shouldShowFields(values) {
|
|
481
|
+
return isEmpty(switchProps) || values.isEnabled;
|
|
482
|
+
};
|
|
483
|
+
return /*#__PURE__*/jsx(EmailFormProvider, {
|
|
484
|
+
formikProps: formikProps,
|
|
485
|
+
initialValues: initialValues,
|
|
486
|
+
maxEmails: maxEmails,
|
|
487
|
+
onSubmit: onSubmit,
|
|
488
|
+
showBccField: showBccField,
|
|
489
|
+
showCcField: showCcField,
|
|
490
|
+
showReplyToField: showReplyToField,
|
|
491
|
+
showSendToAsRadio: showSendToAsRadio,
|
|
492
|
+
showSendToField: showSendToField,
|
|
493
|
+
validationSchema: validationSchema,
|
|
494
|
+
children: function children(_ref2) {
|
|
495
|
+
var _values$sendTo;
|
|
496
|
+
var values = _ref2.values,
|
|
497
|
+
isSubmitting = _ref2.isSubmitting;
|
|
498
|
+
return /*#__PURE__*/jsxs("div", {
|
|
499
|
+
className: "flex h-[calc(100dvh-64px)] flex-grow flex-col overflow-y-auto lg:flex-row",
|
|
500
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
501
|
+
className: "flex w-full flex-col px-5 md:px-10 lg:h-full lg:w-1/2 lg:overflow-y-auto",
|
|
502
|
+
children: [blockNavigation && /*#__PURE__*/jsx(BlockNavigation, {}), isNotEmpty(headerProps) && /*#__PURE__*/jsx(Header, _objectSpread$1({
|
|
503
|
+
className: "px-0",
|
|
504
|
+
size: "small"
|
|
505
|
+
}, headerProps)), isNotEmpty(switchProps) && /*#__PURE__*/jsx("div", {
|
|
506
|
+
className: "flex items-center justify-between gap-y-0.5 pb-6",
|
|
507
|
+
children: /*#__PURE__*/jsx(Tooltip, _objectSpread$1(_objectSpread$1({
|
|
508
|
+
disabled: !(switchProps !== null && switchProps !== void 0 && switchProps.disabled),
|
|
509
|
+
position: "top"
|
|
510
|
+
}, tooltipProps), {}, {
|
|
511
|
+
children: /*#__PURE__*/jsx("div", {
|
|
512
|
+
className: "flex items-center gap-2",
|
|
513
|
+
children: /*#__PURE__*/jsx(Switch, _objectSpread$1({
|
|
514
|
+
"data-testid": "switch",
|
|
515
|
+
name: "isEnabled"
|
|
516
|
+
}, switchProps))
|
|
517
|
+
})
|
|
518
|
+
}))
|
|
519
|
+
}), shouldShowFields(values) && _children, /*#__PURE__*/jsx(EmailForm, _objectSpread$1({
|
|
520
|
+
isLoading: isSubmitting || isLoading,
|
|
521
|
+
isUpdating: isSubmitting || isLoading,
|
|
522
|
+
showFields: shouldShowFields(values)
|
|
523
|
+
}, emailFormProps))]
|
|
524
|
+
}), shouldShowFields(values) && /*#__PURE__*/jsx(MobilePreviewHeader, _objectSpread$1({
|
|
525
|
+
className: "lg:hidden"
|
|
526
|
+
}, mobilePreviewProps)), shouldShowFields(values) && /*#__PURE__*/jsx("div", {
|
|
527
|
+
className: "bg-muted w-full px-6 py-10 lg:w-1/2 lg:overflow-y-auto",
|
|
528
|
+
children: /*#__PURE__*/jsx(EmailPreview, _objectSpread$1({
|
|
529
|
+
body: resolveContent(values.message, formatBody, bodyVariables),
|
|
530
|
+
from: values.sendFrom,
|
|
531
|
+
to: pluck("value", (_values$sendTo = values === null || values === void 0 ? void 0 : values.sendTo) !== null && _values$sendTo !== void 0 ? _values$sendTo : []),
|
|
532
|
+
subject: resolveContent(values.subject, formatSubject, subjectVariables)
|
|
533
|
+
}, emailPreviewProps))
|
|
534
|
+
})]
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
541
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
542
|
+
var EmailFormProvider = function EmailFormProvider(_ref) {
|
|
543
|
+
var _globalProps$user;
|
|
544
|
+
var _ref$onSubmit = _ref.onSubmit,
|
|
545
|
+
onSubmit = _ref$onSubmit === void 0 ? noop : _ref$onSubmit,
|
|
546
|
+
_ref$initialValues = _ref.initialValues,
|
|
547
|
+
initialValues = _ref$initialValues === void 0 ? INITIAL_FORM_VALUES : _ref$initialValues,
|
|
548
|
+
children = _ref.children,
|
|
549
|
+
formikProps = _ref.formikProps,
|
|
550
|
+
_ref$validationSchema = _ref.validationSchema,
|
|
551
|
+
customValidations = _ref$validationSchema === void 0 ? {} : _ref$validationSchema,
|
|
552
|
+
_ref$showSendToField = _ref.showSendToField,
|
|
553
|
+
showSendToField = _ref$showSendToField === void 0 ? false : _ref$showSendToField,
|
|
554
|
+
_ref$showReplyToField = _ref.showReplyToField,
|
|
555
|
+
showReplyToField = _ref$showReplyToField === void 0 ? false : _ref$showReplyToField,
|
|
556
|
+
_ref$showSendToAsRadi = _ref.showSendToAsRadio,
|
|
557
|
+
showSendToAsRadio = _ref$showSendToAsRadi === void 0 ? false : _ref$showSendToAsRadi,
|
|
558
|
+
_ref$showCcField = _ref.showCcField,
|
|
559
|
+
showCcField = _ref$showCcField === void 0 ? false : _ref$showCcField,
|
|
560
|
+
_ref$showBccField = _ref.showBccField,
|
|
561
|
+
showBccField = _ref$showBccField === void 0 ? false : _ref$showBccField,
|
|
562
|
+
_ref$maxEmails = _ref.maxEmails,
|
|
563
|
+
maxEmails = _ref$maxEmails === void 0 ? 10 : _ref$maxEmails;
|
|
564
|
+
return /*#__PURE__*/jsx("div", {
|
|
565
|
+
"data-testid": "email-form-provider",
|
|
566
|
+
children: /*#__PURE__*/jsx(EmailFormContext.Provider, {
|
|
567
|
+
value: {
|
|
568
|
+
showSendToField: showSendToField,
|
|
569
|
+
showSendToAsRadio: showSendToAsRadio,
|
|
570
|
+
showReplyToField: showReplyToField,
|
|
571
|
+
showCcField: showCcField,
|
|
572
|
+
showBccField: showBccField
|
|
573
|
+
},
|
|
574
|
+
children: /*#__PURE__*/jsx(Form, {
|
|
575
|
+
formikProps: _objectSpread({
|
|
576
|
+
enableReinitialize: true,
|
|
577
|
+
validationSchema: getValidationSchema({
|
|
578
|
+
showSendToField: showSendToField,
|
|
579
|
+
showReplyToField: showReplyToField,
|
|
580
|
+
showSendToAsRadio: showSendToAsRadio,
|
|
581
|
+
customValidations: customValidations,
|
|
582
|
+
maxEmails: maxEmails
|
|
583
|
+
}),
|
|
584
|
+
initialValues: _objectSpread(_objectSpread({}, initialValues), {}, {
|
|
585
|
+
replyTo: initialValues.replyTo || ((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.email)
|
|
586
|
+
}),
|
|
587
|
+
onSubmit: onSubmit
|
|
588
|
+
}, formikProps),
|
|
589
|
+
children: children
|
|
590
|
+
})
|
|
591
|
+
})
|
|
592
|
+
});
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
export { EmailForm, EmailFormProvider, EmailPreview, EmailFormComponent as default };
|
|
596
|
+
//# sourceMappingURL=EmailForm.js.map
|