@itwin/grouping-mapping-widget 0.2.0 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +7 -2
  2. package/lib/cjs/widget/GroupingMappingWidget.d.ts +2 -2
  3. package/lib/cjs/widget/GroupingMappingWidget.js +4 -3
  4. package/lib/cjs/widget/GroupingMappingWidget.js.map +1 -1
  5. package/lib/cjs/widget/components/ActionPanel.js +5 -3
  6. package/lib/cjs/widget/components/ActionPanel.js.map +1 -1
  7. package/lib/cjs/widget/components/CalculatedPropertyAction.js +8 -2
  8. package/lib/cjs/widget/components/CalculatedPropertyAction.js.map +1 -1
  9. package/lib/cjs/widget/components/CalculatedPropertyTable.js +3 -2
  10. package/lib/cjs/widget/components/CalculatedPropertyTable.js.map +1 -1
  11. package/lib/cjs/widget/components/ConfirmMappingsImport.js +30 -12
  12. package/lib/cjs/widget/components/ConfirmMappingsImport.js.map +1 -1
  13. package/lib/cjs/widget/components/ConfirmMappingsImport.scss +0 -7
  14. package/lib/cjs/widget/components/CustomCalculationAction.js +3 -1
  15. package/lib/cjs/widget/components/CustomCalculationAction.js.map +1 -1
  16. package/lib/cjs/widget/components/CustomCalculationTable.js +4 -3
  17. package/lib/cjs/widget/components/CustomCalculationTable.js.map +1 -1
  18. package/lib/cjs/widget/components/DeleteModal.js +7 -6
  19. package/lib/cjs/widget/components/DeleteModal.js.map +1 -1
  20. package/lib/cjs/widget/components/DeleteModal.scss +6 -0
  21. package/lib/cjs/widget/components/GroupAction.js +98 -28
  22. package/lib/cjs/widget/components/GroupAction.js.map +1 -1
  23. package/lib/cjs/widget/components/GroupAction.scss +23 -0
  24. package/lib/cjs/widget/components/GroupPropertyAction.js +68 -34
  25. package/lib/cjs/widget/components/GroupPropertyAction.js.map +1 -1
  26. package/lib/cjs/widget/components/GroupPropertyTable.js +3 -2
  27. package/lib/cjs/widget/components/GroupPropertyTable.js.map +1 -1
  28. package/lib/cjs/widget/components/GroupQueryBuilderContext.d.ts +2 -0
  29. package/lib/cjs/widget/components/GroupQueryBuilderContext.js +2 -0
  30. package/lib/cjs/widget/components/GroupQueryBuilderContext.js.map +1 -1
  31. package/lib/cjs/widget/components/Grouping.js +69 -12
  32. package/lib/cjs/widget/components/Grouping.js.map +1 -1
  33. package/lib/cjs/widget/components/Mapping.js +2 -1
  34. package/lib/cjs/widget/components/Mapping.js.map +1 -1
  35. package/lib/cjs/widget/components/MappingAction.js +2 -1
  36. package/lib/cjs/widget/components/MappingAction.js.map +1 -1
  37. package/lib/cjs/widget/components/MappingImportWizardModal.js +1 -1
  38. package/lib/cjs/widget/components/MappingImportWizardModal.js.map +1 -1
  39. package/lib/cjs/widget/components/MappingImportWizardModal.scss +1 -1
  40. package/lib/cjs/widget/components/PropertyMenu.js +22 -12
  41. package/lib/cjs/widget/components/PropertyMenu.js.map +1 -1
  42. package/lib/cjs/widget/components/PropertyMenu.scss +3 -0
  43. package/lib/cjs/widget/components/QueryBuilder.d.ts +1 -1
  44. package/lib/cjs/widget/components/QueryBuilder.js +11 -5
  45. package/lib/cjs/widget/components/QueryBuilder.js.map +1 -1
  46. package/lib/cjs/widget/components/SelectMappings.js +3 -1
  47. package/lib/cjs/widget/components/SelectMappings.js.map +1 -1
  48. package/lib/cjs/widget/components/SelectProject.scss +1 -1
  49. package/lib/cjs/widget/components/property-grid/PrimitivePropertyRenderer.js +7 -3
  50. package/lib/cjs/widget/components/property-grid/PrimitivePropertyRenderer.js.map +1 -1
  51. package/lib/cjs/widget/components/property-grid/PropertyGrid.scss +3 -3
  52. package/lib/cjs/widget/components/property-grid/PropertyRender.d.ts +1 -1
  53. package/lib/cjs/widget/components/property-grid/PropertyRender.js +5 -8
  54. package/lib/cjs/widget/components/property-grid/PropertyRender.js.map +1 -1
  55. package/lib/cjs/widget/components/property-grid/PropertyView.d.ts +2 -0
  56. package/lib/cjs/widget/components/property-grid/PropertyView.js +14 -11
  57. package/lib/cjs/widget/components/property-grid/PropertyView.js.map +1 -1
  58. package/lib/cjs/widget/components/property-grid/PropertyView.scss +19 -4
  59. package/lib/cjs/widget/components/utils.d.ts +2 -0
  60. package/lib/cjs/widget/components/utils.js +45 -4
  61. package/lib/cjs/widget/components/utils.js.map +1 -1
  62. package/lib/cjs/widget/components/utils.scss +5 -0
  63. package/lib/cjs/widget/components/viewerUtils.js +1 -1
  64. package/lib/cjs/widget/components/viewerUtils.js.map +1 -1
  65. package/lib/esm/widget/GroupingMappingWidget.d.ts +2 -2
  66. package/lib/esm/widget/GroupingMappingWidget.js +5 -4
  67. package/lib/esm/widget/GroupingMappingWidget.js.map +1 -1
  68. package/lib/esm/widget/components/ActionPanel.js +6 -4
  69. package/lib/esm/widget/components/ActionPanel.js.map +1 -1
  70. package/lib/esm/widget/components/CalculatedPropertyAction.js +9 -3
  71. package/lib/esm/widget/components/CalculatedPropertyAction.js.map +1 -1
  72. package/lib/esm/widget/components/CalculatedPropertyTable.js +3 -2
  73. package/lib/esm/widget/components/CalculatedPropertyTable.js.map +1 -1
  74. package/lib/esm/widget/components/ConfirmMappingsImport.js +30 -12
  75. package/lib/esm/widget/components/ConfirmMappingsImport.js.map +1 -1
  76. package/lib/esm/widget/components/ConfirmMappingsImport.scss +0 -7
  77. package/lib/esm/widget/components/CustomCalculationAction.js +4 -2
  78. package/lib/esm/widget/components/CustomCalculationAction.js.map +1 -1
  79. package/lib/esm/widget/components/CustomCalculationTable.js +4 -3
  80. package/lib/esm/widget/components/CustomCalculationTable.js.map +1 -1
  81. package/lib/esm/widget/components/DeleteModal.js +8 -7
  82. package/lib/esm/widget/components/DeleteModal.js.map +1 -1
  83. package/lib/esm/widget/components/DeleteModal.scss +6 -0
  84. package/lib/esm/widget/components/GroupAction.js +100 -30
  85. package/lib/esm/widget/components/GroupAction.js.map +1 -1
  86. package/lib/esm/widget/components/GroupAction.scss +23 -0
  87. package/lib/esm/widget/components/GroupPropertyAction.js +69 -35
  88. package/lib/esm/widget/components/GroupPropertyAction.js.map +1 -1
  89. package/lib/esm/widget/components/GroupPropertyTable.js +3 -2
  90. package/lib/esm/widget/components/GroupPropertyTable.js.map +1 -1
  91. package/lib/esm/widget/components/GroupQueryBuilderContext.d.ts +2 -0
  92. package/lib/esm/widget/components/GroupQueryBuilderContext.js +2 -0
  93. package/lib/esm/widget/components/GroupQueryBuilderContext.js.map +1 -1
  94. package/lib/esm/widget/components/Grouping.js +71 -14
  95. package/lib/esm/widget/components/Grouping.js.map +1 -1
  96. package/lib/esm/widget/components/Mapping.js +3 -2
  97. package/lib/esm/widget/components/Mapping.js.map +1 -1
  98. package/lib/esm/widget/components/MappingAction.js +3 -2
  99. package/lib/esm/widget/components/MappingAction.js.map +1 -1
  100. package/lib/esm/widget/components/MappingImportWizardModal.js +1 -1
  101. package/lib/esm/widget/components/MappingImportWizardModal.js.map +1 -1
  102. package/lib/esm/widget/components/MappingImportWizardModal.scss +1 -1
  103. package/lib/esm/widget/components/PropertyMenu.js +23 -13
  104. package/lib/esm/widget/components/PropertyMenu.js.map +1 -1
  105. package/lib/esm/widget/components/PropertyMenu.scss +3 -0
  106. package/lib/esm/widget/components/QueryBuilder.d.ts +1 -1
  107. package/lib/esm/widget/components/QueryBuilder.js +11 -5
  108. package/lib/esm/widget/components/QueryBuilder.js.map +1 -1
  109. package/lib/esm/widget/components/SelectMappings.js +3 -1
  110. package/lib/esm/widget/components/SelectMappings.js.map +1 -1
  111. package/lib/esm/widget/components/SelectProject.scss +1 -1
  112. package/lib/esm/widget/components/property-grid/PrimitivePropertyRenderer.js +7 -3
  113. package/lib/esm/widget/components/property-grid/PrimitivePropertyRenderer.js.map +1 -1
  114. package/lib/esm/widget/components/property-grid/PropertyGrid.scss +3 -3
  115. package/lib/esm/widget/components/property-grid/PropertyRender.d.ts +1 -1
  116. package/lib/esm/widget/components/property-grid/PropertyRender.js +5 -8
  117. package/lib/esm/widget/components/property-grid/PropertyRender.js.map +1 -1
  118. package/lib/esm/widget/components/property-grid/PropertyView.d.ts +2 -0
  119. package/lib/esm/widget/components/property-grid/PropertyView.js +14 -11
  120. package/lib/esm/widget/components/property-grid/PropertyView.js.map +1 -1
  121. package/lib/esm/widget/components/property-grid/PropertyView.scss +19 -4
  122. package/lib/esm/widget/components/utils.d.ts +2 -0
  123. package/lib/esm/widget/components/utils.js +43 -4
  124. package/lib/esm/widget/components/utils.js.map +1 -1
  125. package/lib/esm/widget/components/utils.scss +5 -0
  126. package/lib/esm/widget/components/viewerUtils.js +1 -1
  127. package/lib/esm/widget/components/viewerUtils.js.map +1 -1
  128. package/package.json +4 -4
  129. package/lib/cjs/widget/icons/DatabaseInfo.d.ts +0 -5
  130. package/lib/cjs/widget/icons/DatabaseInfo.js +0 -19
  131. package/lib/cjs/widget/icons/DatabaseInfo.js.map +0 -1
  132. package/lib/cjs/widget/icons/DatabaseInfo.scss +0 -12
  133. package/lib/esm/widget/icons/DatabaseInfo.d.ts +0 -5
  134. package/lib/esm/widget/icons/DatabaseInfo.js +0 -14
  135. package/lib/esm/widget/icons/DatabaseInfo.js.map +0 -1
  136. package/lib/esm/widget/icons/DatabaseInfo.scss +0 -12
