@bigbinary/neeto-molecules 5.5.1 → 5.5.3

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.
Files changed (78) hide show
  1. package/dist/DocumentEditor.js +1 -1
  2. package/dist/EmailForm.js +3 -3
  3. package/dist/EmailPreview.js +1 -1
  4. package/dist/Onboarding.js +391 -8
  5. package/dist/Onboarding.js.map +1 -1
  6. package/dist/OptionFields.js +1 -1
  7. package/dist/ShareViaEmail.js +3 -3
  8. package/dist/circle-user-ieD_gMjm.js +19 -0
  9. package/dist/circle-user-ieD_gMjm.js.map +1 -0
  10. package/dist/cjs/DocumentEditor.js +1 -1
  11. package/dist/cjs/EmailForm.js +3 -3
  12. package/dist/cjs/EmailPreview.js +1 -1
  13. package/dist/cjs/Onboarding.js +409 -7
  14. package/dist/cjs/Onboarding.js.map +1 -1
  15. package/dist/cjs/OptionFields.js +1 -1
  16. package/dist/cjs/ShareViaEmail.js +3 -3
  17. package/dist/cjs/circle-user-D5aGw9mw.js +21 -0
  18. package/dist/cjs/circle-user-D5aGw9mw.js.map +1 -0
  19. package/dist/cjs/v2/AuditLogs.js +2 -16
  20. package/dist/cjs/v2/AuditLogs.js.map +1 -1
  21. package/dist/cjs/v2/DocumentEditor.js +1 -1
  22. package/dist/cjs/v2/EmailForm.js +3 -3
  23. package/dist/cjs/v2/EmailPreview.js +1 -1
  24. package/dist/cjs/v2/Onboarding.js +435 -10
  25. package/dist/cjs/v2/Onboarding.js.map +1 -1
  26. package/dist/cjs/v2/OptionFields.js +1 -1
  27. package/dist/cjs/v2/ShareViaEmail.js +3 -3
  28. package/dist/v2/AuditLogs.js +1 -15
  29. package/dist/v2/AuditLogs.js.map +1 -1
  30. package/dist/v2/DocumentEditor.js +1 -1
  31. package/dist/v2/EmailForm.js +3 -3
  32. package/dist/v2/EmailPreview.js +1 -1
  33. package/dist/v2/Onboarding.js +418 -12
  34. package/dist/v2/Onboarding.js.map +1 -1
  35. package/dist/v2/OptionFields.js +1 -1
  36. package/dist/v2/ShareViaEmail.js +3 -3
  37. package/package.json +5 -5
  38. package/src/translations/ar.json +12 -5
  39. package/src/translations/bg.json +13 -6
  40. package/src/translations/ca.json +13 -6
  41. package/src/translations/cs.json +12 -5
  42. package/src/translations/da.json +13 -6
  43. package/src/translations/de.json +13 -6
  44. package/src/translations/en.json +14 -7
  45. package/src/translations/es-MX.json +13 -6
  46. package/src/translations/es.json +13 -6
  47. package/src/translations/et.json +13 -6
  48. package/src/translations/fi.json +13 -6
  49. package/src/translations/fil.json +13 -6
  50. package/src/translations/fr.json +13 -6
  51. package/src/translations/he.json +13 -6
  52. package/src/translations/hi.json +12 -5
  53. package/src/translations/hr.json +12 -5
  54. package/src/translations/hu.json +13 -6
  55. package/src/translations/id.json +13 -6
  56. package/src/translations/it.json +13 -6
  57. package/src/translations/ja.json +13 -6
  58. package/src/translations/ko.json +13 -6
  59. package/src/translations/lv.json +13 -6
  60. package/src/translations/nl.json +13 -6
  61. package/src/translations/pl.json +13 -6
  62. package/src/translations/pt-BR.json +13 -6
  63. package/src/translations/pt.json +13 -6
  64. package/src/translations/ro.json +13 -6
  65. package/src/translations/ru.json +12 -5
  66. package/src/translations/sk.json +12 -5
  67. package/src/translations/sl.json +13 -6
  68. package/src/translations/sv.json +13 -6
  69. package/src/translations/th.json +12 -5
  70. package/src/translations/tr.json +13 -6
  71. package/src/translations/uk.json +13 -6
  72. package/src/translations/vi.json +13 -6
  73. package/src/translations/zh-CN.json +12 -5
  74. package/src/translations/zh-TW.json +13 -6
  75. package/types/DocumentEditor.d.ts +1 -1
  76. package/types/Onboarding.d.ts +1 -0
  77. package/types/v2/DocumentEditor.d.ts +4 -1
  78. package/types/v2/Onboarding.d.ts +1 -0
@@ -4,7 +4,7 @@ import { useCallback, memo, useRef, useState, useMemo } from 'react';
4
4
  import classnames from 'classnames';
5
5
  import { useFormikContext } from 'formik';
6
6
  import { isPresent, noop } from '@bigbinary/neeto-cist';
7
- import FormikEditor from '@bigbinary/neeto-editor/FormikEditor';
7
+ import FormikEditor from '@bigbinary/neeto-editor-frontend/FormikEditor';
8
8
  import MenuHorizontal from '@bigbinary/neeto-icons/MenuHorizontal';
9
9
  import Modal from '@bigbinary/neetoui/Modal';
10
10
  import Typography from '@bigbinary/neetoui/Typography';
package/dist/EmailForm.js CHANGED
@@ -4,14 +4,14 @@ import { createContext, useState, useContext, createElement } from 'react';
4
4
  import classnames from 'classnames';
5
5
  import { useFormikContext, Field } from 'formik';
6
6
  import { isPresent, isNotEmpty, notEqualsDeep, noop } from '@bigbinary/neeto-cist';
7
- import FormikEditor from '@bigbinary/neeto-editor/FormikEditor';
7
+ import FormikEditor from '@bigbinary/neeto-editor-frontend/FormikEditor';
8
8
  import Button from '@bigbinary/neetoui/Button';
9
9
  import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
10
10
  import Radio from '@bigbinary/neetoui/formik/Radio';
11
11
  import { prop, equals, pluck, isEmpty } from 'ramda';
12
12
  import { useTranslation } from 'react-i18next';
13
13
  import { t } from 'i18next';
14
- import { isEditorEmpty } from '@bigbinary/neeto-editor/utils';
14
+ import { isEditorEmpty } from '@bigbinary/neeto-editor-frontend/utils';
15
15
  import * as yup from 'yup';
16
16
  import Select from '@bigbinary/neetoui/formik/Select';
17
17
  import Input from '@bigbinary/neetoui/formik/Input';
@@ -30,7 +30,7 @@ import MobilePreviewHeader from './MobilePreviewHeader.js';
30
30
  import { n } from './inject-css-C2dztUxs.js';
31
31
  import Form from '@bigbinary/neetoui/formik/Form';
32
32
  import '@bigbinary/neeto-commons-frontend/react-utils/withT';
33
- import '@bigbinary/neeto-editor/EditorContent';
33
+ import '@bigbinary/neeto-editor-frontend/EditorContent';
34
34
  import '@bigbinary/neetoui/Typography';
35
35
  import './index-DAYCJu79.js';
36
36
  import './_commonjsHelpers-BFTU3MAI.js';
@@ -2,7 +2,7 @@ import { memo } from 'react';
2
2
  import classnames from 'classnames';
3
3
  import { isPresent } from '@bigbinary/neeto-cist';
4
4
  import withT from '@bigbinary/neeto-commons-frontend/react-utils/withT';
5
- import EditorContent from '@bigbinary/neeto-editor/EditorContent';
5
+ import EditorContent from '@bigbinary/neeto-editor-frontend/EditorContent';
6
6
  import Typography from '@bigbinary/neetoui/Typography';
7
7
  import Button from '@bigbinary/neetoui/Button';
8
8
  import { P as PropTypes } from './index-DAYCJu79.js';
@@ -1,7 +1,7 @@
1
1
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
2
  import { useState, useLayoutEffect, useEffect, useMemo, useRef } from 'react';
3
3
  import classnames from 'classnames';
4
- import { isPresent, capitalize, noop, findIndexBy } from '@bigbinary/neeto-cist';
4
+ import { capitalize, isPresent, noop, findIndexBy } from '@bigbinary/neeto-cist';
5
5
  import Stepper from '@bigbinary/neetoui/Stepper';
6
6
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
7
7
  import { globalProps } from '@bigbinary/neeto-commons-frontend/initializers';
@@ -10,18 +10,368 @@ import Typography from '@bigbinary/neetoui/Typography';
10
10
  import { R as ReactConfetti } from './react-confetti-BnGq_LBE.js';
11
11
  import { useTranslation, Trans } from 'react-i18next';
12
12
  import { t } from 'i18next';
13
- import useBreakpoints from '@bigbinary/neeto-commons-frontend/react-utils/useBreakpoints';
14
13
  import RightArrow from '@bigbinary/neeto-icons/RightArrow';
14
+ import Checkbox from '@bigbinary/neetoui/Checkbox';
15
+ import { assoc, dissoc } from 'ramda';
16
+ import Notes from '@bigbinary/neeto-icons/Notes';
17
+ import UserCircle from '@bigbinary/neeto-icons/UserCircle';
18
+ import Email from '@bigbinary/neeto-icons/Email';
19
+ import Input from '@bigbinary/neetoui/Input';
15
20
  import { jsxs, jsx } from 'react/jsx-runtime';
21
+ import { useMutation } from '@tanstack/react-query';
22
+ import axios from 'axios';
23
+ import { BASE_API_V1_URL } from '@bigbinary/neeto-commons-frontend/constants';
24
+ import * as yup from 'yup';
25
+ import useBreakpoints from '@bigbinary/neeto-commons-frontend/react-utils/useBreakpoints';
16
26
  import { n } from './inject-css-C2dztUxs.js';
17
27
  import withT from '@bigbinary/neeto-commons-frontend/react-utils/withT';
18
28
 
29
+ var COMMUNITY_OPTIONS = [{
30
+ key: "slack",
31
+ icon: UserCircle,
32
+ dataTestid: "onboarding-community-slack-checkbox",
33
+ recipientDataTestids: {
34
+ change: "onboarding-community-slack-email-change-button",
35
+ input: "onboarding-community-slack-email-input",
36
+ save: "onboarding-community-slack-email-save-button",
37
+ cancel: "onboarding-community-slack-email-cancel-button"
38
+ }
39
+ }, {
40
+ key: "blog",
41
+ icon: Notes,
42
+ dataTestid: "onboarding-community-blog-checkbox",
43
+ recipientDataTestids: {
44
+ change: "onboarding-community-blog-email-change-button",
45
+ input: "onboarding-community-blog-email-input",
46
+ save: "onboarding-community-blog-email-save-button",
47
+ cancel: "onboarding-community-blog-email-cancel-button"
48
+ }
49
+ }];
50
+
51
+ var EmailRecipient = function EmailRecipient(_ref) {
52
+ var email = _ref.email,
53
+ edit = _ref.edit,
54
+ onStartEditing = _ref.onStartEditing,
55
+ onDraftChange = _ref.onDraftChange,
56
+ onSave = _ref.onSave,
57
+ onCancel = _ref.onCancel,
58
+ recipientKey = _ref.recipientKey,
59
+ inputLabelKey = _ref.inputLabelKey,
60
+ dataTestids = _ref.dataTestids;
61
+ var _useTranslation = useTranslation(),
62
+ t = _useTranslation.t;
63
+ var handleKeyDown = function handleKeyDown(event) {
64
+ if (event.key === "Enter") {
65
+ event.preventDefault();
66
+ onSave();
67
+ }
68
+ if (event.key === "Escape") onCancel();
69
+ };
70
+ if (edit) {
71
+ return /*#__PURE__*/jsxs("div", {
72
+ className: "flex items-start gap-2 ps-6 pt-3",
73
+ children: [/*#__PURE__*/jsx("div", {
74
+ className: "w-72",
75
+ children: /*#__PURE__*/jsx(Input, {
76
+ autoFocus: true,
77
+ "aria-label": t(inputLabelKey),
78
+ "data-testid": dataTestids.input,
79
+ error: edit.error,
80
+ type: "email",
81
+ value: edit.draft,
82
+ onChange: function onChange(event) {
83
+ return onDraftChange(event.target.value);
84
+ },
85
+ onKeyDown: handleKeyDown
86
+ })
87
+ }), /*#__PURE__*/jsx(Button, {
88
+ "data-testid": dataTestids.save,
89
+ label: t("neetoMolecules.common.actions.save"),
90
+ onClick: onSave
91
+ }), /*#__PURE__*/jsx(Button, {
92
+ "data-testid": dataTestids.cancel,
93
+ label: t("neetoMolecules.common.actions.cancel"),
94
+ style: "text",
95
+ onClick: onCancel
96
+ })]
97
+ });
98
+ }
99
+ return /*#__PURE__*/jsxs("div", {
100
+ className: "flex flex-wrap items-center gap-2 ps-6 pt-3",
101
+ children: [/*#__PURE__*/jsx(Email, {
102
+ "aria-hidden": true,
103
+ className: "neeto-ui-text-gray-500",
104
+ size: 16
105
+ }), /*#__PURE__*/jsx(Typography, {
106
+ className: "neeto-ui-text-gray-600",
107
+ style: "body2",
108
+ children: /*#__PURE__*/jsx(Trans, {
109
+ components: {
110
+ strong: /*#__PURE__*/jsx("strong", {
111
+ className: "neeto-ui-text-gray-800"
112
+ })
113
+ },
114
+ i18nKey: recipientKey,
115
+ values: {
116
+ email: email
117
+ }
118
+ })
119
+ }), /*#__PURE__*/jsx(Button, {
120
+ "data-testid": dataTestids.change,
121
+ label: t("neetoMolecules.onboarding.communityScreen.changeButton"),
122
+ size: "small",
123
+ style: "link",
124
+ onClick: onStartEditing
125
+ })]
126
+ });
127
+ };
128
+
129
+ var joinCommunity = function joinCommunity(communityJoin) {
130
+ return axios.post("".concat(BASE_API_V1_URL, "/community_join"), {
131
+ communityJoin: communityJoin
132
+ }, {
133
+ showToastr: false
134
+ });
135
+ };
136
+ var communityApi = {
137
+ joinCommunity: joinCommunity
138
+ };
139
+
140
+ var useJoinCommunity = function useJoinCommunity() {
141
+ return useMutation({
142
+ mutationFn: communityApi.joinCommunity
143
+ });
144
+ };
145
+
146
+ var isValidEmail = function isValidEmail(email) {
147
+ return !!email && yup.string().email().isValidSync(email);
148
+ };
149
+
150
+ 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; }
151
+ 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; }
152
+
153
+ // Tracks the email each option goes to, plus any address being edited, so
154
+ // Continue can pick up a draft the user typed but did not save.
155
+ var useRecipientEmails = function useRecipientEmails(defaultEmail) {
156
+ var _useState = useState({
157
+ slack: defaultEmail,
158
+ blog: defaultEmail
159
+ }),
160
+ _useState2 = _slicedToArray(_useState, 2),
161
+ emails = _useState2[0],
162
+ setEmails = _useState2[1];
163
+
164
+ // { [key]: { draft, error } } for the options whose email field is open.
165
+ var _useState3 = useState({}),
166
+ _useState4 = _slicedToArray(_useState3, 2),
167
+ edits = _useState4[0],
168
+ setEdits = _useState4[1];
169
+ var startEditing = function startEditing(key) {
170
+ return setEdits(assoc(key, {
171
+ draft: emails[key],
172
+ error: ""
173
+ }));
174
+ };
175
+ var changeDraft = function changeDraft(key, draft) {
176
+ return setEdits(assoc(key, {
177
+ draft: draft,
178
+ error: ""
179
+ }));
180
+ };
181
+ var cancel = function cancel(key) {
182
+ return setEdits(dissoc(key));
183
+ };
184
+ var validate = function validate(key) {
185
+ var draft = edits[key].draft.trim();
186
+ return isValidEmail(draft) ? {
187
+ draft: draft
188
+ } : {
189
+ error: t("neetoMolecules.onboarding.communityScreen.invalidEmail")
190
+ };
191
+ };
192
+ var save = function save(key) {
193
+ var _validate = validate(key),
194
+ draft = _validate.draft,
195
+ error = _validate.error;
196
+ if (error) {
197
+ setEdits(assoc(key, _objectSpread$3(_objectSpread$3({}, edits[key]), {}, {
198
+ error: error
199
+ })));
200
+ return;
201
+ }
202
+ setEmails(assoc(key, draft));
203
+ setEdits(dissoc(key));
204
+ };
205
+
206
+ // Applies every open draft of the given options. Returns the final emails,
207
+ // or null when a draft is invalid, after showing its error.
208
+ var applyDrafts = function applyDrafts(keys) {
209
+ var nextEmails = emails;
210
+ var nextEdits = edits;
211
+ keys.filter(function (key) {
212
+ return edits[key];
213
+ }).forEach(function (key) {
214
+ var _validate2 = validate(key),
215
+ draft = _validate2.draft,
216
+ error = _validate2.error;
217
+ if (error) {
218
+ nextEdits = assoc(key, _objectSpread$3(_objectSpread$3({}, edits[key]), {}, {
219
+ error: error
220
+ }), nextEdits);
221
+ } else {
222
+ nextEmails = assoc(key, draft, nextEmails);
223
+ nextEdits = dissoc(key, nextEdits);
224
+ }
225
+ });
226
+ setEmails(nextEmails);
227
+ setEdits(nextEdits);
228
+ var hasInvalidDraft = keys.some(function (key) {
229
+ return nextEdits[key];
230
+ });
231
+ return hasInvalidDraft ? null : nextEmails;
232
+ };
233
+ return {
234
+ emails: emails,
235
+ edits: edits,
236
+ startEditing: startEditing,
237
+ changeDraft: changeDraft,
238
+ cancel: cancel,
239
+ save: save,
240
+ applyDrafts: applyDrafts
241
+ };
242
+ };
243
+
19
244
  var GENERAL_ONBOARDING_STEPS = {
20
245
  WELCOME: "welcome",
246
+ COMMUNITY: "community",
21
247
  HELP: "help",
22
248
  FINISH: "finish"
23
249
  };
24
250
 
251
+ 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; }
252
+ 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; }
253
+ var Community = function Community(_ref) {
254
+ var _globalProps$user, _globalProps$appName;
255
+ var setCurrentStep = _ref.setCurrentStep,
256
+ communityScreenClassName = _ref.communityScreenClassName;
257
+ var _useTranslation = useTranslation(),
258
+ t = _useTranslation.t;
259
+ var _useState = useState({
260
+ slack: true,
261
+ blog: true
262
+ }),
263
+ _useState2 = _slicedToArray(_useState, 2),
264
+ selected = _useState2[0],
265
+ setSelected = _useState2[1];
266
+
267
+ // Both start at the signed-in user's email; each can be changed separately.
268
+ var recipients = useRecipientEmails((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.email);
269
+ var _useJoinCommunity = useJoinCommunity(),
270
+ joinCommunity = _useJoinCommunity.mutate;
271
+ var appName = capitalize((_globalProps$appName = globalProps.appName) !== null && _globalProps$appName !== void 0 ? _globalProps$appName : "");
272
+ var handleContinue = function handleContinue() {
273
+ var selectedKeys = Object.keys(selected).filter(function (key) {
274
+ return selected[key];
275
+ });
276
+
277
+ // An address typed but not saved still counts; an invalid one keeps the
278
+ // user here with its error showing.
279
+ var emails = recipients.applyDrafts(selectedKeys);
280
+ if (!emails) return;
281
+
282
+ // The Slack invite and blog subscription are both sent by email in the
283
+ // background, so onboarding moves on without waiting for them.
284
+ if (selectedKeys.length > 0) {
285
+ joinCommunity(_objectSpread$2(_objectSpread$2({}, selected), {}, {
286
+ slackEmail: emails.slack,
287
+ blogEmail: emails.blog
288
+ }));
289
+ }
290
+ setCurrentStep(GENERAL_ONBOARDING_STEPS.HELP);
291
+ };
292
+ return /*#__PURE__*/jsxs("div", {
293
+ className: classnames("mx-auto flex w-full max-w-3xl flex-col items-start gap-y-6 px-6 pt-16 pb-6", communityScreenClassName),
294
+ children: [/*#__PURE__*/jsxs("div", {
295
+ className: "space-y-2",
296
+ children: [/*#__PURE__*/jsx(Typography, {
297
+ "data-testid": "onboarding-community-title",
298
+ style: "h1",
299
+ children: t("neetoMolecules.onboarding.communityScreen.title")
300
+ }), /*#__PURE__*/jsx(Typography, {
301
+ "data-testid": "onboarding-community-description",
302
+ style: "body1",
303
+ children: t("neetoMolecules.onboarding.communityScreen.description", {
304
+ appName: appName
305
+ })
306
+ })]
307
+ }), /*#__PURE__*/jsx("div", {
308
+ className: "neeto-ui-rounded-lg neeto-ui-border-gray-200 flex w-full flex-col gap-6 border p-3 lg:p-6",
309
+ children: COMMUNITY_OPTIONS.map(function (_ref2) {
310
+ var key = _ref2.key,
311
+ Icon = _ref2.icon,
312
+ dataTestid = _ref2.dataTestid,
313
+ recipientDataTestids = _ref2.recipientDataTestids;
314
+ return /*#__PURE__*/jsxs("div", {
315
+ className: "w-full",
316
+ children: [/*#__PURE__*/jsx(Checkbox, {
317
+ checked: selected[key],
318
+ "data-testid": dataTestid,
319
+ id: dataTestid,
320
+ labelProps: {
321
+ className: "text-xl font-semibold"
322
+ },
323
+ label: /*#__PURE__*/jsxs("span", {
324
+ className: "flex flex-wrap items-center gap-2",
325
+ children: [t("neetoMolecules.onboarding.communityScreen.".concat(key, ".title"), {
326
+ appName: appName
327
+ }), /*#__PURE__*/jsx(Icon, {
328
+ "aria-hidden": true,
329
+ size: 24
330
+ })]
331
+ }),
332
+ onChange: function onChange(event) {
333
+ setSelected(assoc(key, event.target.checked));
334
+ if (!event.target.checked) recipients.cancel(key);
335
+ }
336
+ }), /*#__PURE__*/jsx(Typography, {
337
+ className: "neeto-ui-text-gray-600 ps-6 pt-2",
338
+ style: "body1",
339
+ children: t("neetoMolecules.onboarding.communityScreen.".concat(key, ".description"))
340
+ }), selected[key] && /*#__PURE__*/jsx(EmailRecipient, {
341
+ dataTestids: recipientDataTestids,
342
+ edit: recipients.edits[key],
343
+ email: recipients.emails[key],
344
+ inputLabelKey: "neetoMolecules.onboarding.communityScreen.".concat(key, ".emailInputLabel"),
345
+ recipientKey: "neetoMolecules.onboarding.communityScreen.".concat(key, ".recipient"),
346
+ onCancel: function onCancel() {
347
+ return recipients.cancel(key);
348
+ },
349
+ onDraftChange: function onDraftChange(draft) {
350
+ return recipients.changeDraft(key, draft);
351
+ },
352
+ onSave: function onSave() {
353
+ return recipients.save(key);
354
+ },
355
+ onStartEditing: function onStartEditing() {
356
+ return recipients.startEditing(key);
357
+ }
358
+ })]
359
+ }, key);
360
+ })
361
+ }), /*#__PURE__*/jsx(Typography, {
362
+ className: "neeto-ui-text-gray-600",
363
+ style: "body2",
364
+ children: t("neetoMolecules.onboarding.communityScreen.unsubscribe")
365
+ }), /*#__PURE__*/jsx(Button, {
366
+ "data-testid": "community-onboarding-continue-button",
367
+ icon: RightArrow,
368
+ iconPosition: "right",
369
+ label: t("neetoMolecules.onboarding.communityScreen.continueButton"),
370
+ onClick: handleContinue
371
+ })]
372
+ });
373
+ };
374
+
25
375
  var HelpScreen = function HelpScreen(_ref) {
26
376
  var setCurrentStep = _ref.setCurrentStep,
27
377
  helpScreenClassName = _ref.helpScreenClassName;
@@ -74,7 +424,14 @@ var HelpScreen = function HelpScreen(_ref) {
74
424
 
75
425
  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; }
76
426
  function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
77
- var createSteps = function createSteps(onboardingSteps, setCurrentStep, currentStep, helpScreenClassName) {
427
+ var createSteps = function createSteps(onboardingSteps, setCurrentStep, currentStep, helpScreenClassName, isCommunityStepVisible) {
428
+ var communityStep = {
429
+ key: GENERAL_ONBOARDING_STEPS.COMMUNITY,
430
+ label: t("neetoMolecules.onboarding.communityLabel"),
431
+ element: /*#__PURE__*/jsx(Community, {
432
+ setCurrentStep: setCurrentStep
433
+ })
434
+ };
78
435
  var helpStep = {
79
436
  key: GENERAL_ONBOARDING_STEPS.HELP,
80
437
  label: t("neetoMolecules.onboarding.helpLabel"),
@@ -84,7 +441,7 @@ var createSteps = function createSteps(onboardingSteps, setCurrentStep, currentS
84
441
  setCurrentStep: setCurrentStep
85
442
  })
86
443
  };
87
- return onboardingSteps.concat(helpStep).map(function (step, idx) {
444
+ return onboardingSteps.concat(isCommunityStepVisible ? [communityStep, helpStep] : helpStep).map(function (step, idx) {
88
445
  return _objectSpread$1(_objectSpread$1({}, step), {}, {
89
446
  id: idx + 1
90
447
  });
@@ -242,11 +599,27 @@ var Onboarding = function Onboarding(_ref) {
242
599
  welcomeScreenClassName = _ref$welcomeScreenCla === void 0 ? "" : _ref$welcomeScreenCla,
243
600
  _ref$completedScreenC = _ref.completedScreenClassName,
244
601
  completedScreenClassName = _ref$completedScreenC === void 0 ? "" : _ref$completedScreenC,
245
- completedScreenSuccessMessage = _ref.completedScreenSuccessMessage;
602
+ completedScreenSuccessMessage = _ref.completedScreenSuccessMessage,
603
+ _ref$isCommunityStepV = _ref.isCommunityStepVisible,
604
+ isCommunityStepVisible = _ref$isCommunityStepV === void 0 ? true : _ref$isCommunityStepV;
246
605
  var steps = useMemo(function () {
247
- return createSteps(onboardingSteps, setCurrentStep, currentStep, helpScreenClassName);
248
- }, [onboardingSteps]);
606
+ return createSteps(onboardingSteps, setCurrentStep, currentStep, helpScreenClassName, isCommunityStepVisible);
607
+ }, [onboardingSteps, isCommunityStepVisible]);
249
608
  var prevStep = useRef(currentStep);
609
+ var isStepperNavigation = useRef(false);
610
+ var isRedirectingToCommunity = useRef(false);
611
+
612
+ // Products move from their last step straight to Help. Send them through
613
+ // the community step first, unless they picked Help in the stepper.
614
+ useLayoutEffect(function () {
615
+ var isFromStepper = isStepperNavigation.current;
616
+ isStepperNavigation.current = false;
617
+ var shouldShowCommunityFirst = isCommunityStepVisible && !isFromStepper && currentStep === GENERAL_ONBOARDING_STEPS.HELP && prevStep.current !== currentStep && prevStep.current !== GENERAL_ONBOARDING_STEPS.COMMUNITY;
618
+ if (shouldShowCommunityFirst) {
619
+ isRedirectingToCommunity.current = true;
620
+ setCurrentStep(GENERAL_ONBOARDING_STEPS.COMMUNITY);
621
+ }
622
+ }, [currentStep]);
250
623
  var _useState = useState(""),
251
624
  _useState2 = _slicedToArray(_useState, 2),
252
625
  direction = _useState2[0],
@@ -258,6 +631,13 @@ var Onboarding = function Onboarding(_ref) {
258
631
  };
259
632
  useEffect(function () {
260
633
  if (currentStep === prevStep.current) return;
634
+
635
+ // Help is skipped over on the way to the community step, so the
636
+ // animation should run from the step before it.
637
+ if (isRedirectingToCommunity.current) {
638
+ isRedirectingToCommunity.current = false;
639
+ return;
640
+ }
261
641
  setDirection(getOnboardingStepIndex(currentStep) > getOnboardingStepIndex(prevStep.current) ? "forward" : "backward");
262
642
  prevStep.current = currentStep;
263
643
  }, [currentStep]);
@@ -277,7 +657,10 @@ var Onboarding = function Onboarding(_ref) {
277
657
  });
278
658
  }
279
659
  var handleStepChange = function handleStepChange(index) {
280
- return setCurrentStep(steps[index].key);
660
+ var stepKey = steps[index].key;
661
+ if (stepKey === currentStep) return;
662
+ isStepperNavigation.current = true;
663
+ setCurrentStep(stepKey);
281
664
  };
282
665
  var isStepperVisible = steps.length > 1;
283
666
  return /*#__PURE__*/jsxs("div", {