Feature/core components

This commit is contained in:
Anirudh Madhavan 2019-03-21 12:10:32 +00:00 committed by Nikhil Nandagopal
parent 96a47a9bb8
commit 32621a7975
24 changed files with 728 additions and 158 deletions

View File

@ -8,6 +8,11 @@ export type WidgetType =
| "INPUT_GROUP_WIDGET"
| "SPINNER_WIDGET"
| "BUTTON_WIDGET"
| "BREADCRUMBS_WIDGET"
| "TAG_INPUT_WIDGET"
| "NUMERIC_INPUT_WIDGET"
| "CHECKBOX_WIDGET"
| "RADIO_GROUP_WIDGET"
export type ContainerOrientation = "HORIZONTAL" | "VERTICAL"
export type PositionType = "ABSOLUTE" | "CONTAINER_DIRECTION"
export type CSSUnit =
@ -27,7 +32,11 @@ export type CSSUnit =
| "vmax"
| "%"
export type RenderMode = "COMPONENT_PANE" | "CANVAS" | "PAGE" | "CANVAS_SELECTED"
export type RenderMode =
| "COMPONENT_PANE"
| "CANVAS"
| "PAGE"
| "CANVAS_SELECTED"
export const RenderModes: { [id: string]: RenderMode } = {
COMPONENT_PANE: "COMPONENT_PANE",

View File

@ -0,0 +1,35 @@
import * as React from "react"
import { IComponentProps } from "./BaseComponent"
import {
Boundary,
Breadcrumbs,
Breadcrumb,
Card,
IBreadcrumbProps
} from "@blueprintjs/core"
import { Container } from "./ContainerComponent"
class BreadcrumbsComponent extends React.Component<IBreadcrumbsComponentProps> {
render() {
return (
<Container {...this.props}>
<Breadcrumbs
collapseFrom={this.props.collapseFrom}
items={this.props.items}
minVisibleItems={this.props.minVisibleItems}
className={this.props.className}
/>
</Container>
)
}
}
export interface IBreadcrumbsComponentProps extends IComponentProps {
width?: number
collapseFrom?: Boundary
className?: string
minVisibleItems?: number
items?: IBreadcrumbProps[]
}
export default BreadcrumbsComponent

View File

@ -1,14 +1,14 @@
import * as React from "react"
import { Button, MaybeElement } from "@blueprintjs/core"
import { ITextComponentProps } from "./TextComponent"
import PositionContainer from "./PositionContainer"
import { Container } from "./ContainerComponent"
class ButtomComponent extends React.Component<IButtonComponentProps> {
class ButtonComponent extends React.Component<IButtonComponentProps> {
render() {
return (
<PositionContainer {...this.props}>
<Container {...this.props}>
<Button text={this.props.text} icon={this.props.icon} />
</PositionContainer>
</Container>
)
}
}
@ -17,4 +17,4 @@ interface IButtonComponentProps extends ITextComponentProps {
icon?: MaybeElement
}
export default ButtomComponent
export default ButtonComponent

View File

@ -1,30 +1,28 @@
import * as React from "react";
import { IComponentProps } from "./BaseComponent";
import PositionContainer from "./PositionContainer";
import { Callout, Intent } from "@blueprintjs/core";
import * as React from "react"
import { IComponentProps } from "./BaseComponent"
import { Callout, Intent } from "@blueprintjs/core"
import { Container } from "./ContainerComponent"
class CalloutComponent extends React.Component<ICalloutComponentProps> {
render() {
return (
<PositionContainer {...this.props}>
<Container {...this.props}>
<Callout
{...this.props}
title={this.props.title ? this.props.title : undefined}
intent={this.props.intent}
>
{this.props.description}
</Callout>
</PositionContainer>
);
</Container>
)
}
}
export interface ICalloutComponentProps extends IComponentProps {
id?: string;
title?: string;
description?: string;
intent?: Intent;
ellipsize?: boolean;
id?: string
title?: string
description?: string
intent?: Intent
ellipsize?: boolean
}
export default CalloutComponent;
export default CalloutComponent

View File

@ -0,0 +1,29 @@
import * as React from "react"
import { IComponentProps } from "./BaseComponent"
import { Checkbox } from "@blueprintjs/core"
import { Container } from "./ContainerComponent"
class CheckboxComponent extends React.Component<ICheckboxComponentProps> {
render() {
return (
<Container {...this.props}>
{this.props.items.map(item => (
<Checkbox
label={item.label}
defaultIndeterminate={item.defaultIndeterminate}
value={item.value}
/>
))}
</Container>
)
}
}
export interface ICheckboxComponentProps extends IComponentProps {
items: Array<{
label: string
defaultIndeterminate: boolean
value: number | string
}>
}
export default CheckboxComponent

View File

@ -3,12 +3,16 @@ import { ContainerOrientation } from "../constants/WidgetConstants"
import styled from "../constants/DefaultTheme"
import React from "react"
const Container = styled("div")<IContainerProps>`
export const Container = styled("div")<IContainerProps>`
display: "flex"
flexDirection: ${(props) => { return props.orientation === "HORIZONTAL" ? "row" : "column" }};
flexDirection: ${props => {
return props.orientation === "HORIZONTAL" ? "row" : "column"
}};
background: ${props => props.style.backgroundColor};
color: ${props => props.theme.primaryColor};
position: ${props => { return props.style.positionType === "ABSOLUTE" ? "absolute" : "relative" }};
position: ${props => {
return props.style.positionType === "ABSOLUTE" ? "absolute" : "relative"
}};
left: ${props => {
return props.style.xPosition + props.style.xPositionUnit
}};
@ -19,25 +23,13 @@ const Container = styled("div")<IContainerProps>`
class ContainerComponent extends BaseComponent<IContainerProps> {
render() {
return (
<Container {...this.props}>
{this.props.children
? this.props.children.map(child => {
return child
})
: undefined}
</Container>
)
return <Container {...this.props}>{this.props.children}</Container>
}
}
export interface IContainerProps extends IComponentProps {
children?: JSX.Element[]
snapColumnSpace: number
snapRowSpace: number
snapColumns: number
snapRows: number
orientation: ContainerOrientation
children?: JSX.Element[] | JSX.Element
orientation?: ContainerOrientation
}
export default ContainerComponent

View File

@ -1,28 +1,27 @@
import * as React from "react";
import { IComponentProps } from "./BaseComponent";
import { Icon, Intent } from "@blueprintjs/core";
import { IconName } from "@blueprintjs/icons";
import PositionContainer from "./PositionContainer";
import * as React from "react"
import { IComponentProps } from "./BaseComponent"
import { Icon, Intent } from "@blueprintjs/core"
import { IconName } from "@blueprintjs/icons"
import { Container } from "./ContainerComponent"
class IconComponent extends React.Component<IIconComponentProps> {
render() {
return (
<PositionContainer {...this.props}>
<Container {...this.props}>
<Icon
icon={this.props.icon}
iconSize={this.props.iconSize}
intent={this.props.intent}
/>
</PositionContainer>
);
</Container>
)
}
}
export interface IIconComponentProps extends IComponentProps {
iconSize?: number;
icon?: IconName;
intent?: Intent;
ellipsize?: boolean;
iconSize?: number
icon?: IconName
intent?: Intent
ellipsize?: boolean
}
export default IconComponent;
export default IconComponent

View File

@ -1,12 +1,11 @@
import * as React from "react";
import { IComponentProps } from "./BaseComponent";
import PositionContainer from "./PositionContainer";
import { IconName, InputGroup, Intent } from "@blueprintjs/core";
import * as React from "react"
import { IComponentProps } from "./BaseComponent"
import { IconName, InputGroup, Intent } from "@blueprintjs/core"
import { Container } from "./ContainerComponent"
class InputGroupComponent extends React.Component<IInputGroupComponentProps> {
render() {
return (
<PositionContainer {...this.props}>
<Container {...this.props}>
<InputGroup
className={this.props.className}
disabled={this.props.disabled}
@ -21,24 +20,24 @@ class InputGroupComponent extends React.Component<IInputGroupComponentProps> {
defaultValue={this.props.defaultValue}
type={this.props.type}
/>
</PositionContainer>
);
</Container>
)
}
}
export interface IInputGroupComponentProps extends IComponentProps {
className?: string;
disabled?: boolean;
large?: boolean;
intent?: Intent;
defaultValue?: string;
leftIcon?: IconName;
rightElement?: JSX.Element;
round?: boolean;
small?: boolean;
type?: string;
value?: string;
placeholder?: string;
className?: string
disabled?: boolean
large?: boolean
intent?: Intent
defaultValue?: string
leftIcon?: IconName
rightElement?: JSX.Element
round?: boolean
small?: boolean
type?: string
value?: string
placeholder?: string
}
export default InputGroupComponent;
export default InputGroupComponent

View File

@ -0,0 +1,60 @@
import * as React from "react"
import { IComponentProps } from "./BaseComponent"
import { Intent, NumericInput, IconName } from "@blueprintjs/core"
import { Container } from "./ContainerComponent"
class NumericInputComponent extends React.Component<
INumericInputComponentProps
> {
render() {
return (
<Container {...this.props}>
<NumericInput
placeholder={this.props.placeholder}
min={this.props.min}
max={this.props.max}
className={this.props.className}
disabled={this.props.disabled}
large={this.props.large}
intent={this.props.intent}
defaultValue={this.props.defaultValue}
leftIcon={this.props.leftIcon}
rightElement={this.props.rightElement}
allowNumericCharactersOnly={this.props.allowNumericCharactersOnly}
fill={this.props.fill}
majorStepSize={this.props.majorStepSize}
minorStepSize={this.props.minorStepSize}
onButtonClick={this.props.onButtonClick}
inputRef={this.props.inputRef}
selectAllOnFocus={this.props.selectAllOnFocus}
selectAllOnIncrement={this.props.selectAllOnIncrement}
stepSize={this.props.stepSize}
/>
</Container>
)
}
}
export interface INumericInputComponentProps extends IComponentProps {
className?: string
disabled?: boolean
large?: boolean
intent?: Intent
defaultValue?: string
leftIcon?: IconName
rightElement?: JSX.Element
allowNumericCharactersOnly?: boolean
fill?: boolean
majorStepSize?: number | null
max?: number
min?: number
minorStepSize?: number | null
onValueChange?: (valueAsNumber: number, valueAsString: string) => void
onButtonClick?: (valueAsNumber: number, valueAsString: string) => void
inputRef?: (ref: HTMLInputElement | null) => any
selectAllOnFocus?: boolean
selectAllOnIncrement?: boolean
stepSize?: number
placeholder?: string
}
export default NumericInputComponent

View File

@ -1,15 +0,0 @@
import { IComponentProps } from "./BaseComponent";
import styled from "../constants/DefaultTheme";
const PositionContainer = styled("div")<IComponentProps>`
color: ${props => props.theme.primaryColor};
position: ${props => props.style.positionType};
left: ${props => {
return props.style.xPosition + props.style.xPositionUnit;
}};
top: ${props => {
return props.style.yPosition + props.style.yPositionUnit;
}};
`;
export default PositionContainer;

View File

@ -0,0 +1,43 @@
import * as React from "react"
import { IComponentProps } from "./BaseComponent"
import { Radio, RadioGroup, IOptionProps } from "@blueprintjs/core"
import { Container } from "./ContainerComponent"
class RadioGroupComponent extends React.Component<IRadioGroupComponentProps> {
render() {
return (
<Container {...this.props}>
<RadioGroup
inline={this.props.inline}
label={this.props.label}
name={this.props.name}
onChange={this.props.handleRadioChange}
selectedValue={this.props.selectedValue}
disabled={this.props.disabled}
className={this.props.className}
options={this.props.options}
>
{this.props.items.map(item => (
<Radio label={item.label} value={item.value} />
))}
</RadioGroup>
</Container>
)
}
}
export interface IRadioGroupComponentProps extends IComponentProps {
label: string
inline: boolean
selectedValue: string | number
handleRadioChange: (event: React.FormEvent<HTMLInputElement>) => void
disabled: boolean
className: string
name: string
options: IOptionProps[]
items: Array<{
label: string
value: number | string
}>
}
export default RadioGroupComponent

View File

@ -1,27 +1,26 @@
import * as React from "react";
import { IComponentProps } from "./BaseComponent";
import PositionContainer from "./PositionContainer";
import { Spinner, Intent } from "@blueprintjs/core";
import * as React from "react"
import { IComponentProps } from "./BaseComponent"
import { Spinner, Intent } from "@blueprintjs/core"
import { Container } from "./ContainerComponent"
class SpinnerComponent extends React.Component<ISpinnerComponentProps> {
render() {
return (
<PositionContainer {...this.props}>
<Container {...this.props}>
<Spinner
size={this.props.size}
value={this.props.value}
intent={this.props.intent}
/>
</PositionContainer>
);
</Container>
)
}
}
export interface ISpinnerComponentProps extends IComponentProps {
size?: number;
value?: number;
intent?: Intent;
ellipsize?: boolean;
size?: number
value?: number
intent?: Intent
}
export default SpinnerComponent;
export default SpinnerComponent

View File

@ -0,0 +1,35 @@
import * as React from "react"
import { IComponentProps } from "./BaseComponent"
import { Intent, ITagProps, TagInput, HTMLInputProps } from "@blueprintjs/core"
import { Container } from "./ContainerComponent"
class TagInputComponent extends React.Component<ITagInputComponentProps> {
render() {
return (
<Container {...this.props}>
<TagInput
placeholder={this.props.placeholder}
values={this.props.values}
/>
</Container>
)
}
}
export interface ITagInputComponentProps extends IComponentProps {
addOnPaste?: boolean
className?: string
disabled?: boolean
fill?: boolean
inputProps?: HTMLInputProps
inputValue?: string //Controlled value of the <input> element.
intent?: Intent
large?: boolean //Whether the tag input should use a large size
onInputChange?: React.FormEventHandler<HTMLInputElement>
placeholder?: string
rightElement?: JSX.Element
separator?: string | RegExp | false
tagProps?: ITagProps
values?: string[] //Required field
}
export default TagInputComponent

View File

@ -1,16 +1,23 @@
import * as React from "react"
import { IComponentProps } from "./BaseComponent"
import PositionContainer from "./PositionContainer";
import { Text } from "@blueprintjs/core"
import { Container } from "./ContainerComponent"
class TextComponent extends React.Component<ITextComponentProps> {
render() {
return <PositionContainer {...this.props}>{this.props.text}</PositionContainer>
return (
<Container {...this.props}>
<Text ellipsize={this.props.ellipsize} tagName={this.props.tagName}>
{this.props.text}
</Text>
</Container>
)
}
}
export interface ITextComponentProps extends IComponentProps {
text?: string
ellipsize?: boolean
tagName?: keyof JSX.IntrinsicElements
}
export default TextComponent

View File

@ -1,10 +1,10 @@
import { CanvasReduxState } from "../reducers/uiReducers/canvasReducer";
import { IWidgetProps } from "../widgets/BaseWidget";
import { CanvasReduxState } from "../reducers/uiReducers/canvasReducer"
import { IWidgetProps } from "../widgets/BaseWidget"
import ContainerWidget, {
IContainerWidgetProps
} from "../widgets/ContainerWidget";
import { RenderModes } from "../constants/WidgetConstants";
import { Colors } from "../constants/StyleConstants";
} from "../widgets/ContainerWidget"
import { RenderModes } from "../constants/WidgetConstants"
import { Colors } from "../constants/StyleConstants"
const CanvasResponse: IContainerWidgetProps<any> = {
widgetId: "0",
@ -68,9 +68,9 @@ const CanvasResponse: IContainerWidgetProps<any> = {
widgetId: "5",
widgetType: "ICON_WIDGET",
topRow: 4,
leftColumn: 4,
leftColumn: 2,
bottomRow: 5,
rightColumn: 5,
rightColumn: 3,
icon: "globe",
iconSize: "20",
intent: "warning",
@ -83,10 +83,96 @@ const CanvasResponse: IContainerWidgetProps<any> = {
leftColumn: 6,
bottomRow: 5,
rightColumn: 5,
size: 20
},
{
widgetId: "6",
widgetType: "BREADCRUMBS_WIDGET",
topRow: 6,
leftColumn: 2,
bottomRow: 5,
rightColumn: 5,
width: "100%",
collapseFrom: "start",
className: "breadcrumbs",
size: 20,
renderMode: RenderModes.CANVAS,
items: [
{ icon: "folder-close", text: "All files" },
{ icon: "folder-close", text: "Users" },
{ icon: "folder-close", text: "Janet" },
{ href: "#", icon: "folder-close", text: "Photos" },
{ href: "#", icon: "folder-close", text: "Wednesday" },
{ icon: "document", text: "image.jpg" }
]
},
{
widgetId: "7",
widgetType: "TAG_INPUT_WIDGET",
topRow: 7,
leftColumn: 1,
bottomRow: 5,
rightColumn: 5,
palceholder: "Lorem, Ipsum",
values: ["abx", "somf", "soke"],
renderMode: RenderModes.CANVAS
},
{
widgetId: "8",
widgetType: "NUMERIC_INPUT_WIDGET",
topRow: 4,
leftColumn: 1,
bottomRow: 5,
rightColumn: 5,
palceholder: "Numeric input",
allowNumericCharactersOnly: true,
renderMode: RenderModes.CANVAS
},
{
widgetId: "8",
widgetType: "CHECKBOX_WIDGET",
topRow: 6,
leftColumn: 1,
bottomRow: 5,
rightColumn: 5,
items: [
{
label: "a",
value: 1
},
{
label: "b",
value: 2
},
{
label: "c",
value: 3
}
]
},
{
widgetId: "9",
widgetType: "RADIO_GROUP_WIDGET",
topRow: 6,
leftColumn: 1,
bottomRow: 5,
rightColumn: 5,
items: [
{
label: "a",
value: 1
},
{
label: "b",
value: 2
},
{
label: "c",
value: 3
}
]
}
]
};
}
export default CanvasResponse;
export default CanvasResponse

View File

@ -8,21 +8,21 @@ const WidgetPaneResponse: WidgetPaneReduxState = {
text: "Lorem Ipsum",
renderMode: RenderModes.COMPONENT_PANE,
bottomRow: 50,
rightColumn: 200,
rightColumn: 200
},
{
widgetType: "TEXT_WIDGET",
text: "Lorem Ipsum",
renderMode: RenderModes.COMPONENT_PANE,
bottomRow: 50,
rightColumn: 200,
rightColumn: 200
},
{
widgetType: "SPINNER_WIDGET",
renderMode: RenderModes.COMPONENT_PANE,
backgroundColor: "#434343",
bottomRow: 50,
rightColumn: 200,
rightColumn: 200
}
]
}

View File

@ -1,19 +1,28 @@
import BaseWidget, { IWidgetProps } from "../widgets/BaseWidget";
import BaseWidget, { IWidgetProps } from "../widgets/BaseWidget"
import ContainerWidget, {
IContainerWidgetProps
} from "../widgets/ContainerWidget";
import TextWidget, { ITextWidgetProps } from "../widgets/TextWidget";
} from "../widgets/ContainerWidget"
import TextWidget, { ITextWidgetProps } from "../widgets/TextWidget"
import InputGroupWidget, {
IInputGroupWidgetProps
} from "../widgets/InputGroupWidget";
import CalloutWidget, { ICalloutWidgetProps } from "../widgets/CalloutWidget";
import IconWidget, { IIconWidgetProps } from "../widgets/IconWidget";
import SpinnerWidget, { ISpinnerWidgetProps } from "../widgets/SpinnerWidget";
import WidgetFactory from "./WidgetFactory";
import React from "react";
import ButtonWidget, {
IButtonWidgetProps
} from "../widgets/ButtonWidget"
} from "../widgets/InputGroupWidget"
import CalloutWidget, { ICalloutWidgetProps } from "../widgets/CalloutWidget"
import IconWidget, { IIconWidgetProps } from "../widgets/IconWidget"
import SpinnerWidget, { ISpinnerWidgetProps } from "../widgets/SpinnerWidget"
import BreadcrumbsWidget, {
IBreadcrumbsWidgetProps
} from "../widgets/BreadcrumbsWidget"
import TagInputWidget, { ITagInputWidgetProps } from "../widgets/TagInputWidget"
import NumericInputWidget, {
INumericInputWidgetProps
} from "../widgets/NumericInputWidget"
import CheckboxWidget, { ICheckboxWidgetProps } from "../widgets/CheckboxWidget"
import RadioGroupWidget, {
IRadioGroupWidgetProps
} from "../widgets/RadioGroupWidget"
import WidgetFactory from "./WidgetFactory"
import React from "react"
import ButtonWidget, { IButtonWidgetProps } from "../widgets/ButtonWidget"
class WidgetBuilderRegistry {
static registerWidgetBuilders() {
@ -21,46 +30,76 @@ class WidgetBuilderRegistry {
buildWidget(
widgetData: IContainerWidgetProps<IWidgetProps>
): JSX.Element {
return <ContainerWidget {...widgetData} />;
return <ContainerWidget {...widgetData} />
}
});
})
WidgetFactory.registerWidgetBuilder("TEXT_WIDGET", {
buildWidget(widgetData: ITextWidgetProps): JSX.Element {
return <TextWidget {...widgetData} />;
return <TextWidget {...widgetData} />
}
});
})
WidgetFactory.registerWidgetBuilder("BUTTON_WIDGET", {
buildWidget(widgetData: IButtonWidgetProps): JSX.Element {
return <ButtonWidget {...widgetData} />;
return <ButtonWidget {...widgetData} />
}
});
})
WidgetFactory.registerWidgetBuilder("CALLOUT_WIDGET", {
buildWidget(widgetData: ICalloutWidgetProps): JSX.Element {
return <CalloutWidget {...widgetData} />;
return <CalloutWidget {...widgetData} />
}
});
})
WidgetFactory.registerWidgetBuilder("ICON_WIDGET", {
buildWidget(widgetData: IIconWidgetProps): JSX.Element {
return <IconWidget {...widgetData} />;
return <IconWidget {...widgetData} />
}
});
})
WidgetFactory.registerWidgetBuilder("SPINNER_WIDGET", {
buildWidget(widgetData: ISpinnerWidgetProps): JSX.Element {
return <SpinnerWidget {...widgetData} />;
return <SpinnerWidget {...widgetData} />
}
});
})
WidgetFactory.registerWidgetBuilder("INPUT_GROUP_WIDGET", {
buildWidget(widgetData: IInputGroupWidgetProps): JSX.Element {
return <InputGroupWidget {...widgetData} />;
return <InputGroupWidget {...widgetData} />
}
});
})
WidgetFactory.registerWidgetBuilder("BREADCRUMBS_WIDGET", {
buildWidget(widgetData: IBreadcrumbsWidgetProps): JSX.Element {
return <BreadcrumbsWidget {...widgetData} />
}
})
WidgetFactory.registerWidgetBuilder("TAG_INPUT_WIDGET", {
buildWidget(widgetData: ITagInputWidgetProps): JSX.Element {
return <TagInputWidget {...widgetData} />
}
})
WidgetFactory.registerWidgetBuilder("NUMERIC_INPUT_WIDGET", {
buildWidget(widgetData: INumericInputWidgetProps): JSX.Element {
return <NumericInputWidget {...widgetData} />
}
})
WidgetFactory.registerWidgetBuilder("CHECKBOX_WIDGET", {
buildWidget(widgetData: ICheckboxWidgetProps): JSX.Element {
return <CheckboxWidget {...widgetData} />
}
})
WidgetFactory.registerWidgetBuilder("RADIO_GROUP_WIDGET", {
buildWidget(widgetData: IRadioGroupWidgetProps): JSX.Element {
return <RadioGroupWidget {...widgetData} />
}
})
}
}
export default WidgetBuilderRegistry;
export default WidgetBuilderRegistry

View File

@ -0,0 +1,43 @@
import * as React from "react"
import BaseWidget, { IWidgetProps, IWidgetState } from "./BaseWidget"
import { WidgetType, CSSUnits } from "../constants/WidgetConstants"
import { Boundary, IBreadcrumbProps } from "@blueprintjs/core"
import BreadcrumbsComponent from "../editorComponents/BreadcrumbsComponent"
import _ from "lodash"
class BreadcrumbsWidget extends BaseWidget<
IBreadcrumbsWidgetProps,
IWidgetState
> {
constructor(widgetProps: IBreadcrumbsWidgetProps) {
super(widgetProps)
}
getPageView() {
return (
<BreadcrumbsComponent
style={this.getPositionStyle()}
widgetId={this.props.widgetId}
key={this.props.widgetId}
collapseFrom={this.props.collapseFrom}
items={this.props.items}
minVisibleItems={this.props.minVisibleItems}
className={this.props.className}
/>
)
}
getWidgetType(): WidgetType {
return "BREADCRUMBS_WIDGET"
}
}
export interface IBreadcrumbsWidgetProps extends IWidgetProps {
width?: number
collapseFrom?: Boundary
className?: string
minVisibleItems?: number
items?: IBreadcrumbProps[]
}
export default BreadcrumbsWidget

View File

@ -0,0 +1,38 @@
import * as React from "react"
import BaseWidget, { IWidgetProps, IWidgetState } from "./BaseWidget"
import { WidgetType, CSSUnits } from "../constants/WidgetConstants"
import { Icon, Intent } from "@blueprintjs/core"
import { IconName } from "@blueprintjs/icons"
import CheckboxComponent from "../editorComponents/CheckboxComponent"
import _ from "lodash"
class CheckboxWidget extends BaseWidget<ICheckboxWidgetProps, IWidgetState> {
constructor(widgetProps: ICheckboxWidgetProps) {
super(widgetProps)
}
getPageView() {
return (
<CheckboxComponent
style={this.getPositionStyle()}
widgetId={this.props.widgetId}
key={this.props.widgetId}
items={this.props.items}
/>
)
}
getWidgetType(): WidgetType {
return "ICON_WIDGET"
}
}
export interface ICheckboxWidgetProps extends IWidgetProps {
items: Array<{
label: string
defaultIndeterminate: boolean
value: number | string
}>
}
export default CheckboxWidget

View File

@ -55,10 +55,6 @@ class ContainerWidget extends BaseWidget<
...this.getPositionStyle(),
backgroundColor: this.props.backgroundColor
}}
snapColumnSpace={this.snapColumnSpace}
snapRowSpace={this.snapRowSpace}
snapColumns={this.props.snapColumns || DEFAULT_NUM_COLS}
snapRows={this.props.snapRows || DEFAULT_NUM_ROWS}
orientation={this.props.orientation || "VERTICAL"}
>
{_.map(this.props.children, this.renderChildWidget)}

View File

@ -0,0 +1,73 @@
import * as React from "react"
import BaseWidget, { IWidgetProps, IWidgetState } from "./BaseWidget"
import { WidgetType } from "../constants/WidgetConstants"
import NumericInputComponent from "../editorComponents/NumericInputComponent"
import { Intent, IconName } from "@blueprintjs/core"
import _ from "lodash"
class NumericInputWidget extends BaseWidget<
INumericInputWidgetProps,
IWidgetState
> {
constructor(widgetProps: INumericInputWidgetProps) {
super(widgetProps)
}
getPageView() {
return (
<NumericInputComponent
style={this.getPositionStyle()}
widgetId={this.props.widgetId}
key={this.props.widgetId}
placeholder="Enter a number..."
min={this.props.min}
max={this.props.max}
className={this.props.className}
disabled={this.props.disabled}
large={this.props.large}
intent={this.props.intent}
defaultValue={this.props.defaultValue}
leftIcon={this.props.leftIcon}
rightElement={this.props.rightElement}
allowNumericCharactersOnly={this.props.allowNumericCharactersOnly}
fill={this.props.fill}
majorStepSize={this.props.majorStepSize}
minorStepSize={this.props.minorStepSize}
onButtonClick={this.props.onButtonClick}
inputRef={this.props.inputRef}
selectAllOnFocus={this.props.selectAllOnFocus}
selectAllOnIncrement={this.props.selectAllOnIncrement}
stepSize={this.props.stepSize}
/>
)
}
getWidgetType(): WidgetType {
return "NUMERIC_INPUT_WIDGET"
}
}
export interface INumericInputWidgetProps extends IWidgetProps {
className?: string
disabled?: boolean
large?: boolean
intent?: Intent
defaultValue?: string
leftIcon?: IconName
rightElement?: JSX.Element
allowNumericCharactersOnly?: boolean
fill?: boolean
majorStepSize?: number | null
max?: number
min?: number
minorStepSize?: number | null
onValueChange?: (valueAsNumber: number, valueAsString: string) => void
onButtonClick?: (valueAsNumber: number, valueAsString: string) => void
inputRef?: (ref: HTMLInputElement | null) => any
selectAllOnFocus?: boolean
selectAllOnIncrement?: boolean
stepSize?: number
placeholder?: string
}
export default NumericInputWidget

View File

@ -0,0 +1,55 @@
import * as React from "react"
import BaseWidget, { IWidgetProps, IWidgetState } from "./BaseWidget"
import { WidgetType, CSSUnits } from "../constants/WidgetConstants"
import RadioGroupComponent from "../editorComponents/RadioGroupComponent"
import { IOptionProps } from "@blueprintjs/core"
import _ from "lodash"
class RadioButtonWidget extends BaseWidget<
IRadioGroupWidgetProps,
IWidgetState
> {
constructor(widgetProps: IRadioGroupWidgetProps) {
super(widgetProps)
}
getPageView() {
return (
<RadioGroupComponent
style={this.getPositionStyle()}
widgetId={this.props.widgetId}
key={this.props.widgetId}
inline={this.props.inline}
label={this.props.label}
name={this.props.name}
handleRadioChange={this.props.handleRadioChange}
selectedValue={this.props.selectedValue}
items={this.props.items}
disabled={this.props.disabled}
className={this.props.className}
options={this.props.options}
/>
)
}
getWidgetType(): WidgetType {
return "RADIO_GROUP_WIDGET"
}
}
export interface IRadioGroupWidgetProps extends IWidgetProps {
label: string
inline: boolean
selectedValue: string | number
handleRadioChange: (event: React.FormEvent<HTMLInputElement>) => void
disabled: boolean
className: string
name: string
options: IOptionProps[]
items: Array<{
label: string
value: number | string
}>
}
export default RadioButtonWidget

View File

@ -0,0 +1,48 @@
import * as React from "react";
import BaseWidget, { IWidgetProps, IWidgetState } from "./BaseWidget";
import { WidgetType, CSSUnits } from "../constants/WidgetConstants";
import TagInputComponent from "../editorComponents/TagInputComponent";
import { Intent, ITagProps, TagInput, HTMLInputProps } from "@blueprintjs/core";
import _ from "lodash";
class TagInputWidget extends BaseWidget<ITagInputWidgetProps, IWidgetState> {
constructor(widgetProps: ITagInputWidgetProps) {
super(widgetProps);
}
getPageView() {
return (
<TagInputComponent
widgetId={this.props.widgetId}
key={this.props.widgetId}
style={this.getPositionStyle()}
placeholder={this.props.placeholder}
values={this.props.values}
/>
);
}
getWidgetType(): WidgetType {
return "TAG_INPUT_WIDGET";
}
}
export interface ITagInputWidgetProps extends IWidgetProps {
addOnPaste?: boolean;
className?: string;
disabled?: boolean;
fill?: boolean;
inputProps?: HTMLInputProps;
inputValue?: string; //Controlled value of the <input> element.
intent?: Intent;
large?: boolean; //Whether the tag input should use a large size
onInputChange?: React.FormEventHandler<HTMLInputElement>;
placeholder?: string;
rightElement?: JSX.Element;
separator?: string | RegExp | false;
tagProps?: ITagProps;
values?: string[]; //Required field
}
export default TagInputWidget;

View File

@ -1,12 +1,12 @@
import * as React from "react"
import BaseWidget, { IWidgetProps, IWidgetState } from "./BaseWidget"
import { WidgetType, CSSUnits } from "../constants/WidgetConstants"
import TextComponent from "../editorComponents/TextComponent"
import _ from "lodash"
import * as React from "react";
import BaseWidget, { IWidgetProps, IWidgetState } from "./BaseWidget";
import { WidgetType, CSSUnits } from "../constants/WidgetConstants";
import TextComponent from "../editorComponents/TextComponent";
import _ from "lodash";
class TextWidget extends BaseWidget<ITextWidgetProps, IWidgetState> {
constructor(widgetProps: ITextWidgetProps) {
super(widgetProps)
super(widgetProps);
}
getPageView() {
@ -16,18 +16,20 @@ class TextWidget extends BaseWidget<ITextWidgetProps, IWidgetState> {
widgetId={this.props.widgetId}
key={this.props.widgetId}
text={this.props.text}
tagName={this.props.tagName}
/>
)
);
}
getWidgetType(): WidgetType {
return "TEXT_WIDGET"
return "TEXT_WIDGET";
}
}
export interface ITextWidgetProps extends IWidgetProps {
text?: string
ellipsize?: boolean
text?: string;
ellipsize?: boolean;
tagName?: keyof JSX.IntrinsicElements;
}
export default TextWidget
export default TextWidget;