corpushub-design-system 0.1.3 → 0.1.5

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 (27) hide show
  1. package/dist/configs/localization/TreeTexts.d.ts +15 -0
  2. package/dist/configs/localization/TreeTexts.js +15 -0
  3. package/dist/features/CytoscapeMenu/CytoscapeMenuCanvas.d.ts +1 -1
  4. package/dist/features/CytoscapeMenu/CytoscapeMenuConstants.d.ts +66 -0
  5. package/dist/features/CytoscapeMenu/{constants.js → CytoscapeMenuConstants.js} +2 -0
  6. package/dist/features/CytoscapeMenu/{utils.d.ts → CytoscapeMenuUtils.d.ts} +5 -0
  7. package/dist/features/CytoscapeMenu/{utils.js → CytoscapeMenuUtils.js} +21 -0
  8. package/dist/features/CytoscapeMenu/context-menu.d.ts +2 -2
  9. package/dist/features/CytoscapeMenu/context-menu.js +17 -15
  10. package/dist/features/CytoscapeMenu/cytoscape-context-menus.d.ts +1 -1
  11. package/dist/features/CytoscapeMenu/cytoscape-context-menus.js +225 -38
  12. package/dist/features/CytoscapeMenu/favorites.d.ts +12 -0
  13. package/dist/features/CytoscapeMenu/favorites.js +77 -0
  14. package/dist/features/CytoscapeMenu/index.d.ts +1 -1
  15. package/dist/features/CytoscapeMenu/phrase-picker.d.ts +90 -0
  16. package/dist/features/CytoscapeMenu/phrase-picker.js +538 -0
  17. package/dist/features/CytoscapeMenu/style.scss +462 -19
  18. package/dist/features/TreeView/TreeView.d.ts +7 -1
  19. package/dist/features/TreeView/TreeView.js +40 -11
  20. package/dist/features/TreeView/TreeViewImportPenn/TreeViewImportPenn.d.ts +7 -0
  21. package/dist/features/TreeView/TreeViewImportPenn/TreeViewImportPenn.js +26 -0
  22. package/dist/features/TreeView/TreeViewImportPenn/index.d.ts +2 -0
  23. package/dist/features/TreeView/TreeViewImportPenn/index.js +2 -0
  24. package/dist/features/TreeView/TreeViewImportPenn/style.scss +22 -0
  25. package/dist/features/index.d.ts +1 -1
  26. package/package.json +4 -3
  27. package/dist/features/CytoscapeMenu/constants.d.ts +0 -38
@@ -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
  }
@@ -1,6 +1,10 @@
1
1
  import { Core } from 'cytoscape';
2
2
  import { Struct } from '../../configs/types/Struct';
3
3
  import './style.scss';
