tycho-components 0.34.0 → 0.35.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -56,12 +56,12 @@ export default function AppForm({ fields, form, prefix, onChangeFunctions = {},
56
56
  return (_jsx(DatePickerField, { attr: name, label: field.size === 'small' ? undefined : field.name, createdForm: form, disabled: field.disabled, required: field.required, onChange: (_attr, value) => handleChange?.(value), onBlur: handleBlur, height: field.size === 'small' ? '32px' : undefined }, name));
57
57
  }
58
58
  if (field.type === 'textarea') {
59
- return (_jsx(TextField, { attr: name, label: field.name, createdForm: form, disabled: field.disabled, required: field.required, onChange: (value) => handleChange?.(value), multiline: true, rows: field.rows, height: "100%" }, name));
59
+ return (_jsx(TextField, { attr: name, label: field.name, createdForm: form, disabled: field.disabled, required: field.required, onChange: (value) => handleChange?.(value), multiline: true, rows: field.rows, height: "100%", infoText: field.infoText, defaultEndAdornments: field.infoText ? ['info'] : ['close'] }, name));
60
60
  }
61
61
  if (field.type === 'color') {
62
62
  return (_jsx(FormColorField, { attr: name, label: field.name, form: form, disabled: field.disabled, tooltipText: field.tooltipText }, name));
63
63
  }
64
64
  const handleBlur = getOnBlurFn(field.attr);
65
- return (_jsx(TextField, { attr: name, label: field.size === 'small' ? undefined : field.name, placeholder: field.size === 'small' ? field.name : undefined, createdForm: form, mask: field.mask, blurMask: field.blurMask, disabled: field.disabled, required: field.required, onChange: (value) => handleChange?.(value), height: field.size === 'small' ? '32px' : undefined, onBlur: handleBlur }, name));
65
+ return (_jsx(TextField, { attr: name, label: field.size === 'small' ? undefined : field.name, placeholder: field.size === 'small' ? field.name : undefined, createdForm: form, mask: field.mask, blurMask: field.blurMask, disabled: field.disabled, required: field.required, onChange: (value) => handleChange?.(value), height: field.size === 'small' ? '32px' : undefined, onBlur: handleBlur, infoText: field.infoText, defaultEndAdornments: field.infoText ? ['info'] : ['close'] }, name));
66
66
  }) }));
67
67
  }
