@bigbinary/neeto-molecules 4.0.123 → 4.0.125

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.
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
2
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
3
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
- import { useState, useRef, useEffect } from 'react';
4
+ import { useState, useRef, useLayoutEffect } from 'react';
5
5
  import classnames from 'classnames';
6
6
  import { copyToClipboard } from '@bigbinary/neeto-commons-frontend/utils/general';
7
7
  import Copy from '@bigbinary/neeto-icons/Copy';
@@ -18,11 +18,13 @@ var TOOLTIP_CONFIG = {
18
18
  hideAfter: TIME_OUT,
19
19
  position: "top"
20
20
  };
21
+ var BUTTON_SIZES = {
22
+ medium: "medium"};
21
23
 
22
24
  var css = ".neeto-molecules-copy-button{display:flex;justify-content:space-between}.neeto-molecules-copy-button .neeto-ui-btn:active,.neeto-molecules-copy-button .neeto-ui-btn:focus,.neeto-molecules-copy-button .neeto-ui-btn:hover{box-shadow:none}.neeto-molecules-copy-button--active{background:rgba(var(--neeto-ui-success-500));color:rgba(var(--neeto-ui-white))}.neeto-molecules-copy-button--active.neeto-ui-btn:active,.neeto-molecules-copy-button--active.neeto-ui-btn:focus,.neeto-molecules-copy-button--active.neeto-ui-btn:hover{background:rgba(var(--neeto-ui-success-500));box-shadow:none;color:rgba(var(--neeto-ui-white))}";
23
25
  n(css,{});
24
26
 
25
- var _excluded = ["className", "icon", "label", "successLabel", "tooltipContent", "successTooltipContent", "value", "style", "tooltipProps", "onClick"];
27
+ var _excluded = ["className", "icon", "label", "successLabel", "tooltipContent", "successTooltipContent", "value", "style", "size", "tooltipProps", "onClick"];
26
28
  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; }
27
29
  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; }
28
30
  var CopyToClipboardButton = function CopyToClipboardButton(_ref) {
@@ -36,6 +38,8 @@ var CopyToClipboardButton = function CopyToClipboardButton(_ref) {
36
38
  successTooltipContent = _ref.successTooltipContent,
37
39
  value = _ref.value,
38
40
  style = _ref.style,
41
+ _ref$size = _ref.size,
42
+ size = _ref$size === void 0 ? BUTTON_SIZES.medium : _ref$size,
39
43
  tooltipProps = _ref.tooltipProps,
40
44
  onClick = _ref.onClick,
41
45
  otherProps = _objectWithoutProperties(_ref, _excluded);
@@ -57,11 +61,12 @@ var CopyToClipboardButton = function CopyToClipboardButton(_ref) {
57
61
  setIsChecked(false);
58
62
  }, TIME_OUT); // Reset copied state after 2 seconds
59
63
  };
60
- useEffect(function () {
64
+ useLayoutEffect(function () {
61
65
  if (!ref.current) return;
66
+ ref.current.style.minWidth = "";
62
67
  var buttonWidth = ref.current.clientWidth;
63
68
  ref.current.style.minWidth = "".concat(buttonWidth, "px");
64
- }, []);
69
+ }, [size]);
65
70
  var tooltipOptions = label ? null : mergeAll([TOOLTIP_CONFIG, {
66
71
  content: isChecked ? successTooltipContent || t("neetoMolecules.common.copied") : tooltipContent || t("neetoMolecules.common.copyToClipboard")
67
72
  }, tooltipProps]);
@@ -69,13 +74,14 @@ var CopyToClipboardButton = function CopyToClipboardButton(_ref) {
69
74
  var buttonIcon = isChecked ? Check : icon;
70
75
  return /*#__PURE__*/jsx(Button, _objectSpread({
71
76
  ref: ref,
77
+ size: size,
72
78
  style: style,
73
79
  "data-cy": "copy-to-clipboard-button",
74
80
  "data-testid": "copy-button",
75
81
  icon: buttonIcon,
76
82
  label: buttonLabel,
77
83
  tooltipProps: tooltipOptions,
78
- className: classnames("neeto-molecules-copy-button", _defineProperty(_defineProperty({}, className, className), "neeto-molecules-copy-button--active", isChecked)),
84
+ className: classnames("neeto-molecules-copy-button", _defineProperty(_defineProperty(_defineProperty({}, className, className), "neeto-molecules-copy-button--active", isChecked), "neeto-molecules-copy-button--".concat(size), size)),
79
85
  onClick: onHandleClick
80
86
  }, otherProps));
81
87
  };
