@bigbinary/neeto-email-notifications-frontend 2.2.23 → 2.2.25
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/.ready +1 -1
- package/dist/NeetoEmailNotificationForm.js +10 -1593
- package/dist/NeetoEmailNotificationForm.js.map +1 -1
- package/dist/cjs/NeetoEmailNotificationForm.js +8 -1591
- package/dist/cjs/NeetoEmailNotificationForm.js.map +1 -1
- package/dist/cjs/index.js +6 -47
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/v2/NeetoEmailNotificationForm.js +29 -1814
- package/dist/cjs/v2/NeetoEmailNotificationForm.js.map +1 -1
- package/dist/cjs/v2/index.js +4 -24
- package/dist/cjs/v2/index.js.map +1 -1
- package/dist/emailNotificationApi-234PRG05.js +64 -0
- package/dist/emailNotificationApi-234PRG05.js.map +1 -0
- package/dist/emailNotificationApi-BVsGH7CY.js +68 -0
- package/dist/emailNotificationApi-BVsGH7CY.js.map +1 -0
- package/dist/index.js +6 -47
- package/dist/index.js.map +1 -1
- package/dist/v2/NeetoEmailNotificationForm.js +33 -1818
- package/dist/v2/NeetoEmailNotificationForm.js.map +1 -1
- package/dist/v2/index.js +4 -24
- package/dist/v2/index.js.map +1 -1
- package/package.json +17 -16
- package/dist/emailNotificationApi-TbcNMxTw.js +0 -2167
- package/dist/emailNotificationApi-TbcNMxTw.js.map +0 -1
- package/dist/emailNotificationApi-rMt-NHkm.js +0 -2141
- package/dist/emailNotificationApi-rMt-NHkm.js.map +0 -1
|
@@ -1,1814 +1,20 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import FormikEditor from '@bigbinary/neeto-editor/v2/FormikEditor';
|
|
11
|
-
import { prop, isEmpty, mergeLeft, uniqBy, mergeRight, omit, pluck, equals, pick, mergeDeepLeft } from 'ramda';
|
|
12
|
-
import { Trans, useTranslation } from 'react-i18next';
|
|
13
|
-
import { t } from 'i18next';
|
|
14
|
-
import { isEditorEmpty } from '@bigbinary/neeto-editor/v2/utils';
|
|
3
|
+
import { useRef, useMemo } from 'react';
|
|
4
|
+
import { Spinner } from '@bigbinary/neeto-atoms';
|
|
5
|
+
import { isNotEmpty, isNotPresent, noop } from '@bigbinary/neeto-cist';
|
|
6
|
+
import EmailForm from '@bigbinary/neeto-molecules/v2/EmailForm';
|
|
7
|
+
import { pick, mergeLeft, isEmpty, prop, mergeDeepLeft } from 'ramda';
|
|
8
|
+
import { useTranslation } from 'react-i18next';
|
|
9
|
+
import { u as useFetchEmailNotifications, a as useUpdateEmailNotification, b as useResetEmailNotificationToDefault } from '../emailNotificationApi-234PRG05.js';
|
|
15
10
|
import * as yup from 'yup';
|
|
16
11
|
import { string } from 'yup';
|
|
17
|
-
import
|
|
18
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
19
|
-
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
20
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
21
|
-
import { useDropzone } from 'react-dropzone';
|
|
22
|
-
import { withT } from '@bigbinary/neeto-commons-frontend/v2/react-utils';
|
|
23
|
-
import { a as Papa, P as PropTypes, S as SvgAvatarPlaceholder, u as useFetchEmailNotifications, b as useUpdateEmailNotification, c as useResetEmailNotificationToDefault } from '../emailNotificationApi-rMt-NHkm.js';
|
|
24
|
-
import 'stream';
|
|
25
|
-
import { joinHyphenCase, hyphenize, buildUrl, withEventTargetValue } from '@bigbinary/neeto-commons-frontend/v2/utils/general';
|
|
26
|
-
import { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbPage, BreadcrumbLink, BreadcrumbSeparator } from '@bigbinary/neeto-atoms/primitives';
|
|
27
|
-
import { Link, useHistory } from 'react-router-dom';
|
|
28
|
-
import useFuncDebounce from '@bigbinary/neeto-commons-frontend/v2/react-utils/useFuncDebounce';
|
|
29
|
-
import useQueryParams from '@bigbinary/neeto-commons-frontend/v2/react-utils/useQueryParams';
|
|
30
|
-
import useUpdateEffect from '@bigbinary/neeto-commons-frontend/v2/react-utils/useUpdateEffect';
|
|
31
|
-
import { getQueryParams } from '@bigbinary/neeto-commons-frontend/v2/utils';
|
|
32
|
-
import { withT as withT$1 } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
33
|
-
import EditorContent from '@bigbinary/neeto-editor/v2/EditorContent';
|
|
12
|
+
import { jsx } from 'react/jsx-runtime';
|
|
34
13
|
import '@tanstack/react-query';
|
|
35
14
|
import '@bigbinary/neeto-commons-frontend/constants';
|
|
15
|
+
import '@bigbinary/neeto-commons-frontend/react-utils';
|
|
36
16
|
import 'axios';
|
|
37
17
|
|
|
38
|
-
/**
|
|
39
|
-
* @license lucide-react v1.7.0 - ISC
|
|
40
|
-
*
|
|
41
|
-
* This source code is licensed under the ISC license.
|
|
42
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
const mergeClasses = (...classes) => classes.filter((className, index, array) => {
|
|
46
|
-
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
|
|
47
|
-
}).join(" ").trim();
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @license lucide-react v1.7.0 - ISC
|
|
51
|
-
*
|
|
52
|
-
* This source code is licensed under the ISC license.
|
|
53
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
const toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @license lucide-react v1.7.0 - ISC
|
|
60
|
-
*
|
|
61
|
-
* This source code is licensed under the ISC license.
|
|
62
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
const toCamelCase = (string) => string.replace(
|
|
66
|
-
/^([A-Z])|[\s-_]+(\w)/g,
|
|
67
|
-
(match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @license lucide-react v1.7.0 - ISC
|
|
72
|
-
*
|
|
73
|
-
* This source code is licensed under the ISC license.
|
|
74
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const toPascalCase = (string) => {
|
|
79
|
-
const camelCase = toCamelCase(string);
|
|
80
|
-
return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* @license lucide-react v1.7.0 - ISC
|
|
85
|
-
*
|
|
86
|
-
* This source code is licensed under the ISC license.
|
|
87
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
var defaultAttributes = {
|
|
91
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
92
|
-
width: 24,
|
|
93
|
-
height: 24,
|
|
94
|
-
viewBox: "0 0 24 24",
|
|
95
|
-
fill: "none",
|
|
96
|
-
stroke: "currentColor",
|
|
97
|
-
strokeWidth: 2,
|
|
98
|
-
strokeLinecap: "round",
|
|
99
|
-
strokeLinejoin: "round"
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* @license lucide-react v1.7.0 - ISC
|
|
104
|
-
*
|
|
105
|
-
* This source code is licensed under the ISC license.
|
|
106
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
107
|
-
*/
|
|
108
|
-
|
|
109
|
-
const hasA11yProp = (props) => {
|
|
110
|
-
for (const prop in props) {
|
|
111
|
-
if (prop.startsWith("aria-") || prop === "role" || prop === "title") {
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return false;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const LucideContext = createContext({});
|
|
119
|
-
const useLucideContext = () => useContext(LucideContext);
|
|
120
|
-
|
|
121
|
-
const Icon = forwardRef(
|
|
122
|
-
({ color, size, strokeWidth, absoluteStrokeWidth, className = "", children, iconNode, ...rest }, ref) => {
|
|
123
|
-
const {
|
|
124
|
-
size: contextSize = 24,
|
|
125
|
-
strokeWidth: contextStrokeWidth = 2,
|
|
126
|
-
absoluteStrokeWidth: contextAbsoluteStrokeWidth = false,
|
|
127
|
-
color: contextColor = "currentColor",
|
|
128
|
-
className: contextClass = ""
|
|
129
|
-
} = useLucideContext() ?? {};
|
|
130
|
-
const calculatedStrokeWidth = absoluteStrokeWidth ?? contextAbsoluteStrokeWidth ? Number(strokeWidth ?? contextStrokeWidth) * 24 / Number(size ?? contextSize) : strokeWidth ?? contextStrokeWidth;
|
|
131
|
-
return createElement(
|
|
132
|
-
"svg",
|
|
133
|
-
{
|
|
134
|
-
ref,
|
|
135
|
-
...defaultAttributes,
|
|
136
|
-
width: size ?? contextSize ?? defaultAttributes.width,
|
|
137
|
-
height: size ?? contextSize ?? defaultAttributes.height,
|
|
138
|
-
stroke: color ?? contextColor,
|
|
139
|
-
strokeWidth: calculatedStrokeWidth,
|
|
140
|
-
className: mergeClasses("lucide", contextClass, className),
|
|
141
|
-
...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
|
|
142
|
-
...rest
|
|
143
|
-
},
|
|
144
|
-
[
|
|
145
|
-
...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
|
|
146
|
-
...Array.isArray(children) ? children : [children]
|
|
147
|
-
]
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* @license lucide-react v1.7.0 - ISC
|
|
154
|
-
*
|
|
155
|
-
* This source code is licensed under the ISC license.
|
|
156
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
157
|
-
*/
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const createLucideIcon = (iconName, iconNode) => {
|
|
161
|
-
const Component = forwardRef(
|
|
162
|
-
({ className, ...props }, ref) => createElement(Icon, {
|
|
163
|
-
ref,
|
|
164
|
-
iconNode,
|
|
165
|
-
className: mergeClasses(
|
|
166
|
-
`lucide-${toKebabCase(toPascalCase(iconName))}`,
|
|
167
|
-
`lucide-${iconName}`,
|
|
168
|
-
className
|
|
169
|
-
),
|
|
170
|
-
...props
|
|
171
|
-
})
|
|
172
|
-
);
|
|
173
|
-
Component.displayName = toPascalCase(iconName);
|
|
174
|
-
return Component;
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* @license lucide-react v1.7.0 - ISC
|
|
179
|
-
*
|
|
180
|
-
* This source code is licensed under the ISC license.
|
|
181
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
182
|
-
*/
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const __iconNode$6 = [
|
|
186
|
-
["path", { d: "M12 15V3", key: "m9g1x1" }],
|
|
187
|
-
["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }],
|
|
188
|
-
["path", { d: "m7 10 5 5 5-5", key: "brsn70" }]
|
|
189
|
-
];
|
|
190
|
-
const Download = createLucideIcon("download", __iconNode$6);
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* @license lucide-react v1.7.0 - ISC
|
|
194
|
-
*
|
|
195
|
-
* This source code is licensed under the ISC license.
|
|
196
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
197
|
-
*/
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const __iconNode$5 = [
|
|
201
|
-
["path", { d: "M12 3v12", key: "1x0j5s" }],
|
|
202
|
-
["path", { d: "m17 8-5-5-5 5", key: "7q97r8" }],
|
|
203
|
-
["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }]
|
|
204
|
-
];
|
|
205
|
-
const Upload = createLucideIcon("upload", __iconNode$5);
|
|
206
|
-
|
|
207
|
-
var CSV_FILE_SIZE_IN_KB = 32;
|
|
208
|
-
var ONE_KILOBYTE_IN_BYTES = 1024;
|
|
209
|
-
var DOWNLOAD_SAMPLE_EMAIL_CSV_FILE = "https://d2v7kzglnr2dnh.cloudfront.net/others/sample-bulk-email.csv";
|
|
210
|
-
|
|
211
|
-
var Requirements = withT(function (_ref) {
|
|
212
|
-
var t = _ref.t,
|
|
213
|
-
fileSize = _ref.fileSize;
|
|
214
|
-
return /*#__PURE__*/jsxs(Callout, {
|
|
215
|
-
className: "flex flex-col items-center py-6",
|
|
216
|
-
variant: "info",
|
|
217
|
-
children: [/*#__PURE__*/jsxs("ul", {
|
|
218
|
-
className: "flex list-outside list-disc flex-col gap-y-1 leading-normal font-normal",
|
|
219
|
-
children: [fileSize && /*#__PURE__*/jsx("li", {
|
|
220
|
-
children: t("neetoMolecules.shareViaLink.requirements.fileTypeAndSize", {
|
|
221
|
-
limit: fileSize
|
|
222
|
-
})
|
|
223
|
-
}), /*#__PURE__*/jsx("li", {
|
|
224
|
-
children: /*#__PURE__*/jsx(Trans, {
|
|
225
|
-
components: {
|
|
226
|
-
strong: /*#__PURE__*/jsx("strong", {
|
|
227
|
-
className: "font-semibold"
|
|
228
|
-
})
|
|
229
|
-
},
|
|
230
|
-
i18nKey: "neetoMolecules.shareViaLink.requirements.shouldContainColumns"
|
|
231
|
-
})
|
|
232
|
-
})]
|
|
233
|
-
}), /*#__PURE__*/jsx(Button, {
|
|
234
|
-
href: DOWNLOAD_SAMPLE_EMAIL_CSV_FILE,
|
|
235
|
-
icon: Download,
|
|
236
|
-
iconPosition: "left",
|
|
237
|
-
label: t("neetoMolecules.shareViaLink.bulkUploadPane.downloadSampleCSV"),
|
|
238
|
-
variant: "link"
|
|
239
|
-
})]
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
var Requirements$1 = /*#__PURE__*/memo(Requirements);
|
|
243
|
-
|
|
244
|
-
function ownKeys$1$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; }
|
|
245
|
-
function _objectSpread$1$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
246
|
-
var BulkUploadPane = function BulkUploadPane(_ref) {
|
|
247
|
-
var _fileRejections$;
|
|
248
|
-
var isOpen = _ref.isOpen,
|
|
249
|
-
fileSize = _ref.fileSize,
|
|
250
|
-
onClose = _ref.onClose,
|
|
251
|
-
handleFileSubmit = _ref.handleFileSubmit;
|
|
252
|
-
var _useDropzone = useDropzone({
|
|
253
|
-
accept: {
|
|
254
|
-
"text/csv": []
|
|
255
|
-
},
|
|
256
|
-
maxFiles: 1,
|
|
257
|
-
maxSize: fileSize * ONE_KILOBYTE_IN_BYTES,
|
|
258
|
-
onDrop: function onDrop(files) {
|
|
259
|
-
return files[0] && handleFileSubmit(files[0]);
|
|
260
|
-
}
|
|
261
|
-
}),
|
|
262
|
-
getRootProps = _useDropzone.getRootProps,
|
|
263
|
-
getInputProps = _useDropzone.getInputProps,
|
|
264
|
-
isDragActive = _useDropzone.isDragActive,
|
|
265
|
-
fileRejections = _useDropzone.fileRejections;
|
|
266
|
-
var errors = (_fileRejections$ = fileRejections[0]) === null || _fileRejections$ === void 0 ? void 0 : _fileRejections$.errors.map(function (_ref2) {
|
|
267
|
-
var message = _ref2.message,
|
|
268
|
-
code = _ref2.code;
|
|
269
|
-
return /*#__PURE__*/jsx(Typography, {
|
|
270
|
-
className: "text-destructive items",
|
|
271
|
-
"data-testid": "file-input-error-message",
|
|
272
|
-
variant: "body3",
|
|
273
|
-
children: message
|
|
274
|
-
}, code);
|
|
275
|
-
});
|
|
276
|
-
var _useTranslation = useTranslation(),
|
|
277
|
-
t = _useTranslation.t;
|
|
278
|
-
return /*#__PURE__*/jsx(Sheet, {
|
|
279
|
-
isOpen: isOpen,
|
|
280
|
-
onClose: onClose,
|
|
281
|
-
"aria-describedby": undefined,
|
|
282
|
-
"data-testid": "bulk-upload-pane",
|
|
283
|
-
children: /*#__PURE__*/jsxs("div", {
|
|
284
|
-
tabIndex: 0,
|
|
285
|
-
children: [/*#__PURE__*/jsx(Sheet.Header, {
|
|
286
|
-
children: /*#__PURE__*/jsx(Sheet.Title, {
|
|
287
|
-
"data-testid": "bulk-upload-header",
|
|
288
|
-
children: t("neetoMolecules.shareViaLink.bulkUpload")
|
|
289
|
-
})
|
|
290
|
-
}), /*#__PURE__*/jsx(Sheet.Body, {
|
|
291
|
-
children: /*#__PURE__*/jsxs("div", {
|
|
292
|
-
className: "flex w-full flex-col gap-y-4",
|
|
293
|
-
children: [/*#__PURE__*/jsx(Requirements$1, {
|
|
294
|
-
fileSize: fileSize
|
|
295
|
-
}), /*#__PURE__*/jsxs("div", _objectSpread$1$3(_objectSpread$1$3({}, getRootProps({
|
|
296
|
-
className: classnames("border-primary flex cursor-pointer flex-col items-center rounded-md border border-dashed p-2 transition duration-500 ease-in-out hover:bg-muted", {
|
|
297
|
-
"border-muted": isDragActive,
|
|
298
|
-
"border-destructive bg-destructive/10 hover:bg-destructive/10": fileRejections.length
|
|
299
|
-
})
|
|
300
|
-
})), {}, {
|
|
301
|
-
children: [/*#__PURE__*/jsxs("div", {
|
|
302
|
-
className: "flex flex-col items-center gap-y-3 p-4",
|
|
303
|
-
children: [/*#__PURE__*/jsx(Upload, {
|
|
304
|
-
className: "text-primary",
|
|
305
|
-
size: 32
|
|
306
|
-
}), /*#__PURE__*/jsx("input", _objectSpread$1$3(_objectSpread$1$3({}, getInputProps()), {}, {
|
|
307
|
-
"data-testid": "csv-upload-input"
|
|
308
|
-
})), isDragActive ? /*#__PURE__*/jsx(Typography, {
|
|
309
|
-
variant: "body2",
|
|
310
|
-
children: t("neetoMolecules.shareViaLink.bulkUploadPane.dropFileHere")
|
|
311
|
-
}) : /*#__PURE__*/jsxs("div", {
|
|
312
|
-
className: "flex flex-col items-center gap-y-1",
|
|
313
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
314
|
-
className: "flex w-full items-center justify-center gap-x-1",
|
|
315
|
-
children: /*#__PURE__*/jsx(Trans, {
|
|
316
|
-
i18nKey: "neetoMolecules.shareViaLink.bulkUploadPane.dragNDrop",
|
|
317
|
-
components: {
|
|
318
|
-
Button: /*#__PURE__*/jsx(Button, {
|
|
319
|
-
variant: "link"
|
|
320
|
-
})
|
|
321
|
-
}
|
|
322
|
-
})
|
|
323
|
-
}), /*#__PURE__*/jsxs(Typography, {
|
|
324
|
-
className: "text-muted-foreground",
|
|
325
|
-
variant: "body3",
|
|
326
|
-
children: [/*#__PURE__*/jsx(Trans, {
|
|
327
|
-
i18nKey: "neetoMolecules.shareViaLink.bulkUploadPane.supportedFormat",
|
|
328
|
-
values: {
|
|
329
|
-
fileType: "csv"
|
|
330
|
-
},
|
|
331
|
-
components: {
|
|
332
|
-
code: /*#__PURE__*/jsx("code", {
|
|
333
|
-
className: "bg-background m-0 border-s-0 p-0 text-sm"
|
|
334
|
-
})
|
|
335
|
-
}
|
|
336
|
-
}), " ", fileSize && t("neetoMolecules.shareViaLink.bulkUploadPane.supportedSize", {
|
|
337
|
-
fileSize: fileSize
|
|
338
|
-
})]
|
|
339
|
-
})]
|
|
340
|
-
})]
|
|
341
|
-
}), errors]
|
|
342
|
-
}))]
|
|
343
|
-
})
|
|
344
|
-
}), /*#__PURE__*/jsx(Sheet.Footer, {
|
|
345
|
-
className: "flex items-center gap-x-2",
|
|
346
|
-
children: /*#__PURE__*/jsx(Button, {
|
|
347
|
-
"data-testid": "bulk-upload-cancel-button",
|
|
348
|
-
label: t("neetoMolecules.common.actions.cancel"),
|
|
349
|
-
type: "reset",
|
|
350
|
-
variant: "ghost",
|
|
351
|
-
onClick: onClose
|
|
352
|
-
})
|
|
353
|
-
})]
|
|
354
|
-
})
|
|
355
|
-
});
|
|
356
|
-
};
|
|
357
|
-
|
|
358
|
-
var isValidEmail$1 = function isValidEmail(email) {
|
|
359
|
-
return string().email().isValidSync(email);
|
|
360
|
-
};
|
|
361
|
-
var createEmailOptions$1 = function createEmailOptions() {
|
|
362
|
-
var emails = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
363
|
-
return emails.map(function (email) {
|
|
364
|
-
return {
|
|
365
|
-
label: email,
|
|
366
|
-
value: email,
|
|
367
|
-
valid: isValidEmail$1(email)
|
|
368
|
-
};
|
|
369
|
-
});
|
|
370
|
-
};
|
|
371
|
-
var parseCsvEmails = function parseCsvEmails(file, onSuccess) {
|
|
372
|
-
Papa.parse(file, {
|
|
373
|
-
header: true,
|
|
374
|
-
skipEmptyLines: true,
|
|
375
|
-
transformHeader: function transformHeader(h) {
|
|
376
|
-
return h.toLowerCase().replace(/\W/g, "");
|
|
377
|
-
},
|
|
378
|
-
complete: function complete(results) {
|
|
379
|
-
var _results$meta$fields;
|
|
380
|
-
var isEmailFieldPresent = (_results$meta$fields = results.meta.fields) === null || _results$meta$fields === void 0 ? void 0 : _results$meta$fields.includes("email");
|
|
381
|
-
if (isEmailFieldPresent) {
|
|
382
|
-
var emails = results.data.filter(prop("email")).map(function (item) {
|
|
383
|
-
return item.email.trim();
|
|
384
|
-
});
|
|
385
|
-
onSuccess(createEmailOptions$1(emails));
|
|
386
|
-
} else {
|
|
387
|
-
Toastr.error(t("neetoMolecules.sendToFields.errors.invalidCsv"));
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
function ownKeys$a(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; }
|
|
394
|
-
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
395
|
-
var SendToFields = function SendToFields(_ref) {
|
|
396
|
-
var emailInputProps = _ref.emailInputProps,
|
|
397
|
-
ccInputProps = _ref.ccInputProps,
|
|
398
|
-
bccInputProps = _ref.bccInputProps,
|
|
399
|
-
_ref$showUploadCsvBut = _ref.showUploadCsvButton,
|
|
400
|
-
showUploadCsvButton = _ref$showUploadCsvBut === void 0 ? false : _ref$showUploadCsvBut,
|
|
401
|
-
_ref$showCcBccButton = _ref.showCcBccButton,
|
|
402
|
-
showCcBccButton = _ref$showCcBccButton === void 0 ? false : _ref$showCcBccButton,
|
|
403
|
-
_ref$showCcField = _ref.showCcField,
|
|
404
|
-
showCcField = _ref$showCcField === void 0 ? false : _ref$showCcField,
|
|
405
|
-
_ref$showBccField = _ref.showBccField,
|
|
406
|
-
showBccField = _ref$showBccField === void 0 ? false : _ref$showBccField,
|
|
407
|
-
_ref$showSendToField = _ref.showSendToField,
|
|
408
|
-
showSendToField = _ref$showSendToField === void 0 ? true : _ref$showSendToField;
|
|
409
|
-
var _useState = useState(false),
|
|
410
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
411
|
-
isBulkUploadPaneOpen = _useState2[0],
|
|
412
|
-
setIsBulkUploadPaneOpen = _useState2[1];
|
|
413
|
-
var sendToFieldRef = useRef();
|
|
414
|
-
var _useFormikContext = useFormikContext(),
|
|
415
|
-
_useFormikContext$val = _useFormikContext.values,
|
|
416
|
-
showCopyEmails = _useFormikContext$val.showCopyEmails,
|
|
417
|
-
existingSendToEmails = _useFormikContext$val[emailInputProps.name || "sendTo"],
|
|
418
|
-
setFieldValue = _useFormikContext.setFieldValue;
|
|
419
|
-
var _useTranslation = useTranslation(),
|
|
420
|
-
t = _useTranslation.t;
|
|
421
|
-
var handleCSVFile = function handleCSVFile(file) {
|
|
422
|
-
try {
|
|
423
|
-
var _sendToFieldRef$curre;
|
|
424
|
-
var onSuccess = function onSuccess(values) {
|
|
425
|
-
return setFieldValue(emailInputProps.name || "sendTo", [].concat(_toConsumableArray(existingSendToEmails), _toConsumableArray(values)));
|
|
426
|
-
};
|
|
427
|
-
parseCsvEmails(file, onSuccess);
|
|
428
|
-
setIsBulkUploadPaneOpen(false);
|
|
429
|
-
(_sendToFieldRef$curre = sendToFieldRef.current) === null || _sendToFieldRef$curre === void 0 || _sendToFieldRef$curre.focus();
|
|
430
|
-
} catch (error) {
|
|
431
|
-
Toastr.error(error);
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
|
-
var handelCcBccButtonClick = function handelCcBccButtonClick(e) {
|
|
435
|
-
e.stopPropagation();
|
|
436
|
-
setFieldValue("showCopyEmails", !showCopyEmails);
|
|
437
|
-
};
|
|
438
|
-
return /*#__PURE__*/jsxs("div", {
|
|
439
|
-
className: "w-full",
|
|
440
|
-
"data-testid": "send-to-text-field",
|
|
441
|
-
children: [showUploadCsvButton && /*#__PURE__*/jsx("div", {
|
|
442
|
-
className: "flex justify-end",
|
|
443
|
-
children: /*#__PURE__*/jsx(Button, {
|
|
444
|
-
"data-testid": "bulk-upload-button",
|
|
445
|
-
icon: Upload,
|
|
446
|
-
label: t("neetoMolecules.shareViaLink.bulkUpload"),
|
|
447
|
-
size: "sm",
|
|
448
|
-
variant: "link",
|
|
449
|
-
onClick: function onClick() {
|
|
450
|
-
return setIsBulkUploadPaneOpen(true);
|
|
451
|
-
}
|
|
452
|
-
})
|
|
453
|
-
}), showSendToField && /*#__PURE__*/jsx("div", {
|
|
454
|
-
className: "border-border w-full border-b pb-1",
|
|
455
|
-
children: /*#__PURE__*/jsx(MultiEmailInput, _objectSpread$a(_objectSpread$a({
|
|
456
|
-
name: "sendTo",
|
|
457
|
-
ref: sendToFieldRef
|
|
458
|
-
}, emailInputProps), {}, {
|
|
459
|
-
suffix: showCcBccButton && /*#__PURE__*/jsx(Button, {
|
|
460
|
-
"data-testid": "cc-bcc-button",
|
|
461
|
-
label: t("neetoMolecules.emailForm.labels.ccBcc"),
|
|
462
|
-
size: "sm",
|
|
463
|
-
variant: "link",
|
|
464
|
-
onClick: handelCcBccButtonClick,
|
|
465
|
-
onKeyDown: function onKeyDown(event) {
|
|
466
|
-
return event.stopPropagation();
|
|
467
|
-
}
|
|
468
|
-
})
|
|
469
|
-
}))
|
|
470
|
-
}), (showCopyEmails || showCcField || showBccField) && /*#__PURE__*/jsxs("div", {
|
|
471
|
-
className: "mt-5 flex w-full flex-col gap-5",
|
|
472
|
-
children: [(showCopyEmails || showCcField) && /*#__PURE__*/jsx("div", {
|
|
473
|
-
className: "border-border w-full border-b pb-1",
|
|
474
|
-
children: /*#__PURE__*/jsx(MultiEmailInput, _objectSpread$a({
|
|
475
|
-
name: "sendToBcc"
|
|
476
|
-
}, ccInputProps))
|
|
477
|
-
}), (showCopyEmails || showBccField) && /*#__PURE__*/jsx("div", {
|
|
478
|
-
className: "border-border w-full border-b pb-1",
|
|
479
|
-
children: /*#__PURE__*/jsx(MultiEmailInput, _objectSpread$a({
|
|
480
|
-
name: "sendToCc"
|
|
481
|
-
}, bccInputProps))
|
|
482
|
-
})]
|
|
483
|
-
}), /*#__PURE__*/jsx(BulkUploadPane, {
|
|
484
|
-
fileSize: CSV_FILE_SIZE_IN_KB,
|
|
485
|
-
handleFileSubmit: handleCSVFile,
|
|
486
|
-
isOpen: isBulkUploadPaneOpen,
|
|
487
|
-
onClose: function onClose() {
|
|
488
|
-
return setIsBulkUploadPaneOpen(false);
|
|
489
|
-
}
|
|
490
|
-
})]
|
|
491
|
-
});
|
|
492
|
-
};
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* @license lucide-react v1.7.0 - ISC
|
|
496
|
-
*
|
|
497
|
-
* This source code is licensed under the ISC license.
|
|
498
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
499
|
-
*/
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
const __iconNode$4 = [
|
|
503
|
-
[
|
|
504
|
-
"path",
|
|
505
|
-
{ d: "M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1", key: "ezmyqa" }
|
|
506
|
-
],
|
|
507
|
-
[
|
|
508
|
-
"path",
|
|
509
|
-
{
|
|
510
|
-
d: "M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",
|
|
511
|
-
key: "e1hn23"
|
|
512
|
-
}
|
|
513
|
-
]
|
|
514
|
-
];
|
|
515
|
-
const Braces = createLucideIcon("braces", __iconNode$4);
|
|
516
|
-
|
|
517
|
-
var parseVariables = function parseVariables() {
|
|
518
|
-
var variableArr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
519
|
-
var uncategorized = [];
|
|
520
|
-
var groupedVariables = [];
|
|
521
|
-
var categorySet = new Set();
|
|
522
|
-
variableArr.forEach(function (variable) {
|
|
523
|
-
var category = variable.category,
|
|
524
|
-
label = variable.label,
|
|
525
|
-
variables = variable.variables;
|
|
526
|
-
if (category && variables) {
|
|
527
|
-
var parsedVariables = variables.map(mergeLeft({
|
|
528
|
-
category: category,
|
|
529
|
-
categoryLabel: label
|
|
530
|
-
}));
|
|
531
|
-
if (!categorySet.has(category)) {
|
|
532
|
-
categorySet.add(category);
|
|
533
|
-
groupedVariables.push({
|
|
534
|
-
label: label,
|
|
535
|
-
variables: parsedVariables
|
|
536
|
-
});
|
|
537
|
-
} else {
|
|
538
|
-
var existingGroup = findBy({
|
|
539
|
-
label: label
|
|
540
|
-
}, groupedVariables);
|
|
541
|
-
existingGroup.variables = uniqBy(prop("key"), existingGroup.variables.concat(parsedVariables));
|
|
542
|
-
}
|
|
543
|
-
} else {
|
|
544
|
-
uncategorized.push(variable);
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
if (!isEmpty(uncategorized)) {
|
|
548
|
-
groupedVariables.push({
|
|
549
|
-
label: !isEmpty(groupedVariables) ? "Others" : null,
|
|
550
|
-
variables: uncategorized
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
return groupedVariables;
|
|
554
|
-
};
|
|
555
|
-
|
|
556
|
-
var _excluded$6 = ["onVariableClick", "variables", "buttonProps"];
|
|
557
|
-
function ownKeys$9(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; }
|
|
558
|
-
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
559
|
-
var DynamicVariables = function DynamicVariables(_ref) {
|
|
560
|
-
var _ref$onVariableClick = _ref.onVariableClick,
|
|
561
|
-
onVariableClick = _ref$onVariableClick === void 0 ? noop : _ref$onVariableClick,
|
|
562
|
-
_ref$variables = _ref.variables,
|
|
563
|
-
variables = _ref$variables === void 0 ? [] : _ref$variables,
|
|
564
|
-
buttonProps = _ref.buttonProps,
|
|
565
|
-
dropdownProps = _objectWithoutProperties(_ref, _excluded$6);
|
|
566
|
-
if (isEmpty(variables)) return null;
|
|
567
|
-
var parsedVariables = parseVariables(variables);
|
|
568
|
-
return /*#__PURE__*/jsx(DropdownMenu, _objectSpread$9(_objectSpread$9({
|
|
569
|
-
customTarget: /*#__PURE__*/jsx(Button, _objectSpread$9({
|
|
570
|
-
"data-testid": "dynamic-variables-button",
|
|
571
|
-
icon: Braces,
|
|
572
|
-
size: "icon",
|
|
573
|
-
variant: "outline"
|
|
574
|
-
}, buttonProps))
|
|
575
|
-
}, dropdownProps), {}, {
|
|
576
|
-
dropdownProps: _objectSpread$9({
|
|
577
|
-
className: "min-w-56"
|
|
578
|
-
}, dropdownProps === null || dropdownProps === void 0 ? void 0 : dropdownProps.dropdownProps),
|
|
579
|
-
children: /*#__PURE__*/jsx("div", {
|
|
580
|
-
className: "flex max-w-[22.5rem] min-w-[11.5rem] flex-col gap-1.5 p-2",
|
|
581
|
-
"data-testid": "dynamic-variables-list",
|
|
582
|
-
children: parsedVariables.map(function (_ref2) {
|
|
583
|
-
var label = _ref2.label,
|
|
584
|
-
variables = _ref2.variables;
|
|
585
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
586
|
-
children: [label && /*#__PURE__*/jsxs("div", {
|
|
587
|
-
className: "flex flex-row items-center gap-x-2",
|
|
588
|
-
children: [/*#__PURE__*/jsx(Typography, {
|
|
589
|
-
variant: "h6",
|
|
590
|
-
children: label
|
|
591
|
-
}), /*#__PURE__*/jsx("hr", {
|
|
592
|
-
className: "border-border flex flex-grow"
|
|
593
|
-
})]
|
|
594
|
-
}), /*#__PURE__*/jsx("div", {
|
|
595
|
-
className: "flex flex-wrap items-center gap-2",
|
|
596
|
-
"data-testid": joinHyphenCase("dynamic-variables-list", label),
|
|
597
|
-
children: variables.map(function (item) {
|
|
598
|
-
return /*#__PURE__*/jsx("button", {
|
|
599
|
-
className: "border-border text-foreground hover:border-primary hover:text-primary focus-visible:border-primary focus-visible:text-primary rounded-md border p-1.5 text-start transition-colors select-none focus:outline-none",
|
|
600
|
-
"data-testid": joinHyphenCase("dynamic-variables-list-item", item.label),
|
|
601
|
-
onClick: function onClick() {
|
|
602
|
-
return onVariableClick(item);
|
|
603
|
-
},
|
|
604
|
-
children: item.label
|
|
605
|
-
}, item.label);
|
|
606
|
-
})
|
|
607
|
-
})]
|
|
608
|
-
}, label);
|
|
609
|
-
})
|
|
610
|
-
})
|
|
611
|
-
}));
|
|
612
|
-
};
|
|
613
|
-
|
|
614
|
-
var Breadcrumbs = withT(function (_ref) {
|
|
615
|
-
var t = _ref.t,
|
|
616
|
-
_ref$breadcrumbs = _ref.breadcrumbs,
|
|
617
|
-
breadcrumbs = _ref$breadcrumbs === void 0 ? [] : _ref$breadcrumbs,
|
|
618
|
-
_ref$hasTrailingSepar = _ref.hasTrailingSeparator,
|
|
619
|
-
hasTrailingSeparator = _ref$hasTrailingSepar === void 0 ? false : _ref$hasTrailingSepar,
|
|
620
|
-
className = _ref.className;
|
|
621
|
-
return /*#__PURE__*/jsx(Breadcrumb, {
|
|
622
|
-
"aria-label": t("neetoMolecules.breadcrumbs.breadcrumbAriaLabel"),
|
|
623
|
-
className: classnames("mb-4", className),
|
|
624
|
-
children: /*#__PURE__*/jsx(BreadcrumbList, {
|
|
625
|
-
children: breadcrumbs.map(function (_ref2, index) {
|
|
626
|
-
var text = _ref2.text,
|
|
627
|
-
_ref2$link = _ref2.link,
|
|
628
|
-
link = _ref2$link === void 0 ? "#" : _ref2$link;
|
|
629
|
-
var isLast = index + 1 === breadcrumbs.length;
|
|
630
|
-
var isCurrentPage = isLast && !hasTrailingSeparator;
|
|
631
|
-
return /*#__PURE__*/jsxs(React__default.Fragment, {
|
|
632
|
-
children: [/*#__PURE__*/jsx(BreadcrumbItem, {
|
|
633
|
-
"data-testid": "header-breadcrumb",
|
|
634
|
-
children: isCurrentPage ? /*#__PURE__*/jsx(BreadcrumbPage, {
|
|
635
|
-
"data-testid": "".concat(hyphenize(text), "-breadcrumb"),
|
|
636
|
-
children: text
|
|
637
|
-
}) : /*#__PURE__*/jsx(BreadcrumbLink, {
|
|
638
|
-
asChild: true,
|
|
639
|
-
children: /*#__PURE__*/jsx(Link, {
|
|
640
|
-
"data-testid": "".concat(hyphenize(text), "-breadcrumb"),
|
|
641
|
-
to: link,
|
|
642
|
-
children: text
|
|
643
|
-
})
|
|
644
|
-
})
|
|
645
|
-
}), !isCurrentPage && /*#__PURE__*/jsx(BreadcrumbSeparator, {})]
|
|
646
|
-
}, index);
|
|
647
|
-
})
|
|
648
|
-
})
|
|
649
|
-
});
|
|
650
|
-
});
|
|
651
|
-
|
|
652
|
-
/**
|
|
653
|
-
* @license lucide-react v1.7.0 - ISC
|
|
654
|
-
*
|
|
655
|
-
* This source code is licensed under the ISC license.
|
|
656
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
657
|
-
*/
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
const __iconNode$3 = [
|
|
661
|
-
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
662
|
-
["path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3", key: "1u773s" }],
|
|
663
|
-
["path", { d: "M12 17h.01", key: "p32p05" }]
|
|
664
|
-
];
|
|
665
|
-
const CircleQuestionMark = createLucideIcon("circle-question-mark", __iconNode$3);
|
|
666
|
-
|
|
667
|
-
var SIZE = {
|
|
668
|
-
"default": 16,
|
|
669
|
-
large: 18
|
|
670
|
-
};
|
|
671
|
-
|
|
672
|
-
var _excluded$5 = ["label"];
|
|
673
|
-
function ownKeys$8(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; }
|
|
674
|
-
function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
675
|
-
var HelpPopover = function HelpPopover(_ref) {
|
|
676
|
-
var title = _ref.title,
|
|
677
|
-
_ref$size = _ref.size,
|
|
678
|
-
size = _ref$size === void 0 ? "large" : _ref$size,
|
|
679
|
-
description = _ref.description,
|
|
680
|
-
helpLinkProps = _ref.helpLinkProps,
|
|
681
|
-
className = _ref.className,
|
|
682
|
-
_ref$iconColor = _ref.iconColor,
|
|
683
|
-
iconColor = _ref$iconColor === void 0 ? "currentColor" : _ref$iconColor,
|
|
684
|
-
_ref$icon = _ref.icon,
|
|
685
|
-
IconComponent = _ref$icon === void 0 ? CircleQuestionMark : _ref$icon,
|
|
686
|
-
side = _ref.side,
|
|
687
|
-
sideOffset = _ref.sideOffset,
|
|
688
|
-
align = _ref.align,
|
|
689
|
-
alignOffset = _ref.alignOffset;
|
|
690
|
-
var _useTranslation = useTranslation(),
|
|
691
|
-
t = _useTranslation.t;
|
|
692
|
-
var position = align && align !== "center" ? "".concat(side, "-").concat(align) : side;
|
|
693
|
-
return /*#__PURE__*/jsx(Popover, {
|
|
694
|
-
alignOffset: alignOffset,
|
|
695
|
-
position: position,
|
|
696
|
-
sideOffset: sideOffset,
|
|
697
|
-
className: "!max-w-[calc(100vw-2rem)]",
|
|
698
|
-
closeDelay: 150,
|
|
699
|
-
collisionPadding: 12,
|
|
700
|
-
openDelay: 0,
|
|
701
|
-
trigger: /*#__PURE__*/jsx("button", {
|
|
702
|
-
"data-testid": "help-popover-button",
|
|
703
|
-
type: "button",
|
|
704
|
-
className: classnames("inline-flex cursor-pointer items-center justify-center rounded-full border-none bg-transparent p-0", className),
|
|
705
|
-
children: /*#__PURE__*/jsx(IconComponent, {
|
|
706
|
-
color: iconColor,
|
|
707
|
-
size: SIZE[size]
|
|
708
|
-
})
|
|
709
|
-
}),
|
|
710
|
-
children: /*#__PURE__*/jsxs("div", {
|
|
711
|
-
className: "flex flex-col",
|
|
712
|
-
onClick: function onClick(event) {
|
|
713
|
-
return event.stopPropagation();
|
|
714
|
-
},
|
|
715
|
-
children: [title && /*#__PURE__*/jsx(Typography, {
|
|
716
|
-
asChild: true,
|
|
717
|
-
variant: "body2",
|
|
718
|
-
weight: "semibold",
|
|
719
|
-
children: /*#__PURE__*/jsx("h3", {
|
|
720
|
-
className: "mb-2",
|
|
721
|
-
"data-testid": "help-popover-title",
|
|
722
|
-
children: title
|
|
723
|
-
})
|
|
724
|
-
}), typeof description === "string" ? /*#__PURE__*/jsx(Typography, {
|
|
725
|
-
color: "muted",
|
|
726
|
-
"data-testid": "help-popover-description",
|
|
727
|
-
variant: "body2",
|
|
728
|
-
children: description
|
|
729
|
-
}) : description, helpLinkProps && function () {
|
|
730
|
-
var linkLabel = helpLinkProps.label,
|
|
731
|
-
restLinkProps = _objectWithoutProperties(helpLinkProps, _excluded$5);
|
|
732
|
-
return /*#__PURE__*/jsx(Button, {
|
|
733
|
-
asChild: true,
|
|
734
|
-
className: "mt-3 self-start",
|
|
735
|
-
variant: "link",
|
|
736
|
-
children: /*#__PURE__*/jsx("a", _objectSpread$8(_objectSpread$8({
|
|
737
|
-
"data-testid": "help-popover-link-button",
|
|
738
|
-
rel: "noreferrer",
|
|
739
|
-
target: "_blank"
|
|
740
|
-
}, restLinkProps), {}, {
|
|
741
|
-
children: linkLabel !== null && linkLabel !== void 0 ? linkLabel : t("neetoMolecules.common.viewHelpArticle")
|
|
742
|
-
}))
|
|
743
|
-
});
|
|
744
|
-
}()]
|
|
745
|
-
})
|
|
746
|
-
});
|
|
747
|
-
};
|
|
748
|
-
|
|
749
|
-
/**
|
|
750
|
-
* @license lucide-react v1.7.0 - ISC
|
|
751
|
-
*
|
|
752
|
-
* This source code is licensed under the ISC license.
|
|
753
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
754
|
-
*/
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
const __iconNode$2 = [
|
|
758
|
-
["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
|
|
759
|
-
["circle", { cx: "19", cy: "12", r: "1", key: "1wjl8i" }],
|
|
760
|
-
["circle", { cx: "5", cy: "12", r: "1", key: "1pcz8c" }]
|
|
761
|
-
];
|
|
762
|
-
const Ellipsis = createLucideIcon("ellipsis", __iconNode$2);
|
|
763
|
-
|
|
764
|
-
/**
|
|
765
|
-
* @license lucide-react v1.7.0 - ISC
|
|
766
|
-
*
|
|
767
|
-
* This source code is licensed under the ISC license.
|
|
768
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
769
|
-
*/
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
const __iconNode$1 = [
|
|
773
|
-
["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
|
|
774
|
-
["circle", { cx: "12", cy: "5", r: "1", key: "gxeob9" }],
|
|
775
|
-
["circle", { cx: "12", cy: "19", r: "1", key: "lyex9k" }]
|
|
776
|
-
];
|
|
777
|
-
const EllipsisVertical = createLucideIcon("ellipsis-vertical", __iconNode$1);
|
|
778
|
-
|
|
779
|
-
var DEFAULT_TOOLTIP_PROPS = {
|
|
780
|
-
disabled: true,
|
|
781
|
-
position: "bottom"
|
|
782
|
-
};
|
|
783
|
-
|
|
784
|
-
var _excluded$2$1 = ["isVisible", "key"];
|
|
785
|
-
function ownKeys$2$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; }
|
|
786
|
-
function _objectSpread$2$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
787
|
-
var Submenu = withT(function (_ref) {
|
|
788
|
-
var t = _ref.t,
|
|
789
|
-
label = _ref.label,
|
|
790
|
-
_ref$menuItems = _ref.menuItems,
|
|
791
|
-
menuItems = _ref$menuItems === void 0 ? [] : _ref$menuItems;
|
|
792
|
-
return /*#__PURE__*/jsx(DropdownMenu.SubMenu, {
|
|
793
|
-
label: label,
|
|
794
|
-
triggerProps: {
|
|
795
|
-
"aria-haspopup": "menu"
|
|
796
|
-
},
|
|
797
|
-
contentProps: {
|
|
798
|
-
"aria-label": t("neetoMolecules.moreDropdown.submenuAriaLabel", {
|
|
799
|
-
label: label
|
|
800
|
-
})
|
|
801
|
-
},
|
|
802
|
-
children: menuItems.map(function (_ref2) {
|
|
803
|
-
var _ref2$isVisible = _ref2.isVisible,
|
|
804
|
-
isVisible = _ref2$isVisible === void 0 ? true : _ref2$isVisible,
|
|
805
|
-
key = _ref2.key,
|
|
806
|
-
itemProps = _objectWithoutProperties(_ref2, _excluded$2$1);
|
|
807
|
-
if (!isVisible) return null;
|
|
808
|
-
return /*#__PURE__*/jsx(MenuItem, _objectSpread$2$1({}, itemProps), key !== null && key !== void 0 ? key : hyphenate(itemProps.label || "menu-item"));
|
|
809
|
-
})
|
|
810
|
-
});
|
|
811
|
-
});
|
|
812
|
-
|
|
813
|
-
var _excluded$1$1 = ["onClick", "label", "type", "hasSubItems", "menuItems", "dropdownProps"];
|
|
814
|
-
function ownKeys$1$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; }
|
|
815
|
-
function _objectSpread$1$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
816
|
-
var MenuItem = function MenuItem(_ref) {
|
|
817
|
-
var onClick = _ref.onClick,
|
|
818
|
-
label = _ref.label,
|
|
819
|
-
_ref$type = _ref.type,
|
|
820
|
-
type = _ref$type === void 0 ? "menuItem" : _ref$type,
|
|
821
|
-
_ref$hasSubItems = _ref.hasSubItems,
|
|
822
|
-
hasSubItems = _ref$hasSubItems === void 0 ? false : _ref$hasSubItems,
|
|
823
|
-
menuItems = _ref.menuItems,
|
|
824
|
-
dropdownProps = _ref.dropdownProps,
|
|
825
|
-
menuItemProps = _objectWithoutProperties(_ref, _excluded$1$1);
|
|
826
|
-
if (type === "divider") return /*#__PURE__*/jsx(DropdownMenu.Divider, {
|
|
827
|
-
role: "separator"
|
|
828
|
-
});
|
|
829
|
-
if (hasSubItems) {
|
|
830
|
-
return /*#__PURE__*/jsx(Submenu, _objectSpread$1$2({}, _objectSpread$1$2({
|
|
831
|
-
dropdownProps: dropdownProps,
|
|
832
|
-
label: label,
|
|
833
|
-
menuItems: menuItems
|
|
834
|
-
}, menuItemProps)));
|
|
835
|
-
}
|
|
836
|
-
return /*#__PURE__*/jsx(DropdownMenu.MenuItem, _objectSpread$1$2(_objectSpread$1$2({
|
|
837
|
-
onClick: onClick,
|
|
838
|
-
role: "menuitem"
|
|
839
|
-
}, menuItemProps), {}, {
|
|
840
|
-
children: label
|
|
841
|
-
}));
|
|
842
|
-
};
|
|
843
|
-
|
|
844
|
-
var _excluded$4 = ["isRounded", "size", "tooltipProps", "variant"],
|
|
845
|
-
_excluded2$1 = ["className"],
|
|
846
|
-
_excluded3 = ["isVisible", "key"];
|
|
847
|
-
function ownKeys$7(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; }
|
|
848
|
-
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
849
|
-
var MoreDropdown = function MoreDropdown(_ref) {
|
|
850
|
-
var _ref$dropdownButtonPr = _ref.dropdownButtonProps,
|
|
851
|
-
dropdownButtonProps = _ref$dropdownButtonPr === void 0 ? {} : _ref$dropdownButtonPr,
|
|
852
|
-
_ref$isVertical = _ref.isVertical,
|
|
853
|
-
isVertical = _ref$isVertical === void 0 ? false : _ref$isVertical,
|
|
854
|
-
_ref$isDisabled = _ref.isDisabled,
|
|
855
|
-
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
856
|
-
_ref$dropdownProps = _ref.dropdownProps,
|
|
857
|
-
dropdownProps = _ref$dropdownProps === void 0 ? {} : _ref$dropdownProps,
|
|
858
|
-
menuTopChildren = _ref.menuTopChildren,
|
|
859
|
-
menuBottomChildren = _ref.menuBottomChildren,
|
|
860
|
-
_ref$menuItems = _ref.menuItems,
|
|
861
|
-
menuItems = _ref$menuItems === void 0 ? [] : _ref$menuItems;
|
|
862
|
-
var _useTranslation = useTranslation(),
|
|
863
|
-
t = _useTranslation.t;
|
|
864
|
-
var isRoundedButton = dropdownButtonProps.isRounded,
|
|
865
|
-
_dropdownButtonProps$ = dropdownButtonProps.size,
|
|
866
|
-
buttonSize = _dropdownButtonProps$ === void 0 ? "icon" : _dropdownButtonProps$,
|
|
867
|
-
customTooltipProps = dropdownButtonProps.tooltipProps,
|
|
868
|
-
_dropdownButtonProps$2 = dropdownButtonProps.variant,
|
|
869
|
-
variant = _dropdownButtonProps$2 === void 0 ? "ghost" : _dropdownButtonProps$2,
|
|
870
|
-
buttonProps = _objectWithoutProperties(dropdownButtonProps, _excluded$4);
|
|
871
|
-
var tooltipProps = mergeRight(DEFAULT_TOOLTIP_PROPS, customTooltipProps);
|
|
872
|
-
var TargetIcon = isVertical ? EllipsisVertical : Ellipsis;
|
|
873
|
-
var contentClassName = dropdownProps.className,
|
|
874
|
-
restDropdownProps = _objectWithoutProperties(dropdownProps, _excluded2$1);
|
|
875
|
-
var isDropdownDisabled = isDisabled || dropdownProps.disabled;
|
|
876
|
-
var triggerClassName = classnames("shrink-0", {
|
|
877
|
-
"rounded-full": isRoundedButton
|
|
878
|
-
});
|
|
879
|
-
if (isDropdownDisabled && !tooltipProps.disabled) {
|
|
880
|
-
return /*#__PURE__*/jsx(Tooltip, {
|
|
881
|
-
content: tooltipProps.content,
|
|
882
|
-
position: tooltipProps.position || "bottom",
|
|
883
|
-
children: /*#__PURE__*/jsx("span", {
|
|
884
|
-
children: /*#__PURE__*/jsx(Button, _objectSpread$7({
|
|
885
|
-
variant: variant,
|
|
886
|
-
disabled: true,
|
|
887
|
-
className: triggerClassName,
|
|
888
|
-
"data-dropdown-button-style": "more-dropdown",
|
|
889
|
-
"data-testid": "more-dropdown-button",
|
|
890
|
-
icon: TargetIcon,
|
|
891
|
-
size: buttonSize
|
|
892
|
-
}, buttonProps))
|
|
893
|
-
})
|
|
894
|
-
});
|
|
895
|
-
}
|
|
896
|
-
return /*#__PURE__*/jsxs(DropdownMenu, _objectSpread$7(_objectSpread$7({
|
|
897
|
-
customTarget: /*#__PURE__*/jsx(Button, _objectSpread$7({
|
|
898
|
-
variant: variant,
|
|
899
|
-
"aria-haspopup": "menu",
|
|
900
|
-
"aria-label": t("neetoMolecules.moreDropdown.buttonAriaLabel"),
|
|
901
|
-
className: triggerClassName,
|
|
902
|
-
"data-dropdown-button-style": "more-dropdown",
|
|
903
|
-
disabled: isDropdownDisabled,
|
|
904
|
-
icon: TargetIcon,
|
|
905
|
-
size: buttonSize
|
|
906
|
-
}, buttonProps)),
|
|
907
|
-
dropdownProps: {
|
|
908
|
-
"aria-label": t("neetoMolecules.moreDropdown.menuAriaLabel"),
|
|
909
|
-
className: contentClassName
|
|
910
|
-
}
|
|
911
|
-
}, restDropdownProps), {}, {
|
|
912
|
-
children: [menuTopChildren, menuItems.map(function (_ref2) {
|
|
913
|
-
var _ref2$isVisible = _ref2.isVisible,
|
|
914
|
-
isVisible = _ref2$isVisible === void 0 ? true : _ref2$isVisible,
|
|
915
|
-
key = _ref2.key,
|
|
916
|
-
menuItemProps = _objectWithoutProperties(_ref2, _excluded3);
|
|
917
|
-
if (!isVisible) return null;
|
|
918
|
-
return /*#__PURE__*/jsx(MenuItem, _objectSpread$7({}, menuItemProps), key !== null && key !== void 0 ? key : hyphenate(menuItemProps.label || "menu-item"));
|
|
919
|
-
}), menuBottomChildren]
|
|
920
|
-
}));
|
|
921
|
-
};
|
|
922
|
-
|
|
923
|
-
/**
|
|
924
|
-
* @license lucide-react v1.7.0 - ISC
|
|
925
|
-
*
|
|
926
|
-
* This source code is licensed under the ISC license.
|
|
927
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
928
|
-
*/
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
const __iconNode = [
|
|
932
|
-
["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
|
|
933
|
-
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
|
|
934
|
-
];
|
|
935
|
-
const Search$1 = createLucideIcon("search", __iconNode);
|
|
936
|
-
|
|
937
|
-
var getInitialSearchValue = function getInitialSearchValue(_ref) {
|
|
938
|
-
var _ref$initialValue = _ref.initialValue,
|
|
939
|
-
initialValue = _ref$initialValue === void 0 ? "" : _ref$initialValue,
|
|
940
|
-
enableUrlSync = _ref.enableUrlSync,
|
|
941
|
-
searchParamName = _ref.searchParamName;
|
|
942
|
-
if (enableUrlSync) {
|
|
943
|
-
var _queryParams$searchPa;
|
|
944
|
-
var queryParams = getQueryParams({
|
|
945
|
-
toCamelCase: false
|
|
946
|
-
});
|
|
947
|
-
return (_queryParams$searchPa = queryParams[searchParamName]) !== null && _queryParams$searchPa !== void 0 ? _queryParams$searchPa : "";
|
|
948
|
-
}
|
|
949
|
-
return initialValue;
|
|
950
|
-
};
|
|
951
|
-
|
|
952
|
-
var _excluded$3 = ["value", "debounceTime", "onSearch", "onChange", "enableUrlSync", "searchParamName", "className", "label"];
|
|
953
|
-
function ownKeys$6(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; }
|
|
954
|
-
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
955
|
-
var Search = function Search(_ref) {
|
|
956
|
-
var value = _ref.value,
|
|
957
|
-
_ref$debounceTime = _ref.debounceTime,
|
|
958
|
-
debounceTime = _ref$debounceTime === void 0 ? 300 : _ref$debounceTime,
|
|
959
|
-
onSearch = _ref.onSearch,
|
|
960
|
-
onChange = _ref.onChange,
|
|
961
|
-
_ref$enableUrlSync = _ref.enableUrlSync,
|
|
962
|
-
enableUrlSync = _ref$enableUrlSync === void 0 ? false : _ref$enableUrlSync,
|
|
963
|
-
_ref$searchParamName = _ref.searchParamName,
|
|
964
|
-
searchParamName = _ref$searchParamName === void 0 ? "search_term" : _ref$searchParamName,
|
|
965
|
-
className = _ref.className,
|
|
966
|
-
label = _ref.label,
|
|
967
|
-
inputProps = _objectWithoutProperties(_ref, _excluded$3);
|
|
968
|
-
var _useTranslation = useTranslation(),
|
|
969
|
-
t = _useTranslation.t;
|
|
970
|
-
var queryParams = useQueryParams({
|
|
971
|
-
toCamelCase: false
|
|
972
|
-
});
|
|
973
|
-
var history = useHistory();
|
|
974
|
-
var inputId = useId();
|
|
975
|
-
var _useState = useState(getInitialSearchValue({
|
|
976
|
-
initialValue: value,
|
|
977
|
-
enableUrlSync: enableUrlSync,
|
|
978
|
-
searchParamName: searchParamName
|
|
979
|
-
})),
|
|
980
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
981
|
-
internalValue = _useState2[0],
|
|
982
|
-
setInternalValue = _useState2[1];
|
|
983
|
-
var trimmedValue = value === null || value === void 0 ? void 0 : value.trim();
|
|
984
|
-
useUpdateEffect(function () {
|
|
985
|
-
var _queryParams$searchPa;
|
|
986
|
-
if (!enableUrlSync) return;
|
|
987
|
-
var searchParamValue = (_queryParams$searchPa = queryParams === null || queryParams === void 0 ? void 0 : queryParams[searchParamName]) !== null && _queryParams$searchPa !== void 0 ? _queryParams$searchPa : "";
|
|
988
|
-
setInternalValue(searchParamValue);
|
|
989
|
-
}, [queryParams === null || queryParams === void 0 ? void 0 : queryParams[searchParamName]]);
|
|
990
|
-
var handleSearchQueryParams = function handleSearchQueryParams(trimmedValue) {
|
|
991
|
-
if (!trimmedValue && !(queryParams !== null && queryParams !== void 0 && queryParams[searchParamName])) return;
|
|
992
|
-
if (trimmedValue === (queryParams === null || queryParams === void 0 ? void 0 : queryParams[searchParamName])) return;
|
|
993
|
-
var pathname = history.location.pathname;
|
|
994
|
-
if (trimmedValue) {
|
|
995
|
-
history.push(buildUrl(pathname, mergeLeft(_defineProperty({}, searchParamName, trimmedValue), queryParams)));
|
|
996
|
-
} else {
|
|
997
|
-
history.push(buildUrl(pathname, omit([searchParamName], queryParams)));
|
|
998
|
-
}
|
|
999
|
-
};
|
|
1000
|
-
var handleDebouncedSearchTermChange = useFuncDebounce(function (trimmedValue) {
|
|
1001
|
-
if (onSearch) onSearch(trimmedValue);else if (enableUrlSync) handleSearchQueryParams(trimmedValue);
|
|
1002
|
-
}, debounceTime);
|
|
1003
|
-
useUpdateEffect(function () {
|
|
1004
|
-
handleDebouncedSearchTermChange(trimmedValue);
|
|
1005
|
-
}, [trimmedValue]);
|
|
1006
|
-
var prevValueRef = useRef(value);
|
|
1007
|
-
if (value !== undefined && value !== prevValueRef.current) {
|
|
1008
|
-
setInternalValue(value);
|
|
1009
|
-
prevValueRef.current = value;
|
|
1010
|
-
}
|
|
1011
|
-
var handleOnChange = function handleOnChange(e) {
|
|
1012
|
-
var _e$target$value;
|
|
1013
|
-
var trimmedValue = (_e$target$value = e.target.value) === null || _e$target$value === void 0 ? void 0 : _e$target$value.trim();
|
|
1014
|
-
onChange === null || onChange === void 0 || onChange(e);
|
|
1015
|
-
setInternalValue(e.target.value);
|
|
1016
|
-
if ((internalValue === null || internalValue === void 0 ? void 0 : internalValue.trim()) !== trimmedValue) {
|
|
1017
|
-
handleDebouncedSearchTermChange(trimmedValue);
|
|
1018
|
-
}
|
|
1019
|
-
};
|
|
1020
|
-
useEffect(function () {
|
|
1021
|
-
return handleDebouncedSearchTermChange.cancel;
|
|
1022
|
-
}, []);
|
|
1023
|
-
return /*#__PURE__*/jsx(Input, _objectSpread$6({
|
|
1024
|
-
className: className,
|
|
1025
|
-
label: label,
|
|
1026
|
-
id: inputId,
|
|
1027
|
-
placeholder: t("neetoMolecules.common.actions.search"),
|
|
1028
|
-
prefix: /*#__PURE__*/jsx(Search$1, {}),
|
|
1029
|
-
type: "search",
|
|
1030
|
-
value: internalValue,
|
|
1031
|
-
onChange: handleOnChange
|
|
1032
|
-
}, inputProps));
|
|
1033
|
-
};
|
|
1034
|
-
|
|
1035
|
-
var SIZES = {
|
|
1036
|
-
nano: "nano"};
|
|
1037
|
-
var DROPDOWN_BUTTON_SIZES = {
|
|
1038
|
-
nano: "icon-sm",
|
|
1039
|
-
small: "icon"
|
|
1040
|
-
};
|
|
1041
|
-
|
|
1042
|
-
var _excluded$2 = ["dropdownButtonProps"];
|
|
1043
|
-
function ownKeys$5(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; }
|
|
1044
|
-
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1045
|
-
var Header = function Header(_ref) {
|
|
1046
|
-
var title = _ref.title,
|
|
1047
|
-
_ref$titleHelpPopover = _ref.titleHelpPopoverProps,
|
|
1048
|
-
titleHelpPopoverProps = _ref$titleHelpPopover === void 0 ? {} : _ref$titleHelpPopover,
|
|
1049
|
-
searchProps = _ref.searchProps,
|
|
1050
|
-
_ref$className = _ref.className,
|
|
1051
|
-
className = _ref$className === void 0 ? "" : _ref$className,
|
|
1052
|
-
actionBlock = _ref.actionBlock,
|
|
1053
|
-
_ref$breadcrumbs = _ref.breadcrumbs,
|
|
1054
|
-
breadcrumbs = _ref$breadcrumbs === void 0 ? [] : _ref$breadcrumbs,
|
|
1055
|
-
_ref$renderDropdown = _ref.renderDropdown,
|
|
1056
|
-
renderDropdown = _ref$renderDropdown === void 0 ? noop : _ref$renderDropdown,
|
|
1057
|
-
_ref$size = _ref.size,
|
|
1058
|
-
size = _ref$size === void 0 ? "small" : _ref$size,
|
|
1059
|
-
_ref$dataTestid = _ref["data-testid"],
|
|
1060
|
-
dataTestId = _ref$dataTestid === void 0 ? "neeto-molecules-header" : _ref$dataTestid;
|
|
1061
|
-
var headerRef = useRef(null);
|
|
1062
|
-
useLayoutEffect(function () {
|
|
1063
|
-
var updateHeaderHeight = function updateHeaderHeight() {
|
|
1064
|
-
if (!headerRef.current) return;
|
|
1065
|
-
var height = headerRef.current.offsetHeight;
|
|
1066
|
-
document.body.style.setProperty("--nv-header-height", "".concat(height, "px"));
|
|
1067
|
-
};
|
|
1068
|
-
updateHeaderHeight();
|
|
1069
|
-
window.addEventListener("resize", updateHeaderHeight);
|
|
1070
|
-
return function () {
|
|
1071
|
-
window.removeEventListener("resize", updateHeaderHeight);
|
|
1072
|
-
document.body.style.removeProperty("--nv-header-height");
|
|
1073
|
-
};
|
|
1074
|
-
}, []);
|
|
1075
|
-
var isNano = size === SIZES.nano;
|
|
1076
|
-
var hasBreadcrumbs = isNotEmpty(breadcrumbs);
|
|
1077
|
-
var TitleTag = isNano ? "h3" : "h1";
|
|
1078
|
-
return /*#__PURE__*/jsxs("div", {
|
|
1079
|
-
"data-testid": dataTestId,
|
|
1080
|
-
ref: headerRef,
|
|
1081
|
-
className: classnames("flex min-h-0 w-full shrink-0 flex-row items-start justify-between gap-4 pt-10 pb-6", "flex-wrap lg:flex-nowrap", className),
|
|
1082
|
-
children: [/*#__PURE__*/jsxs("div", {
|
|
1083
|
-
className: "flex flex-wrap",
|
|
1084
|
-
children: [hasBreadcrumbs && /*#__PURE__*/jsx(Breadcrumbs, {
|
|
1085
|
-
breadcrumbs: breadcrumbs
|
|
1086
|
-
}), /*#__PURE__*/jsx("div", {
|
|
1087
|
-
className: classnames("flex w-full flex-row items-center gap-3", hasBreadcrumbs ? "mt-0" : "-mt-1 max-lg:-mt-2.5 max-md:-mt-2 max-sm:-mt-1"),
|
|
1088
|
-
children: /*#__PURE__*/jsx(Typography, {
|
|
1089
|
-
asChild: true,
|
|
1090
|
-
variant: isNano ? "h4" : "h2",
|
|
1091
|
-
weight: "semibold",
|
|
1092
|
-
children: /*#__PURE__*/jsxs(TitleTag, {
|
|
1093
|
-
"data-testid": "main-header",
|
|
1094
|
-
children: [title, isPresent(titleHelpPopoverProps) && /*#__PURE__*/jsx(HelpPopover, _objectSpread$5({
|
|
1095
|
-
className: "ms-2 inline-flex align-middle",
|
|
1096
|
-
side: "right"
|
|
1097
|
-
}, titleHelpPopoverProps)), renderDropdown(function (_ref2) {
|
|
1098
|
-
var _ref2$dropdownButtonP = _ref2.dropdownButtonProps,
|
|
1099
|
-
dropdownButtonProps = _ref2$dropdownButtonP === void 0 ? {} : _ref2$dropdownButtonP,
|
|
1100
|
-
dropdownProps = _objectWithoutProperties(_ref2, _excluded$2);
|
|
1101
|
-
return /*#__PURE__*/jsx("span", {
|
|
1102
|
-
className: "ms-2 inline-flex align-middle",
|
|
1103
|
-
children: /*#__PURE__*/jsx(MoreDropdown, _objectSpread$5({
|
|
1104
|
-
dropdownButtonProps: _objectSpread$5({
|
|
1105
|
-
size: DROPDOWN_BUTTON_SIZES[size]
|
|
1106
|
-
}, dropdownButtonProps)
|
|
1107
|
-
}, dropdownProps))
|
|
1108
|
-
});
|
|
1109
|
-
})]
|
|
1110
|
-
})
|
|
1111
|
-
})
|
|
1112
|
-
})]
|
|
1113
|
-
}), /*#__PURE__*/jsxs("div", {
|
|
1114
|
-
className: classnames("flex items-center gap-3 empty:hidden", "flex-wrap justify-start md:flex-nowrap md:justify-end"),
|
|
1115
|
-
children: [searchProps && /*#__PURE__*/jsx(Search, _objectSpread$5({
|
|
1116
|
-
enableUrlSync: true,
|
|
1117
|
-
className: classnames("min-w-[12.6rem] grow-0", searchProps.className)
|
|
1118
|
-
}, searchProps)), actionBlock && /*#__PURE__*/jsx("div", {
|
|
1119
|
-
className: "flex shrink-0 items-center justify-end gap-3 max-[360px]:shrink max-[360px]:flex-wrap max-[360px]:justify-start",
|
|
1120
|
-
children: actionBlock
|
|
1121
|
-
})]
|
|
1122
|
-
})]
|
|
1123
|
-
});
|
|
1124
|
-
};
|
|
1125
|
-
|
|
1126
|
-
var MobilePreviewHeader = withT$1(function (_ref) {
|
|
1127
|
-
var t = _ref.t,
|
|
1128
|
-
_ref$className = _ref.className,
|
|
1129
|
-
className = _ref$className === void 0 ? "" : _ref$className,
|
|
1130
|
-
_ref$message = _ref.message,
|
|
1131
|
-
message = _ref$message === void 0 ? "" : _ref$message;
|
|
1132
|
-
return /*#__PURE__*/jsx("div", {
|
|
1133
|
-
className: classnames("bg-muted px-6 py-5", className),
|
|
1134
|
-
"data-testid": "mobile-preview-header",
|
|
1135
|
-
children: /*#__PURE__*/jsx(Typography, {
|
|
1136
|
-
variant: "body2",
|
|
1137
|
-
children: message || t("neetoMolecules.mobilePreview.message")
|
|
1138
|
-
})
|
|
1139
|
-
});
|
|
1140
|
-
});
|
|
1141
|
-
MobilePreviewHeader.propTypes = {
|
|
1142
|
-
className: PropTypes.string,
|
|
1143
|
-
message: PropTypes.node
|
|
1144
|
-
};
|
|
1145
|
-
|
|
1146
|
-
var MemoizedEditorContent = /*#__PURE__*/memo(EditorContent);
|
|
1147
|
-
var EmailPreview = withT(function (_ref) {
|
|
1148
|
-
var t = _ref.t,
|
|
1149
|
-
_ref$to = _ref.to,
|
|
1150
|
-
to = _ref$to === void 0 ? [] : _ref$to,
|
|
1151
|
-
from = _ref.from,
|
|
1152
|
-
subject = _ref.subject,
|
|
1153
|
-
body = _ref.body,
|
|
1154
|
-
actionButtonText = _ref.actionButtonText,
|
|
1155
|
-
logo = _ref.logo,
|
|
1156
|
-
_ref$className = _ref.className,
|
|
1157
|
-
className = _ref$className === void 0 ? "" : _ref$className,
|
|
1158
|
-
customContent = _ref.customContent;
|
|
1159
|
-
return /*#__PURE__*/jsxs("div", {
|
|
1160
|
-
"data-testid": "email-preview-card",
|
|
1161
|
-
className: classnames("bg-background neeto-ui-theme--light relative flex flex-1 flex-col rounded-lg px-6 py-8", className),
|
|
1162
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
1163
|
-
className: "absolute -end-1.5 -top-1.5 z-10 min-w-max rounded-ss-md rounded-se-md rounded-es-md px-3 py-1.5 text-center text-sm font-medium text-[#49545c] shadow-[0px_3px_4px_0px_#00000026] [background:#ffee6a] after:absolute after:end-0 after:top-full after:-z-20 after:[border-width:0_0_12px_6px] after:border-solid after:[border-color:transparent_#ddd06b] after:content-['']",
|
|
1164
|
-
children: t("neetoMolecules.emailPreview.previewMessage")
|
|
1165
|
-
}), /*#__PURE__*/jsxs("div", {
|
|
1166
|
-
className: "w-full pb-4",
|
|
1167
|
-
children: [/*#__PURE__*/jsx(Typography, {
|
|
1168
|
-
className: "text-foreground min-w-0 grow space-x-2 leading-normal break-words",
|
|
1169
|
-
"data-testid": "email-subject-preview",
|
|
1170
|
-
variant: "h4",
|
|
1171
|
-
children: /*#__PURE__*/jsx("span", {
|
|
1172
|
-
children: subject || /*#__PURE__*/jsx("span", {
|
|
1173
|
-
className: "bg-muted h-2 w-40 rounded-full"
|
|
1174
|
-
})
|
|
1175
|
-
})
|
|
1176
|
-
}), /*#__PURE__*/jsxs("div", {
|
|
1177
|
-
className: "mt-4 flex items-center gap-2",
|
|
1178
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
1179
|
-
className: "shrink-0",
|
|
1180
|
-
children: /*#__PURE__*/jsx(SvgAvatarPlaceholder, {})
|
|
1181
|
-
}), /*#__PURE__*/jsxs("div", {
|
|
1182
|
-
className: "flex flex-col gap-1",
|
|
1183
|
-
children: [isPresent(from) ? /*#__PURE__*/jsx(Typography, {
|
|
1184
|
-
variant: "h6",
|
|
1185
|
-
weight: "medium",
|
|
1186
|
-
children: from
|
|
1187
|
-
}) : /*#__PURE__*/jsxs("div", {
|
|
1188
|
-
className: "flex gap-2",
|
|
1189
|
-
children: [/*#__PURE__*/jsx("span", {
|
|
1190
|
-
className: "bg-muted h-2 w-24 rounded-full"
|
|
1191
|
-
}), /*#__PURE__*/jsx("span", {
|
|
1192
|
-
className: "bg-muted h-2 w-24 rounded-full"
|
|
1193
|
-
})]
|
|
1194
|
-
}), isPresent(to) ? /*#__PURE__*/jsx(Typography, {
|
|
1195
|
-
className: "text-muted-foreground line-clamp-1",
|
|
1196
|
-
"data-testid": "email-to-block",
|
|
1197
|
-
variant: "nano",
|
|
1198
|
-
children: to.join(", ")
|
|
1199
|
-
}) : /*#__PURE__*/jsx("span", {
|
|
1200
|
-
className: "bg-muted h-2 w-16 rounded-full",
|
|
1201
|
-
"data-testid": "email-to-block"
|
|
1202
|
-
})]
|
|
1203
|
-
})]
|
|
1204
|
-
})]
|
|
1205
|
-
}), /*#__PURE__*/jsx("div", {
|
|
1206
|
-
className: "bg-muted flex flex-1 flex-col justify-between gap-y-6 rounded px-6 py-4 text-base leading-relaxed",
|
|
1207
|
-
"data-testid": "email-body-preview-container",
|
|
1208
|
-
children: /*#__PURE__*/jsxs("div", {
|
|
1209
|
-
className: "bg-background w-full p-6 md:p-8 2xl:mx-auto 2xl:max-w-lg",
|
|
1210
|
-
children: [body ? /*#__PURE__*/jsx(MemoizedEditorContent, {
|
|
1211
|
-
className: "whitespace-normal",
|
|
1212
|
-
content: body
|
|
1213
|
-
}) : /*#__PURE__*/jsxs("div", {
|
|
1214
|
-
className: "flex flex-col gap-y-4",
|
|
1215
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
1216
|
-
className: "bg-muted h-2 w-48 max-w-full rounded-full md:w-80"
|
|
1217
|
-
}), /*#__PURE__*/jsx("div", {
|
|
1218
|
-
className: "bg-muted h-2 w-40 max-w-full rounded-full md:w-72"
|
|
1219
|
-
}), /*#__PURE__*/jsx("div", {
|
|
1220
|
-
className: "bg-muted h-2 w-48 max-w-full rounded-full md:w-80"
|
|
1221
|
-
})]
|
|
1222
|
-
}), customContent && customContent, actionButtonText && /*#__PURE__*/jsx("div", {
|
|
1223
|
-
className: "mt-6 flex w-full items-center justify-center",
|
|
1224
|
-
children: /*#__PURE__*/jsx(Button, {
|
|
1225
|
-
className: "pointer-events-none",
|
|
1226
|
-
label: actionButtonText
|
|
1227
|
-
})
|
|
1228
|
-
}), logo && /*#__PURE__*/jsx("img", {
|
|
1229
|
-
alt: t("neetoMolecules.emailPreview.logoAltText"),
|
|
1230
|
-
className: "h-20 w-36 object-cover",
|
|
1231
|
-
"data-testid": "company-logo-preview",
|
|
1232
|
-
src: logo
|
|
1233
|
-
})]
|
|
1234
|
-
})
|
|
1235
|
-
})]
|
|
1236
|
-
});
|
|
1237
|
-
});
|
|
1238
|
-
EmailPreview.propTypes = {
|
|
1239
|
-
/**
|
|
1240
|
-
* The value of the send-to field.
|
|
1241
|
-
*/
|
|
1242
|
-
to: PropTypes.arrayOf(PropTypes.string),
|
|
1243
|
-
/**
|
|
1244
|
-
* The value of the send-from field.
|
|
1245
|
-
*/
|
|
1246
|
-
from: PropTypes.string,
|
|
1247
|
-
/**
|
|
1248
|
-
* The subject of the email.
|
|
1249
|
-
*/
|
|
1250
|
-
subject: PropTypes.string,
|
|
1251
|
-
/**
|
|
1252
|
-
* The body of the email.
|
|
1253
|
-
*/
|
|
1254
|
-
body: PropTypes.string,
|
|
1255
|
-
/**
|
|
1256
|
-
* The text to be shown in the action button.
|
|
1257
|
-
*/
|
|
1258
|
-
actionButtonText: PropTypes.string,
|
|
1259
|
-
/**
|
|
1260
|
-
* Source link for the company logo.
|
|
1261
|
-
*/
|
|
1262
|
-
logo: PropTypes.string,
|
|
1263
|
-
/**
|
|
1264
|
-
* To pass custom content that will be rendered above the action button.
|
|
1265
|
-
*/
|
|
1266
|
-
customContent: PropTypes.string
|
|
1267
|
-
};
|
|
1268
|
-
|
|
1269
|
-
var INITIAL_FORM_VALUES = {
|
|
1270
|
-
sendTo: [],
|
|
1271
|
-
sendToId: "",
|
|
1272
|
-
sendToCc: [],
|
|
1273
|
-
sendToBcc: [],
|
|
1274
|
-
replyTo: "",
|
|
1275
|
-
showCopyEmails: false,
|
|
1276
|
-
subject: "",
|
|
1277
|
-
message: "",
|
|
1278
|
-
isEnabled: false
|
|
1279
|
-
};
|
|
1280
|
-
var EMAIL_FORM_VALIDATION_SCHEMA = yup.object({
|
|
1281
|
-
subject: yup.string().required(t("neetoMolecules.emailForm.errors.subjectRequired")),
|
|
1282
|
-
message: yup.string().test("message", t("neetoMolecules.emailForm.errors.messageRequired"), function (value) {
|
|
1283
|
-
return !isEditorEmpty(value);
|
|
1284
|
-
})
|
|
1285
|
-
});
|
|
1286
|
-
var sendToFieldValidation = function sendToFieldValidation(maxEmails) {
|
|
1287
|
-
var validation = yup.array().test("all-emails-valid", t("neetoMolecules.emailForm.errors.invalidEmailAddress"), function (emails) {
|
|
1288
|
-
return emails === null || emails === void 0 ? void 0 : emails.every(prop("valid"));
|
|
1289
|
-
}).test("max-email-count", t("neetoMolecules.emailForm.errors.maxEmails", {
|
|
1290
|
-
count: maxEmails
|
|
1291
|
-
}), function (emails) {
|
|
1292
|
-
return (emails === null || emails === void 0 ? void 0 : emails.length) <= maxEmails;
|
|
1293
|
-
});
|
|
1294
|
-
return yup.object({
|
|
1295
|
-
sendTo: validation.min(1, t("neetoMolecules.emailForm.errors.required", {
|
|
1296
|
-
entity: t("neetoMolecules.emailForm.fields.sendToEmailAddress")
|
|
1297
|
-
})).nullable(),
|
|
1298
|
-
sendToCc: validation,
|
|
1299
|
-
sendToBcc: validation
|
|
1300
|
-
});
|
|
1301
|
-
};
|
|
1302
|
-
var SEND_TO_ID_FIELD_VALIDATION = yup.object({
|
|
1303
|
-
sendToId: yup.string().required(t("neetoMolecules.emailForm.errors.required", {
|
|
1304
|
-
entity: t("neetoMolecules.emailForm.labels.sendTo")
|
|
1305
|
-
}))
|
|
1306
|
-
});
|
|
1307
|
-
var REPLY_TO_FIELD_VALIDATION = yup.object({
|
|
1308
|
-
replyTo: yup.string().nullable().email(t("neetoMolecules.emailForm.errors.invalidEmailAddress")).required(t("neetoMolecules.emailForm.errors.required", {
|
|
1309
|
-
entity: t("neetoMolecules.emailForm.fields.replyToEmailAddress")
|
|
1310
|
-
}))
|
|
1311
|
-
});
|
|
1312
|
-
var EDITOR_ADDONS = ["highlight", "emoji", "code-block", "block-quote", "image-upload", "divider", "video-embed"];
|
|
1313
|
-
|
|
1314
|
-
/* eslint-disable @bigbinary/neeto/use-zustand-for-global-state-management */
|
|
1315
|
-
var EmailFormContext = /*#__PURE__*/createContext({
|
|
1316
|
-
showSendToField: false,
|
|
1317
|
-
showSendToAsRadio: false,
|
|
1318
|
-
showReplyToField: false,
|
|
1319
|
-
showCcField: false,
|
|
1320
|
-
showBccField: false
|
|
1321
|
-
});
|
|
1322
|
-
|
|
1323
|
-
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; }
|
|
1324
|
-
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; }
|
|
1325
|
-
var getValidationSchema = function getValidationSchema(_ref) {
|
|
1326
|
-
var showSendToField = _ref.showSendToField,
|
|
1327
|
-
showReplyToField = _ref.showReplyToField,
|
|
1328
|
-
showSendToAsRadio = _ref.showSendToAsRadio,
|
|
1329
|
-
customValidations = _ref.customValidations,
|
|
1330
|
-
maxEmails = _ref.maxEmails;
|
|
1331
|
-
var schema = EMAIL_FORM_VALIDATION_SCHEMA.clone();
|
|
1332
|
-
if (showSendToField) {
|
|
1333
|
-
schema = schema.concat(showSendToAsRadio ? SEND_TO_ID_FIELD_VALIDATION : sendToFieldValidation(maxEmails));
|
|
1334
|
-
}
|
|
1335
|
-
if (showReplyToField) schema = schema.concat(REPLY_TO_FIELD_VALIDATION);
|
|
1336
|
-
var isYupObject = customValidations.type === "object";
|
|
1337
|
-
if (isYupObject) {
|
|
1338
|
-
var customFields = customValidations.fields || {};
|
|
1339
|
-
schema = schema.shape(customFields);
|
|
1340
|
-
} else if (_typeof(customValidations) === "object") {
|
|
1341
|
-
schema = schema.shape(customValidations);
|
|
1342
|
-
}
|
|
1343
|
-
return schema;
|
|
1344
|
-
};
|
|
1345
|
-
var getReplyToFieldLabelProps = function getReplyToFieldLabelProps(_ref2) {
|
|
1346
|
-
var popoverProps = _ref2.popoverProps;
|
|
1347
|
-
return {
|
|
1348
|
-
helpIconProps: _objectSpread$3({
|
|
1349
|
-
className: "reply-to-help-icon"
|
|
1350
|
-
}, isPresent(popoverProps) ? {
|
|
1351
|
-
popoverProps: _objectSpread$3(_objectSpread$3({}, popoverProps), {}, {
|
|
1352
|
-
description: popoverProps.description || t("neetoMolecules.emailForm.tooltips.replyTo")
|
|
1353
|
-
})
|
|
1354
|
-
} : {
|
|
1355
|
-
tooltipProps: {
|
|
1356
|
-
content: t("neetoMolecules.emailForm.tooltips.replyTo")
|
|
1357
|
-
}
|
|
1358
|
-
})
|
|
1359
|
-
};
|
|
1360
|
-
};
|
|
1361
|
-
var resolveContent = function resolveContent(content, func, variable) {
|
|
1362
|
-
if (typeof func === "function") {
|
|
1363
|
-
return func(content, variable);
|
|
1364
|
-
}
|
|
1365
|
-
return content;
|
|
1366
|
-
};
|
|
1367
|
-
var normalizeHtmlString = function normalizeHtmlString(str) {
|
|
1368
|
-
if (typeof str !== "string") return str;
|
|
1369
|
-
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();
|
|
1370
|
-
};
|
|
1371
|
-
|
|
1372
|
-
var ReplyToField = function ReplyToField(_ref) {
|
|
1373
|
-
var _ref$options = _ref.options,
|
|
1374
|
-
options = _ref$options === void 0 ? [] : _ref$options,
|
|
1375
|
-
_ref$popoverProps = _ref.popoverProps,
|
|
1376
|
-
popoverProps = _ref$popoverProps === void 0 ? {} : _ref$popoverProps;
|
|
1377
|
-
var _useTranslation = useTranslation(),
|
|
1378
|
-
t = _useTranslation.t;
|
|
1379
|
-
var _useFormikContext = useFormikContext(),
|
|
1380
|
-
setFieldValue = _useFormikContext.setFieldValue;
|
|
1381
|
-
var isDropdownField = isNotEmpty(options);
|
|
1382
|
-
var labelProps = getReplyToFieldLabelProps({
|
|
1383
|
-
popoverProps: popoverProps
|
|
1384
|
-
});
|
|
1385
|
-
if (isDropdownField) {
|
|
1386
|
-
return /*#__PURE__*/jsx(Select, {
|
|
1387
|
-
labelProps: labelProps,
|
|
1388
|
-
options: options,
|
|
1389
|
-
isClearable: true,
|
|
1390
|
-
className: "w-full",
|
|
1391
|
-
"data-testid": "reply-to-select-field",
|
|
1392
|
-
label: t("neetoMolecules.emailForm.labels.replyTo"),
|
|
1393
|
-
name: "replyTo",
|
|
1394
|
-
onChange: function onChange(value) {
|
|
1395
|
-
return setFieldValue("replyTo", value !== null && value !== void 0 ? value : "");
|
|
1396
|
-
}
|
|
1397
|
-
});
|
|
1398
|
-
}
|
|
1399
|
-
return /*#__PURE__*/jsx(Input$1, {
|
|
1400
|
-
labelProps: labelProps,
|
|
1401
|
-
autoFocus: true,
|
|
1402
|
-
nakedInput: true,
|
|
1403
|
-
required: true,
|
|
1404
|
-
className: "w-full",
|
|
1405
|
-
"data-testid": "reply-to-input-field",
|
|
1406
|
-
label: t("neetoMolecules.emailForm.labels.replyTo"),
|
|
1407
|
-
name: "replyTo",
|
|
1408
|
-
placeholder: t("neetoMolecules.emailForm.placeholders.emailPlaceholder"),
|
|
1409
|
-
size: "large",
|
|
1410
|
-
onChange: function onChange(event) {
|
|
1411
|
-
var _event$target$value;
|
|
1412
|
-
return setFieldValue("replyTo", (_event$target$value = event.target.value) === null || _event$target$value === void 0 ? void 0 : _event$target$value.toLowerCase());
|
|
1413
|
-
}
|
|
1414
|
-
});
|
|
1415
|
-
};
|
|
1416
|
-
|
|
1417
|
-
var SendToField = function SendToField(_ref) {
|
|
1418
|
-
var showBccField = _ref.showBccField,
|
|
1419
|
-
showCcField = _ref.showCcField,
|
|
1420
|
-
showSendToTextField = _ref.showSendToTextField;
|
|
1421
|
-
var _useTranslation = useTranslation(),
|
|
1422
|
-
t = _useTranslation.t;
|
|
1423
|
-
if (!showSendToTextField && !showBccField && !showCcField) return null;
|
|
1424
|
-
return /*#__PURE__*/jsx(SendToFields, {
|
|
1425
|
-
showCcBccButton: true,
|
|
1426
|
-
showBccField: showSendToTextField ? false : showBccField,
|
|
1427
|
-
showCcField: showSendToTextField ? false : showCcField,
|
|
1428
|
-
showSendToField: showSendToTextField,
|
|
1429
|
-
bccInputProps: {
|
|
1430
|
-
label: t("neetoMolecules.emailForm.labels.bCc"),
|
|
1431
|
-
name: "sendToBcc",
|
|
1432
|
-
placeholder: t("neetoMolecules.emailForm.placeholders.commaSeparatedEmails")
|
|
1433
|
-
},
|
|
1434
|
-
ccInputProps: {
|
|
1435
|
-
label: t("neetoMolecules.emailForm.labels.cc"),
|
|
1436
|
-
name: "sendToCc",
|
|
1437
|
-
placeholder: t("neetoMolecules.emailForm.placeholders.commaSeparatedEmails")
|
|
1438
|
-
},
|
|
1439
|
-
emailInputProps: {
|
|
1440
|
-
id: "sendTo",
|
|
1441
|
-
name: "sendTo",
|
|
1442
|
-
label: t("neetoMolecules.emailForm.labels.sendTo"),
|
|
1443
|
-
placeholder: t("neetoMolecules.emailForm.placeholders.commaSeparatedEmails"),
|
|
1444
|
-
required: true
|
|
1445
|
-
}
|
|
1446
|
-
});
|
|
1447
|
-
};
|
|
1448
|
-
|
|
1449
|
-
var SubjectField = function SubjectField(_ref) {
|
|
1450
|
-
var name = _ref.name,
|
|
1451
|
-
text = _ref.text,
|
|
1452
|
-
updateText = _ref.updateText,
|
|
1453
|
-
_ref$subjectVariables = _ref.subjectVariables,
|
|
1454
|
-
subjectVariables = _ref$subjectVariables === void 0 ? [] : _ref$subjectVariables,
|
|
1455
|
-
error = _ref.error,
|
|
1456
|
-
_ref$required = _ref.required,
|
|
1457
|
-
required = _ref$required === void 0 ? false : _ref$required,
|
|
1458
|
-
onBlur = _ref.onBlur;
|
|
1459
|
-
var _useState = useState(false),
|
|
1460
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1461
|
-
isFieldFocusedOnce = _useState2[0],
|
|
1462
|
-
setIsFieldFocusedOnce = _useState2[1];
|
|
1463
|
-
var _useTranslation = useTranslation(),
|
|
1464
|
-
t = _useTranslation.t;
|
|
1465
|
-
var tagClickHandler = function tagClickHandler(_ref2) {
|
|
1466
|
-
var slug = _ref2.key,
|
|
1467
|
-
category = _ref2.category;
|
|
1468
|
-
var textAreaElement = document.querySelector("textarea[name=".concat(name, "]"));
|
|
1469
|
-
var splitIndex = isFieldFocusedOnce && textAreaElement ? textAreaElement.selectionEnd : text.length;
|
|
1470
|
-
var variable = category ? "".concat(category, ".").concat(slug) : slug;
|
|
1471
|
-
var updatedSubject = [text.slice(0, splitIndex), " {{".concat(variable, "}}"), text.slice(splitIndex)].join("");
|
|
1472
|
-
updateText(updatedSubject);
|
|
1473
|
-
};
|
|
1474
|
-
return /*#__PURE__*/jsx(Input, {
|
|
1475
|
-
error: error,
|
|
1476
|
-
name: name,
|
|
1477
|
-
onBlur: onBlur,
|
|
1478
|
-
required: required,
|
|
1479
|
-
nakedInput: true,
|
|
1480
|
-
label: t("neetoMolecules.emailForm.labels.subject"),
|
|
1481
|
-
placeholder: t("neetoMolecules.emailForm.placeholders.subject"),
|
|
1482
|
-
value: text,
|
|
1483
|
-
suffix: /*#__PURE__*/jsx(DynamicVariables, {
|
|
1484
|
-
buttonProps: {
|
|
1485
|
-
className: "m-1"
|
|
1486
|
-
},
|
|
1487
|
-
dropdownProps: {
|
|
1488
|
-
className: "overflow-y-auto"
|
|
1489
|
-
},
|
|
1490
|
-
variables: subjectVariables,
|
|
1491
|
-
onVariableClick: tagClickHandler
|
|
1492
|
-
}),
|
|
1493
|
-
onChange: withEventTargetValue(updateText),
|
|
1494
|
-
onFocus: function onFocus() {
|
|
1495
|
-
return setIsFieldFocusedOnce(true);
|
|
1496
|
-
}
|
|
1497
|
-
});
|
|
1498
|
-
};
|
|
1499
|
-
|
|
1500
|
-
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; }
|
|
1501
|
-
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; }
|
|
1502
|
-
var EmailForm = function EmailForm(_ref) {
|
|
1503
|
-
var _globalProps$user;
|
|
1504
|
-
var _ref$messageVariables = _ref.messageVariables,
|
|
1505
|
-
messageVariables = _ref$messageVariables === void 0 ? [] : _ref$messageVariables,
|
|
1506
|
-
_ref$subjectVariables = _ref.subjectVariables,
|
|
1507
|
-
subjectVariables = _ref$subjectVariables === void 0 ? [] : _ref$subjectVariables,
|
|
1508
|
-
handleCancel = _ref.handleCancel,
|
|
1509
|
-
handleResetToDefault = _ref.handleResetToDefault,
|
|
1510
|
-
isLoading = _ref.isLoading,
|
|
1511
|
-
replyToFieldProps = _ref.replyToFieldProps,
|
|
1512
|
-
sendToFieldProps = _ref.sendToFieldProps,
|
|
1513
|
-
replyToOptions = _ref.replyToOptions,
|
|
1514
|
-
_ref$sendToOptions = _ref.sendToOptions,
|
|
1515
|
-
sendToOptions = _ref$sendToOptions === void 0 ? [] : _ref$sendToOptions,
|
|
1516
|
-
_ref$isUpdating = _ref.isUpdating,
|
|
1517
|
-
isUpdating = _ref$isUpdating === void 0 ? false : _ref$isUpdating,
|
|
1518
|
-
_ref$isResetting = _ref.isResetting,
|
|
1519
|
-
isResetting = _ref$isResetting === void 0 ? false : _ref$isResetting,
|
|
1520
|
-
_ref$showFields = _ref.showFields,
|
|
1521
|
-
showFields = _ref$showFields === void 0 ? true : _ref$showFields,
|
|
1522
|
-
_ref$className = _ref.className,
|
|
1523
|
-
className = _ref$className === void 0 ? "" : _ref$className,
|
|
1524
|
-
_ref$editorAddons = _ref.editorAddons,
|
|
1525
|
-
editorAddons = _ref$editorAddons === void 0 ? EDITOR_ADDONS : _ref$editorAddons,
|
|
1526
|
-
showResetToDefaultButton = _ref.showResetToDefaultButton,
|
|
1527
|
-
_ref$editorRef = _ref.editorRef,
|
|
1528
|
-
editorRef = _ref$editorRef === void 0 ? null : _ref$editorRef,
|
|
1529
|
-
_ref$defaultValues = _ref.defaultValues,
|
|
1530
|
-
defaultValues = _ref$defaultValues === void 0 ? {} : _ref$defaultValues;
|
|
1531
|
-
var _useTranslation = useTranslation(),
|
|
1532
|
-
t = _useTranslation.t;
|
|
1533
|
-
var _useContext = useContext(EmailFormContext),
|
|
1534
|
-
showSendToField = _useContext.showSendToField,
|
|
1535
|
-
showSendToAsRadio = _useContext.showSendToAsRadio,
|
|
1536
|
-
showReplyToField = _useContext.showReplyToField,
|
|
1537
|
-
showCcField = _useContext.showCcField,
|
|
1538
|
-
showBccField = _useContext.showBccField;
|
|
1539
|
-
var _useFormikContext = useFormikContext(),
|
|
1540
|
-
setFieldValue = _useFormikContext.setFieldValue,
|
|
1541
|
-
values = _useFormikContext.values,
|
|
1542
|
-
resetForm = _useFormikContext.resetForm;
|
|
1543
|
-
var normalizedValues = _objectSpread$2(_objectSpread$2({}, values), {}, {
|
|
1544
|
-
message: normalizeHtmlString(values.message)
|
|
1545
|
-
});
|
|
1546
|
-
var normalizedDefaultValues = _objectSpread$2(_objectSpread$2({}, defaultValues), {}, {
|
|
1547
|
-
message: normalizeHtmlString(defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues.message)
|
|
1548
|
-
});
|
|
1549
|
-
normalizedDefaultValues.replyTo || (normalizedDefaultValues.replyTo = (_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.email);
|
|
1550
|
-
var disabled = equals(normalizedValues, normalizedDefaultValues);
|
|
1551
|
-
var sendToFieldOptions = (sendToFieldProps === null || sendToFieldProps === void 0 ? void 0 : sendToFieldProps.options) || sendToOptions;
|
|
1552
|
-
var showSendToRadioField = showSendToField && showSendToAsRadio && isNotEmpty(sendToFieldOptions);
|
|
1553
|
-
var showSendToTextField = showSendToField && !showSendToRadioField;
|
|
1554
|
-
return /*#__PURE__*/jsxs("div", {
|
|
1555
|
-
"data-testid": "email-form",
|
|
1556
|
-
className: classnames("flex flex-1 flex-col items-start gap-2 !pb-0", _defineProperty({}, className, className)),
|
|
1557
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
1558
|
-
className: "w-full grow",
|
|
1559
|
-
children: showFields && /*#__PURE__*/jsxs("div", {
|
|
1560
|
-
className: "flex w-full flex-col items-start justify-start gap-5",
|
|
1561
|
-
children: [showSendToRadioField && /*#__PURE__*/jsx(RadioGroup, {
|
|
1562
|
-
className: "pb-2",
|
|
1563
|
-
"data-testid": "send-to-id",
|
|
1564
|
-
label: t("neetoMolecules.emailForm.labels.sendTo"),
|
|
1565
|
-
labelProps: {
|
|
1566
|
-
required: true
|
|
1567
|
-
},
|
|
1568
|
-
name: "sendToId",
|
|
1569
|
-
children: sendToFieldOptions.map(function (_ref2) {
|
|
1570
|
-
var label = _ref2.label,
|
|
1571
|
-
value = _ref2.value;
|
|
1572
|
-
return /*#__PURE__*/createElement(RadioGroup.Item, {
|
|
1573
|
-
label: label,
|
|
1574
|
-
value: value,
|
|
1575
|
-
key: value
|
|
1576
|
-
});
|
|
1577
|
-
})
|
|
1578
|
-
}), /*#__PURE__*/jsx(SendToField, {
|
|
1579
|
-
showBccField: showBccField,
|
|
1580
|
-
showCcField: showCcField,
|
|
1581
|
-
showSendToTextField: showSendToTextField
|
|
1582
|
-
}), showReplyToField && /*#__PURE__*/jsx("div", {
|
|
1583
|
-
className: "border-border w-full border-b pb-1",
|
|
1584
|
-
children: /*#__PURE__*/jsx(ReplyToField, _objectSpread$2({
|
|
1585
|
-
options: replyToOptions
|
|
1586
|
-
}, replyToFieldProps))
|
|
1587
|
-
}), /*#__PURE__*/jsx(Field, {
|
|
1588
|
-
name: "subject",
|
|
1589
|
-
children: function children(_ref3) {
|
|
1590
|
-
var _ref3$field = _ref3.field,
|
|
1591
|
-
value = _ref3$field.value,
|
|
1592
|
-
onBlur = _ref3$field.onBlur,
|
|
1593
|
-
_ref3$meta = _ref3.meta,
|
|
1594
|
-
error = _ref3$meta.error,
|
|
1595
|
-
touched = _ref3$meta.touched;
|
|
1596
|
-
return /*#__PURE__*/jsx("div", {
|
|
1597
|
-
className: "border-border w-full border-b pb-1",
|
|
1598
|
-
children: /*#__PURE__*/jsx(SubjectField, {
|
|
1599
|
-
onBlur: onBlur,
|
|
1600
|
-
subjectVariables: subjectVariables,
|
|
1601
|
-
required: true,
|
|
1602
|
-
error: touched && error ? t(error) : undefined,
|
|
1603
|
-
name: "subject",
|
|
1604
|
-
text: value,
|
|
1605
|
-
updateText: function updateText(text) {
|
|
1606
|
-
return setFieldValue("subject", text);
|
|
1607
|
-
}
|
|
1608
|
-
})
|
|
1609
|
-
});
|
|
1610
|
-
}
|
|
1611
|
-
}), /*#__PURE__*/jsx("div", {
|
|
1612
|
-
className: "w-full",
|
|
1613
|
-
"data-testid": "message-input-container",
|
|
1614
|
-
children: /*#__PURE__*/jsx(FormikEditor, {
|
|
1615
|
-
required: true,
|
|
1616
|
-
addons: editorAddons,
|
|
1617
|
-
"data-testid": "message-input-field",
|
|
1618
|
-
hideSlashCommands: false,
|
|
1619
|
-
id: "form_message",
|
|
1620
|
-
menuType: "fixed",
|
|
1621
|
-
name: "message",
|
|
1622
|
-
placeholder: t("neetoMolecules.emailForm.placeholders.message"),
|
|
1623
|
-
ref: editorRef,
|
|
1624
|
-
variables: messageVariables,
|
|
1625
|
-
shouldUpdate: function shouldUpdate(nextProps, prevProps) {
|
|
1626
|
-
return notEqualsDeep(nextProps.variables, prevProps.variables);
|
|
1627
|
-
}
|
|
1628
|
-
})
|
|
1629
|
-
})]
|
|
1630
|
-
})
|
|
1631
|
-
}), /*#__PURE__*/jsxs("div", {
|
|
1632
|
-
className: "bg-background z-10 flex w-full justify-between py-6 lg:sticky lg:bottom-0",
|
|
1633
|
-
children: [/*#__PURE__*/jsx(ActionBlock, {
|
|
1634
|
-
cancelButtonProps: {
|
|
1635
|
-
onClick: handleCancel
|
|
1636
|
-
},
|
|
1637
|
-
isSubmitting: isLoading || isUpdating
|
|
1638
|
-
}), showResetToDefaultButton && /*#__PURE__*/jsx("div", {
|
|
1639
|
-
children: /*#__PURE__*/jsx(Button, {
|
|
1640
|
-
disabled: disabled,
|
|
1641
|
-
"data-testid": "reset-to-default-button",
|
|
1642
|
-
label: t("neetoMolecules.emailForm.labels.resetToDefault"),
|
|
1643
|
-
loading: isResetting,
|
|
1644
|
-
variant: "secondary",
|
|
1645
|
-
onClick: function onClick() {
|
|
1646
|
-
resetForm();
|
|
1647
|
-
handleResetToDefault();
|
|
1648
|
-
}
|
|
1649
|
-
})
|
|
1650
|
-
})]
|
|
1651
|
-
})]
|
|
1652
|
-
});
|
|
1653
|
-
};
|
|
1654
|
-
|
|
1655
|
-
function ownKeys$1$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; }
|
|
1656
|
-
function _objectSpread$1$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1657
|
-
var EmailFormComponent = function EmailFormComponent(_ref) {
|
|
1658
|
-
var _ref$onSubmit = _ref.onSubmit,
|
|
1659
|
-
onSubmit = _ref$onSubmit === void 0 ? noop : _ref$onSubmit,
|
|
1660
|
-
_ref$initialValues = _ref.initialValues,
|
|
1661
|
-
initialValues = _ref$initialValues === void 0 ? INITIAL_FORM_VALUES : _ref$initialValues,
|
|
1662
|
-
_children = _ref.children,
|
|
1663
|
-
formikProps = _ref.formikProps,
|
|
1664
|
-
validationSchema = _ref.validationSchema,
|
|
1665
|
-
_ref$showSendToField = _ref.showSendToField,
|
|
1666
|
-
showSendToField = _ref$showSendToField === void 0 ? false : _ref$showSendToField,
|
|
1667
|
-
_ref$showReplyToField = _ref.showReplyToField,
|
|
1668
|
-
showReplyToField = _ref$showReplyToField === void 0 ? false : _ref$showReplyToField,
|
|
1669
|
-
_ref$showSendToAsRadi = _ref.showSendToAsRadio,
|
|
1670
|
-
showSendToAsRadio = _ref$showSendToAsRadi === void 0 ? false : _ref$showSendToAsRadi,
|
|
1671
|
-
_ref$blockNavigation = _ref.blockNavigation,
|
|
1672
|
-
blockNavigation = _ref$blockNavigation === void 0 ? true : _ref$blockNavigation,
|
|
1673
|
-
_ref$showCcField = _ref.showCcField,
|
|
1674
|
-
showCcField = _ref$showCcField === void 0 ? false : _ref$showCcField,
|
|
1675
|
-
_ref$showBccField = _ref.showBccField,
|
|
1676
|
-
showBccField = _ref$showBccField === void 0 ? false : _ref$showBccField,
|
|
1677
|
-
_ref$isLoading = _ref.isLoading,
|
|
1678
|
-
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
|
|
1679
|
-
_ref$maxEmails = _ref.maxEmails,
|
|
1680
|
-
maxEmails = _ref$maxEmails === void 0 ? 10 : _ref$maxEmails,
|
|
1681
|
-
_ref$emailFormProps = _ref.emailFormProps,
|
|
1682
|
-
emailFormProps = _ref$emailFormProps === void 0 ? {} : _ref$emailFormProps,
|
|
1683
|
-
_ref$emailPreviewProp = _ref.emailPreviewProps,
|
|
1684
|
-
emailPreviewProps = _ref$emailPreviewProp === void 0 ? {} : _ref$emailPreviewProp,
|
|
1685
|
-
_ref$headerProps = _ref.headerProps,
|
|
1686
|
-
headerProps = _ref$headerProps === void 0 ? {} : _ref$headerProps,
|
|
1687
|
-
_ref$tooltipProps = _ref.tooltipProps,
|
|
1688
|
-
tooltipProps = _ref$tooltipProps === void 0 ? {} : _ref$tooltipProps,
|
|
1689
|
-
_ref$switchProps = _ref.switchProps,
|
|
1690
|
-
switchProps = _ref$switchProps === void 0 ? {} : _ref$switchProps,
|
|
1691
|
-
_ref$mobilePreviewPro = _ref.mobilePreviewProps,
|
|
1692
|
-
mobilePreviewProps = _ref$mobilePreviewPro === void 0 ? {} : _ref$mobilePreviewPro;
|
|
1693
|
-
var formatBody = emailPreviewProps.formatBody,
|
|
1694
|
-
formatSubject = emailPreviewProps.formatSubject,
|
|
1695
|
-
bodyVariables = emailPreviewProps.bodyVariables,
|
|
1696
|
-
subjectVariables = emailPreviewProps.subjectVariables;
|
|
1697
|
-
var shouldShowFields = function shouldShowFields(values) {
|
|
1698
|
-
return isEmpty(switchProps) || values.isEnabled;
|
|
1699
|
-
};
|
|
1700
|
-
return /*#__PURE__*/jsx(EmailFormProvider, {
|
|
1701
|
-
formikProps: formikProps,
|
|
1702
|
-
initialValues: initialValues,
|
|
1703
|
-
maxEmails: maxEmails,
|
|
1704
|
-
onSubmit: onSubmit,
|
|
1705
|
-
showBccField: showBccField,
|
|
1706
|
-
showCcField: showCcField,
|
|
1707
|
-
showReplyToField: showReplyToField,
|
|
1708
|
-
showSendToAsRadio: showSendToAsRadio,
|
|
1709
|
-
showSendToField: showSendToField,
|
|
1710
|
-
validationSchema: validationSchema,
|
|
1711
|
-
children: function children(_ref2) {
|
|
1712
|
-
var _values$sendTo;
|
|
1713
|
-
var values = _ref2.values,
|
|
1714
|
-
isSubmitting = _ref2.isSubmitting;
|
|
1715
|
-
return /*#__PURE__*/jsxs("div", {
|
|
1716
|
-
className: "flex h-[calc(100dvh-64px)] flex-grow flex-col overflow-y-auto lg:flex-row",
|
|
1717
|
-
children: [/*#__PURE__*/jsxs("div", {
|
|
1718
|
-
className: "flex w-full flex-col px-5 md:px-10 lg:h-full lg:w-1/2 lg:overflow-y-auto",
|
|
1719
|
-
children: [blockNavigation && /*#__PURE__*/jsx(BlockNavigation, {}), isNotEmpty(headerProps) && /*#__PURE__*/jsx(Header, _objectSpread$1$1({
|
|
1720
|
-
className: "px-0",
|
|
1721
|
-
size: "small"
|
|
1722
|
-
}, headerProps)), isNotEmpty(switchProps) && /*#__PURE__*/jsx("div", {
|
|
1723
|
-
className: "flex items-center justify-between gap-y-0.5 pb-6",
|
|
1724
|
-
children: /*#__PURE__*/jsx(Tooltip, _objectSpread$1$1(_objectSpread$1$1({
|
|
1725
|
-
disabled: !(switchProps !== null && switchProps !== void 0 && switchProps.disabled),
|
|
1726
|
-
position: "top"
|
|
1727
|
-
}, tooltipProps), {}, {
|
|
1728
|
-
children: /*#__PURE__*/jsx("div", {
|
|
1729
|
-
className: "flex items-center gap-2",
|
|
1730
|
-
children: /*#__PURE__*/jsx(Switch, _objectSpread$1$1({
|
|
1731
|
-
"data-testid": "switch",
|
|
1732
|
-
name: "isEnabled"
|
|
1733
|
-
}, switchProps))
|
|
1734
|
-
})
|
|
1735
|
-
}))
|
|
1736
|
-
}), shouldShowFields(values) && _children, /*#__PURE__*/jsx(EmailForm, _objectSpread$1$1({
|
|
1737
|
-
isLoading: isSubmitting || isLoading,
|
|
1738
|
-
isUpdating: isSubmitting || isLoading,
|
|
1739
|
-
showFields: shouldShowFields(values)
|
|
1740
|
-
}, emailFormProps))]
|
|
1741
|
-
}), shouldShowFields(values) && /*#__PURE__*/jsx(MobilePreviewHeader, _objectSpread$1$1({
|
|
1742
|
-
className: "lg:hidden"
|
|
1743
|
-
}, mobilePreviewProps)), shouldShowFields(values) && /*#__PURE__*/jsx("div", {
|
|
1744
|
-
className: "bg-muted w-full px-6 py-10 lg:w-1/2 lg:overflow-y-auto",
|
|
1745
|
-
children: /*#__PURE__*/jsx(EmailPreview, _objectSpread$1$1({
|
|
1746
|
-
body: resolveContent(values.message, formatBody, bodyVariables),
|
|
1747
|
-
from: values.sendFrom,
|
|
1748
|
-
to: pluck("value", (_values$sendTo = values === null || values === void 0 ? void 0 : values.sendTo) !== null && _values$sendTo !== void 0 ? _values$sendTo : []),
|
|
1749
|
-
subject: resolveContent(values.subject, formatSubject, subjectVariables)
|
|
1750
|
-
}, emailPreviewProps))
|
|
1751
|
-
})]
|
|
1752
|
-
});
|
|
1753
|
-
}
|
|
1754
|
-
});
|
|
1755
|
-
};
|
|
1756
|
-
|
|
1757
|
-
function ownKeys$4(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; }
|
|
1758
|
-
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1759
|
-
var EmailFormProvider = function EmailFormProvider(_ref) {
|
|
1760
|
-
var _globalProps$user;
|
|
1761
|
-
var _ref$onSubmit = _ref.onSubmit,
|
|
1762
|
-
onSubmit = _ref$onSubmit === void 0 ? noop : _ref$onSubmit,
|
|
1763
|
-
_ref$initialValues = _ref.initialValues,
|
|
1764
|
-
initialValues = _ref$initialValues === void 0 ? INITIAL_FORM_VALUES : _ref$initialValues,
|
|
1765
|
-
children = _ref.children,
|
|
1766
|
-
formikProps = _ref.formikProps,
|
|
1767
|
-
_ref$validationSchema = _ref.validationSchema,
|
|
1768
|
-
customValidations = _ref$validationSchema === void 0 ? {} : _ref$validationSchema,
|
|
1769
|
-
_ref$showSendToField = _ref.showSendToField,
|
|
1770
|
-
showSendToField = _ref$showSendToField === void 0 ? false : _ref$showSendToField,
|
|
1771
|
-
_ref$showReplyToField = _ref.showReplyToField,
|
|
1772
|
-
showReplyToField = _ref$showReplyToField === void 0 ? false : _ref$showReplyToField,
|
|
1773
|
-
_ref$showSendToAsRadi = _ref.showSendToAsRadio,
|
|
1774
|
-
showSendToAsRadio = _ref$showSendToAsRadi === void 0 ? false : _ref$showSendToAsRadi,
|
|
1775
|
-
_ref$showCcField = _ref.showCcField,
|
|
1776
|
-
showCcField = _ref$showCcField === void 0 ? false : _ref$showCcField,
|
|
1777
|
-
_ref$showBccField = _ref.showBccField,
|
|
1778
|
-
showBccField = _ref$showBccField === void 0 ? false : _ref$showBccField,
|
|
1779
|
-
_ref$maxEmails = _ref.maxEmails,
|
|
1780
|
-
maxEmails = _ref$maxEmails === void 0 ? 10 : _ref$maxEmails;
|
|
1781
|
-
return /*#__PURE__*/jsx("div", {
|
|
1782
|
-
"data-testid": "email-form-provider",
|
|
1783
|
-
children: /*#__PURE__*/jsx(EmailFormContext.Provider, {
|
|
1784
|
-
value: {
|
|
1785
|
-
showSendToField: showSendToField,
|
|
1786
|
-
showSendToAsRadio: showSendToAsRadio,
|
|
1787
|
-
showReplyToField: showReplyToField,
|
|
1788
|
-
showCcField: showCcField,
|
|
1789
|
-
showBccField: showBccField
|
|
1790
|
-
},
|
|
1791
|
-
children: /*#__PURE__*/jsx(Form, {
|
|
1792
|
-
formikProps: _objectSpread$4({
|
|
1793
|
-
enableReinitialize: true,
|
|
1794
|
-
validationSchema: getValidationSchema({
|
|
1795
|
-
showSendToField: showSendToField,
|
|
1796
|
-
showReplyToField: showReplyToField,
|
|
1797
|
-
showSendToAsRadio: showSendToAsRadio,
|
|
1798
|
-
customValidations: customValidations,
|
|
1799
|
-
maxEmails: maxEmails
|
|
1800
|
-
}),
|
|
1801
|
-
initialValues: _objectSpread$4(_objectSpread$4({}, initialValues), {}, {
|
|
1802
|
-
replyTo: initialValues.replyTo || ((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.email)
|
|
1803
|
-
}),
|
|
1804
|
-
onSubmit: onSubmit
|
|
1805
|
-
}, formikProps),
|
|
1806
|
-
children: children
|
|
1807
|
-
})
|
|
1808
|
-
})
|
|
1809
|
-
});
|
|
1810
|
-
};
|
|
1811
|
-
|
|
1812
18
|
var FORM_VALIDATION_SCHEMA = {
|
|
1813
19
|
isEnabled: yup["boolean"]()
|
|
1814
20
|
};
|
|
@@ -1841,8 +47,7 @@ var parseEmailsOptions = function parseEmailsOptions() {
|
|
|
1841
47
|
var emailOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1842
48
|
return emailOptions.map(prop("label"));
|
|
1843
49
|
};
|
|
1844
|
-
var parseEmailNotificationData = function parseEmailNotificationData(data,
|
|
1845
|
-
var _sendToOptions$;
|
|
50
|
+
var parseEmailNotificationData = function parseEmailNotificationData(data, defaultSendToId) {
|
|
1846
51
|
var notifyEmails = data.notifyEmails,
|
|
1847
52
|
notifyCcEmails = data.notifyCcEmails,
|
|
1848
53
|
notifyBccEmails = data.notifyBccEmails,
|
|
@@ -1854,7 +59,7 @@ var parseEmailNotificationData = function parseEmailNotificationData(data, sendT
|
|
|
1854
59
|
parsed.sendToCc = notifyCcEmails ? createEmailOptions(notifyCcEmails) : [];
|
|
1855
60
|
parsed.sendToBcc = notifyCcEmails ? createEmailOptions(notifyBccEmails) : [];
|
|
1856
61
|
parsed.replyTo = replyToId || customFields["replyTo"];
|
|
1857
|
-
parsed.sendToId = customFields["sendToId"] ||
|
|
62
|
+
parsed.sendToId = customFields["sendToId"] || defaultSendToId || "";
|
|
1858
63
|
parsed.showCopyEmails = !!(notifyCcEmails !== null && notifyCcEmails !== void 0 && notifyCcEmails.length || notifyBccEmails !== null && notifyBccEmails !== void 0 && notifyBccEmails.length);
|
|
1859
64
|
return parsed;
|
|
1860
65
|
};
|
|
@@ -1922,7 +127,7 @@ var _excluded = ["validationSchema"];
|
|
|
1922
127
|
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; }
|
|
1923
128
|
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; }
|
|
1924
129
|
var NeetoEmailNotificationForm = function NeetoEmailNotificationForm(_ref) {
|
|
1925
|
-
var _emailFormProps$sendT
|
|
130
|
+
var _emailFormProps$sendT;
|
|
1926
131
|
var _ref$emailNotificatio = _ref.emailNotificationParams,
|
|
1927
132
|
emailNotificationParams = _ref$emailNotificatio === void 0 ? {} : _ref$emailNotificatio,
|
|
1928
133
|
_ref$emailPreviewProp = _ref.emailPreviewProps,
|
|
@@ -1948,7 +153,7 @@ var NeetoEmailNotificationForm = function NeetoEmailNotificationForm(_ref) {
|
|
|
1948
153
|
_ref$blockNavigation = _ref.blockNavigation,
|
|
1949
154
|
blockNavigation = _ref$blockNavigation === void 0 ? false : _ref$blockNavigation,
|
|
1950
155
|
_ref$onSuccess = _ref.onSuccess,
|
|
1951
|
-
|
|
156
|
+
_onSuccess = _ref$onSuccess === void 0 ? noop : _ref$onSuccess,
|
|
1952
157
|
children = _ref.children;
|
|
1953
158
|
var editorRef = useRef();
|
|
1954
159
|
var _useTranslation = useTranslation(),
|
|
@@ -1958,18 +163,28 @@ var NeetoEmailNotificationForm = function NeetoEmailNotificationForm(_ref) {
|
|
|
1958
163
|
data = _useFetchEmailNotific2 === void 0 ? {} : _useFetchEmailNotific2,
|
|
1959
164
|
isLoading = _useFetchEmailNotific.isLoading;
|
|
1960
165
|
var _useUpdateEmailNotifi = useUpdateEmailNotification(),
|
|
1961
|
-
updateEmailNotification = _useUpdateEmailNotifi.
|
|
166
|
+
updateEmailNotification = _useUpdateEmailNotifi.mutateAsync,
|
|
1962
167
|
isSubmitting = _useUpdateEmailNotifi.isPending;
|
|
1963
168
|
var _useResetEmailNotific = useResetEmailNotificationToDefault(),
|
|
1964
169
|
resetToDefault = _useResetEmailNotific.mutate,
|
|
1965
170
|
isResetting = _useResetEmailNotific.isPending;
|
|
1966
|
-
var
|
|
171
|
+
var defaultSendToId = emailFormProps === null || emailFormProps === void 0 || (_emailFormProps$sendT = emailFormProps.sendToFieldProps) === null || _emailFormProps$sendT === void 0 || (_emailFormProps$sendT = _emailFormProps$sendT.options) === null || _emailFormProps$sendT === void 0 || (_emailFormProps$sendT = _emailFormProps$sendT[0]) === null || _emailFormProps$sendT === void 0 ? void 0 : _emailFormProps$sendT.value;
|
|
172
|
+
var initialValues = useMemo(function () {
|
|
173
|
+
return isNotPresent(data) ? {} : parseEmailNotificationData(data, defaultSendToId);
|
|
174
|
+
}, [data, defaultSendToId]);
|
|
175
|
+
var handleSubmit = function handleSubmit(values, _ref2) {
|
|
1967
176
|
var _emailFormProps$reply;
|
|
177
|
+
var resetForm = _ref2.resetForm;
|
|
1968
178
|
var isDisabledByUser = data.isEnabled && !values.isEnabled;
|
|
1969
179
|
var isReplyToDropdownField = (emailFormProps === null || emailFormProps === void 0 || (_emailFormProps$reply = emailFormProps.replyToFieldProps) === null || _emailFormProps$reply === void 0 ? void 0 : _emailFormProps$reply.options) !== undefined;
|
|
1970
180
|
var body = mergeDeepLeft(packEmailPayload(values, isReplyToDropdownField, isDisabledByUser), emailNotificationParams);
|
|
1971
|
-
updateEmailNotification(body, {
|
|
1972
|
-
onSuccess: onSuccess
|
|
181
|
+
return updateEmailNotification(body, {
|
|
182
|
+
onSuccess: function onSuccess() {
|
|
183
|
+
resetForm({
|
|
184
|
+
values: values
|
|
185
|
+
});
|
|
186
|
+
_onSuccess.apply(void 0, arguments);
|
|
187
|
+
}
|
|
1973
188
|
});
|
|
1974
189
|
};
|
|
1975
190
|
if (isLoading || isNotPresent(data)) {
|
|
@@ -1979,7 +194,7 @@ var NeetoEmailNotificationForm = function NeetoEmailNotificationForm(_ref) {
|
|
|
1979
194
|
});
|
|
1980
195
|
}
|
|
1981
196
|
var newDefaultAttributes = generateDefaultValues(data);
|
|
1982
|
-
var defaultValues = parseEmailNotificationData(newDefaultAttributes,
|
|
197
|
+
var defaultValues = parseEmailNotificationData(newDefaultAttributes, defaultSendToId);
|
|
1983
198
|
defaultValues.defaultAttributes = data.defaultAttributes;
|
|
1984
199
|
var formattedTitle = renderText(title, t("neetoEmailNotifications.emailNotification.title"));
|
|
1985
200
|
var formattedNotificationToggleLabel = renderText(notificationToggleLabel, t("neetoEmailNotifications.emailNotification.notificationToggleLabel"));
|
|
@@ -1987,21 +202,22 @@ var NeetoEmailNotificationForm = function NeetoEmailNotificationForm(_ref) {
|
|
|
1987
202
|
formikProps = _objectWithoutProperties(emailFormikProps, _excluded);
|
|
1988
203
|
var handleResetToDefault = function handleResetToDefault() {
|
|
1989
204
|
resetToDefault(emailNotificationParams, {
|
|
1990
|
-
onSuccess: function onSuccess(
|
|
205
|
+
onSuccess: function onSuccess(_ref3) {
|
|
1991
206
|
var _editorRef$current;
|
|
1992
|
-
var emailNotification =
|
|
207
|
+
var emailNotification = _ref3.emailNotification;
|
|
1993
208
|
return editorRef === null || editorRef === void 0 || (_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 || (_editorRef$current = _editorRef$current.editor) === null || _editorRef$current === void 0 || (_editorRef$current = _editorRef$current.commands) === null || _editorRef$current === void 0 ? void 0 : _editorRef$current.setContent(emailNotification.message);
|
|
1994
209
|
}
|
|
1995
210
|
});
|
|
1996
211
|
};
|
|
1997
212
|
return /*#__PURE__*/jsx("div", {
|
|
1998
213
|
className: "min-w-0 grow overflow-y-auto",
|
|
1999
|
-
children: /*#__PURE__*/jsx(
|
|
2000
|
-
blockNavigation: blockNavigation,
|
|
214
|
+
children: /*#__PURE__*/jsx(EmailForm, _objectSpread(_objectSpread({}, _objectSpread({
|
|
2001
215
|
emailPreviewProps: emailPreviewProps,
|
|
2002
216
|
formikProps: formikProps,
|
|
217
|
+
initialValues: initialValues,
|
|
2003
218
|
tooltipProps: tooltipProps
|
|
2004
219
|
}, mergeLeft(fieldsVisibility, DEFAULT_FIELDS_VISIBILITY))), {}, {
|
|
220
|
+
blockNavigation: blockNavigation && !isSubmitting,
|
|
2005
221
|
isLoading: isSubmitting,
|
|
2006
222
|
validationSchema: customValidationSchema || FORM_VALIDATION_SCHEMA,
|
|
2007
223
|
emailFormProps: _objectSpread({
|
|
@@ -2015,7 +231,6 @@ var NeetoEmailNotificationForm = function NeetoEmailNotificationForm(_ref) {
|
|
|
2015
231
|
titleHelpPopoverProps: helpPopoverProps,
|
|
2016
232
|
breadcrumbs: breadcrumbs
|
|
2017
233
|
},
|
|
2018
|
-
initialValues: parseEmailNotificationData(data, emailFormProps === null || emailFormProps === void 0 || (_emailFormProps$sendT2 = emailFormProps.sendToFieldProps) === null || _emailFormProps$sendT2 === void 0 ? void 0 : _emailFormProps$sendT2.options),
|
|
2019
234
|
switchProps: {
|
|
2020
235
|
label: formattedNotificationToggleLabel,
|
|
2021
236
|
disabled: disabled,
|