tycho-components 0.21.18 → 0.22.0

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 (154) hide show
  1. package/dist/configs/Localization.js +12 -0
  2. package/dist/features/Comments/HeaderNotifications/HeaderNotifications.js +1 -1
  3. package/dist/features/DocumentDrawer/Actions/Actions.d.ts +12 -0
  4. package/dist/features/DocumentDrawer/Actions/Actions.js +77 -0
  5. package/dist/features/DocumentDrawer/Actions/index.d.ts +2 -0
  6. package/dist/features/DocumentDrawer/Actions/index.js +2 -0
  7. package/dist/features/DocumentDrawer/Actions/style.scss +6 -0
  8. package/dist/features/DocumentDrawer/AutomaticParser/AutomaticParser.d.ts +8 -0
  9. package/dist/features/DocumentDrawer/AutomaticParser/AutomaticParser.js +96 -0
  10. package/dist/features/DocumentDrawer/AutomaticParser/index.d.ts +2 -0
  11. package/dist/features/DocumentDrawer/AutomaticParser/index.js +2 -0
  12. package/dist/features/DocumentDrawer/AutomaticParser/style.scss +10 -0
  13. package/dist/features/DocumentDrawer/DocumentDrawer.d.ts +14 -0
  14. package/dist/features/DocumentDrawer/DocumentDrawer.js +111 -0
  15. package/dist/features/DocumentDrawer/DocumentEdit/DocumentEdit.d.ts +35 -0
  16. package/dist/features/DocumentDrawer/DocumentEdit/DocumentEdit.js +207 -0
  17. package/dist/features/DocumentDrawer/DocumentEdit/index.d.ts +2 -0
  18. package/dist/features/DocumentDrawer/DocumentEdit/index.js +1 -0
  19. package/dist/features/DocumentDrawer/DocumentExport/DocumentExport.d.ts +7 -0
  20. package/dist/features/DocumentDrawer/DocumentExport/DocumentExport.js +71 -0
  21. package/dist/features/DocumentDrawer/DocumentExport/ExportInvalidSentences.d.ts +7 -0
  22. package/dist/features/DocumentDrawer/DocumentExport/ExportInvalidSentences.js +12 -0
  23. package/dist/features/DocumentDrawer/DocumentExport/index.d.ts +2 -0
  24. package/dist/features/DocumentDrawer/DocumentExport/index.js +2 -0
  25. package/dist/features/DocumentDrawer/DocumentExport/style.scss +31 -0
  26. package/dist/features/DocumentDrawer/DocumentLexicon/DocumentLexicon.d.ts +7 -0
  27. package/dist/features/DocumentDrawer/DocumentLexicon/DocumentLexicon.js +22 -0
  28. package/dist/features/DocumentDrawer/DocumentLexicon/index.d.ts +2 -0
  29. package/dist/features/DocumentDrawer/DocumentLexicon/index.js +2 -0
  30. package/dist/features/DocumentDrawer/DocumentLexicon/style.scss +38 -0
  31. package/dist/features/DocumentDrawer/DocumentRemove/DocumentRemove.d.ts +12 -0
  32. package/dist/features/DocumentDrawer/DocumentRemove/DocumentRemove.js +28 -0
  33. package/dist/features/DocumentDrawer/DocumentRemove/index.d.ts +2 -0
  34. package/dist/features/DocumentDrawer/DocumentRemove/index.js +2 -0
  35. package/dist/features/DocumentDrawer/DocumentRemove/style.scss +0 -0
  36. package/dist/features/DocumentDrawer/Github/Github.d.ts +8 -0
  37. package/dist/features/DocumentDrawer/Github/Github.js +11 -0
  38. package/dist/features/DocumentDrawer/Github/GithubCommit.d.ts +8 -0
  39. package/dist/features/DocumentDrawer/Github/GithubCommit.js +86 -0
  40. package/dist/features/DocumentDrawer/Github/index.d.ts +2 -0
  41. package/dist/features/DocumentDrawer/Github/index.js +2 -0
  42. package/dist/features/DocumentDrawer/Github/style.scss +31 -0
  43. package/dist/features/DocumentDrawer/ImageGallery/GalleryImage.d.ts +8 -0
  44. package/dist/features/DocumentDrawer/ImageGallery/GalleryImage.js +5 -0
  45. package/dist/features/DocumentDrawer/ImageGallery/GalleryRemoval.d.ts +9 -0
  46. package/dist/features/DocumentDrawer/ImageGallery/GalleryRemoval.js +14 -0
  47. package/dist/features/DocumentDrawer/ImageGallery/ImageGallery.d.ts +9 -0
  48. package/dist/features/DocumentDrawer/ImageGallery/ImageGallery.js +45 -0
  49. package/dist/features/DocumentDrawer/ImageGallery/index.d.ts +2 -0
  50. package/dist/features/DocumentDrawer/ImageGallery/index.js +2 -0
  51. package/dist/features/DocumentDrawer/ImageGallery/style.scss +41 -0
  52. package/dist/features/DocumentDrawer/Info/Info.d.ts +10 -0
  53. package/dist/features/DocumentDrawer/Info/Info.js +16 -0
  54. package/dist/features/DocumentDrawer/Info/index.d.ts +2 -0
  55. package/dist/features/DocumentDrawer/Info/index.js +2 -0
  56. package/dist/features/DocumentDrawer/Info/style.scss +24 -0
  57. package/dist/features/DocumentDrawer/Metadata/DocumentMetadata/DocumentMetadata.d.ts +8 -0
  58. package/dist/features/DocumentDrawer/Metadata/DocumentMetadata/DocumentMetadata.js +60 -0
  59. package/dist/features/DocumentDrawer/Metadata/DocumentMetadata/index.d.ts +2 -0
  60. package/dist/features/DocumentDrawer/Metadata/DocumentMetadata/index.js +2 -0
  61. package/dist/features/DocumentDrawer/Metadata/DocumentMetadata/style.scss +7 -0
  62. package/dist/features/DocumentDrawer/Metadata/DocumentMetadataEdit/DocumentMetadataEdit.d.ts +11 -0
  63. package/dist/features/DocumentDrawer/Metadata/DocumentMetadataEdit/DocumentMetadataEdit.js +195 -0
  64. package/dist/features/DocumentDrawer/Metadata/DocumentMetadataEdit/index.d.ts +2 -0
  65. package/dist/features/DocumentDrawer/Metadata/DocumentMetadataEdit/index.js +2 -0
  66. package/dist/features/DocumentDrawer/Metadata/DocumentMetadataEdit/style.scss +58 -0
  67. package/dist/features/DocumentDrawer/PageStatusComponent/PageStatusComponent.d.ts +9 -0
  68. package/dist/features/DocumentDrawer/PageStatusComponent/PageStatusComponent.js +30 -0
  69. package/dist/features/DocumentDrawer/PageStatusComponent/index.d.ts +2 -0
  70. package/dist/features/DocumentDrawer/PageStatusComponent/index.js +2 -0
  71. package/dist/features/DocumentDrawer/PageStatusComponent/style.scss +19 -0
  72. package/dist/features/DocumentDrawer/Pages/BoxRemoval.d.ts +9 -0
  73. package/dist/features/DocumentDrawer/Pages/BoxRemoval.js +14 -0
  74. package/dist/features/DocumentDrawer/Pages/Boxes.d.ts +9 -0
  75. package/dist/features/DocumentDrawer/Pages/Boxes.js +63 -0
  76. package/dist/features/DocumentDrawer/Pages/PageRemoval.d.ts +9 -0
  77. package/dist/features/DocumentDrawer/Pages/PageRemoval.js +15 -0
  78. package/dist/features/DocumentDrawer/Pages/Pages.d.ts +10 -0
  79. package/dist/features/DocumentDrawer/Pages/Pages.js +72 -0
  80. package/dist/features/DocumentDrawer/Pages/style.scss +48 -0
  81. package/dist/features/DocumentDrawer/deps.d.ts +28 -0
  82. package/dist/features/DocumentDrawer/deps.js +20 -0
  83. package/dist/features/DocumentDrawer/functions/FileUtils.d.ts +4 -0
  84. package/dist/features/DocumentDrawer/functions/FileUtils.js +8 -0
  85. package/dist/features/DocumentDrawer/functions/MetadataUtils.d.ts +41 -0
  86. package/dist/features/DocumentDrawer/functions/MetadataUtils.js +192 -0
  87. package/dist/features/DocumentDrawer/index.d.ts +5 -0
  88. package/dist/features/DocumentDrawer/index.js +3 -0
  89. package/dist/features/DocumentDrawer/localization/ActionsTexts.d.ts +77 -0
  90. package/dist/features/DocumentDrawer/localization/ActionsTexts.js +77 -0
  91. package/dist/features/DocumentDrawer/localization/DocumentTexts.d.ts +140 -0
  92. package/dist/features/DocumentDrawer/localization/DocumentTexts.js +140 -0
  93. package/dist/features/DocumentDrawer/localization/ExportTexts.d.ts +59 -0
  94. package/dist/features/DocumentDrawer/localization/ExportTexts.js +59 -0
  95. package/dist/features/DocumentDrawer/localization/GithubTexts.d.ts +35 -0
  96. package/dist/features/DocumentDrawer/localization/GithubTexts.js +35 -0
  97. package/dist/features/DocumentDrawer/localization/PageTexts.d.ts +45 -0
  98. package/dist/features/DocumentDrawer/localization/PageTexts.js +45 -0
  99. package/dist/features/DocumentDrawer/localization/ParserTexts.d.ts +30 -0
  100. package/dist/features/DocumentDrawer/localization/ParserTexts.js +30 -0
  101. package/dist/features/DocumentDrawer/services/AutomaticParserService.d.ts +8 -0
  102. package/dist/features/DocumentDrawer/services/AutomaticParserService.js +9 -0
  103. package/dist/features/DocumentDrawer/services/BoundingBoxService.d.ts +11 -0
  104. package/dist/features/DocumentDrawer/services/BoundingBoxService.js +20 -0
  105. package/dist/features/DocumentDrawer/services/DocumentService.d.ts +13 -0
  106. package/dist/features/DocumentDrawer/services/DocumentService.js +20 -0
  107. package/dist/features/DocumentDrawer/services/ExportService.d.ts +11 -0
  108. package/dist/features/DocumentDrawer/services/ExportService.js +16 -0
  109. package/dist/features/DocumentDrawer/services/GithubService.d.ts +8 -0
  110. package/dist/features/DocumentDrawer/services/GithubService.js +12 -0
  111. package/dist/features/DocumentDrawer/services/ImageService.d.ts +8 -0
  112. package/dist/features/DocumentDrawer/services/ImageService.js +12 -0
  113. package/dist/features/DocumentDrawer/services/LexiconService.d.ts +10 -0
  114. package/dist/features/DocumentDrawer/services/LexiconService.js +9 -0
  115. package/dist/features/DocumentDrawer/services/MetadataService.d.ts +15 -0
  116. package/dist/features/DocumentDrawer/services/MetadataService.js +26 -0
  117. package/dist/features/DocumentDrawer/services/PageService.d.ts +11 -0
  118. package/dist/features/DocumentDrawer/services/PageService.js +16 -0
  119. package/dist/features/DocumentDrawer/services/SentenceService.d.ts +6 -0
  120. package/dist/features/DocumentDrawer/services/SentenceService.js +6 -0
  121. package/dist/features/DocumentDrawer/style.scss +171 -0
  122. package/dist/features/DocumentDrawer/types/BoundingBox.d.ts +8 -0
  123. package/dist/features/DocumentDrawer/types/BoundingBox.js +1 -0
  124. package/dist/features/DocumentDrawer/types/CatalogSearchFilter.d.ts +15 -0
  125. package/dist/features/DocumentDrawer/types/CatalogSearchFilter.js +16 -0
  126. package/dist/features/DocumentDrawer/types/Category.d.ts +16 -0
  127. package/dist/features/DocumentDrawer/types/Category.js +5 -0
  128. package/dist/features/DocumentDrawer/types/DocumentStatus.d.ts +7 -0
  129. package/dist/features/DocumentDrawer/types/DocumentStatus.js +6 -0
  130. package/dist/features/DocumentDrawer/types/DocumentUpdateRequest.d.ts +13 -0
  131. package/dist/features/DocumentDrawer/types/DocumentUpdateRequest.js +1 -0
  132. package/dist/features/DocumentDrawer/types/Export.d.ts +25 -0
  133. package/dist/features/DocumentDrawer/types/Export.js +36 -0
  134. package/dist/features/DocumentDrawer/types/Lexicon.d.ts +6 -0
  135. package/dist/features/DocumentDrawer/types/Lexicon.js +1 -0
  136. package/dist/features/DocumentDrawer/types/LexiconResponse.d.ts +6 -0
  137. package/dist/features/DocumentDrawer/types/LexiconResponse.js +1 -0
  138. package/dist/features/DocumentDrawer/types/Metadata.d.ts +22 -0
  139. package/dist/features/DocumentDrawer/types/Metadata.js +8 -0
  140. package/dist/features/DocumentDrawer/types/Page.d.ts +10 -0
  141. package/dist/features/DocumentDrawer/types/Page.js +1 -0
  142. package/dist/features/DocumentDrawer/types/PageStatus.d.ts +9 -0
  143. package/dist/features/DocumentDrawer/types/PageStatus.js +8 -0
  144. package/dist/features/DocumentDrawer/types/Parser.d.ts +18 -0
  145. package/dist/features/DocumentDrawer/types/Parser.js +21 -0
  146. package/dist/features/DocumentDrawer/types/Query.d.ts +6 -0
  147. package/dist/features/DocumentDrawer/types/Query.js +1 -0
  148. package/dist/features/DocumentDrawer/types/Sentence.d.ts +4 -0
  149. package/dist/features/DocumentDrawer/types/Sentence.js +1 -0
  150. package/dist/features/index.d.ts +4 -0
  151. package/dist/features/index.js +2 -0
  152. package/dist/shell/Header/HeaderApps/HeaderApps.js +2 -1
  153. package/dist/shell/Header/HelpButton/HelpModal.js +2 -1
  154. package/package.json +1 -1
@@ -0,0 +1,7 @@
1
+ import { Document } from '../deps';
2
+ import './style.scss';
3
+ type Props = {
4
+ doc: Document;
5
+ };
6
+ export default function DocumentExport({ doc }: Props): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,71 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import FileUtils from '../functions/FileUtils';
3
+ import outputService from '../services/ExportService';
4
+ import { EXPORT_TYPE_DISPLAY } from '../types/Export';
5
+ import { saveAs } from 'file-saver';
6
+ import { useState } from 'react';
7
+ import { useTranslation } from 'react-i18next';
8
+ import { useMessageUtils } from '../deps';
9
+ import { Icon } from 'tycho-storybook';
10
+ import ExportInvalidSentences from './ExportInvalidSentences';
11
+ import './style.scss';
12
+ const timingCheck = 5000;
13
+ export default function DocumentExport({ doc }) {
14
+ const { t } = useTranslation('export');
15
+ const { dispatchLoading, dispatchError, dispatchMessage, isLoading } = useMessageUtils();
16
+ const [invalidSentences, setInvalidSentences] = useState();
17
+ let intervalCheck = null;
18
+ const process = (thisType) => {
19
+ if (isLoading())
20
+ return;
21
+ dispatchLoading(true);
22
+ outputService
23
+ .execute(doc.uid, thisType)
24
+ .then((r) => {
25
+ intervalCheck = setInterval(() => check(r.data), timingCheck);
26
+ })
27
+ .catch((err) => {
28
+ dispatchError({ err, t });
29
+ dispatchLoading(false);
30
+ });
31
+ };
32
+ const forceZipDownload = (data) => {
33
+ window.open(data.url);
34
+ };
35
+ const check = (uid) => {
36
+ outputService
37
+ .check(uid)
38
+ .then((r) => {
39
+ if (!r.data?.completed)
40
+ return;
41
+ dispatchLoading(false);
42
+ dispatchMessage({ key: 'export.process.success', t });
43
+ const filename = FileUtils.getFileNameFromURL(r.data.url);
44
+ if (r.data.url.endsWith('.zip')) {
45
+ forceZipDownload(r.data);
46
+ }
47
+ else {
48
+ saveAs(r.data.url, filename);
49
+ }
50
+ clearInterval(intervalCheck);
51
+ })
52
+ .catch((err) => {
53
+ dispatchLoading(false);
54
+ clearInterval(intervalCheck);
55
+ handleError(err);
56
+ });
57
+ };
58
+ const handleError = (err) => {
59
+ const message = err.response.data.message || err.response.data.error;
60
+ if (message === 'psd.invalid.sentences') {
61
+ setInvalidSentences(err.response.data.details);
62
+ }
63
+ else {
64
+ dispatchError({
65
+ err: message.indexOf('\n') !== -1 ? message.split('\n')[0] : err,
66
+ t,
67
+ });
68
+ }
69
+ };
70
+ return (_jsxs("div", { className: "document-export-container", children: [_jsx("div", { className: "header", children: _jsx("div", { className: "title", children: t('export.label.title') }) }), _jsx("div", { className: "body", children: EXPORT_TYPE_DISPLAY.filter((t) => t.active).map((item) => (_jsxs("div", { className: "action-line", onClick: () => process(item.type), children: [_jsx("div", { className: "action-button", children: _jsx(Icon, { name: item.icon, size: "medium" }) }), _jsxs("div", { className: "action-desc", children: [_jsx("span", { className: "title", children: t(`export.label.${item.type.toLowerCase()}`) }), _jsx("span", { children: t(`export.desc.${item.type.toLowerCase()}`) })] })] }, item.icon))) }), invalidSentences && invalidSentences.length > 0 && (_jsx(ExportInvalidSentences, { sentences: invalidSentences, onClose: () => setInvalidSentences([]) }))] }));
71
+ }
@@ -0,0 +1,7 @@
1
+ import './style.scss';
2
+ type Props = {
3
+ sentences: string[];
4
+ onClose: () => void;
5
+ };
6
+ export default function ExportInvalidSentences({ sentences, onClose }: Props): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useTranslation } from 'react-i18next';
3
+ import { AppModal } from '../deps';
4
+ import './style.scss';
5
+ import { Icon } from 'tycho-storybook';
6
+ export default function ExportInvalidSentences({ sentences, onClose }) {
7
+ const { t } = useTranslation('export');
8
+ const handleOpen = (s) => {
9
+ window.open(`/revision/tree/${s}`);
10
+ };
11
+ return (_jsxs(AppModal, { title: t('modal.title.invalid.sentences'), close: onClose, className: "modal-invalid-sentences", hideFooter: true, children: [_jsx("p", { children: t('modal.desc.invalid.sentences') }), sentences.map((s, idx) => (_jsxs("div", { className: "sentence", children: [_jsx("span", { className: "uid", children: s }), _jsx(Icon, { name: "open_in_new", onClick: () => handleOpen(s) })] }, idx.valueOf())))] }));
12
+ }
@@ -0,0 +1,2 @@
1
+ import DocumentExport from './DocumentExport';
2
+ export default DocumentExport;
@@ -0,0 +1,2 @@
1
+ import DocumentExport from './DocumentExport';
2
+ export default DocumentExport;
@@ -0,0 +1,31 @@
1
+ .document-export-container {
2
+ .body {
3
+ height: 90vh;
4
+ overflow-y: auto;
5
+ }
6
+ }
7
+
8
+ .modal-invalid-sentences {
9
+ .body {
10
+ display: flex;
11
+ flex-wrap: wrap;
12
+
13
+ > .sentence {
14
+ display: flex;
15
+ flex: 0 0 50%;
16
+ box-sizing: border-box;
17
+ align-items: center;
18
+ border-bottom: 1px solid var(--border-subtle-2);
19
+ padding: 4px 0px;
20
+
21
+ .uid {
22
+ font-family: 'Courier New', Courier, monospace;
23
+ }
24
+
25
+ > .ds-icon {
26
+ margin-left: 8px;
27
+ cursor: pointer;
28
+ }
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,7 @@
1
+ import { Document } from '../deps';
2
+ import './style.scss';
3
+ type Props = {
4
+ document: Document;
5
+ };
6
+ export default function DocumentLexicon({ document }: Props): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import lexiconService from '../services/LexiconService';
3
+ import { useEffect, useState } from 'react';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { AppPlaceholder, useCorpusUtils } from '../deps';
6
+ import './style.scss';
7
+ export default function DocumentLexicon({ document }) {
8
+ const { t } = useTranslation('document');
9
+ const { getCorpus, hasParameter } = useCorpusUtils();
10
+ const [editions, setEditions] = useState();
11
+ const getAttributes = (edition) => {
12
+ return Object.entries(edition.ops)
13
+ .map(([key, value]) => `${key}: ${value}`)
14
+ .join(', ');
15
+ };
16
+ useEffect(() => {
17
+ lexiconService.list(document).then((response) => {
18
+ setEditions(response.data);
19
+ });
20
+ }, []);
21
+ return (_jsxs("div", { className: "lexicon-container", children: [_jsx("div", { className: "header", children: _jsx("div", { className: "title", children: t('lexicon.label.title') }) }), _jsxs("div", { className: "body", children: [editions && editions.length > 0 && (_jsxs("table", { className: "lexicon-table table-striped", children: [_jsxs("colgroup", { children: [_jsx("col", { className: "word-col", span: 1 }), _jsx("col", { className: "value-col", span: 1 })] }), _jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('lexicon.label.word') }), hasParameter(getCorpus(), 'useEditionTiers') ? (_jsx("th", { children: t('lexicon.label.editions') })) : (_jsx("th", { children: t('lexicon.label.tag') }))] }) }), _jsx("tbody", { children: editions.map((edition, idx) => (_jsxs("tr", { children: [_jsx("td", { children: edition.value }), hasParameter(getCorpus(), 'useEditionTiers') ? (_jsx("td", { children: getAttributes(edition) })) : (_jsx("td", { children: edition.tag }))] }, idx.valueOf()))) })] })), editions && editions.length === 0 && (_jsx(AppPlaceholder, { text: t('placeholder.empty.lexicon') }))] })] }));
22
+ }
@@ -0,0 +1,2 @@
1
+ import DocumentLexicon from './DocumentLexicon';
2
+ export default DocumentLexicon;
@@ -0,0 +1,2 @@
1
+ import DocumentLexicon from './DocumentLexicon';
2
+ export default DocumentLexicon;
@@ -0,0 +1,38 @@
1
+ .lexicon-container {
2
+ width: 100%;
3
+
4
+ .body {
5
+ width: 100%;
6
+ height: 90vh;
7
+ overflow-y: auto;
8
+
9
+ .placeholder-container {
10
+ @include label-large-1;
11
+ height: auto;
12
+ }
13
+
14
+ .lexicon-table {
15
+ border: none;
16
+ width: 100%;
17
+ max-width: 100%;
18
+ table-layout: fixed;
19
+ border-collapse: collapse;
20
+
21
+ col.word-col {
22
+ width: 35%;
23
+ }
24
+
25
+ col.value-col {
26
+ width: 65%;
27
+ }
28
+
29
+ th,
30
+ td {
31
+ box-sizing: border-box;
32
+ padding: 8px;
33
+ word-wrap: break-word;
34
+ overflow-wrap: break-word;
35
+ }
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,12 @@
1
+ import CatalogSearchFilter from '../types/CatalogSearchFilter';
2
+ import { Document } from '../deps';
3
+ import './style.scss';
4
+ type Props = {
5
+ document: Document;
6
+ onClose: () => void;
7
+ useGrid: boolean;
8
+ setFilter: (p: CatalogSearchFilter) => void;
9
+ setOpenFile: (b: boolean) => void;
10
+ };
11
+ export default function DocumentRemove({ document, onClose, useGrid, setFilter, setOpenFile, }: Props): import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { emptyCatalogSearchFilter, } from '../types/CatalogSearchFilter';
3
+ import DocumentService from '../services/DocumentService';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { AppModalConfirm, DateUtils, useMessageUtils } from '../deps';
6
+ import './style.scss';
7
+ export default function DocumentRemove({ document, onClose, useGrid, setFilter, setOpenFile, }) {
8
+ const { t } = useTranslation('actions');
9
+ const { dispatchLoading, isLoading } = useMessageUtils();
10
+ const handleRemove = () => {
11
+ if (isLoading())
12
+ return;
13
+ dispatchLoading(true);
14
+ DocumentService.remove(document.uid)
15
+ .then((r) => {
16
+ setOpenFile(false);
17
+ onClose();
18
+ setFilter({
19
+ ...emptyCatalogSearchFilter(useGrid),
20
+ seed: DateUtils.millis(),
21
+ });
22
+ })
23
+ .finally(() => {
24
+ dispatchLoading(false);
25
+ });
26
+ };
27
+ return (_jsx(AppModalConfirm, { title: t('modal.remove.title'), subtitle: t('message:generic.remove.message'), onClose: onClose, onConfirm: handleRemove }));
28
+ }
@@ -0,0 +1,2 @@
1
+ import DocumentRemove from './DocumentRemove';
2
+ export default DocumentRemove;
@@ -0,0 +1,2 @@
1
+ import DocumentRemove from './DocumentRemove';
2
+ export default DocumentRemove;
@@ -0,0 +1,8 @@
1
+ import { Document } from '../deps';
2
+ import './style.scss';
3
+ type Props = {
4
+ document: Document;
5
+ setOpenFile: (b: boolean) => void;
6
+ };
7
+ export default function Github({ document, setOpenFile }: Props): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { Icon } from 'tycho-storybook';
5
+ import GithubCommit from './GithubCommit';
6
+ import './style.scss';
7
+ export default function Github({ document, setOpenFile }) {
8
+ const { t } = useTranslation('github');
9
+ const [openCommit, setOpenCommit] = useState(false);
10
+ return (_jsxs("div", { className: "github-actions-container", children: [_jsx("div", { className: "header", children: _jsx("div", { className: "title", children: t('label.title') }) }), _jsx("div", { className: "body", children: _jsxs("div", { className: "action-line", onClick: () => setOpenCommit(true), children: [_jsx("div", { className: "action-button", children: _jsx(Icon, { name: "commit", size: "medium" }) }), _jsxs("div", { className: "action-desc", children: [_jsx("span", { className: "title", children: t('label.commit.title') }), _jsx("span", { children: t('label.commit.description') })] })] }, "commit") }), openCommit && (_jsx(GithubCommit, { document: document, onClose: () => setOpenCommit(false) }))] }));
11
+ }
@@ -0,0 +1,8 @@
1
+ import { Document } from '../deps';
2
+ import './style.scss';
3
+ type Props = {
4
+ document: Document;
5
+ onClose: () => void;
6
+ };
7
+ export default function GithubCommit({ document, onClose }: Props): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,86 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import ExportService from '../services/ExportService';
3
+ import GithubService from '../services/GithubService';
4
+ import { useEffect, useState } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
+ import { AppModal, useCorpusUtils, useMessageUtils } from '../deps';
7
+ import './style.scss';
8
+ const timingCheck = 5000;
9
+ export default function GithubCommit({ document, onClose }) {
10
+ const { t } = useTranslation('github');
11
+ const { dispatchLoading, dispatchError, dispatchMessage, isLoading } = useMessageUtils();
12
+ const { getCorpus, hasCorpus } = useCorpusUtils();
13
+ const [exportId, setExportId] = useState('');
14
+ const [openPush, setOpenPush] = useState(false);
15
+ let intervalCheck = null;
16
+ const handleExport = () => {
17
+ if (isLoading())
18
+ return;
19
+ dispatchLoading(true);
20
+ ExportService.executeForGithub(document.uid, document.githubFormat)
21
+ .then((r) => {
22
+ setExportId(r.data);
23
+ })
24
+ .catch((err) => {
25
+ console.log(err);
26
+ dispatchError({ err, t });
27
+ dispatchLoading(false);
28
+ });
29
+ };
30
+ const handleCommit = () => {
31
+ if (isLoading() || !hasCorpus())
32
+ return;
33
+ GithubService.commit(getCorpus())
34
+ .then(() => {
35
+ setOpenPush(true);
36
+ })
37
+ .catch((err) => {
38
+ dispatchError({ err, t });
39
+ dispatchLoading(false);
40
+ });
41
+ };
42
+ const handlePush = () => {
43
+ if (isLoading() || !hasCorpus())
44
+ return;
45
+ dispatchLoading(true);
46
+ GithubService.push(getCorpus())
47
+ .then(() => {
48
+ dispatchMessage({ key: 'push.success', t });
49
+ onClose();
50
+ setOpenPush(false);
51
+ })
52
+ .catch((err) => {
53
+ dispatchError({ err, t });
54
+ })
55
+ .finally(() => {
56
+ dispatchLoading(false);
57
+ });
58
+ };
59
+ const check = () => {
60
+ ExportService.check(exportId)
61
+ .then((r) => {
62
+ if (!r.data)
63
+ return;
64
+ clearInterval(intervalCheck);
65
+ if (r.data.status === 'SUCCESS') {
66
+ handleCommit();
67
+ }
68
+ else {
69
+ dispatchError({ err: r.data.error, t });
70
+ }
71
+ })
72
+ .catch(() => {
73
+ dispatchError({ err: 'export.process.error', t });
74
+ clearInterval(intervalCheck);
75
+ });
76
+ };
77
+ useEffect(() => {
78
+ if (!exportId)
79
+ return;
80
+ intervalCheck = setInterval(check, timingCheck);
81
+ }, [exportId]);
82
+ return (_jsx(_Fragment, { children: !openPush ? (_jsx(AppModal, { title: t('modal.commit.title'), className: "modal-github", close: onClose, confirm: handleExport, children: _jsxs("div", { className: "body", children: [_jsx("p", { children: t('modal.commit.description') }), _jsxs("div", { className: "line", children: [_jsx("b", { children: t('modal.label.github.file') }), _jsx("span", { children: document.github })] }), _jsxs("div", { className: "line", children: [_jsx("b", { children: t('modal.label.github.format') }), _jsx("span", { children: document.githubFormat })] })] }) })) : (_jsx(AppModal, { title: t('modal.push.title'), className: "modal-github", close: () => {
83
+ setOpenPush(false);
84
+ onClose();
85
+ }, confirm: handlePush, children: _jsx("div", { className: "body", children: _jsx("p", { children: t('modal.push.description') }) }) })) }));
86
+ }
@@ -0,0 +1,2 @@
1
+ import Github from './Github';
2
+ export default Github;
@@ -0,0 +1,2 @@
1
+ import Github from './Github';
2
+ export default Github;
@@ -0,0 +1,31 @@
1
+ .github-actions-container {
2
+ .body {
3
+ height: 90vh;
4
+ overflow-y: auto;
5
+ }
6
+ }
7
+
8
+ .modal-github {
9
+ width: 50vw;
10
+ max-width: 50vw;
11
+
12
+ .modal-body {
13
+ padding: 0px;
14
+
15
+ > .body {
16
+ padding: 16px;
17
+
18
+ > p {
19
+ text-align: center;
20
+ }
21
+
22
+ > .line {
23
+ margin-bottom: 4px;
24
+
25
+ > b {
26
+ margin-right: 4px;
27
+ }
28
+ }
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,8 @@
1
+ declare enum ImageGalleryType {
2
+ COVER = "Cover"
3
+ }
4
+ export default ImageGalleryType;
5
+ export default interface GalleryImage {
6
+ type: string;
7
+ url: string;
8
+ }
@@ -0,0 +1,5 @@
1
+ var ImageGalleryType;
2
+ (function (ImageGalleryType) {
3
+ ImageGalleryType["COVER"] = "Cover";
4
+ })(ImageGalleryType || (ImageGalleryType = {}));
5
+ export default ImageGalleryType;
@@ -0,0 +1,9 @@
1
+ import { Document } from '../deps';
2
+ import './style.scss';
3
+ type Props = {
4
+ document: Document;
5
+ onClose: () => void;
6
+ onRemove: () => void;
7
+ };
8
+ export default function GalleryRemoval({ document, onClose, onRemove }: Props): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import ImageService from '../services/ImageService';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { AppModalConfirm } from '../deps';
5
+ import './style.scss';
6
+ export default function GalleryRemoval({ document, onClose, onRemove }) {
7
+ const { t } = useTranslation('document');
8
+ const handleRemove = () => {
9
+ ImageService.removeDocument(document.uid).then(() => {
10
+ onRemove();
11
+ });
12
+ };
13
+ return (_jsx(AppModalConfirm, { title: t('message:generic.remove.title'), subtitle: t('message:generic.remove.message'), onClose: onClose, onConfirm: handleRemove }));
14
+ }
@@ -0,0 +1,9 @@
1
+ import { Document } from '../deps';
2
+ import './style.scss';
3
+ type Props = {
4
+ document: Document;
5
+ setDocument: (d: Document) => void;
6
+ handleChange: (document: Document) => void;
7
+ };
8
+ export default function ImageGallery({ document, setDocument, handleChange, }: Props): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,45 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import ImageService from '../services/ImageService';
3
+ import { useEffect, useState } from 'react';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { AppCard, AppDropzone, AppPicture, AppPlaceholder, useCorpusUtils, useMessageUtils, } from '../deps';
6
+ import { Button, IconButton } from 'tycho-storybook';
7
+ import GalleryRemoval from './GalleryRemoval';
8
+ import './style.scss';
9
+ export default function ImageGallery({ document, setDocument, handleChange, }) {
10
+ const { t } = useTranslation('document');
11
+ const { dispatchMessage } = useMessageUtils();
12
+ const { getCorpus, hasCorpus } = useCorpusUtils();
13
+ const [images, setImages] = useState([]);
14
+ const [removal, setRemoval] = useState();
15
+ const [openUpload, setOpenUpload] = useState(false);
16
+ const handleSuccess = (response) => {
17
+ const image = {
18
+ ...response,
19
+ type: 'COVER',
20
+ };
21
+ ImageService.updateDocument(document.uid, image).then(() => {
22
+ dispatchMessage({ key: 'update.success', t });
23
+ setDocument({ ...document, picture: response.url });
24
+ setImages((prevState) => [...prevState, image]);
25
+ updateImageAtList(response.url);
26
+ setOpenUpload(false);
27
+ });
28
+ };
29
+ const updateImageAtList = (value) => {
30
+ handleChange({ ...document, picture: value });
31
+ };
32
+ useEffect(() => {
33
+ if (document.picture)
34
+ setImages([{ url: document.picture, type: 'COVER' }]);
35
+ }, [document]);
36
+ return (_jsxs("div", { className: "images-container", children: [_jsxs("div", { className: "header", children: [_jsx("div", { className: "title", children: t('images.label.title') }), !document.picture && (_jsx(Button, { size: "small", onClick: () => setOpenUpload(true), text: t('images.tooltip.add'), icon: "add", mode: "outlined" }))] }), _jsxs("div", { className: "body", children: [images.map((image, idx) => (_jsx(AppCard, { footer: _jsxs(_Fragment, { children: [_jsx("span", { children: t('images.label.card') }), _jsx(IconButton, { onClick: () => setRemoval(image), title: t('images.tooltip.remove'), name: "delete", mode: "ghost", size: "small" })] }), children: _jsx(AppPicture, { src: image.url }) }, idx.valueOf()))), images.length === 0 && (_jsx(AppPlaceholder, { text: t('placeholder.empty.images') }))] }), openUpload && hasCorpus() && (_jsx(AppDropzone, { folder: `/${getCorpus().uploadDir}/documents`, onSuccess: handleSuccess, onClose: () => setOpenUpload(false), accept: {
37
+ 'image/jpeg': [],
38
+ 'image/png': [],
39
+ } })), removal && (_jsx(GalleryRemoval, { document: document, onClose: () => setRemoval(undefined), onRemove: () => {
40
+ setDocument({ ...document, picture: '' });
41
+ setImages(images.filter((i) => i.type !== removal.type));
42
+ setRemoval(undefined);
43
+ updateImageAtList('');
44
+ } }))] }));
45
+ }
@@ -0,0 +1,2 @@
1
+ import ImageGallery from './ImageGallery';
2
+ export default ImageGallery;
@@ -0,0 +1,2 @@
1
+ import ImageGallery from './ImageGallery';
2
+ export default ImageGallery;
@@ -0,0 +1,41 @@
1
+ .images-container {
2
+ height: 100%;
3
+ display: flex;
4
+ flex-direction: column;
5
+
6
+ > .body {
7
+ display: flex;
8
+ flex-wrap: wrap;
9
+ max-height: 90vh;
10
+ overflow-y: auto;
11
+ padding: 16px;
12
+ gap: 16px;
13
+
14
+ > .ds-placeholder {
15
+ margin: 0 auto;
16
+ }
17
+
18
+ > .ds-app-card {
19
+ flex: 0 0 calc(50% - 16px);
20
+
21
+ > .body {
22
+ position: relative;
23
+ display: flex;
24
+ justify-content: center;
25
+ align-items: center;
26
+ height: 20vh;
27
+ overflow: hidden;
28
+
29
+ img {
30
+ max-height: 20vh;
31
+ max-width: 230px;
32
+ }
33
+ }
34
+
35
+ > .footer {
36
+ align-items: center;
37
+ justify-content: space-between;
38
+ }
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,10 @@
1
+ import Category from '../types/Category';
2
+ import { Document } from '../deps';
3
+ import './style.scss';
4
+ type Props = {
5
+ document: Document;
6
+ categoriesHierarchy: Category[];
7
+ handleChange: (document: Document) => void;
8
+ };
9
+ export default function Info({ document, categoriesHierarchy, handleChange, }: Props): import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import DocumentEdit, { getDocumentFields } from '../DocumentEdit/DocumentEdit';
3
+ import { useState } from 'react';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { AppCopyText, AppFormInfo } from '../deps';
6
+ import { Button } from 'tycho-storybook';
7
+ import './style.scss';
8
+ export default function Info({ document, categoriesHierarchy, handleChange, }) {
9
+ const { t } = useTranslation(['document', 'actions']);
10
+ const [editOpen, setEditOpen] = useState(false);
11
+ const categoryName = categoriesHierarchy.find((category) => category.uid === document.category)
12
+ ?.name ?? document.category;
13
+ const documentInfoData = { ...document, category: categoryName };
14
+ return (_jsxs("div", { className: "info-container", children: [_jsxs("div", { className: "header", children: [_jsx("div", { className: "title", children: t('document.label.title') }), _jsx(Button, { size: "small", onClick: () => setEditOpen(true), text: t('document.button.edit'), icon: "edit", mode: "outlined" })] }), _jsx("div", { className: "body", children: _jsx(AppFormInfo, { fields: getDocumentFields(categoriesHierarchy, t).filter((field) => field.attr !== 'category' ||
15
+ (categoriesHierarchy?.length ?? 0) > 0), data: documentInfoData }) }), _jsx("div", { className: "footer", children: _jsx(AppCopyText, { content: document.uid }) }), editOpen && (_jsx(DocumentEdit, { document: document, categoriesHierarchy: categoriesHierarchy, onClose: () => setEditOpen(false), onSave: handleChange }))] }));
16
+ }
@@ -0,0 +1,2 @@
1
+ import Info from './Info';
2
+ export default Info;
@@ -0,0 +1,2 @@
1
+ import Info from './Info';
2
+ export default Info;