@selfcommunity/react-ui 0.7.36-alpha.0 → 0.7.36-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/Category/Category.js +8 -2
- package/lib/cjs/components/Group/Group.js +5 -8
- package/lib/cjs/constants/Category.d.ts +2 -0
- package/lib/cjs/constants/Category.js +5 -0
- package/lib/cjs/constants/Group.d.ts +2 -0
- package/lib/cjs/constants/Group.js +3 -1
- package/lib/cjs/utils/string.d.ts +1 -0
- package/lib/cjs/utils/string.js +10 -0
- package/lib/esm/components/Category/Category.js +9 -3
- package/lib/esm/components/Group/Group.js +5 -8
- package/lib/esm/constants/Category.d.ts +2 -0
- package/lib/esm/constants/Category.js +2 -0
- package/lib/esm/constants/Group.d.ts +2 -0
- package/lib/esm/constants/Group.js +2 -0
- package/lib/esm/utils/string.d.ts +1 -0
- package/lib/esm/utils/string.js +6 -0
- package/lib/umd/react-ui.js +1 -1
- package/package.json +2 -2
|
@@ -12,6 +12,8 @@ const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
|
12
12
|
const system_1 = require("@mui/system");
|
|
13
13
|
const BaseItemButton_1 = tslib_1.__importDefault(require("../../shared/BaseItemButton"));
|
|
14
14
|
const constants_1 = require("./constants");
|
|
15
|
+
const string_1 = require("../../utils/string");
|
|
16
|
+
const Category_1 = require("../../constants/Category");
|
|
15
17
|
const messages = (0, react_intl_1.defineMessages)({
|
|
16
18
|
categoryFollowers: {
|
|
17
19
|
id: 'ui.category.categoryFollowers',
|
|
@@ -66,14 +68,18 @@ function Category(inProps) {
|
|
|
66
68
|
const { scCategory, setSCCategory } = (0, react_core_1.useSCFetchCategory)({ id: categoryId, category });
|
|
67
69
|
// MEMO
|
|
68
70
|
const _ButtonBaseProps = (0, react_1.useMemo)(() => (ButtonBaseProps ? ButtonBaseProps : { component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.CATEGORY_ROUTE_NAME, scCategory) }), [ButtonBaseProps, scRoutingContext, scCategory]);
|
|
69
|
-
//
|
|
71
|
+
// HOOKS
|
|
70
72
|
const intl = (0, react_intl_1.useIntl)();
|
|
73
|
+
const theme = (0, material_1.useTheme)();
|
|
74
|
+
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
71
75
|
if (!scCategory) {
|
|
72
76
|
return react_1.default.createElement(Skeleton_1.default, { elevation: elevation });
|
|
73
77
|
}
|
|
74
78
|
// RENDER
|
|
75
79
|
if (!autoHide) {
|
|
76
|
-
return (react_1.default.createElement(Root, Object.assign({ elevation: elevation, className: (0, classnames_1.default)(classes.root, className), ButtonBaseProps: _ButtonBaseProps, image: react_1.default.createElement(material_1.Avatar, { alt: scCategory.name, src: scCategory.image_medium, variant: "square", className: classes.categoryImage }), primary:
|
|
80
|
+
return (react_1.default.createElement(Root, Object.assign({ elevation: elevation, className: (0, classnames_1.default)(classes.root, className), ButtonBaseProps: _ButtonBaseProps, image: react_1.default.createElement(material_1.Avatar, { alt: scCategory.name, src: scCategory.image_medium, variant: "square", className: classes.categoryImage }), primary: isMobile
|
|
81
|
+
? (0, string_1.formatCroppedName)(scCategory.name, Category_1.CATEGORY_NAME_MAX_LENGTH_MOBILE)
|
|
82
|
+
: (0, string_1.formatCroppedName)(scCategory.name, Category_1.CATEGORY_NAME_MAX_LENGTH_DESKTOP), secondary: showFollowers ? `${intl.formatMessage(messages.categoryFollowers, { total: scCategory.followers_counter })}` : scCategory.slogan, actions: react_1.default.createElement(CategoryFollowButton_1.default, Object.assign({ category: scCategory }, categoryFollowButtonProps)) }, rest)));
|
|
77
83
|
}
|
|
78
84
|
return null;
|
|
79
85
|
}
|
|
@@ -14,6 +14,8 @@ const UserDeletedSnackBar_1 = tslib_1.__importDefault(require("../../shared/User
|
|
|
14
14
|
const constants_1 = require("./constants");
|
|
15
15
|
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
16
16
|
const GroupSubscribeButton_1 = tslib_1.__importDefault(require("../GroupSubscribeButton"));
|
|
17
|
+
const string_1 = require("../../utils/string");
|
|
18
|
+
const Group_1 = require("../../constants/Group");
|
|
17
19
|
const messages = (0, react_intl_1.defineMessages)({
|
|
18
20
|
groupMembers: {
|
|
19
21
|
id: 'ui.group.members',
|
|
@@ -82,13 +84,6 @@ function Group(inProps) {
|
|
|
82
84
|
const intl = (0, react_intl_1.useIntl)();
|
|
83
85
|
const theme = (0, material_1.useTheme)();
|
|
84
86
|
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
85
|
-
// HELPERS
|
|
86
|
-
const formatGroupName = (name, maxLength) => {
|
|
87
|
-
if (name.length <= maxLength) {
|
|
88
|
-
return name;
|
|
89
|
-
}
|
|
90
|
-
return name.substring(0, maxLength) + '...';
|
|
91
|
-
};
|
|
92
87
|
/**
|
|
93
88
|
* Render authenticated actions
|
|
94
89
|
* @return {JSX.Element}
|
|
@@ -109,7 +104,9 @@ function Group(inProps) {
|
|
|
109
104
|
*/
|
|
110
105
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
111
106
|
react_1.default.createElement(Root, Object.assign({ elevation: elevation }, rest, { className: (0, classnames_1.default)(classes.root, className), ButtonBaseProps: { component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, scGroup) }, image: react_1.default.createElement(material_1.Avatar, { alt: scGroup.name, src: scGroup.image_medium, className: classes.avatar }), primary: react_1.default.createElement(react_1.default.Fragment, null,
|
|
112
|
-
isMobile
|
|
107
|
+
isMobile
|
|
108
|
+
? (0, string_1.formatCroppedName)(scGroup.name, Group_1.GROUP_NAME_MAX_LENGTH_MOBILE)
|
|
109
|
+
: (0, string_1.formatCroppedName)(scGroup.name, Group_1.GROUP_NAME_MAX_LENGTH_DESKTOP),
|
|
113
110
|
' ',
|
|
114
111
|
react_1.default.createElement(material_1.Icon, { className: classes.icon }, (group === null || group === void 0 ? void 0 : group.privacy) === types_1.SCGroupPrivacyType.PRIVATE ? 'private' : 'public')), secondary: `${intl.formatMessage(messages.groupMembers, { total: scGroup.subscribers_counter })}`, actions: hideActions ? null : renderAuthenticatedActions() })),
|
|
115
112
|
openAlert && react_1.default.createElement(UserDeletedSnackBar_1.default, { open: openAlert, handleClose: () => setOpenAlert(false) })));
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GROUP_DESCRIPTION_MAX_LENGTH = exports.GROUP_TITLE_MAX_LENGTH = void 0;
|
|
3
|
+
exports.GROUP_NAME_MAX_LENGTH_DESKTOP = exports.GROUP_NAME_MAX_LENGTH_MOBILE = exports.GROUP_DESCRIPTION_MAX_LENGTH = exports.GROUP_TITLE_MAX_LENGTH = void 0;
|
|
4
4
|
exports.GROUP_TITLE_MAX_LENGTH = 40;
|
|
5
5
|
exports.GROUP_DESCRIPTION_MAX_LENGTH = 500;
|
|
6
|
+
exports.GROUP_NAME_MAX_LENGTH_MOBILE = 15;
|
|
7
|
+
exports.GROUP_NAME_MAX_LENGTH_DESKTOP = 20;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const formatCroppedName: (name: any, maxLength: any) => any;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatCroppedName = void 0;
|
|
4
|
+
const formatCroppedName = (name, maxLength) => {
|
|
5
|
+
if (name.length <= maxLength) {
|
|
6
|
+
return name;
|
|
7
|
+
}
|
|
8
|
+
return name.substring(0, maxLength) + '...';
|
|
9
|
+
};
|
|
10
|
+
exports.formatCroppedName = formatCroppedName;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React, { useMemo } from 'react';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
|
-
import { Avatar } from '@mui/material';
|
|
4
|
+
import { Avatar, useMediaQuery, useTheme } from '@mui/material';
|
|
5
5
|
import { Link, SCRoutes, useSCFetchCategory, useSCRouting } from '@selfcommunity/react-core';
|
|
6
6
|
import CategorySkeleton from './Skeleton';
|
|
7
7
|
import CategoryFollowButton from '../CategoryFollowButton';
|
|
@@ -10,6 +10,8 @@ import classNames from 'classnames';
|
|
|
10
10
|
import { useThemeProps } from '@mui/system';
|
|
11
11
|
import BaseItemButton from '../../shared/BaseItemButton';
|
|
12
12
|
import { PREFIX } from './constants';
|
|
13
|
+
import { formatCroppedName } from '../../utils/string';
|
|
14
|
+
import { CATEGORY_NAME_MAX_LENGTH_DESKTOP, CATEGORY_NAME_MAX_LENGTH_MOBILE } from '../../constants/Category';
|
|
13
15
|
const messages = defineMessages({
|
|
14
16
|
categoryFollowers: {
|
|
15
17
|
id: 'ui.category.categoryFollowers',
|
|
@@ -64,14 +66,18 @@ export default function Category(inProps) {
|
|
|
64
66
|
const { scCategory, setSCCategory } = useSCFetchCategory({ id: categoryId, category });
|
|
65
67
|
// MEMO
|
|
66
68
|
const _ButtonBaseProps = useMemo(() => (ButtonBaseProps ? ButtonBaseProps : { component: Link, to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, scCategory) }), [ButtonBaseProps, scRoutingContext, scCategory]);
|
|
67
|
-
//
|
|
69
|
+
// HOOKS
|
|
68
70
|
const intl = useIntl();
|
|
71
|
+
const theme = useTheme();
|
|
72
|
+
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
69
73
|
if (!scCategory) {
|
|
70
74
|
return React.createElement(CategorySkeleton, { elevation: elevation });
|
|
71
75
|
}
|
|
72
76
|
// RENDER
|
|
73
77
|
if (!autoHide) {
|
|
74
|
-
return (React.createElement(Root, Object.assign({ elevation: elevation, className: classNames(classes.root, className), ButtonBaseProps: _ButtonBaseProps, image: React.createElement(Avatar, { alt: scCategory.name, src: scCategory.image_medium, variant: "square", className: classes.categoryImage }), primary:
|
|
78
|
+
return (React.createElement(Root, Object.assign({ elevation: elevation, className: classNames(classes.root, className), ButtonBaseProps: _ButtonBaseProps, image: React.createElement(Avatar, { alt: scCategory.name, src: scCategory.image_medium, variant: "square", className: classes.categoryImage }), primary: isMobile
|
|
79
|
+
? formatCroppedName(scCategory.name, CATEGORY_NAME_MAX_LENGTH_MOBILE)
|
|
80
|
+
: formatCroppedName(scCategory.name, CATEGORY_NAME_MAX_LENGTH_DESKTOP), secondary: showFollowers ? `${intl.formatMessage(messages.categoryFollowers, { total: scCategory.followers_counter })}` : scCategory.slogan, actions: React.createElement(CategoryFollowButton, Object.assign({ category: scCategory }, categoryFollowButtonProps)) }, rest)));
|
|
75
81
|
}
|
|
76
82
|
return null;
|
|
77
83
|
}
|
|
@@ -12,6 +12,8 @@ import UserDeletedSnackBar from '../../shared/UserDeletedSnackBar';
|
|
|
12
12
|
import { PREFIX } from './constants';
|
|
13
13
|
import GroupSkeleton from './Skeleton';
|
|
14
14
|
import GroupSubscribeButton from '../GroupSubscribeButton';
|
|
15
|
+
import { formatCroppedName } from '../../utils/string';
|
|
16
|
+
import { GROUP_NAME_MAX_LENGTH_DESKTOP, GROUP_NAME_MAX_LENGTH_MOBILE } from '../../constants/Group';
|
|
15
17
|
const messages = defineMessages({
|
|
16
18
|
groupMembers: {
|
|
17
19
|
id: 'ui.group.members',
|
|
@@ -80,13 +82,6 @@ export default function Group(inProps) {
|
|
|
80
82
|
const intl = useIntl();
|
|
81
83
|
const theme = useTheme();
|
|
82
84
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
83
|
-
// HELPERS
|
|
84
|
-
const formatGroupName = (name, maxLength) => {
|
|
85
|
-
if (name.length <= maxLength) {
|
|
86
|
-
return name;
|
|
87
|
-
}
|
|
88
|
-
return name.substring(0, maxLength) + '...';
|
|
89
|
-
};
|
|
90
85
|
/**
|
|
91
86
|
* Render authenticated actions
|
|
92
87
|
* @return {JSX.Element}
|
|
@@ -107,7 +102,9 @@ export default function Group(inProps) {
|
|
|
107
102
|
*/
|
|
108
103
|
return (React.createElement(React.Fragment, null,
|
|
109
104
|
React.createElement(Root, Object.assign({ elevation: elevation }, rest, { className: classNames(classes.root, className), ButtonBaseProps: { component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, scGroup) }, image: React.createElement(Avatar, { alt: scGroup.name, src: scGroup.image_medium, className: classes.avatar }), primary: React.createElement(React.Fragment, null,
|
|
110
|
-
isMobile
|
|
105
|
+
isMobile
|
|
106
|
+
? formatCroppedName(scGroup.name, GROUP_NAME_MAX_LENGTH_MOBILE)
|
|
107
|
+
: formatCroppedName(scGroup.name, GROUP_NAME_MAX_LENGTH_DESKTOP),
|
|
111
108
|
' ',
|
|
112
109
|
React.createElement(Icon, { className: classes.icon }, (group === null || group === void 0 ? void 0 : group.privacy) === SCGroupPrivacyType.PRIVATE ? 'private' : 'public')), secondary: `${intl.formatMessage(messages.groupMembers, { total: scGroup.subscribers_counter })}`, actions: hideActions ? null : renderAuthenticatedActions() })),
|
|
113
110
|
openAlert && React.createElement(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const formatCroppedName: (name: any, maxLength: any) => any;
|