@selfcommunity/react-ui 0.11.0-alpha.111 → 0.11.0-alpha.113

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.
@@ -76,16 +76,14 @@ function Category(inProps) {
76
76
  // MEMO
77
77
  const _ButtonBaseProps = (0, react_1.useMemo)(() => ButtonBaseProps ? ButtonBaseProps : { component: react_core_1.Link, to: scCategory ? scRoutingContext.url(react_core_1.SCRoutes.CATEGORY_ROUTE_NAME, scCategory) : '' }, [ButtonBaseProps, scRoutingContext, scCategory]);
78
78
  // HOOKS
79
- const intl = (0, react_intl_1.useIntl)();
80
79
  const categoryFollowEnabled = (0, react_core_1.useSCPreferenceEnabled)(react_core_1.SCPreferences.CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED);
81
80
  if (!scCategory) {
82
81
  return (0, jsx_runtime_1.jsx)(Skeleton_1.default, Object.assign({ elevation: elevation }, (variant && { variant })));
83
82
  }
84
83
  // RENDER
85
84
  if (!autoHide) {
86
- return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ disableTypography: showTooltip, elevation: elevation }, (variant && { variant }), { className: (0, classnames_1.default)(classes.root, className, { [classes.followed]: scCategory.followed }, { [classes.autoFollowed]: scCategory.auto_follow === types_1.SCCategoryAutoFollowType.FORCED }), ButtonBaseProps: _ButtonBaseProps, image: (0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: scCategory.name, src: scCategory.image_medium, variant: "square", className: classes.categoryImage }), primary: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: showTooltip ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: scCategory.name }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.primary, component: "span", variant: "body1" }, { children: scCategory.name })) }))) : (scCategory.name) }), secondary: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: showTooltip ? ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.secondary, component: "p", variant: "body2" }, { children: showFollowers && categoryFollowEnabled ? `${intl.formatMessage(messages.categoryFollowers, { total: scCategory.followers_counter })}` : scCategory.slogan }))) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: showFollowers && categoryFollowEnabled
87
- ? `${intl.formatMessage(messages.categoryFollowers, { total: scCategory.followers_counter })}`
88
- : scCategory.slogan })) }), actions: (0, jsx_runtime_1.jsx)(CategoryFollowButton_1.default, Object.assign({ category: scCategory }, categoryFollowButtonProps)) }, rest)));
85
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ disableTypography: showTooltip, elevation: elevation }, (variant && { variant }), { className: (0, classnames_1.default)(classes.root, className, { [classes.followed]: scCategory.followed }, { [classes.autoFollowed]: scCategory.auto_follow === types_1.SCCategoryAutoFollowType.FORCED }), ButtonBaseProps: _ButtonBaseProps, image: (0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: scCategory.name, src: scCategory.image_medium, variant: "square", className: classes.categoryImage }), primary: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: showTooltip ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: scCategory.name }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.primary, component: "span", variant: "body1" }, { children: scCategory.name })) }))) : (scCategory.name) }), secondary: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: showTooltip && showFollowers && categoryFollowEnabled ? ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.secondary, component: "p", variant: "body2" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, Object.assign({}, messages.categoryFollowers, { values: { total: scCategory.followers_counter } })) }))) : (showFollowers &&
86
+ categoryFollowEnabled && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, Object.assign({}, messages.categoryFollowers, { values: { total: scCategory.followers_counter } }))) }), actions: (0, jsx_runtime_1.jsx)(CategoryFollowButton_1.default, Object.assign({ category: scCategory }, categoryFollowButtonProps)) }, rest)));
89
87
  }
90
88
  return null;
91
89
  }
@@ -2,7 +2,7 @@ import { AutocompleteProps, TextFieldProps } from '@mui/material';
2
2
  import { SCTagType } from '@selfcommunity/types';
3
3
  import { TagChipProps } from '../../shared/TagChip';