4
+ type RevisionTreeLink = {
5
+ url: string;
6
+ openInNewTab?: boolean;
7
+ };
4
8
  type Props = {
5
9
  struct?: Struct;
6
10
  expression?: string;
@@ -12,7 +16,9 @@ type Props = {
12
16
  cyRef?: React.MutableRefObject<Core | null>;
13
17
  onClickExpression?: () => void;
14
18
  onExpand?: () => void;
19
+ onImportPenn?: (expression: string) => Promise<void> | void;
15
20
  onReadyCustom?: (thisCy: Core) => void;
21
+ revisionTreeLink?: RevisionTreeLink;
16
22
  };
17
- export default function TreeView({ struct, expression, selector, translations, wheelSensitivity, renderWithInfo, placeholder, cyRef, onClickExpression, onExpand, onReadyCustom, }: Props): import("react").JSX.Element;
23
+ export default function TreeView({ struct, expression, selector, translations, wheelSensitivity, renderWithInfo, placeholder, cyRef, onClickExpression, onExpand, onImportPenn, onReadyCustom, revisionTreeLink, }: Props): import("react").JSX.Element;
18
24
  export {};
@@ -3,20 +3,22 @@ import { saveAs } from 'file-saver';
3
3
  import html2canvas from 'html2canvas';
4
4
  import { useEffect, useState } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
- import { IconButton } from '../../primitives';
7
6
  import AppPlaceholder from '../../common/AppPlaceholder';
8
7
  import DateUtils from '../../functions/DateUtils';
9
8
  import SentenceUtils from '../../functions/SentenceUtils';
9
+ import { IconButton } from '../../primitives';
10
+ import TreeViewImportPenn from './TreeViewImportPenn';
10
11
  import TreeViewSearch from './TreeViewSearch/TreeViewSearch';
11
12
  import CytoscapeTreeConverter from './cytoscape/CytoscapeTreeConverter';
12
13
  import SyntreesCytoscape from './cytoscape/SyntreesCytoscape';
13
14
  import './style.scss';
14
- export default function TreeView({ struct, expression, selector = 'canvas-tree', translations, wheelSensitivity, renderWithInfo = false, placeholder, cyRef, onClickExpression, onExpand, onReadyCustom, }) {
15
+ export default function TreeView({ struct, expression, selector = 'canvas-tree', translations, wheelSensitivity, renderWithInfo = false, placeholder, cyRef, onClickExpression, onExpand, onImportPenn, onReadyCustom, revisionTreeLink, }) {
15
16
  const { t } = useTranslation('tree');
16
17
  const [cy, setCy] = useState(null);
17
18
  const [showInfo, setShowInfo] = useState(renderWithInfo);
18
19
  const [invalid, setInvalid] = useState();
19
20
  const [showSearchModal, setShowSearchModal] = useState(false);
21
+ const [showImportModal, setShowImportModal] = useState(false);
20
22
  const [searchCriteria, setSearchCriteria] = useState({
21
23
  syntacticCategory: [],
22
24
  posTag: [],
@@ -111,6 +113,21 @@ export default function TreeView({ struct, expression, selector = 'canvas-tree',
111
113
  const closeSearchModal = () => {
112
114
  setShowSearchModal(false);
113
115
  };
116
+ const openImportModal = () => {
117
+ setShowImportModal(true);
118
+ };
119
+ const closeImportModal = () => {
120
+ setShowImportModal(false);
121
+ };
122
+ const goToRevisionTree = () => {
123
+ if (!revisionTreeLink?.url)
124
+ return;
125
+ if (revisionTreeLink.openInNewTab) {
126
+ window.open(revisionTreeLink.url, '_blank', 'noopener,noreferrer');
127
+ return;
128
+ }
129
+ window.location.assign(revisionTreeLink.url);
130
+ };
114
131
  useEffect(() => {
115
132
  setInvalid(undefined);
116
133
  load();
@@ -119,38 +136,50 @@ export default function TreeView({ struct, expression, selector = 'canvas-tree',
119
136
  return (_jsx(AppPlaceholder, { text: placeholder || t('placeholder.sentence.notparsed') }));
120
137
  }
121
138
  return (_jsxs("div", { className: "tree-view-container", children: [invalid && (_jsx("div", { className: "tree-placeholder-overlay", children: _jsx(AppPlaceholder, { text: placeholder || t('placeholder.sentence.notparsed') }) })), _jsx("div", { className: "floating-buttons", children: cy &&
122
- getButtons(generateImage, reset, onClickExpression || downloadPsd, toggleInfo, onExpand, expression, openSearchModal)
139
+ getButtons(generateImage, reset, onClickExpression || downloadPsd, toggleInfo, onExpand, expression, openSearchModal, goToRevisionTree, revisionTreeLink, onImportPenn ? openImportModal : undefined)
123
140
  .filter((btn) => btn.condition)
124
141
  .map((btn, i) => {
125
142
  return (_jsx(IconButton, { name: btn.icon, title: t(btn.title), onClick: btn.onClick, size: "medium", iconSize: "medium", mode: "ghost" }, i));
126
- }) }), showSearchModal && cy && (_jsx(TreeViewSearch, { struct: struct, cy: cy, onClose: closeSearchModal, searchCriteria: searchCriteria, setSearchCriteria: setSearchCriteria })), _jsx("div", { id: selector, className: "canvas-tree" }), showInfo && (_jsxs("div", { className: "info", children: [_jsx("span", { children: SentenceUtils.getAsText(struct) }), translations &&
143
+ }) }), showSearchModal && cy && (_jsx(TreeViewSearch, { struct: struct, cy: cy, onClose: closeSearchModal, searchCriteria: searchCriteria, setSearchCriteria: setSearchCriteria })), showImportModal && onImportPenn && (_jsx(TreeViewImportPenn, { onClose: closeImportModal, onImport: onImportPenn })), _jsx("div", { id: selector, className: "canvas-tree" }), showInfo && (_jsxs("div", { className: "info", children: [_jsx("span", { children: SentenceUtils.getAsText(struct) }), translations &&
127
144
  Object.entries(translations).map(([k, v]) => (_jsxs("div", { className: "translation", children: [_jsxs("b", { children: [k, ":"] }), _jsx("span", { children: v })] }, k))), struct.parsed && (_jsxs("span", { className: "date", children: [t('date.parsed'), ' ', DateUtils.formatDateTime(struct.parsed, 'dd/MM/yyyy HH:mm:ss')] }))] }))] }));
128
145
  }
129
- const getButtons = (generateImage, reset, downloadPsd, toggleInfo, onExpand, expression, openSearchModal) => [
146
+ const getButtons = (generateImage, reset, downloadPsd, toggleInfo, onExpand, expression, openSearchModal, goToRevisionTree, revisionTreeLink, openImportModal) => [
130
147
  {
131
148
  condition: true,
132
149
  title: 'button.download.tree',
133
150
  onClick: generateImage,
134
151
  icon: 'download',
135
152
  },
136
- {
137
- condition: true,
138
- title: 'button.recenter.tree',
139
- onClick: reset,
140
- icon: 'center_focus_weak',
141
- },
142
153
  {
143
154
  condition: !!expression,
144
155
  title: 'button.download.penn',
145
156
  onClick: downloadPsd,
146
157
  icon: 'graph_4',
147
158
  },
159
+ {
160
+ condition: !!openImportModal,
161
+ title: 'button.import.penn',
162
+ onClick: openImportModal || (() => { }),
163
+ icon: 'upload',
164
+ },
165
+ {
166
+ condition: true,
167
+ title: 'button.recenter.tree',
168
+ onClick: reset,
169
+ icon: 'center_focus_weak',
170
+ },
148
171
  {
149
172
  condition: !!onExpand,
150
173
  title: 'button.expand.tree',
151
174
  onClick: onExpand || (() => { }),
152
175
  icon: 'open_in_full',
153
176
  },
177
+ {
178
+ condition: !!revisionTreeLink?.url,
179
+ title: 'button.revision.tree',
180
+ onClick: goToRevisionTree || (() => { }),
181
+ icon: 'edit_square',
182
+ },
154
183
  {
155
184
  condition: true,
156
185
  title: 'button.info',
@@ -0,0 +1,7 @@
1
+ import './style.scss';
2
+ type Props = {
3
+ onClose: () => void;
4
+ onImport: (expression: string) => Promise<void> | void;
5
+ };
6
+ export default function TreeViewImportPenn({ onClose, onImport }: Props): import("react").JSX.Element;
7
+ export {};
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import AppModal from '../../../common/AppModal';
5
+ import './style.scss';
6
+ export default function TreeViewImportPenn({ onClose, onImport }) {
7
+ const { t } = useTranslation('tree');
8
+ const [expression, setExpression] = useState('');
9
+ const [importing, setImporting] = useState(false);
10
+ const handleImport = async () => {
11
+ const value = expression.trim();
12
+ if (!value || importing)
13
+ return;
14
+ setImporting(true);
15
+ try {
16
+ await onImport(value);
17
+ onClose();
18
+ }
19
+ finally {
20
+ setImporting(false);
21
+ }
22
+ };
23
+ return (_jsx(AppModal, { title: t('modal.import.penn.title'), close: onClose, confirm: () => {
24
+ void handleImport();
25
+ }, confirmLabel: t('button.import'), disableConfirm: !expression.trim() || importing, disableClose: importing, className: "modal-import-penn", children: _jsx("textarea", { name: "penn-expression", value: expression, rows: 15, placeholder: t('modal.import.penn.placeholder'), disabled: importing, onChange: (e) => setExpression(e.target.value) }) }));
26
+ }
@@ -0,0 +1,2 @@
1
+ import TreeViewImportPenn from './TreeViewImportPenn';
2
+ export default TreeViewImportPenn;
@@ -0,0 +1,2 @@
1
+ import TreeViewImportPenn from './TreeViewImportPenn';
2
+ export default TreeViewImportPenn;
@@ -0,0 +1,22 @@
1
+ .modal-import-penn {
2
+ height: 80vh;
3
+ top: 45% !important;
4
+
5
+ .body {
6
+ display: flex;
7
+ flex: 1 1 auto;
8
+
9
+ textarea {
10
+ flex: 1;
11
+ width: 100%;
12
+ resize: none;
13
+ font-family: var(--font-mono, monospace);
14
+ padding: 12px;
15
+ border: var(--border-default);
16
+ border-radius: var(--radius-100);
17
+ background-color: var(--background-default);
18
+ color: var(--text-primary);
19
+ font-size: 14px;
20
+ }
21
+ }
22
+ }