@bigbinary/neeto-molecules 1.1.18 → 1.1.20

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/README.md CHANGED
@@ -60,6 +60,7 @@ https://neeto-molecules.neeto.com/
60
60
  - [MoreDropdown](./docs/components.md#MoreDropdown)
61
61
  - [Builder](./docs/components.md#Builder)
62
62
  - [Metadata](./docs/components.md#metadata)
63
+ - [DocumentEditor](./docs/components.md#DocumentEditor)
63
64
 
64
65
  ## Installation Instructions
65
66
 
@@ -0,0 +1,274 @@
1
+ import React, { useRef, useState } from 'react';
2
+ import { noop } from '@bigbinary/neeto-commons-frontend/pure';
3
+ import { FormikEditor } from '@bigbinary/neeto-editor';
4
+ import { Typography } from '@bigbinary/neetoui';
5
+ import { Textarea } from '@bigbinary/neetoui/formik';
6
+ import { useTranslation } from 'react-i18next';
7
+ import { useFormikContext } from 'formik';
8
+ import { useHotKeys } from '@bigbinary/neeto-commons-frontend/react-utils';
9
+
10
+ function _extends() {
11
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
12
+ for (var i = 1; i < arguments.length; i++) {
13
+ var source = arguments[i];
14
+ for (var key in source) {
15
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
16
+ target[key] = source[key];
17
+ }
18
+ }
19
+ }
20
+ return target;
21
+ };
22
+ return _extends.apply(this, arguments);
23
+ }
24
+
25
+ function _typeof(obj) {
26
+ "@babel/helpers - typeof";
27
+
28
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
29
+ return typeof obj;
30
+ } : function (obj) {
31
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
32
+ }, _typeof(obj);
33
+ }
34
+
35
+ function _toPrimitive(input, hint) {
36
+ if (_typeof(input) !== "object" || input === null) return input;
37
+ var prim = input[Symbol.toPrimitive];
38
+ if (prim !== undefined) {
39
+ var res = prim.call(input, hint || "default");
40
+ if (_typeof(res) !== "object") return res;
41
+ throw new TypeError("@@toPrimitive must return a primitive value.");
42
+ }
43
+ return (hint === "string" ? String : Number)(input);
44
+ }
45
+
46
+ function _toPropertyKey(arg) {
47
+ var key = _toPrimitive(arg, "string");
48
+ return _typeof(key) === "symbol" ? key : String(key);
49
+ }
50
+
51
+ function _defineProperty(obj, key, value) {
52
+ key = _toPropertyKey(key);
53
+ if (key in obj) {
54
+ Object.defineProperty(obj, key, {
55
+ value: value,
56
+ enumerable: true,
57
+ configurable: true,
58
+ writable: true
59
+ });
60
+ } else {
61
+ obj[key] = value;
62
+ }
63
+ return obj;
64
+ }
65
+
66
+ function _arrayWithHoles(arr) {
67
+ if (Array.isArray(arr)) return arr;
68
+ }
69
+
70
+ function _iterableToArrayLimit(arr, i) {
71
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
72
+ if (null != _i) {
73
+ var _s,
74
+ _e,
75
+ _x,
76
+ _r,
77
+ _arr = [],
78
+ _n = !0,
79
+ _d = !1;
80
+ try {
81
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
82
+ if (Object(_i) !== _i) return;
83
+ _n = !1;
84
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
85
+ } catch (err) {
86
+ _d = !0, _e = err;
87
+ } finally {
88
+ try {
89
+ if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
90
+ } finally {
91
+ if (_d) throw _e;
92
+ }
93
+ }
94
+ return _arr;
95
+ }
96
+ }
97
+
98
+ function _arrayLikeToArray(arr, len) {
99
+ if (len == null || len > arr.length) len = arr.length;
100
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
101
+ return arr2;
102
+ }
103
+
104
+ function _unsupportedIterableToArray(o, minLen) {
105
+ if (!o) return;
106
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
107
+ var n = Object.prototype.toString.call(o).slice(8, -1);
108
+ if (n === "Object" && o.constructor) n = o.constructor.name;
109
+ if (n === "Map" || n === "Set") return Array.from(o);
110
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
111
+ }
112
+
113
+ function _nonIterableRest() {
114
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
115
+ }
116
+
117
+ function _slicedToArray(arr, i) {
118
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
119
+ }
120
+
121
+ var EDITOR_ADDONS = ["highlight", "emoji", "video-upload", "code-block", "block-quote", "image-upload", "image-upload-unsplash", "divider", "video-embed", "undo", "redo", "attachments", "table"];
122
+ var DEFAULT_EDITOR_PROPS = {
123
+ isCharacterCountActive: true,
124
+ isMenuIndependent: true,
125
+ addons: []
126
+ };
127
+
128
+ var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
129
+
130
+ var css = ".neeto-molecules-new-document__wrapper{flex-grow:1;height:100%;overflow-y:auto;width:100%}.neeto-molecules-new-document__wrapper .neeto-molecules-new-document__container{margin:0 auto;max-width:768px!important}.neeto-molecules-new-document__wrapper .neeto-molecules-new-document__title{margin:24px 0 0;width:100%}.neeto-molecules-new-document__wrapper .neeto-molecules-new-document__title .neeto-ui-input{padding:0!important}.neeto-molecules-new-document__wrapper .neeto-molecules-new-document__title .neeto-ui-input textarea{color:rgb(var(--neeto-ui-black));font-size:42px;font-weight:700;line-height:48px;resize:none}.neeto-molecules-new-document__wrapper .neeto-molecules-new-document__title .neeto-ui-input textarea::-moz-placeholder{color:rgb(var(--neeto-ui-gray-300))}.neeto-molecules-new-document__wrapper .neeto-molecules-new-document__title .neeto-ui-input textarea::placeholder{color:rgb(var(--neeto-ui-gray-300))}.neeto-molecules-new-document__wrapper .neeto-molecules-editor-content__error{margin:12px auto}.neeto-molecules-new-document__wrapper .ProseMirror{max-height:none;overflow-y:hidden}.neeto-molecules-new-document__wrapper .neeto-editor-fixed-menu{background-color:rgb(var(--neeto-ui-gray-100));border:thin solid rgb(var(--neeto-ui-gray-200));border-left:none;border-right:none}.neeto-molecules-new-document__wrapper .neeto-editor-fixed-menu__wrapper{margin:0 auto;max-width:768px;padding:4px 8px}.neeto-molecules-new-document__wrapper .editor-content__wrapper{border:none!important;padding:12px 16px 0!important;width:100%!important}.neeto-molecules-new-document__wrapper .editor-content-attachments{border:none;margin:12px auto 0;max-width:768px!important;padding-left:16px;padding-right:16px}.neeto-molecules-new-document__wrapper .editor-content-attachments--no-attachments{display:none!important}.neeto-molecules-new-document__wrapper .neeto-editor-character-count{margin:0 auto;max-width:768px!important;padding-left:16px;padding-right:16px}.neeto-molecules-new-document__wrapper .ne-attachments__wrapper{width:100%}.editor-content__wrapper.neeto-editor{padding:0 16px}.editor-content__wrapper.neeto-editor h1{margin:2rem 0 .25rem}.editor-content__wrapper.neeto-editor h2{margin:1.5rem 0 .25rem}.editor-content__wrapper.neeto-editor h3{margin:1rem 0 .25rem}.editor-content__wrapper.neeto-editor p{font-size:1rem;line-height:1.5}.editor-content__wrapper.neeto-editor ol,.editor-content__wrapper.neeto-editor ul{margin-bottom:1rem;padding-left:24px}.editor-content__wrapper.neeto-editor ol li,.editor-content__wrapper.neeto-editor ul li{margin-bottom:.5rem}.editor-content__wrapper.neeto-editor ol li p,.editor-content__wrapper.neeto-editor ul li p{margin-bottom:0}.editor-content__wrapper.neeto-editor ol li:last-child,.editor-content__wrapper.neeto-editor ul li:last-child{margin-bottom:.5rem}.editor-content__wrapper.neeto-editor .neeto-editor-table{margin:8px 0 0}.editor-content__wrapper.neeto-editor .neeto-editor-table table{border-radius:0}.editor-content__wrapper.neeto-editor .neeto-editor-table p{margin-bottom:0}.editor-content__wrapper.neeto-editor .neeto-editor-table .neeto-editor-table__add-column,.editor-content__wrapper.neeto-editor .neeto-editor-table .neeto-editor-table__add-row{visibility:hidden}.editor-content__wrapper.neeto-editor .neeto-editor-table:hover .neeto-editor-table__add-column,.editor-content__wrapper.neeto-editor .neeto-editor-table:hover .neeto-editor-table__add-row{visibility:visible}ins{background-color:#c1f4cb!important;text-decoration:none!important}del{background-color:#faa!important}.neeto-molecules__menubar .neeto-molecules-menubar__subtitle,.neeto-molecules__menubar .neeto-molecules-menubar__title{margin-left:8px}";
131
+ n(css,{});
132
+
133
+ var useEditor = function useEditor(_ref) {
134
+ var onContentChange = _ref.onContentChange,
135
+ editorContentFieldName = _ref.editorContentFieldName,
136
+ setAttachments = _ref.setAttachments,
137
+ onAttachmentChange = _ref.onAttachmentChange,
138
+ onTitleChange = _ref.onTitleChange,
139
+ titleFieldName = _ref.titleFieldName,
140
+ editorRef = _ref.editorRef;
141
+ var _useFormikContext = useFormikContext(),
142
+ setFieldValue = _useFormikContext.setFieldValue,
143
+ errors = _useFormikContext.errors;
144
+ var handleContentChange = function handleContentChange(content) {
145
+ setFieldValue(editorContentFieldName, content);
146
+ onContentChange(content);
147
+ };
148
+ var handleAttachmentChange = function handleAttachmentChange(attachments) {
149
+ setAttachments(attachments);
150
+ setFieldValue("attachments", attachments);
151
+ onAttachmentChange(attachments);
152
+ };
153
+ var handleTitleChange = function handleTitleChange(event) {
154
+ var title = event.target.value;
155
+ setFieldValue(titleFieldName, title);
156
+ onTitleChange(title);
157
+ };
158
+ var titleHotkeyRef = useHotKeys("return", function () {
159
+ var _editorRef$current, _editorRef$current$ed, _editorRef$current$ed2;
160
+ return (_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 ? void 0 : (_editorRef$current$ed = _editorRef$current.editor) === null || _editorRef$current$ed === void 0 ? void 0 : (_editorRef$current$ed2 = _editorRef$current$ed.commands) === null || _editorRef$current$ed2 === void 0 ? void 0 : _editorRef$current$ed2.focus();
161
+ }, {
162
+ mode: "scoped"
163
+ });
164
+ return {
165
+ handleContentChange: handleContentChange,
166
+ handleAttachmentChange: handleAttachmentChange,
167
+ handleTitleChange: handleTitleChange,
168
+ titleHotkeyRef: titleHotkeyRef,
169
+ errors: errors
170
+ };
171
+ };
172
+
173
+ function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
174
+ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
175
+ var getUniqueAttachments = function getUniqueAttachments(attachments) {
176
+ var uniqueAttachments = attachments === null || attachments === void 0 ? void 0 : attachments.reduce(function (uniqueAttachments, attachment) {
177
+ return _objectSpread$1(_objectSpread$1({}, uniqueAttachments), {}, _defineProperty({}, attachment.signedId, attachment));
178
+ }, {});
179
+ return Object.values(uniqueAttachments || {});
180
+ };
181
+
182
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
183
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
184
+ var Editor = function Editor(_ref) {
185
+ var initialAttachments = _ref.attachments,
186
+ onContentChange = _ref.onContentChange,
187
+ onAttachmentChange = _ref.onAttachmentChange,
188
+ onTitleChange = _ref.onTitleChange,
189
+ _ref$getTitleRef = _ref.getTitleRef,
190
+ getTitleRef = _ref$getTitleRef === void 0 ? noop : _ref$getTitleRef,
191
+ _ref$getEditorRef = _ref.getEditorRef,
192
+ getEditorRef = _ref$getEditorRef === void 0 ? noop : _ref$getEditorRef,
193
+ _ref$editorContentFie = _ref.editorContentFieldName,
194
+ editorContentFieldName = _ref$editorContentFie === void 0 ? "htmlContent" : _ref$editorContentFie,
195
+ _ref$titleFieldName = _ref.titleFieldName,
196
+ titleFieldName = _ref$titleFieldName === void 0 ? "title" : _ref$titleFieldName,
197
+ _ref$editorProps = _ref.editorProps,
198
+ editorProps = _ref$editorProps === void 0 ? DEFAULT_EDITOR_PROPS : _ref$editorProps,
199
+ _ref$titleProps = _ref.titleProps,
200
+ titleProps = _ref$titleProps === void 0 ? {} : _ref$titleProps;
201
+ var _useTranslation = useTranslation(),
202
+ t = _useTranslation.t;
203
+ var titleRef = useRef();
204
+ var editorRef = useRef();
205
+ var _useState = useState(function () {
206
+ return getUniqueAttachments(initialAttachments);
207
+ }),
208
+ _useState2 = _slicedToArray(_useState, 2),
209
+ attachments = _useState2[0],
210
+ setAttachments = _useState2[1];
211
+ var _useEditor = useEditor({
212
+ onContentChange: onContentChange,
213
+ editorContentFieldName: editorContentFieldName,
214
+ setAttachments: setAttachments,
215
+ onAttachmentChange: onAttachmentChange,
216
+ onTitleChange: onTitleChange,
217
+ titleFieldName: titleFieldName,
218
+ editorRef: editorRef
219
+ }),
220
+ handleContentChange = _useEditor.handleContentChange,
221
+ handleAttachmentChange = _useEditor.handleAttachmentChange,
222
+ handleTitleChange = _useEditor.handleTitleChange,
223
+ titleHotkeyRef = _useEditor.titleHotkeyRef,
224
+ errors = _useEditor.errors;
225
+ var setTitleRef = function setTitleRef(node) {
226
+ titleHotkeyRef.current = node;
227
+ getTitleRef(node);
228
+ titleRef.current = node;
229
+ };
230
+ var setEditorRef = function setEditorRef(node) {
231
+ getEditorRef(node);
232
+ editorRef.current = node;
233
+ };
234
+ return /*#__PURE__*/React.createElement("div", {
235
+ className: "neeto-molecules-new-document__wrapper flex",
236
+ "data-testid": "document-editor-container"
237
+ }, /*#__PURE__*/React.createElement(FormikEditor, _extends({
238
+ attachmentsClassName: "editor-content-attachments",
239
+ className: "h-full w-full",
240
+ contentClassName: "editor-content__wrapper neeto-molecules-new-document__container",
241
+ "data-cy": "article-content-text-area",
242
+ error: undefined,
243
+ menuClassName: "w-full sticky top-0 z-20",
244
+ name: editorContentFieldName,
245
+ ref: setEditorRef
246
+ }, _objectSpread({
247
+ attachments: attachments
248
+ }, editorProps), {
249
+ addons: EDITOR_ADDONS.concat(editorProps.addons),
250
+ onChange: handleContentChange,
251
+ onChangeAttachments: handleAttachmentChange
252
+ }), /*#__PURE__*/React.createElement("div", {
253
+ className: "neeto-molecules-new-document__container px-4"
254
+ }, /*#__PURE__*/React.createElement(Textarea, _extends({
255
+ nakedTextarea: true,
256
+ className: "neeto-molecules-new-document__title",
257
+ "data-cy": "article-title-text-field",
258
+ name: titleFieldName,
259
+ ref: setTitleRef,
260
+ rows: 1,
261
+ placeholder: titleProps.placeholder || t("neetoMolecules.documentEditor.title"),
262
+ onChange: handleTitleChange,
263
+ onKeyDown: function onKeyDown(e) {
264
+ return e.key === "Enter" && !e.shiftKey && e.preventDefault();
265
+ }
266
+ }, titleProps)), errors[editorContentFieldName] && /*#__PURE__*/React.createElement(Typography, {
267
+ className: "neeto-ui-input__error neeto-molecules-editor-content__error",
268
+ "data-cy": "articles-content-input-error",
269
+ style: "body3"
270
+ }, errors[editorContentFieldName]))));
271
+ };
272
+
273
+ export { Editor as default };
274
+ //# sourceMappingURL=DocumentEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocumentEditor.js","sources":["../node_modules/@babel/runtime/helpers/esm/extends.js","../node_modules/@babel/runtime/helpers/esm/typeof.js","../node_modules/@babel/runtime/helpers/esm/toPrimitive.js","../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js","../node_modules/@babel/runtime/helpers/esm/defineProperty.js","../node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js","../node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js","../node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js","../node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js","../node_modules/@babel/runtime/helpers/esm/nonIterableRest.js","../node_modules/@babel/runtime/helpers/esm/slicedToArray.js","../src/components/DocumentEditor/constants.js","../node_modules/rollup-plugin-styles/dist/runtime/inject-css.js","../src/components/DocumentEditor/hooks/useEditor.js","../src/components/DocumentEditor/utils.js","../src/components/DocumentEditor/index.jsx"],"sourcesContent":["export default function _extends() {\n _extends = Object.assign ? Object.assign.bind() : function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n return _extends.apply(this, arguments);\n}","export default function _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n }, _typeof(obj);\n}","import _typeof from \"./typeof.js\";\nexport default function _toPrimitive(input, hint) {\n if (_typeof(input) !== \"object\" || input === null) return input;\n var prim = input[Symbol.toPrimitive];\n if (prim !== undefined) {\n var res = prim.call(input, hint || \"default\");\n if (_typeof(res) !== \"object\") return res;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (hint === \"string\" ? String : Number)(input);\n}","import _typeof from \"./typeof.js\";\nimport toPrimitive from \"./toPrimitive.js\";\nexport default function _toPropertyKey(arg) {\n var key = toPrimitive(arg, \"string\");\n return _typeof(key) === \"symbol\" ? key : String(key);\n}","import toPropertyKey from \"./toPropertyKey.js\";\nexport default function _defineProperty(obj, key, value) {\n key = toPropertyKey(key);\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}","export default function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}","export default function _iterableToArrayLimit(arr, i) {\n var _i = null == arr ? null : \"undefined\" != typeof Symbol && arr[Symbol.iterator] || arr[\"@@iterator\"];\n if (null != _i) {\n var _s,\n _e,\n _x,\n _r,\n _arr = [],\n _n = !0,\n _d = !1;\n try {\n if (_x = (_i = _i.call(arr)).next, 0 === i) {\n if (Object(_i) !== _i) return;\n _n = !1;\n } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);\n } catch (err) {\n _d = !0, _e = err;\n } finally {\n try {\n if (!_n && null != _i[\"return\"] && (_r = _i[\"return\"](), Object(_r) !== _r)) return;\n } finally {\n if (_d) throw _e;\n }\n }\n return _arr;\n }\n}","export default function _arrayLikeToArray(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n return arr2;\n}","import arrayLikeToArray from \"./arrayLikeToArray.js\";\nexport default function _unsupportedIterableToArray(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return arrayLikeToArray(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(o);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);\n}","export default function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}","import arrayWithHoles from \"./arrayWithHoles.js\";\nimport iterableToArrayLimit from \"./iterableToArrayLimit.js\";\nimport unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nimport nonIterableRest from \"./nonIterableRest.js\";\nexport default function _slicedToArray(arr, i) {\n return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();\n}","export const EDITOR_ADDONS = [\n \"highlight\",\n \"emoji\",\n \"video-upload\",\n \"code-block\",\n \"block-quote\",\n \"image-upload\",\n \"image-upload-unsplash\",\n \"divider\",\n \"video-embed\",\n \"undo\",\n \"redo\",\n \"attachments\",\n \"table\",\n];\n\nexport const DEFAULT_EDITOR_PROPS = {\n isCharacterCountActive: true,\n isMenuIndependent: true,\n addons: [],\n};\n","var e=[],t=[];function n(n,r){if(n&&\"undefined\"!=typeof document){var a,s=!0===r.prepend?\"prepend\":\"append\",d=!0===r.singleTag,i=\"string\"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName(\"head\")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c()}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n))}function c(){var e=document.createElement(\"style\");if(e.setAttribute(\"type\",\"text/css\"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a=\"prepend\"===s?\"afterbegin\":\"beforeend\";return i.insertAdjacentElement(a,e),e}}export{n as default};\n","import { useFormikContext } from \"formik\";\nimport { useHotKeys } from \"neetocommons/react-utils\";\n\nconst useEditor = ({\n onContentChange,\n editorContentFieldName,\n setAttachments,\n onAttachmentChange,\n onTitleChange,\n titleFieldName,\n editorRef,\n}) => {\n const { setFieldValue, errors } = useFormikContext();\n\n const handleContentChange = content => {\n setFieldValue(editorContentFieldName, content);\n onContentChange(content);\n };\n\n const handleAttachmentChange = attachments => {\n setAttachments(attachments);\n setFieldValue(\"attachments\", attachments);\n onAttachmentChange(attachments);\n };\n\n const handleTitleChange = event => {\n const title = event.target.value;\n setFieldValue(titleFieldName, title);\n onTitleChange(title);\n };\n\n const titleHotkeyRef = useHotKeys(\n \"return\",\n () => editorRef.current?.editor?.commands?.focus(),\n { mode: \"scoped\" }\n );\n\n return {\n handleContentChange,\n handleAttachmentChange,\n handleTitleChange,\n titleHotkeyRef,\n errors,\n };\n};\n\nexport default useEditor;\n","export const getUniqueAttachments = attachments => {\n const uniqueAttachments = attachments?.reduce(\n (uniqueAttachments, attachment) => ({\n ...uniqueAttachments,\n [attachment.signedId]: attachment,\n }),\n {}\n );\n\n return Object.values(uniqueAttachments || {});\n};\n","import React, { useRef, useState } from \"react\";\n\nimport { noop } from \"neetocommons/pure\";\nimport { FormikEditor } from \"neetoeditor\";\nimport { Typography } from \"neetoui\";\nimport { Textarea } from \"neetoui/formik\";\nimport PropTypes from \"prop-types\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { DEFAULT_EDITOR_PROPS, EDITOR_ADDONS } from \"./constants\";\nimport \"./editor.scss\";\nimport useEditor from \"./hooks/useEditor\";\nimport { getUniqueAttachments } from \"./utils\";\n\nconst Editor = ({\n attachments: initialAttachments,\n onContentChange,\n onAttachmentChange,\n onTitleChange,\n getTitleRef = noop,\n getEditorRef = noop,\n editorContentFieldName = \"htmlContent\",\n titleFieldName = \"title\",\n editorProps = DEFAULT_EDITOR_PROPS,\n titleProps = {},\n}) => {\n const { t } = useTranslation();\n\n const titleRef = useRef();\n const editorRef = useRef();\n\n const [attachments, setAttachments] = useState(() =>\n getUniqueAttachments(initialAttachments)\n );\n\n const {\n handleContentChange,\n handleAttachmentChange,\n handleTitleChange,\n titleHotkeyRef,\n errors,\n } = useEditor({\n onContentChange,\n editorContentFieldName,\n setAttachments,\n onAttachmentChange,\n onTitleChange,\n titleFieldName,\n editorRef,\n });\n\n const setTitleRef = node => {\n titleHotkeyRef.current = node;\n getTitleRef(node);\n titleRef.current = node;\n };\n\n const setEditorRef = node => {\n getEditorRef(node);\n editorRef.current = node;\n };\n\n return (\n <div\n className=\"neeto-molecules-new-document__wrapper flex\"\n data-testid=\"document-editor-container\"\n >\n <FormikEditor\n attachmentsClassName=\"editor-content-attachments\"\n className=\"h-full w-full\"\n contentClassName=\"editor-content__wrapper neeto-molecules-new-document__container\"\n data-cy=\"article-content-text-area\"\n error={undefined}\n menuClassName=\"w-full sticky top-0 z-20\"\n name={editorContentFieldName}\n ref={setEditorRef}\n {...{ attachments, ...editorProps }}\n addons={EDITOR_ADDONS.concat(editorProps.addons)}\n onChange={handleContentChange}\n onChangeAttachments={handleAttachmentChange}\n >\n <div className=\"neeto-molecules-new-document__container px-4\">\n <Textarea\n nakedTextarea\n className=\"neeto-molecules-new-document__title\"\n data-cy=\"article-title-text-field\"\n name={titleFieldName}\n ref={setTitleRef}\n rows={1}\n placeholder={\n titleProps.placeholder || t(\"neetoMolecules.documentEditor.title\")\n }\n onChange={handleTitleChange}\n onKeyDown={e =>\n e.key === \"Enter\" && !e.shiftKey && e.preventDefault()\n }\n {...titleProps}\n />\n {errors[editorContentFieldName] && (\n <Typography\n className=\"neeto-ui-input__error neeto-molecules-editor-content__error\"\n data-cy=\"articles-content-input-error\"\n style=\"body3\"\n >\n {errors[editorContentFieldName]}\n </Typography>\n )}\n </div>\n </FormikEditor>\n </div>\n );\n};\n\nEditor.propTypes = {\n /**\n * List of initial attachments.\n */\n attachments: PropTypes.arrayOf(\n PropTypes.shape({\n contentType: PropTypes.string,\n filename: PropTypes.string,\n signedId: PropTypes.string,\n url: PropTypes.string,\n })\n ),\n /**\n * Callback that will be triggered when the editor content changes.\n * This function is not throttled.\n */\n onContentChange: PropTypes.func,\n /**\n * Callback that will be triggered when the attachments changes.\n */\n onAttachmentChange: PropTypes.func,\n /**\n * Callback that will be triggered when the article title changes.\n */\n onTitleChange: PropTypes.func,\n /**\n * This function will be called with the title node reference.\n */\n getTitleRef: PropTypes.func,\n /**\n * This function will be called with editor reference.\n */\n getEditorRef: PropTypes.func,\n /**\n * Formik field name of the editor. The default value is `htmlContent`.\n */\n editorContentFieldName: PropTypes.string,\n /**\n * Formik field name of the title. The default value is `title`.\n */\n titleFieldName: PropTypes.string,\n /**\n * These props will be passed down to the editor component.\n */\n editorProps: PropTypes.object,\n /**\n * These props will be passed down to the title text area component.\n */\n titleProps: PropTypes.object,\n};\n\nexport default Editor;\n"],"names":["toPrimitive","toPropertyKey","arrayLikeToArray","arrayWithHoles","iterableToArrayLimit","unsupportedIterableToArray","nonIterableRest","EDITOR_ADDONS","DEFAULT_EDITOR_PROPS","isCharacterCountActive","isMenuIndependent","addons","useEditor","_ref","onContentChange","editorContentFieldName","setAttachments","onAttachmentChange","onTitleChange","titleFieldName","editorRef","_useFormikContext","useFormikContext","setFieldValue","errors","handleContentChange","content","handleAttachmentChange","attachments","handleTitleChange","event","title","target","value","titleHotkeyRef","useHotKeys","_editorRef$current","_editorRef$current$ed","_editorRef$current$ed2","current","editor","commands","focus","mode","getUniqueAttachments","uniqueAttachments","reduce","attachment","_objectSpread","_defineProperty","signedId","Object","values","Editor","initialAttachments","_ref$getTitleRef","getTitleRef","noop","_ref$getEditorRef","getEditorRef","_ref$editorContentFie","_ref$titleFieldName","_ref$editorProps","editorProps","_ref$titleProps","titleProps","_useTranslation","useTranslation","t","titleRef","useRef","_useState","useState","_useState2","_slicedToArray","_useEditor","setTitleRef","node","setEditorRef","React","createElement","className","FormikEditor","_extends","attachmentsClassName","contentClassName","error","undefined","menuClassName","name","ref","concat","onChange","onChangeAttachments","Textarea","nakedTextarea","rows","placeholder","onKeyDown","e","key","shiftKey","preventDefault","Typography","style"],"mappings":";;;;;;;;;AAAe,SAAS,QAAQ,GAAG;AACnC,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,UAAU,MAAM,EAAE;AACtE,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC/C,MAAM,IAAI,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAChC,MAAM,KAAK,IAAI,GAAG,IAAI,MAAM,EAAE;AAC9B,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;AAC/D,UAAU,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;AACpC,SAAS;AACT,OAAO;AACP,KAAK;AACL,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG,CAAC;AACJ,EAAE,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACzC;;ACbe,SAAS,OAAO,CAAC,GAAG,EAAE;AACrC,EAAE,yBAAyB,CAAC;AAC5B;AACA,EAAE,OAAO,OAAO,GAAG,UAAU,IAAI,OAAO,MAAM,IAAI,QAAQ,IAAI,OAAO,MAAM,CAAC,QAAQ,GAAG,UAAU,GAAG,EAAE;AACtG,IAAI,OAAO,OAAO,GAAG,CAAC;AACtB,GAAG,GAAG,UAAU,GAAG,EAAE;AACrB,IAAI,OAAO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AC3DF,KAAA,CAAAC,aAAA,CAACc,QAAQ,EAAAX,QAAA,CAAA;IACPY,aAAa,EAAA,IAAA;AACbd,IAAAA,SAAS,EAAC,qCAAqC;AAC/C,IAAA,SAAA,EAAQ,0BAA0B;AAClCQ,IAAAA,IAAI,EAAEtE,cAAe;AACrBuE,IAAAA,GAAG,EAAEd,WAAY;AACjBoB,IAAAA,IAAI,EAAE,CAAE;IACRC,WAAW,EACThC,UAAU,CAACgC,WAAW,IAAI7B,CAAC,CAAC,qCAAqC,CAClE;AACDwB,IAAAA,QAAQ,EAAE/D,iBAAkB;IAC5BqE,SAAS,EAAE,SAAAA,SAAAA,CAAAC,CAAC,EAAA;AAAA,MAAA,OACVA,CAAC,CAACC,GAAG,KAAK,OAAO,IAAI,CAACD,CAAC,CAACE,QAAQ,IAAIF,CAAC,CAACG,cAAc,EAAE,CAAA;AAAA,KAAA;AACvD,GAAA,EACGrC,UAAU,CAAA,CACd,EACDzC,MAAM,CAACT,sBAAsB,CAAC,iBAC7BgE,KAAA,CAAAC,aAAA,CAACuB,UAAU,EAAA;AACTtB,IAAAA,SAAS,EAAC,6DAA6D;AACvE,IAAA,SAAA,EAAQ,8BAA8B;AACtCuB,IAAAA,KAAK,EAAC,OAAA;AAAO,GAAA,EAEZhF,MAAM,CAACT,sBAAsB,CAAC,CAElC,CACG,CACO,CACX,CAAA;AAEV;;;;"}
package/dist/EmailForm.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import React, { useRef, useState, useContext } from 'react';
2
2
  import classnames from 'classnames';
3
3
  import { useFormikContext, Field } from 'formik';
4
+ import { isNotEmpty, noop, isPresent } from '@bigbinary/neeto-commons-frontend/pure';
4
5
  import { isEditorEmpty, FormikEditor, EditorContent } from '@bigbinary/neeto-editor';
5
6
  import { Toastr, Button, Input as Input$1, Typography } from '@bigbinary/neetoui';
6
- import { Select, Input, MultiEmailInput, ActionBlock, Form } from '@bigbinary/neetoui/formik';
7
+ import { Select, Input, MultiEmailInput, Radio, ActionBlock, Form } from '@bigbinary/neetoui/formik';
7
8
  import { useTranslation, Trans } from 'react-i18next';
8
9
  import { t } from 'i18next';
9
10
  import { prop } from 'ramda';
10
11
  import * as yup from 'yup';
11
12
  import { string } from 'yup';
12
- import { isNotEmpty, noop, isPresent } from '@bigbinary/neeto-commons-frontend/pure';
13
13
  import { Info, Upload } from '@bigbinary/neeto-icons';
14
14
  import { withT } from '@bigbinary/neeto-commons-frontend/react-utils';
15
15
  import Papa from 'papaparse';
@@ -59,6 +59,7 @@ function _defineProperty(obj, key, value) {
59
59
 
60
60
  var INITIAL_FORM_VALUES = {
61
61
  sendTo: [],
62
+ sendToId: "",
62
63
  sendToCc: [],
63
64
  sendToBcc: [],
64
65
  replyTo: "",
@@ -79,6 +80,11 @@ var SEND_TO_FIELD_VALIDATION = yup.object({
79
80
  return emails === null || emails === void 0 ? void 0 : emails.every(prop("valid"));
80
81
  }).nullable()
81
82
  });
83
+ var SEND_TO_ID_FIELD_VALIDATION = yup.object({
84
+ sendToId: yup.string().required(t("neetoMolecules.emailForm.errors.required", {
85
+ entity: t("neetoMolecules.emailForm.labels.sendTo")
86
+ }))
87
+ });
82
88
  var REPLY_TO_FIELD_VALIDATION = yup.object({
83
89
  replyTo: yup.string().nullable().email(t("neetoMolecules.emailForm.errors.invalidEmailAddress")).required(t("neetoMolecules.emailForm.errors.required", {
84
90
  entity: t("neetoMolecules.emailForm.fields.replyToEmailAddress")
@@ -89,6 +95,7 @@ var EDITOR_ADDONS = ["highlight", "emoji", "code-block", "block-quote", "image-u
89
95
  /* eslint-disable @bigbinary/neeto/use-zustand-for-global-state-management */
90
96
  var EmailFormContext = /*#__PURE__*/React.createContext({
91
97
  showSendToField: false,
98
+ showSendToAsRadio: false,
92
99
  showReplyToField: false
93
100
  });
94
101
 
@@ -861,6 +868,8 @@ var EmailForm = function EmailForm(_ref) {
861
868
  isLoading = _ref.isLoading,
862
869
  _ref$replyToOptions = _ref.replyToOptions,
863
870
  replyToOptions = _ref$replyToOptions === void 0 ? [] : _ref$replyToOptions,
871
+ _ref$sendToOptions = _ref.sendToOptions,
872
+ sendToOptions = _ref$sendToOptions === void 0 ? [] : _ref$sendToOptions,
864
873
  _ref$isUpdating = _ref.isUpdating,
865
874
  isUpdating = _ref$isUpdating === void 0 ? false : _ref$isUpdating,
866
875
  _ref$showFields = _ref.showFields,
@@ -871,10 +880,12 @@ var EmailForm = function EmailForm(_ref) {
871
880
  t = _useTranslation.t;
872
881
  var _useContext = useContext(EmailFormContext),
873
882
  showSendToField = _useContext.showSendToField,
883
+ showSendToAsRadio = _useContext.showSendToAsRadio,
874
884
  showReplyToField = _useContext.showReplyToField;
875
885
  var _useFormikContext = useFormikContext(),
876
886
  setFieldValue = _useFormikContext.setFieldValue,
877
887
  dirty = _useFormikContext.dirty;
888
+ var showSendToRadioField = showSendToField && showSendToAsRadio && isNotEmpty(sendToOptions);
878
889
  return /*#__PURE__*/React.createElement("div", {
879
890
  "data-testid": "email-form",
880
891
  className: classnames("flex flex-1 flex-col items-start gap-2", _defineProperty({}, className, className))
@@ -897,7 +908,22 @@ var EmailForm = function EmailForm(_ref) {
897
908
  return setFieldValue("subject", text);
898
909
  }
899
910
  }));
900
- }), showSendToField && /*#__PURE__*/React.createElement(SendToField, null), showReplyToField && /*#__PURE__*/React.createElement(ReplyToField, {
911
+ }), showSendToRadioField ? /*#__PURE__*/React.createElement(Radio, {
912
+ "data-testid": "send-to-id",
913
+ label: t("neetoMolecules.emailForm.labels.sendTo"),
914
+ labelProps: {
915
+ required: true
916
+ },
917
+ name: "sendToId"
918
+ }, sendToOptions.map(function (_ref3) {
919
+ var label = _ref3.label,
920
+ value = _ref3.value;
921
+ return /*#__PURE__*/React.createElement(Radio.Item, {
922
+ label: label,
923
+ value: value,
924
+ key: value
925
+ });
926
+ })) : /*#__PURE__*/React.createElement(SendToField, null), showReplyToField && /*#__PURE__*/React.createElement(ReplyToField, {
901
927
  replyToOptions: replyToOptions
902
928
  }), /*#__PURE__*/React.createElement("div", {
903
929
  className: "w-full"
@@ -940,9 +966,12 @@ var EmailForm = function EmailForm(_ref) {
940
966
  var getValidationSchema = function getValidationSchema(_ref) {
941
967
  var showSendToField = _ref.showSendToField,
942
968
  showReplyToField = _ref.showReplyToField,
969
+ showSendToAsRadio = _ref.showSendToAsRadio,
943
970
  customValidations = _ref.customValidations;
944
971
  var schema = EMAIL_FORM_VALIDATION_SCHEMA.clone();
945
- if (showSendToField) schema = schema.concat(SEND_TO_FIELD_VALIDATION);
972
+ if (showSendToField) {
973
+ schema = schema.concat(showSendToAsRadio ? SEND_TO_ID_FIELD_VALIDATION : SEND_TO_FIELD_VALIDATION);
974
+ }
946
975
  if (showReplyToField) schema = schema.concat(REPLY_TO_FIELD_VALIDATION);
947
976
  return schema.shape(customValidations);
948
977
  };
@@ -961,12 +990,15 @@ var EmailFormProvider = function EmailFormProvider(_ref) {
961
990
  _ref$showSendToField = _ref.showSendToField,
962
991
  showSendToField = _ref$showSendToField === void 0 ? false : _ref$showSendToField,
963
992
  _ref$showReplyToField = _ref.showReplyToField,
964
- showReplyToField = _ref$showReplyToField === void 0 ? false : _ref$showReplyToField;
993
+ showReplyToField = _ref$showReplyToField === void 0 ? false : _ref$showReplyToField,
994
+ _ref$showSendToAsRadi = _ref.showSendToAsRadio,
995
+ showSendToAsRadio = _ref$showSendToAsRadi === void 0 ? false : _ref$showSendToAsRadi;
965
996
  return /*#__PURE__*/React.createElement("div", {
966
997
  "data-testid": "email-form-provider"
967
998
  }, /*#__PURE__*/React.createElement(EmailFormContext.Provider, {
968
999
  value: {
969
1000
  showSendToField: showSendToField,
1001
+ showSendToAsRadio: showSendToAsRadio,
970
1002
  showReplyToField: showReplyToField
971
1003
  }
972
1004
  }, /*#__PURE__*/React.createElement(Form, {
@@ -975,6 +1007,7 @@ var EmailFormProvider = function EmailFormProvider(_ref) {
975
1007
  validationSchema: getValidationSchema({
976
1008
  showSendToField: showSendToField,
977
1009
  showReplyToField: showReplyToField,
1010
+ showSendToAsRadio: showSendToAsRadio,
978
1011
  customValidations: customValidations
979
1012
  }),
980
1013
  initialValues: _objectSpread(_objectSpread({}, initialValues), {}, {