@selfcommunity/react-ui 0.7.9-alpha.2 → 0.7.9-alpha.4
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/BottomNavigation/BottomNavigation.js +3 -1
- package/lib/cjs/components/Composer/Attributes/Attributes.d.ts +1 -1
- package/lib/cjs/components/Composer/Attributes/Attributes.js +7 -0
- package/lib/cjs/components/Composer/Composer.d.ts +2 -1
- package/lib/cjs/components/Composer/Composer.js +40 -11
- package/lib/cjs/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +9 -2
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +35 -13
- package/lib/cjs/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
- package/lib/cjs/components/CreateGroupButton/CreateGroupButton.js +5 -6
- package/lib/cjs/components/CustomAdv/CustomAdv.d.ts +4 -0
- package/lib/cjs/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
- package/lib/cjs/components/EditGroupButton/EditGroupButton.js +57 -0
- package/lib/cjs/components/EditGroupButton/index.d.ts +3 -0
- package/lib/cjs/components/EditGroupButton/index.js +5 -0
- package/lib/cjs/components/Group/Group.d.ts +4 -3
- package/lib/cjs/components/Group/Group.js +2 -2
- package/lib/cjs/components/Group/Skeleton.js +1 -1
- package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
- package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +101 -0
- package/lib/cjs/components/GroupAutocomplete/index.d.ts +3 -0
- package/lib/cjs/components/GroupAutocomplete/index.js +5 -0
- package/lib/cjs/components/GroupForm/GroupForm.d.ts +70 -0
- package/lib/cjs/components/GroupForm/GroupForm.js +239 -0
- package/lib/cjs/components/GroupForm/constants.d.ts +1 -0
- package/lib/cjs/components/{CreateGroup → GroupForm}/constants.js +1 -1
- package/lib/cjs/components/GroupForm/index.d.ts +3 -0
- package/lib/cjs/components/GroupForm/index.js +5 -0
- package/lib/cjs/components/GroupHeader/GroupHeader.js +4 -2
- package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +8 -8
- package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +6 -4
- package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +19 -14
- package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +11 -1
- package/lib/cjs/components/Groups/Groups.d.ts +65 -0
- package/lib/cjs/components/Groups/Groups.js +181 -0
- package/lib/cjs/components/Groups/Skeleton.d.ts +34 -0
- package/lib/cjs/components/Groups/Skeleton.js +45 -0
- package/lib/cjs/components/Groups/constants.d.ts +1 -0
- package/lib/cjs/components/Groups/constants.js +4 -0
- package/lib/cjs/components/Groups/index.d.ts +4 -0
- package/lib/cjs/components/Groups/index.js +8 -0
- package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +5 -1
- package/lib/cjs/index.d.ts +5 -3
- package/lib/cjs/index.js +10 -4
- package/lib/esm/components/BottomNavigation/BottomNavigation.js +3 -1
- package/lib/esm/components/Composer/Attributes/Attributes.d.ts +1 -1
- package/lib/esm/components/Composer/Attributes/Attributes.js +7 -0
- package/lib/esm/components/Composer/Composer.d.ts +2 -1
- package/lib/esm/components/Composer/Composer.js +40 -11
- package/lib/esm/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +9 -2
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +34 -13
- package/lib/esm/components/CreateGroupButton/CreateGroupButton.d.ts +2 -2
- package/lib/esm/components/CreateGroupButton/CreateGroupButton.js +5 -6
- package/lib/esm/components/CustomAdv/CustomAdv.d.ts +4 -0
- package/lib/esm/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
- package/lib/esm/components/EditGroupButton/EditGroupButton.js +54 -0
- package/lib/esm/components/EditGroupButton/index.d.ts +3 -0
- package/lib/esm/components/EditGroupButton/index.js +2 -0
- package/lib/esm/components/Group/Group.d.ts +4 -3
- package/lib/esm/components/Group/Group.js +2 -2
- package/lib/esm/components/Group/Skeleton.js +1 -1
- package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
- package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +99 -0
- package/lib/esm/components/GroupAutocomplete/index.d.ts +3 -0
- package/lib/esm/components/GroupAutocomplete/index.js +2 -0
- package/lib/esm/components/GroupForm/GroupForm.d.ts +70 -0
- package/lib/esm/components/GroupForm/GroupForm.js +236 -0
- package/lib/esm/components/GroupForm/constants.d.ts +1 -0
- package/lib/esm/components/GroupForm/constants.js +1 -0
- package/lib/esm/components/GroupForm/index.d.ts +3 -0
- package/lib/esm/components/GroupForm/index.js +2 -0
- package/lib/esm/components/GroupHeader/GroupHeader.js +4 -2
- package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +8 -8
- package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +6 -4
- package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +20 -15
- package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +11 -1
- package/lib/esm/components/Groups/Groups.d.ts +65 -0
- package/lib/esm/components/Groups/Groups.js +178 -0
- package/lib/esm/components/Groups/Skeleton.d.ts +34 -0
- package/lib/esm/components/Groups/Skeleton.js +42 -0
- package/lib/esm/components/Groups/constants.d.ts +1 -0
- package/lib/esm/components/Groups/constants.js +1 -0
- package/lib/esm/components/Groups/index.d.ts +4 -0
- package/lib/esm/components/Groups/index.js +4 -0
- package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +5 -1
- package/lib/esm/index.d.ts +5 -3
- package/lib/esm/index.js +4 -2
- package/lib/umd/react-ui.js +1 -1
- package/package.json +6 -6
- package/lib/cjs/components/CreateGroup/CreateGroup.js +0 -187
- package/lib/cjs/components/CreateGroup/constants.d.ts +0 -1
- package/lib/cjs/components/CreateGroup/index.d.ts +0 -3
- package/lib/cjs/components/CreateGroup/index.js +0 -5
- package/lib/esm/components/CreateGroup/CreateGroup.js +0 -184
- package/lib/esm/components/CreateGroup/constants.d.ts +0 -1
- package/lib/esm/components/CreateGroup/constants.js +0 -1
- package/lib/esm/components/CreateGroup/index.d.ts +0 -3
- package/lib/esm/components/CreateGroup/index.js +0 -2
|
@@ -23,6 +23,12 @@ export default (props) => {
|
|
|
23
23
|
const handleClickCategory = useCallback(() => {
|
|
24
24
|
onClick && onClick('categories');
|
|
25
25
|
}, [onClick]);
|
|
26
|
+
const handleDeleteGroup = useCallback(() => {
|
|
27
|
+
onChange && onChange(Object.assign(Object.assign({}, value), { group: null }));
|
|
28
|
+
}, [value, onChange]);
|
|
29
|
+
const handleClickGroup = useCallback(() => {
|
|
30
|
+
onClick && onClick('group');
|
|
31
|
+
}, [onClick]);
|
|
26
32
|
const handleDeleteTag = useCallback((id) => () => {
|
|
27
33
|
onChange && onChange(Object.assign(Object.assign({}, value), { addressing: value.addressing.filter((tag) => tag.id !== id) }));
|
|
28
34
|
}, [value, onChange]);
|
|
@@ -38,6 +44,7 @@ export default (props) => {
|
|
|
38
44
|
return (React.createElement(Root, { className: classNames(classes.root, className) },
|
|
39
45
|
((_a = value === null || value === void 0 ? void 0 : value.categories) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
40
46
|
(value === null || value === void 0 ? void 0 : value.categories.map((c) => (React.createElement(Chip, { key: c.id, label: c.name, onDelete: handleDeleteCategory(c.id), icon: React.createElement(Icon, null, "category"), onClick: handleClickCategory })))),
|
|
47
|
+
(value === null || value === void 0 ? void 0 : value.group) && (React.createElement(Chip, { key: value === null || value === void 0 ? void 0 : value.group.id, label: value === null || value === void 0 ? void 0 : value.group.name, onDelete: handleDeleteGroup, icon: React.createElement(Icon, null, "groups"), onClick: handleClickGroup })),
|
|
41
48
|
((_b = value === null || value === void 0 ? void 0 : value.addressing) === null || _b === void 0 ? void 0 : _b.length) > 0 &&
|
|
42
49
|
(value === null || value === void 0 ? void 0 : value.addressing.map((t) => (React.createElement(TagChip, { key: t.id, tag: t, onDelete: handleDeleteTag(t.id), icon: React.createElement(Icon, null, "label"), onClick: handleClickTag })))),
|
|
43
50
|
(value === null || value === void 0 ? void 0 : value.location) && (React.createElement(Chip, { icon: React.createElement(Icon, null, "add_location_alt"), label: value === null || value === void 0 ? void 0 : value.location.location, onDelete: handleDeleteLocation, onClick: handleClickLocation }))));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SyntheticEvent } from 'react';
|
|
2
|
-
import { SCCategoryType, SCContributionType, SCFeedDiscussionType, SCFeedPostType, SCFeedStatusType, SCMediaType, SCPollType, SCTagType } from '@selfcommunity/types';
|
|
2
|
+
import { SCCategoryType, SCContributionType, SCFeedDiscussionType, SCFeedPostType, SCFeedStatusType, SCGroupType, SCMediaType, SCPollType, SCTagType } from '@selfcommunity/types';
|
|
3
3
|
import { DialogProps } from '@mui/material';
|
|
4
4
|
import { EditorProps } from '../Editor';
|
|
5
5
|
import { SCMediaObjectType } from '../../types/media';
|
|
@@ -27,6 +27,7 @@ export interface ComposerProps extends Omit<DialogProps, 'defaultValue' | 'scrol
|
|
|
27
27
|
title?: string;
|
|
28
28
|
text?: string;
|
|
29
29
|
categories?: SCCategoryType[];
|
|
30
|
+
group?: SCGroupType;
|
|
30
31
|
audience?: string;
|
|
31
32
|
addressing?: SCTagType[];
|
|
32
33
|
medias?: SCMediaType[];
|
|
@@ -27,6 +27,7 @@ import Attributes from './Attributes';
|
|
|
27
27
|
import { PREFIX } from './constants';
|
|
28
28
|
import ComposerSkeleton from './Skeleton';
|
|
29
29
|
import CloseLayer from './Layer/CloseLayer';
|
|
30
|
+
import { AudienceTypes } from './Layer/AudienceLayer/AudienceLayer';
|
|
30
31
|
const DialogTransition = forwardRef(function Transition(props, ref) {
|
|
31
32
|
return React.createElement(Fade, Object.assign({ ref: ref }, props));
|
|
32
33
|
});
|
|
@@ -57,7 +58,9 @@ const COMPOSER_INITIAL_STATE = {
|
|
|
57
58
|
html: '',
|
|
58
59
|
htmlError: null,
|
|
59
60
|
categories: [],
|
|
61
|
+
group: null,
|
|
60
62
|
categoriesError: null,
|
|
63
|
+
groupsError: null,
|
|
61
64
|
addressing: null,
|
|
62
65
|
addressingError: null,
|
|
63
66
|
medias: [],
|
|
@@ -131,7 +134,7 @@ export default function Composer(inProps) {
|
|
|
131
134
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
132
135
|
const [layer, setLayer] = useState();
|
|
133
136
|
const [state, dispatch] = useReducer(reducer, Object.assign(Object.assign(Object.assign({}, COMPOSER_INITIAL_STATE), defaultValue), { key: random() }));
|
|
134
|
-
const { key, id, type, title, titleError, html, categories, addressing, audience, medias, poll, pollError, location, error } = state;
|
|
137
|
+
const { key, id, type, title, titleError, html, categories, group, addressing, audience, medias, poll, pollError, location, error } = state;
|
|
135
138
|
const destructureFeedObject = (_feedObject) => {
|
|
136
139
|
if (_feedObject.type === SCContributionType.POST) {
|
|
137
140
|
_feedObject = _feedObject;
|
|
@@ -151,6 +154,7 @@ export default function Composer(inProps) {
|
|
|
151
154
|
title: _feedObject.title,
|
|
152
155
|
html: _feedObject.html,
|
|
153
156
|
categories: _feedObject.categories,
|
|
157
|
+
group: _feedObject.group,
|
|
154
158
|
addressing: _feedObject.addressing,
|
|
155
159
|
medias: _feedObject.medias,
|
|
156
160
|
poll: _feedObject.poll,
|
|
@@ -302,18 +306,24 @@ export default function Composer(inProps) {
|
|
|
302
306
|
}
|
|
303
307
|
}), [handleAddLayer, handleRemoveLayer, handleChangeCategories, categories]);
|
|
304
308
|
const handleChangeAudience = useCallback((value) => {
|
|
305
|
-
|
|
309
|
+
if (group) {
|
|
310
|
+
dispatch({ type: 'group', value });
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
dispatch({ type: 'addressing', value });
|
|
314
|
+
}
|
|
306
315
|
setLayer(null);
|
|
307
|
-
}, []);
|
|
316
|
+
}, [group]);
|
|
308
317
|
const handleAddAudienceLayer = useCallback(() => handleAddLayer({
|
|
309
318
|
name: 'audience',
|
|
310
319
|
Component: AudienceLayer,
|
|
311
320
|
ComponentProps: {
|
|
312
321
|
onClose: handleRemoveLayer,
|
|
313
322
|
onSave: handleChangeAudience,
|
|
314
|
-
defaultValue: addressing
|
|
323
|
+
defaultValue: group ? group : addressing,
|
|
324
|
+
defaultType: group ? AudienceTypes.AUDIENCE_GROUP : addressing ? AudienceTypes.AUDIENCE_TAG : AudienceTypes.AUDIENCE_ALL
|
|
315
325
|
}
|
|
316
|
-
}), [handleAddLayer, handleRemoveLayer, handleChangeAudience, addressing]);
|
|
326
|
+
}), [handleAddLayer, handleRemoveLayer, handleChangeAudience, addressing, group]);
|
|
317
327
|
const handleChangeLocation = useCallback((value) => {
|
|
318
328
|
dispatch({ type: 'location', value });
|
|
319
329
|
setLayer(null);
|
|
@@ -404,6 +414,9 @@ export default function Composer(inProps) {
|
|
|
404
414
|
if (features.includes(SCFeatureName.TAGGING) && addressing !== null) {
|
|
405
415
|
data.addressing = addressing.map((t) => t.id);
|
|
406
416
|
}
|
|
417
|
+
if (features.includes(SCFeatureName.GROUPING) && group !== null) {
|
|
418
|
+
data.group = group.id;
|
|
419
|
+
}
|
|
407
420
|
setIsSubmitting(true);
|
|
408
421
|
// Finding right url
|
|
409
422
|
const _type = type === COMPOSER_TYPE_POLL ? SCContributionType.POST : type;
|
|
@@ -431,7 +444,7 @@ export default function Composer(inProps) {
|
|
|
431
444
|
dispatch({ type: 'multiple', value: formatHttpErrorCode(error) });
|
|
432
445
|
})
|
|
433
446
|
.then(() => setIsSubmitting(false));
|
|
434
|
-
}, [scUserContext.user, feedObjectType, id, type, title, html, categories, addressing, audience, medias, poll, location, hasPoll]);
|
|
447
|
+
}, [scUserContext.user, feedObjectType, id, type, title, html, categories, group, addressing, audience, medias, poll, location, hasPoll]);
|
|
435
448
|
//edited here
|
|
436
449
|
const handleClose = useCallback((event, reason) => {
|
|
437
450
|
if (unloadRef.current) {
|
|
@@ -486,13 +499,29 @@ export default function Composer(inProps) {
|
|
|
486
499
|
}
|
|
487
500
|
switch (type) {
|
|
488
501
|
case COMPOSER_TYPE_POLL:
|
|
489
|
-
return (React.createElement(ContentPoll, { key: key, onChange: handleChangePoll, value: { html,
|
|
502
|
+
return (React.createElement(ContentPoll, { key: key, onChange: handleChangePoll, value: { html, group, addressing, medias, poll, location }, error: pollError, disabled: isSubmitting }));
|
|
490
503
|
case SCContributionType.DISCUSSION:
|
|
491
|
-
return (React.createElement(ContentDiscussion, { key: key, value: { title, html, categories, addressing, medias, poll, location }, error: { titleError, error }, onChange: handleChangeDiscussion, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: true, uploadImage: true }, EditorProps) }));
|
|
504
|
+
return (React.createElement(ContentDiscussion, { key: key, value: { title, html, categories, group, addressing, medias, poll, location }, error: { titleError, error }, onChange: handleChangeDiscussion, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: true, uploadImage: true }, EditorProps) }));
|
|
492
505
|
default:
|
|
493
|
-
return (React.createElement(ContentPost, { key: key, value: { html, categories, addressing, medias, poll, location }, error: { error }, onChange: handleChangePost, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: false, uploadImage: false }, EditorProps) }));
|
|
506
|
+
return (React.createElement(ContentPost, { key: key, value: { html, categories, group, addressing, medias, poll, location }, error: { error }, onChange: handleChangePost, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: false, uploadImage: false }, EditorProps) }));
|
|
494
507
|
}
|
|
495
|
-
}, [
|
|
508
|
+
}, [
|
|
509
|
+
key,
|
|
510
|
+
type,
|
|
511
|
+
title,
|
|
512
|
+
html,
|
|
513
|
+
categories,
|
|
514
|
+
group,
|
|
515
|
+
addressing,
|
|
516
|
+
medias,
|
|
517
|
+
poll,
|
|
518
|
+
pollError,
|
|
519
|
+
location,
|
|
520
|
+
error,
|
|
521
|
+
handleChangePoll,
|
|
522
|
+
handleChangePost,
|
|
523
|
+
isSubmitting
|
|
524
|
+
]);
|
|
496
525
|
if (!scUserContext.user && !(scUserContext.loading && open)) {
|
|
497
526
|
return null;
|
|
498
527
|
}
|
|
@@ -504,7 +533,7 @@ export default function Composer(inProps) {
|
|
|
504
533
|
React.createElement(LoadingButton, { size: "small", type: "submit", color: "secondary", variant: "contained", disabled: !canSubmit, loading: isSubmitting },
|
|
505
534
|
React.createElement(FormattedMessage, { id: "ui.composer.submit", defaultMessage: "ui.composer.submit" }))),
|
|
506
535
|
React.createElement(DialogContent, { className: classes.content },
|
|
507
|
-
React.createElement(Attributes, { value: { categories, addressing, location }, className: classes.attributes, onChange: handleChangeAttributes, onClick: handleClickAttributes }),
|
|
536
|
+
React.createElement(Attributes, { value: { categories, group, addressing, location }, className: classes.attributes, onChange: handleChangeAttributes, onClick: handleClickAttributes }),
|
|
508
537
|
content,
|
|
509
538
|
medias && medias.length > 0 && (React.createElement(Box, { className: classes.medias }, mediaObjectTypes.map((mediaObjectType) => {
|
|
510
539
|
if (mediaObjectType.previewComponent) {
|
|
@@ -23,6 +23,7 @@ const Root = styled(Box, {
|
|
|
23
23
|
const DEFAULT_DISCUSSION = {
|
|
24
24
|
title: '',
|
|
25
25
|
categories: [],
|
|
26
|
+
group: null,
|
|
26
27
|
medias: [],
|
|
27
28
|
html: '',
|
|
28
29
|
addressing: []
|
|
@@ -42,9 +43,12 @@ export default (props) => {
|
|
|
42
43
|
}, [value]);
|
|
43
44
|
// RENDER
|
|
44
45
|
return (React.createElement(Root, { className: classNames(classes.root, className) },
|
|
45
|
-
generalError && React.createElement(Typography, { className: classes.generalError },
|
|
46
|
-
React.createElement(FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` })),
|
|
47
|
-
React.createElement(TextField, { className: classes.title, placeholder: intl.formatMessage({
|
|
46
|
+
generalError && (React.createElement(Typography, { className: classes.generalError },
|
|
47
|
+
React.createElement(FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` }))),
|
|
48
|
+
React.createElement(TextField, { className: classes.title, placeholder: intl.formatMessage({
|
|
49
|
+
id: 'ui.composer.content.discussion.title.label',
|
|
50
|
+
defaultMessage: 'ui.composer.content.discussion.title.label'
|
|
51
|
+
}), autoFocus: true, fullWidth: true, variant: "outlined", value: value.title, multiline: true, onChange: handleChangeTitle, InputProps: {
|
|
48
52
|
endAdornment: React.createElement(Typography, { variant: "body2" }, COMPOSER_TITLE_MAX_LENGTH - value.title.length)
|
|
49
53
|
}, error: Boolean(titleError), helperText: titleError, disabled: disabled }),
|
|
50
54
|
React.createElement(Editor, Object.assign({}, EditorProps, { editable: !disabled, className: classes.editor, onChange: handleChangeHtml, defaultValue: value.html }))));
|
|
@@ -3,9 +3,16 @@ import { TextFieldProps } from '@mui/material/TextField';
|
|
|
3
3
|
import { BoxProps } from '@mui/material';
|
|
4
4
|
import { SCTagType } from '@selfcommunity/types/src/index';
|
|
5
5
|
import { ComposerLayerProps } from '../../../../types/composer';
|
|
6
|
+
import { SCGroupType } from '@selfcommunity/types';
|
|
7
|
+
export declare enum AudienceTypes {
|
|
8
|
+
AUDIENCE_ALL = "all",
|
|
9
|
+
AUDIENCE_TAG = "tag",
|
|
10
|
+
AUDIENCE_GROUP = "group"
|
|
11
|
+
}
|
|
6
12
|
export interface AudienceLayerProps extends Omit<BoxProps, 'defaultValue'>, ComposerLayerProps {
|
|
7
|
-
|
|
13
|
+
defaultType: AudienceTypes;
|
|
14
|
+
defaultValue: SCTagType[] | SCGroupType;
|
|
8
15
|
TextFieldProps?: TextFieldProps;
|
|
9
16
|
}
|
|
10
|
-
declare const AudienceLayer: React.ForwardRefExoticComponent<Pick<AudienceLayerProps, "p" | "slot" | "style" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "zIndex" | "position" | "top" | "right" | "bottom" | "left" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "marginInline" | "marginInlineStart" | "marginInlineEnd" | "marginBlock" | "marginBlockStart" | "marginBlockEnd" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "paddingInline" | "paddingInlineStart" | "paddingInlineEnd" | "paddingBlock" | "paddingBlockStart" | "paddingBlockEnd" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform" | "component" | "sx" | "classes" | "onClose" | "TextFieldProps" | "onSave"> & React.RefAttributes<unknown>>;
|
|
17
|
+
declare const AudienceLayer: React.ForwardRefExoticComponent<Pick<AudienceLayerProps, "p" | "slot" | "style" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "zIndex" | "position" | "top" | "right" | "bottom" | "left" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "marginInline" | "marginInlineStart" | "marginInlineEnd" | "marginBlock" | "marginBlockStart" | "marginBlockEnd" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "paddingInline" | "paddingInlineStart" | "paddingInlineEnd" | "paddingBlock" | "paddingBlockStart" | "paddingBlockEnd" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform" | "component" | "sx" | "classes" | "onClose" | "TextFieldProps" | "defaultType" | "onSave"> & React.RefAttributes<unknown>>;
|
|
11
18
|
export default AudienceLayer;
|
|
@@ -12,8 +12,13 @@ import Icon from '@mui/material/Icon';
|
|
|
12
12
|
import DialogContent from '@mui/material/DialogContent';
|
|
13
13
|
import { useSCFetchAddressingTagList } from '@selfcommunity/react-core';
|
|
14
14
|
import { PREFIX } from '../../constants';
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
import GroupAutocomplete from '../../../GroupAutocomplete';
|
|
16
|
+
export var AudienceTypes;
|
|
17
|
+
(function (AudienceTypes) {
|
|
18
|
+
AudienceTypes["AUDIENCE_ALL"] = "all";
|
|
19
|
+
AudienceTypes["AUDIENCE_TAG"] = "tag";
|
|
20
|
+
AudienceTypes["AUDIENCE_GROUP"] = "group";
|
|
21
|
+
})(AudienceTypes || (AudienceTypes = {}));
|
|
17
22
|
const classes = {
|
|
18
23
|
root: `${PREFIX}-layer-audience-root`,
|
|
19
24
|
title: `${PREFIX}-layer-title`,
|
|
@@ -27,23 +32,36 @@ const Root = styled(Box, {
|
|
|
27
32
|
})(() => ({}));
|
|
28
33
|
const AudienceLayer = React.forwardRef((props, ref) => {
|
|
29
34
|
// Props
|
|
30
|
-
const { className, onClose, onSave, defaultValue = [], TextFieldProps = {
|
|
35
|
+
const { className, onClose, onSave, defaultType = AudienceTypes.AUDIENCE_TAG, defaultValue = AudienceTypes.AUDIENCE_TAG ? [] : null, TextFieldProps = {
|
|
31
36
|
variant: 'outlined',
|
|
32
37
|
label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.tags.label", defaultMessage: "ui.composer.layer.audience.tags.label" })
|
|
33
|
-
} } = props, rest = __rest(props, ["className", "onClose", "onSave", "defaultValue", "TextFieldProps"]);
|
|
38
|
+
} } = props, rest = __rest(props, ["className", "onClose", "onSave", "defaultType", "defaultValue", "TextFieldProps"]);
|
|
34
39
|
// STATE
|
|
35
40
|
const [autocompleteOpen, setAutocompleteOpen] = useState(false);
|
|
36
|
-
const [audience, setAudience] = useState(
|
|
41
|
+
const [audience, setAudience] = useState(
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
defaultValue === null || defaultValue.length === 0
|
|
45
|
+
? AudienceTypes.AUDIENCE_ALL
|
|
46
|
+
: defaultType === AudienceTypes.AUDIENCE_GROUP
|
|
47
|
+
? AudienceTypes.AUDIENCE_GROUP
|
|
48
|
+
: AudienceTypes.AUDIENCE_TAG);
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
50
|
+
// @ts-ignore
|
|
37
51
|
const [value, setValue] = useState(defaultValue || undefined);
|
|
38
52
|
// HOOKS
|
|
39
53
|
const { scAddressingTags } = useSCFetchAddressingTagList({ fetch: autocompleteOpen });
|
|
40
54
|
// HANDLERS
|
|
41
|
-
const handleSave = useCallback(
|
|
55
|
+
const handleSave = useCallback(
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
() => (defaultType === AudienceTypes.AUDIENCE_GROUP ? onSave(value) : onSave((value === null || value === void 0 ? void 0 : value.length) && (value === null || value === void 0 ? void 0 : value.length) > 0 ? value : null)), [value, onSave]);
|
|
42
59
|
const handleChange = useCallback((event, tags) => setValue(tags), []);
|
|
60
|
+
const handleGroupChange = useCallback((group) => setValue(group), []);
|
|
43
61
|
const handleChangeAudience = useCallback((event, data) => setAudience(data), []);
|
|
44
62
|
const handleAutocompleteOpen = useCallback(() => setAutocompleteOpen(true), []);
|
|
45
63
|
const handleAutocompleteClose = useCallback(() => setAutocompleteOpen(false), []);
|
|
46
|
-
return React.createElement(Root, Object.assign({ ref: ref, className: classNames(className, classes.root) }, rest),
|
|
64
|
+
return (React.createElement(Root, Object.assign({ ref: ref, className: classNames(className, classes.root) }, rest),
|
|
47
65
|
React.createElement(DialogTitle, { className: classes.title },
|
|
48
66
|
React.createElement(IconButton, { onClick: onClose },
|
|
49
67
|
React.createElement(Icon, null, "arrow_back")),
|
|
@@ -53,12 +71,14 @@ const AudienceLayer = React.forwardRef((props, ref) => {
|
|
|
53
71
|
React.createElement(FormattedMessage, { id: "ui.composer.layer.save", defaultMessage: "ui.composer.layer.save" }))),
|
|
54
72
|
React.createElement(DialogContent, { className: classes.content },
|
|
55
73
|
React.createElement(Tabs, { value: audience, onChange: handleChangeAudience, "aria-label": "audience type" },
|
|
56
|
-
React.createElement(Tab, { value: AUDIENCE_ALL, icon: React.createElement(Icon, null, "public"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.all", defaultMessage: "ui.composer.layer.audience.all" }) }),
|
|
57
|
-
React.createElement(Tab, {
|
|
74
|
+
React.createElement(Tab, { value: AudienceTypes.AUDIENCE_ALL, icon: React.createElement(Icon, null, "public"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.all", defaultMessage: "ui.composer.layer.audience.all" }) }),
|
|
75
|
+
React.createElement(Tab, { disabled: defaultType === AudienceTypes.AUDIENCE_TAG, value: AudienceTypes.AUDIENCE_GROUP, icon: React.createElement(Icon, null, "groups"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.group", defaultMessage: "ui.composer.layer.audience.group" }) }),
|
|
76
|
+
React.createElement(Tab, { disabled: defaultType === AudienceTypes.AUDIENCE_GROUP, value: AudienceTypes.AUDIENCE_TAG, icon: React.createElement(Icon, null, "label"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.tag", defaultMessage: "ui.composer.layer.audience.tag" }) })),
|
|
58
77
|
React.createElement(Typography, { className: classes.message },
|
|
59
|
-
audience === AUDIENCE_ALL && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.all.message", defaultMessage: "ui.composer.audience.layer.all.message" })),
|
|
60
|
-
audience ===
|
|
61
|
-
|
|
78
|
+
audience === AudienceTypes.AUDIENCE_ALL && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.all.message", defaultMessage: "ui.composer.audience.layer.all.message" })),
|
|
79
|
+
audience === AudienceTypes.AUDIENCE_GROUP && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.group.message", defaultMessage: "ui.composer.audience.layer.group.message" })),
|
|
80
|
+
audience === AudienceTypes.AUDIENCE_TAG && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.tag.message", defaultMessage: "ui.composer.audience.layer.tag.message" }))),
|
|
81
|
+
audience === AudienceTypes.AUDIENCE_TAG && (React.createElement(Autocomplete, { className: classes.autocomplete, open: autocompleteOpen, onOpen: handleAutocompleteOpen, onClose: handleAutocompleteClose, multiple: true, options: scAddressingTags || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, handleHomeEndKeys: true, clearIcon: null, noOptionsText: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.tags.empty", defaultMessage: "ui.composer.layer.audience.tags.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id, renderTags: (value, getTagProps) => {
|
|
62
82
|
return value.map((option, index) => React.createElement(TagChip, Object.assign({ key: option.id, tag: option }, getTagProps({ index }))));
|
|
63
83
|
}, renderOption: (props, option, { selected, inputValue }) => {
|
|
64
84
|
const matches = match(option.name, inputValue);
|
|
@@ -67,6 +87,7 @@ const AudienceLayer = React.forwardRef((props, ref) => {
|
|
|
67
87
|
React.createElement(TagChip, { key: option.id, tag: option, label: React.createElement(React.Fragment, null, parts.map((part, index) => (React.createElement("span", { key: index, style: { fontWeight: part.highlight ? 700 : 400 } }, part.text)))) })));
|
|
68
88
|
}, renderInput: (params) => {
|
|
69
89
|
return (React.createElement(TextField, Object.assign({}, params, TextFieldProps, { InputProps: Object.assign(Object.assign({}, params.InputProps), { autoComplete: 'addressing', endAdornment: React.createElement(React.Fragment, null, params.InputProps.endAdornment) }) })));
|
|
70
|
-
} }))
|
|
90
|
+
} })),
|
|
91
|
+
audience === AudienceTypes.AUDIENCE_GROUP && React.createElement(GroupAutocomplete, { onChange: handleGroupChange, defaultValue: defaultValue }))));
|
|
71
92
|
});
|
|
72
93
|
export default AudienceLayer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ButtonProps } from '@mui/material/Button/Button';
|
|
2
|
-
import {
|
|
2
|
+
import { GroupFormProps } from '../GroupForm';
|
|
3
3
|
export interface CreateGroupButtonProps extends ButtonProps {
|
|
4
4
|
/**
|
|
5
5
|
* Overrides or extends the styles applied to the component.
|
|
@@ -10,7 +10,7 @@ export interface CreateGroupButtonProps extends ButtonProps {
|
|
|
10
10
|
* Props to spread to CreateGroup component
|
|
11
11
|
* @default empty object
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
GroupFormProps?: GroupFormProps;
|
|
14
14
|
/**
|
|
15
15
|
* Any other properties
|
|
16
16
|
*/
|
|
@@ -6,7 +6,7 @@ import { Button, Icon } from '@mui/material';
|
|
|
6
6
|
import { FormattedMessage } from 'react-intl';
|
|
7
7
|
import { SCUserContext } from '@selfcommunity/react-core';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
|
-
import
|
|
9
|
+
import GroupForm from '../GroupForm';
|
|
10
10
|
const PREFIX = 'SCCreateGroupButton';
|
|
11
11
|
const classes = {
|
|
12
12
|
root: `${PREFIX}-root`
|
|
@@ -41,7 +41,7 @@ export default function CreateGroupButton(inProps) {
|
|
|
41
41
|
props: inProps,
|
|
42
42
|
name: PREFIX
|
|
43
43
|
});
|
|
44
|
-
const { className,
|
|
44
|
+
const { className, GroupFormProps = {}, children } = props, rest = __rest(props, ["className", "GroupFormProps", "children"]);
|
|
45
45
|
// CONTEXT
|
|
46
46
|
const scUserContext = useContext(SCUserContext);
|
|
47
47
|
// STATE
|
|
@@ -52,7 +52,7 @@ export default function CreateGroupButton(inProps) {
|
|
|
52
52
|
* Handle click on button
|
|
53
53
|
*/
|
|
54
54
|
const handleClick = () => {
|
|
55
|
-
setOpen((
|
|
55
|
+
setOpen((o) => !o);
|
|
56
56
|
};
|
|
57
57
|
/**
|
|
58
58
|
* If there's no authUserId, component is hidden.
|
|
@@ -64,7 +64,6 @@ export default function CreateGroupButton(inProps) {
|
|
|
64
64
|
* Renders root object
|
|
65
65
|
*/
|
|
66
66
|
return (React.createElement(React.Fragment, null,
|
|
67
|
-
React.createElement(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClick,
|
|
68
|
-
|
|
69
|
-
open && React.createElement(CreateGroup, Object.assign({}, CreateGroupProps, { open: true, onClose: handleClick }))));
|
|
67
|
+
React.createElement(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClick, variant: "contained", startIcon: React.createElement(Icon, { fontSize: "small" }, "add") }, rest), children !== null && children !== void 0 ? children : React.createElement(FormattedMessage, { id: "ui.createGroupButton", defaultMessage: "ui.createGroupButton" })),
|
|
68
|
+
open && React.createElement(GroupForm, Object.assign({}, GroupFormProps, { open: true, onClose: handleClick }))));
|
|
70
69
|
}
|
|
@@ -23,6 +23,10 @@ export interface CustomAdvProps extends VirtualScrollerItemProps {
|
|
|
23
23
|
* Category ids if the adv must be related to specific categories
|
|
24
24
|
*/
|
|
25
25
|
categoriesId?: Array<number> | null;
|
|
26
|
+
/**
|
|
27
|
+
* Group ids if the adv must be related to specific groups
|
|
28
|
+
*/
|
|
29
|
+
groupsId?: Array<number> | null;
|
|
26
30
|
/**
|
|
27
31
|
* Prefixed height. Usefull to re-mount item on scroll feed.
|
|
28
32
|
*/
|
package/lib/esm/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts}
RENAMED
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateGroupButtonProps } from '../CreateGroupButton';
|
|
2
2
|
import { SCGroupType } from '@selfcommunity/types';
|
|
3
|
-
export interface
|
|
3
|
+
export interface EditGroupButtonProps extends CreateGroupButtonProps {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Group Object
|
|
6
6
|
* @default null
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Open dialog
|
|
11
|
-
* @default true
|
|
12
|
-
*/
|
|
13
|
-
open?: boolean;
|
|
8
|
+
group?: SCGroupType;
|
|
14
9
|
/**
|
|
15
|
-
*
|
|
10
|
+
* Id of the group
|
|
16
11
|
* @default null
|
|
17
12
|
*/
|
|
18
|
-
|
|
13
|
+
groupId?: number | string;
|
|
19
14
|
/**
|
|
20
|
-
*
|
|
15
|
+
* On edit success callback function
|
|
21
16
|
* @default null
|
|
22
17
|
*/
|
|
23
|
-
|
|
18
|
+
onEditSuccess?: (data: SCGroupType) => void;
|
|
24
19
|
/**
|
|
25
20
|
* Any other properties
|
|
26
21
|
*/
|
|
@@ -35,14 +30,14 @@ export interface CreateGroupProps extends BaseDialogProps {
|
|
|
35
30
|
```
|
|
36
31
|
|
|
37
32
|
#### Component Name
|
|
38
|
-
The name `
|
|
33
|
+
The name `SCEditGroupButton` can be used when providing style overrides in the theme.
|
|
39
34
|
|
|
40
35
|
#### CSS
|
|
41
36
|
|
|
42
37
|
|Rule Name|Global class|Description|
|
|
43
38
|
|---|---|---|
|
|
44
|
-
|root|.
|
|
39
|
+
|root|.SCEditGroupButton-root|Styles applied to the root element.|
|
|
45
40
|
|
|
46
41
|
* @param inProps
|
|
47
42
|
*/
|
|
48
|
-
export default function
|
|
43
|
+
export default function EditGroupButton(inProps: EditGroupButtonProps): JSX.Element;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useThemeProps } from '@mui/system';
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
|
+
import { FormattedMessage } from 'react-intl';
|
|
6
|
+
import { useSCFetchGroup } from '@selfcommunity/react-core';
|
|
7
|
+
import classNames from 'classnames';
|
|
8
|
+
import CreateGroupButton from '../CreateGroupButton';
|
|
9
|
+
const PREFIX = 'SCEditGroupButton';
|
|
10
|
+
const classes = {
|
|
11
|
+
root: `${PREFIX}-root`
|
|
12
|
+
};
|
|
13
|
+
const Root = styled(CreateGroupButton, {
|
|
14
|
+
name: PREFIX,
|
|
15
|
+
slot: 'Root',
|
|
16
|
+
overridesResolver: (props, styles) => styles.root
|
|
17
|
+
})(({ theme }) => ({}));
|
|
18
|
+
/**
|
|
19
|
+
*> API documentation for the Community-JS Create Group Button component. Learn about the available props and the CSS API.
|
|
20
|
+
*
|
|
21
|
+
#### Import
|
|
22
|
+
```jsx
|
|
23
|
+
import {CreateGroupButton} from '@selfcommunity/react-ui';
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### Component Name
|
|
27
|
+
The name `SCEditGroupButton` can be used when providing style overrides in the theme.
|
|
28
|
+
|
|
29
|
+
#### CSS
|
|
30
|
+
|
|
31
|
+
|Rule Name|Global class|Description|
|
|
32
|
+
|---|---|---|
|
|
33
|
+
|root|.SCEditGroupButton-root|Styles applied to the root element.|
|
|
34
|
+
|
|
35
|
+
* @param inProps
|
|
36
|
+
*/
|
|
37
|
+
export default function EditGroupButton(inProps) {
|
|
38
|
+
//PROPS
|
|
39
|
+
const props = useThemeProps({
|
|
40
|
+
props: inProps,
|
|
41
|
+
name: PREFIX
|
|
42
|
+
});
|
|
43
|
+
const { className, groupId, group, onEditSuccess } = props, rest = __rest(props, ["className", "groupId", "group", "onEditSuccess"]);
|
|
44
|
+
const { scGroup, setSCGroup } = useSCFetchGroup({ id: groupId, group });
|
|
45
|
+
const handleSuccess = (data) => {
|
|
46
|
+
setSCGroup(data);
|
|
47
|
+
onEditSuccess && onEditSuccess(data);
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Renders root object
|
|
51
|
+
*/
|
|
52
|
+
return (React.createElement(Root, Object.assign({ variant: "outlined", className: classNames(classes.root, className), GroupFormProps: { group: scGroup, onSuccess: handleSuccess } }, rest),
|
|
53
|
+
React.createElement(FormattedMessage, { id: "ui.editGroupButton", defaultMessage: "ui.editGroupButton" })));
|
|
54
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ButtonBaseProps } from '@mui/material';
|
|
2
2
|
import { SCGroupType } from '@selfcommunity/types';
|
|
3
3
|
import { WidgetProps } from '../Widget';
|
|
4
|
+
import { GroupSubscribeButtonProps } from '../GroupSubscribeButton';
|
|
4
5
|
export interface GroupProps extends WidgetProps {
|
|
5
6
|
/**
|
|
6
7
|
* Group Object
|
|
@@ -13,10 +14,10 @@ export interface GroupProps extends WidgetProps {
|
|
|
13
14
|
*/
|
|
14
15
|
groupId?: number;
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @default
|
|
17
|
+
* Props to spread to group subscribe/unsubscribe button
|
|
18
|
+
* @default {}
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
groupSubscribeButtonProps?: GroupSubscribeButtonProps;
|
|
20
21
|
/**
|
|
21
22
|
* Badge content to show as group avatar badge if show reaction is true.
|
|
22
23
|
*/
|
|
@@ -61,7 +61,7 @@ export default function Group(inProps) {
|
|
|
61
61
|
props: inProps,
|
|
62
62
|
name: PREFIX
|
|
63
63
|
});
|
|
64
|
-
const { groupId = null, group = null,
|
|
64
|
+
const { groupId = null, group = null, className = null, elevation, hideActions = false, groupSubscribeButtonProps = {}, buttonProps = {}, visible = true } = props, rest = __rest(props, ["groupId", "group", "className", "elevation", "hideActions", "groupSubscribeButtonProps", "buttonProps", "visible"]);
|
|
65
65
|
// STATE
|
|
66
66
|
const { scGroup } = useSCFetchGroup({ id: groupId, group });
|
|
67
67
|
// CONTEXT
|
|
@@ -76,7 +76,7 @@ export default function Group(inProps) {
|
|
|
76
76
|
function renderAuthenticatedActions() {
|
|
77
77
|
return (React.createElement(Stack, { className: classes.actions, direction: "row", alignItems: "center", justifyContent: "center", spacing: 2 },
|
|
78
78
|
React.createElement(Icon, null, !visible ? 'private' : 'public'),
|
|
79
|
-
React.createElement(GroupSubscribeButton, { group: group, groupId: groupId })));
|
|
79
|
+
React.createElement(GroupSubscribeButton, Object.assign({ group: group, groupId: groupId }, groupSubscribeButtonProps))));
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* Renders group object
|
|
@@ -33,6 +33,6 @@ const Root = styled(BaseItem, {
|
|
|
33
33
|
*/
|
|
34
34
|
export default function GroupSkeleton(props) {
|
|
35
35
|
const theme = useTheme();
|
|
36
|
-
return (React.createElement(Root, Object.assign({ className: classes.root }, props, { image: React.createElement(Skeleton, { animation: "wave", variant: "circular", width: theme.selfcommunity.
|
|
36
|
+
return (React.createElement(Root, Object.assign({ className: classes.root }, props, { image: React.createElement(Skeleton, { animation: "wave", variant: "circular", width: theme.selfcommunity.group.avatar.sizeSmall, height: theme.selfcommunity.group.avatar.sizeSmall }), primary: React.createElement(Skeleton, { animation: "wave", height: 10, width: 120, style: { marginBottom: 10 } }), secondary: React.createElement(Skeleton, { animation: "wave", height: 10, width: 70, style: { marginBottom: 10 } }), actions: React.createElement(Button, { size: "small", variant: "outlined", disabled: true },
|
|
37
37
|
React.createElement(Skeleton, { animation: "wave", height: 10, width: 30, style: { marginTop: 5, marginBottom: 5 } })) })));
|
|
38
38
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
|
2
|
+
import { AutocompleteProps } from '@mui/material';
|
|
3
|
+
import { SCGroupType } from '@selfcommunity/types/src/index';
|
|
4
|
+
export interface GroupAutocompleteProps extends Pick<AutocompleteProps<SCGroupType | null, any, any, any>, Exclude<keyof AutocompleteProps<SCGroupType | null, any, any, any>, 'open' | 'onOpen' | 'onClose' | 'onChange' | 'filterSelectedOptions' | 'disableCloseOnSelect' | 'options' | 'getOptionLabel' | 'value' | 'selectOnFocus' | 'clearOnBlur' | 'blurOnSelect' | 'handleHomeEndKeys' | 'clearIcon' | 'noOptionsText' | 'isOptionEqualToValue' | 'renderTags' | 'renderOption' | 'renderInput'>> {
|
|
5
|
+
/**
|
|
6
|
+
* The maximum number of groups that will be visible when not focused.
|
|
7
|
+
* @default 0
|
|
8
|
+
*/
|
|
9
|
+
limitCountGroups?: number;
|
|
10
|
+
/**
|
|
11
|
+
* If checkbox is selected
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
checkboxSelect?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The props applied to text field
|
|
17
|
+
* @default {variant: 'outlined, label: groups_label}
|
|
18
|
+
*/
|
|
19
|
+
TextFieldProps?: TextFieldProps;
|
|
20
|
+
/**
|
|
21
|
+
* Callback for change event on poll object
|
|
22
|
+
* @param value
|
|
23
|
+
*/
|
|
24
|
+
onChange?: (value: any) => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* > API documentation for the Community-JS Group Autocomplete component. Learn about the available props and the CSS API.
|
|
28
|
+
*
|
|
29
|
+
*
|
|
30
|
+
* This component renders a bar that allows users to search (with autocomplete) for all the groups available in the application.
|
|
31
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/GroupAutocomplete)
|
|
32
|
+
*
|
|
33
|
+
* #### Import
|
|
34
|
+
* ```jsx
|
|
35
|
+
* import {GroupAutocomplete} from '@selfcommunity/react-ui';
|
|
36
|
+
* ```
|
|
37
|
+
* #### Component Name
|
|
38
|
+
* The name `SCGroupAutocomplete` can be used when providing style overrides in the theme.
|
|
39
|
+
*
|
|
40
|
+
* #### CSS
|
|
41
|
+
*
|
|
42
|
+
* |Rule Name|Global class|Description|
|
|
43
|
+
* |---|---|---|
|
|
44
|
+
* |root|.SCGroupAutocomplete-root|Styles applied to the root element.|
|
|
45
|
+
*
|
|
46
|
+
* @param inProps
|
|
47
|
+
*/
|
|
48
|
+
declare const GroupAutocomplete: (inProps: GroupAutocompleteProps) => JSX.Element;
|
|
49
|
+
export default GroupAutocomplete;
|