Skip to content

Commit 47b82df

Browse files
committed
feat(blueprint): added typings to components
1 parent 13fd020 commit 47b82df

21 files changed

+394
-4
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { UseFieldApiComponentConfig, AnyObject } from "@data-driven-forms/react-form-renderer";
2+
import { ReactNode } from "react";
3+
import { ICheckboxProps } from '@blueprintjs/core';
4+
import { FormGroupProps } from "./form-group";
5+
6+
export interface CheckboxOption extends AnyObject {
7+
value?: any;
8+
label: ReactNode;
9+
}
10+
11+
export interface CheckboxProps extends ICheckboxProps {
12+
options?: CheckboxOption[];
13+
}
14+
15+
declare const Checkbox: React.ComponentType<CheckboxProps & FormGroupProps & UseFieldApiComponentConfig>;
16+
17+
export default Checkbox;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { ComponentTypes } from '@data-driven-forms/react-form-renderer';
2+
3+
interface Components {
4+
TextField: React.ComponentType;
5+
Textarea: React.ComponentType;
6+
Select: React.ComponentType;
7+
Checkbox: React.ComponentType;
8+
Radio: React.ComponentType;
9+
Switch: React.ComponentType;
10+
DatePicker: React.ComponentType;
11+
TimePicker: React.ComponentType;
12+
PlainText: React.ComponentType;
13+
SubForm: React.ComponentType;
14+
Wizard: React.ComponentType;
15+
DualListSelect: React.ComponentType;
16+
Slider: React.ComponentType;
17+
}
18+
19+
interface componentMapper {
20+
[ComponentTypes.TEXT_FIELD]: React.ComponentType;
21+
[ComponentTypes.TEXTAREA]: React.ComponentType;
22+
[ComponentTypes.SELECT]: React.ComponentType;
23+
[ComponentTypes.CHECKBOX]: React.ComponentType;
24+
[ComponentTypes.SUB_FORM]: React.ComponentType;
25+
[ComponentTypes.RADIO]: React.ComponentType;
26+
[ComponentTypes.TABS]: React.ComponentType;
27+
[ComponentTypes.DATE_PICKER]: React.ComponentType;
28+
[ComponentTypes.TIME_PICKER]: React.ComponentType;
29+
[ComponentTypes.SWITCH]: React.ComponentType;
30+
[ComponentTypes.PLAIN_TEXT]: React.ComponentType;
31+
[ComponentTypes.WIZARD]: React.ComponentType;
32+
[ComponentTypes.FIELD_ARRAY]: React.ComponentType;
33+
[ComponentTypes.DUAL_LIST_SELECT]: React.ComponentType;
34+
[ComponentTypes.SLIDER]: React.ComponentType;
35+
}
36+
37+
declare const componentMapper: componentMapper;
38+
39+
export const components: Components;
40+
41+
export default componentMapper;

