Skip to content

Commit

Permalink
redactor config node structure, restore external props for config com…
Browse files Browse the repository at this point in the history
…ponents, add HOC function
  • Loading branch information
VasilyStrelyaev committed Aug 20, 2024
1 parent cdd4579 commit b4602a5
Show file tree
Hide file tree
Showing 83 changed files with 5,608 additions and 1,397 deletions.
8 changes: 6 additions & 2 deletions packages/devextreme-react/src/accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import dxAccordion, {
Properties
} from "devextreme/ui/accordion";

import { Component as BaseComponent, IHtmlOptions, ComponentRef } from "./core/component";
import { Component as BaseComponent, IHtmlOptions, ComponentRef, NestedComponentMeta } from "./core/component";
import NestedOption from "./core/nested-option";

import type { dxAccordionItem, ContentReadyEvent, DisposingEvent, InitializedEvent, ItemClickEvent, ItemContextMenuEvent, ItemHoldEvent, ItemRenderedEvent, ItemTitleClickEvent } from "devextreme/ui/accordion";
Expand Down Expand Up @@ -124,7 +124,7 @@ type IItemProps = React.PropsWithChildren<{
titleRender?: (...params: any) => React.ReactNode;
titleComponent?: React.ComponentType<any>;
}>
const Item = (props: IItemProps) => {
const _componentItem = (props: IItemProps) => {
return React.createElement(NestedOption<IItemProps>, {
...props,
elementDescriptor: {
Expand All @@ -143,6 +143,10 @@ const Item = (props: IItemProps) => {
});
};

const Item = Object.assign<typeof _componentItem, NestedComponentMeta>(_componentItem, {
componentType: "option",
});

export default Accordion;
export {
Accordion,
Expand Down
8 changes: 6 additions & 2 deletions packages/devextreme-react/src/action-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import dxActionSheet, {
Properties
} from "devextreme/ui/action_sheet";

import { Component as BaseComponent, IHtmlOptions, ComponentRef } from "./core/component";
import { Component as BaseComponent, IHtmlOptions, ComponentRef, NestedComponentMeta } from "./core/component";
import NestedOption from "./core/nested-option";

import type { dxActionSheetItem, CancelClickEvent, ContentReadyEvent, DisposingEvent, InitializedEvent, ItemClickEvent, ItemContextMenuEvent, ItemHoldEvent, ItemRenderedEvent } from "devextreme/ui/action_sheet";
Expand Down Expand Up @@ -106,7 +106,7 @@ type IItemProps = React.PropsWithChildren<{
render?: (...params: any) => React.ReactNode;
component?: React.ComponentType<any>;
}>
const Item = (props: IItemProps) => {
const _componentItem = (props: IItemProps) => {
return React.createElement(NestedOption<IItemProps>, {
...props,
elementDescriptor: {
Expand All @@ -121,6 +121,10 @@ const Item = (props: IItemProps) => {
});
};

const Item = Object.assign<typeof _componentItem, NestedComponentMeta>(_componentItem, {
componentType: "option",
});

export default ActionSheet;
export {
ActionSheet,
Expand Down
98 changes: 81 additions & 17 deletions packages/devextreme-react/src/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import dxAutocomplete, {
Properties
} from "devextreme/ui/autocomplete";

import { Component as BaseComponent, IHtmlOptions, ComponentRef } from "./core/component";
import { Component as BaseComponent, IHtmlOptions, ComponentRef, NestedComponentMeta } from "./core/component";
import NestedOption from "./core/nested-option";

import type { ChangeEvent, ClosedEvent, ContentReadyEvent, CopyEvent, CutEvent, DisposingEvent, EnterKeyEvent, FocusInEvent, FocusOutEvent, InitializedEvent, InputEvent, ItemClickEvent, KeyDownEvent, KeyUpEvent, OpenedEvent, PasteEvent, ValueChangedEvent } from "devextreme/ui/autocomplete";
Expand Down Expand Up @@ -131,7 +131,7 @@ type IAnimationProps = React.PropsWithChildren<{
hide?: AnimationConfig;
show?: AnimationConfig;
}>
const Animation = (props: IAnimationProps) => {
const _componentAnimation = (props: IAnimationProps) => {
return React.createElement(NestedOption<IAnimationProps>, {
...props,
elementDescriptor: {
Expand All @@ -144,13 +144,17 @@ const Animation = (props: IAnimationProps) => {
});
};

const Animation = Object.assign<typeof _componentAnimation, NestedComponentMeta>(_componentAnimation, {
componentType: "option",
});

// owners:
// Position
type IAtProps = React.PropsWithChildren<{
x?: "center" | "left" | "right";
y?: "bottom" | "center" | "top";
}>
const At = (props: IAtProps) => {
const _componentAt = (props: IAtProps) => {
return React.createElement(NestedOption<IAtProps>, {
...props,
elementDescriptor: {
Expand All @@ -159,13 +163,17 @@ const At = (props: IAtProps) => {
});
};

const At = Object.assign<typeof _componentAt, NestedComponentMeta>(_componentAt, {
componentType: "option",
});

// owners:
// Position
type IBoundaryOffsetProps = React.PropsWithChildren<{
x?: number;
y?: number;
}>
const BoundaryOffset = (props: IBoundaryOffsetProps) => {
const _componentBoundaryOffset = (props: IBoundaryOffsetProps) => {
return React.createElement(NestedOption<IBoundaryOffsetProps>, {
...props,
elementDescriptor: {
Expand All @@ -174,14 +182,18 @@ const BoundaryOffset = (props: IBoundaryOffsetProps) => {
});
};

const BoundaryOffset = Object.assign<typeof _componentBoundaryOffset, NestedComponentMeta>(_componentBoundaryOffset, {
componentType: "option",
});

// owners:
// Autocomplete
type IButtonProps = React.PropsWithChildren<{
location?: "after" | "before";
name?: string;
options?: dxButtonOptions;
}>
const Button = (props: IButtonProps) => {
const _componentButton = (props: IButtonProps) => {
return React.createElement(NestedOption<IButtonProps>, {
...props,
elementDescriptor: {
Expand All @@ -194,13 +206,17 @@ const Button = (props: IButtonProps) => {
});
};

const Button = Object.assign<typeof _componentButton, NestedComponentMeta>(_componentButton, {
componentType: "option",
});

// owners:
// Position
type ICollisionProps = React.PropsWithChildren<{
x?: "fit" | "flip" | "flipfit" | "none";
y?: "fit" | "flip" | "flipfit" | "none";
}>
const Collision = (props: ICollisionProps) => {
const _componentCollision = (props: ICollisionProps) => {
return React.createElement(NestedOption<ICollisionProps>, {
...props,
elementDescriptor: {
Expand All @@ -209,6 +225,10 @@ const Collision = (props: ICollisionProps) => {
});
};

const Collision = Object.assign<typeof _componentCollision, NestedComponentMeta>(_componentCollision, {
componentType: "option",
});

// owners:
// Autocomplete
type IDropDownOptionsProps = React.PropsWithChildren<{
Expand Down Expand Up @@ -278,7 +298,7 @@ type IDropDownOptionsProps = React.PropsWithChildren<{
titleRender?: (...params: any) => React.ReactNode;
titleComponent?: React.ComponentType<any>;
}>
const DropDownOptions = (props: IDropDownOptionsProps) => {
const _componentDropDownOptions = (props: IDropDownOptionsProps) => {
return React.createElement(NestedOption<IDropDownOptionsProps>, {
...props,
elementDescriptor: {
Expand Down Expand Up @@ -307,6 +327,10 @@ const DropDownOptions = (props: IDropDownOptionsProps) => {
});
};

const DropDownOptions = Object.assign<typeof _componentDropDownOptions, NestedComponentMeta>(_componentDropDownOptions, {
componentType: "option",
});

// owners:
// Hide
type IFromProps = React.PropsWithChildren<{
Expand All @@ -316,7 +340,7 @@ type IFromProps = React.PropsWithChildren<{
scale?: number;
top?: number;
}>
const From = (props: IFromProps) => {
const _componentFrom = (props: IFromProps) => {
return React.createElement(NestedOption<IFromProps>, {
...props,
elementDescriptor: {
Expand All @@ -328,6 +352,10 @@ const From = (props: IFromProps) => {
});
};

const From = Object.assign<typeof _componentFrom, NestedComponentMeta>(_componentFrom, {
componentType: "option",
});

// owners:
// Animation
type IHideProps = React.PropsWithChildren<{
Expand All @@ -342,7 +370,7 @@ type IHideProps = React.PropsWithChildren<{
to?: AnimationState;
type?: "css" | "fade" | "fadeIn" | "fadeOut" | "pop" | "slide" | "slideIn" | "slideOut";
}>
const Hide = (props: IHideProps) => {
const _componentHide = (props: IHideProps) => {
return React.createElement(NestedOption<IHideProps>, {
...props,
elementDescriptor: {
Expand All @@ -355,6 +383,10 @@ const Hide = (props: IHideProps) => {
});
};

const Hide = Object.assign<typeof _componentHide, NestedComponentMeta>(_componentHide, {
componentType: "option",
});

// owners:
// Autocomplete
type IItemProps = React.PropsWithChildren<{
Expand All @@ -366,7 +398,7 @@ type IItemProps = React.PropsWithChildren<{
render?: (...params: any) => React.ReactNode;
component?: React.ComponentType<any>;
}>
const Item = (props: IItemProps) => {
const _componentItem = (props: IItemProps) => {
return React.createElement(NestedOption<IItemProps>, {
...props,
elementDescriptor: {
Expand All @@ -381,13 +413,17 @@ const Item = (props: IItemProps) => {
});
};

const Item = Object.assign<typeof _componentItem, NestedComponentMeta>(_componentItem, {
componentType: "option",
});

// owners:
// Position
type IMyProps = React.PropsWithChildren<{
x?: "center" | "left" | "right";
y?: "bottom" | "center" | "top";
}>
const My = (props: IMyProps) => {
const _componentMy = (props: IMyProps) => {
return React.createElement(NestedOption<IMyProps>, {
...props,
elementDescriptor: {
Expand All @@ -396,13 +432,17 @@ const My = (props: IMyProps) => {
});
};

const My = Object.assign<typeof _componentMy, NestedComponentMeta>(_componentMy, {
componentType: "option",
});

// owners:
// Position
type IOffsetProps = React.PropsWithChildren<{
x?: number;
y?: number;
}>
const Offset = (props: IOffsetProps) => {
const _componentOffset = (props: IOffsetProps) => {
return React.createElement(NestedOption<IOffsetProps>, {
...props,
elementDescriptor: {
Expand All @@ -411,6 +451,10 @@ const Offset = (props: IOffsetProps) => {
});
};

const Offset = Object.assign<typeof _componentOffset, NestedComponentMeta>(_componentOffset, {
componentType: "option",
});

// owners:
// Button
type IOptionsProps = React.PropsWithChildren<{
Expand Down Expand Up @@ -442,7 +486,7 @@ type IOptionsProps = React.PropsWithChildren<{
render?: (...params: any) => React.ReactNode;
component?: React.ComponentType<any>;
}>
const Options = (props: IOptionsProps) => {
const _componentOptions = (props: IOptionsProps) => {
return React.createElement(NestedOption<IOptionsProps>, {
...props,
elementDescriptor: {
Expand All @@ -456,6 +500,10 @@ const Options = (props: IOptionsProps) => {
});
};

const Options = Object.assign<typeof _componentOptions, NestedComponentMeta>(_componentOptions, {
componentType: "option",
});

// owners:
// From
// DropDownOptions
Expand Down Expand Up @@ -483,7 +531,7 @@ type IPositionProps = React.PropsWithChildren<{
y?: number;
};
}>
const Position = (props: IPositionProps) => {
const _componentPosition = (props: IPositionProps) => {
return React.createElement(NestedOption<IPositionProps>, {
...props,
elementDescriptor: {
Expand All @@ -492,6 +540,10 @@ const Position = (props: IPositionProps) => {
});
};

const Position = Object.assign<typeof _componentPosition, NestedComponentMeta>(_componentPosition, {
componentType: "option",
});

// owners:
// Animation
type IShowProps = React.PropsWithChildren<{
Expand All @@ -506,7 +558,7 @@ type IShowProps = React.PropsWithChildren<{
to?: AnimationState;
type?: "css" | "fade" | "fadeIn" | "fadeOut" | "pop" | "slide" | "slideIn" | "slideOut";
}>
const Show = (props: IShowProps) => {
const _componentShow = (props: IShowProps) => {
return React.createElement(NestedOption<IShowProps>, {
...props,
elementDescriptor: {
Expand All @@ -515,6 +567,10 @@ const Show = (props: IShowProps) => {
});
};

const Show = Object.assign<typeof _componentShow, NestedComponentMeta>(_componentShow, {
componentType: "option",
});

// owners:
// Hide
type IToProps = React.PropsWithChildren<{
Expand All @@ -524,7 +580,7 @@ type IToProps = React.PropsWithChildren<{
scale?: number;
top?: number;
}>
const To = (props: IToProps) => {
const _componentTo = (props: IToProps) => {
return React.createElement(NestedOption<IToProps>, {
...props,
elementDescriptor: {
Expand All @@ -533,6 +589,10 @@ const To = (props: IToProps) => {
});
};

const To = Object.assign<typeof _componentTo, NestedComponentMeta>(_componentTo, {
componentType: "option",
});

// owners:
// DropDownOptions
type IToolbarItemProps = React.PropsWithChildren<{
Expand All @@ -554,7 +614,7 @@ type IToolbarItemProps = React.PropsWithChildren<{
render?: (...params: any) => React.ReactNode;
component?: React.ComponentType<any>;
}>
const ToolbarItem = (props: IToolbarItemProps) => {
const _componentToolbarItem = (props: IToolbarItemProps) => {
return React.createElement(NestedOption<IToolbarItemProps>, {
...props,
elementDescriptor: {
Expand All @@ -573,6 +633,10 @@ const ToolbarItem = (props: IToolbarItemProps) => {
});
};

const ToolbarItem = Object.assign<typeof _componentToolbarItem, NestedComponentMeta>(_componentToolbarItem, {
componentType: "option",
});

export default Autocomplete;
export {
Autocomplete,
Expand Down
Loading

0 comments on commit b4602a5

Please sign in to comment.