@@ -1 +1 @@
1
- {"version":3,"file":"CopyToClipboardButton.js","sources":["../src/components/CopyToClipboardButton/constants.js","../src/components/CopyToClipboardButton/index.jsx"],"sourcesContent":["const TIME_OUT = 2000;\n\nconst TOOLTIP_CONFIG = {\n trigger: \"click mouseenter\",\n hideAfter: TIME_OUT,\n position: \"top\",\n};\n\nconst BUTTON_STYLES = {\n primary: \"primary\",\n secondary: \"secondary\",\n text: \"text\",\n};\n\nexport { TOOLTIP_CONFIG, TIME_OUT, BUTTON_STYLES };\n","import { useState, useEffect, useRef } from \"react\";\n\nimport classnames from \"classnames\";\nimport { copyToClipboard } from \"neetocommons/utils/general\";\nimport { Copy, Check } from \"neetoicons\";\nimport { Button } from \"neetoui\";\nimport PropTypes from \"prop-types\";\nimport { mergeAll } from \"ramda\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { TOOLTIP_CONFIG, TIME_OUT, BUTTON_STYLES } from \"./constants\";\nimport \"./copyToClipboard.scss\";\n\nconst CopyToClipboardButton = ({\n className,\n icon = Copy,\n label = \"\",\n successLabel,\n tooltipContent,\n successTooltipContent,\n value,\n style,\n tooltipProps,\n onClick,\n ...otherProps\n}) => {\n const { t } = useTranslation();\n\n const [isChecked, setIsChecked] = useState(false);\n\n const ref = useRef();\n\n const onHandleClick = event => {\n event.preventDefault();\n event.stopPropagation();\n\n if (onClick) onClick(event);\n else copyToClipboard(value, { showToastr: false });\n\n setIsChecked(true);\n setTimeout(() => {\n setIsChecked(false);\n }, TIME_OUT); // Reset copied state after 2 seconds\n };\n\n useEffect(() => {\n if (!ref.current) return;\n const buttonWidth = ref.current.clientWidth;\n ref.current.style.minWidth = `${buttonWidth}px`;\n }, []);\n\n const tooltipOptions = label\n ? null\n : mergeAll([\n TOOLTIP_CONFIG,\n {\n content: isChecked\n ? successTooltipContent || t(\"neetoMolecules.common.copied\")\n : tooltipContent || t(\"neetoMolecules.common.copyToClipboard\"),\n },\n tooltipProps,\n ]);\n\n const buttonLabel =\n isChecked && label\n ? successLabel || t(\"neetoMolecules.common.copied\")\n : label;\n const buttonIcon = isChecked ? Check : icon;\n\n return (\n <Button\n {...{ ref, style }}\n data-cy=\"copy-to-clipboard-button\"\n data-testid=\"copy-button\"\n icon={buttonIcon}\n label={buttonLabel}\n tooltipProps={tooltipOptions}\n className={classnames(\"neeto-molecules-copy-button\", {\n [className]: className,\n \"neeto-molecules-copy-button--active\": isChecked,\n })}\n onClick={onHandleClick}\n {...otherProps}\n />\n );\n};\n\nCopyToClipboardButton.propTypes = {\n /**\n * To provide additional classnames to the button.\n */\n className: PropTypes.string,\n /**\n * To provide the icon to be passed to the button. Defaults to the Copy icon.\n */\n icon: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n /**\n * To provide the label to the button. By default there is no label.\n */\n label: PropTypes.string,\n /**\n * The label of button when the value is copied to clipboard. Defaults to 'Copied'.\n */\n successLabel: PropTypes.string,\n /**\n * The value to be copied to clipboard. (required)\n */\n value: PropTypes.string,\n /**\n * To specify the style of the Button.\n */\n style: PropTypes.oneOf(Object.values(BUTTON_STYLES)),\n /**\n * The content of the tooltip when the value is copied to clipboard. Defaults to 'Copy to clipboard'.\n */\n tooltipContent: PropTypes.string,\n /**\n * The content of the tooltip when the value is copied to clipboard. Defaults to 'Copied'.\n */\n successTooltipContent: PropTypes.string,\n};\n\nexport default CopyToClipboardButton;\n"],"names":["TIME_OUT","TOOLTIP_CONFIG","trigger","hideAfter","position","CopyToClipboardButton","_ref","className","_ref$icon","icon","Copy","_ref$label","label","successLabel","tooltipContent","successTooltipContent","value","style","tooltipProps","onClick","otherProps","_objectWithoutProperties","_excluded","_useTranslation","useTranslation","t","_useState","useState","_useState2","_slicedToArray","isChecked","setIsChecked","ref","useRef","onHandleClick","event","preventDefault","stopPropagation","copyToClipboard","showToastr","setTimeout","useEffect","current","buttonWidth","clientWidth","minWidth","concat","tooltipOptions","mergeAll","content","buttonLabel","buttonIcon","Check","_jsx","Button","_objectSpread","classnames","_defineProperty"],"mappings":";;;;;;;;;;;;;;AAAA,IAAMA,QAAQ,GAAG,IAAI;AAErB,IAAMC,cAAc,GAAG;AACrBC,EAAAA,OAAO,EAAE,kBAAkB;AAC3BC,EAAAA,SAAS,EAAEH,QAAQ;AACnBI,EAAAA,QAAQ,EAAE;AACZ,CAAC;;;;;;;;ACOD,IAAMC,qBAAqB,GAAG,SAAxBA,qBAAqBA,CAAAC,IAAA,EAYrB;AAAA,EAAA,IAXJC,SAAS,GAAAD,IAAA,CAATC,SAAS;IAAAC,SAAA,GAAAF,IAAA,CACTG,IAAI;AAAJA,IAAAA,IAAI,GAAAD,SAAA,KAAA,MAAA,GAAGE,IAAI,GAAAF,SAAA;IAAAG,UAAA,GAAAL,IAAA,CACXM,KAAK;AAALA,IAAAA,KAAK,GAAAD,UAAA,KAAA,MAAA,GAAG,EAAE,GAAAA,UAAA;IACVE,YAAY,GAAAP,IAAA,CAAZO,YAAY;IACZC,cAAc,GAAAR,IAAA,CAAdQ,cAAc;IACdC,qBAAqB,GAAAT,IAAA,CAArBS,qBAAqB;IACrBC,KAAK,GAAAV,IAAA,CAALU,KAAK;IACLC,KAAK,GAAAX,IAAA,CAALW,KAAK;IACLC,YAAY,GAAAZ,IAAA,CAAZY,YAAY;IACZC,OAAO,GAAAb,IAAA,CAAPa,OAAO;AACJC,IAAAA,UAAU,GAAAC,wBAAA,CAAAf,IAAA,EAAAgB,SAAA,CAAA;AAEb,EAAA,IAAAC,eAA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C,uCAAuC;GAChE,EACDP,YAAY,CACb,CAAC;AAEN,EAAA,IAAMgC,WAAW,GACfpB,SAAS,IAAIlB,KAAK,GACdC,YAAY,IAAIY,CAAC,CAAC,8BAA8B,CAAC,GACjDb,KAAK;AACX,EAAA,IAAMuC,UAAU,GAAGrB,SAAS,GAAGsB,KAAK,GAAG3C,IAAI;AAE3C,EAAA,oBACE4C,GAAA,CAACC,MAAM,EAAAC,aAAA,CAAA;AACCvB,IAAAA,GAAG,EAAHA,GAAG;AAAEf,IAAAA,KAAK,EAALA,KAAK;AAChB,IAAA,SAAA,EAAQ,0BAA0B;AAClC,IAAA,aAAA,EAAY,aAAa;AACzBR,IAAAA,IAAI,EAAE0C,UAAW;AACjBvC,IAAAA,KAAK,EAAEsC,WAAY;AACnBhC,IAAAA,YAAY,EAAE6B,cAAe;AAC7BxC,IAAAA,SAAS,EAAEiD,UAAU,CAAC,6BAA6B,EAAAC,eAAA,CAAAA,eAAA,CAAA,EAAA,EAChDlD,SAAS,EAAGA,SAAS,CAAA,EACtB,qCAAqC,EAAEuB,SAAS,CACjD,CAAE;AACHX,IAAAA,OAAO,EAAEe;GAAc,EACnBd,UAAU,CACf,CAAC;AAEN;;;;"}
1
+ {"version":3,"file":"CopyToClipboardButton.js","sources":["../src/components/CopyToClipboardButton/constants.js","../src/components/CopyToClipboardButton/index.jsx"],"sourcesContent":["const TIME_OUT = 2000;\n\nconst TOOLTIP_CONFIG = {\n trigger: \"click mouseenter\",\n hideAfter: TIME_OUT,\n position: \"top\",\n};\n\nconst BUTTON_STYLES = {\n primary: \"primary\",\n secondary: \"secondary\",\n text: \"text\",\n};\n\nconst BUTTON_SIZES = {\n small: \"small\",\n medium: \"medium\",\n large: \"large\",\n};\n\nexport { TOOLTIP_CONFIG, TIME_OUT, BUTTON_STYLES, BUTTON_SIZES };\n","import { useState, useLayoutEffect, useRef } from \"react\";\n\nimport classnames from \"classnames\";\nimport { copyToClipboard } from \"neetocommons/utils/general\";\nimport { Copy, Check } from \"neetoicons\";\nimport { Button } from \"neetoui\";\nimport PropTypes from \"prop-types\";\nimport { mergeAll } from \"ramda\";\nimport { useTranslation } from \"react-i18next\";\n\nimport {\n TOOLTIP_CONFIG,\n TIME_OUT,\n BUTTON_STYLES,\n BUTTON_SIZES,\n} from \"./constants\";\nimport \"./copyToClipboard.scss\";\n\nconst CopyToClipboardButton = ({\n className,\n icon = Copy,\n label = \"\",\n successLabel,\n tooltipContent,\n successTooltipContent,\n value,\n style,\n size = BUTTON_SIZES.medium,\n tooltipProps,\n onClick,\n ...otherProps\n}) => {\n const { t } = useTranslation();\n\n const [isChecked, setIsChecked] = useState(false);\n\n const ref = useRef();\n\n const onHandleClick = event => {\n event.preventDefault();\n event.stopPropagation();\n\n if (onClick) onClick(event);\n else copyToClipboard(value, { showToastr: false });\n\n setIsChecked(true);\n setTimeout(() => {\n setIsChecked(false);\n }, TIME_OUT); // Reset copied state after 2 seconds\n };\n\n useLayoutEffect(() => {\n if (!ref.current) return;\n ref.current.style.minWidth = \"\";\n const buttonWidth = ref.current.clientWidth;\n ref.current.style.minWidth = `${buttonWidth}px`;\n }, [size]);\n\n const tooltipOptions = label\n ? null\n : mergeAll([\n TOOLTIP_CONFIG,\n {\n content: isChecked\n ? successTooltipContent || t(\"neetoMolecules.common.copied\")\n : tooltipContent || t(\"neetoMolecules.common.copyToClipboard\"),\n },\n tooltipProps,\n ]);\n\n const buttonLabel =\n isChecked && label\n ? successLabel || t(\"neetoMolecules.common.copied\")\n : label;\n const buttonIcon = isChecked ? Check : icon;\n\n return (\n <Button\n {...{ ref, size, style }}\n data-cy=\"copy-to-clipboard-button\"\n data-testid=\"copy-button\"\n icon={buttonIcon}\n label={buttonLabel}\n tooltipProps={tooltipOptions}\n className={classnames(\"neeto-molecules-copy-button\", {\n [className]: className,\n \"neeto-molecules-copy-button--active\": isChecked,\n [`neeto-molecules-copy-button--${size}`]: size,\n })}\n onClick={onHandleClick}\n {...otherProps}\n />\n );\n};\n\nCopyToClipboardButton.propTypes = {\n /**\n * To provide additional classnames to the button.\n */\n className: PropTypes.string,\n /**\n * To provide the icon to be passed to the button. Defaults to the Copy icon.\n */\n icon: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),\n /**\n * To provide the label to the button. By default there is no label.\n */\n label: PropTypes.string,\n /**\n * The label of button when the value is copied to clipboard. Defaults to 'Copied'.\n */\n successLabel: PropTypes.string,\n /**\n * The value to be copied to clipboard. (required)\n */\n value: PropTypes.string,\n /**\n * To specify the style of the Button.\n */\n style: PropTypes.oneOf(Object.values(BUTTON_STYLES)),\n /**\n * To specify the size of the Button. Defaults to 'medium'.\n */\n size: PropTypes.oneOf(Object.values(BUTTON_SIZES)),\n /**\n * The content of the tooltip when the value is copied to clipboard. Defaults to 'Copy to clipboard'.\n */\n tooltipContent: PropTypes.string,\n /**\n * The content of the tooltip when the value is copied to clipboard. Defaults to 'Copied'.\n */\n successTooltipContent: PropTypes.string,\n};\n\nexport default CopyToClipboardButton;\n"],"names":["TIME_OUT","TOOLTIP_CONFIG","trigger","hideAfter","position","BUTTON_SIZES","small","medium","CopyToClipboardButton","_ref","className","_ref$icon","icon","Copy","_ref$label","label","successLabel","tooltipContent","successTooltipContent","value","style","_ref$size","size","tooltipProps","onClick","otherProps","_objectWithoutProperties","_excluded","_useTranslation","useTranslation","t","_useState","useState","_useState2","_slicedToArray","isChecked","setIsChecked","ref","useRef","onHandleClick","event","preventDefault","stopPropagation","copyToClipboard","showToastr","setTimeout","useLayoutEffect","current","minWidth","buttonWidth","clientWidth","concat","tooltipOptions","mergeAll","content","buttonLabel","buttonIcon","Check","_jsx","Button","_objectSpread","classnames","_defineProperty"],"mappings":";;;;;;;;;;;;;;AAAA,IAAMA,QAAQ,GAAG,IAAI;AAErB,IAAMC,cAAc,GAAG;AACrBC,EAAAA,OAAO,EAAE,kBAAkB;AAC3BC,EAAAA,SAAS,EAAEH,QAAQ;AACnBI,EAAAA,QAAQ,EAAE;AACZ,CAAC;AAQD,IAAMC,YAA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CAACC,MAAM,EAAAC,aAAA,CAAA;AACCvB,IAAAA,GAAG,EAAHA,GAAG;AAAEf,IAAAA,IAAI,EAAJA,IAAI;AAAEF,IAAAA,KAAK,EAALA,KAAK;AACtB,IAAA,SAAA,EAAQ,0BAA0B;AAClC,IAAA,aAAA,EAAY,aAAa;AACzBR,IAAAA,IAAI,EAAE4C,UAAW;AACjBzC,IAAAA,KAAK,EAAEwC,WAAY;AACnBhC,IAAAA,YAAY,EAAE6B,cAAe;IAC7B1C,SAAS,EAAEmD,UAAU,CAAC,6BAA6B,EAAAC,eAAA,CAAAA,eAAA,CAAAA,eAAA,CAAA,EAAA,EAChDpD,SAAS,EAAGA,SAAS,CAAA,EACtB,qCAAqC,EAAEyB,SAAS,CAAA,EAAA,+BAAA,CAAAgB,MAAA,CACf7B,IAAI,CAAA,EAAKA,IAAI,CAC/C,CAAE;AACHE,IAAAA,OAAO,EAAEe;GAAc,EACnBd,UAAU,CACf,CAAC;AAEN;;;;"}
package/dist/EmailForm.js CHANGED
@@ -5,19 +5,18 @@ import classnames from 'classnames';
5
5
  import { useFormikContext, Field } from 'formik';