@@ -1 +1 @@
1
- {"version":3,"file":"SelectMappings.js","sourceRoot":"","sources":["../../../../src/widget/components/SelectMappings.tsx"],"names":[],"mappings":"AAMA,OAAO,EACL,MAAM,EACN,KAAK,EACL,YAAY,EACZ,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,sBAAsB,CAAC;AAE9B,MAAM,aAAa,GAAG,KAAK,EACzB,WAAwE,EACxE,QAAgB,EAChB,YAA2D,EAC3D,EAAE;IACF,IAAI;QACF,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,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BAClC;aACF;SACF;KACF,EACD,EAAE,CACH,CAAC;IAEF,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,WAAW,CAC3B,CAAC,KAAkC,EAAE,EAAE,CAAC,CACtC,oBAAC,cAAc,OAAK,KAAK,EAAE,YAAY,EAAE,YAAY,GAAI,CAC1D,EACD,CAAC,YAAY,CAAC,CACf,CAAC;IAEF,OAAO,CACL,6BAAK,SAAS,EAAC,0BAA0B;QACvC,oBAAC,KAAK,IACJ,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,eAAe,EACxB,SAAS,EAAC,sBAAsB,EAChC,iBAAiB,EAAC,wBAAwB,EAC1C,UAAU,QACV,YAAY,QACZ,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,CAAC,UAAiC,EAAE,EAAE;gBAC9C,UAAU,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;YAChD,CAAC,EACD,iBAAiB,EAAE,SAAS,GAC5B;QACF,6BAAK,SAAS,EAAC,qBAAqB;YAClC,oBAAC,MAAM,IAAC,OAAO,EAAE,MAAM,WAAe;YACtC,oBAAC,MAAM,IACL,SAAS,EAAC,iBAAiB,EAC3B,OAAO,EAAE,GAAG,EAAE;oBACZ,QAAQ,CAAC,gBAAgB,CAAC,CAAC;gBAC7B,CAAC,EACD,QAAQ,EAAE,SAAS,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,WAG7C;YACT,oBAAC,MAAM,IAAC,OAAO,EAAE,QAAQ,aAAiB,CACtC,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,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 type {\n TablePaginatorRendererProps} from \"@itwin/itwinui-react\";\nimport {\n Button,\n Table,\n tableFilters,\n TablePaginator,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { MappingReportingAPI } from \"../../api/generated/api\";\nimport { reportingClientApi } from \"../../api/reportingClient\";\nimport type { Mapping } from \"./Mapping\";\nimport \"./SelectMapping.scss\";\n\nconst fetchMappings = async (\n setMappings: React.Dispatch<React.SetStateAction<MappingReportingAPI[]>>,\n iModelId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>\n) => {\n try {\n setIsLoading(true);\n const mappings = await reportingClientApi.getMappings(iModelId);\n setMappings(mappings);\n } catch {\n } finally {\n setIsLoading(false);\n }\n};\n\nconst useFetchMappings = (\n iModelId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>\n): [\n MappingReportingAPI[],\n React.Dispatch<React.SetStateAction<MappingReportingAPI[]>>\n] => {\n const [mappings, setMappings] = useState<MappingReportingAPI[]>([]);\n useEffect(() => {\n void fetchMappings(setMappings, iModelId, setIsLoading);\n }, [iModelId, setIsLoading]);\n\n return [mappings, setMappings];\n};\n\ninterface SelectMappingsProps {\n iModelId: string;\n onSelect: (selectedMappings: Mapping[]) => void;\n onCancel: () => void;\n backFn: () => void;\n}\n\nconst SelectMappings = ({\n iModelId,\n onSelect,\n onCancel,\n backFn,\n}: SelectMappingsProps) => {\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [mappings] = useFetchMappings(iModelId, setIsLoading);\n const [selectedMappings, setSelectedMappings] = useState<Mapping[]>([]);\n\n const mappingsColumns = useMemo(\n () => [\n {\n Header: \"Table\",\n columns: [\n {\n id: \"mappingName\",\n Header: \"Mapping Name\",\n accessor: \"mappingName\",\n Filter: tableFilters.TextFilter(),\n },\n {\n id: \"description\",\n Header: \"Description\",\n accessor: \"description\",\n Filter: tableFilters.TextFilter(),\n },\n ],\n },\n ],\n []\n );\n\n const pageSizeList = useMemo(() => [10, 25, 50], []);\n const paginator = useCallback(\n (props: TablePaginatorRendererProps) => (\n <TablePaginator {...props} pageSizeList={pageSizeList} />\n ),\n [pageSizeList]\n );\n\n return (\n <div className='select-mapping-container'>\n <Table<Mapping>\n data={mappings}\n columns={mappingsColumns}\n className='select-mapping-table'\n emptyTableContent='No Mappings available.'\n isSortable\n isSelectable\n isLoading={isLoading}\n onSelect={(selectData: Mapping[] | undefined) => {\n selectData && setSelectedMappings(selectData);\n }}\n paginatorRenderer={paginator}\n />\n <div className='import-action-panel'>\n <Button onClick={backFn}>Back</Button>\n <Button\n styleType='high-visibility'\n onClick={() => {\n onSelect(selectedMappings);\n }}\n disabled={isLoading || selectedMappings.length === 0}\n >\n Next\n </Button>\n <Button onClick={onCancel}>Cancel</Button>\n </div>\n </div>\n );\n};\n\nexport default SelectMappings;\n"]}
1
+ {"version":3,"file":"SelectMappings.js","sourceRoot":"","sources":["../../../../src/widget/components/SelectMappings.tsx"],"names":[],"mappings":"AAOA,OAAO,EACL,MAAM,EACN,KAAK,EACL,YAAY,EACZ,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,aAAa,GAAG,KAAK,EACzB,WAAwE,EACxE,QAAgB,EAChB,YAA2D,EAC3D,EAAE;IACF,IAAI;QACF,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAChE,WAAW,CAAC,QAAQ,CAAC,CAAC;KACvB;IAAC,OAAO,KAAU,EAAE;QACnB,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;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EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,WAAW,CAC3B,CAAC,KAAkC,EAAE,EAAE,CAAC,CACtC,oBAAC,cAAc,OAAK,KAAK,EAAE,YAAY,EAAE,YAAY,GAAI,CAC1D,EACD,CAAC,YAAY,CAAC,CACf,CAAC;IAEF,OAAO,CACL,6BAAK,SAAS,EAAC,0BAA0B;QACvC,oBAAC,KAAK,IACJ,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,eAAe,EACxB,SAAS,EAAC,sBAAsB,EAChC,iBAAiB,EAAC,wBAAwB,EAC1C,UAAU,QACV,YAAY,QACZ,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,CAAC,UAAiC,EAAE,EAAE;gBAC9C,UAAU,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;YAChD,CAAC,EACD,iBAAiB,EAAE,SAAS,GAC5B;QACF,6BAAK,SAAS,EAAC,qBAAqB;YAClC,oBAAC,MAAM,IAAC,OAAO,EAAE,MAAM,WAAe;YACtC,oBAAC,MAAM,IACL,SAAS,EAAC,iBAAiB,EAC3B,OAAO,EAAE,GAAG,EAAE;oBACZ,QAAQ,CAAC,gBAAgB,CAAC,CAAC;gBAC7B,CAAC,EACD,QAAQ,EAAE,SAAS,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,WAG7C;YACT,oBAAC,MAAM,IAAC,OAAO,EAAE,QAAQ,aAAiB,CACtC,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,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 type {\n TablePaginatorRendererProps,\n} from \"@itwin/itwinui-react\";\nimport {\n Button,\n Table,\n tableFilters,\n TablePaginator,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { MappingReportingAPI } from \"../../api/generated/api\";\nimport { reportingClientApi } from \"../../api/reportingClient\";\nimport type { Mapping } from \"./Mapping\";\nimport \"./SelectMapping.scss\";\nimport { handleError } from \"./utils\";\n\nconst fetchMappings = async (\n setMappings: React.Dispatch<React.SetStateAction<MappingReportingAPI[]>>,\n iModelId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>\n) => {\n try {\n setIsLoading(true);\n const mappings = await reportingClientApi.getMappings(iModelId);\n setMappings(mappings);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n};\n\nconst useFetchMappings = (\n iModelId: string,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>\n): [\n MappingReportingAPI[],\n React.Dispatch<React.SetStateAction<MappingReportingAPI[]>>\n] => {\n const [mappings, setMappings] = useState<MappingReportingAPI[]>([]);\n useEffect(() => {\n void fetchMappings(setMappings, iModelId, setIsLoading);\n }, [iModelId, setIsLoading]);\n\n return [mappings, setMappings];\n};\n\ninterface SelectMappingsProps {\n iModelId: string;\n onSelect: (selectedMappings: Mapping[]) => void;\n onCancel: () => void;\n backFn: () => void;\n}\n\nconst SelectMappings = ({\n iModelId,\n onSelect,\n onCancel,\n backFn,\n}: SelectMappingsProps) => {\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [mappings] = useFetchMappings(iModelId, setIsLoading);\n const [selectedMappings, setSelectedMappings] = useState<Mapping[]>([]);\n\n const mappingsColumns = useMemo(\n () => [\n {\n Header: \"Table\",\n columns: [\n {\n id: \"mappingName\",\n Header: \"Mapping Name\",\n accessor: \"mappingName\",\n Filter: tableFilters.TextFilter(),\n },\n {\n id: \"description\",\n Header: \"Description\",\n accessor: \"description\",\n Filter: tableFilters.TextFilter(),\n },\n ],\n },\n ],\n []\n );\n\n const pageSizeList = useMemo(() => [10, 25, 50], []);\n const paginator = useCallback(\n (props: TablePaginatorRendererProps) => (\n <TablePaginator {...props} pageSizeList={pageSizeList} />\n ),\n [pageSizeList]\n );\n\n return (\n <div className='select-mapping-container'>\n <Table<Mapping>\n data={mappings}\n columns={mappingsColumns}\n className='select-mapping-table'\n emptyTableContent='No Mappings available.'\n isSortable\n isSelectable\n isLoading={isLoading}\n onSelect={(selectData: Mapping[] | undefined) => {\n selectData && setSelectedMappings(selectData);\n }}\n paginatorRenderer={paginator}\n />\n <div className='import-action-panel'>\n <Button onClick={backFn}>Back</Button>\n <Button\n styleType='high-visibility'\n onClick={() => {\n onSelect(selectedMappings);\n }}\n disabled={isLoading || selectedMappings.length === 0}\n >\n Next\n </Button>\n <Button onClick={onCancel}>Cancel</Button>\n </div>\n </div>\n );\n};\n\nexport default SelectMappings;\n"]}
@@ -32,7 +32,7 @@
32
32
  }
33
33
  .select-project-action-panel {
34
34
  display: flex;
35
- justify-content: right;
35
+ justify-content: center;
36
36
  padding: $iui-baseline * 2 $iui-m $iui-baseline;
37
37
  }
38
38
  }
@@ -5,9 +5,9 @@
5
5
  import * as React from "react";
6
6
  import { Orientation } from "@itwin/core-react";
7
7
  import { PrimitivePropertyLabelRenderer } from "@itwin/components-react";
8
- import { CommonPropertyRenderer } from "@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer";
9
8
  import { HighlightedText } from "@itwin/components-react/lib/cjs/components-react/common/HighlightedText";
10
9
  import { PropertyView } from "./PropertyView";
10
+ import { CommonPropertyRenderer } from "@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer";
11
11
  /** React Component that renders primitive properties
12
12
  * @public
13
13
  */
@@ -15,7 +15,7 @@ export class PrimitivePropertyRenderer extends React.Component {
15
15
  /** @internal */
16
16
  render() {
17
17
  var _a, _b;
18
- const { indentation, highlight, ...props } = this.props;
18
+ const { highlight, indentation, ...props } = this.props;
19
19
  const displayLabel = this.props.propertyRecord.property.displayLabel;
20
20
  const offset = CommonPropertyRenderer.getLabelOffset(indentation, props.orientation, props.width, props.columnRatio, (_a = props.columnInfo) === null || _a === void 0 ? void 0 : _a.minLabelWidth);
21
21
  const activeMatchIndex = this.props.propertyRecord.property.name ===
@@ -29,7 +29,11 @@ export class PrimitivePropertyRenderer extends React.Component {
29
29
  activeMatchIndex,
30
30
  })
31
31
  : displayLabel;
32
- return (React.createElement(PropertyView, { ...props, labelElement: React.createElement(PrimitivePropertyLabelRenderer, { offset: offset, renderColon: this.props.orientation === Orientation.Horizontal, tooltip: displayLabel }, label) }));
32
+ return (React.createElement(PropertyView, { ...this.props, labelElement: React.createElement(PrimitivePropertyLabelRenderer
33
+ // Added offset to account for checkbox
34
+ , {
35
+ // Added offset to account for checkbox
36
+ offset: offset + 24, renderColon: this.props.orientation === Orientation.Horizontal, tooltip: displayLabel }, label) }));
33
37
  }
