@selfcommunity/react-ui 1.0.4-alpha.1 → 1.1.0-alpha.0
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/CategoryHeader/CategoryHeader.js +3 -1
- package/lib/cjs/components/HtmlInfoDialog/HtmlInfoDialog.d.ts +27 -0
- package/lib/cjs/components/HtmlInfoDialog/HtmlInfoDialog.js +26 -0
- package/lib/cjs/components/HtmlInfoDialog/constants.d.ts +1 -0
- package/lib/cjs/components/HtmlInfoDialog/constants.js +4 -0
- package/lib/cjs/components/HtmlInfoDialog/index.d.ts +3 -0
- package/lib/cjs/components/HtmlInfoDialog/index.js +5 -0
- package/lib/esm/components/CategoryHeader/CategoryHeader.js +5 -3
- package/lib/esm/components/HtmlInfoDialog/HtmlInfoDialog.d.ts +27 -0
- package/lib/esm/components/HtmlInfoDialog/HtmlInfoDialog.js +23 -0
- package/lib/esm/components/HtmlInfoDialog/constants.d.ts +1 -0
- package/lib/esm/components/HtmlInfoDialog/constants.js +1 -0
- package/lib/esm/components/HtmlInfoDialog/index.d.ts +3 -0
- package/lib/esm/components/HtmlInfoDialog/index.js +2 -0
- package/lib/umd/react-ui.js +1 -1
- package/package.json +8 -8
|
@@ -14,6 +14,7 @@ const CategoryFollowersButton_1 = tslib_1.__importDefault(require("../CategoryFo
|
|
|
14
14
|
const constants_1 = require("./constants");
|
|
15
15
|
const BuyButton_1 = tslib_1.__importDefault(require("../BuyButton"));
|
|
16
16
|
const TagChip_1 = tslib_1.__importDefault(require("../../shared/TagChip"));
|
|
17
|
+
const HtmlInfoDialog_1 = tslib_1.__importDefault(require("../HtmlInfoDialog"));
|
|
17
18
|
const classes = {
|
|
18
19
|
root: `${constants_1.PREFIX}-root`,
|
|
19
20
|
cover: `${constants_1.PREFIX}-cover`,
|
|
@@ -71,6 +72,7 @@ function CategoryHeader(inProps) {
|
|
|
71
72
|
// STATE
|
|
72
73
|
const { scCategory, setSCCategory } = (0, react_core_1.useSCFetchCategory)({ id: categoryId, category });
|
|
73
74
|
const categoryFollowEnabled = (0, react_core_1.useSCPreferenceEnabled)(react_core_1.SCPreferences.CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED);
|
|
75
|
+
const [openHtmlInfoDialog, setOpenHtmlInfoDialog] = (0, react_1.useState)(false);
|
|
74
76
|
// PAYMENTS
|
|
75
77
|
const { isPaymentsEnabled } = (0, react_core_1.useSCPaymentsEnabled)();
|
|
76
78
|
/**
|
|
@@ -84,6 +86,6 @@ function CategoryHeader(inProps) {
|
|
|
84
86
|
if (!scCategory) {
|
|
85
87
|
return null;
|
|
86
88
|
}
|
|
87
|
-
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: [(0, jsx_runtime_1.jsx)(material_1.Paper, { style: _backgroundCover, classes: { root: classes.cover } }), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.info }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3", className: classes.name, gutterBottom: true }, { children: scCategory.name })), scCategory.slogan && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.slogan }, { children: scCategory.slogan }))), showTags && ((_a = scCategory.tags) === null || _a === void 0 ? void 0 : _a.length) > 0 && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.tags }, { children: scCategory.tags.map((t) => ((0, jsx_runtime_1.jsx)(TagChip_1.default, { tag: t, disposable: false, clickable: false }, t.id))) }))), categoryFollowEnabled && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.followed }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.followedCounter, component: "div" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.categoryHeader.followedBy", defaultMessage: "ui.categoryHeader.followedBy", values: { total: scCategory.followers_counter } }) })), (0, jsx_runtime_1.jsx)(CategoryFollowersButton_1.default, Object.assign({ category: scCategory, categoryId: scCategory === null || scCategory === void 0 ? void 0 : scCategory.id }, CategoryFollowersButtonProps))] }))), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.action }, { children: [isPaymentsEnabled && ((_b = scCategory.paywalls) === null || _b === void 0 ? void 0 : _b.length) > 0 && scCategory.payment_order && ((0, jsx_runtime_1.jsx)(BuyButton_1.default, { contentType: types_1.SCContentType.CATEGORY, content: scCategory })), (0, jsx_runtime_1.jsx)(CategoryFollowButton_1.default, Object.assign({ category: scCategory, onFollow: handleFollow }, CategoryFollowButtonProps))] }))] }))] })));
|
|
89
|
+
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: [(0, jsx_runtime_1.jsx)(material_1.Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: scCategory.html_info && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "contained", onClick: () => setOpenHtmlInfoDialog(true) }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "info" }) }))) })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.info }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h3", className: classes.name, gutterBottom: true }, { children: scCategory.name })), scCategory.slogan && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.slogan }, { children: scCategory.slogan }))), showTags && ((_a = scCategory.tags) === null || _a === void 0 ? void 0 : _a.length) > 0 && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.tags }, { children: scCategory.tags.map((t) => ((0, jsx_runtime_1.jsx)(TagChip_1.default, { tag: t, disposable: false, clickable: false }, t.id))) }))), categoryFollowEnabled && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.followed }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.followedCounter, component: "div" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.categoryHeader.followedBy", defaultMessage: "ui.categoryHeader.followedBy", values: { total: scCategory.followers_counter } }) })), (0, jsx_runtime_1.jsx)(CategoryFollowersButton_1.default, Object.assign({ category: scCategory, categoryId: scCategory === null || scCategory === void 0 ? void 0 : scCategory.id }, CategoryFollowersButtonProps))] }))), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.action }, { children: [isPaymentsEnabled && ((_b = scCategory.paywalls) === null || _b === void 0 ? void 0 : _b.length) > 0 && scCategory.payment_order && ((0, jsx_runtime_1.jsx)(BuyButton_1.default, { contentType: types_1.SCContentType.CATEGORY, content: scCategory })), (0, jsx_runtime_1.jsx)(CategoryFollowButton_1.default, Object.assign({ category: scCategory, onFollow: handleFollow }, CategoryFollowButtonProps))] }))] })), openHtmlInfoDialog && (0, jsx_runtime_1.jsx)(HtmlInfoDialog_1.default, { open: true, htmlInfo: category.html_info, onClose: () => setOpenHtmlInfoDialog(false) })] })));
|
|
88
90
|
}
|
|
89
91
|
exports.default = CategoryHeader;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseDialogProps } from '../../shared/BaseDialog';
|
|
2
|
+
export interface HtmlInfoDialogProps extends BaseDialogProps {
|
|
3
|
+
/**
|
|
4
|
+
* The category's html text.
|
|
5
|
+
*/
|
|
6
|
+
htmlInfo: string;
|
|
7
|
+
/**
|
|
8
|
+
* Overrides or extends the styles applied to the component.
|
|
9
|
+
* @default undefined
|
|
10
|
+
*/
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Open dialog
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
open?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* On dialog close callback function
|
|
19
|
+
* @default undefined
|
|
20
|
+
*/
|
|
21
|
+
onClose?: () => void;
|
|
22
|
+
/**
|
|
23
|
+
* Any other properties
|
|
24
|
+
*/
|
|
25
|
+
[p: string]: any;
|
|
26
|
+
}
|
|
27
|
+
export default function HtmlInfoDialog(inProps: HtmlInfoDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const material_1 = require("@mui/material");
|
|
6
|
+
const BaseDialog_1 = tslib_1.__importDefault(require("../../shared/BaseDialog"));
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
const react_intl_1 = require("react-intl");
|
|
9
|
+
const Root = (0, material_1.styled)(BaseDialog_1.default, {
|
|
10
|
+
name: constants_1.PREFIX,
|
|
11
|
+
slot: 'Root'
|
|
12
|
+
})(() => ({}));
|
|
13
|
+
function HtmlInfoDialog(inProps) {
|
|
14
|
+
//PROPS
|
|
15
|
+
const props = (0, material_1.useThemeProps)({
|
|
16
|
+
props: inProps,
|
|
17
|
+
name: constants_1.PREFIX
|
|
18
|
+
});
|
|
19
|
+
const { htmlInfo, className, open = false, onClose } = props, rest = tslib_1.__rest(props, ["htmlInfo", "className", "open", "onClose"]);
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ DialogContentProps: { dividers: false }, maxWidth: "md", title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.categoryHeader.htmlInfo.dialog.title", defaultMessage: "ui.categoryHeader.htmlInfo.dialog.title" }), fullWidth: true, open: open, scroll: "body", onClose: onClose, className: className, slotProps: {
|
|
21
|
+
paper: {
|
|
22
|
+
elevation: 0
|
|
23
|
+
}
|
|
24
|
+
} }, rest, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { dangerouslySetInnerHTML: { __html: htmlInfo } }) })));
|
|
25
|
+
}
|
|
26
|
+
exports.default = HtmlInfoDialog;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCHtmlInfoDialog";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
|
-
import { Box, Paper, Typography, styled } from '@mui/material';
|
|
3
|
+
import { useMemo, useState } from 'react';
|
|
4
|
+
import { Box, Button, Icon, Paper, Typography, styled } from '@mui/material';
|
|
5
5
|
import CategoryFollowButton from '../CategoryFollowButton';
|
|
6
6
|
import { FormattedMessage } from 'react-intl';
|
|
7
7
|
import { SCPreferences, useSCFetchCategory, useSCPaymentsEnabled, useSCPreferenceEnabled } from '@selfcommunity/react-core';
|
|
@@ -12,6 +12,7 @@ import CategoryFollowersButton from '../CategoryFollowersButton';
|
|
|
12
12
|
import { PREFIX } from './constants';
|
|
13
13
|
import BuyButton from '../BuyButton';
|
|
14
14
|
import TagChip from '../../shared/TagChip';
|
|
15
|
+
import HtmlInfoDialog from '../HtmlInfoDialog';
|
|
15
16
|
const classes = {
|
|
16
17
|
root: `${PREFIX}-root`,
|
|
17
18
|
cover: `${PREFIX}-cover`,
|
|
@@ -69,6 +70,7 @@ export default function CategoryHeader(inProps) {
|
|
|
69
70
|
// STATE
|
|
70
71
|
const { scCategory, setSCCategory } = useSCFetchCategory({ id: categoryId, category });
|
|
71
72
|
const categoryFollowEnabled = useSCPreferenceEnabled(SCPreferences.CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED);
|
|
73
|
+
const [openHtmlInfoDialog, setOpenHtmlInfoDialog] = useState(false);
|
|
72
74
|
// PAYMENTS
|
|
73
75
|
const { isPaymentsEnabled } = useSCPaymentsEnabled();
|
|
74
76
|
/**
|
|
@@ -82,5 +84,5 @@ export default function CategoryHeader(inProps) {
|
|
|
82
84
|
if (!scCategory) {
|
|
83
85
|
return null;
|
|
84
86
|
}
|
|
85
|
-
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: [_jsx(Paper, { style: _backgroundCover, classes: { root: classes.cover } }), _jsxs(Box, Object.assign({ className: classes.info }, { children: [_jsx(Typography, Object.assign({ variant: "h3", className: classes.name, gutterBottom: true }, { children: scCategory.name })), scCategory.slogan && (_jsx(Typography, Object.assign({ variant: "h5", className: classes.slogan }, { children: scCategory.slogan }))), showTags && ((_a = scCategory.tags) === null || _a === void 0 ? void 0 : _a.length) > 0 && (_jsx(Box, Object.assign({ className: classes.tags }, { children: scCategory.tags.map((t) => (_jsx(TagChip, { tag: t, disposable: false, clickable: false }, t.id))) }))), categoryFollowEnabled && (_jsxs(Box, Object.assign({ className: classes.followed }, { children: [_jsx(Typography, Object.assign({ className: classes.followedCounter, component: "div" }, { children: _jsx(FormattedMessage, { id: "ui.categoryHeader.followedBy", defaultMessage: "ui.categoryHeader.followedBy", values: { total: scCategory.followers_counter } }) })), _jsx(CategoryFollowersButton, Object.assign({ category: scCategory, categoryId: scCategory === null || scCategory === void 0 ? void 0 : scCategory.id }, CategoryFollowersButtonProps))] }))), _jsxs(Box, Object.assign({ className: classes.action }, { children: [isPaymentsEnabled && ((_b = scCategory.paywalls) === null || _b === void 0 ? void 0 : _b.length) > 0 && scCategory.payment_order && (_jsx(BuyButton, { contentType: SCContentType.CATEGORY, content: scCategory })), _jsx(CategoryFollowButton, Object.assign({ category: scCategory, onFollow: handleFollow }, CategoryFollowButtonProps))] }))] }))] })));
|
|
87
|
+
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { children: [_jsx(Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: scCategory.html_info && (_jsx(Button, Object.assign({ variant: "contained", onClick: () => setOpenHtmlInfoDialog(true) }, { children: _jsx(Icon, { children: "info" }) }))) })), _jsxs(Box, Object.assign({ className: classes.info }, { children: [_jsx(Typography, Object.assign({ variant: "h3", className: classes.name, gutterBottom: true }, { children: scCategory.name })), scCategory.slogan && (_jsx(Typography, Object.assign({ variant: "h5", className: classes.slogan }, { children: scCategory.slogan }))), showTags && ((_a = scCategory.tags) === null || _a === void 0 ? void 0 : _a.length) > 0 && (_jsx(Box, Object.assign({ className: classes.tags }, { children: scCategory.tags.map((t) => (_jsx(TagChip, { tag: t, disposable: false, clickable: false }, t.id))) }))), categoryFollowEnabled && (_jsxs(Box, Object.assign({ className: classes.followed }, { children: [_jsx(Typography, Object.assign({ className: classes.followedCounter, component: "div" }, { children: _jsx(FormattedMessage, { id: "ui.categoryHeader.followedBy", defaultMessage: "ui.categoryHeader.followedBy", values: { total: scCategory.followers_counter } }) })), _jsx(CategoryFollowersButton, Object.assign({ category: scCategory, categoryId: scCategory === null || scCategory === void 0 ? void 0 : scCategory.id }, CategoryFollowersButtonProps))] }))), _jsxs(Box, Object.assign({ className: classes.action }, { children: [isPaymentsEnabled && ((_b = scCategory.paywalls) === null || _b === void 0 ? void 0 : _b.length) > 0 && scCategory.payment_order && (_jsx(BuyButton, { contentType: SCContentType.CATEGORY, content: scCategory })), _jsx(CategoryFollowButton, Object.assign({ category: scCategory, onFollow: handleFollow }, CategoryFollowButtonProps))] }))] })), openHtmlInfoDialog && _jsx(HtmlInfoDialog, { open: true, htmlInfo: category.html_info, onClose: () => setOpenHtmlInfoDialog(false) })] })));
|
|
86
88
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseDialogProps } from '../../shared/BaseDialog';
|
|
2
|
+
export interface HtmlInfoDialogProps extends BaseDialogProps {
|
|
3
|
+
/**
|
|
4
|
+
* The category's html text.
|
|
5
|
+
*/
|
|
6
|
+
htmlInfo: string;
|
|
7
|
+
/**
|
|
8
|
+
* Overrides or extends the styles applied to the component.
|
|
9
|
+
* @default undefined
|
|
10
|
+
*/
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Open dialog
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
open?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* On dialog close callback function
|
|
19
|
+
* @default undefined
|
|
20
|
+
*/
|
|
21
|
+
onClose?: () => void;
|
|
22
|
+
/**
|
|
23
|
+
* Any other properties
|
|
24
|
+
*/
|
|
25
|
+
[p: string]: any;
|
|
26
|
+
}
|
|
27
|
+
export default function HtmlInfoDialog(inProps: HtmlInfoDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Box, styled, useThemeProps } from '@mui/material';
|
|
4
|
+
import BaseDialog from '../../shared/BaseDialog';
|
|
5
|
+
import { PREFIX } from './constants';
|
|
6
|
+
import { FormattedMessage } from 'react-intl';
|
|
7
|
+
const Root = styled(BaseDialog, {
|
|
8
|
+
name: PREFIX,
|
|
9
|
+
slot: 'Root'
|
|
10
|
+
})(() => ({}));
|
|
11
|
+
export default function HtmlInfoDialog(inProps) {
|
|
12
|
+
//PROPS
|
|
13
|
+
const props = useThemeProps({
|
|
14
|
+
props: inProps,
|
|
15
|
+
name: PREFIX
|
|
16
|
+
});
|
|
17
|
+
const { htmlInfo, className, open = false, onClose } = props, rest = __rest(props, ["htmlInfo", "className", "open", "onClose"]);
|
|
18
|
+
return (_jsx(Root, Object.assign({ DialogContentProps: { dividers: false }, maxWidth: "md", title: _jsx(FormattedMessage, { id: "ui.categoryHeader.htmlInfo.dialog.title", defaultMessage: "ui.categoryHeader.htmlInfo.dialog.title" }), fullWidth: true, open: open, scroll: "body", onClose: onClose, className: className, slotProps: {
|
|
19
|
+
paper: {
|
|
20
|
+
elevation: 0
|
|
21
|
+
}
|
|
22
|
+
} }, rest, { children: _jsx(Box, { dangerouslySetInnerHTML: { __html: htmlInfo } }) })));
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCHtmlInfoDialog";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const PREFIX = 'SCHtmlInfoDialog';
|