Skip to content

Commit

Permalink
Use true imported union / enum types instead of explicit (string) acc…
Browse files Browse the repository at this point in the history
…eptable values React / Vue (#28291)
  • Loading branch information
mpreyskurantov authored Nov 1, 2024
1 parent 3dc8d13 commit a8e9aea
Show file tree
Hide file tree
Showing 128 changed files with 3,507 additions and 3,529 deletions.
3 changes: 2 additions & 1 deletion apps/demos/testing/known-warnings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"The specified credentials are invalid. You can sign up for a free developer account at http://www.bingmapsportal.com",
"W0019 -",
"W0022 -",
"W2108 -"
"W2108 -",
"[Vue warn]: Invalid prop: type check failed for prop"
]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"axe-core": "4.10.0",
"cheerio": "1.0.0-rc.10",
"codelyzer": "6.0.2",
"devextreme-internal-tools": "16.0.0-beta.8",
"devextreme-internal-tools": "16.0.0-beta.9",
"http-server": "14.1.1",
"husky": "8.0.3",
"jest": "29.7.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/devextreme-react/src/action-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import NestedOption from "./core/nested-option";

import type { dxActionSheetItem, CancelClickEvent, ContentReadyEvent, DisposingEvent, InitializedEvent, ItemClickEvent, ItemContextMenuEvent, ItemHoldEvent, ItemRenderedEvent } from "devextreme/ui/action_sheet";
import type { NativeEventInfo } from "devextreme/events/index";
import type { ButtonStyle, ButtonType } from "devextreme/common";
import type { CollectionWidgetItem } from "devextreme/ui/collection/ui.collection_widget.base";
import type { template } from "devextreme/core/templates/template";

Expand Down Expand Up @@ -99,10 +100,10 @@ type IItemProps = React.PropsWithChildren<{
disabled?: boolean;
icon?: string;
onClick?: ((e: NativeEventInfo<any>) => void);
stylingMode?: "text" | "outlined" | "contained";
stylingMode?: ButtonStyle;
template?: ((itemData: CollectionWidgetItem, itemIndex: number, itemElement: any) => string | any) | template;
text?: string;
type?: "danger" | "default" | "normal" | "success";
type?: ButtonType;
render?: (...params: any) => React.ReactNode;
component?: React.ComponentType<any>;
}>
Expand Down
68 changes: 35 additions & 33 deletions packages/devextreme-react/src/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ 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";
import type { ContentReadyEvent as ButtonContentReadyEvent, DisposingEvent as ButtonDisposingEvent, InitializedEvent as ButtonInitializedEvent, dxButtonOptions, ClickEvent, OptionChangedEvent } from "devextreme/ui/button";
import type { AnimationConfig, AnimationState } from "devextreme/animation/fx";
import type { AnimationConfig, AnimationState, AnimationType } from "devextreme/animation/fx";
import type { HorizontalAlignment, VerticalAlignment, TextEditorButtonLocation, PositionAlignment, Direction, ButtonStyle, ButtonType, ToolbarItemLocation, ToolbarItemComponent } from "devextreme/common";
import type { CollisionResolution, PositionConfig, CollisionResolutionCombination } from "devextreme/animation/position";
import type { event, EventInfo } from "devextreme/events/index";
import type { template } from "devextreme/core/templates/template";
import type { Component } from "devextreme/core/component";
import type { PositionConfig } from "devextreme/animation/position";
import type { dxPopupToolbarItem } from "devextreme/ui/popup";
import type { dxPopupToolbarItem, ToolbarLocation } from "devextreme/ui/popup";
import type { CollectionWidgetItem } from "devextreme/ui/collection/ui.collection_widget.base";
import type { LocateInMenuMode, ShowTextMode } from "devextreme/ui/toolbar";

import type dxOverlay from "devextreme/ui/overlay";
import type DOMComponent from "devextreme/core/dom_component";
Expand Down Expand Up @@ -151,8 +153,8 @@ const Animation = Object.assign<typeof _componentAnimation, NestedComponentMeta>
// owners:
// Position
type IAtProps = React.PropsWithChildren<{
x?: "center" | "left" | "right";
y?: "bottom" | "center" | "top";
x?: HorizontalAlignment;
y?: VerticalAlignment;
}>
const _componentAt = (props: IAtProps) => {
return React.createElement(NestedOption<IAtProps>, {
Expand Down Expand Up @@ -189,7 +191,7 @@ const BoundaryOffset = Object.assign<typeof _componentBoundaryOffset, NestedComp
// owners:
// Autocomplete
type IButtonProps = React.PropsWithChildren<{
location?: "after" | "before";
location?: TextEditorButtonLocation;
name?: string;
options?: dxButtonOptions;
}>
Expand All @@ -213,8 +215,8 @@ const Button = Object.assign<typeof _componentButton, NestedComponentMeta>(_comp
// owners:
// Position
type ICollisionProps = React.PropsWithChildren<{
x?: "fit" | "flip" | "flipfit" | "none";
y?: "fit" | "flip" | "flipfit" | "none";
x?: CollisionResolution;
y?: CollisionResolution;
}>
const _componentCollision = (props: ICollisionProps) => {
return React.createElement(NestedOption<ICollisionProps>, {
Expand Down Expand Up @@ -270,7 +272,7 @@ type IDropDownOptionsProps = React.PropsWithChildren<{
onShowing?: ((e: { cancel: boolean | any, component: dxOverlay<any>, element: any, model: any }) => void);
onShown?: ((e: EventInfo<any>) => void);
onTitleRendered?: ((e: { component: dxPopup, element: any, model: any, titleElement: any }) => void);
position?: (() => void) | PositionConfig | "bottom" | "center" | "left" | "left bottom" | "left top" | "right" | "right bottom" | "right top" | "top";
position?: (() => void) | PositionAlignment | PositionConfig;
resizeEnabled?: boolean;
restorePosition?: boolean;
rtlEnabled?: boolean;
Expand All @@ -287,8 +289,8 @@ type IDropDownOptionsProps = React.PropsWithChildren<{
wrapperAttr?: any;
defaultHeight?: (() => number | string) | number | string;
onHeightChange?: (value: (() => number | string) | number | string) => void;
defaultPosition?: (() => void) | PositionConfig | "bottom" | "center" | "left" | "left bottom" | "left top" | "right" | "right bottom" | "right top" | "top";
onPositionChange?: (value: (() => void) | PositionConfig | "bottom" | "center" | "left" | "left bottom" | "left top" | "right" | "right bottom" | "right top" | "top") => void;
defaultPosition?: (() => void) | PositionAlignment | PositionConfig;
onPositionChange?: (value: (() => void) | PositionAlignment | PositionConfig) => void;
defaultVisible?: boolean;
onVisibleChange?: (value: boolean) => void;
defaultWidth?: (() => number | string) | number | string;
Expand Down Expand Up @@ -361,14 +363,14 @@ const From = Object.assign<typeof _componentFrom, NestedComponentMeta>(_componen
type IHideProps = React.PropsWithChildren<{
complete?: (($element: any, config: AnimationConfig) => void);
delay?: number;
direction?: "bottom" | "left" | "right" | "top";
direction?: Direction;
duration?: number;
easing?: string;
from?: AnimationState;
staggerDelay?: number;
start?: (($element: any, config: AnimationConfig) => void);
to?: AnimationState;
type?: "css" | "fade" | "fadeIn" | "fadeOut" | "pop" | "slide" | "slideIn" | "slideOut";
type?: AnimationType;
}>
const _componentHide = (props: IHideProps) => {
return React.createElement(NestedOption<IHideProps>, {
Expand Down Expand Up @@ -420,8 +422,8 @@ const Item = Object.assign<typeof _componentItem, NestedComponentMeta>(_componen
// owners:
// Position
type IMyProps = React.PropsWithChildren<{
x?: "center" | "left" | "right";
y?: "bottom" | "center" | "top";
x?: HorizontalAlignment;
y?: VerticalAlignment;
}>
const _componentMy = (props: IMyProps) => {
return React.createElement(NestedOption<IMyProps>, {
Expand Down Expand Up @@ -474,11 +476,11 @@ type IOptionsProps = React.PropsWithChildren<{
onInitialized?: ((e: ButtonInitializedEvent) => void);
onOptionChanged?: ((e: OptionChangedEvent) => void);
rtlEnabled?: boolean;
stylingMode?: "text" | "outlined" | "contained";
stylingMode?: ButtonStyle;
tabIndex?: number;
template?: ((buttonData: { icon: string, text: string }, contentElement: any) => string | any) | template;
text?: string;
type?: "danger" | "default" | "normal" | "success";
type?: ButtonType | string;
useSubmitBehavior?: boolean;
validationGroup?: string;
visible?: boolean;
Expand Down Expand Up @@ -508,22 +510,22 @@ const Options = Object.assign<typeof _componentOptions, NestedComponentMeta>(_co
// From
// DropDownOptions
type IPositionProps = React.PropsWithChildren<{
at?: Record<string, any> | "bottom" | "center" | "left" | "left bottom" | "left top" | "right" | "right bottom" | "right top" | "top" | {
x?: "center" | "left" | "right";
y?: "bottom" | "center" | "top";
at?: Record<string, any> | PositionAlignment | {
x?: HorizontalAlignment;
y?: VerticalAlignment;
};
boundary?: any | string;
boundaryOffset?: Record<string, any> | string | {
x?: number;
y?: number;
};
collision?: Record<string, any> | "fit" | "fit flip" | "fit flipfit" | "fit none" | "flip" | "flip fit" | "flip none" | "flipfit" | "flipfit fit" | "flipfit none" | "none" | "none fit" | "none flip" | "none flipfit" | {
x?: "fit" | "flip" | "flipfit" | "none";
y?: "fit" | "flip" | "flipfit" | "none";
collision?: CollisionResolutionCombination | Record<string, any> | {
x?: CollisionResolution;
y?: CollisionResolution;
};
my?: Record<string, any> | "bottom" | "center" | "left" | "left bottom" | "left top" | "right" | "right bottom" | "right top" | "top" | {
x?: "center" | "left" | "right";
y?: "bottom" | "center" | "top";
my?: Record<string, any> | PositionAlignment | {
x?: HorizontalAlignment;
y?: VerticalAlignment;
};
of?: any | string;
offset?: Record<string, any> | string | {
Expand All @@ -549,14 +551,14 @@ const Position = Object.assign<typeof _componentPosition, NestedComponentMeta>(_
type IShowProps = React.PropsWithChildren<{
complete?: (($element: any, config: AnimationConfig) => void);
delay?: number;
direction?: "bottom" | "left" | "right" | "top";
direction?: Direction;
duration?: number;
easing?: string;
from?: AnimationState;
staggerDelay?: number;
start?: (($element: any, config: AnimationConfig) => void);
to?: AnimationState;
type?: "css" | "fade" | "fadeIn" | "fadeOut" | "pop" | "slide" | "slideIn" | "slideOut";
type?: AnimationType;
}>
const _componentShow = (props: IShowProps) => {
return React.createElement(NestedOption<IShowProps>, {
Expand Down Expand Up @@ -599,16 +601,16 @@ type IToolbarItemProps = React.PropsWithChildren<{
cssClass?: string;
disabled?: boolean;
html?: string;
locateInMenu?: "always" | "auto" | "never";
location?: "after" | "before" | "center";
locateInMenu?: LocateInMenuMode;
location?: ToolbarItemLocation;
menuItemTemplate?: (() => string | any) | template;
options?: any;
showText?: "always" | "inMenu";
showText?: ShowTextMode;
template?: ((itemData: CollectionWidgetItem, itemIndex: number, itemElement: any) => string | any) | template;
text?: string;
toolbar?: "bottom" | "top";
toolbar?: ToolbarLocation;
visible?: boolean;
widget?: "dxAutocomplete" | "dxButton" | "dxButtonGroup" | "dxCheckBox" | "dxDateBox" | "dxDropDownButton" | "dxMenu" | "dxSelectBox" | "dxSwitch" | "dxTabs" | "dxTextBox";
widget?: ToolbarItemComponent;
menuItemRender?: (...params: any) => React.ReactNode;
menuItemComponent?: React.ComponentType<any>;
render?: (...params: any) => React.ReactNode;
Expand Down
Loading

0 comments on commit a8e9aea

Please sign in to comment.