4
4
  export interface TagAutocompleteProps extends Pick<AutocompleteProps<SCTagType | null, any, any, any>, Exclude<keyof AutocompleteProps<SCTagType | null, any, any, any>, 'open' | 'onOpen' | 'onClose' | 'onChange' | 'filterSelectedOptions' | 'disableCloseOnSelect' | 'options' | 'getOptionLabel' | 'value' | 'selectOnFocus' | 'clearOnBlur' | 'blurOnSelect' | 'handleHomeEndKeys' | 'noOptionsText' | 'isOptionEqualToValue' | 'renderTags' | 'renderOption' | 'renderInput'>> {
5
- defaultValue: SCTagType[] | string;
5
+ defaultValue: SCTagType[] | any;
6
6
  /**
7
7
  * The props applied to text field
8
8
  * @default {variant: 'outlined, label: tags_label}
@@ -88,10 +88,11 @@ const TagAutocomplete = (inProps) => {
88
88
  (0, react_1.useEffect)(() => {
89
89
  const loadDefault = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
90
90
  if (typeof defaultValue === 'string' && defaultValue.trim() !== '') {
91
- const results = yield fetchTags(defaultValue);
92
- const match = results.find((t) => t.name === defaultValue);
93
- if (match)
91
+ const results = yield fetchTags('');
92
+ const match = results.find((t) => t.id === Number(defaultValue));
93
+ if (match) {
94
94
  setValue(match);
95
+ }
95
96
  }
96
97
  });
97
98
  loadDefault();
@@ -104,12 +105,21 @@ const TagAutocomplete = (inProps) => {
104
105
  };
105
106
  const handleClose = () => setOpen(false);
106
107
  const handleChange = (_event, newValue) => setValue(newValue);
107
- return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: classes.root, open: open, onOpen: handleOpen, onClose: handleClose, options: tags || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, handleHomeEndKeys: true, clearIcon: null, noOptionsText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.tags.empty", defaultMessage: "ui.composer.layer.audience.tags.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => (value === null || value === void 0 ? void 0 : value.id) === (option === null || option === void 0 ? void 0 : option.id), inputValue: inputValue, onInputChange: (_e, newInputValue) => setInputValue(newInputValue), renderTags: (value, getTagProps) => value.map((option, index) => (0, jsx_runtime_1.jsx)(TagChip_1.default, Object.assign({ tag: option }, getTagProps({ index })), option.id)), renderOption: (props, option, { inputValue }) => {
108
+ const filterOptions = (0, react_1.useCallback)((options, state) => {
109
+ const search = state.inputValue.toLowerCase();
110
+ return options.filter((option) => {
111
+ var _a, _b;
112
+ const nameMatch = (_a = option.name) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(search);
113
+ const descMatch = (_b = option.description) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(search);
114
+ return nameMatch || descMatch;
115
+ });
116
+ }, []);
117
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: classes.root, open: open, onOpen: handleOpen, onClose: handleClose, options: tags || [], filterOptions: filterOptions, getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, handleHomeEndKeys: true, clearIcon: null, noOptionsText: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.tags.empty", defaultMessage: "ui.composer.layer.audience.tags.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => (value === null || value === void 0 ? void 0 : value.id) === (option === null || option === void 0 ? void 0 : option.id), inputValue: inputValue, onInputChange: (_e, newInputValue) => setInputValue(newInputValue), renderOption: (props, option, { inputValue }) => {
108
118
  const matches = (0, match_1.default)(option.name, inputValue);
109
119
  const parts = (0, parse_1.default)(option.name, matches);
110
- return ((0, jsx_runtime_1.jsx)("li", Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(TagChip_1.default, Object.assign({ disposable: false, tag: option, label: (0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: parts.map((part, index) => ((0, jsx_runtime_1.jsx)("span", Object.assign({ style: { fontWeight: part.highlight ? 700 : 400 } }, { children: part.text }), index))) }) }, TagChipProps), option.id) })));
120
+ return ((0, jsx_runtime_1.jsx)("li", Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(TagChip_1.default, Object.assign({ showDescription: true, disposable: false, tag: option, label: (0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: parts.map((part, index) => ((0, jsx_runtime_1.jsx)("span", Object.assign({ style: { fontWeight: part.highlight ? 700 : 400 } }, { children: part.text }), index))) }) }, TagChipProps), option.id) })));
111
121
  }, renderInput: (params) => {
112
- return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, TextFieldProps, { InputProps: Object.assign(Object.assign({}, params.InputProps), { autoComplete: 'addressing', endAdornment: tags.length > 0 ? ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [' ', loading && (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { color: "inherit", size: 20 }), params.InputProps.endAdornment] })) : null }) })));
122
+ return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, TextFieldProps, { InputProps: Object.assign(Object.assign({}, params.InputProps), { autoComplete: 'tags', endAdornment: tags.length > 0 ? ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [loading && (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { color: "inherit", size: 20 }), params.InputProps.endAdornment] })) : null }) })));
113
123
  } }, rest)));
114
124
  };
115
125
  exports.default = TagAutocomplete;
@@ -72,5 +72,10 @@ export interface TagChipProps {
72
72
  * @default false
73
73
  */
74
74
  ellipsis?: boolean;
75
+ /**
76
+ * If `true`, shows the description of the tag on hover (desktop) or long press (mobile).
77
+ * @default false
78
+ */
79
+ showDescription?: boolean;
75
80
  }