@@ -18,6 +18,7 @@ export type AppFormField = {
18
18
  options?: SelectItem[];
19
19
  tooltip?: boolean;
20
20
  tooltipText?: string;
21
+ infoText?: string;
21
22
  multiple?: boolean;
22
23
  freeSolo?: boolean;
23
24
  minQueryLength?: number;
@@ -2,10 +2,11 @@ import './style.scss';
2
2
  import { Comment } from './types/Comment';
3
3
  type Props = {
4
4
  comment: Comment;
5
+ hasEditAccess?: boolean;
5
6
  onRemove: () => void;
6
7
  onUpdate: (c: Comment) => void;
7
8
  onEdit: () => void;
8
9
  onReply: () => void;
9
10
  };
10
- export default function CommentInfo({ comment, onRemove, onUpdate, onEdit, onReply, }: Props): import("react/jsx-runtime").JSX.Element;
11
+ export default function CommentInfo({ comment, hasEditAccess, onRemove, onUpdate, onEdit, onReply, }: Props): import("react/jsx-runtime").JSX.Element;
11
12
  export {};
@@ -6,7 +6,7 @@ import CommonContext from '../../configs/CommonContext';
6
6
  import DateUtils from '../../functions/DateUtils';
7
7
  import './style.scss';
8
8
  import CommentService from './CommentService';
9
- export default function CommentInfo({ comment, onRemove, onUpdate, onEdit, onReply, }) {
9
+ export default function CommentInfo({ comment, hasEditAccess = true, onRemove, onUpdate, onEdit, onReply, }) {
10
10
  const { t } = useTranslation('comments');
11
11
  const { state } = useContext(CommonContext);
12
12
  const handleMarkRead = () => {
@@ -27,5 +27,5 @@ export default function CommentInfo({ comment, onRemove, onUpdate, onEdit, onRep
27
27
  return false;
28
28
  return !requested.read;
29
29
  };
30
- return (_jsxs("div", { className: "comment", children: [_jsxs("div", { className: "top", children: [_jsx(Avatar, { title: comment.name, src: comment.picture, size: comment.reply ? 'small' : 'medium' }), _jsx("div", { className: "name", children: comment.name }), _jsxs("div", { className: "buttons", children: [!comment.reply && (_jsx(IconButton, { size: "small", onClick: onReply, title: t('tooltip.reply'), name: "reply" })), state.logged?.uid === comment.user && (_jsxs(_Fragment, { children: [_jsx(IconButton, { size: comment.reply ? 'x-small' : 'small', onClick: onEdit, title: t('tooltip.edit'), name: "edit" }), _jsx(IconButton, { size: comment.reply ? 'x-small' : 'small', onClick: handleRemove, title: t('tooltip.delete'), name: "delete" })] })), isNotRead(comment) && (_jsx(IconButton, { size: comment.reply ? 'x-small' : 'small', onClick: handleMarkRead, title: t('tooltip.read'), name: "check_circle" }))] })] }), _jsxs("div", { className: "content", children: [comment.title && _jsx("div", { className: "title", children: comment.title }), _jsx("div", { className: "text", children: comment.value }), comment.requested && (_jsxs("div", { className: "date", children: [_jsx("span", { className: "me-1", children: t('label.requested.to') }), _jsx("span", { children: comment.requested.map((e) => e.name).join(', ') })] })), _jsxs("div", { className: "date", children: [_jsx("span", { className: "me-1", children: t('label.posted.on') }), _jsx("span", { className: "me-1", children: DateUtils.formatDateTime(comment.edited ? comment.edited : comment.date, 'MM/dd/yyyy - HH:mm') }), comment.edited && _jsx("i", { children: t('label.edited') })] })] })] }));
30
+ return (_jsxs("div", { className: "comment", children: [_jsxs("div", { className: "top", children: [_jsx(Avatar, { title: comment.name, src: comment.picture, size: comment.reply ? 'small' : 'medium' }), _jsx("div", { className: "name", children: comment.name }), _jsxs("div", { className: "buttons", children: [hasEditAccess && !comment.reply && (_jsx(IconButton, { size: "small", onClick: onReply, title: t('tooltip.reply'), name: "reply" })), hasEditAccess && state.logged?.uid === comment.user && (_jsxs(_Fragment, { children: [_jsx(IconButton, { size: comment.reply ? 'x-small' : 'small', onClick: onEdit, title: t('tooltip.edit'), name: "edit" }), _jsx(IconButton, { size: comment.reply ? 'x-small' : 'small', onClick: handleRemove, title: t('tooltip.delete'), name: "delete" })] })), isNotRead(comment) && (_jsx(IconButton, { size: comment.reply ? 'x-small' : 'small', onClick: handleMarkRead, title: t('tooltip.read'), name: "check_circle" }))] })] }), _jsxs("div", { className: "content", children: [comment.title && _jsx("div", { className: "title", children: comment.title }), _jsx("div", { className: "text", children: comment.value }), comment.requested && (_jsxs("div", { className: "date", children: [_jsx("span", { className: "me-1", children: t('label.requested.to') }), _jsx("span", { children: comment.requested.map((e) => e.name).join(', ') })] })), _jsxs("div", { className: "date", children: [_jsx("span", { className: "me-1", children: t('label.posted.on') }), _jsx("span", { className: "me-1", children: DateUtils.formatDateTime(comment.edited ? comment.edited : comment.date, 'MM/dd/yyyy - HH:mm') }), comment.edited && _jsx("i", { children: t('label.edited') })] })] })] }));
31
31
  }
@@ -34,7 +34,7 @@ export default function Comments({ uid, keywords, references, mode, onClose, onC
34
34
  };
35
35
  const hasEditAccess = useMemo(() => {
36
36
  return SecurityUtils.hasAccess(uid, ['ADMIN', 'EDITOR'], mode);
37
- }, [uid]);
37
+ }, [uid, mode]);
38
38
  const hasReplies = (thisComment) => comments && comments.some((c) => c.reply === thisComment.id);
39
39
  const getReplies = (thisComment) => comments?.filter((c) => c.reply === thisComment.id) || [];
40
40
  useEffect(() => {
@@ -43,7 +43,7 @@ export default function Comments({ uid, keywords, references, mode, onClose, onC
43
43
  return (_jsx(Drawer, { anchor: "right", open: true, onClose: onClose, children: !comments ? (_jsx(AppLoading, {})) : (_jsxs("div", { className: "comments-container", id: "comment-top", children: [_jsxs("div", { className: "header", children: [_jsx(IconButton, { name: "close", size: "small", mode: "ghost", onClick: onClose }), _jsx("span", { className: "title", children: t('label.title.comments') }), _jsx("div", { className: "actions", children: hasEditAccess && (_jsx(Button, { text: t('button.add'), icon: "add", mode: "outlined", size: "small", className: "edit-button", onClick: () => {
44
44
  setComment(undefined);
45
45
  setOpenAddComment(!openAddComment);
46
- } })) })] }), _jsxs("div", { className: "body", children: [openAddComment && (_jsx(CommentAdd, { uid: uid, mode: mode, users: users, references: references, keywords: keywords, comment: comment, reply: reply, onClose: () => {
46
+ } })) })] }), _jsxs("div", { className: "body", children: [hasEditAccess && openAddComment && (_jsx(CommentAdd, { uid: uid, mode: mode, users: users, references: references, keywords: keywords, comment: comment, reply: reply, onClose: () => {
47
47
  setComment(undefined);
48
48
  setReply(undefined);
49
49
  setOpenAddComment(false);
@@ -59,7 +59,7 @@ export default function Comments({ uid, keywords, references, mode, onClose, onC
59
59
  setComments(updated);
60
60
  onChange?.(updated);
61
61
  }
62
- } })), comments?.length === 0 && (_jsx(AppPlaceholder, { text: t('placeholder.comments.empty') })), comments?.map((el, idx) => (_jsxs("div", { className: "thread", children: [!el.reply && (_jsx(CommentInfo, { comment: el, onRemove: () => {
62
+ } })), comments?.length === 0 && (_jsx(AppPlaceholder, { text: t('placeholder.comments.empty') })), comments?.map((el, idx) => (_jsxs("div", { className: "thread", children: [!el.reply && (_jsx(CommentInfo, { comment: el, hasEditAccess: hasEditAccess, onRemove: () => {
63
63
  const updated = comments?.filter((c) => c.id !== el.id);
64
64
  setComments(updated);
65
65
  onChange && onChange(updated || []);
@@ -75,7 +75,7 @@ export default function Comments({ uid, keywords, references, mode, onClose, onC
75
75
  setReply(el);
76
76
  setOpenAddComment(true);
77
77
  UsabilityUtils.goToAnchor('comment-top');
78
- } })), hasReplies(el) && (_jsx("div", { className: "replies", children: getReplies(el).map((rel, idy) => (_jsx(CommentInfo, { comment: rel, onRemove: () => {
78
+ } })), hasReplies(el) && (_jsx("div", { className: "replies", children: getReplies(el).map((rel, idy) => (_jsx(CommentInfo, { comment: rel, hasEditAccess: hasEditAccess, onRemove: () => {
79
79
  const updated = comments?.filter((c) => c.id !== rel.id);
80
80
  setComments(updated);
81
81
  onChange && onChange(updated || []);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.34.0",
4
+ "version": "0.35.1",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {