tycho-components 0.40.9 → 0.41.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.
Files changed (28) hide show
  1. package/dist/configs/api/applyAuthErrorHandling.js +2 -3
  2. package/dist/configs/localization/CommentsTexts.d.ts +24 -0
  3. package/dist/configs/localization/CommentsTexts.js +24 -0
  4. package/dist/features/Comments/{CommentAdd.d.ts → CommentAdd/CommentAdd.d.ts} +6 -4
  5. package/dist/features/Comments/CommentAdd/CommentAdd.js +107 -0
  6. package/dist/features/Comments/CommentAdd/index.d.ts +2 -0
  7. package/dist/features/Comments/CommentAdd/index.js +2 -0
  8. package/dist/features/Comments/CommentAdd/style.scss +124 -0
  9. package/dist/features/Comments/CommentInfo.d.ts +1 -0
  10. package/dist/features/Comments/CommentInfo.js +8 -4
  11. package/dist/features/Comments/CommentService.d.ts +9 -8
  12. package/dist/features/Comments/CommentService.js +74 -0
  13. package/dist/features/Comments/CommentService.mock.d.ts +4 -0
  14. package/dist/features/Comments/CommentService.mock.js +67 -0
  15. package/dist/features/Comments/CommentThread.d.ts +11 -0
  16. package/dist/features/Comments/CommentThread.js +14 -0
  17. package/dist/features/Comments/CommentUtils.d.ts +24 -0
  18. package/dist/features/Comments/CommentUtils.js +175 -0
  19. package/dist/features/Comments/Comments.d.ts +3 -1
  20. package/dist/features/Comments/Comments.js +254 -49
  21. package/dist/features/Comments/style.scss +178 -66
  22. package/dist/features/Comments/types/Comment.d.ts +0 -2
  23. package/dist/functions/StorybookUtils.d.ts +4 -0
  24. package/dist/functions/StorybookUtils.js +8 -0
  25. package/dist/functions/index.d.ts +1 -0
  26. package/dist/functions/index.js +1 -0
  27. package/package.json +4 -3
  28. package/dist/features/Comments/CommentAdd.js +0 -70
@@ -1,7 +1,98 @@
1
+ .comments-drawer-paper {
2
+ overflow: hidden;
3
+
4
+ &:not(.dock-bottom) {
5
+ width: 40vw;
6
+ max-width: 90vw;
7
+ min-width: 320px;
8
+ }
9
+
10
+ &.dock-bottom {
11
+ width: 100%;
12
+ max-width: none;
13
+ min-width: 0;
14
+ max-height: 90vh;
15
+ min-height: 200px;
16
+ }
17
+ }
18
+
19
+ .comments-undocked-root {
20
+ width: 100%;
21
+ height: 100%;
22
+ overflow: hidden;
23
+ background-color: var(--background-default);
24
+ }
25
+
1
26
  .comments-container {
27
+ position: relative;
2
28
  display: flex;
3
29
  flex-direction: column;
4
- width: 25vw;
30
+ width: 100%;
31
+ height: 100%;
32
+ overflow: hidden;
33
+
34
+ > .comments-resize-handle {
35
+ position: absolute;
36
+ z-index: 2;
37
+ touch-action: none;
38
+
39
+ &::after {
40
+ content: '';
41
+ position: absolute;
42
+ background-color: transparent;
43
+ transition: background-color 0.15s ease;
44
+ }
45
+
46
+ &:hover::after,
47
+ &:active::after {
48
+ background-color: var(--border-hover);
49
+ }
50
+ }
51
+
52
+ &.dock-right > .comments-resize-handle {
53
+ top: 0;
54
+ left: 0;
55
+ width: 6px;
56
+ height: 100%;
57
+ cursor: col-resize;
58
+
59
+ &::after {
60
+ top: 0;
61
+ left: 0;
62
+ width: 2px;
63
+ height: 100%;
64
+ }
65
+ }
66
+
67
+ &.dock-left > .comments-resize-handle {
68
+ top: 0;
69
+ right: 0;
70
+ width: 6px;
71
+ height: 100%;
72
+ cursor: col-resize;
73
+
74
+ &::after {
75
+ top: 0;
76
+ right: 0;
77
+ width: 2px;
78
+ height: 100%;
79
+ }
80
+ }
81
+
82
+ &.dock-bottom > .comments-resize-handle {
83
+ top: 0;
84
+ left: 0;
85
+ width: 100%;
86
+ height: 6px;
87
+ cursor: row-resize;
88
+
89
+ &::after {
90
+ top: 0;
91
+ left: 0;
92
+ width: 100%;
93
+ height: 2px;
94
+ }
95
+ }
5
96
 
6
97
  > .header {
7
98
  display: flex;
@@ -12,132 +103,153 @@
12
103
  > .title {
13
104
  @include tag-medium-1;
14
105
  color: var(--text-secondary);
15
- margin-left: 8px;
106
+ margin-left: var(--spacing-100);
16
107
  }
17
108
 
18
109
  > .actions {
19
110
  display: flex;
111
+ align-items: center;
20
112
  margin-left: auto;
113
+ gap: var(--spacing-100);
21
114
 
22
115
  .edit-button {
23
- margin-right: var(--spacing-100);
116
+ margin-right: 0;
24
117
  }
25
118
  }
26
119
  }
27
120
 
28
121
  > .body {
29
- padding: var(--spacing-0) var(--spacing-250);
30
- background-color: #fff;
31
- padding: 16px;
122
+ flex: 1;
123
+ overflow-y: auto;
124
+ padding: var(--spacing-200);
125
+ background-color: var(--background-default);
32
126
 
33
127
  .thread {
34
- border-bottom: 1px solid var(--border-subtle-1);
128
+ display: flex;
129
+ flex-direction: column;
130
+ gap: var(--spacing-200);
131
+
132
+ & + .thread {
133
+ margin-top: var(--spacing-100);
134
+ }
35
135
 
36
136
  .comment {
37
137
  display: flex;
38
138
  flex-direction: column;
39
- padding: var(--spacing-150) var(--spacing-100);
139
+ border: 1px solid var(--border-subtle-1);
140
+ border-radius: var(--radius-200);
141
+ overflow: hidden;
142
+ background-color: var(--background-default);
40
143
 
41
- .top {
144
+ .comment-header {
42
145
  display: flex;
43
146
  align-items: center;
147
+ gap: var(--spacing-100);
148
+ padding: 4px 8px;
149
+ background-color: var(--layer-hover-2);
150
+ border-bottom: 1px solid var(--border-subtle-1);
44
151
 
45
152
  > .ds-avatar {
46
- margin-right: 8px;
153
+ flex-shrink: 0;
154
+ }
155
+
156
+ .meta {
157
+ display: flex;
158
+ align-items: baseline;
159
+ flex-wrap: wrap;
160
+ gap: var(--spacing-050) var(--spacing-100);
161
+ min-width: 0;
162
+
163
+ .name {
164
+ @include label-medium-1;
165
+ color: var(--text-primary);
166
+ }
167
+
168
+ .timestamp {
169
+ @include helper-small-1;
170
+ color: var(--text-tertiary);
171
+ }
47
172
  }
48
173
 
49
174
  .buttons {
50
175
  display: flex;
51
176
  margin-left: auto;
52
- gap: 8px;
177
+ flex-shrink: 0;
178
+ gap: var(--spacing-100);
53
179
  }
54
180
  }
55
181
 
56
- .content {
57
- margin-top: 16px;
58
-
59
- .title {
60
- @include tag-medium-1;
61
- color: var(--text-accent);
62
- text-transform: none;
63
- margin-bottom: 4px;
64
- }
182
+ .comment-body {
183
+ padding: var(--spacing-200) var(--spacing-150);
184
+ background-color: var(--background-default);
65
185
 
66
186
  .text {
67
187
  @include body-medium-1;
68
188
  color: var(--text-primary);
189
+ word-break: break-word;
190
+
191
+ .wmde-markdown {
192
+ background: transparent;
193
+ font-size: inherit;
194
+ color: inherit;
195
+
196
+ p {
197
+ margin: 0 0 var(--spacing-100);
198
+
199
+ &:last-child {
200
+ margin-bottom: 0;
201
+ }
202
+ }
203
+
204
+ pre,
205
+ code {
206
+ border-radius: var(--radius-100);
207
+ }
208
+
209
+ pre {
210
+ overflow-x: auto;
211
+ }
212
+
213
+ ul,
214
+ ol {
215
+ margin: 0 0 var(--spacing-100);
216
+ padding-left: var(--spacing-250);
217
+ }
218
+ }
69
219
  }
70
220
 
71
- .date {
221
+ .meta-line {
72
222
  @include helper-small-1;
73
223
  color: var(--text-tertiary);
74
- margin-top: 8px;
224
+ margin-top: var(--spacing-100);
75
225
  }
76
226
  }
77
227
  }
78
228
 
79
229
  .replies {
80
- margin-left: 32px;
81
-
82
- .comment {
83
- margin-top: 8px;
84
-
85
- .top {
86
- .name {
87
- font-size: 14px !important;
88
- }
89
- }
90
-
91
- .content {
92
- .title {
93
- font-size: 13px !important;
94
- }
95
-
96
- .text {
97
- font-size: 13px !important;
98
- }
99
- }
100
- }
101
- }
102
- }
103
-
104
- .form {
105
- display: flex;
106
- flex-direction: column;
107
- padding-bottom: 16px;
108
- border-bottom: 1px solid var(--border-subtle-1);
109
-
110
- > .ds-input-text,
111
- > .ds-select-text {
112
- margin-bottom: 8px;
113
- }
114
-
115
- > .buttons {
230
+ margin-left: var(--spacing-400);
116
231
  display: flex;
117
- gap: 8px;
118
-
119
- > .ds-button {
120
- width: 100%;
121
- }
232
+ flex-direction: column;
233
+ gap: var(--spacing-100);
122
234
  }
123
235
  }
124
236
  }
125
237
  }
126
238
 
127
239
  @media (max-width: 1366px) {
128
- .comments-container {
240
+ .comments-drawer-paper:not(.dock-bottom) {
129
241
  width: 40vw;
130
242
  }
131
243
  }
132
244
 
133
245
  @media (max-width: 768px) {
134
- .comments-container {
246
+ .comments-drawer-paper:not(.dock-bottom) {
135
247
  width: 60vw;
136
248
  }
137
249
  }
138
250
 
139
251
  @media (max-width: 767px) {
140
- .comments-container {
252
+ .comments-drawer-paper:not(.dock-bottom) {
141
253
  width: 90vw;
142
254
  }
143
255
  }
@@ -1,13 +1,11 @@
1
1
  export type CommentRequest = {
2
2
  id?: string;
3
- title?: string;
4
3
  value?: string;
5
4
  requested?: string[];
6
5
  coordinates?: string[];
7
6
  };
8
7
  export type Comment = {
9
8
  id: string;
10
- title?: string;
11
9
  value: string;
12
10
  date: string;
13
11
  edited?: string;
@@ -0,0 +1,4 @@
1
+ declare const StorybookUtils: {
2
+ isStorybook: () => boolean;
3
+ };
4
+ export default StorybookUtils;
@@ -0,0 +1,8 @@
1
+ /** True when running inside Storybook (dev server on port 6006, or the `__STORYBOOK__` flag set in .storybook/preview.tsx). */
2
+ const isStorybook = () => typeof window !== 'undefined' &&
3
+ Boolean(window.location.port === '6006' ||
4
+ window.__STORYBOOK__);
5
+ const StorybookUtils = {
6
+ isStorybook,
7
+ };
8
+ export default StorybookUtils;
@@ -5,6 +5,7 @@ export { default as FormUtils } from './FormUtils';
5
5
  export { default as ImageUtils } from './ImageUtils';
6
6
  export { default as SecurityUtils } from './SecurityUtils';
7
7
  export { default as SentenceUtils } from './SentenceUtils';
8
+ export { default as StorybookUtils } from './StorybookUtils';
8
9
  export { EDITION_TOOLS, default as ToolsUtils, type PlatformTools, } from './ToolsUtils';
9
10
  export type { OpenDocumentParams, RedirectPageParams } from './ToolsUtils';
10
11
  export { default as UsabilityUtils } from './UsabilityUtils';
@@ -5,6 +5,7 @@ export { default as FormUtils } from './FormUtils';
5
5
  export { default as ImageUtils } from './ImageUtils';
6
6
  export { default as SecurityUtils } from './SecurityUtils';
7
7
  export { default as SentenceUtils } from './SentenceUtils';
8
+ export { default as StorybookUtils } from './StorybookUtils';
8
9
  export { EDITION_TOOLS, default as ToolsUtils, } from './ToolsUtils';
9
10
  export { default as UsabilityUtils } from './UsabilityUtils';
10
11
  export { conlluViewerConfigurations } from './conllu/ConlluViewerConstants';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.40.9",
4
+ "version": "0.41.1",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -51,6 +51,7 @@
51
51
  "@svgdotjs/svg.js": "^3.2.4",
52
52
  "@svgdotjs/svg.panzoom.js": "^2.1.2",
53
53
  "@tanstack/react-table": "^8.20.6",
54
+ "@uiw/react-md-editor": "^4.1.2",
54
55
  "classnames": "^2.5.1",
55
56
  "cytoscape": "^3.28.1",
56
57
  "cytoscape-dagre": "^2.5.0",
@@ -84,7 +85,7 @@
84
85
  "react-i18next": "^13.0.2",
85
86
  "react-router-dom": "^6.14.2",
86
87
  "react-toastify": "^9.1.3",
87
- "tycho-storybook": "0.11.0",
88
+ "tycho-storybook": "0.12.0",
88
89
  "wavesurfer-react": "^2.2.2",
89
90
  "wavesurfer.js": "^6.6.3"
90
91
  },
@@ -114,7 +115,7 @@
114
115
  "react-toastify": "^9.1.3",
115
116
  "sass-embedded": "^1.97.2",
116
117
  "storybook": "^10.1.11",
117
- "tycho-storybook": "^0.11.0",
118
+ "tycho-storybook": "^0.12.0",
118
119
  "typescript": "^5.7.3",
119
120
  "vite": "^7.0.0",
120
121
  "vitest": "^3.2.6",
@@ -1,70 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { yupResolver } from "@hookform/resolvers/yup";
3
- import { useForm } from "react-hook-form";
4
- import { useTranslation } from "react-i18next";
5
- import { Button, SelectMultipleField, TextField, } from "tycho-storybook";
6
- import * as yup from "yup";
7
- import { useMessageUtils } from "../../configs/useMessageUtils";
8
- import FormUtils from "../../functions/FormUtils";
9
- import "./style.scss";
10
- import { EMPTY_COMMENT_REQUEST, } from "./types/Comment";
11
- import CommentService from "./CommentService";
12
- export default function CommentAdd({ uid, mode, users, references, keywords, comment, reply, onClose, onChange, }) {
13
- const { t } = useTranslation("comments");
14
- const { isLoading, dispatchLoading } = useMessageUtils();
15
- const getFormDefaultValues = () => {
16
- if (comment)
17
- return {
18
- value: comment.value,
19
- title: comment.title,
20
- requested: comment.requested?.map((r) => r.uid),
21
- };
22
- if (reply) {
23
- return {
24
- ...EMPTY_COMMENT_REQUEST,
25
- reply: reply.id,
26
- requested: [reply.user],
27
- };
28
- }
29
- return EMPTY_COMMENT_REQUEST;
30
- };
31
- const createdForm = useForm({
32
- resolver: yupResolver(getFormSchema(t)),
33
- mode: "onChange",
34
- defaultValues: getFormDefaultValues(),
35
- });
36
- const handleAdd = () => {
37
- if (isLoading())
38
- return;
39
- dispatchLoading(true);
40
- CommentService.add(uid, mode, createdForm.getValues(), references, keywords).then((r) => {
41
- dispatchLoading(false);
42
- onClose();
43
- onChange(r.data);
44
- createdForm.reset(EMPTY_COMMENT_REQUEST);
45
- });
46
- };
47
- const handleUpdate = () => {
48
- if (!comment)
49
- return;
50
- CommentService.update(comment.id, createdForm.getValues()).then((r) => {
51
- onClose();
52
- onChange(r.data);
53
- createdForm.reset(EMPTY_COMMENT_REQUEST);
54
- });
55
- };
56
- return (_jsxs("div", { className: "form", children: [_jsx(TextField, { label: t("input.value"), attr: "value", createdForm: createdForm, showEndAdornment: false, placeholder: t("common:generic.placeholder"), required: true, multiline: true }), _jsx(TextField, { label: t("input.title"), attr: "title", createdForm: createdForm, showEndAdornment: false, placeholder: t("common:generic.placeholder") }), _jsx(SelectMultipleField, { label: reply ? t("input.user.reply") : t("input.user"), attr: "requested", createdForm: createdForm, options: [
57
- {
58
- label: t("common:generic.placeholder.select"),
59
- value: "",
60
- },
61
- ...FormUtils.convertList(users, "name", "uid"),
62
- ], showEndAdornment: false }), _jsxs("div", { className: "buttons", children: [_jsx(Button, { onClick: onClose, text: t("button.discard"), color: "danger" }), _jsx(Button, { onClick: comment ? handleUpdate : handleAdd, text: comment ? t("label.button.update") : t("label.button.add"), disabled: !createdForm.formState.isValid })] })] }));
63
- }
64
- const getFormSchema = (t) => yup.object().shape({
65
- id: yup.string().optional(),
66
- title: yup.string().optional(),
67
- value: yup.string().required(t("common:validation.required")),
68
- requested: yup.array().of(yup.string().defined()).optional(),
69
- coordinates: yup.array().of(yup.string().defined()).optional(),
70
- });