76
81
  export default function TagChip(props: TagChipProps): JSX.Element;
@@ -23,7 +23,7 @@ const Root = (0, material_1.styled)(material_1.Chip, {
23
23
  }));
24
24
  function TagChip(props) {
25
25
  // PROPS
26
- const { tag, clickable = true, disposable = true, label = null, ellipsis = false, onClick = null, onDelete = null, className = null } = props, rest = tslib_1.__rest(props, ["tag", "clickable", "disposable", "label", "ellipsis", "onClick", "onDelete", "className"]);
26
+ const { tag, clickable = true, disposable = true, label = null, ellipsis = false, onClick = null, onDelete = null, className = null, showDescription = false } = props, rest = tslib_1.__rest(props, ["tag", "clickable", "disposable", "label", "ellipsis", "onClick", "onDelete", "className", "showDescription"]);
27
27
  // HANDLERS
28
28
  const handleClick = () => {
29
29
  onClick && onClick(tag.id);
@@ -31,9 +31,13 @@ function TagChip(props) {
31
31
  const handleDelete = () => {
32
32
  onDelete && onDelete(tag.id);
33
33
  };
34
+ const root = ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(className, { [classes.ellipsis]: ellipsis }), sx: { backgroundColor: `${tag.color}`, color: (theme) => theme.palette.getContrastText(tag.color) } }, (clickable && { onClick: handleClick }), (disposable && { onDelete: handleDelete }), { label: label ? label : tag.name }, rest)));
34
35
  /**
35
36
  * Renders root object
36
37
  */
37
- return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(className, { [classes.ellipsis]: ellipsis }), sx: { backgroundColor: `${tag.color}`, color: (theme) => theme.palette.getContrastText(tag.color) } }, (clickable && { onClick: handleClick }), (disposable && { onDelete: handleDelete }), { label: label ? label : tag.name }, rest)));
38
+ if (showDescription && tag.description) {
39
+ return ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: tag.description, placement: "right", arrow: true }, { children: root })));
40
+ }
41
+ return root;
38
42
  }
39
43
  exports.default = TagChip;
@@ -6,7 +6,7 @@ import { Link, SCPreferences, SCRoutes, useSCFetchCategory, useSCPreferenceEnabl
6
6
  import { SCCategoryAutoFollowType } from '@selfcommunity/types';
7
7
  import CategorySkeleton from './Skeleton';
8
8
  import CategoryFollowButton from '../CategoryFollowButton';
9
- import { defineMessages, useIntl } from 'react-intl';
9
+ import { defineMessages, FormattedMessage } from 'react-intl';
10
10
  import classNames from 'classnames';
11
11
  import { useThemeProps } from '@mui/system';
12
12
  import BaseItemButton from '../../shared/BaseItemButton';
@@ -74,16 +74,14 @@ export default function Category(inProps) {
74
74
  // MEMO
75
75
  const _ButtonBaseProps = useMemo(() => ButtonBaseProps ? ButtonBaseProps : { component: Link, to: scCategory ? scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, scCategory) : '' }, [ButtonBaseProps, scRoutingContext, scCategory]);
76
76
  // HOOKS
77
- const intl = useIntl();
78
77
  const categoryFollowEnabled = useSCPreferenceEnabled(SCPreferences.CONFIGURATIONS_CATEGORY_FOLLOW_ENABLED);
79
78
  if (!scCategory) {
80
79
  return _jsx(CategorySkeleton, Object.assign({ elevation: elevation }, (variant && { variant })));
81
80
  }
82
81
  // RENDER
83
82
  if (!autoHide) {
84
- return (_jsx(Root, Object.assign({ disableTypography: showTooltip, elevation: elevation }, (variant && { variant }), { className: classNames(classes.root, className, { [classes.followed]: scCategory.followed }, { [classes.autoFollowed]: scCategory.auto_follow === SCCategoryAutoFollowType.FORCED }), ButtonBaseProps: _ButtonBaseProps, image: _jsx(Avatar, { alt: scCategory.name, src: scCategory.image_medium, variant: "square", className: classes.categoryImage }), primary: _jsx(_Fragment, { children: showTooltip ? (_jsx(Tooltip, Object.assign({ title: scCategory.name }, { children: _jsx(Typography, Object.assign({ className: classes.primary, component: "span", variant: "body1" }, { children: scCategory.name })) }))) : (scCategory.name) }), secondary: _jsx(_Fragment, { children: showTooltip ? (_jsx(Typography, Object.assign({ className: classes.secondary, component: "p", variant: "body2" }, { children: showFollowers && categoryFollowEnabled ? `${intl.formatMessage(messages.categoryFollowers, { total: scCategory.followers_counter })}` : scCategory.slogan }))) : (_jsx(_Fragment, { children: showFollowers && categoryFollowEnabled
85
- ? `${intl.formatMessage(messages.categoryFollowers, { total: scCategory.followers_counter })}`
86
- : scCategory.slogan })) }), actions: _jsx(CategoryFollowButton, Object.assign({ category: scCategory }, categoryFollowButtonProps)) }, rest)));
83
+ return (_jsx(Root, Object.assign({ disableTypography: showTooltip, elevation: elevation }, (variant && { variant }), { className: classNames(classes.root, className, { [classes.followed]: scCategory.followed }, { [classes.autoFollowed]: scCategory.auto_follow === SCCategoryAutoFollowType.FORCED }), ButtonBaseProps: _ButtonBaseProps, image: _jsx(Avatar, { alt: scCategory.name, src: scCategory.image_medium, variant: "square", className: classes.categoryImage }), primary: _jsx(_Fragment, { children: showTooltip ? (_jsx(Tooltip, Object.assign({ title: scCategory.name }, { children: _jsx(Typography, Object.assign({ className: classes.primary, component: "span", variant: "body1" }, { children: scCategory.name })) }))) : (scCategory.name) }), secondary: _jsx(_Fragment, { children: showTooltip && showFollowers && categoryFollowEnabled ? (_jsx(Typography, Object.assign({ className: classes.secondary, component: "p", variant: "body2" }, { children: _jsx(FormattedMessage, Object.assign({}, messages.categoryFollowers, { values: { total: scCategory.followers_counter } })) }))) : (showFollowers &&
84
+ categoryFollowEnabled && _jsx(FormattedMessage, Object.assign({}, messages.categoryFollowers, { values: { total: scCategory.followers_counter } }))) }), actions: _jsx(CategoryFollowButton, Object.assign({ category: scCategory }, categoryFollowButtonProps)) }, rest)));
87
85
  }
88
86
  return null;
89
87
  }
@@ -2,7 +2,7 @@ import { AutocompleteProps, TextFieldProps } from '@mui/material';
2
2
  import { SCTagType } from '@selfcommunity/types';
3
3
  import { TagChipProps } from '../../shared/TagChip';
