-
Notifications
You must be signed in to change notification settings - Fork 2
/
DoublePropertyValueRenderer.tsx
44 lines (41 loc) · 1.52 KB
/
DoublePropertyValueRenderer.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
44
/*---------------------------------------------------------------------------------------------
* 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 type { PropertyRecord } from "@itwin/appui-abstract";
import { PropertyValueFormat, StandardTypeNames } from "@itwin/appui-abstract";
import type {
IPropertyValueRenderer,
PropertyValueRendererContext,
} from "../../ValueRendererManager";
import { PrimitivePropertyValueRendererImpl } from "./PrimitivePropertyValueRenderer";
import { convertRecordToString } from "./Common";
/** Default Double Property Renderer
* @public
*/
export class DoublePropertyValueRenderer implements IPropertyValueRenderer {
/** Checks if the renderer can handle given property */
public canRender(record: PropertyRecord) {
return (
record.value.valueFormat === PropertyValueFormat.Primitive &&
record.property.typename === StandardTypeNames.Double.valueOf()
);
}
/** Method that returns a JSX representation of PropertyRecord */
public render(
record: PropertyRecord,
context?: PropertyValueRendererContext
) {
return (
<PrimitivePropertyValueRendererImpl
record={record}
context={context}
stringValueCalculator={convertRecordToString}
/>
);
}
}