Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract common props from the widget component #12886

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions js/renovation/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
} from 'devextreme-generator/component_declaration/common';
import Icon from './icon';
import InkRipple from './ink-ripple';
import Widget, { WidgetProps } from './widget';
import Widget from './widget';
import { BaseWidgetProps } from './utils/base-props';

const stylingModes = ['outlined', 'text', 'contained'];

Expand Down Expand Up @@ -111,7 +112,7 @@ export const viewFunction = (viewModel: Button) => {
};

@ComponentBindings()
export class ButtonProps extends WidgetProps {
export class ButtonProps extends BaseWidgetProps {
@OneWay() activeStateEnabled?: boolean = true;
@OneWay() hoverStateEnabled?: boolean = true;
@OneWay() icon?: string = '';
Expand Down
25 changes: 25 additions & 0 deletions js/renovation/utils/base-props.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
Event, OneWay, ComponentBindings,
} from 'devextreme-generator/component_declaration/common';
import config from '../../core/config';

@ComponentBindings()
export class BaseWidgetProps {
@OneWay() accessKey?: string | null = null;
@OneWay() activeStateEnabled?: boolean = false;
@OneWay() disabled?: boolean = false;
@OneWay() elementAttr?: { [name: string]: any };
@OneWay() focusStateEnabled?: boolean = false;
@OneWay() height?: string | number | null = null;
@OneWay() hint?: string;
@OneWay() hoverStateEnabled?: boolean = false;
@Event() onClick?: (e: any) => void;
@Event({
actionConfig: { excludeValidators: ['disabled', 'readOnly'] },
}) onContentReady?: (e: any) => any = (() => {});
@Event() onKeyDown?: (e: any, options: any) => any;
@OneWay() rtlEnabled?: boolean = config().rtlEnabled;
@OneWay() tabIndex?: number = 0;
@OneWay() visible?: boolean = true;
@OneWay() width?: string | number | null = null;
}
22 changes: 2 additions & 20 deletions js/renovation/widget.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import config from '../core/config';
import {
Component,
ComponentBindings,
Expand All @@ -20,6 +19,7 @@ import { each } from '../core/utils/iterator';
import { extend } from '../core/utils/extend';
import { focusable } from '../ui/widget/selectors';
import { isFakeClickEvent } from '../events/utils';
import { BaseWidgetProps } from './utils/base-props';

const getStyles = ({ width, height, style }) => {
const computedWidth = typeof width === 'function' ? width() : width;
Expand Down Expand Up @@ -97,40 +97,22 @@ export const viewFunction = (viewModel: Widget) => {
};

@ComponentBindings()
export class WidgetProps {
export class WidgetProps extends BaseWidgetProps {
@OneWay() _feedbackHideTimeout?: number = 400;
@OneWay() _feedbackShowTimeout?: number = 30;
@OneWay() accessKey?: string | null = null;
@OneWay() activeStateEnabled?: boolean = false;
@OneWay() activeStateUnit?: string;
@OneWay() aria?: any = {};
@Slot() children?: any;
@OneWay() classes?: string | undefined = '';
@OneWay() className?: string = '';
@OneWay() clickArgs?: any = {};
@OneWay() disabled?: boolean = false;
@OneWay() elementAttr?: { [name: string]: any };
@OneWay() focusStateEnabled?: boolean = false;
@OneWay() height?: string | number | null = null;
@OneWay() hint?: string;
@OneWay() hoverStateEnabled?: boolean = false;
@OneWay() name?: string = '';
@Event() onActive?: (e: any) => any;
@Event() onClick?: (e: any) => void;
@Event({
actionConfig: { excludeValidators: ['disabled', 'readOnly'] },
})
onContentReady?: (e: any) => any = (() => {});
@Event() onDimensionChanged?: () => any;
@Event() onInactive?: (e: any) => any;
@Event() onKeyboardHandled?: (args: any) => any | undefined;
@Event() onKeyDown?: (e: any, options: any) => any;
@Event() onVisibilityChange?: (args: boolean) => undefined;
@OneWay() rtlEnabled?: boolean = config().rtlEnabled;
@OneWay() style?: { [name: string]: any };
@OneWay() tabIndex?: number = 0;
@OneWay() visible?: boolean = true;
@OneWay() width?: string | number | null = null;
}

// tslint:disable-next-line: max-classes-per-file
Expand Down