packages/blueprint-component-mapper/src/files/component-mapper.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ export const components = {
4646
Switch,
4747
PlainText,
4848
DualListSelect,
49-
Slider
49+
Slider,
50+
Wizard
5051
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { FormGroupProps } from "./form-group";
2+
import { UseFieldApiComponentConfig } from "@data-driven-forms/react-form-renderer";
3+
import { IDatePickerProps } from '@blueprintjs/datetime';
4+
import { IPopoverProps, IButtonProps } from "@blueprintjs/core";
5+
6+
export interface DatePickerValueRenderer {
7+
(value?: string | Date): string;
8+
}
9+
10+
export interface DatePickerProps extends IDatePickerProps {
11+
disabled?: boolean;
12+
valueRenderer?: DatePickerValueRenderer;
13+
PopoverProps?: IPopoverProps;
14+
ButtonProps: IButtonProps;
15+
}
16+
17+
declare const DatePicker: React.ComponentType<DatePickerProps & FormGroupProps & UseFieldApiComponentConfig>
18+
19+
export default DatePicker;

packages/blueprint-component-mapper/src/files/date-picker.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { DatePicker as BDatePicker } from '@blueprintjs/datetime';
77
import FormGroupWrapper from './form-group';
88
import propsCatcher from '../common/props-catcher';
99

10-
const DatePicker = ({ input, className, disabled, placeholder, valueRenderer, PopoverProps, ButtonProps, ...props }) => (
10+
const DatePicker = ({ input, disabled, placeholder, valueRenderer, PopoverProps, ButtonProps, ...props }) => (
1111
<Popover disabled={disabled} {...PopoverProps}>
1212
<Button text={input.value ? valueRenderer(input.value) : placeholder} disabled={disabled} {...ButtonProps} />
1313
<BDatePicker id={input.name} {...propsCatcher(props)} {...input} value={input.value || null} />
@@ -21,7 +21,6 @@ DatePicker.defaultProps = {
2121

2222
DatePicker.propTypes = {
2323
input: PropTypes.object,
24-
className: PropTypes.string,
2524
disabled: PropTypes.bool,
2625
placeholder: PropTypes.node,
2726
valueRenderer: PropTypes.func,
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { FormGroupProps } from "./form-group";
2+
import { UseFieldApiComponentConfig, AnyObject } from "@data-driven-forms/react-form-renderer";
3+
import { ReactNode } from "react";
4+
import { IButtonGroupProps, IButtonProps, IControlGroupProps, IInputGroupProps, IMenuProps, IMenuItemProps } from "@blueprintjs/core";
5+
6+
export interface DualListSelectValue extends AnyObject {
7+
value?: any;
8+
label: ReactNode;
9+
}
10+
11+
export interface DualListSelectProps {
12+
leftTitle?: ReactNode;
13+
rightTitle?: ReactNode;
14+
moveLeftTitle?: ReactNode;
15+
moveRightTitle?: ReactNode;
16+
allToLeft?: boolean;
17+
allToRight?: boolean;
18+
validateOnMount?: boolean;
19+
moveAllLeftTitle?: ReactNode;
20+
moveAllRightTitle?: ReactNode;
21+
noValueTitle?: ReactNode;
22+
noOptionsTitle?: ReactNode;
23+
filterOptionsTitle?: ReactNode;
24+
filterValueTitle?: ReactNode;
25+
filterValueText?: ReactNode;
26+
filterOptionsText?: ReactNode;
27+
leftValues?: DualListSelectValue[];
28+
rightValues?: DualListSelectValue[];
29+
WrapperProps?: React.HTMLProps<HTMLDivElement>;
30+
LeftWrapperProps?: React.HTMLProps<HTMLDivElement>;
31+
RightWrapperProps?: React.HTMLProps<HTMLDivElement>;
32+
ButtonGroupProps?: IButtonGroupProps;
33+
ToRightButtonProps?: IButtonProps;
34+
AllToRightButtonProps?: IButtonProps;
35+
AllToLeftButtonProps?: IButtonProps;
36+
ToLeftButtonProps?: IButtonProps;
37+
LeftControlGroupProps?: IControlGroupProps;
38+
LeftInputGroupProps?: IInputGroupProps;
39+
LeftButtonProps?: IButtonProps;
40+
RightControlGroupProps?: IControlGroupProps;
41+
RightInputGroupProps?: IInputGroupProps;
42+
RightButtonProps?: IButtonProps;
43+
LeftMenuProps?: IMenuProps;
44+
LeftMenuItemProps?: IMenuItemProps;
45+
RightMenuProps?: IMenuProps;
46+
RightMenuItemProps?: IMenuItemProps;
47+
}
48+
49+
declare const DualListSelect: React.ComponentType<DualListSelectProps & FormGroupProps & UseFieldApiComponentConfig>
50+
51+
export default DualListSelect;

packages/blueprint-component-mapper/src/files/dual-list-select.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ DualListInternal.propTypes = {
241241
filterValues: PropTypes.func,
242242
rightValues: PropTypes.array,
243243
handleValuesClick: PropTypes.func,
244-
FormFieldGridProps: PropTypes.object,
245244
WrapperProps: PropTypes.object,
246245
LeftWrapperProps: PropTypes.object,
247246
RightWrapperProps: PropTypes.object,
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { ReactNode } from "react";
2+
import { FieldArrayField } from "@data-driven-forms/react-form-renderer";
3+
import { IButtonProps, IFormGroupProps } from "@blueprintjs/core";
4+
5+
export interface FieldArrayButtonLabels {
6+
add: ReactNode;
7+
remove: ReactNode;
8+
}
9+
10+
export interface FieldArrayProps {
11+
label?: ReactNode;
12+
description?: ReactNode;
13+
fields: FieldArrayField[];
14+
defaultItem?: any;
15+
minItems?: number;
16+
maxItems?: number;
17+
noItemsMessage?: ReactNode;
18+
name: string;
19+
buttonLabels?: FieldArrayButtonLabels;
20+
AddContainerProps?: React.HTMLProps<HTMLDivElement>;
21+
AddButtonProps?: IButtonProps;
22+
RemoveButtonProps?: IButtonProps;
23+
ArrayItemProps?: React.HTMLProps<HTMLDivElement>;
24+
FormGroupProps?: IFormGroupProps;
25+
FieldArrayProps?: React.HTMLProps<HTMLDivElement>;
26+
validateOnMount?: boolean;
27+
helperText?: ReactNode;
28+
isRequired?: boolean;
29+
}
30+
31+
declare const FieldArray: React.ComponentType<FieldArrayProps>;
32+
33+
export default FieldArray;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { UseFieldApiComponentConfig, AnyObject } from "@data-driven-forms/react-form-renderer";
2+
import { IFormGroupProps } from '@blueprintjs/core';
3+
import { ReactNode } from "react";
4+
5+
export interface FormGroupProps extends IFormGroupProps {
6+
isDisabled?: boolean;
7+
FormGroupProps?: IFormGroupProps;
8+
isReadOnly?: boolean;
9+
isRequired?: boolean;
10+
helperText?: ReactNode;
11+
label?: ReactNode;
12+
validateOnMount?: boolean;
13+
description?: ReactNode;
14+
hideLabel?: boolean;
15+
}
16+
17+
export interface FormGroupInternalProps extends FormGroupProps {
18+
meta: AnyObject;
19+
input: AnyObject;
20+
Component: React.ComponentType;
21+
}
22+
23+
export const FormGroupInternal: React.ComponentType<FormGroupInternalProps>;
24+
25+
declare const FormGroup: React.ComponentType<FormGroupProps & UseFieldApiComponentConfig>;
26+
27+
export default FormGroup;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { ReactNode } from "react";
2+
3+
export interface FormTemplateProps {
4+
requiredLabelInfo?: ReactNode;
5+
formWrapperProps?: React.HTMLProps<HTMLFormElement>;
6+
showFormControls?: boolean;
7+
disableSubmit: string[];
8+
}
9+
10+
declare const FormTemplate: React.ComponentType<FormTemplateProps>;
11+
12+
export default FormTemplate;

0 commit comments

Comments
 (0)