6
6
  import { isPresent, isNotEmpty, notEqualsDeep, noop } from '@bigbinary/neeto-cist';
7
7
  import FormikEditor from '@bigbinary/neeto-editor/FormikEditor';
8
- import Typography from '@bigbinary/neetoui/Typography';
9
8
  import Button from '@bigbinary/neetoui/Button';
10
9
  import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
11
10
  import Radio from '@bigbinary/neetoui/formik/Radio';
12
11
  import { prop, equals, pluck, isEmpty } from 'ramda';
13
- import { useTranslation, Trans } from 'react-i18next';
12
+ import { useTranslation } from 'react-i18next';
14
13
  import { t } from 'i18next';
15
14
  import { isEditorEmpty } from '@bigbinary/neeto-editor/utils';
16
15
  import * as yup from 'yup';
17
16
  import Select from '@bigbinary/neetoui/formik/Select';
18
17
  import Input from '@bigbinary/neetoui/formik/Input';
19
18
  import _typeof from '@babel/runtime/helpers/typeof';
20
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
19
+ import { jsx, jsxs } from 'react/jsx-runtime';
21
20
  import SendToFields from './SendToFields.js';
22
21
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
23
22
  import { withEventTargetValue } from '@bigbinary/neeto-commons-frontend/utils/general';
