2019-08-29 11:22:09 +00:00
|
|
|
import React from "react";
|
2019-09-09 09:08:54 +00:00
|
|
|
import BaseWidget, { WidgetProps, WidgetState } from "./BaseWidget";
|
2019-11-25 05:07:27 +00:00
|
|
|
import { WidgetType } from "constants/WidgetConstants";
|
|
|
|
|
import TextComponent from "components/designSystems/blueprint/TextComponent";
|
|
|
|
|
import { VALIDATION_TYPES } from "constants/WidgetValidation";
|
|
|
|
|
import { WidgetPropertyValidationType } from "utils/ValidationFactory";
|
2019-02-10 14:14:58 +00:00
|
|
|
|
2019-09-09 09:08:54 +00:00
|
|
|
class TextWidget extends BaseWidget<TextWidgetProps, WidgetState> {
|
2019-11-19 12:44:58 +00:00
|
|
|
static getPropertyValidationMap(): WidgetPropertyValidationType {
|
|
|
|
|
return {
|
|
|
|
|
text: VALIDATION_TYPES.TEXT,
|
2019-11-22 13:12:39 +00:00
|
|
|
textStyle: VALIDATION_TYPES.TEXT,
|
2019-11-19 12:44:58 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-18 15:10:30 +00:00
|
|
|
getPageView() {
|
2019-02-10 14:14:58 +00:00
|
|
|
return (
|
2019-10-31 05:28:11 +00:00
|
|
|
<TextComponent
|
2019-02-11 18:22:23 +00:00
|
|
|
widgetId={this.props.widgetId}
|
|
|
|
|
key={this.props.widgetId}
|
2019-10-31 05:28:11 +00:00
|
|
|
textStyle={this.props.textStyle}
|
2019-02-11 18:22:23 +00:00
|
|
|
text={this.props.text}
|
2019-12-03 04:41:10 +00:00
|
|
|
isLoading={this.props.isLoading}
|
2019-02-10 14:14:58 +00:00
|
|
|
/>
|
2019-03-21 12:10:32 +00:00
|
|
|
);
|
2019-02-10 14:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getWidgetType(): WidgetType {
|
2019-03-21 12:10:32 +00:00
|
|
|
return "TEXT_WIDGET";
|
2019-02-10 14:14:58 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-13 10:45:49 +00:00
|
|
|
export type TextStyle = "BODY" | "HEADING" | "LABEL" | "SUB_TEXT";
|
2019-09-12 08:11:25 +00:00
|
|
|
|
2019-09-09 09:08:54 +00:00
|
|
|
export interface TextWidgetProps extends WidgetProps {
|
2019-03-21 12:10:32 +00:00
|
|
|
text?: string;
|
2019-10-31 05:28:11 +00:00
|
|
|
textStyle: TextStyle;
|
2019-12-03 04:41:10 +00:00
|
|
|
isLoading: boolean;
|
2019-02-10 14:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2019-03-21 12:10:32 +00:00
|
|
|
export default TextWidget;
|