34
38
  }
35
39
  //# sourceMappingURL=PrimitivePropertyRenderer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrimitivePropertyRenderer.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PrimitivePropertyRenderer.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AAEzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8FAA8F,CAAC;AACtI,OAAO,EAAE,eAAe,EAAE,MAAM,yEAAyE,CAAC;AAE1G,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAmB9C;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,KAAK,CAAC,SAAiC;IACpF,gBAAgB;IACA,MAAM;;QACpB,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACxD,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC;QACrE,MAAM,MAAM,GAAG,sBAAsB,CAAC,cAAc,CAClD,WAAW,EACX,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,WAAW,EACjB,MAAA,KAAK,CAAC,UAAU,0CAAE,aAAa,CAChC,CAAC;QAEF,MAAM,gBAAgB,GACpB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI;aACvC,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,eAAe,0CAAE,yBAAyB,CAAA;YACnD,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,cAAc;YAC1C,CAAC,CAAC,SAAS,CAAC;QAChB,MAAM,KAAK,GAAG,SAAS;YACrB,CAAC,CAAC,eAAe,CAAC;gBAChB,IAAI,EAAE,YAAY;gBAClB,UAAU,EAAE,SAAS,CAAC,eAAe;gBACrC,gBAAgB;aACjB,CAAC;YACF,CAAC,CAAC,YAAY,CAAC;QAEjB,OAAO,CACL,oBAAC,YAAY,OACP,KAAK,EACT,YAAY,EACV,oBAAC,8BAA8B,IAC7B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,KAAK,WAAW,CAAC,UAAU,EAC9D,OAAO,EAAE,YAAY,IAEpB,KAAK,CACyB,GAEnC,CACH,CAAC;IACJ,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 * as React from \"react\";\nimport { Orientation } from \"@itwin/core-react\";\nimport { PrimitivePropertyLabelRenderer } from \"@itwin/components-react\";\nimport type { HighlightingComponentProps } from \"@itwin/components-react/lib/cjs/components-react/common/HighlightingComponentProps\";\nimport { CommonPropertyRenderer } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer\";\nimport { HighlightedText } from \"@itwin/components-react/lib/cjs/components-react/common/HighlightedText\";\n\nimport { PropertyView } from \"./PropertyView\";\nimport type { SharedRendererProps } from \"./PropertyRender\";\n\n/** Properties of [[PrimitivePropertyRenderer]] React component\n * @public\n */\nexport interface PrimitiveRendererProps extends SharedRendererProps {\n /** Property value as a React element */\n valueElement?: React.ReactNode;\n /** Render callback for property value. If specified, `valueElement` is ignored. */\n valueElementRenderer?: () => React.ReactNode;\n /** Multiplier of how much the property is indented to the right */\n indentation?: number;\n /** Properties used for highlighting\n * @beta\n */\n highlight?: HighlightingComponentProps;\n}\n\n/** React Component that renders primitive properties\n * @public\n */\nexport class PrimitivePropertyRenderer extends React.Component<PrimitiveRendererProps> {\n /** @internal */\n public override render() {\n const { indentation, highlight, ...props } = this.props;\n const displayLabel = this.props.propertyRecord.property.displayLabel;\n const offset = CommonPropertyRenderer.getLabelOffset(\n indentation,\n props.orientation,\n props.width,\n props.columnRatio,\n props.columnInfo?.minLabelWidth,\n );\n\n const activeMatchIndex =\n this.props.propertyRecord.property.name ===\n highlight?.activeHighlight?.highlightedItemIdentifier\n ? highlight.activeHighlight.highlightIndex\n : undefined;\n const label = highlight\n ? HighlightedText({\n text: displayLabel,\n searchText: highlight.highlightedText,\n activeMatchIndex,\n })\n : displayLabel;\n\n return (\n <PropertyView\n {...props}\n labelElement={\n <PrimitivePropertyLabelRenderer\n offset={offset}\n renderColon={this.props.orientation === Orientation.Horizontal}\n tooltip={displayLabel}\n >\n {label}\n </PrimitivePropertyLabelRenderer>\n }\n />\n );\n }\n}\n"]}
1
+ {"version":3,"file":"PrimitivePropertyRenderer.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PrimitivePropertyRenderer.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;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AAK,WAAW,CAAC,UAAU,EAC9D,OAAO,EAAE,YAAY,IAEpB,KAAK,CACyB,GAEnC,CACH,CAAC;IACJ,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 * as React from \"react\";\nimport { Orientation } from \"@itwin/core-react\";\nimport { PrimitivePropertyLabelRenderer } from \"@itwin/components-react\";\nimport type { HighlightingComponentProps } from \"@itwin/components-react/lib/cjs/components-react/common/HighlightingComponentProps\";\nimport { HighlightedText } from \"@itwin/components-react/lib/cjs/components-react/common/HighlightedText\";\n\nimport { PropertyView } from \"./PropertyView\";\nimport type { SharedRendererProps } from \"./PropertyRender\";\nimport { CommonPropertyRenderer } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer\";\n\n/** Properties of [[PrimitivePropertyRenderer]] React component\n * @public\n */\nexport interface PrimitiveRendererProps extends SharedRendererProps {\n /** Property value as a React element */\n valueElement?: React.ReactNode;\n /** Render callback for property value. If specified, `valueElement` is ignored. */\n valueElementRenderer?: () => React.ReactNode;\n /** Multiplier of how much the property is indented to the right */\n indentation?: number;\n /** Properties used for highlighting\n * @beta\n */\n highlight?: HighlightingComponentProps;\n}\n\n/** React Component that renders primitive properties\n * @public\n */\nexport class PrimitivePropertyRenderer extends React.Component<PrimitiveRendererProps> {\n /** @internal */\n public override render() {\n const { highlight, indentation, ...props } = this.props;\n const displayLabel = this.props.propertyRecord.property.displayLabel;\n const offset = CommonPropertyRenderer.getLabelOffset(\n indentation,\n props.orientation,\n props.width,\n props.columnRatio,\n props.columnInfo?.minLabelWidth,\n );\n\n const activeMatchIndex =\n this.props.propertyRecord.property.name ===\n highlight?.activeHighlight?.highlightedItemIdentifier\n ? highlight.activeHighlight.highlightIndex\n : undefined;\n const label = highlight\n ? HighlightedText({\n text: displayLabel,\n searchText: highlight.highlightedText,\n activeMatchIndex,\n })\n : displayLabel;\n\n return (\n <PropertyView\n {...this.props}\n labelElement={\n <PrimitivePropertyLabelRenderer\n // Added offset to account for checkbox\n offset={offset + 24}\n renderColon={this.props.orientation === Orientation.Horizontal}\n tooltip={displayLabel}\n >\n {label}\n </PrimitivePropertyLabelRenderer>\n }\n />\n );\n }\n}\n"]}
@@ -2,8 +2,8 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- @import "~@itwin/core-react/lib/cjs/core-react/expandable/list";
6
- @import "~@itwin/core-react/lib/cjs/core-react/scrollbar";
5
+ @import '~@itwin/core-react/lib/cjs/core-react/expandable/list';
6
+ @import '~@itwin/core-react/lib/cjs/core-react/scrollbar';
7
7
 
8
8
  .gm-components-property-grid-loader {
9
9
  display: flex;
@@ -61,7 +61,7 @@
61
61
  @include components-property-list;
62
62
 
63
63
  display: grid;
64
- grid-row-gap: 1px; // A gap of 10px is too wasteful
64
+ grid-row-gap: 0px;
65
65
  overflow: hidden;
66
66
  }
67
67
 
@@ -86,7 +86,7 @@ export declare class PropertyRenderer extends React.Component<PropertyRendererPr
86
86
  /** @internal */
87
87
  componentDidUpdate(prevProps: PropertyRendererProps): void;
88
88
  /** @internal */
89
- render(): JSX.Element | undefined;
89
+ render(): JSX.Element;
90
90
  }
91
91
  export {};
92
92
  //# sourceMappingURL=PropertyRender.d.ts.map
@@ -70,19 +70,16 @@ export class PropertyRenderer extends React.Component {
70
70
  };
71
71
  switch (this.props.propertyRecord.value.valueFormat) {
72
72
  case PropertyValueFormat.Primitive:
73
- return React.createElement(PrimitivePropertyRenderer, { ...primitiveRendererProps });
73
+ return (React.createElement(PrimitivePropertyRenderer, { ...primitiveRendererProps }));
74
74
  case PropertyValueFormat.Array:
75
75
  // If array is empty, render it as a primitive property
76
- if (this.props.propertyRecord.value.valueFormat ===
77
- PropertyValueFormat.Array &&
78
- this.props.propertyRecord.value.items.length === 0) {
79
- return React.createElement(PrimitivePropertyRenderer, { ...primitiveRendererProps });
80
- }
81
- break;
76
+ if (this.props.propertyRecord.value.valueFormat === PropertyValueFormat.Array
77
+ && this.props.propertyRecord.value.items.length === 0)
78
+ return (React.createElement(PrimitivePropertyRenderer, { ...primitiveRendererProps }));
79
+ // eslint-disable-next-line no-fallthrough
82
80
  case PropertyValueFormat.Struct:
83
81
  return (React.createElement(NonPrimitivePropertyRenderer, { isCollapsible: true, ...primitiveRendererProps }));
84
82
  }
85
- return;
86
83
  }
87
84
  }