@@ -32,6 +31,7 @@ import { n } from './inject-css-C2dztUxs.js';
32
31
  import Form from '@bigbinary/neetoui/formik/Form';
33
32
  import '@bigbinary/neeto-commons-frontend/react-utils/withT';
34
33
  import '@bigbinary/neeto-editor/EditorContent';
34
+ import '@bigbinary/neetoui/Typography';
35
35
  import './index-DAYCJu79.js';
36
36
  import './_commonjsHelpers-BFTU3MAI.js';
37
37
  import '@babel/runtime/helpers/toConsumableArray';
@@ -111,7 +111,9 @@ var EDITOR_ADDONS = ["highlight", "emoji", "code-block", "block-quote", "image-u
111
111
  var EmailFormContext = /*#__PURE__*/createContext({
112
112
  showSendToField: false,
113
113
  showSendToAsRadio: false,
114
- showReplyToField: false
114
+ showReplyToField: false,
115
+ showCcField: false,
116
+ showBccField: false
115
117
  });
116
118
 
117
119
  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; }
@@ -190,6 +192,7 @@ var ReplyToField = function ReplyToField(_ref) {
190
192
  return /*#__PURE__*/jsx(Input, {
191
193
  labelProps: labelProps,
192
194
  autoFocus: true,
195
+ nakedInput: true,
193
196
  required: true,
194
197
  className: "w-full",
195
198
  "data-testid": "replyToInput",
@@ -261,43 +264,30 @@ var SubjectField = function SubjectField(_ref) {
261
264
  var updatedSubject = [text.slice(0, splitIndex), " {{".concat(variable, "}}"), text.slice(splitIndex)].join("");
262
265
  updateText(updatedSubject);
263
266
  };
264
- return /*#__PURE__*/jsxs(Fragment, {
265
- children: [/*#__PURE__*/jsx(Input$1, {
266
- error: error,
267
- name: name,
268
- onBlur: onBlur,
269
- required: required,
270
- label: t("neetoMolecules.emailForm.labels.subject"),
271
- size: "large",
272
- value: text,
273
- suffix: /*#__PURE__*/jsx(DynamicVariables, {
274
- variables: subjectVariables,
275
- dropdownProps: {
276
- className: "neeto-ui-dropdown__popup overflow-y-auto",
277
- buttonSize: "small"
278
- },
279
- onVariableClick: tagClickHandler
280
- }),
281
- onChange: withEventTargetValue(updateText),
282
- onFocus: function onFocus() {
283
- return setIsFieldFocusedOnce(true);
284
- }
285
- }), /*#__PURE__*/jsx(Typography, {
286
- className: "neeto-ui-text-gray-600 mt-2",
287
- "data-cy": "subject-input-variable-label",
288
- style: "body3",
289
- children: /*#__PURE__*/jsx(Trans, {
290
- components: {
291
- span: /*#__PURE__*/jsx("span", {
292
- className: "font-semibold"
293
- })
294
- },
295
- i18nKey: "neetoMolecules.emailForm.helpText",
296
- values: {
297
- type: "subject"
298
- }
299
- })
300
- })]
267
+ return /*#__PURE__*/jsx(Input$1, {
268
+ error: error,
269
+ name: name,
270
+ onBlur: onBlur,
271
+ required: required,
272
+ nakedInput: true,
273
+ label: t("neetoMolecules.emailForm.labels.subject"),
274
+ placeholder: t("neetoMolecules.emailForm.placeholders.subject"),
275
+ value: text,
276
+ suffix: /*#__PURE__*/jsx(DynamicVariables, {
277
+ buttonProps: {
278
+ className: "m-1"
279
+ },
280
+ variables: subjectVariables,
281
+ dropdownProps: {
282
+ className: "neeto-ui-dropdown__popup overflow-y-auto",
283
+ buttonSize: "small"
284
+ },
285
+ onVariableClick: tagClickHandler
286
+ }),
287
+ onChange: withEventTargetValue(updateText),
288
+ onFocus: function onFocus() {
289
+ return setIsFieldFocusedOnce(true);
290
+ }
301
291
  });
302
292
  };
303
293
 
@@ -358,86 +348,80 @@ var EmailForm = function EmailForm(_ref) {
358
348
  "data-cy": "email-form",
359
349
  "data-testid": "email-form",
360
350
  className: classnames("neeto-notification-email-wrapper__form-container flex flex-1 flex-col items-start gap-2 !pb-0", _defineProperty({}, className, className)),
361
- children: [showFields && /*#__PURE__*/jsxs("div", {
362
- className: "flex w-full flex-col items-start justify-start gap-6",
363
- children: [/*#__PURE__*/jsx(Field, {
364
- name: "subject",
365
- children: function children(_ref2) {
366
- var _ref2$field = _ref2.field,
367
- value = _ref2$field.value,
368
- onBlur = _ref2$field.onBlur,
369
- _ref2$meta = _ref2.meta,
370
- error = _ref2$meta.error,
371
- touched = _ref2$meta.touched;
372
- return /*#__PURE__*/jsx("div", {
373
- className: "w-full",
374
- children: /*#__PURE__*/jsx(SubjectField, {
375
- onBlur: onBlur,
376
- subjectVariables: subjectVariables,
377
- required: true,
378
- error: touched && error ? t(error) : undefined,
379
- name: "subject",
380
- text: value,
381
- updateText: function updateText(text) {
382
- return setFieldValue("subject", text);
383
- }
384
- })
385
- });
386
- }
387
- }), showSendToRadioField && /*#__PURE__*/jsx(Radio, {
388
- "data-testid": "send-to-id",
389
- label: t("neetoMolecules.emailForm.labels.sendTo"),
390
- labelProps: {
391
- required: true
392
- },
393
- name: "sendToId",
394
- children: sendToFieldOptions.map(function (_ref3) {
395
- var label = _ref3.label,
396
- value = _ref3.value;
397
- return /*#__PURE__*/createElement(Radio.Item, {
398
- label: label,
399
- value: value,
400
- key: value
401
- });
402
- })
403
- }), /*#__PURE__*/jsx(SendToField, {
404
- showBccField: showBccField,
405
- showCcField: showCcField,
406
- showSendToTextField: showSendToTextField
407
- }), showReplyToField && /*#__PURE__*/jsx(ReplyToField, _objectSpread$2({
408
- options: replyToOptions
409
- }, replyToFieldProps)), /*#__PURE__*/jsxs("div", {
410
- className: "w-full",
411
- "data-cy": "message-input-container",
412
- children: [/*#__PURE__*/jsx(FormikEditor, {
413
- required: true,
414
- addons: editorAddons,
415
- "data-cy": "message-input-field",
416
- id: "form_message",
417
- label: t("neetoMolecules.emailForm.labels.message"),
418
- name: "message",
419
- ref: editorRef,
420
- variables: messageVariables,
421
- shouldUpdate: function shouldUpdate(nextProps, prevProps) {
422
- return notEqualsDeep(nextProps.variables, prevProps.variables);
423
- }
424
- }), /*#__PURE__*/jsx(Typography, {
425
- className: "neeto-ui-text-gray-500 mt-2",
426
- "data-cy": "message-input-variable-label",
427
- style: "body3",
428
- children: /*#__PURE__*/jsx(Trans, {
429
- i18nKey: "neetoMolecules.emailForm.helpText",
430
- values: {
431
- type: "message"
432
- },
433
- components: {
434
- span: /*#__PURE__*/jsx("span", {
435
- className: "font-semibold"
351
+ children: [/*#__PURE__*/jsx("div", {
352
+ className: "w-full grow",
353
+ children: showFields && /*#__PURE__*/jsxs("div", {
354
+ className: "flex w-full flex-col items-start justify-start gap-5",
355
+ children: [showSendToRadioField && /*#__PURE__*/jsx(Radio, {
356
+ className: "pb-2",
357
+ "data-testid": "send-to-id",
358
+ label: t("neetoMolecules.emailForm.labels.sendTo"),
359
+ labelProps: {
360
+ required: true
361
+ },
362
+ name: "sendToId",
363
+ children: sendToFieldOptions.map(function (_ref2) {
364
+ var label = _ref2.label,
365
+ value = _ref2.value;
366
+ return /*#__PURE__*/createElement(Radio.Item, {
367
+ label: label,
368
+ value: value,
369
+ key: value
370
+ });
371
+ })
372
+ }), /*#__PURE__*/jsx(SendToField, {
373
+ showBccField: showBccField,
374
+ showCcField: showCcField,
375
+ showSendToTextField: showSendToTextField
376
+ }), showReplyToField && /*#__PURE__*/jsx("div", {
377
+ className: "neeto-ui-border-gray-200 w-full border-b pb-1",
378
+ children: /*#__PURE__*/jsx(ReplyToField, _objectSpread$2({
379
+ options: replyToOptions
380
+ }, replyToFieldProps))
381
+ }), /*#__PURE__*/jsx(Field, {
382
+ name: "subject",
383
+ children: function children(_ref3) {
384
+ var _ref3$field = _ref3.field,
385
+ value = _ref3$field.value,
386
+ onBlur = _ref3$field.onBlur,
387
+ _ref3$meta = _ref3.meta,
388
+ error = _ref3$meta.error,
389
+ touched = _ref3$meta.touched;
390
+ return /*#__PURE__*/jsx("div", {
391
+ className: "neeto-notification-email-subject-block neeto-ui-border-gray-200 w-full border-b pb-1",
392
+ children: /*#__PURE__*/jsx(SubjectField, {
393
+ onBlur: onBlur,
394
+ subjectVariables: subjectVariables,
395
+ required: true,
396
+ error: touched && error ? t(error) : undefined,
397
+ name: "subject",
398
+ text: value,
399
+ updateText: function updateText(text) {
400
+ return setFieldValue("subject", text);
401
+ }
436
402
  })
403
+ });
404
+ }
405
+ }), /*#__PURE__*/jsx("div", {
406
+ className: "neeto-notification-email-message-block w-full",
407
+ "data-cy": "message-input-container",
408
+ children: /*#__PURE__*/jsx(FormikEditor, {
409
+ required: true,
410
+ addons: editorAddons,
411
+ "data-cy": "message-input-field",
412
+ hideSlashCommands: false,
413
+ id: "form_message",
414
+ menuType: "none",
415
+ name: "message",
416
+ placeholder: t("neetoMolecules.emailForm.placeholders.message"),
417
+ ref: editorRef,
418
+ variables: messageVariables,
419
+ shouldUpdate: function shouldUpdate(nextProps, prevProps) {
420
+ return notEqualsDeep(nextProps.variables, prevProps.variables);
437
421
  }
438
422
  })
439
423
  })]
440
- })]
424
+ })
441
425
  }), /*#__PURE__*/jsxs("div", {
442
426
  className: "neeto-ui-bg-white neeto-notification-email-wrapper__action-block z-10 flex w-full justify-between py-6 lg:sticky lg:bottom-0",
443
427
  children: [/*#__PURE__*/jsx(ActionBlock, {
@@ -463,7 +447,7 @@ var EmailForm = function EmailForm(_ref) {
463
447
  });
464
448
  };
465
449
 
466
- var css = ".neeto-notification-email-wrapper{height:calc(100vh - 64px);height:calc(100dvh - 64px)}";
450
+ var css = ".neeto-notification-email-wrapper{height:calc(100vh - 64px);height:calc(100dvh - 64px)}.neeto-notification-email-outer-wrapper .neeto-ui-react-select__container .neeto-ui-react-select__control{border:none}.neeto-notification-email-outer-wrapper .neeto-ui-react-select__container .neeto-ui-react-select__control--is-focused{box-shadow:none!important}.neeto-notification-email-outer-wrapper .neeto-ui-react-select__container .neeto-ui-react-select__value-container{padding-left:0}.neeto-notification-email-message-block .neeto-editor,.neeto-notification-email-message-block .neeto-editor-error{border:none;padding:0}.neeto-notification-email-message-block p.is-editor-empty{font-size:14px}.neeto-notification-email-subject-block .neeto-ui-input__suffix{padding:0}.neeto-molecules-email-preview-ribbon{background:#ffee6a;border-bottom-left-radius:6px;border-top-left-radius:6px;border-top-right-radius:6px;box-shadow:0 3px 4px 0 rgba(0,0,0,.149);color:#49545c;font-size:14px;font-weight:500;min-width:-moz-max-content;min-width:max-content;padding:6px 12px;position:absolute;right:-6px;text-align:center;top:-6px;z-index:10}.neeto-molecules-email-preview-ribbon:after{border-color:transparent #ddd06b;border-style:solid;border-width:0 0 12px 6px;content:\"\";left:auto;position:absolute;right:0;top:100%;z-index:-20}";
467
451
  n(css,{});
468
452
 
469
453
  function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }