tycho-components 0.21.1 → 0.21.2

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.
@@ -23,6 +23,11 @@ type Props = {
23
23
  selected?: number;
24
24
  onSuccess?: () => void;
25
25
  iconButtonProps?: SentenceSplitIconButtonProps;
26
+ /** Controlled modal visibility (use with `onOpenChange`). */
27
+ open?: boolean;
28
+ onOpenChange?: (open: boolean) => void;
29
+ /** When true, only the wizard modal is rendered; parent controls `open`. */
30
+ hideTrigger?: boolean;
26
31
  };
27
- export default function SentenceSplit({ struct, documentUid, wordTiers, languages, translations, sound, selected, onSuccess, iconButtonProps, }: Props): import("react/jsx-runtime").JSX.Element;
32
+ export default function SentenceSplit({ struct, documentUid, wordTiers, languages, translations, sound, selected, onSuccess, iconButtonProps, open: openProp, onOpenChange, hideTrigger, }: Props): import("react/jsx-runtime").JSX.Element;
28
33
  export {};
@@ -35,11 +35,19 @@ function resolveInitialSplitToken(selected, wordTokens) {
35
35
  return 0;
36
36
  return selected;
37
37
  }
38
- export default function SentenceSplit({ struct, documentUid, wordTiers, languages, translations, sound, selected, onSuccess, iconButtonProps, }) {
38
+ export default function SentenceSplit({ struct, documentUid, wordTiers, languages, translations, sound, selected, onSuccess, iconButtonProps, open: openProp, onOpenChange, hideTrigger = false, }) {
39
39
  const { t } = useTranslation('sentenceSplit');
40
40
  const { getCorpus } = useCorpusUtils();
41
41
  const { dispatchError, isLoading, dispatchLoading } = useMessageUtils();
42
- const [open, setOpen] = useState(false);
42
+ const [internalOpen, setInternalOpen] = useState(false);
43
+ const isControlled = openProp !== undefined;
44
+ const open = isControlled ? openProp : internalOpen;
45
+ const setOpen = (value) => {
46
+ if (!isControlled) {
47
+ setInternalOpen(value);
48
+ }
49
+ onOpenChange?.(value);
50
+ };
43
51
  const [step, setStep] = useState(STEP_CHOOSE);
44
52
  const [request, setRequest] = useState(emptySentenceSplitRequest);
45
53
  const [hasComments, setHasComments] = useState(null);
@@ -98,7 +106,10 @@ export default function SentenceSplit({ struct, documentUid, wordTiers, language
98
106
  return;
99
107
  dispatchLoading(true);
100
108
  SentenceSplitService.split(struct.uid, request)
101
- .then(() => onSuccess?.())
109
+ .then(() => {
110
+ setOpen(false);
111
+ onSuccess?.();
112
+ })
102
113
  .catch((err) => {
103
114
  dispatchLoading(false);
104
115
  dispatchError({ err, t });
@@ -172,9 +183,9 @@ export default function SentenceSplit({ struct, documentUid, wordTiers, language
172
183
  });
173
184
  }, [step, open]);
174
185
  const mergedIconProps = { ...DEFAULT_ICON_BUTTON_PROPS, ...iconButtonProps };
175
- return (_jsxs(_Fragment, { children: [_jsx(IconButton, { name: "link_off", onClick: () => setOpen(true), title: canOpenSplit
186
+ return (_jsxs(_Fragment, { children: [!hideTrigger && (_jsx(IconButton, { name: "link_off", onClick: () => setOpen(true), title: canOpenSplit
176
187
  ? t('button.label.split')
177
- : t('split.button.disabledTooFewWords'), disabled: !canOpenSplit, ...mergedIconProps }), open && (_jsxs(AppModal, { title: t('modal.split.sentence.title'), className: "sentence-split-modal", close: () => setOpen(false), hideFooter: true, disableEscapeClose: true, disableBackdropClose: true, children: [_jsx("div", { className: "steps-navigation", children: steps.map((stepItem) => (_jsxs("div", { className: `step-item ${step === stepItem.id ? 'active' : ''}`, onClick: () => setStep(stepItem.id), ref: (element) => {
188
+ : t('split.button.disabledTooFewWords'), disabled: !canOpenSplit, ...mergedIconProps })), open && (_jsxs(AppModal, { title: t('modal.split.sentence.title'), className: "sentence-split-modal", close: () => setOpen(false), hideFooter: true, disableEscapeClose: true, disableBackdropClose: true, children: [_jsx("div", { className: "steps-navigation", children: steps.map((stepItem) => (_jsxs("div", { className: `step-item ${step === stepItem.id ? 'active' : ''}`, onClick: () => setStep(stepItem.id), ref: (element) => {
178
189
  stepItemRefs.current[stepItem.id] = element;
179
190
  }, children: [_jsx(Badge, { text: stepItem.displayNumber.toString(), size: "medium", color: step === stepItem.id ? 'blue' : 'none' }), _jsx("div", { className: "step-label", children: stepItem.label })] }, stepItem.id))) }), _jsxs("div", { className: "steps-content", ref: stepsContentRef, children: [_jsxs("div", { className: "sentence-split-body", children: [step === STEP_CHOOSE && (_jsx(SentenceSplitChoose, { struct: struct, request: request, onChange: setRequest })), step === STEP_PREVIEW && request.token !== null && (_jsx(SentenceSplitPreviewStep, { struct: struct, request: request, wordTiers: wordTiers })), step === STEP_TRANSLATIONS && (_jsx(SentenceSplitTranslationsStep, { languages: languages, request: request, onChange: setRequest })), step === STEP_AUDIO && (_jsx(SentenceSplitAudioStep, { sound: sound, request: request, onChange: setRequest })), step === STEP_COMMENTS && request.token !== null && (_jsx(SentenceSplitCommentsStep, { struct: struct, documentUid: documentUid, request: request, onChange: setRequest }))] }), _jsxs("div", { className: "steps-footer", children: [canGoBack && (_jsx(Button, { text: t('split.button.back'), onClick: handleBack, size: "medium", mode: "ghost" })), _jsx(Button, { text: isLastStep ? t('split.button.finish') : t('split.button.next'), onClick: isLastStep ? handleFinishSplit : handleNext, size: "medium", disabled: disablePrimary })] })] })] }))] }));
180
191
  }
@@ -1,6 +1,6 @@
1
1
  export { default as CommentComponent } from './Comments';
2
2
  export { default as HeaderNotifications } from './Comments/HeaderNotifications';
3
- export type { Comment } from './Comments/types/Comment';
3
+ export type { Comment, CommentRequest } from './Comments/types/Comment';
4
4
  export { default as CommentService } from './Comments/CommentService';
5
5
  export { default as Parameters } from './Parameters';
6
6
  export { default as Participants } from './Participants';
@@ -2,7 +2,7 @@ type App = {
2
2
  code: string;
3
3
  icon?: string;
4
4
  image?: string;
5
- visibility: 'public' | 'private';
5
+ visibility: "public" | "private";
6
6
  admin?: boolean;
7
7
  lexicon?: boolean;
8
8
  parser?: boolean;
@@ -1,61 +1,67 @@
1
1
  export const AvailableApps = [
2
2
  {
3
- code: 'reserved',
4
- icon: 'lock',
5
- visibility: 'private',
3
+ code: "reserved",
4
+ icon: "lock",
5
+ visibility: "private",
6
6
  appendCorpusUid: false,
7
7
  },
8
8
  {
9
- code: 'catalog',
10
- icon: 'search',
11
- visibility: 'private',
9
+ code: "catalog",
10
+ icon: "search",
11
+ visibility: "private",
12
12
  },
13
13
  {
14
- code: 'search',
15
- icon: 'match_word',
16
- visibility: 'public',
14
+ code: "search",
15
+ icon: "match_word",
16
+ visibility: "public",
17
17
  },
18
18
  {
19
- code: 'lexicon',
20
- icon: 'book_3',
21
- visibility: 'private',
19
+ code: "lexicon",
20
+ icon: "book_3",
21
+ visibility: "private",
22
22
  lexicon: true,
23
23
  appendCorpusUid: false,
24
24
  },
25
25
  {
26
- code: 'parser',
27
- icon: 'settings',
28
- visibility: 'private',
26
+ code: "parser",
27
+ icon: "settings",
28
+ visibility: "private",
29
29
  parser: true,
30
30
  appendCorpusUid: false,
31
31
  },
32
32
  {
33
- code: 'io',
34
- icon: 'swap_vert',
35
- visibility: 'private',
33
+ code: "io",
34
+ icon: "swap_vert",
35
+ visibility: "private",
36
36
  },
37
37
  {
38
- code: 'viewer',
39
- icon: 'news',
40
- visibility: 'public',
38
+ code: "viewer",
39
+ icon: "news",
40
+ visibility: "public",
41
41
  appendCorpusUid: false,
42
42
  },
43
43
  {
44
- code: 'syntrees',
45
- icon: 'graph_4',
46
- visibility: 'public',
44
+ code: "syntrees",
45
+ icon: "graph_4",
46
+ visibility: "public",
47
47
  appendCorpusUid: false,
48
48
  },
49
49
  {
50
- code: 'psd-reindexer',
51
- icon: '123',
52
- visibility: 'public',
50
+ code: "admin",
51
+ icon: "folder_managed",
52
+ visibility: "private",
53
+ admin: true,
54
+ },
55
+ {
56
+ code: "psd-reindexer",
57
+ icon: "123",
58
+ visibility: "public",
53
59
  appendCorpusUid: false,
54
60
  },
55
61
  {
56
- code: 'admin',
57
- icon: 'folder_managed',
58
- visibility: 'private',
59
- admin: true,
62
+ code: "cs-analyzer",
63
+ icon: "compare",
64
+ visibility: "public",
65
+ appendCorpusUid: false,
60
66
  },
61
67
  ];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tycho-components",
3
3
  "private": false,
4
- "version": "0.21.1",
4
+ "version": "0.21.2",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {