@selfcommunity/react-ui 0.10.2-courses.178 → 0.10.2-courses.179

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 (34) hide show
  1. package/lib/cjs/components/Composer/Content/ContentLesson/ContentLesson.js +1 -0
  2. package/lib/cjs/components/Course/Course.js +1 -1
  3. package/lib/cjs/components/CourseDashboard/Student.js +2 -1
  4. package/lib/cjs/components/CourseDashboard/Teacher/Students.js +1 -1
  5. package/lib/cjs/components/EditCourse/Requests.js +1 -1
  6. package/lib/cjs/components/EditCourse/Users.js +1 -1
  7. package/lib/cjs/components/Editor/Editor.d.ts +1 -1
  8. package/lib/cjs/components/Editor/Editor.js +9 -9
  9. package/lib/cjs/components/Editor/plugins/HorizontalRulePlugin.d.ts +8 -0
  10. package/lib/cjs/components/Editor/plugins/HorizontalRulePlugin.js +34 -0
  11. package/lib/cjs/components/Editor/plugins/LexicalRichTextPlugin.d.ts +2 -2
  12. package/lib/cjs/components/Editor/plugins/LexicalRichTextPlugin.js +2 -3
  13. package/lib/cjs/components/LessonReleaseMenu/LessonReleaseMenu.js +17 -3
  14. package/lib/cjs/utils/buttonCounters.d.ts +1 -0
  15. package/lib/cjs/utils/buttonCounters.js +4 -3
  16. package/lib/esm/components/Composer/Content/ContentLesson/ContentLesson.js +1 -0
  17. package/lib/esm/components/Course/Course.js +1 -1
  18. package/lib/esm/components/CourseDashboard/Student.js +2 -1
  19. package/lib/esm/components/CourseDashboard/Teacher/Students.js +1 -1
  20. package/lib/esm/components/EditCourse/Requests.js +1 -1
  21. package/lib/esm/components/EditCourse/Users.js +1 -1
  22. package/lib/esm/components/Editor/Editor.d.ts +1 -1
  23. package/lib/esm/components/Editor/Editor.js +8 -8
  24. package/lib/esm/components/Editor/plugins/HorizontalRulePlugin.d.ts +8 -0
  25. package/lib/esm/components/Editor/plugins/HorizontalRulePlugin.js +30 -0
  26. package/lib/esm/components/Editor/plugins/LexicalRichTextPlugin.d.ts +2 -2
  27. package/lib/esm/components/Editor/plugins/LexicalRichTextPlugin.js +1 -1
  28. package/lib/esm/components/LessonReleaseMenu/LessonReleaseMenu.js +18 -4
  29. package/lib/esm/utils/buttonCounters.d.ts +1 -0
  30. package/lib/esm/utils/buttonCounters.js +3 -2
  31. package/lib/umd/{687.js → 233.js} +2 -2
  32. package/lib/umd/react-ui.js +1 -1
  33. package/package.json +11 -11
  34. /package/lib/umd/{687.js.LICENSE.txt → 233.js.LICENSE.txt} +0 -0
@@ -50,6 +50,7 @@ exports.default = (props) => {
50
50
  (0, react_1.useEffect)(() => {
51
51
  if (openLink && linkInputRef.current) {
52
52
  linkInputRef.current.scrollIntoView({ behavior: 'smooth' });
53
+ console.log('scroll debug');
53
54
  }
54
55
  }, [openLink]);
55
56
  // RENDER
@@ -158,7 +158,7 @@ function Course(inProps) {
158
158
  }), { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: (_e = scCourse.created_by) === null || _e === void 0 ? void 0 : _e.username })) })), (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_ROUTE_NAME, scCourse), className: classes.previewNameWrapper }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h6", className: classes.previewName }, { children: scCourse.name })) })), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.previewInfo }, { children: [(0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: scCourse.privacy ? `ui.course.privacy.${scCourse.privacy}` : 'ui.course.privacy.draft', defaultMessage: scCourse.privacy ? `ui.course.privacy.${scCourse.privacy}` : 'ui.course.privacy.draft' }), "-", (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.course.type.${scCourse.type}`, defaultMessage: `ui.course.type.${scCourse.type}` })] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.previewCategory }, { children: scCourse.categories.map((category) => ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", label: category.name }, category.id))) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.previewProgress }, { children: renderProgress() }))] })), actions !== null && actions !== void 0 ? actions : ((0, jsx_runtime_1.jsx)(material_1.CardActions, Object.assign({ className: classes.previewActions }, { children: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "outlined", size: "small", component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_ROUTE_NAME, scCourse) }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { defaultMessage: "ui.course.see", id: "ui.course.see" }) })) })))] })));
159
159
  }
160
160
  else {
161
- contentObj = ((0, jsx_runtime_1.jsx)(SnippetRoot, { elevation: 0, className: classes.snippetRoot, image: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.snippetImage }, { children: [(0, jsx_runtime_1.jsx)(material_1.Avatar, { variant: "square", alt: scCourse.name, src: scCourse.image_medium, className: userProfileSnippet ? classes.snippetAvatarUserProfile : classes.snippetAvatar }), !userProfileSnippet && (isCourseAdmin || (0, course_2.isCourseCompleted)(scCourse) || (0, course_2.isCourseNew)(scCourse)) && ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", component: "div", color: (0, course_2.isCourseCompleted)(scCourse) || (isCourseAdmin && scCourse.privacy)
161
+ contentObj = ((0, jsx_runtime_1.jsx)(SnippetRoot, { ButtonBaseProps: { component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.COURSE_ROUTE_NAME, scCourse) }, elevation: 0, className: classes.snippetRoot, image: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.snippetImage }, { children: [(0, jsx_runtime_1.jsx)(material_1.Avatar, { variant: "square", alt: scCourse.name, src: scCourse.image_medium, className: userProfileSnippet ? classes.snippetAvatarUserProfile : classes.snippetAvatar }), !userProfileSnippet && (isCourseAdmin || (0, course_2.isCourseCompleted)(scCourse) || (0, course_2.isCourseNew)(scCourse)) && ((0, jsx_runtime_1.jsx)(material_1.Chip, { size: "small", component: "div", color: (0, course_2.isCourseCompleted)(scCourse) || (isCourseAdmin && scCourse.privacy)
162
162
  ? 'primary'
163
163
  : isCourseAdmin && !scCourse.privacy
164
164
  ? 'default'
@@ -66,11 +66,12 @@ function getUrlNextLesson(course) {
66
66
  return data;
67
67
  }
68
68
  (_a = course.sections) === null || _a === void 0 ? void 0 : _a.some((section) => {
69
+ var _a;
69
70
  const isNextLessonInThisSection = section.num_lessons_completed < section.num_lessons;
70
71
  if (isNextLessonInThisSection) {
71
72
  Object.assign(data, {
72
73
  section_id: section.id,
73
- lesson_id: section.lessons.find((lesson) => lesson.completion_status === types_1.SCCourseLessonCompletionStatusType.UNCOMPLETED).id
74
+ lesson_id: (_a = section.lessons.find((lesson) => lesson.completion_status === types_1.SCCourseLessonCompletionStatusType.UNCOMPLETED)) === null || _a === void 0 ? void 0 : _a.id
74
75
  });
75
76
  }
76
77
  return isNextLessonInThisSection;
@@ -32,7 +32,7 @@ function Students(props) {
32
32
  const [state, dispatch] = (0, react_1.useReducer)(widget_1.dataWidgetReducer, {
33
33
  isLoadingNext: false,
34
34
  next: null,
35
- cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.USER_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY, course === null || course === void 0 ? void 0 : course.id),
35
+ cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.STUDENTS_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY, course.id),
36
36
  cacheStrategy: utils_1.CacheStrategies.CACHE_FIRST,
37
37
  visibleItems: endpointQueryParams.limit
38
38
  }, widget_1.stateWidgetInitializer);
@@ -42,7 +42,7 @@ function Requests(props) {
42
42
  isLoadingPrevious: false,
43
43
  isLoadingNext: false,
44
44
  next: null,
45
- cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.USER_REQUESTS_COURSES_STATE_CACHE_PREFIX_KEY, course.id),
45
+ cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.USERS_REQUESTS_COURSES_STATE_CACHE_PREFIX_KEY, course.id),
46
46
  cacheStrategy: utils_1.CacheStrategies.CACHE_FIRST,
47
47
  visibleItems: endpointQueryParams.limit
48
48
  }, widget_1.stateWidgetInitializer);
@@ -48,7 +48,7 @@ function Users(props) {
48
48
  const [state, dispatch] = (0, react_1.useReducer)(widget_1.dataWidgetReducer, {
49
49
  isLoadingNext: false,
50
50
  next: null,
51
- cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.USER_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY, course.id),
51
+ cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.USERS_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY, course.id),
52
52
  cacheStrategy: utils_1.CacheStrategies.CACHE_FIRST,
53
53
  visibleItems: endpointQueryParams.limit
54
54
  }, widget_1.stateWidgetInitializer);
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { MediaPluginProps } from './plugins';
3
2
  import { ToolbarPluginProps } from './plugins/ToolbarPlugin';
3
+ import { MediaPluginProps } from './plugins';
4
4
  import { SCMediaType } from '@selfcommunity/types';
5
5
  export declare type EditorRef = {
6
6
  focus: () => void;
@@ -11,19 +11,19 @@ const system_1 = require("@mui/system");
11
11
  const nodes_1 = tslib_1.__importDefault(require("./nodes"));
12
12
  const LexicalComposer_1 = require("@lexical/react/LexicalComposer");
13
13
  const LexicalContentEditable_1 = require("@lexical/react/LexicalContentEditable");
14
- const LexicalHistoryPlugin_1 = require("@lexical/react/LexicalHistoryPlugin");
14
+ const ToolbarPlugin_1 = tslib_1.__importDefault(require("./plugins/ToolbarPlugin"));
15
+ const constants_1 = require("./constants");
16
+ const HorizontalRulePlugin_1 = require("./plugins/HorizontalRulePlugin");
15
17
  const LexicalRichTextPlugin_1 = require("./plugins/LexicalRichTextPlugin");
16
- const LexicalErrorBoundary_1 = tslib_1.__importDefault(require("@lexical/react/LexicalErrorBoundary"));
17
- const LexicalHorizontalRulePlugin_1 = require("@lexical/react/LexicalHorizontalRulePlugin");
18
+ const LexicalErrorBoundary_1 = require("@lexical/react/LexicalErrorBoundary");
18
19
  const plugins_1 = require("./plugins");
20
+ const OnBlurPlugin_1 = tslib_1.__importDefault(require("./plugins/OnBlurPlugin"));
21
+ const OnFocusPlugin_1 = tslib_1.__importDefault(require("./plugins/OnFocusPlugin"));
19
22
  const LexicalLinkPlugin_1 = require("@lexical/react/LexicalLinkPlugin");
23
+ const FloatingLinkPlugin_1 = tslib_1.__importDefault(require("./plugins/FloatingLinkPlugin"));
20
24
  const ApiPlugin_1 = tslib_1.__importDefault(require("./plugins/ApiPlugin"));
21
- const ToolbarPlugin_1 = tslib_1.__importDefault(require("./plugins/ToolbarPlugin"));
25
+ const LexicalHistoryPlugin_1 = require("@lexical/react/LexicalHistoryPlugin");
22
26
  const LexicalListPlugin_1 = require("@lexical/react/LexicalListPlugin");
23
- const FloatingLinkPlugin_1 = tslib_1.__importDefault(require("./plugins/FloatingLinkPlugin"));
24
- const OnBlurPlugin_1 = tslib_1.__importDefault(require("./plugins/OnBlurPlugin"));
25
- const OnFocusPlugin_1 = tslib_1.__importDefault(require("./plugins/OnFocusPlugin"));
26
- const constants_1 = require("./constants");
27
27
  const classes = {
28
28
  root: `${constants_1.PREFIX}-root`,
29
29
  focused: `${constants_1.PREFIX}-focused`,
@@ -148,6 +148,6 @@ const Editor = (inProps, ref) => {
148
148
  nodes: [...nodes_1.default],
149
149
  theme: editorTheme
150
150
  }), [editable]);
151
- return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, { [classes.toolbar]: toolbar, [classes.focused]: focused }) }, { children: (0, jsx_runtime_1.jsxs)(LexicalComposer_1.LexicalComposer, Object.assign({ initialConfig: initialConfig }, { children: [toolbar ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ToolbarPlugin_1.default, Object.assign({ uploadImage: uploadImage, uploadFile: uploadFile, MediaPluginProps: { onMediaAdd: handleMediaChange } }, ToolBarProps)), (0, jsx_runtime_1.jsx)(LexicalListPlugin_1.ListPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalHorizontalRulePlugin_1.HorizontalRulePlugin, {})] })) : ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.actions, direction: "row" }, { children: [uploadImage && (0, jsx_runtime_1.jsx)(plugins_1.ImagePlugin, {}), uploadFile && (0, jsx_runtime_1.jsx)(plugins_1.MediaPlugin, Object.assign({}, MediaPluginProps)), (0, jsx_runtime_1.jsx)(plugins_1.EmojiPlugin, {}), action && action] }))), (0, jsx_runtime_1.jsx)(LexicalRichTextPlugin_1.RichTextPlugin, { contentEditable: (0, jsx_runtime_1.jsx)(LexicalContentEditable_1.ContentEditable, { className: classes.content }), placeholder: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.placeholder, onClick: handleFocus }, { children: placeholder })), ErrorBoundary: LexicalErrorBoundary_1.default }), (0, jsx_runtime_1.jsx)(plugins_1.DefaultHtmlValuePlugin, { defaultValue: defaultValue }), (0, jsx_runtime_1.jsx)(LexicalHistoryPlugin_1.HistoryPlugin, {}), (0, jsx_runtime_1.jsx)(plugins_1.OnChangePlugin, { onChange: handleChange }), (0, jsx_runtime_1.jsx)(OnBlurPlugin_1.default, { onBlur: handleHasBlur }), (0, jsx_runtime_1.jsx)(OnFocusPlugin_1.default, { onFocus: handleHasFocus }), (0, jsx_runtime_1.jsx)(plugins_1.AutoLinkPlugin, {}), (0, jsx_runtime_1.jsx)(plugins_1.MentionsPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalLinkPlugin_1.LinkPlugin, {}), (0, jsx_runtime_1.jsx)(FloatingLinkPlugin_1.default, {}), (0, jsx_runtime_1.jsx)(ApiPlugin_1.default, { ref: apiRef })] })) })));
151
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, { [classes.toolbar]: toolbar, [classes.focused]: focused }) }, { children: (0, jsx_runtime_1.jsxs)(LexicalComposer_1.LexicalComposer, Object.assign({ initialConfig: initialConfig }, { children: [toolbar ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ToolbarPlugin_1.default, Object.assign({ uploadImage: uploadImage, uploadFile: uploadFile, MediaPluginProps: { onMediaAdd: handleMediaChange } }, ToolBarProps)), (0, jsx_runtime_1.jsx)(LexicalListPlugin_1.ListPlugin, {}), (0, jsx_runtime_1.jsx)(HorizontalRulePlugin_1.HorizontalRulePlugin, {})] })) : ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.actions, direction: "row" }, { children: [uploadImage && (0, jsx_runtime_1.jsx)(plugins_1.ImagePlugin, {}), uploadFile && (0, jsx_runtime_1.jsx)(plugins_1.MediaPlugin, Object.assign({}, MediaPluginProps)), (0, jsx_runtime_1.jsx)(plugins_1.EmojiPlugin, {}), action && action] }))), (0, jsx_runtime_1.jsx)(LexicalRichTextPlugin_1.RichTextPlugin, { contentEditable: (0, jsx_runtime_1.jsx)(LexicalContentEditable_1.ContentEditable, { className: classes.content }), placeholder: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.placeholder, onClick: handleFocus }, { children: placeholder })), ErrorBoundary: LexicalErrorBoundary_1.LexicalErrorBoundary }), (0, jsx_runtime_1.jsx)(plugins_1.DefaultHtmlValuePlugin, { defaultValue: defaultValue }), (0, jsx_runtime_1.jsx)(LexicalHistoryPlugin_1.HistoryPlugin, {}), (0, jsx_runtime_1.jsx)(plugins_1.OnChangePlugin, { onChange: handleChange }), (0, jsx_runtime_1.jsx)(OnBlurPlugin_1.default, { onBlur: handleHasBlur }), (0, jsx_runtime_1.jsx)(OnFocusPlugin_1.default, { onFocus: handleHasFocus }), (0, jsx_runtime_1.jsx)(plugins_1.AutoLinkPlugin, {}), (0, jsx_runtime_1.jsx)(plugins_1.MentionsPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalLinkPlugin_1.LinkPlugin, {}), (0, jsx_runtime_1.jsx)(FloatingLinkPlugin_1.default, {}), (0, jsx_runtime_1.jsx)(ApiPlugin_1.default, { ref: apiRef })] })) })));
152
152
  };
153
153
  exports.default = (0, react_1.forwardRef)(Editor);
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export declare function HorizontalRulePlugin(): null;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.HorizontalRulePlugin = void 0;
11
+ const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
12
+ const LexicalHorizontalRuleNode_1 = require("@lexical/react/LexicalHorizontalRuleNode");
13
+ const utils_1 = require("@lexical/utils");
14
+ const lexical_1 = require("lexical");
15
+ const react_1 = require("react");
16
+ function HorizontalRulePlugin() {
17
+ const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
18
+ (0, react_1.useEffect)(() => {
19
+ return editor.registerCommand(LexicalHorizontalRuleNode_1.INSERT_HORIZONTAL_RULE_COMMAND, (type) => {
20
+ const selection = (0, lexical_1.$getSelection)();
21
+ if (!(0, lexical_1.$isRangeSelection)(selection)) {
22
+ return false;
23
+ }
24
+ const focusNode = selection.focus.getNode();
25
+ if (focusNode !== null) {
26
+ const horizontalRuleNode = (0, LexicalHorizontalRuleNode_1.$createHorizontalRuleNode)();
27
+ (0, utils_1.$insertNodeToNearestRoot)(horizontalRuleNode);
28
+ }
29
+ return true;
30
+ }, lexical_1.COMMAND_PRIORITY_EDITOR);
31
+ }, [editor]);
32
+ return null;
33
+ }
34
+ exports.HorizontalRulePlugin = HorizontalRulePlugin;
@@ -1,6 +1,6 @@
1
1
  import { ErrorBoundaryType } from '../shared/useDecorators';
2
2
  export declare function RichTextPlugin({ contentEditable, placeholder, ErrorBoundary }: {
3
3
  contentEditable: JSX.Element;
4
- placeholder: ((isEditable: boolean) => null | JSX.Element) | null | JSX.Element;
5
- ErrorBoundary: ErrorBoundaryType;
4
+ placeholder?: ((isEditable: boolean) => null | JSX.Element) | null | JSX.Element;
5
+ ErrorBoundary?: ErrorBoundaryType;
6
6
  }): JSX.Element;
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RichTextPlugin = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const jsx_runtime_1 = require("react/jsx-runtime");
6
5
  const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
7
- const useLexicalEditable_1 = tslib_1.__importDefault(require("@lexical/react/useLexicalEditable"));
6
+ const useLexicalEditable_1 = require("@lexical/react/useLexicalEditable");
8
7
  const useDecorators_1 = require("../shared/useDecorators");
9
8
  const useEditorFocus_1 = require("../shared/useEditorFocus");
10
9
  const useCanShowPlaceholder_1 = require("../shared/useCanShowPlaceholder");
@@ -19,7 +18,7 @@ exports.RichTextPlugin = RichTextPlugin;
19
18
  function Placeholder({ content }) {
20
19
  const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
21
20
  const showPlaceholder = (0, useCanShowPlaceholder_1.useCanShowPlaceholder)(editor);
22
- const editable = (0, useLexicalEditable_1.default)();
21
+ const editable = (0, useLexicalEditable_1.useLexicalEditable)();
23
22
  const hasFocus = (0, useEditorFocus_1.useEditorFocus)();
24
23
  if (!showPlaceholder || hasFocus) {
25
24
  return null;
@@ -67,7 +67,7 @@ function LessonReleaseMenu(inProps) {
67
67
  // CONTEXT
68
68
  const scContext = (0, react_core_1.useSCContext)();
69
69
  // STATE
70
- const [drippedAt, setDrippedAt] = (0, react_1.useState)((section === null || section === void 0 ? void 0 : section.dripped_at) ? new Date(section === null || section === void 0 ? void 0 : section.dripped_at) : null);
70
+ const [drippedAt, setDrippedAt] = (0, react_1.useState)(null);
71
71
  const { delay, _unit } = (0, course_1.getDripDelayAndUnit)((section === null || section === void 0 ? void 0 : section.drip_delay) || 0);
72
72
  const [dripDelay, setDripDelay] = (0, react_1.useState)(delay);
73
73
  const [unit, setUnit] = (0, react_1.useState)(_unit);
@@ -80,6 +80,20 @@ function LessonReleaseMenu(inProps) {
80
80
  const handleUnitChange = (e) => {
81
81
  setUnit(e.target.value);
82
82
  };
83
+ // EFFECTS
84
+ (0, react_1.useEffect)(() => {
85
+ if (section && section.dripped_at) {
86
+ setDrippedAt(new Date(section.dripped_at));
87
+ }
88
+ else {
89
+ setDrippedAt(null);
90
+ }
91
+ }, [section, setDrippedAt]);
92
+ (0, react_1.useEffect)(() => {
93
+ if (section) {
94
+ setDripDelay(delay);
95
+ }
96
+ }, [section, setDripDelay]);
83
97
  // HANDLERS
84
98
  const handleClick = (event) => {
85
99
  setAnchorEl(event.currentTarget);
@@ -125,7 +139,7 @@ function LessonReleaseMenu(inProps) {
125
139
  okButtonLabel: `${intl.formatMessage(messages.pickerOkMessage)}`,
126
140
  cancelButtonLabel: `${intl.formatMessage(messages.pickerCancelMessage)}`,
127
141
  clearButtonLabel: `${intl.formatMessage(messages.pickerClearMessage)}`
128
- } }, { children: (0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileDateTimePicker, { className: classes.picker, disablePast: true, label: drippedAt && ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.lessonReleaseMenu.scheduled.picker.placeholder", defaultMessage: "ui.lessonReleaseMenu.scheduled.picker.placeholder" })), defaultValue: drippedAt, slots: {
142
+ } }, { children: (0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileDateTimePicker, { className: classes.picker, disablePast: true, label: drippedAt && ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.lessonReleaseMenu.scheduled.picker.placeholder", defaultMessage: "ui.lessonReleaseMenu.scheduled.picker.placeholder" })), value: drippedAt, slots: {
129
143
  //actionBar: PickerActionBar,
130
144
  tabs: (props) => (0, jsx_runtime_1.jsx)(x_date_pickers_1.DateTimePickerTabs, Object.assign({}, props)),
131
145
  textField: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { error: false, InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.pickerPlaceholder)}`, endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ disabled: isDisabled }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "expand_more" }) })) }))) }) })))
@@ -141,7 +155,7 @@ function LessonReleaseMenu(inProps) {
141
155
  actionBar: {
142
156
  actions: ['cancel', 'clear', 'accept']
143
157
  }
144
- }, onChange: (value) => setDrippedAt(value), onAccept: handleUpdate, onClear: () => setDrippedAt(null), disabled: isDisabled }) }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { size: "small", placeholder: placeholderStructured, defaultValue: null, onClick: isDisabled ? undefined : handleClick, InputProps: {
158
+ }, onChange: (value) => setDrippedAt(value), onAccept: handleUpdate, onClear: () => setDrippedAt(null), disabled: isDisabled }) }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { size: "small", value: placeholderStructured, onClick: isDisabled ? undefined : handleClick, InputProps: {
145
159
  endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: handleClick, disabled: isDisabled }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "expand_more" }) })) })))
146
160
  }, disabled: isDisabled }), (0, jsx_runtime_1.jsxs)(PopoverRoot, Object.assign({ className: classes.popoverRoot, open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: {
147
161
  vertical: 'bottom',
@@ -1 +1,2 @@
1
+ export declare const DEFAULT_COUNTERS_LIMIT = 3;
1
2
  export declare function numberFormatter(num: number): JSX.Element;
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.numberFormatter = void 0;
3
+ exports.numberFormatter = exports.DEFAULT_COUNTERS_LIMIT = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ exports.DEFAULT_COUNTERS_LIMIT = 3;
5
6
  function numberFormatter(num) {
6
- const surplus = num - 3;
7
+ const surplus = num === exports.DEFAULT_COUNTERS_LIMIT ? 1 : num < exports.DEFAULT_COUNTERS_LIMIT ? num : num - exports.DEFAULT_COUNTERS_LIMIT;
7
8
  if (surplus > 999999) {
8
9
  return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["+", (Math.abs(surplus) / 1000000).toFixed(1), "M"] });
9
10
  }
10
- else if (num > 999) {
11
+ else if (surplus > 999) {
11
12
  return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["+", (Math.abs(surplus) / 1000).toFixed(1), "K"] });
12
13
  }
13
14
  return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["+", surplus] });
@@ -47,6 +47,7 @@ export default (props) => {
47
47
  useEffect(() => {
48
48
  if (openLink && linkInputRef.current) {
49
49
  linkInputRef.current.scrollIntoView({ behavior: 'smooth' });
50
+ console.log('scroll debug');
50
51
  }
51
52
  }, [openLink]);
52
53
  // RENDER
@@ -156,7 +156,7 @@ export default function Course(inProps) {
156
156
  }), { children: _jsx(Typography, Object.assign({ variant: "body2" }, { children: (_e = scCourse.created_by) === null || _e === void 0 ? void 0 : _e.username })) })), _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.COURSE_ROUTE_NAME, scCourse), className: classes.previewNameWrapper }, { children: _jsx(Typography, Object.assign({ variant: "h6", className: classes.previewName }, { children: scCourse.name })) })), _jsxs(Typography, Object.assign({ className: classes.previewInfo }, { children: [_jsx(FormattedMessage, { id: scCourse.privacy ? `ui.course.privacy.${scCourse.privacy}` : 'ui.course.privacy.draft', defaultMessage: scCourse.privacy ? `ui.course.privacy.${scCourse.privacy}` : 'ui.course.privacy.draft' }), "-", _jsx(FormattedMessage, { id: `ui.course.type.${scCourse.type}`, defaultMessage: `ui.course.type.${scCourse.type}` })] })), _jsx(Box, Object.assign({ className: classes.previewCategory }, { children: scCourse.categories.map((category) => (_jsx(Chip, { size: "small", label: category.name }, category.id))) })), _jsx(Box, Object.assign({ className: classes.previewProgress }, { children: renderProgress() }))] })), actions !== null && actions !== void 0 ? actions : (_jsx(CardActions, Object.assign({ className: classes.previewActions }, { children: _jsx(Button, Object.assign({ variant: "outlined", size: "small", component: Link, to: scRoutingContext.url(SCRoutes.COURSE_ROUTE_NAME, scCourse) }, { children: _jsx(FormattedMessage, { defaultMessage: "ui.course.see", id: "ui.course.see" }) })) })))] })));
157
157
  }
158
158
  else {
159
- contentObj = (_jsx(SnippetRoot, { elevation: 0, className: classes.snippetRoot, image: _jsxs(Box, Object.assign({ className: classes.snippetImage }, { children: [_jsx(Avatar, { variant: "square", alt: scCourse.name, src: scCourse.image_medium, className: userProfileSnippet ? classes.snippetAvatarUserProfile : classes.snippetAvatar }), !userProfileSnippet && (isCourseAdmin || isCourseCompleted(scCourse) || isCourseNew(scCourse)) && (_jsx(Chip, { size: "small", component: "div", color: isCourseCompleted(scCourse) || (isCourseAdmin && scCourse.privacy)
159
+ contentObj = (_jsx(SnippetRoot, { ButtonBaseProps: { component: Link, to: scRoutingContext.url(SCRoutes.COURSE_ROUTE_NAME, scCourse) }, elevation: 0, className: classes.snippetRoot, image: _jsxs(Box, Object.assign({ className: classes.snippetImage }, { children: [_jsx(Avatar, { variant: "square", alt: scCourse.name, src: scCourse.image_medium, className: userProfileSnippet ? classes.snippetAvatarUserProfile : classes.snippetAvatar }), !userProfileSnippet && (isCourseAdmin || isCourseCompleted(scCourse) || isCourseNew(scCourse)) && (_jsx(Chip, { size: "small", component: "div", color: isCourseCompleted(scCourse) || (isCourseAdmin && scCourse.privacy)
160
160
  ? 'primary'
161
161
  : isCourseAdmin && !scCourse.privacy
162
162
  ? 'default'
@@ -64,11 +64,12 @@ function getUrlNextLesson(course) {
64
64
  return data;
65
65
  }
66
66
  (_a = course.sections) === null || _a === void 0 ? void 0 : _a.some((section) => {
67
+ var _a;
67
68
  const isNextLessonInThisSection = section.num_lessons_completed < section.num_lessons;
68
69
  if (isNextLessonInThisSection) {
69
70
  Object.assign(data, {
70
71
  section_id: section.id,
71
- lesson_id: section.lessons.find((lesson) => lesson.completion_status === SCCourseLessonCompletionStatusType.UNCOMPLETED).id
72
+ lesson_id: (_a = section.lessons.find((lesson) => lesson.completion_status === SCCourseLessonCompletionStatusType.UNCOMPLETED)) === null || _a === void 0 ? void 0 : _a.id
72
73
  });
73
74
  }
74
75
  return isNextLessonInThisSection;
@@ -29,7 +29,7 @@ function Students(props) {
29
29
  const [state, dispatch] = useReducer(dataWidgetReducer, {
30
30
  isLoadingNext: false,
31
31
  next: null,
32
- cacheKey: SCCache.getWidgetStateCacheKey(SCCache.USER_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY, course === null || course === void 0 ? void 0 : course.id),
32
+ cacheKey: SCCache.getWidgetStateCacheKey(SCCache.STUDENTS_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY, course.id),
33
33
  cacheStrategy: CacheStrategies.CACHE_FIRST,
34
34
  visibleItems: endpointQueryParams.limit
35
35
  }, stateWidgetInitializer);
@@ -39,7 +39,7 @@ function Requests(props) {
39
39
  isLoadingPrevious: false,
40
40
  isLoadingNext: false,
41
41
  next: null,
42
- cacheKey: SCCache.getWidgetStateCacheKey(SCCache.USER_REQUESTS_COURSES_STATE_CACHE_PREFIX_KEY, course.id),
42
+ cacheKey: SCCache.getWidgetStateCacheKey(SCCache.USERS_REQUESTS_COURSES_STATE_CACHE_PREFIX_KEY, course.id),
43
43
  cacheStrategy: CacheStrategies.CACHE_FIRST,
44
44
  visibleItems: endpointQueryParams.limit
45
45
  }, stateWidgetInitializer);
@@ -45,7 +45,7 @@ function Users(props) {
45
45
  const [state, dispatch] = useReducer(dataWidgetReducer, {
46
46
  isLoadingNext: false,
47
47
  next: null,
48
- cacheKey: SCCache.getWidgetStateCacheKey(SCCache.USER_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY, course.id),
48
+ cacheKey: SCCache.getWidgetStateCacheKey(SCCache.USERS_PARTECIPANTS_COURSES_STATE_CACHE_PREFIX_KEY, course.id),
49
49
  cacheStrategy: CacheStrategies.CACHE_FIRST,
50
50
  visibleItems: endpointQueryParams.limit
51
51
  }, stateWidgetInitializer);
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { MediaPluginProps } from './plugins';
3
2
  import { ToolbarPluginProps } from './plugins/ToolbarPlugin';
3
+ import { MediaPluginProps } from './plugins';
4
4
  import { SCMediaType } from '@selfcommunity/types';
5
5
  export declare type EditorRef = {
6
6
  focus: () => void;
@@ -8,19 +8,19 @@ import { useThemeProps } from '@mui/system';
8
8
  import nodes from './nodes';
9
9
  import { LexicalComposer } from '@lexical/react/LexicalComposer';
10
10
  import { ContentEditable } from '@lexical/react/LexicalContentEditable';
11
- import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
11
+ import ToolbarPlugin from './plugins/ToolbarPlugin';
12
+ import { PREFIX } from './constants';
13
+ import { HorizontalRulePlugin } from './plugins/HorizontalRulePlugin';
12
14
  import { RichTextPlugin } from './plugins/LexicalRichTextPlugin';
13
- import LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary';
14
- import { HorizontalRulePlugin } from '@lexical/react/LexicalHorizontalRulePlugin';
15
+ import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
15
16
  import { AutoLinkPlugin, DefaultHtmlValuePlugin, EmojiPlugin, ImagePlugin, MediaPlugin, MentionsPlugin, OnChangePlugin } from './plugins';
17
+ import OnBlurPlugin from './plugins/OnBlurPlugin';
18
+ import OnFocusPlugin from './plugins/OnFocusPlugin';
16
19
  import { LinkPlugin } from '@lexical/react/LexicalLinkPlugin';
20
+ import FloatingLinkPlugin from './plugins/FloatingLinkPlugin';
17
21
  import ApiPlugin from './plugins/ApiPlugin';
18
- import ToolbarPlugin from './plugins/ToolbarPlugin';
22
+ import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
19
23
  import { ListPlugin } from '@lexical/react/LexicalListPlugin';
20
- import FloatingLinkPlugin from './plugins/FloatingLinkPlugin';
21
- import OnBlurPlugin from './plugins/OnBlurPlugin';
22
- import OnFocusPlugin from './plugins/OnFocusPlugin';
23
- import { PREFIX } from './constants';
24
24
  const classes = {
25
25
  root: `${PREFIX}-root`,
26
26
  focused: `${PREFIX}-focused`,
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export declare function HorizontalRulePlugin(): null;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
9
+ import { $createHorizontalRuleNode, INSERT_HORIZONTAL_RULE_COMMAND } from '@lexical/react/LexicalHorizontalRuleNode';
10
+ import { $insertNodeToNearestRoot } from '@lexical/utils';
11
+ import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from 'lexical';
12
+ import { useEffect } from 'react';
13
+ export function HorizontalRulePlugin() {
14
+ const [editor] = useLexicalComposerContext();
15
+ useEffect(() => {
16
+ return editor.registerCommand(INSERT_HORIZONTAL_RULE_COMMAND, (type) => {
17
+ const selection = $getSelection();
18
+ if (!$isRangeSelection(selection)) {
19
+ return false;
20
+ }
21
+ const focusNode = selection.focus.getNode();
22
+ if (focusNode !== null) {
23
+ const horizontalRuleNode = $createHorizontalRuleNode();
24
+ $insertNodeToNearestRoot(horizontalRuleNode);
25
+ }
26
+ return true;
27
+ }, COMMAND_PRIORITY_EDITOR);
28
+ }, [editor]);
29
+ return null;
30
+ }
@@ -1,6 +1,6 @@
1
1
  import { ErrorBoundaryType } from '../shared/useDecorators';
2
2
  export declare function RichTextPlugin({ contentEditable, placeholder, ErrorBoundary }: {
3
3
  contentEditable: JSX.Element;
4
- placeholder: ((isEditable: boolean) => null | JSX.Element) | null | JSX.Element;
5
- ErrorBoundary: ErrorBoundaryType;
4
+ placeholder?: ((isEditable: boolean) => null | JSX.Element) | null | JSX.Element;
5
+ ErrorBoundary?: ErrorBoundaryType;
6
6
  }): JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
3
- import useLexicalEditable from '@lexical/react/useLexicalEditable';
3
+ import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
4
4
  import { useDecorators } from '../shared/useDecorators';
5
5
  import { useEditorFocus } from '../shared/useEditorFocus';
6
6
  import { useCanShowPlaceholder } from '../shared/useCanShowPlaceholder';
@@ -1,6 +1,6 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { useState } from 'react';
3
+ import { useEffect, useState } from 'react';
4
4
  import { styled } from '@mui/material/styles';
5
5
  import { useThemeProps } from '@mui/system';
6
6
  import classNames from 'classnames';
@@ -65,7 +65,7 @@ export default function LessonReleaseMenu(inProps) {
65
65
  // CONTEXT
66
66
  const scContext = useSCContext();
67
67
  // STATE
68
- const [drippedAt, setDrippedAt] = useState((section === null || section === void 0 ? void 0 : section.dripped_at) ? new Date(section === null || section === void 0 ? void 0 : section.dripped_at) : null);
68
+ const [drippedAt, setDrippedAt] = useState(null);
69
69
  const { delay, _unit } = getDripDelayAndUnit((section === null || section === void 0 ? void 0 : section.drip_delay) || 0);
70
70
  const [dripDelay, setDripDelay] = useState(delay);
71
71
  const [unit, setUnit] = useState(_unit);
@@ -78,6 +78,20 @@ export default function LessonReleaseMenu(inProps) {
78
78
  const handleUnitChange = (e) => {
79
79
  setUnit(e.target.value);
80
80
  };
81
+ // EFFECTS
82
+ useEffect(() => {
83
+ if (section && section.dripped_at) {
84
+ setDrippedAt(new Date(section.dripped_at));
85
+ }
86
+ else {
87
+ setDrippedAt(null);
88
+ }
89
+ }, [section, setDrippedAt]);
90
+ useEffect(() => {
91
+ if (section) {
92
+ setDripDelay(delay);
93
+ }
94
+ }, [section, setDripDelay]);
81
95
  // HANDLERS
82
96
  const handleClick = (event) => {
83
97
  setAnchorEl(event.currentTarget);
@@ -123,7 +137,7 @@ export default function LessonReleaseMenu(inProps) {
123
137
  okButtonLabel: `${intl.formatMessage(messages.pickerOkMessage)}`,
124
138
  cancelButtonLabel: `${intl.formatMessage(messages.pickerCancelMessage)}`,
125
139
  clearButtonLabel: `${intl.formatMessage(messages.pickerClearMessage)}`
126
- } }, { children: _jsx(MobileDateTimePicker, { className: classes.picker, disablePast: true, label: drippedAt && (_jsx(FormattedMessage, { id: "ui.lessonReleaseMenu.scheduled.picker.placeholder", defaultMessage: "ui.lessonReleaseMenu.scheduled.picker.placeholder" })), defaultValue: drippedAt, slots: {
140
+ } }, { children: _jsx(MobileDateTimePicker, { className: classes.picker, disablePast: true, label: drippedAt && (_jsx(FormattedMessage, { id: "ui.lessonReleaseMenu.scheduled.picker.placeholder", defaultMessage: "ui.lessonReleaseMenu.scheduled.picker.placeholder" })), value: drippedAt, slots: {
127
141
  //actionBar: PickerActionBar,
128
142
  tabs: (props) => _jsx(DateTimePickerTabs, Object.assign({}, props)),
129
143
  textField: (params) => (_jsx(TextField, Object.assign({}, params, { error: false, InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.pickerPlaceholder)}`, endAdornment: (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: _jsx(IconButton, Object.assign({ disabled: isDisabled }, { children: _jsx(Icon, { children: "expand_more" }) })) }))) }) })))
@@ -139,7 +153,7 @@ export default function LessonReleaseMenu(inProps) {
139
153
  actionBar: {
140
154
  actions: ['cancel', 'clear', 'accept']
141
155
  }
142
- }, onChange: (value) => setDrippedAt(value), onAccept: handleUpdate, onClear: () => setDrippedAt(null), disabled: isDisabled }) }))) : (_jsxs(_Fragment, { children: [_jsx(TextField, { size: "small", placeholder: placeholderStructured, defaultValue: null, onClick: isDisabled ? undefined : handleClick, InputProps: {
156
+ }, onChange: (value) => setDrippedAt(value), onAccept: handleUpdate, onClear: () => setDrippedAt(null), disabled: isDisabled }) }))) : (_jsxs(_Fragment, { children: [_jsx(TextField, { size: "small", value: placeholderStructured, onClick: isDisabled ? undefined : handleClick, InputProps: {
143
157
  endAdornment: (_jsx(InputAdornment, Object.assign({ position: "end" }, { children: _jsx(IconButton, Object.assign({ onClick: handleClick, disabled: isDisabled }, { children: _jsx(Icon, { children: "expand_more" }) })) })))
144
158
  }, disabled: isDisabled }), _jsxs(PopoverRoot, Object.assign({ className: classes.popoverRoot, open: open, anchorEl: anchorEl, onClose: handleClose, anchorOrigin: {
145
159
  vertical: 'bottom',
@@ -1 +1,2 @@
1
+ export declare const DEFAULT_COUNTERS_LIMIT = 3;
1
2
  export declare function numberFormatter(num: number): JSX.Element;
@@ -1,10 +1,11 @@
1
1
  import { Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export const DEFAULT_COUNTERS_LIMIT = 3;
2
3
  export function numberFormatter(num) {
3
- const surplus = num - 3;
4
+ const surplus = num === DEFAULT_COUNTERS_LIMIT ? 1 : num < DEFAULT_COUNTERS_LIMIT ? num : num - DEFAULT_COUNTERS_LIMIT;
4
5
  if (surplus > 999999) {
5
6
  return _jsxs(_Fragment, { children: ["+", (Math.abs(surplus) / 1000000).toFixed(1), "M"] });
6
7
  }
7
- else if (num > 999) {
8
+ else if (surplus > 999) {
8
9
  return _jsxs(_Fragment, { children: ["+", (Math.abs(surplus) / 1000).toFixed(1), "K"] });
9
10
  }
10
11
  return _jsxs(_Fragment, { children: ["+", surplus] });