88
85
  //# sourceMappingURL=PropertyRender.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyRender.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PropertyRender.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAO5D,OAAO,EACL,eAAe,EACf,YAAY,GACb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAGxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8FAA8F,CAAC;AAsEtI;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK,CAAC,SAG3C;IAHD;;QAIE,gBAAgB;QACS,UAAK,GAAoC;YAChE,YAAY,EAAE,YAAY,CAAC,SAAS,CAAC,iBAAiB,CAAC;SACxD,CAAC;QAiCM,kBAAa,GAAG,CAAC,IAAyB,EAAE,EAAE;YACpD,uBAAuB;YACvB,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;gBAC3B,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;aAC/B;QACH,CAAC,CAAC;QAEM,kBAAa,GAAG,GAAG,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AAS,CAAC,SAAS,KAAK,IAAI,CAAC,KAAK,CAAC,SAAS;YAC5C,SAAS,CAAC,WAAW,KAAK,IAAI,CAAC,KAAK,CAAC,WAAW,EAChD;YACA,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACrC;IACH,CAAC;IAED,gBAAgB;IACA,MAAM;QACpB,MAAM,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAChC,MAAM,sBAAsB,GAA2B;YACrD,GAAG,KAAK;YACR,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY;YACrC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW;SACpC,CAAC;QAEF,QAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW,EAAE;YACnD,KAAK,mBAAmB,CAAC,SAAS;gBAChC,OAAO,oBAAC,yBAAyB,OAAK,sBAAsB,GAAI,CAAC;YACnE,KAAK,mBAAmB,CAAC,KAAK;gBAC5B,uDAAuD;gBACvD,IACE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,WAAW;oBAC3C,mBAAmB,CAAC,KAAK;oBACzB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAClD;oBACA,OAAO,oBAAC,yBAAyB,OAAK,sBAAsB,GAAI,CAAC;iBAClE;gBACD,MAAM;YACR,KAAK,mBAAmB,CAAC,MAAM;gBAC7B,OAAO,CACL,oBAAC,4BAA4B,IAC3B,aAAa,EAAE,IAAI,KACf,sBAAsB,GAC1B,CACH,CAAC;SACL;QACD,OAAO;IACT,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 * as React from \"react\";\nimport type { PropertyRecord} from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { Orientation, RatioChangeResult } from \"@itwin/core-react\";\nimport type {\n ActionButtonRenderer,\n PrimitiveRendererProps,\n PropertyUpdatedArgs,\n PropertyValueRendererManager} from \"@itwin/components-react\";\nimport {\n EditorContainer,\n UiComponents,\n} from \"@itwin/components-react\";\n\nimport { NonPrimitivePropertyRenderer } from \"./NonPrimitivePropertyRenderer\";\nimport { PrimitivePropertyRenderer } from \"./PrimitivePropertyRenderer\";\nimport type { PropertyGridColumnInfo } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/PropertyGridColumns\";\nimport type { HighlightingComponentProps } from \"@itwin/components-react/lib/cjs/components-react/common/HighlightingComponentProps\";\nimport { CommonPropertyRenderer } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer\";\n\n/** Properties shared by all renderers and PropertyView\n * @public\n */\nexport interface SharedRendererProps {\n /** PropertyRecord to render */\n propertyRecord: PropertyRecord;\n /** Unique string, that identifies this property component. Should be used if onClick or onRightClick are provided */\n uniqueKey?: string;\n /** Orientation to use for displaying the property */\n orientation: Orientation;\n /** Controls component selection */\n isSelected?: boolean;\n /** Called when property gets clicked. If undefined, clicking is disabled */\n onClick?: (property: PropertyRecord, key?: string) => void;\n /** Called when property gets right clicked. If undefined, right clicking is not working */\n onRightClick?: (property: PropertyRecord, key?: string) => void;\n /** Called to show a context menu for properties */\n onContextMenu?: (property: PropertyRecord, e: React.MouseEvent) => void;\n /** Ratio between label and value cells */\n columnRatio?: number;\n /** Callback to column ratio changed event */\n onColumnRatioChanged?: (ratio: number) => void | RatioChangeResult;\n /** Indicates that properties have *hover* effect */\n isHoverable?: boolean;\n /** Indicates that properties can be selected */\n isSelectable?: boolean;\n /** Width of the whole property element */\n width?: number;\n /** Array of action button renderers @beta */\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}\n\n/** Properties of [[PropertyRenderer]] React component\n * @public\n */\nexport interface PropertyRendererProps extends SharedRendererProps {\n /** Custom value renderer */\n propertyValueRendererManager?: PropertyValueRendererManager;\n /** Multiplier of how much the property is indented to the right */\n indentation?: number;\n /** Indicates property is being edited @beta */\n isEditing?: boolean;\n /** Called when property edit is committed. @beta */\n onEditCommit?: (args: PropertyUpdatedArgs) => void;\n /** Called when property edit is cancelled. @beta */\n onEditCancel?: () => void;\n /** Props used for highlighting. @beta */\n highlight?: HighlightingComponentProps;\n}\n\n/** State of [[PropertyRenderer]] React component\n * @internal\n */\ninterface PropertyRendererState {\n /** Currently loaded property value */\n displayValue?: React.ReactNode;\n}\n\n/** A React component that renders properties\n * @public\n */\nexport class PropertyRenderer extends React.Component<\nPropertyRendererProps,\nPropertyRendererState\n> {\n /** @internal */\n public override readonly state: Readonly<PropertyRendererState> = {\n displayValue: UiComponents.translate(\"general.loading\"),\n };\n\n public static getLabelOffset(\n indentation?: number,\n orientation?: Orientation,\n width?: number,\n columnRatio?: number,\n minColumnLabelWidth?: number,\n ): number {\n return CommonPropertyRenderer.getLabelOffset(\n indentation,\n orientation,\n width,\n columnRatio,\n minColumnLabelWidth,\n );\n }\n\n private updateDisplayValue(props: PropertyRendererProps) {\n if (props.isEditing) {\n this.updateDisplayValueAsEditor(props);\n return;\n }\n\n const displayValue = CommonPropertyRenderer.createNewDisplayValue(\n props.orientation,\n props.propertyRecord,\n props.indentation,\n props.propertyValueRendererManager,\n );\n this.setState({ displayValue });\n }\n\n private _onEditCommit = (args: PropertyUpdatedArgs) => {\n // istanbul ignore else\n if (this.props.onEditCommit) {\n this.props.onEditCommit(args);\n }\n };\n\n private _onEditCancel = () => {\n // istanbul ignore else\n if (this.props.onEditCancel) {\n this.props.onEditCancel();\n }\n };\n\n /** Display property record value in an editor */\n public updateDisplayValueAsEditor(props: PropertyRendererProps) {\n this.setState({\n displayValue: (\n <EditorContainer\n propertyRecord={props.propertyRecord}\n onCommit={this._onEditCommit}\n onCancel={this._onEditCancel}\n setFocus={true}\n />\n ),\n });\n }\n\n /** @internal */\n public override componentDidMount() {\n this.updateDisplayValue(this.props);\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyRendererProps) {\n if (\n prevProps.propertyRecord !== this.props.propertyRecord ||\n prevProps.isEditing !== this.props.isEditing ||\n prevProps.orientation !== this.props.orientation\n ) {\n this.updateDisplayValue(this.props);\n }\n }\n\n /** @internal */\n public override render() {\n const { ...props } = this.props;\n const primitiveRendererProps: PrimitiveRendererProps = {\n ...props,\n valueElement: this.state.displayValue,\n indentation: this.props.indentation,\n };\n\n switch (this.props.propertyRecord.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n return <PrimitivePropertyRenderer {...primitiveRendererProps} />;\n case PropertyValueFormat.Array:\n // If array is empty, render it as a primitive property\n if (\n this.props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Array &&\n this.props.propertyRecord.value.items.length === 0\n ) {\n return <PrimitivePropertyRenderer {...primitiveRendererProps} />;\n }\n break;\n case PropertyValueFormat.Struct:\n return (\n <NonPrimitivePropertyRenderer\n isCollapsible={true}\n {...primitiveRendererProps}\n />\n );\n }\n return;\n }\n}\n"]}
1
+ {"version":3,"file":"PropertyRender.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PropertyRender.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAQ5D,OAAO,EACL,eAAe,EACf,YAAY,GACb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAA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,CAAC,WAAW,KAAK,mBAAmB,CAAC,KAAK;uBACxE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;oBACrD,OAAO,CACL,oBAAC,yBAAyB,OAAK,sBAAsB,GAAI,CAC1D,CAAC;YACN,0CAA0C;YAC1C,KAAK,mBAAmB,CAAC,MAAM;gBAC7B,OAAO,CACL,oBAAC,4BAA4B,IAC3B,aAAa,EAAE,IAAI,KACf,sBAAsB,GAC1B,CACH,CAAC;SACL;IACH,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 * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { Orientation, RatioChangeResult } from \"@itwin/core-react\";\nimport type {\n ActionButtonRenderer,\n PrimitiveRendererProps,\n PropertyUpdatedArgs,\n PropertyValueRendererManager,\n} from \"@itwin/components-react\";\nimport {\n EditorContainer,\n UiComponents,\n} from \"@itwin/components-react\";\n\nimport { NonPrimitivePropertyRenderer } from \"./NonPrimitivePropertyRenderer\";\nimport { PrimitivePropertyRenderer } from \"./PrimitivePropertyRenderer\";\nimport type { PropertyGridColumnInfo } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/PropertyGridColumns\";\nimport type { HighlightingComponentProps } from \"@itwin/components-react/lib/cjs/components-react/common/HighlightingComponentProps\";\nimport { CommonPropertyRenderer } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer\";\n\n/** Properties shared by all renderers and PropertyView\n * @public\n */\nexport interface SharedRendererProps {\n /** PropertyRecord to render */\n propertyRecord: PropertyRecord;\n /** Unique string, that identifies this property component. Should be used if onClick or onRightClick are provided */\n uniqueKey?: string;\n /** Orientation to use for displaying the property */\n orientation: Orientation;\n /** Controls component selection */\n isSelected?: boolean;\n /** Called when property gets clicked. If undefined, clicking is disabled */\n onClick?: (property: PropertyRecord, key?: string) => void;\n /** Called when property gets right clicked. If undefined, right clicking is not working */\n onRightClick?: (property: PropertyRecord, key?: string) => void;\n /** Called to show a context menu for properties */\n onContextMenu?: (property: PropertyRecord, e: React.MouseEvent) => void;\n /** Ratio between label and value cells */\n columnRatio?: number;\n /** Callback to column ratio changed event */\n onColumnRatioChanged?: (ratio: number) => void | RatioChangeResult;\n /** Indicates that properties have *hover* effect */\n isHoverable?: boolean;\n /** Indicates that properties can be selected */\n isSelectable?: boolean;\n /** Width of the whole property element */\n width?: number;\n /** Array of action button renderers @beta */\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}\n\n/** Properties of [[PropertyRenderer]] React component\n * @public\n */\nexport interface PropertyRendererProps extends SharedRendererProps {\n /** Custom value renderer */\n propertyValueRendererManager?: PropertyValueRendererManager;\n /** Multiplier of how much the property is indented to the right */\n indentation?: number;\n /** Indicates property is being edited @beta */\n isEditing?: boolean;\n /** Called when property edit is committed. @beta */\n onEditCommit?: (args: PropertyUpdatedArgs) => void;\n /** Called when property edit is cancelled. @beta */\n onEditCancel?: () => void;\n /** Props used for highlighting. @beta */\n highlight?: HighlightingComponentProps;\n}\n\n/** State of [[PropertyRenderer]] React component\n * @internal\n */\ninterface PropertyRendererState {\n /** Currently loaded property value */\n displayValue?: React.ReactNode;\n}\n\n/** A React component that renders properties\n * @public\n */\nexport class PropertyRenderer extends React.Component<\nPropertyRendererProps,\nPropertyRendererState\n> {\n /** @internal */\n public override readonly state: Readonly<PropertyRendererState> = {\n displayValue: UiComponents.translate(\"general.loading\"),\n };\n\n public static getLabelOffset(\n indentation?: number,\n orientation?: Orientation,\n width?: number,\n columnRatio?: number,\n minColumnLabelWidth?: number,\n ): number {\n return CommonPropertyRenderer.getLabelOffset(\n indentation,\n orientation,\n width,\n columnRatio,\n minColumnLabelWidth,\n );\n }\n\n private updateDisplayValue(props: PropertyRendererProps) {\n if (props.isEditing) {\n this.updateDisplayValueAsEditor(props);\n return;\n }\n\n const displayValue = CommonPropertyRenderer.createNewDisplayValue(\n props.orientation,\n props.propertyRecord,\n props.indentation,\n props.propertyValueRendererManager,\n );\n this.setState({ displayValue });\n }\n\n private _onEditCommit = (args: PropertyUpdatedArgs) => {\n // istanbul ignore else\n if (this.props.onEditCommit) {\n this.props.onEditCommit(args);\n }\n };\n\n private _onEditCancel = () => {\n // istanbul ignore else\n if (this.props.onEditCancel) {\n this.props.onEditCancel();\n }\n };\n\n /** Display property record value in an editor */\n public updateDisplayValueAsEditor(props: PropertyRendererProps) {\n this.setState({\n displayValue: (\n <EditorContainer\n propertyRecord={props.propertyRecord}\n onCommit={this._onEditCommit}\n onCancel={this._onEditCancel}\n setFocus={true}\n />\n ),\n });\n }\n\n /** @internal */\n public override componentDidMount() {\n this.updateDisplayValue(this.props);\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyRendererProps) {\n if (\n prevProps.propertyRecord !== this.props.propertyRecord ||\n prevProps.isEditing !== this.props.isEditing ||\n prevProps.orientation !== this.props.orientation\n ) {\n this.updateDisplayValue(this.props);\n }\n }\n\n /** @internal */\n public override render() {\n const { ...props } = this.props;\n const primitiveRendererProps: PrimitiveRendererProps = {\n ...props,\n valueElement: this.state.displayValue,\n indentation: this.props.indentation,\n };\n\n switch (this.props.propertyRecord.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n return (\n <PrimitivePropertyRenderer {...primitiveRendererProps} />\n );\n case PropertyValueFormat.Array:\n // If array is empty, render it as a primitive property\n if (this.props.propertyRecord.value.valueFormat === PropertyValueFormat.Array\n && this.props.propertyRecord.value.items.length === 0)\n return (\n <PrimitivePropertyRenderer {...primitiveRendererProps} />\n );\n // eslint-disable-next-line no-fallthrough\n case PropertyValueFormat.Struct:\n return (\n <NonPrimitivePropertyRenderer\n isCollapsible={true}\n {...primitiveRendererProps}\n />\n );\n }\n }\n}\n"]}
@@ -11,6 +11,8 @@ export interface PropertyViewProps extends SharedRendererProps {
11
11
  valueElement?: React.ReactNode;
12
12
  /** Render callback for property value. If specified, `valueElement` is ignored. */
13
13
  valueElementRenderer?: () => React.ReactNode;
14
+ /** Multiplier of how much the property is indented to the right */
15
+ indentation?: number;
14
16
  }
15
17
  /**
16
18
  * A React component that renders property as label/value pair
@@ -11,12 +11,15 @@ import { GroupQueryBuilderContext } from "../GroupQueryBuilderContext";
11
11
  import { useCallback } from "react";
12
12
  import { PropertyGridColumnStyleProvider } from "@itwin/components-react/lib/cjs/components-react/properties/renderers/PropertyGridColumns";
13
13
  import { Checkbox } from "@itwin/itwinui-react";
14
+ import { CommonPropertyRenderer } from "@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer";
14
15
  /**
15
16
  * A React component that renders property as label/value pair
16
17
  * @public
17
18
  */
18
19
  export const PropertyView = (props) => {
20
+ var _a;
19
21
  const context = React.useContext(GroupQueryBuilderContext);
22
+ const [isCheckboxLoading, setIsCheckboxLoading] = React.useState(false);
20
23
  const _validatePropertySelection = () => {
21
24
  if (context.currentPropertyList.includes(props.propertyRecord)) {
22
25
  return true;
@@ -58,8 +61,12 @@ export const PropertyView = (props) => {
58
61
  // TODO: roof selected item/category value is an object but format is primitive(needs further exploration)
59
62
  if (!context.currentPropertyList.includes(prop) &&
60
63
  prop.value.valueFormat === PropertyValueFormat.Primitive) {
64
+ if (!(await context.queryBuilder.addProperty(prop))) {
65
+ setIsCheckboxLoading(false);
66
+ setIsPropertySelected(false);
67
+ return;
68
+ }
61
69
  context.setCurrentPropertyList(context.currentPropertyList.concat(prop));
62
- await context.queryBuilder.addProperty(prop);
63
70
  context.setQuery(context.queryBuilder.buildQueryString());
64
71
  }
65
72
  }, [context]);
@@ -109,6 +116,7 @@ export const PropertyView = (props) => {
109
116
  React.useEffect(() => {
110
117
  if (props === null || props === void 0 ? void 0 : props.propertyRecord) {
111
118
  if (isPropertySelected) {
119
+ setIsCheckboxLoading(true);
112
120
  _addNestedProperties(props.propertyRecord);
113
121
  }
114
122
  else {
@@ -122,15 +130,9 @@ export const PropertyView = (props) => {
122
130
  props.propertyRecord,
123
131
  ]);
124
132
  React.useEffect(() => {
125
- if (props === null || props === void 0 ? void 0 : props.propertyRecord) {
126
- if (context.currentPropertyList.includes(props.propertyRecord)) {
127
- setIsPropertySelected(true);
128
- }
129
- else {
130
- setIsPropertySelected(false);
131
- }
132
- }
133
- }, [context.currentPropertyList, props.propertyRecord]);
133
+ if (!context.isRendering)
134
+ setIsCheckboxLoading(false);
135
+ }, [context.isRendering]);
134
136
  const _onPropertySelectionChanged = () => {
135
137
  setIsPropertySelected(!isPropertySelected);
136
138
  };
@@ -179,10 +181,11 @@ export const PropertyView = (props) => {
179
181
  !!props.onColumnRatioChanged;
180
182
  const needActionButtons = !!props.actionButtonRenderers;
181
183
  const columnsStyleProvider = new PropertyGridColumnStyleProvider(props.columnInfo);
184
+ const offset = CommonPropertyRenderer.getLabelOffset(props.indentation, props.orientation, props.width, props.columnRatio, (_a = props.columnInfo) === null || _a === void 0 ? void 0 : _a.minLabelWidth);
182
185
  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' },
183
186
  React.createElement("div", { className: 'components-property-record-label' },
184
187
  props.propertyRecord.value.valueFormat ===
185
- PropertyValueFormat.Primitive && (React.createElement(Checkbox, { className: 'components-property-selection-checkbox', checked: isPropertySelected, onChange: _onPropertySelectionChanged })),
188
+ PropertyValueFormat.Primitive && (React.createElement(Checkbox, { style: { marginLeft: offset }, className: 'components-property-selection-checkbox', checked: isPropertySelected, onChange: _onPropertySelectionChanged, disabled: context.isLoading || context.isRendering || (props.propertyRecord.value.value === undefined), isLoading: isCheckboxLoading })),
186
189
  props.labelElement),
187
190
  needElementSeparator ? (React.createElement(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,
188
191
  props.propertyRecord.value.valueFormat ===
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyView.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PropertyView.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,qBAAqB,CAAC;AAE7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,+BAA+B,EAAE,MAAM,2FAA2F,CAAC;AAC5I,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAchD;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAwB,EAAE,EAAE;IACvD,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAC;IAE3D,MAAM,0BAA0B,GAAG,GAAG,EAAE;QACtC,IAAI,OAAO,CAAC,m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K,CAAC,oBAAoB,EAAE;gBAC9B,CAAC,CAAC,KAAK,CAAC,YAAY,CACjB,CACH,CACP,CAAC,CAAC,CAAC,SAAS;QACd,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAC7B,oBAAC,gBAAgB,IACf,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,QAAQ,EAAE,KAAK,CAAC,cAAc,EAC9B,iBAAiB,EAAE,SAAS,EAC5B,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,GAClD,CACH,CAAC,CAAC,CAAC,SAAS,CACT,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 * as React from \"react\";\nimport type { PropertyRecord} from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { ElementSeparator, Orientation } from \"@itwin/core-react\";\nimport { ActionButtonList } from \"@itwin/components-react\";\n\nimport \"./PropertyView.scss\";\nimport type { SharedRendererProps } from \"./PropertyRender\";\nimport { GroupQueryBuilderContext } from \"../GroupQueryBuilderContext\";\nimport { useCallback } from \"react\";\nimport { PropertyGridColumnStyleProvider } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/PropertyGridColumns\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\n\n/** Properties of [[PropertyView]] React component\n * @public\n */\nexport interface PropertyViewProps extends SharedRendererProps {\n /** Property label as a React element */\n labelElement: React.ReactNode;\n /** Property value as a React element */\n valueElement?: React.ReactNode;\n /** Render callback for property value. If specified, `valueElement` is ignored. */\n valueElementRenderer?: () => React.ReactNode;\n}\n\n/**\n * A React component that renders property as label/value pair\n * @public\n */\nexport const PropertyView = (props: PropertyViewProps) => {\n const context = React.useContext(GroupQueryBuilderContext);\n\n const _validatePropertySelection = () => {\n if (context.currentPropertyList.includes(props.propertyRecord)) {\n return true;\n }\n // Check if all subproperties are selected\n if (!_validateNestedPropertiesSelection(props.propertyRecord)) {\n return false;\n }\n return true;\n };\n\n const _validateNestedPropertiesSelection = (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n if (!context.currentPropertyList.includes(prop)) {\n return false;\n }\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n if (!context.currentPropertyList.includes(prop)) {\n return false;\n }\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n if (\n !_validateNestedPropertiesSelection(\n prop.value.members[subPropName]\n )\n ) {\n return false;\n }\n }\n }\n }\n return true;\n };\n\n const [isHovered, setIsHovered] = React.useState<boolean>(false);\n const [isPropertySelected, setIsPropertySelected] = React.useState<boolean>(\n _validatePropertySelection()\n );\n\n const _addSelectedProperty = useCallback(\n async (prop: PropertyRecord) => {\n // TODO: roof selected item/category value is an object but format is primitive(needs further exploration)\n if (\n !context.currentPropertyList.includes(prop) &&\n prop.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n context.setCurrentPropertyList(\n context.currentPropertyList.concat(prop)\n );\n await context.queryBuilder.addProperty(prop);\n context.setQuery(context.queryBuilder.buildQueryString());\n }\n },\n [context]\n );\n\n const _addNestedProperties = useCallback(\n (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n void _addSelectedProperty(prop);\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n void _addSelectedProperty(prop);\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n _addNestedProperties(prop.value.members[subPropName]);\n }\n }\n }\n },\n [_addSelectedProperty]\n );\n\n const _removeSelectedProperty = useCallback(\n async (prop: PropertyRecord): Promise<void> => {\n if (context.currentPropertyList.includes(prop)) {\n context.setCurrentPropertyList(\n context.currentPropertyList.filter((x: PropertyRecord) => x !== prop)\n );\n await context.queryBuilder.removeProperty(prop);\n context.setQuery(context.queryBuilder.buildQueryString());\n }\n },\n [context]\n );\n\n const _removeNestedProperties = useCallback(\n (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n void _removeSelectedProperty(prop);\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n void _removeSelectedProperty(prop);\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n _removeNestedProperties(prop.value.members[subPropName]);\n }\n }\n }\n },\n [_removeSelectedProperty]\n );\n\n React.useEffect(() => {\n if (props?.propertyRecord) {\n if (isPropertySelected) {\n _addNestedProperties(props.propertyRecord);\n } else {\n _removeNestedProperties(props.propertyRecord);\n }\n }\n }, [\n _addNestedProperties,\n _removeNestedProperties,\n isPropertySelected,\n props.propertyRecord,\n ]);\n\n React.useEffect(() => {\n if (props?.propertyRecord) {\n if (context.currentPropertyList.includes(props.propertyRecord)) {\n setIsPropertySelected(true);\n } else {\n setIsPropertySelected(false);\n }\n }\n }, [context.currentPropertyList, props.propertyRecord]);\n\n const _onPropertySelectionChanged = () => {\n setIsPropertySelected(!isPropertySelected);\n };\n\n const _onClick = () => {\n if (props.onClick) {\n props.onClick(props.propertyRecord, props.uniqueKey);\n }\n };\n\n const _onMouseEnter = () => {\n if (props.isHoverable) {\n setIsHovered(true);\n }\n };\n\n const _onMouseLeave = () => {\n if (props.isHoverable) {\n setIsHovered(false);\n }\n };\n\n const _onContextMenu = (e: React.MouseEvent) => {\n if (props.onContextMenu) {\n props.onContextMenu(props.propertyRecord, e);\n }\n if (props.onRightClick) {\n props.onRightClick(props.propertyRecord, props.uniqueKey);\n }\n e.preventDefault();\n return false;\n };\n\n const getClassName = (viewProps: PropertyViewProps) => {\n let propertyRecordClassName =\n viewProps.orientation === Orientation.Horizontal\n ? \"components-property-record--horizontal\"\n : \"components-property-record--vertical\";\n if (viewProps.isSelected) {\n propertyRecordClassName += \" components--selected\";\n }\n if (viewProps.onClick) {\n propertyRecordClassName += \" components--clickable\";\n }\n if (viewProps.isHoverable) {\n propertyRecordClassName += \" components--hoverable\";\n }\n return propertyRecordClassName;\n };\n\n const ratio = props.columnRatio ? props.columnRatio : 0.25;\n const needElementSeparator =\n props.orientation === Orientation.Horizontal &&\n !!props.onColumnRatioChanged;\n const needActionButtons = !!props.actionButtonRenderers;\n const columnsStyleProvider = new PropertyGridColumnStyleProvider(\n props.columnInfo\n );\n\n return (\n <div\n style={columnsStyleProvider.getStyle(\n props.orientation,\n needActionButtons,\n ratio,\n needElementSeparator\n )}\n className={getClassName(props)}\n onClick={_onClick}\n onContextMenu={_onContextMenu}\n onMouseEnter={_onMouseEnter}\n onMouseLeave={_onMouseLeave}\n role='presentation'\n >\n <div className='components-property-record-label'>\n {props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Primitive && (\n <Checkbox\n className='components-property-selection-checkbox'\n checked={isPropertySelected}\n onChange={_onPropertySelectionChanged}\n />\n )}\n {props.labelElement}\n </div>\n {needElementSeparator ? (\n <ElementSeparator\n movableArea={props.width}\n onRatioChanged={props.onColumnRatioChanged}\n ratio={ratio}\n orientation={props.orientation}\n isResizeHandleHovered={props.isResizeHandleHovered}\n onResizeHandleHoverChanged={props.onResizeHandleHoverChanged}\n isResizeHandleBeingDragged={props.isResizeHandleBeingDragged}\n onResizeHandleDragChanged={props.onResizeHandleDragChanged}\n />\n ) : undefined}\n {props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Primitive ? (\n <div className='components-property-record-value'>\n <span>\n {props.valueElementRenderer\n ? props.valueElementRenderer()\n : props.valueElement}\n </span>\n </div>\n ) : undefined}\n {props.actionButtonRenderers ? (\n <ActionButtonList\n orientation={props.orientation}\n property={props.propertyRecord}\n isPropertyHovered={isHovered}\n actionButtonRenderers={props.actionButtonRenderers}\n />\n ) : undefined}\n </div>\n );\n};\n"]}
1
+ {"version":3,"file":"PropertyView.js","sourceRoot":"","sources":["../../../../../src/widget/components/property-grid/PropertyView.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,qBAAqB,CAAC;AAE7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,+BAA+B,EAAE,MAAM,2FAA2F,CAAC;AAC5I,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,8FAA8F,CAAC;AAgBtI;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAwB,EAAE,EAAE;;IACvD,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAC;IAC3D,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExE,MAAM,0BAA0B,GAAG,GAAG,EAAE;QACtC,IAAI,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE;YAC9D,OAAO,IAAI,CAAC;SACb;QACD,0CAA0C;QAC1C,IAAI,CAAC,kCAAkC,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE;YAC7D,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;I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YACrC,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC,CAC9B,6BAAK,SAAS,EAAC,kCAAkC;YAC/C,kCACG,KAAK,CAAC,oBAAoB;gBACzB,CAAC,CAAC,KAAK,CAAC,oBAAoB,EAAE;gBAC9B,CAAC,CAAC,KAAK,CAAC,YAAY,CACjB,CACH,CACP,CAAC,CAAC,CAAC,SAAS;QACd,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAC7B,oBAAC,gBAAgB,IACf,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,QAAQ,EAAE,KAAK,CAAC,cAAc,EAC9B,iBAAiB,EAAE,SAAS,EAC5B,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,GAClD,CACH,CAAC,CAAC,CAAC,SAAS,CACT,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 * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport { ElementSeparator, Orientation } from \"@itwin/core-react\";\nimport { ActionButtonList } from \"@itwin/components-react\";\n\nimport \"./PropertyView.scss\";\nimport type { SharedRendererProps } from \"./PropertyRender\";\nimport { GroupQueryBuilderContext } from \"../GroupQueryBuilderContext\";\nimport { useCallback } from \"react\";\nimport { PropertyGridColumnStyleProvider } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/PropertyGridColumns\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport { CommonPropertyRenderer } from \"@itwin/components-react/lib/cjs/components-react/properties/renderers/CommonPropertyRenderer\";\n\n/** Properties of [[PropertyView]] React component\n * @public\n */\nexport interface PropertyViewProps extends SharedRendererProps {\n /** Property label as a React element */\n labelElement: React.ReactNode;\n /** Property value as a React element */\n valueElement?: React.ReactNode;\n /** Render callback for property value. If specified, `valueElement` is ignored. */\n valueElementRenderer?: () => React.ReactNode;\n /** Multiplier of how much the property is indented to the right */\n indentation?: number;\n}\n\n/**\n * A React component that renders property as label/value pair\n * @public\n */\nexport const PropertyView = (props: PropertyViewProps) => {\n const context = React.useContext(GroupQueryBuilderContext);\n const [isCheckboxLoading, setIsCheckboxLoading] = React.useState(false);\n\n const _validatePropertySelection = () => {\n if (context.currentPropertyList.includes(props.propertyRecord)) {\n return true;\n }\n // Check if all subproperties are selected\n if (!_validateNestedPropertiesSelection(props.propertyRecord)) {\n return false;\n }\n return true;\n };\n\n const _validateNestedPropertiesSelection = (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n if (!context.currentPropertyList.includes(prop)) {\n return false;\n }\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n if (!context.currentPropertyList.includes(prop)) {\n return false;\n }\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n if (\n !_validateNestedPropertiesSelection(\n prop.value.members[subPropName]\n )\n ) {\n return false;\n }\n }\n }\n }\n return true;\n };\n\n const [isHovered, setIsHovered] = React.useState<boolean>(false);\n const [isPropertySelected, setIsPropertySelected] = React.useState<boolean>(\n _validatePropertySelection()\n );\n\n const _addSelectedProperty = useCallback(\n async (prop: PropertyRecord) => {\n // TODO: roof selected item/category value is an object but format is primitive(needs further exploration)\n if (\n !context.currentPropertyList.includes(prop) &&\n prop.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n\n if (!(await context.queryBuilder.addProperty(prop))) {\n setIsCheckboxLoading(false);\n setIsPropertySelected(false);\n return;\n }\n context.setCurrentPropertyList(\n context.currentPropertyList.concat(prop)\n );\n context.setQuery(context.queryBuilder.buildQueryString());\n }\n },\n [context]\n );\n\n const _addNestedProperties = useCallback(\n (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n void _addSelectedProperty(prop);\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n void _addSelectedProperty(prop);\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n _addNestedProperties(prop.value.members[subPropName]);\n }\n }\n }\n },\n [_addSelectedProperty]\n );\n\n const _removeSelectedProperty = useCallback(\n async (prop: PropertyRecord): Promise<void> => {\n if (context.currentPropertyList.includes(prop)) {\n context.setCurrentPropertyList(\n context.currentPropertyList.filter((x: PropertyRecord) => x !== prop)\n );\n await context.queryBuilder.removeProperty(prop);\n context.setQuery(context.queryBuilder.buildQueryString());\n }\n },\n [context]\n );\n\n const _removeNestedProperties = useCallback(\n (prop: PropertyRecord) => {\n switch (prop.value.valueFormat) {\n case PropertyValueFormat.Primitive:\n void _removeSelectedProperty(prop);\n break;\n case PropertyValueFormat.Array:\n if (prop.value.items.length === 0) {\n void _removeSelectedProperty(prop);\n }\n break;\n case PropertyValueFormat.Struct:\n for (const subPropName in prop.value.members) {\n if (\n Object.prototype.hasOwnProperty.call(\n prop.value.members,\n subPropName\n )\n ) {\n _removeNestedProperties(prop.value.members[subPropName]);\n }\n }\n }\n },\n [_removeSelectedProperty]\n );\n\n React.useEffect(() => {\n if (props?.propertyRecord) {\n if (isPropertySelected) {\n setIsCheckboxLoading(true);\n _addNestedProperties(props.propertyRecord);\n } else {\n _removeNestedProperties(props.propertyRecord);\n }\n }\n }, [\n _addNestedProperties,\n _removeNestedProperties,\n isPropertySelected,\n props.propertyRecord,\n ]);\n\n React.useEffect(() => {\n if (!context.isRendering)\n setIsCheckboxLoading(false);\n }, [context.isRendering]);\n\n const _onPropertySelectionChanged = () => {\n setIsPropertySelected(!isPropertySelected);\n };\n\n const _onClick = () => {\n if (props.onClick) {\n props.onClick(props.propertyRecord, props.uniqueKey);\n }\n };\n\n const _onMouseEnter = () => {\n if (props.isHoverable) {\n setIsHovered(true);\n }\n };\n\n const _onMouseLeave = () => {\n if (props.isHoverable) {\n setIsHovered(false);\n }\n };\n\n const _onContextMenu = (e: React.MouseEvent) => {\n if (props.onContextMenu) {\n props.onContextMenu(props.propertyRecord, e);\n }\n if (props.onRightClick) {\n props.onRightClick(props.propertyRecord, props.uniqueKey);\n }\n e.preventDefault();\n return false;\n };\n\n const getClassName = (viewProps: PropertyViewProps) => {\n let propertyRecordClassName =\n viewProps.orientation === Orientation.Horizontal\n ? \"components-property-record--horizontal\"\n : \"components-property-record--vertical\";\n if (viewProps.isSelected) {\n propertyRecordClassName += \" components--selected\";\n }\n if (viewProps.onClick) {\n propertyRecordClassName += \" components--clickable\";\n }\n if (viewProps.isHoverable) {\n propertyRecordClassName += \" components--hoverable\";\n }\n return propertyRecordClassName;\n };\n\n const ratio = props.columnRatio ? props.columnRatio : 0.25;\n const needElementSeparator =\n props.orientation === Orientation.Horizontal &&\n !!props.onColumnRatioChanged;\n const needActionButtons = !!props.actionButtonRenderers;\n const columnsStyleProvider = new PropertyGridColumnStyleProvider(\n props.columnInfo\n );\n\n const offset = CommonPropertyRenderer.getLabelOffset(\n props.indentation,\n props.orientation,\n props.width,\n props.columnRatio,\n props.columnInfo?.minLabelWidth,\n );\n\n return (\n <div\n style={columnsStyleProvider.getStyle(\n props.orientation,\n needActionButtons,\n ratio,\n needElementSeparator\n )}\n className={getClassName(props)}\n onClick={_onClick}\n onContextMenu={_onContextMenu}\n onMouseEnter={_onMouseEnter}\n onMouseLeave={_onMouseLeave}\n role='presentation'\n >\n <div className='components-property-record-label'>\n {props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Primitive && (\n <Checkbox\n style={{ marginLeft: offset }}\n className='components-property-selection-checkbox'\n checked={isPropertySelected}\n onChange={_onPropertySelectionChanged}\n disabled={context.isLoading || context.isRendering || (props.propertyRecord.value.value === undefined)}\n isLoading={isCheckboxLoading}\n />\n )}\n {props.labelElement}\n </div>\n {needElementSeparator ? (\n <ElementSeparator\n movableArea={props.width}\n onRatioChanged={props.onColumnRatioChanged}\n ratio={ratio}\n orientation={props.orientation}\n isResizeHandleHovered={props.isResizeHandleHovered}\n onResizeHandleHoverChanged={props.onResizeHandleHoverChanged}\n isResizeHandleBeingDragged={props.isResizeHandleBeingDragged}\n onResizeHandleDragChanged={props.onResizeHandleDragChanged}\n />\n ) : undefined}\n {props.propertyRecord.value.valueFormat ===\n PropertyValueFormat.Primitive ? (\n <div className='components-property-record-value'>\n <span>\n {props.valueElementRenderer\n ? props.valueElementRenderer()\n : props.valueElement}\n </span>\n </div>\n ) : undefined}\n {props.actionButtonRenderers ? (\n <ActionButtonList\n orientation={props.orientation}\n property={props.propertyRecord}\n isPropertyHovered={isHovered}\n actionButtonRenderers={props.actionButtonRenderers}\n />\n ) : undefined}\n </div>\n );\n};\n"]}
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- @import "~@itwin/core-react/lib/cjs/core-react/style/themecolors";
6
- @import "~@itwin/itwinui-css/scss/style/typography";
7
- @import "~@itwin/itwinui-css/scss/variables";
5
+ @import '~@itwin/core-react/lib/cjs/core-react/style/themecolors';
6
+ @import '~@itwin/itwinui-css/scss/style/typography';
7
+ @import '~@itwin/itwinui-css/scss/variables';
8
8
 
9
9
  $text-font-size: $iui-font-size;
10
10
  $text-font-color: $buic-text-color;
@@ -52,8 +52,23 @@ $text-font-color: $buic-text-color;
52
52
 
53
53
  .components-property-record-label {
54
54
  @include record-cell;
55
+ position: relative;
55
56
  .components-property-selection-checkbox {
56
- margin-right: $iui-s;
57
+ flex-shrink: 0;
58
+ position: absolute;
59
+ z-index: 1;
60
+ }
61
+ // Radial does not respect checkbox positioning, have to force it.
62
+ > .iui-progress-indicator-radial {
63
+ position: absolute;
64
+ }
65
+ .components-property-selection-loading {
66
+ display: flex;
67
+ width: $iui-m;
68
+ height: $iui-m;
69
+ align-items: center;
70
+ justify-content: center;
71
+ flex-shrink: 0;
57
72
  }
58
73
  }
59
74
 
@@ -11,4 +11,6 @@ export interface WidgetHeaderProps {
11
11
  export declare const WidgetHeader: ({ title, disabled, returnFn, }: WidgetHeaderProps) => JSX.Element;
12
12
  export declare const handleInputChange: <T>(e: React.ChangeEvent<HTMLInputElement>, values: T, setValues: React.Dispatch<React.SetStateAction<T>>) => void;
13
13
  export declare const fetchIdsFromQuery: (query: string, iModelConnection: IModelConnection) => Promise<string[]>;
14
+ export declare const handleError: (errorStatus: number) => void;
15
+ export declare const LoadingSpinner: () => JSX.Element;
14
16
  //# sourceMappingURL=utils.d.ts.map
@@ -3,7 +3,7 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { SvgChevronLeft } from "@itwin/itwinui-icons-react";
6
- import { Text } from "@itwin/itwinui-react";
6
+ import { ProgressRadial, Text, toaster } from "@itwin/itwinui-react";
7
7
  import "./utils.scss";
8
8
  import React from "react";
9
9
  import { QueryRowFormat } from "@itwin/core-common";
@@ -58,15 +58,54 @@ export const fetchIdsFromQuery = async (query, iModelConnection) => {
58
58
  break;
59
59
  }
60
60
  if (Object.keys(value).includes("id")) {
61
- // eslint-disable-next-line dot-notation
62
61
  ids.push(value.id);
63
62
  }
64
63
  else if (Object.keys(value).includes("element.id")) {
65
64
  ids.push(value["element.id"]);
66
65
  }
67
- // eslint-disable-next-line dot-notation
68
- ids.push(value.id);
66
+ else if (Object.keys(value).includes("eCInstanceId")) {
67
+ ids.push(value.eCInstanceId);
68
+ }
69
69
  }
70
70
  return ids;
71
71
  };
72
+ export const handleError = (errorStatus) => {
73
+ let errorMessage = "Error! ";
74
+ switch (errorStatus) {
75
+ case 401:
76
+ errorMessage += `You are unauthorized to do this operation.`;
77
+ break;
78
+ case 403:
79
+ errorMessage += `You don't have permission to access the requested resource.`;
80
+ break;
81
+ case 404:
82
+ errorMessage += `The requested resource was not found.`;
83
+ break;
84
+ case 409:
85
+ errorMessage += `This property name is already being used.`;
86
+ break;
87
+ case 422:
88
+ errorMessage += `Unable to process the request.`;
89
+ break;
90
+ case 429:
91
+ errorMessage += `Too many requests.`;
92
+ break;
93
+ case 500:
94
+ errorMessage += `Internal server error.`;
95
+ break;
96
+ case 502:
97
+ errorMessage += `Bad gateway.`;
98
+ break;
99
+ case 503:
100
+ errorMessage += `Service unavailable.`;
101
+ break;
102
+ default:
103
+ errorMessage += `Something went wrong!`;
104
+ }
105
+ toaster.negative(errorMessage);
106
+ };
107
+ export const LoadingSpinner = () => {
108
+ return (React.createElement("div", { className: "gm-loading-spinner" },
109
+ React.createElement(ProgressRadial, { size: "small", indeterminate: true })));
110
+ };
72
111
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/widget/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;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,GAA6B,EAC7B,iBAAqC,EACrC,EAAE;IACF,+BAA+B;IAC/B,MAAM,SAAS,GAAG,iBAAiB,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IACxE,IAAI,SAAS,CAAC,OAAO,EAAE;QACrB,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;KACxD;SAAM;QACL,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;QACvD,IAAI,SAAS,CAAC,YAAY,CAAC,IAAI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T,SAAkD,EAClD,EAAE;IACF,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC;IAEjC,SAAS,CAAC;QACR,GAAG,MAAM;QACT,CAAC,IAAI,CAAC,EAAE,KAAK;KACd,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EACpC,KAAa,EACb,gBAAkC,EAClC,EAAE;IACF,IAAI,KAAK,KAAK,EAAE,EAAE;QAChB,OAAO,EAAE,CAAC;KACX;IACD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,WAAW,GAAG,gBAAgB,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE;QAC3D,SAAS,EAAE,cAAc,CAAC,kBAAkB;KAC7C,CAAC,CAAC;IACH,OAAO,IAAI,EAAE;QACX,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;QACjD,IAAI,IAAI,EAAE;YACR,MAAM;SACP;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACrC,wCAAwC;YACxC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;SACpB;aAAM,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;YACpD,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;SAC/B;QACD,wCAAwC;QACxC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;KACpB;IACD,OAAO,GAAG,CAAC;AACb,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\";\nimport type {\n ISelectionProvider,\n SelectionChangeEventArgs,\n} from \"@itwin/presentation-frontend\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { QueryRowFormat } from \"@itwin/core-common\";\n\nexport const onSelectionChanged = (\n evt: SelectionChangeEventArgs,\n selectionProvider: ISelectionProvider,\n) => {\n /* eslint-disable no-console */\n const selection = selectionProvider.getSelection(evt.imodel, evt.level);\n if (selection.isEmpty) {\n console.log(\"========== Selection cleared ==========\");\n } else {\n console.log(\"========== Selection change ===========\");\n if (selection.instanceKeys.size !== 0) {\n // log all selected ECInstance ids grouped by ECClass name\n console.log(\"ECInstances:\");\n selection.instanceKeys.forEach((ids, ecclass) => {\n console.log(`${ecclass}: [${[...ids].join(\",\")}]`);\n });\n }\n if (selection.nodeKeys.size !== 0) {\n // log all selected node keys\n console.log(\"Nodes:\");\n selection.nodeKeys.forEach((key) => console.log(JSON.stringify(key)));\n }\n console.log(\"=======================================\");\n }\n /* eslint-enable no-console */\n};\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='widget-header-container'>\n {returnFn && (\n <div\n className={disabled ? \"chevron-disabled\" : \"chevron\"}\n onClick={disabled ? undefined : returnFn}\n >\n <SvgChevronLeft />\n </div>\n )}\n <Text className='title' variant='title'>\n {title}\n </Text>\n </div>\n );\n};\n\nexport const handleInputChange = <T,>(\n e: React.ChangeEvent<HTMLInputElement>,\n values: T,\n setValues: React.Dispatch<React.SetStateAction<T>>,\n) => {\n const { name, value } = e.target;\n\n setValues({\n ...values,\n [name]: value,\n });\n};\n\nexport const fetchIdsFromQuery = async (\n query: string,\n iModelConnection: IModelConnection,\n) => {\n if (query === \"\") {\n return [];\n }\n const ids: string[] = [];\n const rowIterator = iModelConnection.query(query, undefined, {\n rowFormat: QueryRowFormat.UseJsPropertyNames,\n });\n while (true) {\n const { done, value } = await rowIterator.next();\n if (done) {\n break;\n }\n if (Object.keys(value).includes(\"id\")) {\n // eslint-disable-next-line dot-notation\n ids.push(value.id);\n } else if (Object.keys(value).includes(\"element.id\")) {\n ids.push(value[\"element.id\"]);\n }\n // eslint-disable-next-line dot-notation\n ids.push(value.id);\n }\n return ids;\n};\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/widget/components/utils.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,GAA6B,EAC7B,iBAAqC,EACrC,EAAE;IACF,+BAA+B;IAC/B,MAAM,SAAS,GAAG,iBAAiB,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IACxE,IAAI,SAAS,CAAC,OAAO,EAAE;QACrB,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;KACxD;SAAM;QACL,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;QACvD,IAAI,SAAS,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,EAAE;YACrC,0DAA0D;YAC1D,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YAC5B,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;gBAC9C,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,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IAAI,uCAAuC,CAAC;YACxD,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,2CAA2C,CAAC;YAC5D,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,gCAAgC,CAAC;YACjD,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,oBAAoB,CAAC;YACrC,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,wBAAwB,CAAC;YACzC,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,cAAc,CAAC;YAC/B,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,sBAAsB,CAAC;YACvC,MAAM;QACR;YACE,YAAY,IAAI,uBAAuB,CAAC;KAC3C;IACD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;AAEjC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,OAAO,CACL,6BAAK,SAAS,EAAC,oBAAoB;QACjC,oBAAC,cAAc,IAAC,IAAI,EAAC,OAAO,EAAC,aAAa,SAAG,CACzC,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 { ProgressRadial, Text, toaster } from \"@itwin/itwinui-react\";\nimport \"./utils.scss\";\nimport React from \"react\";\nimport type {\n ISelectionProvider,\n SelectionChangeEventArgs,\n} from \"@itwin/presentation-frontend\";\nimport type { IModelConnection } from \"@itwin/core-frontend\";\nimport { QueryRowFormat } from \"@itwin/core-common\";\n\nexport const onSelectionChanged = (\n evt: SelectionChangeEventArgs,\n selectionProvider: ISelectionProvider,\n) => {\n /* eslint-disable no-console */\n const selection = selectionProvider.getSelection(evt.imodel, evt.level);\n if (selection.isEmpty) {\n console.log(\"========== Selection cleared ==========\");\n } else {\n console.log(\"========== Selection change ===========\");\n if (selection.instanceKeys.size !== 0) {\n // log all selected ECInstance ids grouped by ECClass name\n console.log(\"ECInstances:\");\n selection.instanceKeys.forEach((ids, ecclass) => {\n console.log(`${ecclass}: [${[...ids].join(\",\")}]`);\n });\n }\n if (selection.nodeKeys.size !== 0) {\n // log all selected node keys\n console.log(\"Nodes:\");\n selection.nodeKeys.forEach((key) => console.log(JSON.stringify(key)));\n }\n console.log(\"=======================================\");\n }\n /* eslint-enable no-console */\n};\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='widget-header-container'>\n {returnFn && (\n <div\n className={disabled ? \"chevron-disabled\" : \"chevron\"}\n onClick={disabled ? undefined : returnFn}\n >\n <SvgChevronLeft />\n </div>\n )}\n <Text className='title' variant='title'>\n {title}\n </Text>\n </div>\n );\n};\n\nexport const handleInputChange = <T,>(\n e: React.ChangeEvent<HTMLInputElement>,\n values: T,\n setValues: React.Dispatch<React.SetStateAction<T>>,\n) => {\n const { name, value } = e.target;\n\n setValues({\n ...values,\n [name]: value,\n });\n};\n\nexport const fetchIdsFromQuery = async (\n query: string,\n iModelConnection: IModelConnection,\n) => {\n if (query === \"\") {\n return [];\n }\n const ids: string[] = [];\n const rowIterator = iModelConnection.query(query, undefined, {\n rowFormat: QueryRowFormat.UseJsPropertyNames,\n });\n while (true) {\n const { done, value } = await rowIterator.next();\n if (done) {\n break;\n }\n if (Object.keys(value).includes(\"id\")) {\n ids.push(value.id);\n } else if (Object.keys(value).includes(\"element.id\")) {\n ids.push(value[\"element.id\"]);\n } else if (Object.keys(value).includes(\"eCInstanceId\")) {\n ids.push(value.eCInstanceId);\n }\n }\n return ids;\n};\n\nexport const handleError = (errorStatus: number) => {\n let errorMessage = \"Error! \";\n switch (errorStatus) {\n case 401:\n errorMessage += `You are unauthorized to do this operation.`;\n break;\n case 403:\n errorMessage += `You don't have permission to access the requested resource.`;\n break;\n case 404:\n errorMessage += `The requested resource was not found.`;\n break;\n case 409:\n errorMessage += `This property name is already being used.`;\n break;\n case 422:\n errorMessage += `Unable to process the request.`;\n break;\n case 429:\n errorMessage += `Too many requests.`;\n break;\n case 500:\n errorMessage += `Internal server error.`;\n break;\n case 502:\n errorMessage += `Bad gateway.`;\n break;\n case 503:\n errorMessage += `Service unavailable.`;\n break;\n default:\n errorMessage += `Something went wrong!`;\n }\n toaster.negative(errorMessage);\n\n};\n\nexport const LoadingSpinner = () => {\n return (\n <div className=\"gm-loading-spinner\">\n <ProgressRadial size=\"small\" indeterminate />\n </div>\n );\n};\n"]}
@@ -34,3 +34,8 @@
34
34
  text-overflow: ellipsis;
35
35
  }
36
36
  }
37
+
38
+ .gm-loading-spinner {
39
+ display: flex;
40
+ align-items: center;
41
+ }
@@ -49,7 +49,7 @@ export const visualizeElements = (elementIds, color, replace = false, wantEmphas
49
49
  emph.emphasizeElements(elementIds, vp, undefined, replace);
50
50
  };
51
51
  export const zoomToElements = async (elementIds) => {
52
- if (!IModelApp.viewManager.selectedView) {
52
+ if (!IModelApp.viewManager.selectedView || elementIds.length === 0) {
53
53
  return;
54
54
  }
55
55
  const vp = IModelApp.viewManager.selectedView;
@@ -1 +1 @@
1
- {"version":3,"file":"viewerUtils.js","sourceRoot":"","sources":["../../../../src/widget/components/viewerUtils.tsx"],"names":[],"mappings":"AAOA,OAAO,EACL,iBAAiB,EACjB,SAAS,GACV,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,QAAQ,EACR,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EACxC,UAAoB,EACpB,KAAa,EACb,gBAAkC,EAClC,OAAO,G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C;AAC1B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC1C,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,EAAE;QACvC,OAAO;KACR;IACD,MAAM,EAAE,GAAG,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC;IAC9C,MAAM,IAAI,GAAG,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC/C,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;IACjC,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;AACnC,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 type {\n IModelConnection,\n ViewChangeOptions} from \"@itwin/core-frontend\";\nimport {\n EmphasizeElements,\n IModelApp,\n} from \"@itwin/core-frontend\";\nimport type {\n ElementProps} from \"@itwin/core-common\";\nimport {\n ColorDef,\n FeatureOverrideType,\n} from \"@itwin/core-common\";\nimport { KeySet } from \"@itwin/presentation-common\";\nimport { HiliteSetProvider } from \"@itwin/presentation-frontend\";\n\nexport const visualizeElementsById = async (\n elementIds: string[],\n color: string,\n iModelConnection: IModelConnection,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n visualizeElements(ids, color, replace, wantEmphasis);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElementsByKeys = async (\n keySet: KeySet,\n color: string,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n visualizeElements(ids, color, replace, wantEmphasis);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElements = (\n elementIds: string[],\n color: string,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n\n emph.overrideElements(\n elementIds,\n vp,\n ColorDef.fromString(color),\n FeatureOverrideType.ColorOnly,\n true,\n );\n if (!wantEmphasis) {\n return;\n }\n emph.wantEmphasis = true;\n emph.emphasizeElements(elementIds, vp, undefined, replace);\n};\n\nexport const zoomToElements = async (elementIds: string[]) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const viewChangeOpts: ViewChangeOptions = {};\n viewChangeOpts.animateFrustumChange = true;\n // It was removed. Should be a prop to be passed to lookAtViewAlignedVolume within the implementation.\n // viewChangeOpts.marginPercent = new MarginPercent(0.1, 0.1, 0.1, 0.1);\n await vp.zoomToElements(elementIds, { ...viewChangeOpts });\n};\n\nexport const manufactureKeys = async (\n elementIds: string[],\n iModelConnection: IModelConnection,\n): Promise<KeySet> => {\n // segment ids into batches\n const batches: string[][] = [];\n let currBatch: string[] = [];\n const batchSize = 100000;\n for (const id of elementIds) {\n if (currBatch.length < batchSize) {\n currBatch.push(id);\n } else {\n batches.push(currBatch);\n currBatch = [id];\n }\n }\n if (currBatch.length > 0 && currBatch.length <= batchSize) {\n batches.push(currBatch);\n }\n\n // retrieve element properties in batches\n let elemProps: ElementProps[] = [];\n for (const batch of batches) {\n const props = await iModelConnection.elements.getProps(batch);\n elemProps = elemProps.concat(props);\n }\n\n const isElementId = (elem: {\n id: string | undefined;\n className: string;\n }): elem is {\n id: string;\n className: string;\n } => {\n return elem.id !== undefined;\n };\n\n // create keyset from the element properties\n const keys = elemProps\n .map((elem: ElementProps) => ({\n id: elem.id,\n className: elem.classFullName,\n }))\n .filter(isElementId);\n return new KeySet(keys);\n};\n\nexport const clearEmphasizedElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearEmphasizedElements(vp);\n emph.clearOverriddenElements(vp);\n};\n"]}
1
+ {"version":3,"file":"viewerUtils.js","sourceRoot":"","sources":["../../../../src/widget/components/viewerUtils.tsx"],"names":[],"mappings":"AAQA,OAAO,EACL,iBAAiB,EACjB,SAAS,GACV,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EACL,QAAQ,EACR,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EACxC,UAAoB,EACpB,KAAa,EACb,gBAAkC,EAClC,OAAO,GAAG,KAAK,EACf,YAAY,GAAG,IAAI,EACnB,EAAE;IACF,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,EAAE;QACvC,OAAO,EAAE,CAAC;KACX;IAED,MAAM,EAAE,GAAG,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC;IAE9C,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IACnE,MAAM,cAAc,GAAsB,iBAAiB,CAAC,MAAM,CAAC;QACjE,MAAM,EAAE,EAAE,CAAC,MAAM;KAClB,CAAC,CAAC;IACH,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACtD,IAAI,GAAG,CAAC,QAAQ,EAAE;QAChB,MAAM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;KACF;IACD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,MAAM,IAAI,SAAS,EAAE;QACzD,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KACzB;IAED,yCAAyC;IACzC,IAAI,SAAS,GAAmB,EAAE,CAAC;IACnC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;QAC3B,MAAM,KAAK,GAAG,MAAM,gBAAgB,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC9D,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;KACrC;IAED,MAAM,WAAW,GAAG,CAAC,IAGpB,EAGC,EAAE;QACF,OAAO,IAAI,CAAC,EAAE,KAAK,SAAS,CAAC;IAC/B,CAAC,CAAC;IAEF,4CAA4C;IAC5C,MAAM,IAAI,GAAG,SAAS;SACnB,GAAG,CAAC,CAAC,IAAkB,EAAE,EAAE,CAAC,CAAC;QAC5B,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,SAAS,EAAE,IAAI,CAAC,aAAa;KAC9B,CAAC,CAAC;SACF,MAAM,CAAC,WAAW,CAAC,CAAC;IACvB,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC1C,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,EAAE;QACvC,OAAO;KACR;IACD,MAAM,EAAE,GAAG,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC;IAC9C,MAAM,IAAI,GAAG,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC/C,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;IACjC,IAAI,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;AACnC,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 type {\n IModelConnection,\n ViewChangeOptions,\n} from \"@itwin/core-frontend\";\nimport {\n EmphasizeElements,\n IModelApp,\n} from \"@itwin/core-frontend\";\nimport type {\n ElementProps,\n} from \"@itwin/core-common\";\nimport {\n ColorDef,\n FeatureOverrideType,\n} from \"@itwin/core-common\";\nimport { KeySet } from \"@itwin/presentation-common\";\nimport { HiliteSetProvider } from \"@itwin/presentation-frontend\";\n\nexport const visualizeElementsById = async (\n elementIds: string[],\n color: string,\n iModelConnection: IModelConnection,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const keySet = await manufactureKeys(elementIds, iModelConnection);\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n visualizeElements(ids, color, replace, wantEmphasis);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElementsByKeys = async (\n keySet: KeySet,\n color: string,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return [];\n }\n\n const vp = IModelApp.viewManager.selectedView;\n\n const hiliteProvider: HiliteSetProvider = HiliteSetProvider.create({\n imodel: vp.iModel,\n });\n const set = await hiliteProvider.getHiliteSet(keySet);\n if (set.elements) {\n const ids = [...set.elements];\n visualizeElements(ids, color, replace, wantEmphasis);\n return ids;\n }\n return [];\n};\n\nexport const visualizeElements = (\n elementIds: string[],\n color: string,\n replace = false,\n wantEmphasis = true,\n) => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n\n emph.overrideElements(\n elementIds,\n vp,\n ColorDef.fromString(color),\n FeatureOverrideType.ColorOnly,\n true,\n );\n if (!wantEmphasis) {\n return;\n }\n emph.wantEmphasis = true;\n emph.emphasizeElements(elementIds, vp, undefined, replace);\n};\n\nexport const zoomToElements = async (elementIds: string[]) => {\n if (!IModelApp.viewManager.selectedView || elementIds.length === 0) {\n return;\n }\n\n const vp = IModelApp.viewManager.selectedView;\n const viewChangeOpts: ViewChangeOptions = {};\n viewChangeOpts.animateFrustumChange = true;\n // It was removed. Should be a prop to be passed to lookAtViewAlignedVolume within the implementation.\n // viewChangeOpts.marginPercent = new MarginPercent(0.1, 0.1, 0.1, 0.1);\n await vp.zoomToElements(elementIds, { ...viewChangeOpts });\n};\n\nexport const manufactureKeys = async (\n elementIds: string[],\n iModelConnection: IModelConnection,\n): Promise<KeySet> => {\n // segment ids into batches\n const batches: string[][] = [];\n let currBatch: string[] = [];\n const batchSize = 100000;\n for (const id of elementIds) {\n if (currBatch.length < batchSize) {\n currBatch.push(id);\n } else {\n batches.push(currBatch);\n currBatch = [id];\n }\n }\n if (currBatch.length > 0 && currBatch.length <= batchSize) {\n batches.push(currBatch);\n }\n\n // retrieve element properties in batches\n let elemProps: ElementProps[] = [];\n for (const batch of batches) {\n const props = await iModelConnection.elements.getProps(batch);\n elemProps = elemProps.concat(props);\n }\n\n const isElementId = (elem: {\n id: string | undefined;\n className: string;\n }): elem is {\n id: string;\n className: string;\n } => {\n return elem.id !== undefined;\n };\n\n // create keyset from the element properties\n const keys = elemProps\n .map((elem: ElementProps) => ({\n id: elem.id,\n className: elem.classFullName,\n }))\n .filter(isElementId);\n return new KeySet(keys);\n};\n\nexport const clearEmphasizedElements = () => {\n if (!IModelApp.viewManager.selectedView) {\n return;\n }\n const vp = IModelApp.viewManager.selectedView;\n const emph = EmphasizeElements.getOrCreate(vp);\n emph.clearEmphasizedElements(vp);\n emph.clearOverriddenElements(vp);\n};\n"]}