-
Notifications
You must be signed in to change notification settings - Fork 2
/
StructValueRenderer.tsx
43 lines (39 loc) · 1.61 KB
/
StructValueRenderer.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Properties
*/
import * as React from "react";
import { NonPrimitivePropertyRenderer } from "../../NonPrimitivePropertyRenderer";
import type { TableSpecificValueRendererProps } from "./NonPrimitiveValueRenderer";
import { TableNonPrimitiveValueRenderer as TableValueRenderer } from "./NonPrimitiveValueRenderer";
/** A react component which renders struct property value as a button with text
* @public
*/
export class TableStructValueRenderer extends React.PureComponent<TableSpecificValueRendererProps> {
private getButtonLabel(props: TableSpecificValueRendererProps) {
return `{${props.propertyRecord.property.typename}}`;
}
private getDialogContents() {
return (
<NonPrimitivePropertyRenderer
uniqueKey={`table_struct_${this.props.propertyRecord.property.name}`}
orientation={this.props.orientation}
propertyRecord={this.props.propertyRecord}
/>
);
}
/** @internal */
public override render() {
return (
<TableValueRenderer
buttonLabel={this.getButtonLabel(this.props)}
dialogTitle={`Struct of type "${this.props.propertyRecord.property.typename}"`}
dialogContents={this.getDialogContents()}
onDialogOpen={this.props.onDialogOpen}
/>
);
}
}