@itwin/one-click-lca-react 0.1.1
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/LICENSE.md +9 -0
- package/README.md +28 -0
- package/lib/cjs/components/ExportModal.d.ts +10 -0
- package/lib/cjs/components/ExportModal.js +169 -0
- package/lib/cjs/components/ExportModal.js.map +1 -0
- package/lib/cjs/components/ExportModal.scss +85 -0
- package/lib/cjs/components/OneClickLCA.d.ts +5 -0
- package/lib/cjs/components/OneClickLCA.js +13 -0
- package/lib/cjs/components/OneClickLCA.js.map +1 -0
- package/lib/cjs/components/Reports.d.ts +5 -0
- package/lib/cjs/components/Reports.js +105 -0
- package/lib/cjs/components/Reports.js.map +1 -0
- package/lib/cjs/components/Reports.scss +44 -0
- package/lib/cjs/components/utils.d.ts +9 -0
- package/lib/cjs/components/utils.js +16 -0
- package/lib/cjs/components/utils.js.map +1 -0
- package/lib/cjs/components/utils.scss +35 -0
- package/lib/cjs/one-click-lca-widget.d.ts +3 -0
- package/lib/cjs/one-click-lca-widget.js +19 -0
- package/lib/cjs/one-click-lca-widget.js.map +1 -0
- package/lib/cjs/test/ExportModal.test.d.ts +2 -0
- package/lib/cjs/test/ExportModal.test.js +17 -0
- package/lib/cjs/test/ExportModal.test.js.map +1 -0
- package/lib/cjs/test/WidgetHeader.test.d.ts +2 -0
- package/lib/cjs/test/WidgetHeader.test.js +37 -0
- package/lib/cjs/test/WidgetHeader.test.js.map +1 -0
- package/lib/cjs/widgets/OneClickLCAWidget.d.ts +7 -0
- package/lib/cjs/widgets/OneClickLCAWidget.js +32 -0
- package/lib/cjs/widgets/OneClickLCAWidget.js.map +1 -0
- package/lib/esm/components/ExportModal.d.ts +10 -0
- package/lib/esm/components/ExportModal.js +164 -0
- package/lib/esm/components/ExportModal.js.map +1 -0
- package/lib/esm/components/ExportModal.scss +85 -0
- package/lib/esm/components/OneClickLCA.d.ts +5 -0
- package/lib/esm/components/OneClickLCA.js +8 -0
- package/lib/esm/components/OneClickLCA.js.map +1 -0
- package/lib/esm/components/Reports.d.ts +5 -0
- package/lib/esm/components/Reports.js +100 -0
- package/lib/esm/components/Reports.js.map +1 -0
- package/lib/esm/components/Reports.scss +44 -0
- package/lib/esm/components/utils.d.ts +9 -0
- package/lib/esm/components/utils.js +12 -0
- package/lib/esm/components/utils.js.map +1 -0
- package/lib/esm/components/utils.scss +35 -0
- package/lib/esm/one-click-lca-widget.d.ts +3 -0
- package/lib/esm/one-click-lca-widget.js +7 -0
- package/lib/esm/one-click-lca-widget.js.map +1 -0
- package/lib/esm/test/ExportModal.test.d.ts +2 -0
- package/lib/esm/test/ExportModal.test.js +12 -0
- package/lib/esm/test/ExportModal.test.js.map +1 -0
- package/lib/esm/test/WidgetHeader.test.d.ts +2 -0
- package/lib/esm/test/WidgetHeader.test.js +35 -0
- package/lib/esm/test/WidgetHeader.test.js.map +1 -0
- package/lib/esm/widgets/OneClickLCAWidget.d.ts +7 -0
- package/lib/esm/widgets/OneClickLCAWidget.js +25 -0
- package/lib/esm/widgets/OneClickLCAWidget.js.map +1 -0
- package/lib/public/logo/oneClickLCALogo.png +0 -0
- package/package.json +107 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
@import "~@itwin/itwinui-css/scss/variables";
|
|
6
|
+
|
|
7
|
+
.oclca {
|
|
8
|
+
&-scrollable-table {
|
|
9
|
+
overflow-y: scroll;
|
|
10
|
+
max-height: 90%;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&-reports-table {
|
|
14
|
+
:hover {
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&-searchbox-container {
|
|
20
|
+
display: inline-flex;
|
|
21
|
+
justify-content: right;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&-reports-container {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
gap: $iui-baseline;
|
|
28
|
+
margin-bottom: $iui-line-height;
|
|
29
|
+
max-height: 80%;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&-button-center {
|
|
33
|
+
align-self: center;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&-container {
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
padding: $iui-baseline $iui-m;
|
|
40
|
+
box-sizing: border-box;
|
|
41
|
+
height: 100%;
|
|
42
|
+
overflow: auto;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import "./utils.scss";
|
|
3
|
+
export interface WidgetHeaderProps {
|
|
4
|
+
title: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
returnFn?: () => Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const WidgetHeader: ({ title, disabled, returnFn, }: WidgetHeaderProps) => JSX.Element;
|
|
9
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
import { SvgChevronLeft } from "@itwin/itwinui-icons-react";
|
|
7
|
+
import { Text } from "@itwin/itwinui-react";
|
|
8
|
+
import "./utils.scss";
|
|
9
|
+
export const WidgetHeader = ({ title, disabled = false, returnFn, }) => {
|
|
10
|
+
return (_jsxs("div", Object.assign({ className: "oclca-widget-header-container" }, { children: [returnFn && (_jsx("div", Object.assign({ className: disabled ? "oclca-chevron-disabled" : "oclca-chevron", onClick: disabled ? undefined : returnFn, onKeyUp: disabled ? undefined : returnFn }, { children: _jsx(SvgChevronLeft, {}, void 0) }), void 0)), _jsx(Text, Object.assign({ className: "oclca-title", variant: "title" }, { children: title }), void 0)] }), void 0));
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/components/utils.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,cAAc,CAAC;AAStB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAC3B,KAAK,EACL,QAAQ,GAAG,KAAK,EAChB,QAAQ,GACU,EAAE,EAAE;IACtB,OAAO,CACL,6BAAK,SAAS,EAAC,+BAA+B,iBAC3C,QAAQ,IAAI,CACX,4BACE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,eAAe,EAChE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,EACxC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,gBAExC,KAAC,cAAc,aAAG,YACd,CACP,EACD,KAAC,IAAI,kBAAC,SAAS,EAAC,aAAa,EAAC,OAAO,EAAC,OAAO,gBAC1C,KAAK,YACD,aACH,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { SvgChevronLeft } from \"@itwin/itwinui-icons-react\";\nimport { Text } from \"@itwin/itwinui-react\";\nimport \"./utils.scss\";\nimport React from \"react\";\n\nexport interface WidgetHeaderProps {\n title: string;\n disabled?: boolean;\n returnFn?: () => Promise<void>;\n}\n\nexport const WidgetHeader = ({\n title,\n disabled = false,\n returnFn,\n}: WidgetHeaderProps) => {\n return (\n <div className=\"oclca-widget-header-container\">\n {returnFn && (\n <div\n className={disabled ? \"oclca-chevron-disabled\" : \"oclca-chevron\"}\n onClick={disabled ? undefined : returnFn}\n onKeyUp={disabled ? undefined : returnFn}\n >\n <SvgChevronLeft />\n </div>\n )}\n <Text className=\"oclca-title\" variant=\"title\">\n {title}\n </Text>\n </div>\n );\n};\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
@import "~@itwin/itwinui-css/scss/variables";
|
|
6
|
+
@import "~@itwin/itwinui-css/scss/icon/index";
|
|
7
|
+
@import "~@itwin/itwinui-css/scss/button/index";
|
|
8
|
+
|
|
9
|
+
.oclca-widget-header-container {
|
|
10
|
+
display: flex;
|
|
11
|
+
margin-bottom: $iui-baseline * 3;
|
|
12
|
+
.oclca-chevron {
|
|
13
|
+
@include iui-icons-large();
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
align-self: center;
|
|
16
|
+
margin-right: $iui-s;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.oclca-chevron-disabled {
|
|
20
|
+
@include iui-icons-large();
|
|
21
|
+
@include themed {
|
|
22
|
+
fill: t(iui-icons-color-actionable-disabled);
|
|
23
|
+
}
|
|
24
|
+
cursor: not-allowed;
|
|
25
|
+
|
|
26
|
+
align-self: center;
|
|
27
|
+
margin-right: $iui-s;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.oclca-title {
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
white-space: nowrap;
|
|
33
|
+
text-overflow: ellipsis;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** UI Provider for iTwin Viewer Applications */
|
|
6
|
+
export * from "./widgets/OneClickLCAWidget";
|
|
7
|
+
//# sourceMappingURL=one-click-lca-widget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"one-click-lca-widget.js","sourceRoot":"","sources":["../../src/one-click-lca-widget.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,gDAAgD;AAChD,cAAc,6BAA6B,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** UI Provider for iTwin Viewer Applications */\nexport * from \"./widgets/OneClickLCAWidget\";\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "@testing-library/jest-dom";
|
|
3
|
+
import { render, screen } from "@testing-library/react";
|
|
4
|
+
import ExportModal from "../components/ExportModal";
|
|
5
|
+
describe("Testing Export Modal", function () {
|
|
6
|
+
it("signin", function () {
|
|
7
|
+
render(_jsx(ExportModal, { isOpen: true, close: () => { }, reportId: undefined }, void 0));
|
|
8
|
+
expect(screen.getByLabelText("Email")).toBeDefined();
|
|
9
|
+
expect(screen.getByLabelText("Password")).toBeDefined();
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=ExportModal.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExportModal.test.js","sourceRoot":"","sources":["../../../src/test/ExportModal.test.tsx"],"names":[],"mappings":";AAKA,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,WAAW,MAAM,2BAA2B,CAAC;AAEpD,QAAQ,CAAC,sBAAsB,EAAE;IAC/B,EAAE,CAAC,QAAQ,EAAE;QACX,MAAM,CAAC,KAAC,WAAW,IAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,WAAI,CAAC,CAAC;QAC5E,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QACrD,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport React from \"react\";\nimport \"@testing-library/jest-dom\";\nimport { render, screen } from \"@testing-library/react\";\nimport ExportModal from \"../components/ExportModal\";\n\ndescribe(\"Testing Export Modal\", function () {\n it(\"signin\", function () {\n render(<ExportModal isOpen={true} close={() => {}} reportId={undefined} />);\n expect(screen.getByLabelText(\"Email\")).toBeDefined();\n expect(screen.getByLabelText(\"Password\")).toBeDefined();\n });\n});\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import "@testing-library/jest-dom";
|
|
3
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
4
|
+
import { WidgetHeader } from "../components/utils";
|
|
5
|
+
describe("Widget Header Component", function () {
|
|
6
|
+
it("should have hello as title", function () {
|
|
7
|
+
var _a;
|
|
8
|
+
const { container } = render(_jsx(WidgetHeader, { title: "hello" }, void 0));
|
|
9
|
+
expect(screen.getByText("hello")).toBeDefined();
|
|
10
|
+
expect(container.firstChild).toHaveClass("oclca-widget-header-container");
|
|
11
|
+
expect((_a = container.firstChild) === null || _a === void 0 ? void 0 : _a.firstChild).toHaveClass("oclca-title");
|
|
12
|
+
});
|
|
13
|
+
it("with return function", function () {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
const { container } = render(_jsx(WidgetHeader, { title: "hello", returnFn: async () => { } }, void 0));
|
|
16
|
+
expect((_a = container.firstChild) === null || _a === void 0 ? void 0 : _a.firstChild).toHaveClass("oclca-chevron");
|
|
17
|
+
expect((_b = container.firstChild) === null || _b === void 0 ? void 0 : _b.firstChild).not.toHaveClass("oclca-chevron-disabled");
|
|
18
|
+
});
|
|
19
|
+
it("with disabled", function () {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
const { container } = render(_jsx(WidgetHeader, { title: "hello", disabled: true, returnFn: async () => { } }, void 0));
|
|
22
|
+
expect((_a = container.firstChild) === null || _a === void 0 ? void 0 : _a.firstChild).not.toHaveClass("oclca-chevron");
|
|
23
|
+
expect((_b = container.firstChild) === null || _b === void 0 ? void 0 : _b.firstChild).toHaveClass("oclca-chevron-disabled");
|
|
24
|
+
});
|
|
25
|
+
it("with mocked return function", function () {
|
|
26
|
+
const mockReturnFn = jest.fn();
|
|
27
|
+
const { container } = render(_jsx(WidgetHeader, { title: "hello", returnFn: mockReturnFn }, void 0));
|
|
28
|
+
const toTestElement = container.querySelector("SvgChevronLeft");
|
|
29
|
+
if (toTestElement !== null) {
|
|
30
|
+
fireEvent.click(toTestElement);
|
|
31
|
+
}
|
|
32
|
+
expect(mockReturnFn).toHaveBeenCalled;
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=WidgetHeader.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WidgetHeader.test.js","sourceRoot":"","sources":["../../../src/test/WidgetHeader.test.tsx"],"names":[],"mappings":";AAKA,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,QAAQ,CAAC,yBAAyB,EAAE;IAClC,EAAE,CAAC,4BAA4B,EAAE;;QAC/B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,KAAC,YAAY,IAAC,KAAK,EAAC,OAAO,WAAG,CAAC,CAAC;QAC7D,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAChD,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,+BAA+B,CAAC,CAAC;QAC1E,MAAM,CAAC,MAAA,SAAS,CAAC,UAAU,0CAAE,UAAU,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sBAAsB,EAAE;;QACzB,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAC1B,KAAC,YAAY,IAAC,KAAK,EAAC,OAAO,EAAC,QAAQ,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC,WAAI,CACzD,CAAC;QACF,MAAM,CAAC,MAAA,SAAS,CAAC,UAAU,0CAAE,UAAU,CAAC,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;QACtE,MAAM,CAAC,MAAA,SAAS,CAAC,UAAU,0CAAE,UAAU,CAAC,CAAC,GAAG,CAAC,WAAW,CACtD,wBAAwB,CACzB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,eAAe,EAAE;;QAClB,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAC1B,KAAC,YAAY,IAAC,KAAK,EAAC,OAAO,EAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC,WAAI,CACzE,CAAC;QACF,MAAM,CAAC,MAAA,SAAS,CAAC,UAAU,0CAAE,UAAU,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;QAC1E,MAAM,CAAC,MAAA,SAAS,CAAC,UAAU,0CAAE,UAAU,CAAC,CAAC,WAAW,CAClD,wBAAwB,CACzB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE;QAChC,MAAM,YAAY,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAC/B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAC1B,KAAC,YAAY,IAAC,KAAK,EAAC,OAAO,EAAC,QAAQ,EAAE,YAAY,WAAI,CACvD,CAAC;QAEF,MAAM,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;QAChE,IAAI,aAAa,KAAK,IAAI,EAAE;YAC1B,SAAS,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;SAChC;QACD,MAAM,CAAC,YAAY,CAAC,CAAC,gBAAgB,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport React from \"react\";\nimport \"@testing-library/jest-dom\";\nimport { fireEvent, render, screen } from \"@testing-library/react\";\nimport { WidgetHeader } from \"../components/utils\";\n\ndescribe(\"Widget Header Component\", function () {\n it(\"should have hello as title\", function () {\n const { container } = render(<WidgetHeader title=\"hello\" />);\n expect(screen.getByText(\"hello\")).toBeDefined();\n expect(container.firstChild).toHaveClass(\"oclca-widget-header-container\");\n expect(container.firstChild?.firstChild).toHaveClass(\"oclca-title\");\n });\n\n it(\"with return function\", function () {\n const { container } = render(\n <WidgetHeader title=\"hello\" returnFn={async () => {}} />\n );\n expect(container.firstChild?.firstChild).toHaveClass(\"oclca-chevron\");\n expect(container.firstChild?.firstChild).not.toHaveClass(\n \"oclca-chevron-disabled\"\n );\n });\n\n it(\"with disabled\", function () {\n const { container } = render(\n <WidgetHeader title=\"hello\" disabled={true} returnFn={async () => {}} />\n );\n expect(container.firstChild?.firstChild).not.toHaveClass(\"oclca-chevron\");\n expect(container.firstChild?.firstChild).toHaveClass(\n \"oclca-chevron-disabled\"\n );\n });\n\n it(\"with mocked return function\", function () {\n const mockReturnFn = jest.fn();\n const { container } = render(\n <WidgetHeader title=\"hello\" returnFn={mockReturnFn} />\n );\n\n const toTestElement = container.querySelector(\"SvgChevronLeft\");\n if (toTestElement !== null) {\n fireEvent.click(toTestElement);\n }\n expect(mockReturnFn).toHaveBeenCalled;\n });\n});\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AbstractWidgetProps, UiItemsProvider } from "@itwin/appui-abstract";
|
|
2
|
+
import { StagePanelLocation, StagePanelSection } from "@itwin/appui-abstract";
|
|
3
|
+
export declare class OneClickLCAProvider implements UiItemsProvider {
|
|
4
|
+
readonly id = "OneClickLCAProvider";
|
|
5
|
+
provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection): ReadonlyArray<AbstractWidgetProps>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=OneClickLCAWidget.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { StagePanelLocation, StagePanelSection, StageUsage, } from "@itwin/appui-abstract";
|
|
3
|
+
import OneClickLCA from "../components/OneClickLCA";
|
|
4
|
+
export class OneClickLCAProvider {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.id = "OneClickLCAProvider";
|
|
7
|
+
}
|
|
8
|
+
provideWidgets(_stageId, stageUsage, location, section) {
|
|
9
|
+
const widgets = [];
|
|
10
|
+
if (location === StagePanelLocation.Left &&
|
|
11
|
+
section === StagePanelSection.Start &&
|
|
12
|
+
stageUsage === StageUsage.General) {
|
|
13
|
+
const OneClickLCAWidget = {
|
|
14
|
+
id: "OneClickLCAWidget",
|
|
15
|
+
label: "One Click LCA",
|
|
16
|
+
getWidgetContent() {
|
|
17
|
+
return _jsx(OneClickLCA, {}, void 0);
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
widgets.push(OneClickLCAWidget);
|
|
21
|
+
}
|
|
22
|
+
return widgets;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=OneClickLCAWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OneClickLCAWidget.js","sourceRoot":"","sources":["../../../src/widgets/OneClickLCAWidget.tsx"],"names":[],"mappings":";AAQA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,GACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,WAAW,MAAM,2BAA2B,CAAC;AAGpD,MAAM,OAAO,mBAAmB;IAAhC;QACkB,OAAE,GAAG,qBAAqB,CAAC;IA2B7C,CAAC;IAzBQ,cAAc,CACnB,QAAgB,EAChB,UAAkB,EAClB,QAA4B,EAC5B,OAA2B;QAE3B,MAAM,OAAO,GAA0B,EAAE,CAAC;QAC1C,IACE,QAAQ,KAAK,kBAAkB,CAAC,IAAI;YACpC,OAAO,KAAK,iBAAiB,CAAC,KAAK;YACnC,UAAU,KAAK,UAAU,CAAC,OAAO,EACjC;YACA,MAAM,iBAAiB,GAAwB;gBAC7C,EAAE,EAAE,mBAAmB;gBACvB,KAAK,EAAE,eAAe;gBACtB,gBAAgB;oBACd,OAAO,KAAC,WAAW,aAAG,CAAC;gBACzB,CAAC;aACF,CAAC;YAEF,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;SACjC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type {\n AbstractWidgetProps,\n UiItemsProvider,\n} from \"@itwin/appui-abstract\";\nimport {\n StagePanelLocation,\n StagePanelSection,\n StageUsage,\n} from \"@itwin/appui-abstract\";\nimport OneClickLCA from \"../components/OneClickLCA\";\nimport React from \"react\";\n\nexport class OneClickLCAProvider implements UiItemsProvider {\n public readonly id = \"OneClickLCAProvider\";\n\n public provideWidgets(\n _stageId: string,\n stageUsage: string,\n location: StagePanelLocation,\n section?: StagePanelSection\n ): ReadonlyArray<AbstractWidgetProps> {\n const widgets: AbstractWidgetProps[] = [];\n if (\n location === StagePanelLocation.Left &&\n section === StagePanelSection.Start &&\n stageUsage === StageUsage.General\n ) {\n const OneClickLCAWidget: AbstractWidgetProps = {\n id: \"OneClickLCAWidget\",\n label: \"One Click LCA\",\n getWidgetContent() {\n return <OneClickLCA />;\n },\n };\n\n widgets.push(OneClickLCAWidget);\n }\n\n return widgets;\n }\n}\n"]}
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@itwin/one-click-lca-react",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "An iTwin.js 3D Viewer Widget that interfaces with the iTwin Carbon Calculation.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Bentley",
|
|
7
|
+
"BIM",
|
|
8
|
+
"iModel",
|
|
9
|
+
"iTwin.js",
|
|
10
|
+
"Carbon Calculation"
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/itwin/viewer-components-react/tree/master/packages/itwin/one-click-lca-widget"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": {
|
|
18
|
+
"name": "Bentley Systems, Inc.",
|
|
19
|
+
"url": "http://www.bentley.com"
|
|
20
|
+
},
|
|
21
|
+
"main": "lib/cjs/one-click-lca-widget.js",
|
|
22
|
+
"module": "lib/esm/one-click-lca-widget.js",
|
|
23
|
+
"typings": "lib/cjs/one-click-lca-widget",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@itwin/insights-client": "^0.1.0",
|
|
26
|
+
"@itwin/itwinui-icons-react": "^1.5.1",
|
|
27
|
+
"@itwin/itwinui-react": "^1.29.2"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@itwin/appui-abstract": "^3.0.0",
|
|
31
|
+
"@itwin/appui-react": "^3.0.0",
|
|
32
|
+
"@itwin/build-tools": "^3.0.0",
|
|
33
|
+
"@itwin/certa": "^3.0.0",
|
|
34
|
+
"@itwin/core-common": "^3.0.0",
|
|
35
|
+
"@itwin/core-frontend": "^3.0.0",
|
|
36
|
+
"@itwin/core-react": "^3.0.0",
|
|
37
|
+
"@itwin/eslint-plugin": "^3.0.0",
|
|
38
|
+
"@testing-library/dom": "^8.12.0",
|
|
39
|
+
"@testing-library/jest-dom": "^5.16.3",
|
|
40
|
+
"@testing-library/react": "^12.1.4",
|
|
41
|
+
"@types/i18next": "^8.4.2",
|
|
42
|
+
"@types/jest": "^27.4.1",
|
|
43
|
+
"@types/node": "^14.18.9",
|
|
44
|
+
"@types/react": "^17.0.38",
|
|
45
|
+
"@types/react-dom": "^17.0.11",
|
|
46
|
+
"@types/react-table": "^7.7.0",
|
|
47
|
+
"@types/testing-library__jest-dom": "^5.14.3",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
|
49
|
+
"@typescript-eslint/parser": "^5.17.0",
|
|
50
|
+
"cpx2": "^3.0.0",
|
|
51
|
+
"eslint": "^7.32.0",
|
|
52
|
+
"eslint-plugin-node": "^11.1.0",
|
|
53
|
+
"eslint-plugin-react": "^7.25.1",
|
|
54
|
+
"eslint-plugin-react-hooks": "^4.2.0",
|
|
55
|
+
"jest": "^27.5.1",
|
|
56
|
+
"jest-cli": "^27.5.1",
|
|
57
|
+
"nyc": "^15.1.0",
|
|
58
|
+
"react": "^17.0.2",
|
|
59
|
+
"react-dom": "^17.0.2",
|
|
60
|
+
"rimraf": "^3.0.2",
|
|
61
|
+
"ts-jest": "^27.1.3",
|
|
62
|
+
"typescript": "~4.3.0"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"@itwin/appui-abstract": "^3.0.0",
|
|
66
|
+
"@itwin/appui-react": "^3.0.0",
|
|
67
|
+
"@itwin/core-frontend": "^3.0.0",
|
|
68
|
+
"@itwin/core-react": "^3.0.0",
|
|
69
|
+
"react": "^17.0.2",
|
|
70
|
+
"react-dom": "^17.0.2"
|
|
71
|
+
},
|
|
72
|
+
"nyc": {
|
|
73
|
+
"nycrc-path": "./node_modules/@itwin/build-tools/.nycrc",
|
|
74
|
+
"check-coverage": true,
|
|
75
|
+
"statements": 20,
|
|
76
|
+
"branches": 20,
|
|
77
|
+
"functions": 20,
|
|
78
|
+
"lines": 20
|
|
79
|
+
},
|
|
80
|
+
"eslintConfig": {
|
|
81
|
+
"plugins": [
|
|
82
|
+
"@itwin"
|
|
83
|
+
],
|
|
84
|
+
"extends": "plugin:@itwin/ui",
|
|
85
|
+
"rules": {
|
|
86
|
+
"no-duplicate-imports": "off",
|
|
87
|
+
"@typescript-eslint/consistent-type-imports": "error"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"scripts": {
|
|
91
|
+
"build": "npm run -s dual-build && npm run -s copy:assets",
|
|
92
|
+
"build:cjs": "tsc 1>&2 --outDir lib/cjs",
|
|
93
|
+
"build:esm": "tsc 1>&2 --module ES2020 --outDir lib/esm",
|
|
94
|
+
"clean": "rimraf lib",
|
|
95
|
+
"copy:assets": "npm run -s copy:public && npm run -s copy:cjs && npm run -s copy:esm",
|
|
96
|
+
"copy:cjs": "cpx \"./src/**/*.scss\" ./lib/cjs",
|
|
97
|
+
"copy:esm": "cpx \"./src/**/*.scss\" ./lib/esm",
|
|
98
|
+
"copy:public": "cpx \"./public/**/*\" ./lib/public",
|
|
99
|
+
"dual-build": "npm run -s build:cjs && npm run -s build:esm",
|
|
100
|
+
"lint": "eslint -f visualstudio \"./src/**/*.{ts,tsx}\" 1>&2",
|
|
101
|
+
"lint:fix": "npm run lint -- --fix",
|
|
102
|
+
"rebuild": "npm run clean && npm run build",
|
|
103
|
+
"test": "jest",
|
|
104
|
+
"cover": "nyc npm test"
|
|
105
|
+
},
|
|
106
|
+
"readme": "# @itwin/one-click-lca-react\n\nCopyright © Bentley Systems, Incorporated. All rights reserved.\n\nThe One Click CLA widget is a UI component for iTwin Viewer applications that simplifies how users (and developers) interface with the [Carbon Calculation One Click LCA APIs](https://developer.bentley.com/apis/carbon-calculation/overview/).\nThe one-click-lca-react package provides a UiProvider class, `OneClickLCAProvider`, which can be passed into the `uiProviders` prop of the iTwin Viewer's `<Viewer />` component.\n\n## Getting Started\n\nThis is not a standalone UI and requires a parent iTwin Viewer application to work as intended.\nA guide on how to create a basic iTwin Viewer application can be found [here](https://www.itwinjs.org/learning/tutorials/develop-web-viewer).\nThis package provides a viewer _widget_. Documentation on how to add a widget to your application can be found [here](https://developer.bentley.com/tutorials/itwin-viewer-hello-world/#2-your-first-ui-widget).\n\n## Permissions and Scopes\n\nThe SPA client used by your iTwin viewer application must have allowed scopes `insights:read` and `insights:write`, found under the Reporting & Insights category.\nUsers must have the `imodels_read` and `insights_view` [permissions](https://developer.bentley.com/apis/carbon-calculation/operations/create-oneclicklca-job/#authorization) assigned at either the Project or iModel level. Additional instruction on how to create roles and assign permissions can be found in the [iTwin Platform Projects API documentation](https://developer.bentley.com/apis/projects/tutorials/).\n\n## Sample usage\n\n```tsx\nimport { OneClickLCAProvider } from \"@itwin/one-click-lca-widget\";\n\n<Viewer\n ...\n uiProviders={[new OneClickLCAProvider()]}\n/>\n```\n"
|
|
107
|
+
}
|