@appquality/unguess-design-system 3.1.65 → 3.1.67

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/CHANGELOG.md CHANGED
@@ -1,3 +1,34 @@
1
+ # v3.1.67 (Wed Jan 24 2024)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - Minor changes [#305](https://github.com/AppQuality/unguess-design-system/pull/305) ([@cannarocks](https://github.com/cannarocks) [@iDome89](https://github.com/iDome89) [@marcbon](https://github.com/marcbon))
6
+ - fixed behaviour when editor is empty [#304](https://github.com/AppQuality/unguess-design-system/pull/304) ([@iDome89](https://github.com/iDome89))
7
+ - 🔧 fix(chat): fix typo in mentionList.tsx [#303](https://github.com/AppQuality/unguess-design-system/pull/303) ([@marcbon](https://github.com/marcbon))
8
+ - Comments design refinement [#302](https://github.com/AppQuality/unguess-design-system/pull/302) ([@iDome89](https://github.com/iDome89) [@marcbon](https://github.com/marcbon))
9
+ - chore(storybook): add extension [#301](https://github.com/AppQuality/unguess-design-system/pull/301) ([@cannarocks](https://github.com/cannarocks))
10
+
11
+ #### Authors: 3
12
+
13
+ - [@iDome89](https://github.com/iDome89)
14
+ - Luca Cannarozzo ([@cannarocks](https://github.com/cannarocks))
15
+ - Marco Bonomo ([@marcbon](https://github.com/marcbon))
16
+
17
+ ---
18
+
19
+ # v3.1.66 (Fri Jan 19 2024)
20
+
21
+ #### 🐛 Bug Fix
22
+
23
+ - Fix editable comments in chat [#300](https://github.com/AppQuality/unguess-design-system/pull/300) ([@marcbon](https://github.com/marcbon))
24
+ - 🎨 style(comment.tsx): update ReadOnly style to make it more readable [#299](https://github.com/AppQuality/unguess-design-system/pull/299) ([@marcbon](https://github.com/marcbon))
25
+
26
+ #### Authors: 1
27
+
28
+ - Marco Bonomo ([@marcbon](https://github.com/marcbon))
29
+
30
+ ---
31
+
1
32
  # v3.1.65 (Fri Jan 19 2024)
2
33
 
3
34
  #### 🐛 Bug Fix
package/build/index.js CHANGED
@@ -2283,8 +2283,9 @@ const SentimentChart = ({ data, width, height, margin, tooltip, i18n, }) => {
2283
2283
  const ShortcutContainer = styled__default["default"].div `
2284
2284
  display: flex;
2285
2285
  flex-direction: row;
2286
- padding: ${({ theme }) => `${theme.space.sm} ${theme.space.base * 4}px`};
2286
+ padding: ${({ theme }) => `0 ${theme.space.base * 4}px`};
2287
2287
  background-color: ${({ theme }) => theme.palette.grey[100]};
2288
+ font-size: ${({ theme }) => theme.fontSizes.sm};
2288
2289
  `;
2289
2290
  const Text$1 = styled__default["default"](reactTypography.SM) `
2290
2291
  line-height: 1.7;
@@ -2296,7 +2297,7 @@ const SendShortcut = ({ saveText }) => {
2296
2297
  const Footer$4 = styled__default["default"].div `
2297
2298
  display: flex;
2298
2299
  flex-direction: row;
2299
- padding: ${({ theme }) => `${theme.space.sm} 0px`};
2300
+ padding: ${({ theme }) => `${theme.space.xs} 0px ${theme.space.sm}`};
2300
2301
  align-items: center;
2301
2302
  margin: ${({ theme }) => `0 -${theme.space.base * 4}px`};
2302
2303
  justify-content: ${({ showShortcut }) => showShortcut ? "space-between" : "flex-end"};
@@ -2318,7 +2319,8 @@ const ChatContextProvider = ({ onSave, setMentionableUsers, children, }) => {
2318
2319
  if (!result.some((r) => r.id === node.attrs.id))
2319
2320
  result.push({
2320
2321
  id: node.attrs.id,
2321
- name: node.attrs.name
2322
+ name: node.attrs.name,
2323
+ email: node.attrs.email
2322
2324
  });
2323
2325
  }
2324
2326
  });
@@ -2328,7 +2330,7 @@ const ChatContextProvider = ({ onSave, setMentionableUsers, children, }) => {
2328
2330
  editor,
2329
2331
  setEditor,
2330
2332
  triggerSave: () => {
2331
- if (editor && onSave) {
2333
+ if (editor && onSave && !editor.isEmpty) {
2332
2334
  onSave(editor, getMentions(editor));
2333
2335
  editor.commands.clearContent();
2334
2336
  }
@@ -2607,9 +2609,9 @@ const editorStyle = styled.css `
2607
2609
  }
2608
2610
  `;
2609
2611
  const readOnlyStyle = styled.css `
2612
+ pointer-events: none;
2610
2613
  border: none;
2611
- outline: none;
2612
-
2614
+
2613
2615
  .ProseMirror {
2614
2616
  background: transparent;
2615
2617
  border: none;
@@ -2642,7 +2644,6 @@ const EditorContainer$1 = styled__default["default"](reactForms.FauxInput) `
2642
2644
  : `
2643
2645
  margin-left: ${theme.space.sm};
2644
2646
  padding: ${`${theme.space.xxs} ${theme.space.xs}`};
2645
-
2646
2647
  `}
2647
2648
 
2648
2649
  .ProseMirror {
@@ -2862,9 +2863,25 @@ const SvgAtFill = props => /*#__PURE__*/React__namespace.createElement("svg", _e
2862
2863
  d: "M11 5v3h0a3 3 0 01-3 3h0a3 3 0 01-3-3h0a3 3 0 013-3h0a3 3 0 013 3h0v1a2 2 0 002 2h0a2 2 0 002-2V8h0a7 7 0 00-7-7h0a7 7 0 00-7 7h0a7 7 0 007 7h2.8"
2863
2864
  })));
2864
2865
 
2865
- const EditorButton = ({ editor, type, }) => {
2866
- const isActive = editor.isActive(type);
2867
- const getIcon = () => {
2866
+ const MenuContainer = styled__default["default"].div `
2867
+ padding: ${({ theme }) => theme.space.xs} 0;
2868
+ display: flex;
2869
+ flex-direction: row;
2870
+ justify-content: flex-start;
2871
+ align-items: center;
2872
+ gap: ${({ theme }) => theme.space.xxs};
2873
+ `;
2874
+ const VerticalDivider = styled__default["default"].div `
2875
+ width: 2px;
2876
+ height: 24px;
2877
+ background-color: ${({ theme }) => theme.palette.grey[300]};
2878
+ margin: 0 ${({ theme }) => theme.space.xs};
2879
+ `;
2880
+ const CommentBar = ({ editor, i18n, }) => {
2881
+ var _a, _b, _c, _d, _e, _f;
2882
+ if (!editor)
2883
+ return null;
2884
+ const getIcon = (type) => {
2868
2885
  switch (type) {
2869
2886
  case "bold":
2870
2887
  return jsxRuntime.jsx(SvgBoldFill, {});
@@ -2872,9 +2889,11 @@ const EditorButton = ({ editor, type, }) => {
2872
2889
  return jsxRuntime.jsx(SvgItalicFill, {});
2873
2890
  case "mention":
2874
2891
  return jsxRuntime.jsx(SvgAtFill, {});
2892
+ default:
2893
+ return null;
2875
2894
  }
2876
2895
  };
2877
- const handleClick = () => {
2896
+ const handleClick = (type) => {
2878
2897
  switch (type) {
2879
2898
  case "bold":
2880
2899
  return editor.chain().focus().toggleBold().run();
@@ -2884,29 +2903,11 @@ const EditorButton = ({ editor, type, }) => {
2884
2903
  const { from } = editor.state.selection;
2885
2904
  const char = from > 1 ? " @" : "@";
2886
2905
  return editor.commands.insertContent(char);
2906
+ default:
2907
+ return;
2887
2908
  }
2888
2909
  };
2889
- return (jsxRuntime.jsx(IconButton, Object.assign({ size: "small", isBasic: !isActive, isPrimary: isActive, onClick: handleClick }, { children: getIcon() })));
2890
- };
2891
-
2892
- const MenuContainer = styled__default["default"].div `
2893
- padding: ${({ theme }) => theme.space.xxs} 0;
2894
- display: flex;
2895
- flex-direction: row;
2896
- justify-content: flex-start;
2897
- align-items: center;
2898
- `;
2899
- const VerticalDivider = styled__default["default"].div `
2900
- width: 2px;
2901
- height: 24px;
2902
- background-color: ${({ theme }) => theme.palette.grey[300]};
2903
- margin: 0 ${({ theme }) => theme.space.xs};
2904
- `;
2905
- const CommentBar = ({ editor, i18n, }) => {
2906
- var _a, _b, _c, _d, _e, _f;
2907
- if (!editor)
2908
- return null;
2909
- return (jsxRuntime.jsxs(MenuContainer, { children: [jsxRuntime.jsx(Tooltip, Object.assign({ content: (_b = (_a = i18n === null || i18n === void 0 ? void 0 : i18n.menu) === null || _a === void 0 ? void 0 : _a.bold) !== null && _b !== void 0 ? _b : "Bold text", placement: "top", type: "light", size: "small" }, { children: jsxRuntime.jsx(EditorButton, { editor: editor, type: "bold" }) })), jsxRuntime.jsx(Tooltip, Object.assign({ content: (_d = (_c = i18n === null || i18n === void 0 ? void 0 : i18n.menu) === null || _c === void 0 ? void 0 : _c.italic) !== null && _d !== void 0 ? _d : "Italic text", placement: "top", type: "light", size: "small" }, { children: jsxRuntime.jsx(EditorButton, { editor: editor, type: "italic" }) })), jsxRuntime.jsx(VerticalDivider, {}), jsxRuntime.jsx(Tooltip, Object.assign({ content: (_f = (_e = i18n === null || i18n === void 0 ? void 0 : i18n.menu) === null || _e === void 0 ? void 0 : _e.mention) !== null && _f !== void 0 ? _f : "Add a mention", placement: "top", type: "light", size: "small" }, { children: jsxRuntime.jsx(EditorButton, { editor: editor, type: "mention" }) }))] }));
2910
+ return (jsxRuntime.jsxs(MenuContainer, Object.assign({ id: "menu-container" }, { children: [jsxRuntime.jsx(Tooltip, Object.assign({ content: `${(_b = (_a = i18n === null || i18n === void 0 ? void 0 : i18n.menu) === null || _a === void 0 ? void 0 : _a.bold) !== null && _b !== void 0 ? _b : "Bold text"} ${isMac() ? "Cmd" : "Ctrl"} + B`, placement: "top", type: "light", size: "small", hasArrow: false }, { children: jsxRuntime.jsx(IconButton, Object.assign({ size: "small", isBasic: !editor.isActive("bold"), isPrimary: editor.isActive("bold"), isPill: false, onClick: () => handleClick("bold") }, { children: getIcon("bold") })) })), jsxRuntime.jsx(Tooltip, Object.assign({ content: `${(_d = (_c = i18n === null || i18n === void 0 ? void 0 : i18n.menu) === null || _c === void 0 ? void 0 : _c.italic) !== null && _d !== void 0 ? _d : "Italic text"} ${isMac() ? "Cmd" : "Ctrl"} + I`, placement: "top", type: "light", size: "small", hasArrow: false }, { children: jsxRuntime.jsx(IconButton, Object.assign({ size: "small", isBasic: !editor.isActive("italic"), isPrimary: editor.isActive("italic"), isPill: false, onClick: () => handleClick("italic") }, { children: getIcon("italic") })) })), jsxRuntime.jsx(VerticalDivider, {}), jsxRuntime.jsx(Tooltip, Object.assign({ content: (_f = (_e = i18n === null || i18n === void 0 ? void 0 : i18n.menu) === null || _e === void 0 ? void 0 : _e.mention) !== null && _f !== void 0 ? _f : "Add a mention", placement: "top", type: "light", size: "small", hasArrow: false }, { children: jsxRuntime.jsx(IconButton, Object.assign({ size: "small", isBasic: !editor.isActive("mention"), isPrimary: editor.isActive("mention"), isPill: false, onClick: () => handleClick("mention") }, { children: getIcon("mention") })) }))] })));
2910
2911
  };
2911
2912
 
2912
2913
  const CustomMention = Mention__default["default"].extend({
@@ -2986,9 +2987,27 @@ const Item$2 = styled.styled(Button) `
2986
2987
  align-items: flex-start;
2987
2988
  justify-content: center;
2988
2989
  flex-direction: column;
2990
+
2991
+ ${({ isActive }) => isActive &&
2992
+ `
2993
+ background-color: ${getColor(theme.colors.primaryHue, 600, undefined, 0.08)};
2994
+ `}
2989
2995
  `;
2996
+ const EmptyList = styled.styled.div `
2997
+ max-height: 100px;
2998
+ max-width:280px;
2999
+ padding: ${({ theme }) => `${theme.space.xxs} ${theme.space.md}`};
3000
+ `;
3001
+ const EmptyMention = ({ content }) => {
3002
+ return (jsxRuntime.jsx(EmptyList, { children: jsxRuntime.jsx(MD, Object.assign({ style: { color: theme.palette.grey[600] } }, { children: content })) }));
3003
+ };
2990
3004
  const MentionList = React.forwardRef((props, ref) => {
3005
+ var _a, _b;
3006
+ const { editor } = props;
3007
+ const { options } = editor;
3008
+ const { i18n } = options;
2991
3009
  const [selectedIndex, setSelectedIndex] = React.useState(0);
3010
+ const selectedRef = React.useRef(null);
2992
3011
  const selectItem = (index) => {
2993
3012
  const item = props.items[index];
2994
3013
  if (item) {
@@ -3005,6 +3024,11 @@ const MentionList = React.forwardRef((props, ref) => {
3005
3024
  selectItem(selectedIndex);
3006
3025
  };
3007
3026
  React.useEffect(() => setSelectedIndex(0), [props.items]);
3027
+ React.useEffect(() => {
3028
+ if (selectedRef.current) {
3029
+ selectedRef.current.scrollIntoView({ behavior: "smooth" });
3030
+ }
3031
+ }, [selectedIndex]);
3008
3032
  React.useImperativeHandle(ref, () => ({
3009
3033
  onKeyDown: ({ event }) => {
3010
3034
  if (event.key === "ArrowUp") {
@@ -3022,7 +3046,7 @@ const MentionList = React.forwardRef((props, ref) => {
3022
3046
  return false;
3023
3047
  },
3024
3048
  }));
3025
- return (jsxRuntime.jsx("div", Object.assign({ className: "items" }, { children: jsxRuntime.jsx(StyledCard$1, { children: jsxRuntime.jsx(List, { children: props.items.length ? (props.items.map((item, index) => (jsxRuntime.jsx("div", Object.assign({ className: index === selectedIndex ? 'selected' : '' }, { children: jsxRuntime.jsx(Item$2, Object.assign({ isBasic: true, isStretched: true, isAccent: true, isPill: false, onClick: () => selectItem(index) }, { children: jsxRuntime.jsx(MD, Object.assign({ isBold: true, style: { color: theme.palette.black } }, { children: item.name })) }), index) }))))) : (jsxRuntime.jsx("div", Object.assign({ className: "item" }, { children: "No result" }))) }) }) })));
3049
+ return (jsxRuntime.jsx("div", Object.assign({ className: "items" }, { children: jsxRuntime.jsx(StyledCard$1, { children: jsxRuntime.jsx(List, { children: props.items.length ? (props.items.map((item, index) => (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(Item$2, Object.assign({ ref: index === selectedIndex ? selectedRef : undefined, isBasic: true, isStretched: true, isAccent: true, isPill: false, isActive: index === selectedIndex, onClick: () => selectItem(index) }, { children: jsxRuntime.jsx(MD, Object.assign({ isBold: true, style: { color: theme.palette.black } }, { children: item.name })) }), index) })))) : (jsxRuntime.jsx(EmptyMention, { content: (_b = (_a = i18n === null || i18n === void 0 ? void 0 : i18n.mention) === null || _a === void 0 ? void 0 : _a.noResults) !== null && _b !== void 0 ? _b : "No results" })) }) }) })));
3026
3050
  });
3027
3051
 
3028
3052
  /**
@@ -3173,12 +3197,10 @@ const CommentCard = styled.styled(Card) `
3173
3197
  border-radius: 8px;
3174
3198
  `;
3175
3199
  const ReadOnly = styled.styled.div `
3200
+ cursor: text;
3201
+
3176
3202
  > div {
3177
- background-color: ${({ theme }) => theme.palette.grey[100]};
3178
- &:focus {
3179
- box-shadow: none;
3180
- outline: none;
3181
- }
3203
+ background-color: transparent;
3182
3204
  padding: 0;
3183
3205
  }
3184
3206
  `;
@@ -3209,6 +3231,9 @@ const Comment = ({ author, message, children, date, }) => {
3209
3231
  });
3210
3232
  if (!ed)
3211
3233
  return null;
3234
+ ed.setOptions({
3235
+ editable: false,
3236
+ });
3212
3237
  return (jsxRuntime.jsxs(CommentCard, { children: [jsxRuntime.jsxs(AuthorContainer, { children: [jsxRuntime.jsx(Avatar, Object.assign({ avatarType: (_a = author.avatarType) !== null && _a !== void 0 ? _a : "text", style: { flexShrink: 0 } }, { children: author.avatar })), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs(CommentTitle, { children: [(_b = author.name) !== null && _b !== void 0 ? _b : "User", jsxRuntime.jsx(CommentDate, { children: date })] }), jsxRuntime.jsx(ReadOnly, { children: jsxRuntime.jsx(EditorContainer$1, Object.assign({ editable: false }, { children: jsxRuntime.jsx(react.EditorContent, { editor: ed }) })) })] })] }), jsxRuntime.jsx(Footer$3, { children: children })] }));
3213
3238
  };
3214
3239
 
@@ -4,6 +4,7 @@ type validationStatus = "success" | "warning" | "error";
4
4
  export type SuggestedUser = {
5
5
  id: number;
6
6
  name: string;
7
+ email: string;
7
8
  };
8
9
  export interface ChatEditorArgs extends Partial<EditorOptions> {
9
10
  placeholderOptions?: Partial<PlaceholderOptions>;
@@ -17,6 +18,9 @@ export interface ChatEditorArgs extends Partial<EditorOptions> {
17
18
  italic?: string;
18
19
  mention?: string;
19
20
  };
21
+ mention?: {
22
+ noResults?: string;
23
+ };
20
24
  };
21
25
  }
22
26
  export interface Author {
@@ -7,7 +7,7 @@ export type ChatContextType = {
7
7
  setEditor: React.Dispatch<React.SetStateAction<Editor | undefined>>;
8
8
  mentionableUsers: (props: {
9
9
  query: string;
10
- }) => Promise<SuggestedUser[]>;
10
+ }) => SuggestedUser[];
11
11
  };
12
12
  export declare const ChatContext: React.Context<ChatContextType | null>;
13
13
  export declare const ChatContextProvider: ({ onSave, setMentionableUsers, children, }: {
@@ -15,6 +15,6 @@ export declare const ChatContextProvider: ({ onSave, setMentionableUsers, childr
15
15
  children: React.ReactNode;
16
16
  setMentionableUsers: (props: {
17
17
  query: string;
18
- }) => Promise<SuggestedUser[]>;
18
+ }) => SuggestedUser[];
19
19
  }) => import("react/jsx-runtime").JSX.Element;
20
20
  export declare const useChatContext: () => ChatContextType;
@@ -3,6 +3,6 @@ import { SuggestedUser } from "../_types";
3
3
  export declare const editorExtensions: ({ placeholderOptions, mentionableUsers, }: {
4
4
  mentionableUsers: (props: {
5
5
  query: string;
6
- }) => Promise<SuggestedUser[]>;
6
+ }) => SuggestedUser[];
7
7
  placeholderOptions?: Partial<PlaceholderOptions> | undefined;
8
8
  }) => (import("@tiptap/react").Extension<import("@tiptap/extension-typography").TypographyOptions, any> | import("@tiptap/react").Mark<import("@tiptap/extension-link").LinkOptions, any> | import("@tiptap/react").Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/react").Extension<PlaceholderOptions, any> | import("@tiptap/react").Extension<import("@tiptap/extension-character-count").CharacterCountOptions, import("@tiptap/extension-character-count").CharacterCountStorage> | import("@tiptap/react").Node<import("@tiptap/extension-mention").MentionOptions, any>)[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appquality/unguess-design-system",
3
- "version": "3.1.65",
3
+ "version": "3.1.67",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -73,6 +73,7 @@
73
73
  "@babel/preset-react": "^7.18.6",
74
74
  "@babel/preset-typescript": "^7.21.5",
75
75
  "@rollup/plugin-image": "^3.0.2",
76
+ "@storybook/addon-a11y": "^7.6.10",
76
77
  "@storybook/addon-essentials": "^7.0.9",
77
78
  "@storybook/addon-interactions": "^7.0.9",
78
79
  "@storybook/addon-links": "^7.0.9",
@@ -1,5 +0,0 @@
1
- import { Editor } from "@tiptap/react";
2
- export declare const EditorButton: ({ editor, type, }: {
3
- editor: Editor;
4
- type: "bold" | "italic" | "mention";
5
- }) => import("react/jsx-runtime").JSX.Element;