corpushub-design-system 0.1.2 → 0.1.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.
@@ -1,49 +1,492 @@
1
+ // Cytoscape context menus + phrase annotation picker
2
+
3
+ // —— Tokens ——
4
+ $cy-menu-radius: 8px;
5
+ $cy-control-radius: 5px;
6
+ $cy-chip-radius: 999px;
7
+ $cy-font-size: 13px;
8
+ $cy-font-size-sm: 12px;
9
+ $cy-font-size-xs: 11px;
10
+ $cy-gap: 8px;
11
+ $cy-pad-x: 10px;
12
+
13
+ $cy-gold: #e6b422;
14
+ $cy-gold-dark: #c4920a;
15
+ $cy-gold-star: #d4a017;
16
+
17
+ $cy-select-chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%23707276' d='M3 4.5 L6 8 L9 4.5'/></svg>");
18
+
19
+ // —— Mixins ——
20
+ @mixin cy-thin-scrollbar {
21
+ scrollbar-width: thin;
22
+ scrollbar-color: var(--neutral-light-70, #bebfc1) transparent;
23
+ }
24
+
25
+ @mixin cy-focus-ring($offset: 1px, $inset: false) {
26
+ &:focus-visible {
27
+ outline: 2px solid var(--accent-50, #1c83f4);
28
+ outline-offset: $offset;
29
+
30
+ @if $inset {
31
+ border-radius: $cy-control-radius;
32
+ }
33
+ }
34
+ }
35
+
36
+ @mixin cy-focus-gold($offset: 1px) {
37
+ &:focus-visible {
38
+ outline: 2px solid $cy-gold-dark;
39
+ outline-offset: $offset;
40
+ }
41
+ }
42
+
43
+ @mixin cy-disabled {
44
+ &:disabled {
45
+ opacity: 0.5;
46
+ cursor: not-allowed;
47
+ }
48
+ }
49
+
50
+ @mixin cy-reset-button {
51
+ appearance: none;
52
+ border: none;
53
+ background: transparent;
54
+ font: inherit;
55
+ cursor: pointer;
56
+ }
57
+
58
+ @mixin cy-ghost-control {
59
+ @include cy-reset-button;
60
+ color: var(--neutral-light-10, #141415);
61
+ text-align: left;
62
+ }
63
+
64
+ @mixin cy-gold-tint($amount, $base: var(--neutral-light-100, #fff)) {
65
+ background: color-mix(in srgb, $cy-gold $amount, $base);
66
+ }
67
+
68
+ // —— Shared cascade + nested submenu chrome ——
1
69
  .cy-context-menus-cxt-menu {
2
70
  position: absolute;
3
71
  z-index: 1000;
4
72
  display: none;
5
- min-width: 120px;
6
- padding: 4px 0;
7
- background: #fff;
8
- border: 1px solid #ccc;
9
- border-radius: 4px;
10
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
73
+ min-width: 160px;
74
+ padding: 6px;
75
+ background: var(--neutral-light-100, #fff);
76
+ border: 1px solid var(--neutral-light-80, #cbcccd);
77
+ border-radius: $cy-menu-radius;
78
+ box-shadow: 0 4px 18px rgba(32, 37, 49, 0.18);
11
79
  font-family: inherit;
12
- font-size: 14px;
80
+ font-size: $cy-font-size;
81
+ line-height: 1.35;
82
+ color: var(--neutral-light-10, #141415);
83
+
84
+ @include cy-thin-scrollbar;
85
+
86
+ &::selection,
87
+ *::selection {
88
+ background: var(--accent-90, #bce6ff);
89
+ color: var(--neutral-light-10, #141415);
90
+ }
91
+
92
+ // Phrase picker shell (layout: 'picker')
93
+ &.cy-phrase-picker {
94
+ min-width: 240px;
95
+ max-width: min(300px, 92vw);
96
+ padding: 0;
97
+ overflow: hidden;
98
+ }
13
99
  }
14
100
 
15
101
  .cy-context-menus-cxt-menuitem {
16
102
  position: relative;
17
103
  display: flex;
18
104
  align-items: center;
105
+ justify-content: space-between;
106
+ gap: $cy-gap;
19
107
  width: 100%;
20
- padding: 8px 24px 8px 12px;
108
+ margin: 0;
109
+ padding: $cy-gap $cy-pad-x;
21
110
  border: none;
111
+ border-radius: $cy-control-radius;
22
112
  background: transparent;
23
113
  text-align: left;
24
114
  cursor: pointer;
25
115
  white-space: nowrap;
26
- font-size: 18px !important;
116
+ font: inherit;
117
+ font-size: $cy-font-size;
118
+ font-weight: 500;
119
+ color: var(--neutral-light-10, #141415);
27
120
 
28
121
  &:hover:not(:disabled) {
29
122
  z-index: 1;
30
- background: #f0f0f0;
123
+ background: var(--neutral-light-95, #f7f7f8);
31
124
  }
32
125
 
33
- &:disabled {
34
- opacity: 0.5;
35
- cursor: not-allowed;
36
- }
126
+ @include cy-focus-ring(-2px);
127
+ @include cy-disabled;
37
128
  }
38
129
 
39
130
  .cy-context-menus-divider {
40
- border-bottom: 1px solid #eee;
131
+ border-bottom: 1px solid var(--neutral-light-90, #eaeaeb);
132
+ border-radius: 0;
133
+ margin-bottom: 4px;
134
+ padding-bottom: $cy-gap;
41
135
  }
42
136
 
43
137
  .cy-context-menus-submenu-indicator {
44
138
  pointer-events: none;
45
- font-size: 20px !important;
46
- margin-left: 16px;
47
- width: 16px;
48
- height: 16px;
139
+ flex: 0 0 auto;
140
+ margin-left: auto;
141
+ width: 12px;
142
+ height: 12px;
143
+ opacity: 0.7;
144
+ }
145
+
146
+ // —— Phrase annotation picker ——
147
+ .cy-phrase-picker {
148
+ &__select-panel {
149
+ display: flex;
150
+ flex-direction: column;
151
+ gap: $cy-pad-x;
152
+ padding: $cy-pad-x;
153
+ border-top: 1px solid var(--neutral-light-90, #eaeaeb);
154
+ background: var(--neutral-light-100, #fff);
155
+ }
156
+
157
+ &__select-row {
158
+ display: flex;
159
+ align-items: stretch;
160
+ gap: 4px;
161
+
162
+ .cy-phrase-picker__star {
163
+ align-self: stretch;
164
+ width: auto;
165
+ min-width: 32px;
166
+ box-sizing: border-box;
167
+ }
168
+ }
169
+
170
+ &__select {
171
+ flex: 1;
172
+ min-width: 0;
173
+ appearance: none;
174
+ border: 1px solid var(--neutral-light-80, #cbcccd);
175
+ background: var(--neutral-light-100, #fff) $cy-select-chevron no-repeat
176
+ right $cy-pad-x center;
177
+ background-size: 12px;
178
+ border-radius: $cy-control-radius;
179
+ padding: $cy-gap 32px $cy-gap $cy-pad-x;
180
+ font: inherit;
181
+ font-size: $cy-font-size;
182
+ color: var(--neutral-light-10, #141415);
183
+ cursor: pointer;
184
+
185
+ @include cy-focus-ring(1px);
186
+ @include cy-disabled;
187
+ }
188
+
189
+ &__confirm {
190
+ appearance: none;
191
+ align-self: stretch;
192
+ border: none;
193
+ border-radius: $cy-control-radius;
194
+ padding: 9px 14px;
195
+ font: inherit;
196
+ font-size: $cy-font-size;
197
+ font-weight: 600;
198
+ color: var(--neutral-light-100, #fff);
199
+ background: var(--accent-30, #185abd);
200
+ cursor: pointer;
201
+
202
+ &:hover:not(:disabled) {
203
+ background: var(--accent-20, #194c8f);
204
+ }
205
+
206
+ @include cy-focus-ring(2px);
207
+ @include cy-disabled;
208
+ }
209
+
210
+ &__primaries {
211
+ display: flex;
212
+ flex-direction: column;
213
+ gap: 2px;
214
+ padding: 6px;
215
+ border-bottom: 1px solid var(--neutral-light-90, #eaeaeb);
216
+ }
217
+
218
+ &__primary {
219
+ display: flex;
220
+ align-items: stretch;
221
+ gap: 2px;
222
+ border-radius: $cy-control-radius;
223
+
224
+ &:hover {
225
+ background: var(--neutral-light-95, #f7f7f8);
226
+ }
227
+
228
+ &.is-active {
229
+ background: var(--accent-95, #d9f0ff);
230
+
231
+ .cy-phrase-picker__primary-select {
232
+ color: var(--accent-20, #194c8f);
233
+ }
234
+ }
235
+ }
236
+
237
+ &__primary-select {
238
+ @include cy-ghost-control;
239
+ flex: 1;
240
+ min-width: 0;
241
+ display: flex;
242
+ align-items: center;
243
+ justify-content: space-between;
244
+ gap: $cy-gap;
245
+ padding: 9px $cy-pad-x;
246
+ font-size: $cy-font-size;
247
+ font-weight: 500;
248
+ border-radius: $cy-control-radius;
249
+
250
+ @include cy-focus-ring(-2px);
251
+ @include cy-disabled;
252
+ }
253
+
254
+ &__primary-chevron {
255
+ flex: 0 0 auto;
256
+ color: var(--neutral-light-50, #707276);
257
+ font-size: 16px;
258
+ line-height: 1;
259
+ }
260
+
261
+ &__action {
262
+ appearance: none;
263
+ border: 1px solid var(--neutral-light-80, #cbcccd);
264
+ background: var(--neutral-light-100, #fff);
265
+ color: var(--neutral-light-20, #252627);
266
+ border-radius: 4px;
267
+ padding: 4px $cy-pad-x;
268
+ font: inherit;
269
+ font-size: $cy-font-size-sm;
270
+ font-weight: 500;
271
+ cursor: pointer;
272
+
273
+ &:hover:not(:disabled) {
274
+ background: var(--neutral-light-95, #f7f7f8);
275
+ border-color: var(--neutral-light-70, #bebfc1);
276
+ }
277
+
278
+ @include cy-focus-ring(1px);
279
+ @include cy-disabled;
280
+ }
281
+
282
+ &__selected-header {
283
+ display: flex;
284
+ flex-direction: column;
285
+ gap: 0;
286
+ border-bottom: 1px solid var(--neutral-light-90, #eaeaeb);
287
+ background: var(--neutral-light-100, #fff);
288
+ }
289
+
290
+ &__selected-heading {
291
+ display: flex;
292
+ align-items: center;
293
+ gap: $cy-gap;
294
+ min-width: 0;
295
+ padding: $cy-gap $cy-pad-x;
296
+ background: var(--neutral-light-99, #f9fafb);
297
+ }
298
+
299
+ &__back {
300
+ appearance: none;
301
+ flex: 0 0 auto;
302
+ display: inline-flex;
303
+ align-items: center;
304
+ justify-content: center;
305
+ width: 20px;
306
+ height: 20px;
307
+ margin: 0;
308
+ padding: 0;
309
+ border: 1px solid var(--neutral-light-80, #cbcccd);
310
+ border-radius: $cy-control-radius;
311
+ background: var(--neutral-light-100, #fff);
312
+ color: var(--neutral-light-20, #252627);
313
+ cursor: pointer;
314
+
315
+ &:hover {
316
+ background: var(--neutral-light-95, #f7f7f8);
317
+ border-color: var(--neutral-light-70, #bebfc1);
318
+ }
319
+
320
+ @include cy-focus-ring(1px);
321
+ }
322
+
323
+ &__back-icon {
324
+ display: block;
325
+ }
326
+
327
+ &__selected-title {
328
+ flex: 1 1 auto;
329
+ min-width: 0;
330
+ margin: 0;
331
+ overflow: hidden;
332
+ text-overflow: ellipsis;
333
+ white-space: nowrap;
334
+ font-size: $cy-font-size;
335
+ font-weight: 700;
336
+ line-height: 1.3;
337
+ color: var(--neutral-light-10, #141415);
338
+ }
339
+
340
+ &__favorites {
341
+ display: flex;
342
+ flex-direction: column;
343
+ padding: $cy-gap $cy-pad-x $cy-pad-x;
344
+ border-top: 1px solid var(--neutral-light-90, #eaeaeb);
345
+ background: linear-gradient(
346
+ 180deg,
347
+ color-mix(in srgb, $cy-gold 12%, var(--neutral-light-100, #fff)) 0%,
348
+ var(--neutral-light-100, #fff) 100%
349
+ );
350
+ }
351
+
352
+ &__favorites-heading {
353
+ margin: 0 0 6px;
354
+ font-size: $cy-font-size-xs;
355
+ font-weight: 600;
356
+ letter-spacing: 0.02em;
357
+ color: var(--neutral-light-40, #5c5e61);
358
+ }
359
+
360
+ &__favorites-list {
361
+ display: flex;
362
+ flex-wrap: wrap;
363
+ gap: 6px;
364
+ }
365
+
366
+ &__favorite-chip {
367
+ appearance: none;
368
+ border: 1px solid
369
+ color-mix(in srgb, $cy-gold-dark 45%, var(--neutral-light-80, #cbcccd));
370
+ @include cy-gold-tint(18%);
371
+ color: var(--neutral-light-20, #252627);
372
+ border-radius: $cy-chip-radius;
373
+ padding: 3px $cy-pad-x;
374
+ font: inherit;
375
+ font-size: $cy-font-size-sm;
376
+ font-weight: 500;
377
+ cursor: pointer;
378
+ max-width: 100%;
379
+ overflow: hidden;
380
+ text-overflow: ellipsis;
381
+ white-space: nowrap;
382
+
383
+ &:hover:not(:disabled) {
384
+ @include cy-gold-tint(28%);
385
+ }
386
+
387
+ @include cy-focus-gold(1px);
388
+ @include cy-disabled;
389
+ }
390
+
391
+ &__body {
392
+ display: grid;
393
+ grid-template-columns: minmax(112px, 38%) 1fr;
394
+ min-height: 160px;
395
+ max-height: min(280px, 50vh);
396
+ }
397
+
398
+ &__categories,
399
+ &__leaves {
400
+ overflow-y: auto;
401
+ overscroll-behavior: contain;
402
+ @include cy-thin-scrollbar;
403
+ }
404
+
405
+ &__categories {
406
+ border-right: 1px solid var(--neutral-light-90, #eaeaeb);
407
+ background: var(--neutral-light-99, #f9fafb);
408
+ padding: 6px;
409
+ }
410
+
411
+ &__category {
412
+ @include cy-ghost-control;
413
+ display: block;
414
+ width: 100%;
415
+ padding: 7px $cy-pad-x;
416
+ border-radius: $cy-control-radius;
417
+ font-size: $cy-font-size-sm;
418
+ font-weight: 500;
419
+ color: var(--neutral-light-30, #434447);
420
+
421
+ &:hover:not(:disabled):not(.is-active) {
422
+ background: var(--neutral-light-95, #f7f7f8);
423
+ color: var(--neutral-light-10, #141415);
424
+ }
425
+
426
+ &.is-active {
427
+ background: var(--accent-95, #d9f0ff);
428
+ color: var(--accent-20, #194c8f);
429
+ }
430
+
431
+ @include cy-focus-ring(-1px);
432
+ @include cy-disabled;
433
+ }
434
+
435
+ &__leaves {
436
+ padding: 6px;
437
+ background: var(--neutral-light-100, #fff);
438
+ }
439
+
440
+ &__leaf {
441
+ display: flex;
442
+ align-items: stretch;
443
+ gap: 2px;
444
+ border-radius: $cy-control-radius;
445
+
446
+ &:hover {
447
+ background: var(--neutral-light-95, #f7f7f8);
448
+ }
449
+ }
450
+
451
+ &__leaf-apply {
452
+ @include cy-ghost-control;
453
+ flex: 1;
454
+ min-width: 0;
455
+ padding: 7px $cy-gap 7px $cy-pad-x;
456
+ font-size: $cy-font-size;
457
+ overflow: hidden;
458
+ text-overflow: ellipsis;
459
+ white-space: nowrap;
460
+
461
+ @include cy-focus-ring(-2px, $inset: true);
462
+ @include cy-disabled;
463
+ }
464
+
465
+ &__star {
466
+ @include cy-reset-button;
467
+ flex: 0 0 auto;
468
+ display: inline-flex;
469
+ align-items: center;
470
+ justify-content: center;
471
+ width: 32px;
472
+ color: var(--neutral-light-50, #707276);
473
+ border-radius: $cy-control-radius;
474
+
475
+ &:hover:not(:disabled) {
476
+ color: $cy-gold-dark;
477
+ background: color-mix(in srgb, $cy-gold 14%, transparent);
478
+ }
479
+
480
+ @include cy-focus-gold(-2px);
481
+
482
+ &.is-starred {
483
+ color: $cy-gold-star;
484
+ }
485
+
486
+ @include cy-disabled;
487
+ }
488
+
489
+ &__star-icon {
490
+ display: block;
491
+ }
49
492
  }
@@ -8,7 +8,7 @@ export default function ServerErrorReport({ errorContext, corpus, onClose, onSen
8
8
  const { t } = useTranslation('common');
9
9
  const formRef = useRef(null);
10
10
  const [sending, setSending] = useState(false);
11
- const [canSend, setCanSend] = useState(true);
11
+ const [canSend, setCanSend] = useState(false);
12
12
  return (_jsx(AppModal, { title: t('server.error.report.modal.title'), subtitle: t('server.error.report.modal.subtitle'), close: onClose, confirm: () => {
13
13
  void formRef.current?.send();
14
14
  }, disableConfirm: sending || !canSend, confirmLabel: t('server.error.report.modal.send'), className: "server-error-report-modal", children: _jsx(ServerErrorReportForm, { ref: formRef, errorContext: errorContext, corpus: corpus, intent: "error", onSent: onSent, onSendingChange: setSending, onCanSendChange: setCanSend }) }));
@@ -8,27 +8,33 @@ import { Button } from '../../primitives';
8
8
  import { captureTabScreenshot } from './captureTabScreenshot';
9
9
  import { getConsoleLogs } from './consoleCapture';
10
10
  import './styles.scss';
11
- const DEFAULT_USER_MESSAGE = 'No extra information given by the user';
12
11
  const ServerErrorReportForm = forwardRef(function ServerErrorReportForm({ errorContext, corpus, intent = 'error', showSendButton = false, onSent, onSendingChange, onCanSendChange, className, }, ref) {
13
12
  const { t, i18n } = useTranslation('common');
14
13
  const [userMessage, setUserMessage] = useState('');
15
14
  const [sending, setSending] = useState(false);
16
15
  const [sendError, setSendError] = useState(null);
17
- const canSend = !sending;
16
+ const canSend = !!userMessage.trim() && !sending;
18
17
  const placeholderKey = intent === 'feedback'
19
18
  ? 'server.error.report.feedback.placeholder'
20
19
  : 'server.error.report.modal.placeholder';
21
20
  const sendLabelKey = intent === 'feedback'
22
21
  ? 'server.error.report.feedback.send'
23
22
  : 'server.error.report.modal.send';
23
+ const validationKey = intent === 'feedback'
24
+ ? 'server.error.report.feedback.validation'
25
+ : 'server.error.report.validation';
24
26
  const handleSend = async () => {
27
+ if (!userMessage.trim()) {
28
+ setSendError(t(validationKey));
29
+ return;
30
+ }
25
31
  setSending(true);
26
32
  onSendingChange?.(true);
27
33
  setSendError(null);
28
34
  try {
29
35
  const screenshot = await captureTabScreenshot();
30
36
  await ErrorReportService.send({
31
- userMessage: userMessage.trim() || DEFAULT_USER_MESSAGE,
37
+ userMessage,
32
38
  errorContext,
33
39
  sendContext: {
34
40
  locale: i18n.resolvedLanguage || i18n.language,
@@ -21,6 +21,6 @@ export { default as TreeViewSearch } from "./TreeView/TreeViewSearch/TreeViewSea
21
21
  export type { SearchCriteria } from "./TreeView/TreeViewSearch/TreeViewSearch";
22
22
  export { default as CytoscapeMenuCanvas } from "./CytoscapeMenu/CytoscapeMenuCanvas";
23
23
  export { registerCytoscapeContextMenus, contextMenus } from "./CytoscapeMenu";
24
- export type { CytoscapeContextMenuOptions, MenuItemOption, ContextMenusInstance, } from "./CytoscapeMenu";
24
+ export type { CytoscapeContextMenuOptions, MenuItemOption, ContextMenuLayout, ContextMenusInstance, FavoritesAdapter, FavoritesMap, } from "./CytoscapeMenu";
25
25
  export { PageRenderView, collapseElementsForTier, shouldSkipJunctionContinuationElement, shouldSkipSegmentationElement, shouldSkipSegmentationToken, findSegmentationGroupBounds, isTokenBearingCollapsed, tokenRefToToken, isTokenRefVisible, getEditionTierOrder, resolveHighestEditionTierForDisplay, resolveEffectiveEditionTierForDisplay, shouldApplySegmentationOverJunction, JUNCTION_TIER, SEGMENTATION_TIER, } from "./PageRender";
26
26
  export type { PageRenderElement, PageRenderElementType, PageRenderViewProps, PageRenderTokenContext, TokenRef, CollapsedPageRenderElement, TokenClickSource, TokenClickModifiers, } from "./PageRender";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "corpushub-design-system",
3
3
  "private": false,
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -52,6 +52,7 @@
52
52
  },
53
53
  "./styles/main": "./dist/styles/main.scss",
54
54
  "./styles/base/typographs": "./dist/styles/base/_typographs.scss",
55
+ "./features/CytoscapeMenu/style.scss": "./dist/features/CytoscapeMenu/style.scss",
55
56
  "./dist/configs/tour/style.scss": "./dist/configs/tour/style.scss"
56
57
  },
57
58
  "files": [
@@ -136,8 +137,8 @@
136
137
  "scripts": {
137
138
  "start": "storybook dev -p 6006",
138
139
  "build-storybook": "storybook build",
139
- "build": "tsc && node scripts/copy-package-json.js && npm run copy-static",
140
- "build-publish": "tsc && npm run copy-static",
140
+ "build": "tsc -p tsconfig.build.json && node scripts/copy-package-json.js && npm run copy-static",
141
+ "build-publish": "tsc -p tsconfig.build.json && npm run copy-static",
141
142
  "copy-static": "node scripts/copy-static.js",
142
143
  "test": "vitest run"
143
144
  }
@@ -1,38 +0,0 @@
1
- export declare const CXT_MENU_CSS_CLASS = "cy-context-menus-cxt-menu";
2
- export declare const MENUITEM_CSS_CLASS = "cy-context-menus-cxt-menuitem";
3
- export declare const DIVIDER_CSS_CLASS = "cy-context-menus-divider";
4
- export declare const INDICATOR_CSS_CLASS = "cy-context-menus-submenu-indicator";
5
- export interface MenuItemImage {
6
- src: string;
7
- width: number;
8
- height: number;
9
- y: string;
10
- x: string;
11
- }
12
- import type { EventObject } from 'cytoscape';
13
- export interface MenuItemOption {
14
- id: string;
15
- content: string;
16
- tooltipText?: string;
17
- selector: string;
18
- disabled?: boolean;
19
- image?: MenuItemImage;
20
- show?: boolean;
21
- submenu?: MenuItemOption[];
22
- coreAsWell?: boolean;
23
- onClickFunction?: (event: EventObject) => void;
24
- hasTrailingDivider?: boolean;
25
- }
26
- export interface SubmenuIndicatorOption {
27
- src: string;
28
- width: number;
29
- height: number;
30
- }
31
- export interface CytoscapeContextMenuOptions {
32
- evtType?: string;
33
- menuItems?: MenuItemOption[];
34
- menuItemClasses?: string[];
35
- contextMenuClasses?: string[];
36
- submenuIndicator?: SubmenuIndicatorOption;
37
- }
38
- export declare const DEFAULT_OPTS: CytoscapeContextMenuOptions;