@itwin/grouping-mapping-widget 0.5.5 → 0.5.6
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/cjs/widget/components/GroupAction.js +1 -1
- package/lib/cjs/widget/components/GroupAction.js.map +1 -1
- package/lib/cjs/widget/components/Grouping.js +4 -6
- package/lib/cjs/widget/components/Grouping.js.map +1 -1
- package/lib/cjs/widget/components/Grouping.scss +7 -0
- package/lib/cjs/widget/components/HorizontalTile.d.ts +13 -0
- package/lib/cjs/widget/components/{GroupTile.js → HorizontalTile.js} +6 -6
- package/lib/cjs/widget/components/HorizontalTile.js.map +1 -0
- package/lib/{esm/widget/components/GroupTile.scss → cjs/widget/components/HorizontalTile.scss} +2 -2
- package/lib/cjs/widget/components/Mapping.js +37 -57
- package/lib/cjs/widget/components/Mapping.js.map +1 -1
- package/lib/cjs/widget/components/Mapping.scss +21 -7
- package/lib/cjs/widget/components/SelectProject.js +28 -20
- package/lib/cjs/widget/components/SelectProject.js.map +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyGrid.js +6 -6
- package/lib/cjs/widget/components/property-grid/PropertyGrid.js.map +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyGrid.scss +12 -12
- package/lib/cjs/widget/components/property-grid/PropertyList.js +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyList.js.map +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyView.js +5 -5
- package/lib/cjs/widget/components/property-grid/PropertyView.js.map +1 -1
- package/lib/cjs/widget/components/property-grid/PropertyView.scss +13 -62
- package/lib/esm/widget/components/GroupAction.js +1 -1
- package/lib/esm/widget/components/GroupAction.js.map +1 -1
- package/lib/esm/widget/components/Grouping.js +4 -6
- package/lib/esm/widget/components/Grouping.js.map +1 -1
- package/lib/esm/widget/components/Grouping.scss +7 -0
- package/lib/esm/widget/components/HorizontalTile.d.ts +13 -0
- package/lib/esm/widget/components/{GroupTile.js → HorizontalTile.js} +4 -4
- package/lib/esm/widget/components/HorizontalTile.js.map +1 -0
- package/lib/{cjs/widget/components/GroupTile.scss → esm/widget/components/HorizontalTile.scss} +2 -2
- package/lib/esm/widget/components/Mapping.js +40 -60
- package/lib/esm/widget/components/Mapping.js.map +1 -1
- package/lib/esm/widget/components/Mapping.scss +21 -7
- package/lib/esm/widget/components/SelectProject.js +30 -22
- package/lib/esm/widget/components/SelectProject.js.map +1 -1
- package/lib/esm/widget/components/property-grid/PropertyGrid.js +6 -6
- package/lib/esm/widget/components/property-grid/PropertyGrid.js.map +1 -1
- package/lib/esm/widget/components/property-grid/PropertyGrid.scss +12 -12
- package/lib/esm/widget/components/property-grid/PropertyList.js +1 -1
- package/lib/esm/widget/components/property-grid/PropertyList.js.map +1 -1
- package/lib/esm/widget/components/property-grid/PropertyView.js +5 -5
- package/lib/esm/widget/components/property-grid/PropertyView.js.map +1 -1
- package/lib/esm/widget/components/property-grid/PropertyView.scss +13 -62
- package/package.json +1 -1
- package/lib/cjs/widget/components/GroupTile.d.ts +0 -13
- package/lib/cjs/widget/components/GroupTile.js.map +0 -1
- package/lib/cjs/widget/components/property-grid/NonPrimitivePropertyRenderer.scss +0 -16
- package/lib/esm/widget/components/GroupTile.d.ts +0 -13
- package/lib/esm/widget/components/GroupTile.js.map +0 -1
- package/lib/esm/widget/components/property-grid/NonPrimitivePropertyRenderer.scss +0 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mapping.js","sourceRoot":"","sources":["../../../../src/widget/components/Mapping.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,wEAA4D;AAC5D,oDAA+D;AAC/D,oEAOoC;AACpC,wDAO8B;AAE9B,+CAAyE;AAEzE,mCAAwE;AACxE,0BAAwB;AACxB,gEAAwC;AACxC,yCAAuC;AACvC,oEAA4C;AAC5C,yEAAsE;AACtE,yEAAkE;AAElE,uDAAoD;AACpD,+CAAyC;AAGzC,iFAAiF;AAIj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,IACV,UAAU,EAAE,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,WAAW,mCAAI,EAAE,EAC9C,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,KAAK,IAAI,EAAE;;wBACnB,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;wBAC3C,MAAM,aAAa,CAAC,aAAa,CAC/B,WAAW,EACX,QAAQ,EACR,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,EAAE,mCAAI,EAAE,CAC1B,CAAC;oBACJ,CAAC,EACD,OAAO,EAAE,OAAO,GAChB;gBACF,8BAAC,mDAAwB,IACvB,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,OAAO,GACjB,CACD,CACJ,CAAC;KACL;AACH,CAAC,CAAC;AAtMW,QAAA,QAAQ,YAsMnB","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 { Presentation } from \"@itwin/presentation-frontend\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport {\n SvgAdd,\n SvgDelete,\n SvgEdit,\n SvgImport,\n SvgMore,\n SvgProcess,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n ButtonGroup,\n DropdownMenu,\n IconButton,\n MenuItem,\n Table,\n} from \"@itwin/itwinui-react\";\nimport type { CellProps } from \"react-table\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { CreateTypeFromInterface } from \"../utils\";\nimport { handleError, onSelectionChanged, WidgetHeader } from \"./utils\";\nimport \"./Mapping.scss\";\nimport DeleteModal from \"./DeleteModal\";\nimport { Groupings } from \"./Grouping\";\nimport MappingAction from \"./MappingAction\";\nimport { MappingImportWizardModal } from \"./MappingImportWizardModal\";\nimport { useMappingClient } from \"./context/MappingClientContext\";\nimport type { Mapping } from \"@itwin/insights-client\";\nimport { BlockingOverlay } from \"./BlockingOverlay\";\nimport { clearAll } from \"./viewerUtils\";\nimport type { IMappingClient } from \"../IMappingClient\";\nimport type { GetAccessTokenFn } from \"./context/GroupingApiConfigContext\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\n\nexport type MappingType = CreateTypeFromInterface<Mapping>;\n\nenum MappingView {\n MAPPINGS = \"mappings\",\n GROUPS = \"groups\",\n ADDING = \"adding\",\n MODIFYING = \"modifying\",\n IMPORT = \"import\",\n}\n\nconst fetchMappings = async (\n setMappings: React.Dispatch<React.SetStateAction<Mapping[]>>,\n iModelId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n getAccessToken: GetAccessTokenFn,\n mappingClient: IMappingClient,\n) => {\n try {\n setIsLoading(true);\n const accessToken = await getAccessToken();\n const mappings = await mappingClient.getMappings(accessToken, iModelId);\n setMappings(mappings);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n};\n\nconst toggleExtraction = async (\n getAccessToken: GetAccessTokenFn,\n mappingClient: IMappingClient,\n iModelId: string,\n mapping: Mapping\n) => {\n try {\n const newState = !mapping?.extractionEnabled;\n const accessToken = await getAccessToken();\n await mappingClient.updateMapping(\n accessToken,\n iModelId,\n mapping?.id ?? \"\",\n { extractionEnabled: newState }\n );\n } catch (error: any) {\n handleError(error.status);\n }\n};\n\nexport const Mappings = () => {\n const { getAccessToken } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const iModelId = useActiveIModelConnection()?.iModelId as string;\n const [showDeleteModal, setShowDeleteModal] = useState<boolean>(false);\n const [showImportModal, setShowImportModal] = useState<boolean>(false);\n const [showBlockingOverlay, setShowBlockingOverlay] = useState<boolean>(false);\n const [mappingView, setMappingView] = useState<MappingView>(\n MappingView.MAPPINGS\n );\n const [selectedMapping, setSelectedMapping] = useState<Mapping | undefined>(undefined);\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [mappings, setMappings] = useState<Mapping[]>([]);\n\n useEffect(() => {\n void fetchMappings(setMappings, iModelId, setIsLoading, getAccessToken, mappingClient);\n }, [getAccessToken, mappingClient, iModelId, setIsLoading]);\n\n useEffect(() => {\n const removeListener =\n Presentation.selection.selectionChange.addListener(onSelectionChanged);\n return () => {\n removeListener();\n };\n }, []);\n\n const refresh = useCallback(async () => {\n clearAll();\n setMappingView(MappingView.MAPPINGS);\n setSelectedMapping(undefined);\n setMappings([]);\n await fetchMappings(setMappings, iModelId, setIsLoading, getAccessToken, mappingClient);\n }, [getAccessToken, mappingClient, iModelId, setMappings]);\n\n const addMapping = async () => {\n setMappingView(MappingView.ADDING);\n };\n\n const mappingsColumns = useMemo(\n () => [\n {\n Header: \"Table\",\n columns: [\n {\n id: \"mappingName\",\n Header: \"Mapping Name\",\n accessor: \"mappingName\",\n Cell: (value: CellProps<{ mappingName: string }>) => (\n <div\n className=\"iui-anchor\"\n onClick={() => {\n setSelectedMapping(value.row.original);\n setMappingView(MappingView.GROUPS);\n }}\n >\n {value.row.original.mappingName}\n </div>\n ),\n },\n {\n id: \"description\",\n Header: \"Description\",\n accessor: \"description\",\n },\n {\n id: \"dropdown\",\n Header: \"\",\n width: 80,\n Cell: (value: CellProps<MappingType>) => {\n return (\n <DropdownMenu\n menuItems={(close: () => void) => [\n <MenuItem\n key={0}\n onClick={() => {\n setSelectedMapping(value.row.original);\n setMappingView(MappingView.MODIFYING);\n }}\n icon={<SvgEdit />}\n >\n Modify\n </MenuItem>,\n\n <MenuItem\n key={1}\n onClick={async () => {\n setSelectedMapping(value.row.original);\n setShowBlockingOverlay(true);\n close();\n await toggleExtraction(getAccessToken, mappingClient, iModelId, value.row.original);\n await refresh();\n setShowBlockingOverlay(false);\n }}\n icon={<SvgProcess />}\n >\n {value.row.original.extractionEnabled ? \"Disable extraction\" : \"Enable extraction\"}\n </MenuItem>,\n\n <MenuItem\n key={2}\n onClick={() => {\n setSelectedMapping(value.row.original);\n setShowDeleteModal(true);\n close();\n }}\n icon={<SvgDelete />}\n >\n Remove\n </MenuItem>,\n ]}\n >\n <IconButton styleType=\"borderless\">\n <SvgMore\n style={{\n width: \"16px\",\n height: \"16px\",\n }}\n />\n </IconButton>\n </DropdownMenu>\n );\n },\n },\n ],\n },\n ],\n [getAccessToken, mappingClient, iModelId, refresh]\n );\n\n switch (mappingView) {\n case MappingView.ADDING:\n return <MappingAction iModelId={iModelId} returnFn={refresh} />;\n case MappingView.MODIFYING:\n return (\n <MappingAction\n iModelId={iModelId}\n mapping={selectedMapping}\n returnFn={refresh}\n />\n );\n case MappingView.GROUPS:\n return (\n <Groupings\n mapping={selectedMapping as Mapping}\n goBack={refresh}\n />\n );\n default:\n return (\n <>\n <BlockingOverlay isVisible={showBlockingOverlay} />\n <WidgetHeader title=\"Mappings\" />\n <div className=\"mappings-container\">\n <div className=\"table-toolbar\">\n <Button\n startIcon={<SvgAdd />}\n onClick={async () => addMapping()}\n styleType=\"high-visibility\"\n >\n New\n </Button>\n <ButtonGroup onClick={() => setShowImportModal(true)}>\n <IconButton title=\"Import Mappings\">\n <SvgImport />\n </IconButton>\n </ButtonGroup>\n </div>\n <Table<MappingType>\n data={mappings}\n density=\"extra-condensed\"\n columns={mappingsColumns}\n emptyTableContent=\"No Mappings available.\"\n isSortable\n isLoading={isLoading}\n />\n </div>\n <DeleteModal\n entityName={selectedMapping?.mappingName ?? \"\"}\n show={showDeleteModal}\n setShow={setShowDeleteModal}\n onDelete={async () => {\n const accessToken = await getAccessToken();\n await mappingClient.deleteMapping(\n accessToken,\n iModelId,\n selectedMapping?.id ?? \"\"\n );\n }}\n refresh={refresh}\n />\n <MappingImportWizardModal\n show={showImportModal}\n setShow={setShowImportModal}\n onFinish={refresh}\n />\n </>\n );\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"Mapping.js","sourceRoot":"","sources":["../../../../src/widget/components/Mapping.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;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,6BAAO,IACN,KAAK,EAAE;4CACL,KAAK,EAAE,MAAM;4CACb,MAAM,EAAE,MAAM;yCACf,GACD,CACS,CACA,GAEjB,CACH,CAAA;qBAAA,CAAC,CACA,CACP,CACO;gBACV,8BAAC,qBAAW,IACV,UAAU,EAAE,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,WAAW,mCAAI,EAAE,EAC9C,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,KAAK,IAAI,EAAE;;wBACnB,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;wBAC3C,MAAM,aAAa,CAAC,aAAa,CAC/B,WAAW,EACX,QAAQ,EACR,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,EAAE,mCAAI,EAAE,CAC1B,CAAC;oBACJ,CAAC,EACD,OAAO,EAAE,OAAO,GAChB;gBACF,8BAAC,mDAAwB,IACvB,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,OAAO,GACjB,CACD,CACJ,CAAC;KACL;AACH,CAAC,CAAC;AA7KW,QAAA,QAAQ,YA6KnB","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 { Presentation } from \"@itwin/presentation-frontend\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport {\n SvgAdd,\n SvgDelete,\n SvgEdit,\n SvgImport,\n SvgMore,\n SvgProcess,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n DropdownMenu,\n IconButton,\n MenuItem,\n Surface,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useState } from \"react\";\nimport type { CreateTypeFromInterface } from \"../utils\";\nimport { EmptyMessage, handleError, LoadingOverlay, onSelectionChanged, WidgetHeader } from \"./utils\";\nimport \"./Mapping.scss\";\nimport DeleteModal from \"./DeleteModal\";\nimport { Groupings } from \"./Grouping\";\nimport MappingAction from \"./MappingAction\";\nimport { MappingImportWizardModal } from \"./MappingImportWizardModal\";\nimport { useMappingClient } from \"./context/MappingClientContext\";\nimport type { Mapping } from \"@itwin/insights-client\";\nimport { BlockingOverlay } from \"./BlockingOverlay\";\nimport { HorizontalTile } from \"./HorizontalTile\";\nimport { clearAll } from \"./viewerUtils\";\nimport type { IMappingClient } from \"../IMappingClient\";\nimport type { GetAccessTokenFn } from \"./context/GroupingApiConfigContext\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\n\nexport type MappingType = CreateTypeFromInterface<Mapping>;\n\nenum MappingView {\n MAPPINGS = \"mappings\",\n GROUPS = \"groups\",\n ADDING = \"adding\",\n MODIFYING = \"modifying\",\n IMPORT = \"import\",\n}\n\nconst fetchMappings = async (\n setMappings: React.Dispatch<React.SetStateAction<Mapping[]>>,\n iModelId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n getAccessToken: GetAccessTokenFn,\n mappingClient: IMappingClient,\n) => {\n try {\n setIsLoading(true);\n const accessToken = await getAccessToken();\n const mappings = await mappingClient.getMappings(accessToken, iModelId);\n setMappings(mappings);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n};\n\nconst toggleExtraction = async (\n getAccessToken: GetAccessTokenFn,\n mappingClient: IMappingClient,\n iModelId: string,\n mapping: Mapping\n) => {\n try {\n const newState = !mapping?.extractionEnabled;\n const accessToken = await getAccessToken();\n await mappingClient.updateMapping(\n accessToken,\n iModelId,\n mapping?.id ?? \"\",\n { extractionEnabled: newState }\n );\n } catch (error: any) {\n handleError(error.status);\n }\n};\n\nexport const Mappings = () => {\n const { getAccessToken } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const iModelId = useActiveIModelConnection()?.iModelId as string;\n const [showDeleteModal, setShowDeleteModal] = useState<boolean>(false);\n const [showImportModal, setShowImportModal] = useState<boolean>(false);\n const [showBlockingOverlay, setShowBlockingOverlay] = useState<boolean>(false);\n const [mappingView, setMappingView] = useState<MappingView>(\n MappingView.MAPPINGS\n );\n const [selectedMapping, setSelectedMapping] = useState<Mapping | undefined>(undefined);\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [mappings, setMappings] = useState<Mapping[]>([]);\n\n useEffect(() => {\n void fetchMappings(setMappings, iModelId, setIsLoading, getAccessToken, mappingClient);\n }, [getAccessToken, mappingClient, iModelId, setIsLoading]);\n\n useEffect(() => {\n const removeListener =\n Presentation.selection.selectionChange.addListener(onSelectionChanged);\n return () => {\n removeListener();\n };\n }, []);\n\n const refresh = useCallback(async () => {\n clearAll();\n setMappingView(MappingView.MAPPINGS);\n setSelectedMapping(undefined);\n setMappings([]);\n await fetchMappings(setMappings, iModelId, setIsLoading, getAccessToken, mappingClient);\n }, [getAccessToken, mappingClient, iModelId, setMappings]);\n\n const addMapping = async () => {\n setMappingView(MappingView.ADDING);\n };\n\n switch (mappingView) {\n case MappingView.ADDING:\n return <MappingAction iModelId={iModelId} returnFn={refresh} />;\n case MappingView.MODIFYING:\n return (\n <MappingAction\n iModelId={iModelId}\n mapping={selectedMapping}\n returnFn={refresh}\n />\n );\n case MappingView.GROUPS:\n return (\n <Groupings\n mapping={selectedMapping as Mapping}\n goBack={refresh}\n />\n );\n default:\n return (\n <>\n <BlockingOverlay isVisible={showBlockingOverlay} />\n <WidgetHeader title=\"Mappings\" />\n <Surface className=\"gmw-mappings-container\">\n <div className=\"table-toolbar\">\n <div className = \"gmw-button-spacing\">\n <Button\n startIcon={<SvgAdd />}\n onClick={async () => addMapping()}\n styleType=\"high-visibility\"\n >\n New\n </Button>\n <IconButton title=\"Import Mappings\"\n onClick={() => setShowImportModal(true)}>\n <SvgImport />\n </IconButton>\n </div>\n </div>\n {isLoading ? (\n <LoadingOverlay />\n ) : mappings.length === 0 ? (\n <EmptyMessage message=\"No Mappings available.\" />\n ) : (\n <div className = \"mappings-list\">\n {mappings\n .sort((a, b) => a.mappingName?.localeCompare(b.mappingName ?? \"\") ?? 1)\n .map((mapping) => (\n <HorizontalTile\n key = {mapping.id}\n title = {mapping.mappingName ? mapping.mappingName: \"Untitled\"}\n subText = {mapping.description ?? \"\"}\n subtextToolTip = {mapping.description ?? \"\"}\n titleTooltip={mapping.mappingName}\n onClickTitle={() => {\n setSelectedMapping(mapping);\n setMappingView(MappingView.GROUPS);\n }}\n actionGroup = {\n <DropdownMenu\n menuItems={(close: () => void) => [\n <MenuItem\n key={0}\n onClick={() => {\n setSelectedMapping(mapping);\n setMappingView(MappingView.MODIFYING);\n }}\n icon={<SvgEdit />}\n >\n Modify\n </MenuItem>,\n <MenuItem\n key={1}\n onClick={async () => {\n setSelectedMapping(mapping);\n setShowBlockingOverlay(true);\n close();\n await toggleExtraction(getAccessToken, mappingClient, iModelId, mapping);\n await refresh();\n setShowBlockingOverlay(false);\n }}\n icon={<SvgProcess />}\n >\n {mapping.extractionEnabled ? \"Disable extraction\" : \"Enable extraction\"}\n </MenuItem>,\n <MenuItem\n key={2}\n onClick={() => {\n setSelectedMapping(mapping);\n setShowDeleteModal(true);\n close();\n }}\n icon={<SvgDelete />}\n >\n Remove\n </MenuItem>,\n ]}\n >\n <IconButton styleType=\"borderless\">\n <SvgMore\n style={{\n width: \"16px\",\n height: \"16px\",\n }}\n />\n </IconButton>\n </DropdownMenu>\n }\n />\n ))}\n </div>\n )}\n </Surface>\n <DeleteModal\n entityName={selectedMapping?.mappingName ?? \"\"}\n show={showDeleteModal}\n setShow={setShowDeleteModal}\n onDelete={async () => {\n const accessToken = await getAccessToken();\n await mappingClient.deleteMapping(\n accessToken,\n iModelId,\n selectedMapping?.id ?? \"\"\n );\n }}\n refresh={refresh}\n />\n <MappingImportWizardModal\n show={showImportModal}\n setShow={setShowImportModal}\n onFinish={refresh}\n />\n </>\n );\n }\n};\n"]}
|
|
@@ -4,23 +4,37 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
@import '~@itwin/itwinui-css/scss/variables';
|
|
6
6
|
|
|
7
|
-
.mappings-container {
|
|
7
|
+
.gmw-mappings-container {
|
|
8
8
|
display: flex;
|
|
9
9
|
flex-direction: column;
|
|
10
|
-
|
|
10
|
+
flex-grow: 1;
|
|
11
|
+
padding: $iui-baseline $iui-m;
|
|
12
|
+
min-height: 0;;
|
|
11
13
|
|
|
12
14
|
.table-toolbar {
|
|
13
15
|
display: flex;
|
|
16
|
+
justify-content: space-between;
|
|
14
17
|
gap: $iui-s;
|
|
18
|
+
border-bottom: 1px solid var(--iui-color-background-4);
|
|
19
|
+
padding-bottom: $iui-baseline;
|
|
20
|
+
flex-wrap: wrap;
|
|
21
|
+
|
|
22
|
+
.gmw-button-spacing {
|
|
23
|
+
display: flex;
|
|
24
|
+
gap: $iui-s;
|
|
25
|
+
}
|
|
15
26
|
}
|
|
16
27
|
|
|
17
28
|
button {
|
|
18
29
|
align-self: flex-start;
|
|
19
30
|
}
|
|
20
|
-
}
|
|
21
31
|
|
|
22
|
-
.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
.mappings-list {
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
overflow-y: overlay;
|
|
36
|
+
gap: 7.5px;
|
|
37
|
+
margin-top: 7.5px;
|
|
38
|
+
}
|
|
26
39
|
}
|
|
40
|
+
|
|
@@ -26,9 +26,9 @@ const react_1 = __importStar(require("react"));
|
|
|
26
26
|
const GroupingApiConfigContext_1 = require("./context/GroupingApiConfigContext");
|
|
27
27
|
require("./SelectProject.scss");
|
|
28
28
|
const tabsWithIcons = [
|
|
29
|
-
react_1.default.createElement(itwinui_react_1.Tab, { key:
|
|
30
|
-
react_1.default.createElement(itwinui_react_1.Tab, { key:
|
|
31
|
-
react_1.default.createElement(itwinui_react_1.Tab, { key:
|
|
29
|
+
react_1.default.createElement(itwinui_react_1.Tab, { key: "favorite", label: "Favorite projects", startIcon: react_1.default.createElement(itwinui_icons_react_1.SvgStarHollow, null) }),
|
|
30
|
+
react_1.default.createElement(itwinui_react_1.Tab, { key: "recents", label: "Recent projects", startIcon: react_1.default.createElement(itwinui_icons_react_1.SvgCalendar, null) }),
|
|
31
|
+
react_1.default.createElement(itwinui_react_1.Tab, { key: "all", label: "My projects", startIcon: react_1.default.createElement(itwinui_icons_react_1.SvgList, null) }),
|
|
32
32
|
];
|
|
33
33
|
const SelectProject = ({ onSelect, onCancel }) => {
|
|
34
34
|
const { getAccessToken, prefix } = GroupingApiConfigContext_1.useGroupingMappingApiConfig();
|
|
@@ -36,7 +36,10 @@ const SelectProject = ({ onSelect, onCancel }) => {
|
|
|
36
36
|
const [searchInput, setSearchInput] = react_1.useState("");
|
|
37
37
|
const [activeSearchInput, setActiveSearchInput] = react_1.useState("");
|
|
38
38
|
const [accessToken, setAccessToken] = react_1.useState();
|
|
39
|
-
const [apiOverrides, setApiOverrides] = react_1.useState({
|
|
39
|
+
const [apiOverrides, setApiOverrides] = react_1.useState({
|
|
40
|
+
serverEnvironmentPrefix: prefix,
|
|
41
|
+
});
|
|
42
|
+
const [searched, setSearched] = react_1.useState(false);
|
|
40
43
|
react_1.useEffect(() => setApiOverrides({ serverEnvironmentPrefix: prefix }), [prefix]);
|
|
41
44
|
react_1.useEffect(() => {
|
|
42
45
|
const fetchAccessToken = async () => {
|
|
@@ -47,29 +50,34 @@ const SelectProject = ({ onSelect, onCancel }) => {
|
|
|
47
50
|
}, [getAccessToken]);
|
|
48
51
|
const startSearch = react_1.useCallback(() => {
|
|
49
52
|
setActiveSearchInput(searchInput);
|
|
53
|
+
setSearched(true);
|
|
50
54
|
}, [searchInput]);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
const clearSearch = react_1.useCallback(() => {
|
|
56
|
+
setSearchInput("");
|
|
57
|
+
setActiveSearchInput("");
|
|
58
|
+
setSearched(false);
|
|
59
|
+
}, []);
|
|
60
|
+
react_1.useEffect(() => {
|
|
61
|
+
if (searchInput.length === 0) {
|
|
62
|
+
setSearched(false);
|
|
63
|
+
clearSearch();
|
|
64
|
+
}
|
|
65
|
+
}, [searchInput, setSearched, clearSearch]);
|
|
66
|
+
return (react_1.default.createElement("div", { className: "select-project-grid-container" },
|
|
67
|
+
react_1.default.createElement(itwinui_react_1.HorizontalTabs, { labels: tabsWithIcons, onTabSelected: setProjectType, activeIndex: projectType, type: "borderless", contentClassName: "grid-holding-tab" },
|
|
68
|
+
react_1.default.createElement(itwinui_react_1.LabeledInput, { displayStyle: "inline", iconDisplayStyle: "inline", className: "search-input", label: "Search", value: searchInput, placeholder: "Search....", onChange: (event) => {
|
|
54
69
|
const { target: { value }, } = event;
|
|
55
70
|
setSearchInput(value);
|
|
56
71
|
}, onKeyDown: (event) => {
|
|
57
72
|
if (event.key === "Enter") {
|
|
58
73
|
startSearch();
|
|
59
74
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
react_1.default.createElement("div", { className: 'project-grid' },
|
|
67
|
-
react_1.default.createElement(imodel_browser_react_1.ProjectGrid, { onThumbnailClick: onSelect, accessToken: accessToken, apiOverrides: apiOverrides, filterOptions: activeSearchInput, requestType: projectType === 0
|
|
68
|
-
? "favorites"
|
|
69
|
-
: projectType === 1
|
|
70
|
-
? "recents"
|
|
71
|
-
: "" })),
|
|
72
|
-
react_1.default.createElement("div", { className: 'select-project-action-panel' },
|
|
75
|
+
}, svgIcon: searched ? (react_1.default.createElement(itwinui_react_1.IconButton, { onClick: clearSearch, styleType: "borderless" },
|
|
76
|
+
react_1.default.createElement(itwinui_icons_react_1.SvgClose, null))) : (react_1.default.createElement(itwinui_react_1.IconButton, { onClick: startSearch, styleType: "borderless" },
|
|
77
|
+
react_1.default.createElement(itwinui_icons_react_1.SvgSearch, null))) })),
|
|
78
|
+
react_1.default.createElement("div", { className: "project-grid" },
|
|
79
|
+
react_1.default.createElement(imodel_browser_react_1.ProjectGrid, { onThumbnailClick: onSelect, accessToken: accessToken, apiOverrides: apiOverrides, filterOptions: activeSearchInput, requestType: projectType === 0 ? "favorites" : projectType === 1 ? "recents" : "" })),
|
|
80
|
+
react_1.default.createElement("div", { className: "select-project-action-panel" },
|
|
73
81
|
react_1.default.createElement(itwinui_react_1.Button, { onClick: onCancel }, "Cancel"))));
|
|
74
82
|
};
|
|
75
83
|
exports.default = SelectProject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectProject.js","sourceRoot":"","sources":["../../../../src/widget/components/SelectProject.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAUA,
|
|
1
|
+
{"version":3,"file":"SelectProject.js","sourceRoot":"","sources":["../../../../src/widget/components/SelectProject.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAUA,sEAA0D;AAC1D,oEAMoC;AACpC,wDAM8B;AAC9B,+CAAgE;AAChE,iFAAiF;AACjF,gCAA8B;AAE9B,MAAM,aAAa,GAAG;IACpB,8BAAC,mBAAG,IACF,GAAG,EAAC,UAAU,EACd,KAAK,EAAC,mBAAmB,EACzB,SAAS,EAAE,8BAAC,mCAAa,OAAG,GAC5B;IACF,8BAAC,mBAAG,IAAC,GAAG,EAAC,SAAS,EAAC,KAAK,EAAC,iBAAiB,EAAC,SAAS,EAAE,8BAAC,iCAAW,OAAG,GAAI;IACzE,8BAAC,mBAAG,IAAC,GAAG,EAAC,KAAK,EAAC,KAAK,EAAC,aAAa,EAAC,SAAS,EAAE,8BAAC,6BAAO,OAAG,GAAI;CAC9D,CAAC;AAKF,MAAM,aAAa,GAAG,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAsB,EAAE,EAAE;IACnE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,sDAA2B,EAAE,CAAC;IACjE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,gBAAQ,CAAS,CAAC,CAAC,CAAC;IAC1D,MAAM,CAAC,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E,iBAAiB,EAChC,WAAW,EACT,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAEtE,CACE;QACN,uCAAK,SAAS,EAAC,6BAA6B;YAC1C,8BAAC,sBAAM,IAAC,OAAO,EAAE,QAAQ,aAAiB,CACtC,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,aAAa,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 type { AccessToken } from \"@itwin/core-bentley\";\nimport type {\n ApiOverrides,\n IModelFull,\n ProjectFull,\n} from \"@itwin/imodel-browser-react\";\nimport { ProjectGrid } from \"@itwin/imodel-browser-react\";\nimport {\n SvgCalendar,\n SvgClose,\n SvgList,\n SvgSearch,\n SvgStarHollow,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n HorizontalTabs,\n IconButton,\n LabeledInput,\n Tab,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useState } from \"react\";\nimport { useGroupingMappingApiConfig } from \"./context/GroupingApiConfigContext\";\nimport \"./SelectProject.scss\";\n\nconst tabsWithIcons = [\n <Tab\n key=\"favorite\"\n label=\"Favorite projects\"\n startIcon={<SvgStarHollow />}\n />,\n <Tab key=\"recents\" label=\"Recent projects\" startIcon={<SvgCalendar />} />,\n <Tab key=\"all\" label=\"My projects\" startIcon={<SvgList />} />,\n];\ninterface SelectProjectProps {\n onSelect: (project: ProjectFull) => void;\n onCancel: () => void;\n}\nconst SelectProject = ({ onSelect, onCancel }: SelectProjectProps) => {\n const { getAccessToken, prefix } = useGroupingMappingApiConfig();\n const [projectType, setProjectType] = useState<number>(0);\n const [searchInput, setSearchInput] = useState<string>(\"\");\n const [activeSearchInput, setActiveSearchInput] = useState<string>(\"\");\n const [accessToken, setAccessToken] = useState<AccessToken>();\n const [apiOverrides, setApiOverrides] = useState<ApiOverrides<IModelFull[]>>({\n serverEnvironmentPrefix: prefix,\n });\n const [searched, setSearched] = useState<boolean>(false);\n\n useEffect(\n () => setApiOverrides({ serverEnvironmentPrefix: prefix }),\n [prefix]\n );\n\n useEffect(() => {\n const fetchAccessToken = async () => {\n const accessToken = await getAccessToken();\n setAccessToken(accessToken);\n };\n void fetchAccessToken();\n }, [getAccessToken]);\n\n const startSearch = useCallback(() => {\n setActiveSearchInput(searchInput);\n setSearched(true);\n }, [searchInput]);\n\n const clearSearch = useCallback(() => {\n setSearchInput(\"\");\n setActiveSearchInput(\"\");\n setSearched(false);\n }, []);\n\n useEffect(() => {\n if (searchInput.length === 0) {\n setSearched(false);\n clearSearch();\n }\n }, [searchInput, setSearched, clearSearch]);\n\n return (\n <div className=\"select-project-grid-container\">\n <HorizontalTabs\n labels={tabsWithIcons}\n onTabSelected={setProjectType}\n activeIndex={projectType}\n type={\"borderless\"}\n contentClassName=\"grid-holding-tab\"\n >\n <LabeledInput\n displayStyle=\"inline\"\n iconDisplayStyle=\"inline\"\n className=\"search-input\"\n label=\"Search\"\n value={searchInput}\n placeholder=\"Search....\"\n onChange={(event) => {\n const {\n target: { value },\n } = event;\n setSearchInput(value);\n }}\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n startSearch();\n }\n }}\n svgIcon={\n searched ? (\n <IconButton onClick={clearSearch} styleType=\"borderless\">\n <SvgClose />\n </IconButton>\n ) : (\n <IconButton onClick={startSearch} styleType=\"borderless\">\n <SvgSearch />\n </IconButton>\n )\n }\n />\n </HorizontalTabs>\n <div className=\"project-grid\">\n <ProjectGrid\n onThumbnailClick={onSelect}\n accessToken={accessToken}\n apiOverrides={apiOverrides}\n filterOptions={activeSearchInput}\n requestType={\n projectType === 0 ? \"favorites\" : projectType === 1 ? \"recents\" : \"\"\n }\n />\n </div>\n <div className=\"select-project-action-panel\">\n <Button onClick={onCancel}>Cancel</Button>\n </div>\n </div>\n );\n};\n\nexport default SelectProject;\n"]}
|
|
@@ -163,13 +163,13 @@ class PropertyGrid extends React.Component {
|
|
|
163
163
|
render() {
|
|
164
164
|
var _a, _b;
|
|
165
165
|
if (this.state.loadStart) {
|
|
166
|
-
return (React.createElement("div", { className: "
|
|
166
|
+
return (React.createElement("div", { className: "gmw-components-property-grid-loader" },
|
|
167
167
|
React.createElement(itwinui_react_1.ProgressRadial, { indeterminate: true })));
|
|
168
168
|
}
|
|
169
|
-
return (React.createElement("div", { className: "table-box-inner" },
|
|
170
|
-
React.createElement(components_react_1.PropertyGridEventsRelatedPropsSupplier, { isPropertySelectionEnabled: (_a = this.props.isPropertySelectionEnabled) !== null && _a !== void 0 ? _a : false, isPropertySelectionOnRightClickEnabled: this.props.isPropertySelectionOnRightClickEnabled, isPropertyEditingEnabled: this.props.isPropertyEditingEnabled, isPropertyHoverEnabled: (_b = this.props.isPropertyHoverEnabled) !== null && _b !== void 0 ? _b : false, onPropertyContextMenu: this.props.onPropertyContextMenu, onPropertyUpdated: this.props.onPropertyUpdated, onPropertySelectionChanged: this.props.onPropertySelectionChanged }, (selectionContext) => (React.createElement("div", { className: classnames_1.default("components-property-grid-wrapper", this.props.className), style: this.props.style },
|
|
171
|
-
React.createElement("div", { className: classnames_1.default("components-property-grid", "components-smallEditor-host") },
|
|
172
|
-
React.createElement("div", { className: "property-categories" }, this.state.categories.map((categorizedRecords) => (React.createElement(NestedCategoryBlock, { ...selectionContext, key: categorizedRecords.category.name, categorizedRecords: categorizedRecords, onCategoryExpansionToggled: this._onCategoryExpansionToggled, orientation: this.state.orientation, propertyValueRendererManager: this.props.propertyValueRendererManager, actionButtonRenderers: this.props.actionButtonRenderers }))))),
|
|
169
|
+
return (React.createElement("div", { className: "gmw-table-box-inner" },
|
|
170
|
+
React.createElement(components_react_1.PropertyGridEventsRelatedPropsSupplier, { isPropertySelectionEnabled: (_a = this.props.isPropertySelectionEnabled) !== null && _a !== void 0 ? _a : false, isPropertySelectionOnRightClickEnabled: this.props.isPropertySelectionOnRightClickEnabled, isPropertyEditingEnabled: this.props.isPropertyEditingEnabled, isPropertyHoverEnabled: (_b = this.props.isPropertyHoverEnabled) !== null && _b !== void 0 ? _b : false, onPropertyContextMenu: this.props.onPropertyContextMenu, onPropertyUpdated: this.props.onPropertyUpdated, onPropertySelectionChanged: this.props.onPropertySelectionChanged }, (selectionContext) => (React.createElement("div", { className: classnames_1.default("gmw-components-property-grid-wrapper", this.props.className), style: this.props.style },
|
|
171
|
+
React.createElement("div", { className: classnames_1.default("gmw-components-property-grid", "components-smallEditor-host") },
|
|
172
|
+
React.createElement("div", { className: "gmw-property-categories" }, this.state.categories.map((categorizedRecords) => (React.createElement(NestedCategoryBlock, { ...selectionContext, key: categorizedRecords.category.name, categorizedRecords: categorizedRecords, onCategoryExpansionToggled: this._onCategoryExpansionToggled, orientation: this.state.orientation, propertyValueRendererManager: this.props.propertyValueRendererManager, actionButtonRenderers: this.props.actionButtonRenderers }))))),
|
|
173
173
|
React.createElement(core_react_1.ResizableContainerObserver, { onResize: this._onResize }))))));
|
|
174
174
|
}
|
|
175
175
|
}
|
|
@@ -193,6 +193,6 @@ const NestedCategoryBlock = (props) => {
|
|
|
193
193
|
const [width, setWidth] = React.useState(1);
|
|
194
194
|
return (React.createElement(components_react_1.PropertyCategoryBlock, { category: props.categorizedRecords.category, onExpansionToggled: props.onCategoryExpansionToggled },
|
|
195
195
|
props.categorizedRecords.records.length ? (React.createElement(ColumnResizingPropertyListPropsSupplier_1.ColumnResizingPropertyListPropsSupplier, { orientation: props.orientation, width: width }, (partialListProps) => (React.createElement(PropertyList_1.PropertyList, { ...partialListProps, orientation: props.orientation, category: props.categorizedRecords.category, properties: props.categorizedRecords.records, selectedPropertyKey: props.selectedPropertyKey, onPropertyClicked: props.onPropertyClicked, onPropertyRightClicked: props.onPropertyRightClicked, onPropertyContextMenu: props.onPropertyContextMenu, propertyValueRendererManager: props.propertyValueRendererManager, editingPropertyKey: props.editingPropertyKey, onEditCommit: props.onEditCommit, onEditCancel: props.onEditCancel, isPropertyHoverEnabled: props.isPropertyHoverEnabled, isPropertySelectionEnabled: props.isPropertySelectionEnabled, isPropertyRightClickSelectionEnabled: props.isPropertyRightClickSelectionEnabled, actionButtonRenderers: props.actionButtonRenderers, setWidth: setWidth, width: width })))) : undefined,
|
|
196
|
-
props.categorizedRecords.children.length ? (React.createElement("div", { className: "property-categories" }, props.categorizedRecords.children.map((categorizedChildRecords) => (React.createElement(NestedCategoryBlock, { ...props, key: categorizedChildRecords.category.name, categorizedRecords: categorizedChildRecords }))))) : undefined));
|
|
196
|
+
props.categorizedRecords.children.length ? (React.createElement("div", { className: "gmw-property-categories" }, props.categorizedRecords.children.map((categorizedChildRecords) => (React.createElement(NestedCategoryBlock, { ...props, key: categorizedChildRecords.category.name, categorizedRecords: categorizedChildRecords }))))) : undefined));
|
|
197
197
|
};
|
|
198
198
|
//# sourceMappingURL=PropertyGrid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyGrid.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PropertyGrid.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,4DAAoC;AACpC,iCAAgC;AAChC,6CAA+B;AAQ/B,8DAIiC;AAEjC,6KAA0K;AAC1K,kDAA4E;AAG5E,iDAA8C;AAC9C,+BAA6B;AAG7B,kFAA+E;AAC/E,wDAAsD;AAwCtD;;GAEG;AACH,MAAa,YAAa,SAAQ,KAAK,CAAC,SAGvC;IAQC,gBAAgB;IAChB,YAAY,KAAwB;QAClC,KAAK,CAAC,KAAK,CAAC,CAAC;QARP,eAAU,GAAG,KAAK,CAAC;QACnB,qBAAgB,GAAG,KAAK,CAAC;QACzB,2BAAsB,GAAG,KAAK,CAAC;QA2D/B,2BAAsB,GAAG,GAAG,EAAE;YACpC,KAAK,IAAI,CAA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AC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAC1C,6BAAK,SAAS,EAAC,qBAAqB,IACjC,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAClE,oBAAC,mBAAmB,OACd,KAAK,EACT,GAAG,EAAE,uBAAuB,CAAC,QAAQ,CAAC,IAAI,EAC1C,kBAAkB,EAAE,uBAAuB,GAC3C,CACH,CAAC,CACE,CACP,CAAC,CAAC,CAAC,SAAS,CACS,CACzB,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 classnames from \"classnames\";\nimport { produce } from \"immer\";\nimport * as React from \"react\";\nimport type { DisposeFunc } from \"@itwin/core-bentley\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type {\n CommonPropertyGridProps,\n PropertyCategory,\n PropertyData,\n} from \"@itwin/components-react\";\nimport {\n PropertyCategoryBlock,\n PropertyGridCommons,\n PropertyGridEventsRelatedPropsSupplier,\n} from \"@itwin/components-react\";\nimport type { ColumnResizeRelatedPropertyListProps } from \"@itwin/components-react/lib/cjs/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier\";\nimport { ColumnResizingPropertyListPropsSupplier } from \"@itwin/components-react/lib/cjs/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier\";\nimport { Orientation, ResizableContainerObserver } from \"@itwin/core-react\";\n\nimport type { PropertyListProps } from \"./PropertyList\";\nimport { PropertyList } from \"./PropertyList\";\nimport \"./PropertyGrid.scss\";\n\nimport type { PresentationPropertyDataProvider } from \"@itwin/presentation-components\";\nimport { GroupQueryBuilderContext } from \"../context/GroupQueryBuilderContext\";\nimport { ProgressRadial } from \"@itwin/itwinui-react\";\n\n/** Properties for [[PropertyGrid]] React component\n * @public\n */\nexport interface PropertyGridProps extends CommonPropertyGridProps {\n /** Property data provider */\n dataProvider: PresentationPropertyDataProvider;\n}\n\n/** Property Category in the [[PropertyGrid]] state\n * @public\n * @deprecated This was part of [[PropertyGrid]] internal state and should've never been public. The component is not using it anymore.\n */\nexport interface PropertyGridCategory {\n propertyCategory: PropertyCategory;\n propertyCount: number;\n properties: PropertyRecord[];\n}\n\ninterface CategorizedPropertyGridRecords {\n category: PropertyCategory;\n records: PropertyRecord[];\n children: CategorizedPropertyGridRecords[];\n}\n\n/** State of [[PropertyGrid]] React component\n * @internal\n */\ninterface PropertyGridState {\n /** List of PropertyGrid categories */\n categories: CategorizedPropertyGridRecords[];\n /** Actual orientation used by the property grid */\n orientation: Orientation;\n /** If property grid currently loading data, the loading start time */\n loadStart?: Date;\n /** Width of PropertyGrid */\n width: number;\n}\n\n/** PropertyGrid React component.\n * @public\n */\nexport class PropertyGrid extends React.Component<\nPropertyGridProps,\nPropertyGridState\n> {\n private _dataChangesListenerDisposeFunc?: DisposeFunc;\n private _isMounted = false;\n private _isInDataRequest = false;\n private _hasPendingDataRequest = false;\n\n static override contextType = GroupQueryBuilderContext;\n\n /** @internal */\n constructor(props: PropertyGridProps) {\n super(props);\n this.state = {\n categories: [],\n orientation: this.getPreferredOrientation(),\n width: 0,\n };\n }\n\n /** @internal */\n public override componentDidMount() {\n this._isMounted = true;\n this._dataChangesListenerDisposeFunc =\n this.props.dataProvider.onDataChanged.addListener(\n this._onPropertyDataChanged\n );\n\n void this.gatherData();\n }\n\n /** @internal */\n public override componentWillUnmount() {\n // istanbul ignore else\n if (this._dataChangesListenerDisposeFunc) {\n this._dataChangesListenerDisposeFunc();\n this._dataChangesListenerDisposeFunc = undefined;\n }\n this._isMounted = false;\n }\n\n public override componentDidUpdate(prevProps: PropertyGridProps) {\n if (this.props.dataProvider !== prevProps.dataProvider) {\n // istanbul ignore else\n if (this._dataChangesListenerDisposeFunc) {\n this._dataChangesListenerDisposeFunc();\n }\n this._dataChangesListenerDisposeFunc =\n this.props.dataProvider.onDataChanged.addListener(\n this._onPropertyDataChanged\n );\n\n void this.gatherData();\n }\n\n if (\n this.props.orientation !== prevProps.orientation ||\n this.props.isOrientationFixed !== prevProps.isOrientationFixed ||\n this.props.horizontalOrientationMinWidth !==\n prevProps.horizontalOrientationMinWidth\n ) {\n this.updateOrientation(this.state.width);\n }\n }\n\n private _onPropertyDataChanged = () => {\n void this.gatherData();\n };\n\n private async gatherData(): Promise<void> {\n if (this._isInDataRequest) {\n this._hasPendingDataRequest = true;\n return;\n }\n\n this.setState((prev) =>\n prev.loadStart ? null : { loadStart: new Date() }\n );\n\n this._isInDataRequest = true;\n let propertyData: PropertyData;\n try {\n propertyData = await this.props.dataProvider.getData();\n } finally {\n this._isInDataRequest = false;\n }\n\n if (!this._isMounted) {\n return;\n }\n\n if (this._hasPendingDataRequest) {\n this._hasPendingDataRequest = false;\n return this.gatherData();\n }\n\n this.setState((prevState) => {\n const buildCategoriesHierarchy = (\n newCategories: PropertyCategory[],\n stateCategories: CategorizedPropertyGridRecords[] | undefined\n ) =>\n newCategories.map((category): CategorizedPropertyGridRecords => {\n const matchingStateCategory = findCategory(\n stateCategories ?? [],\n category.name,\n false\n );\n return {\n category: {\n ...category,\n expand:\n matchingStateCategory?.category?.expand ?? category.expand,\n },\n records: propertyData.records[category.name] ?? [],\n children: buildCategoriesHierarchy(\n category.childCategories ?? [],\n matchingStateCategory?.children\n ),\n };\n });\n return {\n categories: buildCategoriesHierarchy(\n propertyData.categories,\n prevState.categories\n ),\n loadStart: undefined,\n };\n });\n }\n\n private getPreferredOrientation(): Orientation {\n return this.props.orientation !== undefined\n ? this.props.orientation\n : Orientation.Horizontal;\n }\n\n private _onResize = (width: number) => {\n this.updateOrientation(width);\n };\n\n private _onCategoryExpansionToggled = (categoryName: string) => {\n this.setState((state) => {\n return produce(state, (draft) => {\n const records = findCategory(draft.categories, categoryName, true);\n // istanbul ignore else\n if (records) {\n const category = records.category;\n category.expand = !category.expand;\n }\n });\n });\n };\n\n private updateOrientation(width: number): void {\n const { orientation, isOrientationFixed, horizontalOrientationMinWidth } = {\n ...this.props,\n };\n const currentOrientation = PropertyGridCommons.getCurrentOrientation(\n width,\n orientation,\n isOrientationFixed,\n horizontalOrientationMinWidth\n );\n\n if (\n currentOrientation !== this.state.orientation ||\n width !== this.state.width\n ) {\n this.setState({ orientation: currentOrientation, width });\n }\n }\n\n /** @internal */\n public override render() {\n if (this.state.loadStart) {\n return (\n <div className=\"gm-components-property-grid-loader\">\n <ProgressRadial indeterminate />\n </div>\n );\n }\n\n return (\n <div className=\"table-box-inner\">\n <PropertyGridEventsRelatedPropsSupplier\n isPropertySelectionEnabled={\n this.props.isPropertySelectionEnabled ?? false\n }\n isPropertySelectionOnRightClickEnabled={\n this.props.isPropertySelectionOnRightClickEnabled\n }\n isPropertyEditingEnabled={this.props.isPropertyEditingEnabled}\n isPropertyHoverEnabled={this.props.isPropertyHoverEnabled ?? false}\n onPropertyContextMenu={this.props.onPropertyContextMenu}\n onPropertyUpdated={this.props.onPropertyUpdated}\n onPropertySelectionChanged={this.props.onPropertySelectionChanged}\n >\n {(selectionContext) => (\n <div\n className={classnames(\n \"components-property-grid-wrapper\",\n this.props.className\n )}\n style={this.props.style}\n >\n <div\n className={classnames(\n \"components-property-grid\",\n \"components-smallEditor-host\"\n )}\n >\n <div className=\"property-categories\">\n {this.state.categories.map(\n (categorizedRecords: CategorizedPropertyGridRecords) => (\n <NestedCategoryBlock\n {...selectionContext}\n key={categorizedRecords.category.name}\n categorizedRecords={categorizedRecords}\n onCategoryExpansionToggled={\n this._onCategoryExpansionToggled\n }\n orientation={this.state.orientation}\n propertyValueRendererManager={\n this.props.propertyValueRendererManager\n }\n actionButtonRenderers={this.props.actionButtonRenderers}\n />\n )\n )}\n </div>\n </div>\n <ResizableContainerObserver onResize={this._onResize} />\n </div>\n )}\n </PropertyGridEventsRelatedPropsSupplier>\n </div>\n );\n }\n}\n\nfunction findCategory(\n categories: CategorizedPropertyGridRecords[],\n lookupName: string,\n recurseIntoChildren: boolean\n): CategorizedPropertyGridRecords | undefined {\n for (const category of categories) {\n if (category.category.name === lookupName) {\n return category;\n }\n if (recurseIntoChildren) {\n const matchingChild = findCategory(\n category.children,\n lookupName,\n recurseIntoChildren\n );\n if (matchingChild) {\n return matchingChild;\n }\n }\n }\n return undefined;\n}\n\ninterface NestedCategoryBlockProps\n extends Omit<\n PropertyListProps,\n keyof ColumnResizeRelatedPropertyListProps | \"properties\"\n > {\n categorizedRecords: CategorizedPropertyGridRecords;\n onCategoryExpansionToggled: (categoryName: string) => void;\n orientation: Orientation;\n}\nconst NestedCategoryBlock = (props: NestedCategoryBlockProps) => {\n const [width, setWidth] = React.useState(1);\n return (\n <PropertyCategoryBlock\n category={props.categorizedRecords.category}\n onExpansionToggled={props.onCategoryExpansionToggled}\n >\n {props.categorizedRecords.records.length ? (\n <ColumnResizingPropertyListPropsSupplier\n orientation={props.orientation}\n width={width}\n >\n {(partialListProps: ColumnResizeRelatedPropertyListProps) => (\n <PropertyList\n {...partialListProps}\n orientation={props.orientation}\n category={props.categorizedRecords.category}\n properties={props.categorizedRecords.records}\n selectedPropertyKey={props.selectedPropertyKey}\n onPropertyClicked={props.onPropertyClicked}\n onPropertyRightClicked={props.onPropertyRightClicked}\n onPropertyContextMenu={props.onPropertyContextMenu}\n propertyValueRendererManager={props.propertyValueRendererManager}\n editingPropertyKey={props.editingPropertyKey}\n onEditCommit={props.onEditCommit}\n onEditCancel={props.onEditCancel}\n isPropertyHoverEnabled={props.isPropertyHoverEnabled}\n isPropertySelectionEnabled={props.isPropertySelectionEnabled}\n isPropertyRightClickSelectionEnabled={\n props.isPropertyRightClickSelectionEnabled\n }\n actionButtonRenderers={props.actionButtonRenderers}\n setWidth={setWidth}\n width={width}\n />\n )}\n </ColumnResizingPropertyListPropsSupplier>\n ) : undefined}\n {props.categorizedRecords.children.length ? (\n <div className=\"property-categories\">\n {props.categorizedRecords.children.map((categorizedChildRecords) => (\n <NestedCategoryBlock\n {...props}\n key={categorizedChildRecords.category.name}\n categorizedRecords={categorizedChildRecords}\n />\n ))}\n </div>\n ) : undefined}\n </PropertyCategoryBlock>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"PropertyGrid.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PropertyGrid.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,4DAAoC;AACpC,iCAAgC;AAChC,6CAA+B;AAQ/B,8DAIiC;AAEjC,6KAA0K;AAC1K,kDAA4E;AAG5E,iDAA8C;AAC9C,+BAA6B;AAG7B,kFAA+E;AAC/E,wDAAsD;AAwCtD;;GAEG;AACH,MAAa,YAAa,SAAQ,KAAK,CAAC,SAGvC;IAQC,gBAAgB;IAChB,YAAY,KAAwB;QAClC,KAAK,CAAC,KAAK,CAAC,CAAC;QARP,eAAU,GAAG,KAAK,CAAC;QACnB,qBAAgB,GAAG,KAAK,CAAC;QACzB,2BAAsB,GAAG,KAAK,CAAC;QA2D/B,2BAAsB,GAAG,GAAG,EAAE;YACpC,KAAK,IAAI,CAAC,UAAU,EAAE,CAAC;QACzB,CAAC,CAAC;QAqEM,cAAS,GAAG,CAAC,KAAa,EAAE,EAAE;YACpC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC,CAAC;QAEM,gCAA2B,GAAG,CAAC,YAAoB,EAAE,EAAE;YAC7D,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE;gBACtB,OAAO,eAAO,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;oBAC9B,MAAM,OAAO,GAAG,YAAY,CAAC,KAAK,CAAC,UAAU,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;oBACnE,uBAAuB;oBACvB,IAAI,OAAO,EAAE;wBACX,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;wBAClC,QAAQ,CAAC,MAAM,G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AE,KAAK,CAAC,kBAAkB,CAAC,QAAQ,EAC3C,UAAU,EAAE,KAAK,CAAC,kBAAkB,CAAC,OAAO,EAC5C,mBAAmB,EAAE,KAAK,CAAC,mBAAmB,EAC9C,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAC1C,sBAAsB,EAAE,KAAK,CAAC,sBAAsB,EACpD,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,EAClD,4BAA4B,EAAE,KAAK,CAAC,4BAA4B,EAChE,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAC5C,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,sBAAsB,EAAE,KAAK,CAAC,sBAAsB,EACpD,0BAA0B,EAAE,KAAK,CAAC,0BAA0B,EAC5D,oCAAoC,EAClC,KAAK,CAAC,oCAAoC,EAE5C,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,EAClD,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,GACZ,CACH,CACuC,CAC3C,CAAC,CAAC,CAAC,SAAS;QACZ,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAC1C,6BAAK,SAAS,EAAC,yBAAyB,IACrC,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAClE,oBAAC,mBAAmB,OACd,KAAK,EACT,GAAG,EAAE,uBAAuB,CAAC,QAAQ,CAAC,IAAI,EAC1C,kBAAkB,EAAE,uBAAuB,GAC3C,CACH,CAAC,CACE,CACP,CAAC,CAAC,CAAC,SAAS,CACS,CACzB,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 classnames from \"classnames\";\nimport { produce } from \"immer\";\nimport * as React from \"react\";\nimport type { DisposeFunc } from \"@itwin/core-bentley\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport type {\n CommonPropertyGridProps,\n PropertyCategory,\n PropertyData,\n} from \"@itwin/components-react\";\nimport {\n PropertyCategoryBlock,\n PropertyGridCommons,\n PropertyGridEventsRelatedPropsSupplier,\n} from \"@itwin/components-react\";\nimport type { ColumnResizeRelatedPropertyListProps } from \"@itwin/components-react/lib/cjs/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier\";\nimport { ColumnResizingPropertyListPropsSupplier } from \"@itwin/components-react/lib/cjs/components-react/propertygrid/component/ColumnResizingPropertyListPropsSupplier\";\nimport { Orientation, ResizableContainerObserver } from \"@itwin/core-react\";\n\nimport type { PropertyListProps } from \"./PropertyList\";\nimport { PropertyList } from \"./PropertyList\";\nimport \"./PropertyGrid.scss\";\n\nimport type { PresentationPropertyDataProvider } from \"@itwin/presentation-components\";\nimport { GroupQueryBuilderContext } from \"../context/GroupQueryBuilderContext\";\nimport { ProgressRadial } from \"@itwin/itwinui-react\";\n\n/** Properties for [[PropertyGrid]] React component\n * @public\n */\nexport interface PropertyGridProps extends CommonPropertyGridProps {\n /** Property data provider */\n dataProvider: PresentationPropertyDataProvider;\n}\n\n/** Property Category in the [[PropertyGrid]] state\n * @public\n * @deprecated This was part of [[PropertyGrid]] internal state and should've never been public. The component is not using it anymore.\n */\nexport interface PropertyGridCategory {\n propertyCategory: PropertyCategory;\n propertyCount: number;\n properties: PropertyRecord[];\n}\n\ninterface CategorizedPropertyGridRecords {\n category: PropertyCategory;\n records: PropertyRecord[];\n children: CategorizedPropertyGridRecords[];\n}\n\n/** State of [[PropertyGrid]] React component\n * @internal\n */\ninterface PropertyGridState {\n /** List of PropertyGrid categories */\n categories: CategorizedPropertyGridRecords[];\n /** Actual orientation used by the property grid */\n orientation: Orientation;\n /** If property grid currently loading data, the loading start time */\n loadStart?: Date;\n /** Width of PropertyGrid */\n width: number;\n}\n\n/** PropertyGrid React component.\n * @public\n */\nexport class PropertyGrid extends React.Component<\nPropertyGridProps,\nPropertyGridState\n> {\n private _dataChangesListenerDisposeFunc?: DisposeFunc;\n private _isMounted = false;\n private _isInDataRequest = false;\n private _hasPendingDataRequest = false;\n\n static override contextType = GroupQueryBuilderContext;\n\n /** @internal */\n constructor(props: PropertyGridProps) {\n super(props);\n this.state = {\n categories: [],\n orientation: this.getPreferredOrientation(),\n width: 0,\n };\n }\n\n /** @internal */\n public override componentDidMount() {\n this._isMounted = true;\n this._dataChangesListenerDisposeFunc =\n this.props.dataProvider.onDataChanged.addListener(\n this._onPropertyDataChanged\n );\n\n void this.gatherData();\n }\n\n /** @internal */\n public override componentWillUnmount() {\n // istanbul ignore else\n if (this._dataChangesListenerDisposeFunc) {\n this._dataChangesListenerDisposeFunc();\n this._dataChangesListenerDisposeFunc = undefined;\n }\n this._isMounted = false;\n }\n\n public override componentDidUpdate(prevProps: PropertyGridProps) {\n if (this.props.dataProvider !== prevProps.dataProvider) {\n // istanbul ignore else\n if (this._dataChangesListenerDisposeFunc) {\n this._dataChangesListenerDisposeFunc();\n }\n this._dataChangesListenerDisposeFunc =\n this.props.dataProvider.onDataChanged.addListener(\n this._onPropertyDataChanged\n );\n\n void this.gatherData();\n }\n\n if (\n this.props.orientation !== prevProps.orientation ||\n this.props.isOrientationFixed !== prevProps.isOrientationFixed ||\n this.props.horizontalOrientationMinWidth !==\n prevProps.horizontalOrientationMinWidth\n ) {\n this.updateOrientation(this.state.width);\n }\n }\n\n private _onPropertyDataChanged = () => {\n void this.gatherData();\n };\n\n private async gatherData(): Promise<void> {\n if (this._isInDataRequest) {\n this._hasPendingDataRequest = true;\n return;\n }\n\n this.setState((prev) =>\n prev.loadStart ? null : { loadStart: new Date() }\n );\n\n this._isInDataRequest = true;\n let propertyData: PropertyData;\n try {\n propertyData = await this.props.dataProvider.getData();\n } finally {\n this._isInDataRequest = false;\n }\n\n if (!this._isMounted) {\n return;\n }\n\n if (this._hasPendingDataRequest) {\n this._hasPendingDataRequest = false;\n return this.gatherData();\n }\n\n this.setState((prevState) => {\n const buildCategoriesHierarchy = (\n newCategories: PropertyCategory[],\n stateCategories: CategorizedPropertyGridRecords[] | undefined\n ) =>\n newCategories.map((category): CategorizedPropertyGridRecords => {\n const matchingStateCategory = findCategory(\n stateCategories ?? [],\n category.name,\n false\n );\n return {\n category: {\n ...category,\n expand:\n matchingStateCategory?.category?.expand ?? category.expand,\n },\n records: propertyData.records[category.name] ?? [],\n children: buildCategoriesHierarchy(\n category.childCategories ?? [],\n matchingStateCategory?.children\n ),\n };\n });\n return {\n categories: buildCategoriesHierarchy(\n propertyData.categories,\n prevState.categories\n ),\n loadStart: undefined,\n };\n });\n }\n\n private getPreferredOrientation(): Orientation {\n return this.props.orientation !== undefined\n ? this.props.orientation\n : Orientation.Horizontal;\n }\n\n private _onResize = (width: number) => {\n this.updateOrientation(width);\n };\n\n private _onCategoryExpansionToggled = (categoryName: string) => {\n this.setState((state) => {\n return produce(state, (draft) => {\n const records = findCategory(draft.categories, categoryName, true);\n // istanbul ignore else\n if (records) {\n const category = records.category;\n category.expand = !category.expand;\n }\n });\n });\n };\n\n private updateOrientation(width: number): void {\n const { orientation, isOrientationFixed, horizontalOrientationMinWidth } = {\n ...this.props,\n };\n const currentOrientation = PropertyGridCommons.getCurrentOrientation(\n width,\n orientation,\n isOrientationFixed,\n horizontalOrientationMinWidth\n );\n\n if (\n currentOrientation !== this.state.orientation ||\n width !== this.state.width\n ) {\n this.setState({ orientation: currentOrientation, width });\n }\n }\n\n /** @internal */\n public override render() {\n if (this.state.loadStart) {\n return (\n <div className=\"gmw-components-property-grid-loader\">\n <ProgressRadial indeterminate />\n </div>\n );\n }\n\n return (\n <div className=\"gmw-table-box-inner\">\n <PropertyGridEventsRelatedPropsSupplier\n isPropertySelectionEnabled={\n this.props.isPropertySelectionEnabled ?? false\n }\n isPropertySelectionOnRightClickEnabled={\n this.props.isPropertySelectionOnRightClickEnabled\n }\n isPropertyEditingEnabled={this.props.isPropertyEditingEnabled}\n isPropertyHoverEnabled={this.props.isPropertyHoverEnabled ?? false}\n onPropertyContextMenu={this.props.onPropertyContextMenu}\n onPropertyUpdated={this.props.onPropertyUpdated}\n onPropertySelectionChanged={this.props.onPropertySelectionChanged}\n >\n {(selectionContext) => (\n <div\n className={classnames(\n \"gmw-components-property-grid-wrapper\",\n this.props.className\n )}\n style={this.props.style}\n >\n <div\n className={classnames(\n \"gmw-components-property-grid\",\n \"components-smallEditor-host\"\n )}\n >\n <div className= \"gmw-property-categories\">\n {this.state.categories.map(\n (categorizedRecords: CategorizedPropertyGridRecords) => (\n <NestedCategoryBlock\n {...selectionContext}\n key={categorizedRecords.category.name}\n categorizedRecords={categorizedRecords}\n onCategoryExpansionToggled={\n this._onCategoryExpansionToggled\n }\n orientation={this.state.orientation}\n propertyValueRendererManager={\n this.props.propertyValueRendererManager\n }\n actionButtonRenderers={this.props.actionButtonRenderers}\n />\n )\n )}\n </div>\n </div>\n <ResizableContainerObserver onResize={this._onResize} />\n </div>\n )}\n </PropertyGridEventsRelatedPropsSupplier>\n </div>\n );\n }\n}\n\nfunction findCategory(\n categories: CategorizedPropertyGridRecords[],\n lookupName: string,\n recurseIntoChildren: boolean\n): CategorizedPropertyGridRecords | undefined {\n for (const category of categories) {\n if (category.category.name === lookupName) {\n return category;\n }\n if (recurseIntoChildren) {\n const matchingChild = findCategory(\n category.children,\n lookupName,\n recurseIntoChildren\n );\n if (matchingChild) {\n return matchingChild;\n }\n }\n }\n return undefined;\n}\n\ninterface NestedCategoryBlockProps\n extends Omit<\n PropertyListProps,\n keyof ColumnResizeRelatedPropertyListProps | \"properties\"\n > {\n categorizedRecords: CategorizedPropertyGridRecords;\n onCategoryExpansionToggled: (categoryName: string) => void;\n orientation: Orientation;\n}\nconst NestedCategoryBlock = (props: NestedCategoryBlockProps) => {\n const [width, setWidth] = React.useState(1);\n return (\n <PropertyCategoryBlock\n category={props.categorizedRecords.category}\n onExpansionToggled={props.onCategoryExpansionToggled}\n >\n {props.categorizedRecords.records.length ? (\n <ColumnResizingPropertyListPropsSupplier\n orientation={props.orientation}\n width={width}\n >\n {(partialListProps: ColumnResizeRelatedPropertyListProps) => (\n <PropertyList\n {...partialListProps}\n orientation={props.orientation}\n category={props.categorizedRecords.category}\n properties={props.categorizedRecords.records}\n selectedPropertyKey={props.selectedPropertyKey}\n onPropertyClicked={props.onPropertyClicked}\n onPropertyRightClicked={props.onPropertyRightClicked}\n onPropertyContextMenu={props.onPropertyContextMenu}\n propertyValueRendererManager={props.propertyValueRendererManager}\n editingPropertyKey={props.editingPropertyKey}\n onEditCommit={props.onEditCommit}\n onEditCancel={props.onEditCancel}\n isPropertyHoverEnabled={props.isPropertyHoverEnabled}\n isPropertySelectionEnabled={props.isPropertySelectionEnabled}\n isPropertyRightClickSelectionEnabled={\n props.isPropertyRightClickSelectionEnabled\n }\n actionButtonRenderers={props.actionButtonRenderers}\n setWidth={setWidth}\n width={width}\n />\n )}\n </ColumnResizingPropertyListPropsSupplier>\n ) : undefined}\n {props.categorizedRecords.children.length ? (\n <div className=\"gmw-property-categories\">\n {props.categorizedRecords.children.map((categorizedChildRecords) => (\n <NestedCategoryBlock\n {...props}\n key={categorizedChildRecords.category.name}\n categorizedRecords={categorizedChildRecords}\n />\n ))}\n </div>\n ) : undefined}\n </PropertyCategoryBlock>\n );\n};\n"]}
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
@import '~@itwin/core-react/lib/cjs/core-react/expandable/list';
|
|
6
6
|
@import '~@itwin/core-react/lib/cjs/core-react/scrollbar';
|
|
7
7
|
|
|
8
|
-
.
|
|
8
|
+
.gmw-components-property-grid-loader {
|
|
9
9
|
display: flex;
|
|
10
10
|
justify-content: center;
|
|
11
11
|
align-items: center;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
.components-property-grid {
|
|
15
|
-
.property-categories {
|
|
14
|
+
.gmw-components-property-grid {
|
|
15
|
+
.gmw-property-categories {
|
|
16
16
|
@include uicore-expandable-blocks-list;
|
|
17
17
|
|
|
18
18
|
display: grid;
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
color: $buic-foreground-body;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
.components-property-grid-wrapper {
|
|
30
|
+
.gmw-components-property-grid-wrapper {
|
|
31
31
|
width: 100%;
|
|
32
32
|
height: 100%;
|
|
33
33
|
overflow-y: auto;
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
@include uicore-scrollbar();
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
@mixin components-property-list {
|
|
39
|
+
@mixin gmw-components-property-list {
|
|
40
40
|
width: 100%;
|
|
41
41
|
|
|
42
|
-
.components--selected {
|
|
42
|
+
.gmw-components--selected {
|
|
43
43
|
background-color: $buic-row-selection;
|
|
44
44
|
outline: 1px solid $buic-foreground-primary;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
.components--clickable {
|
|
47
|
+
.gmw-components--clickable {
|
|
48
48
|
cursor: pointer;
|
|
49
49
|
|
|
50
50
|
&:hover {
|
|
@@ -52,20 +52,20 @@
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
.components--hoverable:hover {
|
|
55
|
+
.gmw-components--hoverable:hover {
|
|
56
56
|
background-color: $buic-row-hover;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
.components-property-list--horizontal {
|
|
61
|
-
@include components-property-list;
|
|
60
|
+
.gmw-components-property-list--horizontal {
|
|
61
|
+
@include gmw-components-property-list;
|
|
62
62
|
|
|
63
63
|
display: grid;
|
|
64
64
|
grid-row-gap: 0px;
|
|
65
65
|
overflow: hidden;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
.components-property-list--vertical {
|
|
69
|
-
@include components-property-list;
|
|
68
|
+
.gmw-components-property-list--vertical {
|
|
69
|
+
@include gmw-components-property-list;
|
|
70
70
|
// margin-top: -13px;
|
|
71
71
|
}
|
|
@@ -76,7 +76,7 @@ class PropertyList extends React.Component {
|
|
|
76
76
|
}
|
|
77
77
|
/** @internal */
|
|
78
78
|
render() {
|
|
79
|
-
const propertyListClassName = classnames_1.default((this.props.orientation === core_react_1.Orientation.Horizontal) ? "components-property-list--horizontal" : "components-property-list--vertical", this.props.className);
|
|
79
|
+
const propertyListClassName = classnames_1.default((this.props.orientation === core_react_1.Orientation.Horizontal) ? "gmw-components-property-list--horizontal" : "gmw-components-property-list--vertical", this.props.className);
|
|
80
80
|
return (React.createElement("div", { className: propertyListClassName, style: this.props.style, ref: this._listRef }, this.props.properties.map((propertyRecord) => {
|
|
81
81
|
const key = this.props.category ? getPropertyKey(this.props.category, propertyRecord) : propertyRecord.property.name;
|
|
82
82
|
return (React.createElement(PropertyRender_1.PropertyRenderer, { key: key, uniqueKey: key, isHoverable: this.props.isPropertyHoverEnabled, isSelectable: this.props.isPropertySelectionEnabled, isSelected: key === this.props.selectedPropertyKey, propertyRecord: propertyRecord, orientation: this.props.orientation, onClick: propertyRecord.value.valueFormat === appui_abstract_1.PropertyValueFormat.Primitive ? this.props.onPropertyClicked : undefined, onRightClick: propertyRecord.value.valueFormat === appui_abstract_1.PropertyValueFormat.Primitive ? this.props.onPropertyRightClicked : undefined, onContextMenu: this.props.onPropertyContextMenu, columnRatio: this.props.columnRatio, onColumnRatioChanged: this.props.onColumnChanged, propertyValueRendererManager: this.props.propertyValueRendererManager, isEditing: key === this.props.editingPropertyKey, onEditCommit: this._onEditCommit, onEditCancel: this.props.onEditCancel, actionButtonRenderers: this.props.actionButtonRenderers, isResizeHandleHovered: this.props.isResizeHandleHovered, onResizeHandleHoverChanged: this.props.onResizeHandleHoverChanged, isResizeHandleBeingDragged: this.props.isResizeHandleBeingDragged, onResizeHandleDragChanged: this.props.onResizeHandleDragChanged, columnInfo: this.props.columnInfo, width: this.props.width }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyList.js","sourceRoot":"","sources":["../../../../../src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W,EAAE,CAAC;IACrB,CAAC;IAED,gBAAgB;IACA,kBAAkB;QAChC,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAED,gBAAgB;IACA,MAAM;QACpB,MAAM,qBAAqB,GAAG,oBAAU,CACtC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,KAAK,wBAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"PropertyList.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PropertyList.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAE/B,0DAA4D;AAE5D,kDAAgD;AAQhD,qDAAoD;AA2CpD;;;GAGG;AACH,SAAgB,cAAc,CAAC,gBAAkC,EAAE,cAA8B;IAC/F,OAAO,gBAAgB,CAAC,IAAI,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC;AAC9D,CAAC;AAFD,wCAEC;AAED;;GAEG;AACH,MAAa,YAAa,SAAQ,KAAK,CAAC,SAA4B;IAElE,YAAY,KAAwB;QAClC,KAAK,CAAC,KAAK,CAAC,CAAC;QAGP,aAAQ,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAE7C,kBAAa,GAAG,CAAC,IAAyB,EAAE,EAAE;YACpD,uBAAuB;YACvB,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ;gBAChD,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACvD,CAAC,CAAC;IARF,CAAC;IAUO,WAAW;QACjB,IACE,IAAI,CAAC,KAAK,CAAC,WAAW,KAAK,wBAAW,CAAC,UAAU;YACjD,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EACtB;YACA,OAAO;SACR;QACD,MAAM,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*---------------------------------------------------------------------------------------------\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/** @packageDocumentation\n * @module PropertyGrid\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { PropertyRecord} from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { CommonProps, RatioChangeResult } from \"@itwin/core-react\";\nimport { Orientation } from \"@itwin/core-react\";\nimport type {\n ActionButtonRenderer,\n PropertyCategory,\n PropertyUpdatedArgs,\n PropertyValueRendererManager,\n} from \"@itwin/components-react\";\n\nimport { PropertyRenderer } from \"./PropertyRender\";\nimport type { PropertyGridColumnInfo } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/PropertyGridColumns\";\n\n/** Properties of [[PropertyList]] React component\n * @public\n */\nexport interface PropertyListProps extends CommonProps {\n orientation: Orientation;\n category?: PropertyCategory;\n properties: PropertyRecord[];\n selectedPropertyKey?: string;\n onPropertyClicked?: (property: PropertyRecord, key?: string) => void;\n onPropertyRightClicked?: (property: PropertyRecord, key?: string) => void;\n onPropertyContextMenu?: (property: PropertyRecord, e: React.MouseEvent) => void;\n columnRatio?: number;\n /** Callback to column ratio changed event */\n onColumnChanged?: (ratio: number) => void | RatioChangeResult;\n propertyValueRendererManager?: PropertyValueRendererManager;\n editingPropertyKey?: string;\n onEditCommit?: (args: PropertyUpdatedArgs, category: PropertyCategory) => void;\n onEditCancel?: () => void;\n /** Enables/disables property hovering effect */\n isPropertyHoverEnabled?: boolean;\n /** Enables/disables property selection */\n isPropertySelectionEnabled?: boolean;\n /** Enables/disables property right click selection */\n isPropertyRightClickSelectionEnabled?: boolean;\n /** Array of action button renderers */\n actionButtonRenderers?: ActionButtonRenderer[];\n /** Is resize handle hovered */\n isResizeHandleHovered?: boolean;\n /** Callback to hover event change */\n onResizeHandleHoverChanged?: (isHovered: boolean) => void;\n /** Is resize handle being dragged */\n isResizeHandleBeingDragged?: boolean;\n /** Callback to drag event change */\n onResizeHandleDragChanged?: (isDragStarted: boolean) => void;\n /** Information for styling property grid columns */\n columnInfo?: PropertyGridColumnInfo;\n setWidth?: React.Dispatch<React.SetStateAction<number>>;\n width: number;\n}\n\n/**\n * Get unique key for property record\n * @internal\n */\nexport function getPropertyKey(propertyCategory: PropertyCategory, propertyRecord: PropertyRecord) {\n return propertyCategory.name + propertyRecord.property.name;\n}\n\n/** A React component that renders multiple properties within a category as a list.\n * @public\n */\nexport class PropertyList extends React.Component<PropertyListProps> {\n\n constructor(props: PropertyListProps) {\n super(props);\n }\n\n private _listRef = React.createRef<HTMLDivElement>();\n\n private _onEditCommit = (args: PropertyUpdatedArgs) => {\n // istanbul ignore else\n if (this.props.onEditCommit && this.props.category)\n this.props.onEditCommit(args, this.props.category);\n };\n\n private afterRender() {\n if (\n this.props.orientation !== Orientation.Horizontal ||\n !this._listRef.current\n ) {\n return;\n }\n const width = this._listRef.current.getBoundingClientRect().width;\n if (this.props.setWidth && width !== this.props.width) {\n this.props.setWidth(width);\n }\n }\n\n /** @internal */\n public override componentDidMount() {\n this.afterRender();\n }\n\n /** @internal */\n public override componentDidUpdate() {\n this.afterRender();\n }\n\n /** @internal */\n public override render() {\n const propertyListClassName = classnames(\n (this.props.orientation === Orientation.Horizontal) ? \"gmw-components-property-list--horizontal\" : \"gmw-components-property-list--vertical\",\n this.props.className,\n );\n\n return (\n <div className={propertyListClassName} style={this.props.style} ref={this._listRef}>\n {this.props.properties.map((propertyRecord: PropertyRecord) => {\n const key = this.props.category ? getPropertyKey(this.props.category, propertyRecord) : propertyRecord.property.name;\n return (\n <PropertyRenderer\n key={key}\n uniqueKey={key}\n isHoverable={this.props.isPropertyHoverEnabled}\n isSelectable={this.props.isPropertySelectionEnabled}\n isSelected={key === this.props.selectedPropertyKey}\n propertyRecord={propertyRecord}\n orientation={this.props.orientation}\n onClick={propertyRecord.value.valueFormat === PropertyValueFormat.Primitive ? this.props.onPropertyClicked : undefined}\n onRightClick={propertyRecord.value.valueFormat === PropertyValueFormat.Primitive ? this.props.onPropertyRightClicked : undefined}\n onContextMenu={this.props.onPropertyContextMenu}\n columnRatio={this.props.columnRatio}\n onColumnRatioChanged={this.props.onColumnChanged}\n propertyValueRendererManager={this.props.propertyValueRendererManager}\n isEditing={key === this.props.editingPropertyKey}\n onEditCommit={this._onEditCommit}\n onEditCancel={this.props.onEditCancel}\n actionButtonRenderers={this.props.actionButtonRenderers}\n isResizeHandleHovered={this.props.isResizeHandleHovered}\n onResizeHandleHoverChanged={this.props.onResizeHandleHoverChanged}\n isResizeHandleBeingDragged={this.props.isResizeHandleBeingDragged}\n onResizeHandleDragChanged={this.props.onResizeHandleDragChanged}\n columnInfo={this.props.columnInfo}\n width={this.props.width}\n />);\n })}\n </div>\n );\n }\n}\n"]}
|
|
@@ -194,8 +194,8 @@ const PropertyView = (props) => {
|
|
|
194
194
|
};
|
|
195
195
|
const getClassName = (viewProps) => {
|
|
196
196
|
let propertyRecordClassName = viewProps.orientation === core_react_1.Orientation.Horizontal
|
|
197
|
-
? "components-property-record--horizontal"
|
|
198
|
-
: "components-property-record--vertical";
|
|
197
|
+
? "gmw-components-property-record--horizontal"
|
|
198
|
+
: "gmw-components-property-record--vertical";
|
|
199
199
|
if (viewProps.isSelected) {
|
|
200
200
|
propertyRecordClassName += " components--selected";
|
|
201
201
|
}
|
|
@@ -214,15 +214,15 @@ const PropertyView = (props) => {
|
|
|
214
214
|
const columnsStyleProvider = new PropertyGridColumns_1.PropertyGridColumnStyleProvider(props.columnInfo);
|
|
215
215
|
const offset = CommonPropertyRenderer_1.CommonPropertyRenderer.getLabelOffset(props.indentation, props.orientation, props.width, props.columnRatio, (_a = props.columnInfo) === null || _a === void 0 ? void 0 : _a.minLabelWidth);
|
|
216
216
|
return (React.createElement("div", { style: columnsStyleProvider.getStyle(props.orientation, needActionButtons, ratio, needElementSeparator), className: getClassName(props), onClick: _onClick, onContextMenu: _onContextMenu, onMouseEnter: _onMouseEnter, onMouseLeave: _onMouseLeave, role: "presentation" },
|
|
217
|
-
React.createElement("div", { className: "components-property-record-label" },
|
|
217
|
+
React.createElement("div", { className: "gmw-components-property-record-label" },
|
|
218
218
|
props.propertyRecord.value.valueFormat ===
|
|
219
|
-
appui_abstract_1.PropertyValueFormat.Primitive && (React.createElement(itwinui_react_1.Checkbox, { style: { marginLeft: offset }, className: "components-property-selection-checkbox", checked: isPropertySelected, onChange: _onPropertySelectionChanged, disabled: context.isLoading ||
|
|
219
|
+
appui_abstract_1.PropertyValueFormat.Primitive && (React.createElement(itwinui_react_1.Checkbox, { style: { marginLeft: offset }, className: "gmw-components-property-selection-checkbox", checked: isPropertySelected, onChange: _onPropertySelectionChanged, disabled: context.isLoading ||
|
|
220
220
|
context.isRendering ||
|
|
221
221
|
props.propertyRecord.value.value === undefined, isLoading: isCheckboxLoading })),
|
|
222
222
|
props.labelElement),
|
|
223
223
|
needElementSeparator ? (React.createElement(core_react_1.ElementSeparator, { movableArea: props.width, onRatioChanged: props.onColumnRatioChanged, ratio: ratio, orientation: props.orientation, isResizeHandleHovered: props.isResizeHandleHovered, onResizeHandleHoverChanged: props.onResizeHandleHoverChanged, isResizeHandleBeingDragged: props.isResizeHandleBeingDragged, onResizeHandleDragChanged: props.onResizeHandleDragChanged })) : undefined,
|
|
224
224
|
props.propertyRecord.value.valueFormat ===
|
|
225
|
-
appui_abstract_1.PropertyValueFormat.Primitive ? (React.createElement("div", { className: "components-property-record-value" },
|
|
225
|
+
appui_abstract_1.PropertyValueFormat.Primitive ? (React.createElement("div", { className: "gmw-components-property-record-value" },
|
|
226
226
|
React.createElement("span", null, props.valueElementRenderer
|
|
227
227
|
? props.valueElementRenderer()
|
|
228
228
|
: props.valueElement))) : undefined,
|