tycho-components 0.21.0 → 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 [
|
|
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(() =>
|
|
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
|
}
|
package/dist/features/index.d.ts
CHANGED
|
@@ -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';
|
|
@@ -1,61 +1,67 @@
|
|
|
1
1
|
export const AvailableApps = [
|
|
2
2
|
{
|
|
3
|
-
code:
|
|
4
|
-
icon:
|
|
5
|
-
visibility:
|
|
3
|
+
code: "reserved",
|
|
4
|
+
icon: "lock",
|
|
5
|
+
visibility: "private",
|
|
6
6
|
appendCorpusUid: false,
|
|
7
7
|
},
|
|
8
8
|
{
|
|
9
|
-
code:
|
|
10
|
-
icon:
|
|
11
|
-
visibility:
|
|
9
|
+
code: "catalog",
|
|
10
|
+
icon: "search",
|
|
11
|
+
visibility: "private",
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
|
-
code:
|
|
15
|
-
icon:
|
|
16
|
-
visibility:
|
|
14
|
+
code: "search",
|
|
15
|
+
icon: "match_word",
|
|
16
|
+
visibility: "public",
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
|
-
code:
|
|
20
|
-
icon:
|
|
21
|
-
visibility:
|
|
19
|
+
code: "lexicon",
|
|
20
|
+
icon: "book_3",
|
|
21
|
+
visibility: "private",
|
|
22
22
|
lexicon: true,
|
|
23
23
|
appendCorpusUid: false,
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
|
-
code:
|
|
27
|
-
icon:
|
|
28
|
-
visibility:
|
|
26
|
+
code: "parser",
|
|
27
|
+
icon: "settings",
|
|
28
|
+
visibility: "private",
|
|
29
29
|
parser: true,
|
|
30
30
|
appendCorpusUid: false,
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
|
-
code:
|
|
34
|
-
icon:
|
|
35
|
-
visibility:
|
|
33
|
+
code: "io",
|
|
34
|
+
icon: "swap_vert",
|
|
35
|
+
visibility: "private",
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
|
-
code:
|
|
39
|
-
icon:
|
|
40
|
-
visibility:
|
|
38
|
+
code: "viewer",
|
|
39
|
+
icon: "news",
|
|
40
|
+
visibility: "public",
|
|
41
41
|
appendCorpusUid: false,
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
|
-
code:
|
|
45
|
-
icon:
|
|
46
|
-
visibility:
|
|
44
|
+
code: "syntrees",
|
|
45
|
+
icon: "graph_4",
|
|
46
|
+
visibility: "public",
|
|
47
47
|
appendCorpusUid: false,
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
|
-
code:
|
|
51
|
-
icon:
|
|
52
|
-
visibility:
|
|
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:
|
|
57
|
-
icon:
|
|
58
|
-
visibility:
|
|
59
|
-
|
|
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.
|
|
4
|
+
"version": "0.21.2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -58,7 +58,6 @@
|
|
|
58
58
|
"react-easy-edit": "^2.0.0",
|
|
59
59
|
"react-loading": "^2.0.3",
|
|
60
60
|
"react-simple-keyboard": "^3.8.66",
|
|
61
|
-
"react-toastify": "^9.1.3",
|
|
62
61
|
"simple-keyboard-layouts": "^3.4.82"
|
|
63
62
|
},
|
|
64
63
|
"peerDependencies": {
|
|
@@ -74,6 +73,7 @@
|
|
|
74
73
|
"react-hook-form": "^7.45.2",
|
|
75
74
|
"react-i18next": "^13.0.2",
|
|
76
75
|
"react-router-dom": "^6.14.2",
|
|
76
|
+
"react-toastify": "^9.1.3",
|
|
77
77
|
"tycho-storybook": "0.7.3",
|
|
78
78
|
"wavesurfer-react": "^2.2.2",
|
|
79
79
|
"wavesurfer.js": "^6.6.3",
|
|
@@ -100,6 +100,7 @@
|
|
|
100
100
|
"eslint-plugin-storybook": "^0.11.2",
|
|
101
101
|
"react": "^18.2.0",
|
|
102
102
|
"react-dom": "^18.2.0",
|
|
103
|
+
"react-toastify": "^9.1.3",
|
|
103
104
|
"sass-embedded": "^1.97.2",
|
|
104
105
|
"storybook": "^10.1.11",
|
|
105
106
|
"typescript": "^5.7.3",
|