@finos/legend-lego 0.1.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 (46) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +3 -0
  3. package/lib/code-editor/CodeEditor.d.ts +28 -0
  4. package/lib/code-editor/CodeEditor.d.ts.map +1 -0
  5. package/lib/code-editor/CodeEditor.js +109 -0
  6. package/lib/code-editor/CodeEditor.js.map +1 -0
  7. package/lib/code-editor/CodeEditorUtils.d.ts +61 -0
  8. package/lib/code-editor/CodeEditorUtils.d.ts.map +1 -0
  9. package/lib/code-editor/CodeEditorUtils.js +134 -0
  10. package/lib/code-editor/CodeEditorUtils.js.map +1 -0
  11. package/lib/code-editor/index.d.ts +18 -0
  12. package/lib/code-editor/index.d.ts.map +1 -0
  13. package/lib/code-editor/index.js +18 -0
  14. package/lib/code-editor/index.js.map +1 -0
  15. package/lib/code-editor/testing/MockedMonacoEditor.d.ts +17 -0
  16. package/lib/code-editor/testing/MockedMonacoEditor.d.ts.map +1 -0
  17. package/lib/code-editor/testing/MockedMonacoEditor.js +17 -0
  18. package/lib/code-editor/testing/MockedMonacoEditor.js.map +1 -0
  19. package/lib/code-editor/testing/MonacoEditorMockUtils.d.ts +99 -0
  20. package/lib/code-editor/testing/MonacoEditorMockUtils.d.ts.map +1 -0
  21. package/lib/code-editor/testing/MonacoEditorMockUtils.js +105 -0
  22. package/lib/code-editor/testing/MonacoEditorMockUtils.js.map +1 -0
  23. package/lib/code-editor/testing/index.d.ts +17 -0
  24. package/lib/code-editor/testing/index.d.ts.map +1 -0
  25. package/lib/code-editor/testing/index.js +17 -0
  26. package/lib/code-editor/testing/index.js.map +1 -0
  27. package/lib/data-grid/DataGrid.d.ts +22 -0
  28. package/lib/data-grid/DataGrid.d.ts.map +1 -0
  29. package/lib/data-grid/DataGrid.js +26 -0
  30. package/lib/data-grid/DataGrid.js.map +1 -0
  31. package/lib/data-grid/index.d.ts +17 -0
  32. package/lib/data-grid/index.d.ts.map +1 -0
  33. package/lib/data-grid/index.js +17 -0
  34. package/lib/data-grid/index.js.map +1 -0
  35. package/lib/index.css +17 -0
  36. package/lib/index.css.map +1 -0
  37. package/package.json +80 -0
  38. package/src/code-editor/CodeEditor.tsx +157 -0
  39. package/src/code-editor/CodeEditorUtils.ts +201 -0
  40. package/src/code-editor/index.ts +18 -0
  41. package/src/code-editor/testing/MockedMonacoEditor.ts +24 -0
  42. package/src/code-editor/testing/MonacoEditorMockUtils.tsx +111 -0
  43. package/src/code-editor/testing/index.ts +17 -0
  44. package/src/data-grid/DataGrid.tsx +42 -0
  45. package/src/data-grid/index.ts +17 -0
  46. package/tsconfig.json +48 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MockedMonacoEditor.js","sourceRoot":"","sources":["../../../src/code-editor/testing/MockedMonacoEditor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,yBAAyB,IAAI,OAAO,EACpC,gCAAgC,IAAI,cAAc,EAClD,uBAAuB,IAAI,uBAAuB,EAClD,0BAA0B,IAAI,0BAA0B,EACxD,qBAAqB,IAAI,MAAM,EAC/B,8BAA8B,IAAI,SAAS,GAC5C,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,99 @@
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
+ /**
17
+ * NOTE: we have tried different ways to mock `monaco-editor`. But those ways often involve
18
+ * trying to load `monaco-editor` from `node_modules` and that takes a long time, so we'd better just mock
19
+ * it completely like in this file.
20
+ * See https://gitlab.com/gitlab-org/gitlab/-/issues/119194
21
+ * See https://stackoverflow.com/questions/57731857/cannot-test-jest-with-monaco-editor-unexpected-token
22
+ */
23
+ export declare enum MockedMonacoEditorKeyCode {
24
+ F1 = 59,
25
+ F8 = 66,
26
+ F9 = 67,
27
+ F10 = 68
28
+ }
29
+ export declare enum MockedMonacoEditorMarkerSeverity {
30
+ Hint = 1,
31
+ Info = 2,
32
+ Warning = 4,
33
+ Error = 8
34
+ }
35
+ export declare enum MockedMonacoEditorEndOfLinePreference {
36
+ LF = 1
37
+ }
38
+ export declare const MockedMonacoEditorModel: {
39
+ dispose: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
40
+ updateOptions: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
41
+ getValue: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
42
+ getLineCount: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
43
+ getLineMaxColumn: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
44
+ pushStackElement: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
45
+ pushEditOperations: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
46
+ findMatches: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
47
+ };
48
+ export declare const MockedMonacoEditorInstance: {
49
+ dispose: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
50
+ addCommand: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
51
+ getValue: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
52
+ getPosition: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
53
+ getRawOptions: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
54
+ getModel: () => typeof MockedMonacoEditorModel;
55
+ hasTextFocus: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
56
+ updateOptions: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
57
+ setValue: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
58
+ revealPosition: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
59
+ setPosition: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
60
+ onKeyDown: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
61
+ createDecorationsCollection: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
62
+ onDidChangeModelContent: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
63
+ onDidChangeCursorPosition: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
64
+ onDidFocusEditorText: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
65
+ onDidBlurEditorText: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
66
+ onDidFocusEditorWidget: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
67
+ };
68
+ export declare const MockedMonacoEditorAPI: {
69
+ create: () => typeof MockedMonacoEditorInstance;
70
+ focus: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
71
+ createModel: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
72
+ createDiffEditor: () => {
73
+ getOriginalEditor: () => typeof MockedMonacoEditorInstance;
74
+ getModifiedEditor: () => typeof MockedMonacoEditorInstance;
75
+ };
76
+ setModelMarkers: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
77
+ setModelLanguage: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
78
+ defineTheme: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
79
+ EndOfLinePreference: typeof MockedMonacoEditorEndOfLinePreference;
80
+ removeAllMarkers: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
81
+ };
82
+ export declare enum MockedMonacoLanguageCompletionItemKind {
83
+ Keyword = 17,
84
+ Snippet = 27
85
+ }
86
+ export declare enum MockedMonacoLanguageCompletionItemInsertTextRule {
87
+ InsertAsSnippet = 4
88
+ }
89
+ export declare const MockedMonacoEditorLanguagesAPI: {
90
+ register: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
91
+ setLanguageConfiguration: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
92
+ setMonarchTokensProvider: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
93
+ registerCodeLensProvider: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
94
+ registerHoverProvider: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
95
+ registerCompletionItemProvider: import("@jest/globals").jest.Mock<import("@finos/legend-shared").SuperGenericFunction>;
96
+ CompletionItemKind: typeof MockedMonacoLanguageCompletionItemKind;
97
+ CompletionItemInsertTextRule: typeof MockedMonacoLanguageCompletionItemKind;
98
+ };
99
+ //# sourceMappingURL=MonacoEditorMockUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MonacoEditorMockUtils.d.ts","sourceRoot":"","sources":["../../../src/code-editor/testing/MonacoEditorMockUtils.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH;;;;;;GAMG;AACH,oBAAY,yBAAyB;IACnC,EAAE,KAAK;IACP,EAAE,KAAK;IACP,EAAE,KAAK;IACP,GAAG,KAAK;CACT;AAED,oBAAY,gCAAgC;IAC1C,IAAI,IAAI;IACR,IAAI,IAAI;IACR,OAAO,IAAI;IACX,KAAK,IAAI;CACV;AAED,oBAAY,qCAAqC;IAC/C,EAAE,IAAI;CACP;AAED,eAAO,MAAM,uBAAuB;;;;;;;;;CASnC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;oBAMvB,8BAA8B;;;;;;;;;;;;;CAa7C,CAAC;AAEF,eAAO,MAAM,qBAAqB;kBACpB,iCAAiC;;;;iCAIpB,iCAAiC;iCAEjC,iCAAiC;;;;;;;CAQ3D,CAAC;AAEF,oBAAY,sCAAsC;IAChD,OAAO,KAAK;IACZ,OAAO,KAAK;CACb;AAED,oBAAY,gDAAgD;IAC1D,eAAe,IAAI;CACpB;AAED,eAAO,MAAM,8BAA8B;;;;;;;;;CAS1C,CAAC"}
@@ -0,0 +1,105 @@
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 { createMock } from '@finos/legend-shared';
17
+ /**
18
+ * NOTE: we have tried different ways to mock `monaco-editor`. But those ways often involve
19
+ * trying to load `monaco-editor` from `node_modules` and that takes a long time, so we'd better just mock
20
+ * it completely like in this file.
21
+ * See https://gitlab.com/gitlab-org/gitlab/-/issues/119194
22
+ * See https://stackoverflow.com/questions/57731857/cannot-test-jest-with-monaco-editor-unexpected-token
23
+ */
24
+ export var MockedMonacoEditorKeyCode;
25
+ (function (MockedMonacoEditorKeyCode) {
26
+ MockedMonacoEditorKeyCode[MockedMonacoEditorKeyCode["F1"] = 59] = "F1";
27
+ MockedMonacoEditorKeyCode[MockedMonacoEditorKeyCode["F8"] = 66] = "F8";
28
+ MockedMonacoEditorKeyCode[MockedMonacoEditorKeyCode["F9"] = 67] = "F9";
29
+ MockedMonacoEditorKeyCode[MockedMonacoEditorKeyCode["F10"] = 68] = "F10";
30
+ })(MockedMonacoEditorKeyCode = MockedMonacoEditorKeyCode || (MockedMonacoEditorKeyCode = {}));
31
+ export var MockedMonacoEditorMarkerSeverity;
32
+ (function (MockedMonacoEditorMarkerSeverity) {
33
+ MockedMonacoEditorMarkerSeverity[MockedMonacoEditorMarkerSeverity["Hint"] = 1] = "Hint";
34
+ MockedMonacoEditorMarkerSeverity[MockedMonacoEditorMarkerSeverity["Info"] = 2] = "Info";
35
+ MockedMonacoEditorMarkerSeverity[MockedMonacoEditorMarkerSeverity["Warning"] = 4] = "Warning";
36
+ MockedMonacoEditorMarkerSeverity[MockedMonacoEditorMarkerSeverity["Error"] = 8] = "Error";
37
+ })(MockedMonacoEditorMarkerSeverity = MockedMonacoEditorMarkerSeverity || (MockedMonacoEditorMarkerSeverity = {}));
38
+ export var MockedMonacoEditorEndOfLinePreference;
39
+ (function (MockedMonacoEditorEndOfLinePreference) {
40
+ MockedMonacoEditorEndOfLinePreference[MockedMonacoEditorEndOfLinePreference["LF"] = 1] = "LF";
41
+ })(MockedMonacoEditorEndOfLinePreference = MockedMonacoEditorEndOfLinePreference || (MockedMonacoEditorEndOfLinePreference = {}));
42
+ export const MockedMonacoEditorModel = {
43
+ dispose: createMock(),
44
+ updateOptions: createMock(),
45
+ getValue: createMock(),
46
+ getLineCount: createMock(),
47
+ getLineMaxColumn: createMock(),
48
+ pushStackElement: createMock(),
49
+ pushEditOperations: createMock(),
50
+ findMatches: createMock(),
51
+ };
52
+ export const MockedMonacoEditorInstance = {
53
+ dispose: createMock(),
54
+ addCommand: createMock(),
55
+ getValue: createMock(),
56
+ getPosition: createMock(),
57
+ getRawOptions: createMock(),
58
+ getModel: () => MockedMonacoEditorModel,
59
+ hasTextFocus: createMock(),
60
+ updateOptions: createMock(),
61
+ setValue: createMock(),
62
+ revealPosition: createMock(),
63
+ setPosition: createMock(),
64
+ onKeyDown: createMock(),
65
+ createDecorationsCollection: createMock(),
66
+ onDidChangeModelContent: createMock(),
67
+ onDidChangeCursorPosition: createMock(),
68
+ onDidFocusEditorText: createMock(),
69
+ onDidBlurEditorText: createMock(),
70
+ onDidFocusEditorWidget: createMock(),
71
+ };
72
+ export const MockedMonacoEditorAPI = {
73
+ create: () => MockedMonacoEditorInstance,
74
+ focus: createMock(),
75
+ createModel: createMock(),
76
+ createDiffEditor: () => ({
77
+ getOriginalEditor: () => MockedMonacoEditorInstance,
78
+ getModifiedEditor: () => MockedMonacoEditorInstance,
79
+ }),
80
+ setModelMarkers: createMock(),
81
+ setModelLanguage: createMock(),
82
+ defineTheme: createMock(),
83
+ EndOfLinePreference: MockedMonacoEditorEndOfLinePreference,
84
+ removeAllMarkers: createMock(),
85
+ };
86
+ export var MockedMonacoLanguageCompletionItemKind;
87
+ (function (MockedMonacoLanguageCompletionItemKind) {
88
+ MockedMonacoLanguageCompletionItemKind[MockedMonacoLanguageCompletionItemKind["Keyword"] = 17] = "Keyword";
89
+ MockedMonacoLanguageCompletionItemKind[MockedMonacoLanguageCompletionItemKind["Snippet"] = 27] = "Snippet";
90
+ })(MockedMonacoLanguageCompletionItemKind = MockedMonacoLanguageCompletionItemKind || (MockedMonacoLanguageCompletionItemKind = {}));
91
+ export var MockedMonacoLanguageCompletionItemInsertTextRule;
92
+ (function (MockedMonacoLanguageCompletionItemInsertTextRule) {
93
+ MockedMonacoLanguageCompletionItemInsertTextRule[MockedMonacoLanguageCompletionItemInsertTextRule["InsertAsSnippet"] = 4] = "InsertAsSnippet";
94
+ })(MockedMonacoLanguageCompletionItemInsertTextRule = MockedMonacoLanguageCompletionItemInsertTextRule || (MockedMonacoLanguageCompletionItemInsertTextRule = {}));
95
+ export const MockedMonacoEditorLanguagesAPI = {
96
+ register: createMock(),
97
+ setLanguageConfiguration: createMock(),
98
+ setMonarchTokensProvider: createMock(),
99
+ registerCodeLensProvider: createMock(),
100
+ registerHoverProvider: createMock(),
101
+ registerCompletionItemProvider: createMock(),
102
+ CompletionItemKind: MockedMonacoLanguageCompletionItemKind,
103
+ CompletionItemInsertTextRule: MockedMonacoLanguageCompletionItemKind,
104
+ };
105
+ //# sourceMappingURL=MonacoEditorMockUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MonacoEditorMockUtils.js","sourceRoot":"","sources":["../../../src/code-editor/testing/MonacoEditorMockUtils.tsx"],"names":[],"mappings":"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"}
@@ -0,0 +1,17 @@
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 './MonacoEditorMockUtils.js';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/code-editor/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,17 @@
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 './MonacoEditorMockUtils.js';
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/code-editor/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,22 @@
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 AgReactUiProps, type AgGridReactProps } from '@ag-grid-community/react';
18
+ import { type CellMouseOverEvent, type ICellRendererParams } from '@ag-grid-community/core';
19
+ export declare function DataGrid<TData = unknown>(props: AgGridReactProps<TData> | AgReactUiProps<TData>): JSX.Element;
20
+ export declare const configureDataGridComponent: () => void;
21
+ export type { CellMouseOverEvent as DataGridCellMouseOverEvent, ICellRendererParams as DataGridCellRendererParams, };
22
+ //# sourceMappingURL=DataGrid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataGrid.d.ts","sourceRoot":"","sources":["../../src/data-grid/DataGrid.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAEH,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EAEzB,MAAM,yBAAyB,CAAC;AAEjC,wBAAgB,QAAQ,CAAC,KAAK,GAAG,OAAO,EACtC,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,GACrD,GAAG,CAAC,OAAO,CAEb;AAED,eAAO,MAAM,0BAA0B,QAAO,IAE7C,CAAC;AAEF,YAAY,EACV,kBAAkB,IAAI,0BAA0B,EAChD,mBAAmB,IAAI,0BAA0B,GAClD,CAAC"}
@@ -0,0 +1,26 @@
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 { AgGridReact, } from '@ag-grid-community/react';
18
+ import { ClientSideRowModelModule } from '@ag-grid-community/client-side-row-model';
19
+ import { ModuleRegistry, } from '@ag-grid-community/core';
20
+ export function DataGrid(props) {
21
+ return _jsx(AgGridReact, { ...props, modules: [ClientSideRowModelModule] });
22
+ }
23
+ export const configureDataGridComponent = () => {
24
+ ModuleRegistry.registerModules([ClientSideRowModelModule]);
25
+ };
26
+ //# sourceMappingURL=DataGrid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataGrid.js","sourceRoot":"","sources":["../../src/data-grid/DataGrid.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,WAAW,GAGZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACpF,OAAO,EAGL,cAAc,GACf,MAAM,yBAAyB,CAAC;AAEjC,MAAM,UAAU,QAAQ,CACtB,KAAsD;IAEtD,OAAO,KAAC,WAAW,OAAK,KAAK,EAAE,OAAO,EAAE,CAAC,wBAAwB,CAAC,GAAI,CAAC;AACzE,CAAC;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAS,EAAE;IACnD,cAAc,CAAC,eAAe,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC;AAC7D,CAAC,CAAC"}
@@ -0,0 +1,17 @@
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 './DataGrid.js';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data-grid/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,eAAe,CAAC"}
@@ -0,0 +1,17 @@
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 './DataGrid.js';
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-grid/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,eAAe,CAAC"}
package/lib/index.css ADDED
@@ -0,0 +1,17 @@
1
+ /** @license @finos/legend-lego v0.1.0
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
+
17
+ @import"@ag-grid-community/styles/ag-grid.css";@import"@ag-grid-community/styles/ag-theme-balham.css";.code-editor__container{height:100%;width:100%;position:relative;background:var(--color-dark-grey-50)}.code-editor__body{height:100%;width:100%;position:absolute;top:0;left:0;overflow:hidden}.monaco-editor *{font-size:1.4rem}.monaco-editor--small-font *{font-size:1.2rem}/*# sourceMappingURL=index.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sourceRoot":"","sources":["../style/_data-grid.scss","../style/_code-editor.scss","../style/reset/_monaco-editor.scss"],"names":[],"mappings":"AAgBQ,+CACA,+ECCJ,YACA,WACA,kBACA,qCAGF,mBACE,YACA,WACA,kBACA,MACA,OACA,gBCdJ,iBACE,iBAGF,6BACE","file":"index.css"}
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@finos/legend-lego",
3
+ "version": "0.1.0",
4
+ "description": "Legend shared advanced application components and building blocks",
5
+ "keywords": [
6
+ "legend",
7
+ "component",
8
+ "shared-component"
9
+ ],
10
+ "homepage": "https://github.com/finos/legend-studio/tree/master/packages/legend-lego",
11
+ "bugs": {
12
+ "url": "https://github.com/finos/legend-studio/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/finos/legend-studio.git",
17
+ "directory": "packages/legend-lego"
18
+ },
19
+ "license": "Apache-2.0",
20
+ "sideEffects": false,
21
+ "type": "module",
22
+ "exports": {
23
+ "./data-grid": "./lib/data-grid/index.js",
24
+ "./code-editor": "./lib/code-editor/index.js",
25
+ "./code-editor/test": "./lib/code-editor/testing/index.js",
26
+ "./code-editor/test/MockedMonacoEditor.js": "./lib/code-editor/testing/MockedMonacoEditor.js",
27
+ "./lib/index.css": "./lib/index.css"
28
+ },
29
+ "module": "lib/index.js",
30
+ "types": "lib/index.d.ts",
31
+ "scripts": {
32
+ "build": "yarn clean && yarn build:sass && yarn build:ts",
33
+ "build:sass": "cross-env INIT_CWD=$INIT_CWD node ../../scripts/workflow/buildSass.js",
34
+ "build:ts": "tsc --project ./tsconfig.build.json",
35
+ "clean": "npm-run-all clean:cache clean:lib",
36
+ "clean:cache": "rimraf \"build\"",
37
+ "clean:lib": "rimraf \"lib\"",
38
+ "dev": "npm-run-all --parallel dev:sass dev:ts",
39
+ "dev:sass": "sass style:lib --watch --load-path=../../node_modules/@finos/legend-art/scss",
40
+ "dev:ts": "tsc --watch --preserveWatchOutput",
41
+ "lint:js": "cross-env NODE_ENV=production eslint --cache --cache-location ./build/.eslintcache --report-unused-disable-directives --parser-options=project:\"./tsconfig.json\" \"./src/**/*.{js,ts,tsx}\"",
42
+ "publish:prepare": "node ../../scripts/release/preparePublishContent.js",
43
+ "publish:snapshot": "node ../../scripts/release/publishDevSnapshot.js",
44
+ "test": "jest",
45
+ "test:watch": "jest --watch"
46
+ },
47
+ "dependencies": {
48
+ "@ag-grid-community/client-side-row-model": "29.2.0",
49
+ "@ag-grid-community/core": "29.2.0",
50
+ "@ag-grid-community/react": "29.2.0",
51
+ "@ag-grid-community/styles": "29.2.0",
52
+ "@finos/legend-application": "14.0.0",
53
+ "@finos/legend-art": "6.0.0",
54
+ "@finos/legend-shared": "8.1.0",
55
+ "@types/react": "18.0.34",
56
+ "@types/react-dom": "18.0.11",
57
+ "mobx": "6.9.0",
58
+ "mobx-react-lite": "3.4.3",
59
+ "monaco-editor": "0.37.1",
60
+ "react": "18.2.0",
61
+ "react-dom": "18.2.0"
62
+ },
63
+ "devDependencies": {
64
+ "@finos/legend-dev-utils": "2.0.52",
65
+ "@jest/globals": "29.5.0",
66
+ "cross-env": "7.0.3",
67
+ "eslint": "8.38.0",
68
+ "jest": "29.5.0",
69
+ "npm-run-all": "4.1.5",
70
+ "rimraf": "5.0.0",
71
+ "sass": "1.62.0",
72
+ "typescript": "5.0.4"
73
+ },
74
+ "peerDependencies": {
75
+ "react": "^18.0.0"
76
+ },
77
+ "publishConfig": {
78
+ "directory": "build/publishContent"
79
+ }
80
+ }
@@ -0,0 +1,157 @@
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
+
17
+ import { useState, useRef, useEffect } from 'react';
18
+ import { type IDisposable, editor as monacoEditorAPI } from 'monaco-editor';
19
+ import {
20
+ disposeCodeEditor,
21
+ getBaseCodeEditorOptions,
22
+ resetLineNumberGutterWidth,
23
+ getCodeEditorValue,
24
+ normalizeLineEnding,
25
+ } from './CodeEditorUtils.js';
26
+ import { useResizeDetector } from '@finos/legend-art';
27
+ import {
28
+ type CODE_EDITOR_LANGUAGE,
29
+ CODE_EDITOR_THEME,
30
+ TAB_SIZE,
31
+ useApplicationStore,
32
+ } from '@finos/legend-application';
33
+
34
+ export const CodeEditor: React.FC<{
35
+ inputValue: string;
36
+ isReadOnly?: boolean | undefined;
37
+ language: CODE_EDITOR_LANGUAGE;
38
+ showMiniMap?: boolean | undefined;
39
+ hideGutter?: boolean | undefined;
40
+ extraEditorOptions?:
41
+ | (monacoEditorAPI.IEditorOptions & monacoEditorAPI.IGlobalEditorOptions)
42
+ | undefined;
43
+ updateInput?: ((val: string) => void) | undefined;
44
+ }> = (props) => {
45
+ const {
46
+ inputValue,
47
+ updateInput,
48
+ language,
49
+ isReadOnly,
50
+ showMiniMap,
51
+ hideGutter,
52
+ extraEditorOptions,
53
+ } = props;
54
+ const applicationStore = useApplicationStore();
55
+ const [editor, setEditor] = useState<
56
+ monacoEditorAPI.IStandaloneCodeEditor | undefined
57
+ >();
58
+ const onDidChangeModelContentEventDisposer = useRef<IDisposable | undefined>(
59
+ undefined,
60
+ );
61
+
62
+ /**
63
+ * NOTE: we want to normalize line ending here since if the original
64
+ * input value includes CR '\r' character, it will get normalized, calling
65
+ * the updateInput method and cause a rerender. With the way we setup
66
+ * `onChange` method, React will warn about `setState` being called in
67
+ * `render` method.
68
+ * See https://github.com/finos/legend-studio/issues/608
69
+ */
70
+ const value = normalizeLineEnding(inputValue);
71
+ const textInputRef = useRef<HTMLDivElement>(null);
72
+ const { ref, width, height } = useResizeDetector<HTMLDivElement>();
73
+
74
+ useEffect(() => {
75
+ if (width !== undefined && height !== undefined) {
76
+ editor?.layout({ width, height });
77
+ }
78
+ }, [editor, width, height]);
79
+
80
+ useEffect(() => {
81
+ if (!editor && textInputRef.current) {
82
+ const element = textInputRef.current;
83
+ const _editor = monacoEditorAPI.create(element, {
84
+ ...getBaseCodeEditorOptions(),
85
+ theme: applicationStore.layoutService
86
+ .TEMPORARY__isLightColorThemeEnabled
87
+ ? CODE_EDITOR_THEME.TEMPORARY__VSCODE_LIGHT
88
+ : CODE_EDITOR_THEME.LEGEND,
89
+ formatOnType: true,
90
+ formatOnPaste: true,
91
+ });
92
+ setEditor(_editor);
93
+ }
94
+ }, [applicationStore, editor]);
95
+
96
+ useEffect(() => {
97
+ if (editor) {
98
+ resetLineNumberGutterWidth(editor);
99
+ const model = editor.getModel();
100
+ if (model) {
101
+ monacoEditorAPI.setModelLanguage(model, language);
102
+ }
103
+ }
104
+ }, [editor, language]);
105
+
106
+ if (editor) {
107
+ // dispose the old editor content setter in case the `updateInput` handler changes
108
+ // for a more extensive note on this, see `LambdaEditor`
109
+ onDidChangeModelContentEventDisposer.current?.dispose();
110
+ onDidChangeModelContentEventDisposer.current =
111
+ editor.onDidChangeModelContent(() => {
112
+ const currentVal = getCodeEditorValue(editor);
113
+ if (currentVal !== value) {
114
+ updateInput?.(currentVal);
115
+ }
116
+ });
117
+
118
+ // Set the text value and editor options
119
+ const currentValue = getCodeEditorValue(editor);
120
+ if (currentValue !== value) {
121
+ editor.setValue(value);
122
+ }
123
+ editor.updateOptions({
124
+ readOnly: Boolean(isReadOnly),
125
+ minimap: { enabled: Boolean(showMiniMap) },
126
+ // Hide the line number gutter
127
+ // See https://github.com/microsoft/vscode/issues/30795
128
+ ...(hideGutter
129
+ ? {
130
+ glyphMargin: false,
131
+ folding: false,
132
+ lineNumbers: 'off',
133
+ lineDecorationsWidth: 10,
134
+ lineNumbersMinChars: 0,
135
+ }
136
+ : {}),
137
+ ...(extraEditorOptions ?? {}),
138
+ });
139
+ const model = editor.getModel();
140
+ model?.updateOptions({ tabSize: TAB_SIZE });
141
+ }
142
+
143
+ useEffect(
144
+ () => (): void => {
145
+ if (editor) {
146
+ disposeCodeEditor(editor);
147
+ }
148
+ },
149
+ [editor],
150
+ ); // dispose editor
151
+
152
+ return (
153
+ <div ref={ref} className="code-editor__container">
154
+ <div className="code-editor__body" ref={textInputRef} />
155
+ </div>
156
+ );
157
+ };