@finos/legend-lego 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.
- package/lib/application/DocumentationLink.d.ts +27 -0
- package/lib/application/DocumentationLink.d.ts.map +1 -0
- package/lib/application/DocumentationLink.js +45 -0
- package/lib/application/DocumentationLink.js.map +1 -0
- package/lib/application/FuzzySearchAdvancedConfigMenu.d.ts +23 -0
- package/lib/application/FuzzySearchAdvancedConfigMenu.d.ts.map +1 -0
- package/lib/application/FuzzySearchAdvancedConfigMenu.js +35 -0
- package/lib/application/FuzzySearchAdvancedConfigMenu.js.map +1 -0
- package/lib/application/TabManager.d.ts +24 -0
- package/lib/application/TabManager.d.ts.map +1 -0
- package/lib/application/TabManager.js +117 -0
- package/lib/application/TabManager.js.map +1 -0
- package/lib/application/TabManagerState.d.ts +40 -0
- package/lib/application/TabManagerState.d.ts.map +1 -0
- package/lib/application/TabManagerState.js +93 -0
- package/lib/application/TabManagerState.js.map +1 -0
- package/lib/application/index.d.ts +20 -0
- package/lib/application/index.d.ts.map +1 -0
- package/lib/application/index.js +20 -0
- package/lib/application/index.js.map +1 -0
- package/lib/code-editor/CodeDiffView.d.ts +35 -0
- package/lib/code-editor/CodeDiffView.d.ts.map +1 -0
- package/lib/code-editor/CodeDiffView.js +78 -0
- package/lib/code-editor/CodeDiffView.js.map +1 -0
- package/lib/code-editor/CodeEditor.d.ts +1 -1
- package/lib/code-editor/CodeEditor.d.ts.map +1 -1
- package/lib/code-editor/CodeEditor.js +5 -3
- package/lib/code-editor/CodeEditor.js.map +1 -1
- package/lib/code-editor/CodeEditorConfig.d.ts +31 -0
- package/lib/code-editor/CodeEditorConfig.d.ts.map +1 -0
- package/lib/code-editor/CodeEditorConfig.js +33 -0
- package/lib/code-editor/CodeEditorConfig.js.map +1 -0
- package/lib/code-editor/CodeEditorUtils.d.ts +2 -0
- package/lib/code-editor/CodeEditorUtils.d.ts.map +1 -1
- package/lib/code-editor/CodeEditorUtils.js +46 -1
- package/lib/code-editor/CodeEditorUtils.js.map +1 -1
- package/lib/code-editor/PureLanguageCodeEditorSupport.d.ts +70 -0
- package/lib/code-editor/PureLanguageCodeEditorSupport.d.ts.map +1 -0
- package/lib/code-editor/PureLanguageCodeEditorSupport.js +237 -0
- package/lib/code-editor/PureLanguageCodeEditorSupport.js.map +1 -0
- package/lib/code-editor/PureLanguageService.d.ts +42 -0
- package/lib/code-editor/PureLanguageService.d.ts.map +1 -0
- package/lib/code-editor/PureLanguageService.js +437 -0
- package/lib/code-editor/PureLanguageService.js.map +1 -0
- package/lib/code-editor/__test-utils__/MockedMonacoEditor.d.ts.map +1 -0
- package/lib/code-editor/__test-utils__/MockedMonacoEditor.js.map +1 -0
- package/lib/code-editor/__test-utils__/MonacoEditorMockUtils.d.ts.map +1 -0
- package/lib/code-editor/{testing → __test-utils__}/MonacoEditorMockUtils.js +1 -1
- package/lib/code-editor/__test-utils__/MonacoEditorMockUtils.js.map +1 -0
- package/lib/code-editor/__test__.d.ts +17 -0
- package/lib/code-editor/__test__.d.ts.map +1 -0
- package/lib/code-editor/{testing/index.js → __test__.js} +2 -2
- package/lib/code-editor/__test__.js.map +1 -0
- package/lib/code-editor/index.d.ts +4 -0
- package/lib/code-editor/index.d.ts.map +1 -1
- package/lib/code-editor/index.js +4 -0
- package/lib/code-editor/index.js.map +1 -1
- package/lib/graph-editor/ElementIconUtils.d.ts +18 -0
- package/lib/graph-editor/ElementIconUtils.d.ts.map +1 -0
- package/lib/graph-editor/ElementIconUtils.js +37 -0
- package/lib/graph-editor/ElementIconUtils.js.map +1 -0
- package/lib/graph-editor/PackageableElementOption.d.ts +25 -0
- package/lib/graph-editor/PackageableElementOption.d.ts.map +1 -0
- package/lib/graph-editor/PackageableElementOption.js +46 -0
- package/lib/graph-editor/PackageableElementOption.js.map +1 -0
- package/lib/graph-editor/index.d.ts +18 -0
- package/lib/graph-editor/index.d.ts.map +1 -0
- package/lib/graph-editor/index.js +18 -0
- package/lib/graph-editor/index.js.map +1 -0
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/package.json +14 -9
- package/src/application/DocumentationLink.tsx +82 -0
- package/src/application/FuzzySearchAdvancedConfigMenu.tsx +66 -0
- package/src/application/TabManager.tsx +285 -0
- package/src/application/TabManagerState.ts +124 -0
- package/src/application/index.ts +22 -0
- package/src/code-editor/CodeDiffView.tsx +128 -0
- package/src/code-editor/CodeEditor.tsx +8 -5
- package/src/code-editor/CodeEditorConfig.ts +32 -0
- package/src/code-editor/CodeEditorUtils.ts +76 -1
- package/src/code-editor/PureLanguageCodeEditorSupport.ts +338 -0
- package/src/code-editor/PureLanguageService.ts +501 -0
- package/src/code-editor/{testing → __test-utils__}/MonacoEditorMockUtils.tsx +1 -1
- package/src/code-editor/{testing/index.ts → __test__.ts} +1 -1
- package/src/code-editor/index.ts +8 -0
- package/src/graph-editor/ElementIconUtils.tsx +47 -0
- package/src/graph-editor/PackageableElementOption.tsx +86 -0
- package/{lib/code-editor/testing/index.d.ts → src/graph-editor/index.ts} +3 -2
- package/tsconfig.json +16 -4
- package/lib/code-editor/testing/MockedMonacoEditor.d.ts.map +0 -1
- package/lib/code-editor/testing/MockedMonacoEditor.js.map +0 -1
- package/lib/code-editor/testing/MonacoEditorMockUtils.d.ts.map +0 -1
- package/lib/code-editor/testing/MonacoEditorMockUtils.js.map +0 -1
- package/lib/code-editor/testing/index.d.ts.map +0 -1
- package/lib/code-editor/testing/index.js.map +0 -1
- /package/lib/code-editor/{testing → __test-utils__}/MockedMonacoEditor.d.ts +0 -0
- /package/lib/code-editor/{testing → __test-utils__}/MockedMonacoEditor.js +0 -0
- /package/lib/code-editor/{testing → __test-utils__}/MonacoEditorMockUtils.d.ts +0 -0
- /package/src/code-editor/{testing → __test-utils__}/MockedMonacoEditor.ts +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
17
|
+
export declare const DocumentationLink: React.FC<{
|
|
18
|
+
documentationKey: string;
|
|
19
|
+
title?: string | undefined;
|
|
20
|
+
className?: string | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
export declare const DocumentationPreview: React.FC<{
|
|
23
|
+
text?: string | undefined;
|
|
24
|
+
documentationKey: string;
|
|
25
|
+
className?: string | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
//# sourceMappingURL=DocumentationLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocumentationLink.d.ts","sourceRoot":"","sources":["../../src/application/DocumentationLink.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAQH,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC;IACvC,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CA+BA,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC1C,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAkBA,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { shouldDisplayVirtualAssistantDocumentationEntry, useApplicationStore, } from '@finos/legend-application';
|
|
18
|
+
import { clsx, QuestionCircleIcon } from '@finos/legend-art';
|
|
19
|
+
export const DocumentationLink = (props) => {
|
|
20
|
+
const { documentationKey, title, className } = props;
|
|
21
|
+
const applicationStore = useApplicationStore();
|
|
22
|
+
const documentationEntry = applicationStore.documentationService.getDocEntry(documentationKey);
|
|
23
|
+
const openDocLink = (event) => {
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
event.stopPropagation();
|
|
26
|
+
applicationStore.assistantService.openDocumentationEntryLink(documentationKey);
|
|
27
|
+
};
|
|
28
|
+
if (!documentationEntry ||
|
|
29
|
+
(!documentationEntry.url &&
|
|
30
|
+
!shouldDisplayVirtualAssistantDocumentationEntry(documentationEntry))) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return (_jsx("div", { onClick: openDocLink, title: title ?? 'Click to see documentation', className: clsx('documentation-link', className), children: _jsx(QuestionCircleIcon, {}) }));
|
|
34
|
+
};
|
|
35
|
+
export const DocumentationPreview = (props) => {
|
|
36
|
+
const { documentationKey, text, className } = props;
|
|
37
|
+
const applicationStore = useApplicationStore();
|
|
38
|
+
const documentationEntry = applicationStore.documentationService.getDocEntry(documentationKey);
|
|
39
|
+
const textContent = text ?? documentationEntry?.text;
|
|
40
|
+
if (!documentationEntry || !textContent) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return (_jsxs("div", { className: clsx('documentation-preview', className), children: [_jsx("div", { className: "documentation-preview__text", children: textContent }), _jsx("div", { className: "documentation-preview__hint", children: _jsx(DocumentationLink, { documentationKey: documentationKey }) })] }));
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=DocumentationLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocumentationLink.js","sourceRoot":"","sources":["../../src/application/DocumentationLink.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,+CAA+C,EAC/C,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,MAAM,CAAC,MAAM,iBAAiB,GAIzB,CAAC,KAAK,EAAE,EAAE;IACb,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IACrD,MAAM,gBAAgB,GAAG,mBAAmB,EAAE,CAAC;IAC/C,MAAM,kBAAkB,GACtB,gBAAgB,CAAC,oBAAoB,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IACtE,MAAM,WAAW,GAA4C,CAC3D,KAAK,EACC,EAAE;QACR,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,KAAK,CAAC,eAAe,EAAE,CAAC;QACxB,gBAAgB,CAAC,gBAAgB,CAAC,0BAA0B,CAC1D,gBAAgB,CACjB,CAAC;IACJ,CAAC,CAAC;IAEF,IACE,CAAC,kBAAkB;QACnB,CAAC,CAAC,kBAAkB,CAAC,GAAG;YACtB,CAAC,+CAA+C,CAAC,kBAAkB,CAAC,CAAC,EACvE;QACA,OAAO,IAAI,CAAC;KACb;IACD,OAAO,CACL,cACE,OAAO,EAAE,WAAW,EACpB,KAAK,EAAE,KAAK,IAAI,4BAA4B,EAC5C,SAAS,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,YAEhD,KAAC,kBAAkB,KAAG,GAClB,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAI5B,CAAC,KAAK,EAAE,EAAE;IACb,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IACpD,MAAM,gBAAgB,GAAG,mBAAmB,EAAE,CAAC;IAC/C,MAAM,kBAAkB,GACtB,gBAAgB,CAAC,oBAAoB,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IACtE,MAAM,WAAW,GAAG,IAAI,IAAI,kBAAkB,EAAE,IAAI,CAAC;IAErD,IAAI,CAAC,kBAAkB,IAAI,CAAC,WAAW,EAAE;QACvC,OAAO,IAAI,CAAC;KACb;IACD,OAAO,CACL,eAAK,SAAS,EAAE,IAAI,CAAC,uBAAuB,EAAE,SAAS,CAAC,aACtD,cAAK,SAAS,EAAC,6BAA6B,YAAE,WAAW,GAAO,EAChE,cAAK,SAAS,EAAC,6BAA6B,YAC1C,KAAC,iBAAiB,IAAC,gBAAgB,EAAE,gBAAgB,GAAI,GACrD,IACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
17
|
+
import { type FuzzySearchAdvancedConfigState } from '@finos/legend-shared';
|
|
18
|
+
export declare const FuzzySearchAdvancedConfigMenu: ((props: {
|
|
19
|
+
configState: FuzzySearchAdvancedConfigState;
|
|
20
|
+
}) => JSX.Element) & {
|
|
21
|
+
displayName: string;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=FuzzySearchAdvancedConfigMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FuzzySearchAdvancedConfigMenu.d.ts","sourceRoot":"","sources":["../../src/application/FuzzySearchAdvancedConfigMenu.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAKH,OAAO,EAEL,KAAK,8BAA8B,EACpC,MAAM,sBAAsB,CAAC;AAG9B,eAAO,MAAM,6BAA6B,WAChC;IAAE,WAAW,EAAE,8BAA8B,CAAA;CAAE;;CAuCxD,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { BaseRadioGroup } from '@finos/legend-art';
|
|
18
|
+
import { observer } from 'mobx-react-lite';
|
|
19
|
+
import { DocumentationLink } from './DocumentationLink.js';
|
|
20
|
+
import { ADVANCED_FUZZY_SEARCH_MODE, } from '@finos/legend-shared';
|
|
21
|
+
import { LEGEND_APPLICATION_DOCUMENTATION_KEY } from '@finos/legend-application';
|
|
22
|
+
export const FuzzySearchAdvancedConfigMenu = observer((props) => {
|
|
23
|
+
const { configState } = props;
|
|
24
|
+
const handleSearchMode = (event) => {
|
|
25
|
+
const searchMode = event.target.value;
|
|
26
|
+
configState.setCurrentMode(searchMode);
|
|
27
|
+
};
|
|
28
|
+
return (_jsxs("div", { className: "fuzzy-search__advanced-config__panel", children: [_jsxs("div", { className: "fuzzy-search__advanced-config__panel__header__label", children: ["search config", _jsx(DocumentationLink, { className: "fuzzy-search__advanced-config__panel__header__hint", documentationKey: LEGEND_APPLICATION_DOCUMENTATION_KEY.QUESTION_HOW_TO_USE_ADVANCED_SEARCH_SYNTAX })] }), _jsx("div", { children: _jsx(BaseRadioGroup, { className: "text-search-advanced-config__options", value: configState.currentMode, onChange: handleSearchMode, row: false, options: [
|
|
29
|
+
ADVANCED_FUZZY_SEARCH_MODE.STANDARD,
|
|
30
|
+
ADVANCED_FUZZY_SEARCH_MODE.INCLUDE,
|
|
31
|
+
ADVANCED_FUZZY_SEARCH_MODE.EXACT,
|
|
32
|
+
ADVANCED_FUZZY_SEARCH_MODE.INVERSE,
|
|
33
|
+
], size: 1 }) })] }));
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=FuzzySearchAdvancedConfigMenu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FuzzySearchAdvancedConfigMenu.js","sourceRoot":"","sources":["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(c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
17
|
+
import type { TabManagerState, TabState } from './TabManagerState.js';
|
|
18
|
+
export declare const TabManager: ((props: {
|
|
19
|
+
tabManagerState: TabManagerState;
|
|
20
|
+
tabRenderer?: ((editorState: TabState) => React.ReactNode) | undefined;
|
|
21
|
+
}) => JSX.Element) & {
|
|
22
|
+
displayName: string;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=TabManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabManager.d.ts","sourceRoot":"","sources":["../../src/application/TabManager.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAiBH,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AA+NtE,eAAO,MAAM,UAAU;qBAEF,eAAe;iCACH,QAAQ,KAAK,MAAM,SAAS;;;CA2B5D,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { ChevronDownIcon, clsx, ContextMenu, DragPreviewLayer, DropdownMenu, MenuContent, MenuContentItem, PanelEntryDropZonePlaceholder, TimesIcon, useDragPreviewLayer, } from '@finos/legend-art';
|
|
18
|
+
import { observer } from 'mobx-react-lite';
|
|
19
|
+
import { useRef, useCallback } from 'react';
|
|
20
|
+
import { useDrop, useDrag } from 'react-dnd';
|
|
21
|
+
const horizontalToVerticalScroll = (event) => {
|
|
22
|
+
// if scrolling is more horizontal than vertical, there's nothing much to do, the OS should handle it just fine
|
|
23
|
+
// else, intercept
|
|
24
|
+
if (Math.abs(event.deltaY) <= Math.abs(event.deltaX)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
event.stopPropagation();
|
|
28
|
+
let deltaX;
|
|
29
|
+
// NOTE: only convert horizontal to vertical scroll when the scroll causes more horizontal than vertical displacement
|
|
30
|
+
// let the direction of `deltaY` be the direction of the scroll, i.e.
|
|
31
|
+
// - if we scroll upward, that translate to a left scroll
|
|
32
|
+
// - if we scroll downward, that translates to a right scroll
|
|
33
|
+
if (event.deltaY === 0) {
|
|
34
|
+
deltaX = event.deltaY;
|
|
35
|
+
}
|
|
36
|
+
else if (event.deltaY < 0) {
|
|
37
|
+
deltaX = -Math.abs(event.deltaY);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
deltaX = Math.abs(event.deltaY);
|
|
41
|
+
}
|
|
42
|
+
event.currentTarget.scrollBy(deltaX, 0);
|
|
43
|
+
};
|
|
44
|
+
const TabContextMenu = observer((props) => {
|
|
45
|
+
const { tabState, managerTabState } = props;
|
|
46
|
+
const close = () => managerTabState.closeTab(tabState);
|
|
47
|
+
const closeOthers = () => managerTabState.closeAllOtherTabs(tabState);
|
|
48
|
+
const closeAll = () => managerTabState.closeAllTabs();
|
|
49
|
+
return (_jsxs(MenuContent, { children: [_jsx(MenuContentItem, { onClick: close, children: "Close" }), _jsx(MenuContentItem, { disabled: managerTabState.tabs.length < 2, onClick: closeOthers, children: "Close Others" }), _jsx(MenuContentItem, { onClick: closeAll, children: "Close All" })] }));
|
|
50
|
+
});
|
|
51
|
+
const Tab = observer((props) => {
|
|
52
|
+
const ref = useRef(null);
|
|
53
|
+
const { tabManagerState, tabState, tabRenderer } = props;
|
|
54
|
+
// Drag and Drop
|
|
55
|
+
const handleHover = useCallback((item, monitor) => {
|
|
56
|
+
const draggingTab = item.tab;
|
|
57
|
+
const hoveredTab = tabState;
|
|
58
|
+
const dragIndex = tabManagerState.tabs.findIndex((e) => e === draggingTab);
|
|
59
|
+
const hoverIndex = tabManagerState.tabs.findIndex((e) => e === hoveredTab);
|
|
60
|
+
const hoverBoundingReact = ref.current?.getBoundingClientRect();
|
|
61
|
+
const distanceThreshold = ((hoverBoundingReact?.left ?? 0) - (hoverBoundingReact?.right ?? 0)) /
|
|
62
|
+
2;
|
|
63
|
+
const dragDistance = (monitor.getClientOffset()?.x ?? 0) -
|
|
64
|
+
(hoverBoundingReact?.right ?? 0);
|
|
65
|
+
if (dragIndex < hoverIndex && dragDistance < distanceThreshold) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (dragIndex > hoverIndex && dragDistance > distanceThreshold) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
tabManagerState.swapTabs(draggingTab, hoveredTab);
|
|
72
|
+
}, [tabManagerState, tabState]);
|
|
73
|
+
const closeTabOnMiddleClick = (currTab) => (event) => {
|
|
74
|
+
if (event.nativeEvent.button === 1) {
|
|
75
|
+
tabManagerState.closeTab(currTab);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const [{ isBeingDraggedEditorPanel }, dropConnector] = useDrop(() => ({
|
|
79
|
+
accept: [tabManagerState.dndType],
|
|
80
|
+
hover: (item, monitor) => handleHover(item, monitor),
|
|
81
|
+
collect: (monitor) => ({
|
|
82
|
+
isBeingDraggedEditorPanel: monitor.getItem()
|
|
83
|
+
?.tab,
|
|
84
|
+
}),
|
|
85
|
+
}), [handleHover]);
|
|
86
|
+
const isBeingDragged = tabState === isBeingDraggedEditorPanel;
|
|
87
|
+
const [, dragConnector, dragPreviewConnector] = useDrag(() => ({
|
|
88
|
+
type: tabManagerState.dndType,
|
|
89
|
+
item: () => ({
|
|
90
|
+
tab: tabState,
|
|
91
|
+
}),
|
|
92
|
+
}), [tabState, tabManagerState]);
|
|
93
|
+
dragConnector(dropConnector(ref));
|
|
94
|
+
useDragPreviewLayer(dragPreviewConnector);
|
|
95
|
+
return (_jsx("div", { ref: ref, className: clsx('tab-manager__tab', {
|
|
96
|
+
'tab-manager__tab--active': tabState === tabManagerState.currentTab,
|
|
97
|
+
'tab-manager__tab--dragged': isBeingDragged,
|
|
98
|
+
}), onMouseUp: closeTabOnMiddleClick(tabState), children: _jsx(PanelEntryDropZonePlaceholder, { showPlaceholder: false, className: "tab-manager__tab__dnd__placeholder", children: _jsxs(ContextMenu, { content: _jsx(TabContextMenu, { tabState: tabState, managerTabState: tabManagerState }), className: "tab-manager__tab__content", children: [_jsx("button", { className: "tab-manager__tab__label", tabIndex: -1, onClick: () => tabManagerState.openTab(tabState), title: tabState.description, children: tabRenderer?.(tabState) ?? tabState.label }), _jsx("button", { className: "tab-manager__tab__close-btn", onClick: () => tabManagerState.closeTab(tabState), tabIndex: -1, title: "Close", children: _jsx(TimesIcon, {}) })] }) }) }));
|
|
99
|
+
});
|
|
100
|
+
const TabMenu = observer((props) => {
|
|
101
|
+
const { managerTabState } = props;
|
|
102
|
+
return (_jsx(DropdownMenu, { className: "tab-manager__menu__toggler", title: "Show All Tabs", content: _jsx(MenuContent, { className: "tab-manager__menu", children: managerTabState.tabs.map((tabState) => (_jsxs(MenuContentItem, { className: clsx('tab-manager__menu__item', {
|
|
103
|
+
'tab-manager__menu__item--active': tabState === managerTabState.currentTab,
|
|
104
|
+
}), onClick: () => managerTabState.openTab(tabState), children: [_jsx("div", { className: "tab-manager__menu__item__label", children: tabState.label }), _jsx("div", { className: "tab-manager__menu__item__close-btn", onClick: (event) => {
|
|
105
|
+
// NOTE: prevent default action of dropdown menu
|
|
106
|
+
event.stopPropagation();
|
|
107
|
+
managerTabState.closeTab(tabState);
|
|
108
|
+
}, tabIndex: -1, title: "Close", children: _jsx(TimesIcon, {}) })] }, tabState.uuid))) }), menuProps: {
|
|
109
|
+
anchorOrigin: { vertical: 'bottom', horizontal: 'right' },
|
|
110
|
+
transformOrigin: { vertical: 'top', horizontal: 'right' },
|
|
111
|
+
}, children: _jsx(ChevronDownIcon, {}) }));
|
|
112
|
+
});
|
|
113
|
+
export const TabManager = observer((props) => {
|
|
114
|
+
const { tabManagerState, tabRenderer } = props;
|
|
115
|
+
return (_jsxs("div", { className: "tab-manager", children: [_jsxs("div", { className: "tab-manager__content", onWheel: horizontalToVerticalScroll, children: [tabManagerState.tabs.map((tab) => (_jsx(Tab, { tabState: tab, tabManagerState: tabManagerState, tabRenderer: tabRenderer }, tab.uuid))), _jsx(DragPreviewLayer, { labelGetter: (item) => item.tab.label, types: [tabManagerState.dndType] })] }), _jsx(TabMenu, { managerTabState: tabManagerState })] }));
|
|
116
|
+
});
|
|
117
|
+
//# sourceMappingURL=TabManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabManager.js","sourceRoot":"","sources":["../../src/application/TabManager.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,eAAe,EACf,IAAI,EACJ,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ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AO,CACL,eAAK,SAAS,EAAC,aAAa,aAC1B,eACE,SAAS,EAAC,sBAAsB,EAChC,OAAO,EAAE,0BAA0B,aAElC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CACjC,KAAC,GAAG,IAEF,QAAQ,EAAE,GAAG,EACb,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,WAAW,IAHnB,GAAG,CAAC,IAAI,CAIb,CACH,CAAC,EACF,KAAC,gBAAgB,IACf,WAAW,EAAE,CAAC,IAAmB,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAC5D,KAAK,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,GAChC,IACE,EACN,KAAC,OAAO,IAAC,eAAe,EAAE,eAAe,GAAI,IACzC,CACP,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export declare abstract class TabState {
|
|
17
|
+
readonly uuid: string;
|
|
18
|
+
abstract get label(): string;
|
|
19
|
+
get description(): string | undefined;
|
|
20
|
+
match(tab: TabState): boolean;
|
|
21
|
+
onOpen(): void;
|
|
22
|
+
onClose(): void;
|
|
23
|
+
}
|
|
24
|
+
export declare abstract class TabManagerState {
|
|
25
|
+
currentTab?: TabState | undefined;
|
|
26
|
+
tabs: TabState[];
|
|
27
|
+
constructor();
|
|
28
|
+
setCurrentTab(val: TabState | undefined): void;
|
|
29
|
+
closeAllOtherTabs(tab: TabState): void;
|
|
30
|
+
closeAllTabs(): void;
|
|
31
|
+
swapTabs(tab1: TabState, tab2: TabState): void;
|
|
32
|
+
/**
|
|
33
|
+
* The unique drag and drop type
|
|
34
|
+
* See https://react-dnd.github.io/react-dnd/docs/overview#items-and-types
|
|
35
|
+
*/
|
|
36
|
+
abstract get dndType(): string;
|
|
37
|
+
openTab(tab: TabState): void;
|
|
38
|
+
closeTab(tab: TabState): void;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=TabManagerState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabManagerState.d.ts","sourceRoot":"","sources":["../../src/application/TabManagerState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAUH,8BAAsB,QAAQ;IAC5B,QAAQ,CAAC,IAAI,SAAU;IAEvB,QAAQ,KAAK,KAAK,IAAI,MAAM,CAAC;IAE7B,IAAI,WAAW,IAAI,MAAM,GAAG,SAAS,CAEpC;IAED,KAAK,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO;IAI7B,MAAM,IAAI,IAAI;IAId,OAAO,IAAI,IAAI;CAGhB;AAED,8BAAsB,eAAe;IACnC,UAAU,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAClC,IAAI,EAAE,QAAQ,EAAE,CAAM;;IAetB,aAAa,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS,GAAG,IAAI;IAI9C,iBAAiB,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI;IAStC,YAAY,IAAI,IAAI;IAKpB,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI;IAI9C;;;OAGG;IACH,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC;IAE/B,OAAO,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI;IAe5B,QAAQ,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI;CAiB9B"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { assertNonNullable, assertTrue, swapEntry, uuid, } from '@finos/legend-shared';
|
|
17
|
+
import { action, makeObservable, observable } from 'mobx';
|
|
18
|
+
export class TabState {
|
|
19
|
+
uuid = uuid();
|
|
20
|
+
get description() {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
match(tab) {
|
|
24
|
+
return this === tab;
|
|
25
|
+
}
|
|
26
|
+
onOpen() {
|
|
27
|
+
// do nothing
|
|
28
|
+
}
|
|
29
|
+
onClose() {
|
|
30
|
+
// do nothing
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export class TabManagerState {
|
|
34
|
+
currentTab;
|
|
35
|
+
tabs = [];
|
|
36
|
+
constructor() {
|
|
37
|
+
makeObservable(this, {
|
|
38
|
+
currentTab: observable,
|
|
39
|
+
tabs: observable,
|
|
40
|
+
setCurrentTab: action,
|
|
41
|
+
closeTab: action,
|
|
42
|
+
closeAllTabs: action,
|
|
43
|
+
closeAllOtherTabs: action,
|
|
44
|
+
openTab: action,
|
|
45
|
+
swapTabs: action,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
setCurrentTab(val) {
|
|
49
|
+
this.currentTab = val;
|
|
50
|
+
}
|
|
51
|
+
closeAllOtherTabs(tab) {
|
|
52
|
+
assertNonNullable(this.tabs.find((e) => e === tab), 'Specified tab should be currently opened');
|
|
53
|
+
this.setCurrentTab(tab);
|
|
54
|
+
this.tabs = [tab];
|
|
55
|
+
}
|
|
56
|
+
closeAllTabs() {
|
|
57
|
+
this.setCurrentTab(undefined);
|
|
58
|
+
this.tabs = [];
|
|
59
|
+
}
|
|
60
|
+
swapTabs(tab1, tab2) {
|
|
61
|
+
swapEntry(this.tabs, tab1, tab2);
|
|
62
|
+
}
|
|
63
|
+
openTab(tab) {
|
|
64
|
+
const existingTab = this.tabs.find((t) => t.match(tab));
|
|
65
|
+
if (!existingTab) {
|
|
66
|
+
if (this.currentTab) {
|
|
67
|
+
const currIndex = this.tabs.findIndex((e) => e === this.currentTab);
|
|
68
|
+
this.tabs.splice(currIndex + 1, 0, tab);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
this.tabs.push(tab);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
this.setCurrentTab(tab);
|
|
75
|
+
tab.onOpen();
|
|
76
|
+
}
|
|
77
|
+
closeTab(tab) {
|
|
78
|
+
const tabIndex = this.tabs.findIndex((t) => t.match(tab));
|
|
79
|
+
assertTrue(tabIndex !== -1, `Can't close a tab which is not opened`);
|
|
80
|
+
this.tabs.splice(tabIndex, 1);
|
|
81
|
+
if (this.currentTab === tab) {
|
|
82
|
+
if (this.tabs.length) {
|
|
83
|
+
const openIndex = tabIndex - 1;
|
|
84
|
+
this.setCurrentTab(openIndex >= 0 ? this.tabs[openIndex] : this.tabs[0]);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
this.setCurrentTab(undefined);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
tab.onClose();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=TabManagerState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabManagerState.js","sourceRoot":"","sources":["../../src/application/TabManagerState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,IAAI,GACL,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAE1D,MAAM,OAAgB,QAAQ;IACnB,IAAI,GAAG,IAAI,EAAE,CAAC;IAIvB,IAAI,WAAW;QACb,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,GAAa;QACjB,OAAO,IAAI,KAAK,GAAG,CAAC;IACtB,CAAC;IAED,MAAM;QACJ,aAAa;IACf,CAAC;IAED,OAAO;QACL,aAAa;IACf,CAAC;CACF;AAED,MAAM,OAAgB,eAAe;IACnC,UAAU,CAAwB;IAClC,IAAI,GAAe,EAAE,CAAC;IAEtB;QACE,cAAc,CAAC,IAAI,EAAE;YACnB,UAAU,EAAE,UAAU;YACtB,IAAI,EAAE,UAAU;YAChB,aAAa,EAAE,MAAM;YACrB,QAAQ,EAAE,MAAM;YAChB,YAAY,EAAE,MAAM;YACpB,iBAAiB,EAAE,MAAM;YACzB,OAAO,EAAE,MAAM;YACf,QAAQ,EAAE,MAAM;SACjB,CAAC,CAAC;IACL,CAAC;IAED,aAAa,CAAC,GAAyB;QACrC,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;IACxB,CAAC;IAED,iBAAiB,CAAC,GAAa;QAC7B,iBAAiB,CACf,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,EAChC,0CAA0C,CAC3C,CAAC;QACF,IAAI,CAAC,aAAa,CAAC,GAA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Q,EAAE,CAAC,CAAC,CAAC;QAC9B,IAAI,IAAI,CAAC,UAAU,KAAK,GAAG,EAAE;YAC3B,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBACpB,MAAM,SAAS,GAAG,QAAQ,GAAG,CAAC,CAAC;gBAC/B,IAAI,CAAC,aAAa,CAChB,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CACrD,CAAC;aACH;iBAAM;gBACL,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;aAC/B;SACF;QAED,GAAG,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export * from './DocumentationLink.js';
|
|
17
|
+
export * from './TabManager.js';
|
|
18
|
+
export * from './TabManagerState.js';
|
|
19
|
+
export * from './FuzzySearchAdvancedConfigMenu.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/application/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,wBAAwB,CAAC;AAEvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AAErC,cAAc,oCAAoC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export * from './DocumentationLink.js';
|
|
17
|
+
export * from './TabManager.js';
|
|
18
|
+
export * from './TabManagerState.js';
|
|
19
|
+
export * from './FuzzySearchAdvancedConfigMenu.js';
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/application/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,wBAAwB,CAAC;AAEvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AAErC,cAAc,oCAAoC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
17
|
+
import { CODE_EDITOR_LANGUAGE } from './CodeEditorConfig.js';
|
|
18
|
+
export declare const CodeDiffView: ((props: {
|
|
19
|
+
language: CODE_EDITOR_LANGUAGE;
|
|
20
|
+
from?: string | undefined;
|
|
21
|
+
to?: string | undefined;
|
|
22
|
+
}) => JSX.Element) & {
|
|
23
|
+
displayName: string;
|
|
24
|
+
};
|
|
25
|
+
export declare const JSONDiffView: ((props: {
|
|
26
|
+
from?: unknown;
|
|
27
|
+
to?: unknown;
|
|
28
|
+
/**
|
|
29
|
+
* Use lossless algorithm while parsing/stringifying JSON-like value
|
|
30
|
+
*/
|
|
31
|
+
lossless?: boolean;
|
|
32
|
+
}) => JSX.Element) & {
|
|
33
|
+
displayName: string;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=CodeDiffView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeDiffView.d.ts","sourceRoot":"","sources":["../../src/code-editor/CodeDiffView.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAoBH,OAAO,EAAE,oBAAoB,EAAqB,MAAM,uBAAuB,CAAC;AAEhF,eAAO,MAAM,YAAY,WACf;IACN,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzB;;CAsDF,CAAC;AAaF,eAAO,MAAM,YAAY,WACf;IACN,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,EAAE,CAAC,EAAE,OAAO,CAAC;IACb;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;;CAWF,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2020-present, Goldman Sachs
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { useEffect, useState, useRef } from 'react';
|
|
18
|
+
import { observer } from 'mobx-react-lite';
|
|
19
|
+
import { editor as monacoEditorAPI } from 'monaco-editor';
|
|
20
|
+
import { DEFAULT_TAB_SIZE, useApplicationStore, } from '@finos/legend-application';
|
|
21
|
+
import { useResizeDetector } from '@finos/legend-art';
|
|
22
|
+
import { isString, stringifyLosslessJSON, tryToFormatJSONString, tryToFormatLosslessJSONString, } from '@finos/legend-shared';
|
|
23
|
+
import { disposeDiffCodeEditor, getBaseCodeEditorOptions, } from './CodeEditorUtils.js';
|
|
24
|
+
import { CODE_EDITOR_LANGUAGE, CODE_EDITOR_THEME } from './CodeEditorConfig.js';
|
|
25
|
+
export const CodeDiffView = observer((props) => {
|
|
26
|
+
const { from, to, language } = props;
|
|
27
|
+
const applicationStore = useApplicationStore();
|
|
28
|
+
const [editor, setEditor] = useState();
|
|
29
|
+
const editorRef = useRef(null);
|
|
30
|
+
const originalText = from ?? '';
|
|
31
|
+
const modifiedText = to ?? '';
|
|
32
|
+
const { ref, width, height } = useResizeDetector();
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (width !== undefined && height !== undefined) {
|
|
35
|
+
editor?.layout({ width, height });
|
|
36
|
+
}
|
|
37
|
+
}, [editor, width, height]);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!editor && editorRef.current) {
|
|
40
|
+
const element = editorRef.current;
|
|
41
|
+
const _editor = monacoEditorAPI.createDiffEditor(element, {
|
|
42
|
+
...getBaseCodeEditorOptions(),
|
|
43
|
+
theme: CODE_EDITOR_THEME.LEGEND,
|
|
44
|
+
readOnly: true,
|
|
45
|
+
});
|
|
46
|
+
setEditor(_editor);
|
|
47
|
+
}
|
|
48
|
+
}, [applicationStore, editor]);
|
|
49
|
+
if (editor) {
|
|
50
|
+
const originalModel = monacoEditorAPI.createModel(originalText, language);
|
|
51
|
+
const modifiedModel = monacoEditorAPI.createModel(modifiedText, language);
|
|
52
|
+
editor.setModel({
|
|
53
|
+
original: originalModel,
|
|
54
|
+
modified: modifiedModel,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
// dispose editor
|
|
58
|
+
useEffect(() => () => {
|
|
59
|
+
if (editor) {
|
|
60
|
+
disposeDiffCodeEditor(editor);
|
|
61
|
+
}
|
|
62
|
+
}, [editor]);
|
|
63
|
+
return (_jsx("div", { ref: ref, className: "code-editor__container", children: _jsx("div", { className: "code-editor__body", ref: editorRef }) }));
|
|
64
|
+
});
|
|
65
|
+
const formatJSONLikeValue = (value, lossless) => value
|
|
66
|
+
? isString(value)
|
|
67
|
+
? lossless
|
|
68
|
+
? tryToFormatLosslessJSONString(value)
|
|
69
|
+
: tryToFormatJSONString(value)
|
|
70
|
+
: lossless
|
|
71
|
+
? stringifyLosslessJSON(value, undefined, DEFAULT_TAB_SIZE)
|
|
72
|
+
: JSON.stringify(value, undefined, DEFAULT_TAB_SIZE)
|
|
73
|
+
: '';
|
|
74
|
+
export const JSONDiffView = observer((props) => {
|
|
75
|
+
const { from, to, lossless } = props;
|
|
76
|
+
return (_jsx(CodeDiffView, { language: CODE_EDITOR_LANGUAGE.JSON, from: formatJSONLikeValue(from, Boolean(lossless)), to: formatJSONLikeValue(to, Boolean(lossless)) }));
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=CodeDiffView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeDiffView.js","sourceRoot":"","sources":["../../src/code-editor/CodeDiffView.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACL,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EACL,QAAQ,EACR,qBAAqB,EACrB,qBAAqB,EACrB,6BAA6B,GAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAEhF,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAClC,CAAC,KAIA,EAAE,EAAE;IACH,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACrC,MAAM,gBAAgB,GAAG,mBAAmB,EAAE,CAAC;IAC/C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GACvB,QAAQ,EAAyC,CAAC;IACpD,MAAM,SAAS,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC/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