4
4
  export interface TagAutocompleteProps extends Pick<AutocompleteProps<SCTagType | null, any, any, any>, Exclude<keyof AutocompleteProps<SCTagType | null, any, any, any>, 'open' | 'onOpen' | 'onClose' | 'onChange' | 'filterSelectedOptions' | 'disableCloseOnSelect' | 'options' | 'getOptionLabel' | 'value' | 'selectOnFocus' | 'clearOnBlur' | 'blurOnSelect' | 'handleHomeEndKeys' | 'noOptionsText' | 'isOptionEqualToValue' | 'renderTags' | 'renderOption' | 'renderInput'>> {
5
- defaultValue: SCTagType[] | string;
5
+ defaultValue: SCTagType[] | any;
6
6
  /**
7
7
  * The props applied to text field
8
8
  * @default {variant: 'outlined, label: tags_label}
@@ -1,6 +1,6 @@
1
1
  import { __awaiter, __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import React, { Fragment, useEffect, useState } from 'react';
3
+ import React, { Fragment, useCallback, useEffect, useState } from 'react';
4
4
  import { FormattedMessage } from 'react-intl';
5
5
  import parse from 'autosuggest-highlight/parse';
6
6
  import match from 'autosuggest-highlight/match';
@@ -86,10 +86,11 @@ const TagAutocomplete = (inProps) => {
86
86
  useEffect(() => {
87
87
  const loadDefault = () => __awaiter(void 0, void 0, void 0, function* () {
88
88
  if (typeof defaultValue === 'string' && defaultValue.trim() !== '') {
89
- const results = yield fetchTags(defaultValue);
90
- const match = results.find((t) => t.name === defaultValue);
91
- if (match)
89
+ const results = yield fetchTags('');
90
+ const match = results.find((t) => t.id === Number(defaultValue));
91
+ if (match) {
92
92
  setValue(match);
93
+ }
93
94
  }
94
95
  });
95
96
  loadDefault();
@@ -102,12 +103,21 @@ const TagAutocomplete = (inProps) => {
102
103
  };
103
104
  const handleClose = () => setOpen(false);
104
105
  const handleChange = (_event, newValue) => setValue(newValue);
105
- return (_jsx(Root, Object.assign({ className: classes.root, open: open, onOpen: handleOpen, onClose: handleClose, options: tags || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, handleHomeEndKeys: true, clearIcon: null, noOptionsText: _jsx(FormattedMessage, { id: "ui.composer.layer.audience.tags.empty", defaultMessage: "ui.composer.layer.audience.tags.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => (value === null || value === void 0 ? void 0 : value.id) === (option === null || option === void 0 ? void 0 : option.id), inputValue: inputValue, onInputChange: (_e, newInputValue) => setInputValue(newInputValue), renderTags: (value, getTagProps) => value.map((option, index) => _jsx(TagChip, Object.assign({ tag: option }, getTagProps({ index })), option.id)), renderOption: (props, option, { inputValue }) => {
106
+ const filterOptions = useCallback((options, state) => {
107
+ const search = state.inputValue.toLowerCase();
108
+ return options.filter((option) => {
109
+ var _a, _b;
110
+ const nameMatch = (_a = option.name) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(search);
111
+ const descMatch = (_b = option.description) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(search);
112
+ return nameMatch || descMatch;
113
+ });
114
+ }, []);
115
+ return (_jsx(Root, Object.assign({ className: classes.root, open: open, onOpen: handleOpen, onClose: handleClose, options: tags || [], filterOptions: filterOptions, getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, handleHomeEndKeys: true, clearIcon: null, noOptionsText: _jsx(FormattedMessage, { id: "ui.composer.layer.audience.tags.empty", defaultMessage: "ui.composer.layer.audience.tags.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => (value === null || value === void 0 ? void 0 : value.id) === (option === null || option === void 0 ? void 0 : option.id), inputValue: inputValue, onInputChange: (_e, newInputValue) => setInputValue(newInputValue), renderOption: (props, option, { inputValue }) => {
106
116
  const matches = match(option.name, inputValue);
107
117
  const parts = parse(option.name, matches);
108
- return (_jsx("li", Object.assign({}, props, { children: _jsx(TagChip, Object.assign({ disposable: false, tag: option, label: _jsx(React.Fragment, { children: parts.map((part, index) => (_jsx("span", Object.assign({ style: { fontWeight: part.highlight ? 700 : 400 } }, { children: part.text }), index))) }) }, TagChipProps), option.id) })));
118
+ return (_jsx("li", Object.assign({}, props, { children: _jsx(TagChip, Object.assign({ showDescription: true, disposable: false, tag: option, label: _jsx(React.Fragment, { children: parts.map((part, index) => (_jsx("span", Object.assign({ style: { fontWeight: part.highlight ? 700 : 400 } }, { children: part.text }), index))) }) }, TagChipProps), option.id) })));
109
119
  }, renderInput: (params) => {
110
- return (_jsx(TextField, Object.assign({}, params, TextFieldProps, { InputProps: Object.assign(Object.assign({}, params.InputProps), { autoComplete: 'addressing', endAdornment: tags.length > 0 ? (_jsxs(Fragment, { children: [' ', loading && _jsx(CircularProgress, { color: "inherit", size: 20 }), params.InputProps.endAdornment] })) : null }) })));
120
+ return (_jsx(TextField, Object.assign({}, params, TextFieldProps, { InputProps: Object.assign(Object.assign({}, params.InputProps), { autoComplete: 'tags', endAdornment: tags.length > 0 ? (_jsxs(Fragment, { children: [loading && _jsx(CircularProgress, { color: "inherit", size: 20 }), params.InputProps.endAdornment] })) : null }) })));
111
121
  } }, rest)));
112
122
  };
113
123
  export default TagAutocomplete;
@@ -72,5 +72,10 @@ export interface TagChipProps {
72
72
  * @default false
73
73
  */
74
74
  ellipsis?: boolean;
75
+ /**
76
+ * If `true`, shows the description of the tag on hover (desktop) or long press (mobile).
77
+ * @default false
78
+ */
79
+ showDescription?: boolean;
75
80
  }
76
81
  export default function TagChip(props: TagChipProps): JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { __rest } from "tslib";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { styled, Chip } from '@mui/material';
3
+ import { styled, Chip, Tooltip } from '@mui/material';
4
4
  import classNames from 'classnames';
5
5
  const PREFIX = 'SCTagChip';
6
6
  const classes = {
@@ -21,7 +21,7 @@ const Root = styled(Chip, {
21
21
  }));
22
22
  export default function TagChip(props) {
23
23
  // PROPS
24
- const { tag, clickable = true, disposable = true, label = null, ellipsis = false, onClick = null, onDelete = null, className = null } = props, rest = __rest(props, ["tag", "clickable", "disposable", "label", "ellipsis", "onClick", "onDelete", "className"]);
24
+ const { tag, clickable = true, disposable = true, label = null, ellipsis = false, onClick = null, onDelete = null, className = null, showDescription = false } = props, rest = __rest(props, ["tag", "clickable", "disposable", "label", "ellipsis", "onClick", "onDelete", "className", "showDescription"]);
25
25
  // HANDLERS
26
26
  const handleClick = () => {
27
27
  onClick && onClick(tag.id);
@@ -29,8 +29,12 @@ export default function TagChip(props) {
29
29
  const handleDelete = () => {
30
30
  onDelete && onDelete(tag.id);
31
31
  };
32
+ const root = (_jsx(Root, Object.assign({ className: classNames(className, { [classes.ellipsis]: ellipsis }), sx: { backgroundColor: `${tag.color}`, color: (theme) => theme.palette.getContrastText(tag.color) } }, (clickable && { onClick: handleClick }), (disposable && { onDelete: handleDelete }), { label: label ? label : tag.name }, rest)));
32
33
  /**
33
34
  * Renders root object
34
35
  */
35
- return (_jsx(Root, Object.assign({ className: classNames(className, { [classes.ellipsis]: ellipsis }), sx: { backgroundColor: `${tag.color}`, color: (theme) => theme.palette.getContrastText(tag.color) } }, (clickable && { onClick: handleClick }), (disposable && { onDelete: handleDelete }), { label: label ? label : tag.name }, rest)));
36
+ if (showDescription && tag.description) {
37
+ return (_jsx(Tooltip, Object.assign({ title: tag.description, placement: "right", arrow: true }, { children: root })));
38
+ }
39
+ return root;
36
40
  }